From 72252db3425a88f404f6d76eb15d02ace06747b7 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Mon, 28 Aug 2017 11:11:39 +0800 Subject: [PATCH] touchpad_elan: Discard zero finger clicks Do not report click events when no finger is present on the touchpad. BRANCH=none BUG=b:65098167 TEST=Bend case, hear click, but no event reported in evtest. Change-Id: I0385213102dab0775e1b6906cb3a45933deac757 Signed-off-by: Nicolas Boichat Reviewed-on: https://chromium-review.googlesource.com/637288 Reviewed-by: Vincent Palatin --- driver/touchpad_elan.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/driver/touchpad_elan.c b/driver/touchpad_elan.c index 744ddd6904..fc47c362a9 100644 --- a/driver/touchpad_elan.c +++ b/driver/touchpad_elan.c @@ -154,13 +154,6 @@ static int elan_tp_read_report(void) touch_info = tp_buf[ETP_TOUCH_INFO_OFFSET]; hover_info = tp_buf[ETP_HOVER_INFO_OFFSET]; - if (touch_info & 0x01) - report.button = 1; - if (hover_info & 0x40) { - /* TODO(crosbug.com/p/59083): Report hover event */ - CPRINTF("[TP] hover!\n"); - } - for (i = 0; i < ETP_MAX_FINGERS; i++) { int valid = touch_info & (1 << (3+i)); @@ -199,6 +192,17 @@ static int elan_tp_read_report(void) report.count = ri; report.timestamp = timestamp; + if (touch_info & 0x01) { + /* Do not report zero-finger click events */ + if (report.count > 0) + report.button = 1; + } + + if (hover_info & 0x40) { + /* TODO(b/35582031): Report hover event */ + CPRINTF("[TP] hover!\n"); + } + set_touchpad_report(&report); return 0;