Browse Source

Add functions to disable and enable cursor

Constantine Tarasenkov 9 năm trước cách đây
mục cha
commit
13925f7bd4
2 tập tin đã thay đổi với 20 bổ sung0 xóa
  1. 18 0
      src/core.c
  2. 2 0
      src/raylib.h

+ 18 - 0
src/core.c

@@ -1097,6 +1097,24 @@ void ShowCursor()
     cursorHidden = false;
 }
 
+// Disable mouse cursor
+void DisableCursor()
+{
+#if defined(PLATFORM_DESKTOP)
+    glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
+#endif
+    cursorHidden = true;
+}
+
+// Enable mouse cursor
+void EnableCursor()
+{
+#if defined(PLATFORM_DESKTOP)
+    glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
+#endif
+    cursorHidden = false;
+}
+
 // Check if mouse cursor is hidden
 bool IsCursorHidden()
 {

+ 2 - 0
src/raylib.h

@@ -586,6 +586,8 @@ int GetMouseWheelMove(void);                            // Returns mouse wheel m
 
 void ShowCursor(void);                                  // Shows cursor
 void HideCursor(void);                                  // Hides cursor
+void EnableCursor(void);                                // Enables cursor
+void DisableCursor(void);                               // Disables cursor
 bool IsCursorHidden(void);                              // Returns true if cursor is not visible
 #endif