From 2b640a4f7d961880d53ba7b193774e4aa4a80c65 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Sat, 3 Sep 2016 15:03:18 -0700 Subject: [PATCH] XInput2: Only do a round trip when the mouse has moved This should cut down on round trips and blocking calls dramatically during gameplay. --- .../InputCommon/ControllerInterface/Xlib/XInput2.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp index 59a1c64047..de3490f2e0 100644 --- a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp @@ -216,12 +216,10 @@ void KeyboardMouse::UpdateInput() { XFlush(m_display); - // Get the absolute position of the mouse pointer - UpdateCursor(); - // for the axis controls float delta_x = 0.0f, delta_y = 0.0f; double delta_delta; + bool mouse_moved = false; // Iterate through the event queue - update the axis controls, mouse // button controls, and keyboard controls. @@ -256,6 +254,8 @@ void KeyboardMouse::UpdateInput() m_state.keyboard[dev_event->detail / 8] &= ~(1 << (dev_event->detail % 8)); break; case XI_RawMotion: + mouse_moved = true; + // always safe because there is always at least one byte in // raw_event->valuators.mask, and if a bit is set in the mask, // then the value in raw_values is also available. @@ -286,6 +286,10 @@ void KeyboardMouse::UpdateInput() m_state.axis.y *= MOUSE_AXIS_SMOOTHING; m_state.axis.y += delta_y; m_state.axis.y /= MOUSE_AXIS_SMOOTHING + 1.0f; + + // Get the absolute position of the mouse pointer + if (mouse_moved) + UpdateCursor(); } std::string KeyboardMouse::GetName() const