Platform/Win32/Win32Mouse: add getAbsPosition() and update the position variables in update()
This commit is contained in:
parent
290c6643f5
commit
fa0fc72eb0
2 changed files with 25 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue