LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Ondrej Zary <linux@rainbow-software.org>
To: daniel.ritz@gmx.ch
Cc: linux-kernel@vger.kernel.org
Subject: Invert X or Y axis options for usbtouchscreen
Date: Sat, 24 Mar 2007 15:27:39 +0100	[thread overview]
Message-ID: <200703241527.39792.linux@rainbow-software.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 270 bytes --]

Hello,
this patch adds support for inverting X or Y axis (or both) to the 
usbtouchscreen driver. Invert Y is needed (together with swap XY) for 
LeadingTouch screens (at least for some of them).

Signed-off-by: Ondrej Zary <linux@rainbow-software.org>

-- 
Ondrej Zary

[-- Attachment #2: usbtouchscreen-invert.patch --]
[-- Type: text/x-diff, Size: 1558 bytes --]

--- linux-2.6.20-orig/drivers/usb/input/usbtouchscreen.c	2007-03-23 15:49:35.000000000 +0100
+++ linux/drivers/usb/input/usbtouchscreen.c	2007-03-23 15:52:02.000000000 +0100
@@ -54,6 +54,12 @@
 static int swap_xy;
 module_param(swap_xy, bool, 0644);
 MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
+static int invert_x;
+module_param(invert_x, bool, 0644);
+MODULE_PARM_DESC(invert_x, "Invert X axis.");
+static int invert_y;
+module_param(invert_y, bool, 0644);
+MODULE_PARM_DESC(invert_y, "Invert Y axis.");
 
 /* device specifc data/functions */
 struct usbtouch_usb;
@@ -514,6 +520,7 @@
                                  unsigned char *pkt, int len)
 {
 	struct usbtouch_device_info *type = usbtouch->type;
+	int x, y;
 
 	if (!type->read_data(usbtouch, pkt))
 			return;
@@ -521,12 +528,20 @@
 	input_report_key(usbtouch->input, BTN_TOUCH, usbtouch->touch);
 
 	if (swap_xy) {
-		input_report_abs(usbtouch->input, ABS_X, usbtouch->y);
-		input_report_abs(usbtouch->input, ABS_Y, usbtouch->x);
+		x = usbtouch->y;
+		y = usbtouch->x;
 	} else {
-		input_report_abs(usbtouch->input, ABS_X, usbtouch->x);
-		input_report_abs(usbtouch->input, ABS_Y, usbtouch->y);
+		x = usbtouch->x;
+		y = usbtouch->y;
 	}
+	if (invert_x)
+		x = type->max_xc - x + type->min_xc;
+	if (invert_y)
+		y = type->max_yc - y + type->min_yc;
+
+	input_report_abs(usbtouch->input, ABS_X, x);
+	input_report_abs(usbtouch->input, ABS_Y, y);
+
 	if (type->max_press)
 		input_report_abs(usbtouch->input, ABS_PRESSURE, usbtouch->press);
 	input_sync(usbtouch->input);

                 reply	other threads:[~2007-03-24 14:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=200703241527.39792.linux@rainbow-software.org \
    --to=linux@rainbow-software.org \
    --cc=daniel.ritz@gmx.ch \
    --cc=linux-kernel@vger.kernel.org \
    /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).