Skip to content

Commit 19f5e87

Browse files
authored
pandroid: allow to bind volume keys (#814)
* allow to bind volume keys * fix mapping * pass false instead of null
1 parent efdff98 commit 19f5e87

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,8 @@ protected void onPause() {
151151
}
152152

153153
@Override
154-
public boolean dispatchKeyEvent(KeyEvent event) {
155-
if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP || event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN) {
156-
return super.dispatchKeyEvent(event);
157-
}
158-
159-
if ((!drawerFragment.isOpened()) && InputHandler.processKeyEvent(event)) {
154+
public boolean dispatchKeyEvent(KeyEvent event) {
155+
if ((!drawerFragment.isOpened()) && InputHandler.processKeyEvent(event, true)) {
160156
return true;
161157
}
162158

src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/preferences/InputMapActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public boolean dispatchGenericMotionEvent(MotionEvent ev) {
4747

4848
@Override
4949
public boolean dispatchKeyEvent(KeyEvent event) {
50-
return InputHandler.processKeyEvent(event);
50+
return InputHandler.processKeyEvent(event, false);
5151
}
5252

5353
private void onInputEvent(InputEvent event) {

src/pandroid/app/src/main/java/com/panda3ds/pandroid/input/InputHandler.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public static boolean processMotionEvent(MotionEvent event) {
9090
return true;
9191
}
9292

93-
public static boolean processKeyEvent(KeyEvent event) {
93+
public static boolean processKeyEvent(KeyEvent event, Boolean playing) {
9494
if (!isSourceValid(event.getSource())) {
9595
return false;
9696
}
@@ -110,6 +110,13 @@ public static boolean processKeyEvent(KeyEvent event) {
110110
}
111111
}
112112
String code = KeyEvent.keyCodeToString(event.getKeyCode());
113+
114+
if (playing == true) {
115+
if (InputMap.relative(code) == KeyName.NULL) {
116+
return false;
117+
}
118+
}
119+
113120
if (event.getAction() == KeyEvent.ACTION_UP) {
114121
keyDownEvents.remove(code);
115122
handleEvent(new InputEvent(code, 0.0f));

0 commit comments

Comments
 (0)