This repository contains an experimental extension module to Skybrush Server that allows any gamepad that appears as a USB Human Interface Device to be used as a simulated RC transmitter. Skybrush Server will take care of periodically reading the HID input report bytes from the gamepad and converting them to RC channel values according to a descriptor file that specifies which bytes of the HID input report should be mapped to which RC channels.
-
Check out this repository using git.
-
Install
poetry
if you haven't done so yet;poetry
is a tool that allows you to install Skybrush Server and the extension you are working on in a completely isolated virtual environment. -
Run
poetry install
; this will create a virtual environment and install Skybrush Server with all required dependencies in it, as well as the code of the extension. -
Run
poetry shell
to open a shell associated to the virtual environment that you have just created. -
In the shell prompt, type
skybrushd -c skybrushd.jsonc
to start the server with a configuration file that loads the extension.
When attempting to use USB devices with applications on Ubuntu, users might encounter permission issues that prevent the application from accessing the device without elevated privileges.
Solution: Creating a custon udev rule for USB devices
To solve this issue, you can create a udev rule to set the appropriate permissions for your USB device, allowing non-root users to access it.
-
Identify the vendor and product ID of your USB device:
- Connect your USB device to your Ubuntu machine.
- Open a Terminal (
Ctrl + Alt + T
) and run the commandlsusb
. This lists all connected USB devices. - Locate your device in the list and note the
ID
part, which is formatted asidVendor:idProduct
. For example,054c:05c4
.
-
Create a udev rule file:
- Use a text editor in the Terminal to create a new udev rule file in the
/etc/udev/rules.d/
directory. For instance, usingnano
:sudo nano /etc/udev/rules.d/99-usbdevices.rules
- Use a text editor in the Terminal to create a new udev rule file in the
-
Add a custom udev rule:
- In the editor, add the following line, substituting
your_idVendor_here
andyour_idProduct_here
with your device's actual vendor and product IDs from thelsusb
output:SUBSYSTEM=="usb", ATTRS{idVendor}=="your_idVendor_here", ATTRS{idProduct}=="your_idProduct_here", MODE="0666"
- This rule adjusts the permissions for your specific USB device, allowing all users read/write access.
- In the editor, add the following line, substituting
-
Save and close the file:
- If using
nano
, pressCtrl + O
to save, followed byCtrl + X
to exit.
- If using
-
Reload udev rules:
- To apply the new rule, reload the udev rules with the following command:
sudo udevadm control --reload-rules && sudo udevadm trigger
- To apply the new rule, reload the udev rules with the following command:
-
Test your device:
- Disconnect and reconnect your USB device, then test it with your application to ensure it operates correctly without needing sudo permissions.
See src/skybrush_ext_rc_gamepad/supported_devices.json
; this is the file
that contains the descriptors for all the gamepads that we currently support.
If you want to add a new one, you will typically need the USB vendor and
product ID of the gamepad so we can identify it uniquely in the USB device
list, and you will also need the documentation of how the HID input report
looks like.
Many gamepads out there provide data in the same format as the PlayStation 4 gamepad; the Horipad mini4 (which we support) is an example. If your gamepad is compatible with the Horipad mini4, chances are that you can simply add its USB vendor and product ID to the appropriate section of the device descriptor file to implement support for your gamepad.
If you managed to make this extension work for one of your gamepads and we do not support it officially yet, open an issue or send us a pull request so we can add support for it in the next release.