Continuing with removing raw button code, we create the wheel and strip properties ready to hold actions. Prior to this, the properties would be initialized with the raw buttons; before xsetwacom could set them to actions they would need to be converted.
This does away with the conversion step by following the mold already in place for buttons. With no more need for conversion, we can also nuke the conversion-related bits from xsetwacom. Signed-off-by: Jason Gerecke <killert...@gmail.com> --- src/wcmXCommand.c | 28 ++++++++------------ tools/xsetwacom.c | 74 +++-------------------------------------------------- 2 files changed, 15 insertions(+), 87 deletions(-) diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c index 64ebb8d..f1228b2 100644 --- a/src/wcmXCommand.c +++ b/src/wcmXCommand.c @@ -165,23 +165,6 @@ void InitWcmDeviceProperties(InputInfoPtr pInfo) values[3] = priv->serial; prop_serials = InitWcmAtom(pInfo->dev, WACOM_PROP_SERIALIDS, 32, 4, values); - if (IsPad(priv)) { - values[0] = priv->striplup; - values[1] = priv->stripldn; - values[2] = priv->striprup; - values[3] = priv->striprdn; - prop_strip_buttons = InitWcmAtom(pInfo->dev, WACOM_PROP_STRIPBUTTONS, 8, 4, values); - } - - if (IsPad(priv) || IsCursor(priv)) - { - values[0] = priv->relup; - values[1] = priv->reldn; - values[2] = priv->wheelup; - values[3] = priv->wheeldn; - prop_wheel_buttons = InitWcmAtom(pInfo->dev, WACOM_PROP_WHEELBUTTONS, 8, 4, values); - } - if (IsCursor(priv)) { values[0] = common->wcmCursorProxoutDist; prop_cursorprox = InitWcmAtom(pInfo->dev, WACOM_PROP_PROXIMITY_THRESHOLD, 32, 1, values); @@ -220,6 +203,17 @@ void InitWcmDeviceProperties(InputInfoPtr pInfo) memset(values, 0, sizeof(values)); prop_btnactions = InitWcmAtom(pInfo->dev, WACOM_PROP_BUTTON_ACTIONS, -32, WCM_MAX_MOUSE_BUTTONS, values); + if (IsPad(priv)) { + memset(values, 0, sizeof(values)); + prop_strip_buttons = InitWcmAtom(pInfo->dev, WACOM_PROP_STRIPBUTTONS, -32, 4, values); + } + + if (IsPad(priv) || IsCursor(priv)) + { + memset(values, 0, sizeof(values)); + prop_wheel_buttons = InitWcmAtom(pInfo->dev, WACOM_PROP_WHEELBUTTONS, -32, 4, values); + } + #ifdef DEBUG values[0] = priv->debugLevel; values[1] = common->debugLevel; diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c index 59b0cb1..38002cb 100644 --- a/tools/xsetwacom.c +++ b/tools/xsetwacom.c @@ -1093,62 +1093,6 @@ static char** strjoinsplit(int argc, char **argv, int *nwords) return words; } -static const char *wheel_act_prop[] = { - "Wacom Rel Wheel Up Action", - "Wacom Rel Wheel Down Action", - "Wacom Abs Wheel Up Action", - "Wacom Abs Wheel Down Action", -}; - -/** - * Convert the given property from an 8 bit integer property into an action - * atom property. In the default case, this means that a property with - * values "4 5 4 5" ends up to have the values - * "Wacom RHU Action" "Wacom RHW Action" "Wacom AWU Action" "Wacom AWD - * Action" - * with each of the properties having : - * AC_BUTTON | AC_KEYBTNPRESS | 4 (or 5) - * AC_BUTTON | 4 (or 5) - * - * return 0 on success or 1 on failure. - */ -static int convert_wheel_prop(Display *dpy, XDevice *dev, Atom btnact_prop) -{ - int i; - Atom type; - int format; - unsigned long btnact_nitems, bytes_after; - unsigned char *btnact_data; /* current values (button mappings) */ - unsigned long *btnact_new_data; /* new values (action atoms) */ - - XGetDeviceProperty(dpy, dev, btnact_prop, 0, 100, False, - AnyPropertyType, &type, &format, &btnact_nitems, - &bytes_after, (unsigned char**)&btnact_data); - - btnact_new_data = calloc(btnact_nitems, sizeof(Atom)); - if (!btnact_new_data) - return 1; - - for (i = 0; i < btnact_nitems; i++) { - unsigned long action_data[2]; - Atom prop = XInternAtom(dpy, wheel_act_prop[i], False); - - action_data[0] = AC_BUTTON | AC_KEYBTNPRESS | btnact_data[i]; - action_data[1] = AC_BUTTON | btnact_data[i]; - - XChangeDeviceProperty(dpy, dev, prop, XA_INTEGER, 32, - PropModeReplace, - (unsigned char*)action_data, 2); - - btnact_new_data[i] = prop; - } - - XChangeDeviceProperty(dpy, dev, btnact_prop, XA_ATOM, 32, - PropModeReplace, - (unsigned char*)btnact_new_data, btnact_nitems); - return 0; -} - /** * This function parses the given strings to produce a list of actions that * the driver can carry out. We first combine the strings and then split @@ -1265,21 +1209,11 @@ static void special_map_property(Display *dpy, XDevice *dev, Atom btnact_prop, i return; } - if (format == 8 && type == XA_INTEGER) + if (format != 32 || type != XA_ATOM) { - /* Prop is currently 8 bit integer, i.e. plain button - * mappings. Convert to 32 bit Atom actions first. - */ - if (convert_wheel_prop(dpy, dev, btnact_prop)) - { - fprintf(stderr, "Error creating wheel action.\n"); - return; - } - - XGetDeviceProperty(dpy, dev, btnact_prop, 0, 100, False, - AnyPropertyType, &type, &format, - &btnact_nitems, &bytes_after, - (unsigned char**)&btnact_data); + fprintf(stderr, "Property '%s' in an unexpected format. This is a bug.\n", + XGetAtomName(dpy, btnact_prop)); + return; } /* set or unset the property */ -- 1.7.4.1 ------------------------------------------------------------------------------ Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel