From 0fb8d80507e436bf7a20bd022d7d587f67bf3b9d Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Sat, 12 Dec 2015 18:47:46 +0100 Subject: [PATCH] Small improvements to input code --- src/backends/sdl/input.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/backends/sdl/input.c b/src/backends/sdl/input.c index 641bff9b..b5b77011 100644 --- a/src/backends/sdl/input.c +++ b/src/backends/sdl/input.c @@ -333,6 +333,7 @@ IN_Update(void) break; } #endif + /* fall-through */ case SDL_MOUSEBUTTONUP: switch( event.button.button ) { @@ -367,8 +368,8 @@ IN_Update(void) #if SDL_VERSION_ATLEAST(2, 0, 0) case SDL_TEXTINPUT: - if ((event.text.text[0] >= SDLK_SPACE) && - (event.text.text[0] < SDLK_DELETE)) + if((event.text.text[0] >= ' ') && + (event.text.text[0] <= '~')) { Char_Event(event.text.text[0]); } @@ -384,33 +385,32 @@ IN_Update(void) Char_Event(event.key.keysym.unicode); } #endif - - // fall-through + /* fall-through */ case SDL_KEYUP: { qboolean down = (event.type == SDL_KEYDOWN); #if SDL_VERSION_ATLEAST(2, 0, 0) - // 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 - // see also https://bugzilla.libsdl.org/show_bug.cgi?id=3188 + /* 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 + * see also https://bugzilla.libsdl.org/show_bug.cgi?id=3188 */ SDL_Scancode sc = event.key.keysym.scancode; if(sc >= SDL_SCANCODE_1 && sc <= 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 - // (quake2 uses the ASCII values for those keys) - int key = '0'; // implicitly handles SDL_SCANCODE_0 - if(sc >= SDL_SCANCODE_1 && sc <= SDL_SCANCODE_9) + /* 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 + * (quake2 uses the ASCII values for those keys) */ + int key = '0'; /* implicitly handles SDL_SCANCODE_0 */ + if(sc <= SDL_SCANCODE_9) { key = '1' + (sc - SDL_SCANCODE_1); } Key_Event(key, down, false); } else -#endif // SDL2; SDL1.2 doesn't have scancodes - if ((event.key.keysym.sym >= SDLK_SPACE) && - (event.key.keysym.sym < SDLK_DELETE)) +#endif /* SDL2; (SDL1.2 doesn't have scancodes so nothing we can do there) */ + if((event.key.keysym.sym >= SDLK_SPACE) && + (event.key.keysym.sym < SDLK_DELETE)) { Key_Event(event.key.keysym.sym, down, false); } @@ -428,7 +428,7 @@ IN_Update(void) Key_MarkAllUp(); } -#else // SDL1.2 +#else /* SDL1.2 */ case SDL_ACTIVEEVENT: if(event.active.gain == 0 && (event.active.state & SDL_APPINPUTFOCUS)) {