From: Chris Bagwell <[email protected]> So commit is clear, let me define terminology used in describing change.
internal buttons - xf86-input-wacom has a fixed set of buttons it maps to internal #0 to 4 (stylus buttons, mouse buttons, and pad buttons). It also has generic list of buttons BTN_0.. BTN_* that it defines to internal #0 to 27. X physical buttons - xf86-input-wacom uses a non-user editable priv->button[] array to map internal button #'s to X physical buttons. The current usage of this array is to skip over physical buttons 4 to 7 since they are used for scrolling events by convention. X logical buttons - both "xinput set-button-map" and "xsetwacom --set X ButtonN N" modify an array that converts X physical buttons to X logical buttons. key mappings - "xsetwacom --set X Button N "key 1"" creates a button-to-key mapping. Before this patch, the key mapping was "internal button" to key mappings; instead of X physical buttons to key mappings. New Bamboo driver maps two middle pad buttons to X physical buttons 8 and 9 because internally they are 4 and 5. This mean for button-to-button mappings, user used Button8/9 but for key mappings they used Button4/5 to change behavior. This is a long explaination for small patch that makes key mappings use X physical button names for consistency. It also changes keys[] array to be ones based to allow with X physical buttons being ones based. Signed-off-by: Chris Bagwell <[email protected]> --- The main change to this patch is based on testing feedback from Andrzej Giniewicz. There was an off-by-one bug because keys[] was zero based array but patch was treating it ones based. Modifed keys[] to be one based to align with its intended usage. Also, implemented Peter's suggestions for readability. src/wcmCommon.c | 22 ++++++++++++++-------- src/wcmXCommand.c | 5 +++-- src/xf86WacomDefs.h | 6 ++++-- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/wcmCommon.c b/src/wcmCommon.c index 0fc9cb6..39a211d 100644 --- a/src/wcmCommon.c +++ b/src/wcmCommon.c @@ -271,25 +271,31 @@ static void sendAButton(InputInfoPtr pInfo, int button, int mask, #ifdef DEBUG WacomCommonPtr common = priv->common; #endif + int mapped_button; + if (!priv->button[button]) /* ignore this button event */ return; + mapped_button = priv->button[button]; + DBG(4, priv, "TPCButton(%s) button=%d state=%d " - "code=%08x, coreEvent=%s \n", + "mapped_button=%d, coreEvent=%s \n", common->wcmTPCButton ? "on" : "off", - button, mask, priv->button[button], - (priv->button[button] & AC_CORE) ? "yes" : "no"); + button, mask, mapped_button, + (mapped_button & AC_CORE) ? "yes" : "no"); - if (!priv->keys[button][0]) + if (!priv->keys[mapped_button][0]) { /* No button action configured, send button */ - xf86PostButtonEventP(pInfo->dev, is_absolute(pInfo), priv->button[button], (mask != 0), - first_val, num_val, VCOPY(valuators, num_val)); + xf86PostButtonEventP(pInfo->dev, is_absolute(pInfo), + mapped_button, (mask != 0), + first_val, num_val, + VCOPY(valuators, num_val)); return; } - sendAction(pInfo, (mask != 0), priv->keys[button], - ARRAY_SIZE(priv->keys[button]), + sendAction(pInfo, (mask != 0), priv->keys[mapped_button], + ARRAY_SIZE(priv->keys[mapped_button]), first_val, num_val, valuators); } diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c index 014fd17..11b247f 100644 --- a/src/wcmXCommand.c +++ b/src/wcmXCommand.c @@ -304,9 +304,10 @@ static void wcmUpdateButtonKeyActions(DeviceIntPtr dev, XIPropertyValuePtr prop, XIGetDeviceProperty(dev, values[i], &val); - memset(keys[i], 0, sizeof(keys[i])); + /* keys is one based array to align with X buttons */ + memset(keys[i+1], 0, sizeof(keys[i])); for (j = 0; j < val->size; j++) - keys[i][j] = ((unsigned int*)val->data)[j]; + keys[i+1][j] = ((unsigned int*)val->data)[j]; } } diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h index 6db7cda..c16497b 100644 --- a/src/xf86WacomDefs.h +++ b/src/xf86WacomDefs.h @@ -233,8 +233,10 @@ struct _WacomDeviceRec int maxHeight; /* max active screen height */ int leftPadding; /* left padding for virtual tablet */ int topPadding; /* top padding for virtual tablet */ - int button[WCM_MAX_BUTTONS];/* buttons assignments */ - unsigned keys[WCM_MAX_BUTTONS][256]; /* keystrokes assigned to buttons */ + /* map zero based interal 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]; int relup; int reldn; int wheelup; -- 1.7.3.4 ------------------------------------------------------------------------------ Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ Linuxwacom-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
