feat(libScePad): read per-title input profiles beside the shared input file #7499

Merged
AlxcBTW merged 4 commits from upstream-pr/7499 into main 2026-11-04 19:20:12 +00:00
AlxcBTW commented 2026-10-18 09:35:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-18T09:35:55Z.


What

anyps5-input.ini (or the file ANYPS5_INPUT_CONFIG names) applies to every title. Mouse sensitivity, curve and bindings that suit one title do not suit the next, and the only way to switch is to edit the file or set ANYPS5_INPUT_CONFIG for each launch.

Pad::LoadInputMapping(titleId) now reads a second file after the shared one: anyps5-input.<TITLEID>.ini in the same directory as the shared file (beside the executable, or beside the file ANYPS5_INPUT_CONFIG names), where <TITLEID> is the running title's ID from GetAppTitleId_nid_postfix. The profile has the same format and overrides only what it lists: an action it names replaces the bindings from the shared file (and the built-in ones), a setting it names replaces the shared value, everything else stays. A missing profile is not an error; an invalid line in one reports the profile's path and line like the shared file does. A title ID is used only if it has at most 32 characters of letters, digits, _ and - (Pad::InputProfileName), so an ID can never name a path outside the directory.

The parsing loop moved unchanged into one function (loadInputFile) that both files use; each file keeps its own "first line replaces, later lines add" and "setting given twice" state. With no profile, or no title ID, the result is the same as before. docs/user/INPUT_MAPPING.md has a "Per-game profiles" section.

