OSDL::Events::EventsModule Class Reference

#include <OSDLEvents.h>

Collaboration diagram for OSDL::Events::EventsModule:

[legend]
List of all members.

Detailed Description

Handles the asynchronous event-based interaction model, general input handling, and basic time management, including the logic and rendering frequencies.

Our optional scheduler allows to uncouple all these times.

The user is given the choice between a basic event loop, for which input management, rendering and logic have to happen at the same frequency, and a scheduler, that allows him to set a different frequency for each of these concerns, and permits fine-grained activation of the scheduled objects, be it periodic or specifically programmed.

Both scheduling choices allow idle calls to be performed if, CPU-wise, the process can afford it.

The default idle call is the smallest possible OS sleep (one time slice), to avoid the operating system to take counter-measures against this process, which otherwise would be deemed too CPU-hungry. The user can supply a specific idle callback, if wanted.

Under all circumstances, the callback function should last for very small durations, compared to the frequencies requested (better multiple idle calls than too long too few), otherwise the scheduling may constantly fail.

Event module notes :

The event modules comes with no joystick handler registered, but with a keyboard handler.

Scheduler notes :

Note:
Even though logic and rendering are not as tightly linked as they often are, if the sum of their processing needs exceeds what the hosting computer can give, they will have to overcome this resource limitation. The logic is deemed more important than rendering, therefore jerked graphics will be preferred by the scheduler to frame-rate dependent logic.
Basic settings are as follow :

Note:
With the SDL back-end, a created window (see VideoModule::setMode) is needed to have the event system working.

Definition at line 204 of file OSDLEvents.h.

Public Member Functions

virtual void waitForAnyKey (bool displayWaitingMessage=true) const throw ()
 Waits for any key to be hit.
virtual bool sleepFor (Ceylan::System::Second seconds, Ceylan::System::Microsecond micros) const throw ( EventsException )
 Sleeps for the specified duration.
virtual void useScheduler (bool on=true) throw ()
 Defines whether a scheduler should be used by the event loop.
virtual void setIdleCallback (Ceylan::System::Callback idleCallback, void *callbackData=0, Ceylan::System::Microsecond callbackExpectedMaxDuration=0) throw ()
 Sets the idle function, which is called whenever the current scheduling system, either the main event loop or the scheduler, detects a period of idle activity.
virtual void setEventLoopTargetFrequency (Hertz targetFrequency) throw ()
 Sets the actual target frequency that the basic event loop will try to run at.
virtual void enterMainLoop () throw ( EventsException )
 Enters the main event loop.
virtual void requestQuit () throw ()
 Requests the application to quit by exiting the main loop.
virtual bool hasKeyboardHandler () const throw ()
 Tells whether a keyboard handler is available.
virtual KeyboardHandlergetKeyboardHandler () const throw ( EventsException )
 Returns the keyboard handler currently used.
virtual void setKeyboardHandler (KeyboardHandler &newHandler) throw ()
 Sets a new keyboard handler.
virtual bool hasJoystickHandler () const throw ()
 Tells whether a joystick handler is available.
virtual JoystickHandlergetJoystickHandler () const throw ( EventsException )
 Returns the joystick handler currently used.
virtual void setJoystickHandler (JoystickHandler &newHandler) throw ()
 Sets a new joystick handler.
virtual bool hasMouseHandler () const throw ()
 Tells whether a mouse handler is available.
virtual MouseHandlergetMouseHandler () const throw ( EventsException )
 Returns the mouse handler currently used.
virtual void setMouseHandler (MouseHandler &newHandler) throw ()
 Sets a new mouse handler.
virtual void updateInputState () throw ()
 Updates the state of the various inputs of interest (keyboard, mouse, joystick).
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 std::string DescribeEnvironmentVariables () throw ()
 Returns a summary about the possible use of events-related environment variables, for the selected back-end.
static bool IsEventsInitialized () throw ()
 Tells whether event system has already been initialized.
static Ceylan::System::Millisecond GetMillisecondsSinceStartup () throw ( EventsException )
 Gets the number of milliseconds since the back-end initialization.
static std::string DescribeEvent (const FocusEvent &focusEvent)
 Describes a focus event.
static std::string DescribeEvent (const KeyboardEvent &keyboardEvent)
 Describes a keyboard event.
static std::string DescribeEvent (const MouseMotionEvent &mouseMotionEvent)
 Describes a mouse motion event.
static std::string DescribeEvent (const MouseButtonEvent &mouseButtonEvent)
 Describes a mouse button event.
static std::string DescribeEvent (const JoystickAxisEvent &axisEvent)
 Describes a joystick axis event.
static std::string DescribeEvent (const JoystickTrackballEvent &ballEvent)
 Describes a joystick trackball event.
static std::string DescribeEvent (const JoystickHatEvent &hatEvent)
 Describes a joystick hat event.
static std::string DescribeEvent (const JoystickButtonEvent &buttonEvent)
 Describes a joystick button event.
static std::string DescribeEvent (const UserRequestedQuitEvent &quitEvent)
 Describes a quit event.
static std::string DescribeEvent (const SystemSpecificWindowManagerEvent &windowManagerEvent)
 Describes a window manager event (system specific).
static std::string DescribeEvent (const WindowResizedEvent &resizeEvent)
 Describes a window resized event.
static std::string DescribeEvent (const ScreenExposedEvent &redrawEvent)
 Describes a screen exposed event (needs redraw).
static std::string DescribeEvent (const UserEvent &userEvent)
 Describes an user event.
static Ceylan::System::Microsecond EvaluateCallbackduration (Ceylan::System::Callback callback, void *callbackData) throw ()
 Tries to guess an upper-bound for the average duration of the execution of the specified callback.
static std::string DescribeEvent (BasicEvent anEvent) throw ()
 Returns a string describing the specified basic event.

Static Public Attributes

static const BasicEventType ApplicationFocusChanged
 Identifies the event corresponding to application gaining or loosing focus(es).
static const BasicEventType KeyPressed
 Identifies the event corresponding to a key press.
static const BasicEventType KeyReleased
 Identifies the event corresponding to a key release.
static const BasicEventType MouseMoved
 Identifies the event corresponding to a mouse motion.
static const BasicEventType MouseButtonPressed
 Identifies the event corresponding to a mouse button press.
static const BasicEventType MouseButtonReleased
 Identifies the event corresponding to a mouse button release.
static const BasicEventType JoystickAxisChanged
 Identifies the event corresponding to a joystick axis move.
static const BasicEventType JoystickTrackballChanged
 Identifies the event corresponding to a joystick trackball motion.
static const BasicEventType JoystickHatPositionChanged
 Identifies the event corresponding to a change of joystick hat position.
static const BasicEventType JoystickButtonPressed
 Identifies the event corresponding to a joystick button being pressed.
static const BasicEventType JoystickButtonReleased
 Identifies the event corresponding to a joystick button being released.
static const BasicEventType UserRequestedQuit
 Identifies the event corresponding to the user requesting to quit.
static const BasicEventType SystemSpecificTriggered
 Identifies the event corresponding to system specific event.
static const BasicEventType UserResizedVideoMode
 Identifies the event corresponding to a resize of user's video mode.
static const BasicEventType ScreenNeedsRedraw
 Identifies the event corresponding to a need to redraw screen.
static const BasicEventType FirstUserEventTriggered
 Identifies the first event that can be user-defined.
static const BasicEventType LastUserEventTriggered
 Identifies the last event that can be user-defined.
static const UserEventType NoEvent
 Void event, useful to return when no event should be generated.
static const UserEventType QuitRequested
 Identifies the user event corresponding to a quit request.
static const Hertz DefaultEventLoopTargetedFrequency = 100
 The default frequency targeted by the basic event loop.

Protected Member Functions

virtual void enterBasicMainLoop () throw ( EventsException )
 Enters the basic event loop, not using any scheduler.
virtual void onKeyboardFocusGained (const FocusEvent &keyboardFocusEvent) throw ()
 Called whenever the application gained keyboard focus.
virtual void onKeyboardFocusLost (const FocusEvent &keyboardFocusEvent) throw ()
 Called whenever the application lost keyboard focus.
virtual void onKeyPressed (const KeyboardEvent &keyboardEvent) throw ()
 Called whenever a key is pressed.
virtual void onKeyReleased (const KeyboardEvent &keyboardEvent) throw ()
 Called whenever a key is released.
virtual void onMouseFocusGained (const FocusEvent &mouseFocus) throw ()
 Called whenever the application gained mouse focus.
virtual void onMouseFocusLost (const FocusEvent &mouseFocus) throw ()
 Called whenever the application lost mouse focus.
virtual void onMouseMotion (const MouseMotionEvent &mouseEvent) throw ()
 Called whenever the mouse moved.
virtual void onMouseButtonPressed (const MouseButtonEvent &mouseEvent) throw ()
 Called whenever a mouse button is pressed.
virtual void onMouseButtonReleased (const MouseButtonEvent &mouseEvent) throw ()
 Called whenever a mouse button is released.
virtual void onJoystickAxisChanged (const JoystickAxisEvent &joystickEvent) throw ()
 Called whenever the joystick axis changed.
virtual void onJoystickTrackballChanged (const JoystickTrackballEvent &joystickEvent) throw ()
 Called whenever the joystick trackball changed.
virtual void onJoystickHatChanged (const JoystickHatEvent &joystickEvent) throw ()
 Called whenever the joystick hat changed.
virtual void onJoystickButtonPressed (const JoystickButtonEvent &joystickEvent) throw ()
 Called whenever the joystick button is pressed.
virtual void onJoystickButtonReleased (const JoystickButtonEvent &joystickEvent) throw ()
 Called whenever the joystick button is released.
virtual void onIdle () throw ()
 Called whenever the application is deemed idle.
virtual void onApplicationFocusChanged (const FocusEvent &focusEvent) throw ()
 Called whenever at least one of the three focuses (mouse, keyboard or application visibility) changed.
virtual void onApplicationIconified (const FocusEvent &focusEvent) throw ()
 Called whenever the application is iconified (minimized ).
virtual void onApplicationRestored (const FocusEvent &focusEvent) throw ()
 Called whenever the application is restored.
virtual void onQuitRequested () throw ()
 Called whenever the application is requested to quit.
virtual void onSystemSpecificWindowManagerEvent (const SystemSpecificWindowManagerEvent &wmEvent) throw ()
 Called whenever a system-specific window manager event is received.
virtual void onResizedWindow (const WindowResizedEvent &resizeEvent) throw ()
 Called whenever the window is resized.
virtual void onScreenNeedsRedraw () throw ()
 Called whenever the screen has been modified outside of the application, usually by the window manager, and needs to be redrawn.
virtual void onUserEvent (const UserEvent &userEvent) throw ()
 Called whenever an user-defined event occurs.
virtual void onUnknownEventType (const BasicEvent &unknownEvent) throw ()
 Called whenever an unknown event type occurs during the input update phase.

Protected Attributes

bool _useScheduler
 Tells whether a scheduler should be used.
KeyboardHandler_keyboardHandler
 The internal keyboard handler.
JoystickHandler_joystickHandler
 The internal joystick handler, if any.
MouseHandler_mouseHandler
 The internal mouse handler, if any.
bool _quitRequested
 Tells whether the user asked to quit.
Hertz _loopTargetedFrequency
 The targeted frequency of the basic event loop.
