Unfortunately, the joystick doesn’t work when running in confined mode. It does work when installing the snap in devmode. Note that I added the joystick plug and connected it manually. I also connected the process-control plug manually.
Confirmed my joystick (an 8bitdo gamepad) doesn’t work in your cavestory snap either.
Here is how my gamepad shows up in dmesg.
[Thu Mar 1 01:48:04 2018] usb 1-3: new full-speed USB device number 17 using xhci_hcd
[Thu Mar 1 01:48:05 2018] usb 1-3: New USB device found, idVendor=2dc8, idProduct=ab21
[Thu Mar 1 01:48:05 2018] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[Thu Mar 1 01:48:05 2018] usb 1-3: Product: SFC30 Joystick
[Thu Mar 1 01:48:05 2018] usb 1-3: Manufacturer: SFC30
[Thu Mar 1 01:48:05 2018] input: SFC30 SFC30 Joystick as /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/0003:2DC8:AB21.000A/input/input39
[Thu Mar 1 01:48:05 2018] hid-generic 0003:2DC8:AB21.000A: input,hidraw8: USB HID v1.10 Joystick [SFC30 SFC30 Joystick] on usb-0000:00:14.0-3/input0
However… if I break out of confinement, the joystick still doesn’t work.
cd /snap/cavestory/current`
export LD_LIBRARY_PATH=/snap/cavestory/current/usr/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/snap/cavestory/current/usr/lib/x86_64-linux-gnu/pulseaudio/:$LD_LIBRARY_PATH
bin/nx
Doing the above results in no joystick working. Do you have the joystick working outside of the snap?
I took a look at this. The problem is that cavestory is using /dev/input/event* instead of /dev/input/js*. This means that the device is not getting properly udev tagged to be added to the device cgroup and doesn’t have the proper apparmor rule. The joystick interface currently only supports js* devices.
Eg, when running cavestory in strict mode:
$ cavestory
Loading settings...
<nothing about the joystick>
I am able to get cavestory to notice my gamepad strict mode by:
$ sudo snap install cavestory --beta
$ sudo snap connect cavestory:joystick
# plug in and turn on your controller
# figure out which evdev device is for the joystick
$ ls -l /dev/input/by-id/*event-joystick
lrwxrwxrwx 1 root root 9 May 24 12:02 /dev/input/by-id/usb-hongjingda_HJD-X-event-joystick -> ../event9
# make note of 'event9' here as it is used below. May be different on your system
# update the udev tags for this device
$ sudo sh -c 'echo "# joystick evdev\nKERNEL==\"event9\", TAG+=\"snap_cavestory_cavestory\"" >> /etc/udev/rules.d/70-snap.cavestory.rules'
# make the system see your new tagging rule
$ sudo udevadm trigger
# verify the device is tagged for cavestory
$ udevadm info /dev/input/event9
P: /devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0/0003:2563:0526.0034/input/input78/event9
N: input/event9
S: input/by-id/usb-hongjingda_HJD-X-event-joystick
S: input/by-path/pci-0000:00:14.0-usb-0:2:1.0-event-joystick
E: DEVLINKS=/dev/input/by-id/usb-hongjingda_HJD-X-event-joystick /dev/input/by-path/pci-0000:00:14.0-usb-0:2:1.0-event-joystick
E: DEVNAME=/dev/input/event9
E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0/0003:2563:0526.0034/input/input78/event9
...
E: SUBSYSTEM=input
E: TAGS=:snap_cavestory_cavestory:
# update the apparmor profile to for this device
$ sudo sed -i 's/^}$/\/dev\/input\/event9 rw,\n}/' /var/lib/snapd/apparmor/profiles/snap.cavestory.cavestory
$ sudo apparmor_parser -r /var/lib/snapd/apparmor/profiles/snap.cavestory.cavestory
# launch cavestory
$ cavestory
Opened Joystick 0
Name: hongjingda HJD-X
Number of Axes: 6
Number of Buttons: 16
Number of Balls: 0
No force feedback support
Loading settings...
...
As you can see, the gamepad is now accessible. For some reason cavestory is not able to use my particular gamepad though (going into ‘Options/Control’ I can’t change anything to make it work either).
FYI, I discovered that SDL1 games might be convinced to use the older joystich interface instead of the newer evdev joystick interfaces by using: export SDL_JOYSTICK_DEVICE=/dev/input/js0. That doesn’t happen to help cavestory, but may help someone else.