Linux needs UDEV rules to use hidraw for SDL2 Motion Input on Multiple Controllers #1097

Open
opened 2024-02-18 21:53:42 -03:00 by theofficialgman · 12 comments
theofficialgman commented 2024-02-18 21:53:42 -03:00 (Migrated from github.com)

Current Behavior

use motion is greyed out on Nintendo Switch Pro Controller when the wii u gamepad input is selected

Expected Behavior

expect that use motion is available. see https://github.com/cemu-project/Cemu/issues/1097#issuecomment-1952626670 for fix

Steps to Reproduce

use latest appimage with nintendo switch pro controller. attempt to use SDL input and select use motion but it is greyed out

System Info (Optional)

No response

Emulation Settings (Optional)

No response

Logs (Optional)

No response

### Current Behavior use motion is greyed out on `Nintendo Switch Pro Controller` when the wii u gamepad input is selected ### Expected Behavior expect that use motion is available. see https://github.com/cemu-project/Cemu/issues/1097#issuecomment-1952626670 for fix ### Steps to Reproduce use latest appimage with nintendo switch pro controller. attempt to use SDL input and select use motion but it is greyed out ### System Info (Optional) _No response_ ### Emulation Settings (Optional) _No response_ ### Logs (Optional) _No response_
theofficialgman commented 2024-02-18 21:58:48 -03:00 (Migrated from github.com)

same issue on flatpak

same issue on flatpak
Squall-Leonhart commented 2024-02-19 04:30:22 -03:00 (Migrated from github.com)

insufficient information to act on or investigate.

What controller is this.
what linux distribution and version

Your github profile tells me you should know better than to post such a vague and unactionable issue.

insufficient information to act on or investigate. What controller is this. what linux distribution and version Your github profile tells me you should know better than to post such a vague and unactionable issue.
theofficialgman commented 2024-02-19 10:32:09 -03:00 (Migrated from github.com)

What controller is this.

Controller name already provided twice. To reiterate, it's an official Nintendo switch pro controller.

what linux distribution and version

Also already partially provided. Flatpak distribution and appimage on Kubuntu Mantic 23.10.
I tested the appimages on another system today on Kubuntu Noble 24.04 development and do not have this issue.

Your github profile tells me you should know better than to post such a vague and unactionable issue.

I typically don't provide repetitive and extra irrelevant information. At the time it appeared that distro was likey irrelevant as long as hid-nintendo driver was being used from the kernel as sdl is provided in the appimage statically linked in the main binary.

> What controller is this. Controller name already provided twice. To reiterate, it's an official Nintendo switch pro controller. > what linux distribution and version Also already partially provided. Flatpak distribution and appimage on Kubuntu Mantic 23.10. I tested the appimages on another system today on Kubuntu Noble 24.04 development and do not have this issue. > Your github profile tells me you should know better than to post such a vague and unactionable issue. I typically don't provide repetitive and extra irrelevant information. At the time it appeared that distro was likey irrelevant as long as hid-nintendo driver was being used from the kernel as sdl is provided in the appimage statically linked in the main binary.
Squall-Leonhart commented 2024-02-19 10:54:10 -03:00 (Migrated from github.com)

6.5.0.25.25 has a proposed(and accepted) fix for switch pro controller issues.

6.5.0.25.25 has a proposed(and accepted) fix for switch pro controller issues.
theofficialgman commented 2024-02-19 10:56:50 -03:00 (Migrated from github.com)

I looked into this. it appears that one system is in the input group (the one that works) and the other is not. the system with the user in the input group can read all /dev/input/ nodes without root. the one that isn't cannot and can only read the device node for Nintendo Switch Pro Controller and not Nintendo Switch Pro Controller IMU because only the former has extended permissions for my user (getfacl shows this).

I looked into this. it appears that one system is in the `input` group (the one that works) and the other is not. the system with the user in the `input` group can read all `/dev/input/` nodes without root. the one that isn't cannot and can only read the device node for `Nintendo Switch Pro Controller` and not `Nintendo Switch Pro Controller IMU` because only the former has extended permissions for my user (getfacl shows this).
Squall-Leonhart commented 2024-02-19 11:01:38 -03:00 (Migrated from github.com)

Then this SDL issue explains whats up https://github.com/libsdl-org/SDL/issues/8125

Then this SDL issue explains whats up https://github.com/libsdl-org/SDL/issues/8125
Squall-Leonhart commented 2024-02-19 11:03:23 -03:00 (Migrated from github.com)

Actually, apologies but its this one https://github.com/libsdl-org/SDL/issues/6478

The current dkms-nintendo driver only supplies the motion data as a dev/input/event

Actually, apologies but its this one https://github.com/libsdl-org/SDL/issues/6478 The current dkms-nintendo driver only supplies the motion data as a dev/input/event
theofficialgman commented 2024-02-19 11:05:17 -03:00 (Migrated from github.com)

Then this SDL issue explains whats up libsdl-org/SDL#8125
Actually, apologies but its this one libsdl-org/SDL#6478

no and no. the problem is not that it is exposed separated. that is solved in SDL2 years ago now (see the second issue PR close reason). the problem is that Nintendo Switch Pro Controller IMU doesn't have extended permissions to be read by my user without input group access.

