Forwarding game controllers and other input over SSH
Various systems exist for remotely controlling Linux systems, such as VNC, Synergy/Barrier and other protocols like SPICE and NX. These systems, however, tend to operate at a high level, and are consequently limited in scope. For example, none of these systems support relative mouse pointer movement (often relied upon, for example, by 3D video games) or unusual input devices like gamepads/game controllers.
Last month, I presented an interim solution for relative mouse movement, input-over-ssh (legacy) – but this also operated at a high level, based on X inputs and outputs, and could not be easily extended to other input devices. Now, I have rewritten input-over-ssh based on the Linux evdev interface, allowing for direct forwarding of a variety of input devices from one Linux system to another – mouse, keyboard, gamepads/game controllers, joysticks, drawing tablets, etc.
The new rewrite of input-over-ssh can be found here. input-over-ssh is divided into two components – a client (the device whose input is to be forwarded) and server (the device to forward input to).
Usage
To use input-over-ssh, download input-over-ssh on both the client and server, and install python-evdev as a dependency.
Then navigate to the root directory on the client and run:
python -m input_over_ssh.client -L
This will print a list of all available evdev devices. If no devices appear, ensure the current user has access to the raw /dev/input device files (e.g. by adding the user to the input group).
Then pass the path of the device to be forwarded, and pipe the output to an instance of input-over-ssh running on the server. Also pass the -u
flag to Python when running the client, to force unbuffered output. For example:
python -u -m input_over_ssh.client -p /dev/input/event1 | ssh hostname.example.com 'PYTHONPATH=/path/to/input-over-ssh python -m input_over_ssh.server'
For the adventurous, you ought to be able to replace ssh with netcat/socat over UDP to further reduce latency.
In combination with a VNC server/client setup, this could be used as a open-source alternative to services like Steam Remote Play.
For a full list of command-line options, run python -m input_over_ssh.client --help
.
Approach
input-over-ssh uses python-evdev to directly interface with the Linux evdev input device interface to capture input events, and directly forwards them to the server. The input-over-ssh script running on the server then simply emulates the captured input events using uinput. This low-level interface allows input-over-ssh to forward any suitable input device, without needing to know details about the type of mouse or keyboard or gamepad.
For more details, take a look at the input-over-ssh source code here.