From 290c6643f531a30dd1218aae1f550ea822bc2d4b Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sat, 1 Feb 2020 22:28:21 +0100 Subject: [PATCH] Platform/Win32/Win32Mouse: implement isButtonDown() using GetAsyncKeyState() and remove m_state and m_tracked. --- source/Platform/Win32/Win32Mouse.cpp | 15 ++++++++++++--- source/Platform/Win32/Win32Mouse.h | 4 ---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/source/Platform/Win32/Win32Mouse.cpp b/source/Platform/Win32/Win32Mouse.cpp index da586ae..74b2d83 100644 --- a/source/Platform/Win32/Win32Mouse.cpp +++ b/source/Platform/Win32/Win32Mouse.cpp @@ -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) diff --git a/source/Platform/Win32/Win32Mouse.h b/source/Platform/Win32/Win32Mouse.h index 33994c4..730e01c 100644 --- a/source/Platform/Win32/Win32Mouse.h +++ b/source/Platform/Win32/Win32Mouse.h @@ -28,10 +28,6 @@ protected : protected : Vector2f m_position; - - bool m_state[Mouse::Button::NUM_MBUTTONS]; - - bool m_tracked; }; } // namespace sp