host_keymap: hide labels for explicit unbinds

This commit is contained in:
Matthew Stanley
2026-09-04 23:32:45 -07:00
parent df3bc1bc2b
commit 08ec6fc84a
2 changed files with 23 additions and 0 deletions
+2
View File
@@ -314,6 +314,8 @@ const char *host_keymap_label(HostKeymapAction action, char *out, size_t cap) {
if (action < 0 || action >= HOST_KEYMAP_ACTION_COUNT) return out;
a = &s_actions[action];
if (a->count <= 0) {
if (a->explicit_unbound)
return out;
#if defined(PSX_HAS_RBENGINE_SNAP)
if (action == HOST_KEYMAP_REWIND)
snprintf(out, cap, "F8");
+21
View File
@@ -18,6 +18,7 @@ static int mod_alt(void) { return (int)KMOD_ALT; }
int main(int argc, char **argv) {
uint8_t keys[SDL_NUM_SCANCODES];
char label[32];
const char *cfg = "host_keymap_test.ini";
FILE *f;
(void)argc;
@@ -86,6 +87,26 @@ int main(int argc, char **argv) {
(int)SDL_SCANCODE_F10, 0),
"display perf rebind accepts the F10 scancode");
f = fopen(cfg, "wb");
check(f != NULL, "create temporary explicit-unbind config.ini");
if (!f) return 1;
fputs("[KeyMap]\n"
"SaveStateMenu = None\n",
f);
fclose(f);
host_keymap_load(cfg);
check(!host_keymap_match_event(HOST_KEYMAP_SAVE_STATE_MENU,
(int)SDLK_UNKNOWN,
(int)SDL_SCANCODE_F7, 0),
"explicit save-state-menu unbind disables F7");
check(host_keymap_label(HOST_KEYMAP_SAVE_STATE_MENU, label,
sizeof(label))[0] == 0,
"explicit save-state-menu unbind has no fallback label");
check(host_keymap_match(HOST_KEYMAP_FULLSCREEN, (int)SDLK_RETURN,
mod_alt()),
"missing fullscreen line still keeps default after explicit unbind");
remove(cfg);
if (failures) {
fprintf(stderr, "host_keymap_test: %d failure(s)\n", failures);