OSDL::Events::ClassicalJoystick Class Reference

#include <OSDLClassicalJoystick.h>

Inheritance diagram for OSDL::Events::ClassicalJoystick:

Inheritance graph
[legend]
Collaboration diagram for OSDL::Events::ClassicalJoystick:

Collaboration graph
[legend]

List of all members.


Detailed Description

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.

Note:
Only the two first axes have a deadzone managed, since they usually correspond to the actual stick. Further axes are often dedicated to throttle, which do not need any deadzone at all for most applications.

Controllers should be linked to at most one Classical joystick, since the joystick index is not propagated.

Definition at line 40 of file OSDLClassicalJoystick.h.


Public Member Functions

 ClassicalJoystick (JoystickNumber index, AxisPosition deadZoneExtent=DefaultDeadZoneExtent) throw ( JoystickException )
 Constructs a new joystick handler.
virtual ~ClassicalJoystick () throw ()
 Virtual destructor, closing corresponding joystick device.
virtual void getDeadZoneValues (AxisPosition &firstAxisExtent, AxisPosition &secondAxisExtent) const throw ()
 Returns the deadzone extent for the two first axes.
virtual void setDeadZoneValues (AxisPosition firstAxisExtent=DefaultDeadZoneExtent, AxisPosition secondAxisExtent=DefaultDeadZoneExtent) throw ()
 Sets the deadzone values for the two first axes.
virtual const std::string toString (Ceylan::VerbosityLevels level=Ceylan::high) const throw ()
 Returns an user-friendly description of the state of this object.
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 OSDL::MVC::ControllergetActualController () const throw ( EventsException )
 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) throw ()
 Called whenever an axis of this joystick changed, and notify the linked controller, if any.
virtual void buttonPressed (const JoystickButtonEvent &joystickEvent) throw ()
 Called whenever a button of this joystick was pressed, and notify the linked controller, if any.
virtual void buttonReleased (const JoystickButtonEvent &joystickEvent) throw ()
 Called whenever a button of this joystick was released, and notify the linked controller, if any.
virtual JoystickNumber getIndex () const throw ()
 Returns the index of this joystick in the platform list.
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.

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) throw ()
 Copy constructor made private to ensure that it will never be called.
ClassicalJoystickoperator= (const Joystick &source) throw ()
 Assignment operator made private to ensure that it will never be called.

Friends

class OSDL::Events::JoystickHandler

Constructor & Destructor Documentation

ClassicalJoystick::ClassicalJoystick ( JoystickNumber  index,
AxisPosition  deadZoneExtent = DefaultDeadZoneExtent 
) throw ( JoystickException ) [explicit]

Constructs a new joystick handler.

Parameters:
index the index of this joystick in platform list.
deadZoneExtent the extent of the joystick dead zone.
Exceptions:
JoystickException if the operation failed or is not supported.

Definition at line 57 of file OSDLClassicalJoystick.cc.

ClassicalJoystick::~ClassicalJoystick (  )  throw () [virtual]

Virtual destructor, closing corresponding joystick device.

Definition at line 75 of file OSDLClassicalJoystick.cc.

OSDL::Events::ClassicalJoystick::ClassicalJoystick ( 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.


Member Function Documentation

void ClassicalJoystick::getDeadZoneValues ( AxisPosition firstAxisExtent,
AxisPosition secondAxisExtent 
) const throw () [virtual]

Returns the deadzone extent for the two first axes.

Parameters:
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 81 of file OSDLClassicalJoystick.cc.

References _deadZoneExtentFirstAxis, and _deadZoneExtentSecondAxis.

void ClassicalJoystick::setDeadZoneValues ( AxisPosition  firstAxisExtent = DefaultDeadZoneExtent,
AxisPosition  secondAxisExtent = DefaultDeadZoneExtent 
) throw () [virtual]

Sets the deadzone values for the two first axes.

Parameters:
firstAxisExtent the extent of the deadzone for the first axis.
secondAxisExtent the extent of the deadzone for the second axis.

Definition at line 91 of file OSDLClassicalJoystick.cc.

References _deadZoneExtentFirstAxis, and _deadZoneExtentSecondAxis.

const string ClassicalJoystick::toString ( Ceylan::VerbosityLevels  level = Ceylan::high  )  const throw () [virtual]

Returns an user-friendly description of the state of this object.

Parameters:
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
Ceylan::TextDisplayable

Reimplemented from OSDL::Events::Joystick.

Definition at line 101 of file OSDLClassicalJoystick.cc.

References _deadZoneExtentFirstAxis, _deadZoneExtentSecondAxis, and OSDL::Video::Pixels::toString().

void ClassicalJoystick::axisChanged ( const JoystickAxisEvent joystickEvent  )  throw () [protected, virtual]

Called whenever an axis of this joystick changed, and notify the linked controller, if any.

Parameters:
joystickEvent the corresponding joystick event.
Note:
Expected to be triggered by the Joystick handler.

Reimplemented from OSDL::Events::Joystick.

Definition at line 119 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  )  throw () [protected, virtual]

