Merge pull request #1077 from apartfromtime/Fix-duplicate-entries

Fix duplicate menu key keyboard entries
This commit is contained in:
Yamagi 2023-12-19 18:33:39 +01:00 committed by GitHub
commit e40f5d1480
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 53 deletions

View file

@ -276,6 +276,7 @@ extern int chat_bufferlen;
extern int chat_cursorpos; extern int chat_cursorpos;
extern qboolean chat_team; extern qboolean chat_team;
qboolean IN_NumpadIsOn();
void Char_Event(int key); void Char_Event(int key);
void Key_Event(int key, qboolean down, qboolean special); void Key_Event(int key, qboolean down, qboolean special);
void Key_Init(void); void Key_Init(void);

View file

@ -537,6 +537,18 @@ IN_TranslateGamepadBtnToQ2Key(int btn)
static void IN_Controller_Init(qboolean notify_user); static void IN_Controller_Init(qboolean notify_user);
static void IN_Controller_Shutdown(qboolean notify_user); static void IN_Controller_Shutdown(qboolean notify_user);
qboolean IN_NumpadIsOn()
{
SDL_Keymod mod = SDL_GetModState();
if ((mod & KMOD_NUM) == KMOD_NUM)
{
return true;
}
return false;
}
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* /*

View file

@ -242,27 +242,31 @@ Key_GetMenuKey(int key)
switch (key) switch (key)
{ {
case K_KP_UPARROW: case K_KP_UPARROW:
if (IN_NumpadIsOn() == true) { break; }
case K_UPARROW: case K_UPARROW:
case K_DPAD_UP: case K_DPAD_UP:
return K_UPARROW; return K_UPARROW;
case K_TAB: case K_TAB:
case K_KP_DOWNARROW: case K_KP_DOWNARROW:
if (IN_NumpadIsOn() == true) { break; }
case K_DOWNARROW: case K_DOWNARROW:
case K_DPAD_DOWN: case K_DPAD_DOWN:
return K_DOWNARROW; return K_DOWNARROW;
case K_KP_LEFTARROW: case K_KP_LEFTARROW:
if (IN_NumpadIsOn() == true) { break; }
case K_LEFTARROW: case K_LEFTARROW:
case K_DPAD_LEFT: case K_DPAD_LEFT:
case K_SHOULDER_LEFT: case K_SHOULDER_LEFT:
return K_LEFTARROW; return K_LEFTARROW;
case K_KP_RIGHTARROW: case K_KP_RIGHTARROW:
if (IN_NumpadIsOn() == true) { break; }
case K_RIGHTARROW: case K_RIGHTARROW:
case K_DPAD_RIGHT: case K_DPAD_RIGHT:
case K_SHOULDER_RIGHT: case K_SHOULDER_RIGHT:
return K_RIGHTARROW; return K_RIGHTARROW;
case K_MOUSE1: case K_MOUSE1:
case K_MOUSE2: case K_MOUSE2:
@ -273,22 +277,28 @@ Key_GetMenuKey(int key)
case K_KP_ENTER: case K_KP_ENTER:
case K_ENTER: case K_ENTER:
case K_BTN_A: case K_BTN_A:
return K_ENTER; return K_ENTER;
case K_ESCAPE: case K_ESCAPE:
case K_JOY_BACK: case K_JOY_BACK:
case K_BTN_B: case K_BTN_B:
return K_ESCAPE; return K_ESCAPE;
case K_BACKSPACE: case K_BACKSPACE:
case K_DEL: case K_DEL:
case K_KP_DEL: case K_KP_DEL:
if (IN_NumpadIsOn() == true) { break; }
case K_BTN_Y: case K_BTN_Y:
return K_BACKSPACE; return K_BACKSPACE;
case K_KP_INS:
if (IN_NumpadIsOn() == true) { break; }
case K_INS:
return K_INS;
} }
return key; return key;
} }
const char * const char *
Default_MenuKey(menuframework_s *m, int key) Default_MenuKey(menuframework_s *m, int key)
{ {

View file

@ -223,52 +223,6 @@ extern int keydown[];
qboolean qboolean
Field_Key(menufield_s *f, int key) Field_Key(menufield_s *f, int key)
{ {
switch (key)
{
case K_KP_SLASH:
key = '/';
break;
case K_KP_MINUS:
key = '-';
break;
case K_KP_PLUS:
key = '+';
break;
case K_KP_HOME:
key = '7';
break;
case K_KP_UPARROW:
key = '8';
break;
case K_KP_PGUP:
key = '9';
break;
case K_KP_LEFTARROW:
key = '4';
break;
case K_KP_5:
key = '5';
break;
case K_KP_RIGHTARROW:
key = '6';
break;
case K_KP_END:
key = '1';
break;
case K_KP_DOWNARROW:
key = '2';
break;
case K_KP_PGDN:
key = '3';
break;
case K_KP_INS:
key = '0';
break;
case K_KP_DEL:
key = '.';
break;
}
if (key > 127) if (key > 127)
{ {
return false; return false;