From add8ea46e0ba95dfb2a819b7e7a9b08c6a8ffbac Mon Sep 17 00:00:00 2001 From: Alex Vanderveen Date: Wed, 12 Aug 2026 04:07:11 -0400 Subject: [PATCH] update overlay ui --- runtime/include/host_keymap.h | 5 +++++ runtime/src/host_keymap.c | 31 +++++++++++++++++++++++++++++++ runtime/src/psx_rewind.c | 11 ++++++++--- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/runtime/include/host_keymap.h b/runtime/include/host_keymap.h index 43015703..870d8351 100644 --- a/runtime/include/host_keymap.h +++ b/runtime/include/host_keymap.h @@ -1,6 +1,7 @@ #ifndef PSX_HOST_KEYMAP_H #define PSX_HOST_KEYMAP_H +#include #include #ifdef __cplusplus @@ -26,6 +27,10 @@ void host_keymap_load(const char *config_ini_path); /* 1 if (keycode, mod) matches a binding for `action`. */ int host_keymap_match(HostKeymapAction action, int keycode, int mod); +/* Format the primary bind for `action` into out (e.g. "F8", "Ctrl+R"). + * Returns out, or "F8" / "" on empty action. Always NUL-terminates. */ +const char *host_keymap_label(HostKeymapAction action, char *out, size_t cap); + #ifdef __cplusplus } #endif diff --git a/runtime/src/host_keymap.c b/runtime/src/host_keymap.c index 7c4e3693..de39d7f1 100644 --- a/runtime/src/host_keymap.c +++ b/runtime/src/host_keymap.c @@ -197,3 +197,34 @@ int host_keymap_match(HostKeymapAction action, int keycode, int mod) { } return 0; } + +const char *host_keymap_label(HostKeymapAction action, char *out, size_t cap) { + const HostKeyAction *a; + const HostKeyBind *b; + const char *keyname; + size_t n = 0; + if (!out || cap == 0) return ""; + out[0] = 0; + if (action < 0 || action >= HOST_KEYMAP_ACTION_COUNT) return out; + a = &s_actions[action]; + if (a->count <= 0) { + if (action == HOST_KEYMAP_REWIND) + snprintf(out, cap, "F8"); + return out; + } + b = &a->binds[0]; + if (b->mods & KMOD_CTRL) { + n += (size_t)snprintf(out + n, cap > n ? cap - n : 0, "Ctrl+"); + } + if (b->mods & KMOD_ALT) { + n += (size_t)snprintf(out + n, cap > n ? cap - n : 0, "Alt+"); + } + if (b->mods & KMOD_SHIFT) { + n += (size_t)snprintf(out + n, cap > n ? cap - n : 0, "Shift+"); + } + keyname = SDL_GetKeyName((SDL_Keycode)b->keycode); + if (!keyname || !keyname[0]) + keyname = "?"; + snprintf(out + n, cap > n ? cap - n : 0, "%s", keyname); + return out; +} diff --git a/runtime/src/psx_rewind.c b/runtime/src/psx_rewind.c index bdb2c771..8e7e8f4f 100644 --- a/runtime/src/psx_rewind.c +++ b/runtime/src/psx_rewind.c @@ -5,6 +5,7 @@ #include "boot_state.h" #include "cdrom.h" #include "gpu.h" +#include "host_keymap.h" #include "host_osd.h" #include "interrupts.h" #include "mdec.h" @@ -745,7 +746,8 @@ static void rasterize_panel(void) uint32_t *d = s_panel; int i, n, card_w, card_h, gap, x, y, sel_w, sel_h; int center_x, origin; - char buf[64]; + char buf[96]; + char hk[32]; for (i = 0; i < RW_PANEL_W * RW_PANEL_H; i++) d[i] = 0xE0101218u; @@ -759,8 +761,11 @@ static void rasterize_panel(void) } else { draw_text(d, RW_PANEL_W, 120, 8, "NO SNAPSHOTS YET", 0xFF888888u); } - draw_text(d, RW_PANEL_W, 12, RW_PANEL_H - 16, - "LEFT/RIGHT A LOAD B CLOSE F8", 0xFFAAAAAAu); + host_keymap_label(HOST_KEYMAP_REWIND, hk, sizeof(hk)); + /* Overlay font is uppercase-only; keep PS labels dual for pad + KB users. */ + snprintf(buf, sizeof(buf), + "LEFT/RIGHT A / CROSS LOAD B / CIRCLE CLOSE %s", hk); + draw_text(d, RW_PANEL_W, 12, RW_PANEL_H - 16, buf, 0xFFAAAAAAu); n = (int)s_count; if (n <= 0) {