1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Android: Allow Mouse Capture

This commit is contained in:
thebestnom
2020-11-01 03:30:40 +02:00
parent 90bdba576a
commit e7f259c366
12 changed files with 209 additions and 13 deletions

View File

@@ -988,4 +988,9 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
public void initInputDevices() {
mRenderView.initInputDevices();
}
@Keep
private GodotRenderView getRenderView() { // used by native side to get renderView
return mRenderView;
}
}

View File

@@ -144,6 +144,11 @@ public class GodotGLRenderView extends GLSurfaceView implements GodotRenderView
return inputHandler.onGenericMotionEvent(event) || super.onGenericMotionEvent(event);
}
@Override
public boolean onCapturedPointerEvent(MotionEvent event) {
return inputHandler.onGenericMotionEvent(event);
}
private void init(XRMode xrMode, boolean translucent, int depth, int stencil) {
setPreserveEGLContextOnPause(true);
setFocusableInTouchMode(true);

View File

@@ -119,6 +119,11 @@ public class GodotVulkanRenderView extends VkSurfaceView implements GodotRenderV
return mInputHandler.onGenericMotionEvent(event);
}
@Override
public boolean onCapturedPointerEvent(MotionEvent event) {
return mInputHandler.onGenericMotionEvent(event);
}
@Override
public void onResume() {
super.onResume();

View File

@@ -245,7 +245,7 @@ public class GodotInputHandler implements InputDeviceListener {
}
});
return true;
} else if ((event.getSource() & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE) {
} else if (event.isFromSource(InputDevice.SOURCE_MOUSE) || event.isFromSource(InputDevice.SOURCE_MOUSE_RELATIVE)) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return handleMouseEvent(event);
}
@@ -462,6 +462,11 @@ public class GodotInputHandler implements InputDeviceListener {
}
});
}
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_UP: {
// we can safely ignore these cases because they are always come beside ACTION_BUTTON_PRESS and ACTION_BUTTON_RELEASE
return true;
}
}
return false;
}