From d4f6b48e80e18404bb3a48d5861f3e6998d179a8 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Wed, 3 Apr 2019 16:43:30 +1100
Subject: [PATCH] wintab32: Scale NormalPressure before sending to the client.

We need to workout how to get valid Min/Max Pressure values that are the
same value as windows.
---
 dlls/winex11.drv/wintab.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/dlls/winex11.drv/wintab.c b/dlls/winex11.drv/wintab.c
index 3517bd5..5e823e1 100644
--- a/dlls/winex11.drv/wintab.c
+++ b/dlls/winex11.drv/wintab.c
@@ -925,7 +925,11 @@ static BOOL motion_event( HWND hwnd, XEvent *event )
         FIXME("Negative orAltitude detected\n");
         return FALSE;
     }
-    gMsgPacket.pkNormalPressure = motion->axis_data[2];
+    /* Scale the value sent from XInput 0-65536
+     * Windows                          0-1023
+     */
+    gMsgPacket.pkNormalPressure = ((motion->axis_data[2] - gSysDevice.NPRESSURE.axMin) /
+                        ((float)gSysDevice.NPRESSURE.axMax - gSysDevice.NPRESSURE.axMin)) * 1023;
     gMsgPacket.pkButtons = get_button_state(curnum);
     gMsgPacket.pkChanged = get_changed_state(&gMsgPacket);
     SendMessageW(hwndTabletDefault,WT_PACKET,gMsgPacket.pkSerialNumber,(LPARAM)hwnd);
@@ -1009,7 +1013,11 @@ static BOOL proximity_event( HWND hwnd, XEvent *event )
         FIXME("Negative orAltitude detected\n");
         return FALSE;
     }
-    gMsgPacket.pkNormalPressure = proximity->axis_data[2];
+    /* Scale the value sent from XInput 0-65536
+     * Windows                          0-1023
+     */
+    gMsgPacket.pkNormalPressure = ((proximity->axis_data[2] - gSysDevice.NPRESSURE.axMin) /
+                        ((float)gSysDevice.NPRESSURE.axMax - gSysDevice.NPRESSURE.axMin)) * 1023;
     gMsgPacket.pkButtons = get_button_state(curnum);
 
     /* FIXME: LPARAM loword is true when cursor entering context, false when leaving context
-- 
1.9.1

