summaryrefslogtreecommitdiff
path: root/sokol_app.h
diff options
context:
space:
mode:
authorAndre Weissflog <floooh@gmail.com>2019-09-11 19:22:17 +0200
committerGitHub <noreply@github.com>2019-09-11 19:22:17 +0200
commit526011d88e00d9c308536fe82d934ce0b9a54456 (patch)
tree836d7e283d9bc04c8b17abc57afcbebf91fdf415 /sokol_app.h
parent6e088808a0606f6bd77fde12315bc0fd45d8e2b2 (diff)
parentc439dde9d58a556eac7f59876195695900ac46f2 (diff)
Merge pull request #210 from martincohen/feature/showing-mouse-cursor
208: sokol_app: Show/hide mouse cursor
Diffstat (limited to 'sokol_app.h')
-rw-r--r--sokol_app.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/sokol_app.h b/sokol_app.h
index 0aff81af..60ddd648 100644
--- a/sokol_app.h
+++ b/sokol_app.h
@@ -746,6 +746,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 */
@@ -3867,6 +3871,18 @@ _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;
+ memset(&cursor_info, 0, sizeof(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;
@@ -7067,6 +7083,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;
}