The 'keys' array is indexed into by reference to the X11 button
number stored in the 'buttons' array. While this may have been
useful at some point in time, the benefits have since gone and
left behind nothing but headaches.

Note that because the association with X11 buttons has been
removed, systems which set both raw *and* action button mappings
will appear to have the button number associated with actions
change. Since the only way to set raw button mappings is via
xorg.conf, there is little expected fallout from this change.

Signed-off-by: Jason Gerecke <killert...@gmail.com>
---
 src/wcmCommon.c     |   25 +++++++++----------------
 src/wcmXCommand.c   |    5 ++---
 src/xf86WacomDefs.h |    6 +++---
 3 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/src/wcmCommon.c b/src/wcmCommon.c
index 034a3a3..d92d280 100644
--- a/src/wcmCommon.c
+++ b/src/wcmCommon.c
@@ -286,23 +286,16 @@ static void sendAButton(InputInfoPtr pInfo, int button, 
int mask,
 #ifdef DEBUG
        WacomCommonPtr common = priv->common;
 #endif
-       int mapped_button;
+       int mapped_button = button > 2 ? button + 4 : button; /* maintain prior 
"dead button" behavior */
 
-       if (!priv->button[button])  /* ignore this button event */
-               return;
-
-       mapped_button = priv->button[button];
-
-       DBG(4, priv, "TPCButton(%s) button=%d state=%d "
-               "mapped_button=%d\n",
-               common->wcmTPCButton ? "on" : "off",
-               button, mask, mapped_button);
+       DBG(4, priv, "TPCButton(%s) button=%d state=%d\n",
+           common->wcmTPCButton ? "on" : "off", button, mask);
 
        if (!priv->keys[mapped_button][0])
        {
                /* No button action configured, send button */
                xf86PostButtonEventP(pInfo->dev, is_absolute(pInfo),
-                                    mapped_button, (mask != 0),
+                                    priv->button[button], (mask != 0),
                                     first_val, num_val,
                                     VCOPY(valuators, num_val));
                return;
@@ -433,7 +426,7 @@ static void sendWheelStripEvents(InputInfoPtr pInfo, const 
WacomDeviceState* ds,
        {
                DBG(10, priv, "Left touch strip scroll delta = %d\n", delta);
                fakeButton = getWheelButton(delta, priv->striplup, 
priv->stripldn,
-                                           priv->strip_keys[0+1], 
priv->strip_keys[1+1], &fakeKey);
+                                           priv->strip_keys[0], 
priv->strip_keys[1], &fakeKey);
                sendWheelStripEvent(fakeButton, fakeKey, pInfo, first_val, 
num_vals, valuators);
        }
 
@@ -443,7 +436,7 @@ static void sendWheelStripEvents(InputInfoPtr pInfo, const 
WacomDeviceState* ds,
        {
                DBG(10, priv, "Right touch strip scroll delta = %d\n", delta);
                fakeButton = getWheelButton(delta, priv->striprup, 
priv->striprdn,
-                                           priv->strip_keys[2+1], 
priv->strip_keys[3+1], &fakeKey);
+                                           priv->strip_keys[2], 
priv->strip_keys[3], &fakeKey);
                sendWheelStripEvent(fakeButton, fakeKey, pInfo, first_val, 
num_vals, valuators);
        }
 
@@ -453,7 +446,7 @@ static void sendWheelStripEvents(InputInfoPtr pInfo, const 
WacomDeviceState* ds,
        {
                DBG(10, priv, "Relative wheel scroll delta = %d\n", delta);
                fakeButton = getWheelButton(delta, priv->relup, priv->reldn,
-                                           priv->wheel_keys[0+1], 
priv->wheel_keys[1+1], &fakeKey);
+                                           priv->wheel_keys[0], 
priv->wheel_keys[1], &fakeKey);
                sendWheelStripEvent(fakeButton, fakeKey, pInfo, first_val, 
num_vals, valuators);
        }
 
@@ -463,7 +456,7 @@ static void sendWheelStripEvents(InputInfoPtr pInfo, const 
WacomDeviceState* ds,
        {
                DBG(10, priv, "Left touch wheel scroll delta = %d\n", delta);
                fakeButton = getWheelButton(delta, priv->wheelup, priv->wheeldn,
-                                           priv->wheel_keys[2+1], 
priv->wheel_keys[3+1], &fakeKey);
+                                           priv->wheel_keys[2], 
priv->wheel_keys[3], &fakeKey);
                sendWheelStripEvent(fakeButton, fakeKey, pInfo, first_val, 
num_vals, valuators);
        }
 
@@ -473,7 +466,7 @@ static void sendWheelStripEvents(InputInfoPtr pInfo, const 
WacomDeviceState* ds,
        {
                DBG(10, priv, "Right touch wheel scroll delta = %d\n", delta);
                fakeButton = getWheelButton(delta, priv->wheel2up, 
priv->wheel2dn,
-                                           priv->wheel_keys[4+1], 
priv->wheel_keys[5+1], &fakeKey);
+                                           priv->wheel_keys[4], 
priv->wheel_keys[5], &fakeKey);
                sendWheelStripEvent(fakeButton, fakeKey, pInfo, first_val, 
num_vals, valuators);
        }
 }
diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c
index 0fd5664..ef33011 100644
--- a/src/wcmXCommand.c
+++ b/src/wcmXCommand.c
@@ -329,8 +329,7 @@ static void wcmUpdateButtonKeyActions(DeviceIntPtr dev, 
XIPropertyValuePtr prop,
 
        for (i = 0; i < prop->size; i++)
        {
-               /* keys is one based array to align with X buttons */
-               memset(keys[i+1], 0, sizeof(keys[i+1]));
+               memset(keys[i], 0, sizeof(keys[i]));
 
                if (!values[i])
                        continue;
@@ -338,7 +337,7 @@ static void wcmUpdateButtonKeyActions(DeviceIntPtr dev, 
XIPropertyValuePtr prop,
                XIGetDeviceProperty(dev, values[i], &val);
 
                for (j = 0; j < val->size; j++)
-                       keys[i+1][j] = ((unsigned int*)val->data)[j];
+                       keys[i][j] = ((unsigned int*)val->data)[j];
        }
 }
 
diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h
index 625b07e..ae2b827 100644
--- a/src/xf86WacomDefs.h
+++ b/src/xf86WacomDefs.h
@@ -233,7 +233,7 @@ struct _WacomDeviceRec
        /*  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+1][256];
+       unsigned keys[WCM_MAX_BUTTONS][256];
        int relup;
        int reldn;
        int wheelup;
@@ -243,7 +243,7 @@ struct _WacomDeviceRec
        /* 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+1][256];
+       unsigned wheel_keys[6][256];
 
        int striplup;
        int stripldn;
@@ -252,7 +252,7 @@ struct _WacomDeviceRec
        /* keystrokes assigned to strip events (default is the buttons above).
         * Order is striplup, stripldn, striprup, striprdn. Like 'keys', this
         * array is one-indexed */
-       unsigned strip_keys[4+1][256];
+       unsigned strip_keys[4][256];
        int nbuttons;           /* number of buttons for this subdevice */
        int naxes;              /* number of axes */
                                /* FIXME: always 6, and the code relies on 
that... */
-- 
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