diff options
| author | Jasper St. Pierre <jstpierre@mecheye.net> | 2016-09-03 15:03:18 -0700 |
|---|---|---|
| committer | Jasper St. Pierre <jstpierre@mecheye.net> | 2016-09-04 10:44:22 -0700 |
| commit | 2b640a4f7d961880d53ba7b193774e4aa4a80c65 (patch) | |
| tree | e4ba266f165c10667c6c24b560462d3ccfc8b82a /Source/Core/InputCommon/ControllerInterface/Xlib | |
| parent | 980ecfba7f934f91c021bdeec06d0518dd570bac (diff) | |
XInput2: Only do a round trip when the mouse has moved
This should cut down on round trips and blocking calls dramatically
during gameplay.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/Xlib')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp | 10 |
1 files 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 |
