--- src/xdrv/wcmISDV4.c.original 2007-11-01 13:07:07.000000000 +0900 +++ src/xdrv/wcmISDV4.c 2007-11-01 13:13:09.000000000 +0900 @@ -99,9 +99,7 @@ { /* set parameters */ common->wcmProtocolLevel = 4; - common->wcmPktLength = 5; /* length of a packet - * device packets are 9 bytes long, - * multitouch are only 5 */ + common->wcmPktLength = 9; common->wcmResolX = 2540; /* tablet X resolution in points/inch */ common->wcmResolY = 2540; /* tablet Y resolution in points/inch */ common->wcmTPCButton = 1; /* Tablet PC buttons on by default */ @@ -206,27 +204,11 @@ WacomCommonPtr common = priv->common; WacomDeviceState* last = &common->wcmChannel[0].valid.state; WacomDeviceState* ds; - int n, cur_type, ismt = 0; + int n, cur_type; static int lastismt = 0; DBG(10, common->debugLevel, ErrorF("isdv4Parse \n")); - /* determine the type of message */ - if (data[0] & 0x10) - { - ismt = 1; - common->wcmPktLength = 5; - } - else - { - common->wcmPktLength = 9; - 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 @@ -239,81 +221,57 @@ ds = &common->wcmChannel[0].work; RESET_RELATIVE(*ds); - if (ismt) - { - if (!lastismt && last->pressure) - { - /* pen sends both pen and MultiTouch input, - * since pressing it creates pressure. - * We only want the pen input though. - */ - 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->pressure = (data[0] & 0x01) * common->wcmMaxZ; - ds->buttons = 1; - ds->device_id = STYLUS_DEVICE_ID; - ds->device_type = 0; - DBG(8, priv->debugLevel, ErrorF("isdv4Parse MultiTouch\n")); - } - else - { - ds->proximity = (data[0] & 0x20); - - /* x and y in "normal" orientetion (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) | - ((int)data[3] << 9); - - /* pressure */ - ds->pressure = (((data[6] & 0x07) << 7) | data[5] ); - - /* buttons */ - ds->buttons = (data[0] & 0x07); + ds->proximity = (data[0] & 0x20); - /* check which device we have */ - cur_type = (ds->buttons & 4) ? ERASER_ID : STYLUS_ID; - - /* first time into prox */ - if (!last->proximity && ds->proximity) + /* x and y in "normal" orientetion (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) | + ((int)data[3] << 9); + + /* pressure */ + 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; - /* 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->device_id = (ds->device_type == CURSOR_ID) ? + CURSOR_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")); + /* 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; } + + DBG(8, priv->debugLevel, ErrorF("isdv4Parse %s\n", + ds->device_type == ERASER_ID ? "ERASER " : + ds->device_type == STYLUS_ID ? "STYLUS" : "NONE")); + xf86WcmEvent(common,0,ds); return common->wcmPktLength; }