annotate semiconginev2/platform/windows/window.nim @ 1219:c61658d2d227 compiletime-tests

del: old test file
author sam <sam@basx.dev>
date Wed, 17 Jul 2024 21:03:30 +0700
parents 56781cc0fc7c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1207
804ff842d377 fix: problems with include-structure on windows
sam@sambook-windows.localdomain
parents: 1191
diff changeset
1 import ../../thirdparty/winim/winim/inc/[windef, winuser, wincon, winbase]
804ff842d377 fix: problems with include-structure on windows
sam@sambook-windows.localdomain
parents: 1191
diff changeset
2 import ../../thirdparty/winim/winim/[winstr, utils]
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
3
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
4 include ./virtualkey_map
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
5
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
6 type
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
7 NativeWindow* = object
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
8 hinstance*: HINSTANCE
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
9 hwnd*: HWND
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
10 g_wpPrev: WINDOWPLACEMENT
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
11
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
12
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
13 # sorry, have to use module-global variable to capture windows events
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
14 var currentEvents: seq[Event]
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
15
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
16 template CheckWin32Result*(call: untyped) =
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
17 let value = call
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
18 if value == 0:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
19 raise newException(Exception, "Win32 error: " & astToStr(call) & " returned " & $value)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
20
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
21 let
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
22 andCursorMask = [0xff]
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
23 xorCursorMask = [0x00]
1207
804ff842d377 fix: problems with include-structure on windows
sam@sambook-windows.localdomain
parents: 1191
diff changeset
24 invisibleCursor = CreateCursor(0, 0, 0, 1, 1, pointer(addr andCursorMask), pointer(addr xorCursorMask))
804ff842d377 fix: problems with include-structure on windows
sam@sambook-windows.localdomain
parents: 1191
diff changeset
25 defaultCursor = LoadCursor(0, IDC_ARROW)
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
26 var currentCursor = defaultCursor
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
27
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
28 proc MapLeftRightKeys(key: INT, lparam: LPARAM): INT =
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
29 case key
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
30 of VK_SHIFT:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
31 MapVirtualKey(UINT((lParam and 0x00ff0000) shr 16), MAPVK_VSC_TO_VK_EX)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
32 of VK_CONTROL:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
33 if (lParam and 0x01000000) == 0: VK_LCONTROL else: VK_RCONTROL
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
34 of VK_MENU:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
35 if (lParam and 0x01000000) == 0: VK_LMENU else: VK_RMENU
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
36 else:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
37 key
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
38
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
39 proc WindowHandler(hwnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: LPARAM): LRESULT {.stdcall.} =
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
40 case uMsg
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
41 of WM_DESTROY:
1207
804ff842d377 fix: problems with include-structure on windows
sam@sambook-windows.localdomain
parents: 1191
diff changeset
42 currentEvents.add(Event(eventType: EventType.Quit))
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
43 of WM_KEYDOWN, WM_SYSKEYDOWN:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
44 let key = MapLeftRightKeys(INT(wParam), lParam)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
45 currentEvents.add(Event(eventType: KeyPressed, key: KeyTypeMap.getOrDefault(key, Key.UNKNOWN)))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
46 of WM_KEYUP, WM_SYSKEYUP:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
47 let key = MapLeftRightKeys(INT(wParam), lParam)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
48 currentEvents.add(Event(eventType: KeyReleased, key: KeyTypeMap.getOrDefault(key, Key.UNKNOWN)))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
49 of WM_LBUTTONDOWN:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
50 currentEvents.add(Event(eventType: MousePressed, button: MouseButton.Mouse1))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
51 of WM_LBUTTONUP:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
52 currentEvents.add(Event(eventType: MouseReleased, button: MouseButton.Mouse1))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
53 of WM_MBUTTONDOWN:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
54 currentEvents.add(Event(eventType: MousePressed, button: MouseButton.Mouse2))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
55 of WM_MBUTTONUP:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
56 currentEvents.add(Event(eventType: MouseReleased, button: MouseButton.Mouse2))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
57 of WM_RBUTTONDOWN:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
58 currentEvents.add(Event(eventType: MousePressed, button: MouseButton.Mouse3))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
59 of WM_RBUTTONUP:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
60 currentEvents.add(Event(eventType: MouseReleased, button: MouseButton.Mouse3))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
61 of WM_MOUSEMOVE:
1207
804ff842d377 fix: problems with include-structure on windows
sam@sambook-windows.localdomain
parents: 1191
diff changeset
62 currentEvents.add(Event(eventType: MouseMoved, x: GET_X_LPARAM(lParam), y: GET_Y_LPARAM(lParam)))
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
63 of WM_MOUSEWHEEL:
1207
804ff842d377 fix: problems with include-structure on windows
sam@sambook-windows.localdomain
parents: 1191
diff changeset
64 currentEvents.add(Event(eventType: MouseWheel, amount: float32(GET_WHEEL_DELTA_WPARAM(wParam)) / WHEEL_DELTA))
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
65 of WM_SIZING:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
66 currentEvents.add(Event(eventType: ResizedWindow))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
67 of WM_SIZE:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
68 if wParam == SIZE_MINIMIZED:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
69 currentEvents.add(Event(eventType: MinimizedWindow))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
70 elif wParam == SIZE_RESTORED:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
71 currentEvents.add(Event(eventType: RestoredWindow))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
72 of WM_SETCURSOR:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
73 if LOWORD(lParam) == HTCLIENT:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
74 SetCursor(currentCursor)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
75 return 1
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
76 else:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
77 return DefWindowProc(hwnd, uMsg, wParam, lParam)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
78 else:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
79 return DefWindowProc(hwnd, uMsg, wParam, lParam)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
80
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
81
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
82 proc CreateWindow*(title: string): NativeWindow =
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
83 when DEBUG:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
84 AllocConsole()
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
85 discard stdin.reopen("conIN$", fmRead)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
86 discard stdout.reopen("conOUT$", fmWrite)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
87 discard stderr.reopen("conOUT$", fmWrite)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
88
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
89 result.hInstance = HINSTANCE(GetModuleHandle(nil))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
90 var
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
91 windowClassName = T"EngineWindowClass"
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
92 windowName = T(title)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
93 windowClass = WNDCLASSEX(
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
94 cbSize: UINT(WNDCLASSEX.sizeof),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
95 lpfnWndProc: WindowHandler,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
96 hInstance: result.hInstance,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
97 lpszClassName: windowClassName,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
98 hcursor: currentCursor,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
99 )
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
100
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
101 if(RegisterClassEx(addr(windowClass)) == 0):
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
102 raise newException(Exception, "Unable to register window class")
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
103
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
104 result.hwnd = CreateWindowEx(
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
105 DWORD(0),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
106 windowClassName,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
107 windowName,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
108 DWORD(WS_OVERLAPPEDWINDOW),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
109 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
110 HMENU(0),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
111 HINSTANCE(0),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
112 result.hInstance,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
113 nil
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
114 )
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
115
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
116 result.g_wpPrev.length = UINT(sizeof(WINDOWPLACEMENT))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
117 discard result.hwnd.ShowWindow(SW_SHOW)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
118
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
119 proc SetTitle*(window: NativeWindow, title: string) =
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
120 window.hwnd.SetWindowText(T(title))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
121
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
122 # inspired by the one and only, Raymond Chen
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
123 # https://devblogs.microsoft.com/oldnewthing/20100412-00/?p=14353
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
124 proc Fullscreen*(window: var NativeWindow, enable: bool) =
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
125 let dwStyle: DWORD = GetWindowLong(window.hwnd, GWL_STYLE)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
126 if enable:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
127 var mi = MONITORINFO(cbSize: DWORD(sizeof(MONITORINFO)))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
128 if GetWindowPlacement(window.hwnd, addr window.g_wpPrev) and GetMonitorInfo(MonitorFromWindow(window.hwnd, MONITOR_DEFAULTTOPRIMARY), addr mi):
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
129 SetWindowLong(window.hwnd, GWL_STYLE, dwStyle and (not WS_OVERLAPPEDWINDOW))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
130 SetWindowPos(window.hwnd, HWND_TOP, mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right - mi.rcMonitor.left, mi.rcMonitor.bottom - mi.rcMonitor.top, SWP_NOOWNERZORDER or SWP_FRAMECHANGED)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
131 else:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
132 SetWindowLong(window.hwnd, GWL_STYLE, dwStyle or WS_OVERLAPPEDWINDOW)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
133 SetWindowPlacement(window.hwnd, addr window.g_wpPrev)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
134 SetWindowPos(window.hwnd, HWND(0), 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE or SWP_NOZORDER or SWP_NOOWNERZORDER or SWP_FRAMECHANGED)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
135
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
136 proc HideSystemCursor*(window: NativeWindow) =
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
137 currentCursor = invisibleCursor
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
138 SetCursor(currentCursor)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
139
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
140 proc ShowSystemCursor*(window: NativeWindow) =
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
141 currentCursor = defaultCursor
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
142 SetCursor(currentCursor)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
143
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
144 proc Destroy*(window: NativeWindow) =
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
145 discard
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
146
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
147 proc Size*(window: NativeWindow): (int, int) =
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
148 var rect: RECT
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
149 CheckWin32Result GetWindowRect(window.hwnd, addr(rect))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
150 (int(rect.right - rect.left), int(rect.bottom - rect.top))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
151
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
152 proc PendingEvents*(window: NativeWindow): seq[Event] =
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
153 # empty queue
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
154 currentEvents = newSeq[Event]()
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
155 var msg: MSG
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
156 # fill queue
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
157 while PeekMessage(addr(msg), window.hwnd, 0, 0, PM_REMOVE):
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
158 TranslateMessage(addr(msg))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
159 DispatchMessage(addr(msg))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
160 return currentEvents
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
161
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
162 proc GetMousePosition*(window: NativeWindow): Option[Vec2f] =
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
163 var p: POINT
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
164 let res = GetCursorPos(addr(p))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
165 if res:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
166 return some(Vec2f([float32(p.x), float32(p.y)]))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents:
diff changeset
167 return none(Vec2f)