From: Ping Cheng Date: Wed, 14 May 2008 17:32:03 +0000 (-0700) Subject: Fixed rotation routine X-Git-Url: http://git.debian.org/?p=collab-maint%2Flinux-wacom.git;a=commitdiff_plain;h=21544aeb232d76df8c2eb3e771433d0a4acb30ee Fixed rotation routine --- diff --git a/ChangeLog b/ChangeLog index a2f40a5..64feb47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-05-09 Ping Cheng + * Updated xidump for Xserver 1.4 or later + * Fixed no eraser calibration issue for LCD tablets + * Fixed serial Tablet PC baudrate issue + * Label 0.8.0-1 + 2008-04-25 Ping Cheng * Updated wacom.4x * Update ~/.xsession from wacomcpl for KDE system diff --git a/src/xdrv/wcmCommon.c b/src/xdrv/wcmCommon.c index 84de3e3..a6107c3 100755 --- a/src/xdrv/wcmCommon.c +++ b/src/xdrv/wcmCommon.c @@ -44,6 +44,7 @@ WacomDeviceClass* wcmDeviceClasses[] = extern int xf86WcmDevSwitchModeCall(LocalDevicePtr local, int mode); extern void xf86WcmChangeScreen(LocalDevicePtr local, int value); +extern void xf86WcmInitialCoordinates(LocalDevicePtr local, int axes); /***************************************************************************** * Static functions @@ -1868,3 +1869,148 @@ void xf86WcmInitialScreens(LocalDevicePtr local) i, priv->screenBottomX[i], i, priv->screenBottomY[i])); } } + +/***************************************************************************** + * rotateOneTool + ****************************************************************************/ + +static void rotateOneTool(WacomDevicePtr priv) +{ + WacomCommonPtr common = priv->common; + WacomToolAreaPtr area = priv->toolarea; + int tmpTopX, tmpTopY, tmpBottomX, tmpBottomY, oldMaxX, oldMaxY; + + DBG(10, priv->debugLevel, ErrorF("rotateOneTool for \"%s\" \n", priv->local->name)); + + oldMaxX = priv->wcmMaxX; + oldMaxY = priv->wcmMaxY; + + tmpTopX = priv->topX; + tmpBottomX = priv->bottomX; + tmpTopY = priv->topY; + tmpBottomY = priv->bottomY; + + if (common->wcmRotate == ROTATE_CW || common->wcmRotate == ROTATE_CCW) + { + priv->wcmMaxX = oldMaxY; + priv->wcmMaxY = oldMaxX; + } + + switch (common->wcmRotate) { + case ROTATE_CW: + area->topX = priv->topX = tmpTopY; + area->bottomX = priv->bottomX = tmpBottomY; + area->topY = priv->topY = oldMaxX - tmpBottomX; + area->bottomY = priv->bottomY =oldMaxX - tmpTopX; + break; + case ROTATE_CCW: + area->topX = priv->topX = oldMaxY - tmpBottomY; + area->bottomX = priv->bottomX = oldMaxY - tmpTopY; + area->topY = priv->topY = tmpTopX; + area->bottomY = priv->bottomY = tmpBottomX; + break; + case ROTATE_HALF: + area->topX = priv->topX = oldMaxX - tmpBottomX; + area->bottomX = priv->bottomX = oldMaxX - tmpTopX; + area->topY = priv->topY= oldMaxY - tmpBottomY; + area->bottomY = priv->bottomY = oldMaxY - tmpTopY; + break; + } + xf86WcmInitialScreens(priv->local); + xf86WcmMappingFactor(priv->local); + xf86WcmInitialCoordinates(priv->local, 0); + xf86WcmInitialCoordinates(priv->local, 1); + + if (tmpTopX != priv->topX) + xf86ReplaceIntOption(priv->local->options, "TopX", priv->topX); + if (tmpTopY != priv->topY) + xf86ReplaceIntOption(priv->local->options, "TopY", priv->topY); + if (tmpBottomX != priv->bottomX) + xf86ReplaceIntOption(priv->local->options, "BottomX", priv->bottomX); + if (tmpBottomY != priv->bottomY) + xf86ReplaceIntOption(priv->local->options, "BottomY", priv->bottomY); +} + +/***************************************************************************** + * xf86WcmRotateScreen + ****************************************************************************/ + +void xf86WcmRotateScreen(LocalDevicePtr local, int value) +{ + WacomDevicePtr priv = (WacomDevicePtr)local->private; + WacomCommonPtr common = priv->common; + WacomDevicePtr tmppriv; + int oldRotation; + int tmpTopX, tmpTopY, tmpBottomX, tmpBottomY, oldMaxX, oldMaxY; + + DBG(10, priv->debugLevel, ErrorF("xf86WcmRotateScreen for \"%s\" \n", local->name)); + + if (common->wcmRotate == value) /* initialization */ + { + rotateOneTool(priv); + } + else + { + oldRotation = common->wcmRotate; + common->wcmRotate = value; + + /* rotate all devices at once! else they get misaligned */ + for (tmppriv = common->wcmDevices; tmppriv; tmppriv = tmppriv->next) + { + oldMaxX = tmppriv->wcmMaxX; + oldMaxY = tmppriv->wcmMaxY; + + if (oldRotation == ROTATE_CW || oldRotation == ROTATE_CCW) + { + tmppriv->wcmMaxX = oldMaxY; + tmppriv->wcmMaxY = oldMaxX; + } + + tmpTopX = tmppriv->topX; + tmpBottomX = tmppriv->bottomX; + tmpTopY = tmppriv->topY; + tmpBottomY = tmppriv->bottomY; + + /* recover to the unrotated xy-rectangles */ + switch (oldRotation) { + case ROTATE_CW: + tmppriv->topX = oldMaxY - tmpBottomY; + tmppriv->bottomX = oldMaxY - tmpTopY; + tmppriv->topY = tmpTopX; + tmppriv->bottomY = tmpBottomX; + break; + case ROTATE_CCW: + tmppriv->topX = tmpTopY; + tmppriv->bottomX = tmpBottomY; + tmppriv->topY = oldMaxX - tmpBottomX; + tmppriv->bottomY = oldMaxX - tmpTopX; + break; + case ROTATE_HALF: + tmppriv->topX = oldMaxX - tmpBottomX; + tmppriv->bottomX = oldMaxX - tmpTopX; + tmppriv->topY = oldMaxY - tmpBottomY; + tmppriv->bottomY = oldMaxY - tmpTopY; + break; + } + + /* and rotate them to the new value */ + rotateOneTool(tmppriv); + + switch(value) { + case ROTATE_NONE: + xf86ReplaceStrOption(local->options, "Rotate", "NONE"); + break; + case ROTATE_CW: + xf86ReplaceStrOption(local->options, "Rotate", "CW"); + break; + case ROTATE_CCW: + xf86ReplaceStrOption(local->options, "Rotate", "CCW"); + break; + case ROTATE_HALF: + xf86ReplaceStrOption(local->options, "Rotate", "HALF"); + break; + } + } + } + +} diff --git a/src/xdrv/wcmISDV4.c b/src/xdrv/wcmISDV4.c index cafdf08..d61aa45 100755 --- a/src/xdrv/wcmISDV4.c +++ b/src/xdrv/wcmISDV4.c @@ -99,10 +99,10 @@ static int isdv4Query(LocalDevicePtr local, const char* query, char* data) DBG(1, priv->debugLevel, ErrorF("Querying ISDV4 tablet\n")); /* Send stop command to the tablet */ - err = xf86WcmWrite(local->fd, query, strlen(query)); + err = xf86WcmWrite(local->fd, WC_ISDV4_STOP, strlen(WC_ISDV4_STOP)); if (err == -1) { - ErrorF("Wacom xf86WcmWrite error : %s\n", strerror(errno)); + ErrorF("Wacom xf86WcmWrite ISDV4_STOP error : %s\n", strerror(errno)); return !Success; } @@ -113,7 +113,7 @@ static int isdv4Query(LocalDevicePtr local, const char* query, char* data) /* Send query command to the tablet */ if (!xf86WcmWriteWait(local->fd, query)) { - ErrorF("Wacom unable to xf86WcmWrite request %s query command " + ErrorF("Wacom unable to xf86WcmWrite request %s ISDV4 query command " "after %d tries\n", query, MAXTRY); return !Success; } @@ -121,13 +121,13 @@ static int isdv4Query(LocalDevicePtr local, const char* query, char* data) /* Read the control data */ if (!xf86WcmWaitForTablet(local->fd, data, 11)) { - /* Try 19200 now */ - if (common->wcmISDV4Speed != 19200) + /* Try 19200 if it is not a touch query */ + if (common->wcmISDV4Speed != 19200 && strcmp(query, WC_ISDV4_TOUCH_QUERY)) { common->wcmISDV4Speed = 19200; if (xf86WcmSetSerialSpeed(local->fd, common->wcmISDV4Speed) < 0) return !Success; - return isdv4Query(local, query, data); + return isdv4Query(local, query, data); } else { @@ -137,6 +137,13 @@ static int isdv4Query(LocalDevicePtr local, const char* query, char* data) } } + /* Control data bit check */ + if ( !(data[0] & 0x40) ) + { + ErrorF("Wacom Query ISDV4 control data (%x) error in %s query\n", data[0], query); + return !Success; + } + return Success; } @@ -216,7 +223,7 @@ static int isdv4GetRanges(LocalDevicePtr local) } } - if (common->wcmMaxX && common->wcmPktLength == 5) + if (common->wcmMaxX && common->wcmMaxY) { /* Touch resolution */ common->wcmTouchResolX = common->wcmMaxTouchX * @@ -256,7 +263,7 @@ static int isdv4Parse(LocalDevicePtr local, const unsigned char* data) WacomCommonPtr common = priv->common; WacomDeviceState* last = &common->wcmChannel[0].valid.state; WacomDeviceState* ds; - int n, cur_type, channel; + int n, cur_type, channel = 0; DBG(10, common->debugLevel, ErrorF("isdv4Parse \n")); @@ -268,8 +275,13 @@ static int isdv4Parse(LocalDevicePtr local, const unsigned char* data) return 5; /* ignore touch event */ else { - common->wcmPktLength = 5; - channel = 1; + if (data[0] & 0x10) /* a touch data */ + { + common->wcmPktLength = 5; + channel = 1; + } + else + return 5; } } else @@ -289,7 +301,7 @@ static int isdv4Parse(LocalDevicePtr local, const unsigned char* data) else { /* Coordinate data bit check */ - if (data[0] & 0x40) /* control data*/ + if (data[0] & 0x40) /* control data */ return common->wcmPktLength; } @@ -331,9 +343,9 @@ static int isdv4Parse(LocalDevicePtr local, const unsigned char* data) if (!last->proximity && ds->proximity) ds->device_type = cur_type; /* check on previous proximity */ - else if (cur_type == STYLUS_ID && ds->proximity) + else if (ds->buttons && ds->proximity) { - /* we were fooled by tip and second + /* we might have been fooled by tip and second * sideswitch when it came into prox */ if ((ds->device_type != cur_type) && (ds->device_type == ERASER_ID)) @@ -345,8 +357,8 @@ static int isdv4Parse(LocalDevicePtr local, const unsigned char* data) } } - ds->device_id = (ds->device_type == CURSOR_ID) ? - CURSOR_DEVICE_ID : STYLUS_DEVICE_ID; + ds->device_id = (ds->device_type == ERASER_ID) ? + ERASER_DEVICE_ID : STYLUS_DEVICE_ID; /* don't send button 3 event for eraser * button 1 event will be sent by testing presure level diff --git a/src/xdrv/wcmSerial.c b/src/xdrv/wcmSerial.c index 6370ed3..5d71eef 100755 --- a/src/xdrv/wcmSerial.c +++ b/src/xdrv/wcmSerial.c @@ -255,7 +255,7 @@ int xf86WcmWriteWait(int fd, const char* request) len = xf86WriteSerial(fd, request, strlen(request)); if ((len == -1) && (errno != EAGAIN)) { - ErrorF("Wacom xf86WcmWrite error : %s", strerror(errno)); + ErrorF("Wacom xf86WcmWriteWait error : %s", strerror(errno)); return 0; } @@ -1249,9 +1249,9 @@ static void serialParseP4Common(LocalDevicePtr local, if (!last->proximity && ds->proximity) ds->device_type = cur_type; /* check on previous proximity */ - else if (is_stylus && ds->proximity) + else if (ds->buttons && ds->proximity) { - /* we were fooled by tip and second + /* we might have been fooled by tip and second * sideswitch when it came into prox */ if ((ds->device_type != cur_type) && (ds->device_type == ERASER_ID)) @@ -1295,8 +1295,9 @@ int xf86WcmSerialValidate(WacomCommonPtr common, const unsigned char* data) ((i!=0) && (data[i] & HEADER_BIT)) ) { bad = 1; - ErrorF("xf86WcmSerialValidate: bad magic at %d " - "v=%x l=%d\n", i, data[i], common->wcmPktLength); + if (i!=1) + ErrorF("xf86WcmSerialValidate: bad magic at %d " + "v=%x l=%d\n", i, data[i], common->wcmPktLength); if (i!=0 && (data[i] & HEADER_BIT)) return i; } } diff --git a/src/xdrv/wcmXCommand.c b/src/xdrv/wcmXCommand.c index a260008..fff89f6 100644 --- a/src/xdrv/wcmXCommand.c +++ b/src/xdrv/wcmXCommand.c @@ -20,6 +20,7 @@ * REVISION HISTORY * * 2007-05-25 0.1 - Initial release - span off from xf86Wacom.c + * 2008-05-14 0.2 - Rotate through routine xf86WcmRotateScreen */ @@ -30,6 +31,7 @@ extern void xf86WcmInitialCoordinates(LocalDevicePtr local, int axes); extern void xf86WcmInitialScreens(LocalDevicePtr local); +extern void xf86WcmRotateScreen(LocalDevicePtr local, int value); /***************************************************************************** * xf86WcmSetPadCoreMode @@ -145,12 +147,8 @@ static int xf86WcmSetParam(LocalDevicePtr local, int param, int value) { WacomDevicePtr priv = (WacomDevicePtr)local->private; WacomCommonPtr common = priv->common; - WacomDevicePtr tmppriv; char st[32]; - int oldRotation; - int tmpTopX, tmpTopY, tmpBottomX, tmpBottomY, oldMaxX, oldMaxY; WacomToolAreaPtr area = priv->toolarea; - WacomToolAreaPtr tmparea; /* We don't reset options to the values that the driver are using. * This eliminates confusion when driver is running on default values. @@ -452,106 +450,10 @@ static int xf86WcmSetParam(LocalDevicePtr local, int param, int value) break; case XWACOM_PARAM_ROTATE: if ((value < 0) || (value > 3)) return BadValue; - switch(value) { - case ROTATE_NONE: - xf86ReplaceStrOption(local->options, "Rotate", "NONE"); - break; - case ROTATE_CW: - xf86ReplaceStrOption(local->options, "Rotate", "CW"); - break; - case ROTATE_CCW: - xf86ReplaceStrOption(local->options, "Rotate", "CCW"); - break; - case ROTATE_HALF: - xf86ReplaceStrOption(local->options, "Rotate", "HALF"); - break; - default: - return BadValue; - } - oldRotation = common->wcmRotate; - oldMaxX = priv->wcmMaxX; - oldMaxY = priv->wcmMaxY; - common->wcmRotate = value; - if (((oldRotation == ROTATE_NONE || oldRotation == ROTATE_HALF) && - (value == ROTATE_CW || value == ROTATE_CCW)) || - ((oldRotation == ROTATE_CW || oldRotation == ROTATE_CCW) - && (value == ROTATE_NONE || value == ROTATE_HALF))) - { - priv->wcmMaxX = oldMaxY; - priv->wcmMaxY = oldMaxX; - } - - /* rotate all devices at once! else they get misaligned */ - for (tmppriv = common->wcmDevices; tmppriv; tmppriv = tmppriv->next) - { - tmparea = tmppriv->toolarea; - /* recover the unrotated xy-rectangles */ - switch (oldRotation) { - case ROTATE_CW: - tmpTopX = oldMaxY - tmppriv->bottomY; - tmpBottomX = oldMaxY - tmppriv->topY; - tmpTopY = tmppriv->topX; - tmpBottomY = tmppriv->bottomX; - break; - case ROTATE_CCW: - tmpTopX = tmppriv->topY; - tmpBottomX = tmppriv->bottomY; - tmpTopY = oldMaxX - tmppriv->bottomX; - tmpBottomY = oldMaxX - tmppriv->topX; - break; - case ROTATE_HALF: - tmpTopX = oldMaxX - tmppriv->bottomX; - tmpBottomX = oldMaxX - tmppriv->topX; - tmpTopY = oldMaxY - tmppriv->bottomY; - tmpBottomY = oldMaxY - tmppriv->topY; - break; - default: /* ROTATE_NONE */ - tmpTopX = tmppriv->topX; - tmpBottomX = tmppriv->bottomX; - tmpTopY = tmppriv->topY; - tmpBottomY = tmppriv->bottomY; - break; - } - /* and rotate them back */ - switch (value) { - case ROTATE_CW: - tmparea->topX = tmppriv->topX = tmpTopY; - tmparea->bottomX = tmppriv->bottomX = tmpBottomY; - tmparea->topY = tmppriv->topY = priv->wcmMaxY - tmpBottomX; - tmparea->bottomY = tmppriv->bottomY = priv->wcmMaxY - tmpTopX; - break; - case ROTATE_CCW: - tmparea->topX = tmppriv->topX = priv->wcmMaxX - tmpBottomY; - tmparea->bottomX = tmppriv->bottomX = priv->wcmMaxX - tmpTopY; - tmparea->topY = tmppriv->topY = tmpTopX; - tmparea->bottomY = tmppriv->bottomY = tmpBottomX; - break; - case ROTATE_HALF: - tmparea->topX = tmppriv->topX = priv->wcmMaxX - tmpBottomX; - tmparea->bottomX = tmppriv->bottomX = priv->wcmMaxX - tmpTopX; - tmparea->topY = tmppriv->topY= priv->wcmMaxY - tmpBottomY; - tmparea->bottomY = tmppriv->bottomY = priv->wcmMaxY - tmpTopY; - break; - default: /* ROTATE_NONE */ - tmparea->topX = tmppriv->topX = tmpTopX; - tmparea->bottomX = tmppriv->bottomX = tmpBottomX; - tmparea->topY = tmppriv->topY = tmpTopY; - tmparea->bottomY = tmppriv->bottomY = tmpBottomY; - break; - } - - xf86WcmInitialScreens(tmppriv->local); - xf86WcmMappingFactor(tmppriv->local); - xf86WcmInitialCoordinates(tmppriv->local, 0); - xf86WcmInitialCoordinates(tmppriv->local, 1); - - xf86ReplaceIntOption(tmppriv->local->options, "TopX", tmppriv->topX); - xf86ReplaceIntOption(tmppriv->local->options, "TopY", tmppriv->topY); - xf86ReplaceIntOption(tmppriv->local->options, "BottomX", tmppriv->bottomX); - xf86ReplaceIntOption(tmppriv->local->options, "BottomY", tmppriv->bottomY); - } + if (common->wcmRotate != value) + xf86WcmRotateScreen(local, value); break; - default: + default: DBG(10, priv->debugLevel, ErrorF("xf86WcmSetParam invalid param %d\n",param)); return BadMatch; } diff --git a/src/xdrv/xf86Wacom.c b/src/xdrv/xf86Wacom.c index 0d130f0..821b306 100755 --- a/src/xdrv/xf86Wacom.c +++ b/src/xdrv/xf86Wacom.c @@ -69,9 +69,10 @@ * 2008-03-07 47-pc0.7.9-9 - Support keystrokes in wacomcpl * 2008-04-07 47-pc0.7.9-11 - Synchronized databases * 2008-05-06 47-pc0.8.0-1 - new release + * 2008-05-14 47-pc0.8.0-2 - Update rotation routine */ -static const char identification[] = "$Identification: 47-0.8.0-1 $"; +static const char identification[] = "$Identification: 47-0.8.0-2 $"; /****************************************************************************/ @@ -92,6 +93,7 @@ extern int usbWcmGetRanges(LocalDevicePtr local); extern int xf86WcmDevChangeControl(LocalDevicePtr local, xDeviceCtl* control); extern int xf86WcmDevSwitchMode(ClientPtr client, DeviceIntPtr dev, int mode); extern void xf86WcmInitialScreens(LocalDevicePtr local); +extern void xf86WcmRotateScreen(LocalDevicePtr local, int value); WacomModule gWacomModule = { @@ -171,6 +173,7 @@ static int xf86WcmInitArea(LocalDevicePtr local) } /* need maxWidth and maxHeight for keepshape */ + xf86WcmInitialScreens(local); xf86WcmMappingFactor(local); /* Maintain aspect ratio */ @@ -208,7 +211,7 @@ static int xf86WcmInitArea(LocalDevicePtr local) { inlist = priv->tool->arealist; - /* remove this area from the list */ + /* remove this overlapped area from the list */ for (; inlist; inlist=inlist->next) { if (inlist->next == area) @@ -475,7 +478,6 @@ static void xf86WcmInitialToolSize(LocalDevicePtr local) WacomCommonPtr common = priv->common; WacomToolPtr toollist = common->wcmTool; WacomToolAreaPtr arealist; - int temp; if (IsTouch(priv)) { @@ -492,14 +494,6 @@ static void xf86WcmInitialToolSize(LocalDevicePtr local) priv->wcmResolY = common->wcmResolY; } - /* Rotation rotates the Max Y and Y */ - if (common->wcmRotate==ROTATE_CW || common->wcmRotate==ROTATE_CCW) - { - temp = priv->wcmMaxX; - priv->wcmMaxX = priv->wcmMaxY; - priv->wcmMaxY = temp; - } - for (; toollist; toollist=toollist->next) { arealist = toollist->arealist; @@ -511,6 +505,7 @@ static void xf86WcmInitialToolSize(LocalDevicePtr local) arealist->bottomY = priv->wcmMaxY; } } + return; } @@ -543,16 +538,6 @@ static int xf86WcmRegisterX11Devices (LocalDevicePtr local) IsPad(priv) ? "pad" : "eraser", nbbuttons, nbkeys, nbaxes)); - xf86WcmInitialToolSize(local); - - /* initialize screen bounding rect */ - xf86WcmInitialScreens(local); - - if (xf86WcmInitArea(local) == FALSE) - { - return FALSE; - } - for(loop=1; loop<=nbbuttons; loop++) butmap[loop] = loop; @@ -663,11 +648,15 @@ static int xf86WcmRegisterX11Devices (LocalDevicePtr local) xf86MotionHistoryAllocate(local); #endif - /* x */ - xf86WcmInitialCoordinates(local, 0); + xf86WcmInitialToolSize(local); + + if (xf86WcmInitArea(local) == FALSE) + { + return FALSE; + } - /* y */ - xf86WcmInitialCoordinates(local, 1); + /* Rotation rotates the Max X and Y */ + xf86WcmRotateScreen(local, common->wcmRotate); /* pressure */ InitValuatorAxisStruct(local->dev, 2, 0,