Merge branch 'perpetual-modifier-updates' into 'master'

Set modifiers in a non-reactive manner

See merge request STJr/SRB2!456
This commit is contained in:
Steel Titanium 2019-05-13 00:36:06 -04:00
commit 8a14427420
4 changed files with 15 additions and 52 deletions

View File

@ -1063,16 +1063,6 @@ boolean CON_Responder(event_t *ev)
else if (key == KEY_KPADSLASH)
key = '/';
// capslock
if (key == KEY_CAPSLOCK) // it's a toggle.
{
if (capslock)
capslock = false;
else
capslock = true;
return true;
}
if (key >= 'a' && key <= 'z')
{
if (capslock ^ shiftdown)

View File

@ -176,37 +176,11 @@ void D_PostEvent_end(void) {};
#endif
// modifier keys
// Now handled in I_OsPolling
UINT8 shiftdown = 0; // 0x1 left, 0x2 right
UINT8 ctrldown = 0; // 0x1 left, 0x2 right
UINT8 altdown = 0; // 0x1 left, 0x2 right
boolean capslock = 0; // gee i wonder what this does.
//
// D_ModifierKeyResponder
// Sets global shift/ctrl/alt variables, never actually eats events
//
static inline void D_ModifierKeyResponder(event_t *ev)
{
if (ev->type == ev_keydown || ev->type == ev_console) switch (ev->data1)
{
case KEY_LSHIFT: shiftdown |= 0x1; return;
case KEY_RSHIFT: shiftdown |= 0x2; return;
case KEY_LCTRL: ctrldown |= 0x1; return;
case KEY_RCTRL: ctrldown |= 0x2; return;
case KEY_LALT: altdown |= 0x1; return;
case KEY_RALT: altdown |= 0x2; return;
default: return;
}
else if (ev->type == ev_keyup) switch (ev->data1)
{
case KEY_LSHIFT: shiftdown &= ~0x1; return;
case KEY_RSHIFT: shiftdown &= ~0x2; return;
case KEY_LCTRL: ctrldown &= ~0x1; return;
case KEY_RCTRL: ctrldown &= ~0x2; return;
case KEY_LALT: altdown &= ~0x1; return;
case KEY_RALT: altdown &= ~0x2; return;
default: return;
}
}
//
// D_ProcessEvents
@ -220,9 +194,6 @@ void D_ProcessEvents(void)
{
ev = &events[eventtail];
// Set global shift/ctrl/alt down variables
D_ModifierKeyResponder(ev); // never eats events
// Screenshots over everything so that they can be taken anywhere.
if (M_ScreenshotResponder(ev))
continue; // ate the event

View File

@ -1101,16 +1101,6 @@ boolean HU_Responder(event_t *ev)
c = (INT32)ev->data1;
// capslock (now handled outside of chat on so that it works everytime......)
if (c && c == KEY_CAPSLOCK) // it's a toggle.
{
if (capslock)
capslock = false;
else
capslock = true;
return true;
}
#ifndef NONET
if (!chat_on)
{

View File

@ -580,8 +580,6 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
if (cv_usemouse.value) I_StartupMouse();
}
//else firsttimeonmouse = SDL_FALSE;
capslock = !!( SDL_GetModState() & KMOD_CAPS );// in case CL changes
}
else if (!mousefocus && !kbfocus)
{
@ -939,6 +937,8 @@ void I_StartupMouse(void)
//
void I_OsPolling(void)
{
SDL_Keymod mod;
if (consolevent)
I_GetConsoleEvents();
if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK)
@ -951,6 +951,18 @@ void I_OsPolling(void)
I_GetMouseEvents();
I_GetEvent();
mod = SDL_GetModState();
/* Handle here so that our state is always synched with the system. */
shiftdown = ctrldown = altdown = 0;
capslock = false;
if (mod & KMOD_LSHIFT) shiftdown |= 1;
if (mod & KMOD_RSHIFT) shiftdown |= 2;
if (mod & KMOD_LCTRL) ctrldown |= 1;
if (mod & KMOD_RCTRL) ctrldown |= 2;
if (mod & KMOD_LALT) altdown |= 1;
if (mod & KMOD_RALT) altdown |= 2;
if (mod & KMOD_CAPS) capslock = true;
}
//