summaryrefslogtreecommitdiff
path: root/dix/inpututils.c
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2011-02-23 17:28:18 +0000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-09-29 12:23:51 +1000
commit7e919ef5bfa94d51a06eefb150ab947bdbfb6885 (patch)
treef1d82588a3283549455df9005c33ff9008462637 /dix/inpututils.c
parent79d4deb76d5612b75ef26b4549b7ade3a656687d (diff)
Input: Add double-precision valuator_mask API
Add API for valuator_mask that accepts and returns doubles, rather than ints. No double API is provided for set_range at the moment. Signed-off-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'dix/inpututils.c')
-rw-r--r--dix/inpututils.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/dix/inpututils.c b/dix/inpututils.c
index 1c4af8e5e..0a3d3d8b4 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -497,10 +497,10 @@ valuator_mask_isset(const ValuatorMask *mask, int valuator)
}
/**
- * Set the valuator to the given data.
+ * Set the valuator to the given floating-point data.
*/
void
-valuator_mask_set(ValuatorMask *mask, int valuator, int data)
+valuator_mask_set_double(ValuatorMask *mask, int valuator, double data)
{
mask->last_bit = max(valuator, mask->last_bit);
SetBit(mask->mask, valuator);
@@ -508,13 +508,33 @@ valuator_mask_set(ValuatorMask *mask, int valuator, int data)
}
/**
- * Return the requested valuator value. If the mask bit is not set for the
- * given valuator, the returned value is undefined.
+ * Set the valuator to the given integer data.
+ */
+void
+valuator_mask_set(ValuatorMask *mask, int valuator, int data)
+{
+ valuator_mask_set_double(mask, valuator, data);
+}
+
+/**
+ * Return the requested valuator value as a double. If the mask bit is not
+ * set for the given valuator, the returned value is undefined.
+ */
+double
+valuator_mask_get_double(const ValuatorMask *mask, int valuator)
+{
+ return mask->valuators[valuator];
+}
+
+/**
+ * Return the requested valuator value as an integer, rounding towards zero.
+ * If the mask bit is not set for the given valuator, the returned value is
+ * undefined.
*/
int
valuator_mask_get(const ValuatorMask *mask, int valuator)
{
- return trunc(mask->valuators[valuator]);
+ return trunc(valuator_mask_get_double(mask, valuator));
}
/**