[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260104213132.163904-7-tomasz.pakula.oficjalny@gmail.com>
Date: Sun, 4 Jan 2026 22:31:32 +0100
From: Tomasz Pakuła <tomasz.pakula.oficjalny@...il.com>
To: dmitry.torokhov@...il.com,
corbet@....net,
jikos@...nel.org,
bentiss@...nel.org
Cc: linux-input@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-doc@...r.kernel.org,
vi@...rift.com,
linux-kernel@...imeter.info,
peter.hutterer@...-t.net
Subject: [RFC PATCH 6/6] Input: Add EVIOCGBTNCNT
Allow userspace to get the button count of input
devices. currently only used for Joysticks which
includes Simracing and Simflight hardware. Such
devices are always defined as generic joysticks.
Signed-off-by: Tomasz Pakuła <tomasz.pakula.oficjalny@...il.com>
---
drivers/input/evdev.c | 5 +++++
include/uapi/linux/input.h | 1 +
2 files changed, 6 insertions(+)
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 90ff6be85cf4..b90dc035c0b3 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -1134,6 +1134,11 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
case EVIOCSKEYCODE_V2:
return evdev_handle_set_keycode_v2(dev, p);
+
+ case EVIOCGBTNCNT:
+ if (copy_to_user(p, &dev->button_count, sizeof(unsigned int)))
+ return -EFAULT;
+ return 0;
}
size = _IOC_SIZE(cmd);
diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h
index 6aa703fcfcfb..3d1b17ebcdfc 100644
--- a/include/uapi/linux/input.h
+++ b/include/uapi/linux/input.h
@@ -174,6 +174,7 @@ struct input_mask {
#define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len) /* get all LEDs */
#define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len) /* get all sounds status */
#define EVIOCGSW(len) _IOC(_IOC_READ, 'E', 0x1b, len) /* get all switch states */
+#define EVIOCGBTNCNT _IOR('E', 0x1c, unsigned int) /* get button count */
#define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + (ev), len) /* get event bits */
#define EVIOCGABS(abs) _IOR('E', 0x40 + (abs), struct input_absinfo) /* get abs value/limits */
--
2.52.0
Powered by blists - more mailing lists