openMSX
Classes | Enumerations | Functions
openmsx::Keys Namespace Reference

Classes

struct  CmpKeys
 
struct  P
 

Enumerations

enum  KeyCode {
  K_MASK = 0x1FFFF , K_NONE = K_MASK , K_UNKNOWN = 0 , K_BACKSPACE = 8 ,
  K_TAB = 9 , K_CLEAR = 12 , K_RETURN = 13 , K_PAUSE = 19 ,
  K_ESCAPE = 27 , K_SPACE = ' ' , K_EXCLAIM = '!' , K_QUOTEDBL = '"' ,
  K_HASH = '#' , K_DOLLAR = '$' , K_AMPERSAND = '&' , K_QUOTE = '\'' ,
  K_LEFTPAREN = '(' , K_RIGHTPAREN = ')' , K_ASTERISK = '*' , K_PLUS = '+' ,
  K_COMMA = ',' , K_MINUS = '-' , K_PERIOD = '.' , K_SLASH = '/' ,
  K_0 = '0' , K_1 = '1' , K_2 = '2' , K_3 = '3' ,
  K_4 = '4' , K_5 = '5' , K_6 = '6' , K_7 = '7' ,
  K_8 = '8' , K_9 = '9' , K_COLON = ':' , K_SEMICOLON = ';' ,
  K_LESS = '<' , K_EQUALS = '=' , K_GREATER = '>' , K_QUESTION = '?' ,
  K_AT = '@' , K_LEFTBRACKET = '[' , K_BACKSLASH = '\\' , K_RIGHTBRACKET = ']' ,
  K_CARET = '^' , K_UNDERSCORE = '_' , K_BACKQUOTE = '`' , K_A = 'a' ,
  K_B = 'b' , K_C = 'c' , K_D = 'd' , K_E = 'e' ,
  K_F = 'f' , K_G = 'g' , K_H = 'h' , K_I = 'i' ,
  K_J = 'j' , K_K = 'k' , K_L = 'l' , K_M = 'm' ,
  K_N = 'n' , K_O = 'o' , K_P = 'p' , K_Q = 'q' ,
  K_R = 'r' , K_S = 's' , K_T = 't' , K_U = 'u' ,
  K_V = 'v' , K_W = 'w' , K_X = 'x' , K_Y = 'y' ,
  K_Z = 'z' , K_DELETE = 127 , K_KP0 = 0x100 , K_KP1 = 0x101 ,
  K_KP2 = 0x102 , K_KP3 = 0x103 , K_KP4 = 0x104 , K_KP5 = 0x105 ,
  K_KP6 = 0x106 , K_KP7 = 0x107 , K_KP8 = 0x108 , K_KP9 = 0x109 ,
  K_KP_PERIOD = 0x10A , K_KP_DIVIDE = 0x10B , K_KP_MULTIPLY = 0x10C , K_KP_MINUS = 0x10D ,
  K_KP_PLUS = 0x10E , K_KP_ENTER = 0x10F , K_KP_EQUALS = 0x110 , K_UP = 0x111 ,
  K_DOWN = 0x112 , K_RIGHT = 0x113 , K_LEFT = 0x114 , K_INSERT = 0x115 ,
  K_HOME = 0x116 , K_END = 0x117 , K_PAGEUP = 0x118 , K_PAGEDOWN = 0x119 ,
  K_F1 = 0x11A , K_F2 = 0x11B , K_F3 = 0x11C , K_F4 = 0x11D ,
  K_F5 = 0x11E , K_F6 = 0x11F , K_F7 = 0x120 , K_F8 = 0x121 ,
  K_F9 = 0x122 , K_F10 = 0x123 , K_F11 = 0x124 , K_F12 = 0x125 ,
  K_F13 = 0x126 , K_F14 = 0x127 , K_F15 = 0x128 , K_F16 = 0x129 ,
  K_F17 = 0x12A , K_F18 = 0x12B , K_F19 = 0x144 , K_F20 = 0x145 ,
  K_F21 = 0x146 , K_F22 = 0x147 , K_F23 = 0x148 , K_F24 = 0x149 ,
  K_NUMLOCK = 0x12C , K_CAPSLOCK = 0x12D , K_SCROLLLOCK = 0x12E , K_RSHIFT = 0x12F ,
  K_LSHIFT = 0x130 , K_RCTRL = 0x131 , K_LCTRL = 0x132 , K_RALT = 0x133 ,
  K_LALT = 0x134 , K_LSUPER = 0x137 , K_RSUPER = 0x138 , K_MODE = 0x139 ,
  K_HELP = 0x13B , K_PRINT = 0x13C , K_SYSREQ = 0x13D , K_MENU = 0x13F ,
  K_POWER = 0x140 , K_UNDO = 0x142 , K_BACK = 0x143 , K_ZENKAKU_HENKAKU = 0x10000 ,
  K_MUHENKAN = 0x10001 , K_HENKAN_MODE = 0x10002 , K_HIRAGANA_KATAKANA = 0x10003 , KM_SHIFT = 0x020000 ,
  KM_CTRL = 0x040000 , KM_ALT = 0x080000 , KM_META = 0x100000 , KM_MODE = 0x200000 ,
  KD_PRESS = 0 , KD_RELEASE = 0x400000
}
 Constants that identify keys and key modifiers. More...
 

