*/}}
Forráskód Böngészése

Enable wacom Z (hover) info in windows

YimingWu 6 hónapja
szülő
commit
5c00434359
2 módosított fájl, 11 hozzáadás és 6 törlés
  1. 3 3
      la_interface.h
  2. 8 3
      la_kernel.c

+ 3 - 3
la_interface.h

@@ -224,7 +224,7 @@ STRUCTURE(laEvent){
     uint32_t Input;
 
     int GoodPressure,IsEraser,HasTwist;
-    real Pressure,Orientation,Deviation,Twist;
+    real Pressure,Orientation,Deviation,Twist,Hover;
 
     void *Localized;
 };
@@ -395,7 +395,7 @@ STRUCTURE(LA){
 #ifdef _WIN32
     HINSTANCE hinstance;
     HDC hdc;
-    int WinTabAvailable, WinTabOpened, WinTabMaxPenPressure, WinTabMaxEraserPressure;
+    int WinTabAvailable, WinTabOpened, WinTabMaxPenPressure, WinTabMaxEraserPressure, WinTabMaxHover;
 #endif
 #ifdef __linux__
     Window* win;
@@ -414,7 +414,7 @@ STRUCTURE(LA){
     int InkOrWinTab;
     int WacomDeviceStylus; real StylusPressure, StylusOrientation, StylusDeviation, StylusMaxPressure;
     int WacomDeviceEraser; real EraserPressure, EraserOrientation, EraserDeviation, EraserMaxPressure;
-    int StylusHasTwist; real StylusTwist;
+    int StylusHasTwist; real StylusTwist; real StylusHover;
     int PointerIsEraser,IsPen;
     int evLastX,evLastY;
 

+ 8 - 3
la_kernel.c

@@ -268,7 +268,7 @@ void la_DestroySystemWindowX11(laWindow* w) {
 #include <msgdef.h>
 #include <wintab.h>
 #include <wintab_utils.h>
-#define PACKETDATA	(PK_X | PK_Y | PK_STATUS | PK_BUTTONS | PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE | PK_ORIENTATION | PK_TIME | PK_CURSOR)
+#define PACKETDATA	(PK_X | PK_Y | PK_Z | PK_STATUS | PK_BUTTONS | PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE | PK_ORIENTATION | PK_TIME | PK_CURSOR)
 #define PACKETMODE	PK_BUTTONS
 #include <pktdef.h>
 
@@ -279,7 +279,7 @@ void la_OpenWacomWinTab(HWND hwnd){
 
     HCTX hctx = NULL;
 	UINT wDevice = 0; UINT wExtX = 0; UINT wExtY = 0;
-	UINT wWTInfoRetVal = 0; AXIS TabletX = { 0 }; AXIS TabletY = { 0 };
+	UINT wWTInfoRetVal = 0; AXIS TabletX = { 0 }; AXIS TabletY = { 0 }; AXIS TabletZ = { 0 };
 
 	glogContext.lcOptions |= CXO_SYSTEM;
 	wWTInfoRetVal = gpWTInfoA(WTI_DEFSYSCTX, 0, &glogContext);
@@ -299,6 +299,10 @@ void la_OpenWacomWinTab(HWND hwnd){
 	wWTInfoRetVal = gpWTInfoA(WTI_DEVICES, DVC_Y, &TabletY);
 	assert(wWTInfoRetVal == sizeof(AXIS));
 
+    wWTInfoRetVal = gpWTInfoA(WTI_DEVICES, DVC_Z, &TabletZ);
+    assert(wWTInfoRetVal == sizeof(AXIS));
+    MAIN.WinTabMaxHover = TabletZ.axMax;
+
     AXIS tabletPressure = { 0 };
     gpWTInfoA(WTI_DEVICES, DVC_NPRESSURE, &tabletPressure); MAIN.WinTabMaxPenPressure = tabletPressure.axMax + 1;
 
@@ -1787,7 +1791,7 @@ void la_SaveEvent(SYSWINDOW hwnd, laEvent *e, int use_last_pos){
     e->Pressure=MAIN.IsPen?(MAIN.PointerIsEraser?MAIN.EraserPressure:MAIN.StylusPressure):0.5f;
     e->Orientation=MAIN.PointerIsEraser?MAIN.EraserOrientation:MAIN.StylusOrientation;
     e->Deviation=MAIN.PointerIsEraser?MAIN.EraserDeviation:MAIN.StylusDeviation;
-    e->IsEraser=MAIN.PointerIsEraser;
+    e->IsEraser=MAIN.PointerIsEraser; e->Hover=MAIN.StylusHover;
     e->GoodPressure=MAIN.IsPen;
 
     lstAppendItem(el, (laListItem *)e);
@@ -7491,6 +7495,7 @@ LRESULT CALLBACK LA_WindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
         if (!MAIN.InkOrWinTab) { break; /* Use Windows Ink. */ }
         if (gpWTPacket((HCTX)lparam, wparam, &pkt)) {
             MAIN.StylusPressure = (real)pkt.pkNormalPressure / MAIN.WinTabMaxPenPressure;
+            MAIN.StylusHover = (real)pkt.pkZ / MAIN.WinTabMaxHover;
             real angle = (real)pkt.pkOrientation.orAzimuth / 3600 * TNS_PI * 2 + TNS_PI / 2;
             MAIN.StylusOrientation = angle; MAIN.StylusDeviation = rad((90.0f - (real)pkt.pkOrientation.orAltitude / 10.0f));
             real tw = (real)pkt.pkOrientation.orTwist; tw = rad(tw / 10);