--- /root/touch/usbtouchscreen.c.org 2008-09-16 15:32:40.000000000 +0200 +++ drivers/input/touchscreen/usbtouchscreen.c 2008-09-23 10:26:43.000000000 +0200 @@ -59,6 +59,49 @@ module_param(swap_xy, bool, 0644); MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped."); +static int flip_x; +module_param(flip_x, bool, 0644); +MODULE_PARM_DESC(flip_x, "If set X is subtracted from the range_x parameter."); + +static int flip_y; +module_param(flip_y, bool, 0644); +MODULE_PARM_DESC(flip_y, "If set X is subtracted from the range_x parameter."); + +static int transform_xy; +module_param(transform_xy, bool, 0644); +MODULE_PARM_DESC(transform_xy, "If set the X-coordinate is computed as\ + (range_x * (raw_x - min_x))/(max_x-min_x) and similar for the y-coordinate."); + +static int min_x; +module_param(min_x, int, 0644); +MODULE_PARM_DESC(min_x, "The value of the min_x parameter. See 'transform_xy'\ + for details."); + +static int max_x; +module_param(max_x, int, 0644); +MODULE_PARM_DESC(max_x, "The value of the max_x parameter. See 'transform_xy'\ + for details."); + +static int min_y; +module_param(min_y, int, 0644); +MODULE_PARM_DESC(min_y, "The value of the min_y parameter. See 'transform_xy'\ + for details."); + +static int max_y; +module_param(max_y, int, 0644); +MODULE_PARM_DESC(max_y, "The value of the max_y parameter. See 'transform_xy'\ + for details."); + +static int range_x; +module_param(range_x, int, 0644); +MODULE_PARM_DESC(range_x, "The X-coordinate of the output will be in the\ + interval [0, range_x]."); + +static int range_y; +module_param(range_y, int, 0644); +MODULE_PARM_DESC(range_y, "The Y-coordinate of the output will be in the\ + interval [0, range_y]."); + /* device specifc data/functions */ struct usbtouch_usb; struct usbtouch_device_info { @@ -672,6 +715,18 @@ /***************************************************************************** * Generic Part */ +inline int usbtouch_transform_pkt (int p, int min, int max, int phys) +{ + int result = (phys * (p - min))/(max-min); + if (result < 0) { + return 0; + } else if (result > phys) { + return phys; + } else { + return result; + } +} + static void usbtouch_process_pkt(struct usbtouch_usb *usbtouch, unsigned char *pkt, int len) { @@ -680,15 +735,27 @@ if (!type->read_data(usbtouch, pkt)) return; - 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); - } else { - input_report_abs(usbtouch->input, ABS_X, usbtouch->x); - input_report_abs(usbtouch->input, ABS_Y, usbtouch->y); + int tmp; + tmp = usbtouch->x; + usbtouch->x = usbtouch->y; + usbtouch->y = tmp; } + + if (transform_xy) { + usbtouch->x = usbtouch_transform_pkt (usbtouch->x, min_x, max_x, range_x); + usbtouch->y = usbtouch_transform_pkt (usbtouch->y, min_y, max_y, range_y); + } + + if (flip_x) + usbtouch->x = range_x - usbtouch->x; + + if (flip_y) + usbtouch->y = range_y - usbtouch->y; + + input_report_abs(usbtouch->input, ABS_X, usbtouch->x); + input_report_abs(usbtouch->input, ABS_Y, usbtouch->y); + input_report_key(usbtouch->input, BTN_TOUCH, usbtouch->touch); if (type->max_press) input_report_abs(usbtouch->input, ABS_PRESSURE, usbtouch->press); input_sync(usbtouch->input);