YSTest: Keys.h 源文件

YSTest PreAlpha_b500_20140530 The YSLib Test Project

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

- 文件列表
- 文件成员

全部 类 命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 组 页
Keys.h
浏览该文件的文档.
1 /*
2 © 2012-2014 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 = std::size_t;
43
50 #if YCL_DS
51 yconstexpr KeyIndex KeyBitsetWidth(32);
52 #elif YCL_Win32
53 yconstexpr KeyIndex KeyBitsetWidth(256);
54 #elif YCL_Android
55 yconstexpr KeyIndex KeyBitsetWidth(256);
57 #else
58 # error "Unsupported platform found."
59 #endif
60
61
68 using KeyInput = std::bitset<KeyBitsetWidth>;
69
70
77 YF_API KeyIndex
78 FindFirstKey(const KeyInput&) ynothrow;
79
86 YF_API KeyIndex
87 FindNextKey(const KeyInput&, KeyIndex) ynothrow;
88
89
91
92 namespace KeyCategory
93 {
94
96 enum Category : KeyIndex
97 {
99 None = 0,
101 Alphabetic = 1 << 1,
103 Numeric = 1 << 2,
105 Alphanumeric = Alphabetic | Numeric,
107 Punctuation = 1 << 3,
109 Character = Alphanumeric | Punctuation,
111 Dead = 1 << 4,
113 Lock = 2 << 4,
115 Modifier = 3 << 4,
117 Function = 4 << 4,
119 Navigation = 5 << 4,
121 Editing = 6 << 4,
123 System = 7 << 4,
125 IME = 8 << 4,
127 OEM = 1 << 10,
129 Menu = 1 << 11,
131 Keypad = 1 << 12,
133 NonKeyboard = 2 << 12,
135 Composed = 1 << 14,
137 Virtual = 2 << 14
138 };
139
141 DefBitmaskEnum(Category)
142
143
144
146
150 YF_API YB_PURE Category
151 ClassifyKey(KeyIndex) ynothrow;
152
157 YF_API KeyIndex
158 FindFirstKeyInCategroy(const KeyInput&, KeyIndex) ynothrow;
159
161 #if YCL_Win32
162 inline YB_PURE PDefH(bool, IsComposedKey, KeyIndex code) ynothrow
163 ImplRet(ClassifyKey(code))
164 #else
165 yconstfn PDefH(bool, IsComposedKey, KeyIndex) ynothrow
166 ImplRet({})
167 #endif
169 } // namespace KeyCategory;
171
172
181 #if YCL_Win32
182 YF_API char
183 MapKeyChar(KeyIndex) ynothrow;
184 YF_API char
185 MapKeyChar(const KeyInput&, KeyIndex) ynothrow;
186 #else
187 yconstexpr PDefH(char, MapKeyChar, KeyIndex) ynothrow
188 ImplRet(char())
190 yconstexpr PDefH(char, MapKeyChar, const KeyInput&, KeyIndex) ynothrow
191 ImplRet(char())
192 #endif
193
194
195
201 namespace KeyCodes
202 {
203
204 #if YCL_DS
205 enum NativeSet
207 {
209
210 A = 0,
211 B = 1,
212 Select = 2,
213 Start = 3,
215 Right = 4,
216 Left = 5,
217 Up = 6,
218 Down = 7,
220
221 R = 8,
222 L = 9,
223 X = 10,
224 Y = 11,
225 Touch = 12,
226 Lid = 13
228 };
229
230 //按键别名。
231 yconstexpr NativeSet Enter(A), Esc(B), PgUp(L), PgDn(R);
233 yconstexpr NativeSet Home(X), End(Y);
235 yconstexpr NativeSet Primary(Touch);
236
242 enum ExtendedSet
243 {
244 Backspace = 14,
245 Tab,
246 Shift,
247 Ctrl,
248 Alt,
249 Pause,
250 CapsLock,
252 Space,
253 Insert,
254 Delete,
256 Secondary,
258 Tertiary
259 };
260 #elif YCL_Win32
261
266 enum NativeSet
267 {
268 Empty = 0,
270
271 Primary = 0x01,
274 Secondary = 0x02,
276 Tertiary = 0x04,
278
280 Backspace = 0x08,
283 Tab = 0x09,
285 Enter = 0x0D,
288
289 Shift = 0x10,
292 Ctrl = 0x11,
294 Alt = 0x12,
296 Pause = 0x13,
298 CapsLock = 0x14,
300 Esc = 0x1B,
306 Space = 0x20,
308 PgUp = 0x21,
310 PgDn = 0x22,
312
313 End = 0x23,
316 Home = 0x24,
318 Left = 0x25,
321 Up = 0x26,
323 Right = 0x27,
325 Down = 0x28,
327
328 Insert = 0x2D,
331 Delete = 0x2E
333 };
334 #elif YCL_Android
335
340 enum NativeSet
341 {
343 Empty = 0,
345 Up = 0x13,
347 Down = 0x14,
349 Left = 0x15,
351 Right = 0x16,
353 Alt = 0x39,
355 Shift = 0x3B,
357 Tab = 0x3D,
359 Space = 0x3E,
361 Enter = 0x42,
363 Backspace = 0x43,
365 PgUp = 0x5C,
367 PgDn = 0x5D,
369 Esc = 0x6F,
371 Delete = 0x70,
373 Ctrl = 0x71,
375 CapsLock = 0x73,
377 Pause = 0x79,
379 Home = 0x7A,
381 End = 0x7B,
383 Insert = 0x7C
384 };
385
387 enum ExtendedSet
388 {
389 Primary = 0xE0,
390 Secondary = 0xE1,
391 Tertiary = 0xE2
392 };
393
394 #endif
395
396
403 YF_API bool
404 FetchLockState(KeyIndex) ynothrow;
405
412 YF_API void
413 ToggleLockState(KeyIndex) ynothrow;
414
415 } // namespace KeyCodes;
416
417 } // namespace platform;
418
419 #endif
420
platform::KeyCategory::Alphabetic
表示产生字母字符的键。
Definition: Keys.h:101
platform::KeyCategory::Composed
表示通过多个物理按键组合构成的键。
Definition: Keys.h:135
platform::KeyCategory::Function
表示功能键。
Definition: Keys.h:117
platform::MapKeyChar
yconstexpr MapKeyChar
Definition: Keys.h:190
platform::KeyIndex
std::size_t KeyIndex
按键索引类型：标识特定的按键在按键集合中的位置。
Definition: Keys.h:42
YModules.h
platform::KeyCategory::Keypad
表示小键盘键。
Definition: Keys.h:131
YF_API
#define YF_API
Definition: Platform.h:64
platform::KeyCategory::Editing
表示编辑键（如回车、空格、退格、插入、删除和制表符）
Definition: Keys.h:121
platform::KeyCategory::OEM
表示默认由设备制造商指定。
Definition: Keys.h:127
DefBitmaskEnum
#define DefBitmaskEnum(_tEnum)
Definition: YBaseMacro.h:392
platform::PathCategory::Empty
platform::KeyCategory::Modifier
表示修饰键。
Definition: Keys.h:115
platform::ynothrow
std::size_t size ynothrow
Definition: YCLib/FileSystem.h:256
YSLib::Drawing::size_t
size_t
Definition: ygdi.h:352
platform::KeyCategory::Category
Category
按键类别。
Definition: Keys.h:96
platform::KeyCategory::Numeric
表示产生数字字符的键。
Definition: Keys.h:103
platform::KeyCategory::Dead
表示按键顺序相关的组合键。
Definition: Keys.h:111
platform::FindFirstKey
YF_API KeyIndex FindFirstKey(const KeyInput &) ynothrow
找到输入缓冲区记录中最小的按键编码。
Definition: Keys.cpp:36
platform::KeyCategory::Menu
表示菜单键（如 Menu 和 Win ）。
Definition: Keys.h:129
platform::KeyCategory::ClassifyKey
Category ClassifyKey(KeyIndex code) ynothrow
Definition: Keys.cpp:587
YB_PURE
#define YB_PURE
指示函数或函数模板实例为纯函数。
Definition: ydef.h:331
platform::KeyCategory::Virtual
表示没有对应单一物理按键的虚拟键。
Definition: Keys.h:137
platform::ImplRet
yconstexpr const KeyInput KeyIndex ynothrow ImplRet(char()) namespace KeyCodes
本机按键编码。
Definition: Keys.h:191
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:463
platform::KeyCategory::Character
表示产生字符的键。
Definition: Keys.h:109
platform::A
yconstfn A
Definition: Video.h:118
platform::KeyCategory::None
表示未分配或保留的键。
Definition: Keys.h:99
YSLib::Drawing::Y
p1 p1 Y
Definition: ydraw.h:188
platform::KeyCategory::IME
表示输入法模式键（一般用于日文和韩文）。
Definition: Keys.h:125
platform::KeyCategory::Punctuation
表示产生标点字符的键。
Definition: Keys.h:107
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:462
platform::KeyCategory::FindFirstKeyInCategroy
YF_API KeyIndex FindFirstKeyInCategroy(const KeyInput &, KeyIndex) ynothrow
找到第一个在指定类别的按键编码。
Definition: Keys.cpp:594
platform::KeyCategory::Alphanumeric
表示产生字母或数字字符的键。
Definition: Keys.h:105
YSLib::Drawing::X
p1 X
Definition: ydraw.h:188
platform::FindNextKey
YF_API KeyIndex FindNextKey(const KeyInput &, KeyIndex) ynothrow
找到输入缓冲区记录中大于指定编码的最小的按键编码。
Definition: Keys.cpp:46
platform::KeyCategory::NonKeyboard
表示非键盘键（如鼠标键）。
Definition: Keys.h:133
platform::KeyCategory::Navigation
表示导航键（如方向键和 PgUp ）、菜单键和 Esc 。
Definition: Keys.h:119
platform::KeyCategory::Lock
表示锁定键。
Definition: Keys.h:113
platform::KeyInput
std::bitset< KeyBitsetWidth > KeyInput
按键并行位宽。
Definition: Keys.h:68
platform::PDefH
PDefH(bool, ufexists, const _tString &str) ynothrow ImplRet(ufexists(str.c_str())) YF_API char16_t *u16getcwd_n(char16_t *buf
判断指定字符串为文件名的文件是否存在。
platform::KeyCategory::System
表示系统键（如 SysRq/PrintScr 、 Break/Pause 和电源管理）。
Definition: Keys.h:123