9 #include "imstkDeviceClient.h" 11 #include <unordered_map> 15 using MouseActionType = int;
16 #define MOUSE_RELEASE 0 19 using MouseButtonType = int;
21 #define RIGHT_BUTTON 1 22 #define MIDDLE_BUTTON 2 33 MouseEvent(
const std::string type,
const MouseButtonType buttonId) :
38 MouseEvent(std::string type,
const double scrollDx) :
67 m_prevPos(Vec2d(0.0, 0.0)), m_pos(Vec2d(0.0, 0.0)) { }
72 static std::shared_ptr<MouseDeviceClient> New();
107 const Vec2d&
getPos()
const {
return m_pos; }
119 if (m_buttons.find(buttonId) != m_buttons.end())
121 return m_buttons.at(buttonId) == MOUSE_PRESS;
125 return MOUSE_RELEASE;
137 this->postEvent(
MouseEvent(MouseDeviceClient::mouseMove()));
145 m_buttons[buttonId] = MOUSE_PRESS;
146 this->postEvent(
MouseEvent(MouseDeviceClient::mouseButtonPress(), buttonId));
154 m_buttons[buttonId] = MOUSE_RELEASE;
155 this->postEvent(
MouseEvent(MouseDeviceClient::mouseButtonRelease(), buttonId));
The device client's represents the device and provides an interface to acquire data from a device...
Base class for events which contain a type, priority, and data priority defaults to 0 and uses a grea...
void emitButtonPress(const MouseButtonType buttonId)
Post a click down event.
MouseButtonType m_buttonId
Button id.
const Vec2d & getPrevPos() const
Get the previous position of the mouse.
void emitButtonRelease(const MouseButtonType buttonId)
Post a click release event.
void emitScroll(const double dx)
Post a mouse scroll event.
double m_scrollDx
Mouse scroll.
Provides the information of a mouse event, this includes button presses/releases and scrolling...
const Vec2d & getPos() const
Get the current position of the mouse.
bool isButtonDown(const MouseButtonType buttonId) const
Query if the button is down.
void updateMousePos(const Vec2d &pos)
Update the mouse position.
Interactor styles forward their controls to imstk objects.