-
Notifications
You must be signed in to change notification settings - Fork 353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MPU6050 addon for IMU support in PS4 Mode #551
Conversation
…be configurable or depend on which controller mode we're in.
I'm scrapping the plan to make MPU6050 settings configurable. These defaults are fine and comparable to a DS4
…y float support to config_utils.cpp
Are you able to test whether the IMU accurately functions on a PS4? Seems like the (suspected) IMU parameters in the config report (0x03) are still 0. I'm not sure how would one test this TBH and this is one of the blockers for me when I make my own DS4 emulator. Maybe a hacked PS4 and some homebrew gamepad tester is required. |
I've tested at least the accelerometer on the PS4 and it worked fine for pitch and steering in Wipeout Omega Collection, just like an official controller. I suspect that part of the hid descriptor (or possibly even the entirety of it) just gets ignored/overridden when using the official vendor and product id, but the hid descriptor being incomplete could explain the lack of motion while using different IDs. I might play around with that a little bit more, but it works as is. Neither the PS4 nor PC drivers seem to care. EDIT: Ah, The Last of Us 2 has gyro aim supposedly. Let me get that installed and I can double check gyro function on PS4. |
I did a little more testing on the PS4 side. Looks like we actually need to use the Panthera VID/PID for PS4 (and motion works, yay!), but we have to use DS4 ones on Windows to get motion there. PS4 doesn't recognize the controller if we're using the DS4 VID/PID. The DS4 VID/PID also immediately crashes my Steam Deck, so using that might not be good on Linux, but again motion doesn't work on PC with Panthera. Maybe some HID magic can be done to fix PC IMU support on the Panthera ID without breaking PS4 support? Anyways, the accelerometer seems slightly less sensitive in a split screen comparison in Wipeout Omega Collection (probably just due to lack of calibration, i.e. my up axis reads 8.5G while a real DS4 reads 9.8G) but it's still completely playable. The gyro seems comparable as well in TLoU P2, but since I don't have any split-screen games which support it to compare with it's a little harder to tell. On PC I recall it being very close when doing tests with Steam Input and seeing how far a 90 degree controller turn with high sensitivity settings would spin me in Quake. To fix any inaccuracies, we'd need a comprehensive calibration sequence. 3 steps for the accelerometer (to determine offset and scale for every axis compared to gravity) and also 3 steps for the gyro (probably rotating the controller 360 around every axis to determine the scale). But at a base, just calibrating the gyro offset once (which I'm already doing) makes playing anything pretty much close enough. EDIT: Anyways, this isn't ready to merge, |
I'm going to switch this over to draft mode. I have an MPU6050 breakout board on me to test this, but we can look at how we could add this as an experimental option. |
Got third party vidpids to work with motion. The changes to the 0x03 feature report in ps4_driver.cpp are currently hardcoded. I'll probably switch the internal state values back to G and deg/s floats again (instead of raw sensor values) and just choose sensible conversions/scale factors for the ps4 driver, which would be a lot less convoluted than trying to store the scale factors themselves in gamepadstate or something (especially once we add Switch and PS3 compatibility) |
Going to close this draft and have you resubmit when its ready to be reviewed. Please feel free to ping any of us in discord for questions or ideas, looking great so far. |
#406
This only adds IMU support to PS4 mode.
For Windows and Linux to recognize the IMU data (in Steam Input, GameConTest, etc), I also had to switch the vendor and product ID to official ones since the panthera one didn't work. A real PS4 doesn't care though, it worked both ways.I don't know enough about how Dualshock 3/SixAxis or Switch controllers work to add support there, but that could be a future issue. Perhaps someone with better HID knowledge would be able to get it to work.
To test this, you'll want an MPU6050 breakout board, also called a GY-521.