On Mon, Dec 13, 2010 at 5:15 PM, Peter Hutterer
<[email protected]> wrote:
> On Mon, Dec 13, 2010 at 11:44:07AM -0800, Ping Cheng wrote:
>> On Sun, Dec 12, 2010 at 7:33 PM, Peter Hutterer
>> <[email protected]> wrote:
>> > And clean up the code to use less ABI ifdefs.
>> >
>> > Signed-off-by: Peter Hutterer <[email protected]>
>>
>> Reviewed-by: Ping Cheng <[email protected]>
>>
>> with one typo correction and a few minor comments inline. Everything
>> else looks fine.
>>
>> Ping
>>
>> > ---
>> > src/xf86Wacom.c | 312
>> > ++++++++++++++++++++++++++++++------------------------
>> > 1 files changed, 173 insertions(+), 139 deletions(-)
>> >
>> > diff --git a/src/xf86Wacom.c b/src/xf86Wacom.c
>> > index d4cdae8..ce91538 100644
>> > --- a/src/xf86Wacom.c
>> > +++ b/src/xf86Wacom.c
>> > @@ -51,6 +51,8 @@
>> > #include <xserver-properties.h>
>> > #include <X11/extensions/XKB.h>
>> > #include <xkbsrv.h>
>> > +#else
>> > +#define XIGetKnownProperty(prop) 0
>> > #endif
>> >
>> > static int wcmDevOpen(DeviceIntPtr pWcm);
>> > @@ -398,6 +400,175 @@ static void wcmInitialToolSize(InputInfoPtr pInfo)
>> > return;
>> > }
>> >
>> > +static int
>> > +wcmInitAxes(DeviceIntPtr pWcm)
>> > +{
>> > + InputInfoPtr pInfo = (InputInfoPtr)pWcm->public.devicePrivate;
>> > + WacomDevicePtr priv = (WacomDevicePtr)pInfo->private;
>> > + WacomCommonPtr common = priv->common;
>> > +
>> > + Atom label;
>> > + int min, max, min_res, max_res, res;
>> > + int mode;
>> > +
>> > +
>> > + /* first two valuators are initialised elsewhere */
>> > + if (!IsPad(priv))
>> > + {
>> > + wcmInitialToolSize(pInfo);
>> > +
>> > + if (wcmInitArea(pInfo) == FALSE)
>> > + return FALSE;
>> > +
>> > + wcmInitialCoordinates(priv->pInfo, 0);
>> > + wcmInitialCoordinates(priv->pInfo, 1);
>> > +
>> > + /* Rotation rotates the Max X and Y */
>> > + wcmRotateTablet(pInfo, common->wcmRotate);
>> > + }
>> > +
>> > +
>> > + /* third valuator: pressure */
>> > +
>> > + if (!IsPad(priv))
>> > + {
>> > + label = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_PRESSURE);
>> > + min = 0;
>> > + /* pressure normalized to FILTER_PRESSURE_RES */
>> > + max = FILTER_PRESSURE_RES;
>> > + min_res = max_res = res = 1;
>> > + mode = Absolute;
>> > +
>> > + } else {
>> > + /* The pad doesn't have a pressure axis, so initialise
>> > third
>> > + * axis as unknown relative 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;
>> > + min = max = -1;
>> > + min_res = 0;
>> > + max_res = res = -1;
>> > + mode = Relative;
>> > + }
>> > +
>> > +
>> > + 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);
>> > + min = -900;
>> > + max = -899;
>>
>> max = 899;
>
> amended, thanks.
>
>>
>> > + min_res = max_res = res = 1;
>> > + mode = Absolute;
>> > + } else if (IsPad(priv))
>> > + {
>> > + label = None; /* XXX: what is this axis? */
>> > + min = 0;
>> > + max = 1; /* dummy value if !HasFeature(WCM_STRIP) */
>> > + min_res = max_res = res = 1;
>> > + mode = Absolute;
>> > + if (TabletHasFeature(common, WCM_STRIP))
>> > + max = common->wcmMaxStripX;
>>
>> Should we give STRIP a label and reassign it instead of leaving it as None
>> here?
>
> yeah, we could do this. we don't have a label for this in the server list
> but we could just make up our own. that'll be a separate commit to avoid
> actual code changes when the commit itself is to move things around only.
>
>>
>> > + } else
>> > + {
>> > + label =
>> > XIGetKnownProperty(AXIS_LABEL_PROP_ABS_TILT_X),
>> > + min = -64;
>> > + max = 63;
>> > + min_res = max_res = res = 1;
>> > + 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
>> > + );
>> > +
>> > + /* fifth valuator: tilt-y, cursor:throttle, pad:strip-y */
>> > +
>> > + 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))
>> > + {
>> > + label = None; /* XXX: what is this axis? */
>> > + min = 0;
>> > + max = 1; /* dummy value if !HasFeature(WCM_STRIP) */
>> > + min_res = max_res = res = 1;
>> > + mode = Absolute;
>> > + if (TabletHasFeature(common, WCM_STRIP))
>> > + max = common->wcmMaxStripY;
>>
>> Same for Y.
>>
>> > + } else
>> > + {
>> > + label = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_TILT_Y);
>> > + min = -64;
>> > + max = 63;
>> > + min_res = max_res = res = 1;
>> > + 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
>> > + );
>> > +
>> > + /* fifth valuator: stylus:rotation, pad:abs-wheel */
>>
>> /* fifth valuator: airbrush: abs-wheel, artpen: rotation, pad:abs-wheel */
>
> sorry, I just noticed a typo here. this is the sixth valuator.
> is your comment correct for the fifth or sixth valuator?
Oh, sixth. I didn't notice that typo.
Ping
>> > +
>> > + if (IsStylus(priv))
>> > + {
>> > + label = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_WHEEL);
>> > + max = MAX_ROTATION_RANGE + MIN_ROTATION - 1;
>> > + min = MIN_ROTATION;
>> > + min_res = max_res = res = 1;
>> > + mode = Absolute;
>> > + } else if ((TabletHasFeature(common, WCM_RING)) && IsPad(priv))
>> > + {
>> > + /* Touch ring */
>> > + label = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_WHEEL);
>> > + min = 0;
>> > + max = 71;
>> > + min_res = max_res = res = 1;
>> > + 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
>> > + );
>> > +
>> > + return TRUE;
>> > +}
>> > +
>> > /*****************************************************************************
>> > * wcmDevInit --
>> > * Set up the device's buttons, axes and keys
>> > @@ -407,7 +578,6 @@ static int wcmDevInit(DeviceIntPtr pWcm)
>> > {
>> > InputInfoPtr pInfo = (InputInfoPtr)pWcm->public.devicePrivate;
>> > WacomDevicePtr priv = (WacomDevicePtr)pInfo->private;
>> > - WacomCommonPtr common = priv->common;
>> > unsigned char butmap[WCM_MAX_BUTTONS+1];
>> > int nbaxes, nbbuttons, nbkeys;
>> > int loop;
>> > @@ -506,144 +676,8 @@ static int wcmDevInit(DeviceIntPtr pWcm)
>> > return FALSE;
>> > }
>> >
>> > - if (!IsPad(priv))
>> > - {
>> > - wcmInitialToolSize(pInfo);
>> > -
>> > - if (wcmInitArea(pInfo) == FALSE)
>> > - {
>> > - return FALSE;
>> > - }
>> > -
>> > - wcmInitialCoordinates(priv->pInfo, 0);
>> > - wcmInitialCoordinates(priv->pInfo, 1);
>> > -
>> > - /* Rotation rotates the Max X and Y */
>> > - wcmRotateTablet(pInfo, common->wcmRotate);
>> > -
>> > - /* pressure normalized to FILTER_PRESSURE_RES */
>> > - InitValuatorAxisStruct(pInfo->dev, 2,
>> > -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
>> > -
>> > XIGetKnownProperty(AXIS_LABEL_PROP_ABS_PRESSURE),
>> > -#endif
>> > - 0, FILTER_PRESSURE_RES, 1, 1, 1
>> > -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
>> > - , Absolute
>> > -#endif
>> > - );
>> > -
>> > - } else {
>> > - /* The pad doesn't have a pressure axis, so initialise
>> > third
>> > - * axis as unknown relative 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
>> > - */
>> > - InitValuatorAxisStruct(pInfo->dev, 2,
>> > -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
>> > - None,
>> > -#endif
>> > - -1, -1, 0, -1, -1
>> > -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
>> > - , Relative
>> > -#endif
>> > - );
>> > - }
>> > -
>> > - if (IsCursor(priv))
>> > - {
>> > - /* z-rot and throttle */
>> > - InitValuatorAxisStruct(pInfo->dev, 3,
>> > -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
>> > - XIGetKnownProperty(AXIS_LABEL_PROP_ABS_RZ),
>> > -#endif
>> > - -900, 899, 1, 1, 1
>> > -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
>> > - , Absolute
>> > -#endif
>> > - );
>> > - InitValuatorAxisStruct(pInfo->dev, 4,
>> > -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
>> > - XIGetKnownProperty(AXIS_LABEL_PROP_ABS_THROTTLE),
>> > -#endif
>> > - -1023, 1023, 1, 1, 1
>> > -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
>> > - , Absolute
>> > -#endif
>> > - );
>> > - }
>> > - else if (IsPad(priv))
>> > - {
>> > - /* strip-x and strip-y */
>> > - if (TabletHasFeature(common, WCM_STRIP))
>> > - {
>> > - InitValuatorAxisStruct(pInfo->dev, 3,
>> > -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
>> > - 0, /* XXX what is this axis?*/
>> > -#endif
>> > - 0, common->wcmMaxStripX, 1, 1, 1
>> > -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
>> > - , Absolute
>> > -#endif
>> > - );
>> > - InitValuatorAxisStruct(pInfo->dev, 4,
>> > -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
>> > - 0, /* XXX what is this axis?*/
>> > -#endif
>> > - 0, common->wcmMaxStripY, 1, 1, 1
>> > -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
>> > - , Absolute
>> > -#endif
>> > - );
>> > - }
>> > - }
>> > - else
>> > - {
>> > - /* tilt-x and tilt-y */
>> > - InitValuatorAxisStruct(pInfo->dev, 3,
>> > -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
>> > -
>> > XIGetKnownProperty(AXIS_LABEL_PROP_ABS_TILT_X),
>> > -#endif
>> > - -64, 63, 1, 1, 1
>> > -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
>> > - , Absolute
>> > -#endif
>> > - );
>> > - InitValuatorAxisStruct(pInfo->dev, 4,
>> > -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
>> > -
>> > XIGetKnownProperty(AXIS_LABEL_PROP_ABS_TILT_Y),
>> > -#endif
>> > - -64, 63, 1, 1, 1
>> > -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
>> > - , Absolute
>> > -#endif
>> > - );
>> > - }
>> > -
>> > - if (IsStylus(priv))
>> > - {
>> > - int maxRotation = MAX_ROTATION_RANGE + MIN_ROTATION - 1;
>> > - /* Art Marker Pen rotation or Airbrush absolute Wheel */
>> > - InitValuatorAxisStruct(pInfo->dev, 5,
>> > -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
>> > -
>> > XIGetKnownProperty(AXIS_LABEL_PROP_ABS_WHEEL),
>> > -#endif
>> > - MIN_ROTATION, maxRotation, 1, 1, 1
>> > -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
>> > - , Absolute
>> > -#endif
>> > - );
>> > - }
>> > - else if ((TabletHasFeature(common, WCM_RING)) && IsPad(priv))
>> > - /* Touch ring */
>> > - InitValuatorAxisStruct(pInfo->dev, 5,
>> > -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
>> > -
>> > XIGetKnownProperty(AXIS_LABEL_PROP_ABS_WHEEL),
>> > -#endif
>> > - 0, 71, 1, 1, 1
>> > -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
>> > - , Absolute
>> > -#endif
>> > - );
>> > + if (!wcmInitAxes(pWcm))
>> > + return FALSE;
>> >
>> > if (IsTouch(priv))
>> > {
>> > --
>> > 1.7.3.3
>
------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel