[PATCH] Input: Fix frac calculation on [Raw]DeviceEvent conversion

Peter Hutterer peter.hutterer at who-t.net
Wed Sep 28 22:32:49 PDT 2011


On Sun, Sep 25, 2011 at 08:44:26PM +0200, Max Schwarz wrote:
> (1UL << 32) evaluates to 0 (at least here), so do the
> fraction calculation in two steps as in libXi. Fractions on xXIRawEvent
> were not multiplied at all, which also gave 0 as result.
> 
> Signed-off-by: Max Schwarz <Max at x-quadraht.de>
> ---
> Hi,
> 
> I noticed a problem (see patch) with Daniel Stone's patch
> [PATCH 22/28] Input: Make DeviceEvent use doubles internally
> from june.
> I'm CCing Peter as well, as I noticed the problem on his next-all
> branch. The patch is based on there.
> 
> Best regards,
>   Max
> 
>  dix/eventconvert.c |   10 ++++++----
>  1 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/dix/eventconvert.c b/dix/eventconvert.c
> index 9cc177e..9eb0771 100644
> --- a/dix/eventconvert.c
> +++ b/dix/eventconvert.c
> @@ -635,7 +635,7 @@ eventToDeviceEvent(DeviceEvent *ev, xEvent **xi)
>              SetBit(ptr, i);
>              axisval->integral = trunc(ev->valuators.data[i]);
>              axisval->frac = (ev->valuators.data[i] - axisval->integral) *
> -                            (1UL << 32);
> +                            (1 << 16) * (1 << 16);
>              axisval++;
>          }
>      }
> @@ -679,10 +679,12 @@ eventToRawEvent(RawDeviceEvent *ev, xEvent **xi)
>          {
>              SetBit(ptr, i);
>              axisval->integral = trunc(ev->valuators.data[i]);
> -            axisval->frac = ev->valuators.data[i] - axisval->integral;
> +            axisval->frac = (ev->valuators.data[i] - axisval->integral) *
> +                            (1 << 16) * (1 << 16);
>              axisval_raw->integral = trunc(ev->valuators.data_raw[i]);
> -            axisval_raw->frac = ev->valuators.data_raw[i] -
> -                                axisval_raw->integral;
> +            axisval_raw->frac =
> +                (ev->valuators.data_raw[i] - axisval_raw->integral) *
> +                  (1 << 16) * (1 << 16);
>              axisval++;
>              axisval_raw++;
>          }
> -- 
> 1.7.4.1

merged, thank you

Cheers,
  Peter


More information about the xorg-devel mailing list