From 285ab537f7342c0f2cc0e70e3b6bcbcda3c5af0d Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Tue, 6 Sep 2011 17:38:00 +0200 Subject: [PATCH] Initial implementation of cursor mode on Cocoa. --- src/cocoa_window.m | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 5c1ed4a7..93e37089 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -923,26 +923,6 @@ void _glfwPlatformWaitEvents( void ) _glfwPlatformPollEvents(); } -//======================================================================== -// Hide mouse cursor (lock it) -//======================================================================== - -void _glfwPlatformHideMouseCursor(_GLFWwindow* window) -{ - [NSCursor hide]; - CGAssociateMouseAndMouseCursorPosition(false); -} - -//======================================================================== -// Show mouse cursor (unlock it) -//======================================================================== - -void _glfwPlatformShowMouseCursor(_GLFWwindow* window) -{ - [NSCursor unhide]; - CGAssociateMouseAndMouseCursorPosition(true); -} - //======================================================================== // Set physical mouse cursor position //======================================================================== @@ -975,3 +955,24 @@ void _glfwPlatformSetMouseCursorPos(_GLFWwindow* window, int x, int y) CGDisplayMoveCursorToPoint(CGMainDisplayID(), targetPoint); } +//======================================================================== +// Set physical mouse cursor mode +//======================================================================== + +void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) +{ + switch (mode) + { + case GLFW_CURSOR_NORMAL: + [NSCursor unhide]; + CGAssociateMouseAndMouseCursorPosition(true); + break; + case GLFW_CURSOR_HIDDEN: + break; + case GLFW_CURSOR_CAPTURED: + [NSCursor hide]; + CGAssociateMouseAndMouseCursorPosition(false); + break; + } +} +