Emulator Issues #12662: Official Wii Remotes Not Recognized or Paired on M1 - MacOS 12.0 Monterey - Emulator (2024)

Following up on OatmealDome's pairing program, I pulled up IOBluetooth in Ghidra. For anyone else looking to do this, searching for console strings in the binary is a very good way to find the code that printed that console log.

[IOBluetoothDevicePair peerDidRequestPairing:type:passkey:] contains (approximately) the following code:

if (type == 6) {id adapter = [IOBluetoothDeviceCBPeerAdapter deviceFromClassicPeer:peer];os_log("peerDidRequestPairing: Pincode Pairing. Pincode received: %@", [passkey unsignedIntegerValue]);if ([self userDefinedPincode]) {os_log("%s: User-defined Passcode found.", "-[IOBluetoothDevicePair _peerDidRequestPairing:type:passkey:]");[self pinCodeRequest:adapter];} else {if (some other stuff) {some other stuff} else {os_log("peerDidRequestPairing: User has not previously provided a PINCode for device type %d & the peer \'%@\' that has no input capability. Displaying pairing options now.", [peer deviceType], peer);[self devicePairingFinished:adapter error:0xe00002bc];}}}

...pinCodeRequest: calls devicePairingPINCodeRequest:, so it looks like it now only sends that if userDefinedPincode is true. Conveniently, they have getters and setters for that, so...

@interface IOBluetoothDevicePair()- (void)setUserDefinedPincode:(BOOL)enabled;@endIOBluetoothDevicePair* doPair(IOBluetoothDevice* device, id<IOBluetoothDevicePairDelegate> delegate) {IOBluetoothDevicePair* pair = [IOBluetoothDevicePair pairWithDevice:device];[pair setUserDefinedPincode:YES];[pair setDelegate:delegate];[pair start];}

and we get more fun logs, but no success:

IOBT-[IOBluetoothDevicePair _peerDidRequestPairing:type:passkey:]: User-defined Passcode found.
bluetoothdSending 'pincode request' pairing event for device 40:D2:8A:B9:DA:F1
bluetoothdReceived XPC message "CBClassicMsgIdPairingAgentRespondToPairing" from session "IOBT-555549440166398757ba342887c753e9932bab58-classic-99866-844"
bluetoothdhandlePairingAgentRespondToPairing: Pincode (received as a number) 0 for the device "<private>"
bluetoothdhandlePairingAgentRespondToPairing: Accepting Pairing Request with Pincode <private> for the device "<private>"
IOBT-[IOBluetoothCoreBluetoothCoordinator pairPeer:forType:withKey:] pair peer: <CBClassicPeer: 0x100e04080 774A203D-6851-EEA1-D597-C9FAE4044CA4, Nintendo RVL-CNT-01-UC, disconnected, Unpaired, 40:d2:8a:b9:da:f1, devType: 26, PID: 0x0330, VID: 0x057E> for type: 6 using key: 0
bluetoothdhandlePairingAgentRespondToPairing: pincode being used is <private>
bluetoothdSetting pincode <private> for device 40:D2:8A:B9:DA:F1
bluetoothd Enforcement complete with STATUS 705
bluetoothdPolicy enforcement failed STATUS 705 - cid 0x0000AC06, handle 32505856 securityFailed 1 (status=65535)
bluetoothdL2capControlConnectCfm: STATUS 705 (status=65535)
bluetoothdConnection to device 40:D2:8A:B9:DA:F1 failed - result was 705
bluetoothdReceived connection result for "HID Host" profile on device 40:D2:8A:B9:DA:F1 - result was 158
bluetoothdPairing failure reported for device 40:D2:8A:B9:DA:F1
bluetoothdUnblocking pairing for device 40:D2:8A:B9:DA:F1
bluetoothdCancelling existing pairing timeout event
bluetoothdPairing complete for device 40:D2:8A:B9:DA:F1
bluetoothdDevice 40:D2:8A:B9:DA:F1 ClassicSMPSupported:0 encryptionMode:0
bluetoothdpairingComplete result:158 device->isDerivedFromLE:0 connectionSupportsClassicSMP:0 fCTKDDisabled:0 isPendingClassicSMP:0 address:<private>
bluetoothdSending 'pairing complete' event for device 40:D2:8A:B9:DA:F1 with result 158
... lots of other messages as the failure makes its way back to the app

I checked the code that calculates the message for the "Enforcement complete with" message, and the error formatter returns "OI_STATUS_NONE" for 0xffff, which seems to match the header of this bluetooth library that's also used in Android: https://android.googlesource.com/platform/system/bt/+/8289925/embdrv/sbc/decoder/include/oi_status.h
If that is where this came from, 705 is OI_HCIERR_AUTHENTICATION_FAILURE, which I assume means we sent the wrong pin.

So let's look at what happens when we call replyPINCode:PINCode:...

  • A number of checks are done on a subobject of IOBluetoothDevicePair, of class IOBluetoothDevicePairExpansion. This includes checks for isWiiRemote and isWiiUProController, both of which are false in this case, but I assume this is the code that made it so wiimotes would just pair with older versions of macOS without any special applications. I checked the IOBluetooth dylib from Mojave, and this code is unchanged from back then. If isWiiRemote or isWiiUProController is true, the correct key is calculated from the device address and used in place of the one supplied to replyPINCode:PINCode:.
  • Diverging from the Mojave code (which sent the code straight off to the kernel at this point), it calls [[NSString alloc] initWithBytes:pincode length:8 encoding:NSUTF8Encoding]. Sure hope that pincode was no more than 8 bytes long and valid UTF-8...
  • Then it calls [CBUtil preSSPStringToParingCode:string] which takes the string, converts it back to bytes, and memcpy's it in a 64-bit integer
  • Then [NSNumber numberWithLongLong:integer], embedding it in an NSNumber
  • It calls [[IOBluetoothCoreBluetoothCoordinator sharedInstance] pairPeer:[device classicPeer] forType:[pair currentPairingType] withKey:num]
  • That wraps it up in an NSDictionary, adds some other stuff to it, and sends it over to bluetoothd using xpc

So what happens if we avoid the NSString-ification and call pairPeer:forType:withKey directly?

@interface IOBluetoothCoreBluetoothCoordinator : NSObject+ (IOBluetoothCoreBluetoothCoordinator*)sharedInstance;- (void)pairPeer:(id)peer forType:(NSUInteger)type withKey:(NSNumber*)key;@end@interface IOBluetoothDevice()- (id)classicPeer;@end@interface IOBluetoothDevicePair()- (void)setUserDefinedPincode:(BOOL)enabled;- (NSUInteger)currentPairingType;@end@implementation MyPairingDelegate- (void)devicePairingPINCodeRequest:(id)sender {IOBluetoothDevicePair* pair = (IOBluetoothDevicePair*)sender;IOBluetoothDevice* device = [sender device];const BluetoothDeviceAddress* addr = [device getAddress];BluetoothPINCode code;memset(&code, 0, sizeof(code));for (int i = 0; i < 6; i++) {code.data[i] = addr->data[5 - i];}uint64_t num;memcpy(&num, code.data, sizeof(num));[[IOBluetoothCoreBluetoothCoordinator sharedInstance] pairPeer:[device classicPeer] forType:[pair currentPairingType] withKey:@(num)];// [pair replyPINCode:6 PINCode:&code];}@end

...and we get slightly closer

IOBT-[IOBluetoothDevicePair _peerDidRequestPairing:type:passkey:]: User-defined Passcode found.
bluetoothdSending 'pincode request' pairing event for device 40:D2:8A:B9:DA:F1
bluetoothdReceived XPC message "CBClassicMsgIdPairingAgentRespondToPairing" from session "IOBT-5555494430aa5ffb00af38bd93f2bb29e76b2953-classic-99983-847"
bluetoothdhandlePairingAgentRespondToPairing: Pincode (received as a number) 71273014745841 for the device "<private>"
<The rest is the same as above>

71273014745841 is 0x40D28AB9DAF1, which is the correct code (remember, this is little endian), it made it across this time. Sadly this still doesn't seem to be enough to pair.

I'm taking a break from this for now, if anyone else wants to look through bluetoothd code to see how it handles the code after this, I think that would be the next step. Or if anyone knows how to make bluetoothd not <private> its logs, that would also be helpful.

Emulator Issues #12662: Official Wii Remotes Not Recognized or Paired on M1 - MacOS 12.0 Monterey - Emulator (2024)

FAQs

How to connect Wii controller to mac? ›

macOS
  1. Open Bluetooth Settings and click the plus (+) sign to set up a new device.
  2. While it is scanning, press the red sync button on the back of the controller. ...
  3. Back in the Bluetooth Settings, hit "Continue" and wait for it to fail.
  4. Select 'Passcode Options' and choose "Do not use a passcode with this device".

How to fix a Wii Remote that won't connect? ›

Open the SD Card slot cover on the front of the Wii console and press and hold the red SYNC button for 15 seconds. This will clear all synced Wii Remotes from the console. Resync the Wii Remote by removing the battery cover and pressing the red 'SYNC' button. Then press the SYNC button on the Wii console.

How to connect Wiimote to Mac Reddit? ›

Go to Dolphin's controller configs, at the Wii Remotes section, choose 'Passthrough a Bluetooth adapter'. Run the game, while in the game, go back to the controller configs, click on Sync multiple times until your Wiimote is synced. Oh, you need to make sure your Wiimote is in sync mode as well. And there you have it.

How do I get my Wii to recognize my controller? ›

Press and release the SYNC Button just below the batteries on the Wii Remote; the Player LED on the front of the Wii Remote will blink. While the lights are still blinking, quickly press and release the red SYNC Button on the Wii console. When the Player LED blinking stops and stays lit, the syncing is complete.

How do I connect my Nintendo RVL CNT-01? ›

Press and hold the "1" and "2" buttons on the Wii Remote. Hold both buttons simultaneously until the four blue LED lights on your controller start blinking. On your PC, you should see "Nintendo RVL-CNT-01" under the list of Bluetooth devices.

Where to find Wiimote Bluetooth address? ›

If connecting by holding down the 1+2 buttons, the PIN is the bluetooth address of the wiimote backwards, if connecting by pressing the “sync” button on the back of the wiimote, then the PIN is the bluetooth address of the host backwards.

Why are my Wii Remotes blinking but not connecting? ›

Clear all syncs from the Wii console. Reset the Wii remote. Sync the Wii Remote with the Wii console. If fresh batteries do not help, there might be an issue with your Wii Remote or Wii console.

How do I reset my Wii Remote Sync? ›

if your wii remote doesn't connect to your wii and just turns off after blinking for a few seconds, flip open the front cover on the wii and press the red sync button. and on the wii remote you open the battery cover and press the red sync button. after a few seconds it should connect.

How do I fix my Wii Remote calibration? ›

How to Recalibrate the Wii Remote Plus on Wii
  1. Start a game that uses the Wii MotionPlus accessory. ...
  2. During game play, place the Wii Remote Plus on a flat horizontal surface (such as a table) with the buttons facing down.
  3. Wait for 10 seconds, then check for proper response.

Where is the MAC address on a Wii? ›

Select "Wii Settings" to access the "Wii System Settings" menu. Using the arrow on the right side of the screen, scroll to page two and select "Internet." Select "Console Information." The Wii Console's MAC address will be shown at the top of the screen.

How to play Wii without Wiimote? ›

Can you use a Wii without a Wiimote? No, there is no way to navigate the home screen without one. The Wii controller classic/pro both require a hookup to the Wiimote, and the Gamecube controller needs a Wiimote in order to boot up a game.

Why aren't my Wii Remotes connecting? ›

Ensure the Wii Remote is being used between 3 and 10 feet directly in front of the TV. If the Sensor Bar is being used on top of a cable box, satellite box, or other top-box, remove it and place it directly on the top or bottom of the TV. Check for physical damage. Check the Sensor Bar cord for frayed wires or kinks.

Why is my Wii Remote not being sensed? ›

Check the cord on the Sensor Bar for any frayed wires or kinks, and verify that the Sensor Bar is free of obstructions. Check the button functionality, and that the Sensor Bar is operating correctly, by accessing the Wii Main Menu. Use the "+" and "-" buttons to scroll side-to-side through the Wii Channel screens.

How to check if a Wii Remote is working? ›

Once the batteries have been replaced, press any button on the Wii Remote to see if any lights appear. Verify that your Wii Remote is functioning properly. If your Wii Remote has a steady solid light but you still experience issues, read Wii Remote Not Working Correctly for more help.

How can I connect my controller to my Mac? ›

Connect a wireless game controller to your Apple device
  1. Press and hold the appropriate button or buttons on the controller to put it into pairing mode. This makes it discoverable by your Apple device. ...
  2. Open Bluetooth settings on your Apple device, then select the controller from the list of nearby devices.
Apr 24, 2024

Are Wii Remotes Bluetooth? ›

The controller communicates wirelessly with the console via short-range Bluetooth radio, with which it is possible to operate up to four controllers at a distance of up to 10 metres (30 ft) from the console.

Top Articles
Latest Posts
Article information

Author: Roderick King

Last Updated:

Views: 5721

Rating: 4 / 5 (71 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Roderick King

Birthday: 1997-10-09

Address: 3782 Madge Knoll, East Dudley, MA 63913

Phone: +2521695290067

Job: Customer Sales Coordinator

Hobby: Gunsmithing, Embroidery, Parkour, Kitesurfing, Rock climbing, Sand art, Beekeeping

Introduction: My name is Roderick King, I am a cute, splendid, excited, perfect, gentle, funny, vivacious person who loves writing and wants to share my knowledge and understanding with you.