mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-26 04:32:35 +01:00
raw_mouse: adjust relative mouse position if the window size changed
This commit is contained in:
parent
dfc626c99c
commit
e3d4c067df
@ -159,6 +159,16 @@ void raw_mouse::update_values(const RAWMOUSE& state)
|
||||
const int delta_x = static_cast<int>(state.lLastX * m_mouse_acceleration);
|
||||
const int delta_y = static_cast<int>(state.lLastY * m_mouse_acceleration);
|
||||
|
||||
// Adjust mouse position if the window size changed
|
||||
if (m_window_width_old != m_window_width || m_window_height_old != m_window_height)
|
||||
{
|
||||
m_pos_x = static_cast<int>(std::round((m_pos_x / static_cast<f32>(m_window_width_old)) * m_window_width));
|
||||
m_pos_y = static_cast<int>(std::round((m_pos_y / static_cast<f32>(m_window_height_old)) * m_window_height));
|
||||
|
||||
m_window_width_old = m_window_width;
|
||||
m_window_height_old = m_window_height;
|
||||
}
|
||||
|
||||
// Calculate new position
|
||||
m_pos_x = std::max(0, std::min(m_pos_x + delta_x, m_window_width - 1));
|
||||
m_pos_y = std::max(0, std::min(m_pos_y + delta_y, m_window_height - 1));
|
||||
|
@ -32,6 +32,8 @@ private:
|
||||
display_handle_t m_window_handle{};
|
||||
int m_window_width{};
|
||||
int m_window_height{};
|
||||
int m_window_width_old{};
|
||||
int m_window_height_old{};
|
||||
int m_pos_x{};
|
||||
int m_pos_y{};
|
||||
float m_mouse_acceleration = 1.0f;
|
||||
|
Loading…
Reference in New Issue
Block a user