OSDL::Events::JoystickHandler Class Reference

Handler for all detected joysticks. More...

#include <OSDLJoystickHandler.h>

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

List of all members.

Public Member Functions

 JoystickHandler (bool useClassicalJoysticks=true)
 Constructs a new joystick handler.
virtual ~JoystickHandler () throw ()
 Virtual destructor.
virtual void update ()
 Auto-detects and registers any attached joystick.
virtual void openJoystick (JoystickNumber index)
 Opens joystick of specified index.
virtual void linkToController (JoystickNumber index, OSDL::MVC::Controller &controller)
 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
 Returns an user-friendly description of the state of this object.

Static Public Member Functions

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

Protected Member Functions

virtual void axisChanged (const JoystickAxisEvent &joystickEvent) const
 Called whenever a joystick axis changed, so that its controller, if any, is notified.
virtual void trackballChanged (const JoystickTrackballEvent &joystickEvent) const
 Called whenever a joystick trackball changed, so that its controller, if any, is notified.
virtual void hatChanged (const JoystickHatEvent &joystickEvent) const
 Called whenever a joystick hat changed, so that its controller, if any, is notified.
virtual void buttonPressed (const JoystickButtonEvent &joystickEvent) const
 Called whenever a joystick button was pressed, so that its controller, if any, is notified.
virtual void buttonReleased (const JoystickButtonEvent &joystickEvent) const
 Called whenever a joystick button was released, so that its controller, if any, is notified.
virtual void blank ()
 Blanks this joystick handler, i.e.
virtual void checkJoystickAt (JoystickNumber index) const
 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)
 Copy constructor made private to ensure that it will never be called.
JoystickHandleroperator= (const JoystickHandler &source)
 Assignment operator made private to ensure that it will never be called.

Friends

class OSDL::Events::EventsModule

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 82 of file OSDLJoystickHandler.h.


Constructor & Destructor Documentation

JoystickHandler::JoystickHandler ( bool  useClassicalJoysticks = true  )  [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 88 of file OSDLJoystickHandler.cc.

References OSDL::CommonModule::BackendSuccess, OSDL::Utils::getBackendLastError(), update(), and OSDL::CommonModule::UseVideo.

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

Virtual destructor.

Definition at line 125 of file OSDLJoystickHandler.cc.

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

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


Member Function Documentation

void JoystickHandler::axisChanged ( const JoystickAxisEvent joystickEvent  )  const [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 298 of file OSDLJoystickHandler.cc.

References _joysticks, OSDL::Events::Joystick::axisChanged(), and checkJoystickAt().

Referenced by OSDL::Events::EventsModule::onJoystickAxisChanged().

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

Blanks this joystick handler, i.e.

makes it forget all previously known joysticks.

Definition at line 387 of file OSDLJoystickHandler.cc.

References _joystickCount, and _joysticks.

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

void JoystickHandler::buttonPressed ( const JoystickButtonEvent joystickEvent  )  const [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 351 of file OSDLJoystickHandler.cc.

References _joysticks, OSDL::Events::Joystick::buttonPressed(), and checkJoystickAt().

Referenced by OSDL::Events::EventsModule::onJoystickButtonPressed().

void JoystickHandler::buttonReleased ( const JoystickButtonEvent joystickEvent  )  const [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 369 of file OSDLJoystickHandler.cc.

References _joysticks, OSDL::Events::Joystick::buttonReleased(), and checkJoystickAt().

Referenced by OSDL::Events::EventsModule::onJoystickButtonReleased().

void JoystickHandler::checkJoystickAt ( JoystickNumber  index  )  const [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 408 of file OSDLJoystickHandler.cc.

References _joystickCount, and _joysticks.

Referenced by axisChanged(), buttonPressed(), buttonReleased(), hatChanged(), and trackballChanged().

JoystickNumber JoystickHandler::GetAvailableJoystickCount (  )  [static]

Returns the number of available joysticks, i.e.

the joysticks currently attached to the system.

Definition at line 276 of file OSDLJoystickHandler.cc.

Referenced by linkToController(), openJoystick(), and update().

void JoystickHandler::hatChanged ( const JoystickHatEvent joystickEvent  )  const [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 334 of file OSDLJoystickHandler.cc.

References _joysticks, checkJoystickAt(), and OSDL::Events::Joystick::hatChanged().

Referenced by OSDL::Events::EventsModule::onJoystickHatChanged().

void JoystickHandler::linkToController ( JoystickNumber  index,
OSDL::MVC::Controller controller 
) [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 212 of file OSDLJoystickHandler.cc.

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

void JoystickHandler::openJoystick ( JoystickNumber  index  )  [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 179 of file OSDLJoystickHandler.cc.

References _joystickCount, _joysticks, GetAvailableJoystickCount(), OSDL::Events::Joystick::open(), and OSDL::Video::Pixels::toString().

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

const string JoystickHandler::toString ( Ceylan::VerbosityLevels  level = Ceylan::high  )  const [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 245 of file OSDLJoystickHandler.cc.

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

Referenced by OSDL::Events::EventsModule::toString().

void JoystickHandler::trackballChanged ( const JoystickTrackballEvent joystickEvent  )  const [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 316 of file OSDLJoystickHandler.cc.

References _joysticks, checkJoystickAt(), and OSDL::Events::Joystick::trackballChanged().

Referenced by OSDL::Events::EventsModule::onJoystickTrackballChanged().

void JoystickHandler::update (  )  [virtual]

Auto-detects and registers any attached joystick.

Note:
Recreates from scratch all joystick informations.

Definition at line 145 of file OSDLJoystickHandler.cc.

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

Referenced by JoystickHandler().


Friends And Related Function Documentation

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

Definition at line 91 of file OSDLJoystickHandler.h.


Member Data Documentation

Records how many joysticks are known by this handler.

Definition at line 302 of file OSDLJoystickHandler.h.

Referenced by blank(), checkJoystickAt(), linkToController(), openJoystick(), toString(), and update().

Records all known joysticks.

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

(read it as Joystick * _joysticks[])

Definition at line 315 of file OSDLJoystickHandler.h.

Referenced by axisChanged(), blank(), buttonPressed(), buttonReleased(), checkJoystickAt(), hatChanged(), linkToController(), openJoystick(), toString(), trackballChanged(), and update().

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

Definition at line 324 of file OSDLJoystickHandler.h.

Referenced by update().


The documentation for this class was generated from the following files:
Generated on Mon Nov 29 14:05:51 2010 for OSDL by  doxygen 1.6.3