From 768e819ec8c6814ccf1ef2773cb6eefed76e8498 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Mon, 22 Mar 2021 12:09:40 +1000 Subject: [PATCH] Android: Re-enable logging in EmulationSurfaceView --- .../duckstation/EmulationSurfaceView.java | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/android/app/src/main/java/com/github/stenzek/duckstation/EmulationSurfaceView.java b/android/app/src/main/java/com/github/stenzek/duckstation/EmulationSurfaceView.java index 8bfd693d6..e88a64941 100644 --- a/android/app/src/main/java/com/github/stenzek/duckstation/EmulationSurfaceView.java +++ b/android/app/src/main/java/com/github/stenzek/duckstation/EmulationSurfaceView.java @@ -140,15 +140,20 @@ public class EmulationSurfaceView extends SurfaceView { final ArrayList inputDeviceIds = new ArrayList<>(); for (int deviceId : InputDevice.getDeviceIds()) { final InputDevice device = InputDevice.getDevice(deviceId); - if (device == null || !isBindableDevice(device)) + if (device == null || !isBindableDevice(device)) { + Log.d("EmulationSurfaceView", + String.format("Skipping device %s sources %d", + (device != null) ? device.toString() : "", + (device != null) ? 0 : device.getSources())); continue; + } if (isGamepadDevice(device)) mHasAnyGamepads = true; final int controllerIndex = inputDeviceIds.size(); - Log.d("EmulationSurfaceView", String.format("Tracking device %d/%s (%s)", - controllerIndex, device.getDescriptor(), device.getName())); + Log.d("EmulationSurfaceView", String.format("Tracking device %d/%s (%s, sources %d)", + controllerIndex, device.getDescriptor(), device.getName(), device.getSources())); inputDeviceIds.add(new InputDeviceData(device, controllerIndex)); } @@ -211,16 +216,13 @@ public class EmulationSurfaceView extends SurfaceView { return (data != null) ? data.controllerIndex : -1; } - private boolean handleKeyEvent(int keyCode, KeyEvent event, boolean pressed) { - if (!isBindableDevice(event.getDevice())) - return false; - - /*Log.e("ESV", String.format("Code %d RC %d Pressed %d %s", keyCode, - event.getRepeatCount(), pressed? 1 : 0, event.toString()));*/ + private boolean handleKeyEvent(int deviceId, int repeatCount, int keyCode, boolean pressed) { + final int controllerIndex = getControllerIndexForDeviceId(deviceId); + Log.d("EmulationSurfaceView", String.format("Controller %d Code %d RC %d Pressed %d", + controllerIndex, keyCode, repeatCount, pressed? 1 : 0)); final AndroidHostInterface hi = AndroidHostInterface.getInstance(); - final int controllerIndex = getControllerIndexForDeviceId(event.getDeviceId()); - if (event.getRepeatCount() == 0 && controllerIndex >= 0) + if (repeatCount == 0 && controllerIndex >= 0) hi.handleControllerButtonEvent(controllerIndex, keyCode, pressed); // We don't want to eat external button events unless it's actually bound. @@ -232,12 +234,12 @@ public class EmulationSurfaceView extends SurfaceView { @Override public boolean onKeyDown(int keyCode, KeyEvent event) { - return handleKeyEvent(keyCode, event, true); + return handleKeyEvent(event.getDeviceId(), event.getRepeatCount(), keyCode, true); } @Override public boolean onKeyUp(int keyCode, KeyEvent event) { - return handleKeyEvent(keyCode, event, false); + return handleKeyEvent(event.getDeviceId(), 0, keyCode, false); } private float clamp(float value, float min, float max) { @@ -276,8 +278,8 @@ public class EmulationSurfaceView extends SurfaceView { if (data.axisValues[i] == emuValue) continue; - /*Log.d("EmulationSurfaceView", - String.format("axis %d value %f emuvalue %f", axis, axisValue, emuValue));*/ + Log.d("EmulationSurfaceView", + String.format("axis %d value %f emuvalue %f", axis, axisValue, emuValue)); data.axisValues[i] = emuValue; AndroidHostInterface.getInstance().handleControllerAxisEvent(data.controllerIndex, axis, emuValue);