[Gamepad] Xbox 360 controller not working on macOS
Categories
(Core :: DOM: Device Interfaces, defect, P2)
Tracking
()
People
(Reporter: cfogel, Assigned: cmartin)
References
(Blocks 1 open bug)
Details
Attachments
(2 files, 1 obsolete file)
Affected versions
- 45.3.0esr, 67.0.4, 72.0a1, 73.0b4, 74.0a1 (2020-01-13);
Affected platforms
- macOS 10.15, macOS 10.12, macOS 10.14;
Steps to reproduce
- Launch Firefox;
- Connect a gamepad;
- Access https://html5gamepad.com/
- Move the controls on the gamepad
Expected result
- controls are recognized and displayed on the screen
Actual result
- nothing happens;
Regression range
- it doesn't appear to be a regression;
Additional notes
- reproduced on 2 laptops one with normal USB ports and one with type C USB ports + adapter;
- as reference, controls are picked up fine no Chrome;
- for additional details feel free to contact me or :csasca.
Reporter | ||
Updated•4 years ago
|
Comment 1•4 years ago
•
|
||
One more note is that for the xbox 360 controller, xinput is not used or not seen, but with a generic logitech (model F310) controller, Firefox picks up the commands and works as expected.
Comment 2•4 years ago
•
|
||
Could you check if it works properly in FF 69 even 68? We did some refactor at Bug 1523353, it might be a regression.
Reporter | ||
Comment 3•4 years ago
|
||
Same issue with 68.0 and 69.0 unfortunately.
Comment 4•4 years ago
|
||
It needs more time to investigate it if it is not our recent regression. We need to figure out what's the issue as soon as we can because xbox 360 controller is a very popular controller for users.
Comment 5•4 years ago
•
|
||
After investigating our implementation in CocoaGamepad.cpp
, we should add an another type for kMultiAxisUsage: 0x08
[1], but it still doesn't work for Xbox controllers, I can't get its DeviceAddedCallback
.
It looks like Xbox gamepads in MacOS are no longer to be able to use IOHIDDevice
to query devices. We need to consider to register IOService
and use IOServiceAddMatchingNotification
[2] to listen new devices be added.
[1] https://searchfox.org/mozilla-central/rev/557a0e222dd104c5d805ba344c45d6abc27d3db0/dom/gamepad/cocoa/CocoaGamepad.cpp#508
[2] https://developer.apple.com/documentation/iokit/1514362-ioserviceaddmatchingnotification?language=objc
Comment 6•4 years ago
•
|
||
One more note is that for the xbox 360 controller, xinput is not used or not seen, but with a generic logitech (model F310) controller, Firefox picks up the commands and works as expected.
The F310 has a switch on the backside that toggles between DirectInput and XInput (i.e. Xbox360). It might be worth checking if it's in XInput mode.
Updated•4 years ago
|
Comment 8•4 years ago
|
||
On Mac OS, wireless Xbox controller is still workable, but its button mapping is wrong. However, Xbox controller with USB port couldn't be added to our Gamepad service.
Comment 9•4 years ago
|
||
Comment 10•4 years ago
|
||
Depends on D84917
Comment 11•4 years ago
•
|
||
Microsoft Xbox controllers have too many versions from Xbox 360, One, One S, One Elite, and One Elite 2. Some button mapping of them are different after updating a special version of firmware, and it happened to me. I was using a kMicrosoftProductXboxOneSWireless
controller on Mac OS, but when I tried it again, it was changed to kMicrosoftProductXboxOneSWireless2016
, and its button mapping is different from the previous one.
Updated•4 years ago
|
Comment 12•4 years ago
|
||
Mac OS USB Device Interfaces doc, https://developer.apple.com/library/archive/documentation/DeviceDrivers/Conceptual/USBBook/USBDeviceInterfaces/USBDevInterfaces.html
Comment 13•4 years ago
|
||
Depends on D84918
Comment 14•4 years ago
|
||
Comment 15•4 years ago
•
|
||
We need to replace the mGamepads vector with a hash table which stores gamepads as RefPtr.
I saw lots of used-as-freed errors when getting the callback of ReportChangedCallback()
. It is because the items in mGamepads have been changed but the older objects still register IOHIDDeviceRegisterInputReportCallback
. Using a hashtable also makes our code be easier to maintain.
Comment 16•4 years ago
|
||
I also notice XBOX_ONE_S USB needs to add CFRunLoopRun
to poll events, otherwise, I can see this controller is disconnected intermittently. However, XBOX_ONE_2015 USB don't need this.
But, using CFRunLoopRun
brings us crashes in DualShock4 controllers. DS4 controllers need call IOHIDDeviceRegisterInputReportCallback
to handle its light indicators, we also need it for future haptics feedback support. This callback event will be pending sometimes and be executed when our service is going to shutdown. That flushing events behavior cause used-as-freed problems because our gamepads in mGamepads are already freed. I feel the better solution for XBOX_ONE_S USB is by decreasing the delay of kDarwinGamepadPollInterval
.
Updated•4 years ago
|
Comment 17•4 years ago
|
||
Pushed by cmartin@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a6ceaf14f271 Part 1: Replace map with unordered_map for more efficiently querying remapped game buttons. r=baku https://hg.mozilla.org/integration/autoland/rev/e1dc77c24b2b Part 2: Add Mac OS Xbox wireless gamepads remapping. r=baku
Comment 18•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/a6ceaf14f271
https://hg.mozilla.org/mozilla-central/rev/e1dc77c24b2b
Updated•4 years ago
|
Assignee | ||
Comment 19•4 years ago
|
||
Oops - Didn't mean to let this bug close yet. There's still a third changeset to land.
Updated•2 years ago
|
Updated•8 months ago
|
Description
•