mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Extract UpdateMouseState function
This commit is contained in:
parent
9a17617a28
commit
ff43b32257
|
@ -160,6 +160,29 @@ bool CInput::KeyState(int Key) const
|
|||
return m_aInputState[Key];
|
||||
}
|
||||
|
||||
void CInput::UpdateMouseState()
|
||||
{
|
||||
const int MouseState = SDL_GetMouseState(NULL, NULL);
|
||||
if(MouseState & SDL_BUTTON(SDL_BUTTON_LEFT))
|
||||
m_aInputState[KEY_MOUSE_1] = 1;
|
||||
if(MouseState & SDL_BUTTON(SDL_BUTTON_RIGHT))
|
||||
m_aInputState[KEY_MOUSE_2] = 1;
|
||||
if(MouseState & SDL_BUTTON(SDL_BUTTON_MIDDLE))
|
||||
m_aInputState[KEY_MOUSE_3] = 1;
|
||||
if(MouseState & SDL_BUTTON(SDL_BUTTON_X1))
|
||||
m_aInputState[KEY_MOUSE_4] = 1;
|
||||
if(MouseState & SDL_BUTTON(SDL_BUTTON_X2))
|
||||
m_aInputState[KEY_MOUSE_5] = 1;
|
||||
if(MouseState & SDL_BUTTON(6))
|
||||
m_aInputState[KEY_MOUSE_6] = 1;
|
||||
if(MouseState & SDL_BUTTON(7))
|
||||
m_aInputState[KEY_MOUSE_7] = 1;
|
||||
if(MouseState & SDL_BUTTON(8))
|
||||
m_aInputState[KEY_MOUSE_8] = 1;
|
||||
if(MouseState & SDL_BUTTON(9))
|
||||
m_aInputState[KEY_MOUSE_9] = 1;
|
||||
}
|
||||
|
||||
bool CInput::GetIMEState()
|
||||
{
|
||||
return m_NumTextInputInstances > 0;
|
||||
|
@ -228,26 +251,8 @@ int CInput::Update()
|
|||
if(m_EditingTextLen == 0)
|
||||
m_EditingTextLen = -1;
|
||||
|
||||
// these states must always be updated manually because they are not in the GetKeyState from SDL
|
||||
const int MouseState = SDL_GetMouseState(NULL, NULL);
|
||||
if(MouseState & SDL_BUTTON(SDL_BUTTON_LEFT))
|
||||
m_aInputState[KEY_MOUSE_1] = 1;
|
||||
if(MouseState & SDL_BUTTON(SDL_BUTTON_RIGHT))
|
||||
m_aInputState[KEY_MOUSE_2] = 1;
|
||||
if(MouseState & SDL_BUTTON(SDL_BUTTON_MIDDLE))
|
||||
m_aInputState[KEY_MOUSE_3] = 1;
|
||||
if(MouseState & SDL_BUTTON(SDL_BUTTON_X1))
|
||||
m_aInputState[KEY_MOUSE_4] = 1;
|
||||
if(MouseState & SDL_BUTTON(SDL_BUTTON_X2))
|
||||
m_aInputState[KEY_MOUSE_5] = 1;
|
||||
if(MouseState & SDL_BUTTON(6))
|
||||
m_aInputState[KEY_MOUSE_6] = 1;
|
||||
if(MouseState & SDL_BUTTON(7))
|
||||
m_aInputState[KEY_MOUSE_7] = 1;
|
||||
if(MouseState & SDL_BUTTON(8))
|
||||
m_aInputState[KEY_MOUSE_8] = 1;
|
||||
if(MouseState & SDL_BUTTON(9))
|
||||
m_aInputState[KEY_MOUSE_9] = 1;
|
||||
// these states must always be updated manually because they are not in the SDL_GetKeyboardState from SDL
|
||||
UpdateMouseState();
|
||||
|
||||
SDL_Event Event;
|
||||
bool IgnoreKeys = false;
|
||||
|
|
|
@ -31,6 +31,8 @@ class CInput : public IEngineInput
|
|||
unsigned char m_aInputState[g_MaxKeys]; // SDL_SCANCODE
|
||||
int m_InputCounter;
|
||||
|
||||
void UpdateMouseState();
|
||||
|
||||
// IME support
|
||||
int m_NumTextInputInstances;
|
||||
char m_aEditingText[INPUT_TEXT_SIZE];
|
||||
|
|
Loading…
Reference in a new issue