OSDL::Events::KeyboardHandler Class Reference

Handler for keyboard. More...

#include <OSDLKeyboardHandler.h>

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

List of all members.

Public Types

enum  KeyIdentifier {
  BackspaceKey = SDLK_BACKSPACE, TabKey = SDLK_TAB, ClearKey = SDLK_CLEAR, EnterKey = SDLK_RETURN,
  ReturnKey = SDLK_RETURN, PauseKey = SDLK_PAUSE, EscapeKey = SDLK_ESCAPE, SpaceKey = SDLK_SPACE,
  ExclaimKey = SDLK_EXCLAIM, QuotedBLKey = SDLK_QUOTEDBL, HashKey = SDLK_HASH, DollarKey = SDLK_DOLLAR,
  AmpersandKey = SDLK_AMPERSAND, QuoteKey = SDLK_QUOTE, LeftParenthesisKey = SDLK_LEFTPAREN, RightParenthesisKey = SDLK_RIGHTPAREN,
  AsteriskKey = SDLK_ASTERISK, PlusKey = SDLK_PLUS, CommaKey = SDLK_COMMA, MinusKey = SDLK_MINUS,
  PeriodKey = SDLK_PERIOD, SlashKey = SDLK_SLASH, ZeroKey = SDLK_0, OneKey = SDLK_1,
  TwoKey = SDLK_2, ThreeKey = SDLK_3, FourKey = SDLK_4, FiveKey = SDLK_5,
  SixKey = SDLK_6, SevenKey = SDLK_7, HeightKey = SDLK_8, NineKey = SDLK_9,
  ColonKey = SDLK_COLON, SemiColonKey = SDLK_SEMICOLON, LessKey = SDLK_LESS, EqualsKey = SDLK_EQUALS,
  GreaterKey = SDLK_GREATER, QuestionKey = SDLK_QUESTION, AtKey = SDLK_AT, LeftBracketKey = SDLK_LEFTBRACKET,
  RightBracket = SDLK_RIGHTBRACKET, BackslashKey = SDLK_BACKSLASH, Caret = SDLK_CARET, Underscore = SDLK_UNDERSCORE,
  BackQuote = SDLK_BACKQUOTE, aKey = SDLK_a, bKey = SDLK_b, cKey = SDLK_c,
  dKey = SDLK_d, eKey = SDLK_e, fKey = SDLK_f, gKey = SDLK_g,
  hKey = SDLK_h, iKey = SDLK_i, jKey = SDLK_j, kKey = SDLK_k,
  lKey = SDLK_l, mKey = SDLK_m, nKey = SDLK_n, oKey = SDLK_o,
  pKey = SDLK_p, qKey = SDLK_q, rKey = SDLK_r, sKey = SDLK_s,
  tKey = SDLK_t, uKey = SDLK_u, vKey = SDLK_v, wKey = SDLK_w,
  xKey = SDLK_x, yKey = SDLK_y, zKey = SDLK_z, DeleteKey = SDLK_DELETE,
  International0Key = SDLK_WORLD_0, International1Key = SDLK_WORLD_1, International2Key = SDLK_WORLD_2, International3Key = SDLK_WORLD_3,
  International4Key = SDLK_WORLD_4, International5Key = SDLK_WORLD_5, International6Key = SDLK_WORLD_6, International7Key = SDLK_WORLD_7,
  International8Key = SDLK_WORLD_8, International9Key = SDLK_WORLD_9, International10Key = SDLK_WORLD_10, International11Key = SDLK_WORLD_11,
  International12Key = SDLK_WORLD_12, International13Key = SDLK_WORLD_13, International14Key = SDLK_WORLD_14, International15Key = SDLK_WORLD_15,
  International16Key = SDLK_WORLD_16, International17Key = SDLK_WORLD_17, International18Key = SDLK_WORLD_18, International19Key = SDLK_WORLD_19,
  International20Key = SDLK_WORLD_20, International21Key = SDLK_WORLD_21, International22Key = SDLK_WORLD_22, International23Key = SDLK_WORLD_23,
  International24Key = SDLK_WORLD_24, International25Key = SDLK_WORLD_25, International26Key = SDLK_WORLD_26, International27Key = SDLK_WORLD_27,
  International28Key = SDLK_WORLD_28, International29Key = SDLK_WORLD_29, International30Key = SDLK_WORLD_30, International31Key = SDLK_WORLD_31,
  International32Key = SDLK_WORLD_32, International33Key = SDLK_WORLD_33, International34Key = SDLK_WORLD_34, International35Key = SDLK_WORLD_35,
  International36Key = SDLK_WORLD_36, International37Key = SDLK_WORLD_37, International38Key = SDLK_WORLD_38, International39Key = SDLK_WORLD_39,
  International40Key = SDLK_WORLD_40, International41Key = SDLK_WORLD_41, International42Key = SDLK_WORLD_42, International43Key = SDLK_WORLD_43,
  International44Key = SDLK_WORLD_44, International45Key = SDLK_WORLD_45, International46Key = SDLK_WORLD_46, International47Key = SDLK_WORLD_47,
  International48Key = SDLK_WORLD_48, International49Key = SDLK_WORLD_49, International50Key = SDLK_WORLD_50, International51Key = SDLK_WORLD_51,
  International52Key = SDLK_WORLD_52, International53Key = SDLK_WORLD_53, International54Key = SDLK_WORLD_54, International55Key = SDLK_WORLD_55,
  International56Key = SDLK_WORLD_56, International57Key = SDLK_WORLD_57, International58Key = SDLK_WORLD_58, International59Key = SDLK_WORLD_59,
  International60Key = SDLK_WORLD_60, International61Key = SDLK_WORLD_61, International62Key = SDLK_WORLD_62, International63Key = SDLK_WORLD_63,
  International64Key = SDLK_WORLD_64, International65Key = SDLK_WORLD_65, International66Key = SDLK_WORLD_66, International67Key = SDLK_WORLD_67,
  International68Key = SDLK_WORLD_68, International69Key = SDLK_WORLD_69, International70Key = SDLK_WORLD_70, International71Key = SDLK_WORLD_71,
  International72Key = SDLK_WORLD_72, International73Key = SDLK_WORLD_73, International74Key = SDLK_WORLD_74, International75Key = SDLK_WORLD_75,
  International76Key = SDLK_WORLD_76, International77Key = SDLK_WORLD_77, International78Key = SDLK_WORLD_78, International79Key = SDLK_WORLD_79,
  International80Key = SDLK_WORLD_80, International81Key = SDLK_WORLD_81, International82Key = SDLK_WORLD_82, International83Key = SDLK_WORLD_83,
  International84Key = SDLK_WORLD_84, International85Key = SDLK_WORLD_85, International86Key = SDLK_WORLD_86, International87Key = SDLK_WORLD_87,
  International88Key = SDLK_WORLD_88, International89Key = SDLK_WORLD_89, International90Key = SDLK_WORLD_90, International91Key = SDLK_WORLD_91,
  International92Key = SDLK_WORLD_92, International93Key = SDLK_WORLD_93, International94Key = SDLK_WORLD_94, International95Key = SDLK_WORLD_95,
  ZeroKeypadKey = SDLK_KP0, OneKeypadKey = SDLK_KP1, TwoKeypadKey = SDLK_KP2, ThreeKeypadKey = SDLK_KP3,
  FourKeypadKey = SDLK_KP4, FiveKeypadKey = SDLK_KP5, SixKeypadKey = SDLK_KP6, SevenKeypadKey = SDLK_KP7,
  HeightKeypadKey = SDLK_KP8, NineKeypadKey = SDLK_KP9, PeriodKeypadKey = SDLK_KP_PERIOD, DivideKeypadKey = SDLK_KP_DIVIDE,
  MultiplyKeypadKey = SDLK_KP_MULTIPLY, MinusKeypadKey = SDLK_KP_MINUS, PlusKeypadKey = SDLK_KP_PLUS, EnterKeypadKey = SDLK_KP_ENTER,
  EqualsKeypadKey = SDLK_KP_EQUALS, UpArrowKey = SDLK_UP, DownArrowKey = SDLK_DOWN, LeftArrowKey = SDLK_LEFT,
  RightArrowKey = SDLK_RIGHT, InsertKey = SDLK_INSERT, HomeKey = SDLK_HOME, EndKey = SDLK_END,
  PageUpKey = SDLK_PAGEUP, PageDownKey = SDLK_PAGEDOWN, F1Key = SDLK_F1, F2Key = SDLK_F2,
  F3Key = SDLK_F3, F4Key = SDLK_F4, F5Key = SDLK_F5, F6Key = SDLK_F6,
  F7Key = SDLK_F7, F8Key = SDLK_F8, F9Key = SDLK_F9, F10Key = SDLK_F10,
  F11Key = SDLK_F11, F12Key = SDLK_F12, F13Key = SDLK_F13, F14Key = SDLK_F14,
  F15Key = SDLK_F15, NumLockKey = SDLK_NUMLOCK, CapsLockKey = SDLK_CAPSLOCK, ScrolLockKey = SDLK_SCROLLOCK,
  LeftShiftKey = SDLK_LSHIFT, RightShiftKey = SDLK_RSHIFT, LeftControlKey = SDLK_LCTRL, RightControlKey = SDLK_RCTRL,
  LeftAltKey = SDLK_LALT, RightAltKey = SDLK_RALT, LeftMetaKey = SDLK_LMETA, RightMetaKey = SDLK_RMETA,
  LeftSuperKey = SDLK_LSUPER, RightSuperKey = SDLK_RSUPER, ModeKey = SDLK_MODE, ComposeKey = SDLK_COMPOSE,
  HelpKey = SDLK_HELP, PrintKey = SDLK_PRINT, SysReqKey = SDLK_SYSREQ, BreakKey = SDLK_BREAK,
  MenuKey = SDLK_MENU, PowerKey = SDLK_POWER, EuroKey = SDLK_EURO, UndoKey = SDLK_UNDO
}
 

