Skip to content

Commit d405c89

Browse files
committed
xrEngine/xr_input.cpp: update input before processing it (it is realtime 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
1 parent 2ec83d2 commit d405c89

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/xrEngine/Device_Initialize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void CRenderDevice::Initialize()
4141
if (strstr(Core.Params, "-weather"))
4242
initialize_weather_editor();
4343

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

4646
if (!m_sdlWnd)
4747
{

src/xrEngine/xr_input.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void CInput::SetKBDAcquire(bool bAcquire) {}
8686

8787
void CInput::MouseUpdate()
8888
{
89-
SDL_Event event;
89+
SDL_PumpEvents();
9090

9191
bool mouse_prev[COUNT_MOUSE_BUTTONS];
9292

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

102102
bool mouseMoved = false;
103103
offs[0] = offs[1] = offs[2] = 0;
104+
105+
SDL_Event event;
104106
while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_MOUSEMOTION, SDL_MOUSEWHEEL))
105107
{
106108
switch (event.type)
@@ -163,6 +165,8 @@ void CInput::MouseUpdate()
163165

164166
void CInput::KeyUpdate()
165167
{
168+
SDL_PumpEvents();
169+
166170
SDL_Event event;
167171
while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_KEYDOWN, SDL_KEYMAPCHANGED))
168172
{
@@ -331,8 +335,8 @@ void CInput::OnFrame(void)
331335

332336
if (Device.dwPrecacheFrame == 0)
333337
{
334-
MouseUpdate();
335338
KeyUpdate();
339+
MouseUpdate();
336340
}
337341

338342
stats.FrameTime.End();

0 commit comments

Comments
 (0)