Android: Re-enable logging in EmulationSurfaceView

This commit is contained in:
Connor McLaughlin 2021-03-22 12:09:40 +10:00
parent dd130c2132
commit 768e819ec8

View File

@ -140,15 +140,20 @@ public class EmulationSurfaceView extends SurfaceView {
final ArrayList<InputDeviceData> inputDeviceIds = new ArrayList<>(); final ArrayList<InputDeviceData> inputDeviceIds = new ArrayList<>();
for (int deviceId : InputDevice.getDeviceIds()) { for (int deviceId : InputDevice.getDeviceIds()) {
final InputDevice device = InputDevice.getDevice(deviceId); 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; continue;
}
if (isGamepadDevice(device)) if (isGamepadDevice(device))
mHasAnyGamepads = true; mHasAnyGamepads = true;
final int controllerIndex = inputDeviceIds.size(); final int controllerIndex = inputDeviceIds.size();
Log.d("EmulationSurfaceView", String.format("Tracking device %d/%s (%s)", Log.d("EmulationSurfaceView", String.format("Tracking device %d/%s (%s, sources %d)",
controllerIndex, device.getDescriptor(), device.getName())); controllerIndex, device.getDescriptor(), device.getName(), device.getSources()));
inputDeviceIds.add(new InputDeviceData(device, controllerIndex)); inputDeviceIds.add(new InputDeviceData(device, controllerIndex));
} }
@ -211,16 +216,13 @@ public class EmulationSurfaceView extends SurfaceView {
return (data != null) ? data.controllerIndex : -1; return (data != null) ? data.controllerIndex : -1;
} }
private boolean handleKeyEvent(int keyCode, KeyEvent event, boolean pressed) { private boolean handleKeyEvent(int deviceId, int repeatCount, int keyCode, boolean pressed) {
if (!isBindableDevice(event.getDevice())) final int controllerIndex = getControllerIndexForDeviceId(deviceId);
return false; Log.d("EmulationSurfaceView", String.format("Controller %d Code %d RC %d Pressed %d",
controllerIndex, keyCode, repeatCount, pressed? 1 : 0));
/*Log.e("ESV", String.format("Code %d RC %d Pressed %d %s", keyCode,
event.getRepeatCount(), pressed? 1 : 0, event.toString()));*/
final AndroidHostInterface hi = AndroidHostInterface.getInstance(); final AndroidHostInterface hi = AndroidHostInterface.getInstance();
final int controllerIndex = getControllerIndexForDeviceId(event.getDeviceId()); if (repeatCount == 0 && controllerIndex >= 0)
if (event.getRepeatCount() == 0 && controllerIndex >= 0)
hi.handleControllerButtonEvent(controllerIndex, keyCode, pressed); hi.handleControllerButtonEvent(controllerIndex, keyCode, pressed);
// We don't want to eat external button events unless it's actually bound. // We don't want to eat external button events unless it's actually bound.
@ -232,12 +234,12 @@ public class EmulationSurfaceView extends SurfaceView {
@Override @Override
public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
return handleKeyEvent(keyCode, event, true); return handleKeyEvent(event.getDeviceId(), event.getRepeatCount(), keyCode, true);
} }
@Override @Override
public boolean onKeyUp(int keyCode, KeyEvent event) { 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) { private float clamp(float value, float min, float max) {
@ -276,8 +278,8 @@ public class EmulationSurfaceView extends SurfaceView {
if (data.axisValues[i] == emuValue) if (data.axisValues[i] == emuValue)
continue; continue;
/*Log.d("EmulationSurfaceView", Log.d("EmulationSurfaceView",
String.format("axis %d value %f emuvalue %f", axis, axisValue, emuValue));*/ String.format("axis %d value %f emuvalue %f", axis, axisValue, emuValue));
data.axisValues[i] = emuValue; data.axisValues[i] = emuValue;
AndroidHostInterface.getInstance().handleControllerAxisEvent(data.controllerIndex, axis, emuValue); AndroidHostInterface.getInstance().handleControllerAxisEvent(data.controllerIndex, axis, emuValue);