List of all currently available key identifiers: allows to identify a keyboard key being pressed or released.

More...
enum  KeyModifier {
  NoneModifier = KMOD_NONE, LeftShiftModifier = KMOD_LSHIFT, RightShiftModifier = KMOD_RSHIFT, LeftControlModifier = KMOD_LCTRL,
  RightControlModifier = KMOD_RCTRL, LeftAltModifier = KMOD_LALT, RightAltModifier = KMOD_RALT, LeftMetaModifier = KMOD_LMETA,
  RightMetaModifier = KMOD_RMETA, NumModifier = KMOD_NUM, CapsModifier = KMOD_CAPS, ModeModifier = KMOD_MODE,
  ReservedModifier = KMOD_RESERVED, ShiftModifier, ControlModifier, AltModifier,
  MetaModifier
}

Public Member Functions

 KeyboardHandler (KeyboardMode initialMode=rawInput, bool useSmarterDefaultKeyHandler=false)
 Constructs a new keyboard handler.
virtual ~KeyboardHandler () throw ()
 Virtual destructor.
virtual void linkToController (KeyIdentifier rawKey, OSDL::MVC::Controller &controller)
 Links the specified raw key to specified controller, so that any further key press or release of this raw key will be sent to the controller, if the keyboard is in raw input mode.
