From 9617227a875cf92e773f269dd501318bfd7abc15 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Thu, 12 Jan 2012 20:48:57 +0000 Subject: [PATCH] Support for the first "thumb" mouse button, called MOUSE4 in the menu. The second one is passed to the 'mouseb' variable, but the game currently can't map it since ud.config.MouseFunctions[] would have to be enlarged, breaking savegame compatibility. Works both for the Windows and SDL layers. For the latter, instead of using the SDL_BUTTON_X1/X2 macro constants, I'm using 8 and 9, since that is what SDL (and incidentally or not, xev) gives me for those buttons. git-svn-id: https://svn.eduke32.com/eduke32@2252 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/rawinput.c | 22 ++++++++++++++++------ polymer/eduke32/build/src/sdlayer.c | 10 ++++++++-- polymer/eduke32/build/src/winlayer.c | 1 + 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/polymer/eduke32/build/src/rawinput.c b/polymer/eduke32/build/src/rawinput.c index c90125f3d..29aeda44f 100644 --- a/polymer/eduke32/build/src/rawinput.c +++ b/polymer/eduke32/build/src/rawinput.c @@ -14,8 +14,8 @@ extern volatile uint8_t moustat, mousegrab; extern uint32_t mousewheel[2]; extern void SetKey(int32_t key, int32_t state); -#define MASK_DOWN (1<<(i<<1)) -#define MASK_UP (MASK_DOWN<<1) +//#define MASK_DOWN (1<<(i<<1)) +//#define MASK_UP (MASK_DOWN<<1) #define MouseWheelFakePressTime 50 #ifndef GET_RAWINPUT_CODE_WPARAM #define GET_RAWINPUT_CODE_WPARAM(wParam) ((wParam) & 0xff) @@ -42,21 +42,31 @@ static inline void RI_ProcessMouse(const RAWMOUSE *rmouse) mousey -= pos.y; } - for (i = 0, mask = 1; i < 4; i++) + for (i = 0, mask = (1<<0); mask < (1<<8); i++, mask<<=2) { + // usButtonFlags: + // 1<<0: left down -> 1 / 1<<0 + // 1<<2: middle down -> 2 / 1<<1 + // 1<<4: right down -> 3 / 1<<2 + // 1<<6: x1 down -> 4 / 1<<3 + // ----------- mwheel here + // 1<<8: x2 down -> 7 / 1<<6 + + if (mask == 1<<8) + i = 6; + if (rmouse->usButtonFlags & mask) // button down { if (mousepresscallback) - mousepresscallback(i, 1); + mousepresscallback(i+1, 1); mouseb |= 1<usButtonFlags & (mask<<1)) // button up { if (mousepresscallback) - mousepresscallback(i, 0); + mousepresscallback(i+1, 0); mouseb &= ~(1<usButtonFlags & RI_MOUSE_WHEEL) ? rmouse->usButtonData : 0; diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index 47157e4f6..5832207e4 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -1778,6 +1778,8 @@ int32_t handleevents(void) case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: +//if (ev.button.button>=0) +// initprintf("BTN %d\n", ev.button.button); switch (ev.button.button) { // some of these get reordered to match winlayer @@ -1789,9 +1791,13 @@ int32_t handleevents(void) j = 1; break; case SDL_BUTTON_MIDDLE: j = 2; break; - case SDL_BUTTON_WHEELUP: - case SDL_BUTTON_WHEELDOWN: + case 8 /*SDL_BUTTON_X1*/: // 8 --> 3 + j = 3; break; + case SDL_BUTTON_WHEELUP: // 4 + case SDL_BUTTON_WHEELDOWN: // 5 j = ev.button.button; break; + case 9 /*SDL_BUTTON_X2*/: // 9 --> 6 + j = 6; break; } if (j<0) break; diff --git a/polymer/eduke32/build/src/winlayer.c b/polymer/eduke32/build/src/winlayer.c index be863545f..3022822b3 100644 --- a/polymer/eduke32/build/src/winlayer.c +++ b/polymer/eduke32/build/src/winlayer.c @@ -963,6 +963,7 @@ void releaseallbuttons(void) if (mouseb & 8) mousepresscallback(4, 0); if (mousewheel[0]>0) mousepresscallback(5,0); if (mousewheel[1]>0) mousepresscallback(6,0); + if (mouseb & 64) mousepresscallback(7, 0); } mousewheel[0]=mousewheel[1]=0; mouseb = 0;