Clementine
Keyboard.h
1 // Copyright 2021 SMS
2 // License(Apache-2.0)
3 
4 #pragma once
5 
6 #include <cstdint>
7 #include <unordered_map>
8 
9 namespace clem
10 {
14 class Keyboard
15 {
16 public:
17  enum class Key : uint8_t;
18 
19  static void update();
20 
27  static bool getState(Key k);
28 
35  static void setState(Key k, bool s);
36 
37  static void init();
38  static void deinit();
39 
40 private:
41  static std::unordered_map<Key, bool> states;
42 };
43 
44 enum class Keyboard::Key : uint8_t
45 {
46  A = 0x41,
47  B,
48  C,
49  D,
50  E,
51  F,
52  G,
53  H,
54  I,
55  J,
56  K,
57  L,
58  M,
59  N,
60  O,
61  P,
62  Q,
63  R,
64  S,
65  T,
66  U,
67  V,
68  W,
69  X,
70  Y,
71  Z,
72 
73  Escape = 0x1B,
74 
75  Space = 0x20,
76  Prior,
77  Next,
78  End,
79  Home,
80  Left,
81  Up,
82  Right,
83  Down,
84  Select,
85  Print,
86  Execute,
87  Snapshot,
88  Insert,
89  Delete,
90 };
91 } // namespace clem
Definition: Assert.cpp:10
键盘.
Definition: Keyboard.h:14
static void setState(Key k, bool s)
设置按键状态.
Definition: Keyboard.cpp:30
static bool getState(Key k)
获取按键状态.
Definition: Keyboard.cpp:22