diff options
author | Philippe Coval <philippe.coval@open.eurogiciel.org> | 2015-05-22 18:05:22 +0200 |
---|---|---|
committer | Stéphane Desneux (sdx) <stephane.desneux@open.eurogiciel.org> | 2015-05-28 06:48:49 -0700 |
commit | 5dfe9a0a0f9194ee078f888a4514e50117d6a278 (patch) | |
tree | f00beb3f1aed4927a7e21c09773cb31a9fc3f5fb | |
parent | 6465eb64ad349d5e99f16ff17232edf358f986be (diff) | |
download | kernel-common-5dfe9a0a0f9194ee078f888a4514e50117d6a278.tar.gz kernel-common-5dfe9a0a0f9194ee078f888a4514e50117d6a278.tar.bz2 kernel-common-5dfe9a0a0f9194ee078f888a4514e50117d6a278.zip |
usbtouchscreen: adds support for inverting X or Y axis (or both)
Invert Y is needed (together with swap XY) for some touchscreens :
- LeadingTouch screens (at least for some of them)
- cartft 8in4 (USB ID=0eef:0001)
Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
Signed-off-by: Philippe Coval <philippe.coval@open.eurogiciel.org>
Change-Id: I3b551be8734d5d5f272c8ee8579d2233d6c11ca4
-rw-r--r-- | drivers/input/touchscreen/usbtouchscreen.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c index a0966331a89b..28db033b9377 100644 --- a/drivers/input/touchscreen/usbtouchscreen.c +++ b/drivers/input/touchscreen/usbtouchscreen.c @@ -63,6 +63,12 @@ static bool 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."); static bool hwcalib_xy; module_param(hwcalib_xy, bool, 0644); @@ -1292,6 +1298,7 @@ static void usbtouch_process_pkt(struct usbtouch_usb *usbtouch, unsigned char *pkt, int len) { struct usbtouch_device_info *type = usbtouch->type; + int x, y; if (!type->read_data(usbtouch, pkt)) return; @@ -1299,12 +1306,20 @@ static void usbtouch_process_pkt(struct usbtouch_usb *usbtouch, 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); |