diff options
| author | Tilka <tilkax@gmail.com> | 2020-01-25 20:28:01 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-25 20:28:01 +0000 |
| commit | b0e040431a633ea3b0486673592e0de753110823 (patch) | |
| tree | 5b2e36a8cc6259de49d28461a00778960f254faa /Source/Core/InputCommon/ControllerInterface/Xlib | |
| parent | 9827aa7a37e444cb359d4db50f5d73cb58eda77c (diff) | |
| parent | b92f6480a0b7517666ad139fc81c89033f84830f (diff) | |
Merge pull request #8581 from jordan-woyak/ciface-ar-aware
InputCommon: Make "Cursor" inputs aware of the rendered aspect ratio.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/Xlib')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp | 6 | ||||
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.h | 7 |
2 files changed, 7 insertions, 6 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp index d9642c6264..540a2ec9a8 100644 --- a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp @@ -212,9 +212,11 @@ void KeyboardMouse::UpdateCursor() XWindowAttributes win_attribs; XGetWindowAttributes(m_display, m_window, &win_attribs); + const auto window_scale = g_controller_interface.GetWindowInputScale(); + // the mouse position as a range from -1 to 1 - m_state.cursor.x = win_x / (float)win_attribs.width * 2 - 1; - m_state.cursor.y = win_y / (float)win_attribs.height * 2 - 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; } void KeyboardMouse::UpdateInput() diff --git a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.h b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.h index e657f8b8df..52c424a3e6 100644 --- a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.h +++ b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.h @@ -12,6 +12,7 @@ extern "C" { #include <X11/keysym.h> } +#include "Common/Matrix.h" #include "InputCommon/ControllerInterface/ControllerInterface.h" namespace ciface::XInput2 @@ -25,10 +26,8 @@ private: { char keyboard[32]; unsigned int buttons; - struct - { - float x, y; - } cursor, axis; + Common::Vec2 cursor; + Common::Vec2 axis; }; class Key : public Input |
