[PATCH 12/27] Input: Set fractional member in set_raw_valuators
Daniel Stone
daniel at fooishbar.org
Fri Jun 3 07:59:48 PDT 2011
RawDeviceEvents have space for fractional valuator members, so might as
well start using them.
Signed-off-by: Daniel Stone <daniel at fooishbar.org>
---
dix/getevents.c | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/dix/getevents.c b/dix/getevents.c
index 1f145ac..2afe1a1 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -179,16 +179,20 @@ init_raw(DeviceIntPtr dev, RawDeviceEvent *event, Time ms, int type, int detail)
}
static void
-set_raw_valuators(RawDeviceEvent *event, ValuatorMask *mask, int32_t* data)
+set_raw_valuators(RawDeviceEvent *event, ValuatorMask *mask, int32_t* data,
+ int32_t* data_frac)
{
int i;
+ double val;
for (i = 0; i < valuator_mask_size(mask); i++)
{
if (valuator_mask_isset(mask, i))
{
SetBit(event->valuators.mask, i);
- data[i] = valuator_mask_get(mask, i);
+ val = valuator_mask_get_double(mask, i);
+ data[i] = round_towards_zero(val);
+ data_frac[i] = (val - data[i]) * (1UL << 32);
}
}
}
@@ -980,11 +984,13 @@ GetKeyboardEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
valuator_mask_copy(&mask, mask_in);
init_raw(pDev, raw, ms, type, key_code);
- set_raw_valuators(raw, &mask, raw->valuators.data_raw);
+ set_raw_valuators(raw, &mask, raw->valuators.data_raw,
+ raw->valuators.data_raw_frac);
clipValuators(pDev, &mask);
- set_raw_valuators(raw, &mask, raw->valuators.data);
+ set_raw_valuators(raw, &mask, raw->valuators.data,
+ raw->valuators.data_frac);
event = &events->device_event;
init_event(pDev, event, ms);
@@ -1129,7 +1135,8 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons
valuator_mask_copy(&mask, mask_in);
init_raw(pDev, raw, ms, type, buttons);
- set_raw_valuators(raw, &mask, raw->valuators.data_raw);
+ set_raw_valuators(raw, &mask, raw->valuators.data_raw,
+ raw->valuators.data_raw_frac);
if (flags & POINTER_ABSOLUTE)
{
@@ -1177,7 +1184,8 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons
moveRelative(pDev, &x, &y, &mask);
}
- set_raw_valuators(raw, &mask, raw->valuators.data);
+ set_raw_valuators(raw, &mask, raw->valuators.data,
+ raw->valuators.data_frac);
positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative,
&x, &y, x_frac, y_frac, scr, &cx, &cy, &cx_frac, &cy_frac);
--
1.7.5.3
More information about the xorg-devel
mailing list