*/}}
Browse Source

Twist info improved

YimingWu 3 months ago
parent
commit
5f874edf58
2 changed files with 7 additions and 6 deletions
  1. 2 2
      la_interface.h
  2. 5 4
      la_kernel.c

+ 2 - 2
la_interface.h

@@ -200,7 +200,7 @@ STRUCTURE(laEvent){
     int p1, p2;
     uint32_t Input;
 
-    int GoodPressure,IsEraser;
+    int GoodPressure,IsEraser,HasTwist;
     real Pressure,Orientation,Deviation,Twist;
 
     void *Localized;
@@ -382,7 +382,7 @@ STRUCTURE(LA){
     int InkOrWinTab;
     int WacomDeviceStylus; real StylusPressure, StylusOrientation, StylusDeviation, StylusMaxPressure;
     int WacomDeviceEraser; real EraserPressure, EraserOrientation, EraserDeviation, EraserMaxPressure;
-    real StylusTwist;
+    int StylusHasTwist; real StylusTwist;
     int PointerIsEraser,IsPen;
     int evLastX,evLastY;
 

+ 5 - 4
la_kernel.c

@@ -1537,7 +1537,7 @@ void la_SaveEvent(SYSWINDOW hwnd, laEvent *e, int use_last_pos){
     la_MakeSpecialKeyBit(hwnd,wnd,e,use_last_pos);
     if(use_last_pos){ e->x=MAIN.evLastX; e->y=MAIN.evLastY; }
 
-    e->Twist=MAIN.StylusTwist;
+    e->Twist=MAIN.StylusTwist; e->HasTwist = MAIN.StylusHasTwist;
     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;
@@ -7080,9 +7080,9 @@ static void la_RecordWacomMotions(XIRawEvent *event)
         else { MAIN.EraserOrientation=orientation;MAIN.EraserDeviation=deviation; }
     }else{ MAIN.StylusDeviation=MAIN.StylusOrientation=MAIN.EraserDeviation=MAIN.EraserOrientation=0; }
     if(XIMaskIsSet(event->valuators.mask, 5)){
-        real angle=valuator[5]; angle=rad((900-angle)/10*2-180); if(angle<0) angle+=TNS_PI*2; MAIN.StylusTwist=angle; 
-        // printf("a %lf\n",angle);
-    }else{ MAIN.StylusTwist=0; }
+        real angle=valuator[5]; angle=rad((900-angle)/10*2-180); if(angle<0) angle+=TNS_PI*2; MAIN.StylusTwist=angle;
+        if(TNS_DOUBLE_CLOSE_ENOUGH(angle,TNS_PI)){ MAIN.StylusHasTwist=0; }else{ MAIN.StylusHasTwist=1; }
+    }else{ MAIN.StylusTwist=TNS_PI; MAIN.StylusHasTwist=0; }
 
     MAIN.IsPen=1;
 }
@@ -7132,6 +7132,7 @@ LRESULT CALLBACK LA_WindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
             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;
+            if(TNS_DOUBLE_CLOSE_ENOUGH(tw,TNS_PI)){ MAIN.StylusHasTwist=0; }else{ MAIN.StylusHasTwist=1; }
             MAIN.EraserDeviation = MAIN.StylusDeviation; MAIN.EraserOrientation = MAIN.StylusOrientation;
             MAIN.EraserPressure = MAIN.StylusPressure;
             MAIN.IsPen = 1; MAIN.PointerIsEraser = ((pkt.pkStatus & TPS_INVERT) == TPS_INVERT);