pandroid: allow to bind volume keys (#814)
* allow to bind volume keys * fix mapping * pass false instead of null
This commit is contained in:
@@ -152,11 +152,7 @@ public class GameActivity extends BaseActivity implements EmulatorCallback, Sens
|
||||
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP || event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN) {
|
||||
return super.dispatchKeyEvent(event);
|
||||
}
|
||||
|
||||
if ((!drawerFragment.isOpened()) && InputHandler.processKeyEvent(event)) {
|
||||
if ((!drawerFragment.isOpened()) && InputHandler.processKeyEvent(event, true)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class InputMapActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
return InputHandler.processKeyEvent(event);
|
||||
return InputHandler.processKeyEvent(event, false);
|
||||
}
|
||||
|
||||
private void onInputEvent(InputEvent event) {
|
||||
|
||||
@@ -90,7 +90,7 @@ public class InputHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean processKeyEvent(KeyEvent event) {
|
||||
public static boolean processKeyEvent(KeyEvent event, Boolean playing) {
|
||||
if (!isSourceValid(event.getSource())) {
|
||||
return false;
|
||||
}
|
||||
@@ -110,6 +110,13 @@ public class InputHandler {
|
||||
}
|
||||
}
|
||||
String code = KeyEvent.keyCodeToString(event.getKeyCode());
|
||||
|
||||
if (playing == true) {
|
||||
if (InputMap.relative(code) == KeyName.NULL) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
keyDownEvents.remove(code);
|
||||
handleEvent(new InputEvent(code, 0.0f));
|
||||
|
||||
Reference in New Issue
Block a user