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
This commit is contained in:
svdijk 2012-06-08 19:27:12 +00:00
parent a74060efc0
commit 10e987f862
5 changed files with 63 additions and 64 deletions

View file

@ -300,10 +300,13 @@ void IN_SendKeyEvents (void)
SDL_Event event; SDL_Event event;
int sym, state; int sym, state;
int modstate; int modstate;
qboolean gamekey;
gamekey = (key_dest == key_game || m_keys_bind_grab);
if (key_dest != prev_key_dest) if (key_dest != prev_key_dest)
{ {
SDL_EnableUNICODE((key_dest == key_console || key_dest == key_message)); SDL_EnableUNICODE(!gamekey);
Key_ClearStates(); Key_ClearStates();
prev_key_dest = key_dest; prev_key_dest = key_dest;
} }
@ -470,85 +473,89 @@ void IN_SendKeyEvents (void)
sym = K_ALT; sym = K_ALT;
break; break;
case SDLK_KP0: case SDLK_KP0:
if (modstate & KMOD_NUM) if (gamekey)
sym = SDLK_0; sym = KP_INS;
else else sym = (modstate & KMOD_NUM) ? SDLK_0 : K_INS;
sym = K_INS;
break; break;
case SDLK_KP1: case SDLK_KP1:
if (modstate & KMOD_NUM) if (gamekey)
sym = SDLK_1; sym = KP_END;
else else sym = (modstate & KMOD_NUM) ? SDLK_1 : K_END;
sym = K_END;
break; break;
case SDLK_KP2: case SDLK_KP2:
if (modstate & KMOD_NUM) if (gamekey)
sym = SDLK_2; sym = KP_DOWNARROW;
else else sym = (modstate & KMOD_NUM) ? SDLK_2 : K_DOWNARROW;
sym = K_DOWNARROW;
break; break;
case SDLK_KP3: case SDLK_KP3:
if (modstate & KMOD_NUM) if (gamekey)
sym = SDLK_3; sym = KP_PGDN;
else else sym = (modstate & KMOD_NUM) ? SDLK_3 : K_PGDN;
sym = K_PGDN;
break; break;
case SDLK_KP4: case SDLK_KP4:
if (modstate & KMOD_NUM) if (gamekey)
sym = SDLK_4; sym = KP_LEFTARROW;
else else sym = (modstate & KMOD_NUM) ? SDLK_4 : K_LEFTARROW;
sym = K_LEFTARROW;
break; break;
case SDLK_KP5: case SDLK_KP5:
sym = SDLK_5; if (gamekey)
sym = KP_5;
else sym = (modstate & KMOD_NUM) ? SDLK_5 : 0;
break; break;
case SDLK_KP6: case SDLK_KP6:
if (modstate & KMOD_NUM) if (gamekey)
sym = SDLK_6; sym = KP_RIGHTARROW;
else else sym = (modstate & KMOD_NUM) ? SDLK_6 : K_RIGHTARROW;
sym = K_RIGHTARROW;
break; break;
case SDLK_KP7: case SDLK_KP7:
if (modstate & KMOD_NUM) if (gamekey)
sym = SDLK_7; sym = KP_HOME;
else else sym = (modstate & KMOD_NUM) ? SDLK_7 : K_HOME;
sym = K_HOME;
break; break;
case SDLK_KP8: case SDLK_KP8:
if (modstate & KMOD_NUM) if (gamekey)
sym = SDLK_8; sym = KP_UPARROW;
else else sym = (modstate & KMOD_NUM) ? SDLK_8 : K_UPARROW;
sym = K_UPARROW;
break; break;
case SDLK_KP9: case SDLK_KP9:
if (modstate & KMOD_NUM) if (gamekey)
sym = SDLK_9; sym = KP_PGUP;
else else sym = (modstate & KMOD_NUM) ? SDLK_9 : K_PGUP;
sym = K_PGUP;
break; break;
case SDLK_KP_PERIOD: case SDLK_KP_PERIOD:
if (modstate & KMOD_NUM) if (gamekey)
sym = SDLK_PERIOD; sym = KP_DEL;
else else sym = (modstate & KMOD_NUM) ? SDLK_PERIOD : K_DEL;
sym = K_DEL;
break; break;
case SDLK_KP_DIVIDE: case SDLK_KP_DIVIDE:
sym = SDLK_SLASH; if (gamekey)
sym = KP_SLASH;
else sym = SDLK_SLASH;
break; break;
case SDLK_KP_MULTIPLY: case SDLK_KP_MULTIPLY:
sym = SDLK_ASTERISK; if (gamekey)
sym = KP_STAR;
else sym = SDLK_ASTERISK;
break; break;
case SDLK_KP_MINUS: case SDLK_KP_MINUS:
sym = SDLK_MINUS; if (gamekey)
sym = KP_MINUS;
else sym = SDLK_MINUS;
break; break;
case SDLK_KP_PLUS: case SDLK_KP_PLUS:
sym = SDLK_PLUS; if (gamekey)
sym = KP_PLUS;
else sym = SDLK_PLUS;
break; break;
case SDLK_KP_ENTER: case SDLK_KP_ENTER:
sym = SDLK_RETURN; if (gamekey)
sym = KP_ENTER;
else sym = SDLK_RETURN;
break; break;
case SDLK_KP_EQUALS: case SDLK_KP_EQUALS:
sym = SDLK_EQUALS; if (gamekey)
sym = 0;
else sym = SDLK_EQUALS;
break; break;
case 178: /* the '˛' key */ case 178: /* the '˛' key */
sym = '~'; sym = '~';