Called whenever a button of this joystick was pressed, and notify the linked controller, if any.

Parameters:
joystickEvent the corresponding joystick event.
Note:
Expected to be triggered by the Joystick handler.

Reimplemented from OSDL::Events::Joystick.

Definition at line 176 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  )  throw () [protected, virtual]

Called whenever a button of this joystick was released, and notify the linked controller, if any.

Parameters:
joystickEvent the corresponding joystick event.
Note:
Expected to be triggered by the Joystick handler.

Reimplemented from OSDL::Events::Joystick.

Definition at line 221 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.

ClassicalJoystick& OSDL::Events::ClassicalJoystick::operator= ( const Joystick source  )  throw () [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.

const string & Joystick::getName (  )  const throw () [virtual, inherited]

Returns the implementation dependent name of this joystick.

Definition at line 103 of file OSDLJoystick.cc.

References OSDL::Events::Joystick::_name.

bool Joystick::isOpen (  )  const throw () [virtual, inherited]

void Joystick::open (  )  throw ( JoystickException ) [virtual, inherited]

Opens the joystick, so that it can be used.

Exceptions:
JoystickException if the joystick was already open.

Definition at line 138 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().

void Joystick::close (  )  throw ( JoystickException ) [virtual, inherited]

Closes the joystick.

Exceptions:
JoystickException if the joystick was not open.

Definition at line 156 of file OSDLJoystick.cc.

References OSDL::Events::Joystick::_internalJoystick, and OSDL::Events::Joystick::isOpen().

Referenced by OSDL::Events::Joystick::~Joystick().

JoystickAxesCount Joystick::getNumberOfAxes (  )  const throw () [virtual, inherited]

Returns the number of joystick axes.

Note:
The joystick must already have been opened.

Definition at line 254 of file OSDLJoystick.cc.

References OSDL::Events::Joystick::_axisCount, and OSDL::Events::Joystick::isOpen().

JoystickTrackballsCount Joystick::getNumberOfTrackballs (  )  const throw () [virtual, inherited]

Returns the number of joystick trackballs.

Note:
The joystick must already have been opened.

Definition at line 268 of file OSDLJoystick.cc.

References OSDL::Events::Joystick::_trackballCount, and OSDL::Events::Joystick::isOpen().

JoystickHatsCount Joystick::getNumberOfHats (  )  const throw () [virtual, inherited]

Returns the number of joystick hats.

Note:
The joystick must already have been opened.

Definition at line 282 of file OSDLJoystick.cc.

References OSDL::Events::Joystick::_hatCount, and OSDL::Events::Joystick::isOpen().

JoystickButtonsCount Joystick::getNumberOfButtons (  )  const throw () [virtual, inherited]

Returns the number of joystick buttons.

Note:
The joystick must already have been opened.

Definition at line 296 of file OSDLJoystick.cc.

References OSDL::Events::Joystick::_buttonCount, and OSDL::Events::Joystick::isOpen().

AxisPosition Joystick::getAbscissaPosition (  )  const throw () [virtual, inherited]

Returns the absolute position of the X axis.

Note:
On most modern joysticks the X axis is represented by axis 0, which is the axis that is used by this method.

Joystick must be already open.

Definition at line 310 of file OSDLJoystick.cc.

References OSDL::Events::Joystick::_axisCount, OSDL::Events::Joystick::_internalJoystick, and OSDL::Events::Joystick::isOpen().

AxisPosition Joystick::getOrdinatePosition (  )  const throw () [virtual, inherited]

Returns the absolute position of the Y axis.

Note:
On most modern joysticks the Y axis is represented by axis 1, which is the axis that is used by this method.

Joystick must be already open.

Definition at line 337 of file OSDLJoystick.cc.

References OSDL::Events::Joystick::_axisCount, OSDL::Events::Joystick::_internalJoystick, and OSDL::Events::Joystick::isOpen().

AxisPosition Joystick::getPositionOfAxis ( JoystickAxesCount  index  )  const throw ( JoystickException ) [virtual, inherited]

Returns the absolute position of the specified axis.

Parameters:
index the index of the axis for this joystick.
Returns:
the axis position.
Exceptions:
JoystickException if the joystick is not already opened or if index is out of bounds.

Definition at line 364 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 throw ( JoystickException ) [virtual, inherited]

Returns the absolute position of the specified hat.

Parameters:
index the index of the hat for this joystick.
Returns:
the hat position.
Exceptions:
JoystickException if the joystick is not already open or if index is out of bounds.

Definition at line 389 of file OSDLJoystick.cc.

References OSDL::Events::Joystick::_hatCount, OSDL::Events::Joystick::_internalJoystick, OSDL::Events::Joystick::isOpen(), and OSDL::Video::Pixels::toString().

bool Joystick::isButtonPressed ( JoystickButtonsCount  buttonNumber  )  const throw ( JoystickException ) [virtual, inherited]

Tells whether specified joystick button is pressed.

Parameters:
buttonNumber the number of the button for this joystick.
Returns:
true iff the button is currently pressed.
Exceptions:
JoystickException if the joystick is not already open or if the button number is out of bounds.

Definition at line 414 of file OSDLJoystick.cc.

References OSDL::Events::Joystick::_buttonCount, OSDL::Events::Joystick::_internalJoystick, OSDL::Events::Joystick::isOpen(), and OSDL::Video::Pixels::toString().

bool Joystick::getPositionOfTrackball ( JoystickTrackballsCount  ball,
BallMotion deltaX,
BallMotion deltaY 
) const throw ( JoystickException ) [virtual, inherited]

Returns the relative position of the specified trackball.

Parameters:
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.
Returns:
true iff the operation succeeded.
Exceptions:
JoystickException if the joystick is not already open or if index is out of bounds.
Note:
Trackballs can only return relative motion since the last call of this method.

Definition at line 439 of file OSDLJoystick.cc.

References OSDL::Events::Joystick::_internalJoystick, OSDL::Events::Joystick::_trackballCount, OSDL::Events::Joystick::isOpen(), and OSDL::Video::Pixels::toString().

void Joystick::update (  )  throw () [virtual, inherited]

Updates the description of this joystick (trackballs, hats, buttons, etc.

)

Note:
The joystick must be open.

Definition at line 499 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().

JoystickNumber Joystick::getIndex (  )  const throw () [protected, virtual, inherited]

Returns the index of this joystick in the platform list.

Note:
Should be useless.

Definition at line 466 of file OSDLJoystick.cc.

References OSDL::Events::Joystick::_index, OSDL::Events::Joystick::_internalJoystick, and OSDL::Video::Pixels::toString().

void Joystick::trackballChanged ( const JoystickTrackballEvent joystickEvent  )  throw () [protected, virtual, inherited]

Called whenever a trackball of this joystick changed, and notifies the linked controller, if any.

Parameters:
joystickEvent the corresponding joystick event.
Note:
Expected to be triggered by the Joystick handler.

Definition at line 191 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::hatChanged ( const JoystickHatEvent joystickEvent  )  throw () [protected, virtual, inherited]

Called whenever a hat of this joystick changed, and notifies the linked controller, if any.

Parameters:
joystickEvent the corresponding joystick event.
Note:
Expected to be triggered by the Joystick handler.

Definition at line 207 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().

OSDL::MVC::Controller & InputDevice::getActualController (  )  const throw ( EventsException ) [virtual, inherited]

Returns the actual (OSDL) controller this input device should be linked to.

Exceptions:
EventException if this input device is not linked to any controller, or if the controller is not an OSDL one.
See also:
isLinkedToController

Definition at line 33 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().


Friends And Related Function Documentation

friend class OSDL::Events::JoystickHandler [friend]

Reimplemented from OSDL::Events::Joystick.

Definition at line 49 of file OSDLClassicalJoystick.h.


Member Data Documentation

Definition at line 126 of file OSDLClassicalJoystick.h.

Stores the dead zone extent for first axis.

If d is the dead zone value, then a reported joystick axis value in:

  • ]32768; -d[ will notify the controller to the joystick is on the left
  • [-d;d] will not notify the controller of anything
  • ]d; 32767[ will notify the controller to the joystick is on the right

Definition at line 193 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:

  • ]32768; -d[ will notify the controller to the joystick is up
  • [-d;d] will not notify the controller of anything
  • ]d; 32767[ will notify the controller to the joystick is down

Definition at line 207 of file OSDLClassicalJoystick.h.

Referenced by axisChanged(), getDeadZoneValues(), setDeadZoneValues(), and toString().

std::string OSDL::Events::Joystick::_name [protected, inherited]

The implementation dependent name of this joystick, if any.

Definition at line 391 of file OSDLJoystick.h.

Referenced by OSDL::Events::Joystick::getName(), and OSDL::Events::Joystick::toString().

The number of this joystick in platform list.

Definition at line 395 of file OSDLJoystick.h.

Referenced by OSDL::Events::Joystick::getIndex(), OSDL::Events::Joystick::isOpen(), OSDL::Events::Joystick::open(), and OSDL::Events::Joystick::toString().


The documentation for this class was generated from the following files:

Generated on Fri Aug 1 14:46:16 2008 for OSDL by  doxygen 1.5.5