OSDL::Events::JoystickHandler Class Reference

#include <OSDLJoystickHandler.h>

Inheritance diagram for OSDL::Events::JoystickHandler:

[legend]
Collaboration diagram for OSDL::Events::JoystickHandler:
[legend]
List of all members.

Detailed Description

Handler for all detected joysticks.

Joystick indexes range from 0 (included) to GetAvailableJoystickCount() (excluded).

Note:
The UseJoystick flag must be specified in the call to CommonModule::getCommonModule so that joystick support is enabled.

Definition at line 50 of file OSDLJoystickHandler.h.

Public Member Functions

 JoystickHandler (bool useClassicalJoysticks=true) throw ( InputDeviceHandlerException )
 Constructs a new joystick handler.
virtual ~JoystickHandler () throw ()
 Virtual destructor.
virtual void update () throw ()
 Auto-detects and registers any attached joystick.
virtual void openJoystick (JoystickNumber index) throw ( JoystickException )
 Opens joystick of specified index.
virtual void linkToController (JoystickNumber index, OSDL::MVC::Controller &controller) throw ( JoystickException )
 Links specified joystick to specified controller, so that any further joystick-related event will be sent to the controller.
virtual const std::string toString (Ceylan::VerbosityLevels level=Ceylan::high) const throw ()
 Returns an user-friendly description of the state of this object.

Static Public Member Functions

static JoystickNumber GetAvailableJoystickCount () throw ()
 Returns the number of available joysticks, i.e.

Protected Member Functions

virtual void axisChanged (const JoystickAxisEvent &joystickEvent) const throw ()
 Called whenever a joystick axis changed, so that its controller, if any, is notified.
virtual void trackballChanged (const JoystickTrackballEvent &joystickEvent) const throw ()
 Called whenever a joystick trackball changed, so that its controller, if any, is notified.
virtual void hatChanged (const JoystickHatEvent &joystickEvent) const throw ()
 Called whenever a joystick hat changed, so that its controller, if any, is notified.
virtual void buttonPressed (const JoystickButtonEvent &joystickEvent) const throw ()
 Called whenever a joystick button was pressed, so that its controller, if any, is notified.
virtual void buttonReleased (const JoystickButtonEvent &joystickEvent) const throw ()
 Called whenever a joystick button was released, so that its controller, if any, is notified.
virtual void blank () throw ()
 Blanks this joystick handler, i.e.
virtual void checkJoystickAt (JoystickNumber index) const throw ()
 Checks that the joystick at the specified index exists and is opened.

Protected Attributes

JoystickNumber _joystickCount
 Records how many joysticks are known by this handler.
Joystick ** _joysticks
 Records all known joysticks.
bool _useClassicalJoysticks
 Tells whether complex joysticks (if false) or classical joysticks (if true) should be created.

Private Member Functions

 JoystickHandler (const JoystickHandler &source) throw ()
 Copy constructor made private to ensure that it will never be called.
JoystickHandleroperator= (const JoystickHandler &source) throw ()
 Assignment operator made private to ensure that it will never be called.

Friends

class OSDL::Events::EventsModule


Constructor & Destructor Documentation

JoystickHandler::JoystickHandler ( bool  useClassicalJoysticks = true  )  throw ( InputDeviceHandlerException ) [explicit]

Constructs a new joystick handler.

Parameters:
useClassicalJoysticks tells whether detected joysticks should be managed as complex joysticks (powerful interface, but it requires the controller to take in charge this complexity) or classical joysticks (for usual needs, comes with preset behaviours which ease controller work).
Exceptions:
InputDeviceHandlerException if the initialization of the joystick subsystem failed.

Definition at line 46 of file OSDLJoystickHandler.cc.

References OSDL::Utils::getBackendLastError().

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

Virtual destructor.

Definition at line 74 of file OSDLJoystickHandler.cc.

References blank(), and OSDL::CommonModule::UseJoystick.

