From 3fdcbbc07762d2f0ca71dcbd19426910980e08e5 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Tue, 21 Sep 2010 23:22:39 +0200 Subject: [PATCH] --- yaml --- r: 215561 b: refs/heads/master c: 1d958c83c8d77ad4977ae963017e87cec8cca9b5 h: refs/heads/master i: 215559: b95bce78503b302112b0a19811a8aed3b0b451c2 v: v3 --- [refs] | 2 +- trunk/drivers/hid/hid-3m-pct.c | 41 +++++----------------------------- 2 files changed, 6 insertions(+), 37 deletions(-) diff --git a/[refs] b/[refs] index 616c402d82b3..7b355d5cc489 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 1f01a1fe167f588c8b6b449fde2f5427ca940423 +refs/heads/master: 1d958c83c8d77ad4977ae963017e87cec8cca9b5 diff --git a/trunk/drivers/hid/hid-3m-pct.c b/trunk/drivers/hid/hid-3m-pct.c index 3c380e1c5b60..39628e02a428 100644 --- a/trunk/drivers/hid/hid-3m-pct.c +++ b/trunk/drivers/hid/hid-3m-pct.c @@ -37,7 +37,6 @@ MODULE_LICENSE("GPL"); struct mmm_finger { __s32 x, y, w, h; __u16 id; - __u8 rank; bool prev_touch; bool touch, valid; }; @@ -45,7 +44,7 @@ struct mmm_finger { struct mmm_data { struct mmm_finger f[MAX_SLOTS]; __u16 id; - __u8 curid, num; + __u8 curid; __u8 nexp, nreal; bool touch, valid; }; @@ -156,13 +155,7 @@ 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) { 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 - * or a release event in our touchscreen emulation. - */ for (i = 0; i < MAX_SLOTS; ++i) { struct mmm_finger *f = &md->f[i]; if (!f->valid) { @@ -183,34 +176,11 @@ static void mmm_filter_event(struct mmm_data *md, struct input_dev *input) wide ? f->w : f->h); input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR, wide ? f->h : f->w); - /* - * 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) + /* touchscreen emulation: pick the oldest contact */ + if (!oldest || ((f->id - oldest->id) & (SHRT_MAX + 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; input_event(input, EV_ABS, ABS_MT_TRACKING_ID, -1); } f->prev_touch = f->touch; @@ -219,11 +189,10 @@ static void mmm_filter_event(struct mmm_data *md, struct input_dev *input) /* touchscreen emulation */ if (oldest) { - if (pressed) - input_event(input, EV_KEY, BTN_TOUCH, 1); + 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) { + } else { input_event(input, EV_KEY, BTN_TOUCH, 0); } input_sync(input);