Open Bug 1609068 Opened 4 years ago Updated 7 months ago

[Gamepad] Xbox 360 controller not working on macOS

Categories

(Core :: DOM: Device Interfaces, defect, P2)

Unspecified
macOS
defect

Tracking

()

REOPENED
81 Branch
Tracking Status
firefox-esr68 --- wontfix
firefox72 --- wontfix
firefox73 --- wontfix
firefox74 --- wontfix
firefox81 --- fixed

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

  1. Launch Firefox;
  2. Connect a gamepad;
  3. Access https://html5gamepad.com/
  4. 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.
Summary: [Gamepad] Xbox 360 controller not working on macOS 10.15 → [Gamepad] Xbox 360 controller not working on macOS

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.

Could you check if it works properly in FF 69 even 68? We did some refactor at Bug 1523353, it might be a regression.

Flags: needinfo?(cristian.fogel)

Same issue with 68.0 and 69.0 unfortunately.

Flags: needinfo?(cristian.fogel)

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.

Priority: -- → P2

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

Blocks: 1643833

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.

Assignee: nobody → dmu

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.

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.

Attachment #9166101 - Attachment description: Bug 1609068 - Part 1: Replace map with unordered_map for more efficiently query remapped game buttons. → Bug 1609068 - Part 1: Replace map with unordered_map for more efficiently querying remapped game buttons.

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.

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.

See Also: → 1658383
Assignee: dmu → cmartin
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
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 81 Branch

Oops - Didn't mean to let this bug close yet. There's still a third changeset to land.

Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Severity: normal → S3
Attachment #9166698 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.