Skip to content

Commit

Permalink
Clear key bindings with controller Y button
Browse files Browse the repository at this point in the history
and show an appropriate hint at the top of the menu if a controller is active
  • Loading branch information
andrei-drexler committed Dec 30, 2023
1 parent a8be9b1 commit 2052868
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Quake/in_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ void IN_ShutdownJoystick (void)
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
}

qboolean IN_HasGamepad (void)
{
return joy_active_controller != NULL;
}

void IN_GyroActionDown (void)
{
switch ((int)gyro_mode.value)
Expand Down
1 change: 1 addition & 0 deletions Quake/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ qboolean IN_HasGyro (void);
void IN_StartGyroCalibration (void);
qboolean IN_IsCalibratingGyro (void);

qboolean IN_HasGamepad (void);

void IN_SendKeyEvents (void);
// used as a callback for Sys_SendKeyEvents() by some drivers
Expand Down
8 changes: 7 additions & 1 deletion Quake/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -4553,7 +4553,12 @@ void M_Keys_Draw (void)
if (bind_grab)
M_Print (12, y + 32, "Press a key or button for this action");
else
M_Print (18, y + 32, "Enter to change, backspace to clear");
{
const char *msg = IN_HasGamepad () ?
"Enter/A to change, backspace/Y to clear" :
"Enter to change, backspace to clear";
M_PrintAligned (160, y + 32, ALIGN_CENTER, msg);
}

y += KEYLIST_OFS;

Expand Down Expand Up @@ -4678,6 +4683,7 @@ void M_Keys_Key (int k)
break;
/* fall-through */
case K_DEL:
case K_YBUTTON:
M_ThrottledSound ("misc/menu2.wav");
M_UnbindCommand (bindnames[keysmenu.list.cursor][0]);
break;
Expand Down

0 comments on commit 2052868

Please sign in to comment.