Skip to content

Switch 2 controllers over Bluetooth LE on the Mac: off-by-default setting, pairing by Sync in the game, motion, Home (1 of 3, #1267) - #1346

Closed
JakePre wants to merge 1 commit into
seedds:mainfrom
JakePre:switch2-pr1
Closed

JakePre wants to merge 1 commit into
seedds:mainfrom
JakePre:switch2-pr1

Conversation

@JakePre

@JakePre JakePre commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What and why

This is the first of the three PRs agreed in #1267. macOS has no driver for Joy-Con 2 or Pro Controller 2: they're Bluetooth LE devices with Nintendo's own GATT service. A Joy-Con 2 also forgets its connection the moment it drops unless it's bonded to the host. This PR adds motion and real pairing with no extra app. Rumble and the Joy-Con modes come in the next two PRs.

  • dm/host/switch2_proto.h: the protocol in pure C. It covers the advertisement and what the host does with it, command framing, bonding, the 63-byte report, stick calibration and the motion maps. tests/t_switch2.c has 61 checks on recorded reports and replies.
  • dm/host/pad_switch2_apple.{h,m}: one CoreBluetooth transport for the Mac and iOS front ends, shared the way haptics_apple.m is. The front end gives each pad a player slot through dm_switch2_front.
    • The Mac's own Bluetooth address comes from system_profiler, behind TARGET_OS_OSX.
    • Where the address can't be known (iOS), a controller in pairing mode is used without bonding. iOS: Switch 2 Pro Controller over CoreBluetooth #645 can then shrink to the iOS wiring.
  • The setting: one row in dm/games/settings.tsv, DM_SW2, off by default. While it's off, no Bluetooth client is created, so no permission prompt appears.
  • Pairing in the host: hold Sync during a game.
    • The host bonds the controller with the console's 0x15 commands: this Mac's address and two fresh random keys. The controller keeps playing on the same link.
    • After that, a button press wakes it toward this Mac and it connects without Sync.
    • Bonding only happens to a controller in pairing mode. A controller advertising another host, such as a nearby Switch 2, is never written to.
    • The feedback is the player LEDs and a log line (paired with this Mac).
  • Pads: a Pro Controller 2, or a left and a right Joy-Con 2 together, is one Pro-style pad. Its motion is the player's six-axis sensor (the right Joy-Con's sensor for a pair). One Joy-Con on its own is a sideways pad.
  • Motion accuracy (added on 7 November, after hardware measurements):
    • Gyro scale, measured: 0.0607 °/s per count. 14 tilts from lying on an edge to standing against a wall (90° by the accelerometer) read 1.153× as much at the nominal 0.070, on a left and a right Joy-Con 2 alike (1.13–1.17 each). Four 360° turns by hand agree (13.6% high). So every rotation was about 15% too fast.
    • Sample times from the controller's own clock: the report's first four bytes are a millisecond counter (+30 a report on a Mac's 30 ms connection interval, +60 or +90 when one was lost). Notifications arrive in bursts, and a lost report leaves a gap only the clock shows, so each sample is timed by the clock, never later than its arrival and at most 60 ms behind it (s2_clock_sample).
    • Gyro offset from the first sample: Jake's Joy-Cons read 0.8 and 1.5 °/s off at rest, fixed per controller. The offset learned for a controller is kept under its serial number (NSUserDefaults, sw2.gyroOffset.<serial>) and used at the next connection; a right Joy-Con 2 also has a usable factory offset (16 bytes at 0x13040: a temperature and the offset in rad/s, which matched its rest offset to 0.9 counts). A left Joy-Con 2's factory block doesn't match its rest offset, so it isn't used. The rest learning still refines it.
    • Checked by feel in Super Mario Odyssey on the Mac (Jake: "feels a lot better").
  • Home: Home, A and B take part in the hold-to-quit prompt.
  • Joining: with DM_PAD_PRESS_TO_JOIN on, a Switch 2 pad becomes a player at its first button press, as GameController and HID pads do (pad_join). While the controller applet's prompt is up, a pad that hasn't joined counts as waiting, its A and B work the prompt, and no input reaches the game.
  • Left out, as agreed: Capture, the launcher sheet and per-game grouping.

Keys. Fresh random 16-byte keys work for both key commands. A left and a right Joy-Con 2 each bonded with them, woke on a button press and reconnected with no Sync. The answer to the first key was the same bytes on both controllers and with any key sent. The answer to the second key changes with the key.

Licences. The protocol facts come from switch2mac, ndeadly/switch2_controller_research, trevlars/switch2-controllers-linux (MIT) and Nadeflore/switch2-controllers. The code was written from those notes and copies none of them. The old Nadeflore/Switch2Connect link was wrong.

Reference entry: Switch 2 controllers over Bluetooth LE. The symptom index was regenerated, and a line was added to the Dread and Odyssey notes.

Checked

  • Tests: these all pass:
    • make -C dm/host/tests GAME=0100000000010000 run, including t_switch2 (76 checks: the clock field, a right Joy-Con 2's factory block, the measured scale, and sample times under bursts, a lost report, a late arrival, silence and a clock that went back)
    • dm/tools/tests/test_docs.py, test_env_switches.py, test_settings.py, test_nsp_mac_app.py, test_usage.py
    • the new file compiled with -Wall -Werror for iOS (iphoneos, arm64) and for the Mac
    • lint_c.py tidy --against origin/main (LLVM 23.1.5): no findings in the files this PR touches. Two findings outside it, in dm/gfx/tests/t_int_float_view.m:29 and dm/host/hle_svc.c:46, are already on main; its lint-c run for 7249ee9 fails on the same ones.
  • Games run: with a left and a right Joy-Con 2:
    • Metroid Dread (010093801237C000, 2.1.0):
      • with the setting on, both Joy-Cons woke on a button press and played as one pair
      • holding Sync on the right one during the game bonded it, and it kept playing
      • holding Home opened the prompt, and A quit
      • a Joy-Con paired back to a Switch 2 sitting next to the Mac woke for the console, and the host left it alone (woke for another host: left alone, logged once). Holding Sync on it during the game then paired it with the Mac again
    • Super Mario Odyssey (0100000000010000, 1.3.0): the cap throw by shaking works.
    • Pro Controller 2: untested. I don't have one, and the docs say so.
  • Setting off: dm_switch2_start returns on DM_SW2 unset or 0 before any CoreBluetooth object is made. I read this in the code; I didn't watch a run with it off for a missing prompt.
  • Permissions: macOS asked for Bluetooth on the first start of a freshly packed Dread, even though an older build with the same bundle ID existed. It didn't ask on the second start. So it's once per app, and again after the app is packed again. The docs say so.
  • Devices and OS: M1 Pro, macOS 27.2.
  • regress.py: impact reports this as broad because front_mac.m changed, but the reach is narrow. With DM_SW2 off, the default, the only new work is one getenv in dm_switch2_start and walking an empty pad list in the Home prompt's button poll. With it on, Dread and Odyssey are above. I didn't run regress.py check. If you want it on particular games, tell me which. I added impact_map.tsv rows for the three new files.

Front ends

Front-ends: new: DM_SW2=1 (settings row, off by default) turns on Switch 2 controllers over Bluetooth LE; the Mac app's Info.plist needs NSBluetoothAlwaysUsageDescription (pack_app.py writes it), without which the host stays off

Docs

  • The finding is in docs/reference/services.md, docs_symptoms.py was run, and the Dread and Odyssey notes link it
  • No chain tool changed
  • No game files, keys or extracted game data

🤖 Generated with Claude Code

…troller 2): an off-by-default setting, pairing by Sync during the game, motion, and Home through the hold-to-quit prompt (issue seedds#1267)

macOS lists these controllers neither as GameController nor as HID devices: they are Bluetooth LE devices with Nintendo's own GATT service, and a Joy-Con 2 forgets a connection the moment it drops unless it is bonded to the host. switch2_proto.h is the protocol in pure C (advertisement and what the host does with it, command framing, bonding, the input report, stick calibration, the motion maps; tests/t_switch2.c, 61 checks on recorded reports and replies). pad_switch2_apple.m is one CoreBluetooth transport for the Mac and iOS front ends, as haptics_apple.m is; the front end gives each pad a player slot through dm_switch2_front. The Mac-only address lookup is behind TARGET_OS_OSX; where the host's own address cannot be known (iOS) a controller in pairing mode is used without bonding.

Settings row DM_SW2, off by default: with it off no Bluetooth client is created, so no permission prompt appears. With it on, a controller held in Sync advertises no host and the game bonds it with the console's 0x15 commands (this Mac's address and two fresh random keys; the console's constants are not needed), and it keeps playing on the same link; from then on a button press wakes it toward this Mac and it connects without Sync. A controller advertising another host (a Switch 2 nearby) is never written to. A Pro Controller 2, or a left and a right Joy-Con 2 together, is one Pro-style pad with motion as the player's six-axis sensor; one Joy-Con alone is a sideways pad. Home, A and B take part in the hold-to-quit prompt.

Checked on an M1 Pro, macOS 27.2, with a left and a right Joy-Con 2: Metroid Dread 2.1.0 (both woke and played as one pair, a Joy-Con held in Sync during the game bonded and kept playing, Home hold and A quit; a Joy-Con paired back to a Switch 2 beside the Mac woke for it and was left alone until Sync paired it with the Mac again; macOS asked for Bluetooth on the first start of a freshly packed app and not on the second) and Super Mario Odyssey 1.3.0 (motion: the cap throw by shaking). The Pro Controller 2 is untested. Protocol facts are from the community's notes (switch2mac, ndeadly/switch2_controller_research, trevlars/switch2-controllers-linux, Nadeflore/switch2-controllers); the code was written from them and copies none.

Motion: the gyro scale is measured (0.0607 degrees per second per count: 14 tilts edge to wall, 90 degrees by the accelerometer, read 1.153 times as much at the nominal 0.070, on a left and a right Joy-Con 2); each sample is timed by the controller's millisecond clock (the report's first four bytes) instead of its arrival, so a burst of notifications or a lost report no longer bends the integration (s2_clock_sample); and the gyro offset is there from the first sample: the one learned for that controller before (kept under its serial number), or a right Joy-Con 2's factory offset at 0x13040, which matches its rest offset.

Front-ends: new: DM_SW2=1 (settings row, off by default) turns on Switch 2 controllers over Bluetooth LE; the Mac app's Info.plist needs NSBluetoothAlwaysUsageDescription (pack_app.py writes it), without which the host stays off

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
seedds added a commit that referenced this pull request Nov 9, 2026
…troller 2): an off-by-default setting, pairing by Sync during the game, motion, and Home through the hold-to-quit prompt (issue #1267)

macOS lists these controllers neither as GameController nor as HID devices: they are Bluetooth LE devices with Nintendo's own GATT service, and a Joy-Con 2 forgets a connection the moment it drops unless it is bonded to the host. switch2_proto.h is the protocol in pure C (advertisement and what the host does with it, command framing, bonding, the input report, stick calibration, the motion maps; tests/t_switch2.c, 61 checks on recorded reports and replies). pad_switch2_apple.m is one CoreBluetooth transport for the Mac and iOS front ends, as haptics_apple.m is; the front end gives each pad a player slot through dm_switch2_front. On the Mac, this Mac's own address comes from IOBluetoothHostController once CoreBluetooth reports that the app may use Bluetooth (behind TARGET_OS_OSX); where the host's own address cannot be known (iOS) a controller in pairing mode is used without bonding.

Settings row DM_SW2, off by default: with it off no Bluetooth client is created, so no permission prompt appears. With it on, a controller held in Sync advertises no host and the game bonds it with the console's 0x15 commands (this Mac's address and two fresh random keys; the console's constants are not needed), and it keeps playing on the same link; from then on a button press wakes it toward this Mac and it connects without Sync. A controller advertising another host (a Switch 2 nearby) is never written to. A Pro Controller 2, or a left and a right Joy-Con 2 together, is one Pro-style pad with motion as the player's six-axis sensor; one Joy-Con alone is a sideways pad. Home, A and B take part in the hold-to-quit prompt.

Checked on an M1 Pro, macOS 27.2, with a left and a right Joy-Con 2: Metroid Dread 2.1.0 (both woke and played as one pair, a Joy-Con held in Sync during the game bonded and kept playing, Home hold and A quit; a Joy-Con paired back to a Switch 2 beside the Mac woke for it and was left alone until Sync paired it with the Mac again; macOS asked for Bluetooth on the first start of a freshly packed app and not on the second) and Super Mario Odyssey 1.3.0 (motion: the cap throw by shaking). A Pro Controller 2 was checked by another tester on an M4 Pro (Super Mario Bros. Wonder 1.2.0): pairing by Sync, every button, full stick travel from its factory calibration and Home; its motion map and gyro scale are borrowed, not measured on it. Protocol facts are from the community's notes (switch2mac, ndeadly/switch2_controller_research, trevlars/switch2-controllers-linux, Nadeflore/switch2-controllers); the code was written from them and copies none.

Motion: the gyro scale is measured (0.0607 degrees per second per count: 14 tilts edge to wall, 90 degrees by the accelerometer, read 1.153 times as much at the nominal 0.070, on a left and a right Joy-Con 2); each sample is timed by the controller's millisecond clock (the report's first four bytes) instead of its arrival, so a burst of notifications or a lost report no longer bends the integration (s2_clock_sample); and the gyro offset is there from the first sample: the one learned for that controller before (kept under its serial number), or a right Joy-Con 2's factory offset at 0x13040, which matches its rest offset.

