diff options
| author | martincohen <m@coh.io> | 2019-09-08 11:04:58 +0200 |
|---|---|---|
| committer | martincohen <m@coh.io> | 2019-09-08 11:04:58 +0200 |
| commit | 283dc841fb512458fa14cb458404f7ab38315283 (patch) | |
| tree | f15f05374a7613722785bb48793597e72ae171db /sokol_app.h | |
| parent | 7eab3f1318556c0ba3123856289ade047a1bdd4e (diff) | |
Showing and querying mouse cursor.
Diffstat (limited to 'sokol_app.h')
| -rw-r--r-- | sokol_app.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/sokol_app.h b/sokol_app.h index 86e7a9e0..9024d950 100644 --- a/sokol_app.h +++ b/sokol_app.h @@ -744,6 +744,10 @@ SOKOL_API_DECL float sapp_dpi_scale(void); SOKOL_API_DECL void sapp_show_keyboard(bool visible); /* return true if the mobile device onscreen keyboard is currently shown */ SOKOL_API_DECL bool sapp_keyboard_shown(void); +/* show or hide the mouse cursor */ +SOKOL_API_DECL void sapp_show_mouse(bool visible); +/* show or hide the mouse cursor */ +SOKOL_API_DECL bool sapp_mouse_shown(); /* return the userdata pointer optionally provided in sapp_desc */ SOKOL_API_DECL void* sapp_userdata(void); /* return a copy of the sapp_desc structure */ @@ -3857,6 +3861,16 @@ _SOKOL_PRIVATE bool _sapp_win32_utf8_to_wide(const char* src, wchar_t* dst, int } } +_SOKOL_PRIVATE void _sapp_win32_show_mouse(bool shown) { + ShowCursor((BOOL)shown); +} + +_SOKOL_PRIVATE bool _sapp_win32_mouse_shown(void) { + CURSORINFO cursor_info = { .cbSize = sizeof(CURSORINFO) }; + GetCursorInfo(&cursor_info); + return (cursor_info.flags & CURSOR_SHOWING) != 0; +} + _SOKOL_PRIVATE void _sapp_win32_init_keytable(void) { /* same as GLFW */ _sapp.keycodes[0x00B] = SAPP_KEYCODE_0; @@ -7023,6 +7037,22 @@ SOKOL_API_IMPL bool sapp_keyboard_shown(void) { return _sapp.onscreen_keyboard_shown; } +SOKOL_API_IMPL void sapp_show_mouse(bool shown) { + #if defined(_WIN32) + _sapp_win32_show_mouse(shown); + #else + _SOKOL_UNUSED(shown); + #endif +} + +SOKOL_API_IMPL bool sapp_mouse_shown(void) { + #if defined(_WIN32) + return _sapp_win32_mouse_shown(); + #else + return false; + #endif +} + SOKOL_API_IMPL void sapp_request_quit(void) { _sapp.quit_requested = true; } |