YSTest: Keys.h 源文件

YSTest PreAlpha_b800_20170810 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

Keys.h
浏览该文件的文档.
1 /*
2 © 2011-2015 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #ifndef YCL_INC_Keys_h_
29 #define YCL_INC_Keys_h_ 1
30
31 #include "YModules.h"
32 #include YFM_YCLib_YCommon
33 #include <bitset>
34
35 namespace platform
36 {
37
42 using KeyIndex = size_t;
43
50 #if YCL_DS
51 yconstexpr const KeyIndex KeyBitsetWidth(32);
52 #elif YCL_Win32 || YCL_Android || YCL_OS_X
53 yconstexpr const KeyIndex KeyBitsetWidth(256);
54 #elif YCL_Linux
55 yconstexpr const KeyIndex KeyBitsetWidth(0x200);
56 #else
57 # error "Unsupported platform found."
58 #endif
59
60
67 using KeyInput = std::bitset<KeyBitsetWidth>;
68
69
76 YF_API KeyIndex
77 FindFirstKey(const KeyInput&) ynothrow;
78
85 YF_API KeyIndex
86 FindNextKey(const KeyInput&, KeyIndex) ynothrow;
87
88
94 namespace KeyCategory
95 {
96
98 enum Category : std::uint_least32_t
99 {
101 None = 0,
103 Alphabetic = 1 << 1,
105 Numeric = 1 << 2,
107 Alphanumeric = Alphabetic | Numeric,
109 Punctuation = 1 << 3,
111 Character = Alphanumeric | Punctuation,
113 Dead = 1 << 4,
115 Lock = 2 << 4,
117 Modifier = 1 << 6,
119 Function = 1 << 7,
121 Navigation = 1 << 8,
123 Editing = 1 << 9,
125 System = 1 << 10,
127 IME = 1 << 11,
129 OEM = 1 << 12,
131 Menu = 1 << 13,
133 Keypad = 1 << 14,
135 NonKeyboard = 2 << 14,
137 Composed = 1 << 16,
139 Virtual = 2 << 16
140 };
141
143 DefBitmaskEnum(Category)
144
145
146
148
152 YF_API YB_PURE Category
153 ClassifyKey(KeyIndex) ynothrow;
154
159 YF_API KeyIndex
160 FindFirstKeyInCategroy(const KeyInput&, KeyIndex) ynothrow;
161
163 #if YCL_Win32
164 inline YB_PURE PDefH(bool, IsComposedKey, KeyIndex code) ynothrow
165 ImplRet(ClassifyKey(code))
166 #else
167 yconstfn PDefH(bool, IsComposedKey, KeyIndex) ynothrow
168 ImplRet({})
169 #endif
171 } // namespace KeyCategory;
173
174
183 #if YCL_Win32
184 YF_API char
185 MapKeyChar(KeyIndex) ynothrow;
186 YF_API char
187 MapKeyChar(const KeyInput&, KeyIndex) ynothrow;
188 #else
189 yconstfn PDefH(char, MapKeyChar, KeyIndex) ynothrow
190 ImplRet({})
192 yconstfn PDefH(char, MapKeyChar, const KeyInput&, KeyIndex) ynothrow
193 ImplRet({})
194 #endif
196
197
203 namespace KeyCodes
204 {
205
207
208 namespace DS
209 {
211 enum NativeSet
212 {
214
215 A = 0,
216 B = 1,
217 Select = 2,
218 Start = 3,
220 Right = 4,
221 Left = 5,
222 Up = 6,
223 Down = 7,
225
226 R = 8,
227 L = 9,
228 X = 10,
229 Y = 11,
230 Touch = 12,
231 Lid = 13
233 };
234
236
237 static yconstexpr const NativeSet Enter = A, Esc = B, PgUp = L, PgDn = R;
239 static yconstexpr const NativeSet Home = X, End = Y;
241 static yconstexpr const NativeSet Primary = Touch;
243
249 enum ExtendedSet
250 {
251 Backspace = 14,
252 Tab,
253 Shift,
254 Ctrl,
255 Alt,
256 Pause,
257 CapsLock,
259 Space,
260 Insert,
261 Delete,
263 Secondary,
265 Tertiary
266 };
267 } // namespace DS;
268
269
270 namespace Win32
271 {
277 enum NativeSet
278 {
279 Empty = 0,
281
282 Primary = 0x01,
285 Secondary = 0x02,
287 Tertiary = 0x04,
289
291 Backspace = 0x08,
294 Tab = 0x09,
296 Enter = 0x0D,
299
300 Shift = 0x10,
303 Ctrl = 0x11,
305 Alt = 0x12,
307 Pause = 0x13,
309 CapsLock = 0x14,
311 Esc = 0x1B,
317 Space = 0x20,
319 PgUp = 0x21,
321 PgDn = 0x22,
323
324 End = 0x23,
327 Home = 0x24,
329 Left = 0x25,
332 Up = 0x26,
334 Right = 0x27,
336 Down = 0x28,
338
339 Insert = 0x2D,
342 Delete = 0x2E
344 };
345 } // namespace Win32;
346
347
348 namespace Android
349 {
355 enum NativeSet
356 {
358 Empty = 0,
360 Up = 0x13,
362 Down = 0x14,
364 Left = 0x15,
366 Right = 0x16,
368 Alt = 0x39,
370 Shift = 0x3B,
372 Tab = 0x3D,
374 Space = 0x3E,
376 Enter = 0x42,
378 Backspace = 0x43,
380 PgUp = 0x5C,
382 PgDn = 0x5D,
384 Esc = 0x6F,
386 Delete = 0x70,
388 Ctrl = 0x71,
390 CapsLock = 0x73,
392 Pause = 0x79,
394 Home = 0x7A,
396 End = 0x7B,
398 Insert = 0x7C
399 };
400
402 enum ExtendedSet
403 {
404 Primary = 0xE0,
405 Secondary = 0xE1,
406 Tertiary = 0xE2
407 };
408 } // namespace Android;
409
410
411 namespace Linux
412 {
418 enum NativeSet
419 {
421 Empty = 0,
423 Esc = 1,
425 Backspace = 14,
427 Tab = 15,
429 Enter = 28,
431 Ctrl = 29,
433 Shift = 42,
435 Alt = 56,
437 Space = 57,
439 CapsLock = 58,
441 Home = 102,
443 Up = 103,
445 PgUp = 104,
447 Left = 105,
449 Right = 106,
451 End = 107,
453 Down = 108,
455 PgDn = 109,
457 Insert = 110,
459 Delete = 111,
461 Pause = 119,
463 Primary = 0x110,
465 Secondary = 0x111,
467 Tertiary = 0x112
468 };
469 } // namespace Linux;
471
472 #if YCL_DS
473 using namespace DS;
475 #elif YCL_Win32
476 using namespace Win32;
478 #elif YCL_Android
479 using namespace Android;
481 #elif YCL_Linux
482 using namespace Linux;
484 #endif
485
486
493 YF_API bool
494 FetchLockState(KeyIndex) ynothrow;
495
502 YF_API void
503 ToggleLockState(KeyIndex) ynothrow;
504
505 } // namespace KeyCodes;
506
507 } // namespace platform;
508
509 #endif
510
platform::KeyCategory::FindFirstKeyInCategroy
YF_API KeyIndex FindFirstKeyInCategroy(const KeyInput &, KeyIndex) ynothrow
找到第一个在指定类别的按键编码。
Definition: Keys.cpp:1115
platform::KeyCodes::Linux::Pause
Definition: Keys.h:461
platform::KeyCategory::Menu
表示菜单键（如 Menu 和 Win ）。
Definition: Keys.h:131
platform::KeyCodes::DS::Start
Definition: Keys.h:218
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:680
platform::KeyCategory::Lock
表示锁定键。
Definition: Keys.h:115
platform::KeyCategory::Virtual
表示没有对应单一物理按键的虚拟键。
Definition: Keys.h:139
DefBitmaskEnum
#define DefBitmaskEnum(_tEnum)
Definition: YBaseMacro.h:481
platform::KeyCodes::Linux::Tertiary
Definition: Keys.h:467
platform::KeyCodes::DS::R
Definition: Keys.h:226
platform::KeyCodes::Linux::Esc
Definition: Keys.h:423
platform::KeyCategory::Alphabetic
表示产生字母字符的键。
Definition: Keys.h:103
platform::KeyCodes::Linux::PgDn
Definition: Keys.h:455
platform
默认平台命名空间。
Definition: Container.h:47
platform::KeyCategory::Category
Category
按键类别。
Definition: Keys.h:98
platform::size_t
YF_API size_t
Definition: FileIO.h:1353
platform::KeyCodes
本机按键编码。
Definition: Keys.h:203
platform::KeyCodes::DS::NativeSet
NativeSet
Definition: Keys.h:211
platform::KeyCodes::DS::Lid
Definition: Keys.h:231
platform::KeyCodes::Linux::PgUp
Definition: Keys.h:445
platform::KeyCodes::Android::NativeSet
NativeSet
基本公用按键集合。
Definition: Keys.h:355
platform::KeyCategory::Alphanumeric
表示产生字母或数字字符的键。
Definition: Keys.h:107
DS
platform::KeyCategory::Dead
表示按键顺序相关的组合键。
Definition: Keys.h:113
platform::PDefH
const string const char *sig PDefH(string, ComposeMessageWithSignature, const char *msg, const char *sig) ImplRet(string(Nonnull(msg))+" @ "+Nonnull(sig)) template< class _type > inline YB_NONNULL(2) string ComposeMessageWithSignature(const _type &msg
platform::KeyCategory::Composed
表示通过多个物理按键组合构成的键。
Definition: Keys.h:137
platform::KeyCodes::ToggleLockState
YF_API void ToggleLockState(KeyIndex) ynothrow
切换锁定键状态。
platform::KeyCodes::Linux::Secondary
Definition: Keys.h:465
platform::KeyCodes::Linux::Ctrl
Definition: Keys.h:431
platform::KeyCodes::Linux::CapsLock
Definition: Keys.h:439
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:679
platform::KeyCodes::Linux::NativeSet
NativeSet
基本公用按键集合。
Definition: Keys.h:418
platform::KeyCategory::None
表示未分配或保留的键。
Definition: Keys.h:101
platform::KeyCategory::Character
表示产生字符的键。
Definition: Keys.h:111
platform::ImplRet
const string const char *sig ImplRet(msg+" @ "+Nonnull(sig)) inline YB_NONNULL(1
platform::KeyCodes::DS::ExtendedSet
ExtendedSet
扩展集：作为 DS 可直接被 KeyInput 表示的非物理键按键编码。
Definition: Keys.h:249
platform::KeyCodes::DS::L
Definition: Keys.h:227
platform::KeyCodes::Linux::Enter
Definition: Keys.h:429
YB_PURE
#define YB_PURE
指示函数或函数模板实例为纯函数。
Definition: ydef.h:527
platform::KeyCodes::Win32::NativeSet
NativeSet
基本公用按键集合。
Definition: Keys.h:277
platform::KeyCategory::IME
表示输入法模式键（一般用于日文和韩文）。
Definition: Keys.h:127
platform::KeyCategory::Numeric
表示产生数字字符的键。
Definition: Keys.h:105
platform::KeyCategory::ClassifyKey
Category ClassifyKey(KeyIndex code) ynothrow
Definition: Keys.cpp:1108
platform::KeyCodes::Linux::Backspace
Definition: Keys.h:425
platform::KeyCodes::DS::Y
Definition: Keys.h:229
platform::KeyCodes::DS::Left
Definition: Keys.h:221
platform::KeyCodes::Android::ExtendedSet
ExtendedSet
Definition: Keys.h:402
YF_API
#define YF_API
Definition: Platform.h:56
YModules.h
platform::KeyCodes::DS::B
Definition: Keys.h:216
platform::KeyCategory::Navigation
表示导航键（如方向键和 PgUp ）、菜单键和 Esc 。
Definition: Keys.h:121
platform::KeyInput
std::bitset< KeyBitsetWidth > KeyInput
按键并行位宽。
Definition: Keys.h:67
platform::KeyCodes::Linux::Space
Definition: Keys.h:437
platform::KeyIndex
size_t KeyIndex
按键索引类型：标识特定的按键在按键集合中的位置。
Definition: Keys.h:42
platform::KeyCategory::Punctuation
表示产生标点字符的键。
Definition: Keys.h:109
platform::KeyCodes::Linux::Home
Definition: Keys.h:441
platform::FindNextKey
YF_API KeyIndex FindNextKey(const KeyInput &, KeyIndex) ynothrow
找到输入缓冲区记录中大于指定编码的最小的按键编码。
Definition: Keys.cpp:48
platform::KeyCategory::Editing
表示编辑键（如回车、空格、退格、插入、删除和制表符）
Definition: Keys.h:123
platform::KeyCodes::DS::X
Definition: Keys.h:228
platform::KeyCategory
按键类别。
Definition: Keys.h:94
platform::KeyCategory::Keypad
表示小键盘键。
Definition: Keys.h:133
platform::KeyCodes::Linux::Alt
Definition: Keys.h:435
platform::FindFirstKey
YF_API KeyIndex FindFirstKey(const KeyInput &) ynothrow
找到输入缓冲区记录中最小的按键编码。
Definition: Keys.cpp:38
platform::KeyCodes::Linux::Primary
Definition: Keys.h:463
platform::KeyCodes::DS::Down
Definition: Keys.h:223
platform::KeyCodes::Linux::Insert
Definition: Keys.h:457
platform::KeyCategory::Modifier
表示修饰键。
Definition: Keys.h:117
platform::KeyCodes::Win32::Empty
Definition: Keys.h:279
platform::KeyCodes::Linux::End
Definition: Keys.h:451
platform::KeyCategory::NonKeyboard
表示非键盘键（如鼠标键）。
Definition: Keys.h:135
platform::KeyCodes::DS::Right
Definition: Keys.h:220
platform::KeyCategory::OEM
表示默认由设备制造商指定。
Definition: Keys.h:129
platform::KeyCategory::System
表示系统键（如 SysRq/PrintScr 、 Break/Pause 和电源管理）。
Definition: Keys.h:125
platform::KeyCodes::DS::Select
Definition: Keys.h:217
platform::KeyCodes::Linux::Shift
Definition: Keys.h:433
platform::KeyCodes::DS::Touch
Definition: Keys.h:230
platform::KeyCodes::FetchLockState
YF_API bool FetchLockState(KeyIndex) ynothrow
取锁定键状态。
platform::KeyCodes::DS::A
Definition: Keys.h:215
platform::KeyCodes::Linux::Tab
Definition: Keys.h:427
platform::KeyCodes::DS::Up
Definition: Keys.h:222
platform::KeyCategory::Function
表示功能键。
Definition: Keys.h:119
platform::KeyCodes::DS::Delete
Definition: Keys.h:261
platform::ynothrow
const _tString &path ynothrow
Definition: YCLib/FileSystem.h:274