Since they are normally considered as the tangential pressure,
reporting them in a normalized way helps application developers
downstream.

Signed-off-by: Ping Cheng <[email protected]>
---
 src/wcmUSB.c        |   26 +++++++++++++++++---------
 src/xf86Wacom.c     |    8 ++++----
 src/xf86WacomDefs.h |    3 +++
 3 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/src/wcmUSB.c b/src/wcmUSB.c
index f8836fb..fa06023 100644
--- a/src/wcmUSB.c
+++ b/src/wcmUSB.c
@@ -950,9 +950,11 @@ static void usbParseChannel(LocalDevicePtr local, int 
channel)
                                ds->stripx = event->value; 
                        else if (event->code == ABS_RY)
                                ds->stripy = event->value;
-                       else if (event->code == ABS_RZ) 
-                               ds->rotation = event->value;
-                       else if (event->code == ABS_TILT_X)
+                       else if (event->code == ABS_RZ) {
+                               ds->rotation = event->value - MIN_ROTATION;
+                               ds->rotation *= FILTER_PRESSURE_RES;
+                               ds->rotation /= (MAX_ROTATION - MIN_ROTATION);
+                       } else if (event->code == ABS_TILT_X)
                                ds->tiltx = event->value - 
common->wcmMaxtiltX/2;
                        else if (event->code ==  ABS_TILT_Y)
                                ds->tilty = event->value - 
common->wcmMaxtiltY/2;
@@ -963,12 +965,18 @@ static void usbParseChannel(LocalDevicePtr local, int 
channel)
                                        ds->pressure = event->value;
                        } else if (event->code == ABS_DISTANCE)
                                ds->distance = event->value;
-                       else if (event->code == ABS_WHEEL || 
-                                   event->code == ABS_Z)
-                               ds->abswheel = event->value;
-                       else if (event->code == ABS_THROTTLE)
-                               ds->throttle = event->value;
-                       else if (event->code == ABS_MISC && event->value)
+                       else if (event->code == ABS_WHEEL) {
+                               ds->abswheel = event->value * 
FILTER_PRESSURE_RES;
+                               ds->abswheel /= MAX_ABS_WHEEL;
+                       } else if (event->code == ABS_Z) {
+                               ds->abswheel = event->value - MIN_ROTATION;
+                               ds->abswheel *= FILTER_PRESSURE_RES;
+                               ds->abswheel /= (MAX_ROTATION - MIN_ROTATION);
+                       } else if (event->code == ABS_THROTTLE) {
+                               ds->throttle = event->value + MAX_ABS_WHEEL;
+                               ds->throttle *= FILTER_PRESSURE_RES;
+                               ds->throttle /= (2 * MAX_ABS_WHEEL);
+                       } else if (event->code == ABS_MISC && event->value)
                                ds->device_id = event->value;
                }
                else if (event->type == EV_REL)
diff --git a/src/xf86Wacom.c b/src/xf86Wacom.c
index 1cfca5e..1424cf1 100644
--- a/src/xf86Wacom.c
+++ b/src/xf86Wacom.c
@@ -780,12 +780,12 @@ static int wcmRegisterX11Devices (LocalDevicePtr local)
 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
                XIGetKnownProperty(AXIS_LABEL_PROP_ABS_RZ),
 #endif
-               -900, 899, 1, 1, 1);
+               0, FILTER_PRESSURE_RES, 1, 1, 1);
                InitValuatorAxisStruct(local->dev, 4,
 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
                XIGetKnownProperty(AXIS_LABEL_PROP_ABS_THROTTLE),
 #endif
-               -1023, 1023, 1, 1, 1);
+               0, FILTER_PRESSURE_RES, 1, 1, 1);
        }
        else if (IsPad(priv))
        {
@@ -825,7 +825,7 @@ static int wcmRegisterX11Devices (LocalDevicePtr local)
 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
                                0, /* XXX what is this axis?*/
 #endif
-                               -900, 899, 1, 1, 1);
+                               0, FILTER_PRESSURE_RES, 1, 1, 1);
        else if ((TabletHasFeature(common, WCM_RING)) && IsPad(priv))
                /* Touch ring */
                InitValuatorAxisStruct(local->dev, 5,
@@ -840,7 +840,7 @@ static int wcmRegisterX11Devices (LocalDevicePtr local)
 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
                                XIGetKnownProperty(AXIS_LABEL_PROP_ABS_WHEEL),
 #endif
-                               0, 1023, 1, 1, 1);
+                               0, FILTER_PRESSURE_RES, 1, 1, 1);
        }
 
        if (IsTouch(priv))
diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h
index 363954e..d9afdc6 100644
--- a/src/xf86WacomDefs.h
+++ b/src/xf86WacomDefs.h
@@ -35,6 +35,9 @@
 #define MAX_SUPPRESS 100        /* max value of suppress */
 #define BUFFER_SIZE 256         /* size of reception buffer */
 #define MAXTRY 3                /* max number of try to receive magic number */
+#define MIN_ROTATION  -900      /* the minimum value of the marker pen 
rotation */
+#define MAX_ROTATION   899      /* the maximum value of the marker pen 
rotation */
+#define MAX_ABS_WHEEL 1023      /* the maximum value of absolute wheel */
 
 /* Default max distance to the tablet at which a proximity-out event is 
generated for
  * cursor device (e.g. mouse). 
-- 
1.6.6.1


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to