Tested

  • Linux (Ubuntu 24.04, GCC 13, Mesa lavapipe runner), fork CI at 55b64a0b94 (the PR head 636cc9e58 plus the CI scaffolding commit; run 39115078106, ctest -R '^(pad_|guest_pad|video_out_mouse|mouse_input|keyboard_input)'): 9 of 9 passed, among them pad_input_mapping. Not run on Windows. An earlier run of the previous head (39113712815) failed to compile (InputBinding unqualified in the moved loop) and was fixed before this one.
  • New checks in pad_input_mapping: profile names (valid IDs, empty, path separator, dot, over the length limit); a profile overrides and adds settings and replaces the bindings of an action it lists; another title ID and no title ID keep the shared file; a partial profile keeps what it does not list; a profile may set a setting the shared file also sets; an invalid profile names its file and line and does not affect other titles.
  • Not tested in a game; the title ID wiring in PadInput (GetAppTitleId_nid_postfix, trimmed at the first NUL) is covered only by compiling.
  • python3 tools/check_conventions.py --base origin/main passes. tools/pr_overlap.py lists no overlap with a comparable pull request and could not compare #674, #4891 and #7201 (InputMapping.cpp, PadInput.cpp, InputMapping.hpp, docs); #674 (an input editor) also changes PadInput.cpp and INPUT_MAPPING.md. Based on cdb7ed035.

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
  • Unblocks: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4908011273 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7499). Originally posted by [AlxcBTW](https://github.com/AlxcBTW) on 2026-10-18T09:35:55Z. --- ### What `anyps5-input.ini` (or the file `ANYPS5_INPUT_CONFIG` names) applies to every title. Mouse sensitivity, curve and bindings that suit one title do not suit the next, and the only way to switch is to edit the file or set `ANYPS5_INPUT_CONFIG` for each launch. `Pad::LoadInputMapping(titleId)` now reads a second file after the shared one: `anyps5-input.<TITLEID>.ini` in the same directory as the shared file (beside the executable, or beside the file `ANYPS5_INPUT_CONFIG` names), where `<TITLEID>` is the running title's ID from `GetAppTitleId_nid_postfix`. The profile has the same format and overrides only what it lists: an action it names replaces the bindings from the shared file (and the built-in ones), a setting it names replaces the shared value, everything else stays. A missing profile is not an error; an invalid line in one reports the profile's path and line like the shared file does. A title ID is used only if it has at most 32 characters of letters, digits, `_` and `-` (`Pad::InputProfileName`), so an ID can never name a path outside the directory. The parsing loop moved unchanged into one function (`loadInputFile`) that both files use; each file keeps its own "first line replaces, later lines add" and "setting given twice" state. With no profile, or no title ID, the result is the same as before. `docs/user/INPUT_MAPPING.md` has a "Per-game profiles" section. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> - Linux (Ubuntu 24.04, GCC 13, Mesa lavapipe runner), fork CI at 55b64a0b94 (the PR head 636cc9e58 plus the CI scaffolding commit; run 39115078106, ctest `-R '^(pad_|guest_pad|video_out_mouse|mouse_input|keyboard_input)'`): 9 of 9 passed, among them `pad_input_mapping`. Not run on Windows. An earlier run of the previous head (39113712815) failed to compile (`InputBinding` unqualified in the moved loop) and was fixed before this one. - New checks in `pad_input_mapping`: profile names (valid IDs, empty, path separator, dot, over the length limit); a profile overrides and adds settings and replaces the bindings of an action it lists; another title ID and no title ID keep the shared file; a partial profile keeps what it does not list; a profile may set a setting the shared file also sets; an invalid profile names its file and line and does not affect other titles. - Not tested in a game; the title ID wiring in `PadInput` (`GetAppTitleId_nid_postfix`, trimmed at the first NUL) is covered only by compiling. - `python3 tools/check_conventions.py --base origin/main` passes. `tools/pr_overlap.py` lists no overlap with a comparable pull request and could not compare #674, #4891 and #7201 (`InputMapping.cpp`, `PadInput.cpp`, `InputMapping.hpp`, docs); #674 (an input editor) also changes `PadInput.cpp` and `INPUT_MAPPING.md`. Based on cdb7ed035. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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] Unblocks: none - [x] AI-assisted: yes
LeandroLP23 commented 2026-10-18 16:44:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-18T16:44:36Z.


Windows run, since the description lists Windows as not run. Windows 11 26300, Ryzen AI 7 350, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. main 6efb7261b with this PR (636cc9e58) merged alone. It conflicts with #7496 to #7498, so it was not combined with them.

The build is clean. pad_input_mapping, which holds the new profile checks, together with pad_keyboard_mouse and pad_sdl, passes 3 runs of 3.

AI-assisted

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6252462333 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7499#issuecomment-6252462333). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-18T16:44:36Z. --- Windows run, since the description lists Windows as not run. Windows 11 26300, Ryzen AI 7 350, WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`. `main` `6efb7261b` with this PR (`636cc9e58`) merged alone. It conflicts with #7496 to #7498, so it was not combined with them. The build is clean. `pad_input_mapping`, which holds the new profile checks, together with `pad_keyboard_mouse` and `pad_sdl`, passes 3 runs of 3. AI-assisted
AlxcBTW commented 2026-10-18 16:48:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-18T16:48:11Z.


@LeandroLP23 thanks for the Windows run. The conflict with #7496 to #7498 is textual: all four add rows to the default-bindings table in docs/user/INPUT_MAPPING.md and touch the same binding list. Whichever merges first, I rebase the others onto it.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6252498226 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7499#issuecomment-6252498226). Originally posted by [AlxcBTW](https://github.com/AlxcBTW) on 2026-10-18T16:48:11Z. --- @LeandroLP23 thanks for the Windows run. The conflict with #7496 to #7498 is textual: all four add rows to the default-bindings table in `docs/user/INPUT_MAPPING.md` and touch the same binding list. Whichever merges first, I rebase the others onto it. AI-assisted: yes (Claude Code)
oneandonlydean commented 2026-10-18 20:22:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-18T20:22:35Z.


One small change before merge: the example profile name in docs/user/INPUT_MAPPING.md ("for example anyps5-input.PPSA16064.ini") uses a real title's ID. We keep user docs free of specific titles. Could you use a placeholder such as anyps5-input.PPSA00000.ini there, and in profileNames() in tests/InputMapping.cpp (the 4 PPSA16064 lines)? The other profile tests already use PPSA00001/PPSA00002, so any made-up ID works.

The rest reads well: the loop moved unchanged, each file keeps its own override state, and InputProfileName can't name a path outside the directory. Heads-up on order: this conflicts with #7496 and #7500 in tests/InputMapping.cpp (and with #7500 in INPUT_MAPPING.md). They're add/add conflicts at the same spot, and keeping both sides resolves them. Whichever lands second will need a rebase.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6254704619 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7499#issuecomment-6254704619). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-18T20:22:35Z. --- One small change before merge: the example profile name in `docs/user/INPUT_MAPPING.md` ("for example `anyps5-input.PPSA16064.ini`") uses a real title's ID. We keep user docs free of specific titles. Could you use a placeholder such as `anyps5-input.PPSA00000.ini` there, and in `profileNames()` in `tests/InputMapping.cpp` (the 4 `PPSA16064` lines)? The other profile tests already use `PPSA00001`/`PPSA00002`, so any made-up ID works. The rest reads well: the loop moved unchanged, each file keeps its own override state, and `InputProfileName` can't name a path outside the directory. Heads-up on order: this conflicts with #7496 and #7500 in `tests/InputMapping.cpp` (and with #7500 in `INPUT_MAPPING.md`). They're add/add conflicts at the same spot, and keeping both sides resolves them. Whichever lands second will need a rebase.
blawesom commented 2026-10-19 08:02:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-19T08:02:36Z.


Rebase handoff — rebased onto current main (authorship unchanged). Test-function conflicts unioned (main's newer stick-modifier/keyboard-ramp tests kept alongside your profile tests, with the runner calls integrated); docs unioned.

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV): builds; the input-mapping tests pass; conventions pass; full suite green apart from the four known main regressions (#5444 Mesa, #7584 BDA, #7766, #7784), none from this PR.

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/7499
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is 8942f4739.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6262560168 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7499#issuecomment-6262560168). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-19T08:02:36Z. --- **Rebase handoff** — rebased onto current `main` (authorship unchanged). Test-function conflicts unioned (main's newer stick-modifier/keyboard-ramp tests kept alongside your profile tests, with the runner calls integrated); docs unioned. Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`, AMD RX 9070 XT / RADV): builds; the input-mapping tests pass; conventions pass; **full suite green apart from the four known `main` regressions** (#5444 Mesa, #7584 BDA, #7766, #7784), none from this PR. **To pick it up:** ``` git fetch https://github.com/blawesom/AnyPS5 rebase/7499 git checkout <your branch> git merge --ff-only FETCH_HEAD ``` Head is `8942f4739`.
oneandonlydean commented 2026-10-19 08:53:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-19T08:53:24Z.


@blawesom thanks for the rebase. The code and tests come through exactly as reviewed, and main's stick-modifier and keyboard-ramp tests are all still there and called next to the profile tests.

One fix is needed in docs/user/INPUT_MAPPING.md: in the per-game profile example, the ```ini fences got lost and main's next heading ended up on the example's last line:

MouseSensitivity = 0.6
Cross = KEY:F## Mouse as the right stick

It should read:

```ini
MouseSensitivity = 0.6
Cross = KEY:F
```

## Mouse as the right stick

@AlxcBTW this is a real rebase (it doesn't contain your current head), so --ff-only won't pick it up. Once the docs fix is on rebase/7499, adopting it would be git fetch https://github.com/blawesom/AnyPS5 rebase/7499, then git reset --hard FETCH_HEAD on your branch and git push --force-with-lease. Or you can merge main into your branch yourself. The PPSA16064 example ID from the earlier comment still needs swapping for a placeholder, and that can go in the same push.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6263436570 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7499#issuecomment-6263436570). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-19T08:53:24Z. --- @blawesom thanks for the rebase. The code and tests come through exactly as reviewed, and main's stick-modifier and keyboard-ramp tests are all still there and called next to the profile tests. One fix is needed in `docs/user/INPUT_MAPPING.md`: in the per-game profile example, the ```` ```ini ```` fences got lost and main's next heading ended up on the example's last line: ``` MouseSensitivity = 0.6 Cross = KEY:F## Mouse as the right stick ``` It should read: ```` ```ini MouseSensitivity = 0.6 Cross = KEY:F ``` ## Mouse as the right stick ```` @AlxcBTW this is a real rebase (it doesn't contain your current head), so `--ff-only` won't pick it up. Once the docs fix is on `rebase/7499`, adopting it would be `git fetch https://github.com/blawesom/AnyPS5 rebase/7499`, then `git reset --hard FETCH_HEAD` on your branch and `git push --force-with-lease`. Or you can merge `main` into your branch yourself. The `PPSA16064` example ID from the earlier comment still needs swapping for a placeholder, and that can go in the same push.
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!7499
No description provided.