Models a classical joystick, with simplified access to the two main axes, commonly used to indicate the joystick current direction, with customizable deadzone support and two buttons directly managed. More...
#include <OSDLClassicalJoystick.h>
Public Member Functions | |
ClassicalJoystick (JoystickNumber index, AxisPosition deadZoneExtent=DefaultDeadZoneExtent) | |
Constructs a new joystick handler. | |
virtual | ~ClassicalJoystick () throw () |
Virtual destructor, closing corresponding joystick device. | |
virtual void | getDeadZoneValues (AxisPosition &firstAxisExtent, AxisPosition &secondAxisExtent) const |
Returns the deadzone extent for the two first axes. | |
virtual void | setDeadZoneValues (AxisPosition firstAxisExtent=DefaultDeadZoneExtent, AxisPosition secondAxisExtent=DefaultDeadZoneExtent) |
Sets the deadzone values for the two first axes. | |
virtual const std::string | toString (Ceylan::VerbosityLevels level=Ceylan::high) const |
Returns an user-friendly description of the state of this object. | |
virtual const std::string & | getName () const |
Returns the implementation dependent name of this joystick. | |
virtual bool | isOpen () const |
Tells whether this joystick is currently opened. | |
virtual void | open () |
Opens the joystick, so that it can be used. | |
virtual void | close () |
Closes the joystick. | |
virtual JoystickAxesCount | getNumberOfAxes () const |
Returns the number of joystick axes. | |
virtual JoystickTrackballsCount | getNumberOfTrackballs () const |
Returns the number of joystick trackballs. | |
virtual JoystickHatsCount | getNumberOfHats () const |
Returns the number of joystick hats. | |
virtual JoystickButtonsCount | getNumberOfButtons () const |
Returns the number of joystick buttons. | |
virtual AxisPosition | getAbscissaPosition () const |
Returns the absolute position of the X axis. | |
virtual AxisPosition | getOrdinatePosition () const |
Returns the absolute position of the Y axis. | |
virtual AxisPosition | getPositionOfAxis (JoystickAxesCount index) const |
Returns the absolute position of the specified axis. | |
virtual HatPosition | getPositionOfHat (JoystickHatsCount index) const |
Returns the absolute position of the specified hat. | |
virtual bool | isButtonPressed (JoystickButtonsCount buttonNumber) const |
Tells whether specified joystick button is pressed. | |
virtual bool | getPositionOfTrackball (JoystickTrackballsCount ball, BallMotion &deltaX, BallMotion &deltaY) const |
Returns the relative position of the specified trackball. | |
virtual void | update () |
Updates the description of this joystick (trackballs, hats, buttons, etc. | |
virtual OSDL::MVC::Controller & | getActualController () const |
Returns the actual (OSDL) controller this input device should be linked to. | |
Static Public Attributes | |
static const AxisPosition | DefaultDeadZoneExtent = 100 |
Protected Member Functions | |
virtual void | axisChanged (const JoystickAxisEvent &joystickEvent) |
Called whenever an axis of this joystick changed, and notify the linked controller, if any. | |
virtual void | buttonPressed (const JoystickButtonEvent &joystickEvent) |
Called whenever a button of this joystick was pressed, and notify the linked controller, if any. | |
virtual void | buttonReleased (const JoystickButtonEvent &joystickEvent) |
Called whenever a button of this joystick was released, and notify the linked controller, if any. | |
virtual JoystickNumber | getIndex () const |
Returns the index of this joystick in the platform list. | |
virtual void | trackballChanged (const JoystickTrackballEvent &joystickEvent) |
Called whenever a trackball of this joystick changed, and notifies the linked controller, if any. | |
virtual void | hatChanged (const JoystickHatEvent &joystickEvent) |
Called whenever a hat of this joystick changed, and notifies the linked controller, if any. | |
Protected Attributes | |
AxisPosition | _deadZoneExtentFirstAxis |
Stores the dead zone extent for first axis. | |
AxisPosition | _deadZoneExtentSecondAxis |
Stores the dead zone extent for first axis. | |
std::string | _name |
The implementation dependent name of this joystick, if any. | |
JoystickNumber | _index |
The number of this joystick in platform list. | |
LowLevelJoystick * | _internalJoystick |
The internal raw joystick being used. | |
JoystickAxesCount | _axisCount |
The number of axes for this joystick. | |
JoystickTrackballsCount | _trackballCount |
The number of trackballs for this joystick. | |
JoystickHatsCount | _hatCount |
The number of hats for this joystick. | |
JoystickButtonsCount | _buttonCount |
The number of buttons for this joystick. | |
Private Member Functions | |
ClassicalJoystick (const Joystick &source) | |
Copy constructor made private to ensure that it will never be called. | |
ClassicalJoystick & | operator= (const Joystick &source) |
Assignment operator made private to ensure that it will never be called. | |
Friends | |
class | OSDL::Events::JoystickHandler |
Models a classical joystick, with simplified access to the two main axes, commonly used to indicate the joystick current direction, with customizable deadzone support and two buttons directly managed.
This simplifies the task of the any controller being linked to this joystick.
Definition at line 68 of file OSDLClassicalJoystick.h.
ClassicalJoystick::ClassicalJoystick | ( | JoystickNumber | index, | |
AxisPosition | deadZoneExtent = DefaultDeadZoneExtent | |||
) | [explicit] |
Constructs a new joystick handler.
index | the index of this joystick in platform list. | |
deadZoneExtent | the extent of the joystick dead zone. |
JoystickException | if the operation failed or is not supported. |
Definition at line 87 of file OSDLClassicalJoystick.cc.
ClassicalJoystick::~ClassicalJoystick | ( | ) | throw () [virtual] |
Virtual destructor, closing corresponding joystick device.
Definition at line 105 of file OSDLClassicalJoystick.cc.
OSDL::Events::ClassicalJoystick::ClassicalJoystick | ( | const Joystick & | 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 ClassicalJoystick::axisChanged | ( | const JoystickAxisEvent & | joystickEvent | ) | [protected, virtual] |
Called whenever an axis of this joystick changed, and notify the linked controller, if any.
joystickEvent | the corresponding joystick event. |
Reimplemented from OSDL::Events::Joystick.
Definition at line 153 of file OSDLClassicalJoystick.cc.
References _deadZoneExtentFirstAxis, _deadZoneExtentSecondAxis, OSDL::Events::EventsModule::DescribeEvent(), OSDL::Events::InputDevice::getActualController(), OSDL::MVC::Controller::joystickDown(), OSDL::MVC::Controller::joystickLeft(), OSDL::MVC::Controller::joystickRight(), OSDL::MVC::Controller::joystickUp(), and OSDL_JOYSTICK_LOG.
void ClassicalJoystick::buttonPressed | ( | const JoystickButtonEvent & | joystickEvent | ) | [protected, virtual] |
Called whenever a button of this joystick was pressed, and notify the linked controller, if any.
joystickEvent | the corresponding joystick event. |
Reimplemented from OSDL::Events::Joystick.
Definition at line 209 of file OSDLClassicalJoystick.cc.
References OSDL::Events::EventsModule::DescribeEvent(), OSDL::Events::InputDevice::getActualController(), OSDL::MVC::Controller::joystickFirstButtonPressed(), OSDL::MVC::Controller::joystickSecondButtonPressed(), and OSDL_JOYSTICK_LOG.
void ClassicalJoystick::buttonReleased | ( | const JoystickButtonEvent & | joystickEvent | ) | [protected, virtual] |
Called whenever a button of this joystick was released, and notify the linked controller, if any.
joystickEvent | the corresponding joystick event. |
Reimplemented from OSDL::Events::Joystick.
Definition at line 254 of file OSDLClassicalJoystick.cc.
References OSDL::Events::EventsModule::DescribeEvent(), OSDL::Events::InputDevice::getActualController(), OSDL::MVC::Controller::joystickFirstButtonReleased(), OSDL::MVC::Controller::joystickSecondButtonReleased(), and OSDL_JOYSTICK_LOG.
void Joystick::close | ( | ) | [virtual, inherited] |
Closes the joystick.
JoystickException | if the joystick was not open. |
Definition at line 190 of file OSDLJoystick.cc.
References OSDL::Events::Joystick::_internalJoystick, and OSDL::Events::Joystick::isOpen().
Referenced by OSDL::Events::Joystick::~Joystick().
AxisPosition Joystick::getAbscissaPosition | ( | ) | const [virtual, inherited] |
Returns the absolute position of the X axis.
Definition at line 350 of file OSDLJoystick.cc.
References OSDL::Events::Joystick::_axisCount, OSDL::Events::Joystick::_internalJoystick, and OSDL::Events::Joystick::isOpen().
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(), axisChanged(), OSDL::Events::Mouse::buttonPressed(), OSDL::Events::Joystick::buttonPressed(), buttonPressed(), OSDL::Events::Mouse::buttonReleased(), OSDL::Events::Joystick::buttonReleased(), buttonReleased(), OSDL::Events::Mouse::focusGained(), OSDL::Events::Mouse::focusLost(), OSDL::Events::Joystick::hatChanged(), OSDL::Events::Mouse::mouseMoved(), and OSDL::Events::Joystick::trackballChanged().
void ClassicalJoystick::getDeadZoneValues | ( | AxisPosition & | firstAxisExtent, | |
AxisPosition & | secondAxisExtent | |||
) | const [virtual] |
Returns the deadzone extent for the two first axes.
firstAxisExtent | will be set to the extent for the first axis. | |
secondAxisExtent | will be set to the extent for the second axis. |
Definition at line 112 of file OSDLClassicalJoystick.cc.
References _deadZoneExtentFirstAxis, and _deadZoneExtentSecondAxis.
JoystickNumber Joystick::getIndex | ( | ) | const [protected, virtual, inherited] |
Returns the index of this joystick in the platform list.
Definition at line 509 of file OSDLJoystick.cc.
References OSDL::Events::Joystick::_index, OSDL::Events::Joystick::_internalJoystick, and OSDL::Video::Pixels::toString().
const string & Joystick::getName | ( | ) | const [virtual, inherited] |
Returns the implementation dependent name of this joystick.
Definition at line 134 of file OSDLJoystick.cc.
References OSDL::Events::Joystick::_name.
JoystickAxesCount Joystick::getNumberOfAxes | ( | ) | const [virtual, inherited] |
Returns the number of joystick axes.
Definition at line 290 of file OSDLJoystick.cc.
References OSDL::Events::Joystick::_axisCount, and OSDL::Events::Joystick::isOpen().
JoystickButtonsCount Joystick::getNumberOfButtons | ( | ) | const [virtual, inherited] |
Returns the number of joystick buttons.
Definition at line 335 of file OSDLJoystick.cc.
References OSDL::Events::Joystick::_buttonCount, and OSDL::Events::Joystick::isOpen().
JoystickHatsCount Joystick::getNumberOfHats | ( | ) | const [virtual, inherited] |
Returns the number of joystick hats.
Definition at line 320 of file OSDLJoystick.cc.
References OSDL::Events::Joystick::_hatCount, and OSDL::Events::Joystick::isOpen().
JoystickTrackballsCount Joystick::getNumberOfTrackballs | ( | ) | const [virtual, inherited] |
Returns the number of joystick trackballs.
Definition at line 305 of file OSDLJoystick.cc.
References OSDL::Events::Joystick::_trackballCount, and OSDL::Events::Joystick::isOpen().
AxisPosition Joystick::getOrdinatePosition | ( | ) | const [virtual, inherited] |
Returns the absolute position of the Y axis.
Definition at line 378 of file OSDLJoystick.cc.
References OSDL::Events::Joystick::_axisCount, OSDL::Events::Joystick::_internalJoystick, and OSDL::Events::Joystick::isOpen().
AxisPosition Joystick::getPositionOfAxis | ( | JoystickAxesCount | index | ) | const [virtual, inherited] |
Returns the absolute position of the specified axis.
index | the index of the axis for this joystick. |
JoystickException | if the joystick is not already opened or if index is out of bounds. |
Definition at line 406 of file OSDLJoystick.cc.
References OSDL::Events::Joystick::_axisCount, OSDL::Events::Joystick::_internalJoystick, OSDL::Events::Joystick::isOpen(), and OSDL::Video::Pixels::toString().
HatPosition Joystick::getPositionOfHat | ( | JoystickHatsCount | index | ) | const [virtual, inherited] |
Returns the absolute position of the specified hat.
index | the index of the hat for this joystick. |
JoystickException | if the joystick is not already open or if index is out of bounds. |
Definition at line 431 of file OSDLJoystick.cc.
References OSDL::Events::Joystick::_hatCount, OSDL::Events::Joystick::_internalJoystick, OSDL::Events::Joystick::isOpen(), and OSDL::Video::Pixels::toString().
bool Joystick::getPositionOfTrackball | ( | JoystickTrackballsCount | ball, | |
BallMotion & | deltaX, | |||
BallMotion & | deltaY | |||
) | const [virtual, inherited] |
Returns the relative position of the specified trackball.
ball | the number of the ball for this joystick. | |
deltaX | the abscissa motion delta, since last call to this method, will be stored here. | |
deltaY | the ordinate motion delta, since last call to this method, will be stored here. |
JoystickException | if the joystick is not already open or if index is out of bounds. |
Definition at line 481 of file OSDLJoystick.cc.
References OSDL::Events::Joystick::_internalJoystick, OSDL::Events::Joystick::_trackballCount, OSDL::Events::Joystick::isOpen(), and OSDL::Video::Pixels::toString().
void Joystick::hatChanged | ( | const JoystickHatEvent & | joystickEvent | ) | [protected, virtual, inherited] |
Called whenever a hat of this joystick changed, and notifies the linked controller, if any.
joystickEvent | the corresponding joystick event. |
Definition at line 242 of file OSDLJoystick.cc.
References OSDL::Events::EventsModule::DescribeEvent(), OSDL::Events::InputDevice::getActualController(), OSDL::MVC::Controller::joystickHatChanged(), and OSDL_JOYSTICK_LOG.
Referenced by OSDL::Events::JoystickHandler::hatChanged().
bool Joystick::isButtonPressed | ( | JoystickButtonsCount | buttonNumber | ) | const [virtual, inherited] |
Tells whether specified joystick button is pressed.
buttonNumber | the number of the button for this joystick. |
JoystickException | if the joystick is not already open or if the button number is out of bounds. |
Definition at line 456 of file OSDLJoystick.cc.
References OSDL::Events::Joystick::_buttonCount, OSDL::Events::Joystick::_internalJoystick, OSDL::Events::Joystick::isOpen(), and OSDL::Video::Pixels::toString().
bool Joystick::isOpen | ( | ) | const [virtual, inherited] |
Tells whether this joystick is currently opened.
Definition at line 143 of file OSDLJoystick.cc.
References OSDL::Events::Joystick::_index, OSDL::Events::Joystick::_internalJoystick, OSDL::Events::Joystick::toString(), and OSDL::Video::Pixels::toString().
Referenced by OSDL::Events::Joystick::close(), OSDL::Events::Joystick::getAbscissaPosition(), OSDL::Events::Joystick::getNumberOfAxes(), OSDL::Events::Joystick::getNumberOfButtons(), OSDL::Events::Joystick::getNumberOfHats(), OSDL::Events::Joystick::getNumberOfTrackballs(), OSDL::Events::Joystick::getOrdinatePosition(), OSDL::Events::Joystick::getPositionOfAxis(), OSDL::Events::Joystick::getPositionOfHat(), OSDL::Events::Joystick::getPositionOfTrackball(), OSDL::Events::Joystick::isButtonPressed(), OSDL::Events::Joystick::open(), OSDL::Events::Joystick::toString(), and OSDL::Events::Joystick::~Joystick().
void Joystick::open | ( | ) | [virtual, inherited] |
Opens the joystick, so that it can be used.
JoystickException | if the joystick was already open. |
Definition at line 171 of file OSDLJoystick.cc.
References OSDL::Events::Joystick::_index, OSDL::Events::Joystick::_internalJoystick, OSDL::Events::Joystick::isOpen(), and OSDL::Events::Joystick::update().
Referenced by OSDL::Events::JoystickHandler::openJoystick().
ClassicalJoystick& OSDL::Events::ClassicalJoystick::operator= | ( | const Joystick & | source | ) | [private] |
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.
Reimplemented from OSDL::Events::Joystick.
void ClassicalJoystick::setDeadZoneValues | ( | AxisPosition | firstAxisExtent = DefaultDeadZoneExtent , |
|
AxisPosition | secondAxisExtent = DefaultDeadZoneExtent | |||
) | [virtual] |
Sets the deadzone values for the two first axes.
firstAxisExtent | the extent of the deadzone for the first axis. | |
secondAxisExtent | the extent of the deadzone for the second axis. |
Definition at line 123 of file OSDLClassicalJoystick.cc.
References _deadZoneExtentFirstAxis, and _deadZoneExtentSecondAxis.
const string ClassicalJoystick::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::Joystick.
Definition at line 134 of file OSDLClassicalJoystick.cc.
References _deadZoneExtentFirstAxis, and _deadZoneExtentSecondAxis.
void Joystick::trackballChanged | ( | const JoystickTrackballEvent & | joystickEvent | ) | [protected, virtual, inherited] |
Called whenever a trackball of this joystick changed, and notifies the linked controller, if any.
joystickEvent | the corresponding joystick event. |
Definition at line 226 of file OSDLJoystick.cc.
References OSDL::Events::EventsModule::DescribeEvent(), OSDL::Events::InputDevice::getActualController(), OSDL::MVC::Controller::joystickTrackballChanged(), and OSDL_JOYSTICK_LOG.
Referenced by OSDL::Events::JoystickHandler::trackballChanged().
void Joystick::update | ( | ) | [virtual, inherited] |
Updates the description of this joystick (trackballs, hats, buttons, etc.
)
Definition at line 543 of file OSDLJoystick.cc.
References OSDL::Events::Joystick::_axisCount, OSDL::Events::Joystick::_buttonCount, OSDL::Events::Joystick::_hatCount, OSDL::Events::Joystick::_internalJoystick, and OSDL::Events::Joystick::_trackballCount.
Referenced by OSDL::Events::Joystick::open().
friend class OSDL::Events::JoystickHandler [friend] |
Reimplemented from OSDL::Events::Joystick.
Definition at line 77 of file OSDLClassicalJoystick.h.
JoystickAxesCount OSDL::Events::Joystick::_axisCount [protected, inherited] |
The number of axes for this joystick.
Definition at line 455 of file OSDLJoystick.h.
Referenced by OSDL::Events::Joystick::getAbscissaPosition(), OSDL::Events::Joystick::getNumberOfAxes(), OSDL::Events::Joystick::getOrdinatePosition(), OSDL::Events::Joystick::getPositionOfAxis(), OSDL::Events::Joystick::toString(), and OSDL::Events::Joystick::update().
JoystickButtonsCount OSDL::Events::Joystick::_buttonCount [protected, inherited] |
The number of buttons for this joystick.
Definition at line 470 of file OSDLJoystick.h.
Referenced by OSDL::Events::Joystick::getNumberOfButtons(), OSDL::Events::Joystick::isButtonPressed(), OSDL::Events::Joystick::toString(), and OSDL::Events::Joystick::update().
Stores the dead zone extent for first axis.
If d is the dead zone value, then a reported joystick axis value in:
Definition at line 227 of file OSDLClassicalJoystick.h.
Referenced by axisChanged(), getDeadZoneValues(), setDeadZoneValues(), and toString().
Stores the dead zone extent for first axis.
If d is the dead zone value, then a reported joystick axis value in:
Definition at line 242 of file OSDLClassicalJoystick.h.
Referenced by axisChanged(), getDeadZoneValues(), setDeadZoneValues(), and toString().
JoystickHatsCount OSDL::Events::Joystick::_hatCount [protected, inherited] |
The number of hats for this joystick.
Definition at line 465 of file OSDLJoystick.h.
Referenced by OSDL::Events::Joystick::getNumberOfHats(), OSDL::Events::Joystick::getPositionOfHat(), OSDL::Events::Joystick::toString(), and OSDL::Events::Joystick::update().
JoystickNumber OSDL::Events::Joystick::_index [protected, inherited] |
The number of this joystick in platform list.
Definition at line 445 of file OSDLJoystick.h.
Referenced by OSDL::Events::Joystick::getIndex(), OSDL::Events::Joystick::isOpen(), OSDL::Events::Joystick::open(), and OSDL::Events::Joystick::toString().
LowLevelJoystick* OSDL::Events::Joystick::_internalJoystick [protected, inherited] |
The internal raw joystick being used.
Definition at line 450 of file OSDLJoystick.h.
Referenced by OSDL::Events::Joystick::close(), OSDL::Events::Joystick::getAbscissaPosition(), OSDL::Events::Joystick::getIndex(), OSDL::Events::Joystick::getOrdinatePosition(), OSDL::Events::Joystick::getPositionOfAxis(), OSDL::Events::Joystick::getPositionOfHat(), OSDL::Events::Joystick::getPositionOfTrackball(), OSDL::Events::Joystick::isButtonPressed(), OSDL::Events::Joystick::isOpen(), OSDL::Events::Joystick::open(), and OSDL::Events::Joystick::update().
std::string OSDL::Events::Joystick::_name [protected, inherited] |
The implementation dependent name of this joystick, if any.
Definition at line 440 of file OSDLJoystick.h.
Referenced by OSDL::Events::Joystick::getName(), OSDL::Events::Joystick::Joystick(), and OSDL::Events::Joystick::toString().
JoystickTrackballsCount OSDL::Events::Joystick::_trackballCount [protected, inherited] |
The number of trackballs for this joystick.
Definition at line 460 of file OSDLJoystick.h.
Referenced by OSDL::Events::Joystick::getNumberOfTrackballs(), OSDL::Events::Joystick::getPositionOfTrackball(), OSDL::Events::Joystick::toString(), and OSDL::Events::Joystick::update().
const AxisPosition ClassicalJoystick::DefaultDeadZoneExtent = 100 [static] |
Definition at line 156 of file OSDLClassicalJoystick.h.