Rename "pointer" to "mouse pointer"

This will help to distinguish them from "touch pointers".
This commit is contained in:
Romain Vimont 2019-09-22 14:45:56 +02:00
commit 8d1f58278e

View file

@ -20,35 +20,35 @@ public class Controller {
private final KeyCharacterMap charMap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD); private final KeyCharacterMap charMap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
private long lastMouseDown; private long lastMouseDown;
private final MotionEvent.PointerProperties[] pointerProperties = {new MotionEvent.PointerProperties()}; private final MotionEvent.PointerProperties[] mousePointerProperties = {new MotionEvent.PointerProperties()};
private final MotionEvent.PointerCoords[] pointerCoords = {new MotionEvent.PointerCoords()}; private final MotionEvent.PointerCoords[] mousePointerCoords = {new MotionEvent.PointerCoords()};
public Controller(Device device, DesktopConnection connection) { public Controller(Device device, DesktopConnection connection) {
this.device = device; this.device = device;
this.connection = connection; this.connection = connection;
initPointer(); initMousePointer();
sender = new DeviceMessageSender(connection); sender = new DeviceMessageSender(connection);
} }
private void initPointer() { private void initMousePointer() {
MotionEvent.PointerProperties props = pointerProperties[0]; MotionEvent.PointerProperties props = mousePointerProperties[0];
props.id = 0; props.id = 0;
props.toolType = MotionEvent.TOOL_TYPE_FINGER; props.toolType = MotionEvent.TOOL_TYPE_FINGER;
MotionEvent.PointerCoords coords = pointerCoords[0]; MotionEvent.PointerCoords coords = mousePointerCoords[0];
coords.orientation = 0; coords.orientation = 0;
coords.pressure = 1; coords.pressure = 1;
coords.size = 1; coords.size = 1;
} }
private void setPointerCoords(Point point) { private void setMousePointerCoords(Point point) {
MotionEvent.PointerCoords coords = pointerCoords[0]; MotionEvent.PointerCoords coords = mousePointerCoords[0];
coords.x = point.getX(); coords.x = point.getX();
coords.y = point.getY(); coords.y = point.getY();
} }
private void setScroll(int hScroll, int vScroll) { private void setScroll(int hScroll, int vScroll) {
MotionEvent.PointerCoords coords = pointerCoords[0]; MotionEvent.PointerCoords coords = mousePointerCoords[0];
coords.setAxisValue(MotionEvent.AXIS_HSCROLL, hScroll); coords.setAxisValue(MotionEvent.AXIS_HSCROLL, hScroll);
coords.setAxisValue(MotionEvent.AXIS_VSCROLL, vScroll); coords.setAxisValue(MotionEvent.AXIS_VSCROLL, vScroll);
} }
@ -158,8 +158,8 @@ public class Controller {
// ignore event // ignore event
return false; return false;
} }
setPointerCoords(point); setMousePointerCoords(point);
MotionEvent event = MotionEvent.obtain(lastMouseDown, now, action, 1, pointerProperties, pointerCoords, 0, buttons, 1f, 1f, 0, 0, MotionEvent event = MotionEvent.obtain(lastMouseDown, now, action, 1, mousePointerProperties, mousePointerCoords, 0, buttons, 1f, 1f, 0, 0,
InputDevice.SOURCE_TOUCHSCREEN, 0); InputDevice.SOURCE_TOUCHSCREEN, 0);
return injectEvent(event); return injectEvent(event);
} }
@ -171,9 +171,9 @@ public class Controller {
// ignore event // ignore event
return false; return false;
} }
setPointerCoords(point); setMousePointerCoords(point);
setScroll(hScroll, vScroll); setScroll(hScroll, vScroll);
MotionEvent event = MotionEvent.obtain(lastMouseDown, now, MotionEvent.ACTION_SCROLL, 1, pointerProperties, pointerCoords, 0, 0, 1f, 1f, 0, MotionEvent event = MotionEvent.obtain(lastMouseDown, now, MotionEvent.ACTION_SCROLL, 1, mousePointerProperties, mousePointerCoords, 0, 0, 1f, 1f, 0,
0, InputDevice.SOURCE_MOUSE, 0); 0, InputDevice.SOURCE_MOUSE, 0);
return injectEvent(event); return injectEvent(event);
} }