mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-22 09:39:42 +00:00
Revert "Merge redundant input events"
This commit is contained in:
parent
fe8437ae10
commit
cef415509f
1 changed files with 4 additions and 29 deletions
|
@ -49,42 +49,17 @@ InputWrapper::InputWrapper(SDL_Window* window, osg::ref_ptr<osgViewer::Viewer> v
|
||||||
|
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
|
|
||||||
SDL_Event event;
|
SDL_Event evt;
|
||||||
|
|
||||||
if (windowEventsOnly)
|
if (windowEventsOnly)
|
||||||
{
|
{
|
||||||
// During loading, just handle window events, and keep others for later
|
// During loading, just handle window events, and keep others for later
|
||||||
while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_WINDOWEVENT, SDL_WINDOWEVENT))
|
while (SDL_PeepEvents(&evt, 1, SDL_GETEVENT, SDL_WINDOWEVENT, SDL_WINDOWEVENT))
|
||||||
handleWindowEvent(event);
|
handleWindowEvent(evt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merge redundant events to avoid unnecessary listener calls
|
while(SDL_PollEvent(&evt))
|
||||||
std::vector<SDL_Event> events;
|
|
||||||
while(SDL_PollEvent(&event)) {
|
|
||||||
if (events.empty() || events.back().type != event.type)
|
|
||||||
{
|
|
||||||
events.emplace_back(event);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_Event& previousEvent = events.back();
|
|
||||||
|
|
||||||
switch (event.type)
|
|
||||||
{
|
|
||||||
case SDL_MOUSEMOTION:
|
|
||||||
previousEvent.motion.x = event.motion.x;
|
|
||||||
previousEvent.motion.y = event.motion.y;
|
|
||||||
previousEvent.motion.xrel += event.motion.xrel;
|
|
||||||
previousEvent.motion.yrel += event.motion.yrel;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
events.emplace_back(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (const SDL_Event& evt : events)
|
|
||||||
{
|
{
|
||||||
switch(evt.type)
|
switch(evt.type)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue