This patch adds functions capable of resetting the action properties (button/stip/wheel) to their default, and calls them on initialization.
Signed-off-by: Jason Gerecke <killert...@gmail.com> --- src/wcmXCommand.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c index 3897593..59ea965 100644 --- a/src/wcmXCommand.c +++ b/src/wcmXCommand.c @@ -103,6 +103,55 @@ Atom prop_debuglevels; #endif /** + * Resets an arbitrary Action property, given a pointer to the old + * handler and information about the new Action. + */ +void wcmResetAction(InputInfoPtr pInfo, const char *name, int index, + Atom *handler, unsigned int (*action)[256], + unsigned int (*new_action)[256], Atom prop, int nprop) +{ + char buff[64]; + sprintf(buff, name, index); + + handler[index] = MakeAtom(buff, strlen(buff), TRUE); + memset(action[index], 0, sizeof(action[index])); + memcpy(action[index], *new_action, sizeof(*new_action)); + XIChangeDeviceProperty(pInfo->dev, handler[index], XA_INTEGER, 32, + PropModeReplace, 1, (char*)new_action, FALSE); +} + +void wcmResetButtonAction(InputInfoPtr pInfo, int button, int nbuttons) +{ + WacomDevicePtr priv = (WacomDevicePtr) pInfo->private; + unsigned int new_action[256] = {}; + int logical_button = priv->button_default[button]; + int mouse_button = button < 3 ? button : button + 4; + + new_action[0] = AC_BUTTON | AC_KEYBTNPRESS | logical_button; + wcmResetAction(pInfo, "Wacom button action %d", mouse_button, priv->btn_actions, priv->keys, &new_action, prop_btnactions, nbuttons); +} + +void wcmResetStripAction(InputInfoPtr pInfo, int index) +{ + WacomDevicePtr priv = (WacomDevicePtr) pInfo->private; + unsigned int new_action[256] = {}; + + new_action[0] = AC_BUTTON | AC_KEYBTNPRESS | (priv->strip_default[index]); + new_action[1] = AC_BUTTON | (priv->strip_default[index]); + wcmResetAction(pInfo, "Wacom strip action %d", index, priv->strip_actions, priv->strip_keys, &new_action, prop_strip_buttons, 4); +} + +void wcmResetWheelAction(InputInfoPtr pInfo, int index) +{ + WacomDevicePtr priv = (WacomDevicePtr) pInfo->private; + unsigned int new_action[256] = {}; + + new_action[0] = AC_BUTTON | AC_KEYBTNPRESS | (priv->wheel_default[index]); + new_action[1] = AC_BUTTON | (priv->wheel_default[index]); + wcmResetAction(pInfo, "Wacom wheel action %d", index, priv->wheel_actions, priv->wheel_keys, &new_action, prop_wheel_buttons, 6); +} + +/** * Registers a property for the input device. This function registers * the property name atom, as well as creates the property itself. * At creation, the property values are initialized from the 'values' @@ -158,6 +207,7 @@ void InitWcmDeviceProperties(InputInfoPtr pInfo) WacomCommonPtr common = priv->common; int values[WCM_MAX_BUTTONS]; int nbuttons; + int i; DBG(10, priv, "\n"); @@ -227,21 +277,25 @@ void InitWcmDeviceProperties(InputInfoPtr pInfo) values[0] = MakeAtom(pInfo->type_name, strlen(pInfo->type_name), TRUE); prop_tooltype = InitWcmAtom(pInfo->dev, WACOM_PROP_TOOL_TYPE, XA_ATOM, 32, 1, values); - - /* default to no actions */ nbuttons = min(max(priv->nbuttons + 4, 7), WCM_MAX_BUTTONS); memset(values, 0, sizeof(values)); prop_btnactions = InitWcmAtom(pInfo->dev, WACOM_PROP_BUTTON_ACTIONS, XA_ATOM, 32, nbuttons, values); + for (i = 0; i < priv->nbuttons; i++) + wcmResetButtonAction(pInfo, i, priv->nbuttons); if (IsPad(priv)) { memset(values, 0, sizeof(values)); prop_strip_buttons = InitWcmAtom(pInfo->dev, WACOM_PROP_STRIPBUTTONS, XA_ATOM, 32, 4, values); + for (i = 0; i < 4; i++) + wcmResetStripAction(pInfo, i); } if (IsPad(priv) || IsCursor(priv)) { memset(values, 0, sizeof(values)); prop_wheel_buttons = InitWcmAtom(pInfo->dev, WACOM_PROP_WHEELBUTTONS, XA_ATOM, 32, 6, values); + for (i = 0; i < 6; i++) + wcmResetWheelAction(pInfo, i); } values[0] = common->vendor_id; -- 1.7.9.5 ------------------------------------------------------------------------------ Better than sec? Nothing is better than sec when it comes to monitoring Big Data applications. Try Boundary one-second resolution app monitoring today. Free. http://p.sf.net/sfu/Boundary-dev2dev _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel