feat(libSceSystemGesture): report primitive touch events from the pad reports #7574

Merged
bl4nkTHEBUNKER merged 1 commit from upstream-pr/7574 into main 2026-10-19 23:45:51 +00:00
bl4nkTHEBUNKER commented 2026-10-18 15:09:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by bl4nkTHEBUNKER on 2026-10-18T15:09:35Z.


What

sceSystemGestureUpdatePrimitiveTouchRecognizer now reads the pad reports the title passes in and tracks every touch as a primitive, so the primitive event queries report real events instead of reporting that no touch input exists.

  • The second argument is SceSystemGestureTouchPadData, {int32 padHandle, int32 reportNumber, const ScePadData* padDataBuffer, 8 reserved bytes}, as fpPS4 records it; its SceSystemGestureTouchRecognizer (361 qwords) and SceSystemGestureRectangle (4 floats and 8 reserved bytes) are the layouts main already uses.
  • The touch states 0 inactive, 1 begin, 2 active, 3 end come from the Vita header in RPCS3, whose primitive event layout is the same shape as the one in SceTypes.hpp. No public source states the PS5 values.
  • A primitive keeps the touch id the pad reports; positions are the pad's touchpad coordinates unscaled; delta_time and elapsed_time come from the reports' own timestamp, so a title that replays its own reports gets the same events. An ended touch stays readable as one end event until the next sampled report drops it.
  • GetPrimitiveTouchEvents, GetPrimitiveTouchEventsCount and GetPrimitiveTouchEventByIndex report the tracked events, and GetPrimitiveTouchEventByPrimitiveID no longer throws for a tracked touch. It still throws for an id no touch has, because the console's error there is not known.
  • The recognizer side (tap, drag, hold, pinch, rotation, flick) is unchanged and still reports no gesture event; that is a separate topic, not folded in here.

Everything unverified against console behaviour is in docs/dev/debt/libSceSystemGesture.md: the unchecked padHandle, the coordinate units, the is_updated rule, the result for a null pInputData or padDataBuffer, a too small event buffer, and the unknown id.

Tested

