wintab: fixing pkChange value in packets

Eriks Dobelis eriks.dobelis at biti.lv
Mon Mar 24 03:19:19 CDT 2014


This is one of the patches to fix 
http://bugs.winehq.org/show_bug.cgi?id=18517 and enable pressure 
sensitivity in Photoshop CS4+

There is a field pkChange in packets, which should have bits set 
accordingly to the values, which have changed since last packet. 
Currently, it is not set. Seems that Photoshop CS4 is using the field. 
The change introduces a struct to keep values sent in the previous 
packet and sets pkChange according to changes.


  dlls/winex11.drv/wintab.c | 61 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1 file changed, 61 insertions(+)

-------------- next part --------------
>From da3b14fa7c5b088bd5d191197187237aa15ddd73 Mon Sep 17 00:00:00 2001
From: Eriks Dobelis <eriks.dobelis at biti.lv>
Date: Mon, 24 Mar 2014 09:32:38 +0200
Subject: [PATCH 3/5] Implementing sending of pkChange value

---
 dlls/winex11.drv/wintab.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/dlls/winex11.drv/wintab.c b/dlls/winex11.drv/wintab.c
index a1aae49..a45f9ff 100644
--- a/dlls/winex11.drv/wintab.c
+++ b/dlls/winex11.drv/wintab.c
@@ -250,6 +250,16 @@ typedef struct tagWTPACKET {
         ROTATION pkRotation; /* 1.1 */
 } WTPACKET, *LPWTPACKET;
 
+typedef struct {
+    UINT          status;
+    DWORD         x;
+    DWORD         y;
+    UINT          normalPressure;
+    DWORD         buttons;
+    UINT          cursor;
+    ORIENTATION   orientation;
+    ROTATION      rotation;    
+} lastValues;
 
 #ifdef SONAME_LIBXI
 
@@ -267,6 +277,16 @@ static int           proximity_out_type;
 static HWND          hwndTabletDefault;
 static WTPACKET      gMsgPacket;
 static DWORD         gSerial;
+static lastValues    last = {
+    .status = 0xffff,
+    .x = 0xffff,
+    .y = 0xffff,
+    .normalPressure = 0xffff,
+    .buttons = 0xffff,
+    .cursor = 0xffff,
+    .orientation = {.orAzimuth = 0xffff, .orAltitude = 0xffff, .orTwist = 0xffff },
+    .rotation = {.roPitch = 0xffff, .roRoll = 0xffff, .roYaw = 0xffff }    
+};
 
 /* Reference: http://www.wacomeng.com/devsupport/ibmpc/gddevpc.html
  *
@@ -847,6 +867,44 @@ static int cursor_from_device(DWORD deviceid, LPWTI_CURSORS_INFO *cursorp)
     return -1;
 }
 
+static DWORD setChanged( WTPACKET *pkt) {
+    DWORD change = 0;
+    if (pkt -> pkStatus != last.status) {
+        change |= PK_STATUS;
+        last.status = pkt->pkStatus;
+    }
+    if (pkt -> pkX != last.x) {
+        change |= PK_X;
+        last.x = pkt->pkX;
+    }
+    if (pkt -> pkY != last.y) {
+        change |= PK_Y;
+        last.y = pkt->pkY;
+    }
+    if (pkt -> pkNormalPressure != last.normalPressure) {
+        change |= PK_NORMAL_PRESSURE;
+        last.normalPressure = pkt->pkNormalPressure;
+    }
+    if (pkt -> pkCursor != last.cursor) {
+        change |= PK_CURSOR;
+        last.cursor = pkt->pkCursor;
+    }
+    if (pkt -> pkButtons != last.buttons) {
+        change |= PK_BUTTONS;
+        last.buttons = pkt->pkButtons;
+    }
+    if (memcmp(&pkt -> pkOrientation, &last.orientation, sizeof(ORIENTATION)) != 0) {
+        change |= PK_ORIENTATION;
+        last.orientation = pkt->pkOrientation;
+    }
+    if (memcmp(&pkt -> pkRotation, &last.rotation, sizeof(ROTATION)) != 0) {
+        change |= PK_ROTATION;
+        last.rotation = pkt->pkRotation;
+    }
+
+    return change; 
+}
+
 static void motion_event( HWND hwnd, XEvent *event )
 {
     XDeviceMotionEvent *motion = (XDeviceMotionEvent *)event;
@@ -873,6 +931,7 @@ static void motion_event( HWND hwnd, XEvent *event )
                                            * (gMsgPacket.pkStatus & TPS_INVERT?-1:1));
     gMsgPacket.pkNormalPressure = motion->axis_data[2];
     gMsgPacket.pkButtons = get_button_state(curnum);
+    gMsgPacket.pkChanged = setChanged(&gMsgPacket);    
     SendMessageW(hwndTabletDefault,WT_PACKET,gMsgPacket.pkSerialNumber,(LPARAM)hwnd);
 }
 
@@ -902,6 +961,7 @@ static void button_event( HWND hwnd, XEvent *event )
                                            * (gMsgPacket.pkStatus & TPS_INVERT?-1:1));
     gMsgPacket.pkNormalPressure = button->axis_data[2];
     gMsgPacket.pkButtons = get_button_state(curnum);
+    gMsgPacket.pkChanged = setChanged(&gMsgPacket);    
     SendMessageW(hwndTabletDefault,WT_PACKET,gMsgPacket.pkSerialNumber,(LPARAM)hwnd);
 }
 
@@ -941,6 +1001,7 @@ static void proximity_event( HWND hwnd, XEvent *event )
                                            * (gMsgPacket.pkStatus & TPS_INVERT?-1:1));
     gMsgPacket.pkNormalPressure = proximity->axis_data[2];
     gMsgPacket.pkButtons = get_button_state(curnum);
+    //gMsgPacket.pkChanged = setChanged(&gMsgPacket);    
 
     /* FIXME: LPARAM loword is true when cursor entering context, false when leaving context
      * This needs to be handled here or in wintab32.  Using the proximity_in_type is not correct
-- 
1.8.3.2



More information about the wine-patches mailing list