Inject mouse events as touchscreen

As a mouse, some clicks on close prositions are sometimes not generated
on some devices.
This commit is contained in:
Romain Vimont 2018-01-25 17:17:21 +01:00
parent 1930c81062
commit f70359f14f

View file

@ -31,7 +31,7 @@ public class EventController {
private void initPointer() { private void initPointer() {
MotionEvent.PointerProperties props = pointerProperties[0]; MotionEvent.PointerProperties props = pointerProperties[0];
props.id = 0; props.id = 0;
props.toolType = MotionEvent.TOOL_TYPE_MOUSE; props.toolType = MotionEvent.TOOL_TYPE_FINGER;
MotionEvent.PointerCoords coords = pointerCoords[0]; MotionEvent.PointerCoords coords = pointerCoords[0];
coords.orientation = 0; coords.orientation = 0;
@ -108,7 +108,7 @@ public class EventController {
return false; return false;
} }
setPointerCoords(rawPoint); setPointerCoords(rawPoint);
MotionEvent event = MotionEvent.obtain(lastMouseDown, now, action, 1, pointerProperties, pointerCoords, 0, buttons, 1f, 1f, 0, 0, InputDevice.SOURCE_MOUSE, 0); MotionEvent event = MotionEvent.obtain(lastMouseDown, now, action, 1, pointerProperties, pointerCoords, 0, buttons, 1f, 1f, 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0);
return injectEvent(event); return injectEvent(event);
} }