1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-23 10:48:51 -05:00

Cleanup of Win32 mouse button handling.

This commit is contained in:
Camilla Berglund 2013-04-16 20:57:51 +02:00
parent c12759880d
commit 7b7ef1e07b

View File

@ -481,77 +481,55 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
} }
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
{
SetCapture(hWnd);
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS);
return 0;
}
case WM_RBUTTONDOWN: case WM_RBUTTONDOWN:
{
SetCapture(hWnd);
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS);
return 0;
}
case WM_MBUTTONDOWN: case WM_MBUTTONDOWN:
{
SetCapture(hWnd);
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_MIDDLE, GLFW_PRESS);
return 0;
}
case WM_XBUTTONDOWN: case WM_XBUTTONDOWN:
{
SetCapture(hWnd);
if (uMsg == WM_LBUTTONDOWN)
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS);
else if (uMsg == WM_RBUTTONDOWN)
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS);
else if (uMsg == WM_MBUTTONDOWN)
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_MIDDLE, GLFW_PRESS);
else
{ {
if (HIWORD(wParam) == XBUTTON1) if (HIWORD(wParam) == XBUTTON1)
{
SetCapture(hWnd);
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_4, GLFW_PRESS); _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_4, GLFW_PRESS);
}
else if (HIWORD(wParam) == XBUTTON2) else if (HIWORD(wParam) == XBUTTON2)
{
SetCapture(hWnd);
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_5, GLFW_PRESS); _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_5, GLFW_PRESS);
return TRUE;
} }
return 1; return 0;
} }
case WM_LBUTTONUP: case WM_LBUTTONUP:
{
ReleaseCapture();
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_RELEASE);
return 0;
}
case WM_RBUTTONUP: case WM_RBUTTONUP:
{
ReleaseCapture();
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_RELEASE);
return 0;
}
case WM_MBUTTONUP: case WM_MBUTTONUP:
{
ReleaseCapture();
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_MIDDLE, GLFW_RELEASE);
return 0;
}
case WM_XBUTTONUP: case WM_XBUTTONUP:
{
ReleaseCapture();
if (uMsg == WM_LBUTTONUP)
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_RELEASE);
else if (uMsg == WM_RBUTTONUP)
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_RELEASE);
else if (uMsg == WM_MBUTTONUP)
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_MIDDLE, GLFW_RELEASE);
else
{ {
if (HIWORD(wParam) == XBUTTON1) if (HIWORD(wParam) == XBUTTON1)
{
ReleaseCapture();
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_4, GLFW_RELEASE); _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_4, GLFW_RELEASE);
}
else if (HIWORD(wParam) == XBUTTON2) else if (HIWORD(wParam) == XBUTTON2)
{
ReleaseCapture();
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_5, GLFW_RELEASE); _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_5, GLFW_RELEASE);
return TRUE;
} }
return 1; return 0;
} }
case WM_MOUSEMOVE: case WM_MOUSEMOVE: