From ce37a83df37ec58a481738124e7a501d0aa2d16b Mon Sep 17 00:00:00 2001 From: "Stanislav Ch. Nikolov" Date: Tue, 1 Sep 2026 22:42:25 +0300 Subject: [PATCH] Add support for advanced pen & pointer win32 functions --- core/sys/windows/user32.odin | 95 ++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/core/sys/windows/user32.odin b/core/sys/windows/user32.odin index d2f54b127..afce7c01f 100644 --- a/core/sys/windows/user32.odin +++ b/core/sys/windows/user32.odin @@ -346,6 +346,10 @@ foreign user32 { GetScrollInfo :: proc(hwnd: HWND, nBar: c_int, lpsi: ^SCROLLINFO) -> BOOL --- ShowScrollBar :: proc(hwnd: HWND, nBar: c_int, bShow: BOOL) -> BOOL --- EnableScrollBar :: proc(hwnd: HWND, wSBflags: UINT, wArrows: UINT) -> BOOL --- + + EnableMouseInPointer :: proc(fEnable: BOOL) --- + GetPointerInfo :: proc(pointerId: UINT, pointerInfo: ^POINTER_INFO) -> BOOL --- + GetPointerPenInfo :: proc(pointerId: UINT, penInfo: ^POINTER_PEN_INFO) -> BOOL --- } CreateWindowW :: #force_inline proc "system" ( @@ -970,6 +974,97 @@ ESB_DISABLE_DOWN :: 0x0002 ESB_DISABLE_LTUP :: ESB_DISABLE_LEFT ESB_DISABLE_RTDN :: ESB_DISABLE_RIGHT +POINTER_INPUT_TYPE :: enum DWORD { + PT_POINTER = 1, + PT_TOUCH = 2, + PT_PEN = 3, + PT_MOUSE = 4, + PT_TOUCHPAD = 5, +} + +POINTER_BUTTON_CHANGE_TYPE :: enum { + NONE, + FIRSTBUTTON_DOWN, + FIRSTBUTTON_UP, + SECONDBUTTON_DOWN, + SECONDBUTTON_UP, + THIRDBUTTON_DOWN, + THIRDBUTTON_UP, + FOURTHBUTTON_DOWN, + FOURTHBUTTON_UP, + FIFTHBUTTON_DOWN, + FIFTHBUTTON_UP +} + +PointerFlag :: enum { + new = 0, + in_rage = 1, + in_contact = 2, + first_button = 4, + second_button = 5, + third_button = 6, + fourth_button = 7, + fifth_button = 8, + primary = 13, + confidence = 14, + canceled = 15, + down = 16, + update = 17, + up = 18, + wheel = 19, + hwheel = 20, + capture_changed = 21, + has_transform = 22, +} + +PenFlag :: enum { + barrel = 0, + inverted = 1, + eraser = 2, +} + +PenMask :: enum { + pressure = 0, + rotation = 1, + tiltX = 2, + tiltY = 3, +} + +POINTER_INFO :: struct { + pointerType: POINTER_INPUT_TYPE, + pointerId: UINT, + frameId: UINT, + pointerFlags: bit_set[PointerFlag; UINT], + sourceDevice: HANDLE, + hwndTarget: HWND, + ptPixelLocation: POINT, + ptHimetricLocation: POINT, + ptPixelLocationRaw: POINT, + ptHimetricLocationRaw: POINT, + dwTime: DWORD, + historyCount: UINT, + InputData: INT32, + dwKeyStates: DWORD, + PerformanceCount: UINT, + ButtonChangeType: POINTER_BUTTON_CHANGE_TYPE, +} + +POINTER_PEN_INFO :: struct { + pointerInfo: POINTER_INFO, + penFlags: bit_set[PenFlag; UINT], + penMask: bit_set[PenMask; UINT], + + // pressure normalized to a range between 0 and 1024. 0 if the device does not report pressure. + pressure: UINT, + + // clockwise rotation, or twist, of the pointer normalized in a range of 0 to 359 + rotation: UINT, + + // -90 to +90; positive value indicating a tilt toward the user + tiltX: INT, + tiltY: INT, +} + // Command constants for GetWindow GW_HWNDFIRST :: 0 GW_HWNDLAST :: 1