I've not been able to fully keep up or understand logic related to
abswheel but I have a generic comment anyways.

It doesn't surprise me we may need a device_id to fully resolve
this... but I think we should keep hardware specific logic as close to
reading from hardware as possible.  In this case it would be
usbParseAbsEvent().  I'm talking about using same if(isStylus) and
if(device_id)'s but just different location.

If we want the core to normalize then I'd create
priv->asbwheel_min/max/etc so that the same normalization logic can
always be performed regardless of tool/hw.  You still need same if()'s
but they are only needed at init phase instead of runtime.

Chris

On Mon, Nov 29, 2010 at 11:35 AM, Ping Cheng <[email protected]> wrote:
> Due to the limitation of number of valators we can use, Airbrush
> wheel and Art Pen rotation share the same fifth valuator. But
> they do not have the same range of values. So, we normalize the
> airbrush wheel (0, 1023) to the Art Pen rotation (-900, 899).
>
> Signed-off-by: Ping Cheng <[email protected]>
> ---
>  src/wcmCommon.c |   16 ++++++++++++++--
>  src/wcmUSB.c    |    9 ++-------
>  2 files changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/src/wcmCommon.c b/src/wcmCommon.c
> index 8050600..a006a9a 100644
> --- a/src/wcmCommon.c
> +++ b/src/wcmCommon.c
> @@ -629,7 +629,7 @@ void wcmSendEvents(InputInfoPtr pInfo, const 
> WacomDeviceState* ds)
>        if (ds->proximity)
>                wcmRotateAndScaleCoordinates(pInfo, &x, &y);
>
> -       if (IsCursor(priv))
> +       if (IsCursor(priv))
>        {
>                v3 = ds->rotation;
>                v4 = ds->throttle;
> @@ -639,8 +639,20 @@ void wcmSendEvents(InputInfoPtr pInfo, const 
> WacomDeviceState* ds)
>                v3 = tx;
>                v4 = ty;
>        }
> -       v5 = ds->abswheel;
>
> +       if (IsStylus(priv))
> +       {
> +               /* Normalize abswheel airbrush data to Art Pen rotation range.
> +                * The test below is for Art Pen. We do not normalize them
> +                * since they are already at the range.
> +               */
> +               if (ds->device_id != 0x885 && ds->device_id != 0x804)
> +                       v5 = ds->abswheel * MAX_ROTATION_RANGE/
> +                               (double)MAX_ABS_WHEEL + MIN_ROTATION;
> +       }
> +       else
> +               v5 = ds->abswheel;
> +
>        DBG(6, priv, "%s prox=%d\tx=%d"
>                "\ty=%d\tz=%d\tv3=%d\tv4=%d\tv5=%d\tid=%d"
>                "\tserial=%u\tbutton=%s\tbuttons=%d\n",
> diff --git a/src/wcmUSB.c b/src/wcmUSB.c
> index 90e8cf6..01b34f1 100644
> --- a/src/wcmUSB.c
> +++ b/src/wcmUSB.c
> @@ -816,13 +816,8 @@ static int usbParseAbsEvent(WacomCommonPtr common,
>                        ds->distance = event->value;
>                        break;
>                case ABS_WHEEL:
> -                       {
> -                               double norm = event->value *
> -                                       MAX_ROTATION_RANGE /
> -                                       (double)MAX_ABS_WHEEL;
> -                               ds->abswheel = (int)norm + MIN_ROTATION;
> -                               break;
> -                       }
> +                       ds->abswheel = event->value;
> +                       break;
>                case ABS_Z:
>                        ds->abswheel = event->value;
>                        break;
> --
> 1.7.2.3
>

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to