From 9b384732956e284c70b4e7690f1b3e037de7e83d Mon Sep 17 00:00:00 2001 From: Eukara Date: Fri, 23 Jul 2021 13:36:18 +0000 Subject: [PATCH] More input adjustments, added new SDL gamepad button mappings git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5989 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cl_cg.c | 6 + engine/client/cl_ui.c | 6 + engine/client/in_sdl.c | 86 +++++---- engine/client/in_win.c | 60 +++---- engine/client/keys.c | 73 +++++--- engine/client/keys.h | 358 ++++++++++++++++++++------------------ engine/client/pr_clcmd.c | 215 ++++++++++++----------- engine/common/pr_common.h | 4 +- 8 files changed, 444 insertions(+), 364 deletions(-) diff --git a/engine/client/cl_cg.c b/engine/client/cl_cg.c index ab10554f1..3767fdc3d 100644 --- a/engine/client/cl_cg.c +++ b/engine/client/cl_cg.c @@ -1441,6 +1441,12 @@ qboolean CG_KeyPress(int key, int unicode, int down) case K_GP_A: key = K_ENTER; break; + case K_GP_B: + key = K_ESCAPE; + break; + case K_GP_X: + key = K_BACKSPACE; + break; } return VM_Call(cgvm, CG_KEY_EVENT, key, down); diff --git a/engine/client/cl_ui.c b/engine/client/cl_ui.c index d823bb32c..c86c53f34 100644 --- a/engine/client/cl_ui.c +++ b/engine/client/cl_ui.c @@ -1818,6 +1818,12 @@ qboolean UI_KeyPress(struct menu_s *m, qboolean isdown, unsigned int devid, int case K_GP_A: key = K_ENTER; break; + case K_GP_B: + key = K_ESCAPE; + break; + case K_GP_X: + key = K_BACKSPACE; + break; } if (key && key < 1024) diff --git a/engine/client/in_sdl.c b/engine/client/in_sdl.c index f528a3621..7c7b874b6 100644 --- a/engine/client/in_sdl.c +++ b/engine/client/in_sdl.c @@ -182,9 +182,9 @@ static void J_ControllerAxis(SDL_JoystickID jid, int axis, int value) if (joy && axis < sizeof(axismap)/sizeof(axismap[0]) && joy->qdevid != DEVID_UNSET) { /* hack to allow for RTRIGGER and LTRIGGER */ if (axis == 4) - IN_KeyEvent(joy->qdevid, (value > 128) ? 1 : 0, K_GP_LEFT_TRIGGER, 0); + IN_KeyEvent(joy->qdevid, (value > 16382) ? 1 : 0, K_GP_LEFT_TRIGGER, 0); else if (axis == 5) - IN_KeyEvent(joy->qdevid, (value > 128) ? 1 : 0, K_GP_RIGHT_TRIGGER, 0); + IN_KeyEvent(joy->qdevid, (value > 16382) ? 1 : 0, K_GP_RIGHT_TRIGGER, 0); else IN_JoystickAxisEvent(joy->qdevid, axismap[axis], value / 32767.0); } @@ -204,21 +204,27 @@ static void J_ControllerButton(SDL_JoystickID jid, int button, qboolean pressed) //but that doesn't meant that fte has specific k_ names for those buttons, but the mapping should be reliable, at least until they get mapped to proper k_ values. int buttonmap[] = { - K_GP_A, /*SDL_CONTROLLER_BUTTON_A*/ - K_GP_B, /*SDL_CONTROLLER_BUTTON_B*/ - K_GP_X, /*SDL_CONTROLLER_BUTTON_X*/ - K_GP_Y, /*SDL_CONTROLLER_BUTTON_Y*/ - K_GP_BACK, /*SDL_CONTROLLER_BUTTON_BACK*/ - K_GP_GUIDE, /*SDL_CONTROLLER_BUTTON_GUIDE*/ - K_GP_START, /*SDL_CONTROLLER_BUTTON_START*/ - K_GP_LEFT_THUMB, /*SDL_CONTROLLER_BUTTON_LEFTSTICK*/ - K_GP_RIGHT_THUMB, /*SDL_CONTROLLER_BUTTON_RIGHTSTICK*/ - K_GP_LEFT_SHOULDER, /*SDL_CONTROLLER_BUTTON_LEFTSHOULDER*/ - K_GP_RIGHT_SHOULDER, /*SDL_CONTROLLER_BUTTON_RIGHTSHOULDER*/ - K_GP_DPAD_UP, /*SDL_CONTROLLER_BUTTON_DPAD_UP*/ - K_GP_DPAD_DOWN, /*SDL_CONTROLLER_BUTTON_DPAD_DOWN*/ - K_GP_DPAD_LEFT, /*SDL_CONTROLLER_BUTTON_DPAD_LEFT*/ - K_GP_DPAD_RIGHT /*SDL_CONTROLLER_BUTTON_DPAD_RIGHT*/ + K_GP_A, + K_GP_B, + K_GP_X, + K_GP_Y, + K_GP_BACK, + K_GP_GUIDE, + K_GP_START, + K_GP_LEFT_STICK, + K_GP_RIGHT_STICK, + K_GP_LEFT_SHOULDER, + K_GP_RIGHT_SHOULDER, + K_GP_DPAD_UP, + K_GP_DPAD_DOWN, + K_GP_DPAD_LEFT, + K_GP_DPAD_RIGHT, + K_GP_MISC1, + K_GP_PADDLE1, + K_GP_PADDLE2, + K_GP_PADDLE3, + K_GP_PADDLE4, + K_GP_TOUCHPAD }; struct sdljoy_s *joy = J_DevId(jid); @@ -241,6 +247,34 @@ static void J_JoystickButton(SDL_JoystickID jid, int button, qboolean pressed) K_JOY2, K_JOY3, K_JOY4, + K_JOY5, + K_JOY6, + K_JOY7, + K_JOY8, + K_JOY9, + K_JOY10, + K_JOY11, + K_JOY12, + K_JOY13, + K_JOY14, + K_JOY15, + K_JOY16, + K_JOY17, + K_JOY18, + K_JOY19, + K_JOY20, + K_JOY21, + K_JOY22, + K_JOY23, + K_JOY24, + K_JOY25, + K_JOY26, + K_JOY27, + K_JOY28, + K_JOY29, + K_JOY30, + K_JOY31, + K_JOY32, K_AUX1, K_AUX2, K_AUX3, @@ -256,23 +290,7 @@ static void J_JoystickButton(SDL_JoystickID jid, int button, qboolean pressed) K_AUX13, K_AUX14, K_AUX15, - K_AUX16, - K_AUX17, - K_AUX18, - K_AUX19, - K_AUX20, - K_AUX21, - K_AUX22, - K_AUX23, - K_AUX24, - K_AUX25, - K_AUX26, - K_AUX27, - K_AUX28, - K_AUX29, - K_AUX30, - K_AUX31, - K_AUX32 + K_AUX16 }; struct sdljoy_s *joy = J_DevId(jid); diff --git a/engine/client/in_win.c b/engine/client/in_win.c index 5bd3a0600..e518637d8 100644 --- a/engine/client/in_win.c +++ b/engine/client/in_win.c @@ -351,35 +351,35 @@ static const int mmjbuttons[32] = K_JOY3, K_JOY4, //yes, aux1-4 skipped for compat with other quake engines. - K_AUX5, - K_AUX6, - K_AUX7, - K_AUX8, - K_AUX9, - K_AUX10, - K_AUX11, - K_AUX12, - K_AUX13, - K_AUX14, - K_AUX15, - K_AUX16, - K_AUX17, - K_AUX18, - K_AUX19, - K_AUX20, - K_AUX21, - K_AUX22, - K_AUX23, - K_AUX24, - K_AUX25, - K_AUX26, - K_AUX27, - K_AUX28, + K_JOY9, + K_JOY10, + K_JOY11, + K_JOY12, + K_JOY13, + K_JOY14, + K_JOY15, + K_JOY16, + K_JOY17, + K_JOY18, + K_JOY19, + K_JOY20, + K_JOY21, + K_JOY22, + K_JOY23, + K_JOY24, + K_JOY25, + K_JOY26, + K_JOY27, + K_JOY28, + K_JOY29, + K_JOY30, + K_JOY31, + K_JOY32, //29-32 used for the pov stuff, so lets switch back to aux1-4 to avoid wastage - K_AUX1, - K_AUX2, - K_AUX3, - K_AUX4 + K_JOY5, + K_JOY6, + K_JOY7, + K_JOY8 }; // forward-referenced functions @@ -2018,12 +2018,12 @@ void INS_Commands (void) { if ( (povstate & (1<oldpovstate & (1<devid, K_AUX29 + i, 0, true); + Key_Event (joy->devid, K_AUX13 + i, 0, true); } if ( !(povstate & (1<oldpovstate & (1<devid, K_AUX29 + i, 0, false); + Key_Event (joy->devid, K_AUX13 + i, 0, false); } } joy->oldpovstate = povstate; diff --git a/engine/client/keys.c b/engine/client/keys.c index 74ae75d8b..d68ceb78d 100644 --- a/engine/client/keys.c +++ b/engine/client/keys.c @@ -217,6 +217,34 @@ keyname_t keynames[] = {"JOY2", K_JOY2}, {"JOY3", K_JOY3}, {"JOY4", K_JOY4}, + {"JOY5", K_JOY5}, + {"JOY6", K_JOY6}, + {"JOY7", K_JOY7}, + {"JOY8", K_JOY8}, + {"JOY9", K_JOY9}, + {"JOY10", K_JOY10}, + {"JOY11", K_JOY11}, + {"JOY12", K_JOY12}, + {"JOY13", K_JOY13}, + {"JOY14", K_JOY14}, + {"JOY15", K_JOY15}, + {"JOY16", K_JOY16}, + {"JOY17", K_JOY17}, + {"JOY18", K_JOY18}, + {"JOY19", K_JOY19}, + {"JOY20", K_JOY20}, + {"JOY21", K_JOY21}, + {"JOY22", K_JOY22}, + {"JOY23", K_JOY23}, + {"JOY24", K_JOY24}, + {"JOY25", K_JOY25}, + {"JOY26", K_JOY26}, + {"JOY27", K_JOY27}, + {"JOY28", K_JOY28}, + {"JOY29", K_JOY29}, + {"JOY30", K_JOY30}, + {"JOY31", K_JOY31}, + {"JOY32", K_JOY32}, {"AUX1", K_AUX1}, {"AUX2", K_AUX2}, @@ -234,22 +262,6 @@ keyname_t keynames[] = {"AUX14", K_AUX14}, {"AUX15", K_AUX15}, {"AUX16", K_AUX16}, - {"AUX17", K_AUX17}, - {"AUX18", K_AUX18}, - {"AUX19", K_AUX19}, - {"AUX20", K_AUX20}, - {"AUX21", K_AUX21}, - {"AUX22", K_AUX22}, - {"AUX23", K_AUX23}, - {"AUX24", K_AUX24}, - {"AUX25", K_AUX25}, - {"AUX26", K_AUX26}, - {"AUX27", K_AUX27}, - {"AUX28", K_AUX28}, - {"AUX29", K_AUX29}, - {"AUX30", K_AUX30}, - {"AUX31", K_AUX31}, - {"AUX32", K_AUX32}, {"PAUSE", K_PAUSE}, @@ -275,13 +287,19 @@ keyname_t keynames[] = {"GP_RTRIGGER", K_GP_RIGHT_TRIGGER}, {"GP_BACK", K_GP_BACK}, {"GP_START", K_GP_START}, - {"GP_LTHUMB", K_GP_LEFT_THUMB}, - {"GP_RTHUMB", K_GP_RIGHT_THUMB}, + {"GP_LTHUMB", K_GP_LEFT_STICK}, + {"GP_RTHUMB", K_GP_RIGHT_STICK}, {"GP_DPAD_UP", K_GP_DPAD_UP}, {"GP_DPAD_DOWN", K_GP_DPAD_DOWN}, {"GP_DPAD_LEFT", K_GP_DPAD_LEFT}, {"GP_DPAD_RIGHT", K_GP_DPAD_RIGHT}, {"GP_GUIDE", K_GP_GUIDE}, + {"GP_SHARE", K_GP_MISC1}, + {"GP_PADDLE1", K_GP_PADDLE1}, + {"GP_PADDLE2", K_GP_PADDLE2}, + {"GP_PADDLE3", K_GP_PADDLE3}, + {"GP_PADDLE4", K_GP_PADDLE4}, + {"GP_TOUCHPAD", K_GP_TOUCHPAD}, {"GP_UNKNOWN", K_GP_UNKNOWN}, //names for playstation controllers @@ -289,6 +307,7 @@ keyname_t keynames[] = {"GP_CIRCLE", K_GP_B}, {"GP_SQUARE", K_GP_X}, {"GP_TRIANGLE", K_GP_Y}, + {"GP_MIC", K_GP_MISC1}, //axis->button emulation {"GP_LTHUMB_UP", K_GP_LEFT_THUMB_UP}, @@ -308,8 +327,8 @@ keyname_t keynames[] = {"X360_DPAD_RIGHT", K_GP_DPAD_RIGHT}, {"X360_START", K_GP_START}, {"X360_BACK", K_GP_BACK}, - {"X360_LEFT_THUMB", K_GP_LEFT_THUMB}, - {"X360_RIGHT_THUMB", K_GP_RIGHT_THUMB}, + {"X360_LEFT_THUMB", K_GP_LEFT_STICK}, + {"X360_RIGHT_THUMB", K_GP_RIGHT_STICK}, {"X360_LEFT_SHOULDER", K_GP_LEFT_SHOULDER}, {"X360_RIGHT_SHOULDER", K_GP_RIGHT_SHOULDER}, {"X360_A", K_GP_A}, @@ -328,8 +347,8 @@ keyname_t keynames[] = {"X360_RIGHT_THUMB_RIGHT", K_GP_RIGHT_THUMB_RIGHT}, //quakespasm compat - {"LTHUMB", K_GP_LEFT_THUMB}, - {"RTHUMB", K_GP_RIGHT_THUMB}, + {"LTHUMB", K_GP_LEFT_STICK}, + {"RTHUMB", K_GP_RIGHT_STICK}, {"LSHOULDER", K_GP_LEFT_SHOULDER}, {"RSHOULDER", K_GP_RIGHT_SHOULDER}, {"ABUTTON", K_GP_A}, @@ -341,14 +360,14 @@ keyname_t keynames[] = #endif /* Steam Controller */ - {"SC_LPADDLE", K_AUX12}, - {"SC_RPADDLE", K_AUX13}, + {"SC_LPADDLE", K_JOY16}, + {"SC_RPADDLE", K_JOY17}, {NULL, 0} }; #if defined(CSQC_DAT) || defined(MENU_DAT) -int MP_TranslateFTEtoQCCodes(int code); +int MP_TranslateFTEtoQCCodes(keynum_t code); void Key_PrintQCDefines(vfsfile_t *f, qboolean defines) { int i, j; @@ -3212,8 +3231,8 @@ void Key_Event (unsigned int devid, int key, unsigned int unicode, qboolean down case K_GP_DPAD_RIGHT: dc = "+moveright"; goto defaultedbind; case K_GP_GUIDE: dc = "togglemenu"; goto defaultedbind; - case K_GP_LEFT_THUMB: dc = "+movedown"; goto defaultedbind; - case K_GP_RIGHT_THUMB: + case K_GP_LEFT_STICK: dc = "+movedown"; goto defaultedbind; + case K_GP_RIGHT_STICK: default: break; } diff --git a/engine/client/keys.h b/engine/client/keys.h index ff79ae396..af3d5c1d0 100644 --- a/engine/client/keys.h +++ b/engine/client/keys.h @@ -39,197 +39,209 @@ enum // // these are the key numbers that should be passed to Key_Event // -enum { -K_TAB = 9, -K_ENTER = 13, -K_ESCAPE = 27, -K_SPACE = 32, +typedef enum { + K_TAB = 9, + K_ENTER = 13, + K_ESCAPE = 27, + K_SPACE = 32, -// normal keys should be passed as lowercased ascii - -K_BACKSPACE = 127, + // normal keys should be passed as lowercased ascii + K_BACKSPACE = 127, -K_SCRLCK, -K_CAPSLOCK, -K_POWER, -K_PAUSE, + K_SCRLCK, + K_CAPSLOCK, + K_POWER, + K_PAUSE, -K_UPARROW, -K_DOWNARROW, -K_LEFTARROW, -K_RIGHTARROW, + K_UPARROW, + K_DOWNARROW, + K_LEFTARROW, + K_RIGHTARROW, -K_LALT, -K_LCTRL, -K_LSHIFT, -K_INS, -K_DEL, -K_PGDN, -K_PGUP, -K_HOME, -K_END, + K_LALT, + K_LCTRL, + K_LSHIFT, + K_INS, + K_DEL, + K_PGDN, + K_PGUP, + K_HOME, + K_END, -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_F13, -K_F14, -K_F15, + 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_F13, + K_F14, + K_F15, -K_KP_HOME, -K_KP_UPARROW, -K_KP_PGUP, -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_KP_SLASH, -K_KP_MINUS, -K_KP_PLUS, -K_KP_NUMLOCK, -K_KP_STAR, -K_KP_EQUALS, + K_KP_HOME, + K_KP_UPARROW, + K_KP_PGUP, + 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_KP_SLASH, + K_KP_MINUS, + K_KP_PLUS, + K_KP_NUMLOCK, + K_KP_STAR, + K_KP_EQUALS, -// -// mouse buttons generate virtual keys -// -K_MOUSE1, -K_MOUSE2, -K_MOUSE3, -K_MOUSE4, -K_MOUSE5, -K_MOUSE6, -K_MOUSE7, -K_MOUSE8, -K_MOUSE9, -K_MOUSE10, + K_MOUSE1, + K_MOUSE2, + K_MOUSE3, + K_MOUSE4, + K_MOUSE5, -// JACK: Intellimouse(c) Mouse Wheel Support -K_MWHEELUP, -K_MWHEELDOWN, // 189 + K_MWHEELDOWN, + K_MWHEELUP, -K_GP_A = 190, -K_GP_B = 191, -K_GP_X = 192, -K_GP_Y = 193, -K_GP_LEFT_SHOULDER = 194, -K_GP_RIGHT_SHOULDER = 195, -K_GP_LEFT_TRIGGER = 196, -K_GP_RIGHT_TRIGGER = 197, -K_GP_BACK = 198, -K_GP_START = 199, -K_GP_LEFT_THUMB = 200, -K_GP_RIGHT_THUMB = 201, -K_GP_GUIDE = 202, + K_JOY1, + K_JOY2, + K_JOY3, + K_JOY4, + K_JOY5, + K_JOY6, + K_JOY7, + K_JOY8, + K_JOY9, + K_JOY10, + K_JOY11, + K_JOY12, + K_JOY13, + K_JOY14, + K_JOY15, + K_JOY16, + K_JOY17, + K_JOY18, + K_JOY19, + K_JOY20, + K_JOY21, + K_JOY22, + K_JOY23, + K_JOY24, + K_JOY25, + K_JOY26, + K_JOY27, + K_JOY28, + K_JOY29, + K_JOY30, + K_JOY31, + K_JOY32, -// -// joystick buttons -// -K_JOY1 = 203, -K_JOY2 = 204, -K_JOY3 = 205, -K_JOY4 = 206, + K_AUX1, + K_AUX2, + K_AUX3, + K_AUX4, + K_AUX5, + K_AUX6, + K_AUX7, + K_AUX8, + K_AUX9, + K_AUX10, + K_AUX11, + K_AUX12, + K_AUX13, + K_AUX14, + K_AUX15, + K_AUX16, -// -// aux keys are for multi-buttoned joysticks to generate so they can use -// the normal binding process -// -K_AUX1 = 207, -K_AUX2 = 208, -K_AUX3 = 209, -K_AUX4 = 210, -K_AUX5 = 211, -K_AUX6 = 212, -K_AUX7 = 213, -K_AUX8 = 214, -K_AUX9 = 215, -K_AUX10 = 216, -K_AUX11 = 217, -K_AUX12 = 218, -K_AUX13 = 219, -K_AUX14 = 220, -K_AUX15 = 221, -K_AUX16 = 222, -K_AUX17 = 223, -K_AUX18 = 224, -K_AUX19 = 225, -K_AUX20 = 226, -K_AUX21 = 227, -K_AUX22 = 228, -K_AUX23 = 229, -K_AUX24 = 230, -K_AUX25 = 231, -K_AUX26 = 232, -K_AUX27 = 233, -K_AUX28 = 234, -K_AUX29 = 235, -K_AUX30 = 236, -K_AUX31 = 237, -K_AUX32 = 238, + /* if you change the above order, you _will_ break Trinity! + * only make modifcations below, unless you want to start + * remapping keys for that too */ -K_LWIN = 239, -K_RWIN = 240, -K_APP = 241, -K_SEARCH = 242, -K_VOLUP = 243, -K_VOLDOWN = 244, -K_RALT = 245, -K_RCTRL = 246, -K_RSHIFT = 247, -K_PRINTSCREEN = 248, + /* Section dedicated to SDL controller definitions */ + K_GP_A, + K_GP_B, + K_GP_X, + K_GP_Y, + K_GP_BACK, + K_GP_GUIDE, + K_GP_START, + K_GP_LEFT_STICK, + K_GP_RIGHT_STICK, + K_GP_LEFT_SHOULDER, + K_GP_RIGHT_SHOULDER, + K_GP_DPAD_UP, + K_GP_DPAD_DOWN, + K_GP_DPAD_LEFT, + K_GP_DPAD_RIGHT, + K_GP_MISC1, /* share/mic-mute button */ + K_GP_PADDLE1, + K_GP_PADDLE2, + K_GP_PADDLE3, + K_GP_PADDLE4, + K_GP_TOUCHPAD, /* when pressed */ -//K_UNUSED = 249, -//K_UNUSED = 250, + /* emulated, we'll trigger these 'buttons' when we reach 50% pressed */ + K_GP_LEFT_TRIGGER, + K_GP_RIGHT_TRIGGER, + K_GP_LEFT_THUMB_UP, + K_GP_LEFT_THUMB_DOWN, + K_GP_LEFT_THUMB_LEFT, + K_GP_LEFT_THUMB_RIGHT, + K_GP_RIGHT_THUMB_UP, + K_GP_RIGHT_THUMB_DOWN, + K_GP_RIGHT_THUMB_LEFT, + K_GP_RIGHT_THUMB_RIGHT, + K_GP_UNKNOWN, -K_GP_DPAD_UP = 251, -K_GP_DPAD_DOWN = 252, -K_GP_DPAD_LEFT = 253, -K_GP_DPAD_RIGHT = 254, -K_GP_UNKNOWN = 255, + /* extra dinput mouse buttons */ + K_MOUSE6, + K_MOUSE7, + K_MOUSE8, + K_MOUSE9, + K_MOUSE10, -//axis->button emulation. for weird people. -K_GP_LEFT_THUMB_UP, -K_GP_LEFT_THUMB_DOWN, -K_GP_LEFT_THUMB_LEFT, -K_GP_LEFT_THUMB_RIGHT, -K_GP_RIGHT_THUMB_UP, -K_GP_RIGHT_THUMB_DOWN, -K_GP_RIGHT_THUMB_LEFT, -K_GP_RIGHT_THUMB_RIGHT, -K_JOY_UP, -K_JOY_DOWN, -K_JOY_LEFT, -K_JOY_RIGHT, + /* spare joystick button presses */ + K_JOY_UP, + K_JOY_DOWN, + K_JOY_LEFT, + K_JOY_RIGHT, -K_MM_BROWSER_BACK, -K_MM_BROWSER_FAVORITES, -K_MM_BROWSER_FORWARD, -K_MM_BROWSER_HOME, -K_MM_BROWSER_REFRESH, -K_MM_BROWSER_STOP, -K_MM_VOLUME_MUTE, -K_MM_TRACK_NEXT, -K_MM_TRACK_PREV, -K_MM_TRACK_STOP, -K_MM_TRACK_PLAYPAUSE, + /* extra keys */ + K_LWIN, + K_RWIN, + K_APP, + K_SEARCH, + K_VOLUP, + K_VOLDOWN, + K_RALT, + K_RCTRL, + K_RSHIFT, + K_PRINTSCREEN, -K_MAX -}; + /* multimedia keyboard */ + K_MM_BROWSER_BACK, + K_MM_BROWSER_FAVORITES, + K_MM_BROWSER_FORWARD, + K_MM_BROWSER_HOME, + K_MM_BROWSER_REFRESH, + K_MM_BROWSER_STOP, + K_MM_VOLUME_MUTE, + K_MM_TRACK_NEXT, + K_MM_TRACK_PREV, + K_MM_TRACK_STOP, + K_MM_TRACK_PLAYPAUSE, + K_MAX +} keynum_t; #define KEY_MODIFIER_SHIFT (1<<0) #define KEY_MODIFIER_ALT (1<<1) diff --git a/engine/client/pr_clcmd.c b/engine/client/pr_clcmd.c index 238df2ab3..fd1e1e091 100644 --- a/engine/client/pr_clcmd.c +++ b/engine/client/pr_clcmd.c @@ -11,11 +11,11 @@ int qcinput_scan; int qcinput_unicode; //QC key codes are based upon DP's keycode constants. This is on account of menu.dat coming first. -int MP_TranslateFTEtoQCCodes(int code) +int MP_TranslateFTEtoQCCodes(keynum_t code) { - switch(code) + safeswitch(code) { - case K_TAB: return 9; + case K_TAB: return 9; case K_ENTER: return 13; case K_ESCAPE: return 27; case K_SPACE: return 32; @@ -94,51 +94,51 @@ int MP_TranslateFTEtoQCCodes(int code) case K_JOY2: return 769; case K_JOY3: return 770; case K_JOY4: return 771; -// case K_JOY5: return 772; -// case K_JOY6: return 773; -// case K_JOY7: return 774; -// case K_JOY8: return 775; -// case K_JOY9: return 776; -// case K_JOY10: return 777; -// case K_JOY11: return 778; -// case K_JOY12: return 779; -// case K_JOY13: return 780; -// case K_JOY14: return 781; -// case K_JOY15: return 782; -// case K_JOY16: return 783; + case K_JOY5: return 772; + case K_JOY6: return 773; + case K_JOY7: return 774; + case K_JOY8: return 775; + case K_JOY9: return 776; + case K_JOY10: return 777; + case K_JOY11: return 778; + case K_JOY12: return 779; + case K_JOY13: return 780; + case K_JOY14: return 781; + case K_JOY15: return 782; + case K_JOY16: return 783; + case K_JOY17: return 784; + case K_JOY18: return 785; + case K_JOY19: return 786; + case K_JOY20: return 787; + case K_JOY21: return 788; + case K_JOY22: return 789; + case K_JOY23: return 790; + case K_JOY24: return 791; + case K_JOY25: return 792; + case K_JOY26: return 793; + case K_JOY27: return 794; + case K_JOY28: return 795; + case K_JOY29: return 796; + case K_JOY30: return 797; + case K_JOY31: return 798; + case K_JOY32: return 799; - case K_AUX1: return 784; - case K_AUX2: return 785; - case K_AUX3: return 786; - case K_AUX4: return 787; - case K_AUX5: return 788; - case K_AUX6: return 789; - case K_AUX7: return 790; - case K_AUX8: return 791; - case K_AUX9: return 792; - case K_AUX10: return 793; - case K_AUX11: return 794; - case K_AUX12: return 795; - case K_AUX13: return 796; - case K_AUX14: return 797; - case K_AUX15: return 798; - case K_AUX16: return 799; - case K_AUX17: return 800; - case K_AUX18: return 801; - case K_AUX19: return 802; - case K_AUX20: return 803; - case K_AUX21: return 804; - case K_AUX22: return 805; - case K_AUX23: return 806; - case K_AUX24: return 807; - case K_AUX25: return 808; - case K_AUX26: return 809; - case K_AUX27: return 810; - case K_AUX28: return 811; - case K_AUX29: return 812; - case K_AUX30: return 813; - case K_AUX31: return 814; - case K_AUX32: return 815; + case K_AUX1: return 800; + case K_AUX2: return 801; + case K_AUX3: return 802; + case K_AUX4: return 803; + case K_AUX5: return 804; + case K_AUX6: return 805; + case K_AUX7: return 806; + case K_AUX8: return 807; + case K_AUX9: return 808; + case K_AUX10: return 809; + case K_AUX11: return 810; + case K_AUX12: return 811; + case K_AUX13: return 812; + case K_AUX14: return 813; + case K_AUX15: return 814; + case K_AUX16: return 815; case K_GP_DPAD_UP: return 816; case K_GP_DPAD_DOWN: return 817; @@ -146,8 +146,8 @@ int MP_TranslateFTEtoQCCodes(int code) case K_GP_DPAD_RIGHT: return 819; case K_GP_START: return 820; case K_GP_BACK: return 821; - case K_GP_LEFT_THUMB: return 822; - case K_GP_RIGHT_THUMB: return 823; + case K_GP_LEFT_STICK: return 822; + case K_GP_RIGHT_STICK: return 823; case K_GP_LEFT_SHOULDER: return 824; case K_GP_RIGHT_SHOULDER: return 825; case K_GP_A: return 826; @@ -169,7 +169,26 @@ int MP_TranslateFTEtoQCCodes(int code) case K_JOY_LEFT: return 842; case K_JOY_RIGHT: return 843; - + case K_GP_MISC1: + case K_GP_PADDLE1: + case K_GP_PADDLE2: + case K_GP_PADDLE3: + case K_GP_PADDLE4: + case K_GP_TOUCHPAD: + case K_GP_GUIDE: + case K_GP_UNKNOWN: + case K_MM_BROWSER_FAVORITES: + case K_MM_BROWSER_FORWARD: + case K_MM_BROWSER_BACK: + case K_MM_BROWSER_HOME: + case K_MM_BROWSER_REFRESH: + case K_MM_BROWSER_STOP: + case K_MM_VOLUME_MUTE: + case K_MM_TRACK_NEXT: + case K_MM_TRACK_PREV: + case K_MM_TRACK_STOP: + case K_MAX: + case K_MM_TRACK_PLAYPAUSE: case K_F13: case K_F14: case K_F15: @@ -181,7 +200,7 @@ int MP_TranslateFTEtoQCCodes(int code) case K_APP: case K_SEARCH: return -code; - default: + safedefault: if (code == -1) //mod bug return code; if (code < 0) //negative values are 'qc-native' keys, for stuff that the api lacks. @@ -192,7 +211,7 @@ int MP_TranslateFTEtoQCCodes(int code) } } -int MP_TranslateQCtoFTECodes(int code) +keynum_t MP_TranslateQCtoFTECodes(int code) { switch(code) { @@ -272,51 +291,51 @@ int MP_TranslateQCtoFTECodes(int code) case 769: return K_JOY2; case 770: return K_JOY3; case 771: return K_JOY4; -// case 772: return K_JOY5; -// case 773: return K_JOY6; -// case 774: return K_JOY7; -// case 775: return K_JOY8; -// case 776: return K_JOY9; -// case 777: return K_JOY10; -// case 778: return K_JOY11; -// case 779: return K_JOY12; -// case 780: return K_JOY13; -// case 781: return K_JOY14; -// case 782: return K_JOY15; -// case 783: return K_JOY16; + case 772: return K_JOY5; + case 773: return K_JOY6; + case 774: return K_JOY7; + case 775: return K_JOY8; + case 776: return K_JOY9; + case 777: return K_JOY10; + case 778: return K_JOY11; + case 779: return K_JOY12; + case 780: return K_JOY13; + case 781: return K_JOY14; + case 782: return K_JOY15; + case 783: return K_JOY16; + case 784: return K_JOY17; + case 785: return K_JOY18; + case 786: return K_JOY19; + case 787: return K_JOY20; + case 788: return K_JOY21; + case 789: return K_JOY22; + case 790: return K_JOY23; + case 791: return K_JOY24; + case 792: return K_JOY25; + case 793: return K_JOY26; + case 794: return K_JOY27; + case 795: return K_JOY28; + case 796: return K_JOY29; + case 797: return K_JOY30; + case 798: return K_JOY31; + case 799: return K_JOY32; - case 784: return K_AUX1; - case 785: return K_AUX2; - case 786: return K_AUX3; - case 787: return K_AUX4; - case 788: return K_AUX5; - case 789: return K_AUX6; - case 790: return K_AUX7; - case 791: return K_AUX8; - case 792: return K_AUX9; - case 793: return K_AUX10; - case 794: return K_AUX11; - case 795: return K_AUX12; - case 796: return K_AUX13; - case 797: return K_AUX14; - case 798: return K_AUX15; - case 799: return K_AUX16; - case 800: return K_AUX17; - case 801: return K_AUX18; - case 802: return K_AUX19; - case 803: return K_AUX20; - case 804: return K_AUX21; - case 805: return K_AUX22; - case 806: return K_AUX23; - case 807: return K_AUX24; - case 808: return K_AUX25; - case 809: return K_AUX26; - case 810: return K_AUX27; - case 811: return K_AUX28; - case 812: return K_AUX29; - case 813: return K_AUX30; - case 814: return K_AUX31; - case 815: return K_AUX32; + case 800: return K_AUX1; + case 801: return K_AUX2; + case 802: return K_AUX3; + case 803: return K_AUX4; + case 804: return K_AUX5; + case 805: return K_AUX6; + case 806: return K_AUX7; + case 807: return K_AUX8; + case 808: return K_AUX9; + case 809: return K_AUX10; + case 810: return K_AUX11; + case 811: return K_AUX12; + case 812: return K_AUX13; + case 813: return K_AUX14; + case 814: return K_AUX15; + case 815: return K_AUX16; case 816: return K_GP_DPAD_UP; case 817: return K_GP_DPAD_DOWN; @@ -324,8 +343,8 @@ int MP_TranslateQCtoFTECodes(int code) case 819: return K_GP_DPAD_RIGHT; case 820: return K_GP_START; case 821: return K_GP_BACK; - case 822: return K_GP_LEFT_THUMB; - case 823: return K_GP_RIGHT_THUMB; + case 822: return K_GP_LEFT_STICK; + case 823: return K_GP_RIGHT_STICK; case 824: return K_GP_LEFT_SHOULDER; case 825: return K_GP_RIGHT_SHOULDER; case 826: return K_GP_A; diff --git a/engine/common/pr_common.h b/engine/common/pr_common.h index 1d86f9f88..4cfb9f616 100644 --- a/engine/common/pr_common.h +++ b/engine/common/pr_common.h @@ -85,8 +85,8 @@ extern cvar_t pr_gc_threaded; extern int qcinput_scan; extern int qcinput_unicode; -int MP_TranslateFTEtoQCCodes(int code); -int MP_TranslateQCtoFTECodes(int code); +int MP_TranslateFTEtoQCCodes(keynum_t code); +keynum_t MP_TranslateQCtoFTECodes(int code); qboolean WPhys_Push (world_t *w, wedict_t *pusher, vec3_t move, vec3_t amove); #ifdef ENGINE_ROUTING