feat(pad): reload the input mapping at runtime, with a file watch and pad chords #17500

Closed
MarcZX10 wants to merge 29 commits from upstream-pr/17500 into main
MarcZX10 commented 2026-11-08 20:06:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-08T20:06:38Z.


What

Pad and keyboard input mapping can change while the title runs, without a restart:

  • ReloadInputMapping (F1 by default, or a PAD: chord) reads anyps5-input.ini and the title's profile again. The new file is read completely before anything changes; if it has an error, the current mapping stays and the error names the file, the line and the reason.
  • ANYPS5_INPUT_WATCH=1 checks the modification time and size of the file and the profile about once a second on a background thread, and reloads only after a change has stayed the same for one check.
  • PAD: chords trigger emulator actions from controller buttons held together. Their buttons still reach the title's pad state.

The three parts share the mapping snapshot store and the input thread, which is why they are one PR.

Commits: mapping snapshot store and its swap on the input thread; text parser with file and line errors; the reload action and its default key; the file stamp and change debounce with the watch flag; pad chord parsing and dispatch; docs per commit.

Test fix: reloadErrorNamesLine assumed that the default table binds Cross once, so crossOnKey could never hold on the default configuration (Cross is bound to RETURN and SPACE). The test now takes a copy before the failed reload and requires the whole configuration to be unchanged, field by field.

Tested

Linux, Debian kernel 6.1.0-54-amd64, Intel Xeon E5-1620 v2. Pad tests do not need a display.

Command:

flock <build lock> env VERIFY_DIR=<worktree> VERIFY_TAG=inputfix5 ANYPS5_REQUIRE_DISPLAY=1 bash <main checkout>/.git/info/tools/run_tests.sh '^(pad_input_mapping|pad_keyboard_mouse)$' pad_input_mapping_tests pad_keyboard_mouse_tests

Output:

BUILD-EXIT 0
1/2 Test #3866: pad_input_mapping ................   Passed    0.02 sec
2/2 Test #3872: pad_keyboard_mouse ...............   Passed    0.02 sec
100% tests passed, 0 tests failed out of 2

Not verified:

  • Real controllers and real window focus. The unit tests cover chord parsing and chord requests and the reload action; no physical pad was used.
  • The file watch with editors that save by rename, and with a rewrite that keeps both modification time and size. The watch compares only those two; the debt file lists it.
  • Windows and macOS. Nothing was run there.
  • The known gaps listed in the debt file: chord buttons still reach the pad state, chords are not dispatched while the IME or a modal dialog captures input, and window hotkeys never reach the game's pad except through a chord.

Overlap: no open PR implements the reload, the file watch or the pad chords. #17149 (WHEEL:Left and WHEEL:Right) adds a wheelTilt field to InputBinding and changes the same wheel parser, duplicate check and wheel event handling in InputMapping.cpp, InputMapping.hpp and KeyboardMouse.cpp. The two will conflict. Whichever merges second must also compare wheelTilt in sameBinding in the new test; this PR does not, because that field does not exist here yet.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: none; no GPU used by these tests
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5214682662 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17500). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-08T20:06:38Z. --- ### What Pad and keyboard input mapping can change while the title runs, without a restart: - `ReloadInputMapping` (F1 by default, or a `PAD:` chord) reads `anyps5-input.ini` and the title's profile again. The new file is read completely before anything changes; if it has an error, the current mapping stays and the error names the file, the line and the reason. - `ANYPS5_INPUT_WATCH=1` checks the modification time and size of the file and the profile about once a second on a background thread, and reloads only after a change has stayed the same for one check. - `PAD:` chords trigger emulator actions from controller buttons held together. Their buttons still reach the title's pad state. The three parts share the mapping snapshot store and the input thread, which is why they are one PR. Commits: mapping snapshot store and its swap on the input thread; text parser with file and line errors; the reload action and its default key; the file stamp and change debounce with the watch flag; pad chord parsing and dispatch; docs per commit. Test fix: `reloadErrorNamesLine` assumed that the default table binds Cross once, so `crossOnKey` could never hold on the default configuration (Cross is bound to RETURN and SPACE). The test now takes a copy before the failed reload and requires the whole configuration to be unchanged, field by field. ### Tested Linux, Debian kernel 6.1.0-54-amd64, Intel Xeon E5-1620 v2. Pad tests do not need a display. Command: ``` flock <build lock> env VERIFY_DIR=<worktree> VERIFY_TAG=inputfix5 ANYPS5_REQUIRE_DISPLAY=1 bash <main checkout>/.git/info/tools/run_tests.sh '^(pad_input_mapping|pad_keyboard_mouse)$' pad_input_mapping_tests pad_keyboard_mouse_tests ``` Output: ``` BUILD-EXIT 0 1/2 Test #3866: pad_input_mapping ................ Passed 0.02 sec 2/2 Test #3872: pad_keyboard_mouse ............... Passed 0.02 sec 100% tests passed, 0 tests failed out of 2 ``` Not verified: - Real controllers and real window focus. The unit tests cover chord parsing and chord requests and the reload action; no physical pad was used. - The file watch with editors that save by rename, and with a rewrite that keeps both modification time and size. The watch compares only those two; the debt file lists it. - Windows and macOS. Nothing was run there. - The known gaps listed in the debt file: chord buttons still reach the pad state, chords are not dispatched while the IME or a modal dialog captures input, and window hotkeys never reach the game's pad except through a chord. Overlap: no open PR implements the reload, the file watch or the pad chords. #17149 (`WHEEL:Left` and `WHEEL:Right`) adds a `wheelTilt` field to `InputBinding` and changes the same wheel parser, duplicate check and wheel event handling in `InputMapping.cpp`, `InputMapping.hpp` and `KeyboardMouse.cpp`. The two will conflict. Whichever merges second must also compare `wheelTilt` in `sameBinding` in the new test; this PR does not, because that field does not exist here yet. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: none; no GPU used by these tests - [x] AI-assisted: yes

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!17500
No description provided.