mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 22:50:45 +00:00
Support up to 16 mouse buttons (SDL-only)
Mostly necessary because SDL doesn't properly return mouse buttons X1/X2 on Linux/X11, see https://bugzilla.libsdl.org/show_bug.cgi?id=2310 Not sure if this is possible with Windows, DIMOFS_BUTTON7 seems to be the highest constant there. Also passing sdlevent.wheel.y directly as scroll delta
This commit is contained in:
parent
65d1428dd1
commit
aa51d38b3c
4 changed files with 77 additions and 28 deletions
|
@ -204,6 +204,17 @@ keyname_t keynames[] =
|
|||
NAMEKEY( MOUSE7, "#str_07060" ),
|
||||
NAMEKEY( MOUSE8, "#str_07061" ),
|
||||
|
||||
// DG: some more mouse buttons
|
||||
NAMEKEY2( MOUSE9 ),
|
||||
NAMEKEY2( MOUSE10 ),
|
||||
NAMEKEY2( MOUSE11 ),
|
||||
NAMEKEY2( MOUSE12 ),
|
||||
NAMEKEY2( MOUSE13 ),
|
||||
NAMEKEY2( MOUSE14 ),
|
||||
NAMEKEY2( MOUSE15 ),
|
||||
NAMEKEY2( MOUSE16 ),
|
||||
// DG end
|
||||
|
||||
NAMEKEY( MWHEELDOWN, "#str_07132" ),
|
||||
NAMEKEY( MWHEELUP, "#str_07131" ),
|
||||
|
||||
|
|
|
@ -1360,6 +1360,16 @@ void idUsercmdGenLocal::Mouse()
|
|||
case M_ACTION6:
|
||||
case M_ACTION7:
|
||||
case M_ACTION8:
|
||||
|
||||
// DG: support some more mouse buttons
|
||||
case M_ACTION9:
|
||||
case M_ACTION10:
|
||||
case M_ACTION11:
|
||||
case M_ACTION12:
|
||||
case M_ACTION13:
|
||||
case M_ACTION14:
|
||||
case M_ACTION15:
|
||||
case M_ACTION16: // DG end
|
||||
mouseButton = K_MOUSE1 + ( action - M_ACTION1 );
|
||||
mouseDown = ( value != 0 );
|
||||
Key( mouseButton, mouseDown );
|
||||
|
|
|
@ -827,8 +827,9 @@ Sys_GetEvent
|
|||
*/
|
||||
sysEvent_t Sys_GetEvent()
|
||||
{
|
||||
SDL_Event ev;
|
||||
sysEvent_t res = { };
|
||||
|
||||
SDL_Event ev;
|
||||
int key;
|
||||
|
||||
// when this is returned, it's assumed that there are no more events!
|
||||
|
@ -870,7 +871,7 @@ sysEvent_t Sys_GetEvent()
|
|||
return res;
|
||||
}
|
||||
// DG end
|
||||
#endif
|
||||
#endif // SDL2
|
||||
|
||||
static int32 uniChar = 0;
|
||||
|
||||
|
@ -942,7 +943,7 @@ sysEvent_t Sys_GetEvent()
|
|||
}
|
||||
|
||||
continue; // handle next event
|
||||
#else
|
||||
#else // SDL 1.2
|
||||
case SDL_ACTIVEEVENT:
|
||||
{
|
||||
// DG: (un-)pause the game when focus is gained, that also (un-)grabs the input
|
||||
|
@ -985,8 +986,8 @@ sysEvent_t Sys_GetEvent()
|
|||
PushConsoleEvent( "vid_restart" );
|
||||
continue; // handle next event
|
||||
}
|
||||
// DG end
|
||||
#endif
|
||||
// DG end
|
||||
#endif // SDL1.2
|
||||
|
||||
case SDL_KEYDOWN:
|
||||
if( ev.key.keysym.sym == SDLK_RETURN && ( ev.key.keysym.mod & KMOD_ALT ) > 0 )
|
||||
|
@ -1023,7 +1024,7 @@ sysEvent_t Sys_GetEvent()
|
|||
uniChar = ev.key.keysym.unicode; // for SE_CHAR
|
||||
}
|
||||
// DG end
|
||||
#endif
|
||||
#endif // SDL 1.2
|
||||
|
||||
// fall through
|
||||
case SDL_KEYUP:
|
||||
|
@ -1049,7 +1050,7 @@ sysEvent_t Sys_GetEvent()
|
|||
|
||||
continue; // just handle next event
|
||||
}
|
||||
#else
|
||||
#else // SDL1.2
|
||||
key = SDL_KeyToDoom3Key( ev.key.keysym.sym, isChar );
|
||||
|
||||
if( key == 0 )
|
||||
|
@ -1079,7 +1080,7 @@ sysEvent_t Sys_GetEvent()
|
|||
continue; // just handle next event
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // SDL 1.2
|
||||
}
|
||||
|
||||
res.evType = SE_KEY;
|
||||
|
@ -1117,7 +1118,7 @@ sysEvent_t Sys_GetEvent()
|
|||
}
|
||||
|
||||
continue; // just handle next event
|
||||
#endif
|
||||
#endif // SDL2
|
||||
|
||||
case SDL_MOUSEMOTION:
|
||||
// DG: return event with absolute mouse-coordinates when in menu
|
||||
|
@ -1150,25 +1151,16 @@ sysEvent_t Sys_GetEvent()
|
|||
case SDL_MOUSEWHEEL:
|
||||
res.evType = SE_KEY;
|
||||
|
||||
if( ev.wheel.y > 0 )
|
||||
{
|
||||
res.evValue = K_MWHEELUP;
|
||||
mouse_polls.Append( mouse_poll_t( M_DELTAZ, 1 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
res.evValue = K_MWHEELDOWN;
|
||||
mouse_polls.Append( mouse_poll_t( M_DELTAZ, -1 ) );
|
||||
}
|
||||
|
||||
// DG: remember mousewheel direction to issue a "not pressed anymore" event
|
||||
res.evValue = (ev.wheel.y > 0) ? K_MWHEELUP : K_MWHEELDOWN;
|
||||
mouse_polls.Append( mouse_poll_t( M_DELTAZ, ev.wheel.y ) );
|
||||
|
||||
res.evValue2 = 1; // for "pressed"
|
||||
|
||||
// remember mousewheel direction to issue a "not pressed anymore" event
|
||||
mwheelRel = res.evValue;
|
||||
// DG end
|
||||
|
||||
res.evValue2 = 1;
|
||||
|
||||
return res;
|
||||
#endif
|
||||
#endif // SDL2
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
|
@ -1200,7 +1192,20 @@ sysEvent_t Sys_GetEvent()
|
|||
if( ev.button.state == SDL_PRESSED )
|
||||
mouse_polls.Append( mouse_poll_t( M_DELTAZ, -1 ) );
|
||||
break;
|
||||
#endif
|
||||
#endif // SDL1.2
|
||||
|
||||
default:
|
||||
// handle X1 button and above
|
||||
if( ev.button.button <= 16 ) // d3bfg doesn't support more than 16 mouse buttons
|
||||
{
|
||||
int buttonIndex = ev.button.button - SDL_BUTTON_LEFT;
|
||||
res.evValue = K_MOUSE1 + buttonIndex;
|
||||
mouse_polls.Append( mouse_poll_t( M_ACTION1 + buttonIndex, ev.button.state == SDL_PRESSED ? 1 : 0 ) );
|
||||
}
|
||||
else // unsupported mouse button
|
||||
{
|
||||
continue; // just ignore
|
||||
}
|
||||
}
|
||||
|
||||
res.evValue2 = ev.button.state == SDL_PRESSED ? 1 : 0;
|
||||
|
@ -1483,7 +1488,8 @@ sysEvent_t Sys_GetEvent()
|
|||
|
||||
case SDL_QUIT:
|
||||
PushConsoleEvent( "quit" );
|
||||
return no_more_events; // don't handle next event, just quit.
|
||||
res = no_more_events; // don't handle next event, just quit.
|
||||
return res;
|
||||
|
||||
case SDL_USEREVENT:
|
||||
switch( ev.user.code )
|
||||
|
@ -1503,7 +1509,8 @@ sysEvent_t Sys_GetEvent()
|
|||
}
|
||||
}
|
||||
|
||||
return no_more_events;
|
||||
res = no_more_events;
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -119,6 +119,16 @@ enum sys_mEvents
|
|||
M_ACTION6,
|
||||
M_ACTION7,
|
||||
M_ACTION8,
|
||||
// DG: support some more mouse buttons
|
||||
M_ACTION9,
|
||||
M_ACTION10,
|
||||
M_ACTION11,
|
||||
M_ACTION12,
|
||||
M_ACTION13,
|
||||
M_ACTION14,
|
||||
M_ACTION15,
|
||||
M_ACTION16,
|
||||
// DG end
|
||||
M_DELTAX,
|
||||
M_DELTAY,
|
||||
M_DELTAZ,
|
||||
|
@ -390,6 +400,17 @@ enum keyNum_t
|
|||
K_MOUSE7,
|
||||
K_MOUSE8,
|
||||
|
||||
// DG: add some more mouse buttons
|
||||
K_MOUSE9,
|
||||
K_MOUSE10,
|
||||
K_MOUSE11,
|
||||
K_MOUSE12,
|
||||
K_MOUSE13,
|
||||
K_MOUSE14,
|
||||
K_MOUSE15,
|
||||
K_MOUSE16,
|
||||
// DG end
|
||||
|
||||
K_MWHEELDOWN,
|
||||
K_MWHEELUP,
|
||||
|
||||
|
|
Loading…
Reference in a new issue