Models a basic mouse, including relevant buttons and wheels. More...
#include <OSDLMouse.h>
Public Member Functions | |
Mouse (MouseNumber index, bool classicalMouseMode=true) | |
Constructs a new mouse instance. | |
virtual | ~Mouse () throw () |
Virtual destructor, closing corresponding mouse device. | |
virtual Video::Coordinate | getCursorAbscissa () const |
Returns the absolute abscissa of this mouse cursor. | |
virtual Video::Coordinate | getCursorOrdinate () const |
Returns the absolute ordinate of this mouse cursor. | |
virtual void | setCursorPosition (const Video::TwoDimensional::Point2D &newPosition) const |
Sets the cursor position for this mouse. | |
virtual void | setCursorPosition (Video::Coordinate x, Video::Coordinate y) const |
Sets the cursor position for this mouse. | |
virtual bool | getCursorVisibility () const |
Returns whether the cursor of this mouse is visible. | |
virtual void | setCursorVisibility (bool on) |
Sets the visibility for the cursor of this mouse. | |
virtual MouseButtonNumber | getNumberOfButtons () const |
Returns the number of actual mouse buttons, wheels not included. | |
virtual MouseWheelNumber | getNumberOfWheels () const |
Returns the number of mouse wheels. | |
virtual bool | isLeftButtonPressed () const |
Tells whether the left button of this mouse is currently pressed. | |
virtual bool | isMiddleButtonPressed () const |
Tells whether the middle button of this mouse is currently pressed. | |
virtual bool | isRightButtonPressed () const |
Tells whether the right button of this mouse is currently pressed. | |
virtual bool | isButtonPressed (MouseButtonNumber buttonNumber) const |
Tells whether specified mouse button is pressed. | |
virtual MouseButtonMask | getButtonStates () const |
Returns the state of all the buttons of this mouse. | |
virtual void | update () |
Updates the description of this mouse, for relative movements of the cursor. | |
virtual const std::string | toString (Ceylan::VerbosityLevels level=Ceylan::high) const |
Returns an user-friendly description of the state of this object. | |
virtual OSDL::MVC::Controller & | getActualController () const |
Returns the actual (OSDL) controller this input device should be linked to. | |
Static Public Member Functions | |
static bool | IsPressed (MouseButtonMask mask, MouseButtonNumber buttonToInspect) |
Reads specified button mask, and tells whether specified mouse button is currently pressed. | |
Static Public Attributes | |
static const MouseButtonNumber | DefaultButtonTotalNumber = 5 |
By default, a mouse is supposed to have 5 buttons: left, middle, right, wheel up and down. | |
static const MouseButtonNumber | DefaultButtonActualNumber = 3 |
By default, a mouse is supposed to have 3 actual buttons: left, middle, right. | |
static const MouseWheelNumber | DefaultWheelNumber = 1 |
By default, a mouse is supposed to have 1 wheel. | |
Protected Member Functions | |
virtual MouseNumber | getIndex () const |
Returns the index of this mouse in the platform list. | |
virtual void | focusGained (const FocusEvent &mouseFocusEvent) |
Called whenever this mouse gained focus, and notifies the linked controller, if any. | |
virtual void | focusLost (const FocusEvent &mouseFocusEvent) |
Called whenever this mouse lost focus, and notifies the linked controller, if any. | |
virtual void | mouseMoved (const MouseMotionEvent &mouseEvent) |
Called whenever this mouse moved, and notifies the linked controller, if any. | |
virtual void | buttonPressed (const MouseButtonEvent &mouseEvent) |
Called whenever a button of this mouse was pressed, and notifies the linked controller, if any. | |
virtual void | buttonReleased (const MouseButtonEvent &mouseEvent) |
Called whenever a button of this mouse was released, and notifies the linked controller, if any. | |
Protected Attributes | |
MouseNumber | _index |
The number of this mouse in platform list. | |
bool | _inClassicalMode |
Tells whether this mouse should be in classical mode. | |
MouseButtonNumber | _buttonTotalCount |
The number of total buttons for this mouse. | |
Video::Coordinate | _lastRelativeAbscissa |
Records the last relative abscissa. | |
Video::Coordinate | _lastRelativeOrdinate |
Records the last relative ordinate. | |
Private Member Functions | |
Mouse (const Mouse &source) | |
Copy constructor made private to ensure that it will never be called. | |
Mouse & | operator= (const Mouse &source) |
Assignment operator made private to ensure that it will never be called. | |
Friends | |
class | OSDL::Events::MouseHandler |
Models a basic mouse, including relevant buttons and wheels.
All events for this mouse are propagated to the associated controller, if any, which allows to finely master all available informations, at the expense of a higher complexity on the controller part.
For usual needs, Mouse instances should be set in classical mode: it would be more convenient, since it is a higher-level (but a little less general-purpose) model.
Definition at line 84 of file OSDLMouse.h.
Mouse::Mouse | ( | MouseNumber | index, | |
bool | classicalMouseMode = true | |||
) | [explicit] |
Constructs a new mouse instance.
index | the index of this mouse in platform list. | |
classicalMouseMode | tells whether this mouse should be in classical mode (higher level), or in normal mode (low-level events only are propagated to controllers). |
MouseException | if the operation failed or is not supported. |
Definition at line 92 of file OSDLMouse.cc.
Mouse::~Mouse | ( | ) | throw () [virtual] |
Virtual destructor, closing corresponding mouse device.
Definition at line 112 of file OSDLMouse.cc.
OSDL::Events::Mouse::Mouse | ( | const Mouse & | source | ) | [explicit, private] |
Copy constructor made private to ensure that it will never be called.
The compiler should complain whenever this undefined constructor is called, implicitly or not.
void Mouse::buttonPressed | ( | const MouseButtonEvent & | mouseEvent | ) | [protected, virtual] |
Called whenever a button of this mouse was pressed, and notifies the linked controller, if any.
mouseEvent | the corresponding mouse event. |
Definition at line 442 of file OSDLMouse.cc.
References OSDL::Events::EventsModule::DescribeEvent(), OSDL::Events::InputDevice::getActualController(), OSDL::MVC::Controller::mouseButtonPressed(), and OSDL_MOUSE_LOG.
Referenced by OSDL::Events::MouseHandler::buttonPressed().
void Mouse::buttonReleased | ( | const MouseButtonEvent & | mouseEvent | ) | [protected, virtual] |
Called whenever a button of this mouse was released, and notifies the linked controller, if any.
mouseEvent | the corresponding mouse event. |
Definition at line 458 of file OSDLMouse.cc.
References OSDL::Events::EventsModule::DescribeEvent(), OSDL::Events::InputDevice::getActualController(), OSDL::MVC::Controller::mouseButtonReleased(), and OSDL_MOUSE_LOG.
Referenced by OSDL::Events::MouseHandler::buttonReleased().
void Mouse::focusGained | ( | const FocusEvent & | mouseFocusEvent | ) | [protected, virtual] |
Called whenever this mouse gained focus, and notifies the linked controller, if any.
mouseFocusEvent | the event about the change in mouse focus. |
Definition at line 394 of file OSDLMouse.cc.
References OSDL::Events::DefaultMouse, OSDL::Events::EventsModule::DescribeEvent(), OSDL::Events::InputDevice::getActualController(), OSDL::MVC::Controller::mouseFocusGained(), and OSDL_MOUSE_LOG.
Referenced by OSDL::Events::MouseHandler::focusGained().
void Mouse::focusLost | ( | const FocusEvent & | mouseFocusEvent | ) | [protected, virtual] |
Called whenever this mouse lost focus, and notifies the linked controller, if any.
mouseFocusEvent | the event about the change in mouse focus. |
Definition at line 410 of file OSDLMouse.cc.
References OSDL::Events::DefaultMouse, OSDL::Events::EventsModule::DescribeEvent(), OSDL::Events::InputDevice::getActualController(), OSDL::MVC::Controller::mouseFocusLost(), and OSDL_MOUSE_LOG.
Referenced by OSDL::Events::MouseHandler::focusLost().
OSDL::MVC::Controller & InputDevice::getActualController | ( | ) | const [virtual, inherited] |
Returns the actual (OSDL) controller this input device should be linked to.
EventException | if this input device is not linked to any controller, or if the controller is not an OSDL one. |
Definition at line 63 of file OSDLInputDevice.cc.
Referenced by OSDL::Events::Joystick::axisChanged(), OSDL::Events::ClassicalJoystick::axisChanged(), buttonPressed(), OSDL::Events::Joystick::buttonPressed(), OSDL::Events::ClassicalJoystick::buttonPressed(), buttonReleased(), OSDL::Events::Joystick::buttonReleased(), OSDL::Events::ClassicalJoystick::buttonReleased(), focusGained(), focusLost(), OSDL::Events::Joystick::hatChanged(), mouseMoved(), and OSDL::Events::Joystick::trackballChanged().
MouseButtonMask Mouse::getButtonStates | ( | ) | const [virtual] |
Returns the state of all the buttons of this mouse.
This includes the wheels.
Definition at line 314 of file OSDLMouse.cc.
Video::Coordinate Mouse::getCursorAbscissa | ( | ) | const [virtual] |
Returns the absolute abscissa of this mouse cursor.
Definition at line 124 of file OSDLMouse.cc.
Video::Coordinate Mouse::getCursorOrdinate | ( | ) | const [virtual] |
Returns the absolute ordinate of this mouse cursor.
Definition at line 145 of file OSDLMouse.cc.
bool Mouse::getCursorVisibility | ( | ) | const [virtual] |
Returns whether the cursor of this mouse is visible.
Definition at line 190 of file OSDLMouse.cc.
MouseNumber Mouse::getIndex | ( | ) | const [protected, virtual] |
Returns the index of this mouse in the platform list.
Definition at line 474 of file OSDLMouse.cc.
References _index.
MouseButtonNumber Mouse::getNumberOfButtons | ( | ) | const [virtual] |
Returns the number of actual mouse buttons, wheels not included.
Definition at line 219 of file OSDLMouse.cc.
References DefaultButtonActualNumber.
MouseWheelNumber Mouse::getNumberOfWheels | ( | ) | const [virtual] |
Returns the number of mouse wheels.
Definition at line 228 of file OSDLMouse.cc.
References DefaultWheelNumber.
bool Mouse::isButtonPressed | ( | MouseButtonNumber | buttonNumber | ) | const [virtual] |
Tells whether specified mouse button is pressed.
buttonNumber | the number of the button for this mouse, for example 'LeftButton'. |
MouseException | if the mouse is not already open or if the button number is out of bounds. |
Definition at line 295 of file OSDLMouse.cc.
bool Mouse::isLeftButtonPressed | ( | ) | const [virtual] |
Tells whether the left button of this mouse is currently pressed.
Definition at line 238 of file OSDLMouse.cc.
bool Mouse::isMiddleButtonPressed | ( | ) | const [virtual] |
Tells whether the middle button of this mouse is currently pressed.
Definition at line 257 of file OSDLMouse.cc.
bool Mouse::IsPressed | ( | MouseButtonMask | mask, | |
MouseButtonNumber | buttonToInspect | |||
) | [static] |
Reads specified button mask, and tells whether specified mouse button is currently pressed.
Definition at line 372 of file OSDLMouse.cc.
bool Mouse::isRightButtonPressed | ( | ) | const [virtual] |
Tells whether the right button of this mouse is currently pressed.
Definition at line 276 of file OSDLMouse.cc.
void Mouse::mouseMoved | ( | const MouseMotionEvent & | mouseEvent | ) | [protected, virtual] |
Called whenever this mouse moved, and notifies the linked controller, if any.
mouseEvent | the corresponding mouse event. |
Definition at line 426 of file OSDLMouse.cc.
References OSDL::Events::DefaultMouse, OSDL::Events::EventsModule::DescribeEvent(), OSDL::Events::InputDevice::getActualController(), OSDL::MVC::Controller::mouseMoved(), and OSDL_MOUSE_LOG.
Referenced by OSDL::Events::MouseHandler::mouseMoved().
Assignment operator made private to ensure that it will never be called.
The compiler should complain whenever this undefined operator is called, implicitly or not.
virtual void OSDL::Events::Mouse::setCursorPosition | ( | Video::Coordinate | x, | |
Video::Coordinate | y | |||
) | const [virtual] |
Sets the cursor position for this mouse.
x | the new cursor abscissa. | |
y | the new cursor ordinate. |
void Mouse::setCursorPosition | ( | const Video::TwoDimensional::Point2D & | newPosition | ) | const [virtual] |
Sets the cursor position for this mouse.
newPosition | the new cursor position. |
Definition at line 167 of file OSDLMouse.cc.
References OSDL::Video::TwoDimensional::Point2D::getX(), and OSDL::Video::TwoDimensional::Point2D::getY().
void Mouse::setCursorVisibility | ( | bool | on | ) | [virtual] |
Sets the visibility for the cursor of this mouse.
on | cursor rendering will be enabled iff true. |
Definition at line 203 of file OSDLMouse.cc.
const string Mouse::toString | ( | Ceylan::VerbosityLevels | level = Ceylan::high |
) | const [virtual] |
Returns an user-friendly description of the state of this object.
level | the requested verbosity level. |
Reimplemented from OSDL::Events::InputDevice.
Definition at line 351 of file OSDLMouse.cc.
References _buttonTotalCount, and _inClassicalMode.
void Mouse::update | ( | ) | [virtual] |
Updates the description of this mouse, for relative movements of the cursor.
Definition at line 332 of file OSDLMouse.cc.
References _lastRelativeAbscissa, and _lastRelativeOrdinate.
friend class OSDL::Events::MouseHandler [friend] |
Definition at line 93 of file OSDLMouse.h.
The number of total buttons for this mouse.
Definition at line 462 of file OSDLMouse.h.
Referenced by toString().
bool OSDL::Events::Mouse::_inClassicalMode [protected] |
Tells whether this mouse should be in classical mode.
Definition at line 457 of file OSDLMouse.h.
Referenced by toString().
MouseNumber OSDL::Events::Mouse::_index [protected] |
The number of this mouse in platform list.
Definition at line 452 of file OSDLMouse.h.
Referenced by getIndex().
Records the last relative abscissa.
Definition at line 466 of file OSDLMouse.h.
Referenced by update().
Records the last relative ordinate.
Definition at line 470 of file OSDLMouse.h.
Referenced by update().
const MouseButtonNumber Mouse::DefaultButtonActualNumber = 3 [static] |
By default, a mouse is supposed to have 3 actual buttons: left, middle, right.
Definition at line 344 of file OSDLMouse.h.
Referenced by getNumberOfButtons().
const MouseButtonNumber Mouse::DefaultButtonTotalNumber = 5 [static] |
By default, a mouse is supposed to have 5 buttons: left, middle, right, wheel up and down.
Definition at line 335 of file OSDLMouse.h.
const MouseWheelNumber Mouse::DefaultWheelNumber = 1 [static] |
By default, a mouse is supposed to have 1 wheel.
Definition at line 352 of file OSDLMouse.h.
Referenced by getNumberOfWheels().