sigmaxipi / chromium-for-stadia

Quick hack to get Google Stadia running on unsupported Android devices
155 stars 19 forks source link

PS4 controller doesn't have proper button mappings. #5

Closed sigmaxipi closed 4 years ago

sigmaxipi commented 4 years ago

The Dualshock controller isn't handled properly by Android + Chrome + Gamepad API. Going to https://html5gamepad.com/ on a Windows browser shows the expected mapping and navigator.getGamepads()[0] returns {id: "Wireless Controller (STANDARD GAMEPAD Vendor: 054c Product: 09cc)".... Going to that page on Android Chrome + a BT or USB Dualshock controller shows {id: "Wireless Controller",... and the mapping is incorrect.

The expected button mapping is X, O, Square, Triangle, L1, R1, L2, R2, Share, Options, Left thumbstick, Right thumbstick, dUp, dDown, dLeft, dRight, PS, Touchpad and this works on Windows.

On Android, the detected mapping is O, null, X, Square, Triangle, null, null, null, L2, R2, Share, Options,, dUp, dDown, dLeft, dRight, PS. And the touchpad maps to a mouse.

sigmaxipi commented 4 years ago

This is caused by an incorrect mapping for the PS4 controllers. This should be fixed upstream in Chrome, but I'll patch this repo to fix it for now.

sigmaxipi commented 4 years ago

Broken button mapping may still occur on pre-Android 10 devices. This can be tested with https://html5gamepad.com/. Using an older version of the apk may help.

nondebug commented 4 years ago

Relevant upstream patch, should be in Chrome 81 once it lands:

https://chromium-review.googlesource.com/c/chromium/src/+/1958910

Your patch uses the new mapping for Build.VERSION_CODES.P and newer, do you know of any devices with Android P that need the new mapping?

sigmaxipi commented 4 years ago

An S9 with starqltesq:9/PPR1.180610.011/G960USQS7CSJ9: and Chrome 78.0.3904.108 has the wrong mapping on html5gamepad.com. But it works with my Chromium apk. I think I used >=P because of articles like https://www.xda-developers.com/android-pie-support-playstation-4-dualshock-4/ which stated DualShock support was added to P. but I didn't investigate in depth.

nondebug commented 4 years ago

I tried with a Pixel 3 on PD1A.180720.031 (the oldest build I could flash) and it also needed the new mapping. Tested with:

DS4 v2 USB & Bluetooth (CUH-ZCT2U) SIXAXIS USB (CECHZC1U) DS3 USB (CECHZC2U)

I also tried a DS4 v1 (CUH-ZCT1E) but it only worked over Bluetooth. Over USB there's an issue with hid-sony that breaks with this particular DS4 version. The label on the back has "4-472-348-02 G", I've only seen this issue with devices that have that particular revision code but maybe there are others.

It seems Android 9 includes some of the hid-sony patches that fix the DS3 and DS4 mappings, while Android 10 pulls in all upstream patches to date. I'll change my patch to use >=P.

Behniha commented 3 years ago

This is caused by an incorrect mapping for the PS4 controllers. This should be fixed upstream in Chrome, but I'll patch this repo to fix it for now.

PS4 controller doesn't have proper button mappings!!! I have the same issue, my phone is honor 8c, please help me out! I'm so new in github :(