summaryrefslogtreecommitdiff
authorPeter Hutterer <peter.hutterer@who-t.net>2009-12-15 02:29:17 (GMT)
committer Peter Hutterer <peter.hutterer@who-t.net>2009-12-16 23:56:12 (GMT)
commitb9d5e7319f83ee608a216a17e9a59621bedb7e58 (patch) (side-by-side diff)
treef74c1231d3fc8c21cee7b2df57f2c0493618b432
parentb009e88c4ca2a72d286d15b44426150e792acd5d (diff)
downloadxf86-input-wacom-b9d5e7319f83ee608a216a17e9a59621bedb7e58.zip
xf86-input-wacom-b9d5e7319f83ee608a216a17e9a59621bedb7e58.tar.gz
Release keys still down when a button is released.
xsetwacom --set <device name> "Button1" "key +shift" keeps the shift key down until the button is released, allowing it to work like a real modifier. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/wcmCommon.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/wcmCommon.c b/src/wcmCommon.c
index 17018c8..c5c4a57 100644
--- a/src/wcmCommon.c
+++ b/src/wcmCommon.c
@@ -423,6 +423,25 @@ static void toggleDisplay(LocalDevicePtr local)
}
/*****************************************************************************
+ * countPresses
+ * Count the number of key/button presses not released for the given key
+ * array.
+ ****************************************************************************/
+static int countPresses(int keybtn, unsigned int* keys, int size)
+{
+ int i, act, count = 0;
+
+ for (i = 0; i < size; i++)
+ {
+ act = keys[i];
+ if ((act & AC_CODE) == keybtn)
+ count += (act & AC_KEYBTNPRESS) ? 1 : -1;
+ }
+
+ return count;
+}
+
+/*****************************************************************************
* sendAButton --
* Send one button event, called by xf86WcmSendButtons
****************************************************************************/
@@ -505,6 +524,45 @@ static void sendAButton(LocalDevicePtr local, int button, int mask,
break;
}
}
+
+ /* Release all non-released keys for this button. */
+ for (i = 0; !mask && i < ARRAY_SIZE(priv->keys[button]); i++)
+ {
+ unsigned int action = priv->keys[button][i];
+
+ switch ((action & AC_TYPE))
+ {
+ case AC_BUTTON:
+ {
+ int btn_no = (action & AC_CODE);
+
+ /* don't care about releases here */
+ if (!(action & AC_KEYBTNPRESS))
+ break;
+
+ if (countPresses(btn_no, &priv->keys[button][i],
+ ARRAY_SIZE(priv->keys[button]) - i))
+ xf86PostButtonEvent(local->dev,
+ is_absolute, btn_no,
+ 0, 0, naxes,
+ rx, ry, rz, v3, v4, v5);
+ }
+ break;
+ case AC_KEY:
+ {
+ int key_sym = (action & AC_CODE);
+
+ /* don't care about releases here */
+ if (!(action & AC_KEYBTNPRESS))
+ break;
+
+ if (countPresses(key_sym, &priv->keys[button][i],
+ ARRAY_SIZE(priv->keys[button]) - i))
+ emitKeysym(local->dev, key_sym, 0);
+ }
+ }
+
+ }
}
/*****************************************************************************