|
|
ccad43 |
From 7523a530494484e8b92e0c8604fb39a51b4887f8 Mon Sep 17 00:00:00 2001
|
|
|
ccad43 |
From: Peter Hutterer <peter.hutterer@who-t.net>
|
|
|
ccad43 |
Date: Wed, 24 Oct 2018 10:15:58 +1000
|
|
|
ccad43 |
Subject: [PATCH 3/4] Split EV_MSC handling out of the EV_SYN handling
|
|
|
ccad43 |
|
|
|
ccad43 |
The only thing these two had in common was the reset of the event count on
|
|
|
ccad43 |
failure. Might as well split them up to make the code more readable.
|
|
|
ccad43 |
|
|
|
ccad43 |
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
|
|
|
ccad43 |
Reviewed-by: Ping Cheng <ping.cheng@wacom.com>
|
|
|
ccad43 |
(cherry picked from commit 8a6f201fde45b6aef9785bdfbfd0d908ff1c4071)
|
|
|
ccad43 |
---
|
|
|
ccad43 |
src/wcmUSB.c | 68 +++++++++++++++++++++++++++++++---------------------
|
|
|
ccad43 |
1 file changed, 41 insertions(+), 27 deletions(-)
|
|
|
ccad43 |
|
|
|
ccad43 |
diff --git a/src/wcmUSB.c b/src/wcmUSB.c
|
|
|
ccad43 |
index be9be6e..cf89ff8 100644
|
|
|
ccad43 |
--- a/src/wcmUSB.c
|
|
|
ccad43 |
+++ b/src/wcmUSB.c
|
|
|
ccad43 |
@@ -59,6 +59,8 @@ static void usbParseEvent(InputInfoPtr pInfo,
|
|
|
ccad43 |
const struct input_event* event);
|
|
|
ccad43 |
static void usbParseSynEvent(InputInfoPtr pInfo,
|
|
|
ccad43 |
const struct input_event *event);
|
|
|
ccad43 |
+static void usbParseMscEvent(InputInfoPtr pInfo,
|
|
|
ccad43 |
+ const struct input_event *event);
|
|
|
ccad43 |
static void usbDispatchEvents(InputInfoPtr pInfo);
|
|
|
ccad43 |
static int usbChooseChannel(WacomCommonPtr common, int device_type, unsigned int serial);
|
|
|
ccad43 |
|
|
|
ccad43 |
@@ -994,8 +996,44 @@ static void usbParseEvent(InputInfoPtr pInfo,
|
|
|
ccad43 |
/* save it for later */
|
|
|
ccad43 |
private->wcmEvents[private->wcmEventCnt++] = *event;
|
|
|
ccad43 |
|
|
|
ccad43 |
- if (event->type == EV_MSC || event->type == EV_SYN)
|
|
|
ccad43 |
- usbParseSynEvent(pInfo, event);
|
|
|
ccad43 |
+ switch (event->type)
|
|
|
ccad43 |
+ {
|
|
|
ccad43 |
+ case EV_MSC:
|
|
|
ccad43 |
+ usbParseMscEvent(pInfo, event);
|
|
|
ccad43 |
+ break;
|
|
|
ccad43 |
+ case EV_SYN:
|
|
|
ccad43 |
+ usbParseSynEvent(pInfo, event);
|
|
|
ccad43 |
+ break;
|
|
|
ccad43 |
+ default:
|
|
|
ccad43 |
+ break;
|
|
|
ccad43 |
+ }
|
|
|
ccad43 |
+}
|
|
|
ccad43 |
+
|
|
|
ccad43 |
+static void usbParseMscEvent(InputInfoPtr pInfo,
|
|
|
ccad43 |
+ const struct input_event *event)
|
|
|
ccad43 |
+{
|
|
|
ccad43 |
+ WacomDevicePtr priv = (WacomDevicePtr)pInfo->private;
|
|
|
ccad43 |
+ WacomCommonPtr common = priv->common;
|
|
|
ccad43 |
+ wcmUSBData* private = common->private;
|
|
|
ccad43 |
+
|
|
|
ccad43 |
+ if (event->code != MSC_SERIAL)
|
|
|
ccad43 |
+ return;
|
|
|
ccad43 |
+
|
|
|
ccad43 |
+ if (event->value != 0)
|
|
|
ccad43 |
+ {
|
|
|
ccad43 |
+ /* save the serial number so we can look up the channel number later */
|
|
|
ccad43 |
+ private->wcmLastToolSerial = event->value;
|
|
|
ccad43 |
+ }
|
|
|
ccad43 |
+ else
|
|
|
ccad43 |
+ {
|
|
|
ccad43 |
+ /* we don't report serial numbers for some tools but we never report
|
|
|
ccad43 |
+ * a serial number with a value of 0 - if that happens drop the
|
|
|
ccad43 |
+ * whole frame */
|
|
|
ccad43 |
+ LogMessageVerbSigSafe(X_ERROR, 0,
|
|
|
ccad43 |
+ "%s: usbParse: Ignoring event from invalid serial 0\n",
|
|
|
ccad43 |
+ pInfo->name);
|
|
|
ccad43 |
+ private->wcmEventCnt = 0;
|
|
|
ccad43 |
+ }
|
|
|
ccad43 |
}
|
|
|
ccad43 |
|
|
|
ccad43 |
/**
|
|
|
ccad43 |
@@ -1011,33 +1049,9 @@ static void usbParseSynEvent(InputInfoPtr pInfo,
|
|
|
ccad43 |
WacomCommonPtr common = priv->common;
|
|
|
ccad43 |
wcmUSBData* private = common->private;
|
|
|
ccad43 |
|
|
|
ccad43 |
- if ((event->type == EV_MSC) && (event->code == MSC_SERIAL))
|
|
|
ccad43 |
- {
|
|
|
ccad43 |
- /* we don't report serial numbers for some tools
|
|
|
ccad43 |
- * but we never report a serial number with a value of 0 */
|
|
|
ccad43 |
- if (event->value == 0)
|
|
|
ccad43 |
- {
|
|
|
ccad43 |
- LogMessageVerbSigSafe(X_ERROR, 0,
|
|
|
ccad43 |
- "%s: usbParse: Ignoring event from invalid serial 0\n",
|
|
|
ccad43 |
- pInfo->name);
|
|
|
ccad43 |
- goto skipEvent;
|
|
|
ccad43 |
- }
|
|
|
ccad43 |
-
|
|
|
ccad43 |
- /* save the serial number so we can look up the channel number later */
|
|
|
ccad43 |
- private->wcmLastToolSerial = event->value;
|
|
|
ccad43 |
-
|
|
|
ccad43 |
+ if (event->code != SYN_REPORT)
|
|
|
ccad43 |
return;
|
|
|
ccad43 |
|
|
|
ccad43 |
- } else if ((event->type == EV_SYN) && (event->code == SYN_REPORT))
|
|
|
ccad43 |
- {
|
|
|
ccad43 |
- /* end of record. fall through to dispatch */
|
|
|
ccad43 |
- }
|
|
|
ccad43 |
- else
|
|
|
ccad43 |
- {
|
|
|
ccad43 |
- /* not a MSC_SERIAL and not a SYN_REPORT, bail out */
|
|
|
ccad43 |
- return;
|
|
|
ccad43 |
- }
|
|
|
ccad43 |
-
|
|
|
ccad43 |
/* ignore events without information */
|
|
|
ccad43 |
if ((private->wcmEventCnt < 2) && private->wcmLastToolSerial)
|
|
|
ccad43 |
{
|
|
|
ccad43 |
--
|
|
|
ccad43 |
2.19.2
|
|
|
ccad43 |
|