1
0
Fork 0

Platform/Win32/Win32Mouse: implement isButtonDown() using GetAsyncKeyState() and remove m_state and m_tracked.

This commit is contained in:
Henrik Hautakoski 2020-02-01 22:28:21 +01:00
parent c7c1ff68fd
commit 290c6643f5
No known key found for this signature in database
GPG key ID: 96765B12FEAC4745
2 changed files with 12 additions and 7 deletions

View file

@ -26,8 +26,6 @@ static RECT GetClientArea(HWND hwnd) {
void Win32Mouse::init()
{
memset(m_state, 0, Mouse::Button::NUM_MBUTTONS);
m_tracked = false;
}
Vector2f Win32Mouse::getPosition() const
@ -37,7 +35,18 @@ Vector2f Win32Mouse::getPosition() const
bool Win32Mouse::isButtonDown(Mouse::Button button) const
{
return m_state[button];
int btn;
switch(button) {
case Mouse::Left : btn = VK_LBUTTON; break;
case Mouse::Right : btn = VK_RBUTTON; break;
case Mouse::Middle : btn = VK_MBUTTON; break;
case Mouse::Button1 : btn = VK_XBUTTON1; break;
case Mouse::Button2 : btn = VK_XBUTTON2; break;
default: btn = 0;
}
return ::GetAsyncKeyState(btn) & 0x8000;
}
void Win32Mouse::update(InputModule *input)

View file

@ -28,10 +28,6 @@ protected :
protected :
Vector2f m_position;
bool m_state[Mouse::Button::NUM_MBUTTONS];
bool m_tracked;
};
} // namespace sp