xerpi / ds4vita

Use a DS4 on your PSVita
175 stars 34 forks source link

DS4 motion movements ignored #29

Open OperationNT414C opened 7 years ago

OperationNT414C commented 7 years ago

Hello,

DS4 motion movement seem to be ignored. When I tried to activate logs and add a log inside "SceMotion_sceMotionGetState", there was no call detected. Then I add log at the hook point:

BIND_FUNC_EXPORT_HOOK(SceMotion_sceMotionGetState, KERNEL_PID, "SceMotion", TAI_ANY_LIBRARY, 0xBDB32767); LOG("sceMotionGetState hook result: %d\n", SceMotion_sceMotionGetState_hook_uid); log_flush();

It returns a negative value (which means that the hook have failed). Do you have any idea why this function hook fails? I tried it on Enso and on default Henkaku.

Thank you for your help!

OperationNT414C commented 7 years ago

By looking at some taihen code ("module.c"), I wrote inside the plugin some lines to get accessible modules. Here is the output:

ds4vita_log.txt

"SceMotion" isn't an accessible module. However, undocumented "SceMotionDev" module exists. My guess is that "SceMotion" is just a "helper" for "SceMotionDev" and it is loaded only in application context.

xerpi commented 7 years ago

Yeah that's right, SceDriverUser is the user module that is a wrapper from SceMotionDev to SceMotion, as you can see here and here.

OperationNT414C commented 7 years ago

Hello xerpi,

Thank you for you clarification. In fact, my main purpose was to understand how "ds4vita" connects to the PS Vita through BlueTooth and see if the PS TV follows the same protocol. By "luck", it is the case. :-)

From this knowledge (thanks to your code ;-) ), I was able to create plugins for PS TV which catch DS3/4 controllers BlueTooth signal, retrieve accelerometer/gyroscope sensor data and interpret them for "SceMotion" calls. Here is the code: https://github.com/OperationNT414C/DSMotion

It would have been better to directly hook "SceMotionDev" calls and inject sensors retrieved data but those functions are not documented. Do you know any procedure to "understand" how an undocumented function works? (I mean, at least, knowing the function signature)

Those plugins also work on a real PS Vita with "ds3vita" and "ds4vita". However, with "ds3vita", motion sensors data seems to much spaced over time. The PS TV driver for DS3 doesn't have this issue: do you think it could be related to the data sent through call "ds3_set_operational"?

Anyway, it is not an important usecase :-). Thank you again for your sources, I wouldn't be able to do it without them!