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)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ public :
|
|||
// Get mouse position
|
||||
virtual Vector2f getPosition() const;
|
||||
|
||||
virtual Vector2f getAbsPosition() const;
|
||||
|
||||
virtual bool isButtonDown(Mouse::Button button) const;
|
||||
|
||||
static bool handleMessage(MSG msg, Event& event);
|
||||
|
|
@ -27,7 +29,11 @@ protected :
|
|||
virtual void update(InputModule *input);
|
||||
|
||||
protected :
|
||||
// position in relative (focused window) coordinates.
|
||||
Vector2f m_position;
|
||||
|
||||
// position in absolute (screen) coordinates.
|
||||
Vector2f m_abs_position;
|
||||
};
|
||||
|
||||
} // namespace sp
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue