mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-28 10:59:16 -04:00
update overlay ui
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#ifndef PSX_HOST_KEYMAP_H
|
||||
#define PSX_HOST_KEYMAP_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user