> Then this SDL issue explains whats up [libsdl-org/SDL#8125](https://github.com/libsdl-org/SDL/issues/8125) > Actually, apologies but its this one [libsdl-org/SDL#6478](https://github.com/libsdl-org/SDL/issues/6478) no and no. the problem is not that it is exposed separated. that is solved in SDL2 years ago now (see the second issue PR close reason). the problem is that `Nintendo Switch Pro Controller IMU` doesn't have extended permissions to be read by my user without `input` group access.
Squall-Leonhart commented 2024-02-19 11:26:39 -03:00 (Migrated from github.com)

https://github.com/libsdl-org/SDL/pull/7697 was first added to SDL 3.0 to partially (not fully) mitigate
the udev rule with read access is still required to get the sensor.

https://github.com/libsdl-org/SDL/pull/8336 backports the change to SDL 2.30 which has only just come out, should in part correct this issue and #753.

https://github.com/libsdl-org/SDL/pull/7697 was first added to SDL 3.0 to partially (not fully) mitigate the udev rule with read access is still required to get the sensor. https://github.com/libsdl-org/SDL/pull/8336 backports the change to SDL 2.30 which has only just come out, should in part correct this issue and #753.
theofficialgman commented 2024-02-19 11:39:33 -03:00 (Migrated from github.com)

libsdl-org/SDL#7697 was first added to SDL 3.0 to partially (not fully) mitigate the udev rule with read access is still required to get the sensor.

libsdl-org/SDL#8336 backports the change to SDL 2.30 which has only just come out, should in part correct this issue and #753.

I don't see what that PR changes. This already works on SDL2.28.5 (what is used in latest CEMU 2.0-65) as long as read access exists. I am not really sure why it works already since that PR is not in 2.28.5 edit: see https://github.com/cemu-project/Cemu/issues/1097#issuecomment-1952626670

The PR to systemd linked within that PR (https://github.com/libsdl-org/SDL/pull/7697#issuecomment-1593369338) is what is needed though to add uaccess so that regular users can read the IMU https://github.com/systemd/systemd/pull/22860

> [libsdl-org/SDL#7697](https://github.com/libsdl-org/SDL/pull/7697) was first added to SDL 3.0 to partially (not fully) mitigate the udev rule with read access is still required to get the sensor. > > [libsdl-org/SDL#8336](https://github.com/libsdl-org/SDL/pull/8336) backports the change to SDL 2.30 which has only just come out, should in part correct this issue and #753. ~~I don't see what that PR changes. This already works on SDL2.28.5 (what is used in latest CEMU 2.0-65) as long as read access exists. I am not really sure why it works already since that PR is not in 2.28.5~~ edit: see https://github.com/cemu-project/Cemu/issues/1097#issuecomment-1952626670 The PR to systemd linked within that PR (https://github.com/libsdl-org/SDL/pull/7697#issuecomment-1593369338) is what is needed though to add uaccess so that regular users can read the IMU https://github.com/systemd/systemd/pull/22860
theofficialgman commented 2024-02-19 11:58:25 -03:00 (Migrated from github.com)

even after removing the user from the input group and rebooting it still works on my noble machine. it appears that on connecting the controller in CEMU the controller restarts or reconnects (the lights change). according to the PRs hidraw based input and motion should already be functioning in SDL2 and I have found that is what is being used here (instead of hid-nintendo event# inputs).

It works on my one system through HIDRAW as a side affect of having Steam installed, which installs a udev rule for hidraw access by user as part of the package

/lib/udev/rules.d/60-steam-input.rules

# Nintendo Switch Pro Controller over USB hidraw
KERNEL=="hidraw*", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="2009", MODE="0660", TAG+="uaccess"

# Nintendo Switch Pro Controller over bluetooth hidraw
KERNEL=="hidraw*", KERNELS=="*057E:2009*", MODE="0660", TAG+="uaccess"

60-steam-input.rules.zip

so basically, the only way it is going to work in the current SDL2 (2.28.5) is if the user has that udev rule provided for hidraw access via user, like steam provides.

I have confirmed adding that rule (not all of steam, just the rule) to the system that previously was not working fixes it.

even after removing the user from the `input` group and rebooting it still works on my noble machine. it appears that on connecting the controller in CEMU the controller restarts or reconnects (the lights change). according to the PRs hidraw based input and motion should already be functioning in SDL2 and I have found that is what is being used here (instead of hid-nintendo event# inputs). It works on my one system through HIDRAW as a side affect of having Steam installed, which installs a udev rule for hidraw access by user as part of the package `/lib/udev/rules.d/60-steam-input.rules` ``` # Nintendo Switch Pro Controller over USB hidraw KERNEL=="hidraw*", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="2009", MODE="0660", TAG+="uaccess" # Nintendo Switch Pro Controller over bluetooth hidraw KERNEL=="hidraw*", KERNELS=="*057E:2009*", MODE="0660", TAG+="uaccess" ``` [60-steam-input.rules.zip](https://github.com/cemu-project/Cemu/files/14333958/60-steam-input.rules.zip) so basically, the only way it is going to work in the current SDL2 (2.28.5) is if the user has that udev rule provided for hidraw access via user, like steam provides. I have confirmed adding that rule (not all of steam, just the rule) to the system that previously was not working fixes it.
theofficialgman commented 2024-02-19 12:03:48 -03:00 (Migrated from github.com)

testing the gyro in Nintendo Land it works but it appears to be offset by 90deg (I am looking at the ground with the controller flat, I have to hold the controller up/down to make it look forward).

Not sure if this is incorrect parsing by SDL2 of the hidraw input or incorrect parsing by Cemu.

edit: nevermind, just checked, that is just how this game was and I forgot.

testing the gyro in Nintendo Land it works ~~but it appears to be offset by 90deg (I am looking at the ground with the controller flat, I have to hold the controller up/down to make it look forward).~~ ~~Not sure if this is incorrect parsing by SDL2 of the hidraw input or incorrect parsing by Cemu.~~ edit: nevermind, just checked, that is just how this game was and I forgot.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: cemu-project_Mirror/Cemu-2024-03-05#1097
No description provided.