From 9eee6631cc4167c3084a440346c9317f8f468661 Mon Sep 17 00:00:00 2001 From: crthpl <56052645+crthpl@users.noreply.github.com> Date: Tue, 6 Jul 2021 10:43:41 -0700 Subject: [PATCH] sokol: add mouse locking (#10684) --- vlib/sokol/sapp/sapp.v | 10 ++++++++++ vlib/sokol/sapp/sapp_funcs.v | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/vlib/sokol/sapp/sapp.v b/vlib/sokol/sapp/sapp.v index a5264a2688..f963277acf 100644 --- a/vlib/sokol/sapp/sapp.v +++ b/vlib/sokol/sapp/sapp.v @@ -86,6 +86,16 @@ pub fn mouse_shown() bool { return C.sapp_mouse_shown() } +[inline] +pub fn lock_mouse(locked bool) { + C.sapp_lock_mouse(locked) +} + +[inline] +pub fn mouse_locked() bool { + return C.sapp_mouse_locked() +} + // return the userdata pointer optionally provided in sapp_desc [inline] pub fn userdata() voidptr { diff --git a/vlib/sokol/sapp/sapp_funcs.v b/vlib/sokol/sapp/sapp_funcs.v index f05c06564b..aae95c8e1e 100644 --- a/vlib/sokol/sapp/sapp_funcs.v +++ b/vlib/sokol/sapp/sapp_funcs.v @@ -26,9 +26,15 @@ fn C.sapp_keyboard_shown() bool // show or hide the mouse cursor fn C.sapp_show_mouse(visible bool) -// show or hide the mouse cursor +// return true if the mouse cursor is shown fn C.sapp_mouse_shown() bool +// lock or unlock the mouse cursor +fn C.sapp_lock_mouse(locked bool) + +// return true if the mouse cursor is locked +fn C.sapp_mouse_locked() bool + // return the userdata pointer optionally provided in sapp_desc fn C.sapp_userdata() voidptr