summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRay <[email protected]>2020-10-21 11:08:37 +0200
committerRay <[email protected]>2020-10-21 11:08:37 +0200
commitf12db180cd84553bd26c11f4e6585f81c3e611c3 (patch)
treec0aa51132a98595e59b83821aa0dabacec6589d9 /src
parent9833fe45eb5cd6cfd3593b7f4d1aae9cf7367729 (diff)
downloadraylib-f12db180cd84553bd26c11f4e6585f81c3e611c3.tar.gz
raylib-f12db180cd84553bd26c11f4e6585f81c3e611c3.zip
Reviewed PR #1407
Diffstat (limited to 'src')
-rw-r--r--src/core.c40
-rw-r--r--src/raylib.h32
2 files changed, 19 insertions, 53 deletions
diff --git a/src/core.c b/src/core.c
index 3534caed..917c8b32 100644
--- a/src/core.c
+++ b/src/core.c
@@ -423,8 +423,7 @@ typedef struct CoreData {
Vector2 offset; // Mouse offset
Vector2 scale; // Mouse scaling
- MouseCursor cursor; // Tracks current mouse cursor
- void* standardCursors[10]; // Opaque pointers to GLFW cursors
+ int cursor; // Tracks current mouse cursor
bool cursorHidden; // Track if cursor is hidden
bool cursorOnScreen; // Tracks if cursor is inside client area
@@ -756,26 +755,6 @@ void InitWindow(int width, int height, const char *title)
#endif
#endif
-#if defined(PLATFORM_DESKTOP)
- // Initialize GLFW's standard cursors
- const int shapes[] = {
- 0x00036001, // MOUSE_CURSOR_ARROW
- 0x00036002, // MOUSE_CURSOR_IBEAM
- 0x00036003, // MOUSE_CURSOR_CROSSHAIR
- 0x00036004, // MOUSE_CURSOR_POINTING_HAND
- 0x00036005, // MOUSE_CURSOR_RESIZE_EW
- 0x00036006, // MOUSE_CURSOR_RESIZE_NS
- 0x00036007, // MOUSE_CURSOR_RESIZE_NWSE
- 0x00036008, // MOUSE_CURSOR_RESIZE_NESW
- 0x00036009, // MOUSE_CURSOR_RESIZE_ALL
- 0x0003600A, // MOUSE_CURSOR_NOT_ALLOWED
- };
- for (int i = 0; i < sizeof(CORE.Input.Mouse.standardCursors) / sizeof(CORE.Input.Mouse.standardCursors[0]); i += 1)
- {
- CORE.Input.Mouse.standardCursors[i] = glfwCreateStandardCursor(shapes[i]);
- }
-#endif
-
#if defined(PLATFORM_WEB)
// Detect fullscreen change events
emscripten_set_fullscreenchange_callback("#canvas", NULL, 1, EmscriptenFullscreenChangeCallback);
@@ -820,11 +799,6 @@ void CloseWindow(void)
rlglClose(); // De-init rlgl
-#if defined(PLATFORM_DESKTOP)
- for (int i = 0; i < sizeof(CORE.Input.Mouse.standardCursors) / sizeof(CORE.Input.Mouse.standardCursors[0]); i += 1)
- glfwDestroyCursor(CORE.Input.Mouse.standardCursors[i]);
-#endif
-
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
glfwDestroyWindow(CORE.Window.handle);
glfwTerminate();
@@ -2762,24 +2736,22 @@ float GetMouseWheelMove(void)
}
// Returns mouse cursor
-MouseCursor GetMouseCursor(void)
+int GetMouseCursor(void)
{
return CORE.Input.Mouse.cursor;
}
// Set mouse cursor
// NOTE: This is a no-op on platforms other than PLATFORM_DESKTOP
-void SetMouseCursor(MouseCursor cursor)
+void SetMouseCursor(int cursor)
{
#if defined(PLATFORM_DESKTOP)
CORE.Input.Mouse.cursor = cursor;
- if (cursor == MOUSE_CURSOR_DEFAULT)
- {
- glfwSetCursor(CORE.Window.handle, NULL);
- }
+ if (cursor == MOUSE_CURSOR_DEFAULT) glfwSetCursor(CORE.Window.handle, NULL);
else
{
- glfwSetCursor(CORE.Window.handle, CORE.Input.Mouse.standardCursors[cursor]);
+ // NOTE: We are relating internal GLFW enum values to our MouseCursor enum values
+ glfwSetCursor(CORE.Window.handle, glfwCreateStandardCursor(0x00036000 + cursor));
}
#endif
}
diff --git a/src/raylib.h b/src/raylib.h
index bb5a3c47..36a9b63d 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -619,23 +619,17 @@ typedef enum {
// Mouse cursor types
typedef enum {
- MOUSE_CURSOR_DEFAULT = -1,
- MOUSE_CURSOR_ARROW = 0,
- MOUSE_CURSOR_IBEAM = 1,
- MOUSE_CURSOR_CROSSHAIR = 2,
- MOUSE_CURSOR_POINTING_HAND = 3,
- // The horizontal resize/move arrow shape.
- MOUSE_CURSOR_RESIZE_EW = 4,
- // The vertical resize/move arrow shape.
- MOUSE_CURSOR_RESIZE_NS = 5,
- // The top-left to bottom-right diagonal resize/move arrow shape.
- MOUSE_CURSOR_RESIZE_NWSE = 6,
- // The top-right to bottom-left diagonal resize/move arrow shape.
- MOUSE_CURSOR_RESIZE_NESW = 7,
- // The omni-directional resize/move cursor shape.
- MOUSE_CURSOR_RESIZE_ALL = 8,
- // The operation-not-allowed shape.
- MOUSE_CURSOR_NOT_ALLOWED = 9
+ MOUSE_CURSOR_DEFAULT = 0,
+ MOUSE_CURSOR_ARROW = 1,
+ MOUSE_CURSOR_IBEAM = 2,
+ MOUSE_CURSOR_CROSSHAIR = 3,
+ MOUSE_CURSOR_POINTING_HAND = 4,
+ MOUSE_CURSOR_RESIZE_EW = 5, // The horizontal resize/move arrow shape
+ MOUSE_CURSOR_RESIZE_NS = 6, // The vertical resize/move arrow shape
+ MOUSE_CURSOR_RESIZE_NWSE = 7, // The top-left to bottom-right diagonal resize/move arrow shape
+ MOUSE_CURSOR_RESIZE_NESW = 8, // The top-right to bottom-left diagonal resize/move arrow shape
+ MOUSE_CURSOR_RESIZE_ALL = 9, // The omni-directional resize/move cursor shape
+ MOUSE_CURSOR_NOT_ALLOWED = 10 // The operation-not-allowed shape
} MouseCursor;
// Gamepad number
@@ -1037,8 +1031,8 @@ RLAPI void SetMousePosition(int x, int y); // Set mouse posit
RLAPI void SetMouseOffset(int offsetX, int offsetY); // Set mouse offset
RLAPI void SetMouseScale(float scaleX, float scaleY); // Set mouse scaling
RLAPI float GetMouseWheelMove(void); // Returns mouse wheel movement Y
-RLAPI MouseCursor GetMouseCursor(void); // Returns mouse cursor
-RLAPI void SetMouseCursor(MouseCursor cursor); // Set mouse cursor
+RLAPI int GetMouseCursor(void); // Returns mouse cursor if (MouseCursor enum)
+RLAPI void SetMouseCursor(int cursor); // Set mouse cursor
// Input-related functions: touch
RLAPI int GetTouchX(void); // Returns touch position X for touch point 0 (relative to screen size)