Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(linux): allow configuring real wiimotes with known bluetooth addresses #13240

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thalesmg
Copy link

@thalesmg thalesmg commented Dec 25, 2024

This adds the option to configure real Wiimotes by specifying their Bluetooth addresses in the configuration file. This allows off-brand Wiimotes to work without using the Bluetooth Passthrough option, if you know their Bluetooth addresses beforehand.

Despite correctly setting the LAP to 0x9e8b00 (Limited Inquiry Access Code (LIAC)) in WiimoteScannerLinux::FindWiimotes while scanning, which is indeed enough to make off-brand / knock-off Wiimotes respond to a Bluetooth Inquiry, some (several? all?) bluetooth adapters seem to override and ignore this given LAP value when performing the Inquiry, and actually use the 0x9e8b33 value (General Inquiry Access Code (GIAC)) as if a null pointer have been given to hci_inquiry, as inspection of USB/Bluetooth packets by Wireshark indicate. Off-brand Wiimotes don't respond to inquiries with this LAP.

Wireshark capture of an Inquiry that attempts to use LAP = 0x9e8b00

If one happens to know the Bluetooth address of their Wiimote (for example, by checking BluetoothPassthrough.LinkKeys after using Bluetooth Passthrough, or other means such as directly using libusb to force the adapter to use the correct LAP in the Inquiry), then it's enough to add those addresses to the vector of found Wiimotes.

Example logs of using this patch to connect to a knock-off Wiimote with a known address

Since this a niche use case and I only happen to know and have tested in Linux, this change only affects the WiimoteScannerLinux backend. It's likely that it could be added to other backends, but I'm unfamiliar with these.

If no addresses are given or this config section does not exist, behavior is completely unchanged.

…resses

This adds the option to configure real Wiimotes by specifying their Bluetooth addresses in
the configuration file.  This allows off-brand Wiimotes to work without using the
Bluetooth Passthrough option, if you know their Bluetooth addresses beforehand.

Despite correctly setting the LAP to `0x9e8b00` in `WiimoteScannerLinux::FindWiimotes`
while scanning, which is indeed enough to make off-brand / knock-off Wiimotes respond to a
Bluetooth Inquiry, some (several? all?) bluetooth adapters seem to override and ignore
this given LAP value when performing the Inquiry, and actually use the `0x9e8b33` value as
if a null pointer have been given to `hci_inquiry`, as inspection of USB/Bluetooth packets
by Wireshark indicate.  Off-brand Wiimotes don't respond to inquiries with this LAP.

If one happens to know the Bluetooth address of their Wiimote (for example, by checking
`BluetoothPassthrough.LinkKeys` after using Bluetooth Passthrough, or other means such as
directly using `libusb` to force the adapter to use the correct LAP in the Inquiry), then
it's enough to add those addresses to the vector of found Wiimotes.

Since this a niche use case and I only happen to know and have tested in Linux, this
change only affects the `WiimoteScannerLinux` backend.  It's likely that it could be added
to other backends, but I'm unfamiliar with these.

If no addresses are given or this config section does not exist, behavior is completely
unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant