Commit 0d9d93c4 authored by Dmitry Torokhov's avatar Dmitry Torokhov
Browse files

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: default avatarDmitry Torokhov <dtor@mail.ru>
parent f42649e8
Loading
Loading
Loading
Loading
+26 −25
Original line number Diff line number Diff line
@@ -124,15 +124,13 @@ static void mousedev_touchpad_event(struct input_dev *dev, struct mousedev *mous
	int size, tmp;
	enum { FRACTION_DENOM = 128 };

	if (mousedev->touch) {
		size = dev->absmax[ABS_X] - dev->absmin[ABS_X];
		if (size == 0)
			size = 256 * 2;

	switch (code) {
		case ABS_X:
			fx(0) = value;
				if (mousedev->pkt_count >= 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;
@@ -142,7 +140,11 @@ static void mousedev_touchpad_event(struct input_dev *dev, struct mousedev *mous

		case ABS_Y:
			fy(0) = value;
				if (mousedev->pkt_count >= 2) {
			if (mousedev->touch && mousedev->pkt_count >= 2) {
				/* use X size to keep the same scale */
				size = dev->absmax[ABS_X] - dev->absmin[ABS_X];
				if (size == 0)
					size = 256 * 2;
				tmp = -((value - fy(2)) * (256 * FRACTION_DENOM)) / size;
				tmp += mousedev->frac_dy;
				mousedev->packet.dy = tmp / FRACTION_DENOM;
@@ -151,7 +153,6 @@ static void mousedev_touchpad_event(struct input_dev *dev, struct mousedev *mous
			break;
	}
}
}

static void mousedev_abs_event(struct input_dev *dev, struct mousedev *mousedev, unsigned int code, int value)
{