Mercurial > games > semicongine
changeset 1307:5a898b18a58a
fix: mouse lock on windows
author | sam <sam@basx.dev> |
---|---|
date | Wed, 07 Aug 2024 22:22:16 +0700 |
parents | 7be3628298f5 |
children | 196bfc6af8e0 |
files | semicongine/input.nim semicongine/rendering/platform/windows.nim |
diffstat | 2 files changed, 2 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/semicongine/input.nim Wed Aug 07 20:58:11 2024 +0700 +++ b/semicongine/input.nim Wed Aug 07 22:22:16 2024 +0700 @@ -35,11 +35,7 @@ input.mouseMove = vec2i(0, 0) input.windowWasResized = false - # if input.lockMouse and input.hasFocus: - # setMousePosition(vulkan.window, x=int(vulkan.swapchain.width div 2), y=int(vulkan.swapchain.height div 2)) - let newMousePos = getMousePosition(vulkan.window) - input.mouseMove = newMousePos - input.mousePosition if input.lockMouse and input.hasFocus: input.mousePosition = vulkan.window.size div 2
--- a/semicongine/rendering/platform/windows.nim Wed Aug 07 20:58:11 2024 +0700 +++ b/semicongine/rendering/platform/windows.nim Wed Aug 07 22:22:16 2024 +0700 @@ -205,8 +205,8 @@ proc setMousePosition*(window: NativeWindow, pos: Vec2i) = var p = POINT(x: pos.x, y: pos.y) - discard window.hwnd.ScreenToClient(addr(p)) - discard SetCursorPos(pos.x, pos.y) + discard window.hwnd.ClientToScreen(addr(p)) + discard SetCursorPos(p.x, p.y) proc createNativeSurface*(instance: VkInstance, window: NativeWindow): VkSurfaceKHR = assert instance.Valid