From ffe299eaea8a7295228701205c9286cc66e9ab0f Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Sun, 18 Apr 2010 16:22:56 +0200 Subject: Hold MT data during pure button events Some devices send button events through a separate device, causing the driver to temporarily lose the MT state. As a result, spurious button events are emitted in conjunction with multi-finger clicks. This patch makes sure that the MT state is updated only after receiving MT data, restoring click normality. Signed-off-by: Henrik Rydberg --- src/hwdata.c | 8 +++++++- src/hwdata.h | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/hwdata.c b/src/hwdata.c index 9ec6241..689418e 100644 --- a/src/hwdata.c +++ b/src/hwdata.c @@ -32,6 +32,7 @@ static void set_value(struct HWData *hw, int code, int value) (&hw->finger[hw->nread].touch_major)[code] = value; SETBIT(hw->mread[hw->nread], code); } + hw->mtread++; } static void accept_finger(struct HWData *hw) @@ -49,7 +50,9 @@ static void accept_finger(struct HWData *hw) static void accept_packet(struct HWData *hw, const struct timeval* tv) { static const mstime_t ms = 1000; - hw->nfinger = hw->nread; + if (hw->mtread) + hw->nfinger = hw->nread; + hw->mtread = 0; hw->nread = 0; hw->mread[hw->nread] = 0; hw->evtime = tv->tv_usec / ms + tv->tv_sec * ms; @@ -70,6 +73,9 @@ int read_hwdata(struct HWData *hw, const struct input_event* ev) break; case EV_KEY: switch (ev->code) { + case BTN_TOUCH: + hw->mtread++; + break; case BTN_LEFT: if (ev->value) SETBIT(hw->button, MT_BUTTON_LEFT); diff --git a/src/hwdata.h b/src/hwdata.h index 81d847b..15a9fcb 100644 --- a/src/hwdata.h +++ b/src/hwdata.h @@ -73,7 +73,7 @@ struct HWData { struct FingerData finger[DIM_FINGER]; unsigned mask[DIM_FINGER], mread[DIM_FINGER]; unsigned button; - int nfinger, nread; + int nfinger, mtread, nread; mstime_t evtime; }; -- cgit v1.2.3