aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/input
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/input')
-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) {