linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] input: fix BTN_TOUCH reporting in input_mt_report_pointer_emulation for hovering finger
@ 2014-10-09 13:31 Chung-yih Wang
  2014-10-15 11:02 ` Chung-Yih Wang (王崇懿)
  2014-10-27 10:08 ` [PATCH v2] input: fix BTN_TOUCH reporting in input_mt_report_pointer_emulation Chung-yih Wang
  0 siblings, 2 replies; 7+ messages in thread
From: Chung-yih Wang @ 2014-10-09 13:31 UTC (permalink / raw)
  To: linux-input
  Cc: Henrik Rydberg, Dmitry Torokhov, benjamin.tissoires,
	Chung-yih Wang

  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, e.g.
hovering finger, happened on device. The patch uses touch_count and finger_count
to get the final reporting code for BTN_TOUCH and BTN_TOOL_<name>,
respectively. In addition, as there are some hard-coded pressure thresholds
defined in touch device's driver classes, 'touch_threshold' is introduced into
struct input_dev in order to tell if a finger is considered as a touch one in
input_mt_report_pointer_emulation().

---
 drivers/input/input-mt.c | 15 ++++++++++-----
 include/linux/input.h    |  2 ++
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c
index fbe29fc..47e41d6 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 pressure = input_mt_get_value(ps, ABS_MT_PRESSURE);
 
 		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 (pressure > dev->touch_threshold)
+			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);
diff --git a/include/linux/input.h b/include/linux/input.h
index 82ce323..5b2739d 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -187,6 +187,8 @@ struct input_dev {
 	struct input_value *vals;
 
 	bool devres_managed;
+
+	unsigned int touch_threshold;
 };
 #define to_input_dev(d) container_of(d, struct input_dev, dev)
 
-- 
2.0.0.526.g5318336


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] input: fix BTN_TOUCH reporting in input_mt_report_pointer_emulation for hovering finger
  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 ` [PATCH v2] input: fix BTN_TOUCH reporting in input_mt_report_pointer_emulation Chung-yih Wang
  1 sibling, 1 reply; 7+ messages in thread
From: Chung-Yih Wang (王崇懿) @ 2014-10-15 11:02 UTC (permalink / raw)
  To: Linux Input
  Cc: Henrik Rydberg, Dmitry Torokhov, Benjamin Tissoires,
	Chung-yih Wang

any comment for this patch?

On Thu, Oct 9, 2014 at 9:31 PM, Chung-yih Wang <cywang@chromium.org> wrote:
>   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, e.g.
> hovering finger, happened on device. The patch uses touch_count and finger_count
> to get the final reporting code for BTN_TOUCH and BTN_TOOL_<name>,
> respectively. In addition, as there are some hard-coded pressure thresholds
> defined in touch device's driver classes, 'touch_threshold' is introduced into
> struct input_dev in order to tell if a finger is considered as a touch one in
> input_mt_report_pointer_emulation().
>
> ---
>  drivers/input/input-mt.c | 15 ++++++++++-----
>  include/linux/input.h    |  2 ++
>  2 files changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c
> index fbe29fc..47e41d6 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 pressure = input_mt_get_value(ps, ABS_MT_PRESSURE);
>
>                 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 (pressure > dev->touch_threshold)
> +                       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);
> diff --git a/include/linux/input.h b/include/linux/input.h
> index 82ce323..5b2739d 100644
> --- a/include/linux/input.h
> +++ b/include/linux/input.h
> @@ -187,6 +187,8 @@ struct input_dev {
>         struct input_value *vals;
>
>         bool devres_managed;
> +
> +       unsigned int touch_threshold;
>  };
>  #define to_input_dev(d) container_of(d, struct input_dev, dev)
>
> --
> 2.0.0.526.g5318336
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] input: fix BTN_TOUCH reporting in input_mt_report_pointer_emulation for hovering finger
  2014-10-15 11:02 ` Chung-Yih Wang (王崇懿)