Windows 11, GCC 16.2 (MSYS2 UCRT64), core/libs/tests/GuestSystemGesture.cpp extended and run against the library sources with -Wall -Wextra (clean, test passes). The new assertions cover: begin on a first report; active with the delta vector, delta time and elapsed time on a move; is_updated 0 when a held touch does not move; one end event after the release and its drop on the next report; two touches at once; lookup by primitive id, including the throw for an unknown id; an event buffer shorter than the event count; several reports in one update; and reset and finalize clearing the events. The existing no-input assertions still hold. No title tested: no touch-driven title was run.

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: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4910224182 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7574). Originally posted by [bl4nkTHEBUNKER](https://github.com/bl4nkTHEBUNKER) on 2026-10-18T15:09:35Z. --- ### What `sceSystemGestureUpdatePrimitiveTouchRecognizer` now reads the pad reports the title passes in and tracks every touch as a primitive, so the primitive event queries report real events instead of reporting that no touch input exists. - The second argument is `SceSystemGestureTouchPadData`, `{int32 padHandle, int32 reportNumber, const ScePadData* padDataBuffer, 8 reserved bytes}`, as [fpPS4](https://github.com/red-prig/fpPS4/blob/585d06fa7c04698c41272b95a696a14c4180e13e/src/ps4_libscesystemgesture.pas) records it; its `SceSystemGestureTouchRecognizer` (361 qwords) and `SceSystemGestureRectangle` (4 floats and 8 reserved bytes) are the layouts main already uses. - The touch states 0 inactive, 1 begin, 2 active, 3 end come from the Vita header in [RPCS3](https://github.com/RPCS3/rpcs3/blob/38c444cfa1dbe152daa63b1703c12172078cd056/rpcs3/Emu/PSP2/Modules/sceSystemGesture.h), whose primitive event layout is the same shape as the one in `SceTypes.hpp`. No public source states the PS5 values. - A primitive keeps the touch id the pad reports; positions are the pad's touchpad coordinates unscaled; `delta_time` and `elapsed_time` come from the reports' own `timestamp`, so a title that replays its own reports gets the same events. An ended touch stays readable as one `end` event until the next sampled report drops it. - `GetPrimitiveTouchEvents`, `GetPrimitiveTouchEventsCount` and `GetPrimitiveTouchEventByIndex` report the tracked events, and `GetPrimitiveTouchEventByPrimitiveID` no longer throws for a tracked touch. It still throws for an id no touch has, because the console's error there is not known. - The recognizer side (tap, drag, hold, pinch, rotation, flick) is unchanged and still reports no gesture event; that is a separate topic, not folded in here. Everything unverified against console behaviour is in [docs/dev/debt/libSceSystemGesture.md](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/debt/libSceSystemGesture.md): the unchecked `padHandle`, the coordinate units, the `is_updated` rule, the result for a null `pInputData` or `padDataBuffer`, a too small event buffer, and the unknown id. ### Tested Windows 11, GCC 16.2 (MSYS2 UCRT64), `core/libs/tests/GuestSystemGesture.cpp` extended and run against the library sources with `-Wall -Wextra` (clean, test passes). The new assertions cover: begin on a first report; active with the delta vector, delta time and elapsed time on a move; `is_updated` 0 when a held touch does not move; one end event after the release and its drop on the next report; two touches at once; lookup by primitive id, including the throw for an unknown id; an event buffer shorter than the event count; several reports in one update; and reset and finalize clearing the events. The existing no-input assertions still hold. No title tested: no touch-driven title was run. ### 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: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-18 15:33:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T15:33:56Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5965 core/libs/SceTypes.hpp
PR 6044 core/libs/tests/GuestSystemGesture.cpp
PR 6977 core/libs/SceTypes.hpp
PR 7081 core/libs/SceTypes.hpp
PR 7412 core/libs/SceTypes.hpp
PR 8106 core/libs/prx/libSceSystemGesture/Export.cpp
docs/dev/debt/libSceSystemGesture.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6251739962 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7574#issuecomment-6251739962). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-18T15:33:56Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 5965](https://www.github.com/boykopovar/AnyPS5/pull/5965) | `core/libs/SceTypes.hpp` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestSystemGesture.cpp` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `core/libs/SceTypes.hpp` | | [PR 7081](https://www.github.com/boykopovar/AnyPS5/pull/7081) | `core/libs/SceTypes.hpp` | | [PR 7412](https://www.github.com/boykopovar/AnyPS5/pull/7412) | `core/libs/SceTypes.hpp` | | [PR 8106](https://www.github.com/boykopovar/AnyPS5/pull/8106) | `core/libs/prx/libSceSystemGesture/Export.cpp`<br>`docs/dev/debt/libSceSystemGesture.md` |
bl4nkTHEBUNKER commented 2026-10-18 15:54:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by bl4nkTHEBUNKER on 2026-10-18T15:54:52Z.


Overlap checked, including the three shared files the bot could not compare.

#6447 is the one real overlap, on sceSystemGestureGetPrimitiveTouchEventByPrimitiveID. It turns the throw into a blanket INDEX_OUT_OF_ARRAY; this pull request answers the export from the primitive events it tracks and keeps a throw only for an id that no tracked touch has, so the two cannot both apply as written. Neither needs the other, so Depends on stays none. I am happy either way: if #6447 goes first I rebase this one onto it, and the hunk disappears since this pull request rewrites the same function. Its second gesture hunk, sceSystemGestureGetTouchEventByEventID, does not overlap, because this pull request leaves that export untouched.

The other three do not overlap:

  • #6044 only renames core/libs/tests/GuestSystemGesture.cpp to core/libs/tests/input/GuestSystemGesture.cpp with no content change, so whichever goes second rebases over the move.
  • #6138 changes NetCtlCallback at SceTypes.hpp L1275, far from the SystemGestureTouchPadData this pull request adds after the other SystemGesture structures.
  • #6977 adds VideoOutBufferAttribute after VideoOutVblankStatus, below the block this pull request touches.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6251952750 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7574#issuecomment-6251952750). Originally posted by [bl4nkTHEBUNKER](https://github.com/bl4nkTHEBUNKER) on 2026-10-18T15:54:52Z. --- Overlap checked, including the three shared files the bot could not compare. **#6447** is the one real overlap, on `sceSystemGestureGetPrimitiveTouchEventByPrimitiveID`. It turns the throw into a blanket `INDEX_OUT_OF_ARRAY`; this pull request answers the export from the primitive events it tracks and keeps a throw only for an id that no tracked touch has, so the two cannot both apply as written. Neither needs the other, so `Depends on` stays `none`. I am happy either way: if #6447 goes first I rebase this one onto it, and the hunk disappears since this pull request rewrites the same function. Its second gesture hunk, `sceSystemGestureGetTouchEventByEventID`, does not overlap, because this pull request leaves that export untouched. The other three do not overlap: - **#6044** only renames `core/libs/tests/GuestSystemGesture.cpp` to `core/libs/tests/input/GuestSystemGesture.cpp` with no content change, so whichever goes second rebases over the move. - **#6138** changes `NetCtlCallback` at `SceTypes.hpp` L1275, far from the `SystemGestureTouchPadData` this pull request adds after the other `SystemGesture` structures. - **#6977** adds `VideoOutBufferAttribute` after `VideoOutVblankStatus`, below the block this pull request touches.
github-actions[bot] commented 2026-10-19 16:40:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T16:40:27Z.


Progress report (e5f18ea → 15af4e3)

📈 System libraries: 90.26% (+0.02%, +1 implemented functions)

✅ 1 implemented
Library Name
libSceSystemGesture sceSystemGestureGetPrimitiveTouchEventByPrimitiveID
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6272234855 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7574#issuecomment-6272234855). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T16:40:27Z. --- <!-- progress-report --> ### Progress report (e5f18ea → 15af4e3) 📈 **System libraries**: 90.26% (+0.02%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libSceSystemGesture | `sceSystemGestureGetPrimitiveTouchEventByPrimitiveID` | </details>
adriadam10 commented 2026-10-19 23:49:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T23:49:54Z.


Checked the PadData fields used, the new test cases (each fails on main, where the events were never reported), locking and the TechnicalDebt entry; the console-side unknowns are listed there. #6447 is closed, so the overlap is gone; merged.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6279901210 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7574#issuecomment-6279901210). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-19T23:49:54Z. --- Checked the `PadData` fields used, the new test cases (each fails on `main`, where the events were never reported), locking and the TechnicalDebt entry; the console-side unknowns are listed there. #6447 is closed, so the overlap is gone; merged.
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!7574
No description provided.