Fix locked hardware buttons on Android
authorMaksim Gamarnik <MoNTE48@mail.ua>
Sat, 14 May 2016 13:35:56 +0000 (23:35 +1000)
committerCraig Robbins <kde.psych@gmail.com>
Sat, 14 May 2016 13:42:36 +0000 (23:42 +1000)
Fixes #2122
Fixes #1454

Addendum (est31)
According from its docs in android_native_app_glue.h (from the NDK), the
onInputEvent should "Return 1 if you have handled the event, 0 for any
default dispatching". Before, we always returned 1, meaning we blocked
all hardware keys to be given to the OS.
This broke the volume keys and has caused #2122 and #1454.

Although it bases on lots of guesswork, it can probably safely be said that
CGUIEnvironment::postEventFromUser returns true if the event was handled,
and false if not. Therefore, set the status variable depending on what
postEventFromUser returned.

build/android/patches/irrlicht-back_button.patch
build/android/src/main/java/net.minetest.minetest/MtNativeActivity.java

index 227749ba7587f83f655f1f4290e98c2aa42b5829..de567adc03f8417f2906c6b855a6502e05a5b1cd 100644 (file)
@@ -1,14 +1,15 @@
---- irrlicht/source/Irrlicht/Android/CIrrDeviceAndroid.cpp     2014-06-03 20:56:21.289559503 +0200
-+++ irrlicht/source/Irrlicht/Android/CIrrDeviceAndroid.cpp.orig        2014-06-03 20:57:39.281556749 +0200
-@@ -423,6 +423,7 @@
-                       }\r
-                       \r
-                       device->postEventFromUser(event);\r
-+                      status = 1;\r
-               }\r
-               break;\r
-               default:\r
-@@ -479,7 +480,7 @@
+--- irrlicht/source/Irrlicht/Android/CIrrDeviceAndroid.cpp.orig        2015-08-29 15:43:09.000000000 +0300
++++ irrlicht/source/Irrlicht/Android/CIrrDeviceAndroid.cpp     2016-05-13 21:36:22.880388505 +0300
+@@ -486,7 +486,7 @@
+                               event.KeyInput.Char = 0;
+                       }
+-                      device->postEventFromUser(event);
++                      status = device->postEventFromUser(event);
+               }
+               break;
+               default:
+@@ -543,7 +543,7 @@
      KeyMap[1] = KEY_LBUTTON; // AKEYCODE_SOFT_LEFT\r
      KeyMap[2] = KEY_RBUTTON; // AKEYCODE_SOFT_RIGHT\r
      KeyMap[3] = KEY_HOME; // AKEYCODE_HOME\r
index fc95a8379e5b2408cec70a3c6aaed00490444646..3173a71f4bbf6290e38f3987c614a294ea303a96 100644 (file)
@@ -19,6 +19,10 @@ public class MtNativeActivity extends NativeActivity {
        public void onDestroy() {
                super.onDestroy();
        }
+       
+       @Override
+       public void onBackPressed() {
+       }
 
 
        public void copyAssets() {