You've already forked godot
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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user