diff -aur linuxwacom-0.7.9-7/ChangeLog linuxwacom-0.7.9-7.mod/ChangeLog --- linuxwacom-0.7.9-7/ChangeLog 2008-01-22 20:22:32.000000000 +0100 +++ linuxwacom-0.7.9-7.mod/ChangeLog 2008-02-12 13:13:59.000000000 +0100 @@ -1,3 +1,14 @@ +2008-02-12 Rene van Paassen + + * src/xdrv/wcmISDV4.c (isdv4GetRanges): the "correct if the wrong + speed is chosen and data does not look good" strategy failed; it + re-initialised but did not re-read the range, leading to a range + of 0, divide by 0, etc. + + * src/xdrv/wcmISDV4.c (isdv4Parse): corrected the parsing code for + the digitizer/touch on a Toshiba Portege M700. I believe this code + should work on more devices, but only testing can tell. + 2008-01-22 Ping Cheng * Updarted xsetwacom for Cintiq 12WX, Bamboo1, and BambooFun * Regrouped the routines for coming Xorg 7.3 hot-plug support (Magnus Vigerlöf) Only in linuxwacom-0.7.9-7.mod/src/include: kernel-config.h Only in linuxwacom-0.7.9-7.mod/src/include: stamp-h1 Only in linuxwacom-0.7.9-7.mod/src/include: stamp-h2 Only in linuxwacom-0.7.9-7.mod/src/include: stamp-h3 Only in linuxwacom-0.7.9-7.mod/src/include: util-config.h Only in linuxwacom-0.7.9-7.mod/src/include: xdrv-config.h Only in linuxwacom-0.7.9-7.mod/src/util: .deps Only in linuxwacom-0.7.9-7.mod/src: wacom.4x.gz Only in linuxwacom-0.7.9-7.mod/src/wacomxi: .deps Only in linuxwacom-0.7.9-7.mod/src/wacomxi: wacomcpl diff -aur linuxwacom-0.7.9-7/src/xdrv/wcmISDV4.c linuxwacom-0.7.9-7.mod/src/xdrv/wcmISDV4.c --- linuxwacom-0.7.9-7/src/xdrv/wcmISDV4.c 2008-01-22 20:22:31.000000000 +0100 +++ linuxwacom-0.7.9-7.mod/src/xdrv/wcmISDV4.c 2008-02-12 12:12:04.000000000 +0100 @@ -1,3 +1,6 @@ + + + /* * Copyright 1995-2002 by Frederic Lepied, France. * Copyright 2002-2007 by Ping Cheng, Wacom Technology. @@ -166,14 +169,15 @@ return !Success; } - /* Control data bit check */ + /* Control data bit check */ if ( !(data[0] & 0x40) ) { /* Try 38400 now */ if (common->wcmISDV4Speed != 38400) { common->wcmISDV4Speed = 38400; - return isdv4Init(local, NULL, NULL); + isdv4Init(local, NULL, NULL); + return isdv4GetRanges(local); } else { @@ -188,6 +192,9 @@ common->wcmMaxY = ( (data[3] << 9) | (data[4] << 2 ) | ( (data[6] & 0x18) >> 3) ); common->wcmVersion = ( data[10] | (data[9] << 7) ); + DBG(2, priv->debugLevel, ErrorF("mx=%d, my=%d, mz=%d ver=%04x\n", common->wcmMaxX, + common->wcmMaxY, common->wcmMaxZ, + (int)common->wcmVersion)); return Success; } @@ -215,12 +222,11 @@ WacomDeviceState* last = &common->wcmChannel[0].valid.state; WacomDeviceState* ds; int n, cur_type, ismt = 0; - static int lastismt = 0; DBG(10, common->debugLevel, ErrorF("isdv4Parse \n")); /* determine the type of message */ - if (data[0] & 0x10) + if ((data[0] & 0xfe) == 0x90) { ismt = 1; common->wcmPktLength = 5; @@ -228,13 +234,14 @@ else { common->wcmPktLength = 9; - if (common->buffer + common->bufpos - data < common->wcmPktLength) - { - /* we can't handle this yet */ - return 0; - } } - + + if (common->buffer + common->bufpos - data < common->wcmPktLength) + { + /* we can't handle this yet */ + return 0; + } + if ((n = xf86WcmSerialValidate(common,data)) > 0) return n; else @@ -249,7 +256,8 @@ if (ismt) { - if (!lastismt && last->pressure) + /* pressure is probably not the right test, Proximity is! */ + if (last->proximity & 0x20) { /* pen sends both pen and MultiTouch input, * since pressing it creates pressure. @@ -257,23 +265,42 @@ */ return common->wcmPktLength; } - lastismt = ismt; /* MultiTouch input is comparably simple */ - ds->proximity = 0; - ds->x = (((((int)data[1]) << 7) | ((int)data[2])) - 18) * common->wcmMaxX / 926; - ds->y = (((((int)data[3]) << 7) | ((int)data[4])) - 51) * common->wcmMaxY / 934; + ds->x = (((((int)data[1]) << 7) | ((int)data[2]))) * common->wcmMaxX / 4096; + ds->y = (((((int)data[3]) << 7) | ((int)data[4]))) * common->wcmMaxY / 4096; ds->pressure = (data[0] & 0x01) * common->wcmMaxZ; - ds->buttons = 1; - ds->device_id = STYLUS_DEVICE_ID; - ds->device_type = 0; + ds->buttons = (data[0] & 0x01); + ds->device_id = CURSOR_DEVICE_ID; + ds->device_type = CURSOR_ID; + ds->proximity = ds->buttons; + + /* Proximity for this device is linked to button events. + Need to send extra events when pressing / releasing. */ + if (!ds->proximity && last->proximity) { + /* releasing the finger. Send a report with prox in + and button out. The normal report then sends + prox out. */ + ds->proximity = 1; + xf86WcmEvent(common,0,ds); + ds->proximity = 0; + DBG(8, priv->debugLevel, ErrorF("finger release\n")); + } + else if (ds->proximity && !last->proximity) { + /* pressing the finger. Send a report with prox in and + button still out. The normal event sends button in. */ + ds->buttons = 0; + xf86WcmEvent(common,0,ds); + ds->buttons = 1; + DBG(8, priv->debugLevel, ErrorF("finger press\n")); + } DBG(8, priv->debugLevel, ErrorF("isdv4Parse MultiTouch\n")); } else { ds->proximity = (data[0] & 0x20); - /* x and y in "normal" orientetion (wide length is X) */ + /* x and y in "normal" orientention (wide length is X) */ ds->x = (((int)data[6] & 0x60) >> 5) | ((int)data[2] << 2) | ((int)data[1] << 9); ds->y = (((int)data[6] & 0x18) >> 3) | ((int)data[4] << 2) | @@ -283,41 +310,11 @@ ds->pressure = (((data[6] & 0x07) << 7) | data[5] ); /* buttons */ - ds->buttons = (data[0] & 0x07); - - /* check which device we have */ - cur_type = (ds->buttons & 4) ? ERASER_ID : STYLUS_ID; - - /* first time into prox */ - if (!last->proximity && ds->proximity) - ds->device_type = cur_type; - /* check on previous proximity */ - else if (cur_type == STYLUS_ID && ds->proximity) - { - /* we were fooled by tip and second - * sideswitch when it came into prox */ - if ((ds->device_type != cur_type) && - (ds->device_type == ERASER_ID)) - { - /* send a prox-out for old device */ - WacomDeviceState out = { 0 }; - xf86WcmEvent(common, 0, &out); - ds->device_type = cur_type; - } - } - - ds->device_id = (ds->device_type == CURSOR_ID) ? - CURSOR_DEVICE_ID : STYLUS_DEVICE_ID; - - /* don't send button 3 event for eraser - * button 1 event will be sent by testing presure level - */ - if (ds->device_type == ERASER_ID && ds->buttons&4) - { - ds->buttons = 0; - ds->device_id = ERASER_DEVICE_ID; - } + ds->buttons = (data[0] & 0x03); + /* simply changing device type works fine. */ + ds->device_type = (data[0] & 4) ? ERASER_ID : STYLUS_ID; + ds->device_id = (data[0] & 4) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID; DBG(8, priv->debugLevel, ErrorF("isdv4Parse %s\n", ds->device_type == ERASER_ID ? "ERASER " : ds->device_type == STYLUS_ID ? "STYLUS" : "NONE"));