Move onKeyDown/onKeyUp from Godot to GodotView

Press 'back' button should not terminate program, normal handle 'back' event in game logic
This commit is contained in:
sanikoyes 2014-04-06 21:53:38 +08:00
parent 77a840e350
commit bae5ad7c8b
2 changed files with 16 additions and 10 deletions

View File

@ -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() { public PaymentsManager getPaymentsManager() {
return mPaymentsManager; return mPaymentsManager;
} }

View File

@ -98,8 +98,24 @@ public class GodotView extends GLSurfaceView {
return activity.gotTouchEvent(event); 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) { private void init(boolean translucent, int depth, int stencil) {
this.setFocusableInTouchMode(true);
/* By default, GLSurfaceView() creates a RGB_565 opaque surface. /* By default, GLSurfaceView() creates a RGB_565 opaque surface.
* If we want a translucent one, we should change the surface's * If we want a translucent one, we should change the surface's
* format here, using PixelFormat.TRANSLUCENT for GL Surfaces * format here, using PixelFormat.TRANSLUCENT for GL Surfaces