aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@insightbb.com>2007-04-12 01:31:55 -0400
committerDmitry Torokhov <dtor@insightbb.com>2007-04-12 01:31:55 -0400
commit0d9d93c411c9351ba186f5ec910b10da7c1d9d14 (patch)
tree4c4752f0d4774d1cc3353facad0daba4c0de7285 /drivers/input
parentf42649e84831efc69d5f621f1c36a39b4e384a99 (diff)
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>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/mousedev.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index 764970f5da2e..3b8011c56c86 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -124,32 +124,33 @@ static void mousedev_touchpad_event(struct input_dev *dev, struct mousedev *mous
124 int size, tmp; 124 int size, tmp;
125 enum { FRACTION_DENOM = 128 }; 125 enum { FRACTION_DENOM = 128 };
126 126
127 if (mousedev->touch) { 127 switch (code) {
128 size = dev->absmax[ABS_X] - dev->absmin[ABS_X]; 128 case ABS_X:
129 if (size == 0) 129 fx(0) = value;
130 size = 256 * 2; 130 if (mousedev->touch && mousedev->pkt_count >= 2) {
131 131 size = dev->absmax[ABS_X] - dev->absmin[ABS_X];
132 switch (code) { 132 if (size == 0)
133 case ABS_X: 133 size = 256 * 2;
134 fx(0) = value; 134 tmp = ((value - fx(2)) * (256 * FRACTION_DENOM)) / size;
135 if (mousedev->pkt_count >= 2) { 135 tmp += mousedev->frac_dx;
136 tmp = ((value - fx(2)) * (256 * FRACTION_DENOM)) / size; 136 mousedev->packet.dx = tmp / FRACTION_DENOM;
137 tmp += mousedev->frac_dx; 137 mousedev->frac_dx = tmp - mousedev->packet.dx * FRACTION_DENOM;
138 mousedev->packet.dx = tmp / FRACTION_DENOM; 138 }
139 mousedev->frac_dx = tmp - mousedev->packet.dx * FRACTION_DENOM; 139 break;
140 }
141 break;
142 140
143 case ABS_Y: 141 case ABS_Y:
144 fy(0) = value; 142 fy(0) = value;
145 if (mousedev->pkt_count >= 2) { 143 if (mousedev->touch && mousedev->pkt_count >= 2) {
146 tmp = -((value - fy(2)) * (256 * FRACTION_DENOM)) / size; 144 /* use X size to keep the same scale */
147 tmp += mousedev->frac_dy; 145 size = dev->absmax[ABS_X] - dev->absmin[ABS_X];
148 mousedev->packet.dy = tmp / FRACTION_DENOM; 146 if (size == 0)
149 mousedev->frac_dy = tmp - mousedev->packet.dy * FRACTION_DENOM; 147 size = 256 * 2;
150 } 148 tmp = -((value - fy(2)) * (256 * FRACTION_DENOM)) / size;
151 break; 149 tmp += mousedev->frac_dy;
152 } 150 mousedev->packet.dy = tmp / FRACTION_DENOM;
151 mousedev->frac_dy = tmp - mousedev->packet.dy * FRACTION_DENOM;
152 }
153 break;
153 } 154 }
154} 155}
155 156