1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

Add cursor shape support for the Android platform

This commit is contained in:
Fredia Huya-Kouadio
2022-10-05 10:43:36 -07:00
parent d81a253f9f
commit 46f091a803
10 changed files with 248 additions and 12 deletions

View File

@@ -568,6 +568,11 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
return mView.getHolder().getSurface();
}
@Keep
public GodotView getRenderView() { // used by native side to get renderView
return mView;
}
/**
* Used by the native code (java_godot_wrapper.h) to access the input fallback mapping.
* @return The input fallback mapping for the current XR mode.

View File

@@ -44,8 +44,12 @@ import org.godotengine.godot.xr.regular.RegularFallbackConfigChooser;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.PixelFormat;
import android.os.Build;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.PointerIcon;
import androidx.annotation.Keep;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
@@ -89,6 +93,10 @@ public class GodotView extends GLSurfaceView {
this.inputHandler = new GodotInputHandler(this);
this.godotRenderer = new GodotRenderer();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
setPointerIcon(PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_DEFAULT));
}
init(xrMode, p_translucent);
}
@@ -118,6 +126,24 @@ public class GodotView extends GLSurfaceView {
return inputHandler.onGenericMotionEvent(event) || super.onGenericMotionEvent(event);
}
/**
* Called from JNI to change the pointer icon
*/
@Keep
private void setPointerIcon(int pointerType) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
setPointerIcon(PointerIcon.getSystemIcon(getContext(), pointerType));
}
}
@Override
public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return getPointerIcon();
}
return super.onResolvePointerIcon(event, pointerIndex);
}
private void init(XRMode xrMode, boolean translucent) {
setPreserveEGLContextOnPause(true);
setFocusableInTouchMode(true);