From bc9751faa5068b35d34a8a6fcef3290261fc6de8 Mon Sep 17 00:00:00 2001 From: Nati Date: Sun, 15 Nov 2026 01:38:26 +0800 Subject: [PATCH] save simple button mappings per port The F10 bar's simple mapping UI persisted one shared [controller] binding set: rebinding on any port overwrote it, and the next launch applied the last writer's layout to every port (issue #404). The expression system (expr__) was already per-port; the simple mapping path now matches it. Bindings now persist as [controller] "_" (a_1 .. right_4). Every write site (rebind capture, threshold slider, GameCube restore, layout presets) saves the port it edits, and ApplyConfiguredMappings reads the port's own binding first. The old shared keys stay as the fallback for ports never rebound, so existing configs keep behaving exactly as before until a port is individually reconfigured. Fixes #404 --- runtime/include/runtime_config.h | 52 ++++++++++++++++++++++++++ runtime/src/settings_overlay.cpp | 27 +++++++------ runtime/tests/runtime_config_tests.cpp | 28 ++++++++++++++ 3 files changed, 96 insertions(+), 11 deletions(-) diff --git a/runtime/include/runtime_config.h b/runtime/include/runtime_config.h index ea5a12b94..939c4c40d 100644 --- a/runtime/include/runtime_config.h +++ b/runtime/include/runtime_config.h @@ -90,6 +90,10 @@ struct RuntimeUserConfig { // comma-separated SDL-style physical button names ("south", or // "dpad_up,left_shoulder") as values; pressing either bound button counts. std::array, 12> controllerButtons; + // Per-port overrides of controllerButtons ("a_1" .. "right_4", the suffix is port + 1). + // A port falls back to the shared controllerButtons entry while its override is unset, so + // configs written before per-port bindings keep applying to every port unchanged. + std::array, 12>, 4> controllerPortButtons; std::optional rumbleEnabled; // Shake a motion controller to press the D-pad, like shaking a Wii Remote. std::optional motionTrick; @@ -413,6 +417,21 @@ inline RuntimeUserConfig ParseConfigDocument(const toml::value& document) { for (const auto& [key, value] : section->as_table()) { if (key.rfind("expr_", 0) == 0 && value.is_string()) { config.controllerExpressions[key] = value.as_string(); + continue; + } + // "