And copy the server's xf86ScaleAxis for the test. Not ideal, I guess but oh
well.

Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
---
 src/wcmCommon.c     |    8 +++++---
 test/fake-symbols.c |   19 ++++++++++++++++++-
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/src/wcmCommon.c b/src/wcmCommon.c
index 315aa4e..47deba4 100644
--- a/src/wcmCommon.c
+++ b/src/wcmCommon.c
@@ -1124,9 +1124,11 @@ normalizePressure(const WacomDevicePtr priv, const 
WacomDeviceState *ds)
                p = priv->minPressure;
        }
 
-       /* normalize pressure to FILTER_PRESSURE_RES */
-       pressure = (p - priv->minPressure) * FILTER_PRESSURE_RES;
-       pressure /= (common->wcmMaxZ - priv->minPressure);
+       /* normalize pressure to 0..FILTER_PRESSURE_RES */
+       pressure = xf86ScaleAxis(p - priv->minPressure,
+                                FILTER_PRESSURE_RES, 0,
+                                common->wcmMaxZ - priv->minPressure,
+                                0);
 
        return (int)pressure;
 }
diff --git a/test/fake-symbols.c b/test/fake-symbols.c
index 83f13cc..8f6241c 100644
--- a/test/fake-symbols.c
+++ b/test/fake-symbols.c
@@ -121,7 +121,24 @@ xf86ScaleAxis(int  Cx,
               int      from_max,
               int      from_min )
 {
-    return 0;
+    int X;
+    int64_t to_width = to_max - to_min;
+    int64_t from_width = from_max - from_min;
+
+    if (from_width) {
+       X = (int)(((to_width * (Cx - from_min)) / from_width) + to_min);
+    }
+    else {
+       X = 0;
+        /*ErrorF ("Divide by Zero in xf86ScaleAxis\n");*/
+    }
+
+    if (X > to_max)
+       X = to_max;
+    if (X < to_min)
+       X = to_min;
+
+    return X;
 }
 
 
-- 
1.7.4


------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to