From 1e77247b38c346cc057778667fa4f051c290f65a Mon Sep 17 00:00:00 2001 From: Simon Morris Date: Tue, 11 Mar 2014 14:40:53 +0000 Subject: [PATCH] Fix volume and back keys on android --- project/src/common/Display.cpp | 2 +- .../android/template/src/org/haxe/lime/MainView.java | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/project/src/common/Display.cpp b/project/src/common/Display.cpp index acedcacb0..16bcefa37 100644 --- a/project/src/common/Display.cpp +++ b/project/src/common/Display.cpp @@ -1652,7 +1652,7 @@ void Stage::HandleEvent(Event &inEvent) mFocusObject->OnKey(inEvent); #ifdef ANDROID // Non-cancelled back key ... - if (inEvent.result==0 && inEvent.code==27 && inEvent.type == etKeyUp) + if (inEvent.result==0 && inEvent.value==27 && inEvent.type == etKeyUp) { StopAnimation(); } diff --git a/templates/android/template/src/org/haxe/lime/MainView.java b/templates/android/template/src/org/haxe/lime/MainView.java index 1ef7c52d3..08110e01e 100644 --- a/templates/android/template/src/org/haxe/lime/MainView.java +++ b/templates/android/template/src/org/haxe/lime/MainView.java @@ -579,7 +579,7 @@ class MainView extends GLSurfaceView { case 112: return 127; // delete } - + return result; } @@ -592,9 +592,16 @@ class MainView extends GLSurfaceView { case KeyEvent.KEYCODE_BACK: return 27; /* Fake Escape */ case KeyEvent.KEYCODE_MENU: return 0x01000012; /* Fake MENU */ case KeyEvent.KEYCODE_DEL: return 8; + + // These will be ignored by the app and passed to the default handler + case KeyEvent.KEYCODE_VOLUME_UP: + case KeyEvent.KEYCODE_VOLUME_DOWN: + case KeyEvent.KEYCODE_VOLUME_MUTE: + return 0; } - + + if (inCode >= 7 && inCode <= 16) { return inCode + 41; // 1-9