throttle mouse motion events to one per frame
This commit is contained in:
@@ -174,6 +174,7 @@ namespace OpenRA.GlRenderer
|
|||||||
|
|
||||||
var mods = MakeModifiers(Sdl.SDL_GetModState());
|
var mods = MakeModifiers(Sdl.SDL_GetModState());
|
||||||
Game.HandleModifierKeys(mods);
|
Game.HandleModifierKeys(mods);
|
||||||
|
MouseEventArgs pendingMotion = null;
|
||||||
|
|
||||||
Sdl.SDL_Event e;
|
Sdl.SDL_Event e;
|
||||||
while (Sdl.SDL_PollEvent(out e) != 0)
|
while (Sdl.SDL_PollEvent(out e) != 0)
|
||||||
@@ -186,6 +187,12 @@ namespace OpenRA.GlRenderer
|
|||||||
|
|
||||||
case Sdl.SDL_MOUSEBUTTONDOWN:
|
case Sdl.SDL_MOUSEBUTTONDOWN:
|
||||||
{
|
{
|
||||||
|
if (pendingMotion != null)
|
||||||
|
{
|
||||||
|
Game.DispatchMouseInput(MouseInputEvent.Move, pendingMotion, mods);
|
||||||
|
pendingMotion = null;
|
||||||
|
}
|
||||||
|
|
||||||
var button = MakeButton(e.button.button);
|
var button = MakeButton(e.button.button);
|
||||||
lastButtonBits |= button;
|
lastButtonBits |= button;
|
||||||
|
|
||||||
@@ -196,6 +203,12 @@ namespace OpenRA.GlRenderer
|
|||||||
|
|
||||||
case Sdl.SDL_MOUSEBUTTONUP:
|
case Sdl.SDL_MOUSEBUTTONUP:
|
||||||
{
|
{
|
||||||
|
if (pendingMotion != null)
|
||||||
|
{
|
||||||
|
Game.DispatchMouseInput(MouseInputEvent.Move, pendingMotion, mods);
|
||||||
|
pendingMotion = null;
|
||||||
|
}
|
||||||
|
|
||||||
var button = MakeButton(e.button.button);
|
var button = MakeButton(e.button.button);
|
||||||
lastButtonBits &= ~button;
|
lastButtonBits &= ~button;
|
||||||
|
|
||||||
@@ -206,9 +219,7 @@ namespace OpenRA.GlRenderer
|
|||||||
|
|
||||||
case Sdl.SDL_MOUSEMOTION:
|
case Sdl.SDL_MOUSEMOTION:
|
||||||
{
|
{
|
||||||
Game.DispatchMouseInput(MouseInputEvent.Move,
|
pendingMotion = new MouseEventArgs(lastButtonBits, 0, e.motion.x, e.motion.y, 0);
|
||||||
new MouseEventArgs(lastButtonBits, 0, e.motion.x, e.motion.y, 0),
|
|
||||||
mods);
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case Sdl.SDL_KEYDOWN:
|
case Sdl.SDL_KEYDOWN:
|
||||||
@@ -242,6 +253,12 @@ namespace OpenRA.GlRenderer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pendingMotion != null)
|
||||||
|
{
|
||||||
|
Game.DispatchMouseInput(MouseInputEvent.Move, pendingMotion, mods);
|
||||||
|
pendingMotion = null;
|
||||||
|
}
|
||||||
|
|
||||||
CheckGlError();
|
CheckGlError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user