aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/input/appletouch.c
diff options
context:
space:
mode:
authorJason Parekh <jasonparekh@gmail.com>2006-11-17 01:05:58 -0500
committerDmitry Torokhov <dtor@insightbb.com>2006-11-17 01:05:58 -0500
commit00081d3729a450c37afb01c01528f4f305806d86 (patch)
treec572b8b4da05d3828b66c91debe7a160ee259165 /drivers/usb/input/appletouch.c
parenteb5d5829b368c5e32f248a70797bee5a414a2ef0 (diff)
Input: appletouch - verious updates for MacBooks
Change a bit the finger detection method used by the appletouch driver to reduce touchpad "jumpiness": - Adjust the method for detecting multiple fingers. Previously, it recognized a new finger when a low sensor reading is followed by a high sensor reading. The new method checks for 'humps' in the sensor readings, so there doesn't necessarily have to be a low sensor between two high sensors for two fingers to be triggered. This allows detecting presence of two fingers on the touchpad even when they touch each other. - Change absolute coordinate calculation to us to get rid of "jumps". Instead of using full value from a sensor once it passes the threshold subtract theshold value from the reading. - Allow adjusting threshold value via module parameter. The patch doesn't seem to affect the Powerbooks but does greatly improve the touchpad behaviour on the MacBooks. Signed-off-by: Jason Parekh <jasonparekh@gmail.com> Signed-off-by: Stelian Pop <stelian@popies.net> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/usb/input/appletouch.c')
-rw-r--r--drivers/usb/input/appletouch.c47
1 files changed, 43 insertions, 4 deletions
diff --git a/drivers/usb/input/appletouch.c b/drivers/usb/input/appletouch.c
index 4c213513484d..4825db4b2566 100644
--- a/drivers/usb/input/appletouch.c
+++ b/drivers/usb/input/appletouch.c
@@ -154,6 +154,13 @@ MODULE_AUTHOR("Johannes Berg, Stelian Pop, Frank Arnold, Michael Hanselmann");
154MODULE_DESCRIPTION("Apple PowerBooks USB touchpad driver"); 154MODULE_DESCRIPTION("Apple PowerBooks USB touchpad driver");
155MODULE_LICENSE("GPL"); 155MODULE_LICENSE("GPL");
156 156
157/*
158 * Make the threshold a module parameter
159 */
160static int threshold = ATP_THRESHOLD;
161module_param(threshold, int, 0644);
162MODULE_PARM_DESC(threshold, "Discards any change in data from a sensor (trackpad has hundreds of these sensors) less than this value");
163
157static int debug = 1; 164static int debug = 1;
158module_param(debug, int, 0644); 165module_param(debug, int, 0644);
159MODULE_PARM_DESC(debug, "Activate debugging output"); 166MODULE_PARM_DESC(debug, "Activate debugging output");
@@ -183,16 +190,48 @@ static int atp_calculate_abs(int *xy_sensors, int nb_sensors, int fact,
183 int i; 190 int i;
184 /* values to calculate mean */ 191 /* values to calculate mean */
185 int pcum = 0, psum = 0; 192 int pcum = 0, psum = 0;
193 int is_increasing = 0;
186 194
187 *fingers = 0; 195 *fingers = 0;
188 196
189 for (i = 0; i < nb_sensors; i++) { 197 for (i = 0; i < nb_sensors; i++) {
190 if (xy_sensors[i] < ATP_THRESHOLD) 198 if (xy_sensors[i] < threshold) {
199 if (is_increasing)
200 is_increasing = 0;
201
191 continue; 202 continue;
192 if ((i - 1 < 0) || (xy_sensors[i - 1] < ATP_THRESHOLD)) 203 }
204
205 /*
206 * Makes the finger detection more versatile. For example,
207 * two fingers with no gap will be detected. Also, my
208 * tests show it less likely to have intermittent loss
209 * of multiple finger readings while moving around (scrolling).
210 *
211 * Changes the multiple finger detection to counting humps on
212 * sensors (transitions from nonincreasing to increasing)
213 * instead of counting transitions from low sensors (no
214 * finger reading) to high sensors (finger above
215 * sensor)
216 *
217 * - Jason Parekh <jasonparekh@gmail.com>
218 */
219 if (i < 1 || (!is_increasing && xy_sensors[i - 1] < xy_sensors[i])) {
193 (*fingers)++; 220 (*fingers)++;
194 pcum += xy_sensors[i] * i; 221 is_increasing = 1;
195 psum += xy_sensors[i]; 222 } else if (i > 0 && xy_sensors[i - 1] >= xy_sensors[i]) {
223 is_increasing = 0;
224 }
225
226 /*
227 * Subtracts threshold so a high sensor that just passes the threshold
228 * won't skew the calculated absolute coordinate. Fixes an issue
229 * where slowly moving the mouse would occassionaly jump a number of
230 * pixels (let me restate--slowly moving the mouse makes this issue
231 * most apparent).
232 */
233 pcum += (xy_sensors[i] - threshold) * i;
234 psum += (xy_sensors[i] - threshold);
196 } 235 }
197 236
198 if (psum > 0) { 237 if (psum > 0) {