Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Burger::Keyboard Class Reference

Keyboard input manager. More...

Inheritance diagram for Burger::Keyboard:
Collaboration diagram for Burger::Keyboard:

Public Types

enum  { KEYCAPDOWN = 0x01 , KEYCAPPRESSED = 0x02 , KEYCAPTOGGLE = 0x4 }
 
enum  eAsciiCode {
  ASCII_BACKSPACE = 0x08 , ASCII_TAB = 0x09 , ASCII_ENTER = 0x0D , ASCII_RETURN = 0x0D ,
  ASCII_ESCAPE = 0x1B , ASCII_ESC = 0x1B , ASCII_SPACE = 0x20 , ASCII_F1 = 0x80 ,
  ASCII_F2 = 0x81 , ASCII_F3 = 0x82 , ASCII_F4 = 0x83 , ASCII_F5 = 0x84 ,
  ASCII_F6 = 0x85 , ASCII_F7 = 0x86 , ASCII_F8 = 0x87 , ASCII_F9 = 0x88 ,
  ASCII_F10 = 0x89 , ASCII_F11 = 0x8A , ASCII_F12 = 0x8B , ASCII_F13 = 0x8C ,
  ASCII_F14 = 0x8D , ASCII_F15 = 0x8E , ASCII_PAUSE = 0x8F , ASCII_SCROLLLOCK = 0x090 ,
  ASCII_HOME = 0x91 , ASCII_END = 0x92 , ASCII_LEFTARROW = 0x2190 , ASCII_UPARROW = 0x2191 ,
  ASCII_RIGHTARROW = 0x2192 , ASCII_DOWNARROW = 0x2193 , ASCII_PAGEUP = 0x21DE , ASCII_PAGEDOWN = 0x21DF ,
  ASCII_DELETE = 0x232B , ASCII_INSERT = 0x2380 , ASCII_PRINTSCREEN = 0x2399
}
 Unicode translations for several common keys. More...
 
enum  eScanCode {
  SC_INVALID , SC_A , SC_B , SC_C ,
  SC_D , SC_E , SC_F , SC_G ,
  SC_H , SC_I , SC_J , SC_K ,
  SC_L , SC_M , SC_N , SC_O ,
  SC_P , SC_Q , SC_R , SC_S ,
  SC_T , SC_U , SC_V , SC_W ,
  SC_X , SC_Y , SC_Z , SC_FUSS ,
  SC_0 , SC_1 , SC_2 , SC_3 ,
  SC_4 , SC_5 , SC_6 , SC_7 ,
  SC_8 , SC_9 , SC_TILDE , SC_UNDERSCORE ,
  SC_MINUS = SC_UNDERSCORE , SC_PLUS , SC_EQUALS = SC_PLUS , SC_BACKSPACE ,
  SC_RIGHTBRACE , SC_RIGHTBRACKET = SC_RIGHTBRACE , SC_LEFTBRACE , SC_LEFTBRACKET = SC_LEFTBRACE ,
  SC_RETURN , SC_QUOTE , SC_GRAVE = SC_QUOTE , SC_COLON ,
  SC_SEMICOLON = SC_COLON , SC_VERTBAR , SC_BACKSLASH = SC_VERTBAR , SC_COMMA ,
  SC_PERIOD , SC_SLASH , SC_TAB , SC_SPACE ,
  SC_POWERBOOKENTER , SC_ESCAPE , SC_LEFTCONTROL , SC_RIGHTCONTROL ,
  SC_LEFTOPTION , SC_RIGHTOPTION , SC_LEFTALT , SC_LEFTOPENAPPLE = SC_LEFTALT ,
  SC_RIGHTALT , SC_RIGHTOPENAPPLE = SC_RIGHTALT , SC_LEFTSHIFT , SC_RIGHTSHIFT ,
  SC_LEFTMENU , SC_RIGHTMENU , SC_CAPSLOCK , SC_KEYPADPERIOD ,
  SC_KEYPADCOMMA , SC_KEYPADASTERISK , SC_KEYPADPLUS , SC_NUMLOCK ,
  SC_KEYPADSLASH , SC_KEYPADENTER , SC_KEYPADMINUS , SC_KEYPADEQUALS ,
  SC_KEYPAD0 , SC_KEYPAD1 , SC_KEYPAD2 , SC_KEYPAD3 ,
  SC_KEYPAD4 , SC_KEYPAD5 , SC_KEYPAD6 , SC_KEYPAD7 ,
  SC_KEYPAD8 , SC_KEYPAD9 , SC_PRINTSCREEN , SC_SYSRQ = SC_PRINTSCREEN ,
  SC_SCROLLLOCK , SC_PAUSE , SC_INSERT , SC_DELETE ,
  SC_HOME , SC_END , SC_PAGEUP , SC_PAGEDOWN ,
  SC_LEFTARROW , SC_RIGHTARROW , SC_DOWNARROW , SC_UPARROW ,
  SC_F1 , SC_F2 , SC_F3 , SC_F4 ,
  SC_F5 , SC_F6 , SC_F7 , SC_F8 ,
  SC_F9 , SC_F10 , SC_F11 , SC_F12 ,
  SC_F13 , SC_F14 , SC_F15 , SC_OEM_102 ,
  SC_KANA , SC_ABNT_C1 , SC_CONVERT , SC_NOCONVERT ,
  SC_YEN , SC_ABNT_C2 , SC_PREVTRACK , SC_AT ,
  SC_COLONPC98 , SC_UNDERLINE , SC_KANJI , SC_STOP ,
  SC_AX , SC_UNLABELED , SC_NEXTTRACK , SC_MUTE ,
  SC_CALCULATOR , SC_PLAYPAUSE , SC_MEDIASTOP , SC_VOLUMEDOWN ,
  SC_VOLUMEUP , SC_WEBHOME , SC_APPS , SC_POWER ,
  SC_SLEEP , SC_WAKE , SC_WEBSEARCH , SC_WEBFAVORITES ,
  SC_WEBREFRESH , SC_WEBSTOP , SC_WEBFORWARD , SC_WEBBACK ,
  SC_MYCOMPUTER , SC_MAIL , SC_MEDIASELECT , SC_EXTRA ,
  SC_MAXENTRY = 255
}
 Unified scan codes. More...
 
