|
@@ -97,22 +97,12 @@ public class GodotInputHandler implements InputDeviceListener {
|
|
final int button = getGodotButton(keyCode);
|
|
final int button = getGodotButton(keyCode);
|
|
final int godotJoyId = mJoystickIds.get(deviceId);
|
|
final int godotJoyId = mJoystickIds.get(deviceId);
|
|
|
|
|
|
- queueEvent(new Runnable() {
|
|
|
|
- @Override
|
|
|
|
- public void run() {
|
|
|
|
- GodotLib.joybutton(godotJoyId, button, false);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ queueEvent(() -> GodotLib.joybutton(godotJoyId, button, false));
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
final int scanCode = event.getScanCode();
|
|
final int scanCode = event.getScanCode();
|
|
final int chr = event.getUnicodeChar(0);
|
|
final int chr = event.getUnicodeChar(0);
|
|
- queueEvent(new Runnable() {
|
|
|
|
- @Override
|
|
|
|
- public void run() {
|
|
|
|
- GodotLib.key(keyCode, scanCode, chr, false);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ queueEvent(() -> GodotLib.key(keyCode, scanCode, chr, false));
|
|
}
|
|
}
|
|
|
|
|
|
return true;
|
|
return true;
|
|
@@ -143,22 +133,12 @@ public class GodotInputHandler implements InputDeviceListener {
|
|
final int button = getGodotButton(keyCode);
|
|
final int button = getGodotButton(keyCode);
|
|
final int godotJoyId = mJoystickIds.get(deviceId);
|
|
final int godotJoyId = mJoystickIds.get(deviceId);
|
|
|
|
|
|
- queueEvent(new Runnable() {
|
|
|
|
- @Override
|
|
|
|
- public void run() {
|
|
|
|
- GodotLib.joybutton(godotJoyId, button, true);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ queueEvent(() -> GodotLib.joybutton(godotJoyId, button, true));
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
final int scanCode = event.getScanCode();
|
|
final int scanCode = event.getScanCode();
|
|
final int chr = event.getUnicodeChar(0);
|
|
final int chr = event.getUnicodeChar(0);
|
|
- queueEvent(new Runnable() {
|
|
|
|
- @Override
|
|
|
|
- public void run() {
|
|
|
|
- GodotLib.key(keyCode, scanCode, chr, true);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ queueEvent(() -> GodotLib.key(keyCode, scanCode, chr, true));
|
|
}
|
|
}
|
|
|
|
|
|
return true;
|
|
return true;
|
|
@@ -190,19 +170,16 @@ public class GodotInputHandler implements InputDeviceListener {
|
|
final int action = event.getActionMasked();
|
|
final int action = event.getActionMasked();
|
|
final int pointer_idx = event.getPointerId(event.getActionIndex());
|
|
final int pointer_idx = event.getPointerId(event.getActionIndex());
|
|
|
|
|
|
- mRenderView.queueOnRenderThread(new Runnable() {
|
|
|
|
- @Override
|
|
|
|
- public void run() {
|
|
|
|
- switch (action) {
|
|
|
|
- case MotionEvent.ACTION_DOWN:
|
|
|
|
- case MotionEvent.ACTION_CANCEL:
|
|
|
|
- case MotionEvent.ACTION_UP:
|
|
|
|
- case MotionEvent.ACTION_MOVE:
|
|
|
|
- case MotionEvent.ACTION_POINTER_UP:
|
|
|
|
- case MotionEvent.ACTION_POINTER_DOWN: {
|
|
|
|
- GodotLib.touch(event.getSource(), action, pointer_idx, evcount, arr);
|
|
|
|
- } break;
|
|
|
|
- }
|
|
|
|
|
|
+ mRenderView.queueOnRenderThread(() -> {
|
|
|
|
+ switch (action) {
|
|
|
|
+ case MotionEvent.ACTION_DOWN:
|
|
|
|
+ case MotionEvent.ACTION_CANCEL:
|
|
|
|
+ case MotionEvent.ACTION_UP:
|
|
|
|
+ case MotionEvent.ACTION_MOVE:
|
|
|
|
+ case MotionEvent.ACTION_POINTER_UP:
|
|
|
|
+ case MotionEvent.ACTION_POINTER_DOWN: {
|
|
|
|
+ GodotLib.touch(event.getSource(), action, pointer_idx, evcount, arr);
|
|
|
|
+ } break;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -228,13 +205,7 @@ public class GodotInputHandler implements InputDeviceListener {
|
|
// save value to prevent repeats
|
|
// save value to prevent repeats
|
|
joystick.axesValues.put(axis, value);
|
|
joystick.axesValues.put(axis, value);
|
|
final int godotAxisIdx = i;
|
|
final int godotAxisIdx = i;
|
|
- queueEvent(new Runnable() {
|
|
|
|
- @Override
|
|
|
|
- public void run() {
|
|
|
|
- GodotLib.joyaxis(godotJoyId, godotAxisIdx, value);
|
|
|
|
- //Log.i(tag, "GodotLib.joyaxis("+godotJoyId+", "+godotAxisIdx+", "+value+");");
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ queueEvent(() -> GodotLib.joyaxis(godotJoyId, godotAxisIdx, value));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -244,13 +215,7 @@ public class GodotInputHandler implements InputDeviceListener {
|
|
if (joystick.hatX != hatX || joystick.hatY != hatY) {
|
|
if (joystick.hatX != hatX || joystick.hatY != hatY) {
|
|
joystick.hatX = hatX;
|
|
joystick.hatX = hatX;
|
|
joystick.hatY = hatY;
|
|
joystick.hatY = hatY;
|
|
- queueEvent(new Runnable() {
|
|
|
|
- @Override
|
|
|
|
- public void run() {
|
|
|
|
- GodotLib.joyhat(godotJoyId, hatX, hatY);
|
|
|
|
- //Log.i(tag, "GodotLib.joyhat("+godotJoyId+", "+hatX+", "+hatY+");");
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ queueEvent(() -> GodotLib.joyhat(godotJoyId, hatX, hatY));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
return true;
|
|
@@ -259,12 +224,7 @@ public class GodotInputHandler implements InputDeviceListener {
|
|
final float x = event.getX();
|
|
final float x = event.getX();
|
|
final float y = event.getY();
|
|
final float y = event.getY();
|
|
final int type = event.getAction();
|
|
final int type = event.getAction();
|
|
- queueEvent(new Runnable() {
|
|
|
|
- @Override
|
|
|
|
- public void run() {
|
|
|
|
- GodotLib.hover(type, x, y);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ queueEvent(() -> GodotLib.hover(type, x, y));
|
|
return true;
|
|
return true;
|
|
|
|
|
|
} else if (event.isFromSource(InputDevice.SOURCE_MOUSE) || event.isFromSource(InputDevice.SOURCE_MOUSE_RELATIVE)) {
|
|
} else if (event.isFromSource(InputDevice.SOURCE_MOUSE) || event.isFromSource(InputDevice.SOURCE_MOUSE_RELATIVE)) {
|
|
@@ -356,12 +316,7 @@ public class GodotInputHandler implements InputDeviceListener {
|
|
}
|
|
}
|
|
mJoysticksDevices.put(deviceId, joystick);
|
|
mJoysticksDevices.put(deviceId, joystick);
|
|
|
|
|
|
- queueEvent(new Runnable() {
|
|
|
|
- @Override
|
|
|
|
- public void run() {
|
|
|
|
- GodotLib.joyconnectionchanged(id, true, joystick.name);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ queueEvent(() -> GodotLib.joyconnectionchanged(id, true, joystick.name));
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -374,12 +329,7 @@ public class GodotInputHandler implements InputDeviceListener {
|
|
mJoystickIds.delete(deviceId);
|
|
mJoystickIds.delete(deviceId);
|
|
mJoysticksDevices.delete(deviceId);
|
|
mJoysticksDevices.delete(deviceId);
|
|
|
|
|
|
- queueEvent(new Runnable() {
|
|
|
|
- @Override
|
|
|
|
- public void run() {
|
|
|
|
- GodotLib.joyconnectionchanged(godotJoyId, false, "");
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ queueEvent(() -> GodotLib.joyconnectionchanged(godotJoyId, false, ""));
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -468,12 +418,7 @@ public class GodotInputHandler implements InputDeviceListener {
|
|
final float x = event.getX();
|
|
final float x = event.getX();
|
|
final float y = event.getY();
|
|
final float y = event.getY();
|
|
final int type = event.getAction();
|
|
final int type = event.getAction();
|
|
- queueEvent(new Runnable() {
|
|
|
|
- @Override
|
|
|
|
- public void run() {
|
|
|
|
- GodotLib.hover(type, x, y);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ queueEvent(() -> GodotLib.hover(type, x, y));
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
case MotionEvent.ACTION_BUTTON_PRESS:
|
|
case MotionEvent.ACTION_BUTTON_PRESS:
|
|
@@ -483,12 +428,7 @@ public class GodotInputHandler implements InputDeviceListener {
|
|
final float y = event.getY();
|
|
final float y = event.getY();
|
|
final int buttonsMask = event.getButtonState();
|
|
final int buttonsMask = event.getButtonState();
|
|
final int action = event.getAction();
|
|
final int action = event.getAction();
|
|
- queueEvent(new Runnable() {
|
|
|
|
- @Override
|
|
|
|
- public void run() {
|
|
|
|
- GodotLib.touch(event.getSource(), action, 0, 1, new float[] { 0, x, y }, buttonsMask);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ queueEvent(() -> GodotLib.touch(event.getSource(), action, 0, 1, new float[] { 0, x, y }, buttonsMask));
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
case MotionEvent.ACTION_SCROLL: {
|
|
case MotionEvent.ACTION_SCROLL: {
|
|
@@ -498,12 +438,7 @@ public class GodotInputHandler implements InputDeviceListener {
|
|
final int action = event.getAction();
|
|
final int action = event.getAction();
|
|
final float verticalFactor = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
|
|
final float verticalFactor = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
|
|
final float horizontalFactor = event.getAxisValue(MotionEvent.AXIS_HSCROLL);
|
|
final float horizontalFactor = event.getAxisValue(MotionEvent.AXIS_HSCROLL);
|
|
- queueEvent(new Runnable() {
|
|
|
|
- @Override
|
|
|
|
- public void run() {
|
|
|
|
- GodotLib.touch(event.getSource(), action, 0, 1, new float[] { 0, x, y }, buttonsMask, verticalFactor, horizontalFactor);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ queueEvent(() -> GodotLib.touch(event.getSource(), action, 0, 1, new float[] { 0, x, y }, buttonsMask, verticalFactor, horizontalFactor));
|
|
}
|
|
}
|
|
case MotionEvent.ACTION_DOWN:
|
|
case MotionEvent.ACTION_DOWN:
|
|
case MotionEvent.ACTION_UP: {
|
|
case MotionEvent.ACTION_UP: {
|