[RFC 2/2] input: evdev: Add EVIOC mechanism to extract the MT slot state
From: Benjamin Tissoires
Date: Thu Jan 27 2011 - 05:36:06 EST
This patch adds the ability to extract the MT slot state sequentially
via EVIOCGABS. The slot parameter is first selected by calling
EVIOCSABS with ABS_MT_SLOT as argument, followed by a set of EVIOCGABS
calls. The slot selection is local to the evdev client handler, and
does not affect the actual input state.
Signed-off-by: Henrik Rydberg <rydberg@xxxxxxxxxxx>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@xxxxxxx>
---
drivers/input/evdev.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index c8471a2..a689079 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -23,6 +23,7 @@
#include <linux/input.h>
#include <linux/major.h>
#include <linux/device.h>
+#include <linux/input/mt.h>
#include "input-compat.h"
struct evdev {
@@ -45,6 +46,7 @@ struct evdev_client {
struct fasync_struct *fasync;
struct evdev *evdev;
struct list_head node;
+ int slot; /* used to extract MT events via EVIOC */
int bufsize;
struct input_event buffer[];
};
@@ -741,7 +743,7 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
return -EINVAL;
t = _IOC_NR(cmd) & ABS_MAX;
- abs = dev->absinfo[t];
+ abs = input_mt_get_absinfo(dev, t, client->slot);
if (copy_to_user(p, &abs, min_t(size_t,
size, sizeof(struct input_absinfo))))
@@ -767,9 +769,10 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
if (size < sizeof(struct input_absinfo))
abs.resolution = 0;
- /* We can't change number of reserved MT slots */
- if (t == ABS_MT_SLOT)
- return -EINVAL;
+ if (t == ABS_MT_SLOT) {
+ client->slot = abs.value;
+ return 0;
+ }
/*
* Take event lock to ensure that we are not
--
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/