enum  eKeyFlags {
  FLAG_ALT = 0x02 , FLAG_CONTROL = 0x04 , FLAG_OPTION = 0x08 , FLAG_SHIFT = 0x10 ,
  FLAG_CAPSLOCK = 0x40 , FLAG_NUMLOCK = 0x80
}
 Keycode modifier flags. More...
 

Public Member Functions

const Burger::StaticRTTIget_StaticRTTI (void) const noexcept override
 Get the description to the class.
 
 Keyboard (GameApp *pAppInstance) noexcept
 Default constructor.
 
virtual ~Keyboard ()
 Default destructor.
 
GameAppGetApp (void) const noexcept
 Return the parent application.
 
uint_t PeekKeyEvent (KeyEvent_t *pEvent) noexcept
 Check if a keyboard event is pending.
 
uint_t GetKeyEvent (KeyEvent_t *pEvent) noexcept
 Retrieve a keyboard event.
 
void ClearKey (eScanCode uScanCode) noexcept
 Clear the key event for the specific scan code.
 
eScanCode AnyPressed (void) const noexcept
 Check if a key is pressed at this very moment.
 
uint_t HasBeenPressed (eScanCode uScanCode) const noexcept
 Check if the requested key is currently or previously held down.
 
uint_t HasBeenPressedClear (eScanCode uScanCode) noexcept
 Check if the requested key is currently or previously held down and clear the event.
 
uint_t IsPressed (eScanCode uScanCode) const noexcept
 Check if the requested key is currently held down.
 
uint_t GetKey (void) noexcept
 Return the Unicode value of a pending key press.
 
uint_t GetKeyLowerCase (void) noexcept
 Return a key in lower case.
 
uint_t GetKeyUpperCase (void) noexcept
 Return a key in upper case.
 
void Flush (void) noexcept
 Flush the keyboard buffer.
 
uint_t Wait (void) noexcept
 Wait for a key press.
 
uint_t PostKeyDown (eScanCode uScanCode) noexcept
 Post a scan code key down.
 
uint_t PostKeyUp (eScanCode uScanCode) noexcept
 Post a scan code key up.
 
uint_t PostKey (eScanCode uScanCode) noexcept
 Post a scan code key down and a key up.
 
uint_t PostUnicodeDown (uint32_t uUnicode) noexcept
 Post an ASCII/Unicode key down.
 
uint_t PostUnicodeUp (uint32_t uUnicode) noexcept
 Post an ASCII/Unicode key up.
 
uint_t PostUnicode (uint32_t uUnicode) noexcept
 Post an ASCII/Unicode key down.
 
uint_t PostKeyEvent (const KeyEvent_t *pEvent) noexcept
 Post the keyboard event.
 
uint_t EncodeScanCode (KeyEvent_t *pEvent, eScanCode uScanCode) const noexcept
 Convert a scan code to a KeyEvent_t.
 
uint_t EncodeUnicode (KeyEvent_t *pEvent, uint32_t uUnicode) const noexcept
 Convert a Unicode character to a KeyEvent_t.
 
uint_t GetCurrentFlags (void) const noexcept
 Return the flags for a KeyEvent_t based on the currently active modifiers.
 
uint_t DisableWindowsKey (void) noexcept
 Install keyboard intercept function disabling Windows Key.
 
void EnableWindowsKey (void) noexcept
 Remove keyboard intercept function disabling Windows Key.
 
HHOOK__ * GetWindowsPreviousKeyboardHook (void) const noexcept
 Return the Windows default Keyboard Hook function.
 
uint_t IsDirectInputActive (void) const noexcept
 Is DirectInput active?
 
uint_t PostWindowsKeyEvent (eEvent uEvent, uint32_t uScanCode) noexcept
 Post a windows scan code key event.
 
uint_t EncodeWindowsScanCode (KeyEvent_t *pEvent, uint_t uWindowsCode) const noexcept
 Convert a windows a scan code to a KeyEvent_t (Windows only)
 
void AcquireDirectInput (void) noexcept
 Acquire DirectInput (Windows only)
 
void UnacquireDirectInput (void) noexcept
 Release DirectInput (Windows only)
 
void ReadSystemKeyboardDelays (void) noexcept
 Read System keyboard delay constants (Windows only)
 
void DisableAccessibilityShortcutKeys (void) const noexcept
 Disable the accessibility shortcut keys (Windows only)
 
void RestoreAccessibilityShortcutKeys (void) noexcept
 Restore the accessibility shortcut keys (Windows only)
 
void ProcessEvent (NSEvent *pEvent) noexcept
 Process a MacOSX keystroke.
 
- Public Member Functions inherited from Burger::Base
const char * get_class_name (void) const noexcept
 Get the name of the class.
 
virtual ~Base () noexcept=default
 Destructor.
 

Static Public Member Functions

static eScanCode StringToScanCode (const char *pString) noexcept
 Convert a string to a scan code.
 
static void ScanCodeToString (char *pString, uintptr_t uStringSize, eScanCode uScanCode) noexcept
 Convert a scan code into a string.
 

Static Public Attributes

static const Burger::StaticRTTI g_StaticRTTI
 
static const uint_t kBufferSize = 128
 Number of keystrokes in keyboard cache.
 
- Static Public Attributes inherited from Burger::Base
static const Burger::StaticRTTI g_StaticRTTI
 The global description of the class.
 

Protected Member Functions

void Lock (void) noexcept
 
void Unlock (void) noexcept
 

Static Protected Member Functions

static uintptr_t WindowsKeyboardThread (void *pData)
 Windows thread for monitoring keyboard events (Windows only)
 

Protected Attributes

GameAppm_pAppInstance
 Application instances.
 
IDirectInputDevice8W * m_pKeyboardDevice
 DirectInput Device reference (Windows only)
 
void * m_pKeyboardEvent
 Event signal for DirectInput (Windows only)
 
void * m_pKeyboardTimerEvent
 Keyboard repeat timer event (Windows only)
 
HHOOK__ * m_pPreviousKeyboardHook
 Previous keyboard low level hook.
 
Thread m_KeyboardThread
 Asynchronous thread monitoring DirectInput (Windows only)
 
uint_t m_bDirectInput8Acquired
 TRUE if DirectInput8 is active (Windows only)
 
uint_t m_bRepeatActive
 TRUE if auto repeat time is active (Windows only)
 
volatile uint32_t m_bQuit
 TRUE when the thread is shutting down (Windows only)
 
Burger_tagSTICKYKEYS m_DefaultStickyKeys
 Previous settings for Sticky Keys (Windows only)
 
Burger_tagTOGGLEKEYS m_DefaultToggleKeys
 Previous settings for Toggle Keys (Windows only)
 
Burger_tagFILTERKEYS m_DefaultFilterKeys
 Previous settings for Filter Keys (Windows only)
 
Mutex m_KeyboardLock
 Lock for multi-threading (MacOSX and Windows only)
 
uint8_t m_KeyArray [SC_MAXENTRY+1]
 Array with the current state of the keyboard.
 
uint_t m_uArrayStart
 Read index for m_KeyEvents.
 
uint_t m_uArrayEnd
 Write index for m_KeyEvents.
 
uint_t m_uInitialDelay
 Initial delay in ms for autorepeat.
 
uint_t m_uRepeatDelay
 Delay between repeating keystrokes.
 
KeyEvent_t m_KeyEvents [kBufferSize]
 Circular buffer holding keyboard events.
 
KeyEvent_t m_RepeatEvent
 Event to post on a repeat.
 

Private Member Functions

 Keyboard (const Keyboard &)=delete
 
Keyboardoperator= (const Keyboard &)=delete
 
 Keyboard (Keyboard &&)=delete
 
Keyboardoperator= (Keyboard &&)=delete
 

Detailed Description

Keyboard input manager.


This class manages keyboard input down to the individual key cap. It's main use is to use the keyboard as a gaming input device. Emphasis is on speed, low latency and accuracy.

When this class is instantiated, a keyboard monitor is activated which will check for all key strokes. There are a maximum of 256 keyboard scan codes that can be monitored. Each byte will contain the current status of the key by scan code. The lowest bit (mask with 0x01) will determine the key down status at the current moment in time. Bit #1 (mask with 0x02) is set when the key is pressed but never cleared unless you call a function that clears the flag or Keyboard::Flush() with flushes all events.

This array is checked by several routines that use the keyboard as a game input device.

The array is volatile since some keyboard monitors run as a separate thread.

See also
Burger::Joypad and Burger::Mouse

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
KEYCAPDOWN 

If TRUE in m_KeyArray, this key is currently held down.

KEYCAPPRESSED 

If TRUE in m_KeyArray, this key was pressed, but wasn't acknowledged by the application.

KEYCAPTOGGLE 

If TRUE in m_KeyArray, this key is toggled "on".

◆ eAsciiCode

Unicode translations for several common keys.


When these keys are pressed, they return these specific Unicode compatible "ASCII" codes.

Enumerator
ASCII_BACKSPACE 

Backspace key.

ASCII_TAB 

Tab key.

ASCII_ENTER 

Return/enter key.

ASCII_RETURN 

Return/enter key.

ASCII_ESCAPE 

Escape key.

ASCII_ESC 

Escape key.

ASCII_SPACE 

Space bar.

ASCII_F1 

F1 key.

ASCII_F2 

F2 key.

ASCII_F3 

F3 key.

ASCII_F4 

F4 key.

ASCII_F5 

F5 key.

ASCII_F6 

F6 key.

ASCII_F7 

F7 key.

ASCII_F8 

F8 key.

ASCII_F9 

F9 key.

ASCII_F10 

F10 key.

ASCII_F11 

F11 key.

ASCII_F12 

F12 key.

ASCII_F13 

F12 key.

ASCII_F14 

F12 key.

ASCII_F15 

F12 key.

ASCII_PAUSE 

Pause key.

ASCII_SCROLLLOCK 

Scroll lock key.

ASCII_HOME 

Home key.

ASCII_END 

End key.

ASCII_LEFTARROW 

Left arrow key.

ASCII_UPARROW 

Up arrow key.

ASCII_RIGHTARROW 

Right arrow key.

ASCII_DOWNARROW 

Down arrow key.

ASCII_PAGEUP 

Page up key.

ASCII_PAGEDOWN 

Page down key.

ASCII_DELETE 

Delete key.

ASCII_INSERT 

Insert key.

ASCII_PRINTSCREEN 

Printscreen key.

◆ eKeyFlags

Keycode modifier flags.


When a keyboard event is generated, a set of flags can be attached to denote any type of modification that was applied to the keystroke at the moment of press.

See also
KeyEvent_t
Enumerator
FLAG_ALT 

Alt/Open Apple key is held down at the same time.

FLAG_CONTROL 

Control key is held down at the same time.

FLAG_OPTION 

Option key is held down at the same time.

FLAG_SHIFT 

Shift key is held down at the same time.

FLAG_CAPSLOCK 

Caps lock is active,.

FLAG_NUMLOCK 

Num lock is active.

◆ eScanCode

Unified scan codes.


All platforms will have their keyboard scan codes mapped to these enumerations. It allows an application to save a keyboard mapping file on one platform and read it in on another and have the keys map properly.

Enumerator
SC_INVALID 

Zero means no key.

SC_A 

A Key.

SC_B 

B Key.

SC_C 

C Key.

SC_D 

D Key.

SC_E 

E Key.

SC_F 

F Key.

SC_G 

G Key.

SC_H 

H Key.

SC_I 

I Key.

SC_J 

J Key.

SC_K 

K Key.

SC_L 

L Key.

SC_M 

M Key.

SC_N 

N Key.

SC_O 

O Key.

SC_P 

P Key.

SC_Q 

Q Key.

SC_R 

R Key.

SC_S 

S Key.

SC_T 

T Key.

SC_U 

U Key.

SC_V 

V Key.

SC_W 

W Key.

SC_X 

X Key.

SC_Y 

Y Key.

SC_Z 

Z Key.

SC_FUSS 

German ss.

SC_0 

)/0 Key

SC_1 

!/1 Key

SC_2 

@/2 Key

SC_3 

#/3 Key

SC_4 

$/4 Key

SC_5 

%/5 Key

SC_6 

^/6 Key

SC_7 

&/7 Key

SC_8 

*‍/8 Key

SC_9 