Ceylan::Uint32 _idleCallsCount
 Count the number of idle calls made during the current event loop.
Ceylan::System::Callback _loopIdleCallback
 The idle callback, if any, to be called by the basic event loop.
void * _loopIdleCallbackData
 The data, if any, to provide to the idle callback, should the basic event loop be used.
Ceylan::System::Microsecond _loopIdleCallbackMaxDuration
 An estimated upper bound of the duration of current idle callback.

Static Protected Attributes

static std::string _SDLEnvironmentVariables []
 Array of all known environment variables related to events, for the SDL back-end.
static bool _EventsInitialized
 Tells whether event system has already been initialized.
static const Ceylan::Uint32 _FrameTimingSlotsCount
 Number of available slots used to keep track of frame rate.
static const Ceylan::Sint16 _MouseFocus
 Designates the mouse focus.
static const Ceylan::Sint16 _KeyboardFocus
 Designates the keyboard focus.
static const Ceylan::Sint16 _ApplicationFocus
 Designates the application focus (iconified or restored).
static const std::string _MessageHeader
 Header of messages sent by default implementations (ex : onMouseFocusGained).
static const Ceylan::Uint32 _MouseButtonCount
 Records the total number of buttons supported for a mouse.

Private Member Functions

 EventsModule (Ceylan::Flags eventsFlag) throw ( EventsException )
 Initializes the events module.
virtual ~EventsModule () throw ()
 Deletes the events module.
 EventsModule (const EventsModule &source) throw ()
 Copy constructor made private to ensure that it will never be called.
EventsModuleoperator= (const EventsModule &source) throw ()
 Assignment operator made private to ensure that it will never be called.

Friends

class OSDL::CommonModule


Constructor & Destructor Documentation

OSDL::Events::EventsModule::EventsModule ( Ceylan::Flags  eventsFlag  )  throw ( EventsException ) [explicit, private]

Initializes the events module.

Parameters:
eventsFlag flag describing which input device should be enabled (keyboard, mouse, joystick, etc.)
Exceptions:
EventsException if the initialization of an input subsystem failed.
Note:
Some input device handlers (ex : mouse or joystick) may be created even though not specifically requested, because some events may have to be managed anyway (ex : keyboard or mouse focus lost, etc.).

EventsModule::~EventsModule (  )  throw () [private, virtual]

Deletes the events module.

Definition at line 223 of file OSDLEvents.cc.

References _joystickHandler, _keyboardHandler, and _mouseHandler.

