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
This commit is contained in:
Sander van Dijk 2014-09-12 20:37:05 +00:00
parent 1e522abb2d
commit da5ee0c612
2 changed files with 9 additions and 20 deletions

View file

@ -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:

View file

@ -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)