Nice!

On Mon, Jan 11, 2010 at 03:59:26PM +0000, Przemysław Firszt wrote:
> From 8cdbb16abd0086fd752241b2c25662eb16d37498 Mon Sep 17 00:00:00 2001
> From: Przemo Firszt <prz...@firszt.eu>
> Date: Mon, 11 Jan 2010 15:34:40 +0000
> Subject: [PATCH 5/5] Replace hardcoded rotation tables using function
> 
> Signed-off-by: Przemo Firszt <prz...@firszt.eu>
> ---
>  src/wcmTilt2Rotation.c |  702 
> +-----------------------------------------------
>  1 files changed, 6 insertions(+), 696 deletions(-)
> 
> diff --git a/src/wcmTilt2Rotation.c b/src/wcmTilt2Rotation.c
> index 23fd878..925bbd4 100644
> --- a/src/wcmTilt2Rotation.c
> +++ b/src/wcmTilt2Rotation.c
> @@ -21,673 +21,14 @@
>  #endif
>  
>  #include "xf86Wacom.h"
> +#include <math.h>
>  
> -void wcmTilt2R(WacomDeviceStatePtr ds);
> -
[..]
> -unsigned short tiltTable_63[2] = {
> -     (45 | (20 << 8)),(44 | (19 << 8))
> -};
> +#ifndef M_PI
> +#define M_PI 3.14159265358979323846
> +#endif

Is this necessary? which version of math.h doesn't have M_PI defined?

>  
> -unsigned short tiltTable_64[1] = {
> -     (45 | (19 << 8))
> -};
>  
> -unsigned short *cTable[] = {
> -     
> &tiltTable_00[0],&tiltTable_01[0],&tiltTable_02[0],&tiltTable_03[0],&tiltTable_04[0],&tiltTable_05[0],
> -     
> &tiltTable_06[0],&tiltTable_07[0],&tiltTable_08[0],&tiltTable_09[0],&tiltTable_10[0],&tiltTable_11[0],
> -     
> &tiltTable_12[0],&tiltTable_13[0],&tiltTable_14[0],&tiltTable_15[0],&tiltTable_16[0],&tiltTable_17[0],
> -     
> &tiltTable_18[0],&tiltTable_19[0],&tiltTable_20[0],&tiltTable_21[0],&tiltTable_22[0],&tiltTable_23[0],
> -     
> &tiltTable_24[0],&tiltTable_25[0],&tiltTable_26[0],&tiltTable_27[0],&tiltTable_28[0],&tiltTable_29[0],
> -     
> &tiltTable_30[0],&tiltTable_31[0],&tiltTable_32[0],&tiltTable_33[0],&tiltTable_34[0],&tiltTable_35[0],
> -     
> &tiltTable_36[0],&tiltTable_37[0],&tiltTable_38[0],&tiltTable_39[0],&tiltTable_40[0],&tiltTable_41[0],
> -     
> &tiltTable_42[0],&tiltTable_43[0],&tiltTable_44[0],&tiltTable_45[0],&tiltTable_46[0],&tiltTable_47[0],
> -     
> &tiltTable_48[0],&tiltTable_49[0],&tiltTable_50[0],&tiltTable_51[0],&tiltTable_52[0],&tiltTable_53[0],
> -     
> &tiltTable_54[0],&tiltTable_55[0],&tiltTable_56[0],&tiltTable_57[0],&tiltTable_58[0],&tiltTable_59[0],
> -     
> &tiltTable_60[0],&tiltTable_61[0],&tiltTable_62[0],&tiltTable_63[0],&tiltTable_64[0]
> -};
> +void wcmTilt2R(WacomDeviceStatePtr ds);

weird, how comes this line was moved by the diff?

I like the patch, lines disappearing is always good :) If Ping's tests are
successful, I'll merge it in.

Cheers,
  Peter
>  
>  
> /*****************************************************************************
>   *  wcmTilt2R -
> @@ -700,38 +41,7 @@ void wcmTilt2R(WacomDeviceStatePtr ds)
>       short tilt_x = ds->tiltx;
>       short tilt_y = ds->tilty;
>  
> -     short offset = -180;
> -     unsigned short *xyTable;
> -
> -     if (tilt_x < 0)
> -     {
> -             tilt_x = -tilt_x;
> -             offset *= -1;
> -     }
> -
> -     if (tilt_y <= 0)
> -     {
> -             tilt_y = -tilt_y;
> -             offset *= -1;
> -             offset -= 180;
> -     }
> -
> -     if (tilt_y < tilt_x)
> -     {
> -             short tmp = tilt_x;
> -             tilt_x = tilt_y;
> -             tilt_y = tmp;
> -             offset *= -1;
> -             offset -= 90;
> -     }
> -
> -     xyTable = cTable[tilt_x];
> -     ds->rotation = (xyTable[tilt_y-tilt_x] & 0xFF) + offset;
> -
> -     if (ds->rotation < 0)
> -     {
> -             ds->rotation *= -1;
> -     }
> +     ds->rotation = ABS(round(((180 * atan2(tilt_x,tilt_y)) / M_PI) - 180));
>  
>       /* Intuos4 mouse has an (180-5) offset */
>       ds->rotation = ((360 - ds->rotation + 180 - 5) % 360) * 5;
> -- 
> 1.6.5.7
> 


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to