fix(libScePad): open the special port with a handle that reads as disconnected #9878
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9878"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by ntamas94 on 2026-10-22T20:18:19Z.
What
scePadOpenreturnedDEVICE_NOT_CONNECTED(0x80920007) for a special port (type 2) since #3838, which fixed a real bug (both ports read the same input queue) but guessed the console side: its debt entry says whether the console opens a handle and reports the device as disconnected later is unknown.Measured on a PS4 Pro, firmware 10.71, with no special controller connected (
probe/padspecial.cand the 97-case libScePad survey of the ps4probe homebrew,survey/results/libScePad.ps4.txt):scePadOpen(user, SPECIAL, 0, NULL)returns a handle (0x03070502) andALREADY_OPENED(0x80920004) on a second open;scePadGetHandlereturns it;scePadReadreturns one record andscePadReadStatethe same record (buttons 0, sticks 0x80, orientation (0, 0, 0, 1), acceleration (0, 1, 0),connected0, timestamp 0);scePadGetControllerInformationis all zero;scePadDeviceClassGetExtendedInformationwrites device class -1;scePadSetVibration,scePadSetLightBar,scePadResetLightBar,scePadSetMotionSensorState,scePadResetOrientationandscePadClosereturn 0;scePadRead(-1)isINVALID_HANDLE.Unity's PS4 input module opens the standard port and then the special port of a user and keeps the pad handle only if both opens succeed; otherwise it reads with handle -1 every frame (disassembly of the relinked eboot of CUSA09558 at
0x140f20251..0x140f202ee; tracedscePadRead(0xffffffff)per frame). Knowledge is Power (CUSA09558) and Knowledge is Power: Decades (CUSA12435) had no controller input under AnyPS5 for that reason.The special port now opens a handle per user (
PAD_SPECIAL_HANDLE+ slot, 16 slots for the console's 16 accounts; a 17th user id gets 0x809b0081, the code the survey measured for an unknown user), tracked apart from the standard handle byscePadCloseandscePadGetHandle; a second open by the same user returnsALREADY_OPENED. Every pad call accepts the handle: reads return the measured rest record,scePadGetControllerInformationandscePadDeviceClassParseDatazeroed structures, extended information device class -1, and the setters succeed without touching the emulated pad. The standard handle keeps its own queue, so the double drain #3838 fixed for PPSA16827 does not come back: that title's per-framescePadRead,scePadGetControllerInformationandscePadDeviceClassParseDataon the special handle now get a disconnected record instead of draining the standard queue.scePadOpenExtis unchanged (PPSA01317 expectsDEVICE_NOT_CONNECTEDand skips the user). With two users logged in, the survey probe shows each user's handle,ALREADY_OPENEDand close are independent of the other user's (rows in the review thread). Not measured: the console's handle values (fresh per open), the calls the survey did not cover on the special handle, and a PS5; all of it is indocs/dev/debt/libScePad.md.Overlap (the overlap comment): #7881 (up to 4 controllers) and #9178 (remote control port handle) change the same
scePadOpen/scePadGetHandlelines;PAD_SPECIAL_HANDLE+ slot is 0x20..0x2f, outside #7881'sPAD_HANDLE_BASE + portrange and apart from #9178'sPAD_REMOTE_HANDLE(0x10), so the rebase is mechanical whichever lands first. #5038 (libScePad stubs) touchesscePadOpenExtand the same debt entry, notscePadOpen. #6337 (timestamped samples) and #6044 (test suite labels) touchGuestPad.cppnear the new test but not the same checks. None of them implements the special port, so this PR depends on none of them; it will be rebased on whichever merges first.Tested
-DBUILD_TESTING=ON:guest_pad(special port: handle,ALREADY_OPENED, rest record, information, extended information, setters, close; two users, close of one, reads on the other) andguest_pad_vibration_modepass. With theExport.cppchange reverted,guest_padaborts at the first special-portRequire(the special open returns 0x80920007).probe/padspecial.c, the libScePad survey and the two-user special-port survey (second user logged in) as described above; the special-port rows are in the review thread.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code