From: djkurtz@chromium.org
To: dmitry.torokhov@gmail.com, rydberg@euromail.se,
chase.douglas@canonical.com, rubini@cvml.unipv.it
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
derek.foreman@collabora.co.uk, daniel.stone@collabora.co.uk,
olofj@chromium.org, Daniel Kurtz <djkurtz@chromium.org>
Subject: [PATCH 1/9 v2] Input: synaptics - refactor y inversion
Date: Wed, 20 Jul 2011 21:38:58 +0800 [thread overview]
Message-ID: <1311169146-20066-2-git-send-email-djkurtz@chromium.org> (raw)
In-Reply-To: <1311169146-20066-1-git-send-email-djkurtz@chromium.org>
From: Daniel Kurtz <djkurtz@chromium.org>
Synaptics touchpads report increasing y from bottom to top.
This is inverted from normal userspace "top of screen is 0" coordinates.
Thus, the kernel driver reports inverted y coordinates to userspace.
This patch refactors this inversion.
Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
---
drivers/input/mouse/synaptics.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 5538fc6..297e88f 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -44,6 +44,16 @@
#define YMIN_NOMINAL 1408
#define YMAX_NOMINAL 4448
+/*
+ * Synaptics touchpads report the y coordinate from bottom to top, which is
+ * opposite from what userspace expects.
+ * This function is used to invert y before reporting.
+ */
+static int invert_y(int y)
+{
+ return YMAX_NOMINAL + YMIN_NOMINAL - y;
+}
+
/*****************************************************************************
* Stuff we need even when we do not want native Synaptics support
@@ -502,8 +512,7 @@ static void synaptics_report_semi_mt_slot(struct input_dev *dev, int slot,
input_mt_report_slot_state(dev, MT_TOOL_FINGER, active);
if (active) {
input_report_abs(dev, ABS_MT_POSITION_X, x);
- input_report_abs(dev, ABS_MT_POSITION_Y,
- YMAX_NOMINAL + YMIN_NOMINAL - y);
+ input_report_abs(dev, ABS_MT_POSITION_Y, invert_y(y));
}
}
@@ -597,7 +606,7 @@ static void synaptics_process_packet(struct psmouse *psmouse)
if (num_fingers > 0) {
input_report_abs(dev, ABS_X, hw.x);
- input_report_abs(dev, ABS_Y, YMAX_NOMINAL + YMIN_NOMINAL - hw.y);
+ input_report_abs(dev, ABS_Y, invert_y(hw.y));
}
input_report_abs(dev, ABS_PRESSURE, hw.z);
--
1.7.3.1
next prev parent reply other threads:[~2011-07-20 13:38 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-20 13:38 [PATCH 0/9 v2] Synaptics image sensor support djkurtz
2011-07-20 13:38 ` djkurtz [this message]
2011-07-23 0:30 ` [PATCH 1/9 v2] Input: synaptics - refactor y inversion Chase Douglas
2011-07-25 8:27 ` Dmitry Torokhov
2011-07-26 2:19 ` Daniel Kurtz
2011-07-26 22:59 ` Chase Douglas
2011-07-20 13:38 ` [PATCH 2/9 v2] Input: synaptics - refactor agm packet parsing djkurtz
2011-07-23 0:32 ` Chase Douglas
2011-07-20 13:39 ` [PATCH 3/9 v2] Input: synaptics - refactor initialization of abs position axes djkurtz
2011-07-23 0:36 ` Chase Douglas
2011-07-20 13:39 ` [PATCH 4/9 v2] Input: synaptics - add image sensor support djkurtz
2011-07-20 13:39 ` [PATCH 5/9 v2] Input: synaptics - decode AGM packet types djkurtz
2011-07-20 13:39 ` [PATCH 6/9 v2] Input: synaptics - process finger (<=3) transitions djkurtz
2011-07-23 1:11 ` Chase Douglas
2011-07-20 13:39 ` [PATCH 7/9 v2] Input: synaptics - improved 2->3 finger transition handling djkurtz
2011-07-23 1:07 ` Chase Douglas
2011-07-23 4:36 ` Daniel Kurtz
2011-07-26 23:14 ` Chase Douglas
2011-07-27 4:48 ` Daniel Kurtz
2011-07-27 21:13 ` Chase Douglas
2011-07-28 1:00 ` Daniel Kurtz
2011-07-28 2:07 ` Chase Douglas
2011-07-28 13:56 ` Daniel Kurtz
2011-07-28 17:31 ` Chase Douglas
2011-07-20 13:39 ` [PATCH 8/9 v2] Input: add BTN_TOOL_QUINTTAP for reporting 5 fingers on touchpad djkurtz
2011-07-23 0:59 ` Chase Douglas
2011-07-25 8:29 ` Dmitry Torokhov
2011-07-25 9:14 ` Daniel Kurtz
2011-07-25 18:16 ` Dmitry Torokhov
2011-07-26 2:18 ` Daniel Kurtz
2011-08-11 20:07 ` Henrik Rydberg
2011-07-26 23:03 ` Chase Douglas
2011-07-20 13:39 ` [PATCH 9/9 v2] Input: synaptics - process finger (<=5) transitions djkurtz
2011-07-23 1:02 ` Chase Douglas
2011-07-23 4:11 ` Daniel Kurtz
2011-07-26 23:17 ` Chase Douglas
2011-07-23 1:13 ` [PATCH 0/9 v2] Synaptics image sensor support Chase Douglas
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=1311169146-20066-2-git-send-email-djkurtz@chromium.org \
--to=djkurtz@chromium.org \
--cc=chase.douglas@canonical.com \
--cc=daniel.stone@collabora.co.uk \
--cc=derek.foreman@collabora.co.uk \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olofj@chromium.org \
--cc=rubini@cvml.unipv.it \
--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;
as well as URLs for NNTP newsgroup(s).