From 75f35393c33a06dda4b92f22d9634a92142145f3 Mon Sep 17 00:00:00 2001 From: Filippo Tarpini Date: Sat, 2 Jan 2021 18:30:14 +0200 Subject: [PATCH 1/3] Fix XInput2 cursor going to +infinite if the window size was 0 --- Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp index dac0c085fa..a60edc3282 100644 --- a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp @@ -227,8 +227,8 @@ void KeyboardMouse::UpdateCursor() const auto window_scale = g_controller_interface.GetWindowInputScale(); // the mouse position as a range from -1 to 1 - m_state.cursor.x = (win_x / win_attribs.width * 2 - 1) * window_scale.x; - m_state.cursor.y = (win_y / win_attribs.height * 2 - 1) * window_scale.y; + m_state.cursor.x = (win_x / std::max(win_attribs.width, 1) * 2 - 1) * window_scale.x; + m_state.cursor.y = (win_y / std::max(win_attribs.height, 1) * 2 - 1) * window_scale.y; } void KeyboardMouse::UpdateInput() From 5a5c815ff037b4520d2ef90581b080d5d78e4b4f Mon Sep 17 00:00:00 2001 From: Filippo Tarpini Date: Sat, 2 Jan 2021 18:33:13 +0200 Subject: [PATCH 2/3] Fix DInput cursor going to +infinite if the window size was 0 --- .../ControllerInterface/DInput/DInputKeyboardMouse.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp b/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp index 5aca9f5280..e5e10802cc 100644 --- a/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp +++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp @@ -126,9 +126,9 @@ void KeyboardMouse::UpdateCursorInput() RECT rect; GetClientRect(m_hwnd, &rect); - // Width and height are the size of the rendering window. - const auto win_width = rect.right - rect.left; - const auto win_height = rect.bottom - rect.top; + // Width and height are the size of the rendering window. They could be 0 + const auto win_width = std::max(rect.right - rect.left, 1l); + const auto win_height = std::max(rect.bottom - rect.top, 1l); const auto window_scale = g_controller_interface.GetWindowInputScale(); From 8813ba69f5594180923cb2e2699ecd270a9cbd71 Mon Sep 17 00:00:00 2001 From: Filippo Tarpini Date: Sat, 2 Jan 2021 18:34:22 +0200 Subject: [PATCH 3/3] Fix Quartz cursor going to +infinite if the window size was 0 --- .../ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm b/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm index d594ac9e5f..216ae58e6c 100644 --- a/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm +++ b/Source/Core/InputCommon/ControllerInterface/Quartz/QuartzKeyboardAndMouse.mm @@ -188,8 +188,8 @@ void KeyboardAndMouse::UpdateInput() loc.x -= bounds.origin.x; loc.y -= bounds.origin.y; - m_cursor.x = (loc.x / bounds.size.width * 2 - 1.0) * window_scale.x; - m_cursor.y = (loc.y / bounds.size.height * 2 - 1.0) * window_scale.y; + m_cursor.x = (loc.x / std::max(bounds.size.width, 1.0) * 2 - 1.0) * window_scale.x; + m_cursor.y = (loc.y / std::max(bounds.size.height, 1.0) * 2 - 1.0) * window_scale.y; } std::string KeyboardAndMouse::GetName() const