Joystick on Ubuntu Core

I’ve installed the scummvm snap on a desktop and used a joystick (now joystick is autoconnected) to navigate the user interface. However the same snap running on Ubuntu Core with mir-kiosk, the joystick doesn’t work in the application.

The device shows up when disconnected/attached:

[Tue Jul 14 09:08:05 2020] usb 1-1.3: USB disconnect, device number 3
[Tue Jul 14 09:08:05 2020] xpad 1-1.3:1.0: xpad_try_sending_next_out_packet - usb_submit_urb failed with result -19
[Tue Jul 14 09:08:08 2020] usb 1-1.3: new full-speed USB device number 5 using xhci_hcd
[Tue Jul 14 09:08:08 2020] usb 1-1.3: New USB device found, idVendor=0e6f, idProduct=0413, bcdDevice= 1.00
[Tue Jul 14 09:08:08 2020] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[Tue Jul 14 09:08:08 2020] usb 1-1.3: Product: Afterglow Gamepad for Xbox 360
[Tue Jul 14 09:08:08 2020] usb 1-1.3: Manufacturer: BDA
[Tue Jul 14 09:08:08 2020] usb 1-1.3: SerialNumber: 0ABED28D
[Tue Jul 14 09:08:08 2020] input: Afterglow AX.1 Gamepad for Xbox 360 as /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.3/1-1.3:1.0/input/input3

Is there some reason we should expect joysticks to not work on core? Has anyone else got a joystick working on core?

Is the joystick interface connected on this UC device too (just asking as sometimes there are situations where interfaces don’t autoconnect the same on UC as on classic)?

If the interface is connected, do you see any system denials while trying to use the joystick ?

Yup! It’s connected.

popey@localhost:~$ snap connections scummvm
Interface                 Plug                     Slot                             Notes
alsa                      scummvm:alsa             :alsa                            -
audio-playback            scummvm:audio-playback   -                                -
content[gnome-3-28-1804]  scummvm:gnome-3-28-1804  gnome-3-28-1804:gnome-3-28-1804  -
content[gtk-3-themes]     scummvm:gtk-3-themes     gtk-common-themes:gtk-3-themes   -
content[icon-themes]      scummvm:icon-themes      gtk-common-themes:icon-themes    -
content[sound-themes]     scummvm:sound-themes     gtk-common-themes:sound-themes   -
desktop                   scummvm:desktop          -                                -
desktop-legacy            scummvm:desktop-legacy   -                                -
gsettings                 scummvm:gsettings        -                                -
home                      scummvm:home             -                                -
joystick                  scummvm:joystick         :joystick                        -
mount-observe             scummvm:mount-observe    -                                -
network                   scummvm:network          :network                         -
network-bind              scummvm:network-bind     :network-bind                    -
opengl                    scummvm:opengl           :opengl                          -
pulseaudio                scummvm:pulseaudio       pulseaudio:service               -
removable-media           scummvm:removable-media  -                                -
unity7                    scummvm:unity7           -                                -
wayland                   scummvm:wayland          mir-kiosk:wayland                -
x11                       scummvm:x11              -                                -

Only these denials which don’t look related?

popey@localhost:~$ dmesg | grep DENIED
[   17.874299] audit: type=1400 audit(1594744690.660:64): apparmor="DENIED" operation="open" profile="snap.mir-kiosk.daemon" name="/run/user/0/#3256" pid=1262 comm="miral-kiosk" requested_mask="wr" denied_mask="wr" fsuid=0 ouid=0
[   17.874317] audit: type=1400 audit(1594744690.660:65): apparmor="DENIED" operation="open" profile="snap.mir-kiosk.daemon" name="/dev/shm/#3" pid=1262 comm="miral-kiosk" requested_mask="wr" denied_mask="wr" fsuid=0 ouid=0
[   20.804971] audit: type=1400 audit(1594744693.592:66): apparmor="DENIED" operation="symlink" profile="snap.scummvm.daemon" name="/run/user/0/snap.scummvm" pid=1638 comm="ln" requested_mask="c" denied_mask="c" fsuid=0 ouid=0
[   55.769222] audit: type=1400 audit(1594744728.557:69): apparmor="DENIED" operation="capable" profile="snap.scummvm.daemon" pid=1718 comm="scummvm" capability=21  capname="sys_admin"

Can you post the output of