virtual void unlinkFromController (KeyIdentifier rawKey, OSDL::MVC::Controller &controller)
 Unlinks the specified controller from the specified raw key.
virtual void linkToController (Ceylan::Unicode unicode, OSDL::MVC::Controller &controller)
 Links the specified Unicode to specified controller, so that any further selection of this Unicode will be sent to the controller, if the keyboard is in text input mode.
virtual void linkToFocusController (OSDL::MVC::Controller &controller)
 Links this keyboard hander to specified focus-tracking controller, so that any further change to the keyboard focus will be notified to the controller.
virtual void linkToHandler (KeyIdentifier rawKey, KeyboardEventHandler handler)
 Links the specified raw key to specified keyboard event handler, so that if no controller is linked to this raw key, the keyboard event handler is triggered.
virtual void linkToHandler (Ceylan::Unicode unicode, KeyboardEventHandler handler)
 Links the specified Unicode to specified keyboard event handler, so that if no controller is linked to this Unicode, the keyboard event handler is triggered.
virtual void setSmarterDefaultKeyHandlers ()
 Sets the default key handlers to the smarter handlers.
virtual void linkDefaultRawKeyController (OSDL::MVC::Controller &newDefaultController)
 Links a new default controller for raw key events.
virtual bool unlinkDefaultRawKeyController ()
 Unlinks current default controller for raw key events.
virtual void setDefaultRawKeyHandler (KeyboardEventHandler newHandler)
 Sets a new default handler for raw key events.
virtual void setDefaultUnicodeHandler (KeyboardEventHandler newHandler)
 Sets a new default handler for Unicode events.
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 KeyboardMode GetMode ()
 Returns the current keyboard mode.
static void SetMode (KeyboardMode newMode)
 Sets the current keyboard mode.
static std::string DescribeKey (KeyIdentifier key)
 Describes specified key.
static std::string DescribeModifier (KeyModifier modifier)
 Describes specified key modifier.
static std::string DescribeUnicode (Ceylan::Unicode value)
 Describes specified Unicode value.

Static Public Attributes

static const
Ceylan::System::Millisecond 
DefaultDelayBeforeKeyRepeat = 500
 Specifies how long by default a key must be pressed before it begins repeating, in milliseconds.
static const
Ceylan::System::Millisecond 
DefaulKeyRepeatInterval = 30
 Specifies how many milliseconds by default should be waited until two repeated keys: once a key is hold long enough to repeat, this will be the time between two repeats of this key.

Protected Member Functions

virtual void focusGained (const FocusEvent &keyboardFocusEvent)
 Called whenever this keyboard gained focus, so that its controller, if any, is notified.
virtual void focusLost (const FocusEvent &keyboardFocusEvent)
 Called whenever this keyboard lost focus, so that its controller, if any, is notified.
virtual void keyPressed (const KeyboardEvent &keyboardEvent)
 Called whenever a key was pressed, so that its controller, if any, is notified.
virtual void keyReleased (const KeyboardEvent &keyboardEvent)
 Called whenever a key was released, so that its controller, if any, is notified.

Protected Attributes

std::map< KeyIdentifier,
OSDL::MVC::Controller * > 
_rawKeyControllerMap
 Allows to link a controller to a specific keyboard raw key, when in raw input mode.
std::map< KeyIdentifier,
KeyboardEventHandler
_rawKeyHandlerMap
 Fall-back map used whenever a raw key was pressed or released without being registered in the map making raw keys correspond to controllers: it may then be linked to a specific keyboard event handler.
std::map< Ceylan::Unicode,
OSDL::MVC::Controller * > 
_unicodeControllerMap
 Allows to link a controller to a specific Unicode, when in text input mode.
std::map< Ceylan::Unicode,
KeyboardEventHandler
_unicodeHandlerMap
 Fall-back map used whenever a Unicode was selected by the user without being registered in the map making Unicodes correspond to controllers: it may then be linked to a specific keyboard event handler.
OSDL::MVC::Controller_defaultRawKeyController
 The default raw key controller, if any.
KeyboardEventHandler _defaultRawKeyHandler
 Default raw key event handler, does nothing, but can log keyboard events.
KeyboardEventHandler _defaultUnicodeHandler
 Default Unicode event handler, does nothing, but can log keyboard events.
OSDL::MVC::Controller_focusController
 The controller that will receive focus changes.
bool _unicodeInputWasActivated
 Records the status of Unicode input before this handler was created, so that it can be restored.

Static Protected Attributes

static KeyboardMode _CurrentMode = rawInput
 Stores the current keyboard interacting scheme.

Private Member Functions

 KeyboardHandler (const KeyboardHandler &source)
 Copy constructor made private to ensure that it will never be called.
KeyboardHandleroperator= (const KeyboardHandler &source)
 Assignment operator made private to ensure that it will never be called.

Friends

class OSDL::Events::EventsModule

Detailed Description

Handler for keyboard.

Keyboard inputs are managed according to the current keyboard mode (example: raw input, text input with unicode support, etc.).

In raw mode, a key can be specifically managed by a controller, otherwise by an specific handler, otherwise by a default controller, otherwise by a default handler.

Definition at line 147 of file OSDLKeyboardHandler.h.


Member Enumeration Documentation

List of all currently available key identifiers: allows to identify a keyboard key being pressed or released.

First column lists the key identifiers which are to be used in user applications, second one maps them to the keys defined by the SDL back-end, and third describes the corresponding key.

The source of the complete list is the SDL back-end (SDL_keysym.h).

