From 10e987f862b197125c1d373173592c46aeb7486b Mon Sep 17 00:00:00 2001 From: svdijk Date: Fri, 8 Jun 2012 19:27:12 +0000 Subject: [PATCH] Re-introduce KP_* syms, but only "in-game". git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@683 af15c1b1-3010-417e-b628-4374ebc0bcbd --- quakespasm/Quake/in_sdl.c | 103 ++++++++++++++++++++------------------ quakespasm/Quake/keys.c | 8 --- quakespasm/Quake/keys.h | 2 - quakespasm/Quake/menu.c | 12 ++--- quakespasm/Quake/menu.h | 2 + 5 files changed, 63 insertions(+), 64 deletions(-) diff --git a/quakespasm/Quake/in_sdl.c b/quakespasm/Quake/in_sdl.c index fd90aeae..fc07e3ac 100644 --- a/quakespasm/Quake/in_sdl.c +++ b/quakespasm/Quake/in_sdl.c @@ -300,10 +300,13 @@ void IN_SendKeyEvents (void) SDL_Event event; int sym, state; int modstate; + qboolean gamekey; + + gamekey = (key_dest == key_game || m_keys_bind_grab); if (key_dest != prev_key_dest) { - SDL_EnableUNICODE((key_dest == key_console || key_dest == key_message)); + SDL_EnableUNICODE(!gamekey); Key_ClearStates(); prev_key_dest = key_dest; } @@ -470,85 +473,89 @@ void IN_SendKeyEvents (void) sym = K_ALT; break; case SDLK_KP0: - if (modstate & KMOD_NUM) - sym = SDLK_0; - else - sym = K_INS; + if (gamekey) + sym = KP_INS; + else sym = (modstate & KMOD_NUM) ? SDLK_0 : K_INS; break; case SDLK_KP1: - if (modstate & KMOD_NUM) - sym = SDLK_1; - else - sym = K_END; + if (gamekey) + sym = KP_END; + else sym = (modstate & KMOD_NUM) ? SDLK_1 : K_END; break; case SDLK_KP2: - if (modstate & KMOD_NUM) - sym = SDLK_2; - else - sym = K_DOWNARROW; + if (gamekey) + sym = KP_DOWNARROW; + else sym = (modstate & KMOD_NUM) ? SDLK_2 : K_DOWNARROW; break; case SDLK_KP3: - if (modstate & KMOD_NUM) - sym = SDLK_3; - else - sym = K_PGDN; + if (gamekey) + sym = KP_PGDN; + else sym = (modstate & KMOD_NUM) ? SDLK_3 : K_PGDN; break; case SDLK_KP4: - if (modstate & KMOD_NUM) - sym = SDLK_4; - else - sym = K_LEFTARROW; + if (gamekey) + sym = KP_LEFTARROW; + else sym = (modstate & KMOD_NUM) ? SDLK_4 : K_LEFTARROW; break; case SDLK_KP5: - sym = SDLK_5; + if (gamekey) + sym = KP_5; + else sym = (modstate & KMOD_NUM) ? SDLK_5 : 0; break; case SDLK_KP6: - if (modstate & KMOD_NUM) - sym = SDLK_6; - else - sym = K_RIGHTARROW; + if (gamekey) + sym = KP_RIGHTARROW; + else sym = (modstate & KMOD_NUM) ? SDLK_6 : K_RIGHTARROW; break; case SDLK_KP7: - if (modstate & KMOD_NUM) - sym = SDLK_7; - else - sym = K_HOME; + if (gamekey) + sym = KP_HOME; + else sym = (modstate & KMOD_NUM) ? SDLK_7 : K_HOME; break; case SDLK_KP8: - if (modstate & KMOD_NUM) - sym = SDLK_8; - else - sym = K_UPARROW; + if (gamekey) + sym = KP_UPARROW; + else sym = (modstate & KMOD_NUM) ? SDLK_8 : K_UPARROW; break; case SDLK_KP9: - if (modstate & KMOD_NUM) - sym = SDLK_9; - else - sym = K_PGUP; + if (gamekey) + sym = KP_PGUP; + else sym = (modstate & KMOD_NUM) ? SDLK_9 : K_PGUP; break; case SDLK_KP_PERIOD: - if (modstate & KMOD_NUM) - sym = SDLK_PERIOD; - else - sym = K_DEL; + if (gamekey) + sym = KP_DEL; + else sym = (modstate & KMOD_NUM) ? SDLK_PERIOD : K_DEL; break; case SDLK_KP_DIVIDE: - sym = SDLK_SLASH; + if (gamekey) + sym = KP_SLASH; + else sym = SDLK_SLASH; break; case SDLK_KP_MULTIPLY: - sym = SDLK_ASTERISK; + if (gamekey) + sym = KP_STAR; + else sym = SDLK_ASTERISK; break; case SDLK_KP_MINUS: - sym = SDLK_MINUS; + if (gamekey) + sym = KP_MINUS; + else sym = SDLK_MINUS; break; case SDLK_KP_PLUS: - sym = SDLK_PLUS; + if (gamekey) + sym = KP_PLUS; + else sym = SDLK_PLUS; break; case SDLK_KP_ENTER: - sym = SDLK_RETURN; + if (gamekey) + sym = KP_ENTER; + else sym = SDLK_RETURN; break; case SDLK_KP_EQUALS: - sym = SDLK_EQUALS; + if (gamekey) + sym = 0; + else sym = SDLK_EQUALS; break; case 178: /* the '²' key */ sym = '~'; diff --git a/quakespasm/Quake/keys.c b/quakespasm/Quake/keys.c index 3a20f9c6..199cd802 100644 --- a/quakespasm/Quake/keys.c +++ b/quakespasm/Quake/keys.c @@ -76,7 +76,6 @@ keyname_t keynames[] = {"CTRL", K_CTRL}, {"SHIFT", K_SHIFT}, -#if 0 /* QuakeSpasm: keypad keys are mapped to their non-keypad counterparts */ //johnfitz -- keypad {"KP_NUMLOCK", KP_NUMLOCK}, {"KP_SLASH", KP_SLASH }, @@ -96,7 +95,6 @@ keyname_t keynames[] = {"KP_INS", KP_INS }, {"KP_DEL", KP_DEL }, //johnfitz -#endif {"F1", K_F1}, {"F2", K_F2}, @@ -196,9 +194,6 @@ void Key_Console (int key) switch (key) { case K_ENTER: -#if 0 /* QuakeSpasm: keypad keys are mapped to their non-keypad counterparts */ - case KP_ENTER: -#endif key_tabpartial[0] = 0; Cbuf_AddText (key_lines[edit_line]+1); // skip the prompt Cbuf_AddText ("\n"); @@ -773,9 +768,6 @@ void Key_Init (void) for (i=32 ; i<128 ; i++) consolekeys[i] = true; consolekeys[K_ENTER] = true; -#if 0 /* QuakeSpasm: keypad keys are mapped to their non-keypad counterparts */ - consolekeys[KP_ENTER] = true; //johnfitz -#endif consolekeys[K_TAB] = true; consolekeys[K_LEFTARROW] = true; consolekeys[K_RIGHTARROW] = true; diff --git a/quakespasm/Quake/keys.h b/quakespasm/Quake/keys.h index d6aa02b9..4ae71705 100644 --- a/quakespasm/Quake/keys.h +++ b/quakespasm/Quake/keys.h @@ -60,7 +60,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define K_HOME 151 #define K_END 152 -#if 0 /* QuakeSpasm: keypad keys are mapped to their non-keypad counterparts */ //johnfitz -- keypad #define KP_NUMLOCK 153 #define KP_SLASH 154 @@ -80,7 +79,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define KP_INS 168 #define KP_DEL 169 //johnfitz -#endif #define K_PAUSE 255 diff --git a/quakespasm/Quake/menu.c b/quakespasm/Quake/menu.c index 43e8844c..791237a1 100644 --- a/quakespasm/Quake/menu.c +++ b/quakespasm/Quake/menu.c @@ -1283,7 +1283,7 @@ const char *bindnames[][2] = #define NUMCOMMANDS (sizeof(bindnames)/sizeof(bindnames[0])) int keys_cursor; -int bind_grab; +qboolean m_keys_bind_grab; void M_Menu_Keys_f (void) { @@ -1349,7 +1349,7 @@ void M_Keys_Draw (void) p = Draw_CachePic ("gfx/ttl_cstm.lmp"); M_DrawPic ( (320-p->width)/2, 4, p); - if (bind_grab) + if (m_keys_bind_grab) M_Print (12, 32, "Press a key or button for this action"); else M_Print (18, 32, "Enter to change, backspace to clear"); @@ -1380,7 +1380,7 @@ void M_Keys_Draw (void) } } - if (bind_grab) + if (m_keys_bind_grab) M_DrawCharacter (130, 48 + keys_cursor*8, '='); else M_DrawCharacter (130, 48 + keys_cursor*8, 12+((int)(realtime*4)&1)); @@ -1392,7 +1392,7 @@ void M_Keys_Key (int k) char cmd[80]; int keys[2]; - if (bind_grab) + if (m_keys_bind_grab) { // defining a key S_LocalSound ("misc/menu1.wav"); if ((k != K_ESCAPE) && (k != '`')) @@ -1401,7 +1401,7 @@ void M_Keys_Key (int k) Cbuf_InsertText (cmd); } - bind_grab = false; + m_keys_bind_grab = false; IN_Deactivate(vid.type == MODE_WINDOWED); // deactivate because we're returning to the menu return; } @@ -1433,7 +1433,7 @@ void M_Keys_Key (int k) S_LocalSound ("misc/menu2.wav"); if (keys[1] != -1) M_UnbindCommand (bindnames[keys_cursor][0]); - bind_grab = true; + m_keys_bind_grab = true; IN_Activate(); // activate to allow mouse key binding break; diff --git a/quakespasm/Quake/menu.h b/quakespasm/Quake/menu.h index 5d93d55d..ec3caed2 100644 --- a/quakespasm/Quake/menu.h +++ b/quakespasm/Quake/menu.h @@ -56,6 +56,8 @@ extern enum m_state_e m_return_state; extern qboolean m_entersound; +extern qboolean m_keys_bind_grab; + // // menus //