Fixed bug 1569 - Android volume keys not honoured inside SDL
authorSam Lantinga <slouken@libsdl.org>
Wed, 31 Jul 2013 21:08:22 -0700
changeset 7557 609bd82bdcf6
parent 7556 574f465da18a
child 7558 0614504d2265
Fixed bug 1569 - Android volume keys not honoured inside SDL Joseba GarcĂ­a Echebarria The current version of SDL HG in Android doesn't do anything when volume keys are pressed. The change makes SDL ignore volume keys so that they're handled by the OS and the sound volume can be changed within an app.
android-project/src/org/libsdl/app/SDLActivity.java
--- a/android-project/src/org/libsdl/app/SDLActivity.java	Thu Aug 01 00:01:57 2013 -0400
+++ b/android-project/src/org/libsdl/app/SDLActivity.java	Wed Jul 31 21:08:22 2013 -0700
@@ -711,6 +711,12 @@
     @Override
     public boolean onKey(View  v, int keyCode, KeyEvent event) {
 
+        // Ignore volume keys so they're handled by Android
+        if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
+            keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
+            return false;
+        }
+        
         if (event.getAction() == KeyEvent.ACTION_DOWN) {
             //Log.v("SDL", "key down: " + keyCode);
             SDLActivity.onNativeKeyDown(keyCode);