See also:
also generic/CeylanUtils.h for the Nintendo keys, they have been duplicated here for a simpler use of OSDL.
Enumerator:
BackspaceKey 
TabKey 
ClearKey 
EnterKey 
ReturnKey 
PauseKey 
EscapeKey 
SpaceKey 
ExclaimKey 
QuotedBLKey 
HashKey 
DollarKey 
AmpersandKey 
QuoteKey 
LeftParenthesisKey 
RightParenthesisKey 
AsteriskKey 
PlusKey 
CommaKey 
MinusKey 
PeriodKey 
SlashKey 
ZeroKey 
OneKey 
TwoKey 
ThreeKey 
FourKey 
FiveKey 
SixKey 
SevenKey 
HeightKey 
NineKey 
ColonKey 
SemiColonKey 
LessKey 
EqualsKey 
GreaterKey 
QuestionKey 
AtKey 
LeftBracketKey 
RightBracket 
BackslashKey 
Caret 
Underscore 
BackQuote 
aKey 
bKey 
cKey 
dKey 
eKey 
fKey 
gKey 
hKey 
iKey 
jKey 
kKey 
lKey 
mKey 
nKey 
oKey 
pKey 
qKey 
rKey 
sKey 
tKey 
uKey 
vKey 
wKey 
xKey 
yKey 
zKey 
DeleteKey 
International0Key 
International1Key 
International2Key 
International3Key 
International4Key 
International5Key 
International6Key 
International7Key 
International8Key 
International9Key 
International10Key 
International11Key 
International12Key 
International13Key 
International14Key 
International15Key 
International16Key 
International17Key 
International18Key 
International19Key 
International20Key 
International21Key 
International22Key 
International23Key 
International24Key 
International25Key 
International26Key 
International27Key 
International28Key 
International29Key 
International30Key 
International31Key 
International32Key 
International33Key 
International34Key 
International35Key 
International36Key 
International37Key 
International38Key 
International39Key 
International40Key 
International41Key 
International42Key 
International43Key 
International44Key 
International45Key 
International46Key 
International47Key 
International48Key 
International49Key 
International50Key 
International51Key 
International52Key 
International53Key 
International54Key 
International55Key 
International56Key 
International57Key 
International58Key 
International59Key 
International60Key 
International61Key 
International62Key 
International63Key 
International64Key 
International65Key 
International66Key 
International67Key 
International68Key 
International69Key 
International70Key 
International71Key 
International72Key 
International73Key 
International74Key 
International75Key 
International76Key 
International77Key 
International78Key 
International79Key 
International80Key 
International81Key 
International82Key 
International83Key 
International84Key 
International85Key 
International86Key 
International87Key 
International88Key 
International89Key 
International90Key 
International91Key 
International92Key 
International93Key 
International94Key 
International95Key 
ZeroKeypadKey 
OneKeypadKey 
TwoKeypadKey 
ThreeKeypadKey 
FourKeypadKey 
FiveKeypadKey 
SixKeypadKey 
SevenKeypadKey 
HeightKeypadKey 
NineKeypadKey 
PeriodKeypadKey 
DivideKeypadKey 
MultiplyKeypadKey 
MinusKeypadKey 
PlusKeypadKey 
EnterKeypadKey 
EqualsKeypadKey 
UpArrowKey 
DownArrowKey 
LeftArrowKey 
RightArrowKey 
InsertKey 
HomeKey 
EndKey 
PageUpKey 
PageDownKey 
F1Key 
F2Key 
F3Key 
F4Key 
F5Key 
F6Key 
F7Key 
F8Key 
F9Key 
F10Key 
F11Key 
F12Key 
F13Key 
F14Key 
F15Key 
NumLockKey 
CapsLockKey 
ScrolLockKey 
LeftShiftKey 
RightShiftKey 
LeftControlKey 
RightControlKey 
LeftAltKey 
RightAltKey 
LeftMetaKey 
RightMetaKey 
LeftSuperKey 
RightSuperKey 
ModeKey 
ComposeKey 
HelpKey 
PrintKey 
SysReqKey 
BreakKey 
MenuKey 
PowerKey 
EuroKey 
UndoKey 

Definition at line 180 of file OSDLKeyboardHandler.h.

Enumerator:
NoneModifier 
LeftShiftModifier 
RightShiftModifier 
LeftControlModifier 
RightControlModifier 
LeftAltModifier 
RightAltModifier 
LeftMetaModifier 
RightMetaModifier 
NumModifier 
CapsModifier 
ModeModifier 
ReservedModifier 
ShiftModifier 
ControlModifier 
AltModifier 
MetaModifier 

Definition at line 543 of file OSDLKeyboardHandler.h.


Constructor & Destructor Documentation

KeyboardHandler::KeyboardHandler ( KeyboardMode  initialMode = rawInput,
bool  useSmarterDefaultKeyHandler = false 
) [explicit]

Constructs a new keyboard handler.

Parameters:
initialMode the mode in which this keyboard will start.
useSmarterDefaultKeyHandler if true, a key handler that will exit the event loop if escape or 'q' is pressed, will be used. Otherwise, a do-nothing key handler will be used.
Note:
The keyboard mode is shared between all keyboard handlers.
Exceptions:
InputDeviceHandlerException if keyboard could not be initialized.

Definition at line 201 of file OSDLKeyboardHandler.cc.

References _defaultRawKeyHandler, _defaultUnicodeHandler, _unicodeInputWasActivated, doNothingKeyHandler(), SetMode(), and setSmarterDefaultKeyHandlers().

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

Virtual destructor.

Definition at line 252 of file OSDLKeyboardHandler.cc.

References _defaultRawKeyController, and _unicodeInputWasActivated.

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

string KeyboardHandler::DescribeKey ( KeyIdentifier  key  )  [static]

Describes specified key.

Parameters:
key the key to describe.

Definition at line 498 of file OSDLKeyboardHandler.cc.

References BackspaceKey, ClearKey, DeleteKey, EnterKey, EscapeKey, PauseKey, SpaceKey, TabKey, and toString().

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

