igo95862 / bubblejail

Bubblewrap based sandboxing for desktop applications
243 stars 17 forks source link

how to get switch controller to work #127

Open FeyrisTan opened 3 weeks ago

FeyrisTan commented 3 weeks ago

Output of bubblejail --version

0.9.1

Your distro name and version

Arch Linux

Description

Controller: 8bitdo pro 2 bluetooth

Simply enabling Joysticks and gamepads is not enough. For example if I have an emulator setup with bubblejail it can see my controller in xbox mode but not in switch mode. Everything works fine outside of bubble.

igo95862 commented 3 weeks ago

Hello @FeyrisTan

Do you have [joystick] service enabled? How does your /dev/input folder looks like then controller is plugged in? (ls -l)

The current gamepad detected algorithm is not perfect and will be reworked to use udev in the future. See #16 .

FeyrisTan commented 3 weeks ago

[joystick] is in the services file.

/dev/input has: folders: by-id, by-path event: 0-26 (0-28 with controller connected) and then just js0 mice and mouse0-1

tried it with usb as well but same result. but it does work in "normal" xbox mode just not in switch mode.

igo95862 commented 3 weeks ago

Can you check the permission bits in the /dev/input. Currently the gamepad detection relies on the devices being other readable but maybe switch mode does not set that.

Also you can try running the strace to check if there is a some kind of path that is missing.

FeyrisTan commented 2 weeks ago

strace: https://privatebin.net/?3aff5c4399c1a7ee#7Hrn9uEiAFvZJYibgcnfJB7U3fVNqeU724vP8PxKXV2m

and ls -l in /dev/input:

drwxr-xr-x     - root 10 Sep 11:36  by-id
drwxr-xr-x     - root 10 Sep 11:36  by-path
crw-rw---- 13,64 root 10 Sep 11:36  event0
crw-rw---- 13,65 root 10 Sep 11:36  event1
crw-rw---- 13,66 root 10 Sep 11:36  event2
crw-rw---- 13,67 root 10 Sep 11:36  event3
crw-rw---- 13,68 root 10 Sep 11:36  event4
crw-rw---- 13,69 root 10 Sep 11:36  event5
crw-rw---- 13,70 root 10 Sep 11:36  event6
crw-rw---- 13,71 root 10 Sep 11:36  event7
crw-rw---- 13,72 root 10 Sep 11:36  event8
crw-rw---- 13,73 root 10 Sep 11:36  event9
crw-rw---- 13,74 root 10 Sep 11:36  event10
crw-rw---- 13,75 root 10 Sep 11:36  event11
crw-rw---- 13,76 root 10 Sep 11:36  event12
crw-rw---- 13,77 root 10 Sep 11:36  event13
crw-rw---- 13,78 root 10 Sep 11:36  event14
crw-rw---- 13,79 root 10 Sep 11:36  event15
crw-rw---- 13,80 root 10 Sep 11:36  event16
crw-rw---- 13,81 root 10 Sep 11:36  event17
crw-rw---- 13,82 root 10 Sep 11:36  event18
crw-rw---- 13,83 root 10 Sep 11:36  event19
crw-rw---- 13,84 root 10 Sep 11:36  event20
crw-rw---- 13,85 root 10 Sep 11:36  event21
crw-rw---- 13,86 root 10 Sep 11:36  event22
crw-rw---- 13,87 root 10 Sep 11:36  event23
crw-rw---- 13,88 root 10 Sep 11:36  event24
crw-rw---- 13,89 root 10 Sep 11:36  event25
crw-rw---- 13,90 root 10 Sep 11:36  event26
crw-rw-r--  13,0 root 10 Sep 11:36  js0
crw-rw---- 13,63 root 10 Sep 11:36  mice
crw-rw---- 13,32 root 10 Sep 11:36  mouse0
crw-rw---- 13,33 root 10 Sep 11:36  mouse1
igo95862 commented 2 weeks ago

Looks like only js0 has the read permission. The current algorithm is very imperfect and relies on permissions of input device to have read permission. I have plans to use the udev but it has to wait for my library to add sd-device functionality.

Meanwhile you can try passing the missing eventX files using the debug service. This is very unreliable but see if that fixes the switch controller support.

FeyrisTan commented 2 weeks ago

Meaning like this?

[debug]
raw_bwrap_args = [
  "/dev/input/event27",
  "/dev/input/event28",
 ]

because that does not work

igo95862 commented 2 weeks ago

Like this:

[debug]
raw_bwrap_args = [
  "--dev-bind", "/dev/input/event27", "/dev/input/event27",
  "--dev-bind",  "/dev/input/event28", "/dev/input/event28",
 ]

See bwrap man page.

FeyrisTan commented 2 weeks ago

That does the trick! Ty for your help!

FeyrisTan commented 2 weeks ago

Ah ofc there is still something not working.. Motion controls.

igo95862 commented 2 weeks ago

Do they have their own eventX device files?

FeyrisTan commented 2 weeks ago

I only see event27 and 28 being added when connecting the controller

igo95862 commented 2 weeks ago

Can you run udevadm monitor and post what it outputs when a controller gets plugged in?

FeyrisTan commented 2 weeks ago
❯ udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent

