Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed volume keys not being handled by Android if screen keyboard is …
Browse files Browse the repository at this point in the history
…visible.

See bug #1569.
  • Loading branch information
philippwiesemann committed Aug 4, 2013
1 parent 70bf97e commit 8760185
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions android-project/src/org/libsdl/app/SDLActivity.java
Expand Up @@ -134,6 +134,16 @@ protected void onDestroy() {
}
}

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
int keyCode = event.getKeyCode();
// Ignore volume keys so they're handled by Android
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
return false;
}
return super.dispatchKeyEvent(event);
}

/** Called by onPause or surfaceDestroyed. Even if surfaceDestroyed
* is the first to be called, mIsSurfaceReady should still be set
Expand Down Expand Up @@ -726,12 +736,6 @@ public void onDraw(Canvas canvas) {}
// Key events
@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);
Expand Down

0 comments on commit 8760185

Please sign in to comment.