Skip to content

Mac: read HID gamepads that GameController does not list - #669

Closed
larsniet wants to merge 2 commits into
seedds:mainfrom
larsniet:mac-hid-gamepads
Closed

larsniet wants to merge 2 commits into
seedds:mainfrom
larsniet:mac-hid-gamepads

Conversation

@larsniet

Copy link
Copy Markdown
Contributor

What and why

Fixes #637.

On the Mac, a controller that macOS pairs but GameController does not list is ignored. An 8BitDo Ultimate 2C Wireless in its own mode (VID 0x2DC8, PID 0x301B, Bluetooth HID) shows up in System Settings with a battery level, but no game sees it. GameController only takes Xbox, PlayStation, Switch Pro and MFi controllers.

This reads such controllers with IOHIDManager and gives each one a player slot, the same way front_mac.m does for GameController pads, so they mix freely (2 Xbox + 2 8BitDo = players 1 to 4).

  • dm/host/pad_hid.h: pure mapping from HID buttons, hat and axes to Switch buttons and sticks (analog triggers press ZL / ZR past half, a small dead zone per axis). Default buttons follow 8BitDo's D-input numbering.
  • dm/host/pad_hid_mac.h: the IOHIDManager side. It skips GameController's synthetic devices and the vendors GameController drives itself (Microsoft, Sony, Nintendo), so no controller is read twice.
  • front_mac.m: attach / detach / read for HID pads on the existing slots.
  • Settings: DM_HID_MAP=A=1,B=2,... remaps buttons, DM_HID_LOG=1 logs each button's usage number, DM_HID_PADS=0 turns it off.

Known limit: the skip list is by vendor. An MFi pad from another vendor would be read twice; the comment in pad_hid_mac.h says where to add it.

Checked

  • Tests: make -C dm/host/tests GAME=0100152000022000 run passes, including the new t_pad_hid (16 checks).
  • Games run: Mario Kart 8 Deluxe (0100152000022000, v1507328) and Super Mario Party Jamboree (0100965017338000, v458752), with an 8BitDo Ultimate 2C Wireless over Bluetooth next to an Xbox controller. Sticks, triggers, d-pad and all buttons checked against the [hid] log lines.
  • Devices and OS: Apple M4, macOS 27.0.1.
  • Not checked: other HID gamepads, more than one 8BitDo at once, iOS (this is Mac only).

Docs

  • docs/playing.md, "On the Mac": what is read and the three settings.
  • No game files, keys or data extracted from a game in the change.

@larsniet
larsniet force-pushed the mac-hid-gamepads branch 2 times, most recently from 502c302 to f010229 Compare October 30, 2026 15:07
An 8BitDo in its own mode pairs as a Bluetooth HID gamepad that GameController never
lists, so it got no input (seedds#637). pad_hid_mac.h reads such pads with IOHIDManager
(skipping GameController's synthetic devices and the Microsoft, Sony and Nintendo pads
it drives itself) and gives each a player slot like a GameController controller.
pad_hid.h maps buttons, hat, sticks and analog triggers; DM_HID_MAP overrides the
button map, DM_HID_LOG=1 logs usages, DM_HID_PADS=0 turns it off.
The tool tests failed because DM_HID_LOG, DM_HID_MAP and DM_HID_PADS, which the
previous commit reads, had no row. dm/tools/env_switches.py added them; this writes
their meanings. test_env_switches passes.
seedds added a commit that referenced this pull request Nov 1, 2026
…#669, #637)

An 8BitDo in its own mode pairs as a Bluetooth HID gamepad that GameController never
lists, so it got no input. pad_hid_mac.h reads such pads with IOHIDManager and gives each
a player slot like a GameController controller; pad_hid.h maps buttons, hat, sticks and
analog triggers (tests/t_pad_hid.c). DM_HID_MAP moves the buttons, DM_HID_LOG=1 logs each
button's number, DM_HID_PADS=0 turns it off.

A device is skipped when +[GCController supportsHIDDevice:] says GameController lists it
itself, so no pad of any vendor is read twice (the PR skipped Microsoft, Sony and Nintendo
by vendor ID). Each stick has one round dead zone with the deflection scaled back to start
at 0, in place of a fixed cut per axis. HID has no standard button numbering: the default
is 8BitDo's, and a pad of another vendor gets a log line saying so and how to map it.
With DM_PAD_MERGE=1 player 1 is released only when the last controller of either kind
goes away, and HID pads leave the player mask alone, as GameController ones do.

Fixes #637.

Co-authored-by: Lars van der Niet <[email protected]>
@seedds

seedds commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Thanks, Lars! This landed on main as a5281d0 with you as co-author. I made three changes:

  • Pads GameController lists itself are now skipped with +[GCController supportsHIDDevice:] instead of the Microsoft/Sony/Nintendo vendor list, so no pad of any vendor is read twice.
  • Each stick has one round dead zone, and movement past it starts from 0 (no jump to 12%).
  • The default map stays 8BitDo's numbering. A pad from another vendor gets a log line saying so and pointing to DM_HID_LOG / DM_HID_MAP.

With DM_PAD_MERGE=1, player 1 is now released only when the last controller of either kind goes away.

I don't have an 8BitDo here: could you check that your Ultimate 2C still connects as controller '...' (HID) connected on current main (that supportsHIDDevice returns NO for it), and that the sticks feel right?

@larsniet

larsniet commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Tested main (a5281d0) with my Ultimate 2C Wireless over Bluetooth, and it's skipped now. supportsHIDDevice: returns YES for it (2dc8:301b), so hidpad_found bails at pad_hid_mac.h:43, but GameController never actually lists the pad, so there's no input from either side. The PR's vendor-list build on the same Mac logs controller '8BitDo Ultimate 2C Wireless' (HID) connected: player 1 and plays.

Looks like supportsHIDDevice means "I know this kind of device" rather than "I'll give you a controller for it". Opened #859, which keeps your check but only for the Microsoft/Sony/Nintendo vendors. Haven't been able to try the new dead zone yet, my test build had no picture (main's host in an older app build). Will do once I have a full build.

Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
…seedds#669, seedds#637)

An 8BitDo in its own mode pairs as a Bluetooth HID gamepad that GameController never
lists, so it got no input. pad_hid_mac.h reads such pads with IOHIDManager and gives each
a player slot like a GameController controller; pad_hid.h maps buttons, hat, sticks and
analog triggers (tests/t_pad_hid.c). DM_HID_MAP moves the buttons, DM_HID_LOG=1 logs each
button's number, DM_HID_PADS=0 turns it off.

A device is skipped when +[GCController supportsHIDDevice:] says GameController lists it
itself, so no pad of any vendor is read twice (the PR skipped Microsoft, Sony and Nintendo
by vendor ID). Each stick has one round dead zone with the deflection scaled back to start
at 0, in place of a fixed cut per axis. HID has no standard button numbering: the default
is 8BitDo's, and a pad of another vendor gets a log line saying so and how to map it.
With DM_PAD_MERGE=1 player 1 is released only when the last controller of either kind
goes away, and HID pads leave the player mask alone, as GameController ones do.

Fixes seedds#637.

Co-authored-by: Lars van der Niet <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mac: controllers that GameController doesn't recognize (8BitDo in D-input/BLE mode) get no input

2 participants