From 7d93442564b57c2d292df7f823c2115d3e0b8c12 Mon Sep 17 00:00:00 2001 From: Javier Date: Sun, 3 Apr 2022 00:03:15 +0200 Subject: complete wheel support --- w16mouse.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'w16mouse.c') diff --git a/w16mouse.c b/w16mouse.c index 2faefbf..f4c16a9 100644 --- a/w16mouse.c +++ b/w16mouse.c @@ -116,13 +116,18 @@ static void FAR int33_mouse_callback(uint16_t events, uint16_t buttons, int16_t * The initialization routine should check whether a mouse exists. * @return nonzero value indicates a mouse exists. */ -#pragma off (unreferenced); +#pragma off (unreferenced) BOOL FAR PASCAL LibMain(HINSTANCE hInstance, WORD wDataSegment, WORD wHeapSize, LPSTR lpszCmdLine) -#pragma pop (unreferenced); +#pragma pop (unreferenced) { - // We are not going to bother checking whether the int33 driver exists - // and just assume it does. + uint16_t version = int33_get_driver_version(); + + // For now we just check for the presence of any int33 driver version + if (version <= 0) { + // This will cause a "can't load .drv" message from Windows + return 0; + } return 1; } @@ -149,6 +154,10 @@ VOID FAR PASCAL Enable(LPFN_MOUSEEVENT lpEventProc) if (!enabled) { int33_reset(); + // Since the mouse driver will likely not know the Windows resolution, + // let's manually set up a large window of coordinates so as to have + // as much precision as possible. + // We use 0x7FFF instead of 0xFFFF because this parameter is officially a signed value. int33_set_horizontal_window(0, 0x7FFF); int33_set_vertical_window(0, 0x7FFF); @@ -162,8 +171,7 @@ VOID FAR PASCAL Enable(LPFN_MOUSEEVENT lpEventProc) VOID FAR PASCAL Disable(VOID) { if (enabled) { - int33_reset(); - + int33_reset(); // This removes our handler and removes all other settings enabled = false; } } -- cgit v1.2.3