Mercurial > games > semicongine
diff semiconginev2/input.nim @ 1254:b0f4c8ccd49a
did: stuff to test gltf importer
author | sam <sam@basx.dev> |
---|---|
date | Sat, 27 Jul 2024 20:47:54 +0700 |
parents | 56781cc0fc7c |
children | bfb75c934f4e |
line wrap: on
line diff
--- a/semiconginev2/input.nim Fri Jul 26 23:39:24 2024 +0700 +++ b/semiconginev2/input.nim Sat Jul 27 20:47:54 2024 +0700 @@ -11,6 +11,7 @@ mouseWheel: float32 windowWasResized: bool = true windowIsMinimized: bool = false + lockMouse: bool = false # warning, shit is not thread safe var input: Input @@ -25,6 +26,9 @@ input.mouseMove = NewVec2f() input.windowWasResized = false + if input.lockMouse: + SetMousePosition(vulkan.window, x=int(vulkan.swapchain.width div 2), y=int(vulkan.swapchain.height div 2)) + var killed = false for event in vulkan.window.PendingEvents(): case event.eventType: @@ -72,10 +76,12 @@ proc MousePositionNormalized*(size: (int, int)): Vec2f = result.x = (input.mousePosition.x / float32(size[0])) * 2.0 - 1.0 result.y = (input.mousePosition.y / float32(size[1])) * 2.0 - 1.0 -proc MouseMove*(): auto = input.mouseMove -proc MouseWheel*(): auto = input.mouseWheel +proc MouseMove*(): Vec2f = input.mouseMove +proc MouseWheel*(): float32 = input.mouseWheel proc WindowWasResized*(): auto = input.windowWasResized proc WindowIsMinimized*(): auto = input.windowIsMinimized +proc LockMouse*(value: bool) = input.lockMouse = value + # actions as a slight abstraction over raw input