lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Sat, 11 Nov 2006 15:30:33 +0100
From:	Stelian Pop <stelian@...ies.net>
To:	Dmitry Torokhov <dmitry.torokhov@...il.com>
Cc:	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Jason Parekh <jasonparekh@...il.com>
Subject: [PATCH] appletouch improvements for MacBook

Hi,

The attached patch, originally from Jason Parekh, changes a bit the
finger detection method used by the appletouch driver.

The patch doesn't seem to affect the Powerbooks but does greatly improve
the touchpad behaviour on the MacBooks (no more "jumpiness").

Quoting Jason, for the description of the patch:
- The detection method for multiple fingers.  Previously, it
recognizes a new finger when a low sensor is followed by a high
sensor.  I changed it so it 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 (I personally leave my two
fingers touching each other when two-finger scrolling, so this became
an issue for me).

- The absolute coordinate function.  Previously, it incorporates new
sensors into the function once the sensor passes the threshold.
However, as soon as a sensor passes the threshold, its full value
(usually the threshold value since it just passed it) is included in
the calculation.  This caused there to be some jumps in the cursor
when moving the mouse around.  What I do instead if subtract the
threshold from each sensor when calculating the absolute position.
This allows my cursor to be extremely smooth since a newly high sensor
that gets included in the absolute position calculation will only have
a value of 1 instead of the threshold value.

- The threshold value.  The default value remains at 10, but it is a
module option now.

Signed-off-by: Jason Parekh <jasonparekh@...il.com>
Signed-off-by: Stelian Pop <stelian@...ies.net>

---

 appletouch.c |   49 ++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 44 insertions(+), 5 deletions(-)

diff -r ce04cd6b09e6 drivers/usb/input/appletouch.c
--- a/drivers/usb/input/appletouch.c	Sat Oct 21 20:58:23 2006 +0200
+++ b/drivers/usb/input/appletouch.c	Sat Oct 21 21:25:01 2006 +0200
@@ -154,6 +154,13 @@ MODULE_DESCRIPTION("Apple PowerBooks USB
 MODULE_DESCRIPTION("Apple PowerBooks USB touchpad driver");
 MODULE_LICENSE("GPL");
 
+/*
+ * Make the threshold a module parameter
+ */
+static int threshold = ATP_THRESHOLD;
+module_param(threshold, int, 0644);
+MODULE_PARM_DESC(threshold, "Discards any change in data from a sensor (trackpad has hundreds of these sensors) less than this value");
+
 static int debug = 1;
 module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, "Activate debugging output");
@@ -183,16 +190,48 @@ static int atp_calculate_abs(int *xy_sen
 	int i;
 	/* values to calculate mean */
 	int pcum = 0, psum = 0;
-
+	int is_increasing = 0;
+	
 	*fingers = 0;
 
 	for (i = 0; i < nb_sensors; i++) {
-		if (xy_sensors[i] < ATP_THRESHOLD)
+		if (xy_sensors[i] < threshold) {
+			if (is_increasing)
+				is_increasing = 0;
+			
 			continue;
-		if ((i - 1 < 0) || (xy_sensors[i - 1] < ATP_THRESHOLD))
+		}
+		
+		/*
+ 		 * Makes the finger detection more versatile.  For example,
+ 		 * two fingers with no gap will be detected.  Also, my
+ 		 * tests show it less likely to have intermittent loss
+ 		 * of multiple finger readings while moving around (scrolling).
+ 		 *
+ 		 * Changes the multiple finger detection to counting humps on
+ 		 * sensors (transitions from nonincreasing to increasing)
+ 		 * instead of counting transitions from low sensors (no
+ 		 * finger reading) to high sensors (finger above
+ 		 * sensor)
+ 		 * 
+ 		 * - Jason Parekh <jasonparekh@...il.com>
+ 		 */
+		if ((i < 1) || (!is_increasing && (xy_sensors[i-1] < xy_sensors[i]))) {
 			(*fingers)++;
-		pcum += xy_sensors[i] * i;
-		psum += xy_sensors[i];
+			is_increasing = 1;
+		} else if ((i > 0) && (xy_sensors[i-1] >= xy_sensors[i])) {
+			is_increasing = 0;
+		}
+		
+		/* 
+		 * Subtracts threshold so a high sensor that just passes the threshold
+ 		 * won't skew the calculated absolute coordinate.  Fixes an issue
+ 		 * where slowly moving the mouse would occassionaly jump a number of
+ 		 * pixels (let me restate--slowly moving the mouse makes this issue
+ 		 * most apparent).
+ 		 */
+		pcum += (xy_sensors[i]-threshold) * i;
+		psum += (xy_sensors[i]-threshold);
 	}
 
 	if (psum > 0) {

-- 
Stelian Pop <stelian@...ies.net>

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