Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix Input Handling
  • Loading branch information
BeaR authored and oy committed Jul 7, 2012
1 parent c059c09 commit 8372849
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
13 changes: 9 additions & 4 deletions src/engine/client/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ CInput::CInput()

m_InputCurrent = 0;
m_InputGrabbed = 0;
m_InputDispatched = false;

m_LastRelease = 0;
m_ReleaseDelta = -1;
Expand Down Expand Up @@ -116,10 +117,14 @@ int CInput::Update()
/*if(!input_grabbed && Graphics()->WindowActive())
Input()->MouseModeRelative();*/

// clear and begin count on the other one
m_InputCurrent^=1;
mem_zero(&m_aInputCount[m_InputCurrent], sizeof(m_aInputCount[m_InputCurrent]));
mem_zero(&m_aInputState[m_InputCurrent], sizeof(m_aInputState[m_InputCurrent]));
if(m_InputDispatched)
{
// clear and begin count on the other one
m_InputCurrent^=1;
mem_zero(&m_aInputCount[m_InputCurrent], sizeof(m_aInputCount[m_InputCurrent]));
mem_zero(&m_aInputState[m_InputCurrent], sizeof(m_aInputState[m_InputCurrent]));
m_InputDispatched = false;
}

{
int i;
Expand Down
7 changes: 6 additions & 1 deletion src/engine/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class IInput : public IInterface

unsigned char m_aInputState[2][1024];
int m_InputCurrent;
bool m_InputDispatched;

int KeyWasPressed(int Key) { return m_aInputState[m_InputCurrent^1][Key]; }

Expand All @@ -51,7 +52,11 @@ class IInput : public IInterface

// events
int NumEvents() const { return m_NumEvents; }
void ClearEvents() { m_NumEvents = 0; }
void ClearEvents()
{
m_NumEvents = 0;
m_InputDispatched = true;
}
CEvent GetEvent(int Index) const
{
if(Index < 0 || Index >= m_NumEvents)
Expand Down

0 comments on commit 8372849

Please sign in to comment.