for d in $(cat /sys/fs/cgroup/devices/snap.scummvm.daemon/devices.list | awk '{print $2}'); do 
    udevadm info --query=property --path=/dev/char/$d | grep -Po 'DEVNAME=\K.*'
done

Thanks for the help.

popey@localhost:~$ for d in $(cat /sys/fs/cgroup/devices/snap.scummvm.daemon/devices.list | awk '{print $2}'); do 
>     udevadm info --query=property --path=/dev/char/$d | grep -Po 'DEVNAME=\K.*'
> done
/dev/null
/dev/full
/dev/zero
/dev/random
/dev/urandom
/dev/tty
/dev/console
/dev/ptmx
syspath not found
syspath not found
syspath not found
syspath not found
syspath not found
syspath not found
syspath not found
syspath not found
syspath not found
/dev/net/tun
/dev/input/event2
/dev/input/js0
/dev/vchiq
syspath not found
/dev/snd/pcmC0D0p
/dev/snd/pcmC0D1p
/dev/snd/pcmC0D2p
/dev/snd/controlC0
/dev/dri/card0
/dev/snd/timer

so these are your joystick devices (presumably), which means that I don’t think confinement is to blame here for why the joystick doesn’t work. Do you know more details about how scummvm tries to access joysticks?

I don’t but @lotharsm might :slight_smile:

Yes, that’s correct, the /dev/input/js0X devices are the joysticks. I don’t see why it doesn’t work on core yet. ScummVM isn’t doing anything fancy regarding the joysticks, it really just uses the Joystick/Gamepad handling from the SDL2 libraries.

@popey, can you please check if your specific gamepad works on the ScummVM snap not running on core, but on a “full” system instead? I just checked it against a PS4 controller, that works fine (on a full system, I don’t have a core installation ready for testing right now). Can you also check if e.g. the SuperTux snap fails in the same way on core? This would help to rule out if e.g. all SDL2 applications are broken this way or if it’s something specific to ScummVM.

@lotharsm Yes, the same joystick works on my Ubuntu 20.04 classic system in ScummVM with no tweaks.

Sadly if I remove scummvm and install supertux, then connect the joystick interface (that should be automatic?) and sudo supertux sadly it segfaults. I think it probably also needs pulseaudio given there’s nothing to connect audio-playback to?

Ah this came up in another thread, you need to install the pulseaudio snap on UC and use the pulseaudio plug from supertuxkart snap

I have the pulseaudio snap installed (for scummvm) but the supertux (not supertuxkart) snap doesn’t specify the pulseaudio interface, so I can’t plug it.

popey@localhost:~$ snap list
Name               Version                     Rev   Tracking       Publisher     Notes
bashtop            latest                      79    latest/stable  kz6fittycent  -
core               16-2.45.1                   9440  latest/stable  canonical✓    core
core18             20200707                    1882  latest/stable  canonical✓    base
gnome-3-28-1804    3.28.0-17-gde3d74c.de3d74c  129   latest/stable  canonical✓    -
gtk-common-themes  0.1-36-gc75f853             1506  latest/stable  canonical✓    -
mir-kiosk          1.8.0-snap93                3763  latest/stable  canonical✓    -
pi                 18-1                        35    18-pi/stable   canonical✓    gadget
pi-kernel          5.3.0-1028.30~18.04.2       170   18-pi/stable   canonical✓    kernel
pulseaudio         8.0-3                       12    latest/stable  canonical✓    -
snapd              2.45.1                      8144  latest/stable  canonical✓    snapd
supertux           0.6.2                       226   latest/stable  lserramari    -
popey@localhost:~$ snap connections supertux
Interface       Plug                     Slot               Notes
audio-playback  supertux:audio-playback  -                  -
home            supertux:home            -                  -
joystick        supertux:joystick        :joystick          manual
network         supertux:network         :network           -
opengl          supertux:opengl          :opengl            -
unity7          supertux:unity7          -                  -
wayland         supertux:wayland         mir-kiosk:wayland  -
x11             supertux:x11             -                  -
popey@localhost:~$ 

If you unsquashfs the supertux snap, and add the pulseaudio plug to the plugs in the snap.yaml, and then snap try squashfs-root and then connect all the interfaces does it run ?

Oh yeah, i keep forgetting about that.

popey@localhost:~$ nano squashfs-root/meta/snap.yaml 
-bash: nano: command not found

Grrr… :smiley:

Ok, did that, still segfaults.

