diff options
author | Jason Gerecke <jason.gerecke@wacom.com> | 2022-01-26 15:39:43 -0800 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2022-02-22 10:41:51 +1000 |
commit | 3287bf8dd89f7d57dcbab61090f92880e01e2e77 (patch) | |
tree | 24ab1bc90668b11201ba2759f2f3028dd3254255 /src | |
parent | 23f2c7fcf77dc7f4a42864bc66ef91162137577a (diff) | |
download | xf86-input-wacom-3287bf8dd89f7d57dcbab61090f92880e01e2e77.tar.gz |
Store serial numbers as unsigned values
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/WacomInterface.h | 2 | ||||
-rw-r--r-- | src/gwacom/wacom-device.c | 4 | ||||
-rw-r--r-- | src/wcmUSB.c | 16 | ||||
-rw-r--r-- | src/wcmValidateDevice.c | 2 | ||||
-rw-r--r-- | src/x11/xf86Wacom.c | 2 | ||||
-rw-r--r-- | src/xf86WacomDefs.h | 2 |
6 files changed, 15 insertions, 13 deletions
diff --git a/src/WacomInterface.h b/src/WacomInterface.h index 632c839..dc3656f 100644 --- a/src/WacomInterface.h +++ b/src/WacomInterface.h @@ -276,7 +276,7 @@ void wcmNotifyEvdev(WacomDevicePtr priv, const struct input_event *event); * frontend is idle later. */ void wcmQueueHotplug(WacomDevicePtr priv, const char *name, - const char *type, int serial); + const char *type, unsigned int serial); /* X server interface emulations */ diff --git a/src/gwacom/wacom-device.c b/src/gwacom/wacom-device.c index 29315a5..29fb9ae 100644 --- a/src/gwacom/wacom-device.c +++ b/src/gwacom/wacom-device.c @@ -709,7 +709,7 @@ static gboolean hotplugDevice(gpointer data) return FALSE; } -void wcmQueueHotplug(WacomDevicePtr priv, const char* name, const char *type, int serial) +void wcmQueueHotplug(WacomDevicePtr priv, const char* name, const char *type, unsigned int serial) { WacomDevice *device = priv->frontend; struct hotplug *hotplug = g_new0(struct hotplug, 1); @@ -717,7 +717,7 @@ void wcmQueueHotplug(WacomDevicePtr priv, const char* name, const char *type, in char buf[64] = {0}; wacom_options_set(new_opts, "Type", type); - if (serial > -1) { + if (serial != UINT_MAX) { snprintf(buf, sizeof(buf), "0x%x", serial); wacom_options_set(new_opts, "Serial", buf); } diff --git a/src/wcmUSB.c b/src/wcmUSB.c index b9084d9..4b17dcb 100644 --- a/src/wcmUSB.c +++ b/src/wcmUSB.c @@ -33,7 +33,7 @@ #define MAX_USB_EVENTS 128 typedef struct { - int wcmLastToolSerial; + unsigned int wcmLastToolSerial; int wcmDeviceType; Bool wcmPenTouch; Bool wcmUseMT; @@ -856,10 +856,10 @@ static int usbParse(WacomDevicePtr priv, const unsigned char* data, unsigned lon * @param[in] serial Serial number of device * @return Serial number of device as through from Protocol 5 */ -static int protocol5Serial(int device_type, unsigned int serial) { +static unsigned int protocol5Serial(int device_type, unsigned int serial) { if (!serial) { /* Generic Protocol does not send serial numbers */ - return device_type == PAD_ID ? -1 : 1; + return device_type == PAD_ID ? DEFAULT_TOOL_SERIAL : 1; } else if (serial == 0xf0) { /* Protocol 4 uses the expected anonymous serial @@ -868,7 +868,7 @@ static int protocol5Serial(int device_type, unsigned int serial) { * for a Protocol 5 serial number, but isn't a * problem as yet. */ - return -1; + return DEFAULT_TOOL_SERIAL; } else { /* Protocol 5 FTW */ @@ -894,7 +894,7 @@ static int usbChooseChannel(WacomCommonPtr common, int device_type, unsigned int int i, channel = -1; /* force events from PAD device to PAD_CHANNEL */ - if (serial == -1) + if (serial == DEFAULT_TOOL_SERIAL) channel = PAD_CHANNEL; /* find existing channel */ @@ -942,7 +942,7 @@ static int usbChooseChannel(WacomCommonPtr common, int device_type, unsigned int continue; if (common->wcmChannel[i].work.proximity && - (common->wcmChannel[i].work.serial_num != -1)) + (common->wcmChannel[i].work.serial_num != DEFAULT_TOOL_SERIAL)) { common->wcmChannel[i].work.proximity = 0; /* dispatch event */ @@ -1048,7 +1048,7 @@ static void usbParseSynEvent(WacomDevicePtr priv, /* ignore events without information */ if ((private->wcmEventCnt < 2) && private->wcmLastToolSerial) { - DBG(3, common, "%s: dropping empty event for serial %d\n", + DBG(3, common, "%s: dropping empty event for serial %u\n", priv->name, private->wcmLastToolSerial); goto skipEvent; } @@ -1382,7 +1382,7 @@ static void usbParseAbsMTEvent(WacomCommonPtr common, struct input_event *event) { case ABS_MT_SLOT: if (event->value >= 0) { - int serial = event->value + 1; + unsigned int serial = event->value + 1; private->wcmMTChannel = usbChooseChannel(common, TOUCH_ID, serial); if (private->wcmMTChannel < 0) return; diff --git a/src/wcmValidateDevice.c b/src/wcmValidateDevice.c index a1a925b..d5a7b2b 100644 --- a/src/wcmValidateDevice.c +++ b/src/wcmValidateDevice.c @@ -446,7 +446,7 @@ wcmAddHotpluggedDevice(WacomDevicePtr priv, const char *basename, const char *ty if (rc == -1) return; - wcmQueueHotplug(priv, name, type, ser ? ser->serial : -1); + wcmQueueHotplug(priv, name, type, ser ? ser->serial : UINT_MAX); free(name); } diff --git a/src/x11/xf86Wacom.c b/src/x11/xf86Wacom.c index 039c5da..36d3c4a 100644 --- a/src/x11/xf86Wacom.c +++ b/src/x11/xf86Wacom.c @@ -342,7 +342,7 @@ wcmHotplugDevice(ClientPtr client, pointer closure ) * @param type Type name for this tool * @param serial Serial number this device should be bound to (-1 for "any") */ -void wcmQueueHotplug(WacomDevicePtr priv, const char* name, const char *type, int serial) +void wcmQueueHotplug(WacomDevicePtr priv, const char* name, const char *type, unsigned int serial) { WacomHotplugInfo *hotplug_info; diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h index bde3ab3..886bf77 100644 --- a/src/xf86WacomDefs.h +++ b/src/xf86WacomDefs.h @@ -60,6 +60,8 @@ #define PROXOUT_INTUOS_DISTANCE 10 #define PROXOUT_GRAPHIRE_DISTANCE 42 +#define DEFAULT_TOOL_SERIAL UINT_MAX + /* 4.15 */ #ifndef BTN_STYLUS3 |