-
Notifications
You must be signed in to change notification settings - Fork 318
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
FIX: Set macOS Xbox wireless gamepad button mappings based on PID/VID #2097
FIX: Set macOS Xbox wireless gamepad button mappings based on PID/VID #2097
Conversation
7da428c
to
41d5a3f
Compare
59e6563
to
90f2587
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me - just one minor comment about the Assert message.
|
||
public XInputControllerWirelessOSXStateV2 WithButton(Button button) | ||
{ | ||
Debug.Assert((int)button < 32, $"Expected button < 32, so we fit into the 32 bit wide bitmask"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message is a bit odd and misses the unit "button < 32," here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, "A maximum of 32 buttons is supported for this layout". Which anyway can only happen if casting an integer (Out of valid range) into button and calling this function? So basically its an ArgumentOutOfRange exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good point. This was essentially copy pasted.
I changed the messages but left it as Debug.Assert as I think this will be something to be caught in Debug builds.
Packages/com.unity.inputsystem/InputSystem/Plugins/XInput/XboxGamepadMacOS.cs
Show resolved
Hide resolved
Packages/com.unity.inputsystem/InputSystem/Editor/Debugger/InputDeviceDebuggerWindow.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me and thanks for expanding the test coverage. Its a bit unfortunate we need to add a whole class to fix something like this though.
Packages/com.unity.inputsystem/InputSystem/Plugins/XInput/XboxGamepadMacOS.cs
Show resolved
Hide resolved
Only for macOS since Windows uses XInput. Uses some PIDs sourced from SDL2 database. Adds automated test to establish layout mapping. We will need to update this based on reports from users in the future.
Will help track down devices that might have a firmware version update that changes the button bit mapping structure while maintaining the same PID.
217bedd
to
2e68145
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pauliusd01 says: Tried: Xbox, PS5, PS4 controllers on Win11 and MacOS player/playmode visualiser as well as the debugger. Seemed fine to me.
Also checked with Xbox pad I have and looked good.
Description
This PR fixes https://jira.unity3d.com/browse/ISXB-1264 by mapping "old" Xbox One wireless controllers based on their PID and VID.
Only for macOS since Windows uses XInput.
I also added the Version field to the Input Debugger device view. There might be some devices that get their firmware changed without a PID and VID change, so this could help us track down those devices.
Testing status & QA
Tested with a Xbox One wireless device which maps to a struct equivalent to Xbox Series.
More devices should be tested with, especially the ones that caused the ISS bug cc @ieuanrees .
Overall Product Risks
Unclear what other combinations of PID/VID we are missing.
Comments to reviewers
In general, I don't like this approach since I'm creating a lot of duplication. But I didn't find a better approach with the logic we have.
Also, we could probably expand the coverage by using this database. But I prefer for users to report their devices to us as we don't know if all those devices are still up to date.
A better alternative would be to stop using HID and rely on Apple Game Controller framework. But that requires platform code changes.
Checklist
Before review:
Changed
,Fixed
,Added
sections.Area_CanDoX
,Area_CanDoX_EvenIfYIsTheCase
,Area_WhenIDoX_AndYHappens_ThisIsTheResult
.During merge:
NEW: ___
.FIX: ___
.DOCS: ___
.CHANGE: ___
.RELEASE: 1.1.0-preview.3
.After merge: