Input: mousedev - fix sudden warps with touchpads

Pete Zaitcev reports that with his touchpad, if he lifts the finger
and places it elsewhere, the pointer sometimes warps dramatically.
This happens because we don't store coordinates unless we detect a
touch so sometimes we have stale coordinates in queue (from where
the finger left the pad) and averaging makes cursor to jump across
the screen. The solution is to always store the latest coordinates.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
This commit is contained in:
Dmitry Torokhov 2007-04-12 01:31:55 -04:00
parent f42649e848
commit 0d9d93c411
1 changed files with 26 additions and 25 deletions

View File

@ -124,32 +124,33 @@ static void mousedev_touchpad_event(struct input_dev *dev, struct mousedev *mous
int size, tmp; int size, tmp;
enum { FRACTION_DENOM = 128 }; enum { FRACTION_DENOM = 128 };
if (mousedev->touch) { switch (code) {
size = dev->absmax[ABS_X] - dev->absmin[ABS_X]; case ABS_X:
if (size == 0) fx(0) = value;
size = 256 * 2; if (mousedev->touch && mousedev->pkt_count >= 2) {
size = dev->absmax[ABS_X] - dev->absmin[ABS_X];
if (size == 0)
size = 256 * 2;
tmp = ((value - fx(2)) * (256 * FRACTION_DENOM)) / size;
tmp += mousedev->frac_dx;
mousedev->packet.dx = tmp / FRACTION_DENOM;
mousedev->frac_dx = tmp - mousedev->packet.dx * FRACTION_DENOM;
}
break;
switch (code) { case ABS_Y:
case ABS_X: fy(0) = value;
fx(0) = value; if (mousedev->touch && mousedev->pkt_count >= 2) {
if (mousedev->pkt_count >= 2) { /* use X size to keep the same scale */
tmp = ((value - fx(2)) * (256 * FRACTION_DENOM)) / size; size = dev->absmax[ABS_X] - dev->absmin[ABS_X];
tmp += mousedev->frac_dx; if (size == 0)
mousedev->packet.dx = tmp / FRACTION_DENOM; size = 256 * 2;
mousedev->frac_dx = tmp - mousedev->packet.dx * FRACTION_DENOM; tmp = -((value - fy(2)) * (256 * FRACTION_DENOM)) / size;
} tmp += mousedev->frac_dy;
break; mousedev->packet.dy = tmp / FRACTION_DENOM;
mousedev->frac_dy = tmp - mousedev->packet.dy * FRACTION_DENOM;
case ABS_Y: }
fy(0) = value; break;
if (mousedev->pkt_count >= 2) {
tmp = -((value - fy(2)) * (256 * FRACTION_DENOM)) / size;
tmp += mousedev->frac_dy;
mousedev->packet.dy = tmp / FRACTION_DENOM;
mousedev->frac_dy = tmp - mousedev->packet.dy * FRACTION_DENOM;
}
break;
}
} }
} }