--- linux-2.4.19/drivers/usb/wacom.c.orig Sun Aug 25 05:54:07 2002 +++ linux-2.4.19/drivers/usb/wacom.c Wed Aug 28 22:11:49 2002 @@ -1,6 +1,7 @@ /* - * $Id: wacom.c,v 1.23 2001/05/29 12:57:18 vojtech Exp $ + * : wacom.c,v 1.23 2001/05/29 12:57:18 vojtech Exp * + * Copyright (c) 2002 Ping Cheng * Copyright (c) 2000-2001 Vojtech Pavlik * Copyright (c) 2000 Andreas Bach Aaen * Copyright (c) 2000 Clifford Wolf @@ -85,7 +86,6 @@ MODULE_AUTHOR( DRIVER_AUTHOR ); MODULE_DESCRIPTION( DRIVER_DESC ); MODULE_LICENSE("GPL"); - #define USB_VENDOR_ID_WACOM 0x056a struct wacom_features { @@ -111,6 +111,7 @@ struct wacom_features *features; int tool[2]; int open; + int x, y; __u32 serial[2]; }; @@ -128,16 +129,31 @@ return; } - prox = data[1] & 0x20; + prox = data[1] & 0x40; input_report_key(dev, BTN_TOOL_PEN, prox); if (prox) { - int pressure = (data[4] & 0x04) >> 2 | ((__u32)(data[7] & 0x7f) << 1); - - input_report_abs(dev, ABS_X, data[3] | ((__u32)data[2] << 8) | ((__u32)(data[1] & 0x03) << 16)); - input_report_abs(dev, ABS_Y, data[6] | ((__u32)data[5] << 8) | ((__u32)(data[4] & 0x03) << 8)); - input_report_abs(dev, ABS_PRESSURE, (data[7] & 0x80) ? (255 - pressure) : (pressure + 255)); + int pressure; + if ( wacom->features->pressure_max > 350 ) { + pressure = ((data[4] & 0x04) >> 1) | ((__u32)(data[7] & 0x3f) << 2) | + ((data[4] & 0x40) >> 6); + if ( (__u32)(data[7] & 0x40) ) { + pressure = ( pressure | ~0xff ); + } + } + else { + if ( wacom->features->pressure_max > 150 ) { + pressure = (data[4] & 0x04) >> 2 | ((__u32)(data[7] & 0x3f) << 1); + if ( (__u32)(data[7] & 0x40) ) { + pressure = ( pressure | ~0x7f ); + } + } + } + pressure += (( wacom->features->pressure_max + 1 )/ 2); + input_report_abs(dev, ABS_X, data[3] | ((__u32)data[2] << 7) | ((__u32)(data[1] & 0x03) << 14)); + input_report_abs(dev, ABS_Y, data[6] | ((__u32)data[5] << 7) | ((__u32)(data[4] & 0x03) << 14)); + input_report_abs(dev, ABS_PRESSURE, pressure); input_report_key(dev, BTN_TOUCH, data[4] & 0x08); input_report_key(dev, BTN_STYLUS, data[4] & 0x10); input_report_key(dev, BTN_STYLUS2, data[4] & 0x20); @@ -190,6 +206,10 @@ x = data[2] | ((__u32)data[3] << 8); y = data[4] | ((__u32)data[5] << 8); + /* exponential smoothing to eliminate jitter */ + x = (wacom->x * 2 + x) / 3; + y = (wacom->y * 2 + y) / 3; + switch ((data[1] >> 5) & 3) { case 0: /* Pen */ @@ -208,16 +228,16 @@ input_report_abs(dev, ABS_DISTANCE, data[7]); input_report_rel(dev, REL_WHEEL, (signed char) data[6]); - input_report_abs(dev, ABS_X, x); - input_report_abs(dev, ABS_Y, y); + input_report_abs(dev, ABS_X, wacom->x = x); + input_report_abs(dev, ABS_Y, wacom->y = y); input_event(dev, EV_MSC, MSC_SERIAL, data[1] & 0x01); return; } if (data[1] & 0x80) { - input_report_abs(dev, ABS_X, x); - input_report_abs(dev, ABS_Y, y); + input_report_abs(dev, ABS_X, wacom->x = x); + input_report_abs(dev, ABS_Y, wacom->y = y); } input_report_abs(dev, ABS_PRESSURE, data[6] | ((__u32)data[7] << 8)); @@ -235,6 +255,7 @@ struct input_dev *dev = &wacom->dev; unsigned int t; int idx; + int x, y; if (urb->status) return; @@ -256,13 +277,14 @@ case 0x832: case 0x012: wacom->tool[idx] = BTN_TOOL_PENCIL; break; /* Inking pen */ case 0x822: + case 0x842: case 0x852: case 0x022: wacom->tool[idx] = BTN_TOOL_PEN; break; /* Pen */ case 0x812: case 0x032: wacom->tool[idx] = BTN_TOOL_BRUSH; break; /* Stroke pen */ case 0x09c: case 0x007: - case 0x094: wacom->tool[idx] = BTN_TOOL_MOUSE; break; /* Mouse 4D */ + case 0x094: wacom->tool[idx] = BTN_TOOL_MOUSE; break; /* Mouse 4D and 2D */ case 0x096: wacom->tool[idx] = BTN_TOOL_LENS; break; /* Lens cursor */ case 0x82a: case 0x85a: @@ -283,8 +305,15 @@ return; } - input_report_abs(dev, ABS_X, ((__u32)data[2] << 8) | data[3]); - input_report_abs(dev, ABS_Y, ((__u32)data[4] << 8) | data[5]); + x = ((__u32)data[2] << 8) | data[3]; + y = ((__u32)data[4] << 8) | data[5]; + + /* exponential smoothing to eliminate jitter */ + wacom->x = (wacom->x * 2 + x) / 3; + wacom->y = (wacom->y * 2 + y) / 3; + + input_report_abs(dev, ABS_X, wacom->x); + input_report_abs(dev, ABS_Y, wacom->y); input_report_abs(dev, ABS_DISTANCE, data[9] >> 4); if ((data[1] & 0xb8) == 0xa0) { /* general pen packet */ @@ -312,22 +341,33 @@ } else { - input_report_key(dev, BTN_LEFT, data[8] & 0x01); - input_report_key(dev, BTN_MIDDLE, data[8] & 0x02); - input_report_key(dev, BTN_RIGHT, data[8] & 0x04); - if ((data[1] & 0x10) == 0) { /* 4D mouse packets */ + input_report_key(dev, BTN_LEFT, data[8] & 0x01); + input_report_key(dev, BTN_MIDDLE, data[8] & 0x02); + input_report_key(dev, BTN_RIGHT, data[8] & 0x04); + input_report_key(dev, BTN_SIDE, data[8] & 0x20); input_report_key(dev, BTN_EXTRA, data[8] & 0x10); input_report_abs(dev, ABS_THROTTLE, (data[8] & 0x08) ? ((__u32)data[6] << 2) | ((data[7] >> 6) & 3) : -((__u32)data[6] << 2) | ((data[7] >> 6) & 3)); - } else { /* Lens cursor packets */ - - input_report_key(dev, BTN_SIDE, data[8] & 0x10); - input_report_key(dev, BTN_EXTRA, data[8] & 0x08); + } else { + if (wacom->tool[idx] == BTN_TOOL_MOUSE) { /* 2D mouse packets */ + input_report_key(dev, BTN_LEFT, data[8] & 0x04); + input_report_key(dev, BTN_MIDDLE, data[8] & 0x08); + input_report_key(dev, BTN_RIGHT, data[8] & 0x10); + input_report_abs(dev, REL_WHEEL, + ((__u32)(data[8] & 0x01) - (__u32)((data[8] & 0x02) >> 1))); + } + else { /* Lens cursor packets */ + input_report_key(dev, BTN_LEFT, data[8] & 0x01); + input_report_key(dev, BTN_MIDDLE, data[8] & 0x02); + input_report_key(dev, BTN_RIGHT, data[8] & 0x04); + input_report_key(dev, BTN_SIDE, data[8] & 0x10); + input_report_key(dev, BTN_EXTRA, data[8] & 0x08); + } } } } @@ -346,39 +386,39 @@ BIT(EV_REL), 0, BIT(REL_WHEEL), 0 }, { "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 32, wacom_graphire_irq, BIT(EV_REL), 0, BIT(REL_WHEEL), 0 }, - { "Wacom Graphire2 5x7", 8, 10206, 7422, 511, 32, wacom_graphire_irq, + { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 32, wacom_graphire_irq, BIT(EV_REL), 0, BIT(REL_WHEEL), 0 }, { "Wacom Intuos 4x5", 10, 12700, 10360, 1023, 15, wacom_intuos_irq, 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS }, - { "Wacom Intuos 6x8", 10, 20320, 15040, 1023, 15, wacom_intuos_irq, + { "Wacom Intuos 6x8", 10, 20600, 16450, 1023, 15, wacom_intuos_irq, 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS }, - { "Wacom Intuos 9x12", 10, 30480, 23060, 1023, 15, wacom_intuos_irq, + { "Wacom Intuos 9x12", 10, 30670, 24130, 1023, 15, wacom_intuos_irq, 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS }, - { "Wacom Intuos 12x12", 10, 30480, 30480, 1023, 15, wacom_intuos_irq, + { "Wacom Intuos 12x12", 10, 30670, 31040, 1023, 15, wacom_intuos_irq, 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS }, - { "Wacom Intuos 12x18", 10, 47720, 30480, 1023, 15, wacom_intuos_irq, + { "Wacom Intuos 12x18", 10, 45860, 31040, 1023, 15, wacom_intuos_irq, 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS }, - { "Wacom PL400", 8, 12328, 9256, 511, 32, wacom_pl_irq, + { "Wacom PL400", 8, 5408, 4056, 255, 32, wacom_pl_irq, 0, 0, 0, 0 }, - { "Wacom PL500", 8, 12328, 9256, 511, 32, wacom_pl_irq, + { "Wacom PL500", 8, 6144, 4608, 255, 32, wacom_pl_irq, 0, 0, 0, 0 }, - { "Wacom PL600", 8, 12328, 9256, 511, 32, wacom_pl_irq, + { "Wacom PL600", 8, 6126, 4604, 255, 32, wacom_pl_irq, 0, 0, 0, 0 }, - { "Wacom PL600SX", 8, 12328, 9256, 511, 32, wacom_pl_irq, + { "Wacom PL600SX", 8, 6260, 5016, 255, 32, wacom_pl_irq, 0, 0, 0, 0 }, - { "Wacom PL550", 8, 12328, 9256, 511, 32, wacom_pl_irq, + { "Wacom PL550", 8, 6144, 4608, 511, 32, wacom_pl_irq, 0, 0, 0, 0 }, - { "Wacom PL800", 8, 12328, 9256, 511, 32, wacom_pl_irq, + { "Wacom PL800", 8, 7220, 5780, 511, 32, wacom_pl_irq, 0, 0, 0, 0 }, { "Wacom Intuos2 4x5", 10, 12700, 10360, 1023, 15, wacom_intuos_irq, 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS }, - { "Wacom Intuos2 6x8", 10, 20320, 15040, 1023, 15, wacom_intuos_irq, + { "Wacom Intuos2 6x8", 10, 20600, 16450, 1023, 15, wacom_intuos_irq, 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS }, - { "Wacom Intuos2 9x12", 10, 30480, 23060, 1023, 15, wacom_intuos_irq, + { "Wacom Intuos2 9x12", 10, 30670, 24130, 1023, 15, wacom_intuos_irq, 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS }, - { "Wacom Intuos2 12x12", 10, 30480, 30480, 1023, 15, wacom_intuos_irq, + { "Wacom Intuos2 12x12", 10, 30670, 31040, 1023, 15, wacom_intuos_irq, 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS }, - { "Wacom Intuos2 12x18", 10, 47720, 30480, 1023, 15, wacom_intuos_irq, + { "Wacom Intuos2 12x18", 10, 45860, 31040, 1023, 15, wacom_intuos_irq, 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS }, { NULL , 0 } }; @@ -436,6 +476,7 @@ struct usb_endpoint_descriptor *endpoint; struct wacom *wacom; char rep_data[2] = {0x02, 0x02}; + int ret; if (!(wacom = kmalloc(sizeof(struct wacom), GFP_KERNEL))) return NULL; memset(wacom, 0, sizeof(struct wacom)); @@ -527,3 +568,4 @@ module_init(wacom_init); module_exit(wacom_exit); +