summaryrefslogtreecommitdiffstats
path: root/platform/android/java/src/org/godotengine/godot/input
diff options
context:
space:
mode:
authorRuslan Mustakov <r.mustakov@gmail.com>2017-08-18 21:17:35 +0700
committerRuslan Mustakov <r.mustakov@gmail.com>2017-08-30 18:14:19 +0700
commit5ccdeccb6ed6b8480a86b0db36f192526cba1274 (patch)
treeeafb890997ee985210b66272957aa22ad00df125 /platform/android/java/src/org/godotengine/godot/input
parent8b9026c05e9982a7bc0c7f52776ad74276b90252 (diff)
downloadredot-engine-5ccdeccb6ed6b8480a86b0db36f192526cba1274.tar.gz
Make GDNative work on Android
The changes include work done to ensure that GDNative apps and Nim integration specifically can run on Android. The changes have been tested on our WIP game, which uses godot-nim and depends on several third-party .so libs, and Platformer demo to ensure nothing got broken. - .so libraries are exported to lib/ folder in .apk, instead of assets/, because that's where Android expects them to be and it resolves the library name into "lib/<ABI>/<name>", where <ABI> is the ABI matching the current device. So we establish the convention that Android .so files in the project must be located in the folder corresponding to the ABI they were compiled for. - Godot callbacks (event handlers) are now called from the same thread from which Main::iteration is called. It is also what Godot now considers to be the main thread, because Main::setup is also called from there. This makes threading on Android more consistent with other platforms, making the code that depends on Thread::get_main_id more portable (GDNative has such code). - Sizes of GDNative API types have been fixed to work on 32-bit platforms.
Diffstat (limited to 'platform/android/java/src/org/godotengine/godot/input')
-rw-r--r--platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java43
1 files changed, 32 insertions, 11 deletions
diff --git a/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java b/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java
index c2d03e4ecc..04669a3b0c 100644
--- a/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java
+++ b/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java
@@ -89,8 +89,13 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene
//Log.d(TAG, "beforeTextChanged(" + pCharSequence + ")start: " + start + ",count: " + count + ",after: " + after);
for (int i=0;i<count;i++){
- GodotLib.key(KeyEvent.KEYCODE_DEL, 0, true);
- GodotLib.key(KeyEvent.KEYCODE_DEL, 0, false);
+ mView.queueEvent(new Runnable() {
+ @Override
+ public void run() {
+ GodotLib.key(KeyEvent.KEYCODE_DEL, 0, true);
+ GodotLib.key(KeyEvent.KEYCODE_DEL, 0, false);
+ }
+ });
}
}
@@ -99,9 +104,14 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene
//Log.d(TAG, "onTextChanged(" + pCharSequence + ")start: " + start + ",count: " + count + ",before: " + before);
for (int i=start;i<start+count;i++){
- int ch = pCharSequence.charAt(i);
- GodotLib.key(0, ch, true);
- GodotLib.key(0, ch, false);
+ final int ch = pCharSequence.charAt(i);
+ mView.queueEvent(new Runnable() {
+ @Override
+ public void run() {
+ GodotLib.key(0, ch, true);
+ GodotLib.key(0, ch, false);
+ }
+ });
}
}
@@ -111,8 +121,14 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene
if (this.mEdit == pTextView && this.isFullScreenEdit()) {
// user press the action button, delete all old text and insert new text
for (int i = this.mOriginText.length(); i > 0; i--) {
- GodotLib.key(KeyEvent.KEYCODE_DEL, 0, true);
- GodotLib.key(KeyEvent.KEYCODE_DEL, 0, false);
+ mView.queueEvent(new Runnable() {
+ @Override
+ public void run() {
+ GodotLib.key(KeyEvent.KEYCODE_DEL, 0, true);
+ GodotLib.key(KeyEvent.KEYCODE_DEL, 0, false);
+ }
+ });
+
/*
if (BuildConfig.DEBUG) {
Log.d(TAG, "deleteBackward");
@@ -131,9 +147,14 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene
}
for(int i = 0; i < text.length(); i++) {
- int ch = text.codePointAt(i);
- GodotLib.key(0, ch, true);
- GodotLib.key(0, ch, false);
+ final int ch = text.codePointAt(i);
+ mView.queueEvent(new Runnable() {
+ @Override
+ public void run() {
+ GodotLib.key(0, ch, true);
+ GodotLib.key(0, ch, false);
+ }
+ });
}
/*
if (BuildConfig.DEBUG) {
@@ -141,7 +162,7 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene
}
*/
}
-
+
if (pActionID == EditorInfo.IME_ACTION_DONE) {
this.mView.requestFocus();
}