An open API service indexing awesome lists of open source software.

https://github.com/laanwj/remote-uinput-rs

Bridge evdev events from one system to another, minimizing latency
https://github.com/laanwj/remote-uinput-rs

evdev linux networking remote-control

Last synced: about 1 month ago
JSON representation

Bridge evdev events from one system to another, minimizing latency

Awesome Lists containing this project

README

          

# remote-uinput-rs

Bridge Linux evdev events from one system to another, minimizing latency.

The bridge consists of two components, `remote-uinput-server` and `remote-uinput-client`. The client sends evdev events coming from the device to the server, which makes the evdev device available to local applications.

Input events are exchanged between the client and server as tiny UDP packets. The device descriptors aren't sent over the network. These can be generated by the client, and need to be manually provided to the server as a JSON configuration file.

## Example

On the client side, generate configuration for the devices to be shared, and copy it to the server:

```sh
$ target/release/remote-uinput-client list-devices

045e:0008 /dev/input/event0: usb-xhci-hcd.1-2.2/input0: Microsoft Microsoft SideWinder Precision Pro (USB)

# you can either use
# --device-by-usbid 045e:0008
# --device-by-path /dev/input/event0
# --device-by-phys usb-xhci-hcd.1-2.2/input0
# --device-by-name "Microsoft Microsoft SideWinder Precision Pro (USB)"
$ remote-uinput-client --generate-config --device-by-usbid 045e:0008 > remote-uinput-config.json
$ scp remote-uinput-config.json server:
```
If the device you want to share doesn't appear in `list-devices` output, make sure that the user you're running it has access to it. You can also check with the utility `evtest`.

Start server side. The default, when no `--bind` is specified, is to bind on port 9002 on any interface. The server generally needs to be run as root to be allowed to create uevent devices:

```sh
$ RUST_LOG="info" remote-uinput-server -c remote-uinput-config.json
```

Start client side (replace `192.168.1.2` with the server address):

```sh
$ RUST_LOG="info" remote-uinput-client --destination 192.168.1.2:9002 --device-by-usbid 045e:0008
```

## Components

### remote-uinput-server

The server receives events from the network, and makes the evdev device(s) available to local applications.

```
$ target/release/remote-uinput-server --help
Usage: remote-uinput-server [OPTIONS] --config

Options:
-c, --config Path to JSON config file
-b, --bind Bind address [default: 0.0.0.0:9002]
-h, --help Print help
-V, --version Print version
```

Specifying a configuration file is mandatory. Normally, this is generated on the client side (see Example section above). The configuration is a simple JSON list of device descriptors,

remote-uinput-config.json

```json
[
{
"name": "Microsoft Microsoft SideWinder Precision Pro (USB)",
"vendor": 1118,
"product": 8,
"version": 256,
"capabilities": {
"4": [
4
],
"3": [
0,
1,
5,
6,
16,
17
],
"1": [
288,
289,
290,
291,
292,
293,
294,
295,
296
]
},
"abs_info": {
"1": {
"value": 0,
"minimum": -512,
"maximum": 511,
"fuzz": 3,
"flat": 63,
"resolution": 0
},
"5": {
"value": 1,
"minimum": -32,
"maximum": 31,
"fuzz": 0,
"flat": 3,
"resolution": 78
},
"17": {
"value": 0,
"minimum": -1,
"maximum": 1,
"fuzz": 0,
"flat": 0,
"resolution": 0
},
"16": {
"value": 0,
"minimum": -1,
"maximum": 1,
"fuzz": 0,
"flat": 0,
"resolution": 0
},
"0": {
"value": 30,
"minimum": -512,
"maximum": 511,
"fuzz": 3,
"flat": 63,
"resolution": 0
},
"6": {
"value": 7,
"minimum": -64,
"maximum": 63,
"fuzz": 0,
"flat": 7,
"resolution": 0
}
},
"properties": []
}
]
```

### remote-uinput-client

The client sends evdev events coming from selected device(s) over the network to the specified destination.

```
$ target/release/remote-uinput-client --help
Usage: remote-uinput-client [OPTIONS] [COMMAND]

Commands:
list-devices List available input devices
help Print this message or the help of the given subcommand(s)

Options:
-d, --destination Destination IP:port (e.g., 127.0.0.1:9002)
-p, --device-by-path Forward device with the given device path (can specify multiple)
-n, --device-by-name Forward device with the given name (can specify multiple)
--device-by-phys Forward device with the given physical path (can specify multiple)
--device-by-usbid Forward device with the given USB ID e.g. 1234:5678 (can specify multiple)
-e, --exclusive Grab the device for exclusive input
-g, --generate-config Generate server configuration for selected devices
-h, --help Print help
-V, --version Print version
```

When there are multiple devices that match a selection like `--device-by-name`, they will all be shared. If this is unwanted use a more specific selection like `--device-by-path` or `--device-by-phys`.

It is intentionally possible to specify missing devices. These will be skipped, but will reserve an internal index slot. This makes it possible to specify devices at the server side that are not currently connected to the client.