(/9 Key

SC_TILDE 

~/` Key

SC_UNDERSCORE 

_/- Key

SC_MINUS 

_/- Key

SC_PLUS 

+/= Key

SC_EQUALS 

+/= Key

SC_BACKSPACE 

Backspace key.

SC_RIGHTBRACE 

{/[ key

SC_RIGHTBRACKET 

{/[ key

SC_LEFTBRACE 

}/] key

SC_LEFTBRACKET 

}/] key

SC_RETURN 

Return key.

SC_QUOTE 

"/' key

SC_GRAVE 

"/' key

SC_COLON 

:/; key

SC_SEMICOLON 

:/; key

SC_VERTBAR 

|/\ key

SC_BACKSLASH 

|/\ key

SC_COMMA 

</, key

SC_PERIOD 

>/. key

SC_SLASH 

?// key

SC_TAB 

Tab key.

SC_SPACE 

Spacebar.

SC_POWERBOOKENTER 

Mac powerbook enter key.

SC_ESCAPE 

Escape key.

SC_LEFTCONTROL 

Left control key.

SC_RIGHTCONTROL 

Right control key.

SC_LEFTOPTION 

Left option key.

SC_RIGHTOPTION 

Right option key.

SC_LEFTALT 

Left Alt/Apple key.

SC_LEFTOPENAPPLE 

Left Alt/Apple key.

SC_RIGHTALT 

Right Alt/Apple key.

SC_RIGHTOPENAPPLE 

Right Alt/Apple key.

SC_LEFTSHIFT 

Left shift key.

SC_RIGHTSHIFT 

Right shift key.

SC_LEFTMENU 

Left menu key.

SC_RIGHTMENU 

Right menu key.

SC_CAPSLOCK 

Caps lock key.

SC_KEYPADPERIOD 

Keypad period.

SC_KEYPADCOMMA 

Keypad comma (NEC PC98)

SC_KEYPADASTERISK 

Keypad asterisk.

SC_KEYPADPLUS 

Keypad +.

SC_NUMLOCK 

Numlock.

SC_KEYPADSLASH 

Keypad divide.

SC_KEYPADENTER 

Keypad enter.

SC_KEYPADMINUS 

Keypad -.

SC_KEYPADEQUALS 

Keypad =.

SC_KEYPAD0 

Keypad 0.

SC_KEYPAD1 

Keypad 1.

SC_KEYPAD2 

Keypad 2.

SC_KEYPAD3 

Keypad 3.

SC_KEYPAD4 

Keypad 4.

SC_KEYPAD5 

Keypad 5.

SC_KEYPAD6 

Keypad 6.

SC_KEYPAD7 

Keypad 7.

SC_KEYPAD8 

Keypad 8.

SC_KEYPAD9 

Keypad 9.

SC_PRINTSCREEN 

Print screen.

SC_SYSRQ 

System Request.

SC_SCROLLLOCK 

Scroll lock.

SC_PAUSE 

Pause key.

SC_INSERT 

Insert key.

SC_DELETE 

Delete key.

SC_HOME 

Home key.

SC_END 

End key.

SC_PAGEUP 

Pageup key.

SC_PAGEDOWN 

Pagedown key.

SC_LEFTARROW 

Left arrow key.

SC_RIGHTARROW 

Right arrow key.

SC_DOWNARROW 

Down arrow key.

SC_UPARROW 

Up arrow key.

SC_F1 

Function key 1.

SC_F2 

Function key 2.

SC_F3 

Function key 3.

SC_F4 

Function key 4.

SC_F5 

Function key 5.

SC_F6 

Function key 6.

SC_F7 

Function key 7.

SC_F8 

Function key 8.

SC_F9 

Function key 9.

SC_F10 

Function key 10.

SC_F11 

Function key 11.

SC_F12 

Function key 12.

SC_F13 

Function key 13.

SC_F14 

Function key 14.

SC_F15 

Function key 15.

SC_OEM_102 

<> or | on RT 102-key keyboard (Non-U.S.)

SC_KANA 

(Japanese keyboard)

SC_ABNT_C1 

/? on Brazilian keyboard

SC_CONVERT 

(Japanese keyboard)

SC_NOCONVERT 

(Japanese keyboard)

SC_YEN 

(Japanese keyboard)

SC_ABNT_C2 

Numpad . on Brazilian keyboard.

SC_PREVTRACK 

Previous Track (CIRCUMFLEX on Japanese keyboard)

SC_AT 

(NEC PC98)

SC_COLONPC98 

(NEC PC98)

SC_UNDERLINE 

(NEC PC98)

SC_KANJI 

(Japanese keyboard)

SC_STOP 

(NEC PC98)

SC_AX 

(Japan AX)

SC_UNLABELED 

(J3100)

SC_NEXTTRACK 

Next Track.

SC_MUTE 

Mute.

SC_CALCULATOR 

Calculator.

SC_PLAYPAUSE 

Play / Pause.

SC_MEDIASTOP 

Media Stop.

SC_VOLUMEDOWN 

Volume -.

SC_VOLUMEUP 

Volume +.

SC_WEBHOME 

Web home.

SC_APPS 

AppMenu key.

SC_POWER 

System Power.

SC_SLEEP 

System Sleep.

SC_WAKE 

System Wake.

SC_WEBSEARCH 

Web Search.

SC_WEBFAVORITES 

Web Favorites.

SC_WEBREFRESH 

Web Refresh.

SC_WEBSTOP 

Web Stop.

SC_WEBFORWARD 

Web Forward.

SC_WEBBACK 

Web Back.

SC_MYCOMPUTER 

My Computer.

SC_MAIL 

Mail.

SC_MEDIASELECT 

Media Select.

SC_EXTRA 

Extra key codes.

SC_MAXENTRY 

Highest scan code valid value.

Constructor & Destructor Documentation

◆ Keyboard() [1/3]

Burger::Keyboard::Keyboard ( const Keyboard & )
privatedelete

◆ Keyboard() [2/3]

Burger::Keyboard::Keyboard ( Keyboard && )
privatedelete

◆ Keyboard() [3/3]

Burger::Keyboard::Keyboard ( GameApp * pAppInstance)
noexcept

Default constructor.


Installs the heartbeat thread to periodically refresh the m_KeyArray and generate the lists of upcoming key events

See also
~Keyboard()

◆ ~Keyboard()

Burger::Keyboard::~Keyboard ( )
virtual

Default destructor.


Shuts down the heartbeat thread and releases all allocated system resources.

Member Function Documentation

◆ AcquireDirectInput()

void BURGER_API Burger::Keyboard::AcquireDirectInput ( void )
noexcept

Acquire DirectInput (Windows only)


Call Acquire() on the DirectInput mouse device.

Note
This is only available on Windows
See also
UnacquireDirectInput(void)

◆ AnyPressed()

Burger::Keyboard::eScanCode BURGER_API Burger::Keyboard::AnyPressed ( void ) const
noexcept

Check if a key is pressed at this very moment.


Scan the keyboard status array and return the scan code of the first key found that's held down.

Returns
SC_INVALID if no key was pressed or the scan code of the first key found

◆ ClearKey()

void BURGER_API Burger::Keyboard::ClearKey ( eScanCode uScanCode)
noexcept

Clear the key event for the specific scan code.


If the code is invalid, do nothing. Otherwise, clear the keyboard flags in the m_KeyArray

Parameters
uScanCodeValid keyboard scan code to check
See also
AnyPressed() or IsPressed(eScanCode)

◆ DisableAccessibilityShortcutKeys()

void BURGER_API Burger::Keyboard::DisableAccessibilityShortcutKeys ( void ) const
noexcept

Disable the accessibility shortcut keys (Windows only)


There are some keyboard modes that are intended for people with typing problems. If any of these features were not enabled when the application started, disable the ability to turn them on by using keyboard shortcuts. It helps prevent a player using the keyboard from accidentally enabling this feature while mashing buttons like crazy.

Note
This is only available on Windows
See also
RestoreAccessibilityShortcutKeys(void)

◆ DisableWindowsKey()

uint_t BURGER_API Burger::Keyboard::DisableWindowsKey ( void )
noexcept

Install keyboard intercept function disabling Windows Key.


Installs a keyboard hook that disables the windows key.

Note
If kTraceFlagActiveDebugging is set, this feature is disabled since it causes Visual Studio 2010's debugger to wait 5 seconds per keystroke
This is only available on Windows
Returns
Zero if no error, Windows error code on failure
See also
EnableWindowsKey(void)

◆ EnableWindowsKey()

void BURGER_API Burger::Keyboard::EnableWindowsKey ( void )
noexcept

Remove keyboard intercept function disabling Windows Key.


If DisableWindowsKey(void) was called, it installed a keyboard hook that disabled the windows key. This function removes that intercept.

Note
This is only available on Windows
See also
DisableWindowsKey(void)

◆ EncodeScanCode()

uint_t BURGER_API Burger::Keyboard::EncodeScanCode ( KeyEvent_t * pEvent,
eScanCode uScanCode ) const
noexcept

Convert a scan code to a KeyEvent_t.


Given a scan code, check the state of the keyboard and determine the Unicode/ASCII code to be generated for this keypress.

Returns
Zero if successful, non-zero if a scan code is unknown.

◆ EncodeUnicode()

uint_t BURGER_API Burger::Keyboard::EncodeUnicode ( KeyEvent_t * pEvent,
uint32_t uUnicode ) const
noexcept

Convert a Unicode character to a KeyEvent_t.


Given a Unicode character, look up the scan code, if available, and fill in a KeyEvent_t to be generated for this keypress.

Returns
Zero if successful, non-zero if the Unicode value is unknown.

◆ EncodeWindowsScanCode()

uint_t BURGER_API Burger::Keyboard::EncodeWindowsScanCode ( KeyEvent_t * pEvent,
uint_t uWindowsCode ) const
noexcept

Convert a windows a scan code to a KeyEvent_t (Windows only)


Convert a windows scan code to a Keyboard event

Note
This is only available on Windows
Returns
Zero if successful, non-zero if a scan code is unknown.

◆ Flush()

void BURGER_API Burger::Keyboard::Flush ( void )
noexcept

Flush the keyboard buffer.


Release all pending keyboard events and erase the keyboard array.

◆ get_StaticRTTI()

const Burger::StaticRTTI * Burger::Keyboard::get_StaticRTTI ( void ) const
overridevirtualnoexcept

Get the description to the class.


This virtual function will pull the pointer to the StaticRTTI instance that has the name of the class. Due to it being virtual, it will be the name of the most derived class.

Returns
Pointer to a global, read only instance of StaticRTTI for the true class

Reimplemented from Burger::Base.

◆ GetApp()

GameApp * Burger::Keyboard::GetApp ( void ) const
inlinenoexcept

Return the parent application.


Get the pointer to the application that is connected to the Keyboard manager

Returns
Pointer to the connected GameApp

◆ GetCurrentFlags()

uint_t BURGER_API Burger::Keyboard::GetCurrentFlags ( void ) const
noexcept

Return the flags for a KeyEvent_t based on the currently active modifiers.


Check the state of previously pressed keys and return the modifier flags for converting a scan code into an ASCII/Unicode value.

Returns
FLAG_??? merged together for setting KeyEvent_t::m_uFlags

◆ GetKey()

uint_t BURGER_API Burger::Keyboard::GetKey ( void )
noexcept

Return the Unicode value of a pending key press.


Check if a key is pending and return zero if not, else return the Unicode value. All key up events up until the key down are consumed.

Returns
Zero if no key is pending, Unicode key if there was a pending key

◆ GetKeyEvent()

uint_t BURGER_API Burger::Keyboard::GetKeyEvent ( KeyEvent_t * pEvent)
noexcept

Retrieve a keyboard event.


If a keyboard event is in the queue, return the event and remove it from the list.

Parameters
pEventPointer to a KeyEvent_t structure to receive the event.
Returns
Zero if no key was pending, non-zero if a keyboard event was retrieved.
See also
PeekKeyEvent(KeyEvent_t *)

◆ GetKeyLowerCase()

uint_t BURGER_API Burger::Keyboard::GetKeyLowerCase ( void )
noexcept

Return a key in lower case.


Check if a key is pending and return zero if not, else the Unicode code in lower case

Returns
Zero if no key is pending, lower case key if there was a pending key

◆ GetKeyUpperCase()

uint_t BURGER_API Burger::Keyboard::GetKeyUpperCase ( void )
noexcept

Return a key in upper case.


Check if a key is pending and return zero if not, else the Unicode code in upper case

Returns
Zero if no key is pending, upper case key if there was a pending key

◆ GetWindowsPreviousKeyboardHook()

HHOOK__ * Burger::Keyboard::GetWindowsPreviousKeyboardHook ( void ) const
inlinenoexcept

Return the Windows default Keyboard Hook function.


If a keyboard hook was installed via a call to DisableWindowsKey(), this pointer is valid and points to the function in Windows to be passed to the function CallNextHookEx()

Note
This is only available on Windows
Returns
Pointer to the connected previous Windows Keyboard Hook

◆ HasBeenPressed()

uint_t BURGER_API Burger::Keyboard::HasBeenPressed ( eScanCode uScanCode) const
noexcept

Check if the requested key is currently or previously held down.


If a key has been pressed, return TRUE. If the key has not been pressed or the scan code is invalid, return FALSE. This function will not clear the event. Use HasBeenPressedClear() to clear the event

Parameters
uScanCodeValid Scan code
Returns
TRUE if the key was pressed, FALSE if not
See also
HasBeenPressedClear(eScanCode)

◆ HasBeenPressedClear()

uint_t BURGER_API Burger::Keyboard::HasBeenPressedClear ( eScanCode uScanCode)
noexcept

Check if the requested key is currently or previously held down and clear the event.


If a key is pressed, clear the event and return TRUE, otherwise or if the scan code is invalid, return FALSE

Parameters
uScanCodeValid Scan code
Returns
TRUE if the key was pressed, FALSE if not
See also
HasBeenPressed(eScanCode)

◆ IsDirectInputActive()

uint_t Burger::Keyboard::IsDirectInputActive ( void ) const
inlinenoexcept

Is DirectInput active?


Returns TRUE is keyboard input is managed by DirectInput. This mode is only active if the game has focus and is full screen.

Note
This is only available on Windows
Returns
TRUE if DirectInput is active, FALSE if not

◆ IsPressed()

uint_t BURGER_API Burger::Keyboard::IsPressed ( eScanCode uScanCode) const
noexcept

Check if the requested key is currently held down.


If the key is currently held down, return TRUE, otherwise or if the scan code is invalid, return FALSE

Parameters
uScanCodeValid Scan code
Returns
TRUE if the key was pressed, FALSE if not

◆ Lock()

void Burger::Keyboard::Lock ( void )
inlineprotectednoexcept

◆ operator=() [1/2]

Keyboard & Burger::Keyboard::operator= ( const Keyboard & )
privatedelete

◆ operator=() [2/2]

Keyboard & Burger::Keyboard::operator= ( Keyboard && )
privatedelete

◆ PeekKeyEvent()

uint_t BURGER_API Burger::Keyboard::PeekKeyEvent ( KeyEvent_t * pEvent)
noexcept

Check if a keyboard event is pending.


See if a key is pending from the keyboard, if so, return the event without removing it from the queue.

Parameters
pEventPointer to a KeyEvent_t structure to receive the event.
Returns
Zero if no key was pending, non-zero if a keyboard event was retrieved.
See also
GetKeyEvent(KeyEvent_t *)

◆ PostKey()

uint_t BURGER_API Burger::Keyboard::PostKey ( eScanCode uScanCode)
noexcept

Post a scan code key down and a key up.


Given a keyboard scan code, post a key down event followed by a key up event

Parameters
uScanCodeKeyboard scan code
Returns
Zero if posted successfully, non-zero if not.
See also
PostKeyUp(eScanCode) or PostKeyDown(eScanCode)

◆ PostKeyDown()

uint_t BURGER_API Burger::Keyboard::PostKeyDown ( eScanCode uScanCode)
noexcept

Post a scan code key down.


Given a keyboard scan code, post a key down event

Parameters
uScanCodeKeyboard scan code
Returns
Zero if posted successfully, non-zero if not.
See also
PostKeyUp(eScanCode)

◆ PostKeyEvent()

uint_t BURGER_API Burger::Keyboard::PostKeyEvent ( const KeyEvent_t * pEvent)
noexcept

Post the keyboard event.


Given a valid keyboard event structure, post the event

Parameters
pEventPointer to a valid keyboard event
Returns
Zero if successful, error code if not

◆ PostKeyUp()

uint_t BURGER_API Burger::Keyboard::PostKeyUp ( eScanCode uScanCode)
noexcept

Post a scan code key up.


Given a keyboard scan code, post a key up event

Parameters
uScanCodeKeyboard scan code
Returns
Zero if posted successfully, non-zero if not.
See also
PostKeyDown(eScanCode)

◆ PostUnicode()

uint_t BURGER_API Burger::Keyboard::PostUnicode ( uint32_t uUnicode)
noexcept

Post an ASCII/Unicode key down.


Given an ASCII/Unicode character, post a key down event

Parameters
uUnicodeUnicode32 character
Returns
Zero if posted successfully, non-zero if not.
See also
PostUnicodeUp(uint32_t) or PostUnicodeDown(uint32_t)

◆ PostUnicodeDown()

uint_t BURGER_API Burger::Keyboard::PostUnicodeDown ( uint32_t uUnicode)
noexcept

Post an ASCII/Unicode key down.


Given an ASCII/Unicode character, post a key down event

Parameters
uUnicodeUnicode32 character
Returns
Zero if posted successfully, non-zero if not.
See also
PostUnicodeUp(uint32_t)

◆ PostUnicodeUp()

uint_t BURGER_API Burger::Keyboard::PostUnicodeUp ( uint32_t uUnicode)
noexcept

Post an ASCII/Unicode key up.


Given an ASCII/Unicode character, post a key up event

Parameters
uUnicodeUnicode32 character
Returns
Zero if posted successfully, non-zero if not.
See also
PostUnicodeDown(uint32_t)

◆ PostWindowsKeyEvent()

uint_t BURGER_API Burger::Keyboard::PostWindowsKeyEvent ( eEvent uEvent,
uint32_t uScanCode )
noexcept

Post a windows scan code key event.


Given a Windows keyboard scan code, convert it to a Burgerlib key press and post the event

Note
This is only available on Windows
Parameters
uEventType of key event to post
uScanCodeWindows keyboard scan code
Returns
Zero if posted successfully, non-zero if not.
See also
PostKeyEvent(const KeyEvent_t *)

◆ ProcessEvent()

void BURGER_API Burger::Keyboard::ProcessEvent ( NSEvent * pEvent)
noexcept

Process a MacOSX keystroke.


When an NSEvent is created that is of a type of NSKeyDown, NSKeyUp or NSFlagsChanged, this function will process the event into a Burgerlib compatible keystroke

Parameters
pEventPointer to a NSEvent with a keyboard event.

◆ ReadSystemKeyboardDelays()

void BURGER_API Burger::Keyboard::ReadSystemKeyboardDelays ( void )
noexcept

Read System keyboard delay constants (Windows only)


On startup and when a WM_SETTINGCHANGE event is triggered, read the settings for the keyboard auto-repeat from Windows and record it so auto-repeat is as the user requested it.

Note
This is only available on Windows

◆ RestoreAccessibilityShortcutKeys()

void BURGER_API Burger::Keyboard::RestoreAccessibilityShortcutKeys ( void )
noexcept

Restore the accessibility shortcut keys (Windows only)


Restore the accessibility shortcut keys to the settings that were captured upon instantiation of the Keyboard class

Note
This is only available on Windows
See also
DisableAccessibilityShortcutKeys(void)

◆ ScanCodeToString()

void BURGER_API Burger::Keyboard::ScanCodeToString ( char * pString,
uintptr_t uStringSize,
eScanCode uScanCode )
staticnoexcept

Convert a scan code into a string.


Given a Burgerlib keyboard scan code, return a string that best describes the scan code. If StringSize is 0, nothing will be done since the output buffer is invalid.

Parameters
pStringPointer to a "C" string buffer to store the result
uStringSizesizeof() the buffer to prevent overruns
uScanCodeValid Burgerlib scan code
See also
StringToScanCode()

◆ StringToScanCode()

Burger::Keyboard::eScanCode BURGER_API Burger::Keyboard::StringToScanCode ( const char * pString)
staticnoexcept

Convert a string to a scan code.


Given a pointer to a string describing a keyboard scan code. Look up the scan code and return the value. I return a -1 if there is no match.

Parameters
pStringPointer to a "C" string
Returns
Burgerlib scan code or a -1 if no match is found.
See also
ScanCodeToString()

◆ UnacquireDirectInput()

void BURGER_API Burger::Keyboard::UnacquireDirectInput ( void )
noexcept

Release DirectInput (Windows only)


Call Unacquire() on the DirectInput mouse device.

Note
This is only available on Windows
See also
AcquireDirectInput(void)

◆ Unlock()

void Burger::Keyboard::Unlock ( void )
inlineprotectednoexcept

◆ Wait()

uint_t BURGER_API Burger::Keyboard::Wait ( void )
noexcept

Wait for a key press.


Wait for a keypress, but call GetKey() to allow screen savers to kick in.

Returns
Unicode code of pressed key

◆ WindowsKeyboardThread()

uintptr_t BURGER_API Burger::Keyboard::WindowsKeyboardThread ( void * pData)
staticprotected

Windows thread for monitoring keyboard events (Windows only)


Burgerlib reads keyboard events using DirectInput and asynchronous thread events.

This function runs as a separate thread and processes all DirectInput events.

Note
This is used by the keyboard manager, it's not intended to be used by applications.
Parameters
pDataPointer to the Keyboard class instance
Returns
Zero when asked to shut down

Member Data Documentation

◆ g_StaticRTTI

const Burger::StaticRTTI Burger::Keyboard::g_StaticRTTI
static

◆ kBufferSize

const uint_t Burger::Keyboard::kBufferSize = 128
static

Number of keystrokes in keyboard cache.

◆ m_bDirectInput8Acquired

uint_t Burger::Keyboard::m_bDirectInput8Acquired
protected

TRUE if DirectInput8 is active (Windows only)

◆ m_bQuit

volatile uint32_t Burger::Keyboard::m_bQuit
protected

TRUE when the thread is shutting down (Windows only)

◆ m_bRepeatActive

uint_t Burger::Keyboard::m_bRepeatActive
protected

TRUE if auto repeat time is active (Windows only)

◆ m_DefaultFilterKeys

Burger_tagFILTERKEYS Burger::Keyboard::m_DefaultFilterKeys
protected

Previous settings for Filter Keys (Windows only)

◆ m_DefaultStickyKeys

Burger_tagSTICKYKEYS Burger::Keyboard::m_DefaultStickyKeys
protected

Previous settings for Sticky Keys (Windows only)

◆ m_DefaultToggleKeys

Burger_tagTOGGLEKEYS Burger::Keyboard::m_DefaultToggleKeys
protected

Previous settings for Toggle Keys (Windows only)

◆ m_KeyArray

uint8_t Burger::Keyboard::m_KeyArray[SC_MAXENTRY+1]
protected

Array with the current state of the keyboard.

◆ m_KeyboardLock

Mutex Burger::Keyboard::m_KeyboardLock
protected

Lock for multi-threading (MacOSX and Windows only)

◆ m_KeyboardThread

Thread Burger::Keyboard::m_KeyboardThread
protected

Asynchronous thread monitoring DirectInput (Windows only)

◆ m_KeyEvents

KeyEvent_t Burger::Keyboard::m_KeyEvents[kBufferSize]
protected

Circular buffer holding keyboard events.

◆ m_pAppInstance

GameApp* Burger::Keyboard::m_pAppInstance
protected

Application instances.

◆ m_pKeyboardDevice

IDirectInputDevice8W* Burger::Keyboard::m_pKeyboardDevice
protected

DirectInput Device reference (Windows only)

◆ m_pKeyboardEvent

void* Burger::Keyboard::m_pKeyboardEvent
protected

Event signal for DirectInput (Windows only)

◆ m_pKeyboardTimerEvent

void* Burger::Keyboard::m_pKeyboardTimerEvent
protected

Keyboard repeat timer event (Windows only)

◆ m_pPreviousKeyboardHook

HHOOK__* Burger::Keyboard::m_pPreviousKeyboardHook
protected

Previous keyboard low level hook.

◆ m_RepeatEvent

KeyEvent_t Burger::Keyboard::m_RepeatEvent
protected

Event to post on a repeat.

◆ m_uArrayEnd

uint_t Burger::Keyboard::m_uArrayEnd
protected

Write index for m_KeyEvents.

◆ m_uArrayStart

uint_t Burger::Keyboard::m_uArrayStart
protected

Read index for m_KeyEvents.

◆ m_uInitialDelay

uint_t Burger::Keyboard::m_uInitialDelay
protected

Initial delay in ms for autorepeat.

◆ m_uRepeatDelay

uint_t Burger::Keyboard::m_uRepeatDelay
protected

Delay between repeating keystrokes.