# HG changeset patch # User sam # Date 1723044136 -25200 # Node ID 5a898b18a58a04c00138d96d75308c06639a1cb8 # Parent 7be3628298f549459fb72e96dfe1d84353c8574e fix: mouse lock on windows diff -r 7be3628298f5 -r 5a898b18a58a semicongine/input.nim --- 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 diff -r 7be3628298f5 -r 5a898b18a58a semicongine/rendering/platform/windows.nim --- 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