diff options
author | sanikoyes <sanikoyes@163.com> | 2014-04-06 21:53:38 +0800 |
---|---|---|
committer | sanikoyes <sanikoyes@163.com> | 2014-04-06 21:53:38 +0800 |
commit | bae5ad7c8bc14c44a3222017ca7b561d7aa514be (patch) | |
tree | 2b7b36194debe6da2e6d6fd37f584e76e9f20cd7 /platform/android/java/src/com | |
parent | 77a840e350668a9c80b1e63b9b73aac44221c53b (diff) |
Move onKeyDown/onKeyUp from Godot to GodotView
Press 'back' button should not terminate program, normal handle 'back' event in game logic
Diffstat (limited to 'platform/android/java/src/com')
-rw-r--r-- | platform/android/java/src/com/android/godot/Godot.java | 10 | ||||
-rw-r--r-- | platform/android/java/src/com/android/godot/GodotView.java | 16 |
2 files changed, 16 insertions, 10 deletions
diff --git a/platform/android/java/src/com/android/godot/Godot.java b/platform/android/java/src/com/android/godot/Godot.java index 5a1bac5e86..0fa07e2490 100644 --- a/platform/android/java/src/com/android/godot/Godot.java +++ b/platform/android/java/src/com/android/godot/Godot.java @@ -346,16 +346,6 @@ public class Godot extends Activity implements SensorEventListener } - @Override public boolean onKeyUp(int keyCode, KeyEvent event) { - GodotLib.key(keyCode, event.getUnicodeChar(0), false); - return super.onKeyUp(keyCode, event); - }; - - @Override public boolean onKeyDown(int keyCode, KeyEvent event) { - GodotLib.key(keyCode, event.getUnicodeChar(0), true); - return super.onKeyDown(keyCode, event); - } - public PaymentsManager getPaymentsManager() { return mPaymentsManager; } diff --git a/platform/android/java/src/com/android/godot/GodotView.java b/platform/android/java/src/com/android/godot/GodotView.java index b5ab81cb24..1993be8d2c 100644 --- a/platform/android/java/src/com/android/godot/GodotView.java +++ b/platform/android/java/src/com/android/godot/GodotView.java @@ -98,8 +98,24 @@ public class GodotView extends GLSurfaceView { return activity.gotTouchEvent(event); }; + @Override public boolean onKeyUp(int keyCode, KeyEvent event) { + GodotLib.key(keyCode, event.getUnicodeChar(0), false); + return super.onKeyUp(keyCode, event); + }; + + @Override public boolean onKeyDown(int keyCode, KeyEvent event) { + GodotLib.key(keyCode, event.getUnicodeChar(0), true); + if (keyCode == KeyEvent.KEYCODE_BACK) { + // press 'back' button should not terminate program + // normal handle 'back' event in game logic + return true; + } + return super.onKeyDown(keyCode, event); + } + private void init(boolean translucent, int depth, int stencil) { + this.setFocusableInTouchMode(true); /* By default, GLSurfaceView() creates a RGB_565 opaque surface. * If we want a translucent one, we should change the surface's * format here, using PixelFormat.TRANSLUCENT for GL Surfaces |