From da5ee0c612985b6e006823647a553cdddd460307 Mon Sep 17 00:00:00 2001 From: Sander van Dijk Date: Fri, 12 Sep 2014 20:37:05 +0000 Subject: [PATCH] input: remove the USE_SDL2 check from keys.c. Instead, make the backend responsible for calling either or both of Key_Event and Char_Event under the appropriate circumstances. For SDL2 this means no change, for SDL1 this means call both when a key is pressed, but call only Key_Event when a key is released. git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1022 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/in_sdl.c | 2 ++ Quake/keys.c | 27 +++++++-------------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/Quake/in_sdl.c b/Quake/in_sdl.c index 7bff3758..0b43f2af 100644 --- a/Quake/in_sdl.c +++ b/Quake/in_sdl.c @@ -788,6 +788,8 @@ void IN_SendKeyEvents (void) break; } Key_Event (sym, state); + if (event.type == SDL_KEYDOWN) + Char_Event (sym); break; #endif case SDL_MOUSEBUTTONDOWN: diff --git a/Quake/keys.c b/Quake/keys.c index d3e210ec..fcf885a2 100644 --- a/Quake/keys.c +++ b/Quake/keys.c @@ -50,12 +50,6 @@ qboolean consolekeys[256]; // if true, can't be rebound while in console qboolean menubound[256]; // if true, can't be rebound while in menu qboolean keydown[256]; -#if defined(USE_SDL2) -const qboolean backend_sends_char_events = true; -#else -const qboolean backend_sends_char_events = false; -#endif - typedef struct { const char *name; @@ -236,8 +230,6 @@ Interactive line editing and console scrollback extern char *con_text, key_tabpartial[MAXCMDLINE]; extern int con_current, con_linewidth, con_vislines; -void Char_Console (int key); - void Key_Console (int key) { static char current[MAXCMDLINE] = ""; @@ -441,9 +433,6 @@ void Key_Console (int key) } break; } - - if (!backend_sends_char_events) - Char_Console (key); } void Char_Console (int key) @@ -454,6 +443,9 @@ void Char_Console (int key) if (key < 32 || key > 126) return; // non printable + if (keydown[K_CTRL]) + return; // control character + if (key_linepos < MAXCMDLINE-1) { qboolean endpos = !workline[key_linepos]; @@ -503,8 +495,6 @@ void Key_EndChat (void) chat_buffer[0] = 0; } -void Char_Message (int key); - void Key_Message (int key) { if (key == K_ENTER) @@ -532,9 +522,6 @@ void Key_Message (int key) chat_buffer[--chat_bufferlen] = 0; return; } - - if (!backend_sends_char_events) - Char_Message (key); } void Char_Message (int key) @@ -542,6 +529,9 @@ void Char_Message (int key) if (key < 32 || key > 126) return; // non printable + if (keydown[K_CTRL]) + return; // control character + if (chat_bufferlen == sizeof(chat_buffer) - 1) return; // all full @@ -1051,10 +1041,7 @@ void Key_Event (int key, qboolean down) =================== Char_Event -Called by the backend when the user has input a character, e.g. coming from -the SDL_TEXTINPUT event. -The backend_sends_char_events variable indicates whether the backend calls this -function. +Called by the backend when the user has input a character. =================== */ void Char_Event (int key)