Repository navigation
Conversation
This was referenced Nov 5, 2026
This was referenced Nov 6, 2026
JakePre
force-pushed
the
switch2-pr1
branch
4 times, most recently
from
November 7, 2026 19:26
3d68a78 to
58a3170
Compare
…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>
Owner
3 tasks done
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.chas 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 wayhaptics_apple.mis. The front end gives each pad a player slot throughdm_switch2_front.system_profiler, behindTARGET_OS_OSX.dm/games/settings.tsv,DM_SW2, off by default. While it's off, no Bluetooth client is created, so no permission prompt appears.0x15commands: this Mac's address and two fresh random keys. The controller keeps playing on the same link.paired with this Mac).s2_clock_sample).NSUserDefaults,sw2.gyroOffset.<serial>) and used at the next connection; a right Joy-Con 2 also has a usable factory offset (16 bytes at0x13040: 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.DM_PAD_PRESS_TO_JOINon, 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.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/Switch2Connectlink 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
make -C dm/host/tests GAME=0100000000010000 run, includingt_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-Wall -Werrorfor iOS (iphoneos, arm64) and for the Maclint_c.py tidy --against origin/main(LLVM 23.1.5): no findings in the files this PR touches. Two findings outside it, indm/gfx/tests/t_int_float_view.m:29anddm/host/hle_svc.c:46, are already onmain; its lint-c run for 7249ee9 fails on the same ones.woke for another host: left alone, logged once). Holding Sync on it during the game then paired it with the Mac againdm_switch2_startreturns onDM_SW2unset 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.impactreports this as broad becausefront_mac.mchanged, but the reach is narrow. WithDM_SW2off, the default, the only new work is onegetenvindm_switch2_startand walking an empty pad list in the Home prompt's button poll. With it on, Dread and Odyssey are above. I didn't runregress.py check. If you want it on particular games, tell me which. I addedimpact_map.tsvrows 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
docs/reference/services.md,docs_symptoms.pywas run, and the Dread and Odyssey notes link it🤖 Generated with Claude Code