mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-16 01:11:28 +00:00
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
This commit is contained in:
parent
80949930bd
commit
9617227a87
3 changed files with 25 additions and 8 deletions
|
@ -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<<i;
|
||||
}
|
||||
else if (rmouse->usButtonFlags & (mask<<1)) // button up
|
||||
{
|
||||
if (mousepresscallback)
|
||||
mousepresscallback(i, 0);
|
||||
mousepresscallback(i+1, 0);
|
||||
mouseb &= ~(1<<i);
|
||||
}
|
||||
mask <<= 2;
|
||||
}
|
||||
|
||||
MWheel = (rmouse->usButtonFlags & RI_MOUSE_WHEEL) ? rmouse->usButtonData : 0;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue