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
|
@Override
|
||||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||||
if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP || event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN) {
|
if ((!drawerFragment.isOpened()) && InputHandler.processKeyEvent(event, true)) {
|
||||||
return super.dispatchKeyEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((!drawerFragment.isOpened()) && InputHandler.processKeyEvent(event)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class InputMapActivity extends BaseActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||||
return InputHandler.processKeyEvent(event);
|
return InputHandler.processKeyEvent(event, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onInputEvent(InputEvent event) {
|
private void onInputEvent(InputEvent event) {
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public class InputHandler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean processKeyEvent(KeyEvent event) {
|
public static boolean processKeyEvent(KeyEvent event, Boolean playing) {
|
||||||
if (!isSourceValid(event.getSource())) {
|
if (!isSourceValid(event.getSource())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -110,6 +110,13 @@ public class InputHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
String code = KeyEvent.keyCodeToString(event.getKeyCode());
|
String code = KeyEvent.keyCodeToString(event.getKeyCode());
|
||||||
|
|
||||||
|
if (playing == true) {
|
||||||
|
if (InputMap.relative(code) == KeyName.NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (event.getAction() == KeyEvent.ACTION_UP) {
|
if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||||
keyDownEvents.remove(code);
|
keyDownEvents.remove(code);
|
||||||
handleEvent(new InputEvent(code, 0.0f));
|
handleEvent(new InputEvent(code, 0.0f));
|
||||||
|
|||||||
Reference in New Issue
Block a user