-
Notifications
You must be signed in to change notification settings - Fork 329
Adding better support for Switch Pro controller #1471
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
Conversation
|
Dmytro Ivanov seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Packages/com.unity.inputsystem/InputSystem/Plugins/Switch/SwitchProControllerHID.cs
Show resolved
Hide resolved
Packages/com.unity.inputsystem/InputSystem/Plugins/Switch/SwitchProControllerHID.cs
Show resolved
Hide resolved
Packages/com.unity.inputsystem/InputSystem/Plugins/Switch/SwitchProControllerHID.cs
Show resolved
Hide resolved
|
Agree with @mattdatwork that TODOs might fit into a JIRA ticket tied to Device Support epic rather than being forgotten TODOs in code. |
7582d06 to
67a8605
Compare
|
Thank you for linking this fork/pull request to me! I was able to use it to add Joy-Con and Pro Controller support, including HD Rumble, IMU data, and controller colors, in my repository here: https://github.com/Meorge/JoyConUnityInputSystem If you think it makes sense, I could fork off of this branch and add my changes, so that the Input System also supports Joy-Cons and the extra controller features. |
|
@Meorge I think I'll go merge this first, and if you can base your changes against this PR we might be able to incorporate them later. One of the concerns I have right now is if you notice, |
Sounds good to me! I've got some other things I need to work on, but I'll keep an eye on this and perhaps work on my own PR once this has been merged.
The approach I took to this in my code was to not continue processing simple input reports (i.e. return |
|
@Meorge According to this https://github.com/libsdl-org/SDL/blob/main/src/joystick/controller_type.h#L576-L597 there are bunch of controllers that are input only controllers, and their state struct https://github.com/libsdl-org/SDL/blob/main/src/joystick/hidapi/SDL_hidapi_switch.c#L118-L124 seems to be 7 bytes long. And tbh I'm not sure about switching controllers to full mode, because then code that tries to read it as a HID gamepad starts spamming completely random data. E.g. Unity GetButton + Steam, because Steam switching the gamepad into full mode, and that breaks down HID layer ... So maybe keeping us into whatever mode the gamepad happens to be could be more pragmatic. SDL2 does switch to full mode but they restore to simple mode at shutdown, which is also interesting. |
67a8605 to
efed90e
Compare
efed90e to
ba7294a
Compare
Description
Switch controllers generally have simple and full modes, our existing support relied on a controller being in simple mode, but any app (browser, steam, etc) could switch it to full mode and then we were not compatible with data layout at all. Also our previous implementation was lacking initial handshake.
Changes made
Implemented support for handshake, simple and full modes.
Notes
Needs some extra testing, I verified it works on Windows/macOS and USB/BT.
It seems controller is time sensitive to handshake sequence, so I implemented handshake restart in case if we're getting stuck somewhere (editor not refreshing, lost focus, etc)