mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-13 23:40:58 +00:00
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:
parent
1e522abb2d
commit
da5ee0c612
2 changed files with 9 additions and 20 deletions
|
@ -788,6 +788,8 @@ void IN_SendKeyEvents (void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Key_Event (sym, state);
|
Key_Event (sym, state);
|
||||||
|
if (event.type == SDL_KEYDOWN)
|
||||||
|
Char_Event (sym);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
|
|
27
Quake/keys.c
27
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 menubound[256]; // if true, can't be rebound while in menu
|
||||||
qboolean keydown[256];
|
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
|
typedef struct
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
|
@ -236,8 +230,6 @@ Interactive line editing and console scrollback
|
||||||
extern char *con_text, key_tabpartial[MAXCMDLINE];
|
extern char *con_text, key_tabpartial[MAXCMDLINE];
|
||||||
extern int con_current, con_linewidth, con_vislines;
|
extern int con_current, con_linewidth, con_vislines;
|
||||||
|
|
||||||
void Char_Console (int key);
|
|
||||||
|
|
||||||
void Key_Console (int key)
|
void Key_Console (int key)
|
||||||
{
|
{
|
||||||
static char current[MAXCMDLINE] = "";
|
static char current[MAXCMDLINE] = "";
|
||||||
|
@ -441,9 +433,6 @@ void Key_Console (int key)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!backend_sends_char_events)
|
|
||||||
Char_Console (key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Char_Console (int key)
|
void Char_Console (int key)
|
||||||
|
@ -454,6 +443,9 @@ void Char_Console (int key)
|
||||||
if (key < 32 || key > 126)
|
if (key < 32 || key > 126)
|
||||||
return; // non printable
|
return; // non printable
|
||||||
|
|
||||||
|
if (keydown[K_CTRL])
|
||||||
|
return; // control character
|
||||||
|
|
||||||
if (key_linepos < MAXCMDLINE-1)
|
if (key_linepos < MAXCMDLINE-1)
|
||||||
{
|
{
|
||||||
qboolean endpos = !workline[key_linepos];
|
qboolean endpos = !workline[key_linepos];
|
||||||
|
@ -503,8 +495,6 @@ void Key_EndChat (void)
|
||||||
chat_buffer[0] = 0;
|
chat_buffer[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Char_Message (int key);
|
|
||||||
|
|
||||||
void Key_Message (int key)
|
void Key_Message (int key)
|
||||||
{
|
{
|
||||||
if (key == K_ENTER)
|
if (key == K_ENTER)
|
||||||
|
@ -532,9 +522,6 @@ void Key_Message (int key)
|
||||||
chat_buffer[--chat_bufferlen] = 0;
|
chat_buffer[--chat_bufferlen] = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!backend_sends_char_events)
|
|
||||||
Char_Message (key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Char_Message (int key)
|
void Char_Message (int key)
|
||||||
|
@ -542,6 +529,9 @@ void Char_Message (int key)
|
||||||
if (key < 32 || key > 126)
|
if (key < 32 || key > 126)
|
||||||
return; // non printable
|
return; // non printable
|
||||||
|
|
||||||
|
if (keydown[K_CTRL])
|
||||||
|
return; // control character
|
||||||
|
|
||||||
if (chat_bufferlen == sizeof(chat_buffer) - 1)
|
if (chat_bufferlen == sizeof(chat_buffer) - 1)
|
||||||
return; // all full
|
return; // all full
|
||||||
|
|
||||||
|
@ -1051,10 +1041,7 @@ void Key_Event (int key, qboolean down)
|
||||||
===================
|
===================
|
||||||
Char_Event
|
Char_Event
|
||||||
|
|
||||||
Called by the backend when the user has input a character, e.g. coming from
|
Called by the backend when the user has input a character.
|
||||||
the SDL_TEXTINPUT event.
|
|
||||||
The backend_sends_char_events variable indicates whether the backend calls this
|
|
||||||
function.
|
|
||||||
===================
|
===================
|
||||||
*/
|
*/
|
||||||
void Char_Event (int key)
|
void Char_Event (int key)
|
||||||
|
|
Loading…
Reference in a new issue