lxgui
Loading...
Searching...
No Matches
input_keys.hpp
1#ifndef LXGUI_INPUT_KEYS_HPP
2#define LXGUI_INPUT_KEYS_HPP
3
4#include "lxgui/lxgui.hpp"
5
6#include <cstdint>
7#include <optional>
8#include <string_view>
9
10namespace lxgui::input {
11
12enum class mouse_button : std::uint8_t { left = 0, right, middle };
13
14enum class mouse_button_event : std::uint8_t { up = 0, down = 1, double_click = 2 };
15
16enum class key : std::uint8_t {
17 k_unassigned = 0x00,
18 k_escape = 0x01,
19 k_1 = 0x02,
20 k_2 = 0x03,
21 k_3 = 0x04,
22 k_4 = 0x05,
23 k_5 = 0x06,
24 k_6 = 0x07,
25 k_7 = 0x08,
26 k_8 = 0x09,
27 k_9 = 0x0A,
28 k_0 = 0x0B,
29 k_minus = 0x0C,
30 k_equals = 0x0D,
31 k_back = 0x0E,
32 k_tab = 0x0F,
33 k_q = 0x10,
34 k_w = 0x11,
35 k_e = 0x12,
36 k_r = 0x13,
37 k_t = 0x14,
38 k_y = 0x15,
39 k_u = 0x16,
40 k_i = 0x17,
41 k_o = 0x18,
42 k_p = 0x19,
43 k_lbracket = 0x1A,
44 k_rbracket = 0x1B,
45 k_return = 0x1C,
46 k_lcontrol = 0x1D,
47 k_a = 0x1E,
48 k_s = 0x1F,
49 k_d = 0x20,
50 k_f = 0x21,
51 k_g = 0x22,
52 k_h = 0x23,
53 k_j = 0x24,
54 k_k = 0x25,
55 k_l = 0x26,
56 k_semicolon = 0x27,
57 k_apostrophe = 0x28,
58 k_grave = 0x29,
59 k_lshift = 0x2A,
60 k_backslash = 0x2B,
61 k_z = 0x2C,
62 k_x = 0x2D,
63 k_c = 0x2E,
64 k_v = 0x2F,
65 k_b = 0x30,
66 k_n = 0x31,
67 k_m = 0x32,
68 k_comma = 0x33,
69 k_period = 0x34,
70 k_slash = 0x35,
71 k_rshift = 0x36,
72 k_multiply = 0x37,
73 k_lmenu = 0x38,
74 k_space = 0x39,
75 k_capital = 0x3A,
76 k_f1 = 0x3B,
77 k_f2 = 0x3C,
78 k_f3 = 0x3D,
79 k_f4 = 0x3E,
80 k_f5 = 0x3F,
81 k_f6 = 0x40,
82 k_f7 = 0x41,
83 k_f8 = 0x42,
84 k_f9 = 0x43,
85 k_f10 = 0x44,
86 k_numlock = 0x45,
87 k_scroll = 0x46,
88 k_numpad_7 = 0x47,
89 k_numpad_8 = 0x48,
90 k_numpad_9 = 0x49,
91 k_subtract = 0x4A,
92 k_numpad_4 = 0x4B,
93 k_numpad_5 = 0x4C,
94 k_numpad_6 = 0x4D,
95 k_add = 0x4E,
96 k_numpad_1 = 0x4F,
97 k_numpad_2 = 0x50,
98 k_numpad_3 = 0x51,
99 k_numpad_0 = 0x52,
100 k_decimal = 0x53,
101 k_oem_102 = 0x56,
102 k_f11 = 0x57,
103 k_f12 = 0x58,
104 k_f13 = 0x64,
105 k_f14 = 0x65,
106 k_f15 = 0x66,
107 k_kana = 0x70,
108 k_abnt_c1 = 0x73,
109 k_convert = 0x79,
110 k_noconvert = 0x7B,
111 k_yen = 0x7D,
112 k_abnt_c2 = 0x7E,
113 k_numpadequals = 0x8D,
114 k_prevtrack = 0x90,
115 k_at = 0x91,
116 k_colon = 0x92,
117 k_underline = 0x93,
118 k_kanji = 0x94,
119 k_stop = 0x95,
120 k_ax = 0x96,
121 k_unlabeled = 0x97,
122 k_nexttrack = 0x99,
123 k_numpadenter = 0x9C,
124 k_rcontrol = 0x9D,
125 k_mute = 0xA0,
126 k_calculator = 0xA1,
127 k_playpause = 0xA2,
128 k_mediastop = 0xA4,
129 k_volumedown = 0xAE,
130 k_volumeup = 0xB0,
131 k_webhome = 0xB2,
132 k_numpadcomma = 0xB3,
133 k_divide = 0xB5,
134 k_sysrq = 0xB7,
135 k_rmenu = 0xB8,
136 k_pause = 0xC5,
137 k_home = 0xC7,
138 k_up = 0xC8,
139 k_pgup = 0xC9,
140 k_left = 0xCB,
141 k_right = 0xCD,
142 k_end = 0xCF,
143 k_down = 0xD0,
144 k_pgdown = 0xD1,
145 k_insert = 0xD2,
146 k_delete = 0xD3,
147 k_lwin = 0xDB,
148 k_rwin = 0xDC,
149 k_apps = 0xDD,
150 k_power = 0xDE,
151 k_sleep = 0xDF,
152 k_wake = 0xE3,
153 k_websearch = 0xE5,
154 k_webfavorites = 0xE6,
155 k_webrefresh = 0xE7,
156 k_webstop = 0xE8,
157 k_webforward = 0xE9,
158 k_webback = 0xEA,
159 k_mycomputer = 0xEB,
160 k_mail = 0xEC,
161 k_mediaselect = 0xED,
162 k_maxkey = 0xFF
163};
164
173std::string_view get_mouse_button_codename(mouse_button button_id);
174
182std::string_view get_localizable_mouse_button_name(mouse_button button_id);
183
192std::string_view get_mouse_button_event_codename(mouse_button_event button_event);
193
202
212std::string_view
214
220std::optional<std::pair<mouse_button, mouse_button_event>>
221get_mouse_button_and_event_from_codename(std::string_view button_and_event_name);
222
231std::string_view get_key_codename(key key_id);
232
239key get_key_from_codename(std::string_view key_name);
240
248std::string_view get_localizable_key_name(key key_id);
249
250constexpr std::size_t mouse_button_number = 3u;
251constexpr std::size_t key_number = static_cast<std::size_t>(key::k_maxkey);
252
253} // namespace lxgui::input
254
255#endif
std::string_view get_mouse_button_event_codename(mouse_button_event button_event)
Returns a standard English name for the provided mouse button event.
std::string_view get_localizable_mouse_button_name(mouse_button button_id)
Returns the localizable name of the provided mouse button.
std::optional< std::pair< mouse_button, mouse_button_event > > get_mouse_button_and_event_from_codename(std::string_view button_and_event_name)
Returns a mouse button and a button event ID from a string formatted as "<button>:<event>".
@ k_convert
/ ? on Portugese (Brazilian) keyboards
@ k_webfavorites
Web Search.
@ k_tab
Backspace.
@ k_abnt_c2
(Japanese keyboard)
@ k_f15
(NEC PC98)
@ k_space
Left Alt.
@ k_pause
Right Alt.
@ k_rwin
Left Windows key.
@ k_apps
Right Windows key.
@ k_mail
My Computer.
@ k_pgup
UpArrow on arrow keypad.
@ k_end
RightArrow on arrow keypad.
@ k_left
PgUp on arrow keypad.
@ k_delete
Insert on arrow keypad.
@ k_underline
(NEC PC98)
@ k_sysrq
/ on numeric keypad
@ k_prevtrack
= on numeric keypad (NEC PC98)
@ k_numpadenter
Next Track.
@ k_webrefresh
Web Favorites.
@ k_webstop
Web Refresh.
@ k_ax
(NEC PC98)
@ k_volumedown
Media Stop.
@ k_oem_102
. on numeric keypad
@ k_kana
(NEC PC98)
@ k_lwin
Delete on arrow keypad.
@ k_sleep
System Power.
@ k_websearch
System Wake.
@ k_kanji
(NEC PC98)
@ k_webforward
Web Stop.
@ k_lcontrol
Enter on main keyboard.
@ k_insert
PgDn on arrow keypad.
@ k_down
End on arrow keypad.
@ k_mediastop
Play / Pause.
@ k_volumeup
Volume -.
@ k_playpause
Calculator.
@ k_nexttrack
(J3100)
@ k_wake
System Sleep.
@ k_right
LeftArrow on arrow keypad.
@ k_stop
(Japanese keyboard)
@ k_webback
Web Forward.
@ k_numpadcomma
Web home.
@ k_power
AppMenu key.
@ k_abnt_c1
(Japanese keyboard)
@ k_up
Home on arrow keypad.
@ k_rshift
/ on main keyboard
@ k_f14
(NEC PC98)
@ k_slash
. on main keyboard
@ k_pgdown
DownArrow on arrow keypad.
@ k_f11
< > | on UK/Germany keyboards
@ k_numpadequals
Numpad . on Portugese (Brazilian) keyboards.
@ k_rcontrol
Enter on numeric keypad.
@ k_yen
(Japanese keyboard)
@ k_unlabeled
(Japan AX)
@ k_noconvert
(Japanese keyboard)
@ k_at
Previous Track (K_CIRCUMFLEX on Japanese keyboard)
@ k_webhome
Volume +.
@ k_colon
(NEC PC98)
@ k_divide
, on numeric keypad (NEC PC98)
@ k_numpad_7
Scroll Lock.
@ k_maxkey
Media Select.
@ k_mycomputer
Web Back.
std::string_view get_localizable_key_name(key key_id)
Returns the localizable name of the provided key.
std::string_view get_mouse_button_codename(mouse_button button_id)
Returns a standard English name for the provided mouse button.
Definition input_keys.cpp:7
std::string_view get_localizable_mouse_button_event_name(mouse_button_event button_event)
Returns the localizable name of the provided mouse button event.
key get_key_from_codename(std::string_view key_name)
Returns the key code from the standard English name of a key.
constexpr std::size_t key_number
constexpr std::size_t mouse_button_number
std::string_view get_mouse_button_and_event_codename(mouse_button button_id, mouse_button_event button_event)
Returns a standard Engilsh name for the provided mouse button and event.
std::string_view get_key_codename(key key_id)
Returns a standard English name for the provided key.