From: "Henrik Rydberg" <rydberg@euromail.se>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Jiri Kosina <jkosina@suse.cz>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Henrik Rydberg <rydberg@euromail.se>,
Ping Cheng <pingc@wacom.com>,
Chris Bagwell <chris@cnpbagwell.com>
Subject: [RFC][PATCH] input: Introduce device information ioctl
Date: Tue, 7 Dec 2010 08:25:26 +0100 [thread overview]
Message-ID: <1291706726-8835-1-git-send-email-rydberg@euromail.se> (raw)
Today, userspace sets up an input device based on the data it emits.
This is not always enough; a tablet and a touchscreen may emit exactly
the same data, for instance, but the former should be set up with a
pointer whereas the latter does not need to. Recently, a new type of
touchpad has emerged where the buttons are under the pad, which changes
handling logic without changing the emitted data. This patch introduces
a new ioctl, EVIOCGDEVINFO, which allows userspace to extract information
about the device resulting in proper setup.
Suggested-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Cc: Ping Cheng <pingc@wacom.com>
Cc: Chris Bagwell <chris@cnpbagwell.com>
---
Hi all,
Here is a patch attempting to formulate Dmitry's device type idea. It
compiles, but further testing awaits a general consesus on the device
types and capabilities to start out with. Are the ones listed here apt
for the job?
Cheers,
Henrik
drivers/input/evdev.c | 6 ++++++
include/linux/input.h | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index e3f7fc6..db78592 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -632,6 +632,12 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
return -EFAULT;
return 0;
+ case EVIOCGDEVINFO:
+ if (copy_to_user(p, &dev->devinfo,
+ sizeof(struct input_devinfo)))
+ return -EFAULT;
+ return 0;
+
case EVIOCGREP:
if (!test_bit(EV_REP, dev->evbit))
return -ENOSYS;
diff --git a/include/linux/input.h b/include/linux/input.h
index 6ef4446..8c58d2a 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -57,6 +57,21 @@ struct input_absinfo {
};
/**
+ * struct input_devinfo - device information via EVIOCGDEVINFO ioctl
+ * @types: bitmask of types (DEVTYPE_*) matching this device
+ * @capabilities: bitmask of capabilities (DEVCAPS_*) of this device
+ *
+ * This struct provides information about the device needed for
+ * automatic setup in userspace, such as if the device is direct
+ * (touchscreen) or indirect (touchpad), and if there are other
+ * special considerations, such as the touchpad also being a button.
+ */
+struct input_devinfo {
+ __u32 types;
+ __u32 capabilities;
+};
+
+/**
* struct input_keymap_entry - used by EVIOCGKEYCODE/EVIOCSKEYCODE ioctls
* @scancode: scancode represented in machine-endian form.
* @len: length of the scancode that resides in @scancode buffer.
@@ -91,6 +106,7 @@ struct input_keymap_entry {
#define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len) /* get device name */
#define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len) /* get physical location */
#define EVIOCGUNIQ(len) _IOC(_IOC_READ, 'E', 0x08, len) /* get unique identifier */
+#define EVIOCGDEVINFO _IOR('E', 0x09, struct input_devinfo) /* get device information */
#define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len) /* get global key state */
#define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len) /* get all LEDs */
@@ -108,6 +124,23 @@ struct input_keymap_entry {
#define EVIOCGRAB _IOW('E', 0x90, int) /* Grab/Release device */
/*
+ * Device types
+ */
+
+#define DEVTYPE_KEYBOARD 0
+#define DEVTYPE_MOUSE 1
+#define DEVTYPE_JOYSTICK 2
+#define DEVTYPE_TOUCHPAD 3
+#define DEVTYPE_TABLET 4
+#define DEVTYPE_TOUCHSCREEN 5
+
+/*
+ * Device capabilities
+ */
+
+#define DEVCAPS_PAD_IS_BUTTON 1
+
+/*
* Event types
*/
@@ -1177,6 +1210,7 @@ struct input_dev {
const char *phys;
const char *uniq;
struct input_id id;
+ struct input_devinfo devinfo;
unsigned long evbit[BITS_TO_LONGS(EV_CNT)];
unsigned long keybit[BITS_TO_LONGS(KEY_CNT)];
--
1.7.1
next reply other threads:[~2010-12-07 7:26 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-07 7:25 Henrik Rydberg [this message]
2010-12-07 9:16 ` Dmitry Torokhov
2010-12-07 10:48 ` Kay Sievers
2010-12-07 10:56 ` Dmitry Torokhov
2010-12-07 11:19 ` Kay Sievers
2010-12-07 12:44 ` Arnd Bergmann
2010-12-07 12:52 ` Kay Sievers
2010-12-07 12:55 ` Arnd Bergmann
2010-12-07 12:40 ` Arnd Bergmann
2010-12-07 12:49 ` Kay Sievers
2010-12-07 16:51 ` Dmitry Torokhov
2010-12-07 19:57 ` Henrik Rydberg
2010-12-08 6:02 ` Dmitry Torokhov
2010-12-08 19:04 ` Henrik Rydberg
2010-12-09 9:25 ` Dmitry Torokhov
2010-12-07 16:22 ` Greg KH
2010-12-07 16:48 ` Dmitry Torokhov
2010-12-07 18:48 ` Ping Cheng
2010-12-07 19:35 ` Dmitry Torokhov
2010-12-07 19:18 ` Chris Bagwell
2010-12-07 19:37 ` Dmitry Torokhov
2010-12-08 20:26 ` Valdis.Kletnieks
2010-12-08 20:37 ` Henrik Rydberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1291706726-8835-1-git-send-email-rydberg@euromail.se \
--to=rydberg@euromail.se \
--cc=chris@cnpbagwell.com \
--cc=dmitry.torokhov@gmail.com \
--cc=jkosina@suse.cz \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pingc@wacom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®