KERNEL[15058.196520] add      /devices/pci0000:00/0000:00:14.0/usb1/1-9/1-9:1.0/bluetooth/hci0/hci0:256 (bluetooth)
UDEV  [15058.198560] add      /devices/pci0000:00/0000:00:14.0/usb1/1-9/1-9:1.0/bluetooth/hci0/hci0:256 (bluetooth)
KERNEL[15058.327234] add      /devices/virtual/misc/uhid/0005:057E:2009.000C (hid)
KERNEL[15058.327449] add      /devices/virtual/misc/uhid/0005:057E:2009.000C/hidraw/hidraw9 (hidraw)
UDEV  [15058.327700] add      /devices/virtual/misc/uhid/0005:057E:2009.000C (hid)
UDEV  [15058.331130] add      /devices/virtual/misc/uhid/0005:057E:2009.000C/hidraw/hidraw9 (hidraw)
KERNEL[15059.521118] add      /devices/virtual/misc/uhid/0005:057E:2009.000C/leds/0005:057E:2009.000C:green:player-1 (leds)
KERNEL[15059.521138] add      /devices/virtual/misc/uhid/0005:057E:2009.000C/leds/0005:057E:2009.000C:green:player-2 (leds)
KERNEL[15059.521147] add      /devices/virtual/misc/uhid/0005:057E:2009.000C/leds/0005:057E:2009.000C:green:player-3 (leds)
KERNEL[15059.521155] add      /devices/virtual/misc/uhid/0005:057E:2009.000C/leds/0005:057E:2009.000C:green:player-4 (leds)
UDEV  [15059.521714] add      /devices/virtual/misc/uhid/0005:057E:2009.000C/leds/0005:057E:2009.000C:green:player-1 (leds)
UDEV  [15059.522556] add      /devices/virtual/misc/uhid/0005:057E:2009.000C/leds/0005:057E:2009.000C:green:player-2 (leds)
UDEV  [15059.522577] add      /devices/virtual/misc/uhid/0005:057E:2009.000C/leds/0005:057E:2009.000C:green:player-3 (leds)
UDEV  [15059.522704] add      /devices/virtual/misc/uhid/0005:057E:2009.000C/leds/0005:057E:2009.000C:green:player-4 (leds)
KERNEL[15059.542134] add      /devices/virtual/misc/uhid/0005:057E:2009.000C/leds/0005:057E:2009.000C:blue:player-5 (leds)
KERNEL[15059.542153] add      /devices/virtual/misc/uhid/0005:057E:2009.000C/power_supply/nintendo_switch_controller_battery_0005:057E:2009.000C/wakeup39 (wakeup)
KERNEL[15059.542168] add      /devices/virtual/misc/uhid/0005:057E:2009.000C/power_supply/nintendo_switch_controller_battery_0005:057E:2009.000C/hwmon4 (hwmon)
KERNEL[15059.542207] add      /devices/virtual/misc/uhid/0005:057E:2009.000C/input/input34 (input)
KERNEL[15059.542234] add      /devices/virtual/misc/uhid/0005:057E:2009.000C/input/input34/event27 (input)
KERNEL[15059.542252] add      /devices/virtual/misc/uhid/0005:057E:2009.000C/input/input35 (input)
KERNEL[15059.542264] add      /devices/virtual/misc/uhid/0005:057E:2009.000C/input/input35/event28 (input)
KERNEL[15059.542283] bind     /devices/virtual/misc/uhid/0005:057E:2009.000C (hid)
UDEV  [15059.542606] add      /devices/virtual/misc/uhid/0005:057E:2009.000C/power_supply/nintendo_switch_controller_battery_0005:057E:2009.000C/wakeup39 (wakeup)
UDEV  [15059.542868] add      /devices/virtual/misc/uhid/0005:057E:2009.000C/leds/0005:057E:2009.000C:blue:player-5 (leds)
UDEV  [15059.542882] add      /devices/virtual/misc/uhid/0005:057E:2009.000C/power_supply/nintendo_switch_controller_battery_0005:057E:2009.000C/hwmon4 (hwmon)
UDEV  [15059.543217] add      /devices/virtual/misc/uhid/0005:057E:2009.000C/input/input34 (input)
UDEV  [15059.543754] add      /devices/virtual/misc/uhid/0005:057E:2009.000C/input/input35 (input)
KERNEL[15059.554085] change   /devices/virtual/misc/uhid/0005:057E:2009.000C/power_supply/nintendo_switch_controller_battery_0005:057E:2009.000C (power_supply)
UDEV  [15059.556064] add      /devices/virtual/misc/uhid/0005:057E:2009.000C/input/input35/event28 (input)
UDEV  [15059.556163] add      /devices/virtual/misc/uhid/0005:057E:2009.000C/input/input34/event27 (input)
UDEV  [15059.556570] bind     /devices/virtual/misc/uhid/0005:057E:2009.000C (hid)
UDEV  [15059.556974] change   /devices/virtual/misc/uhid/0005:057E:2009.000C/power_supply/nintendo_switch_controller_battery_0005:057E:2009.000C (power_supply)
igo95862 commented 2 weeks ago

Hmmm... Maybe try adding the "--dev-bind", "/sys/devices/virtual/misc/uhid/0005:057E:2009.000C", "/sys/devices/virtual/misc/uhid/0005:057E:2009.000C",to the raw bwrap args? (not sure if it will work)

FeyrisTan commented 2 weeks ago

that did not work