juan518munoz / PicoSwitch-WirelessGamepadAdapter

Use any bluetooth gamepad on your Nintendo Switch with a Raspberry Pi Pico W.
Apache License 2.0
46 stars 5 forks source link

Dualshock 3 pairing #9

Closed Invictaz closed 7 months ago

Invictaz commented 8 months ago

To retrieve the bluetooth mac address first flash

https://micropython.org/download/RPI_PICO_W/RPI_PICO_W-latest.uf2

then open Thonny and run the following code

import bluetooth

ble = bluetooth.BLE()
ble.active(True)

print('Getting MAC/Ethernet Address for this device.')

# This returns a tuple with an index and the MAC address bytes
index, mac_bytes = ble.config('mac')
# each MAC address is 6 bytes or 48 bits
print("Hex byte array:", mac_bytes, 'length:', len(mac_bytes))

# Format the MAC address in the standard notation
formatted_mac = ':'.join(['{:02x}'.format(byte) for byte in mac_bytes])
print("MAC Address:", formatted_mac)
juan518munoz commented 8 months ago

Hi, could you we a bit more specific about the issue? I don't understand what the logging is for.

Invictaz commented 8 months ago

If you have the MAC address you can use tools like Sixaxispairtool or Sixpair.c to write the bluetooth address of the Pico to the controller, since your adapter firmware does not have an option to manually pair a Dualshock 3 over usb.

Dualshock 3 is the only controller that needs a Mac address written over usb first in order to connect wirelessly as it does not have automatic pairing.

juan518munoz commented 7 months ago

Pairing a DS3 requires manual modifications to the codebase. I'm leaving this to the end user.

Invictaz commented 7 months ago

These instructions are way too targeted towards Linux savvy people. There should be an easier way to pair without all kinds of API's and command line tools. There is the Sixaxis Compatibility checker app on Android that does the mac address writing. The way Bluepad describes it (via Terminal) is also overcomplicated. If you run the command I posted on top once you have the BD Address and since it is not rolling or changing you can use it over and over again.

juan518munoz commented 7 months ago

The snippet of code you provided only shows how to get the bluetooth address of the pico w, it doesn't specify how to get the address of the DS3, that's why it looks simpler. I don't know if there are simpler methods, but following the guide I posted on my previous comment, it looks as it's a mandatory step to make the library work with this type of controller.

Invictaz commented 7 months ago

The snippet of code you provided only shows how to get the bluetooth address of the pico w, it doesn't specify how to get the address of the DS3, that's why it looks simpler. I don't know if there are simpler methods, but following the guide I posted on my previous comment, it looks as it's a mandatory step to make the library work with this type of controller.

The bluetooth address of the DS3 can be retrieved by using tools as Sixpair.c or https://github.com/G2-Games/sixaxis-pair_rs/releases/tag/1.0.0 which released recently.

I'm still looking for micropython or other type of code to work directly on the Pico, however OGX-Mini also doesn't have wired Dualshock 3 support so I cannot adapt the code from that. If you reopen the issue I will look for ways to get the bluetooth address, but it almost always needs either an external device or an usb-a port soldered onto the pico. There is no way to wirelessly get the bluetooth address.