|  | @@ -8468,7 +8468,7 @@ static int32_t la_AndroidInputCallback(struct android_app *app, AInputEvent *eve
 | 
	
		
			
				|  |  |      __android_log_print(ANDROID_LOG_DEBUG, "huh 5678", "123 input");
 | 
	
		
			
				|  |  |      if(!MAIN.AppEnabled){return 0;}
 | 
	
		
			
				|  |  |      //laRedrawAllWindows();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +    static int prev_button_state=0;
 | 
	
		
			
				|  |  |      int type = AInputEvent_getType(event);
 | 
	
		
			
				|  |  |      if(type == AINPUT_EVENT_TYPE_KEY){
 | 
	
		
			
				|  |  |          int32_t keycode = AKeyEvent_getKeyCode(event);
 | 
	
	
		
			
				|  | @@ -8519,10 +8519,18 @@ static int32_t la_AndroidInputCallback(struct android_app *app, AInputEvent *eve
 | 
	
		
			
				|  |  |          int32_t action = AMotionEvent_getAction(event);
 | 
	
		
			
				|  |  |          unsigned int flags = action & AMOTION_EVENT_ACTION_MASK;
 | 
	
		
			
				|  |  |          int32_t pointerIndex = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
 | 
	
		
			
				|  |  | +        real rx=AMotionEvent_getX(event, 0), ry=AMotionEvent_getY(event, 0);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if(pcount){
 | 
	
		
			
				|  |  | -            real rx=AMotionEvent_getX(event, 0), ry=AMotionEvent_getY(event, 0);
 | 
	
		
			
				|  |  |              x=rx; y=ry;
 | 
	
		
			
				|  |  | +            int tool_type=AMotionEvent_getToolType(event,0);
 | 
	
		
			
				|  |  | +            real pressure = AMotionEvent_getAxisValue(event,AMOTION_EVENT_AXIS_PRESSURE,0);
 | 
	
		
			
				|  |  | +            if(tool_type == AMOTION_EVENT_TOOL_TYPE_STYLUS || tool_type==AMOTION_EVENT_TOOL_TYPE_ERASER){
 | 
	
		
			
				|  |  | +                MAIN.StylusPressure = MAIN.EraserPressure = pressure; MAIN.IsPen = 1; 
 | 
	
		
			
				|  |  | +                MAIN.PointerIsEraser = (tool_type==AMOTION_EVENT_TOOL_TYPE_ERASER);
 | 
	
		
			
				|  |  | +            }else{
 | 
	
		
			
				|  |  | +                MAIN.IsPen = 0;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |              if(pcount>=2 && (flags!=AMOTION_EVENT_ACTION_UP) && (flags!=AMOTION_EVENT_ACTION_CANCEL)
 | 
	
		
			
				|  |  |                  && (flags!=AMOTION_EVENT_ACTION_POINTER_UP)){
 | 
	
		
			
				|  |  |                  real x2=AMotionEvent_getX(event, 1), y2=AMotionEvent_getY(event, 1);
 | 
	
	
		
			
				|  | @@ -8560,14 +8568,28 @@ static int32_t la_AndroidInputCallback(struct android_app *app, AInputEvent *eve
 | 
	
		
			
				|  |  |              }else{
 | 
	
		
			
				|  |  |                  temp_distance = 0; cx=0; cy=0;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +            if(flags==AMOTION_EVENT_ACTION_HOVER_MOVE){
 | 
	
		
			
				|  |  | +                la_SendMouseEvent(0, LA_MOUSEMOVE, rx,ry);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }else{
 | 
	
		
			
				|  |  | +            la_SendMouseEvent(0, LA_MOUSEMOVE, rx,ry);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if(!gesture_handled){
 | 
	
		
			
				|  |  | -            if (flags == AMOTION_EVENT_ACTION_DOWN){
 | 
	
		
			
				|  |  | +            if (flags == AMOTION_EVENT_ACTION_DOWN || flags == AMOTION_EVENT_ACTION_BUTTON_PRESS){
 | 
	
		
			
				|  |  |                  la_SendMouseEvent(0,LA_MOUSEMOVE,x,y);
 | 
	
		
			
				|  |  | -                la_SendMouseEvent(0,LA_L_MOUSE_DOWN,x,y);
 | 
	
		
			
				|  |  | +                int btn=AMotionEvent_getButtonState(event);
 | 
	
		
			
				|  |  | +                int evtype=LA_L_MOUSE_DOWN;
 | 
	
		
			
				|  |  | +                if(btn & AMOTION_EVENT_BUTTON_STYLUS_PRIMARY){ evtype=LA_M_MOUSE_DOWN; }
 | 
	
		
			
				|  |  | +                elif(btn & AMOTION_EVENT_BUTTON_STYLUS_SECONDARY){ evtype=LA_R_MOUSE_DOWN; }
 | 
	
		
			
				|  |  | +                la_SendMouseEvent(0,evtype,x,y);
 | 
	
		
			
				|  |  | +                prev_button_state = btn;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            else if (flags == AMOTION_EVENT_ACTION_UP){
 | 
	
		
			
				|  |  | -                la_SendMouseEvent(0,LA_L_MOUSE_UP,x,y);
 | 
	
		
			
				|  |  | +            else if (flags == AMOTION_EVENT_ACTION_UP || flags == AMOTION_EVENT_ACTION_BUTTON_RELEASE){
 | 
	
		
			
				|  |  | +                int btn=AMotionEvent_getButtonState(event); int changed = (~btn)&prev_button_state; 
 | 
	
		
			
				|  |  | +                int evtype=LA_L_MOUSE_UP;
 | 
	
		
			
				|  |  | +                if(changed & AMOTION_EVENT_BUTTON_STYLUS_PRIMARY){ evtype=LA_M_MOUSE_UP; }
 | 
	
		
			
				|  |  | +                elif(changed & AMOTION_EVENT_BUTTON_STYLUS_SECONDARY){ evtype=LA_R_MOUSE_UP; }
 | 
	
		
			
				|  |  | +                la_SendMouseEvent(0,evtype,x,y);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              else if (flags == AMOTION_EVENT_ACTION_MOVE){
 | 
	
		
			
				|  |  |                  la_SendMouseEvent(0,LA_MOUSEMOVE,x,y);
 |