HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
keyboard_virtual_key_win32_impl.hpp
1// Copyright Take Vos 2021-2022.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
8
9#include "keyboard_virtual_key_intf.hpp"
10#include "keyboard_modifiers.hpp"
11#include "../macros.hpp"
12
13hi_export_module(hikogui.GUI : keyboard_virtual_key_impl);
14
15hi_export namespace hi::inline v1 {
16
17[[nodiscard]] constexpr keyboard_virtual_key to_keyboard_virtual_key(int key_code, bool extended, keyboard_modifiers modifiers) noexcept
18{
19 switch (key_code) {
20 case VK_MENU:
21 return keyboard_virtual_key::menu;
22 case VK_BACK:
23 return keyboard_virtual_key::backspace;
24 case VK_TAB:
25 return keyboard_virtual_key::tab;
26 case VK_CLEAR:
27 return keyboard_virtual_key::clear;
28 case VK_RETURN:
29 return keyboard_virtual_key::enter;
30 case VK_PAUSE:
31 return keyboard_virtual_key::pause_break;
32 case VK_ESCAPE:
33 return keyboard_virtual_key::escape;
34 case VK_SPACE:
35 return keyboard_virtual_key::space;
36 case VK_PRIOR:
37 return keyboard_virtual_key::page_up;
38 case VK_NEXT:
39 return keyboard_virtual_key::page_down;
40 case VK_END:
41 return keyboard_virtual_key::end;
42 case VK_HOME:
43 return keyboard_virtual_key::home;
44 case VK_LEFT:
45 return keyboard_virtual_key::left;
46 case VK_UP:
47 return keyboard_virtual_key::up;
48 case VK_RIGHT:
49 return keyboard_virtual_key::right;
50 case VK_DOWN:
51 return keyboard_virtual_key::down;
52 case VK_PRINT:
53 return keyboard_virtual_key::print_screen;
54 case VK_SNAPSHOT:
55 return keyboard_virtual_key::print_screen;
56 case VK_INSERT:
57 return keyboard_virtual_key::insert;
58 case VK_DELETE:
59 return keyboard_virtual_key::_delete;
60 case '0':
61 return keyboard_virtual_key::_0;
62 case '1':
63 return keyboard_virtual_key::_1;
64 case '2':
65 return keyboard_virtual_key::_2;
66 case '3':
67 return keyboard_virtual_key::_3;
68 case '4':
69 return keyboard_virtual_key::_4;
70 case '5':
71 return keyboard_virtual_key::_5;
72 case '6':
73 return keyboard_virtual_key::_6;
74 case '7':
75 return keyboard_virtual_key::_7;
76 case '8':
77 return keyboard_virtual_key::_8;
78 case '9':
79 return keyboard_virtual_key::_9;
80 case 'A':
81 return keyboard_virtual_key::A;
82 case 'B':
83 return keyboard_virtual_key::B;
84 case 'C':
85 return keyboard_virtual_key::C;
86 case 'D':
87 return keyboard_virtual_key::D;
88 case 'E':
89 return keyboard_virtual_key::E;
90 case 'F':
91 return keyboard_virtual_key::F;
92 case 'G':
93 return keyboard_virtual_key::G;
94 case 'H':
95 return keyboard_virtual_key::H;
96 case 'I':
97 return keyboard_virtual_key::I;
98 case 'J':
99 return keyboard_virtual_key::J;
100 case 'K':
101 return keyboard_virtual_key::K;
102 case 'L':
103 return keyboard_virtual_key::L;
104 case 'M':
105 return keyboard_virtual_key::M;
106 case 'N':
107 return keyboard_virtual_key::N;
108 case 'O':
109 return keyboard_virtual_key::O;
110 case 'P':
111 return keyboard_virtual_key::P;
112 case 'Q':
113 return keyboard_virtual_key::Q;
114 case 'R':
115 return keyboard_virtual_key::R;
116 case 'S':
117 return keyboard_virtual_key::S;
118 case 'T':
119 return keyboard_virtual_key::T;
120 case 'U':
121 return keyboard_virtual_key::U;
122 case 'V':
123 return keyboard_virtual_key::V;
124 case 'W':
125 return keyboard_virtual_key::W;
126 case 'X':
127 return keyboard_virtual_key::X;
128 case 'Y':
129 return keyboard_virtual_key::Y;
130 case 'Z':
131 return keyboard_virtual_key::Z;
132 case VK_NUMPAD0:
133 return keyboard_virtual_key::_0;
134 case VK_NUMPAD1:
135 return keyboard_virtual_key::_1;
136 case VK_NUMPAD2:
137 return keyboard_virtual_key::_2;
138 case VK_NUMPAD3:
139 return keyboard_virtual_key::_3;
140 case VK_NUMPAD4:
141 return keyboard_virtual_key::_4;
142 case VK_NUMPAD5:
143 return keyboard_virtual_key::_5;
144 case VK_NUMPAD6:
145 return keyboard_virtual_key::_6;
146 case VK_NUMPAD7:
147 return keyboard_virtual_key::_7;
148 case VK_NUMPAD8:
149 return keyboard_virtual_key::_8;
150 case VK_NUMPAD9:
151 return keyboard_virtual_key::_9;
152 case VK_MULTIPLY:
153 return keyboard_virtual_key::star;
154 case VK_ADD:
155 return keyboard_virtual_key::plus;
156 case VK_SUBTRACT:
157 return keyboard_virtual_key::minus;
158 case VK_DECIMAL:
159 return keyboard_virtual_key::period;
160 case VK_DIVIDE:
161 return keyboard_virtual_key::slash;
162 case VK_F1:
163 return keyboard_virtual_key::F1;
164 case VK_F2:
165 return keyboard_virtual_key::F2;
166 case VK_F3:
167 return keyboard_virtual_key::F3;
168 case VK_F4:
169 return keyboard_virtual_key::F4;
170 case VK_F5:
171 return keyboard_virtual_key::F5;
172 case VK_F6:
173 return keyboard_virtual_key::F6;
174 case VK_F7:
175 return keyboard_virtual_key::F7;
176 case VK_F8:
177 return keyboard_virtual_key::F8;
178 case VK_F9:
179 return keyboard_virtual_key::F9;
180 case VK_F10:
181 return keyboard_virtual_key::F10;
182 case VK_F11:
183 return keyboard_virtual_key::F11;
184 case VK_F12:
185 return keyboard_virtual_key::F12;
186 case VK_F13:
187 return keyboard_virtual_key::F13;
188 case VK_F14:
189 return keyboard_virtual_key::F14;
190 case VK_F15:
191 return keyboard_virtual_key::F15;
192 case VK_F16:
193 return keyboard_virtual_key::F16;
194 case VK_F17:
195 return keyboard_virtual_key::F17;
196 case VK_F18:
197 return keyboard_virtual_key::F18;
198 case VK_F19:
199 return keyboard_virtual_key::F19;
200 case VK_F20:
201 return keyboard_virtual_key::F20;
202 case VK_F21:
203 return keyboard_virtual_key::F21;
204 case VK_F22:
205 return keyboard_virtual_key::F22;
206 case VK_F23:
207 return keyboard_virtual_key::F23;
208 case VK_F24:
209 return keyboard_virtual_key::F24;
210 case VK_BROWSER_BACK:
211 return keyboard_virtual_key::browser_back;
212 case VK_BROWSER_FORWARD:
213 return keyboard_virtual_key::browser_forward;
214 case VK_BROWSER_REFRESH:
215 return keyboard_virtual_key::browser_refresh;
216 case VK_BROWSER_STOP:
217 return keyboard_virtual_key::browser_stop;
218 case VK_BROWSER_SEARCH:
219 return keyboard_virtual_key::browser_search;
220 case VK_BROWSER_FAVORITES:
221 return keyboard_virtual_key::browser_favorites;
222 case VK_BROWSER_HOME:
223 return keyboard_virtual_key::browser_home;
224 case VK_VOLUME_MUTE:
225 return keyboard_virtual_key::volume_mute;
226 case VK_VOLUME_DOWN:
227 return keyboard_virtual_key::volume_down;
228 case VK_VOLUME_UP:
229 return keyboard_virtual_key::volume_up;
230 case VK_MEDIA_NEXT_TRACK:
231 return keyboard_virtual_key::media_next_track;
232 case VK_MEDIA_PREV_TRACK:
233 return keyboard_virtual_key::media_prev_track;
234 case VK_MEDIA_STOP:
235 return keyboard_virtual_key::media_stop;
236 case VK_MEDIA_PLAY_PAUSE:
237 return keyboard_virtual_key::media_play_pause;
238 case VK_OEM_1:
239 return to_bool(modifiers & keyboard_modifiers::shift) ? keyboard_virtual_key::colon : keyboard_virtual_key::semi_colon;
240 case VK_OEM_PLUS:
241 return keyboard_virtual_key::plus;
242 case VK_OEM_COMMA:
243 return keyboard_virtual_key::comma;
244 case VK_OEM_MINUS:
245 return keyboard_virtual_key::minus;
246 case VK_OEM_PERIOD:
247 return keyboard_virtual_key::period;
248 case VK_OEM_2:
249 return to_bool(modifiers & keyboard_modifiers::shift) ? keyboard_virtual_key::question : keyboard_virtual_key::slash;
250 case VK_OEM_3:
251 return to_bool(modifiers & keyboard_modifiers::shift) ? keyboard_virtual_key::tilde : keyboard_virtual_key::backtick;
252 case VK_OEM_4:
253 return to_bool(modifiers & keyboard_modifiers::shift) ? keyboard_virtual_key::open_brace :
254 keyboard_virtual_key::open_bracket;
255 case VK_OEM_5:
256 return to_bool(modifiers & keyboard_modifiers::shift) ? keyboard_virtual_key::pipe : keyboard_virtual_key::backslash;
257 case VK_OEM_6:
258 return to_bool(modifiers & keyboard_modifiers::shift) ? keyboard_virtual_key::close_brace :
259 keyboard_virtual_key::close_bracket;
260 case VK_OEM_7:
261 return to_bool(modifiers & keyboard_modifiers::shift) ? keyboard_virtual_key::double_quote : keyboard_virtual_key::quote;
262 case VK_PLAY:
263 return keyboard_virtual_key::media_play_pause;
264 case VK_OEM_CLEAR:
265 return keyboard_virtual_key::clear;
266 default:
267 return keyboard_virtual_key::nul;
268 }
269}
270
271} // namespace hi::inline v1
Rules for working with win32 headers.
DOXYGEN BUG.
Definition algorithm_misc.hpp:20