XInput2: Only do a round trip when the mouse has moved
This should cut down on round trips and blocking calls dramatically during gameplay.
This commit is contained in:
parent
980ecfba7f
commit
2b640a4f7d
|
@ -216,12 +216,10 @@ void KeyboardMouse::UpdateInput()
|
||||||
{
|
{
|
||||||
XFlush(m_display);
|
XFlush(m_display);
|
||||||
|
|
||||||
// Get the absolute position of the mouse pointer
|
|
||||||
UpdateCursor();
|
|
||||||
|
|
||||||
// for the axis controls
|
// for the axis controls
|
||||||
float delta_x = 0.0f, delta_y = 0.0f;
|
float delta_x = 0.0f, delta_y = 0.0f;
|
||||||
double delta_delta;
|
double delta_delta;
|
||||||
|
bool mouse_moved = false;
|
||||||
|
|
||||||
// Iterate through the event queue - update the axis controls, mouse
|
// Iterate through the event queue - update the axis controls, mouse
|
||||||
// button controls, and keyboard controls.
|
// button controls, and keyboard controls.
|
||||||
|
@ -256,6 +254,8 @@ void KeyboardMouse::UpdateInput()
|
||||||
m_state.keyboard[dev_event->detail / 8] &= ~(1 << (dev_event->detail % 8));
|
m_state.keyboard[dev_event->detail / 8] &= ~(1 << (dev_event->detail % 8));
|
||||||
break;
|
break;
|
||||||
case XI_RawMotion:
|
case XI_RawMotion:
|
||||||
|
mouse_moved = true;
|
||||||
|
|
||||||
// always safe because there is always at least one byte in
|
// always safe because there is always at least one byte in
|
||||||
// raw_event->valuators.mask, and if a bit is set in the mask,
|
// raw_event->valuators.mask, and if a bit is set in the mask,
|
||||||
// then the value in raw_values is also available.
|
// 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 *= MOUSE_AXIS_SMOOTHING;
|
||||||
m_state.axis.y += delta_y;
|
m_state.axis.y += delta_y;
|
||||||
m_state.axis.y /= MOUSE_AXIS_SMOOTHING + 1.0f;
|
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
|
std::string KeyboardMouse::GetName() const
|
||||||
|
|
Loading…
Reference in New Issue