Skip to content

Commit

Permalink
xrEngine/xr_input.cpp: update input before processing it (it is realt…
Browse files Browse the repository at this point in the history
…ime now)

Mouse updates happens much more frequently, so it should be updated after keyboard
This should solve reaction delay problem

xrEngine/Device_initialize.cpp: Init only SDL Video
  • Loading branch information
Xottab-DUTY committed Jul 23, 2018
1 parent cbd1555 commit 213c011
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/xrEngine/Device_Initialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void CRenderDevice::Initialize()
if (strstr(Core.Params, "-weather"))
initialize_weather_editor();

R_ASSERT3(SDL_Init(SDL_INIT_EVERYTHING) == 0, "Unable to initialize SDL", SDL_GetError());
R_ASSERT3(SDL_Init(SDL_INIT_VIDEO) == 0, "Unable to initialize SDL", SDL_GetError());

if (!m_sdlWnd)
{
Expand Down
8 changes: 6 additions & 2 deletions src/xrEngine/xr_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void CInput::SetKBDAcquire(bool bAcquire) {}

void CInput::MouseUpdate()
{
SDL_Event event;
SDL_PumpEvents();

bool mouse_prev[COUNT_MOUSE_BUTTONS];

Expand All @@ -101,6 +101,8 @@ void CInput::MouseUpdate()

bool mouseMoved = false;
offs[0] = offs[1] = offs[2] = 0;

SDL_Event event;
while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_MOUSEMOTION, SDL_MOUSEWHEEL))
{
switch (event.type)
Expand Down Expand Up @@ -163,6 +165,8 @@ void CInput::MouseUpdate()

void CInput::KeyUpdate()
{
SDL_PumpEvents();

SDL_Event event;
while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_KEYDOWN, SDL_KEYMAPCHANGED))
{
Expand Down Expand Up @@ -331,8 +335,8 @@ void CInput::OnFrame(void)

if (Device.dwPrecacheFrame == 0)
{
MouseUpdate();
KeyUpdate();
MouseUpdate();
}

stats.FrameTime.End();
Expand Down

0 comments on commit 213c011

Please sign in to comment.