hashlink icon indicating copy to clipboard operation
hashlink copied to clipboard

SDL/DX: Add mouse handling API

Open Yanrishatum opened this issue 4 years ago • 0 comments

  • DirectX: Added Event.mouseXRel and mouseYRel variables, fixing the data mismatch between DX and SDL.
  • DirectX: Added setCursorPosition and setCursorPositionGlobal to set mouse position with relative to window and screen coordinates.
  • DirectX: Added support for relative mouse mode via setRelativeMouseMode and getRelativeMouseMode (see below)
  • DirectX: Fixed winClipCursor and improved how cursor capture works.
  • SDL: Added Window.warpMouse and Sdl.warpMouseGlobal bindings to set the mouse position.
  • SDL: Added Sdl.getRelativeMouseMode.
  • SDL: Added Window.grab that 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

Yanrishatum avatar Feb 20 '21 06:02 Yanrishatum