*/}}
Browse Source

Wacom twist support on linux

YimingWu 1 year ago
parent
commit
3534e1ec64
2 changed files with 7 additions and 3 deletions
  1. 2 1
      la_interface.h
  2. 5 2
      la_kernel.c

+ 2 - 1
la_interface.h

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

+ 5 - 2
la_kernel.c

@@ -1202,6 +1202,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->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;
@@ -6707,10 +6708,12 @@ static void la_RecordWacomMotions(XIRawEvent *event)
     if(XIMaskIsSet(event->valuators.mask, 3) && XIMaskIsSet(event->valuators.mask, 4)){
         real x=valuator[3],y=valuator[4];
         real orientation=atan2(y,x); real deviation=sqrt(x*x+y*y); deviation=rad(deviation);
-        //printf("%f %f\n",orientation,deviation);
         if(IsStylus){ MAIN.StylusOrientation=orientation;MAIN.StylusDeviation=deviation; }
         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=(900-angle)/10*2; MAIN.StylusTwist=angle; 
+    }else{ MAIN.StylusTwist=0; }
 
     MAIN.IsPen=1;
 }