[Thu Jul 16 16:09:05 2020] audit: type=1400 audit(1594915745.614:96): apparmor="DENIED" operation="rmdir" profile="snap.supertux.supertux" name="/root/snap/supertux/x1/" pid=8020 comm="rmdir" requested_mask="d" denied_mask="d" fsuid=0 ouid=0
[Thu Jul 16 16:09:05 2020] audit: type=1400 audit(1594915745.630:97): apparmor="DENIED" operation="rmdir" profile="snap.supertux.supertux" name="/root/snap/supertux/x1/" pid=8022 comm="rmdir" requested_mask="d" denied_mask="d" fsuid=0 ouid=0
[Thu Jul 16 16:09:05 2020] audit: type=1400 audit(1594915745.642:98): apparmor="DENIED" operation="rmdir" profile="snap.supertux.supertux" name="/root/snap/supertux/x1/" pid=8024 comm="rmdir" requested_mask="d" denied_mask="d" fsuid=0 ouid=0
[Thu Jul 16 16:09:05 2020] audit: type=1400 audit(1594915745.662:99): apparmor="DENIED" operation="rmdir" profile="snap.supertux.supertux" name="/root/snap/supertux/x1/" pid=8026 comm="rmdir" requested_mask="d" denied_mask="d" fsuid=0 ouid=0
[Thu Jul 16 16:09:05 2020] audit: type=1400 audit(1594915745.686:100): apparmor="DENIED" operation="rmdir" profile="snap.supertux.supertux" name="/root/snap/supertux/x1/" pid=8028 comm="rmdir" requested_mask="d" denied_mask="d" fsuid=0 ouid=0
[Thu Jul 16 16:09:05 2020] audit: type=1400 audit(1594915745.702:101): apparmor="DENIED" operation="rmdir" profile="snap.supertux.supertux" name="/root/snap/supertux/x1/" pid=8030 comm="rmdir" requested_mask="d" denied_mask="d" fsuid=0 ouid=0
[Thu Jul 16 16:09:05 2020] audit: type=1400 audit(1594915745.714:102): apparmor="DENIED" operation="rmdir" profile="snap.supertux.supertux" name="/root/snap/supertux/x1/" pid=8032 comm="rmdir" requested_mask="d" denied_mask="d" fsuid=0 ouid=0
[Thu Jul 16 16:09:05 2020] audit: type=1400 audit(1594915745.734:103): apparmor="DENIED" operation="rmdir" profile="snap.supertux.supertux" name="/root/snap/supertux/x1/" pid=8034 comm="rmdir" requested_mask="d" denied_mask="d" fsuid=0 ouid=0
[Thu Jul 16 16:09:05 2020] audit: type=1400 audit(1594915745.970:104): apparmor="DENIED" operation="capable" profile="snap.supertux.supertux" pid=7949 comm="supertux2" capability=1  capname="dac_override"
popey@localhost:~$ snap connections supertux
Interface       Plug                     Slot                Notes
audio-playback  supertux:audio-playback  -                   -
home            supertux:home            -                   -
joystick        supertux:joystick        :joystick           manual
network         supertux:network         :network            -
opengl          supertux:opengl          :opengl             -
pulseaudio      supertux:pulseaudio      pulseaudio:service  -
unity7          supertux:unity7          -                   -
wayland         supertux:wayland         mir-kiosk:wayland   -
x11             supertux:x11             -                   -
snap install nano --devmode

FTW :smile:

Hmm, I think we may be dovetailing too much here on supertux, is there some other game is known to use a joystick well on classic that is easily installable on core ?

This post made me order a cheap gamepad to try to reproduce this problem. Let’s see if I can get it delivered before you fix whatever is causing the bug.

1 Like

No, we’re breaking new ground here :slight_smile:

1 Like

in that case, can you post more information on the segfault that happens? can you do snap run --strace to see where it segfaults ?

Missing libmirclient somewhere?

I think that’s a red herring. I have to admit this is my first time trying to debug a SEGFAULT on UC, and the experience isn’t great since we don’t have gdb or gdbserver and it’s non-trivial how to add that to a system so we could run snap run --gdb supertux or snap run --experimental-gdbserver supertux, but I will hack something together that should get us further to at least the point where we can say where supertux is crashing

@popey, just in case we want to follow the libmirclient route and to rule out the red herring: I added libmirclient9 to the stage-packages of SuperTux, so you can re-test it with the latest build from the edge channel.

1 Like