OSDL::Events::JoystickHandler::JoystickHandler ( const JoystickHandler 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 JoystickHandler::update (  )  throw () [virtual]

Auto-detects and registers any attached joystick.

Note:
Recreates from scratch all joystick informations.

Definition at line 90 of file OSDLJoystickHandler.cc.

References _joystickCount, _joysticks, _useClassicalJoysticks, blank(), GetAvailableJoystickCount(), and OSDL::Video::Pixels::toString().

void JoystickHandler::openJoystick ( JoystickNumber  index  )  throw ( JoystickException ) [virtual]

Opens joystick of specified index.

If joystick is already opened, does nothing.

Parameters:
index the index of the joystick to open.
Exceptions:
JoystickException if index is out of bounds.
See also:
GetAvailableJoystickCount

Definition at line 123 of file OSDLJoystickHandler.cc.

References OSDL::Video::Pixels::toString().

void JoystickHandler::linkToController ( JoystickNumber  index,
OSDL::MVC::Controller controller 
) throw ( JoystickException ) [virtual]

Links specified joystick to specified controller, so that any further joystick-related event will be sent to the controller.

Removes automatically any link previously defined between this joystick and any other controller.

Parameters:
index the index of the joystick that shall be linked to the controller.
controller the OSDL controller which will be notified of joystick changes.
Exceptions:
JoystickException if index is out of bounds.

Definition at line 156 of file OSDLJoystickHandler.cc.

References OSDL::Video::Pixels::toString().

const string JoystickHandler::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

Definition at line 188 of file OSDLJoystickHandler.cc.

References OSDL::Video::Pixels::toString().

JoystickNumber JoystickHandler::GetAvailableJoystickCount (  )  throw () [static]

Returns the number of available joysticks, i.e.

the joysticks currently attached to the system.

Definition at line 220 of file OSDLJoystickHandler.cc.

Referenced by update().

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

Called whenever a joystick axis changed, so that its controller, if any, is notified.

Note:
Expected to be triggered by the EventsModule.

Definition at line 232 of file OSDLJoystickHandler.cc.

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

Called whenever a joystick trackball changed, so that its controller, if any, is notified.

Note:
Expected to be triggered by the EventsModule.

Definition at line 245 of file OSDLJoystickHandler.cc.

void JoystickHandler::hatChanged ( const JoystickHatEvent joystickEvent  )  const throw () [protected, virtual]

Called whenever a joystick hat changed, so that its controller, if any, is notified.

Note:
Expected to be triggered by the EventsModule.

Definition at line 258 of file OSDLJoystickHandler.cc.

void JoystickHandler::buttonPressed ( const JoystickButtonEvent joystickEvent  )  const throw () [protected, virtual]

Called whenever a joystick button was pressed, so that its controller, if any, is notified.

Note:
Expected to be triggered by the EventsModule.

Definition at line 271 of file OSDLJoystickHandler.cc.

void JoystickHandler::buttonReleased ( const JoystickButtonEvent joystickEvent  )  const throw () [protected, virtual]

Called whenever a joystick button was released, so that its controller, if any, is notified.

Note:
Expected to be triggered by the EventsModule.

Definition at line 284 of file OSDLJoystickHandler.cc.

void JoystickHandler::blank (  )  throw () [protected, virtual]

Blanks this joystick handler, i.e.

makes it forget all previously known joysticks.

Definition at line 298 of file OSDLJoystickHandler.cc.

References _joystickCount, and _joysticks.

Referenced by update(), and ~JoystickHandler().

void JoystickHandler::checkJoystickAt ( JoystickNumber  index  )  const throw () [protected, virtual]

Checks that the joystick at the specified index exists and is opened.

Parameters:
index the index of the joystick to check.
Note:
Stop in emergency the application if the check failed.

Definition at line 318 of file OSDLJoystickHandler.cc.

JoystickHandler& OSDL::Events::JoystickHandler::operator= ( const JoystickHandler 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.


Friends And Related Function Documentation

friend class OSDL::Events::EventsModule [friend]

Definition at line 59 of file OSDLJoystickHandler.h.


Member Data Documentation

JoystickNumber OSDL::Events::JoystickHandler::_joystickCount [protected]

Records how many joysticks are known by this handler.

Definition at line 260 of file OSDLJoystickHandler.h.

Referenced by blank(), and update().

Joystick** OSDL::Events::JoystickHandler::_joysticks [protected]

Records all known joysticks.

A dynamic array is preferred to a list for performance reasons.

(read it as Joystick * _joysticks[])

Definition at line 272 of file OSDLJoystickHandler.h.

Referenced by blank(), and update().

bool OSDL::Events::JoystickHandler::_useClassicalJoysticks [protected]

Tells whether complex joysticks (if false) or classical joysticks (if true) should be created.

Definition at line 280 of file OSDLJoystickHandler.h.

Referenced by update().


The documentation for this class was generated from the following files:
Generated on Fri Mar 30 14:47:28 2007 for OSDL by  doxygen 1.5.1