When updating the value of oldState, it is sufficient to simply
use an assignment statement for the entire struct rather than
explicitly setting each field. A static const "out of prox"
state is created to define the default out-of-prox values.

Signed-off-by: Jason Gerecke <killert...@gmail.com>
---
 src/wcmCommon.c     | 24 ++----------------------
 src/xf86WacomDefs.h |  5 +++++
 2 files changed, 7 insertions(+), 22 deletions(-)

diff --git a/src/wcmCommon.c b/src/wcmCommon.c
index f9650f9..65b0fe4 100644
--- a/src/wcmCommon.c
+++ b/src/wcmCommon.c
@@ -489,18 +489,9 @@ static void wcmUpdateOldState(const InputInfoPtr pInfo,
 {
        const WacomDevicePtr priv = (WacomDevicePtr) pInfo->private;
 
-       priv->oldState.abswheel = ds->abswheel;
-       priv->oldState.abswheel2 = ds->abswheel2;
-       priv->oldState.buttons = ds->buttons;
+       priv->oldState = *ds;
        priv->oldState.x = currentX;
        priv->oldState.y = currentY;
-       priv->oldState.pressure = ds->pressure;
-       priv->oldState.tiltx = ds->tilty;
-       priv->oldState.tilty = ds->tiltx;
-       priv->oldState.stripx = ds->stripx;
-       priv->oldState.stripy = ds->stripy;
-       priv->oldState.rotation = ds->rotation;
-       priv->oldState.throttle = ds->throttle;
 }
 
 static void
@@ -722,18 +713,7 @@ void wcmSendEvents(InputInfoPtr pInfo, const 
WacomDeviceState* ds)
                wcmUpdateOldState(pInfo, ds, x, y);
        else
        {
-               priv->oldState.buttons = 0;
-               priv->oldState.abswheel = MAX_PAD_RING + 1;
-               priv->oldState.abswheel2 = MAX_PAD_RING + 1;
-               priv->oldState.x = 0;
-               priv->oldState.y = 0;
-               priv->oldState.pressure = 0;
-               priv->oldState.tiltx = 0;
-               priv->oldState.tilty = 0;
-               priv->oldState.stripx = 0;
-               priv->oldState.stripy = 0;
-               priv->oldState.rotation = 0;
-               priv->oldState.throttle = 0;
+               priv->oldState = OUTPROX_STATE;
                priv->oldState.serial_num = serial;
                priv->oldState.device_id = id;
                wcmUpdateSerial(pInfo, 0, 0);
diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h
index 01ae655..1f6f43a 100644
--- a/src/xf86WacomDefs.h
+++ b/src/xf86WacomDefs.h
@@ -233,6 +233,11 @@ struct _WacomDeviceState
        int sample;     /* wraps every 24 days */
 };
 
+static const struct _WacomDeviceState OUTPROX_STATE = {
+  .abswheel = MAX_PAD_RING + 1,
+  .abswheel2 = MAX_PAD_RING + 1
+};
+
 struct _WacomDeviceRec
 {
        char *name;             /* Do not move, same offset as 
common->device_path. Used by DBG macro */
-- 
1.9.2


------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
&#149; 3 signs your SCM is hindering your productivity
&#149; Requirements for releasing software faster
&#149; Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to