hashlink
hashlink copied to clipboard
SDL/DX: Add mouse handling API
- DirectX: Added
Event.mouseXRelandmouseYRelvariables, fixing the data mismatch between DX and SDL. - DirectX: Added
setCursorPositionandsetCursorPositionGlobalto set mouse position with relative to window and screen coordinates. - DirectX: Added support for relative mouse mode via
setRelativeMouseModeandgetRelativeMouseMode(see below) - DirectX: Fixed
winClipCursorand improved how cursor capture works. - SDL: Added
Window.warpMouseandSdl.warpMouseGlobalbindings to set the mouse position. - SDL: Added
Sdl.getRelativeMouseMode. - SDL: Added
Window.grabthat traps the cursor within the window boundaries.
In short, for SDL: Added bindings for common mouse handlers such as setting position, relative mode and cursor trap.
DirectX implementation is heavily based on how SDL does it, especially improvement of cursor clipping, so it would be possible to drag the window and click the title buttons while the cursor grab is enabled by unfocusing the window and licking on the titlebar. Relative mouse mode enables raw input mode, and also implies the trapping of cursor within the window. When enabled, mouse is hidden, but still moves within the window boundaries.
This is a prerequisite PR to implement https://github.com/HeapsIO/heaps/issues/568