mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Benjamin Tissoires <benjamin.tissoires@enac.fr>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Henrik Rydberg <rydberg@euromail.se>,
	Ping Cheng <pingc@wacom.com>,
	Benjamin Tissoires <benjamin.tissoires@enac.fr>,
	Jiri Kosina <jkosina@suse.cz>,
	Chris Bagwell <chris@cnpbagwell.com>,
	Rafi Rubin <rafi@seas.upenn.edu>,
	Stephane Chatty <chatty@lii-enac.fr>,
	Peter Hutterer <peter.hutterer@who-t.net>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC 2/2] input: evdev: Add EVIOC mechanism to extract the MT slot state
Date: Thu, 27 Jan 2011 11:35:47 +0100	[thread overview]
Message-ID: <1296124547-3323-3-git-send-email-benjamin.tissoires@enac.fr> (raw)
In-Reply-To: <1296124547-3323-1-git-send-email-benjamin.tissoires@enac.fr>

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@euromail.se>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@enac.fr>
---
 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


  parent reply	other threads:[~2011-01-27 10:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-27 10:35 [RFC 0/2] " Benjamin Tissoires
2011-01-27 10:35 ` [RFC 1/2] input: mt: Add method " Benjamin Tissoires
2011-01-27 12:06   ` Henrik Rydberg
2011-01-27 12:49     ` Benjamin Tissoires
2011-01-28 17:33       ` Henrik Rydberg
2011-01-28 18:10         ` Benjamin Tissoires
2011-01-28 18:34           ` Henrik Rydberg
2011-01-27 10:35 ` Benjamin Tissoires [this message]
2011-01-27 12:09   ` [RFC 2/2] input: evdev: Add EVIOC mechanism " Henrik Rydberg
2011-01-28 17:39     ` Dmitry Torokhov

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=1296124547-3323-3-git-send-email-benjamin.tissoires@enac.fr \
    --to=benjamin.tissoires@enac.fr \
    --cc=chatty@lii-enac.fr \
    --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=peter.hutterer@who-t.net \
    --cc=pingc@wacom.com \
    --cc=rafi@seas.upenn.edu \
    --cc=rydberg@euromail.se \
    /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®