aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDaniel Kurtz <djkurtz@chromium.org>2011-08-24 02:00:24 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2011-08-24 02:07:56 -0400
commit6de58dd625a7645008c5c450bf97a5793faf58c3 (patch)
tree0b01737e03693592824857412dce4e01f4b4e22d /drivers
parent66fd9385ee9c582ee88031ba5028748cb38c986d (diff)
Input: synaptics - refactor y inversion
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> Acked-by: Chase Douglas <chase.douglas@canonical.com> Acked-by: Henrik Rydberg <rydberg@euromail.se> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/input/mouse/synaptics.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 5538fc657af..b0008bcb26f 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -44,6 +44,16 @@
44#define YMIN_NOMINAL 1408 44#define YMIN_NOMINAL 1408
45#define YMAX_NOMINAL 4448 45#define YMAX_NOMINAL 4448
46 46
47/*
48 * Synaptics touchpads report the y coordinate from bottom to top, which is
49 * opposite from what userspace expects.
50 * This function is used to invert y before reporting.
51 */
52static int synaptics_invert_y(int y)
53{
54 return YMAX_NOMINAL + YMIN_NOMINAL - y;
55}
56
47 57
48/***************************************************************************** 58/*****************************************************************************
49 * Stuff we need even when we do not want native Synaptics support 59 * 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,
502 input_mt_report_slot_state(dev, MT_TOOL_FINGER, active); 512 input_mt_report_slot_state(dev, MT_TOOL_FINGER, active);
503 if (active) { 513 if (active) {
504 input_report_abs(dev, ABS_MT_POSITION_X, x); 514 input_report_abs(dev, ABS_MT_POSITION_X, x);
505 input_report_abs(dev, ABS_MT_POSITION_Y, 515 input_report_abs(dev, ABS_MT_POSITION_Y, synaptics_invert_y(y));
506 YMAX_NOMINAL + YMIN_NOMINAL - y);
507 } 516 }
508} 517}
509 518
@@ -597,7 +606,7 @@ static void synaptics_process_packet(struct psmouse *psmouse)
597 606
598 if (num_fingers > 0) { 607 if (num_fingers > 0) {
599 input_report_abs(dev, ABS_X, hw.x); 608 input_report_abs(dev, ABS_X, hw.x);
600 input_report_abs(dev, ABS_Y, YMAX_NOMINAL + YMIN_NOMINAL - hw.y); 609 input_report_abs(dev, ABS_Y, synaptics_invert_y(hw.y));
601 } 610 }
602 input_report_abs(dev, ABS_PRESSURE, hw.z); 611 input_report_abs(dev, ABS_PRESSURE, hw.z);
603 612