*/}}
1
0
Prechádzať zdrojové kódy

Windows ink with pen history to handle more events thus smooth pen input

YimingWu 1 rok pred
rodič
commit
8b0973608e
1 zmenil súbory, kde vykonal 29 pridanie a 15 odobranie
  1. 29 15
      la_kernel.c

+ 29 - 15
la_kernel.c

@@ -6969,7 +6969,7 @@ LRESULT CALLBACK LA_WindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
     short wheelmark = 0;
     int  WheelDir = 0;
     UINT32 pointerId; POINTER_INPUT_TYPE pointerType;
-    POINTER_PEN_INFO penInfo; POINTER_TOUCH_INFO touchInfo;
+    POINTER_PEN_INFO penInfo[128]; POINTER_TOUCH_INFO touchInfo; int peninfonum = 128;
     POINT point;
     PACKET pkt;
     static POINT ptOld, ptNew;
@@ -6999,17 +6999,17 @@ LRESULT CALLBACK LA_WindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
         break;
     case WT_PACKET:
         if (!MAIN.InkOrWinTab) { break; /* Use Windows Ink. */ }
-        if (gpWTPacket((HCTX)lparam, wparam, &pkt)){
-            MAIN.StylusPressure = (real)pkt.pkNormalPressure/MAIN.WinTabMaxPenPressure;
-            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);
+        if (gpWTPacket((HCTX)lparam, wparam, &pkt)) {
+            MAIN.StylusPressure = (real)pkt.pkNormalPressure / MAIN.WinTabMaxPenPressure;
+            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);
             MAIN.StylusTwist = tw;
-            MAIN.EraserDeviation=MAIN.StylusDeviation;MAIN.EraserOrientation=MAIN.StylusOrientation;
-            MAIN.EraserPressure=MAIN.StylusPressure;
-            MAIN.IsPen = 1; MAIN.PointerIsEraser=((pkt.pkStatus & TPS_INVERT)==TPS_INVERT);
+            MAIN.EraserDeviation = MAIN.StylusDeviation; MAIN.EraserOrientation = MAIN.StylusOrientation;
+            MAIN.EraserPressure = MAIN.StylusPressure;
+            MAIN.IsPen = 1; MAIN.PointerIsEraser = ((pkt.pkStatus & TPS_INVERT) == TPS_INVERT);
         }
-        break;
+        return 0; break;
 
     case WM_SYSCOMMAND:
         switch (wparam) {
@@ -7029,6 +7029,8 @@ LRESULT CALLBACK LA_WindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
     case WM_SETCURSOR:
         if(MAIN.CurrentCursor) return 1;
         break;
+    case WM_POINTERDOWN:
+    case WM_POINTERUP:
     case WM_POINTERUPDATE:
         if (MAIN.InkOrWinTab) { break;/* Use WinTab. */ }
         pointerId = GET_POINTERID_WPARAM(wparam);
@@ -7036,14 +7038,26 @@ LRESULT CALLBACK LA_WindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
 
         if(!GetPointerType(pointerId, &pointerType)){
             pointerType = PT_POINTER;
-            printf("is pointer\n");
         }
         if(pointerType == PT_PEN){
-            if(GetPointerPenInfo(pointerId, &penInfo)){
-                point.x = penInfo.pointerInfo.ptPixelLocation.x; point.y = penInfo.pointerInfo.ptPixelLocation.y;
-                ScreenToClient(hwnd, &point);
-                MAIN.IsPen = 1; MAIN.StylusPressure = (real)penInfo.pressure / 1024; MAIN.PointerIsEraser = 0;
+            if(GetPointerPenInfoHistory(pointerId, &peninfonum, penInfo)){
+                for (int i = peninfonum-1; i>=0; i--) {
+                    point.x = penInfo[i].pointerInfo.ptPixelLocation.x; point.y = penInfo[i].pointerInfo.ptPixelLocation.y;
+                    ScreenToClient(hwnd, &point);
+                    MAIN.IsPen = 1; MAIN.StylusPressure = (real)penInfo[i].pressure / 1024; MAIN.PointerIsEraser = 0;
+                    switch (penInfo[i].pointerInfo.ButtonChangeType) {
+                    case POINTER_CHANGE_FIRSTBUTTON_DOWN: la_SendMouseEvent(hwnd, LA_L_MOUSE_DOWN, point.x, point.y); break;
+                    case POINTER_CHANGE_FIRSTBUTTON_UP: la_SendMouseEvent(hwnd, LA_L_MOUSE_UP, point.x, point.y); break;
+                    case POINTER_CHANGE_SECONDBUTTON_DOWN: la_SendMouseEvent(hwnd, LA_M_MOUSE_DOWN, point.x, point.y); break;
+                    case POINTER_CHANGE_SECONDBUTTON_UP: la_SendMouseEvent(hwnd, LA_M_MOUSE_UP, point.x, point.y); break;
+                    case POINTER_CHANGE_THIRDBUTTON_DOWN: la_SendMouseEvent(hwnd, LA_R_MOUSE_DOWN, point.x, point.y); break;
+                    case POINTER_CHANGE_THIRDBUTTON_UP: la_SendMouseEvent(hwnd, LA_R_MOUSE_UP, point.x, point.y); break;
+                    }
+                    la_SendMouseEvent(hwnd, LA_MOUSEMOVE, point.x, point.y);
+                }
             }
+            SkipPointerFrameMessages(pointerId);
+            return 0;
         }
         else if (pointerType == PT_TOUCH){
             if (GetPointerTouchInfo(pointerId, &touchInfo)) {