blip  0.1
KeyEvent Class Reference

A keyboard input event. More...

#include <KeyEvent.hpp>

Inheritance diagram for KeyEvent:

Public Types

enum  Action { Action_Unknown = -1, Action_KeyDown = 0, Action_KeyUp, Action_Multiple }
 Keypress actions. More...
 
enum  KeyCode {
  K_Unknown = 0, K_SoftLeft, K_SoftRight, K_Home,
  K_Back, K_Call, K_EndCall, K_0,
  K_1, K_2, K_3, K_4,
  K_5, K_6, K_7, K_8,
  K_9, K_Star, K_Pound, K_DPadUp,
  K_DPadDown, K_DPadLeft, K_DPadRight, K_DPad_Center,
  K_VolumeUp, K_VolumeDown, K_Power, K_Camera,
  K_Clear, K_A, K_B, K_C,
  K_D, K_E, K_F, K_G,
  K_H, K_I, K_J, K_K,
  K_L, K_M, K_N, K_O,
  K_P, K_Q, K_R, K_S,
  K_T, K_U, K_V, K_W,
  K_X, K_Y, K_Z, K_Comma,
  K_Period, K_AltLeft, K_AltRight, K_ShiftLeft,
  K_ShiftRight, K_Tab, K_Space, K_Sym,
  K_Explorer, K_Envelope, K_Enter, K_Delete,
  K_Grave, K_Minus, K_Equals, K_LeftBracket,
  K_RightBracket, K_Backslash, K_Semicolon, K_Apostrophe,
  K_Slash, K_At, K_Num, K_HeadsetHook,
  K_Focus, K_Plus, K_Menu, K_Notification,
  K_Search, K_MediaPlayPause, K_MediaStop, K_MediaNext,
  K_MediaPrevious, K_MediaRewind, K_MediaFastForward, K_Mute,
  K_PageUp, K_PageDown, K_PictSymbols, K_SwitchCharset,
  K_ButtonA, K_ButtonB, K_ButtonC, K_ButtonX,
  K_ButtonY, K_ButtonZ, K_ButtonL1, K_ButtonR1,
  K_Button_L2, K_ButtonR2, K_ButtonThumbLeft, K_ButtonThumbRight,
  K_ButtonStart, K_ButtonSelect, K_ButtonMode, K_Escape,
  K_ForwardDelete, K_ControlLeft, K_ControlRight, K_CapsLock,
  K_ScrollLock, K_MetaLeft, K_MetaRight, K_Function,
  K_SysRq, K_Break, K_MoveHome, K_MoveEnd,
  K_Insert, K_Forward, K_MediaPlay, K_MediaPause,
  K_MediaClose, K_MediaEject, K_MediaRecord, K_F1,
  K_F2, K_F3, K_F4, K_F5,
  K_F6, K_F7, K_F8, K_F9,
  K_F10, K_F11, K_F12, K_NumLock,
  K_NumPad_0, K_NumPad_1, K_NumPad_2, K_NumPad_3,
  K_NumPad_4, K_NumPad_5, K_NumPad_6, K_NumPad_7,
  K_NumPad_8, K_NumPad_9, K_NumPad_Divide, K_NumPad_Multiply,
  K_NumPad_Subtract, K_NumPad_Add, K_NumPad_Dot, K_NumPad_Comma,
  K_NumPad_Enter, K_NumPad_Equals, K_NumPad_LeftParen, K_NumPad_RightParen,
  K_VolumeMute, K_Info, K_ChannelUp, K_ChannelDown,
  K_ZoomIn, K_ZoomOut, K_TV, K_Window,
  K_Guide, K_DVR, K_Bookmark, K_Captions,
  K_Settings, K_TVPower, K_TVInput, K_STBPower,
  K_STBInput, K_AVRPower, K_AVRInput, K_ProgRed,
  K_ProgGreen, K_ProgYellow, K_ProgBlue, K_AppSwitch,
  K_Button1, K_Button2, K_Button3, K_Button4,
  K_Button5, K_Button6, K_Button7, K_Button8,
  K_Button9, K_Button10, K_Button11, K_Button12,
  K_Button13, K_Button14, K_Button15, K_Button16,
  K_LanguageSwitch, K_MannerMode, K_3DMode, K_Contacts,
  K_Calendar, K_Music, K_Calculator, K_ZenkakuHankaku,
  K_Eisu, K_Muhenkan, K_Henkan, K_KatakanaHiragana,
  K_Yen, K_Ro, K_Kana, K_Assist,
  K_BrightnessDown, K_BrightnessUp, K_MediaAudioTrack
}
 Key codes. More...
 