@ 2014-10-15 18:05   ` Dmitry Torokhov
  0 siblings, 0 replies; 7+ messages in thread
From: Dmitry Torokhov @ 2014-10-15 18:05 UTC (permalink / raw)
  To: Chung-Yih Wang (王崇懿)
  Cc: Linux Input, Henrik Rydberg, Benjamin Tissoires

Hi Chung-Yih,

On Wed, Oct 15, 2014 at 07:02:31PM +0800, Chung-Yih Wang (王崇懿) wrote:
> any comment for this patch?
> 
> On Thu, Oct 9, 2014 at 9:31 PM, Chung-yih Wang <cywang@chromium.org> wrote:
> >   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, e.g.
> > hovering finger, happened on device. The patch uses touch_count and finger_count
> > to get the final reporting code for BTN_TOUCH and BTN_TOOL_<name>,
> > respectively. In addition, as there are some hard-coded pressure thresholds
> > defined in touch device's driver classes, 'touch_threshold' is introduced into
> > struct input_dev in order to tell if a finger is considered as a touch one in
> > input_mt_report_pointer_emulation().
> >
> > ---
> >  drivers/input/input-mt.c | 15 ++++++++++-----
> >  include/linux/input.h    |  2 ++
> >  2 files changed, 12 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c
> > index fbe29fc..47e41d6 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 pressure = input_mt_get_value(ps, ABS_MT_PRESSURE);
> >
> >                 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 (pressure > dev->touch_threshold)
> > +                       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);
> > diff --git a/include/linux/input.h b/include/linux/input.h
> > index 82ce323..5b2739d 100644
> > --- a/include/linux/input.h
> > +++ b/include/linux/input.h
> > @@ -187,6 +187,8 @@ struct input_dev {
> >         struct input_value *vals;
> >
> >         bool devres_managed;
> > +
> > +       unsigned int touch_threshold;

I'd rather not use the pressure threshold, but gate it on distance,
since touch threshold would be user preference. This way we are not
changing existing behavior where registered touches are reported in the
finger count, only true hovering contacts will be excluded.

Henrik, Benjamin?

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] input: fix BTN_TOUCH reporting in input_mt_report_pointer_emulation
  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-27 10:08 ` Chung-yih Wang
  2014-10-28 20:47   ` Benjamin Tissoires
  1 sibling, 1 reply; 7+ messages in thread
From: Chung-yih Wang @ 2014-10-27 10:08 UTC (permalink / raw)
  To: linux-input
  Cc: linux-kernel, Henrik Rydberg, Dmitry Torokhov, benjamin.tissoires,
	Chung-yih Wang

  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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] input: fix BTN_TOUCH reporting in input_mt_report_pointer_emulation
  2014-10-27 10:08 ` [PATCH v2] input: fix BTN_TOUCH reporting in input_mt_report_pointer_emulation Chung-yih Wang
@ 2014-10-28 20:47   ` Benjamin Tissoires
  2014-10-28 21:07     ` Dmitry Torokhov
  0 siblings, 1 reply; 7+ messages in thread
From: Benjamin Tissoires @ 2014-10-28 20:47 UTC (permalink / raw)
  To: Chung-yih Wang
  Cc: linux-input, linux-kernel@vger.kernel.org, Henrik Rydberg,
	Dmitry Torokhov, Peter Hutterer, Hans de Goede

Hi Chung-yih,

On Mon, Oct 27, 2014 at 6:08 AM, Chung-yih Wang <cywang@chromium.org> wrote:
>   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);

I don't really like this statement, even if it works. Some devices do
not report ABS_MT_DISTANCE, and the value for them should not be
considered as '0' but 'undefined'.

>
>                 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)

I'd rather test here if ABS_MT_DISTANCE is used, and then if the value is 0.

> +                       touch_count++;
>         }
>
> -       input_event(dev, EV_KEY, BTN_TOUCH, count > 0);
> +       input_event(dev, EV_KEY, BTN_TOUCH, touch_count > 0);

For the record, I *think* this will not break user space. This is used
in the touchpad part of libinput, and does not seemed to be impacted
by the change.
Adding Peter and Hans in CC who can tell us if I am assuming right.

Cheers,
Benjamin

