wcmInitAxes calls InitValuatorAxisStruct seven times, with each
call requring two ifdefs each. To keep this function readable,
this patch adds a wrapper function that centralizes all that
ifdef uglyness into a single spot.

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

diff --git a/src/xf86Wacom.c b/src/xf86Wacom.c
index 3e128f9..0190678 100644
--- a/src/xf86Wacom.c
+++ b/src/xf86Wacom.c
@@ -137,6 +137,18 @@ static void wcmInitialToolSize(InputInfoPtr pInfo)
        return;
 }
 
+static void wcmInitAxis(DeviceIntPtr dev, int axis, Atom label, int min, int 
max, int res, int min_res, int max_res, int mode) {
+       InitValuatorAxisStruct(dev, axis,
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
+                              label,
+#endif
+                              min, max, res, min_res, max_res
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
+                              ,mode
+#endif
+       );
+}
+
 static int
 wcmInitAxes(DeviceIntPtr pWcm)
 {
@@ -157,15 +169,8 @@ wcmInitAxes(DeviceIntPtr pWcm)
        res = priv->resolX;
        mode = Absolute;
 
-       InitValuatorAxisStruct(pInfo->dev, 0,
-#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
-                              label,
-#endif
-                              min, max, res, min_res, max_res
-#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
-                              , mode
-#endif
-                              );
+       wcmInitAxis(pInfo->dev, 0, label, min, max, res, min_res, max_res, 
mode);
+
 
        /* second valuator: y */
        label = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y);
@@ -176,19 +181,10 @@ wcmInitAxes(DeviceIntPtr pWcm)
        res = priv->resolY;
        mode = Absolute;
 
-       InitValuatorAxisStruct(pInfo->dev, 1,
-#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
-                              label,
-#endif
-                              min, max, res, min_res, max_res
-#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
-                              , mode
-#endif
-                              );
+       wcmInitAxis(pInfo->dev, 1, label, min, max, res, min_res, max_res, 
mode);
 
 
        /* third valuator: pressure */
-
        mode = Absolute;
        min_res = max_res = res = 1;
        min = 0;
@@ -208,19 +204,10 @@ wcmInitAxes(DeviceIntPtr pWcm)
                max = 1;
        }
 
+       wcmInitAxis(pInfo->dev, 2, label, min, max, res, min_res, max_res, 
mode);
 
-       InitValuatorAxisStruct(pInfo->dev, 2,
-#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
-                              label,
-#endif
-                              min, max, res, min_res, max_res
-#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
-                              , mode
-#endif
-                              );
 
        /* fourth valuator: tilt-x, cursor:z-rotation, pad:strip-x */
-
        if (IsCursor(priv))
        {
                label = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_RZ);
@@ -246,18 +233,10 @@ wcmInitAxes(DeviceIntPtr pWcm)
                        mode = Absolute;
        }
 
-       InitValuatorAxisStruct(pInfo->dev, 3,
-#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
-                              label,
-#endif
-                              min, max, res, min_res, max_res
-#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
-                              , mode
-#endif
-                              );
+       wcmInitAxis(pInfo->dev, 3, label, min, max, res, min_res, max_res, 
mode);
 
-       /* fifth valuator: tilt-y, cursor:throttle, pad:strip-y */
 
+       /* fifth valuator: tilt-y, cursor:throttle, pad:strip-y */
        if (IsCursor(priv))
        {
                label = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_THROTTLE);
@@ -283,18 +262,10 @@ wcmInitAxes(DeviceIntPtr pWcm)
                mode = Absolute;
        }
 
-       InitValuatorAxisStruct(pInfo->dev, 4,
-#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
-                              label,
-#endif
-                              min, max, res, min_res, max_res
-#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
-                              , mode
-#endif
-                              );
+       wcmInitAxis(pInfo->dev, 4, label, min, max, res, min_res, max_res, 
mode);
 
-       /* sixth valuator: airbrush: abs-wheel, artpen: rotation, pad:abs-wheel 
*/
 
+       /* sixth valuator: airbrush: abs-wheel, artpen: rotation, pad:abs-wheel 
*/
        if (IsStylus(priv))
        {
                label = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_WHEEL);
@@ -312,15 +283,8 @@ wcmInitAxes(DeviceIntPtr pWcm)
                mode = Absolute;
        }
 
-       InitValuatorAxisStruct(pInfo->dev, 5,
-#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
-                              label,
-#endif
-                              min, max, res, min_res, max_res
-#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
-                              , mode
-#endif
-                              );
+       wcmInitAxis(pInfo->dev, 5, label, min, max, res, min_res, max_res, 
mode);
+
 
        /* seventh valuator: abswheel2 */
        if ((TabletHasFeature(common, WCM_DUALRING)) && IsPad(priv))
@@ -332,15 +296,7 @@ wcmInitAxes(DeviceIntPtr pWcm)
                min_res = max_res = res = 1;
                mode = Absolute;
 
-               InitValuatorAxisStruct(pInfo->dev, 6,
-#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
-                                      label,
-#endif
-                                      min, max, res, min_res, max_res
-#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
-                                      , mode
-#endif
-                                      );
+               wcmInitAxis(pInfo->dev, 6, label, min, max, res, min_res, 
max_res, mode);
        }
 
        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