From 664403884d685031014b4984733e2bd395f90409 Mon Sep 17 00:00:00 2001 From: kone <70107937+konekowo@users.noreply.github.com> Date: Tue, 18 Apr 2023 23:07:02 -0400 Subject: [PATCH] mobile support part 1 --- .../lax1dude/eaglercraft/v1_8/internal/PlatformInput.java | 6 +++--- .../lax1dude/eaglercraft/v1_8/internal/PlatformRuntime.java | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformInput.java b/src/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformInput.java index 243f7981..6e5f101e 100644 --- a/src/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformInput.java +++ b/src/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformInput.java @@ -515,7 +515,7 @@ public class PlatformInput { pointerLockFlag = grab; mouseGrabTimer = t; if (grab) { - canvas.requestPointerLock(); + if (!PlatformRuntime.isMobile) canvas.requestPointerLock(); if (mouseUngrabTimeout != -1) Window.clearTimeout(mouseUngrabTimeout); mouseUngrabTimeout = -1; if (t - mouseUngrabTimer < 3000l) { @@ -524,7 +524,7 @@ public class PlatformInput { new TimerHandler() { @Override public void onTimer() { - canvas.requestPointerLock(); + if (!PlatformRuntime.isMobile) canvas.requestPointerLock(); } }, 3100 - (int) (t - mouseUngrabTimer) @@ -533,7 +533,7 @@ public class PlatformInput { } else { if (mouseUngrabTimeout != -1) Window.clearTimeout(mouseUngrabTimeout); mouseUngrabTimeout = -1; - Window.current().getDocument().exitPointerLock(); + if (!PlatformRuntime.isMobile) Window.current().getDocument().exitPointerLock(); } mouseDX = 0.0D; mouseDY = 0.0D; diff --git a/src/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformRuntime.java b/src/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformRuntime.java index 589a5995..64fd5ea1 100644 --- a/src/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformRuntime.java +++ b/src/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/PlatformRuntime.java @@ -72,6 +72,7 @@ public class PlatformRuntime { public static HTMLElement parent = null; public static HTMLCanvasElement canvas = null; public static WebGL2RenderingContext webgl = null; + public static boolean isMobile = false; static WebGLFramebuffer mainFramebuffer = null; @@ -119,7 +120,8 @@ public class PlatformRuntime { try { doc.exitPointerLock(); } catch (Throwable t) { - throw new PlatformIncompatibleException("Mouse cursor lock is not available on this device!"); + isMobile = true; + //throw new PlatformIncompatibleException("Mouse cursor lock is not available on this device!"); } logger.info("Creating WebGL context");