All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] HID: wacom: generic: sync pad events only for actual packets
@ 2017-04-04  0:57 Ping Cheng
  2017-04-04  8:15 ` Benjamin Tissoires
  0 siblings, 1 reply; 2+ messages in thread
From: Ping Cheng @ 2017-04-04  0:57 UTC (permalink / raw)
  To: linux-input; +Cc: jkosina, benjamin.tissoires, skomra, killertofu, Ping Cheng

Commits d793ff8 and 4082da8 introduced two pad usages which do not
actually send pad input events. To make sure we do not post empty
pad packets, pad_input_event_flag is introduced. Turn on the flag
for real pad input events so we can synchronize them properly.

Signed-off-by: Ping Cheng <ping.cheng@wacom.com>
---
Jiri: this patch is based on your for-4.12/wacom branch
---
 drivers/hid/wacom_wac.c | 6 +++++-
 drivers/hid/wacom_wac.h | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index f136038..ffef32a 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -1881,6 +1881,7 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field
 		 /* fall through*/
 	default:
 		input_event(input, usage->type, usage->code, value);
+		if (value) features->pad_input_event_flag = true;
 		break;
 	}
 }
@@ -1919,11 +1920,14 @@ static void wacom_wac_pad_report(struct hid_device *hdev,
 	struct wacom_wac *wacom_wac = &wacom->wacom_wac;
 	struct input_dev *input = wacom_wac->pad_input;
 	bool active = wacom_wac->hid_data.inrange_state != 0;
+	struct wacom_features *features = &wacom_wac->features;
 
 	/* report prox for expresskey events */
-	if (wacom_equivalent_usage(report->field[0]->physical) == HID_DG_TABLETFUNCTIONKEY) {
+	if ((wacom_equivalent_usage(report->field[0]->physical) == HID_DG_TABLETFUNCTIONKEY) &&
+	    features->pad_input_event_flag) {
 		input_event(input, EV_ABS, ABS_MISC, active ? PAD_DEVICE_ID : 0);
 		input_sync(input);
+		if (!active) features->pad_input_event_flag = false;
 	}
 
 }
diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h
index 839bd4b..ff09609 100644
--- a/drivers/hid/wacom_wac.h
+++ b/drivers/hid/wacom_wac.h
@@ -263,6 +263,7 @@ struct wacom_features {
 	int pktlen;
 	bool check_for_hid_type;
 	int hid_type;
+	bool pad_input_event_flag;
 };
 
 struct wacom_shared {
-- 
2.7.4


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

* Re: [PATCH] HID: wacom: generic: sync pad events only for actual packets
  2017-04-04  0:57 [PATCH] HID: wacom: generic: sync pad events only for actual packets Ping Cheng
@ 2017-04-04  8:15 ` Benjamin Tissoires
  0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Tissoires @ 2017-04-04  8:15 UTC (permalink / raw)
  To: Ping Cheng
  Cc: linux-input, Jiri Kosina, Aaron Skomra, Jason Gerecke, Ping Cheng

Hi Ping,

On Tue, Apr 4, 2017 at 2:57 AM, Ping Cheng <pinglinux@gmail.com> wrote:
> Commits d793ff8 and 4082da8 introduced two pad usages which do not
> actually send pad input events. To make sure we do not post empty
> pad packets, pad_input_event_flag is introduced. Turn on the flag
> for real pad input events so we can synchronize them properly.
>
> Signed-off-by: Ping Cheng <ping.cheng@wacom.com>
> ---
> Jiri: this patch is based on your for-4.12/wacom branch
> ---
>  drivers/hid/wacom_wac.c | 6 +++++-
>  drivers/hid/wacom_wac.h | 1 +
>  2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
> index f136038..ffef32a 100644
> --- a/drivers/hid/wacom_wac.c
> +++ b/drivers/hid/wacom_wac.c
> @@ -1881,6 +1881,7 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field
>                  /* fall through*/
>         default:
>                 input_event(input, usage->type, usage->code, value);
> +               if (value) features->pad_input_event_flag = true;

Please have a line break after the if(value) statement

>                 break;
>         }
>  }
> @@ -1919,11 +1920,14 @@ static void wacom_wac_pad_report(struct hid_device *hdev,
>         struct wacom_wac *wacom_wac = &wacom->wacom_wac;
>         struct input_dev *input = wacom_wac->pad_input;
>         bool active = wacom_wac->hid_data.inrange_state != 0;
> +       struct wacom_features *features = &wacom_wac->features;
>
>         /* report prox for expresskey events */
> -       if (wacom_equivalent_usage(report->field[0]->physical) == HID_DG_TABLETFUNCTIONKEY) {
> +       if ((wacom_equivalent_usage(report->field[0]->physical) == HID_DG_TABLETFUNCTIONKEY) &&
> +           features->pad_input_event_flag) {
>                 input_event(input, EV_ABS, ABS_MISC, active ? PAD_DEVICE_ID : 0);
>                 input_sync(input);
> +               if (!active) features->pad_input_event_flag = false;

Same here, please add a line break.

>         }
>
>  }
> diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h
> index 839bd4b..ff09609 100644
> --- a/drivers/hid/wacom_wac.h
> +++ b/drivers/hid/wacom_wac.h
> @@ -263,6 +263,7 @@ struct wacom_features {
>         int pktlen;
>         bool check_for_hid_type;
>         int hid_type;
> +       bool pad_input_event_flag;

I'd say this should go into struct hid_data. wacom_features is very
static now and describes the device itself. hid_data contains actual
data coming in from the device.

Cheers,
Benjamin

>  };
>
>  struct wacom_shared {
> --
> 2.7.4
>

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

end of thread, other threads:[~2017-04-04  8:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-04  0:57 [PATCH] HID: wacom: generic: sync pad events only for actual packets Ping Cheng
2017-04-04  8:15 ` Benjamin Tissoires

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.