enum  Source {
  Source_Unknown = -1, Source_Keyboard = 1, Source_DPad = 2, Source_GamePad = 3,
  Source_TouchScreen = 4, Source_Mouse = 5, Source_Stylus = 6, Source_Trackball = 7,
  Source_TouchPad = 8, Source_TouchNavigation = 9, Source_Joystick = 10, Source_Any = 0
}
 User input event sources. More...
 
enum  Class {
  Class_Unknown = - 1, Class_None = 0, Class_Button = 1, Class_Pointer = 2,
  Class_Navigation = 3, Class_Position = 4, Class_Joystick = 5
}
 Input event classes. More...
 
enum  Type { Type_Key, Type_Motion, Type_Sensor, Type_Timer }
 Event types. More...
 

Public Member Functions

virtual ~KeyEvent ()
 Destructor. More...
 
Action getAction () const
 Get the keypress action for this event. More...
 
const ccxx::Flags< int32_t > getFlags () const
 Get the flags associated with this event. More...
 
KeyCode getKeyCode () const
 Get the keycode for this event. More...
 
char getCharacter () const
 Get the ASCII character represented by this event. More...
 
int32_t getScanCode () const
 Get the scancode for this event. More...
 
int32_t getMetaState () const
 Get the state of the modifier keys at the time of this event. More...
 
int getRepeatCount () const
 Get the repeat count for this event. More...
 
time_ms_t getDownTime () const
 Get the amount of time that the key was held down. More...
 
virtual time_ms_t getEventTime () const
 Get the time at which this event occurred. More...
 
bool isMetaKeyPressed () const
 Test if any modifier key was pressed at the time of this event. More...
 
bool isAltPressed () const
 Test if either Alt key was pressed at the time of this event. More...
 
bool isLeftAltPressed () const
 Test if the left Alt key was pressed at the time of this event. More...
 
bool isRightAltPressed () const
 Test if the right Alt key was pressed at the time of this event. More...
 
bool isCapsLockPressed () const
 Test if the Caps Lock key was pressed at the time of this event. More...
 
bool isControlPressed () const
 Test if either Control key was pressed at the time of this event. More...
 
bool isLeftControlPressed () const
 Test if the left Control key was pressed at the time of this event. More...
 
bool isRightControlPressed () const
 Test if the right Control key was pressed at the time of this event. More...
 
bool isFunctionPressed () const
 Test if the Function key was pressed at the time of this event. More...
 
bool isNumLockPressed () const
 Test if the Num Lock key was pressed at the time of this event. More...
 
bool isScrollLockPressed () const
 Test if the Scroll Lock key was pressed at the time of this event. More...
 
bool isShiftPressed () const
 Test if either Shift key was pressed at the time of this event. More...
 
bool isLeftShiftPressed () const
 Test if the left Shift key was pressed at the time of this event. More...
 
bool isRightShiftPressed () const
 Test if the right Shift key was pressed at the time of this event. More...
 
bool isSymPressed () const
 Test if the Sym key was pressed at the time of this event. More...
 
int32_t getDeviceID () const
 Get the ID of the input device which is the source of this event. More...
 
virtual Source getSource () const
 Get the source of this event. More...
 
Class getClass () const
 Get the class of this event. More...
 
Type getType () const
 Get the event type. More...
 

