-
Notifications
You must be signed in to change notification settings - Fork 0
Use a gamepad controller inside a lxd container
I use the software sc-controller (github link), so I can emulate a Xbox-Controller or keyboard inputs.
The version I use is v0.4.7 (app image).
You start by connecting your controller to your host, via bluetooth or usb.
Then you start sc-controller on the host and set it up.
Now you can search for the simulated controller via:
cat /proc/bus/input/devices
It should show an event with the name "Xbox...", just copy the eventnumber, e.g.:
event18
Add the event/device to the lxd controller with:
lxc config device add containername gamepadone unix-char source=/dev/input/eventnumber path=/dev/input/eventnumber required=false mode=0666
Explanation:
- replace "containername" with the name of your container
- you can also replace "gamepadone" with a name that you want to choose
- "unix-char" is the device-type
- "source" and "path" are the paths on the host (source) and in the container (path), where you will find the event
- replace "eventnumber" in source with the eventnumber you have copied above:
e.g. "event18" (also replace it for "path") - "required=false" ensures that the container starts, even if the device is not found
- "mode=0666" makes the controller/event usable for a normal user inside the container
You can check whether the event/device was added sucessfully, with:
ls /dev/input
#inside the container of course
More information on devices:
https://lxd.readthedocs.io/en/latest/instances/#devices-configuration
You can change the keys/values of the device with:
lxc config device set containername gamepadone key=value
You can delete the device with:
lxc config device remove containername gamepadone
Now you should be able to use the controller inside your container.
Additional Information:
- Sadly the "unix-hotplug" device did not work for me, but maybe you are luckier. It would make it easier, because the eventnumber can change and with the above method you need to change it by hand.