string KeyboardHandler::DescribeModifier ( KeyModifier  modifier  )  [static]

Describes specified key modifier.

Parameters:
modifier the modifier to describe (alt, control, meta, etc.).

Definition at line 562 of file OSDLKeyboardHandler.cc.

References CapsModifier, LeftAltModifier, LeftControlModifier, LeftMetaModifier, LeftShiftModifier, ModeModifier, NumModifier, ReservedModifier, RightAltModifier, RightControlModifier, RightMetaModifier, and RightShiftModifier.

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

string KeyboardHandler::DescribeUnicode ( Ceylan::Unicode  value  )  [static]

Describes specified Unicode value.

Parameters:
value the Unicode value to describe.

Definition at line 620 of file OSDLKeyboardHandler.cc.

References toString().

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

void KeyboardHandler::focusGained ( const FocusEvent keyboardFocusEvent  )  [protected, virtual]

Called whenever this keyboard gained focus, so that its controller, if any, is notified.

Note:
Expected to be triggered by the EventsModule.

Definition at line 639 of file OSDLKeyboardHandler.cc.

References _focusController, and OSDL::MVC::Controller::keyboardFocusGained().

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

void KeyboardHandler::focusLost ( const FocusEvent keyboardFocusEvent  )  [protected, virtual]

Called whenever this keyboard lost focus, so that its controller, if any, is notified.

Note:
Expected to be triggered by the EventsModule.

Definition at line 649 of file OSDLKeyboardHandler.cc.

References _focusController, and OSDL::MVC::Controller::keyboardFocusLost().

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

KeyboardMode KeyboardHandler::GetMode (  )  [static]

Returns the current keyboard mode.

The keyboard at startup is in raw input mode.

Returns:
KeyboardMode the current keyboard mode.
Note:
This belongs to overall common settings, it has therefore to be static.

Definition at line 451 of file OSDLKeyboardHandler.cc.

References _CurrentMode.

Referenced by OSDL::Events::EventsModule::DescribeEvent(), and smarterKeyHandler().

void KeyboardHandler::keyPressed ( const KeyboardEvent keyboardEvent  )  [protected, virtual]

Called whenever a key was pressed, so that its controller, if any, is notified.

If no controller is registered for this key, then:

  • if a key handler is registered for this key, it will be called
  • otherwise (no handler for this key is found), then the default key handler will be called.
Note:
The actions taken depend on the current input mode.
Expected to be triggered by the EventsModule.

Definition at line 659 of file OSDLKeyboardHandler.cc.

References _CurrentMode, _defaultRawKeyController, _defaultRawKeyHandler, _defaultUnicodeHandler, _rawKeyControllerMap, _rawKeyHandlerMap, _unicodeControllerMap, _unicodeHandlerMap, OSDL_KEYBOARD_HANDLER_LOG, OSDL::Events::rawInput, OSDL::MVC::Controller::rawKeyPressed(), and OSDL::Events::textInput.

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

void KeyboardHandler::keyReleased ( const KeyboardEvent keyboardEvent  )  [protected, virtual]

Called whenever a key was released, so that its controller, if any, is notified.

If no controller is registered for this key, then:

  • if a key handler is registered for this key, it will be called.
  • otherwise (no handler for this key is found), then the default key handler will be called.
Note:
The actions taken depend on the current input mode.
Expected to be triggered by the EventsModule.

Definition at line 799 of file OSDLKeyboardHandler.cc.

References _CurrentMode, _defaultRawKeyHandler, _rawKeyControllerMap, _rawKeyHandlerMap, OSDL_KEYBOARD_HANDLER_LOG, and OSDL::Events::rawInput.

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

void KeyboardHandler::linkDefaultRawKeyController ( OSDL::MVC::Controller newDefaultController  )  [virtual]

Links a new default controller for raw key events.

Parameters:
newDefaultController the new default controller, whose ownership is not taken.

Any preexisting default controller will be forgotten (but not deleted) first.

Definition at line 373 of file OSDLKeyboardHandler.cc.

References _defaultRawKeyController.

void KeyboardHandler::linkToController ( Ceylan::Unicode  unicode,
OSDL::MVC::Controller controller 
) [virtual]

Links the specified Unicode to specified controller, so that any further selection of this Unicode will be sent to the controller, if the keyboard is in text input mode.

Removes automatically any link previously defined between this Unicode and any other controller.

Parameters:
unicode the Unicode that shall be linked to the controller.
controller the OSDL controller which will be notified of this Unicode being selected.
Note:
Ownership of the controller is not taken.

Definition at line 322 of file OSDLKeyboardHandler.cc.

References _unicodeControllerMap.

