diff --git a/client/src/main/java/nl/andrewl/aos2_client/control/context/NormalContext.java b/client/src/main/java/nl/andrewl/aos2_client/control/context/NormalContext.java index 70e9385..9794b72 100644 --- a/client/src/main/java/nl/andrewl/aos2_client/control/context/NormalContext.java +++ b/client/src/main/java/nl/andrewl/aos2_client/control/context/NormalContext.java @@ -3,6 +3,7 @@ package nl.andrewl.aos2_client.control.context; import nl.andrewl.aos2_client.Camera; import nl.andrewl.aos2_client.control.InputContext; import nl.andrewl.aos2_client.control.InputHandler; +import nl.andrewl.aos2_client.util.WindowUtils; import nl.andrewl.aos_core.model.item.BlockItemStack; import nl.andrewl.aos_core.model.item.GunItemStack; import nl.andrewl.aos_core.model.item.ItemStack; @@ -81,6 +82,9 @@ public class NormalContext implements InputContext { hitting = false; interacting = false; reloading = false; + var size = WindowUtils.getSize(inputHandler.getWindowId()); + lastMouseCursorX = size.first() / 2f; + lastMouseCursorY = size.second() / 2f; updateInputState(); } diff --git a/client/src/main/java/nl/andrewl/aos2_client/render/GameRenderer.java b/client/src/main/java/nl/andrewl/aos2_client/render/GameRenderer.java index bbee304..b7afd74 100644 --- a/client/src/main/java/nl/andrewl/aos2_client/render/GameRenderer.java +++ b/client/src/main/java/nl/andrewl/aos2_client/render/GameRenderer.java @@ -94,6 +94,9 @@ public class GameRenderer { glfwSetMouseButtonCallback(windowHandle, new PlayerInputMouseClickCallback(inputHandler)); glfwSetScrollCallback(windowHandle, new PlayerInputMouseScrollCallback(inputHandler)); glfwSetCharCallback(windowHandle, new PlayerCharacterInputCallback(inputHandler)); + glfwSetWindowFocusCallback(windowHandle, (window, focused) -> { + if (!focused) inputHandler.switchToExitMenuContext(); + }); if (config.captureCursor) { glfwSetInputMode(windowHandle, GLFW_CURSOR, GLFW_CURSOR_DISABLED); }