Storing the defaults for strips and wheels in individual
variables makes updating and scanning through them very
tedious. This patch replaces the variables with arrays
and introduces new #define statements to keep the level
of semantic meaning we had.

Signed-off-by: Jason Gerecke <killert...@gmail.com>
---
 src/wcmCommon.c         |   22 +++++++++---------
 src/wcmConfig.c         |   24 ++++++++++----------
 src/wcmValidateDevice.c |   10 ++++----
 src/wcmXCommand.c       |   20 ++++++++--------
 src/xf86WacomDefs.h     |   53 ++++++++++++++++++++++++-----------------------
 5 files changed, 65 insertions(+), 64 deletions(-)

diff --git a/src/wcmCommon.c b/src/wcmCommon.c
index d92d280..518ca9f 100644
--- a/src/wcmCommon.c
+++ b/src/wcmCommon.c
@@ -295,7 +295,7 @@ static void sendAButton(InputInfoPtr pInfo, int button, int 
mask,
        {
                /* No button action configured, send button */
                xf86PostButtonEventP(pInfo->dev, is_absolute(pInfo),
-                                    priv->button[button], (mask != 0),
+                                    priv->button_default[button], (mask != 0),
                                     first_val, num_val,
                                     VCOPY(valuators, num_val));
                return;
@@ -425,8 +425,8 @@ static void sendWheelStripEvents(InputInfoPtr pInfo, const 
WacomDeviceState* ds,
        if (delta && IsPad(priv) && priv->oldProximity == ds->proximity)
        {
                DBG(10, priv, "Left touch strip scroll delta = %d\n", delta);
-               fakeButton = getWheelButton(delta, priv->striplup, 
priv->stripldn,
-                                           priv->strip_keys[0], 
priv->strip_keys[1], &fakeKey);
+               fakeButton = getWheelButton(delta, 
priv->strip_default[STRIP_LEFT_UP], priv->strip_default[STRIP_LEFT_DN],
+                                           priv->strip_keys[STRIP_LEFT_UP], 
priv->strip_keys[STRIP_LEFT_DN], &fakeKey);
                sendWheelStripEvent(fakeButton, fakeKey, pInfo, first_val, 
num_vals, valuators);
        }
 
@@ -435,8 +435,8 @@ static void sendWheelStripEvents(InputInfoPtr pInfo, const 
WacomDeviceState* ds,
        if (delta && IsPad(priv) && priv->oldProximity == ds->proximity)
        {
                DBG(10, priv, "Right touch strip scroll delta = %d\n", delta);
-               fakeButton = getWheelButton(delta, priv->striprup, 
priv->striprdn,
-                                           priv->strip_keys[2], 
priv->strip_keys[3], &fakeKey);
+               fakeButton = getWheelButton(delta, 
priv->strip_default[STRIP_RIGHT_UP], priv->strip_default[STRIP_RIGHT_DN],
+                                           priv->strip_keys[STRIP_RIGHT_UP], 
priv->strip_keys[STRIP_RIGHT_DN], &fakeKey);
                sendWheelStripEvent(fakeButton, fakeKey, pInfo, first_val, 
num_vals, valuators);
        }
 
@@ -445,8 +445,8 @@ static void sendWheelStripEvents(InputInfoPtr pInfo, const 
WacomDeviceState* ds,
        if (delta && IsCursor(priv) && priv->oldProximity == ds->proximity)
        {
                DBG(10, priv, "Relative wheel scroll delta = %d\n", delta);
-               fakeButton = getWheelButton(delta, priv->relup, priv->reldn,
-                                           priv->wheel_keys[0], 
priv->wheel_keys[1], &fakeKey);
+               fakeButton = getWheelButton(delta, 
priv->wheel_default[WHEEL_REL_UP], priv->wheel_default[WHEEL_REL_DN],
+                                           priv->wheel_keys[WHEEL_REL_UP], 
priv->wheel_keys[WHEEL_REL_DN], &fakeKey);
                sendWheelStripEvent(fakeButton, fakeKey, pInfo, first_val, 
num_vals, valuators);
        }
 
@@ -455,8 +455,8 @@ static void sendWheelStripEvents(InputInfoPtr pInfo, const 
WacomDeviceState* ds,
        if (delta && IsPad(priv) && priv->oldProximity == ds->proximity)
        {
                DBG(10, priv, "Left touch wheel scroll delta = %d\n", delta);
-               fakeButton = getWheelButton(delta, priv->wheelup, priv->wheeldn,
-                                           priv->wheel_keys[2], 
priv->wheel_keys[3], &fakeKey);
+               fakeButton = getWheelButton(delta, 
priv->wheel_default[WHEEL_ABS_UP], priv->wheel_default[WHEEL_ABS_DN],
+                                           priv->wheel_keys[WHEEL_ABS_UP], 
priv->wheel_keys[WHEEL_ABS_DN], &fakeKey);
                sendWheelStripEvent(fakeButton, fakeKey, pInfo, first_val, 
num_vals, valuators);
        }
 
@@ -465,8 +465,8 @@ static void sendWheelStripEvents(InputInfoPtr pInfo, const 
WacomDeviceState* ds,
        if (delta && IsPad(priv) && priv->oldProximity == ds->proximity)
        {
                DBG(10, priv, "Right touch wheel scroll delta = %d\n", delta);
-               fakeButton = getWheelButton(delta, priv->wheel2up, 
priv->wheel2dn,
-                                           priv->wheel_keys[4], 
priv->wheel_keys[5], &fakeKey);
+               fakeButton = getWheelButton(delta, 
priv->wheel_default[WHEEL2_ABS_UP], priv->wheel_default[WHEEL2_ABS_DN],
+                                           priv->wheel_keys[WHEEL2_ABS_UP], 
priv->wheel_keys[WHEEL2_ABS_DN], &fakeKey);
                sendWheelStripEvent(fakeButton, fakeKey, pInfo, first_val, 
num_vals, valuators);
        }
 }
diff --git a/src/wcmConfig.c b/src/wcmConfig.c
index 5920e11..a17139b 100644
--- a/src/wcmConfig.c
+++ b/src/wcmConfig.c
@@ -71,21 +71,21 @@ static int wcmAllocate(InputInfoPtr pInfo)
        /* Default button and expresskey values, offset buttons 4 and higher
         * by the 4 scroll buttons. */
        for (i=0; i<WCM_MAX_BUTTONS; i++)
-               priv->button[i] = (i < 3) ? i + 1 : i + 5;
+               priv->button_default[i] = (i < 3) ? i + 1 : i + 5;
 
-       priv->nbuttons = WCM_MAX_BUTTONS;               /* Default number of 
buttons */
-       priv->relup = 5;                        /* Default relative wheel up 
event */
-       priv->reldn = 4;                        /* Default relative wheel down 
event */
+       priv->nbuttons = WCM_MAX_BUTTONS;       /* Default number of buttons */
+       priv->wheel_default[WHEEL_REL_UP] = 5;
+       priv->wheel_default[WHEEL_REL_DN] = 4;
        /* wheel events are set to 0, but the pad overwrites this default
         * later in wcmParseOptions, when we have IsPad() available */
-       priv->wheelup = 0;                      /* Default absolute wheel up 
event */
-       priv->wheeldn = 0;                      /* Default absolute wheel down 
event */
-       priv->wheel2up = 0;                     /* Default absolute wheel2 up 
event */
-       priv->wheel2dn = 0;                     /* Default absolute wheel2 down 
event */
-       priv->striplup = 4;                     /* Default left strip up event 
*/
-       priv->stripldn = 5;                     /* Default left strip down 
event */
-       priv->striprup = 4;                     /* Default right strip up event 
*/
-       priv->striprdn = 5;                     /* Default right strip down 
event */
+       priv->wheel_default[WHEEL_ABS_UP] = 0;
+       priv->wheel_default[WHEEL_ABS_DN] = 0;
+       priv->wheel_default[WHEEL2_ABS_UP] = 0;
+       priv->wheel_default[WHEEL2_ABS_DN] = 0;
+       priv->strip_default[STRIP_LEFT_UP] = 4;
+       priv->strip_default[STRIP_LEFT_DN] = 5;
+       priv->strip_default[STRIP_RIGHT_UP] = 4;
+       priv->strip_default[STRIP_RIGHT_DN] = 5;
        priv->naxes = 6;                        /* Default number of axes */
 
        /* JEJ - throttle sampling code */
diff --git a/src/wcmValidateDevice.c b/src/wcmValidateDevice.c
index 862e005..8c8871b 100644
--- a/src/wcmValidateDevice.c
+++ b/src/wcmValidateDevice.c
@@ -729,8 +729,8 @@ Bool wcmPreInitParseOptions(InputInfoPtr pInfo, Bool 
is_primary,
         */
        if (IsPad(priv))
        {
-               priv->wheelup = priv->wheel2up = 4;
-               priv->wheeldn = priv->wheel2dn = 5;
+               priv->wheel_default[WHEEL_ABS_UP] = 
priv->wheel_default[WHEEL2_ABS_UP] = 4;
+               priv->wheel_default[WHEEL_ABS_DN] = 
priv->wheel_default[WHEEL2_ABS_DN] = 5;
                set_absolute(pInfo, TRUE);
        }
 
@@ -910,14 +910,14 @@ Bool wcmPreInitParseOptions(InputInfoPtr pInfo, Bool 
is_primary,
        /* Swap stylus buttons 2 and 3 for Tablet PCs */
        if (TabletHasFeature(common, WCM_TPC) && IsStylus(priv))
        {
-               priv->button[1] = 3;
-               priv->button[2] = 2;
+               priv->button_default[1] = 3;
+               priv->button_default[2] = 2;
        }
 
        for (i=0; i<WCM_MAX_BUTTONS; i++)
        {
                sprintf(b, "Button%d", i+1);
-               priv->button[i] = xf86SetIntOption(pInfo->options, b, 
priv->button[i]);
+               priv->button_default[i] = xf86SetIntOption(pInfo->options, b, 
priv->button_default[i]);
        }
 
        /* Now parse class-specific options */
diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c
index ef33011..9a41c59 100644
--- a/src/wcmXCommand.c
+++ b/src/wcmXCommand.c
@@ -539,12 +539,12 @@ static int wcmSetWheelProperty(DeviceIntPtr dev, Atom 
property,
        WacomDevicePtr priv = (WacomDevicePtr) pInfo->private;
 
        struct wheel_strip_update_t wsup = {
-               .up1 = &priv->relup,
-               .dn1 = &priv->reldn,
-               .up2 = &priv->wheelup,
-               .dn2 = &priv->wheeldn,
-               .up3 = &priv->wheel2up,
-               .dn3 = &priv->wheel2dn,
+               .up1 = &priv->wheel_default[WHEEL_REL_UP],
+               .dn1 = &priv->wheel_default[WHEEL_REL_DN],
+               .up2 = &priv->wheel_default[WHEEL_ABS_UP],
+               .dn2 = &priv->wheel_default[WHEEL_ABS_DN],
+               .up3 = &priv->wheel_default[WHEEL2_ABS_UP],
+               .dn3 = &priv->wheel_default[WHEEL2_ABS_DN],
 
                .handlers = priv->wheel_actions,
                .keys     = priv->wheel_keys,
@@ -561,10 +561,10 @@ static int wcmSetStripProperty(DeviceIntPtr dev, Atom 
property,
        WacomDevicePtr priv = (WacomDevicePtr) pInfo->private;
 
        struct wheel_strip_update_t wsup = {
-               .up1 = &priv->striplup,
-               .dn1 = &priv->stripldn,
-               .up2 = &priv->striprup,
-               .dn2 = &priv->striprdn,
+               .up1 = &priv->strip_default[STRIP_LEFT_UP],
+               .dn1 = &priv->strip_default[STRIP_LEFT_DN],
+               .up2 = &priv->strip_default[STRIP_RIGHT_UP],
+               .dn2 = &priv->strip_default[STRIP_RIGHT_DN],
                .up3 = NULL,
                .dn3 = NULL,
 
diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h
index ae2b827..0537eef 100644
--- a/src/xf86WacomDefs.h
+++ b/src/xf86WacomDefs.h
@@ -192,6 +192,18 @@ struct _WacomModel
 #define AXIS_INVERT  0x01               /* Flag describing an axis which 
increases "downward" */
 #define AXIS_BITWISE 0x02               /* Flag describing an axis which 
changes bitwise */
 
+/* Indicies into the wheel/strip default/keys/actions arrays */
+#define WHEEL_REL_UP      0
+#define WHEEL_REL_DN      1
+#define WHEEL_ABS_UP      2
+#define WHEEL_ABS_DN      3
+#define WHEEL2_ABS_UP     4
+#define WHEEL2_ABS_DN     5
+#define STRIP_LEFT_UP     0
+#define STRIP_LEFT_DN     1
+#define STRIP_RIGHT_UP    2
+#define STRIP_RIGHT_DN    3
+
 /* get/set/property */
 typedef struct _PROPINFO PROPINFO;
 
@@ -230,29 +242,23 @@ struct _WacomDeviceRec
        int maxHeight;          /* max active screen height in screen coords */
        int leftPadding;        /* left padding for virtual tablet in device 
coordinates*/
        int topPadding;         /* top padding for virtual tablet in device 
coordinates*/
-       /*  map zero based internal buttons to one based X buttons */
-       int button[WCM_MAX_BUTTONS];
-       /* map one based X buttons to keystrokes */
-       unsigned keys[WCM_MAX_BUTTONS][256];
-       int relup;
-       int reldn;
-       int wheelup;
-       int wheeldn;
-       int wheel2up;
-       int wheel2dn;
-       /* keystrokes assigned to wheel events (default is the buttons above).
-        * Order is relup, reldwn, wheelup, wheeldn, wheel2up, wheel2dn.
-        * Like 'keys', this array is one-indexed */
-       unsigned wheel_keys[6][256];
 
-       int striplup;
-       int stripldn;
-       int striprup;
-       int striprdn;
-       /* keystrokes assigned to strip events (default is the buttons above).
-        * Order is striplup, stripldn, striprup, striprdn. Like 'keys', this
-        * array is one-indexed */
+       /* button mapping information
+        *
+        * 'button' variables are indexed by physical button number 
(0..nbuttons)
+        * 'strip' variables are indexed by STRIP_* defines
+        * 'wheel' variables are indexed by WHEEL_* defines
+        */
+       int button_default[WCM_MAX_BUTTONS]; /* Default mappings set by 
ourselves (possibly overridden by xorg.conf) */
+       int strip_default[4];
+       int wheel_default[6];
+       unsigned keys[WCM_MAX_BUTTONS][256]; /* Action codes to perform when 
the associated event occurs */
        unsigned strip_keys[4][256];
+       unsigned wheel_keys[6][256];
+       Atom btn_actions[WCM_MAX_BUTTONS];   /* Action references so we can 
update the action codes when a client makes a change */
+       Atom strip_actions[4];
+       Atom wheel_actions[6];
+
        int nbuttons;           /* number of buttons for this subdevice */
        int naxes;              /* number of axes */
                                /* FIXME: always 6, and the code relies on 
that... */
@@ -296,11 +302,6 @@ struct _WacomDeviceRec
 
        int isParent;           /* set to 1 if the device is not 
auto-hotplugged */
 
-       /* property handlers to listen to for action properties */
-       Atom btn_actions[WCM_MAX_BUTTONS];
-       Atom wheel_actions[6];
-       Atom strip_actions[4];
-
        OsTimerPtr serial_timer; /* timer used for serial number property 
update */
 };
 
-- 
1.7.9.1


------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to