void KeyboardHandler::linkToController ( KeyIdentifier  rawKey,
OSDL::MVC::Controller controller 
) [virtual]

Links the specified raw key to specified controller, so that any further key press or release of this raw key will be sent to the controller, if the keyboard is in raw input mode.

Removes automatically any link previously defined between this raw key and any other controller.

Parameters:
rawKey the identifier of the raw key that shall be linked to the controller.
controller the OSDL controller which will be notified of this raw key presses and releases.
Note:
Ownership of the controller is not taken.

Definition at line 278 of file OSDLKeyboardHandler.cc.

References _rawKeyControllerMap.

void KeyboardHandler::linkToFocusController ( OSDL::MVC::Controller controller  )  [virtual]

Links this keyboard hander to specified focus-tracking controller, so that any further change to the keyboard focus will be notified to the controller.

Removes automatically any link previously defined between this Unicode and any other controller.

Parameters:
controller the OSDL controller which will be notified of the focus change.
Note:
Ownership of the controller is not taken.

Definition at line 332 of file OSDLKeyboardHandler.cc.

References _focusController.

void KeyboardHandler::linkToHandler ( Ceylan::Unicode  unicode,
KeyboardEventHandler  handler 
) [virtual]

Links the specified Unicode to specified keyboard event handler, so that if no controller is linked to this Unicode, the keyboard event handler is triggered.

Parameters:
unicode the Unicode to link with the keyboard event handler.
handler the handler that will received the Unicode event, in the lack of linked controller.

Definition at line 352 of file OSDLKeyboardHandler.cc.

References _unicodeHandlerMap.

void KeyboardHandler::linkToHandler ( KeyIdentifier  rawKey,
KeyboardEventHandler  handler 
) [virtual]

Links the specified raw key to specified keyboard event handler, so that if no controller is linked to this raw key, the keyboard event handler is triggered.

Parameters:
rawKey the raw key to link with the keyboard event handler.
handler the handler that will received the raw key event, in the lack of linked controller.

Definition at line 342 of file OSDLKeyboardHandler.cc.

References _rawKeyHandlerMap.

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

void KeyboardHandler::setDefaultRawKeyHandler ( KeyboardEventHandler  newHandler  )  [virtual]

Sets a new default handler for raw key events.

Parameters:
newHandler the new handler

Definition at line 401 of file OSDLKeyboardHandler.cc.

References _defaultRawKeyHandler.

void KeyboardHandler::setDefaultUnicodeHandler ( KeyboardEventHandler  newHandler  )  [virtual]

Sets a new default handler for Unicode events.

Parameters:
newHandler the new handler

Definition at line 411 of file OSDLKeyboardHandler.cc.

References _defaultUnicodeHandler.

void KeyboardHandler::SetMode ( KeyboardMode  newMode  )  [static]

Sets the current keyboard mode.

Parameters:
newMode the new keyboard mode.
Note:
This belongs to overall common settings, it has therefore to be static.

Definition at line 460 of file OSDLKeyboardHandler.cc.

References _CurrentMode, DefaulKeyRepeatInterval, DefaultDelayBeforeKeyRepeat, OSDL_KEYBOARD_HANDLER_LOG, OSDL::Events::rawInput, OSDL::Events::textInput, and OSDL::Video::Pixels::toString().

Referenced by KeyboardHandler(), and smarterKeyHandler().

void KeyboardHandler::setSmarterDefaultKeyHandlers (  )  [virtual]

Sets the default key handlers to the smarter handlers.

These handlers allow to trigger an exit from the event loop if escape or 'q' key is pressed, both for raw and input modes.

The 'F1' key is used to toggle between raw input and text input keyboard modes.

Definition at line 362 of file OSDLKeyboardHandler.cc.

References _defaultRawKeyHandler, _defaultUnicodeHandler, and smarterKeyHandler().

Referenced by KeyboardHandler().

const string KeyboardHandler::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 421 of file OSDLKeyboardHandler.cc.

References _CurrentMode, OSDL::Events::rawInput, and OSDL::Events::textInput.

Referenced by DescribeKey(), DescribeUnicode(), and OSDL::Events::EventsModule::toString().

bool KeyboardHandler::unlinkDefaultRawKeyController (  )  [virtual]

Unlinks current default controller for raw key events.

Returns:
true iff there was a controller to unlink.

Definition at line 383 of file OSDLKeyboardHandler.cc.

References _defaultRawKeyController.

void KeyboardHandler::unlinkFromController ( KeyIdentifier  rawKey,
OSDL::MVC::Controller controller 
) [virtual]

Unlinks the specified controller from the specified raw key.

