From ca6bb3ae1d2805e92aef30a99abb12ec9d6d795e Mon Sep 17 00:00:00 2001 From: crueter Date: Sun, 17 May 2026 23:44:57 +0200 Subject: [PATCH] [cmake, dist] Update udev rule to act on all joysticks, and add install option (#3968) This is needed for gyro access. Signed-off-by: crueter Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3968 Reviewed-by: Lizzie Reviewed-by: MaranBr --- CMakeLists.txt | 16 ++++++++++++++-- dist/72-eden-input.rules | 8 ++++++++ dist/72-yuzu-input.rules | 19 ------------------- docs/Options.md | 3 +++ 4 files changed, 25 insertions(+), 21 deletions(-) create mode 100644 dist/72-eden-input.rules delete mode 100644 dist/72-yuzu-input.rules diff --git a/CMakeLists.txt b/CMakeLists.txt index 32e873f009..cbb4a25a2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -190,8 +190,7 @@ if(MSVC) $<$:$<$:/${libflag}d>> $<$:$<$:/${libflag}>> $<$:$<$:/${libflag}>> - $<$:$<$:/${libflag}>> - ) + $<$:$<$:/${libflag}>>) endif() # TODO(crueter): Cleanup, each dep that has a bundled option should allow to choose between bundled, external, system @@ -230,6 +229,10 @@ cmake_dependent_option(USE_DISCORD_PRESENCE "Enables Discord Rich Presence" OFF option(YUZU_TESTS "Compile tests" "${BUILD_TESTING}") +# Install udev rules on Linux (mainly for gyros) +# Only acts on joysticks and nothing else. +cmake_dependent_option(YUZU_INSTALL_UDEV_RULES "Install udev rules for gyro access" OFF "PLATFORM_LINUX" OFF) + option(YUZU_DOWNLOAD_ANDROID_VVL "Download validation layer binary for android" ON) option(YUZU_LEGACY "Apply patches that improve compatibility with older GPUs (e.g. Snapdragon 865) at the cost of performance" OFF) @@ -730,6 +733,8 @@ endif() # https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html # https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html # https://www.freedesktop.org/software/appstream/docs/ + +# TODO: Icon/install handling n such should be put into dist/CMakeLists.txt if(ENABLE_QT AND UNIX AND NOT APPLE) install(FILES "dist/dev.eden_emu.eden.desktop" DESTINATION "share/applications") @@ -742,3 +747,10 @@ if(ENABLE_QT AND UNIX AND NOT APPLE) install(FILES "dist/dev.eden_emu.eden.metainfo.xml" DESTINATION "share/metainfo") endif() + +if (YUZU_INSTALL_UDEV_RULES) + include(GNUInstallDirs) + + install(FILES "dist/72-eden-input.rules" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/udev/rules.d") +endif() diff --git a/dist/72-eden-input.rules b/dist/72-eden-input.rules new file mode 100644 index 0000000000..b84ed200a3 --- /dev/null +++ b/dist/72-eden-input.rules @@ -0,0 +1,8 @@ +# SPDX-FileCopyrightText: 2023 yuzu Emulator Project +# SPDX-License-Identifier: GPL-2.0-or-later + +# Allow systemd-logind to manage user access to hidraw with this file +# On most systems, this file should be installed to /etc/udev/rules.d/72-eden-input.rules +# Consult your distro if this is not the case + +KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ENV{ID_INPUT_JOYSTICK}=="1", MODE="0660", TAG+="uaccess" diff --git a/dist/72-yuzu-input.rules b/dist/72-yuzu-input.rules deleted file mode 100644 index d64f8b28d7..0000000000 --- a/dist/72-yuzu-input.rules +++ /dev/null @@ -1,19 +0,0 @@ -# SPDX-FileCopyrightText: 2023 yuzu Emulator Project -# SPDX-License-Identifier: GPL-2.0-or-later - -# Allow systemd-logind to manage user access to hidraw with this file -# On most systems, this file should be installed to /etc/udev/rules.d/72-yuzu-input.rules -# Consult your distro if this is not the case - -# Switch Pro Controller (USB/Bluetooth) -KERNEL=="hidraw*", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="2009", MODE="0660", TAG+="uaccess" -KERNEL=="hidraw*", KERNELS=="*057e:2009*", MODE="0660", TAG+="uaccess" - -# Joy-Con L (Bluetooth) -KERNEL=="hidraw*", KERNELS=="*057e:2006*", MODE="0660", TAG+="uaccess" - -# Joy-Con R (Bluetooth) -KERNEL=="hidraw*", KERNELS=="*057e:2007*", MODE="0660", TAG+="uaccess" - -# Joy-Con Charging Grip (USB) -KERNEL=="hidraw*", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="200e", MODE="0660", TAG+="uaccess" diff --git a/docs/Options.md b/docs/Options.md index 3eb6effe92..adf8127d41 100644 --- a/docs/Options.md +++ b/docs/Options.md @@ -44,6 +44,9 @@ These options control dependencies. - UNIX may be better off appending `-flto=thin` to compiler args - `USE_FASTER_LINKER` (OFF) Check if a faster linker is available - Not recommended outside of Linux +- `YUZU_INSTALL_UDEV_RULES` (OFF) Install udev rules to enable hidraw access + - Needed for gyroscopes + - Only available on Linux ### Flavors