From c8f350aa70e8b2196e1094d91492c424ac3ad574 Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 19 May 2023 17:48:42 +0100 Subject: [PATCH] CON_ShiftChar: Integrate numpad translation from CON_Responder, so both chat and menu input can take advantage The original written comment by Callum remarks that it was good for writing IP addresses, and this makes it apply to the IP address Online Menu field... Also adds better comments. --- src/console.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/console.c b/src/console.c index dbfbf5c31..42b2e85b4 100644 --- a/src/console.c +++ b/src/console.c @@ -648,11 +648,31 @@ INT32 CON_ShiftChar(INT32 ch) { if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) { + // Standard Latin-script uppercase translation if (shiftdown ^ capslock) ch = shiftxform[ch]; } - else // if we're holding shift we should still shift non letter symbols + else if (ch >= KEY_KEYPAD7 && ch <= KEY_KPADDEL) { + // Numpad keycodes mapped to printable equivalent + const char keypad_translation[] = + { + '7','8','9','-', + '4','5','6','+', + '1','2','3', + '0','.' + }; + + ch = keypad_translation[ch - KEY_KEYPAD7]; + } + else if (ch == KEY_KPADSLASH) + { + // Ditto, but non-contiguous keycode + ch = '/'; + } + else + { + // QWERTY keycode translation if (shiftdown) ch = shiftxform[ch]; } @@ -1296,19 +1316,6 @@ boolean CON_Responder(event_t *ev) return true; } - // allow people to use keypad in console (good for typing IP addresses) - Calum - if (key >= KEY_KEYPAD7 && key <= KEY_KPADDEL) - { - char keypad_translation[] = {'7','8','9','-', - '4','5','6','+', - '1','2','3', - '0','.'}; - - key = keypad_translation[key - KEY_KEYPAD7]; - } - else if (key == KEY_KPADSLASH) - key = '/'; - key = CON_ShiftChar(key); // enter a char into the command prompt