Turn my Raspberry Pi 0W into a bluetooth HID gamepad
-
Hello there !
I've been trying to get through this for weeks... many projects are quite similar but I have never found one that answers my problem.
As the title says, I want to turn my Raspeberry Pi 0 W into a bluetooth HID gamepad.
I figured out that another way is possible. Indeed you can create your own bluetooth HID device with either the Adafruit BlueFruit Ez-Key or a the RN-42 module (or even the HC-05 with the RN-42 firmware). But I want neither of these solutions.
I want to use my Raspberry Pi 0 W in a way that it will be recognized as a bluetooth gamepad. Creating the gamepad is fine, I used the GPIO of the Pi for the inputs.
But once the gamepad is physically done, how to make my Pi appear as a gamepad ? I've seen that you can use hciconfig in the terminal of Raspbian in order to change the class of the Pi and set it as a gamepad but I must admit that I didn't understand everything.
And it's important that it appears as a gamepad and not as a keyboard.
In a nutshell, I would like to turn my old wired nes controller in a bluetooth one, and play on another Pi where Retropie is installed.
Thank you in advance if someone takes his time to help me with this because I can't take it anymore haha !
-
While I am by far no expert with Bluetooth, I think you need to set the hciconfig class.
man hciconfig
states this for class:class [class] With no class, prints class of device. Otherwise, sets class of device to class. class is a 24-bit hex number describing the class of device, as specified in section 1.2 of the Bluetooth Assigned Numers document.
You can find this at hciconfig (1) - Linux Man Pages
I found a list of classes at BlueTooth's Baseband page.
In Table 9: The Peripheral Major Class keyboard/pointing device field it uses this bit config
5 4 3 2 Minor Device Class bit no. of CoD 0 0 0 1 Joystick 0 0 1 0 Gamepad
And Minor Device Class field - Toy Major Class has this:
7 6 5 4 3 2 Minor Device Class bit no. of CoD 0 0 0 1 0 0 Controller 0 0 0 1 0 1 Game
If this helps, here is how I get BlueTooth information from a connected device:
pi@lucaspi:~ $ hcitool con Connections: > ACL **00:26:43:66:A8:74** handle 11 state 1 lm SLAVE pi@lucaspi:~ $ hcitool info **00:26:43:66:A8:74** Requesting information ... BD Address: 00:26:43:66:A8:74 OUI Company: Alps Electric Co., Ltd (00-26-43) Device Name: PLAYSTATION(R)3 Controller LMP Version: 2.0 (0x3) LMP Subversion: 0x131f Manufacturer: Cambridge Silicon Radio (10) Features: 0xfc 0x07 0x82 0x7e 0x08 0x18 0x00 0x80 <encryption> <slot offset> <timing accuracy> <role switch> <hold mode> <sniff mode> <park state> <RSSI> <channel quality> <paging scheme> <broadcast encrypt> <EDR ACL 2 Mbps> <EDR ACL 3 Mbps> <enhanced iscan> <interlaced iscan> <interlaced pscan> <inquiry with RSSI> <AFH cap. slave> <AFH cap. master> <AFH class. master> <extended features>
Try connecting your pi 0 to your other pi/debian system and see what info is different.
Lastly, maybe check out Bluetooth CoD: Bluetooth Class of Device/Class of Service Explained for information on CoD info. I will be reading this as well for one of my projects, so I might be able to provide more info.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.