From db582a2c8cc0bf7d237a973f17ad099fdf424859 Mon Sep 17 00:00:00 2001 From: Alexander Holland Date: Wed, 29 Aug 2018 17:06:48 +0200 Subject: Adds Pen support for Android --- .../java/lib/src/org/godotengine/godot/GodotLib.java | 5 +++++ .../src/org/godotengine/godot/input/GodotInputHandler.java | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'platform/android/java/lib/src') diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java b/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java index 067fa6f4b9..67dce172dc 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java @@ -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) diff --git a/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java b/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java index 2beca67922..2756ca6c83 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java +++ b/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java @@ -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; } -- cgit v1.2.3