|
8 | 8 | #include "CommonTools/Async/InterruptableCommands.tpp" |
9 | 9 | #include "CommonTools/Async/SuperControlSession.tpp" |
10 | 10 | #include "Controllers/KeyboardInput/KeyboardInput.h" |
| 11 | +#include "StandardHid_Keyboard_KeyMappings.h" |
11 | 12 | #include "StandardHid_Keyboard.h" |
12 | 13 |
|
13 | 14 | //#include <iostream> |
@@ -67,165 +68,6 @@ class KeyboardState : public ControllerState{ |
67 | 68 |
|
68 | 69 |
|
69 | 70 |
|
70 | | -const std::map<QtKeyMap::QtKey, KeyboardKey>& KEYID_TO_HID_KEY(){ |
71 | | - static const std::map<QtKeyMap::QtKey, KeyboardKey> database{ |
72 | | - {Qt::Key::Key_A, KeyboardKey::KEY_A}, |
73 | | - {Qt::Key::Key_B, KeyboardKey::KEY_B}, |
74 | | - {Qt::Key::Key_C, KeyboardKey::KEY_C}, |
75 | | - {Qt::Key::Key_D, KeyboardKey::KEY_D}, |
76 | | - {Qt::Key::Key_E, KeyboardKey::KEY_E}, |
77 | | - {Qt::Key::Key_F, KeyboardKey::KEY_F}, |
78 | | - {Qt::Key::Key_G, KeyboardKey::KEY_G}, |
79 | | - {Qt::Key::Key_H, KeyboardKey::KEY_H}, |
80 | | - {Qt::Key::Key_I, KeyboardKey::KEY_I}, |
81 | | - {Qt::Key::Key_J, KeyboardKey::KEY_J}, |
82 | | - {Qt::Key::Key_K, KeyboardKey::KEY_K}, |
83 | | - {Qt::Key::Key_L, KeyboardKey::KEY_L}, |
84 | | - {Qt::Key::Key_M, KeyboardKey::KEY_M}, |
85 | | - {Qt::Key::Key_N, KeyboardKey::KEY_N}, |
86 | | - {Qt::Key::Key_O, KeyboardKey::KEY_O}, |
87 | | - {Qt::Key::Key_P, KeyboardKey::KEY_P}, |
88 | | - {Qt::Key::Key_Q, KeyboardKey::KEY_Q}, |
89 | | - {Qt::Key::Key_R, KeyboardKey::KEY_R}, |
90 | | - {Qt::Key::Key_S, KeyboardKey::KEY_S}, |
91 | | - {Qt::Key::Key_T, KeyboardKey::KEY_T}, |
92 | | - {Qt::Key::Key_U, KeyboardKey::KEY_U}, |
93 | | - {Qt::Key::Key_V, KeyboardKey::KEY_V}, |
94 | | - {Qt::Key::Key_W, KeyboardKey::KEY_W}, |
95 | | - {Qt::Key::Key_X, KeyboardKey::KEY_X}, |
96 | | - {Qt::Key::Key_Y, KeyboardKey::KEY_Y}, |
97 | | - {Qt::Key::Key_Z, KeyboardKey::KEY_Z}, |
98 | | - |
99 | | - {Qt::Key::Key_1, KeyboardKey::KEY_1}, |
100 | | - {Qt::Key::Key_2, KeyboardKey::KEY_2}, |
101 | | - {Qt::Key::Key_3, KeyboardKey::KEY_3}, |
102 | | - {Qt::Key::Key_4, KeyboardKey::KEY_4}, |
103 | | - {Qt::Key::Key_5, KeyboardKey::KEY_5}, |
104 | | - {Qt::Key::Key_6, KeyboardKey::KEY_6}, |
105 | | - {Qt::Key::Key_7, KeyboardKey::KEY_7}, |
106 | | - {Qt::Key::Key_8, KeyboardKey::KEY_8}, |
107 | | - {Qt::Key::Key_9, KeyboardKey::KEY_9}, |
108 | | - {Qt::Key::Key_0, KeyboardKey::KEY_0}, |
109 | | - |
110 | | - {Qt::Key::Key_Enter, KeyboardKey::KEY_ENTER}, |
111 | | - {Qt::Key::Key_Escape, KeyboardKey::KEY_ESC}, |
112 | | - {Qt::Key::Key_Backspace, KeyboardKey::KEY_BACKSPACE}, |
113 | | - {Qt::Key::Key_Tab, KeyboardKey::KEY_TAB}, |
114 | | - {Qt::Key::Key_Space, KeyboardKey::KEY_SPACE}, |
115 | | - {Qt::Key::Key_Minus, KeyboardKey::KEY_MINUS}, |
116 | | - {Qt::Key::Key_Equal, KeyboardKey::KEY_EQUAL}, |
117 | | - {Qt::Key::Key_BraceLeft, KeyboardKey::KEY_LEFT_BRACE}, |
118 | | - {Qt::Key::Key_BracketLeft, KeyboardKey::KEY_LEFT_BRACE}, |
119 | | - {Qt::Key::Key_BraceRight, KeyboardKey::KEY_RIGHT_BRACE}, |
120 | | - {Qt::Key::Key_BracketRight, KeyboardKey::KEY_RIGHT_BRACE}, |
121 | | - {Qt::Key::Key_Backslash, KeyboardKey::KEY_BACKSLASH}, |
122 | | - {Qt::Key::Key_Semicolon, KeyboardKey::KEY_SEMICOLON}, |
123 | | - {Qt::Key::Key_Apostrophe, KeyboardKey::KEY_APOSTROPHE}, |
124 | | - |
125 | | - {Qt::Key::Key_AsciiTilde, KeyboardKey::KEY_GRAVE}, |
126 | | - |
127 | | - {Qt::Key::Key_Comma, KeyboardKey::KEY_COMMA}, |
128 | | - {Qt::Key::Key_Period, KeyboardKey::KEY_DOT}, |
129 | | - {Qt::Key::Key_Slash, KeyboardKey::KEY_SLASH}, |
130 | | - {Qt::Key::Key_CapsLock, KeyboardKey::KEY_CAPS_LOCK}, |
131 | | - |
132 | | - {Qt::Key::Key_F1, KeyboardKey::KEY_F1}, |
133 | | - {Qt::Key::Key_F2, KeyboardKey::KEY_F2}, |
134 | | - {Qt::Key::Key_F3, KeyboardKey::KEY_F3}, |
135 | | - {Qt::Key::Key_F4, KeyboardKey::KEY_F4}, |
136 | | - {Qt::Key::Key_F5, KeyboardKey::KEY_F5}, |
137 | | - {Qt::Key::Key_F6, KeyboardKey::KEY_F6}, |
138 | | - {Qt::Key::Key_F7, KeyboardKey::KEY_F7}, |
139 | | - {Qt::Key::Key_F8, KeyboardKey::KEY_F8}, |
140 | | - {Qt::Key::Key_F9, KeyboardKey::KEY_F9}, |
141 | | - {Qt::Key::Key_F10, KeyboardKey::KEY_F10}, |
142 | | - {Qt::Key::Key_F11, KeyboardKey::KEY_F11}, |
143 | | - {Qt::Key::Key_F12, KeyboardKey::KEY_F12}, |
144 | | - |
145 | | - {Qt::Key::Key_Print, KeyboardKey::KEY_PRINT_SCREEN}, |
146 | | - {Qt::Key::Key_ScrollLock, KeyboardKey::KEY_SCROLL_LOCK}, |
147 | | - {Qt::Key::Key_Pause, KeyboardKey::KEY_PAUSE}, |
148 | | - {Qt::Key::Key_Insert, KeyboardKey::KEY_INSERT}, |
149 | | - {Qt::Key::Key_Home, KeyboardKey::KEY_HOME}, |
150 | | - {Qt::Key::Key_PageUp, KeyboardKey::KEY_PAGE_UP}, |
151 | | - {Qt::Key::Key_Delete, KeyboardKey::KEY_DELETE}, |
152 | | - {Qt::Key::Key_End, KeyboardKey::KEY_END}, |
153 | | - {Qt::Key::Key_PageDown, KeyboardKey::KEY_PAGE_DOWN}, |
154 | | - {Qt::Key::Key_Right, KeyboardKey::KEY_RIGHT}, |
155 | | - {Qt::Key::Key_Left, KeyboardKey::KEY_LEFT}, |
156 | | - {Qt::Key::Key_Down, KeyboardKey::KEY_DOWN}, |
157 | | - {Qt::Key::Key_Up, KeyboardKey::KEY_UP}, |
158 | | - {Qt::Key::Key_NumLock, KeyboardKey::KEY_NUM_LOCK}, |
159 | | - |
160 | | - {{Qt::Key::Key_Slash, true}, KeyboardKey::KEY_KP_SLASH}, |
161 | | - {{Qt::Key::Key_Asterisk, true}, KeyboardKey::KEY_KP_ASTERISK}, |
162 | | - {{Qt::Key::Key_Minus, true}, KeyboardKey::KEY_KP_MINUS}, |
163 | | - {{Qt::Key::Key_Plus, true}, KeyboardKey::KEY_KP_PLUS}, |
164 | | - {{Qt::Key::Key_Enter, true}, KeyboardKey::KEY_KP_ENTER}, |
165 | | - {{Qt::Key::Key_1, true}, KeyboardKey::KEY_KP_1}, |
166 | | - {{Qt::Key::Key_2, true}, KeyboardKey::KEY_KP_2}, |
167 | | - {{Qt::Key::Key_3, true}, KeyboardKey::KEY_KP_3}, |
168 | | - {{Qt::Key::Key_4, true}, KeyboardKey::KEY_KP_4}, |
169 | | - {{Qt::Key::Key_5, true}, KeyboardKey::KEY_KP_5}, |
170 | | - {{Qt::Key::Key_6, true}, KeyboardKey::KEY_KP_6}, |
171 | | - {{Qt::Key::Key_7, true}, KeyboardKey::KEY_KP_7}, |
172 | | - {{Qt::Key::Key_8, true}, KeyboardKey::KEY_KP_8}, |
173 | | - {{Qt::Key::Key_9, true}, KeyboardKey::KEY_KP_9}, |
174 | | - {{Qt::Key::Key_0, true}, KeyboardKey::KEY_KP_0}, |
175 | | - {{Qt::Key::Key_Period, true}, KeyboardKey::KEY_KP_DOT}, |
176 | | - |
177 | | - {Qt::Key::Key_F13, KeyboardKey::KEY_F13}, |
178 | | - {Qt::Key::Key_F14, KeyboardKey::KEY_F14}, |
179 | | - {Qt::Key::Key_F15, KeyboardKey::KEY_F15}, |
180 | | - {Qt::Key::Key_F16, KeyboardKey::KEY_F16}, |
181 | | - {Qt::Key::Key_F17, KeyboardKey::KEY_F17}, |
182 | | - {Qt::Key::Key_F18, KeyboardKey::KEY_F18}, |
183 | | - {Qt::Key::Key_F19, KeyboardKey::KEY_F19}, |
184 | | - {Qt::Key::Key_F20, KeyboardKey::KEY_F20}, |
185 | | - {Qt::Key::Key_F21, KeyboardKey::KEY_F21}, |
186 | | - {Qt::Key::Key_F22, KeyboardKey::KEY_F22}, |
187 | | - {Qt::Key::Key_F23, KeyboardKey::KEY_F23}, |
188 | | - {Qt::Key::Key_F24, KeyboardKey::KEY_F24}, |
189 | | - |
190 | | - {Qt::Key::Key_Open, KeyboardKey::KEY_OPEN}, |
191 | | - {Qt::Key::Key_Help, KeyboardKey::KEY_HELP}, |
192 | | - {Qt::Key::Key_Menu, KeyboardKey::KEY_MENU}, |
193 | | - {Qt::Key::Key_Select, KeyboardKey::KEY_SELECT}, |
194 | | - {Qt::Key::Key_Stop, KeyboardKey::KEY_STOP}, |
195 | | -// {Qt::Key::Key_Again, KeyboardKey::KEY_AGAIN}, |
196 | | - {Qt::Key::Key_Undo, KeyboardKey::KEY_UNDO}, |
197 | | - {Qt::Key::Key_Cut, KeyboardKey::KEY_CUT}, |
198 | | - {Qt::Key::Key_Copy, KeyboardKey::KEY_COPY}, |
199 | | - {Qt::Key::Key_Paste, KeyboardKey::KEY_PASTE}, |
200 | | - {Qt::Key::Key_Find, KeyboardKey::KEY_FIND}, |
201 | | - {Qt::Key::Key_VolumeMute, KeyboardKey::KEY_VOLUME_MUTE}, |
202 | | - {Qt::Key::Key_VolumeUp, KeyboardKey::KEY_VOLUME_UP}, |
203 | | - {Qt::Key::Key_VolumeDown, KeyboardKey::KEY_VOLUME_DOWN}, |
204 | | - |
205 | | - {Qt::Key::Key_Control, KeyboardKey::KEY_LEFT_CTRL}, |
206 | | - {Qt::Key::Key_Shift, KeyboardKey::KEY_LEFT_SHIFT}, |
207 | | - {Qt::Key::Key_Alt, KeyboardKey::KEY_LEFT_ALT}, |
208 | | - {Qt::Key::Key_Meta, KeyboardKey::KEY_LEFT_META}, |
209 | | - |
210 | | -// {Qt::Key::Key_MediaPlay, KeyboardKey::KEY_MEDIA_PLAYPAUSE}, |
211 | | -// {Qt::Key::Key_MediaStop, KeyboardKey::KEY_MEDIA_STOPCD}, |
212 | | -// {Qt::Key::Key_MediaPrevious,KeyboardKey::KEY_MEDIA_PREVIOUS_SONG}, |
213 | | -// {Qt::Key::Key_MediaNext, KeyboardKey::KEY_MEDIA_NEXT_SONG}, |
214 | | -// {Qt::Key::Key_Eject, KeyboardKey::KEY_MEDIA_EJECTCD}, |
215 | | -// {Qt::Key::Key_Eject, KeyboardKey::KEY_MEDIA_VOLUME_UP}, |
216 | | -// {Qt::Key::Key_Eject, KeyboardKey::KEY_MEDIA_VOLUME_DOWN}, |
217 | | - }; |
218 | | - return database; |
219 | | -}; |
220 | | - |
221 | | - |
222 | | - |
223 | | - |
224 | | - |
225 | | - |
226 | | - |
227 | | - |
228 | | - |
229 | 71 |
|
230 | 72 |
|
231 | 73 |
|
@@ -253,7 +95,9 @@ class Keyboard::KeyboardManager final : public PokemonAutomation::KeyboardInputC |
253 | 95 | } |
254 | 96 | virtual void update_state(ControllerState& state, const std::set<uint32_t>& pressed_keys) override{ |
255 | 97 | const QtKeyMap& qkey_map = QtKeyMap::instance(); |
256 | | - const std::map<QtKeyMap::QtKey, KeyboardKey>& hid_map = KEYID_TO_HID_KEY(); |
| 98 | + |
| 99 | + // TODO: Support other keyboard layouts. |
| 100 | + const std::map<QtKeyMap::QtKey, KeyboardKey>& hid_map = KEYID_TO_HID_QWERTY(); |
257 | 101 |
|
258 | 102 | KeyboardState& local_state = static_cast<KeyboardState&>(state); |
259 | 103 | local_state.clear(); |
|
0 commit comments