summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2011-03-02 13:29:24 +0000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-09-29 12:23:51 +1000
commit3463078f9697fad0ee11837d80e88889fc6a28a4 (patch)
tree76c545c832c0a0f65d806f0bd1e1d22fe6a3d740
parent4e52cc0ef48145134cd58d357fb7289e6f8bb709 (diff)
Input: Convert clipAxis, moveAbsolute and moveRelative to double
Change all these three to use doubles internally, though the outputs of moveAbsolute and moveRelative are still truncated to int. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
-rw-r--r--dix/getevents.c48
1 files changed, 25 insertions, 23 deletions
diff --git a/dix/getevents.c b/dix/getevents.c
index fd8b0988a..30044bae8 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -617,7 +617,7 @@ GetMaximumEventsNum(void) {
* InitValuatorAxisClassStruct.
*/
static void
-clipAxis(DeviceIntPtr pDev, int axisNum, int *val)
+clipAxis(DeviceIntPtr pDev, int axisNum, double *val)
{
AxisInfoPtr axis;
@@ -647,9 +647,9 @@ clipValuators(DeviceIntPtr pDev, ValuatorMask *mask)
for (i = 0; i < valuator_mask_size(mask); i++)
if (valuator_mask_isset(mask, i))
{
- int val = valuator_mask_get(mask, i);
+ double val = valuator_mask_get_double(mask, i);
clipAxis(pDev, i, &val);
- valuator_mask_set(mask, i, val);
+ valuator_mask_set_double(mask, i, val);
}
}
@@ -699,17 +699,18 @@ static void
moveAbsolute(DeviceIntPtr dev, int *x_out, int *y_out, ValuatorMask *mask)
{
int i;
- int x, y;
for (i = 0; i < valuator_mask_size(mask); i++)
{
- if (valuator_mask_isset(mask, i))
- {
- int val = valuator_mask_get(mask, i);
- clipAxis(dev, i, &val);
- dev->last.valuators[i] = val;
- valuator_mask_set(mask, i, val);
- }
+ double val;
+
+ if (!valuator_mask_isset(mask, i))
+ continue;
+ val = valuator_mask_get_double(mask, i);
+ clipAxis(dev, i, &val);
+ dev->last.valuators[i] = trunc(val);
+ dev->last.remainder[i] = val - trunc(val);
+ valuator_mask_set_double(mask, i, val);
}
*x_out = dev->last.valuators[0];
@@ -733,18 +734,19 @@ moveRelative(DeviceIntPtr dev, int *x_out, int *y_out, ValuatorMask *mask)
/* calc other axes, clip, drop back into valuators */
for (i = 0; i < valuator_mask_size(mask); i++)
{
- if (valuator_mask_isset(mask, i))
- {
- int val = dev->last.valuators[i];
- val += valuator_mask_get(mask, i);
- /* x & y need to go over the limits to cross screens if the SD
- * isn't currently attached; otherwise, clip to screen bounds. */
- if (valuator_get_mode(dev, i) == Absolute &&
- ((i != 0 && i != 1) || clip_xy))
- clipAxis(dev, i, &val);
- dev->last.valuators[i] = val;
- valuator_mask_set(mask, i, val);
- }
+ double val = dev->last.valuators[i] + dev->last.remainder[i];
+
+ if (!valuator_mask_isset(mask, i))
+ continue;
+ val += valuator_mask_get_double(mask, i);
+ /* x & y need to go over the limits to cross screens if the SD
+ * isn't currently attached; otherwise, clip to screen bounds. */
+ if (valuator_get_mode(dev, i) == Absolute &&
+ ((i != 0 && i != 1) || clip_xy))
+ clipAxis(dev, i, &val);
+ dev->last.valuators[i] = trunc(val);
+ dev->last.remainder[i] = val - trunc(val);
+ valuator_mask_set_double(mask, i, val);
}
*x_out = dev->last.valuators[0];