StuBS
Key Struct Reference

Class that abstracts a key, made up of the scan code and the modifier bits. More...

#include <object/key.h>

Public Types

enum  Scancode : uint8_t {
  KEY_INVALID = 0 ,
  KEY_ESCAPE ,
  KEY_1 ,
  KEY_2 ,
  KEY_3 ,
  KEY_4 ,
  KEY_5 ,
  KEY_6 ,
  KEY_7 ,
  KEY_8 ,
  KEY_9 ,
  KEY_0 ,
  KEY_DASH ,
  KEY_EQUAL ,
  KEY_BACKSPACE ,
  KEY_TAB ,
  KEY_Q ,
  KEY_W ,
  KEY_E ,
  KEY_R ,
  KEY_T ,
  KEY_Y ,
  KEY_U ,
  KEY_I ,
  KEY_O ,
  KEY_P ,
  KEY_OPEN_BRACKET ,
  KEY_CLOSE_BRACKET ,
  KEY_ENTER ,
  KEY_LEFT_CTRL ,
  KEY_A ,
  KEY_S ,
  KEY_D ,
  KEY_F ,
  KEY_G ,
  KEY_H ,
  KEY_J ,
  KEY_K ,
  KEY_L ,
  KEY_SEMICOLON ,
  KEY_APOSTROPH ,
  KEY_GRAVE_ACCENT ,
  KEY_LEFT_SHIFT ,
  KEY_BACKSLASH ,
  KEY_Z ,
  KEY_X ,
  KEY_C ,
  KEY_V ,
  KEY_B ,
  KEY_N ,
  KEY_M ,
  KEY_COMMA ,
  KEY_PERIOD ,
  KEY_SLASH ,
  KEY_RIGHT_SHIFT ,
  KEY_KP_STAR ,
  KEY_LEFT_ALT ,
  KEY_SPACEBAR ,
  KEY_CAPS_LOCK ,
  KEY_F1 ,
  KEY_F2 ,
  KEY_F3 ,
  KEY_F4 ,
  KEY_F5 ,
  KEY_F6 ,
  KEY_F7 ,
  KEY_F8 ,
  KEY_F9 ,
  KEY_F10 ,
  KEY_NUM_LOCK ,
  KEY_SCROLL_LOCK ,
  KEY_KP_7 ,
  KEY_KP_8 ,
  KEY_KP_9 ,
  KEY_KP_DASH ,
  KEY_KP_4 ,
  KEY_KP_5 ,
  KEY_KP_6 ,
  KEY_KP_PLUS ,
  KEY_KP_1 ,
  KEY_KP_2 ,
  KEY_KP_3 ,
  KEY_KP_0 ,
  KEY_KP_PERIOD ,
  KEY_SYSREQ ,
  KEY_EUROPE_2 ,
  KEY_F11 ,
  KEY_F12 ,
  KEY_KP_EQUAL ,
  KEYS ,
  KEY_DIV = KEY_7 ,
  KEY_DEL = KEY_KP_PERIOD ,
  KEY_UP = KEY_KP_8 ,
  KEY_DOWN = KEY_KP_2 ,
  KEY_LEFT = KEY_KP_4 ,
  KEY_RIGHT = KEY_KP_6
}
 The keys' scan codes (code 1)
 

Public Member Functions

 Key ()
 Default constructor: Instantiates an invalid key by setting ASCII, scan code, and modifier bits to 0.
 
bool valid () const
 Invalid keys have a scancode = 0. More...
 
void invalidate ()
 Marks the key as invalid by setting the scan code to 0.
 
unsigned char ascii () const
 Get the key's ASCII value. More...
 
bool alt () const
 Indicates whether the ALT modifier is set. More...
 
bool ctrl () const
 Indicates whether the CTRL modifier is set. More...
 
 operator char () const
 Conversion to char (ASCII code)
 

Public Attributes

Scancode scancode
 
bool shift: 1
 
bool alt_left: 1
 
bool alt_right: 1
 
bool ctrl_left: 1
 
bool ctrl_right: 1
 
bool caps_lock: 1
 
bool num_lock: 1
 
bool scroll_lock: 1
 

Detailed Description

Class that abstracts a key, made up of the scan code and the modifier bits.

Member Function Documentation

◆ valid()

bool Key::valid ( ) const
inline

Invalid keys have a scancode = 0.

Returns
Checks whether a key is valid.

◆ ascii()

unsigned char Key::ascii ( ) const

Get the key's ASCII value.

Returns
the key's ASCII value

◆ alt()

bool Key::alt ( ) const
inline

Indicates whether the ALT modifier is set.

Returns
true if ALT key was pressed during key press

◆ ctrl()

bool Key::ctrl ( ) const
inline

Indicates whether the CTRL modifier is set.

Returns
true if CTRL key was pressed during key press

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