Skip to content

Commit

Permalink
Show gamepad buttons on help screen
Browse files Browse the repository at this point in the history
  • Loading branch information
fragglet committed Dec 2, 2024
1 parent 39f97eb commit b3208ca
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/sdl/controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,9 @@ bool Vid_HaveController(void)
{
return controller != NULL;
}

const char *Vid_ControllerButtonName(enum gamekey key)
{
return SDL_GameControllerGetStringForButton(
controller_bindings[key]);
}
9 changes: 9 additions & 0 deletions src/swgrpha.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,21 @@ static void PrintHelp(void)
swcolor(2);
swposcur(1, 2);
swputs("BEGINNER'S HELP");
if (Vid_HaveController()) {
swposcur(21, 2);
swputs("GAMEPAD CONTROLS:");
}

swcolor(3);
for (i = 0; i < arrlen(items); i++) {
snprintf(buf, sizeof(buf), "%-11s- %s",
items[i].name, Vid_KeyName(keybindings[items[i].key]));
swposcur(1, i + 3);
swputs(buf);
if (Vid_HaveController()) {
swposcur(21, i + 3);
swputs(Vid_ControllerButtonName(items[i].key));
}
}
snprintf(buf, sizeof(buf), "%-11s- %s", "Restart", "Ctrl-R");
swposcur(1, i + 3);
Expand Down
1 change: 1 addition & 0 deletions src/video.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,6 @@ extern void Vid_ShowTouchKeys(const char *keys);

enum menukey Vid_ControllerMenuKey(void);
bool Vid_HaveController(void);
const char *Vid_ControllerButtonName(enum gamekey key);

#endif

0 comments on commit b3208ca

Please sign in to comment.