1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Adds Pen support for Android

This commit is contained in:
Alexander Holland
2018-08-29 17:06:48 +02:00
parent 5a23ab61fa
commit db582a2c8c
6 changed files with 44 additions and 1 deletions

View File

@@ -94,6 +94,11 @@ public class GodotLib {
*/
public static native void touch(int what, int pointer, int howmany, int[] arr);
/**
* Forward hover events from the main thread to the GL thread.
*/
public static native void hover(int type, int x, int y);
/**
* Forward accelerometer sensor events from the main thread to the GL thread.
* @see android.hardware.SensorEventListener#onSensorChanged(SensorEvent)

View File

@@ -188,7 +188,18 @@ public class GodotInputHandler implements InputDeviceListener {
}
return true;
}
};
} else if ((event.getSource() & InputDevice.SOURCE_STYLUS) == InputDevice.SOURCE_STYLUS) {
final int x = Math.round(event.getX());
final int y = Math.round(event.getY());
final int type = event.getAction();
queueEvent(new Runnable() {
@Override
public void run() {
GodotLib.hover(type, x, y);
}
});
return true;
}
return false;
}