Added better mouse recapture.
This commit is contained in:
parent
7b0a1ca0e7
commit
dbb2e8a40f
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue