On Thu, Mar 10, 2011 at 1:04 PM, Peter Hutterer <peter.hutte...@who-t.net>wrote:
> Because not everyone has hours to figure out what each function does.
> Come to think of it, I don't actually either...
>
> Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
> ---
> src/wcmFilter.c | 34 +++++++++++++++++++++++++++++-----
> 1 files changed, 29 insertions(+), 5 deletions(-)
>
> diff --git a/src/wcmFilter.c b/src/wcmFilter.c
> index 731df4c..ba50877 100644
> --- a/src/wcmFilter.c
> +++ b/src/wcmFilter.c
> @@ -313,12 +313,29 @@ int wcmFilterCoord(WacomCommonPtr common,
> WacomChannelPtr pChannel,
> return 0; /* lookin' good */
> }
>
>
> -/*****************************************************************************
> - * wcmTilt2R -
> - * Converts tilt X and Y to rotation, for Intuos4 mouse for now.
> - * It can be used for other devices when necessary.
> -
> ****************************************************************************/
> +/***
> + * Convert tilt X and Y to rotation
> + *
> + * This function is currently called for the Intuos4 mouse (cursor) tool
> + * only, but it may be used for other devices in the future.
> + *
> + * Method used: rotation angle is calculated through the atan of the
> tiltx/y
> + * coordinates, then converted to degrees and normalized into the rotation
> + * range (MIN_ROTATION/MAX_ROTATION).
>
> + * IMPORTANT: calculation inverts direction, the formula to get the target
> + * rotation value in degrees is: 360 - offset - input-angle.
> + *
> + * Example table of return values for an offset of 0, assuming a
> left-handed
> + * coordinate system:
> + * input 0 degrees: MIN
> + * 90 degrees: MAX - RANGE/4
> + * 180 degrees: RANGE/2
> + * 270 degrees: MIN + RANGE/4
> + *
> + * @param ds The current device state, will be modified to set to the
> + * calculated rotation value.
> + */
> void wcmTilt2R(WacomDeviceStatePtr ds)
> {
> short tilt_x = ds->tiltx;
> @@ -327,16 +344,23 @@ void wcmTilt2R(WacomDeviceStatePtr ds)
>
> /* other tilt-enabled devices need to apply round() after this call
> */
> if (tilt_x || tilt_y)
> + /* rotate in the inverse direction, changing CW to CCW
> + * rotation and vice versa */
> rotation = ((180.0 * atan2(-tilt_x,tilt_y)) / M_PI) + 180.0;
>
> /* Intuos4 mouse has an (180-5) offset */
> ds->rotation = round((360.0 - rotation + 180.0 - 5.0) * 5.0);
> ds->rotation %= 1800;
>
> + /* ds->rotation now normalised into 0 - MAX, but we want MIN - MAX
> + * with 180 degrees (ignoring offset) being at 0 (for whatever
> + * reason we need this) */
> if (ds->rotation >= 900)
> ds->rotation = 1800 - ds->rotation;
> else
> ds->rotation = -ds->rotation;
> +
> + /* FIXME: shouldn't we reset tilt? */
>
Since tilt is only used as raw value to calculate rotation for I4 mouse,
i.e., they are not posted as valuators, resetting them or not does not make
a difference.
Acked-by: Ping Cheng <pingli...@gmail.com> for the whole series.
Thank you.
Ping
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel