Skip to content

Commit

Permalink
Use separate bindings for dpad buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-drexler committed Dec 30, 2023
1 parent efe242b commit 28b3004
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Quake/in_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,8 @@ IN_KeyForControllerButton
*/
static int IN_KeyForControllerButton(SDL_GameControllerButton button)
{
qboolean remap_dpad = (key_dest != key_game && !M_KeyBinding ());

switch (button)
{
case SDL_CONTROLLER_BUTTON_A: return K_ABUTTON;
Expand All @@ -609,10 +611,10 @@ static int IN_KeyForControllerButton(SDL_GameControllerButton button)
case SDL_CONTROLLER_BUTTON_RIGHTSTICK: return K_RTHUMB;
case SDL_CONTROLLER_BUTTON_LEFTSHOULDER: return K_LSHOULDER;
case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER: return K_RSHOULDER;
case SDL_CONTROLLER_BUTTON_DPAD_UP: return K_UPARROW;
case SDL_CONTROLLER_BUTTON_DPAD_DOWN: return K_DOWNARROW;
case SDL_CONTROLLER_BUTTON_DPAD_LEFT: return K_LEFTARROW;
case SDL_CONTROLLER_BUTTON_DPAD_RIGHT: return K_RIGHTARROW;
case SDL_CONTROLLER_BUTTON_DPAD_UP: return remap_dpad ? K_UPARROW : K_DPAD_UP;
case SDL_CONTROLLER_BUTTON_DPAD_DOWN: return remap_dpad ? K_DOWNARROW : K_DPAD_DOWN;
case SDL_CONTROLLER_BUTTON_DPAD_LEFT: return remap_dpad ? K_LEFTARROW : K_DPAD_LEFT;
case SDL_CONTROLLER_BUTTON_DPAD_RIGHT: return remap_dpad ? K_RIGHTARROW : K_DPAD_RIGHT;
case SDL_CONTROLLER_BUTTON_MISC1: return K_MISC1;
case SDL_CONTROLLER_BUTTON_PADDLE1: return K_PADDLE1;
case SDL_CONTROLLER_BUTTON_PADDLE2: return K_PADDLE2;
Expand Down
4 changes: 4 additions & 0 deletions Quake/keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ static const keyname_t keynames[] =
{"RTHUMB", K_RTHUMB},
{"LSHOULDER", K_LSHOULDER},
{"RSHOULDER", K_RSHOULDER},
{"DPAD_UP", K_DPAD_UP},
{"DPAD_DOWN", K_DPAD_DOWN},
{"DPAD_LEFT", K_DPAD_LEFT},
{"DPAD_RIGHT", K_DPAD_RIGHT},
{"ABUTTON", K_ABUTTON},
{"BBUTTON", K_BBUTTON},
{"XBUTTON", K_XBUTTON},
Expand Down
4 changes: 4 additions & 0 deletions Quake/keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ typedef enum keycode_t
K_RTHUMB,
K_LSHOULDER,
K_RSHOULDER,
K_DPAD_UP,
K_DPAD_DOWN,
K_DPAD_LEFT,
K_DPAD_RIGHT,
K_ABUTTON,
K_BBUTTON,
K_XBUTTON,
Expand Down

0 comments on commit 28b3004

Please sign in to comment.