From a30b450b1367971ea15b270aedcc8c995ade504d Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Thu, 17 Apr 2014 15:22:50 -0700 Subject: [PATCH] Do not consume keyboard arrow keys on Android (pass to both joystick and keyboard events) and handle dpad center as keyboard enter (like on Kindle FireTV) --- .../template/src/org/haxe/lime/MainView.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/templates/android/template/src/org/haxe/lime/MainView.java b/templates/android/template/src/org/haxe/lime/MainView.java index e416d07e6..7db41c224 100644 --- a/templates/android/template/src/org/haxe/lime/MainView.java +++ b/templates/android/template/src/org/haxe/lime/MainView.java @@ -344,7 +344,7 @@ class MainView extends GLSurfaceView { final MainView me = this; - ::if (ANDROID_TARGET_SDK_VERSION > 11)::if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1 && (event.isGamepadButton (inKeyCode) || (inKeyCode >= 19 && inKeyCode <= 22))) { + ::if (ANDROID_TARGET_SDK_VERSION > 11)::if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1 && (event.isGamepadButton (inKeyCode) || (inKeyCode >= 19 && inKeyCode <=22))) { if (event.getRepeatCount () == 0) { @@ -362,7 +362,11 @@ class MainView extends GLSurfaceView { } - return true; + if (inKeyCode < 19 || inKeyCode > 22) { + + return true; + + } }::end:: @@ -394,7 +398,7 @@ class MainView extends GLSurfaceView { final MainView me = this; - ::if (ANDROID_TARGET_SDK_VERSION > 11)::if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1 && (event.isGamepadButton (inKeyCode) || (inKeyCode >= 19 && inKeyCode <= 22))) { + ::if (ANDROID_TARGET_SDK_VERSION > 11)::if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1 && (event.isGamepadButton (inKeyCode) || (inKeyCode >= 19 && inKeyCode <=22))) { if (event.getRepeatCount () == 0) { @@ -412,7 +416,11 @@ class MainView extends GLSurfaceView { } - return true; + if (inKeyCode < 19 || inKeyCode > 22) { + + return true; + + } }::end:: @@ -589,6 +597,7 @@ class MainView extends GLSurfaceView { switch (inCode) { + case KeyEvent.KEYCODE_DPAD_CENTER: return 13; // Enter case KeyEvent.KEYCODE_BACK: return 27; /* Fake Escape */ case KeyEvent.KEYCODE_MENU: return 0x01000012; /* Fake MENU */ case KeyEvent.KEYCODE_DEL: return 8;