From f32c827d513c44f07e1d0fbcc0c96cef18c9a4d9 Mon Sep 17 00:00:00 2001 From: Max Schwarz Date: Sun, 25 Sep 2011 20:44:26 +0200 Subject: Input: Fix frac calculation on [Raw]DeviceEvent conversion (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 Signed-off-by: Peter Hutterer --- dix/eventconvert.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'dix/eventconvert.c') diff --git a/dix/eventconvert.c b/dix/eventconvert.c index 9cc177efc..f9aafa5d1 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++; } -- cgit v1.2.3