1
0
Fork 0

Platform/Win32/Win32Mouse: add getAbsPosition() and update the position variables in update()

This commit is contained in:
Henrik Hautakoski 2020-02-01 22:30:10 +01:00
parent 290c6643f5
commit fa0fc72eb0
No known key found for this signature in database
GPG key ID: 96765B12FEAC4745
2 changed files with 25 additions and 0 deletions

View file

@ -33,6 +33,11 @@ Vector2f Win32Mouse::getPosition() const
return m_position;
}
Vector2f Win32Mouse::getAbsPosition() const
{
return m_abs_position;
}
bool Win32Mouse::isButtonDown(Mouse::Button button) const
{
int btn;
@ -51,6 +56,20 @@ bool Win32Mouse::isButtonDown(Mouse::Button button) const
void Win32Mouse::update(InputModule *input)
{
HWND handle;
POINT p;
// Update absolute position
GetCursorPos(&p);
m_abs_position = Vector2f(p.x, p.y);
// Update relative position
handle = ::GetCapture();
if (handle) {
// Translate position to focued window.
ScreenToClient(handle, &p);
m_position = Vector2f(p.x, p.y);
}
}
bool Win32Mouse::handleMessage(MSG msg, Event& event)