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, action mapping (via xsetwacom) no longer depends on
on the raw mapping (via xorg.conf). For instance, on a system
which has 'Option "Button3" "1"' set, use of the command
'xsetwacom set <id> button 1 10' will no longer cause *both*
button 1 and button 3 to emit button 10. Its unlikely anyone
relies on this quirk, but can be easily worked around if
necessary.

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 c5b3d59..a6fa309 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 76bf857..1cbae62 100644
--- a/src/wcmXCommand.c
+++ b/src/wcmXCommand.c
@@ -332,8 +332,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;
@@ -341,7 +340,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 4ae6fe7..60fbd7b 100644
--- a/src/xf86WacomDefs.h
+++ b/src/xf86WacomDefs.h
@@ -234,7 +234,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;
@@ -244,7 +244,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;
@@ -253,7 +253,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.11.1


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to