DanielOgorchock / joycond

userspace daemon to combine joy-cons from the hid-nintendo kernel driver
GNU General Public License v3.0
360 stars 68 forks source link

Installing joycond Breaks Switch Pro Controller Compatibility With Steam (bad MODE in 89-joycond.rules) #84

Open gardotd426 opened 2 years ago

gardotd426 commented 2 years ago

So I installed joycond-cemuhook-git so I could have motion controls in Ryujinx and Yuzu, etc. But I noticed that Steam was no longer detecting my Switch Pro controller over Bluetooth, only over USB-C. So I uninstalled joycond, (and by extension joycond-cemuhook-git) and sure enough, Steam immediately started picking up the Switch Pro controller over BT again.

I didn't understand how this was possible since I was obviously unloading hid-nintendo before opening Steam, but I eventually tracked it down to joycond's /usr/lib/udev/rules.d/89-joycond.rules. That's what breaks Steam BT detection.

See, the nintendo-udev and game-devices-udev packages on Arch also provide udev .rules files for Switch Pro controllers, but they differ in their content (I'll just be posting the Switch Pro Bluetooth lines here):

71-nintendo-controllers.rules (game-devices-udev):

KERNEL=="hidraw*", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="2009", MODE="0660", TAG+="uaccess"

70-nintendo.rules (nintendo-udev):

KERNEL=="hidraw*", SUBSYSTEM=="hidraw", KERNELS=="0005:057E:2009.*", MODE="0666"

89-joycond.rules (joycond):

KERNEL=="hidraw*", KERNELS=="*057E:2009*", MODE="0600", TAG-="uaccess", RUN+="/bin/setfacl -b /dev/%k"

So, I removed the joycond 89-joycond.rules file, ran sudo udevadm control --reload-rules && sudo udevadm trigger, and tried again. joycond-cemuhook-git still worked, I still had motion controls in my emulators, but what's more is that Steam actually picked up the controller over Bluetooth.

So I placed the 89-joycond.rules file back in /usr/lib/udev/rules.d and reloaded udev again, but first I edited the relevant line and changed MODE="0600" toMODE="0666"like the 70-nintendo.rules file was using. Once again, everything worked. So then I tried0660like71-nintendo-controllers.rules` has, and everything worked with that, too.

So your setting 0600 in 89-joycond.rules is confirmed to be what breaks Steam detection of the Switch Pro controller over Bluetooth. I considered filing a PR with it changed to either 0660 or 0666 but I wanted to file this issue instead so you could choose which is better, but joycond seems to still work with both 0660 and 0666. I just tested about 5 times in a row with 0660, loaded hid-nintendo, ran joycond successfully, ran joycond-cemuhook, tested motion controls in Ryujinx, killed joycond-cemuhook and joycond, unloaded hid-nintendo, opened steam, connected controller via BT, controller is detected, repeat. If I change it back to your 0600 it immediately breaks BT detection in Steam.

Toomoch commented 2 years ago

check this commit, it's intentional: https://github.com/DanielOgorchock/joycond/commit/e1cd6b01bd9b3c8f552c04db1011f009ea4abe87. steam messes the inputs up if hid-nintendo and joycond are loaded, because steam has it's own driver

gardotd426 commented 2 years ago

No what I'm saying is that it breaks Steam detecting the controller over Bluetooth even when joycond is not running and hid-nintendo is not loaded. Unless I change MODE="0600" to MODE="0660"

gardotd426 commented 2 years ago

Does changing that one line to MODE="0660" affect the workaround at all? I didn't see any negative effects

DanielOgorchock commented 2 years ago

The behavior is intentional to hide hidraw completely from steam for the controller. I didn't foresee someone disabling hid nintendo while having joycond installed. Maybe the udev rule can have an additional filter added to check that hid-nintendo is the driver bound to the input device.

The intended way to use the pro controller with steam with joycond is to use the hid-nintendo driver, and then when the player LEDs are blinking, press the Plus and Minus buttons simultaneously. Then steam will be able to use the controller as a generic evdev device.

gardotd426 commented 2 years ago

The behavior is intentional to hide hidraw completely from steam for the controller. I didn't foresee someone disabling hid nintendo while having joycond installed.

Well yeah I disable hid-nintendo because per the Arch Wiki hid-nintendo conflicts with SteamInput's Switch Pro Controller driver. Does using the method you described (with hid-nintendo) allow full functionality within Steam like SteamInput does? Like gyro support, rumble, etc.?

EDIT: Seems it doesn't support Gyro controls at all when using this method, I haven't checked rumble yet. So yeah I can definitely see people wanting to use Steam Input (unless Gyro support inside Steam is planned for this project?).

I guess I'll have to just manually edit that .rules file myself (like I said, joycond and joycond-cemuhook both work fine with the 0600 changed to 0660, it just also allows Steam to connect).

gardotd426 commented 2 years ago

So actually, with everything stock (no modifying any files), Steam can't detect the controller even through USB with joycond installed (not even running, just installed). Obviously since it's connected via USB, pressing the Plus+Minus buttons does nothing.

What's more, I don't know if this should be a separate issue but actually running joycond completely breaks any ability to even use the Switch Pro Controller. What I mean is, when I start joycond, and then connect the controller (regardless of whether it's Bluetooth or USB), the four indicator LEDs on the bottom start flashing, and they don't stop. Like, I can leave it sat for 10 minutes and nothing happens.

The only terminal output is the following:

adding epoll_subscriber: fd=4
Creating new phys_ctlr for /dev/input/event4
Found Pro Controller
no match found for /sys//devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:0b:00.3/usb3/3-2/3-2:1.0/bluetooth/hci0/hci0:256/0005:057E:2009.000C/input/input39/event4/device/device/leds/*player*5
driver_name: Nintendo Switch Pro Controller
MAC: 70:48:F7:70:C9:7F
adding epoll_subscriber: fd=5
DEVNAME=event4 ACTION=remove DEVPATH=/devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:0b:00.3/usb3/3-2/3-2:1.0/bluetooth/hci0/hci0:256/0005:057E:2009.000C/input/input39/event4
Removing /devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:0b:00.3/usb3/3-2/3-2:1.0/bluetooth/hci0/hci0:256/0005:057E:2009.000C/input/input39/event4 from unpaired list
DEVNAME=event23 ACTION=add DEVPATH=/devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:0b:00.3/usb3/3-1/3-1:1.0/0003:057E:2009.000D/input/input41/event23
Creating new phys_ctlr for /dev/input/event23
Found Pro Controller
no match found for /sys//devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:0b:00.3/usb3/3-1/3-1:1.0/0003:057E:2009.000D/input/input41/event23/device/device/leds/*player*5
driver_name: Nintendo Switch Pro Controller
MAC: 70:48:F7:70:C9:7F
adding epoll_subscriber: fd=5

I of course have hid-nintendo loaded. If I don't run joycond, then I can use the controller fine (outside of Steam). Weirdly enough I can even use joycond-cemuhook-git which supposedly requires joycond to work.

The second I try and use joycond, it breaks compatibility. The lights just flash and flash. And I don't mean the cascading lights, like 1 then 2 then 3 then 4, I mean all 4 indicator LEDS flash together.

I've tried reboots, I've tried with both 5.14.20 and 5.15.4, I have no idea what's going on but it seems like joycond is just flat out broken with the Switch Pro controller at the moment.

DanielOgorchock commented 2 years ago

So actually, with everything stock (no modifying any files), Steam can't detect the controller even through USB with joycond installed (not even running, just installed). Obviously since it's connected via USB, pressing the Plus+Minus buttons does nothing.

What's more, I don't know if this should be a separate issue but actually running joycond completely breaks any ability to even use the Switch Pro Controller. What I mean is, when I start joycond, and then connect the controller (regardless of whether it's Bluetooth or USB), the four indicator LEDs on the bottom start flashing, and they don't stop. Like, I can leave it sat for 10 minutes and nothing happens.

The only terminal output is the following:

adding epoll_subscriber: fd=4
Creating new phys_ctlr for /dev/input/event4
Found Pro Controller
no match found for /sys//devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:0b:00.3/usb3/3-2/3-2:1.0/bluetooth/hci0/hci0:256/0005:057E:2009.000C/input/input39/event4/device/device/leds/*player*5
driver_name: Nintendo Switch Pro Controller
MAC: 70:48:F7:70:C9:7F
adding epoll_subscriber: fd=5
DEVNAME=event4 ACTION=remove DEVPATH=/devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:0b:00.3/usb3/3-2/3-2:1.0/bluetooth/hci0/hci0:256/0005:057E:2009.000C/input/input39/event4
Removing /devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:0b:00.3/usb3/3-2/3-2:1.0/bluetooth/hci0/hci0:256/0005:057E:2009.000C/input/input39/event4 from unpaired list
DEVNAME=event23 ACTION=add DEVPATH=/devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:0b:00.3/usb3/3-1/3-1:1.0/0003:057E:2009.000D/input/input41/event23
Creating new phys_ctlr for /dev/input/event23
Found Pro Controller
no match found for /sys//devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:0b:00.3/usb3/3-1/3-1:1.0/0003:057E:2009.000D/input/input41/event23/device/device/leds/*player*5
driver_name: Nintendo Switch Pro Controller
MAC: 70:48:F7:70:C9:7F
adding epoll_subscriber: fd=5

I of course have hid-nintendo loaded. If I don't run joycond, then I can use the controller fine (outside of Steam). Weirdly enough I can even use joycond-cemuhook-git which supposedly requires joycond to work.

The second I try and use joycond, it breaks compatibility. The lights just flash and flash. And I don't mean the cascading lights, like 1 then 2 then 3 then 4, I mean all 4 indicator LEDS flash together.

I've tried reboots, I've tried with both 5.14.20 and 5.15.4, I have no idea what's going on but it seems like joycond is just flat out broken with the Switch Pro controller at the moment.

If the LEDs are blinking in unison, that means joycond is waiting for you to press the triggers on the controller (or optionally Plus and Minus for the pro controller). Are you saying it doesn't react to pressing the triggers?

DanielOgorchock commented 2 years ago

If you want to use steam input, comment out lines 3 and 5 of 89-joycond.rules. I'll try to think of a better way to toggle this without having to modify the udev rules.

banaanihillo commented 1 year ago

@gardotd426 @DanielOgorchock pardon me for revisiting an old (but open) issue, but I'm trying to make the best of the fragments of information about Nintendo Switch (Pro / Joy-Con) gyro support on Steam for Linux,

If at all possible, could you append the read-me or add a gist with the instructions above, assuming they still work? If I understood correctly, it is possible to selectively enable or disable parts of hidraw / joycond / udev rules / hid-nintendo to make Steam use its own control support (with motion controls support), but the potential instructions are a bit buried underneath a couple layers of trial and error, judging by the earlier comments.

I understand that this whole discussion may be outdated, especially due to the fact that hid-nintendo should be part of the mainline kernel by now, right? If you could point me in any direction as to the current support of Nintendo Switch gyro-capable controllers on Steam, with or without Steam's own controller support, I'd really appreciate it!