Currently there is a set_cursor_grab API which is supposed to confine the cursor movement to within the window client area, but sometimes the user may want to lock the cursor to the current position instead (e.g. for camera control). Also, the web platform does not support confining the cursor but does support locking the cursor with the Pointer Lock API. Therefore, I would suggest adding a new API set_cursor_lock to lock the cursor to the current position, and fixing the set_cursor_grab API to actually confine the cursor on all supported platforms.
A better alternative would be to change set_cursor_grab to take an enum CursorGrabState { Off, Confine, Lock } so that only one of the two cursor grabbing modes can be active at once.
|
set_cursor_grab / Confine |
set_cursor_lock / Lock |
| Windows |
Supported, already implemented |
Supported, unimplemented (could reuse cursor grab impl.) |
| Linux (X11) |
Supported, already implemented |
Unknown (could just move the mouse after mouse moved?) |
| Linux (Wayland) |
Supported, unimplemented (#1678) |
Supported, already implemented for set_cursor_grab |
| macOS |
Supported, unimplemented (#1093) |
Supported, already implemented for set_cursor_grab |
| iOS |
Not supported |
Not supported |
| Android |
Not supported |
Not supported |
| Web |
Not supported |
Supported, unimplemented (#1674) |
Currently there is a
set_cursor_grabAPI which is supposed to confine the cursor movement to within the window client area, but sometimes the user may want to lock the cursor to the current position instead (e.g. for camera control). Also, the web platform does not support confining the cursor but does support locking the cursor with the Pointer Lock API. Therefore, I would suggest adding a new APIset_cursor_lockto lock the cursor to the current position, and fixing theset_cursor_grabAPI to actually confine the cursor on all supported platforms.A better alternative would be to change
set_cursor_grabto take anenum CursorGrabState { Off, Confine, Lock }so that only one of the two cursor grabbing modes can be active at once.set_cursor_grabset_cursor_grab