>         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
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] input: fix BTN_TOUCH reporting in input_mt_report_pointer_emulation
  2014-10-28 20:47   ` Benjamin Tissoires
@ 2014-10-28 21:07     ` Dmitry Torokhov
  2014-10-29  0:14       ` Peter Hutterer
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Torokhov @ 2014-10-28 21:07 UTC (permalink / raw)
  To: Benjamin Tissoires
  Cc: Chung-yih Wang, linux-input, linux-kernel@vger.kernel.org,
	Henrik Rydberg, Peter Hutterer, Hans de Goede

On Tue, Oct 28, 2014 at 04:47:56PM -0400, Benjamin Tissoires wrote:
> Hi Chung-yih,
> 
> On Mon, Oct 27, 2014 at 6:08 AM, Chung-yih Wang <cywang@chromium.org> wrote:
> >   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);
> 
> I don't really like this statement, even if it works. Some devices do
> not report ABS_MT_DISTANCE, and the value for them should not be
> considered as '0' but 'undefined'.

I think it incidentally still 0 as we zero out memory we allocate.

> 
> >
> >                 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)
> 
> I'd rather test here if ABS_MT_DISTANCE is used, and then if the value is 0.
> 
> > +                       touch_count++;

I do not think we should include hovering contacts into finger_count
either. I.e if I have one finger touching and one finger hovering we
should be emitting BTN_TOOL_FINGER and not BTN_TOOL_DOUBLETAP.

> >         }
> >
> > -       input_event(dev, EV_KEY, BTN_TOUCH, count > 0);
> > +       input_event(dev, EV_KEY, BTN_TOUCH, touch_count > 0);
> 
> For the record, I *think* this will not break user space. This is used
> in the touchpad part of libinput, and does not seemed to be impacted
> by the change.
> Adding Peter and Hans in CC who can tell us if I am assuming right.
> 
> Cheers,
> Benjamin
> 
> >         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
> >

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] input: fix BTN_TOUCH reporting in input_mt_report_pointer_emulation
  2014-10-28 21:07     ` Dmitry Torokhov
@ 2014-10-29  0:14       ` Peter Hutterer
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Hutterer @ 2014-10-29  0:14 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Benjamin Tissoires, Chung-yih Wang, linux-input,
	linux-kernel@vger.kernel.org, Henrik Rydberg, Hans de Goede

On Tue, Oct 28, 2014 at 02:07:06PM -0700, Dmitry Torokhov wrote:
> On Tue, Oct 28, 2014 at 04:47:56PM -0400, Benjamin Tissoires wrote:
> > Hi Chung-yih,
> > 
> > On Mon, Oct 27, 2014 at 6:08 AM, Chung-yih Wang <cywang@chromium.org> wrote:
> > >   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);
> > 
> > I don't really like this statement, even if it works. Some devices do
> > not report ABS_MT_DISTANCE, and the value for them should not be
> > considered as '0' but 'undefined'.
> 
> I think it incidentally still 0 as we zero out memory we allocate.
> 
> > 
> > >
> > >                 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)
> > 
> > I'd rather test here if ABS_MT_DISTANCE is used, and then if the value is 0.

shouldn't you test for absinfo->minimum anyway? or does the kernel guarantee
that 0 is the minimum for distance?

> > 
> > > +                       touch_count++;
> 
> I do not think we should include hovering contacts into finger_count
> either. I.e if I have one finger touching and one finger hovering we
> should be emitting BTN_TOOL_FINGER and not BTN_TOOL_DOUBLETAP.

yes, please. DOUBLETAP for hovering would trigger things like two-finger
scrolling in some clients, not ideal.

> > >         }
> > >
> > > -       input_event(dev, EV_KEY, BTN_TOUCH, count > 0);
> > > +       input_event(dev, EV_KEY, BTN_TOUCH, touch_count > 0);
> > 
> > For the record, I *think* this will not break user space. This is used
> > in the touchpad part of libinput, and does not seemed to be impacted
> > by the change.
> > Adding Peter and Hans in CC who can tell us if I am assuming right.

should be fine, we've treated BTN_TOUCH as signal that at least one touch is
down. in the wacom driver we use it for proximity info, the rest just never
had to worry about proximity, so it's most likely just unhandled.
 
Cheers,
   Peter

> > 
> > >         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
> > >
> 
> Thanks.
> 
> -- 
> Dmitry

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-10-29  0:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH v2] input: fix BTN_TOUCH reporting in input_mt_report_pointer_emulation Chung-yih Wang
2014-10-28 20:47   ` Benjamin Tissoires
2014-10-28 21:07     ` Dmitry Torokhov
2014-10-29  0:14       ` Peter Hutterer

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).