Specialization of generic Ceylan controller, linked with actual input devices such as mouse, keyboard or joystick. More...
#include <OSDLController.h>
Public Member Functions | |
Controller () | |
Constructs a new controller. | |
Controller (Ceylan::Model &model) | |
Constructs a controller that will send events to the specified model. | |
virtual | ~Controller () throw () |
Virtual destructor. | |
virtual void | keyboardFocusGained (const OSDL::Events::FocusEvent &keyboardFocusEvent) |
Called whenever a keyboard linked to this controller has gained focus. | |
virtual void | keyboardFocusLost (const OSDL::Events::FocusEvent &keyboardFocusEvent) |
Called whenever a keyboard linked to this controller has lost focus. | |
virtual void | rawKeyPressed (const OSDL::Events::KeyboardEvent &keyboardPressedEvent) |
Called whenever a raw key linked to this controller has been pressed. | |
virtual void | rawKeyReleased (const OSDL::Events::KeyboardEvent &keyboardReleasedEvent) |
Called whenever a raw key linked to this controller has been released. | |
virtual void | unicodeSelected (const OSDL::Events::KeyboardEvent &keyboardPressedEvent) |
Called whenever a Unicode character linked to this controller has been selected. | |
virtual void | mouseFocusGained (const OSDL::Events::FocusEvent &mouseFocusEvent) |
Called whenever a mouse linked to this controller has gained focus. | |
virtual void | mouseFocusLost (const OSDL::Events::FocusEvent &mouseFocusEvent) |
Called whenever a mouse linked to this controller has lost focus. | |
virtual void | mouseMoved (const OSDL::Events::MouseMotionEvent &mouseMotionEvent) |
Called whenever a mouse linked to this controller moved. | |
virtual void | mouseButtonPressed (const OSDL::Events::MouseButtonEvent &mouseButtonPressedEvent) |
Called whenever a mouse linked to this controller had one of its buttons pressed. | |
virtual void | mouseButtonReleased (const OSDL::Events::MouseButtonEvent &mouseButtonReleasedEvent) |
Called whenever a mouse linked to this controller had one of its buttons released. | |
virtual void | joystickAxisChanged (const OSDL::Events::JoystickAxisEvent &joystickAxisEvent) |
Called whenever a joystick linked to this controller had one of its axes changed. | |
virtual void | joystickTrackballChanged (const OSDL::Events::JoystickTrackballEvent &joystickTrackballEvent) |
Called whenever a joystick linked to this controller had one of its trackballs changed. | |
virtual void | joystickHatChanged (const OSDL::Events::JoystickHatEvent &joystickHatChangedEvent) |
Called whenever a joystick linked to this controller had one of its hats changed. | |
virtual void | joystickButtonPressed (const OSDL::Events::JoystickButtonEvent &joystickButtonPressedEvent) |
Called whenever a joystick linked to this controller had one of its buttons pressed. | |
virtual void | joystickButtonReleased (const OSDL::Events::JoystickButtonEvent &joystickButtonReleasedEvent) |
Called whenever a joystick linked to this controller had one of its buttons changed. | |
virtual void | joystickLeft (Events::AxisPosition leftExtent) |
Called whenever the classical joystick linked to this controller is pushed to the left. | |
virtual void | joystickRight (Events::AxisPosition rightExtent) |
Called whenever the classical joystick linked to this controller is pushed to the right. | |
virtual void | joystickUp (Events::AxisPosition upExtent) |
Called whenever the classical joystick linked to this controller is pushed up. | |
virtual void | joystickDown (Events::AxisPosition downExtent) |
Called whenever the classical joystick linked to this controller is pushed down. | |
virtual void | joystickFirstButtonPressed () |
Called whenever the first button of the classical joystick linked to this controller, if any, is pressed. | |
virtual void | joystickFirstButtonReleased () |
Called whenever the first button of the classical joystick linked to this controller, if any, is released. | |
virtual void | joystickSecondButtonPressed () |
Called whenever the second button of the classical joystick linked to this controller, if any, is pressed. | |
virtual void | joystickSecondButtonReleased () |
Called whenever the second button of the classical joystick linked to this controller, if any, is released. | |
virtual const Ceylan::Event & | getEventFor (const Ceylan::CallerEventListener &listener) |
As this controller drives its listeners, they are not expected to request events from it, therefore this inherited method will throw an exception in all cases. | |
virtual const std::string | toString (Ceylan::VerbosityLevels level=Ceylan::high) const |
Returns an user-friendly description of the state of this object. | |
Private Member Functions | |
Controller (const Controller &source) | |
Copy constructor made private to ensure that it will never be called. | |
Controller & | operator= (const Controller &source) |
Assignment operator made private to ensure that it will never be called. |
Specialization of generic Ceylan controller, linked with actual input devices such as mouse, keyboard or joystick.
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}.
These controllers are mostly designed to capture flow of informations coming from an actual input device.
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 115 of file OSDLController.h.
Controller::Controller | ( | ) |
Constructs a new controller.
Definition at line 62 of file OSDLController.cc.
Controller::Controller | ( | Ceylan::Model & | model | ) | [explicit] |
Constructs a controller that will send events to the specified model.
Definition at line 69 of file OSDLController.cc.
Controller::~Controller | ( | ) | throw () [virtual] |
Virtual destructor.
Definition at line 76 of file OSDLController.cc.
OSDL::MVC::Controller::Controller | ( | const Controller & | 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.
const Ceylan::Event & Controller::getEventFor | ( | const Ceylan::CallerEventListener & | listener | ) | [virtual] |
As this controller drives its listeners, they are not expected to request events from it, therefore this inherited method will throw an exception in all cases.
Definition at line 448 of file OSDLController.cc.
virtual void OSDL::MVC::Controller::joystickAxisChanged | ( | const OSDL::Events::JoystickAxisEvent & | joystickAxisEvent | ) | [virtual] |
Called whenever a joystick linked to this controller had one of its axes changed.
Referenced by OSDL::Events::Joystick::axisChanged().
virtual void OSDL::MVC::Controller::joystickButtonPressed | ( | const OSDL::Events::JoystickButtonEvent & | joystickButtonPressedEvent | ) | [virtual] |
Called whenever a joystick linked to this controller had one of its buttons pressed.
Referenced by OSDL::Events::Joystick::buttonPressed().
virtual void OSDL::MVC::Controller::joystickButtonReleased | ( | const OSDL::Events::JoystickButtonEvent & | joystickButtonReleasedEvent | ) | [virtual] |
Called whenever a joystick linked to this controller had one of its buttons changed.
Referenced by OSDL::Events::Joystick::buttonReleased().
virtual void OSDL::MVC::Controller::joystickDown | ( | Events::AxisPosition | downExtent | ) | [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. |
Referenced by OSDL::Events::ClassicalJoystick::axisChanged().
void Controller::joystickFirstButtonPressed | ( | ) | [virtual] |
Called whenever the first button of the classical joystick linked to this controller, if any, is pressed.
Definition at line 413 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
Referenced by OSDL::Events::ClassicalJoystick::buttonPressed().
void Controller::joystickFirstButtonReleased | ( | ) | [virtual] |
Called whenever the first button of the classical joystick linked to this controller, if any, is released.
Definition at line 422 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
Referenced by OSDL::Events::ClassicalJoystick::buttonReleased().
virtual void OSDL::MVC::Controller::joystickHatChanged | ( | const OSDL::Events::JoystickHatEvent & | joystickHatChangedEvent | ) | [virtual] |
Called whenever a joystick linked to this controller had one of its hats changed.
Referenced by OSDL::Events::Joystick::hatChanged().
virtual void OSDL::MVC::Controller::joystickLeft | ( | Events::AxisPosition | leftExtent | ) | [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. |
Referenced by OSDL::Events::ClassicalJoystick::axisChanged().
virtual void OSDL::MVC::Controller::joystickRight | ( | Events::AxisPosition | rightExtent | ) | [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. |
Referenced by OSDL::Events::ClassicalJoystick::axisChanged().
void Controller::joystickSecondButtonPressed | ( | ) | [virtual] |
Called whenever the second button of the classical joystick linked to this controller, if any, is pressed.
Definition at line 431 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
Referenced by OSDL::Events::ClassicalJoystick::buttonPressed().
void Controller::joystickSecondButtonReleased | ( | ) | [virtual] |
Called whenever the second button of the classical joystick linked to this controller, if any, is released.
Definition at line 440 of file OSDLController.cc.
References OSDL_CONTROLLER_LOG.
Referenced by OSDL::Events::ClassicalJoystick::buttonReleased().
virtual void OSDL::MVC::Controller::joystickTrackballChanged | ( | const OSDL::Events::JoystickTrackballEvent & | joystickTrackballEvent | ) | [virtual] |
Called whenever a joystick linked to this controller had one of its trackballs changed.
Referenced by OSDL::Events::Joystick::trackballChanged().
virtual void OSDL::MVC::Controller::joystickUp | ( | Events::AxisPosition | upExtent | ) | [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. |
Referenced by OSDL::Events::ClassicalJoystick::axisChanged().
virtual void OSDL::MVC::Controller::keyboardFocusGained | ( | const OSDL::Events::FocusEvent & | keyboardFocusEvent | ) | [virtual] |
Called whenever a keyboard linked to this controller has gained focus.
Referenced by OSDL::Events::KeyboardHandler::focusGained().
virtual void OSDL::MVC::Controller::keyboardFocusLost | ( | const OSDL::Events::FocusEvent & | keyboardFocusEvent | ) | [virtual] |
Called whenever a keyboard linked to this controller has lost focus.
Referenced by OSDL::Events::KeyboardHandler::focusLost().
virtual void OSDL::MVC::Controller::mouseButtonPressed | ( | const OSDL::Events::MouseButtonEvent & | mouseButtonPressedEvent | ) | [virtual] |
Called whenever a mouse linked to this controller had one of its buttons pressed.
Referenced by OSDL::Events::Mouse::buttonPressed().
virtual void OSDL::MVC::Controller::mouseButtonReleased | ( | const OSDL::Events::MouseButtonEvent & | mouseButtonReleasedEvent | ) | [virtual] |
Called whenever a mouse linked to this controller had one of its buttons released.
Referenced by OSDL::Events::Mouse::buttonReleased().
virtual void OSDL::MVC::Controller::mouseFocusGained | ( | const OSDL::Events::FocusEvent & | mouseFocusEvent | ) | [virtual] |
Called whenever a mouse linked to this controller has gained focus.
Referenced by OSDL::Events::Mouse::focusGained().
virtual void OSDL::MVC::Controller::mouseFocusLost | ( | const OSDL::Events::FocusEvent & | mouseFocusEvent | ) | [virtual] |
Called whenever a mouse linked to this controller has lost focus.
Referenced by OSDL::Events::Mouse::focusLost().
virtual void OSDL::MVC::Controller::mouseMoved | ( | const OSDL::Events::MouseMotionEvent & | mouseMotionEvent | ) | [virtual] |
Called whenever a mouse linked to this controller moved.
Referenced by OSDL::Events::Mouse::mouseMoved().
Controller& OSDL::MVC::Controller::operator= | ( | const Controller & | 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.
virtual void OSDL::MVC::Controller::rawKeyPressed | ( | const OSDL::Events::KeyboardEvent & | keyboardPressedEvent | ) | [virtual] |
Called whenever a raw key linked to this controller has been pressed.
Referenced by OSDL::Events::KeyboardHandler::keyPressed().
virtual void OSDL::MVC::Controller::rawKeyReleased | ( | const OSDL::Events::KeyboardEvent & | keyboardReleasedEvent | ) | [virtual] |
Called whenever a raw key linked to this controller has been released.
const string Controller::toString | ( | Ceylan::VerbosityLevels | level = Ceylan::high |
) | const [virtual] |
Returns an user-friendly description of the state of this object.
level | the requested verbosity level. |
Definition at line 458 of file OSDLController.cc.
virtual void OSDL::MVC::Controller::unicodeSelected | ( | const OSDL::Events::KeyboardEvent & | keyboardPressedEvent | ) | [virtual] |
Called whenever a Unicode character linked to this controller has been selected.