diff options
author | Jason Gerecke <jason.gerecke@wacom.com> | 2022-01-04 11:24:16 -0800 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2022-02-22 10:41:51 +1000 |
commit | ca19d531ab888e9ff80d5beb26af366061a2edd5 (patch) | |
tree | 72ed945657e6c8e443bd14e071f71980278952cb /src | |
parent | 0962f67b2c7660fdbdf80a189b90b0e37e61314d (diff) | |
download | xf86-input-wacom-ca19d531ab888e9ff80d5beb26af366061a2edd5.tar.gz |
Store button state as unsigned int
The WacomDeviceState structure uses an unsigned int to store keys and
some functions that operate on keys and buttons are already set up to
work with unsigned values. Make buttons unsigned for consistency with
keys and to reduce warnings.
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/wcmCommon.c | 10 | ||||
-rw-r--r-- | src/wcmUSB.c | 12 | ||||
-rw-r--r-- | src/xf86WacomDefs.h | 2 |
3 files changed, 12 insertions, 12 deletions
diff --git a/src/wcmCommon.c b/src/wcmCommon.c index 6e3ee2b..e26e754 100644 --- a/src/wcmCommon.c +++ b/src/wcmCommon.c @@ -245,12 +245,12 @@ int wcmReadPacket(WacomDevicePtr priv) * previous one. ****************************************************************************/ -static void wcmSendButtons(WacomDevicePtr priv, const WacomDeviceState* ds, int buttons, +static void wcmSendButtons(WacomDevicePtr priv, const WacomDeviceState* ds, unsigned int buttons, const WacomAxisData *axes) { unsigned int button, mask, first_button; WacomCommonPtr common = priv->common; - DBG(6, priv, "buttons=%d\n", buttons); + DBG(6, priv, "buttons=%u\n", buttons); /* button behaviour (TPC button on): if only tip is pressed/released, send button 1 events @@ -607,7 +607,7 @@ static void sendWheelStripEvents(WacomDevicePtr priv, const WacomDeviceState* ds static void sendCommonEvents(WacomDevicePtr priv, const WacomDeviceState* ds, const WacomAxisData *axes) { - int buttons = ds->buttons; + unsigned int buttons = ds->buttons; int x = 0, y = 0; wcmAxisGet(axes, WACOM_AXIS_X, &x); @@ -905,7 +905,7 @@ void wcmSendEvents(WacomDevicePtr priv, const WacomDeviceState* ds) wcmAxisDump(&axes, dump, sizeof(dump)); DBG(6, priv, "%s o_prox=%d\tprox=%d\t%s\tid=%d" - "\tserial=%u\tbutton=%s\tbuttons=%d\n", + "\tserial=%u\tbutton=%s\tbuttons=%u\n", is_absolute(priv) ? "abs" : "rel", priv->oldState.proximity, ds->proximity, dump, id, serial, is_button ? "true" : "false", ds->buttons); @@ -1130,7 +1130,7 @@ void wcmEvent(WacomCommonPtr common, unsigned int channel, ds = *pState; DBG(10, common, - "c=%u i=%d t=%d s=0x%x x=%d y=%d b=%d " + "c=%u i=%d t=%d s=0x%x x=%d y=%d b=%u " "p=%d rz=%d tx=%d ty=%d aw=%d aw2=%d rw=%d " "t=%d px=%d st=%d cs=%d \n", channel, diff --git a/src/wcmUSB.c b/src/wcmUSB.c index fbe47ae..d9ff852 100644 --- a/src/wcmUSB.c +++ b/src/wcmUSB.c @@ -1347,15 +1347,15 @@ static void usbParseAbsEvent(WacomCommonPtr common, * * @return The new button mask */ -static int -mod_buttons(WacomCommonPtr common, int buttons, int btn, int state) +static unsigned int +mod_buttons(WacomCommonPtr common, unsigned int buttons, unsigned int btn, Bool state) { - int mask; + unsigned int mask; if (btn >= sizeof(int) * 8) { wcmLogCommonSafe(common, W_ERROR, - "%s: Invalid button number %d. Insufficient storage\n", + "%s: Invalid button number %u. Insufficient storage\n", __func__, btn); return buttons; } @@ -2073,8 +2073,8 @@ TEST_CASE(test_mod_buttons) WacomCommonRec common = {0}; for (size_t i = 0; i < sizeof(int) * 8; i++) { - int buttons = mod_buttons(&common, 0, i, 1); - assert(buttons == (1 << i)); + unsigned int buttons = mod_buttons(&common, 0, i, 1); + assert(buttons == (1u << i)); buttons = mod_buttons(&common, 0, i, 0); assert(buttons == 0); } diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h index 604c9a1..f73edf9 100644 --- a/src/xf86WacomDefs.h +++ b/src/xf86WacomDefs.h @@ -190,7 +190,7 @@ struct _WacomDeviceState unsigned int serial_num; int x; int y; - int buttons; + unsigned int buttons; int pressure; int tiltx; int tilty; |