Static Public Attributes

static const uint32_t ALT_MASK = 1 << 1
 A mask for testing if either Alt key was pressed. More...
 
static const uint32_t ALT_LEFT_MASK = 1 << 4
 A mask for testing if the left Alt key was pressed. More...
 
static const uint32_t ALT_RIGHT_MASK = 1 << 5
 A mask for testing if the right Alt key was pressed. More...
 
static const uint32_t ALT_ANY_MASK = KeyEvent::ALT_MASK | KeyEvent::ALT_LEFT_MASK | KeyEvent::ALT_RIGHT_MASK
 A mask for testing if any Alt key was pressed. More...
 
static const uint32_t CAPS_LOCK_MASK = 1 << 20
 A mask for testing if the Caps Lock key was pressed. More...
 
static const uint32_t CTRL_MASK = 1 << 12
 A mask for testing if either Control key was pressed. More...
 
static const uint32_t CTRL_LEFT_MASK = 1 << 13
 A mask for testing if the left Control key was pressed. More...
 
static const uint32_t CTRL_RIGHT_MASK = 1 << 14
 A mask for testing if the right Control key was pressed. More...
 
static const uint32_t CTRL_ANY_MASK = KeyEvent::CTRL_MASK | KeyEvent::CTRL_LEFT_MASK | KeyEvent::CTRL_RIGHT_MASK
 A mask for testing if any Control key was pressed. More...
 
static const uint32_t FUNCTION_MASK = 1 << 3
 A mask for testing if the Function key was pressed. More...
 
static const uint32_t META_MASK = 1 << 16
 A mask for testing if either Meta key was pressed. More...
 
static const uint32_t META_LEFT_MASK = 1 << 17
 A mask for testing if the left Meta key was pressed. More...
 
static const uint32_t META_RIGHT_MASK = 1 << 18
 A mask for testing if the right Meta key was pressed. More...
 
static const uint32_t META_ANY_MASK = KeyEvent::META_MASK | KeyEvent::META_LEFT_MASK | KeyEvent::META_RIGHT_MASK
 A mask for testing if any Meta key was pressed. More...
 
static const uint32_t NUM_LOCK_MASK = 1 << 21
 A mask for testing if the Num Lock key was pressed. More...
 
static const uint32_t SCROLL_LOCK_MASK = 1 << 22
 A mask for testing if the Scroll Lock key was pressed. More...
 
static const uint32_t SHIFT_MASK = 1 << 0
 A mask for testing if either Shift key was pressed. More...
 
static const uint32_t SHIFT_LEFT_MASK = 1 << 6
 A mask for testing if the left Shift key was pressed. More...
 
static const uint32_t SHIFT_RIGHT_MASK = 1 << 7
 A mask for testing if the right Shift key was pressed. More...
 
static const uint32_t SHIFT_ANY_MASK
 A mask for testing if any Shift key was pressed. More...
 
static const uint32_t SYM_MASK = 1 << 2
 A mask for testing if the Sym key was pressed. More...
 

Detailed Description

A keyboard input event.

Author
Mark Lindner

Member Enumeration Documentation

◆ Action

enum Action

Keypress actions.

Enumerator
Action_Unknown 
Action_KeyDown 
Action_KeyUp 
Action_Multiple 

◆ Class

enum Class
inherited

Input event classes.

Enumerator
Class_Unknown 
Class_None 
Class_Button 
Class_Pointer 
Class_Navigation 
Class_Position 
Class_Joystick 

◆ KeyCode

enum KeyCode

Key codes.