View file

@ -76,7 +76,6 @@ keyname_t keynames[] =
{"CTRL", K_CTRL}, {"CTRL", K_CTRL},
{"SHIFT", K_SHIFT}, {"SHIFT", K_SHIFT},
#if 0 /* QuakeSpasm: keypad keys are mapped to their non-keypad counterparts */
//johnfitz -- keypad //johnfitz -- keypad
{"KP_NUMLOCK", KP_NUMLOCK}, {"KP_NUMLOCK", KP_NUMLOCK},
{"KP_SLASH", KP_SLASH }, {"KP_SLASH", KP_SLASH },
@ -96,7 +95,6 @@ keyname_t keynames[] =
{"KP_INS", KP_INS }, {"KP_INS", KP_INS },
{"KP_DEL", KP_DEL }, {"KP_DEL", KP_DEL },
//johnfitz //johnfitz
#endif
{"F1", K_F1}, {"F1", K_F1},
{"F2", K_F2}, {"F2", K_F2},
@ -196,9 +194,6 @@ void Key_Console (int key)
switch (key) switch (key)
{ {
case K_ENTER: case K_ENTER:
#if 0 /* QuakeSpasm: keypad keys are mapped to their non-keypad counterparts */
case KP_ENTER:
#endif
key_tabpartial[0] = 0; key_tabpartial[0] = 0;
Cbuf_AddText (key_lines[edit_line]+1); // skip the prompt Cbuf_AddText (key_lines[edit_line]+1); // skip the prompt
Cbuf_AddText ("\n"); Cbuf_AddText ("\n");
@ -773,9 +768,6 @@ void Key_Init (void)
for (i=32 ; i<128 ; i++) for (i=32 ; i<128 ; i++)
consolekeys[i] = true; consolekeys[i] = true;
consolekeys[K_ENTER] = 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_TAB] = true;
consolekeys[K_LEFTARROW] = true; consolekeys[K_LEFTARROW] = true;
consolekeys[K_RIGHTARROW] = true; consolekeys[K_RIGHTARROW] = true;

View file

@ -60,7 +60,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define K_HOME 151 #define K_HOME 151
#define K_END 152 #define K_END 152
#if 0 /* QuakeSpasm: keypad keys are mapped to their non-keypad counterparts */
//johnfitz -- keypad //johnfitz -- keypad
#define KP_NUMLOCK 153 #define KP_NUMLOCK 153
#define KP_SLASH 154 #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_INS 168
#define KP_DEL 169 #define KP_DEL 169
//johnfitz //johnfitz
#endif
#define K_PAUSE 255 #define K_PAUSE 255

View file

@ -1283,7 +1283,7 @@ const char *bindnames[][2] =
#define NUMCOMMANDS (sizeof(bindnames)/sizeof(bindnames[0])) #define NUMCOMMANDS (sizeof(bindnames)/sizeof(bindnames[0]))
int keys_cursor; int keys_cursor;
int bind_grab; qboolean m_keys_bind_grab;
void M_Menu_Keys_f (void) void M_Menu_Keys_f (void)
{ {
@ -1349,7 +1349,7 @@ void M_Keys_Draw (void)
p = Draw_CachePic ("gfx/ttl_cstm.lmp"); p = Draw_CachePic ("gfx/ttl_cstm.lmp");
M_DrawPic ( (320-p->width)/2, 4, p); 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"); M_Print (12, 32, "Press a key or button for this action");
else else
M_Print (18, 32, "Enter to change, backspace to clear"); 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, '='); M_DrawCharacter (130, 48 + keys_cursor*8, '=');
else else
M_DrawCharacter (130, 48 + keys_cursor*8, 12+((int)(realtime*4)&1)); 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]; char cmd[80];
int keys[2]; int keys[2];
if (bind_grab) if (m_keys_bind_grab)
{ // defining a key { // defining a key
S_LocalSound ("misc/menu1.wav"); S_LocalSound ("misc/menu1.wav");
if ((k != K_ESCAPE) && (k != '`')) if ((k != K_ESCAPE) && (k != '`'))
@ -1401,7 +1401,7 @@ void M_Keys_Key (int k)
Cbuf_InsertText (cmd); 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 IN_Deactivate(vid.type == MODE_WINDOWED); // deactivate because we're returning to the menu
return; return;
} }
@ -1433,7 +1433,7 @@ void M_Keys_Key (int k)
S_LocalSound ("misc/menu2.wav"); S_LocalSound ("misc/menu2.wav");
if (keys[1] != -1) if (keys[1] != -1)
M_UnbindCommand (bindnames[keys_cursor][0]); M_UnbindCommand (bindnames[keys_cursor][0]);
bind_grab = true; m_keys_bind_grab = true;
IN_Activate(); // activate to allow mouse key binding IN_Activate(); // activate to allow mouse key binding
break; break;

View file

@ -56,6 +56,8 @@ extern enum m_state_e m_return_state;
extern qboolean m_entersound; extern qboolean m_entersound;
extern qboolean m_keys_bind_grab;
// //
// menus // menus
// //