OSDL::Events::EventsModule::EventsModule ( const EventsModule 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 EventsModule::waitForAnyKey ( bool  displayWaitingMessage = true  )  const throw () [virtual]

Waits for any key to be hit.

Will not work with the SDL back-end unless a window is opened thanks to VideoModule::setMode : otherwise, no event would be generated.

Note:
This waiting method does not poll indefinitively for events, which would use 100% of the CPU all the time. It just waits for an event, consuming almost no ressource.

Definition at line 254 of file OSDLEvents.cc.

virtual bool OSDL::Events::EventsModule::sleepFor ( Ceylan::System::Second  seconds,
Ceylan::System::Microsecond  micros 
) const throw ( EventsException ) [virtual]

Sleeps for the specified duration.

Parameters:
seconds the number of seconds to wait.
micros the remaining part of the time to wait, expressed as a number of microseconds.
As full seconds should be taken into account with the parameter seconds, micros should be less than one second, i.e. should be in the range 0 to 10E6 - 1.

Exceptions:
EventsException if a system call failed.
Returns:
whether the deadline was successfully met, i.e. if the waiting was on schedule.
Note:
This method must cope with the operating system scheduling, its precision should be of about a few microseconds.
See also:
Ceylan::System::smartSleep

void EventsModule::useScheduler ( bool  on = true  )  throw () [virtual]

Defines whether a scheduler should be used by the event loop.

If a scheduler is wanted but does not already exist, it will be created with default settings.

This scheduler will be in charge of all the active objects that will be registered subsequently.

Parameters:
on tells whether a scheduler is wanted.
See also:
Scheduler::GetScheduler method to further customize the scheduler.

Definition at line 319 of file OSDLEvents.cc.

void EventsModule::setIdleCallback ( Ceylan::System::Callback  idleCallback,
void *  callbackData = 0,
Ceylan::System::Microsecond  callbackExpectedMaxDuration = 0 
) throw () [virtual]

Sets the idle function, which is called whenever the current scheduling system, either the main event loop or the scheduler, detects a period of idle activity.

The callback can be useful when dealing with animations for example, or to execute background activities (such as counting the frame rate), or to let the process yield some CPU time so that the OS does not consider it as too CPU-hungry, and does not take counter-measures against it.

Note:
Ensure that the maximum time spent in the callback is negligible compared to the period corresponding to the maximum frequency being set, so that it does not result in a too heavy load which would make the scheduler fail constantly.
Parameters:
idleCallback the idle callback, which can be null (0) to specify no idle callback is wanted.
callbackData the user-supplied data pointer that the idle callback will be given, if not null.
callbackExpectedMaxDuration the maximum duration, in microseconds, expected for this idle call-back. Helps the main loop enforcing its target frequency. If this value is null, the idle callback will be launched once immediately (during the call of this method), and the measured duration, increased of 20%, will be kept as upper bound.
Any prior callback or callback data will be replaced by the one specified.

Definition at line 340 of file OSDLEvents.cc.

void EventsModule::setEventLoopTargetFrequency ( Hertz  targetFrequency  )  throw () [virtual]

Sets the actual target frequency that the basic event loop will try to run at.

Note:
Will not take effect until the next call to the basic event loop.

Definition at line 374 of file OSDLEvents.cc.

void EventsModule::enterMainLoop (  )  throw ( EventsException ) [virtual]

Enters the main event loop.

If a scheduler is being used, will start it, and stop it on exit. Otherwise the basic event loop will be used.

Note:
If an idle callback is set, it will be executed appropriately.
Exceptions:
EventsException if a serious scheduling or event-related problem occured.

Definition at line 382 of file OSDLEvents.cc.

References _useScheduler, enterBasicMainLoop(), and OSDL::CommonModule::IsBackendInitialized().

void EventsModule::requestQuit (  )  throw () [virtual]

Requests the application to quit by exiting the main loop.

Note:
This method is useful for input handlers to send too quit notifications, otherwise the only way of quitting would be provided by the window manager, if any.

Definition at line 430 of file OSDLEvents.cc.

References _quitRequested, and _useScheduler.

Referenced by onQuitRequested().

bool EventsModule::hasKeyboardHandler (  )  const throw () [virtual]

Tells whether a keyboard handler is available.

Definition at line 460 of file OSDLEvents.cc.

References _keyboardHandler.

KeyboardHandler & EventsModule::getKeyboardHandler (  )  const throw ( EventsException ) [virtual]

Returns the keyboard handler currently used.

Exceptions:
EventsException if no keyboard handler is available.

Definition at line 469 of file OSDLEvents.cc.

References _keyboardHandler.

void EventsModule::setKeyboardHandler ( KeyboardHandler newHandler  )  throw () [virtual]

Sets a new keyboard handler.

Parameters:
newHandler the new keyboard handler.
Note:
If a keyboard handler was already registered, it is unregistered and deallocated first.

Definition at line 484 of file OSDLEvents.cc.

bool EventsModule::hasJoystickHandler (  )  const throw () [virtual]

Tells whether a joystick handler is available.

Definition at line 497 of file OSDLEvents.cc.

References _joystickHandler.

JoystickHandler & EventsModule::getJoystickHandler (  )  const throw ( EventsException ) [virtual]

Returns the joystick handler currently used.

Exceptions:
EventsException if no joystick handler is available.

Definition at line 505 of file OSDLEvents.cc.

References _joystickHandler.

void EventsModule::setJoystickHandler ( JoystickHandler newHandler  )  throw () [virtual]

Sets a new joystick handler.

Parameters:
newHandler the new joystick handler.
Note:
If a joystick handler was already registered, it is unregistered and deallocated first.

Definition at line 520 of file OSDLEvents.cc.

bool EventsModule::hasMouseHandler (  )  const throw () [virtual]

Tells whether a mouse handler is available.

Definition at line 533 of file OSDLEvents.cc.

References _mouseHandler.

MouseHandler & EventsModule::getMouseHandler (  )  const throw ( EventsException ) [virtual]

Returns the mouse handler currently used.

Exceptions:
EventsException if no mouse handler is available.

Definition at line 541 of file OSDLEvents.cc.

References _mouseHandler.

void EventsModule::setMouseHandler ( MouseHandler newHandler  )  throw () [virtual]

Sets a new mouse handler.

Parameters:
newHandler the new joystcik handler.
Note:
If a mouse handler was already registered, it is unregistered and deallocated first.

Definition at line 556 of file OSDLEvents.cc.

void EventsModule::updateInputState (  )  throw () [virtual]

Updates the state of the various inputs of interest (keyboard, mouse, joystick).

Reads all pending low-level events and dispatch them to the appropriate manager.

Note:
Useful for event loops, public for allowing the scheduler to call it.

Definition at line 569 of file OSDLEvents.cc.

References ApplicationFocusChanged, FirstUserEventTriggered, JoystickAxisChanged, JoystickButtonPressed, JoystickButtonReleased, JoystickHatPositionChanged, JoystickTrackballChanged, KeyPressed, KeyReleased, LastUserEventTriggered, MouseButtonPressed, MouseButtonReleased, MouseMoved, onApplicationFocusChanged(), onJoystickAxisChanged(), onJoystickButtonPressed(), onJoystickButtonReleased(), onJoystickHatChanged(), onJoystickTrackballChanged(), onKeyPressed(), onKeyReleased(), onMouseButtonPressed(), onMouseButtonReleased(), onMouseMotion(), onQuitRequested(), onResizedWindow(), onScreenNeedsRedraw(), onSystemSpecificWindowManagerEvent(), onUnknownEventType(), onUserEvent(), ScreenNeedsRedraw, SystemSpecificTriggered, UserRequestedQuit, and UserResizedVideoMode.

Referenced by enterBasicMainLoop().

const string EventsModule::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 673 of file OSDLEvents.cc.

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

string EventsModule::DescribeEnvironmentVariables (  )  throw () [static]

Returns a summary about the possible use of events-related environment variables, for the selected back-end.

Note:
The SDL back-end can be partly driven by a set of environment variables.

Definition at line 735 of file OSDLEvents.cc.

References _SDLEnvironmentVariables, and OSDL::Video::Pixels::toString().

bool EventsModule::IsEventsInitialized (  )  throw () [static]

Tells whether event system has already been initialized.

Note:
This method is static so that calling it is convenient : no need to explicitly retrieve the common module, then events module before knowing the result.
The need to retrieve the right module from scratch at each call is rather inefficient though.

Definition at line 1746 of file OSDLEvents.cc.

References _EventsInitialized.

Millisecond EventsModule::GetMillisecondsSinceStartup (  )  throw ( EventsException ) [static]

Gets the number of milliseconds since the back-end initialization.

Note:
This value wraps (overflows) if the program runs for more than about 49 days.
Exceptions:
EventsException if the back-end is not already initialized.

Definition at line 864 of file OSDLEvents.cc.

References OSDL::CommonModule::IsBackendInitialized().

string EventsModule::DescribeEvent ( const FocusEvent focusEvent  )  [static]

Describes a focus event.

Definition at line 1526 of file OSDLEvents.cc.

References _ApplicationFocus, _KeyboardFocus, and _MouseFocus.

Referenced by OSDL::Events::Joystick::axisChanged(), OSDL::Events::ClassicalJoystick::axisChanged(), OSDL::Events::Mouse::buttonPressed(), OSDL::Events::Joystick::buttonPressed(), OSDL::Events::ClassicalJoystick::buttonPressed(), OSDL::Events::Mouse::buttonReleased(), OSDL::Events::Joystick::buttonReleased(), OSDL::Events::ClassicalJoystick::buttonReleased(), doNothingKeyHandler(), OSDL::Events::Mouse::focusGained(), OSDL::Events::Mouse::focusLost(), OSDL::Events::Joystick::hatChanged(), OSDL::Events::Mouse::mouseMoved(), smarterKeyHandler(), and OSDL::Events::Joystick::trackballChanged().

string EventsModule::DescribeEvent ( const KeyboardEvent keyboardEvent  )  [static]

Describes a keyboard event.

Definition at line 1560 of file OSDLEvents.cc.

References OSDL::Events::KeyboardHandler::DescribeKey(), OSDL::Events::KeyboardHandler::DescribeModifier(), OSDL::Events::KeyboardHandler::DescribeUnicode(), OSDL::Events::KeyboardHandler::GetMode(), KeyPressed, and OSDL::Events::textInput.

string EventsModule::DescribeEvent ( const MouseMotionEvent mouseMotionEvent  )  [static]

Describes a mouse motion event.

Definition at line 1588 of file OSDLEvents.cc.

References _MouseButtonCount, and OSDL::Video::Pixels::toString().

string EventsModule::DescribeEvent ( const MouseButtonEvent mouseButtonEvent  )  [static]

Describes a mouse button event.

Definition at line 1608 of file OSDLEvents.cc.

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

string EventsModule::DescribeEvent ( const JoystickAxisEvent axisEvent  )  [static]

Describes a joystick axis event.

Definition at line 1658 of file OSDLEvents.cc.

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

string EventsModule::DescribeEvent ( const JoystickTrackballEvent ballEvent  )  [static]

Describes a joystick trackball event.

Definition at line 1668 of file OSDLEvents.cc.

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

string EventsModule::DescribeEvent ( const JoystickHatEvent hatEvent  )  [static]

Describes a joystick hat event.

Definition at line 1680 of file OSDLEvents.cc.

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

string EventsModule::DescribeEvent ( const JoystickButtonEvent buttonEvent  )  [static]

Describes a joystick button event.

Definition at line 1690 of file OSDLEvents.cc.

string EventsModule::DescribeEvent ( const UserRequestedQuitEvent quitEvent  )  [static]

Describes a quit event.

Definition at line 1701 of file OSDLEvents.cc.

string EventsModule::DescribeEvent ( const SystemSpecificWindowManagerEvent windowManagerEvent  )  [static]

Describes a window manager event (system specific).

Definition at line 1709 of file OSDLEvents.cc.

string EventsModule::DescribeEvent ( const WindowResizedEvent resizeEvent  )  [static]

Describes a window resized event.

Definition at line 1724 of file OSDLEvents.cc.

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

string EventsModule::DescribeEvent ( const ScreenExposedEvent redrawEvent  )  [static]

Describes a screen exposed event (needs redraw).

Definition at line 1733 of file OSDLEvents.cc.

string EventsModule::DescribeEvent ( const UserEvent userEvent  )  [static]

Describes an user event.

Definition at line 1739 of file OSDLEvents.cc.

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

Ceylan::System::Microsecond EventsModule::EvaluateCallbackduration ( Ceylan::System::Callback  callback,
void *  callbackData 
) throw () [static]

Tries to guess an upper-bound for the average duration of the execution of the specified callback.

Parameters:
callback the callback whose duration will be evaluated.
callbackData the data that will be given to the callback for the evaluation.
Returns:
A guessed upper-bound for the duration of the callback.
Note:
Will run the callback once, and return the measured duration increased of 20%.

Definition at line 1754 of file OSDLEvents.cc.

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

string EventsModule::DescribeEvent ( BasicEvent  anEvent  )  throw () [static]

Returns a string describing the specified basic event.

Definition at line 788 of file OSDLEvents.cc.

void EventsModule::enterBasicMainLoop (  )  throw ( EventsException ) [protected, virtual]

Enters the basic event loop, not using any scheduler.

The loop will aim to enforce the specified frequency, i.e. the current frame per second target.

Note:
This is basically a never-return method, if no exit handler is registered.
Exceptions:
EventsException if a time-related problem, more serious than deadline misses, occurs.

Definition at line 888 of file OSDLEvents.cc.

References _idleCallsCount, _loopIdleCallback, _loopIdleCallbackMaxDuration, _loopTargetedFrequency, _quitRequested, OSDL::getExistingCommonModule(), OSDL::Rendering::Renderer::GetExistingRootRenderer(), OSDL::CommonModule::getVideoModule(), OSDL::Rendering::Renderer::HasExistingRootRenderer(), onIdle(), OSDL::Video::VideoModule::redraw(), OSDL::Video::Pixels::toString(), and updateInputState().

Referenced by enterMainLoop().

void EventsModule::onKeyboardFocusGained ( const FocusEvent keyboardFocusEvent  )  throw () [protected, virtual]

Called whenever the application gained keyboard focus.

Parameters:
keyboardFocusEvent the keyboard focus event.
Note:
Made to be overriden, basically just writes the event in the standard output.

Definition at line 1096 of file OSDLEvents.cc.

References OSDL_EVENT_LOG.

void EventsModule::onKeyboardFocusLost ( const FocusEvent keyboardFocusEvent  )  throw () [protected, virtual]

Called whenever the application lost keyboard focus.

Parameters:
keyboardFocusEvent the keyboard focus event.
keyboardFocusEvent the keyboard focus event.
Note:
Made to be overriden, basically just writes the event in the standard output.

Definition at line 1113 of file OSDLEvents.cc.

References OSDL_EVENT_LOG.

void EventsModule::onKeyPressed ( const KeyboardEvent keyboardEvent  )  throw () [protected, virtual]

Called whenever a key is pressed.

Parameters:
keyboardEvent the keyboard event.

Definition at line 1130 of file OSDLEvents.cc.

References OSDL_EVENT_LOG.

Referenced by updateInputState().

void EventsModule::onKeyReleased ( const KeyboardEvent keyboardEvent  )  throw () [protected, virtual]

Called whenever a key is released.

Parameters:
keyboardEvent the keyboard event.

Definition at line 1146 of file OSDLEvents.cc.

References OSDL_EVENT_LOG.

Referenced by updateInputState().

void EventsModule::onMouseFocusGained ( const FocusEvent mouseFocus  )  throw () [protected, virtual]

Called whenever the application gained mouse focus.

Parameters:
mouseFocus the mouse that gained focus.
Note:
Made to be overriden, basically just writes the event in the standard output.

Definition at line 1166 of file OSDLEvents.cc.

References OSDL_EVENT_LOG.

void EventsModule::onMouseFocusLost ( const FocusEvent mouseFocus  )  throw () [protected, virtual]

Called whenever the application lost mouse focus.

Parameters:
mouse the mouse that lost focus.
Note:
Made to be overriden, basically just writes the event in the standard output.

Definition at line 1183 of file OSDLEvents.cc.

References OSDL_EVENT_LOG.

void EventsModule::onMouseMotion ( const MouseMotionEvent mouseEvent  )  throw () [protected, virtual]

Called whenever the mouse moved.

Parameters:
mouseEvent the mouse motion event.

Definition at line 1200 of file OSDLEvents.cc.

References OSDL_EVENT_LOG.

Referenced by updateInputState().

void EventsModule::onMouseButtonPressed ( const MouseButtonEvent mouseEvent  )  throw () [protected, virtual]

Called whenever a mouse button is pressed.

Parameters:
mouseEvent the mouse button event.

Definition at line 1216 of file OSDLEvents.cc.

References OSDL_EVENT_LOG.

Referenced by updateInputState().

void EventsModule::onMouseButtonReleased ( const MouseButtonEvent mouseEvent  )  throw () [protected, virtual]

Called whenever a mouse button is released.

Parameters:
mouseEvent the mouse button event.

Definition at line 1233 of file OSDLEvents.cc.

References OSDL_EVENT_LOG.

Referenced by updateInputState().

void EventsModule::onJoystickAxisChanged ( const JoystickAxisEvent joystickEvent  )  throw () [protected, virtual]

Called whenever the joystick axis changed.

Parameters:
joystickEvent the joystick axis event.
Note:
All opened joysticks can be updated.

Definition at line 1254 of file OSDLEvents.cc.

References OSDL_EVENT_LOG.

Referenced by updateInputState().

void EventsModule::onJoystickTrackballChanged ( const JoystickTrackballEvent joystickEvent  )  throw () [protected, virtual]

Called whenever the joystick trackball changed.

Parameters:
joystickEvent the joystick trackball event.
Note:
All opened joysticks can be updated.

Definition at line 1271 of file OSDLEvents.cc.

References OSDL_EVENT_LOG.

Referenced by updateInputState().

void EventsModule::onJoystickHatChanged ( const JoystickHatEvent joystickEvent  )  throw () [protected, virtual]

Called whenever the joystick hat changed.

Parameters:
joystickEvent the joystick hat event.
Note:
All opened joysticks can be updated.

Definition at line 1289 of file OSDLEvents.cc.

References OSDL_EVENT_LOG.

Referenced by updateInputState().

void EventsModule::onJoystickButtonPressed ( const JoystickButtonEvent joystickEvent  )  throw () [protected, virtual]

Called whenever the joystick button is pressed.

Parameters:
joystickEvent the joystick button event.
Note:
All opened joysticks can be updated.

Definition at line 1306 of file OSDLEvents.cc.

References OSDL_EVENT_LOG.

Referenced by updateInputState().

void EventsModule::onJoystickButtonReleased ( const JoystickButtonEvent joystickEvent  )  throw () [protected, virtual]

Called whenever the joystick button is released.

Parameters:
joystickEvent the joystick button event.
Note:
All opened joysticks can be updated.

Definition at line 1324 of file OSDLEvents.cc.

References OSDL_EVENT_LOG.

Referenced by updateInputState().

void EventsModule::onIdle (  )  throw () [protected, virtual]

Called whenever the application is deemed idle.

Applies the idle behaviour, which can be user-defined (setIdleCallback), or otherwise which will default to micro-sleeps.

See also:
setIdleCallback

Definition at line 1346 of file OSDLEvents.cc.

References _idleCallsCount, _loopIdleCallback, _loopIdleCallbackData, and OSDL_EVENT_LOG.

Referenced by enterBasicMainLoop().

void EventsModule::onApplicationFocusChanged ( const FocusEvent focusEvent  )  throw () [protected, virtual]

Called whenever at least one of the three focuses (mouse, keyboard or application visibility) changed.

Note:
Call specialized methods such as onMouseFocusGained to handle each case.

Definition at line 1377 of file OSDLEvents.cc.

References OSDL_EVENT_LOG.

Referenced by updateInputState().

void EventsModule::onApplicationIconified ( const FocusEvent focusEvent  )  throw () [protected, virtual]

Called whenever the application is iconified (minimized ).

Note:
Made to be overriden, basically just writes the event in the standard output.

Definition at line 1415 of file OSDLEvents.cc.

References OSDL_EVENT_LOG.

void EventsModule::onApplicationRestored ( const FocusEvent focusEvent  )  throw () [protected, virtual]

Called whenever the application is restored.

Note:
Made to be overriden, basically just writes the event in the standard output.

Definition at line 1425 of file OSDLEvents.cc.

References OSDL_EVENT_LOG.

void EventsModule::onQuitRequested (  )  throw () [protected, virtual]

Called whenever the application is requested to quit.

Definition at line 1435 of file OSDLEvents.cc.

References OSDL_EVENT_LOG, and requestQuit().

Referenced by updateInputState().

void EventsModule::onSystemSpecificWindowManagerEvent ( const SystemSpecificWindowManagerEvent wmEvent  )  throw () [protected, virtual]

Called whenever a system-specific window manager event is received.

These unhandled events are received from the window manager, and can be used, for example, to implement cut-and-paste in your application.

Definition at line 1445 of file OSDLEvents.cc.

References OSDL_EVENT_LOG.

Referenced by updateInputState().

void EventsModule::onResizedWindow ( const WindowResizedEvent resizeEvent  )  throw () [protected, virtual]

Called whenever the window is resized.

Only applications that have been specified as resizable in the setMode call can receive that event.

Note:
The window should be resized to the new dimensions using setMode.

Definition at line 1461 of file OSDLEvents.cc.

References OSDL::getExistingCommonModule(), OSDL::CommonModule::getVideoModule(), OSDL_EVENT_LOG, OSDL::Video::VideoModule::resize(), and OSDL::Video::Pixels::toString().

Referenced by updateInputState().

void EventsModule::onScreenNeedsRedraw (  )  throw () [protected, virtual]

Called whenever the screen has been modified outside of the application, usually by the window manager, and needs to be redrawn.

Definition at line 1486 of file OSDLEvents.cc.

References OSDL::getExistingCommonModule(), OSDL::CommonModule::getVideoModule(), OSDL_EVENT_LOG, and OSDL::Video::VideoModule::redraw().

Referenced by updateInputState().

void EventsModule::onUserEvent ( const UserEvent userEvent  )  throw () [protected, virtual]

Called whenever an user-defined event occurs.

Note:
Data is transmitted alongside this event.

Definition at line 1505 of file OSDLEvents.cc.

References OSDL_EVENT_LOG.

Referenced by updateInputState().

void EventsModule::onUnknownEventType ( const BasicEvent unknownEvent  )  throw () [protected, virtual]

Called whenever an unknown event type occurs during the input update phase.

Definition at line 1514 of file OSDLEvents.cc.

References OSDL_EVENT_LOG.

Referenced by updateInputState().

EventsModule& OSDL::Events::EventsModule::operator= ( const EventsModule 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::CommonModule [friend]

Definition at line 209 of file OSDLEvents.h.


Member Data Documentation

const BasicEventType EventsModule::ApplicationFocusChanged [static]

Identifies the event corresponding to application gaining or loosing focus(es).

Definition at line 642 of file OSDLEvents.h.

Referenced by updateInputState().

const BasicEventType EventsModule::KeyPressed [static]

Identifies the event corresponding to a key press.

Definition at line 645 of file OSDLEvents.h.

Referenced by DescribeEvent(), smarterKeyHandler(), and updateInputState().

const BasicEventType EventsModule::KeyReleased [static]

Identifies the event corresponding to a key release.

Definition at line 648 of file OSDLEvents.h.

Referenced by updateInputState().

const BasicEventType EventsModule::MouseMoved [static]

Identifies the event corresponding to a mouse motion.

Definition at line 651 of file OSDLEvents.h.

Referenced by updateInputState().

const BasicEventType EventsModule::MouseButtonPressed [static]

Identifies the event corresponding to a mouse button press.

Definition at line 654 of file OSDLEvents.h.

Referenced by updateInputState().

const BasicEventType EventsModule::MouseButtonReleased [static]

Identifies the event corresponding to a mouse button release.

Definition at line 662 of file OSDLEvents.h.

Referenced by updateInputState().

const BasicEventType EventsModule::JoystickAxisChanged [static]

Identifies the event corresponding to a joystick axis move.

Definition at line 666 of file OSDLEvents.h.

Referenced by updateInputState().

const BasicEventType EventsModule::JoystickTrackballChanged [static]

Identifies the event corresponding to a joystick trackball motion.

Definition at line 674 of file OSDLEvents.h.

Referenced by updateInputState().

const BasicEventType EventsModule::JoystickHatPositionChanged [static]

Identifies the event corresponding to a change of joystick hat position.

Definition at line 682 of file OSDLEvents.h.

Referenced by updateInputState().

const BasicEventType EventsModule::JoystickButtonPressed [static]

Identifies the event corresponding to a joystick button being pressed.

Definition at line 690 of file OSDLEvents.h.

Referenced by updateInputState().

const BasicEventType EventsModule::JoystickButtonReleased [static]

Identifies the event corresponding to a joystick button being released.

Definition at line 698 of file OSDLEvents.h.

Referenced by updateInputState().

const BasicEventType EventsModule::UserRequestedQuit [static]

Identifies the event corresponding to the user requesting to quit.

Definition at line 706 of file OSDLEvents.h.

Referenced by updateInputState().

const BasicEventType EventsModule::SystemSpecificTriggered [static]

Identifies the event corresponding to system specific event.

Definition at line 714 of file OSDLEvents.h.

Referenced by updateInputState().

const BasicEventType EventsModule::UserResizedVideoMode [static]

Identifies the event corresponding to a resize of user's video mode.

Definition at line 722 of file OSDLEvents.h.

Referenced by updateInputState().

const BasicEventType EventsModule::ScreenNeedsRedraw [static]

Identifies the event corresponding to a need to redraw screen.

Definition at line 730 of file OSDLEvents.h.

Referenced by updateInputState().

const BasicEventType EventsModule::FirstUserEventTriggered [static]

Identifies the first event that can be user-defined.

Definition at line 734 of file OSDLEvents.h.

Referenced by updateInputState().

const BasicEventType EventsModule::LastUserEventTriggered [static]

Identifies the last event that can be user-defined.

Definition at line 737 of file OSDLEvents.h.

Referenced by updateInputState().

const UserEventType EventsModule::NoEvent [static]

Void event, useful to return when no event should be generated.

Definition at line 747 of file OSDLEvents.h.

const UserEventType EventsModule::QuitRequested [static]

Identifies the user event corresponding to a quit request.

Definition at line 751 of file OSDLEvents.h.

const Hertz OSDL::Events::EventsModule::DefaultEventLoopTargetedFrequency = 100 [static]

The default frequency targeted by the basic event loop.

Definition at line 755 of file OSDLEvents.h.

bool OSDL::Events::EventsModule::_useScheduler [protected]

Tells whether a scheduler should be used.

Note:
By default, a basic event loop is used, instead of a full-blown scheduler.

Definition at line 1084 of file OSDLEvents.h.

Referenced by enterMainLoop(), and requestQuit().

KeyboardHandler* OSDL::Events::EventsModule::_keyboardHandler [protected]

The internal keyboard handler.

Definition at line 1091 of file OSDLEvents.h.

Referenced by getKeyboardHandler(), hasKeyboardHandler(), and ~EventsModule().

JoystickHandler* OSDL::Events::EventsModule::_joystickHandler [protected]

The internal joystick handler, if any.

Definition at line 1098 of file OSDLEvents.h.

Referenced by getJoystickHandler(), hasJoystickHandler(), and ~EventsModule().

MouseHandler* OSDL::Events::EventsModule::_mouseHandler [protected]

The internal mouse handler, if any.

Definition at line 1105 of file OSDLEvents.h.

Referenced by getMouseHandler(), hasMouseHandler(), and ~EventsModule().

string EventsModule::_SDLEnvironmentVariables [static, protected]

Array of all known environment variables related to events, for the SDL back-end.

Definition at line 1114 of file OSDLEvents.h.

Referenced by DescribeEnvironmentVariables().

bool OSDL::Events::EventsModule::_quitRequested [protected]

Tells whether the user asked to quit.

Definition at line 1118 of file OSDLEvents.h.

Referenced by enterBasicMainLoop(), and requestQuit().

Hertz OSDL::Events::EventsModule::_loopTargetedFrequency [protected]

The targeted frequency of the basic event loop.

The loop will try to enforce it. Should there be time left for an iteration, then the event loop will call the idle callback multiple times, until the next iteration is to occur.

If no idle callback is registered, then for each iteration with time left, the event loop will call the basic sleep mecanism, as provided by the operating system. This will be the smallest possible actual sleep duration, which is at least 1 millisecond with Linux 2.6 kernels.

Definition at line 1137 of file OSDLEvents.h.

Referenced by enterBasicMainLoop().

Ceylan::Uint32 OSDL::Events::EventsModule::_idleCallsCount [protected]

Count the number of idle calls made during the current event loop.

Definition at line 1145 of file OSDLEvents.h.

Referenced by enterBasicMainLoop(), and onIdle().

Ceylan::System::Callback OSDL::Events::EventsModule::_loopIdleCallback [protected]

The idle callback, if any, to be called by the basic event loop.

Definition at line 1153 of file OSDLEvents.h.

Referenced by enterBasicMainLoop(), and onIdle().

void* OSDL::Events::EventsModule::_loopIdleCallbackData [protected]

The data, if any, to provide to the idle callback, should the basic event loop be used.

Definition at line 1161 of file OSDLEvents.h.

Referenced by onIdle().

Ceylan::System::Microsecond OSDL::Events::EventsModule::_loopIdleCallbackMaxDuration [protected]

An estimated upper bound of the duration of current idle callback.

Helps the event loop to respect its expected pace.

Definition at line 1171 of file OSDLEvents.h.

Referenced by enterBasicMainLoop().

bool EventsModule::_EventsInitialized [static, protected]

Tells whether event system has already been initialized.

Definition at line 1179 of file OSDLEvents.h.

Referenced by IsEventsInitialized().

const Ceylan::Uint32 OSDL::Events::EventsModule::_FrameTimingSlotsCount [static, protected]

Number of available slots used to keep track of frame rate.

Definition at line 1183 of file OSDLEvents.h.

const Ceylan::Sint16 EventsModule::_MouseFocus [static, protected]

Designates the mouse focus.

Definition at line 1187 of file OSDLEvents.h.

Referenced by DescribeEvent().

const Ceylan::Sint16 EventsModule::_KeyboardFocus [static, protected]

Designates the keyboard focus.

Definition at line 1190 of file OSDLEvents.h.

Referenced by DescribeEvent().

const Ceylan::Sint16 EventsModule::_ApplicationFocus [static, protected]

Designates the application focus (iconified or restored).

Definition at line 1193 of file OSDLEvents.h.

Referenced by DescribeEvent().

const string EventsModule::_MessageHeader [static, protected]

Header of messages sent by default implementations (ex : onMouseFocusGained).

Definition at line 1201 of file OSDLEvents.h.

const Ceylan::Uint32 EventsModule::_MouseButtonCount [static, protected]

Records the total number of buttons supported for a mouse.

Definition at line 1208 of file OSDLEvents.h.

Referenced by DescribeEvent().


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