linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chung-yih Wang <cywang@chromium.org>
To: linux-input@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	Henrik Rydberg <rydberg@euromail.se>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	benjamin.tissoires@gmail.com,
	Chung-yih Wang <cywang@chromium.org>
Subject: [PATCH v2] input: fix BTN_TOUCH reporting in input_mt_report_pointer_emulation
Date: Mon, 27 Oct 2014 18:08:47 +0800	[thread overview]
Message-ID: <1414404527-17526-1-git-send-email-cywang@chromium.org> (raw)
In-Reply-To: <1412861506-21732-1-git-send-email-cywang@chromium.org>

  From the definition of BTN_TOUCH, BTN_TOOL_<name> and BTN_TOUCH codes
are orthogonal. BTN_TOUCH should be zero if there is no physical contact
happened on device. With ABS_MT_DISTANCE information, the patch uses
touch_count and finger_count to get the final reporting code for
BTN_TOUCH and BTN_TOOL_<name>, respectively.

Signed-off-by: Chung-yih Wang <cywang@chromium.org>
---
 drivers/input/input-mt.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c
index fbe29fc..a2ab8e3 100644
--- a/drivers/input/input-mt.c
+++ b/drivers/input/input-mt.c
@@ -192,18 +192,21 @@ void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count)
 {
 	struct input_mt *mt = dev->mt;
 	struct input_mt_slot *oldest;
-	int oldid, count, i;
+	int oldid, i;
+	int touch_count, finger_count;
 
 	if (!mt)
 		return;
 
 	oldest = NULL;
 	oldid = mt->trkid;
-	count = 0;
+	touch_count = 0;
+	finger_count = 0;
 
 	for (i = 0; i < mt->num_slots; ++i) {
 		struct input_mt_slot *ps = &mt->slots[i];
 		int id = input_mt_get_value(ps, ABS_MT_TRACKING_ID);
+		int distance = input_mt_get_value(ps, ABS_MT_DISTANCE);
 
 		if (id < 0)
 			continue;
@@ -211,12 +214,14 @@ void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count)
 			oldest = ps;
 			oldid = id;
 		}
-		count++;
+		finger_count++;
+		if (distance == 0)
+			touch_count++;
 	}
 
-	input_event(dev, EV_KEY, BTN_TOUCH, count > 0);
+	input_event(dev, EV_KEY, BTN_TOUCH, touch_count > 0);
 	if (use_count)
-		input_mt_report_finger_count(dev, count);
+		input_mt_report_finger_count(dev, finger_count);
 
 	if (oldest) {
 		int x = input_mt_get_value(oldest, ABS_MT_POSITION_X);
-- 
2.1.2


  parent reply	other threads:[~2014-10-27 10:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-09 13:31 [PATCH] input: fix BTN_TOUCH reporting in input_mt_report_pointer_emulation for hovering finger Chung-yih Wang
2014-10-15 11:02 ` Chung-Yih Wang (王崇懿)
2014-10-15 18:05   ` Dmitry Torokhov
2014-10-27 10:08 ` Chung-yih Wang [this message]
2014-10-28 20:47   ` [PATCH v2] input: fix BTN_TOUCH reporting in input_mt_report_pointer_emulation Benjamin Tissoires
2014-10-28 21:07     ` Dmitry Torokhov
2014-10-29  0:14       ` Peter Hutterer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1414404527-17526-1-git-send-email-cywang@chromium.org \
    --to=cywang@chromium.org \
    --cc=benjamin.tissoires@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rydberg@euromail.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).