Axes which aren't used by specific devices 'leak' some of the
settings of the prior axis while creating the necessary 'filler'
axis. This patch introduces an 'initFillerAxis' function that
provides a consistent filler axis and restructures calls as
necessary.

Signed-off-by: Jason Gerecke <killert...@gmail.com>
---
 src/xf86Wacom.c | 78 +++++++++++++++++++++++++++++++++++----------------------
 1 file changed, 48 insertions(+), 30 deletions(-)

diff --git a/src/xf86Wacom.c b/src/xf86Wacom.c
index 0190678..0f55fe1 100644
--- a/src/xf86Wacom.c
+++ b/src/xf86Wacom.c
@@ -149,6 +149,11 @@ static void wcmInitAxis(DeviceIntPtr dev, int axis, Atom 
label, int min, int max
        );
 }
 
+static void wcmInitFillerAxis(DeviceIntPtr dev, int axis)
+{
+       wcmInitAxis(dev, axis, None, 0, 1, 1, 1, 1, Absolute);
+}
+
 static int
 wcmInitAxes(DeviceIntPtr pWcm)
 {
@@ -194,76 +199,81 @@ wcmInitAxes(DeviceIntPtr pWcm)
                label = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_PRESSURE);
                /* pressure normalized to FILTER_PRESSURE_RES */
                max = FILTER_PRESSURE_RES;
+               wcmInitAxis(pInfo->dev, 2, label, min, max, res, min_res, 
max_res, mode);
+
        } else {
                /* The pad doesn't have a pressure axis, so initialise third
                 * axis as unknown absolute axis on the pad. This way, we
                 * can leave the strip/abswheel axes on later axes and don't
                 * run the danger of clients misinterpreting the axis info
                 */
-               label = None;
-               max = 1;
+               wcmInitFillerAxis(pInfo->dev, 2);
        }
 
-       wcmInitAxis(pInfo->dev, 2, label, min, max, res, min_res, max_res, 
mode);
-
 
        /* fourth valuator: tilt-x, cursor:z-rotation, pad:strip-x */
-       if (IsCursor(priv))
+       if (IsPen(priv))
+       {
+               label = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_TILT_X),
+               min = -64;
+               max = 63;
+               min_res = max_res = res = 1;
+               mode = Absolute;
+               wcmInitAxis(pInfo->dev, 3, label, min, max, res, min_res, 
max_res, mode);
+       }
+       else if (IsCursor(priv))
        {
                label = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_RZ);
                min = MIN_ROTATION;
                max = MIN_ROTATION + MAX_ROTATION_RANGE - 1;
                min_res = max_res = res = 1;
                mode = Absolute;
-       } else if (IsPad(priv))
+               wcmInitAxis(pInfo->dev, 3, label, min, max, res, min_res, 
max_res, mode);
+       } else if (IsPad(priv) && TabletHasFeature(common, WCM_STRIP))
        {
                label = None; /* XXX: what is this axis? */
                min = 0;
-               max = 1; /* dummy value if !HasFeature(WCM_STRIP) */
+               max = common->wcmMaxStripX;
                min_res = max_res = res = 1;
                mode = Absolute;
-               if (TabletHasFeature(common, WCM_STRIP))
-                       max = common->wcmMaxStripX;
+               wcmInitAxis(pInfo->dev, 3, label, min, max, res, min_res, 
max_res, mode);
        } else
        {
-                       label = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_TILT_X),
-                       min = -64;
-                       max = 63;
-                       min_res = max_res = res = 1;
-                       mode = Absolute;
+               wcmInitFillerAxis(pInfo->dev, 3);
        }
 
-       wcmInitAxis(pInfo->dev, 3, label, min, max, res, min_res, max_res, 
mode);
-
 
        /* fifth valuator: tilt-y, cursor:throttle, pad:strip-y */
-       if (IsCursor(priv))
+       if (IsPen(priv))
+       {
+               label = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_TILT_Y);
+               min = -64;
+               max = 63;
+               min_res = max_res = res = 1;
+               mode = Absolute;
+               wcmInitAxis(pInfo->dev, 4, label, min, max, res, min_res, 
max_res, mode);
+       }
+       else if (IsCursor(priv))
        {
                label = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_THROTTLE);
                min = -1023;
                max = 1023;
                min_res = max_res = res = 1;
                mode = Absolute;
-       } else if (IsPad(priv))
+               wcmInitAxis(pInfo->dev, 4, label, min, max, res, min_res, 
max_res, mode);
+       } else if (IsPad(priv) && TabletHasFeature(common, WCM_STRIP))
        {
                label = None; /* XXX: what is this axis? */
                min = 0;
-               max = 1; /* dummy value if !HasFeature(WCM_STRIP) */
+               max = common->wcmMaxStripY;
                min_res = max_res = res = 1;
                mode = Absolute;
-               if (TabletHasFeature(common, WCM_STRIP))
-                       max = common->wcmMaxStripY;
+               wcmInitAxis(pInfo->dev, 4, label, min, max, res, min_res, 
max_res, mode);
        } else
        {
-               label = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_TILT_Y);
-               min = -64;
-               max = 63;
-               min_res = max_res = res = 1;
-               mode = Absolute;
+               wcmInitFillerAxis(pInfo->dev, 4);
        }
 
-       wcmInitAxis(pInfo->dev, 4, label, min, max, res, min_res, max_res, 
mode);
-
 
        /* sixth valuator: airbrush: abs-wheel, artpen: rotation, pad:abs-wheel 
*/
        if (IsStylus(priv))
@@ -273,6 +283,7 @@ wcmInitAxes(DeviceIntPtr pWcm)
                min = MIN_ROTATION;
                min_res = max_res = res = 1;
                mode = Absolute;
+               wcmInitAxis(pInfo->dev, 5, label, min, max, res, min_res, 
max_res, mode);
        } else if ((TabletHasFeature(common, WCM_RING)) && IsPad(priv))
        {
                /* Touch ring */
@@ -281,9 +292,12 @@ wcmInitAxes(DeviceIntPtr pWcm)
                max = MAX_PAD_RING;
                min_res = max_res = res = 1;
                mode = Absolute;
+               wcmInitAxis(pInfo->dev, 5, label, min, max, res, min_res, 
max_res, mode);
+       }
+       else
+       {
+               wcmInitFillerAxis(pInfo->dev, 5);
        }
-
-       wcmInitAxis(pInfo->dev, 5, label, min, max, res, min_res, max_res, 
mode);
 
 
        /* seventh valuator: abswheel2 */
@@ -298,6 +312,10 @@ wcmInitAxes(DeviceIntPtr pWcm)
 
                wcmInitAxis(pInfo->dev, 6, label, min, max, res, min_res, 
max_res, mode);
        }
+       else
+       {
+               wcmInitFillerAxis(pInfo->dev, 6);
+       }
 
        return TRUE;
 }
-- 
1.7.11


------------------------------------------------------------------------------
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