Enumerator
K_Unknown 
K_SoftLeft 
K_SoftRight 
K_Home 
K_Back 
K_Call 
K_EndCall 
K_0 
K_1 
K_2 
K_3 
K_4 
K_5 
K_6 
K_7 
K_8 
K_9 
K_Star 
K_Pound 
K_DPadUp 
K_DPadDown 
K_DPadLeft 
K_DPadRight 
K_DPad_Center 
K_VolumeUp 
K_VolumeDown 
K_Power 
K_Camera 
K_Clear 
K_A 
K_B 
K_C 
K_D 
K_E 
K_F 
K_G 
K_H 
K_I 
K_J 
K_K 
K_L 
K_M 
K_N 
K_O 
K_P 
K_Q 
K_R 
K_S 
K_T 
K_U 
K_V 
K_W 
K_X 
K_Y 
K_Z 
K_Comma 
K_Period 
K_AltLeft 
K_AltRight 
K_ShiftLeft 
K_ShiftRight 
K_Tab 
K_Space 
K_Sym 
K_Explorer 
K_Envelope 
K_Enter 
K_Delete 
K_Grave 
K_Minus 
K_Equals 
K_LeftBracket 
K_RightBracket 
K_Backslash 
K_Semicolon 
K_Apostrophe 
K_Slash 
K_At 
K_Num 
K_HeadsetHook 
K_Focus 
K_Plus 
K_Menu 
K_Notification 
K_Search 
K_MediaPlayPause 
K_MediaStop 
K_MediaNext 
K_MediaPrevious 
K_MediaRewind 
K_MediaFastForward 
K_Mute 
K_PageUp 
K_PageDown 
K_PictSymbols 
K_SwitchCharset 
K_ButtonA 
K_ButtonB 
K_ButtonC 
K_ButtonX 
K_ButtonY 
K_ButtonZ 
K_ButtonL1 
K_ButtonR1 
K_Button_L2 
K_ButtonR2 
K_ButtonThumbLeft 
K_ButtonThumbRight 
K_ButtonStart 
K_ButtonSelect 
K_ButtonMode 
K_Escape 
K_ForwardDelete 
K_ControlLeft 
K_ControlRight 
K_CapsLock 
K_ScrollLock 
K_MetaLeft 
K_MetaRight 
K_Function 
K_SysRq 
K_Break 
K_MoveHome 
K_MoveEnd 
K_Insert 
K_Forward 
K_MediaPlay 
K_MediaPause 
K_MediaClose 
K_MediaEject 
K_MediaRecord 
K_F1 
K_F2 
K_F3 
K_F4 
K_F5 
K_F6 
K_F7 
K_F8 
K_F9 
K_F10 
K_F11 
K_F12 
K_NumLock 
K_NumPad_0 
K_NumPad_1 
K_NumPad_2 
K_NumPad_3 
K_NumPad_4 
K_NumPad_5 
K_NumPad_6 
K_NumPad_7 
K_NumPad_8 
K_NumPad_9 
K_NumPad_Divide 
K_NumPad_Multiply 
K_NumPad_Subtract 
K_NumPad_Add 
K_NumPad_Dot 
K_NumPad_Comma 
K_NumPad_Enter 
K_NumPad_Equals 
K_NumPad_LeftParen 
K_NumPad_RightParen 
K_VolumeMute 
K_Info 
K_ChannelUp 
K_ChannelDown 
K_ZoomIn 
K_ZoomOut 
K_TV 
K_Window 
K_Guide 
K_DVR 
K_Bookmark 
K_Captions 
K_Settings 
K_TVPower 
K_TVInput 
K_STBPower 
K_STBInput 
K_AVRPower 
K_AVRInput 
K_ProgRed 
K_ProgGreen 
K_ProgYellow 
K_ProgBlue 
K_AppSwitch 
K_Button1 
K_Button2 
K_Button3 
K_Button4 
K_Button5 
K_Button6 
K_Button7 
K_Button8 
K_Button9 
K_Button10 
K_Button11 
K_Button12 
K_Button13 
K_Button14 
K_Button15 
K_Button16 
K_LanguageSwitch 
K_MannerMode 
K_3DMode 
K_Contacts 
K_Calendar 
K_Music 
K_Calculator 
K_ZenkakuHankaku 
K_Eisu 
K_Muhenkan 
K_Henkan 
K_KatakanaHiragana 
K_Yen 
K_Ro 
K_Kana 
K_Assist 
K_BrightnessDown 
K_BrightnessUp 
K_MediaAudioTrack 

