Joystick Passthrough

OK obviously not a mission critical issue but I am running Steam in a container and, for the life of me, can’t get it to recognize my Logitech USB Controller (Gamepad F310). I’ve added the USB via “device”:

lxc config device add steam gamepad usb vendorid=046d productid=c216

lsusb within the container produces:
Bus 001 Device 008: ID 046d:c216 Logitech, Inc. F310 Gamepad [DirectInput Mode]

and yet, no dice. In the past, I’ve run Steam on the host and the gamepad works just fine.

Any thoughts?

My guess is that applications don’t interact with your joystick through /dev/bus/usb as a usb device provides but instead through some kind of hid/input type device instead.

You could try using a unix-hotplug type device instead which if you can easily unplug and plug your joystick back in should cause the relevant devices to all show up in the container.

Alternatively, you’d need to track down the relevant /dev/input/ device entries and manually pass those into the container using some unix-char devices.

I appreciate the response.

I tried adding it via the second suggestion:
lxc config device add steam js0 source=/dev/input/js0 path=/dev/input/js0

but just get this error:
Error: Invalid devices: Device validation failed for "js0": Failed loading device "js0": Unsupported device type

Again, not mission critical but I appreciate any suggestions

lxc config device add steam js0 unix-char path=/dev/input/js0 should do it

The main thing was the missing unix-char part.

Unfortunately that was not the solution but I think I have narrowed down the problem (though I am not sure of the solution):

Local Device Found
  type: 046d c216
  path: sdl://0
  serial_number:  - 0
  Manufacturer: 
  Product:      Logitech Dual Action
  Release:      111
  Interface:    -1

!! Steam controller device opened for index 0.
Couldn't initialize virtual gamepad: Couldn't open /dev/uinput for writing

It looks like I need to give the Steam container write access to the host’s /dev/uinput?

Hmm, looks that way indeed.

Would I need to make that a privileged container in order to gain write access?

You don’t need to make it privileged to do that, just adding a unix-char device for /dev/uinput should do the trick.

1 Like

In the end, here is what had to be done for my particular setup to work (generally):

lxc config device add steam js0 unix-char path=/dev/input/js0 uid=1000 gid=1000 mode=0777
lxc config device add steam event22 unix-char path=/dev/input/event22 uid=1000 gid=1000 mode=0777
lxc config device add steam uinput unix-char path=/dev/uinput uid=1000 gid=1000 mode=0777

Now the joystick is available in the Steam settings and one of the two games I play that requires a joystick. The one that does not work (Streets of Rage 4) I have no idea why. Obviously that isn’t a LXD issue, though.

Thank you so much Stephane!

EDIT: Small update (if anyone finds this through their Google-foo), the above solution comes with the following caveat: hotplugging is not available. The controler must be plugged in when Steam starts.

Also, if a game does not recognize the controller, try going into that game’s settings and disabling Steam assist. That worked for me.

As always, all credit goes to Stephane!