user32.odin 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. // +build windows
  2. package sys_windows
  3. foreign import user32 "system:User32.lib"
  4. @(default_calling_convention="stdcall")
  5. foreign user32 {
  6. GetClassInfoW :: proc(hInstance: HINSTANCE, lpClassNAme: LPCWSTR, lpWndClass: ^WNDCLASSW) -> BOOL ---
  7. GetClassInfoExW :: proc(hInsatnce: HINSTANCE, lpszClass: LPCWSTR, lpwcx: ^WNDCLASSEXW) -> BOOL ---
  8. GetClassLongW :: proc(hWnd: HWND, nIndex: c_int) -> DWORD ---
  9. SetClassLongW :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG) -> DWORD ---
  10. GetWindowLongW :: proc(hWnd: HWND, nIndex: c_int) -> LONG ---
  11. SetWindowLongW :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG) -> LONG ---
  12. GetClassNameW :: proc(hWnd: HWND, lpClassName: LPWSTR, nMaxCount: c_int) -> c_int ---
  13. RegisterClassW :: proc(lpWndClass: ^WNDCLASSW) -> ATOM ---
  14. RegisterClassExW :: proc(^WNDCLASSEXW) -> ATOM ---
  15. UnregisterClassW :: proc(lpClassName: LPCWSTR, hInstance: HINSTANCE) -> BOOL ---
  16. CreateWindowExW :: proc(
  17. dwExStyle: DWORD,
  18. lpClassName: LPCWSTR,
  19. lpWindowName: LPCWSTR,
  20. dwStyle: DWORD,
  21. X: c_int,
  22. Y: c_int,
  23. nWidth: c_int,
  24. nHeight: c_int,
  25. hWndParent: HWND,
  26. hMenu: HMENU,
  27. hInstance: HINSTANCE,
  28. lpParam: LPVOID,
  29. ) -> HWND ---
  30. DestroyWindow :: proc(hWnd: HWND) -> BOOL ---
  31. ShowWindow :: proc(hWnd: HWND, nCmdShow: c_int) -> BOOL ---
  32. IsWindow :: proc(hWnd: HWND) -> BOOL ---
  33. BringWindowToTop :: proc(hWnd: HWND) -> BOOL ---
  34. GetTopWindow :: proc(hWnd: HWND) -> HWND ---
  35. SetForegroundWindow :: proc(hWnd: HWND) -> BOOL ---
  36. GetForegroundWindow :: proc() -> HWND ---
  37. UpdateWindow :: proc(hWnd: HWND) -> BOOL ---
  38. SetActiveWindow :: proc(hWnd: HWND) -> HWND ---
  39. GetActiveWindow :: proc() -> HWND ---
  40. GetMessageW :: proc(lpMsg: ^MSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT) -> BOOL ---
  41. TranslateMessage :: proc(lpMsg: ^MSG) -> BOOL ---
  42. DispatchMessageW :: proc(lpMsg: ^MSG) -> LRESULT ---
  43. WaitMessage :: proc() -> BOOL ---
  44. PeekMessageA :: proc(lpMsg: ^MSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT, wRemoveMsg: UINT) -> BOOL ---
  45. PeekMessageW :: proc(lpMsg: ^MSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT, wRemoveMsg: UINT) -> BOOL ---
  46. PostMessageA :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> BOOL ---
  47. PostMessageW :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> BOOL ---
  48. SendMessageA :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  49. SendMessageW :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  50. PostThreadMessageA :: proc(idThread: DWORD, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> BOOL ---
  51. PostThreadMessageW :: proc(idThread: DWORD, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> BOOL ---
  52. PostQuitMessage :: proc(nExitCode: c_int) ---
  53. GetQueueStatus :: proc(flags: UINT) -> DWORD ---
  54. DefWindowProcA :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  55. DefWindowProcW :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  56. FindWindowA :: proc(lpClassName: LPCSTR, lpWindowName: LPCSTR) -> HWND ---
  57. FindWindowW :: proc(lpClassName: LPCWSTR, lpWindowName: LPCWSTR) -> HWND ---
  58. FindWindowExA :: proc(hWndParent: HWND, hWndChildAfter: HWND, lpszClass: LPCSTR, lpszWindow: LPCSTR) -> HWND ---
  59. FindWindowExW :: proc(hWndParent: HWND, hWndChildAfter: HWND, lpszClass: LPCWSTR, lpszWindow: LPCWSTR) -> HWND ---
  60. LoadIconA :: proc(hInstance: HINSTANCE, lpIconName: LPCSTR) -> HICON ---
  61. LoadIconW :: proc(hInstance: HINSTANCE, lpIconName: LPCWSTR) -> HICON ---
  62. LoadCursorA :: proc(hInstance: HINSTANCE, lpCursorName: LPCSTR) -> HCURSOR ---
  63. LoadCursorW :: proc(hInstance: HINSTANCE, lpCursorName: LPCWSTR) -> HCURSOR ---
  64. LoadImageW :: proc(hInst: HINSTANCE, name: LPCWSTR, type: UINT, cx: c_int, cy: c_int, fuLoad: UINT) -> HANDLE ---
  65. GetWindowRect :: proc(hWnd: HWND, lpRect: LPRECT) -> BOOL ---
  66. GetClientRect :: proc(hWnd: HWND, lpRect: LPRECT) -> BOOL ---
  67. ClientToScreen :: proc(hWnd: HWND, lpPoint: LPPOINT) -> BOOL ---
  68. ScreenToClient :: proc(hWnd: HWND, lpPoint: LPPOINT) -> BOOL ---
  69. SetWindowPos :: proc(
  70. hWnd: HWND,
  71. hWndInsertAfter: HWND,
  72. X: c_int,
  73. Y: c_int,
  74. cx: c_int,
  75. cy: c_int,
  76. uFlags: UINT,
  77. ) -> BOOL ---
  78. MoveWindow :: proc(hWnd: HWND, X, Y, hWidth, hHeight: c_int, bRepaint: BOOL) -> BOOL ---
  79. GetSystemMetrics :: proc(nIndex: c_int) -> c_int ---
  80. AdjustWindowRect :: proc(lpRect: LPRECT, dwStyle: DWORD, bMenu: BOOL) -> BOOL ---
  81. AdjustWindowRectEx :: proc(lpRect: LPRECT, dwStyle: DWORD, bMenu: BOOL, dwExStyle: DWORD) -> BOOL ---
  82. AdjustWindowRectExForDpi :: proc(lpRect: LPRECT, dwStyle: DWORD, bMenu: BOOL, dwExStyle: DWORD, dpi: UINT) -> BOOL ---
  83. SystemParametersInfoW :: proc(uiAction, uiParam: UINT, pvParam: PVOID, fWinIni: UINT) -> BOOL ---
  84. GetMonitorInfoW :: proc(hMonitor: HMONITOR, lpmi: LPMONITORINFO) -> BOOL ---
  85. GetWindowDC :: proc(hWnd: HWND) -> HDC ---
  86. GetDC :: proc(hWnd: HWND) -> HDC ---
  87. ReleaseDC :: proc(hWnd: HWND, hDC: HDC) -> c_int ---
  88. GetDlgCtrlID :: proc(hWnd: HWND) -> c_int ---
  89. GetDlgItem :: proc(hDlg: HWND, nIDDlgItem: c_int) -> HWND ---
  90. CreatePopupMenu :: proc() -> HMENU ---
  91. DestroyMenu :: proc(hMenu: HMENU) -> BOOL ---
  92. AppendMenuW :: proc(hMenu: HMENU, uFlags: UINT, uIDNewItem: UINT_PTR, lpNewItem: LPCWSTR) -> BOOL ---
  93. TrackPopupMenu :: proc(hMenu: HMENU, uFlags: UINT, x: int, y: int, nReserved: int, hWnd: HWND, prcRect: ^RECT) -> i32 ---
  94. RegisterWindowMessageW :: proc(lpString: LPCWSTR) -> UINT ---
  95. GetUpdateRect :: proc(hWnd: HWND, lpRect: LPRECT, bErase: BOOL) -> BOOL ---
  96. ValidateRect :: proc(hWnd: HWND, lpRect: ^RECT) -> BOOL ---
  97. InvalidateRect :: proc(hWnd: HWND, lpRect: ^RECT, bErase: BOOL) -> BOOL ---
  98. BeginPaint :: proc(hWnd: HWND, lpPaint: ^PAINTSTRUCT) -> HDC ---
  99. EndPaint :: proc(hWnd: HWND, lpPaint: ^PAINTSTRUCT) -> BOOL ---
  100. GetCapture :: proc() -> HWND ---
  101. SetCapture :: proc(hWnd: HWND) -> HWND ---
  102. ReleaseCapture :: proc() -> BOOL ---
  103. TrackMouseEvent :: proc(lpEventTrack: LPTRACKMOUSEEVENT) -> BOOL ---
  104. GetKeyState :: proc(nVirtKey: c_int) -> SHORT ---
  105. GetAsyncKeyState :: proc(vKey: c_int) -> SHORT ---
  106. GetKeyboardState :: proc(lpKeyState: PBYTE) -> BOOL ---
  107. MapVirtualKeyW :: proc(uCode: UINT, uMapType: UINT) -> UINT ---
  108. ToUnicode :: proc(nVirtKey: UINT, wScanCode: UINT, lpKeyState: ^BYTE, pwszBuff: LPWSTR, cchBuff: c_int, wFlags: UINT) -> c_int ---
  109. SetWindowsHookExW :: proc(idHook: c_int, lpfn: HOOKPROC, hmod: HINSTANCE, dwThreadId: DWORD) -> HHOOK ---
  110. UnhookWindowsHookEx :: proc(hhk: HHOOK) -> BOOL ---
  111. CallNextHookEx :: proc(hhk: HHOOK, nCode: c_int, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  112. SetTimer :: proc(hWnd: HWND, nIDEvent: UINT_PTR, uElapse: UINT, lpTimerFunc: TIMERPROC) -> UINT_PTR ---
  113. KillTimer :: proc(hWnd: HWND, uIDEvent: UINT_PTR) -> BOOL ---
  114. // MessageBoxA :: proc(hWnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT) -> c_int ---
  115. MessageBoxW :: proc(hWnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: UINT) -> c_int ---
  116. // MessageBoxExA :: proc(hWnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT, wLanguageId: WORD) -> c_int ---
  117. MessageBoxExW :: proc(hWnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: UINT, wLanguageId: WORD) -> c_int ---
  118. ClipCursor :: proc(lpRect: LPRECT) -> BOOL ---
  119. GetCursorPos :: proc(lpPoint: LPPOINT) -> BOOL ---
  120. SetCursorPos :: proc(X: c_int, Y: c_int) -> BOOL ---
  121. SetCursor :: proc(hCursor: HCURSOR) -> HCURSOR ---
  122. EnumDisplaySettingsW :: proc(lpszDeviceName: LPCWSTR, iModeNum: DWORD, lpDevMode: ^DEVMODEW) -> BOOL ---
  123. MonitorFromPoint :: proc(pt: POINT, dwFlags: Monitor_From_Flags) -> HMONITOR ---
  124. MonitorFromRect :: proc(lprc: LPRECT, dwFlags: Monitor_From_Flags) -> HMONITOR ---
  125. MonitorFromWindow :: proc(hwnd: HWND, dwFlags: Monitor_From_Flags) -> HMONITOR ---
  126. EnumDisplayMonitors :: proc(hdc: HDC, lprcClip: LPRECT, lpfnEnum: Monitor_Enum_Proc, dwData: LPARAM) -> BOOL ---
  127. EnumWindows :: proc(lpEnumFunc: Window_Enum_Proc, lParam: LPARAM) -> BOOL ---
  128. SetThreadDpiAwarenessContext :: proc(dpiContext: DPI_AWARENESS_CONTEXT) -> DPI_AWARENESS_CONTEXT ---
  129. GetThreadDpiAwarenessContext :: proc() -> DPI_AWARENESS_CONTEXT ---
  130. GetWindowDpiAwarenessContext :: proc(hwnd: HWND) -> DPI_AWARENESS_CONTEXT ---
  131. GetDpiFromDpiAwarenessContext :: proc(value: DPI_AWARENESS_CONTEXT) -> UINT ---
  132. GetDpiForWindow :: proc(hwnd: HWND) -> UINT ---
  133. SetProcessDpiAwarenessContext :: proc(value: DPI_AWARENESS_CONTEXT) -> BOOL ---
  134. BroadcastSystemMessageW :: proc(
  135. flags: DWORD,
  136. lpInfo: LPDWORD,
  137. Msg: UINT,
  138. wParam: WPARAM,
  139. lParam: LPARAM,
  140. ) -> c_long ---
  141. BroadcastSystemMessageExW :: proc(
  142. flags: DWORD,
  143. lpInfo: LPDWORD,
  144. Msg: UINT,
  145. wParam: WPARAM,
  146. lParam: LPARAM,
  147. pbsmInfo: PBSMINFO,
  148. ) -> c_long ---
  149. SendMessageTimeoutW :: proc(
  150. hWnd: HWND,
  151. Msg: UINT,
  152. wParam: WPARAM,
  153. lParam: LPARAM,
  154. fuFlags: UINT,
  155. uTimeout: UINT,
  156. lpdwResult: PDWORD_PTR,
  157. ) -> LRESULT ---
  158. GetSysColor :: proc(nIndex: c_int) -> DWORD ---
  159. GetSysColorBrush :: proc(nIndex: c_int) -> HBRUSH ---
  160. SetSysColors :: proc(cElements: c_int, lpaElements: ^INT, lpaRgbValues: ^COLORREF) -> BOOL ---
  161. MessageBeep :: proc(uType: UINT) -> BOOL ---
  162. IsDialogMessageW :: proc(hDlg: HWND, lpMsg: LPMSG) -> BOOL ---
  163. GetWindowTextLengthW :: proc(hWnd: HWND) -> c_int ---
  164. GetWindowTextW :: proc(hWnd: HWND, lpString: LPWSTR, nMaxCount: c_int) -> c_int ---
  165. SetWindowTextW :: proc(hWnd: HWND, lpString: LPCWSTR) -> BOOL ---
  166. CallWindowProcW :: proc(lpPrevWndFunc: WNDPROC, hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  167. EnableWindow :: proc(hWnd: HWND, bEnable: BOOL) -> BOOL ---
  168. DefRawInputProc :: proc(paRawInput: ^PRAWINPUT, nInput: INT, cbSizeHeader: UINT) -> LRESULT ---
  169. GetRawInputBuffer :: proc(pRawInput: PRAWINPUT, pcbSize: PUINT, cbSizeHeader: UINT) -> UINT ---
  170. GetRawInputData :: proc(hRawInput: HRAWINPUT, uiCommand: UINT, pData: LPVOID, pcbSize: PUINT, cbSizeHeader: UINT) -> UINT ---
  171. GetRawInputDeviceInfoW :: proc(hDevice: HANDLE, uiCommand: UINT, pData: LPVOID, pcbSize: PUINT) -> UINT ---
  172. GetRawInputDeviceList :: proc(pRawInputDeviceList: PRAWINPUTDEVICELIST, puiNumDevices: PUINT, cbSize: UINT) -> UINT ---
  173. GetRegisteredRawInputDevices :: proc(pRawInputDevices: PRAWINPUTDEVICE, puiNumDevices: PUINT, cbSize: UINT) -> UINT ---
  174. RegisterRawInputDevices :: proc(pRawInputDevices: PCRAWINPUTDEVICE, uiNumDevices: UINT, cbSize: UINT) -> BOOL ---
  175. SendInput :: proc(cInputs: UINT, pInputs: [^]INPUT, cbSize: c_int) -> UINT ---
  176. SetLayeredWindowAttributes :: proc(hWnd: HWND, crKey: COLORREF, bAlpha: BYTE, dwFlags: DWORD) -> BOOL ---
  177. FillRect :: proc(hDC: HDC, lprc: ^RECT, hbr: HBRUSH) -> int ---
  178. EqualRect :: proc(lprc1: ^RECT, lprc2: ^RECT) -> BOOL ---
  179. GetWindowInfo :: proc(hwnd: HWND, pwi: PWINDOWINFO) -> BOOL ---
  180. GetWindowPlacement :: proc(hWnd: HWND, lpwndpl: ^WINDOWPLACEMENT) -> BOOL ---
  181. SetWindowPlacement :: proc(hwnd: HWND, lpwndpl: ^WINDOWPLACEMENT) -> BOOL ---
  182. SetWindowRgn :: proc(hWnd: HWND, hRgn: HRGN, bRedraw: BOOL) -> int ---
  183. CreateRectRgnIndirect :: proc(lprect: ^RECT) -> HRGN ---
  184. GetSystemMetricsForDpi :: proc(nIndex: int, dpi: UINT) -> int ---
  185. GetSystemMenu :: proc(hWnd: HWND, bRevert: BOOL) -> HMENU ---
  186. EnableMenuItem :: proc(hMenu: HMENU, uIDEnableItem: UINT, uEnable: UINT) -> BOOL ---
  187. }
  188. CreateWindowW :: #force_inline proc "stdcall" (
  189. lpClassName: LPCTSTR,
  190. lpWindowName: LPCTSTR,
  191. dwStyle: DWORD,
  192. X: c_int,
  193. Y: c_int,
  194. nWidth: c_int,
  195. nHeight: c_int,
  196. hWndParent: HWND,
  197. hMenu: HMENU,
  198. hInstance: HINSTANCE,
  199. lpParam: LPVOID,
  200. ) -> HWND {
  201. return CreateWindowExW(
  202. 0,
  203. lpClassName,
  204. lpWindowName,
  205. dwStyle,
  206. X,
  207. Y,
  208. nWidth,
  209. nHeight,
  210. hWndParent,
  211. hMenu,
  212. hInstance,
  213. lpParam,
  214. )
  215. }
  216. when ODIN_ARCH == .amd64 {
  217. @(default_calling_convention="stdcall")
  218. foreign user32 {
  219. GetClassLongPtrW :: proc(hWnd: HWND, nIndex: c_int) -> ULONG_PTR ---
  220. SetClassLongPtrW :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG_PTR) -> ULONG_PTR ---
  221. GetWindowLongPtrW :: proc(hWnd: HWND, nIndex: c_int) -> LONG_PTR ---
  222. SetWindowLongPtrW :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG_PTR) -> LONG_PTR ---
  223. }
  224. } else when ODIN_ARCH == .i386 {
  225. GetClassLongPtrW :: GetClassLongW
  226. SetClassLongPtrW :: SetClassLongW
  227. GetWindowLongPtrW :: GetWindowLongW
  228. SetWindowLongPtrW :: SetWindowLongW
  229. }
  230. GET_SC_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> c_int {
  231. return c_int(wParam) & 0xFFF0
  232. }
  233. GET_WHEEL_DELTA_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> c_short {
  234. return cast(c_short)HIWORD(cast(DWORD)wParam)
  235. }
  236. GET_KEYSTATE_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> WORD {
  237. return LOWORD(cast(DWORD)wParam)
  238. }
  239. GET_NCHITTEST_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> c_short {
  240. return cast(c_short)LOWORD(cast(DWORD)wParam)
  241. }
  242. GET_XBUTTON_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> WORD {
  243. return HIWORD(cast(DWORD)wParam)
  244. }
  245. MAKEINTRESOURCEW :: #force_inline proc "contextless" (#any_int i: int) -> LPWSTR {
  246. return cast(LPWSTR)uintptr(WORD(i))
  247. }
  248. Monitor_From_Flags :: enum DWORD {
  249. MONITOR_DEFAULTTONULL = 0x00000000, // Returns NULL
  250. MONITOR_DEFAULTTOPRIMARY = 0x00000001, // Returns a handle to the primary display monitor
  251. MONITOR_DEFAULTTONEAREST = 0x00000002, // Returns a handle to the display monitor that is nearest to the window
  252. }
  253. Monitor_Enum_Proc :: #type proc "stdcall" (HMONITOR, HDC, LPRECT, LPARAM) -> BOOL
  254. Window_Enum_Proc :: #type proc "stdcall" (HWND, LPARAM) -> BOOL
  255. USER_DEFAULT_SCREEN_DPI :: 96
  256. DPI_AWARENESS_CONTEXT :: distinct HANDLE
  257. DPI_AWARENESS_CONTEXT_UNAWARE :: DPI_AWARENESS_CONTEXT(~uintptr(0)) // -1
  258. DPI_AWARENESS_CONTEXT_SYSTEM_AWARE :: DPI_AWARENESS_CONTEXT(~uintptr(1)) // -2
  259. DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE :: DPI_AWARENESS_CONTEXT(~uintptr(2)) // -3
  260. DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 :: DPI_AWARENESS_CONTEXT(~uintptr(3)) // -4
  261. DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED :: DPI_AWARENESS_CONTEXT(~uintptr(4)) // -5
  262. RAWINPUTHEADER :: struct {
  263. dwType: DWORD,
  264. dwSize: DWORD,
  265. hDevice: HANDLE,
  266. wParam: WPARAM,
  267. }
  268. RAWHID :: struct {
  269. dwSizeHid: DWORD,
  270. dwCount: DWORD,
  271. bRawData: [1]BYTE,
  272. }
  273. RAWMOUSE :: struct {
  274. usFlags: USHORT,
  275. DUMMYUNIONNAME: struct #raw_union {
  276. ulButtons: ULONG,
  277. DUMMYSTRUCTNAME: struct {
  278. usButtonFlags: USHORT,
  279. usButtonData: USHORT,
  280. },
  281. },
  282. ulRawButtons: ULONG,
  283. lLastX: LONG,
  284. lLastY: LONG,
  285. ulExtraInformation: ULONG,
  286. }
  287. RAWKEYBOARD :: struct {
  288. MakeCode: USHORT,
  289. Flags: USHORT,
  290. Rserved: USHORT,
  291. VKey: USHORT,
  292. Message: UINT,
  293. ExtraInformation: ULONG,
  294. }
  295. RAWINPUT :: struct {
  296. header: RAWINPUTHEADER,
  297. data: struct #raw_union {
  298. mouse: RAWMOUSE,
  299. keyboard: RAWKEYBOARD,
  300. hid: RAWHID,
  301. },
  302. }
  303. PRAWINPUT :: ^RAWINPUT
  304. HRAWINPUT :: distinct LPARAM
  305. RAWINPUTDEVICE :: struct {
  306. usUsagePage: USHORT,
  307. usUsage: USHORT,
  308. dwFlags: DWORD,
  309. hwndTarget: HWND,
  310. }
  311. PRAWINPUTDEVICE :: ^RAWINPUTDEVICE
  312. PCRAWINPUTDEVICE :: PRAWINPUTDEVICE
  313. RAWINPUTDEVICELIST :: struct {
  314. hDevice: HANDLE,
  315. dwType: DWORD,
  316. }
  317. PRAWINPUTDEVICELIST :: ^RAWINPUTDEVICELIST
  318. RID_DEVICE_INFO_HID :: struct {
  319. dwVendorId: DWORD,
  320. dwProductId: DWORD,
  321. dwVersionNumber: DWORD,
  322. usUsagePage: USHORT,
  323. usUsage: USHORT,
  324. }
  325. RID_DEVICE_INFO_KEYBOARD :: struct {
  326. dwType: DWORD,
  327. dwSubType: DWORD,
  328. dwKeyboardMode: DWORD,
  329. dwNumberOfFunctionKeys: DWORD,
  330. dwNumberOfIndicators: DWORD,
  331. dwNumberOfKeysTotal: DWORD,
  332. }
  333. RID_DEVICE_INFO_MOUSE :: struct {
  334. dwId: DWORD,
  335. dwNumberOfButtons: DWORD,
  336. dwSampleRate: DWORD,
  337. fHasHorizontalWheel: BOOL,
  338. }
  339. RID_DEVICE_INFO :: struct {
  340. cbSize: DWORD,
  341. dwType: DWORD,
  342. DUMMYUNIONNAME: struct #raw_union {
  343. mouse: RID_DEVICE_INFO_MOUSE,
  344. keyboard: RID_DEVICE_INFO_KEYBOARD,
  345. hid: RID_DEVICE_INFO_HID,
  346. },
  347. }
  348. RIDEV_REMOVE :: 0x00000001
  349. RIDEV_EXCLUDE :: 0x00000010
  350. RIDEV_PAGEONLY :: 0x00000020
  351. RIDEV_NOLEGACY :: 0x00000030
  352. RIDEV_INPUTSINK :: 0x00000100
  353. RIDEV_CAPTUREMOUSE :: 0x00000200
  354. RIDEV_NOHOTKEYS :: 0x00000200
  355. RIDEV_APPKEYS :: 0x00000400
  356. RIDEV_EXINPUTSINK :: 0x00001000
  357. RIDEV_DEVNOTIFY :: 0x00002000
  358. RID_HEADER :: 0x10000005
  359. RID_INPUT :: 0x10000003
  360. RIM_TYPEMOUSE :: 0
  361. RIM_TYPEKEYBOARD :: 1
  362. RIM_TYPEHID :: 2
  363. MOUSE_MOVE_RELATIVE :: 0x00
  364. MOUSE_MOVE_ABSOLUTE :: 0x01
  365. MOUSE_VIRTUAL_DESKTOP :: 0x02
  366. MOUSE_ATTRIUBTTES_CHANGED :: 0x04
  367. MOUSE_MOVE_NOCOALESCE :: 0x08
  368. RI_MOUSE_BUTTON_1_DOWN :: 0x0001
  369. RI_MOUSE_LEFT_BUTTON_DOWNS :: RI_MOUSE_BUTTON_1_DOWN
  370. RI_MOUSE_BUTTON_1_UP :: 0x0002
  371. RI_MOUSE_LEFT_BUTTON_UP :: RI_MOUSE_BUTTON_1_UP
  372. RI_MOUSE_BUTTON_2_DOWN :: 0x0004
  373. RI_MOUSE_RIGHT_BUTTON_DOWN :: RI_MOUSE_BUTTON_2_DOWN
  374. RI_MOUSE_BUTTON_2_UP :: 0x0008
  375. RI_MOUSE_RIGHT_BUTTON_UP :: RI_MOUSE_BUTTON_2_UP
  376. RI_MOUSE_BUTTON_3_DOWN :: 0x0010
  377. RI_MOUSE_MIDDLE_BUTTON_DOWN :: RI_MOUSE_BUTTON_3_DOWN
  378. RI_MOUSE_BUTTON_3_UP :: 0x0020
  379. RI_MOUSE_MIDDLE_BUTTON_UP :: RI_MOUSE_BUTTON_3_UP
  380. RI_MOUSE_BUTTON_4_DOWN :: 0x0040
  381. RI_MOUSE_BUTTON_4_UP :: 0x0080
  382. RI_MOUSE_BUTTON_5_DOWN :: 0x0100
  383. RI_MOUSE_BUTTON_5_UP :: 0x0200
  384. RI_MOUSE_WHEEL :: 0x0400
  385. RI_MOUSE_HWHEEL :: 0x0800
  386. WINDOWPLACEMENT :: struct {
  387. length: UINT,
  388. flags: UINT,
  389. showCmd: UINT,
  390. ptMinPosition: POINT,
  391. ptMaxPosition: POINT,
  392. rcNormalPosition: RECT,
  393. }
  394. WINDOWINFO :: struct {
  395. cbSize: DWORD,
  396. rcWindow: RECT,
  397. rcClient: RECT,
  398. dwStyle: DWORD,
  399. dwExStyle: DWORD,
  400. dwWindowStatus: DWORD,
  401. cxWindowBorders: UINT,
  402. cyWindowBorders: UINT,
  403. atomWindowType: ATOM,
  404. wCreatorVersion: WORD,
  405. }
  406. PWINDOWINFO :: ^WINDOWINFO