◆ Source

enum Source
inherited

User input event sources.

Enumerator
Source_Unknown 
Source_Keyboard 
Source_DPad 
Source_GamePad 
Source_TouchScreen 
Source_Mouse 
Source_Stylus 
Source_Trackball 
Source_TouchPad 
Source_TouchNavigation 
Source_Joystick 
Source_Any 

◆ Type

enum Type
inherited

Event types.

Enumerator
Type_Key 

Key input events.

Type_Motion 

Motion input events.

Type_Sensor 

Sensor events.

Type_Timer 

Timer events.

Constructor & Destructor Documentation

◆ ~KeyEvent()

~KeyEvent ( )
virtual

Destructor.

Member Function Documentation

◆ getAction()

KeyEvent::Action getAction ( ) const

Get the keypress action for this event.

◆ getCharacter()

char getCharacter ( ) const

Get the ASCII character represented by this event.

Note that this method assumes a keyboard with a US-English layout.

◆ getClass()

InputEvent::Class getClass ( ) const
inherited

Get the class of this event.

◆ getDeviceID()

int32_t getDeviceID ( ) const
inherited

Get the ID of the input device which is the source of this event.

◆ getDownTime()

time_ms_t getDownTime ( ) const

Get the amount of time that the key was held down.

◆ getEventTime()

time_ms_t getEventTime ( ) const
virtual

Get the time at which this event occurred.

Implements InputEvent.

◆ getFlags()

const Flags< int32_t > getFlags ( ) const

Get the flags associated with this event.

◆ getKeyCode()

KeyEvent::KeyCode getKeyCode ( ) const

Get the keycode for this event.

◆ getMetaState()

int32_t getMetaState ( ) const

Get the state of the modifier keys at the time of this event.

Generally it is simpler to use the convenience methods like isMetaKeyPressed() and isAltPressed() to test individual modifier keys.

◆ getRepeatCount()

int getRepeatCount ( ) const

Get the repeat count for this event.

◆ getScanCode()

int32_t getScanCode ( ) const

Get the scancode for this event.

◆ getSource()

InputEvent::Source getSource ( ) const
virtualinherited

Get the source of this event.

◆ getType()

Type getType ( ) const
inlineinherited

Get the event type.

◆ isAltPressed()

bool isAltPressed ( ) const

Test if either Alt key was pressed at the time of this event.

◆ isCapsLockPressed()

bool isCapsLockPressed ( ) const

Test if the Caps Lock key was pressed at the time of this event.

◆ isControlPressed()

bool isControlPressed ( ) const

Test if either Control key was pressed at the time of this event.

◆ isFunctionPressed()

bool isFunctionPressed ( ) const

Test if the Function key was pressed at the time of this event.

◆ isLeftAltPressed()

bool isLeftAltPressed ( ) const

Test if the left Alt key was pressed at the time of this event.

◆ isLeftControlPressed()

bool isLeftControlPressed ( ) const

Test if the left Control key was pressed at the time of this event.

◆ isLeftShiftPressed()

bool isLeftShiftPressed ( ) const

Test if the left Shift key was pressed at the time of this event.

◆ isMetaKeyPressed()

bool isMetaKeyPressed ( ) const

Test if any modifier key was pressed at the time of this event.

◆ isNumLockPressed()

bool isNumLockPressed ( ) const

Test if the Num Lock key was pressed at the time of this event.

◆ isRightAltPressed()

bool isRightAltPressed ( ) const

Test if the right Alt key was pressed at the time of this event.

◆ isRightControlPressed()

bool isRightControlPressed ( ) const

Test if the right Control key was pressed at the time of this event.

◆ isRightShiftPressed()

bool isRightShiftPressed ( ) const

Test if the right Shift key was pressed at the time of this event.

◆ isScrollLockPressed()

