public static void MouseButtonCallback(IntPtr hWnd, InputManager inputManager, uint button, uint x, uint y) { bool down = false; switch (button) { case WinUser.WM_LBUTTONDOWN: WinUser.SetCapture(hWnd); button = Input.SP_MOUSE_LEFT; down = true; break; case WinUser.WM_LBUTTONUP: WinUser.ReleaseCapture(); button = Input.SP_MOUSE_LEFT; down = false; break; case WinUser.WM_RBUTTONDOWN: WinUser.SetCapture(hWnd); button = Input.SP_MOUSE_RIGHT; down = true; break; case WinUser.WM_RBUTTONUP: WinUser.ReleaseCapture(); button = Input.SP_MOUSE_RIGHT; down = false; break; case WinUser.WM_MBUTTONDOWN: WinUser.SetCapture(hWnd); button = Input.SP_MOUSE_MIDDLE; down = true; break; case WinUser.WM_MBUTTONUP: WinUser.ReleaseCapture(); button = Input.SP_MOUSE_MIDDLE; down = false; break; } inputManager.mouseButtons[button] = down; inputManager.mousePosition.x = x; inputManager.mousePosition.y = y; Log.Assert(() => inputManager.eventCallback != null); if (down) { inputManager.eventCallback(new MousePressedEvent(button, x, y)); } else { inputManager.eventCallback(new MouseReleasedEvent(button, x, y)); } }