The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=b6cad334e649f49c57da52b139de353ad9078985
commit b6cad334e649f49c57da52b139de353ad9078985 Author: Vladimir Kondratyev <[email protected]> AuthorDate: 2025-12-01 20:42:15 +0000 Commit: Vladimir Kondratyev <[email protected]> CommitDate: 2025-12-01 20:42:15 +0000 hid: Make game controllers accessible to members of the game group Their events have to be accessible by unprivileged users via e.g. libsdl. MFC after: 1 month --- share/man/man4/hgame.4 | 7 ++++--- share/man/man4/ps4dshock.4 | 5 ++++- share/man/man4/xb360gp.4 | 5 ++++- sys/dev/hid/hgame.c | 7 ++++++- sys/dev/hid/ps4dshock.c | 9 ++++++++- 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/share/man/man4/hgame.4 b/share/man/man4/hgame.4 index 94ad4f5ff4a4..dd69d9ef3de1 100644 --- a/share/man/man4/hgame.4 +++ b/share/man/man4/hgame.4 @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd November 12, 2025 +.Dd November 30, 2025 .Dt HGAME 4 .Os .Sh NAME @@ -69,8 +69,9 @@ prompt, or add it to To give user applications access to the game controllers, allow user access to the .Pa /dev/input/event* -nodes with -.Xr devfs.rules 5 . +nodes with inclusion of user in the +.Em games +group. .Sh HARDWARE The .Nm diff --git a/share/man/man4/ps4dshock.4 b/share/man/man4/ps4dshock.4 index 282a58c49e63..f48e2c07c1b7 100644 --- a/share/man/man4/ps4dshock.4 +++ b/share/man/man4/ps4dshock.4 @@ -21,7 +21,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd September 19, 2020 +.Dd November 30, 2025 .Dt PS4DSHOCK 4 .Os .Sh NAME @@ -55,6 +55,9 @@ The device presents the game controller as a .Ar evdev type device. +It is accessible to members of the +.Em games +group. .Sh SYSCTL VARIABLES Next parameters are available as .Xr sysctl 8 diff --git a/share/man/man4/xb360gp.4 b/share/man/man4/xb360gp.4 index 4e8d4b65fcfd..1ff42e970858 100644 --- a/share/man/man4/xb360gp.4 +++ b/share/man/man4/xb360gp.4 @@ -21,7 +21,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd September 16, 2020 +.Dd November 30, 2025 .Dt XB360GP 4 .Os .Sh NAME @@ -56,6 +56,9 @@ The device presents the game controller as a .Ar evdev type device. +It is accessible to members of the +.Em games +group. .Sh SYSCTL VARIABLES The following variable is available as both .Xr sysctl 8 diff --git a/sys/dev/hid/hgame.c b/sys/dev/hid/hgame.c index b074f6145d0e..8dde6b5550c9 100644 --- a/sys/dev/hid/hgame.c +++ b/sys/dev/hid/hgame.c @@ -33,8 +33,10 @@ #include <sys/param.h> #include <sys/bus.h> +#include <sys/conf.h> #include <sys/kernel.h> #include <sys/module.h> +#include <sys/stat.h> #include <sys/sysctl.h> #include <dev/evdev/input.h> @@ -170,8 +172,11 @@ hgame_final_cb(HIDMAP_CB_ARGS) { struct evdev_dev *evdev = HIDMAP_CB_GET_EVDEV(); - if (HIDMAP_CB_GET_STATE() == HIDMAP_CB_IS_ATTACHING) + if (HIDMAP_CB_GET_STATE() == HIDMAP_CB_IS_ATTACHING) { evdev_support_prop(evdev, INPUT_PROP_DIRECT); + evdev_set_cdev_mode(evdev, UID_ROOT, GID_GAMES, + S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); + } /* Do not execute callback at interrupt handler and detach */ return (ENOSYS); diff --git a/sys/dev/hid/ps4dshock.c b/sys/dev/hid/ps4dshock.c index d3c6b3eeadf9..1cd9cb13bad3 100644 --- a/sys/dev/hid/ps4dshock.c +++ b/sys/dev/hid/ps4dshock.c @@ -37,10 +37,12 @@ #include <sys/param.h> #include <sys/bus.h> +#include <sys/conf.h> #include <sys/kernel.h> #include <sys/lock.h> #include <sys/malloc.h> #include <sys/module.h> +#include <sys/stat.h> #include <sys/sx.h> #include <sys/sysctl.h> @@ -806,8 +808,11 @@ ps4dshock_final_cb(HIDMAP_CB_ARGS) { struct evdev_dev *evdev = HIDMAP_CB_GET_EVDEV(); - if (HIDMAP_CB_GET_STATE() == HIDMAP_CB_IS_ATTACHING) + if (HIDMAP_CB_GET_STATE() == HIDMAP_CB_IS_ATTACHING) { evdev_support_prop(evdev, INPUT_PROP_DIRECT); + evdev_set_cdev_mode(evdev, UID_ROOT, GID_GAMES, + S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); + } /* Do not execute callback at interrupt handler and detach */ return (ENOSYS); @@ -886,6 +891,8 @@ ps4dsacc_final_cb(HIDMAP_CB_ARGS) if (HIDMAP_CB_GET_STATE() == HIDMAP_CB_IS_ATTACHING) { evdev_support_event(evdev, EV_ABS); evdev_support_prop(evdev, INPUT_PROP_ACCELEROMETER); + evdev_set_cdev_mode(evdev, UID_ROOT, GID_GAMES, + S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); } /* Do not execute callback at interrupt handler and detach */ return (ENOSYS);
