#include <OSDLJoystickHandler.h>
Inheritance diagram for OSDL::Events::JoystickHandler:
Joystick indexes range from 0 (included) to GetAvailableJoystickCount() (excluded).
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. | |
JoystickHandler & | operator= (const JoystickHandler &source) throw () |
Assignment operator made private to ensure that it will never be called. | |
Friends | |
class | OSDL::Events::EventsModule |
JoystickHandler::JoystickHandler | ( | bool | useClassicalJoysticks = true |
) | throw ( InputDeviceHandlerException ) [explicit] |
Constructs a new joystick handler.
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). |
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.
void JoystickHandler::update | ( | ) | throw () [virtual] |
Auto-detects and registers any attached joystick.
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.
index | the index of the joystick to open. |
JoystickException | if index is out of bounds. |
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.
index | the index of the joystick that shall be linked to the controller. | |
controller | the OSDL controller which will be notified of joystick changes. |
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.
level | the requested verbosity level. |
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.
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.
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.
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.
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.
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.
index | the index of the joystick to check. |
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.
friend class OSDL::Events::EventsModule [friend] |
Definition at line 59 of file OSDLJoystickHandler.h.
Records how many joysticks are known by this handler.
Definition at line 260 of file OSDLJoystickHandler.h.
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.
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().