* [PATCH] usbtouchscreen: option to swap X and Y axes
@ 2008-09-18 17:16 Matteo Croce
2008-09-20 2:45 ` Jiri Kosina
0 siblings, 1 reply; 3+ messages in thread
From: Matteo Croce @ 2008-09-18 17:16 UTC (permalink / raw)
To: linux-input
Here there is a patch to invert the X and Y axes, as my controller swaps it:
Signed-off-by: Matteo Croce <matteo@openwrt.org>
--- a/drivers/input/touchscreen/usbtouchscreen.c 2008-09-18
18:50:44.294868149 +0200
+++ b/drivers/input/touchscreen/usbtouchscreen.c 2008-09-18
18:50:44.226867816 +0200
@@ -56,8 +56,16 @@
#define DRIVER_DESC "USB Touchscreen Driver"
static int swap_xy;
+static int invert_x;
+static int invert_y;
+
module_param(swap_xy, bool, 0644);
+module_param(invert_x, bool, 0644);
+module_param(invert_y, bool, 0644);
+
MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
+MODULE_PARM_DESC(invert_x, "If set X axe is inverted.");
+MODULE_PARM_DESC(invert_y, "If set Y axe is inverted.");
/* device specifc data/functions */
struct usbtouch_usb;
@@ -683,6 +691,7 @@
unsigned char *pkt, int len)
{
struct usbtouch_device_info *type = usbtouch->type;
+ int x, y;
if (!type->read_data(usbtouch, pkt))
return;
@@ -690,12 +699,22 @@
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;
+ if(invert_x)
+ x = type->max_yc - (x - type->min_yc);
+ if(invert_y)
+ y = type->max_xc - (y - type->min_xc);
} 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);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] usbtouchscreen: option to swap X and Y axes
2008-09-18 17:16 [PATCH] usbtouchscreen: option to swap X and Y axes Matteo Croce
@ 2008-09-20 2:45 ` Jiri Kosina
2008-09-20 16:47 ` Matteo Croce
0 siblings, 1 reply; 3+ messages in thread
From: Jiri Kosina @ 2008-09-20 2:45 UTC (permalink / raw)
To: Matteo Croce; +Cc: linux-input
On Thu, 18 Sep 2008, Matteo Croce wrote:
> Here there is a patch to invert the X and Y axes, as my controller swaps it:
>
> Signed-off-by: Matteo Croce <matteo@openwrt.org>
>
> --- a/drivers/input/touchscreen/usbtouchscreen.c 2008-09-18
> 18:50:44.294868149 +0200
> +++ b/drivers/input/touchscreen/usbtouchscreen.c 2008-09-18
> 18:50:44.226867816 +0200
> @@ -56,8 +56,16 @@
> #define DRIVER_DESC "USB Touchscreen Driver"
>
> static int swap_xy;
> +static int invert_x;
> +static int invert_y;
> +
> module_param(swap_xy, bool, 0644);
> +module_param(invert_x, bool, 0644);
> +module_param(invert_y, bool, 0644);
> +
> MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
> +MODULE_PARM_DESC(invert_x, "If set X axe is inverted.");
> +MODULE_PARM_DESC(invert_y, "If set Y axe is inverted.");
If this is done just by certain devices, maybe VID/PID-based autodetection
might be much more user friendly than using module parameter?
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] usbtouchscreen: option to swap X and Y axes
2008-09-20 2:45 ` Jiri Kosina
@ 2008-09-20 16:47 ` Matteo Croce
0 siblings, 0 replies; 3+ messages in thread
From: Matteo Croce @ 2008-09-20 16:47 UTC (permalink / raw)
To: Jiri Kosina; +Cc: linux-input
On Saturday 20 September 2008 04:45:48 Jiri Kosina wrote:
> On Thu, 18 Sep 2008, Matteo Croce wrote:
> > Here there is a patch to invert the X and Y axes, as my controller swaps
> > it:
> >
> > Signed-off-by: Matteo Croce <matteo@openwrt.org>
> >
> > --- a/drivers/input/touchscreen/usbtouchscreen.c 2008-09-18
> > 18:50:44.294868149 +0200
> > +++ b/drivers/input/touchscreen/usbtouchscreen.c 2008-09-18
> > 18:50:44.226867816 +0200
> > @@ -56,8 +56,16 @@
> > #define DRIVER_DESC "USB Touchscreen Driver"
> >
> > static int swap_xy;
> > +static int invert_x;
> > +static int invert_y;
> > +
> > module_param(swap_xy, bool, 0644);
> > +module_param(invert_x, bool, 0644);
> > +module_param(invert_y, bool, 0644);
> > +
> > MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
> > +MODULE_PARM_DESC(invert_x, "If set X axe is inverted.");
> > +MODULE_PARM_DESC(invert_y, "If set Y axe is inverted.");
>
> If this is done just by certain devices, maybe VID/PID-based autodetection
> might be much more user friendly than using module parameter?
no, sometimes you have to swap just because you attached it in the wrong
direction,
this is what appened to me, I have 50 swapped touchscreens, and i decided to
hack
the driver instead to redo all the work
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-09-20 16:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-18 17:16 [PATCH] usbtouchscreen: option to swap X and Y axes Matteo Croce
2008-09-20 2:45 ` Jiri Kosina
2008-09-20 16:47 ` Matteo Croce
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).