natiny_input_set_mouse_capture
void natiny_input_set_mouse_capture(bool enabled);
Enables or disables mouse capture. While captured, the cursor is hidden and mouse movement continues past the window edges.
Parameters
| Name | Type | Description |
|---|---|---|
enabled |
bool |
true to capture the mouse, false to release it |
Example
if (natiny_input_get_mouse_button_pressed(NATINY_INPUT_MOUSE_BUTTON_LEFT))
natiny_input_set_mouse_capture(true);
Notes
- A window must exist before this function is called. Otherwise it does nothing.
- Escape releases the mouse. In a browser, changing tabs can also release it;
use
natiny_input_get_mouse_capturedto read the state. - In a browser, enabling capture may be deferred until the next user gesture, and a refused request is retried on the next click. A browser refuses one for about a second after Escape released the last.
- Mouse movement is
0on the frame capture changes and on the following frame.