mirror of
https://github.com/glfw/glfw.git
synced 2025-10-04 05:36:35 +00:00
Support useRawInput option on windows
This commit is contained in:
parent
ec6eb3cb83
commit
ac55b04da2
@ -290,7 +290,7 @@ static void disableCursor(_GLFWwindow* window)
|
|||||||
centerCursor(window);
|
centerCursor(window);
|
||||||
updateClipRect(window);
|
updateClipRect(window);
|
||||||
|
|
||||||
if (!RegisterRawInputDevices(&rid, 1, sizeof(rid)))
|
if (window->useRawInput && !RegisterRawInputDevices(&rid, 1, sizeof(rid)))
|
||||||
{
|
{
|
||||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||||
"Win32: Failed to register raw input device");
|
"Win32: Failed to register raw input device");
|
||||||
@ -310,7 +310,7 @@ static void enableCursor(_GLFWwindow* window)
|
|||||||
_glfw.win32.restoreCursorPosY);
|
_glfw.win32.restoreCursorPosY);
|
||||||
updateCursorImage(window);
|
updateCursorImage(window);
|
||||||
|
|
||||||
if (!RegisterRawInputDevices(&rid, 1, sizeof(rid)))
|
if (window->useRawInput && !RegisterRawInputDevices(&rid, 1, sizeof(rid)))
|
||||||
{
|
{
|
||||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||||
"Win32: Failed to remove raw input device");
|
"Win32: Failed to remove raw input device");
|
||||||
@ -825,9 +825,18 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
|
|
||||||
// Disabled cursor motion input is provided by WM_INPUT
|
// Disabled cursor motion input is provided by WM_INPUT
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
break;
|
{
|
||||||
|
if (_glfw.win32.disabledCursorWindow != window || window->useRawInput)
|
||||||
|
break;
|
||||||
|
|
||||||
_glfwInputCursorPos(window, x, y);
|
const int dx = x - window->win32.lastCursorPosX;
|
||||||
|
const int dy = y - window->win32.lastCursorPosY;
|
||||||
|
_glfwInputCursorPos(window,
|
||||||
|
window->virtualCursorPosX + dx,
|
||||||
|
window->virtualCursorPosY + dy);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_glfwInputCursorPos(window, x, y);
|
||||||
|
|
||||||
window->win32.lastCursorPosX = x;
|
window->win32.lastCursorPosX = x;
|
||||||
window->win32.lastCursorPosY = y;
|
window->win32.lastCursorPosY = y;
|
||||||
@ -856,7 +865,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
int dx, dy;
|
int dx, dy;
|
||||||
|
|
||||||
// Only process input when disabled cursor mode is applied
|
// Only process input when disabled cursor mode is applied
|
||||||
if (_glfw.win32.disabledCursorWindow != window)
|
if (_glfw.win32.disabledCursorWindow != window || !window->useRawInput)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
GetRawInputData(ri, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER));
|
GetRawInputData(ri, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER));
|
||||||
@ -1845,8 +1854,15 @@ void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
|
|||||||
|
|
||||||
void _glfwPlatformSetWindowUseRawInput(_GLFWwindow* window, GLFWbool enabled)
|
void _glfwPlatformSetWindowUseRawInput(_GLFWwindow* window, GLFWbool enabled)
|
||||||
{
|
{
|
||||||
window->useRawInput = enabled;
|
if (window->useRawInput != enabled)
|
||||||
// TODO
|
{
|
||||||
|
int update = (_glfw.win32.disabledCursorWindow == window);
|
||||||
|
if (update)
|
||||||
|
enableCursor(window);
|
||||||
|
window->useRawInput = enabled;
|
||||||
|
if (update)
|
||||||
|
disableCursor(window);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformPollEvents(void)
|
void _glfwPlatformPollEvents(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user