#include <OSDLController.h>
As these controllers have to be able to listen to various input devices, all specific method handlers (such as axisChanged) have to be defined. Their default implementation is basically a do-nothing method, only adding logs if in debug mode. This way, the controllers being instanciated in the application, which are child classes of these OSDL::Events::Controller, just have to override the handlers corresponding to the specific events they want to listen to : not defining an handler does not prevent from instanciating the controller.
These controllers must have a total control of the input devices they are linked to. This hinders abstracting events to simplify their management : for example, one cannot say that an increasing joystick axis value means in all cases the same as, say, the mouse being pushed forward or the right arrow key being pressed.
Therefore the controllers are tightly linked to the input devices, and they will be in charge of converting these low level input events into higher level object-specific events.
One of the consequences is that for event propagation an abstract Ceylan::Controller is not suitable : one cannot call such specific methods like axisChanged. That is the explanation too for the OSDL::Events::Controller::getActualController method.
Some basic abstraction efforts are done, though. For example, according to the keyboard mode (raw or text), the controller is notified differently for more versality.
Similarly, if a controller is linked with a classical joystick, the joystick actual direction will be reported thanks to the joystickLeft, joystickRight, joystickUp and joystickDown methods instead of the unspecialized axisChanged method. Same thing for joystick{First|Second}Button{Pressed|Released}.
However, most modelings of AI behaviours will have to fit into the controller interface. Basically, the AI of, say, a driver, should be uncoupled from the physics that apply to his car. In this case, the driver is only a particular controller for that car, and its only options may be for him to steer the wheel or press the gas pedal. Whatever is the cause of these actions, this is the task of the model to take them into account and update the object state accordingly.
AI-based controllers may inherit from active objects, so that they can be scheduled as well.
Definition at line 86 of file OSDLController.h.
Public Member Functions | |
Controller () throw () | |
Constructs a new controller. | |
Controller (Ceylan::Model &model) throw () | |
Constructs a controller that will send events to the specified model. | |
virtual | ~Controller () throw () |
Virtual destructor. | |
virtual void | keyboardFocusGained (const FocusEvent &keyboardFocusEvent) throw () |
Called whenever a keyboard linked to this controller has gained focus. | |
virtual void | keyboardFocusLost (const FocusEvent &keyboardFocusEvent) throw () |
Called whenever a keyboard linked to this controller has lost focus. | |
virtual void | rawKeyPressed (const KeyboardEvent &keyboardPressedEvent) throw () |
Called whenever a raw key linked to this controller has been pressed. | |
virtual void | rawKeyReleased (const KeyboardEvent &keyboardReleasedEvent) throw () |
Called whenever a raw key linked to this controller has been released. | |
virtual void | unicodeSelected (const KeyboardEvent &keyboardPressedEvent) throw () |
Called whenever a Unicode character linked to this controller has been selected. | |
virtual void | mouseFocusGained (const FocusEvent &mouseFocusEvent) throw () |
Called whenever a mouse linked to this controller has gained focus. | |
virtual void | mouseFocusLost (const FocusEvent &mouseFocusEvent) throw () |
Called whenever a mouse linked to this controller has lost focus. | |
virtual void | mouseMoved (const MouseMotionEvent &mouseMotionEvent) throw () |
Called whenever a mouse linked to this controller moved. | |
virtual void | mouseButtonPressed (const MouseButtonEvent &mouseButtonPressedEvent) throw () |
Called whenever a mouse linked to this controller had one of its buttons pressed. | |
virtual void | mouseButtonReleased (const MouseButtonEvent &mouseButtonReleasedEvent) throw () |
Called whenever a mouse linked to this controller had one of its buttons released. | |
virtual void | joystickAxisChanged (const JoystickAxisEvent &joystickAxisEvent) throw () |
Called whenever a joystick linked to this controller had one of its axes changed. | |
virtual void | joystickTrackballChanged (const JoystickTrackballEvent &joystickTrackballEvent) throw () |
Called whenever a joystick linked to this controller had one of its trackballs changed. | |
virtual void | joystickHatChanged (const JoystickHatEvent &joystickHatChangedEvent) throw () |
Called whenever a joystick linked to this controller had one of its hats changed. | |
virtual void | joystickButtonPressed (const JoystickButtonEvent &joystickButtonPressedEvent) throw () |
Called whenever a joystick linked to this controller had one of its buttons pressed. | |
virtual void | joystickButtonReleased (const JoystickButtonEvent &joystickButtonReleasedEvent) throw () |
Called whenever a joystick linked to this controller had one of its buttons changed. | |
virtual void | joystickLeft (Events::AxisPosition leftExtent) throw () |
Called whenever the classical joystick linked to this controller is pushed to the left. | |
virtual void | joystickRight (Events::AxisPosition rightExtent) throw () |
Called whenever the classical joystick linked to this controller is pushed to the right. | |
virtual void | joystickUp (Events::AxisPosition upExtent) throw () |
Called whenever the classical joystick linked to this controller is pushed up. | |
virtual void | joystickDown (Events::AxisPosition downExtent) throw () |
Called whenever the classical joystick linked to this controller is pushed down. | |
virtual void | joystickFirstButtonPressed () throw () |
Called whenever the first button of the classical joystick linked to this controller, if any, is pressed. | |
virtual void | joystickFirstButtonReleased () throw () |
Called whenever the first button of the classical joystick linked to this controller, if any, is released. | |
virtual void | joystickSecondButtonPressed () throw () |
Called whenever the second button of the classical joystick linked to this controller, if any, is pressed. | |
virtual void | joystickSecondButtonReleased () throw () |
Called whenever the second button of the classical joystick linked to this controller, if any, is released. | |
virtual const std::string | toString (Ceylan::VerbosityLevels level=Ceylan::high) const throw () |
Returns an user-friendly description of the state of this object. | |
Private Member Functions | |
Controller (const Controller &source) throw () | |
Copy constructor made private to ensure that it will never be called. | |
Controller & | operator= (const Controller &source) throw () |
Assignment operator made private to ensure that it will never be called. |
Controller::Controller | ( | ) | throw () |
Controller::Controller | ( | Ceylan::Model & | model | ) | throw () [explicit] |
Constructs a controller that will send events to the specified model.
Definition at line 41 of file OSDLController.cc.
Controller::~Controller | ( | ) | throw () [virtual] |
OSDL::MVC::Controller::Controller | ( | const Controller & | 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 Controller::keyboardFocusGained | ( | const FocusEvent & | keyboardFocusEvent | ) | throw () [virtual] |
Called whenever a keyboard linked to this controller has gained focus.
Definition at line 58 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
void Controller::keyboardFocusLost | ( | const FocusEvent & | keyboardFocusEvent | ) | throw () [virtual] |
Called whenever a keyboard linked to this controller has lost focus.
Definition at line 76 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
void Controller::rawKeyPressed | ( | const KeyboardEvent & | keyboardPressedEvent | ) | throw () [virtual] |
Called whenever a raw key linked to this controller has been pressed.
Definition at line 94 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
void Controller::rawKeyReleased | ( | const KeyboardEvent & | keyboardReleasedEvent | ) | throw () [virtual] |
Called whenever a raw key linked to this controller has been released.
Definition at line 112 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
void Controller::unicodeSelected | ( | const KeyboardEvent & | keyboardPressedEvent | ) | throw () [virtual] |
Called whenever a Unicode character linked to this controller has been selected.
Definition at line 130 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
void Controller::mouseFocusGained | ( | const FocusEvent & | mouseFocusEvent | ) | throw () [virtual] |
Called whenever a mouse linked to this controller has gained focus.
Definition at line 152 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
void Controller::mouseFocusLost | ( | const FocusEvent & | mouseFocusEvent | ) | throw () [virtual] |
Called whenever a mouse linked to this controller has lost focus.
Definition at line 169 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
void Controller::mouseMoved | ( | const MouseMotionEvent & | mouseMotionEvent | ) | throw () [virtual] |
Called whenever a mouse linked to this controller moved.
Definition at line 186 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
void Controller::mouseButtonPressed | ( | const MouseButtonEvent & | mouseButtonPressedEvent | ) | throw () [virtual] |
Called whenever a mouse linked to this controller had one of its buttons pressed.
Definition at line 204 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
void Controller::mouseButtonReleased | ( | const MouseButtonEvent & | mouseButtonReleasedEvent | ) | throw () [virtual] |
Called whenever a mouse linked to this controller had one of its buttons released.
Definition at line 222 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
void Controller::joystickAxisChanged | ( | const JoystickAxisEvent & | joystickAxisEvent | ) | throw () [virtual] |
Called whenever a joystick linked to this controller had one of its axes changed.
Definition at line 242 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
void Controller::joystickTrackballChanged | ( | const JoystickTrackballEvent & | joystickTrackballEvent | ) | throw () [virtual] |
Called whenever a joystick linked to this controller had one of its trackballs changed.
Definition at line 260 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
void Controller::joystickHatChanged | ( | const JoystickHatEvent & | joystickHatChangedEvent | ) | throw () [virtual] |
Called whenever a joystick linked to this controller had one of its hats changed.
Definition at line 278 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
void Controller::joystickButtonPressed | ( | const JoystickButtonEvent & | joystickButtonPressedEvent | ) | throw () [virtual] |
Called whenever a joystick linked to this controller had one of its buttons pressed.
Definition at line 297 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
void Controller::joystickButtonReleased | ( | const JoystickButtonEvent & | joystickButtonReleasedEvent | ) | throw () [virtual] |
Called whenever a joystick linked to this controller had one of its buttons changed.
Definition at line 316 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
void Controller::joystickLeft | ( | Events::AxisPosition | leftExtent | ) | throw () [virtual] |
Called whenever the classical joystick linked to this controller is pushed to the left.
leftExtent | the extent, ranging for [0,32767], of the joystick position to the left. |
This method is meant to be overriden so that this controller can react to this event.
Definition at line 335 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
void Controller::joystickRight | ( | Events::AxisPosition | rightExtent | ) | throw () [virtual] |
Called whenever the classical joystick linked to this controller is pushed to the right.
rightExtent | the extent, ranging for [0,32767], of the joystick position to the right. |
This method is meant to be overriden so that this controller can react to this event.
Definition at line 344 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
void Controller::joystickUp | ( | Events::AxisPosition | upExtent | ) | throw () [virtual] |
Called whenever the classical joystick linked to this controller is pushed up.
upExtent | the up extent, ranging for [0,32767], of the joystick position. |
This method is meant to be overriden so that this controller can react to this event.
Definition at line 353 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
void Controller::joystickDown | ( | Events::AxisPosition | downExtent | ) | throw () [virtual] |
Called whenever the classical joystick linked to this controller is pushed down.
downExtent | the down extent, ranging for [0,32767], of the joystick position. |
This method is meant to be overriden so that this controller can react to this event.
Definition at line 362 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
void Controller::joystickFirstButtonPressed | ( | ) | throw () [virtual] |
Called whenever the first button of the classical joystick linked to this controller, if any, is pressed.
Definition at line 371 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
void Controller::joystickFirstButtonReleased | ( | ) | throw () [virtual] |
Called whenever the first button of the classical joystick linked to this controller, if any, is released.
Definition at line 379 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
void Controller::joystickSecondButtonPressed | ( | ) | throw () [virtual] |
Called whenever the second button of the classical joystick linked to this controller, if any, is pressed.
Definition at line 387 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
void Controller::joystickSecondButtonReleased | ( | ) | throw () [virtual] |
Called whenever the second button of the classical joystick linked to this controller, if any, is released.
Definition at line 395 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
const string Controller::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 404 of file OSDLController.cc.
References OSDL::Video::Pixels::toString().
Controller& OSDL::MVC::Controller::operator= | ( | const Controller & | 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.