1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-10-08 07:07:25 -04:00

Renamed or implemented missing methods for cursor specific features.

This commit is contained in:
Marcel Metz 2011-10-01 01:40:36 -04:00
parent f50e43d47a
commit 71af8b190f

View File

@ -33,6 +33,8 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
void showMouseCursor(_GLFWwindow* window);
void captureMouseCursor(_GLFWwindow* window);
//======================================================================== //========================================================================
// Convert BPP to RGB bits based on "best guess" // Convert BPP to RGB bits based on "best guess"
@ -1850,18 +1852,11 @@ void _glfwPlatformWaitEvents(void)
// Hide mouse cursor (lock it) // Hide mouse cursor (lock it)
//======================================================================== //========================================================================
void _glfwPlatformHideMouseCursor(_GLFWwindow* window) void hideMouseCursor(_GLFWwindow* window)
{ {
RECT ClipWindowRect;
ShowCursor(FALSE); ShowCursor(FALSE);
// Clip cursor to the window captureMouseCursor(window);
if (GetWindowRect(window->Win32.handle, &ClipWindowRect))
ClipCursor(&ClipWindowRect);
// Capture cursor to user window
SetCapture(window->Win32.handle);
} }
@ -1869,7 +1864,7 @@ void _glfwPlatformHideMouseCursor(_GLFWwindow* window)
// Show mouse cursor (unlock it) // Show mouse cursor (unlock it)
//======================================================================== //========================================================================
void _glfwPlatformShowMouseCursor(_GLFWwindow* window) void showMouseCursor(_GLFWwindow* window)
{ {
// Un-capture cursor // Un-capture cursor
ReleaseCapture(); ReleaseCapture();
@ -1880,6 +1875,22 @@ void _glfwPlatformShowMouseCursor(_GLFWwindow* window)
ShowCursor(TRUE); ShowCursor(TRUE);
} }
//========================================================================
// Capture mouse cursor
//========================================================================
static void captureMouseCursor(_GLFWwindow* window)
{
RECT ClipWindowRect;
// Clip cursor to the window
if (GetWindowRect(window->Win32.handle, &ClipWindowRect))
ClipCursor(&ClipWindowRect);
// Capture cursor to user window
SetCapture(window->Win32.handle);
}
//======================================================================== //========================================================================
// Set physical mouse cursor position // Set physical mouse cursor position
@ -1897,3 +1908,24 @@ void _glfwPlatformSetMouseCursorPos(_GLFWwindow* window, int x, int y)
SetCursorPos(pos.x, pos.y); SetCursorPos(pos.x, pos.y);
} }
//========================================================================
// Set physical mouse cursor mode
//========================================================================
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
{
switch (mode)
{
case GLFW_CURSOR_NORMAL:
showMouseCursor(window);
break;
case GLFW_CURSOR_HIDDEN:
hideMouseCursor(window);
break;
case GLFW_CURSOR_CAPTURED:
captureMouseCursor(window);
break;
}
}