From 323ef1981e850b0a91b099a4d934eb2e6864cbce Mon Sep 17 00:00:00 2001 From: Andrei Drexler Date: Sat, 30 Dec 2023 11:13:01 +0100 Subject: [PATCH] Avoid using explicit keycode values to make it easier to add keys in the future --- Quake/keys.h | 144 ++++++++++++++++++++++++++------------------------- 1 file changed, 73 insertions(+), 71 deletions(-) diff --git a/Quake/keys.h b/Quake/keys.h index 177a8c1c2..e6fc92bd7 100644 --- a/Quake/keys.h +++ b/Quake/keys.h @@ -36,89 +36,91 @@ typedef enum keycode_t // normal keys should be passed as lowercased ascii K_BACKSPACE = 127, - K_UPARROW = 128, - K_DOWNARROW = 129, - K_LEFTARROW = 130, - K_RIGHTARROW = 131, - - K_ALT = 132, - K_CTRL = 133, - K_SHIFT = 134, - K_F1 = 135, - K_F2 = 136, - K_F3 = 137, - K_F4 = 138, - K_F5 = 139, - K_F6 = 140, - K_F7 = 141, - K_F8 = 142, - K_F9 = 143, - K_F10 = 144, - K_F11 = 145, - K_F12 = 146, - K_INS = 147, - K_DEL = 148, - K_PGDN = 149, - K_PGUP = 150, - K_HOME = 151, - K_END = 152, - - K_KP_NUMLOCK = 153, - K_KP_SLASH = 154, - K_KP_STAR = 155, - K_KP_MINUS = 156, - K_KP_HOME = 157, - K_KP_UPARROW = 158, - K_KP_PGUP = 159, - K_KP_PLUS = 160, - K_KP_LEFTARROW = 161, - K_KP_5 = 162, - K_KP_RIGHTARROW = 163, - K_KP_END = 164, - K_KP_DOWNARROW = 165, - K_KP_PGDN = 166, - K_KP_ENTER = 167, - K_KP_INS = 168, - K_KP_DEL = 169, - - K_COMMAND = 170, - - K_CAPSLOCK = 171, - K_SCROLLLOCK = 172, - K_PRINTSCREEN = 173, - - K_PAUSE = 255, + K_UPARROW, + K_DOWNARROW, + K_LEFTARROW, + K_RIGHTARROW, + + K_ALT, + K_CTRL, + K_SHIFT, + K_F1, + K_F2, + K_F3, + K_F4, + K_F5, + K_F6, + K_F7, + K_F8, + K_F9, + K_F10, + K_F11, + K_F12, + K_INS, + K_DEL, + K_PGDN, + K_PGUP, + K_HOME, + K_END, + + K_KP_NUMLOCK, + K_KP_SLASH, + K_KP_STAR, + K_KP_MINUS, + K_KP_HOME, + K_KP_UPARROW, + K_KP_PGUP, + K_KP_PLUS, + K_KP_LEFTARROW, + K_KP_5, + K_KP_RIGHTARROW, + K_KP_END, + K_KP_DOWNARROW, + K_KP_PGDN, + K_KP_ENTER, + K_KP_INS, + K_KP_DEL, + + K_COMMAND, + + K_CAPSLOCK, + K_SCROLLLOCK, + K_PRINTSCREEN, // // mouse buttons generate virtual keys // K_MOUSE1 = 200, - K_MOUSE2 = 201, - K_MOUSE3 = 202, - -// JACK: Intellimouse(c) Mouse Wheel Support - - K_MWHEELUP = 239, - K_MWHEELDOWN = 240, + K_MOUSE2, + K_MOUSE3, // thumb buttons - K_MOUSE4 = 241, - K_MOUSE5 = 242, + K_MOUSE4, + K_MOUSE5, + +// JACK: Intellimouse(c) Mouse Wheel Support + K_MWHEELUP, + K_MWHEELDOWN, // SDL2 game controller keys - K_LTHUMB = 243, - K_RTHUMB = 244, - K_LSHOULDER = 245, - K_RSHOULDER = 246, - K_ABUTTON = 247, - K_BBUTTON = 248, - K_XBUTTON = 249, - K_YBUTTON = 250, - K_LTRIGGER = 251, - K_RTRIGGER = 252, + K_LTHUMB, + K_RTHUMB, + K_LSHOULDER, + K_RSHOULDER, + K_ABUTTON, + K_BBUTTON, + K_XBUTTON, + K_YBUTTON, + K_LTRIGGER, + K_RTRIGGER, + + K_PAUSE, + + NUM_KEYCODES, } keycode_t; #define MAX_KEYS 256 +COMPILE_TIME_ASSERT (too_many_keycodes, NUM_KEYCODES <= MAX_KEYS); #define MAXCMDLINE 256