Merge remote-tracking branch 'origin/dev' into ptbr-menu-catalog

# Conflicts:
#	runtime/ov_probe.c
This commit is contained in:
Lucas-blip-png committed 2026-10-31 09:40:37 -04:00
commit 902ea50f14
144 files changed
+9871 -4842

No files matched your search

+17 -12
View File
@@ -1,6 +1,6 @@
// The in-game menu core: Dear ImGui state, the event queue the window adapter fills, gamepad navigation, the Vulkan back
// end on our device and the menu's pages. Free of any window system (menu.h). ImGui runs on the present path only,
// under gfx_window.c's present lock; the event functions only queue.
// under gfx_present.c's present lock; the event functions only queue.
//
// The Vulkan set-up follows LAS Recomp's runtime/nvn/vulkan/imgui_glue.cpp (https://github.com/peiikai/LASRecomp @
// da35b83a9611d046a9a681aae668d7085954d37f, MIT, Copyright (c) 2026 Peiikai): dynamic rendering into the swapchain
@@ -241,7 +241,7 @@ static int vk_up(const MenuTarget *t) {
ii.Queue = t->queue;
ii.DescriptorPoolSize = 16;
ii.MinImageCount = 2;
ii.ImageCount = 4; // vertex buffers rotate per recorded frame: more than gfx_window.c's 2 frames in flight
ii.ImageCount = 4; // vertex buffers rotate per recorded frame: more than gfx_present.c's 2 frames in flight
ii.MSAASamples = VK_SAMPLE_COUNT_1_BIT;
ii.UseDynamicRendering = true;
g_vk_fmt = t->format;
@@ -417,12 +417,14 @@ static void row_window_size(void) {
opt_choice_list("TOTK_WINDOW_SIZE", UI_MENU_WINDOW_SIZE, pv, pn, n, UI_MENU_WINDOW_SIZE_DESC);
}
// The game resolution (resolution.c): 16:9 sizes from its smallest, 1280x720 (for weak GPUs), up, the common 21:9
// monitor sizes (the camera and the HUD follow a wider shape, resolution.c res_init), and the current value when it is
// another size.
// The game resolution (resolution.c): 16:9 sizes from its smallest, 1280x720 (for weak GPUs), up, the common 21:9 and
// 32:9 monitor sizes and the 16:10 screens of the Steam Deck, handhelds and laptops (the camera and the HUD follow
// another shape, resolution.c res_init; the installer lays the HUD out for each, installer/steps.py ASPECT_SIZES), and
// the current value when it is another size.
static void row_output_res(void) {
static const char *const vals[] = {"1280x720", "1600x900", "1920x1080", "2560x1440", "3200x1800", "3840x2160",
"2560x1080", "3440x1440", "3840x1600", "5120x2160"};
"2560x1080", "3440x1440", "3840x1600", "5120x2160", "3840x1080", "5120x1440",
"1280x800", "1680x1050", "1920x1200", "2560x1600"};
enum { N = sizeof vals / sizeof *vals };
char shown[N][32];
const char *names[N];
@@ -486,9 +488,10 @@ static void row_game_lang(void) {
// The frame limit (frame_rate.c): unset, the older fps60 = 0 still means 30. The monitor choice shows the rate it gives.
static void row_fps_limit() {
static const char *const vals[] = {"30", "60", "90", "120", "144", "display"};
static const UiTextId ids[] = {UI_MENU_FPS_30, UI_MENU_FPS_60, UI_MENU_FPS_90, UI_MENU_FPS_120, UI_MENU_FPS_144,
UI_MENU_FPS_DISPLAY};
// 40 and 45: the Steam Deck's screen runs at 40 to 60 Hz (the OLED to 90); 40 divides 40 and 120 Hz evenly
static const char *const vals[] = {"30", "40", "45", "60", "90", "120", "144", "display"};
static const UiTextId ids[] = {UI_MENU_FPS_30, UI_MENU_FPS_40, UI_MENU_FPS_45, UI_MENU_FPS_60,
UI_MENU_FPS_90, UI_MENU_FPS_120, UI_MENU_FPS_144, UI_MENU_FPS_DISPLAY};
enum { N = sizeof vals / sizeof *vals };
const char *names[N];
for (int i = 0; i < N; i++) names[i] = menu_text(ids[i]);
@@ -553,6 +556,7 @@ static void tab_game(float scale) {
row_game_lang();
static const UiTextId mode[] = {UI_MENU_MODE_DOCKED, UI_MENU_MODE_HANDHELD};
opt_choice("TOTK_OPERATION_MODE", UI_MENU_OPERATION_MODE, mode, 2, UI_MENU_OPERATION_MODE_DESC);
opt_toggle("TOTK_ASSUME_FOCUS", UI_MENU_ASSUME_FOCUS, UI_MENU_ASSUME_FOCUS_DESC);
opt_end();
}
@@ -567,7 +571,7 @@ static void tab_sound(float scale) {
// romfs-patches-xbox, "prompts change after restart" while the prompts in use differ from the choice. Automatic with a
// gamepad connected: "in use: Xbox". NULL otherwise.
static const char *pad_layout_note(void) {
bool want = !_stricmp(cfg_value("TOTK_PAD_LAYOUT"), "xbox_prompts");
bool want = !strcasecmp(cfg_value("TOTK_PAD_LAYOUT"), "xbox_prompts");
if (want && !romfs_xbox_prompts_ready()) return menu_text(UI_MENU_PAD_LAYOUT_PROMPTS_MISSING);
if (want != (romfs_xbox_prompts_active() != 0)) return menu_text(UI_MENU_PAD_LAYOUT_PROMPTS_RESTART);
int got = input_pad_layout();
@@ -705,6 +709,7 @@ static void tab_advanced(float scale) {
opt_toggle("TOTK_VK_VALIDATION", UI_MENU_VK_VALIDATION, UI_MENU_VK_VALIDATION_DESC);
static const UiTextId dyn[] = {UI_MENU_AUTO, UI_MENU_OFF, UI_MENU_ON}; // unset, 0, 1
opt_choice("TOTK_VK_DYN_VERTEX", UI_MENU_VK_DYN_VERTEX, dyn, 3, UI_MENU_VK_DYN_VERTEX_DESC);
opt_choice("TOTK_VK_DYN_A2C", UI_MENU_VK_DYN_A2C, dyn, 3, UI_MENU_VK_DYN_A2C_DESC);
opt_toggle("TOTK_VK_SUBGROUP_PIN", UI_MENU_VK_SUBGROUP_PIN, UI_MENU_VK_SUBGROUP_PIN_DESC);
opt_group(UI_MENU_GROUP_DIAG);
@@ -714,7 +719,7 @@ static void tab_advanced(float scale) {
static char rec_path[600]; // the recording goes beside the log
if (!rec_path[0]) {
char dir[512];
snprintf(rec_path, sizeof rec_path, "%s\\input-record.txt", sysinfo_log_folder(dir, sizeof dir) ? dir : ".");
snprintf(rec_path, sizeof rec_path, "%s/input-record.txt", sysinfo_log_folder(dir, sizeof dir) ? dir : ".");
}
row_set_or_not("TOTK_INPUT_RECORD", UI_MENU_INPUT_RECORD, UI_MENU_INPUT_RECORD_DESC, rec_path);
if (opt_button("##open_log", UI_MENU_OPEN_LOG, UI_MENU_OPEN_LOG_DESC, action_value(log_note, UI_MENU_OPEN_LOG))) {
@@ -959,7 +964,7 @@ static void perf_label(UiTextId label, const ImVec4 &c) {
static float perf_gb(float mb) { return mb < 0 ? -1 : mb / 1024; }
// The picture lines: the window, the game image the present shows and the 3D scene it holds (resolution.c), how the
// present scales the image to the window (gfx_window.c, the last present), the frame limit and the presentation mode
// present scales the image to the window (gfx_present.c, the last present), the frame limit and the presentation mode
// in use.
static void perf_picture(const MenuTarget *t, const ImVec4 &c) {
unsigned out[2], scene[2];
+4 -4
View File
@@ -1,6 +1,6 @@
// The in-game menu (ui/menu.cpp, Dear ImGui) and its seams to the platform side: the window and its input (ui/menu_win.cpp
// on Windows; an SDL3 window gets its own adapter later), the gamepad (input_pad_read, input.h) and the present path
// (gfx_window.c). The menu core calls no window system: events come in through menu_event_*, the drawing happens in the
// on Windows, ui/menu_sdl.cpp with SDL), the gamepad (input_pad_read, input.h) and the present path
// (gfx_present.c). The menu core calls no window system: events come in through menu_event_*, the drawing happens in the
// present path's command buffer.
//
// F1 or Esc on the keyboard and Minus and Plus held together (consumed in poll_merged, input_menu_gate in input.h) open it;
@@ -34,7 +34,7 @@ void menu_event_mouse_button(int button, int down); // 0 left, 1 right, 2 midd
void menu_event_wheel(float dx, float dy);
void menu_event_focus(int focused);
// ---- the overlay, drawn into the swapchain image after the game image (gfx_window.c, present lock held)
// ---- the overlay, drawn into the swapchain image after the game image (gfx_present.c, present lock held)
typedef struct {
VkInstance instance;
VkPhysicalDevice phys;
@@ -54,7 +54,7 @@ int menu_overlay_frame(uint64_t frame, const MenuTarget *t, const char **shot);
void menu_overlay_draw(VkCommandBuffer cb);
void menu_vk_release(void); // before the device goes away (gfx_window_release_vk)
// ---- what the menu asks of the platform side (gfx_window.c)
// ---- what the menu asks of the platform side (gfx_window_win.c, gfx_window_sdl.c)
void gfx_window_apply_settings(void); // TOTK_FULLSCREEN or TOTK_WINDOW_SIZE changed: the window follows
void gfx_window_request_close(void); // as the window's close button: the process ends
int gfx_window_monitor_size(int *w, int *h); // pixels of the monitor the window is on; 0 when unknown
+82
View File
@@ -0,0 +1,82 @@
// SDL3 adapter of the in-game menu: the window's events to menu events (menu.h), as ui/menu_win.cpp does for Win32.
// Window thread (gfx_window_sdl.c's event loop, after input_sdl_event).
//
// F1 opens and closes the menu, Esc opens it (with the menu open, Esc goes to the menu, which closes). Esc also releases
// the cursor (input_sdl.c sees the event first; closing the menu gives the capture back). While the menu is open, its
// keys, the mouse and focus changes go to it; the game reads the keyboard through input_sdl.c and gets nothing while
// the menu is open (input_menu). Mouse positions come in window units and go to the menu in pixels.
#include <SDL3/SDL.h>
#include "imgui.h"
extern "C" {
#include "input.h"
#include "input_sdl.h"
#include "ui/menu.h"
}
static ImGuiKey key_of(SDL_Scancode sc) {
switch (sc) {
case SDL_SCANCODE_UP: return ImGuiKey_UpArrow;
case SDL_SCANCODE_DOWN: return ImGuiKey_DownArrow;
case SDL_SCANCODE_LEFT: return ImGuiKey_LeftArrow;
case SDL_SCANCODE_RIGHT: return ImGuiKey_RightArrow;
case SDL_SCANCODE_RETURN: case SDL_SCANCODE_KP_ENTER: return ImGuiKey_Enter;
case SDL_SCANCODE_SPACE: return ImGuiKey_Space;
case SDL_SCANCODE_ESCAPE: return ImGuiKey_Escape;
case SDL_SCANCODE_TAB: return ImGuiKey_Tab;
case SDL_SCANCODE_BACKSPACE: return ImGuiKey_Backspace;
case SDL_SCANCODE_DELETE: return ImGuiKey_Delete; // clears a cell of the remapping rows
case SDL_SCANCODE_HOME: return ImGuiKey_Home;
case SDL_SCANCODE_END: return ImGuiKey_End;
case SDL_SCANCODE_PAGEUP: return ImGuiKey_PageUp;
case SDL_SCANCODE_PAGEDOWN: return ImGuiKey_PageDown;
case SDL_SCANCODE_LSHIFT: case SDL_SCANCODE_RSHIFT: return ImGuiKey_LeftShift;
case SDL_SCANCODE_LCTRL: case SDL_SCANCODE_RCTRL: return ImGuiKey_LeftCtrl;
case SDL_SCANCODE_Q: return ImGuiKey_Q; // previous tab
case SDL_SCANCODE_E: return ImGuiKey_E; // next tab
default: return ImGuiKey_None;
}
}
extern "C" void menu_sdl_event(const SDL_Event *e) {
float d = (float)gfx_window_sdl_density();
switch (e->type) {
case SDL_EVENT_KEY_DOWN:
// Esc with the menu open (opened by F1 too) is not a toggle here: it goes to the menu, which closes itself
if (!e->key.repeat && (e->key.scancode == SDL_SCANCODE_F1 ||
(e->key.scancode == SDL_SCANCODE_ESCAPE && !menu_is_open()))) {
menu_toggle();
return;
}
if (e->key.scancode == SDL_SCANCODE_F10) {
if (!e->key.repeat) menu_perf_cycle();
return;
}
[[fallthrough]];
case SDL_EVENT_KEY_UP:
if (!menu_is_open()) return;
if (ImGuiKey k = key_of(e->key.scancode)) menu_event_key(k, e->type == SDL_EVENT_KEY_DOWN);
return;
case SDL_EVENT_MOUSE_MOTION:
if (menu_is_open()) menu_event_mouse_pos(e->motion.x * d, e->motion.y * d);
return;
case SDL_EVENT_MOUSE_BUTTON_DOWN:
case SDL_EVENT_MOUSE_BUTTON_UP: {
if (!menu_is_open()) return;
int b = e->button.button == SDL_BUTTON_LEFT ? 0 : e->button.button == SDL_BUTTON_RIGHT ? 1
: e->button.button == SDL_BUTTON_MIDDLE ? 2 : -1;
if (b < 0) return;
menu_event_mouse_pos(e->button.x * d, e->button.y * d);
menu_event_mouse_button(b, e->type == SDL_EVENT_MOUSE_BUTTON_DOWN);
return;
}
case SDL_EVENT_MOUSE_WHEEL:
if (menu_is_open()) menu_event_wheel(e->wheel.x, e->wheel.y);
return;
case SDL_EVENT_WINDOW_FOCUS_GAINED:
case SDL_EVENT_WINDOW_FOCUS_LOST:
menu_event_focus(e->type == SDL_EVENT_WINDOW_FOCUS_GAINED);
return;
}
}
+3 -2
View File
@@ -1,5 +1,5 @@
// Win32 adapter of the in-game menu: window messages to menu events (menu.h). The only Win32 code of the menu; an SDL3
// window gets its own adapter later. Window thread.
// Win32 adapter of the in-game menu: window messages to menu events (menu.h). The only Win32 code of the menu; the SDL3
// window has its own (ui/menu_sdl.cpp). Window thread.
//
// F1 opens and closes the menu, Esc opens it (with the menu open, Esc goes to the menu, which closes). Esc also releases
// the cursor (input_window_msg runs first; closing the menu gives the capture back). While the menu is open, its keys,
@@ -12,6 +12,7 @@
extern "C" {
#include "input.h"
#include "input_win.h"
#include "ui/menu.h"
}
+1 -1
View File
@@ -36,7 +36,7 @@ static bool g_disable_next; // opt_disable_next: the next row is gr
static UiTextId g_disable_note;
// The description pane: this frame's hovered and selected rows, the page's first row, and the last one shown.
struct Desc { char text[512]; };
struct Desc { char text[UI_DESC_BYTES]; };
static Desc g_hover, g_focus, g_first, g_shown;
// disabled: the note of a row opt_disable_next greyed out, else NULL.