in_sdl.c, key.c: Fixes agreed on with Sander:

1. Remove Key_IgnoreTextInput(), and simple always send a Char_Event when
we receive TEXTINPUT (SDL2) or the unicode field of a KEYDOWN event is
filled (SDL1.).
2. Remove handling of K_KP_* in the menu/console, since they cannot be
relied on to not also send text (see issue described above). The handling
of K_KP_ENTER can stay, since we do know that it never sends text.
3. Remove the interpretation hack for the numpad, since it will no longer
be needed (and doesn't currently work for SDL2 anyway); if a numpad key
generates text we will handle it (because of "1"), if not then it will
simply be if ignored (because of "2”).

git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@1110 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
ewasylishen 2014-10-14 03:30:44 +00:00
parent e404d2ba60
commit 6caa4dbf59
5 changed files with 3 additions and 121 deletions

View File

@ -1709,7 +1709,6 @@ static void VID_MenuKey (int key)
break;
case K_UPARROW:
case K_KP_UPARROW:
S_LocalSound ("misc/menu1.wav");
video_options_cursor--;
if (video_options_cursor < 0)
@ -1717,7 +1716,6 @@ static void VID_MenuKey (int key)
break;
case K_DOWNARROW:
case K_KP_DOWNARROW:
S_LocalSound ("misc/menu1.wav");
video_options_cursor++;
if (video_options_cursor >= VIDEO_OPTIONS_ITEMS)
@ -1725,7 +1723,6 @@ static void VID_MenuKey (int key)
break;
case K_LEFTARROW:
case K_KP_LEFTARROW:
S_LocalSound ("misc/menu3.wav");
switch (video_options_cursor)
{
@ -1747,7 +1744,6 @@ static void VID_MenuKey (int key)
break;
case K_RIGHTARROW:
case K_KP_RIGHTARROW:
S_LocalSound ("misc/menu3.wav");
switch (video_options_cursor)
{

View File

@ -583,15 +583,6 @@ static inline qboolean IN_NumpadKey (int key)
}
}
static inline qboolean IN_ExpectCharEvent (SDL_Event event)
{
#if defined(USE_SDL2)
return (SDL_PeepEvents(&event, 1, SDL_PEEKEVENT, SDL_TEXTINPUT, SDL_TEXTINPUT) > 0);
#else
return (event.key.keysym.unicode != 0);
#endif
}
void IN_SendKeyEvents (void)
{
SDL_Event event;
@ -655,17 +646,10 @@ void IN_SendKeyEvents (void)
key = IN_SDL_KeysymToQuakeKey(event.key.keysym.sym);
#endif
// Filter key down events for numpad keys when we expect them
// to also send a char event. Doing this only for key down events
// will generate some stray key up events, but that's much less
// problematic than missing key up events.
if (down && textmode && IN_NumpadKey(key) && IN_ExpectCharEvent(event))
key = 0;
Key_Event (key, down);
#if !defined(USE_SDL2)
if (down && !Key_IgnoreTextInput(key) && (event.key.keysym.unicode & ~0x7F) == 0)
if (down && (event.key.keysym.unicode & ~0x7F) == 0)
Char_Event (event.key.keysym.unicode);
#endif
break;

View File

@ -277,7 +277,6 @@ void Key_Console (int key)
return;
case K_DEL:
case K_KP_DEL:
key_tabpartial[0] = 0;
workline += key_linepos;
if (*workline)
@ -292,7 +291,6 @@ void Key_Console (int key)
return;
case K_HOME:
case K_KP_HOME:
if (keydown[K_CTRL])
{
//skip initial empty lines
@ -316,14 +314,12 @@ void Key_Console (int key)
return;
case K_END:
case K_KP_END:
if (keydown[K_CTRL])
con_backscroll = 0;
else key_linepos = strlen(workline);
return;
case K_PGUP:
case K_KP_PGUP:
case K_MWHEELUP:
con_backscroll += keydown[K_CTRL] ? ((con_vislines>>3) - 4) : 2;
if (con_backscroll > con_totallines - (vid.height>>3) - 1)
@ -331,7 +327,6 @@ void Key_Console (int key)
return;
case K_PGDN:
case K_KP_PGDN:
case K_MWHEELDOWN:
con_backscroll -= keydown[K_CTRL] ? ((con_vislines>>3) - 4) : 2;
if (con_backscroll < 0)
@ -339,7 +334,6 @@ void Key_Console (int key)
return;
case K_LEFTARROW:
case K_KP_LEFTARROW:
if (key_linepos > 1)
{
key_linepos--;
@ -348,7 +342,6 @@ void Key_Console (int key)
return;
case K_RIGHTARROW:
case K_KP_RIGHTARROW:
len = strlen(workline);
if ((int)len == key_linepos)
{
@ -368,7 +361,6 @@ void Key_Console (int key)
return;
case K_UPARROW:
case K_KP_UPARROW:
if (history_line == edit_line)
Q_strcpy(current, workline);
@ -390,7 +382,6 @@ void Key_Console (int key)
return;
case K_DOWNARROW:
case K_KP_DOWNARROW:
if (history_line == edit_line)
return;
@ -408,7 +399,6 @@ void Key_Console (int key)
return;
case K_INS:
case K_KP_INS:
if (keydown[K_SHIFT]) /* Shift-Ins paste */
PasteToConsole();
else key_insert ^= 1;
@ -1150,50 +1140,6 @@ qboolean Key_TextEntry (void)
}
}
/*
===================
Key_IgnoreTextInput
===================
*/
qboolean Key_IgnoreTextInput (int key)
{
#if defined(PLATFORM_OSX) || defined(PLATFORM_MAC)
if (keydown[K_COMMAND])
return true;
#endif
if (keydown[K_CTRL])
return true;
if (key < 0 || key >= MAX_KEYS)
return false;
if (specialkeys[key])
return true;
if (!keybindings[key])
return false;
if (key_inputgrab.active)
return false;
switch (key_dest)
{
case key_message:
return false;
case key_menu:
return menubound[key];
case key_game:
if (!con_forcedup)
return true;
/* fallthrough */
case key_console:
return !consolekeys[key];
default:
return true;
}
}
/*
===================
Key_ClearStates

View File

@ -169,7 +169,6 @@ void Key_GetGrabbedInput (int *lastkey, int *lastchar);
void Key_Event (int key, qboolean down);
void Char_Event (int key);
qboolean Key_TextEntry (void);
qboolean Key_IgnoreTextInput (int key);
void Key_SetBinding (int keynum, const char *binding);
const char *Key_KeynumToString (int keynum);

View File

@ -287,14 +287,12 @@ void M_Main_Key (int key)
break;
case K_DOWNARROW:
case K_KP_DOWNARROW:
S_LocalSound ("misc/menu1.wav");
if (++m_main_cursor >= MAIN_ITEMS)
m_main_cursor = 0;
break;
case K_UPARROW:
case K_KP_UPARROW:
S_LocalSound ("misc/menu1.wav");
if (--m_main_cursor < 0)
m_main_cursor = MAIN_ITEMS - 1;
@ -370,14 +368,12 @@ void M_SinglePlayer_Key (int key)
break;
case K_DOWNARROW:
case K_KP_DOWNARROW:
S_LocalSound ("misc/menu1.wav");
if (++m_singleplayer_cursor >= SINGLEPLAYER_ITEMS)
m_singleplayer_cursor = 0;
break;
case K_UPARROW:
case K_KP_UPARROW:
S_LocalSound ("misc/menu1.wav");
if (--m_singleplayer_cursor < 0)
m_singleplayer_cursor = SINGLEPLAYER_ITEMS - 1;
@ -539,9 +535,7 @@ void M_Load_Key (int k)
return;
case K_UPARROW:
case K_KP_UPARROW:
case K_LEFTARROW:
case K_KP_LEFTARROW:
S_LocalSound ("misc/menu1.wav");
load_cursor--;
if (load_cursor < 0)
@ -549,9 +543,7 @@ void M_Load_Key (int k)
break;
case K_DOWNARROW:
case K_KP_DOWNARROW:
case K_RIGHTARROW:
case K_KP_RIGHTARROW:
S_LocalSound ("misc/menu1.wav");
load_cursor++;
if (load_cursor >= MAX_SAVEGAMES)
@ -578,9 +570,7 @@ void M_Save_Key (int k)
return;
case K_UPARROW:
case K_KP_UPARROW:
case K_LEFTARROW:
case K_KP_LEFTARROW:
S_LocalSound ("misc/menu1.wav");
load_cursor--;
if (load_cursor < 0)
@ -588,9 +578,7 @@ void M_Save_Key (int k)
break;
case K_DOWNARROW:
case K_KP_DOWNARROW:
case K_RIGHTARROW:
case K_KP_RIGHTARROW:
S_LocalSound ("misc/menu1.wav");
load_cursor++;
if (load_cursor >= MAX_SAVEGAMES)
@ -644,14 +632,12 @@ void M_MultiPlayer_Key (int key)
break;
case K_DOWNARROW:
case K_KP_DOWNARROW:
S_LocalSound ("misc/menu1.wav");
if (++m_multiplayer_cursor >= MULTIPLAYER_ITEMS)
m_multiplayer_cursor = 0;
break;
case K_UPARROW:
case K_KP_UPARROW:
S_LocalSound ("misc/menu1.wav");
if (--m_multiplayer_cursor < 0)
m_multiplayer_cursor = MULTIPLAYER_ITEMS - 1;
@ -753,7 +739,6 @@ void M_Setup_Key (int k)
break;
case K_UPARROW:
case K_KP_UPARROW:
S_LocalSound ("misc/menu1.wav");
setup_cursor--;
if (setup_cursor < 0)
@ -761,7 +746,6 @@ void M_Setup_Key (int k)
break;
case K_DOWNARROW:
case K_KP_DOWNARROW:
S_LocalSound ("misc/menu1.wav");
setup_cursor++;
if (setup_cursor >= NUM_SETUP_CMDS)
@ -769,7 +753,6 @@ void M_Setup_Key (int k)
break;
case K_LEFTARROW:
case K_KP_LEFTARROW:
if (setup_cursor < 2)
return;
S_LocalSound ("misc/menu3.wav");
@ -779,7 +762,6 @@ void M_Setup_Key (int k)
setup_bottom = setup_bottom - 1;
break;
case K_RIGHTARROW:
case K_KP_RIGHTARROW:
if (setup_cursor < 2)
return;
forward:
@ -948,14 +930,12 @@ again:
break;
case K_DOWNARROW:
case K_KP_DOWNARROW:
S_LocalSound ("misc/menu1.wav");
if (++m_net_cursor >= m_net_items)
m_net_cursor = 0;
break;
case K_UPARROW:
case K_KP_UPARROW:
S_LocalSound ("misc/menu1.wav");
if (--m_net_cursor < 0)
m_net_cursor = m_net_items - 1;
@ -1262,7 +1242,6 @@ void M_Options_Key (int k)
return;
case K_UPARROW:
case K_KP_UPARROW:
S_LocalSound ("misc/menu1.wav");
options_cursor--;
if (options_cursor < 0)
@ -1270,7 +1249,6 @@ void M_Options_Key (int k)
break;
case K_DOWNARROW:
case K_KP_DOWNARROW:
S_LocalSound ("misc/menu1.wav");
options_cursor++;
if (options_cursor >= OPTIONS_ITEMS)
@ -1278,19 +1256,17 @@ void M_Options_Key (int k)
break;
case K_LEFTARROW:
case K_KP_LEFTARROW:
M_AdjustSliders (-1);
break;
case K_RIGHTARROW:
case K_KP_RIGHTARROW:
M_AdjustSliders (1);
break;
}
if (options_cursor == OPTIONS_ITEMS - 1 && vid_menudrawfn == NULL)
{
if (k == K_UPARROW || k == K_KP_UPARROW)
if (k == K_UPARROW)
options_cursor = OPTIONS_ITEMS - 2;
else
options_cursor = 0;
@ -1457,9 +1433,7 @@ void M_Keys_Key (int k)
break;
case K_LEFTARROW:
case K_KP_LEFTARROW:
case K_UPARROW:
case K_KP_UPARROW:
S_LocalSound ("misc/menu1.wav");
keys_cursor--;
if (keys_cursor < 0)
@ -1467,9 +1441,7 @@ void M_Keys_Key (int k)
break;
case K_DOWNARROW:
case K_KP_DOWNARROW:
case K_RIGHTARROW:
case K_KP_RIGHTARROW:
S_LocalSound ("misc/menu1.wav");
keys_cursor++;
if (keys_cursor >= (int)NUMCOMMANDS)
@ -1488,7 +1460,6 @@ void M_Keys_Key (int k)
case K_BACKSPACE: // delete bindings
case K_DEL:
case K_KP_DEL:
S_LocalSound ("misc/menu2.wav");
M_UnbindCommand (bindnames[keys_cursor][0]);
break;
@ -1548,18 +1519,14 @@ void M_Help_Key (int key)
break;
case K_UPARROW:
case K_KP_UPARROW:
case K_RIGHTARROW:
case K_KP_RIGHTARROW:
m_entersound = true;
if (++help_page >= NUM_HELP_PAGES)
help_page = 0;
break;
case K_DOWNARROW:
case K_KP_DOWNARROW:
case K_LEFTARROW:
case K_KP_LEFTARROW:
m_entersound = true;
if (--help_page < 0)
help_page = NUM_HELP_PAGES-1;
@ -1781,7 +1748,6 @@ void M_LanConfig_Key (int key)
break;
case K_UPARROW:
case K_KP_UPARROW:
S_LocalSound ("misc/menu1.wav");
lanConfig_cursor--;
if (lanConfig_cursor < 0)
@ -1789,7 +1755,6 @@ void M_LanConfig_Key (int key)
break;
case K_DOWNARROW:
case K_KP_DOWNARROW:
S_LocalSound ("misc/menu1.wav");
lanConfig_cursor++;
if (lanConfig_cursor >= NUM_LANCONFIG_CMDS)
@ -1846,7 +1811,7 @@ void M_LanConfig_Key (int key)
if (StartingGame && lanConfig_cursor == 2)
{
if (key == K_UPARROW || key == K_KP_UPARROW)
if (key == K_UPARROW)
lanConfig_cursor = 1;
else
lanConfig_cursor = 0;
@ -2293,7 +2258,6 @@ void M_GameOptions_Key (int key)
break;
case K_UPARROW:
case K_KP_UPARROW:
S_LocalSound ("misc/menu1.wav");
gameoptions_cursor--;
if (gameoptions_cursor < 0)
@ -2301,7 +2265,6 @@ void M_GameOptions_Key (int key)
break;
case K_DOWNARROW:
case K_KP_DOWNARROW:
S_LocalSound ("misc/menu1.wav");
gameoptions_cursor++;
if (gameoptions_cursor >= NUM_GAMEOPTIONS)
@ -2309,7 +2272,6 @@ void M_GameOptions_Key (int key)
break;
case K_LEFTARROW:
case K_KP_LEFTARROW:
if (gameoptions_cursor == 0)
break;
S_LocalSound ("misc/menu3.wav");
@ -2317,7 +2279,6 @@ void M_GameOptions_Key (int key)
break;
case K_RIGHTARROW:
case K_KP_RIGHTARROW:
if (gameoptions_cursor == 0)
break;
S_LocalSound ("misc/menu3.wav");
@ -2465,9 +2426,7 @@ void M_ServerList_Key (int k)
break;
case K_UPARROW:
case K_KP_UPARROW:
case K_LEFTARROW:
case K_KP_LEFTARROW:
S_LocalSound ("misc/menu1.wav");
slist_cursor--;
if (slist_cursor < 0)
@ -2475,9 +2434,7 @@ void M_ServerList_Key (int k)
break;
case K_DOWNARROW:
case K_KP_DOWNARROW:
case K_RIGHTARROW:
case K_KP_RIGHTARROW:
S_LocalSound ("misc/menu1.wav");
slist_cursor++;
if (slist_cursor >= hostCacheCount)