Front-ends: new: DM_SW2=1 (settings row, off by default) turns on Switch 2 controllers over Bluetooth LE; the Mac app's Info.plist needs NSBluetoothAlwaysUsageDescription (pack_app.py writes it), without which the host stays off

PR #1346

Co-authored-by: JakePre <130175182+JakePre@users.noreply.github.com>
@seedds

seedds commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Landed as a342d64, with this Mac's Bluetooth address now read through IOBluetooth and the Pro Controller 2 docs updated. Details in #1267. Thanks!

@seedds seedds closed this Nov 9, 2026
Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
…troller 2): an off-by-default setting, pairing by Sync during the game, motion, and Home through the hold-to-quit prompt (issue seedds#1267)

macOS lists these controllers neither as GameController nor as HID devices: they are Bluetooth LE devices with Nintendo's own GATT service, and a Joy-Con 2 forgets a connection the moment it drops unless it is bonded to the host. switch2_proto.h is the protocol in pure C (advertisement and what the host does with it, command framing, bonding, the input report, stick calibration, the motion maps; tests/t_switch2.c, 61 checks on recorded reports and replies). pad_switch2_apple.m is one CoreBluetooth transport for the Mac and iOS front ends, as haptics_apple.m is; the front end gives each pad a player slot through dm_switch2_front. On the Mac, this Mac's own address comes from IOBluetoothHostController once CoreBluetooth reports that the app may use Bluetooth (behind TARGET_OS_OSX); where the host's own address cannot be known (iOS) a controller in pairing mode is used without bonding.

Settings row DM_SW2, off by default: with it off no Bluetooth client is created, so no permission prompt appears. With it on, a controller held in Sync advertises no host and the game bonds it with the console's 0x15 commands (this Mac's address and two fresh random keys; the console's constants are not needed), and it keeps playing on the same link; from then on a button press wakes it toward this Mac and it connects without Sync. A controller advertising another host (a Switch 2 nearby) is never written to. A Pro Controller 2, or a left and a right Joy-Con 2 together, is one Pro-style pad with motion as the player's six-axis sensor; one Joy-Con alone is a sideways pad. Home, A and B take part in the hold-to-quit prompt.

Checked on an M1 Pro, macOS 27.2, with a left and a right Joy-Con 2: Metroid Dread 2.1.0 (both woke and played as one pair, a Joy-Con held in Sync during the game bonded and kept playing, Home hold and A quit; a Joy-Con paired back to a Switch 2 beside the Mac woke for it and was left alone until Sync paired it with the Mac again; macOS asked for Bluetooth on the first start of a freshly packed app and not on the second) and Super Mario Odyssey 1.3.0 (motion: the cap throw by shaking). A Pro Controller 2 was checked by another tester on an M4 Pro (Super Mario Bros. Wonder 1.2.0): pairing by Sync, every button, full stick travel from its factory calibration and Home; its motion map and gyro scale are borrowed, not measured on it. Protocol facts are from the community's notes (switch2mac, ndeadly/switch2_controller_research, trevlars/switch2-controllers-linux, Nadeflore/switch2-controllers); the code was written from them and copies none.

Motion: the gyro scale is measured (0.0607 degrees per second per count: 14 tilts edge to wall, 90 degrees by the accelerometer, read 1.153 times as much at the nominal 0.070, on a left and a right Joy-Con 2); each sample is timed by the controller's millisecond clock (the report's first four bytes) instead of its arrival, so a burst of notifications or a lost report no longer bends the integration (s2_clock_sample); and the gyro offset is there from the first sample: the one learned for that controller before (kept under its serial number), or a right Joy-Con 2's factory offset at 0x13040, which matches its rest offset.

Front-ends: new: DM_SW2=1 (settings row, off by default) turns on Switch 2 controllers over Bluetooth LE; the Mac app's Info.plist needs NSBluetoothAlwaysUsageDescription (pack_app.py writes it), without which the host stays off

PR seedds#1346

Co-authored-by: JakePre <130175182+JakePre@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation game: 0100000000010000 Super Mario Odyssey game: 010093801237C000 Metroid Dread host The Horizon host: SVCs, services, threads, memory (dm/host) mac The Mac front end and app (dm/mac, front_mac.m) packing Building an IPA or a Mac app: the NSP script, extraction, the shader split, the packers tools Tools and scripts (dm/tools, scripts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants