From: "Henrik Rydberg" <rydberg@euromail.se>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Mika Kuoppala <mika.kuoppala@nokia.com>,
Peter Hutterer <peter.hutterer@who-t.net>,
Benjamin Tissoires <tissoire@cena.fr>,
Stephane Chatty <chatty@enac.fr>,
Rafi Rubin <rafi@seas.upenn.edu>,
Michael Poole <mdpoole@troilus.org>,
Henrik Rydberg <rydberg@euromail.se>
Subject: [PATCH 1/2] input: mt: Add method to extract the MT slot state
Date: Tue, 25 May 2010 13:52:58 +0200 [thread overview]
Message-ID: <1274788379-11026-2-git-send-email-rydberg@euromail.se> (raw)
In-Reply-To: <1274788379-11026-1-git-send-email-rydberg@euromail.se>
This patch adds the function input_mt_get_abs_value(), which may be
used to extract the current state of the MT slots.
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
---
drivers/input/input.c | 31 +++++++++++++++++++++++++++++++
include/linux/input.h | 2 ++
2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 9b6d474..24d1105 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -659,6 +659,37 @@ static int input_default_setkeycode(struct input_dev *dev,
}
/**
+ * input_mt_get_abs_value - retrieve MT state variables from a device slot
+ * @dev: input device which state is being queried
+ * @code: ABS code to retrieve
+ * @slot: slot to retrieve from
+ *
+ * Return the ABS state of the given MT slot. If code is not an MT
+ * event, the corresponding ABS event is returned.
+ *
+ * This function may be called by anyone interested in extracting the
+ * current MT state. Used by evdev handlers.
+ */
+int input_mt_get_abs_value(struct input_dev *dev, unsigned int code, int slot)
+{
+ unsigned int mtmap = input_mt_abs_map[code];
+ unsigned long flags;
+ int retval;
+
+ spin_lock_irqsave(&dev->event_lock, flags);
+ if (!mtmap)
+ retval = dev->abs[code];
+ else if (slot >= 0 && slot < dev->mtsize)
+ retval = dev->mt[slot].abs[mtmap - 1];
+ else
+ retval = 0;
+ spin_unlock_irqrestore(&dev->event_lock, flags);
+
+ return retval;
+}
+EXPORT_SYMBOL(input_mt_get_abs_value);
+
+/**
* input_get_keycode - retrieve keycode currently mapped to a given scancode
* @dev: input device which keymap is being queried
* @scancode: scancode (or its equivalent for device in question) for which
diff --git a/include/linux/input.h b/include/linux/input.h
index bea6958..03727d6 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -1436,6 +1436,8 @@ static inline void input_mt_slot(struct input_dev *dev, int slot)
input_event(dev, EV_ABS, ABS_MT_SLOT, slot);
}
+int input_mt_get_abs_value(struct input_dev *dev, unsigned int code, int slot);
+
void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code);
static inline void input_set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat)
--
1.6.3.3
next prev parent reply other threads:[~2010-05-25 11:54 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-25 11:52 [PATCH 0/2] input: mt: Add EVIOC mechanism for MT slots Henrik Rydberg
2010-05-25 11:52 ` Henrik Rydberg [this message]
2010-05-25 11:52 ` [PATCH 2/2] input: evdev: Add EVIOC mechanism to extract the MT slot state Henrik Rydberg
2010-05-25 17:34 ` [PATCH 0/2] input: mt: Add EVIOC mechanism for MT slots Dmitry Torokhov
2010-05-25 19:52 ` Henrik Rydberg
2010-05-25 20:23 ` Dmitry Torokhov
2010-05-26 15:59 ` Ping Cheng
2010-05-27 7:03 ` Dmitry Torokhov
2010-05-27 7:08 ` Benjamin Tissoires
2010-05-27 7:24 ` Dmitry Torokhov
2010-05-27 11:17 ` Benjamin Tissoires
2010-05-27 12:33 ` Henrik Rydberg
2010-05-27 22:59 ` Ping Cheng
2010-05-27 23:12 ` 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=1274788379-11026-2-git-send-email-rydberg@euromail.se \
--to=rydberg@euromail.se \
--cc=akpm@linux-foundation.org \
--cc=chatty@enac.fr \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mdpoole@troilus.org \
--cc=mika.kuoppala@nokia.com \
--cc=peter.hutterer@who-t.net \
--cc=rafi@seas.upenn.edu \
--cc=tissoire@cena.fr \
/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;
as well as URLs for NNTP newsgroup(s).