Parameters:
rawKey the identifier of the raw key that shall be unlinked from the controller.
controller the OSDL controller to unlink from that key.

Definition at line 288 of file OSDLKeyboardHandler.cc.

References _rawKeyControllerMap, and OSDL_KEYBOARD_HANDLER_LOG.


Friends And Related Function Documentation

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

Definition at line 156 of file OSDLKeyboardHandler.h.


Member Data Documentation

KeyboardMode KeyboardHandler::_CurrentMode = rawInput [static, protected]

Stores the current keyboard interacting scheme.

Definition at line 973 of file OSDLKeyboardHandler.h.

Referenced by GetMode(), keyPressed(), keyReleased(), SetMode(), and toString().

The default raw key controller, if any.

Definition at line 1078 of file OSDLKeyboardHandler.h.

Referenced by keyPressed(), linkDefaultRawKeyController(), unlinkDefaultRawKeyController(), and ~KeyboardHandler().

Default raw key event handler, does nothing, but can log keyboard events.

Note:
It is only used when in raw input mode.

Definition at line 1089 of file OSDLKeyboardHandler.h.

Referenced by KeyboardHandler(), keyPressed(), keyReleased(), setDefaultRawKeyHandler(), and setSmarterDefaultKeyHandlers().

Default Unicode event handler, does nothing, but can log keyboard events.

Note:
It is only used when in text input mode.

Definition at line 1100 of file OSDLKeyboardHandler.h.

Referenced by KeyboardHandler(), keyPressed(), setDefaultUnicodeHandler(), and setSmarterDefaultKeyHandlers().

The controller that will receive focus changes.

No controller is owned by this handler.

Definition at line 1110 of file OSDLKeyboardHandler.h.

Referenced by focusGained(), focusLost(), and linkToFocusController().

Allows to link a controller to a specific keyboard raw key, when in raw input mode.

The controller can be then notified than one of its tracked keys has been pressed or released.

Note:
This is used only in raw input mode.

Definition at line 998 of file OSDLKeyboardHandler.h.

Referenced by keyPressed(), keyReleased(), linkToController(), and unlinkFromController().

Fall-back map used whenever a raw key was pressed or released without being registered in the map making raw keys correspond to controllers: it may then be linked to a specific keyboard event handler.

When a key has been pressed or released, but no controller was linked to it, this key is sent to this default key dictionnary which manages external settings not linked with MVC-based simulation world.

For example, an application could decide to quit when the so-defined 'q' key is pressed, which obviously should not rely on the controller MVC framework.

Note:
This is used only in raw input mode.

Definition at line 1021 of file OSDLKeyboardHandler.h.

Referenced by keyPressed(), keyReleased(), and linkToHandler().

Allows to link a controller to a specific Unicode, when in text input mode.

The controller can be then notified than one of its tracked unicodes has been selected by the user.

Note:
This is used only in text input mode. Linked controllers will only be notified in this mode of key presses and repeats (not of key releases which are not relevant in this context).

Definition at line 1039 of file OSDLKeyboardHandler.h.

Referenced by keyPressed(), and linkToController().

Fall-back map used whenever a Unicode was selected by the user without being registered in the map making Unicodes correspond to controllers: it may then be linked to a specific keyboard event handler.

When a Unicode is selected, but no controller was linked to it, this Unicode is sent to this default Unicode dictionnary which manages external settings not linked with the MVC-based simulation world.

For example, an application could decide to quit when the 'q' Unicode is selected, which obviously should not rely on the controller MVC framework.

Note:
This is used only in text input mode. Linked event handlers will only be notified in this mode of key presses and repeats (not of key releases which are not relevant in this context).

Definition at line 1065 of file OSDLKeyboardHandler.h.

Referenced by keyPressed(), and linkToHandler().

Records the status of Unicode input before this handler was created, so that it can be restored.

Definition at line 1119 of file OSDLKeyboardHandler.h.

Referenced by KeyboardHandler(), and ~KeyboardHandler().

const Ceylan::System::Millisecond KeyboardHandler::DefaulKeyRepeatInterval = 30 [static]

Specifies how many milliseconds by default should be waited until two repeated keys: once a key is hold long enough to repeat, this will be the time between two repeats of this key.

Definition at line 900 of file OSDLKeyboardHandler.h.

Referenced by SetMode().

const Ceylan::System::Millisecond KeyboardHandler::DefaultDelayBeforeKeyRepeat = 500 [static]

Specifies how long by default a key must be pressed before it begins repeating, in milliseconds.

Definition at line 888 of file OSDLKeyboardHandler.h.

Referenced by SetMode().


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