mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-13 00:24:44 +00:00
Small improvements to input code
This commit is contained in:
parent
dc155cca9c
commit
0fb8d80507
1 changed files with 16 additions and 16 deletions
|
@ -333,6 +333,7 @@ IN_Update(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
/* fall-through */
|
||||||
case SDL_MOUSEBUTTONUP:
|
case SDL_MOUSEBUTTONUP:
|
||||||
switch( event.button.button )
|
switch( event.button.button )
|
||||||
{
|
{
|
||||||
|
@ -367,8 +368,8 @@ IN_Update(void)
|
||||||
|
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
case SDL_TEXTINPUT:
|
case SDL_TEXTINPUT:
|
||||||
if ((event.text.text[0] >= SDLK_SPACE) &&
|
if((event.text.text[0] >= ' ') &&
|
||||||
(event.text.text[0] < SDLK_DELETE))
|
(event.text.text[0] <= '~'))
|
||||||
{
|
{
|
||||||
Char_Event(event.text.text[0]);
|
Char_Event(event.text.text[0]);
|
||||||
}
|
}
|
||||||
|
@ -384,33 +385,32 @@ IN_Update(void)
|
||||||
Char_Event(event.key.keysym.unicode);
|
Char_Event(event.key.keysym.unicode);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
/* fall-through */
|
||||||
// fall-through
|
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
{
|
{
|
||||||
qboolean down = (event.type == SDL_KEYDOWN);
|
qboolean down = (event.type == SDL_KEYDOWN);
|
||||||
|
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
// workaround for AZERTY-keyboards, which don't have 1, 2, ..., 9, 0 in first row:
|
/* workaround for AZERTY-keyboards, which don't have 1, 2, ..., 9, 0 in first row:
|
||||||
// always map those physical keys (scancodes) to those keycodes anyway
|
* always map those physical keys (scancodes) to those keycodes anyway
|
||||||
// see also https://bugzilla.libsdl.org/show_bug.cgi?id=3188
|
* see also https://bugzilla.libsdl.org/show_bug.cgi?id=3188 */
|
||||||
SDL_Scancode sc = event.key.keysym.scancode;
|
SDL_Scancode sc = event.key.keysym.scancode;
|
||||||
if(sc >= SDL_SCANCODE_1 && sc <= SDL_SCANCODE_0)
|
if(sc >= SDL_SCANCODE_1 && sc <= SDL_SCANCODE_0)
|
||||||
{
|
{
|
||||||
// Note that the SDL_SCANCODEs are SDL_SCANCODE_1, _2, ..., _9, SDL_SCANCODE_0
|
/* Note that the SDL_SCANCODEs are SDL_SCANCODE_1, _2, ..., _9, SDL_SCANCODE_0
|
||||||
// while in ASCII it's '0', '1', ..., '9' => handle 0 and 1-9 separately
|
* while in ASCII it's '0', '1', ..., '9' => handle 0 and 1-9 separately
|
||||||
// (quake2 uses the ASCII values for those keys)
|
* (quake2 uses the ASCII values for those keys) */
|
||||||
int key = '0'; // implicitly handles SDL_SCANCODE_0
|
int key = '0'; /* implicitly handles SDL_SCANCODE_0 */
|
||||||
if(sc >= SDL_SCANCODE_1 && sc <= SDL_SCANCODE_9)
|
if(sc <= SDL_SCANCODE_9)
|
||||||
{
|
{
|
||||||
key = '1' + (sc - SDL_SCANCODE_1);
|
key = '1' + (sc - SDL_SCANCODE_1);
|
||||||
}
|
}
|
||||||
Key_Event(key, down, false);
|
Key_Event(key, down, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif // SDL2; SDL1.2 doesn't have scancodes
|
#endif /* SDL2; (SDL1.2 doesn't have scancodes so nothing we can do there) */
|
||||||
if ((event.key.keysym.sym >= SDLK_SPACE) &&
|
if((event.key.keysym.sym >= SDLK_SPACE) &&
|
||||||
(event.key.keysym.sym < SDLK_DELETE))
|
(event.key.keysym.sym < SDLK_DELETE))
|
||||||
{
|
{
|
||||||
Key_Event(event.key.keysym.sym, down, false);
|
Key_Event(event.key.keysym.sym, down, false);
|
||||||
}
|
}
|
||||||
|
@ -428,7 +428,7 @@ IN_Update(void)
|
||||||
Key_MarkAllUp();
|
Key_MarkAllUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // SDL1.2
|
#else /* SDL1.2 */
|
||||||
case SDL_ACTIVEEVENT:
|
case SDL_ACTIVEEVENT:
|
||||||
if(event.active.gain == 0 && (event.active.state & SDL_APPINPUTFOCUS))
|
if(event.active.gain == 0 && (event.active.state & SDL_APPINPUTFOCUS))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue