[PATCH 1/5] hid: 3m: Revert 267fcc

Henrik Rydberg rydberg at euromail.se
Wed Sep 1 11:22:20 UTC 2010


This reverts commit 267fcc51174f3e1a8ae045af2d75ed9d7545ed17.
---
 drivers/hid/hid-3m-pct.c |   47 ++++++++++++++++++++++++++++++++++++---------
 1 files changed, 37 insertions(+), 10 deletions(-)

diff --git a/drivers/hid/hid-3m-pct.c b/drivers/hid/hid-3m-pct.c
index fc57c0c..2a0d56b 100644
--- a/drivers/hid/hid-3m-pct.c
+++ b/drivers/hid/hid-3m-pct.c
@@ -125,7 +125,9 @@ static int mmm_input_mapped(struct hid_device *hdev, struct hid_input *hi,
  */
 static void mmm_filter_event(struct mmm_data *md, struct input_dev *input)
 {
-	int i, index = -1;
+	struct mmm_finger *oldest = 0;
+	bool pressed = false, released = false;
+	int i;
 
 	/*
 	 * we need to iterate on all fingers to decide if we have a press
@@ -147,20 +149,45 @@ static void mmm_filter_event(struct mmm_data *md, struct input_dev *input)
 			input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR,
 						wide ? f->h : f->w);
 			input_mt_sync(input);
-
-			if (index < 0)
-				index = i;
+			/*
+			 * touchscreen emulation: maintain the age rank
+			 * of this finger, decide if we have a press
+			 */
+			if (f->rank == 0) {
+				f->rank = ++(md->num);
+				if (f->rank == 1)
+					pressed = true;
+			}
+			if (f->rank == 1)
+				oldest = f;
+		} else {
+			/* this finger took off the screen */
+			/* touchscreen emulation: maintain age rank of others */
+			int j;
+
+			for (j = 0; j < 10; ++j) {
+				struct mmm_finger *g = &md->f[j];
+				if (g->rank > f->rank) {
+					g->rank--;
+					if (g->rank == 1)
+						oldest = g;
+				}
+			}
+			f->rank = 0;
+			--(md->num);
+			if (md->num == 0)
+				released = true;
 		}
 		f->valid = 0;
 	}
 
 	/* touchscreen emulation */
-	if (index >= 0) {
-		struct mmm_finger *f = &md->f[index];
-		input_event(input, EV_KEY, BTN_TOUCH, 1);
-		input_event(input, EV_ABS, ABS_X, f->x);
-		input_event(input, EV_ABS, ABS_Y, f->y);
-	} else {
+	if (oldest) {
+		if (pressed)
+			input_event(input, EV_KEY, BTN_TOUCH, 1);
+		input_event(input, EV_ABS, ABS_X, oldest->x);
+		input_event(input, EV_ABS, ABS_Y, oldest->y);
+	} else if (released) {
 		input_event(input, EV_KEY, BTN_TOUCH, 0);
 	}
 }
-- 
1.7.1





More information about the kernel-team mailing list