mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Split CInput::NextFrame() from CInput::Update() (fixes #444)
This commit is contained in:
parent
a0a7d96ca0
commit
72a6e20ba8
|
@ -2809,6 +2809,7 @@ void CClient::Run()
|
|||
}
|
||||
m_pGraphics->Swap();
|
||||
}
|
||||
Input()->NextFrame();
|
||||
}
|
||||
if(Input()->VideoRestartNeeded())
|
||||
{
|
||||
|
|
|
@ -126,19 +126,20 @@ bool CInput::KeyState(int Key) const
|
|||
return m_aInputState[Key>=KEY_MOUSE_1 ? Key : SDL_GetScancodeFromKey(KeyToKeycode(Key))];
|
||||
}
|
||||
|
||||
void CInput::NextFrame()
|
||||
{
|
||||
int i;
|
||||
const Uint8 *pState = SDL_GetKeyboardState(&i);
|
||||
if(i >= KEY_LAST)
|
||||
i = KEY_LAST-1;
|
||||
mem_copy(m_aInputState, pState, i);
|
||||
}
|
||||
|
||||
int CInput::Update()
|
||||
{
|
||||
// keep the counter between 1..0xFFFF, 0 means not pressed
|
||||
m_InputCounter = (m_InputCounter%0xFFFF)+1;
|
||||
|
||||
{
|
||||
int i;
|
||||
const Uint8 *pState = SDL_GetKeyboardState(&i);
|
||||
if(i >= KEY_LAST)
|
||||
i = KEY_LAST-1;
|
||||
mem_copy(m_aInputState, pState, i);
|
||||
}
|
||||
|
||||
// these states must always be updated manually because they are not in the GetKeyState from SDL
|
||||
int i = SDL_GetMouseState(NULL, NULL);
|
||||
if(i&SDL_BUTTON(1)) m_aInputState[KEY_MOUSE_1] = 1; // 1 is left
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
virtual void SetClipboardText(const char *Text);
|
||||
|
||||
virtual int Update();
|
||||
virtual void NextFrame();
|
||||
|
||||
virtual int VideoRestartNeeded();
|
||||
};
|
||||
|
|
|
@ -76,6 +76,7 @@ class IEngineInput : public IInput
|
|||
public:
|
||||
virtual void Init() = 0;
|
||||
virtual int Update() = 0;
|
||||
virtual void NextFrame() = 0;
|
||||
virtual int VideoRestartNeeded() = 0;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue