From da1bdf711cb03390006ada5af673b3dad3134009 Mon Sep 17 00:00:00 2001 From: terminx Date: Wed, 3 Mar 2010 01:43:34 +0000 Subject: [PATCH] Better mouse fix? git-svn-id: https://svn.eduke32.com/eduke32@1606 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/winlayer.c | 151 ++++++++++++--------------- 1 file changed, 66 insertions(+), 85 deletions(-) diff --git a/polymer/eduke32/build/src/winlayer.c b/polymer/eduke32/build/src/winlayer.c index 9b9e7305b..d18a0988a 100644 --- a/polymer/eduke32/build/src/winlayer.c +++ b/polymer/eduke32/build/src/winlayer.c @@ -725,7 +725,7 @@ static HMODULE hDInputDLL = NULL; static LPDIRECTINPUT7A lpDI = NULL; static LPDIRECTINPUTDEVICE7A lpDID[NUM_INPUTS] = { NULL, NULL, NULL }; static BOOL bDInputInited = FALSE; -#define INPUT_BUFFER_SIZE 32 +#define INPUT_BUFFER_SIZE 256 static GUID guidDevs[NUM_INPUTS]; static char devacquired[NUM_INPUTS] = { 0,0,0 }; @@ -886,68 +886,6 @@ void setkeypresscallback(void (*callback)(int32_t, int32_t)) { keypresscallback void setmousepresscallback(void (*callback)(int32_t, int32_t)) { mousepresscallback = callback; } void setjoypresscallback(void (*callback)(int32_t, int32_t)) { joypresscallback = callback; } -DWORD WINAPI ProcessMouse(LPVOID lpThreadParameter) -{ - int32_t i; - DIMOUSESTATE2 mousestate; - - UNREFERENCED_PARAMETER(lpThreadParameter); - - while (moustat && lpDID[MOUSE]) - { - if (!appactive || !mousegrab) - { - Sleep(100); - continue; - } - - if ((WaitForSingleObject(inputevt[MOUSE], INFINITE)) != WAIT_OBJECT_0) - continue; - - if (IDirectInputDevice7_GetDeviceState(lpDID[MOUSE], sizeof(DIMOUSESTATE2), - (LPDIMOUSESTATE2)&mousestate) != DI_OK) - continue; - - mousex += (int16_t)mousestate.lX; - mousey += (int16_t)mousestate.lY; - - if (mousestate.lZ > 0) // wheel up - { - if (mousewheel[0] > 0 && mousepresscallback) mousepresscallback(5,0); - mousewheel[0] = getticks(); - mouseb |= 16; - if (mousepresscallback) mousepresscallback(5, 1); - } - else if (mousestate.lZ < 0) // wheel down - { - if (mousewheel[1] > 0 && mousepresscallback) mousepresscallback(6,0); - mousewheel[1] = getticks(); - mouseb |= 32; - if (mousepresscallback) mousepresscallback(6, 1); - } - - for (i=0; i<4; i++) - { - if (mousestate.rgbButtons[i] & 0x80) mouseb |= 1< 0) // wheel up + { + if (mousewheel[0] > 0 && mousepresscallback) mousepresscallback(5,0); + mousewheel[0] = getticks(); + mouseb |= 16; + if (mousepresscallback) mousepresscallback(5, 1); + } + else if ((int32_t)didod[dwElements-1].dwData < 0) // wheel down + { + if (mousewheel[1] > 0 && mousepresscallback) mousepresscallback(6,0); + mousewheel[1] = getticks(); + mouseb |= 32; + if (mousepresscallback) mousepresscallback(6, 1); + } + } + break; + + case DIMOFS_BUTTON4: + case DIMOFS_BUTTON5: + case DIMOFS_BUTTON6: + case DIMOFS_BUTTON7: + didod[dwElements-1].dwOfs += 2; // skip mousewheel buttons + bit = 1<<(didod[dwElements-1].dwOfs - DIMOFS_BUTTON0); + case DIMOFS_BUTTON0: + case DIMOFS_BUTTON1: + case DIMOFS_BUTTON2: + case DIMOFS_BUTTON3: + if (didod[dwElements-1].dwData & 0x80) mouseb |= bit; + else mouseb &= ~bit; + if (mousepresscallback) + mousepresscallback(didod[dwElements-1].dwOfs - DIMOFS_BUTTON0 + 1, mouseb & bit); + break; + } + } + while (--dwElements); + } + break; + case KEYBOARD: // keyboard if (!lpDID[KEYBOARD]) break; result = IDirectInputDevice7_GetDeviceData(lpDID[KEYBOARD], sizeof(DIDEVICEOBJECTDATA),