--- evdev.c.orig-abs 2005-09-21 15:08:46.000000000 -0600 +++ evdev.c 2005-09-22 15:38:13.000000000 -0600 @@ -74,7 +74,7 @@ } TouchState; typedef struct { - int oldabsx, oldabsy; + int oldabsx, oldabsy; /* old *scaled* absolute coordinates */ int touchStart; TouchState state; OsTimerPtr upTimer; @@ -124,15 +124,9 @@ EvdevConvert(InputInfoPtr pInfo, int first, int num, int v0, int v1, int v2, int v3, int v4, int v5, int *x, int *y) { - EvdevPrivatePtr priv = pInfo->private; if (first == 0 && num == 2) { - if(priv->touchPad) { - *x = v0; - *y = v1; - } else { - *x = xf86ScaleAxis(v0, 0, priv->screen_width, priv->min_x, priv->max_x); - *y = xf86ScaleAxis(v1, 0, priv->screen_height, priv->min_y, priv->max_y); - } + *x = v0; + *y = v1; return TRUE; } else @@ -145,15 +139,11 @@ struct input_event ev; int len, value; int dx, dy; - int absx, absy; EvdevPrivatePtr priv = pInfo->private; dx = 0; dy = 0; - absx = priv->oldabsx; - absy = priv->oldabsy; - while (xf86WaitForInput (pInfo->fd, 0) > 0) { len = read(pInfo->fd, &ev, sizeof ev); if (len != sizeof ev) { @@ -196,11 +186,34 @@ case EV_ABS: switch (ev.code) { case ABS_X: - absx = value; + if (priv->state & (STATE_TOUCHING || STATE_DRAGGING)) { + value = xf86ScaleAxis(value, 0, priv->screen_width, + priv->min_x, priv->max_x); + if (!priv->touchPad) { + xf86XInputSetScreen(pInfo, priv->screen_num, + value, priv->oldabsy); + xf86PostMotionEvent(pInfo->dev, TRUE, 0, 2, + value, priv->oldabsy); + } else if (priv->oldabsx != -1) { + dx = value - priv->oldabsx; + } + priv->oldabsx = value; + } break; - case ABS_Y: - absy = value; + if (priv->state & (STATE_TOUCHING || STATE_DRAGGING)) { + value = xf86ScaleAxis(value, 0, priv->screen_height, + priv->min_y, priv->max_y); + if (!priv->touchPad) { + xf86XInputSetScreen(pInfo, priv->screen_num, + priv->oldabsx, value); + xf86PostMotionEvent(pInfo->dev, TRUE, 0, 2, + priv->oldabsx, value); + } else if (priv->oldabsy != -1) { + dy = value - priv->oldabsy; + } + priv->oldabsy = value; + } break; } break; @@ -285,25 +298,8 @@ } } - if(priv->state == STATE_TOUCHING || priv->state == STATE_DRAGGING) { - if(!priv->touchPad) { - int conv_x, conv_y; - EvdevConvert(pInfo, 0, 2, absx, absy, 0, 0, 0, 0, &conv_x, &conv_y); - xf86XInputSetScreen(pInfo, priv->screen_num, conv_x, conv_y); - - xf86PostMotionEvent(pInfo->dev, TRUE, 0, 2, absx, absy); - } else { - if(priv->oldabsx != -1) - dx = absx - priv->oldabsx; - if(priv->oldabsy != -1) - dy = absy - priv->oldabsy; - } - } - priv->oldabsx = absx; - priv->oldabsy = absy; - if (dx != 0 || dy != 0) - xf86PostMotionEvent(pInfo->dev, 0, 0, 2, dx, dy); + xf86PostMotionEvent(pInfo->dev, FALSE, 0, 2, dx, dy); } #define TestBit(bit, array) (array[(bit) / 8] & (1 << ((bit) % 8))) @@ -747,24 +743,6 @@ return; } - if(!priv->touchPad) { - if (ioctl(pInfo->fd, - EVIOCGABS(ABS_X), &absinfo) < 0) { - xf86Msg(X_ERROR, "ioctl EVIOCGABS failed: %s\n", strerror(errno)); - return; - } - priv->min_x = absinfo.minimum; - priv->max_x = absinfo.maximum; - - if (ioctl(pInfo->fd, - EVIOCGABS(ABS_Y), &absinfo) < 0) { - xf86Msg(X_ERROR, "ioctl EVIOCGABS failed: %s\n", strerror(errno)); - return; - } - priv->min_y = absinfo.minimum; - priv->max_y = absinfo.maximum; - } - has_axes = FALSE; has_buttons = FALSE; has_keys = FALSE; @@ -777,12 +755,31 @@ if (TestBit(ABS_X, abs_bitmask) && TestBit(ABS_Y, abs_bitmask)) { xf86Msg(X_INFO, "%s: Found x and y absolute axes\n", pInfo->name); has_axes = TRUE; + + if (ioctl(pInfo->fd, EVIOCGABS(ABS_X), &absinfo) < 0) { + xf86Msg(X_ERROR, "ioctl EVIOCGABS failed: %s\n", strerror(errno)); + return; + } + priv->min_x = absinfo.minimum; + priv->max_x = absinfo.maximum; + priv->oldabsx = -1; + + if (ioctl(pInfo->fd, EVIOCGABS(ABS_Y), &absinfo) < 0) { + xf86Msg(X_ERROR, "ioctl EVIOCGABS failed: %s\n", strerror(errno)); + return; + } + priv->min_y = absinfo.minimum; + priv->max_y = absinfo.maximum; + priv->oldabsy = -1; } if (TestBit(BTN_LEFT, key_bitmask) || (TestBit(BTN_TOOL_FINGER, key_bitmask) && priv->tapTime > 0)) { xf86Msg(X_INFO, "%s: Found mouse buttons\n", pInfo->name); has_buttons = TRUE; + + if (!TestBit(BTN_TOOL_FINGER, key_bitmask)) + priv->state = STATE_TOUCHING; } for (i = 0; i < BTN_MISC; i++) @@ -855,7 +852,7 @@ priv->touchStart = 0; priv->state = STATE_NORMAL; priv->tapTime = 200; - priv->touchPad = TRUE; + priv->touchPad = FALSE; xf86CollectInputOptions(pInfo, NULL, NULL); xf86ProcessCommonOptions(pInfo, pInfo->options);