InputCommon: Make "Cursor" inputs aware of the rendered aspect ratio.

This commit is contained in:
Jordan Woyak
2020-01-24 00:06:39 -06:00
parent 42c03c4dad
commit b92f6480a0
9 changed files with 59 additions and 21 deletions

View File

@ -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()