summaryrefslogtreecommitdiff
path: root/platform/android/java/src
diff options
context:
space:
mode:
authorsanikoyes <sanikoyes@163.com>2014-03-12 20:41:09 +0800
committersanikoyes <sanikoyes@163.com>2014-03-12 20:41:09 +0800
commitcf9d97018f7d2c89628a651f79551754ea8ea228 (patch)
treed1cec96b1d40fb5556052e44d6c86a79e89e1a5d /platform/android/java/src
parent98a970585a14b63731d98cf26641045800bf2dcc (diff)
fix android input doe's not work(line edit/text edit)
Diffstat (limited to 'platform/android/java/src')
-rw-r--r--platform/android/java/src/com/android/godot/Godot.java35
-rw-r--r--platform/android/java/src/com/android/godot/GodotLib.java2
2 files changed, 34 insertions, 3 deletions
diff --git a/platform/android/java/src/com/android/godot/Godot.java b/platform/android/java/src/com/android/godot/Godot.java
index cf1545df82..5260f6149c 100644
--- a/platform/android/java/src/com/android/godot/Godot.java
+++ b/platform/android/java/src/com/android/godot/Godot.java
@@ -283,13 +283,44 @@ public class Godot extends Activity implements SensorEventListener
return true;
}
+ @Override public boolean onKeyMultiple(final int inKeyCode, int repeatCount, KeyEvent event) {
+ String s = event.getCharacters();
+ if (s == null || s.length() == 0)
+ return super.onKeyMultiple(inKeyCode, repeatCount, event);
+
+ final char[] cc = s.toCharArray();
+ int cnt = 0;
+ for (int i = cc.length; --i >= 0; cnt += cc[i] != 0 ? 1 : 0);
+ if (cnt == 0) return super.onKeyMultiple(inKeyCode, repeatCount, event);
+ final Activity me = this;
+ queueEvent(new Runnable() {
+ // This method will be called on the rendering thread:
+ public void run() {
+ for (int i = 0, n = cc.length; i < n; i++) {
+ int keyCode;
+ if ((keyCode = cc[i]) != 0) {
+ // Simulate key down and up...
+ GodotLib.key(0, keyCode, true);
+ GodotLib.key(0, keyCode, false);
+ }
+ }
+ }
+ });
+ return true;
+ }
+
+ private void queueEvent(Runnable runnable) {
+ // TODO Auto-generated method stub
+
+ }
+
@Override public boolean onKeyUp(int keyCode, KeyEvent event) {
- GodotLib.key(event.getUnicodeChar(0), false);
+ GodotLib.key(keyCode, event.getUnicodeChar(0), false);
return super.onKeyUp(keyCode, event);
};
@Override public boolean onKeyDown(int keyCode, KeyEvent event) {
- GodotLib.key(event.getUnicodeChar(0), true);
+ GodotLib.key(keyCode, event.getUnicodeChar(0), true);
return super.onKeyDown(keyCode, event);
};
diff --git a/platform/android/java/src/com/android/godot/GodotLib.java b/platform/android/java/src/com/android/godot/GodotLib.java
index f0ec3e97c6..4e6374ed4f 100644
--- a/platform/android/java/src/com/android/godot/GodotLib.java
+++ b/platform/android/java/src/com/android/godot/GodotLib.java
@@ -51,7 +51,7 @@ public class GodotLib {
public static native void step();
public static native void touch(int what,int pointer,int howmany, int[] arr);
public static native void accelerometer(float x, float y, float z);
- public static native void key(int p_unicode_char, boolean p_pressed);
+ public static native void key(int p_scancode, int p_unicode_char, boolean p_pressed);
public static native void focusin();
public static native void focusout();
public static native void audio();