[PATCH 05/28] Input: Convert ValuatorMask to double-precision internally

Daniel Stone daniel at fooishbar.org
Thu Jun 9 10:17:13 PDT 2011


Switch the ValuatorMask struct to using doubles instead of ints for the
actual values.  Preserve the old int API, and (attempt to) round towards
zero for values we return.

Signed-off-by: Daniel Stone <daniel at fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 dix/inpututils.c     |    4 ++--
 include/inpututils.h |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/dix/inpututils.c b/dix/inpututils.c
index 49e1758..20132d5 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -514,7 +514,7 @@ valuator_mask_set(ValuatorMask *mask, int valuator, int data)
 int
 valuator_mask_get(const ValuatorMask *mask, int valuator)
 {
-    return mask->valuators[valuator];
+    return trunc(mask->valuators[valuator]);
 }
 
 /**
@@ -527,7 +527,7 @@ valuator_mask_unset(ValuatorMask *mask, int valuator)
         int i, lastbit = -1;
 
         ClearBit(mask->mask, valuator);
-        mask->valuators[valuator] = 0;
+        mask->valuators[valuator] = 0.0;
 
         for (i = 0; i <= mask->last_bit; i++)
             if (valuator_mask_isset(mask, i))
diff --git a/include/inpututils.h b/include/inpututils.h
index 92a7543..4d02125 100644
--- a/include/inpututils.h
+++ b/include/inpututils.h
@@ -34,7 +34,7 @@
 struct _ValuatorMask {
     int8_t      last_bit; /* highest bit set in mask */
     uint8_t     mask[(MAX_VALUATORS + 7)/8];
-    int         valuators[MAX_VALUATORS]; /* valuator data */
+    double      valuators[MAX_VALUATORS]; /* valuator data */
 };
 
 extern void verify_internal_event(const InternalEvent *ev);
-- 
1.7.5.3



More information about the xorg-devel mailing list