Functions

KeyCode getCode (std::string_view name)
 Translate key name to key code. More...
 
std::pair< KeyCode, KeyCodegetCodes (SDL_Keycode keyCode, Uint16 mod=KMOD_NONE, SDL_Scancode scanCode=SDL_SCANCODE_UNKNOWN, bool release=false)
 Translate SDL_Keycode/SDL_Scancode into openMSX key/scan Keycode's. More...
 
std::string getName (KeyCode keyCode)
 Translate key code to key name. More...
 
KeyCode combine (KeyCode key, KeyCode modifier)
 Convenience method to create key combinations (hides ugly casts). More...
 

Enumeration Type Documentation

◆ KeyCode

Constants that identify keys and key modifiers.

There are two special key codes:

  • K_NONE : returned when we do string -> key code translation and there is no key with given name. Most likely the keyname was misspelled.
  • K_UNKNOWN : this code is returned when a real key was pressed, but we have no idea which key it is. Should only happen when the user has some exotic keyboard. Note that it might be possible that there are multiple keys that produce this code.
Enumerator
K_MASK 
K_NONE 
K_UNKNOWN 
K_BACKSPACE 
K_TAB 
K_CLEAR 
K_RETURN 
K_PAUSE 
K_ESCAPE 
K_SPACE 
K_EXCLAIM 
K_QUOTEDBL 
K_HASH 
K_DOLLAR 
K_AMPERSAND 
K_QUOTE 
K_LEFTPAREN 
K_RIGHTPAREN 
K_ASTERISK 
K_PLUS 
K_COMMA 
K_MINUS 
K_PERIOD 
K_SLASH 
K_0 
K_1 
K_2 
K_3 
K_4 
K_5 
K_6 
K_7 
K_8 
K_9 
K_COLON 
K_SEMICOLON 
K_LESS 
K_EQUALS 
K_GREATER 
K_QUESTION 
K_AT 
K_LEFTBRACKET 
K_BACKSLASH 
K_RIGHTBRACKET 
K_CARET 
K_UNDERSCORE 
K_BACKQUOTE 
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_DELETE 
K_KP0 
K_KP1 
K_KP2 
K_KP3 
K_KP4 
K_KP5 
K_KP6 
K_KP7 
K_KP8 
K_KP9 
K_KP_PERIOD 
K_KP_DIVIDE 
K_KP_MULTIPLY 
K_KP_MINUS 
K_KP_PLUS 
K_KP_ENTER 
K_KP_EQUALS 
K_UP 
K_DOWN 
K_RIGHT 
K_LEFT 
K_INSERT 
K_HOME 
K_END 
K_PAGEUP 
K_PAGEDOWN 
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_F13 
K_F14 
K_F15 
K_F16 
K_F17 
K_F18 
K_F19 
K_F20 
K_F21 
K_F22 
K_F23 
K_F24 
K_NUMLOCK 
K_CAPSLOCK 
K_SCROLLLOCK 
K_RSHIFT 
K_LSHIFT 
K_RCTRL 
K_LCTRL 
K_RALT 
K_LALT 
K_LSUPER 
K_RSUPER 
K_MODE 
K_HELP 
K_PRINT 
K_SYSREQ 
K_MENU 
K_POWER 
K_UNDO 
K_BACK 
K_ZENKAKU_HENKAKU 
K_MUHENKAN 
K_HENKAN_MODE 
K_HIRAGANA_KATAKANA 
KM_SHIFT 
KM_CTRL 
KM_ALT 
KM_META 
KM_MODE 
KD_PRESS 
KD_RELEASE 

Definition at line 26 of file Keys.hh.

Function Documentation

◆ combine()

KeyCode openmsx::Keys::combine ( KeyCode  key,
KeyCode  modifier 
)
inline

Convenience method to create key combinations (hides ugly casts).

Definition at line 234 of file Keys.hh.

Referenced by openmsx::PixelOperations< Pixel >::blend(), getCodes(), and openmsx::PixelOperations< Pixel >::lerp().

◆ getCode()

KeyCode openmsx::Keys::getCode ( std::string_view  name)

Translate key name to key code.

Returns K_NONE when the name is unknown.

Definition at line 330 of file Keys.cc.

References binary_find(), K_MASK, and K_NONE.

Referenced by openmsx::KeyCodeSetting::getKey(), and openmsx::KeyCodeSetting::KeyCodeSetting().

◆ getCodes()

std::pair< KeyCode, KeyCode > openmsx::Keys::getCodes ( SDL_Keycode  sdlKeyCode,
Uint16  mod,
SDL_Scancode  sdlScanCode,
bool  release 
)

◆ getName()

std::string openmsx::Keys::getName ( KeyCode  keyCode)

Translate key code to key name.

Returns the string "unknown" for unknown key codes.

Definition at line 730 of file Keys.cc.

References K_MASK, KD_RELEASE, KM_ALT, KM_CTRL, KM_META, KM_MODE, and KM_SHIFT.

Referenced by openmsx::ArchiveBase< Derived >::serializeBase(), openmsx::toTclList(), and openmsx::ChakkariCopy::writeIO().