This is a userspace application that reads the PPM audio stream produced by many RC controllers, and produces a virtual joystick using the uinput system.
This was forked from floft/ppmadapter
because it seemed more up to date, but I had to fix an issue with not enough arguments
in each key being sent in the events key ecodes.EV_ABS
. (See my commit d997209).
After that it worked. I'm not really a python programmer so this was tricky to figure out.
And this was forked from amckee/ppmadapter that provided a Python 3 compatible version of PPM Adapter. However, it seemed not to work with his controller, so he had modified it to use the PPM to TX logic (but still being userspace not requiring a user-compiled kernel module) at nexx512/txppm/ppm.c.
This application requires two libraries, pyaudio and python-evdev. They are
declared in the setup.cfg file, so will be installed if you pip install
,
but you can also install them using your system package manager, looking for
packages similar in name to:
python-pyaudio python-evdev
You need user access to /dev/uinput. To create a udev rule giving access to users in the "input" group, put in /etc/udev/rules.d/99-uinput.rules
KERNEL=="uinput", GROUP:="input", MODE:="0660"
Then make sure the uinput driver is loaded on boot, creating
/etc/modules-load.d/uinput.conf (note: if you don't want to reboot, load
with sudo modprobe uinput
).
uinput
Then reload the udev rules with (and make sure you're in the "input" group, if not, add yourself and logout/login or reboot):
sudo udevadm control --reload-rules && sudo udevadm trigger
sudo usermod -a -G input your_username
To select which microphone input you wish to use, list them with:
python3 -m ppmadapter inputs
Start PPM Adapter specifying one of the inputs (e.g. hw:0, hw:1,7, or default):
python3 -m ppmadapter -i default run
Also see options --plot and/or --debug for debugging and --average and
--buffer for adjusting smoothness and latency. After running, dmesg
should
show the input has been created:
input: ppmadapter as /devices/virtual/input/inputXX
Tested controllers: Spektrum DX6i, RadioLink AT9S
A few options for checking the joystick inputs are reasonable: jstest-gtk
or crrcsim
. For a simulator, I've tried using crrcsim
(either as audio
input directly or with the input from PPM Adapter),
neXt, and FlightGear.
For neXt, you can create a config file ~/neXt/controllerconfigs.txt something like the following and then configure/calibrate the channels within the simulator:
03000000010000000100000001000000,ppmadapter,platform:Linux,leftx:a4,lefty:a1,rightx:a2,righty:a3
(Alternatively generate your own config using controllermap)
GPL v3