#include <OSDLJoystick.h>
Inheritance diagram for OSDL::Events::Joystick:
Usually, joystick directions should be interpreted this way :
All events for this joystick 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, ClassicalJoystick child class should be more convenient, since it is a higher-level (but a little less general-purpose) model.
Definition at line 50 of file OSDLJoystick.h.
Public Member Functions | |
Joystick (JoystickNumber index) throw () | |
Constructs a new joystick manager. | |
virtual | ~Joystick () throw () |
Virtual destructor, closing corresponding joystick device. | |
virtual const std::string & | getName () const throw () |
Returns the implementation dependent name of this joystick. | |
virtual bool | isOpen () const throw () |
Tells whether this joystick is currently opened. | |
virtual void | open () throw ( JoystickException ) |
Opens the joystick, so that it can be used. | |
virtual void | close () throw ( JoystickException ) |
Closes the joystick. | |
virtual JoystickAxesCount | getNumberOfAxes () const throw () |
Returns the number of joystick axes. | |
virtual JoystickTrackballsCount | getNumberOfTrackballs () const throw () |
Returns the number of joystick trackballs. | |
virtual JoystickHatsCount | getNumberOfHats () const throw () |
Returns the number of joystick hats. | |
virtual JoystickButtonsCount | getNumberOfButtons () const throw () |
Returns the number of joystick buttons. | |
virtual AxisPosition | getAbscissaPosition () const throw () |
Returns the absolute position of the X axis. | |
virtual AxisPosition | getOrdinatePosition () const throw () |
Returns the absolute position of the Y axis. | |
virtual AxisPosition | getPositionOfAxis (JoystickAxesCount index) const throw ( JoystickException ) |
Returns the absolute position of the specified axis. | |
virtual HatPosition | getPositionOfHat (JoystickHatsCount index) const throw ( JoystickException ) |
Returns the absolute position of the specified hat. | |
virtual bool | isButtonPressed (JoystickButtonsCount buttonNumber) const throw ( JoystickException ) |
Tells whether specified joystick button is pressed. | |
virtual bool | getPositionOfTrackball (JoystickTrackballsCount ball, BallMotion &deltaX, BallMotion &deltaY) const throw ( JoystickException ) |
Returns the relative position of the specified trackball. | |
virtual void | update () throw () |
Updates the description of this joystick (trackballs, hats, buttons, etc. | |
virtual const std::string | toString (Ceylan::VerbosityLevels level=Ceylan::high) const throw () |
Returns an user-friendly description of the state of this object. | |
virtual OSDL::MVC::Controller & | getActualController () const throw ( EventsException ) |
Returns the actual (OSDL) controller this input device should be linked to. | |
Protected Member Functions | |
virtual JoystickNumber | getIndex () const throw () |
Returns the index of this joystick in the platform list. | |
virtual void | axisChanged (const JoystickAxisEvent &joystickEvent) throw () |
Called whenever an axis of this joystick changed, and notifies the linked controller, if any. | |
virtual void | trackballChanged (const JoystickTrackballEvent &joystickEvent) throw () |
Called whenever a trackball of this joystick changed, and notifies the linked controller, if any. | |
virtual void | hatChanged (const JoystickHatEvent &joystickEvent) throw () |
Called whenever a hat of this joystick changed, and notifies the linked controller, if any. | |
virtual void | buttonPressed (const JoystickButtonEvent &joystickEvent) throw () |
Called whenever a button of this joystick was pressed, and notifies the linked controller, if any. | |
virtual void | buttonReleased (const JoystickButtonEvent &joystickEvent) throw () |
Called whenever a button of this joystick was released, and notifies the linked controller, if any. | |
Protected Attributes | |
std::string | _name |
The implementation dependent name of this joystick, if any. | |
JoystickNumber | _index |
The number of this joystick in platform list. | |
RawJoystick * | _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 | |
Joystick (const Joystick &source) throw () | |
Copy constructor made private to ensure that it will never be called. | |
Joystick & | operator= (const Joystick &source) throw () |
Assignment operator made private to ensure that it will never be called. | |
Friends | |
class | OSDL::Events::JoystickHandler |
Joystick::Joystick | ( | JoystickNumber | index | ) | throw () [explicit] |
Constructs a new joystick manager.
index | the index of this joystick in platform list. |
Definition at line 44 of file OSDLJoystick.cc.
Joystick::~Joystick | ( | ) | throw () [virtual] |
Virtual destructor, closing corresponding joystick device.
Definition at line 61 of file OSDLJoystick.cc.
OSDL::Events::Joystick::Joystick | ( | const Joystick & | source | ) | throw () [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.
const string & Joystick::getName | ( | ) | const throw () [virtual] |
Returns the implementation dependent name of this joystick.
Definition at line 78 of file OSDLJoystick.cc.
References _name.
bool Joystick::isOpen | ( | ) | const throw () [virtual] |
Tells whether this joystick is currently opened.
Definition at line 84 of file OSDLJoystick.cc.
References _index, _internalJoystick, and OSDL::Video::Pixels::toString().
Referenced by close(), getAbscissaPosition(), getNumberOfAxes(), getNumberOfButtons(), getNumberOfHats(), getNumberOfTrackballs(), getOrdinatePosition(), open(), and ~Joystick().
void Joystick::open | ( | ) | throw ( JoystickException ) [virtual] |
Opens the joystick, so that it can be used.
JoystickException | if the joystick was already open. |
Definition at line 103 of file OSDLJoystick.cc.
References _index, _internalJoystick, isOpen(), and update().
void Joystick::close | ( | ) | throw ( JoystickException ) [virtual] |
Closes the joystick.
JoystickException | if the joystick was not open. |
Definition at line 117 of file OSDLJoystick.cc.
References _internalJoystick, and isOpen().
Referenced by ~Joystick().
JoystickAxesCount Joystick::getNumberOfAxes | ( | ) | const throw () [virtual] |
Returns the number of joystick axes.
Definition at line 210 of file OSDLJoystick.cc.
References _axisCount, and isOpen().
JoystickTrackballsCount Joystick::getNumberOfTrackballs | ( | ) | const throw () [virtual] |
Returns the number of joystick trackballs.
Definition at line 224 of file OSDLJoystick.cc.
References _trackballCount, and isOpen().
JoystickHatsCount Joystick::getNumberOfHats | ( | ) | const throw () [virtual] |
Returns the number of joystick hats.
Definition at line 238 of file OSDLJoystick.cc.
JoystickButtonsCount Joystick::getNumberOfButtons | ( | ) | const throw () [virtual] |
Returns the number of joystick buttons.
Definition at line 252 of file OSDLJoystick.cc.
References _buttonCount, and isOpen().
AxisPosition Joystick::getAbscissaPosition | ( | ) | const throw () [virtual] |
Returns the absolute position of the X axis.
Joystick must be already open.
Definition at line 266 of file OSDLJoystick.cc.
References _axisCount, _internalJoystick, and isOpen().
AxisPosition Joystick::getOrdinatePosition | ( | ) | const throw () [virtual] |
Returns the absolute position of the Y axis.
Joystick must be already open.
Definition at line 285 of file OSDLJoystick.cc.
References _axisCount, _internalJoystick, and isOpen().
AxisPosition Joystick::getPositionOfAxis | ( | JoystickAxesCount | index | ) | const throw ( JoystickException ) [virtual] |
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 304 of file OSDLJoystick.cc.
References OSDL::Video::Pixels::toString().
HatPosition Joystick::getPositionOfHat | ( | JoystickHatsCount | index | ) | const throw ( JoystickException ) [virtual] |
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 321 of file OSDLJoystick.cc.
References OSDL::Video::Pixels::toString().
bool Joystick::isButtonPressed | ( | JoystickButtonsCount | buttonNumber | ) | const throw ( JoystickException ) [virtual] |
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 338 of file OSDLJoystick.cc.
References OSDL::Video::Pixels::toString().
bool Joystick::getPositionOfTrackball | ( | JoystickTrackballsCount | ball, | |
BallMotion & | deltaX, | |||
BallMotion & | deltaY | |||
) | const throw ( JoystickException ) [virtual] |
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 355 of file OSDLJoystick.cc.
References OSDL::Video::Pixels::toString().
void Joystick::update | ( | ) | throw () [virtual] |
Updates the description of this joystick (trackballs, hats, buttons, etc.
)
Definition at line 399 of file OSDLJoystick.cc.
References _axisCount, _buttonCount, _hatCount, _internalJoystick, and _trackballCount.
Referenced by open().
const string Joystick::toString | ( | Ceylan::VerbosityLevels | level = Ceylan::high |
) | const throw () [virtual] |
Returns an user-friendly description of the state of this object.
level | the requested verbosity level. |
Reimplemented from OSDL::Events::InputDevice.
Reimplemented in OSDL::Events::ClassicalJoystick.
Definition at line 410 of file OSDLJoystick.cc.
References OSDL::Video::Pixels::toString().
JoystickNumber Joystick::getIndex | ( | ) | const throw () [protected, virtual] |
Returns the index of this joystick in the platform list.
Definition at line 374 of file OSDLJoystick.cc.
References _index, _internalJoystick, and OSDL::Video::Pixels::toString().
void Joystick::axisChanged | ( | const JoystickAxisEvent & | joystickEvent | ) | throw () [protected, virtual] |
Called whenever an axis of this joystick changed, and notifies the linked controller, if any.
joystickEvent | the corresponding joystick event. |
Reimplemented in OSDL::Events::ClassicalJoystick.
Definition at line 132 of file OSDLJoystick.cc.
References OSDL::Events::EventsModule::DescribeEvent(), and OSDL_JOYSTICK_LOG.
void Joystick::trackballChanged | ( | const JoystickTrackballEvent & | joystickEvent | ) | throw () [protected, virtual] |
Called whenever a trackball of this joystick changed, and notifies the linked controller, if any.
joystickEvent | the corresponding joystick event. |
Definition at line 147 of file OSDLJoystick.cc.
References OSDL::Events::EventsModule::DescribeEvent(), and OSDL_JOYSTICK_LOG.
void Joystick::hatChanged | ( | const JoystickHatEvent & | joystickEvent | ) | throw () [protected, virtual] |
Called whenever a hat of this joystick changed, and notifies the linked controller, if any.
joystickEvent | the corresponding joystick event. |
Definition at line 163 of file OSDLJoystick.cc.
References OSDL::Events::EventsModule::DescribeEvent(), and OSDL_JOYSTICK_LOG.
void Joystick::buttonPressed | ( | const JoystickButtonEvent & | joystickEvent | ) | throw () [protected, virtual] |
Called whenever a button of this joystick was pressed, and notifies the linked controller, if any.
joystickEvent | the corresponding joystick event. |
Reimplemented in OSDL::Events::ClassicalJoystick.
Definition at line 178 of file OSDLJoystick.cc.
References OSDL::Events::EventsModule::DescribeEvent(), and OSDL_JOYSTICK_LOG.
void Joystick::buttonReleased | ( | const JoystickButtonEvent & | joystickEvent | ) | throw () [protected, virtual] |
Called whenever a button of this joystick was released, and notifies the linked controller, if any.
joystickEvent | the corresponding joystick event. |
Reimplemented in OSDL::Events::ClassicalJoystick.
Definition at line 194 of file OSDLJoystick.cc.
References OSDL::Events::EventsModule::DescribeEvent(), and OSDL_JOYSTICK_LOG.
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 in OSDL::Events::ClassicalJoystick.
OSDL::MVC::Controller & InputDevice::getActualController | ( | ) | const throw ( EventsException ) [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 33 of file OSDLInputDevice.cc.
friend class OSDL::Events::JoystickHandler [friend] |
std::string OSDL::Events::Joystick::_name [protected] |
The implementation dependent name of this joystick, if any.
Definition at line 370 of file OSDLJoystick.h.
Referenced by getName().
JoystickNumber OSDL::Events::Joystick::_index [protected] |
The number of this joystick in platform list.
Definition at line 374 of file OSDLJoystick.h.
Referenced by getIndex(), isOpen(), and open().
RawJoystick* OSDL::Events::Joystick::_internalJoystick [protected] |
The internal raw joystick being used.
Definition at line 378 of file OSDLJoystick.h.
Referenced by close(), getAbscissaPosition(), getIndex(), getOrdinatePosition(), isOpen(), open(), and update().
JoystickAxesCount OSDL::Events::Joystick::_axisCount [protected] |
The number of axes for this joystick.
Definition at line 382 of file OSDLJoystick.h.
Referenced by getAbscissaPosition(), getNumberOfAxes(), getOrdinatePosition(), and update().
The number of trackballs for this joystick.
Definition at line 386 of file OSDLJoystick.h.
Referenced by getNumberOfTrackballs(), and update().
JoystickHatsCount OSDL::Events::Joystick::_hatCount [protected] |
The number of hats for this joystick.
Definition at line 390 of file OSDLJoystick.h.
Referenced by getNumberOfHats(), and update().
The number of buttons for this joystick.
Definition at line 394 of file OSDLJoystick.h.
Referenced by getNumberOfButtons(), and update().