bool isScrollLockPressed ( ) const

Test if the Scroll Lock key was pressed at the time of this event.

◆ isShiftPressed()

bool isShiftPressed ( ) const

Test if either Shift key was pressed at the time of this event.

◆ isSymPressed()

bool isSymPressed ( ) const

Test if the Sym key was pressed at the time of this event.

Member Data Documentation

◆ ALT_ANY_MASK

const uint32_t ALT_ANY_MASK = KeyEvent::ALT_MASK | KeyEvent::ALT_LEFT_MASK | KeyEvent::ALT_RIGHT_MASK
static

A mask for testing if any Alt key was pressed.

◆ ALT_LEFT_MASK

const uint32_t ALT_LEFT_MASK = 1 << 4
static

A mask for testing if the left Alt key was pressed.

◆ ALT_MASK

const uint32_t ALT_MASK = 1 << 1
static

A mask for testing if either Alt key was pressed.

◆ ALT_RIGHT_MASK

const uint32_t ALT_RIGHT_MASK = 1 << 5
static

A mask for testing if the right Alt key was pressed.

◆ CAPS_LOCK_MASK

const uint32_t CAPS_LOCK_MASK = 1 << 20
static

A mask for testing if the Caps Lock key was pressed.

◆ CTRL_ANY_MASK

const uint32_t CTRL_ANY_MASK = KeyEvent::CTRL_MASK | KeyEvent::CTRL_LEFT_MASK | KeyEvent::CTRL_RIGHT_MASK
static

A mask for testing if any Control key was pressed.

◆ CTRL_LEFT_MASK

const uint32_t CTRL_LEFT_MASK = 1 << 13
static

A mask for testing if the left Control key was pressed.

◆ CTRL_MASK

const uint32_t CTRL_MASK = 1 << 12
static

A mask for testing if either Control key was pressed.

◆ CTRL_RIGHT_MASK

const uint32_t CTRL_RIGHT_MASK = 1 << 14
static

A mask for testing if the right Control key was pressed.

◆ FUNCTION_MASK

const uint32_t FUNCTION_MASK = 1 << 3
static

A mask for testing if the Function key was pressed.

◆ META_ANY_MASK

const uint32_t META_ANY_MASK = KeyEvent::META_MASK | KeyEvent::META_LEFT_MASK | KeyEvent::META_RIGHT_MASK
static

A mask for testing if any Meta key was pressed.

◆ META_LEFT_MASK

const uint32_t META_LEFT_MASK = 1 << 17
static

A mask for testing if the left Meta key was pressed.

◆ META_MASK

const uint32_t META_MASK = 1 << 16
static

A mask for testing if either Meta key was pressed.

◆ META_RIGHT_MASK

const uint32_t META_RIGHT_MASK = 1 << 18
static

A mask for testing if the right Meta key was pressed.

◆ NUM_LOCK_MASK

const uint32_t NUM_LOCK_MASK = 1 << 21
static

A mask for testing if the Num Lock key was pressed.

◆ SCROLL_LOCK_MASK

const uint32_t SCROLL_LOCK_MASK = 1 << 22
static

A mask for testing if the Scroll Lock key was pressed.

◆ SHIFT_ANY_MASK

const uint32_t SHIFT_ANY_MASK
static
Initial value:

A mask for testing if any Shift key was pressed.

◆ SHIFT_LEFT_MASK

const uint32_t SHIFT_LEFT_MASK = 1 << 6
static

A mask for testing if the left Shift key was pressed.

◆ SHIFT_MASK

const uint32_t SHIFT_MASK = 1 << 0
static

A mask for testing if either Shift key was pressed.

◆ SHIFT_RIGHT_MASK

const uint32_t SHIFT_RIGHT_MASK = 1 << 7
static

A mask for testing if the right Shift key was pressed.

◆ SYM_MASK

const uint32_t SYM_MASK = 1 << 2
static

A mask for testing if the Sym key was pressed.


The documentation for this class was generated from the following files: