Generates an interface between Swarms input device and a userland Xpad device.
The input device outputs an UDP-packet with a JSON-object. Therefore, some steps are required to mask the input device as a gamepad.
To employ the Swarms input device with Qgroundcontrol, the Swarms input device has to be masked as recognized gamepad controller, like the Xbox 360-controller.
- xboxdrv
- The shell script employed in this repo assumes that xboxdrv is installed in /usr/bin/xboxdrv
- For xboxdrv to work, the uinput module needs to be writeable:
sudo chmod 0666 /dev/uinput
- python 2.7 with python-evdev
Although not required, it's beneficial to install jstest-gtk.
sudo apt-get install jstest-gtk
This allows the user to test gamepads and joysticks.
The Swarms input device employ an ethernet interface. The input device consists of two Raspberry Pi machines; the main machine has the local IP-address 172.16.0.12
. As of May 2018 the username and password for the machine is the Raspberry Pi default. To ssh into the input device the wired connection needs to be properly set-up:
In the terminal window the input device can be accessed by ssh-connection.
The machine doesn't send out signals by default. In the home directory there's a shell script that accesess the RPi.GPIO Python library:
./start_local.sh
This script sends a JSON-list through UDP-packets.
To translate a JSON-object to a gamepad, a template or mold has to be employed. For this repo, the mold is a physical PS4-controller. For the shell script to correctly work, a physical PS4-controller needs to be connected by USB. The PS4-controller connection can be investigated through lsbus
.
git clone https://github.com/sunnyerteit/swarms_xbox_interface
After prerequisites are fulfilled and connection is established with the input device, the program is started through a shell-script:
# The first step allows everyone to execute the script.
sudo chmod +x Controller_event.sh
sudo ./Controller_event.sh
When running the script, there's an initial delay of <2 minutes, as xboxdrv requires some time to initialize.
As of May 2018, there are only four physical joysticks that generates output to the userland Xpad device.