SDXFrameWork 0.09 SDXFrameWork

- Main Page
- Related Pages
- Classes

All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Keyboard.h
1 #pragma once//☀SDL
2 #include <Multimedia/SDX.h>
3 #include <Multimedia/Key.h>
4 #include <Multimedia/InputEnum.h>
5
6 namespace SDX
7 {
10 class Keyboard
11 {
12 private:
13 Keyboard(const Keyboard &key){};
14 Keyboard& operator =(const Keyboard &key) = delete;
15 public:
16 Keyboard(){};
17 bool press[256];
18
19 Key Back;
20 Key Tab;
21 Key Return;
22 Key LShift;
23 Key RShift;
24 Key LControl;
25 Key RControl;
26 Key Escape;
27 Key Space;
28 Key PageUp;
29 Key PageDown;
30 Key End;
31 Key Home;
32 Key Left;
33 Key Up;
34 Key Right;
35 Key Down;
36 Key Insert;
37 Key Delete;
38
39 Key Minus;
40 Key Yen;
41 Key PrevTrack;
42 Key Period;
43 Key Slash;
44 Key LAlt;
45 Key RAlt;
46 Key Scroll;
47 Key Semicolon;
48 Key Colon;
49 Key LBracket;
50 Key RBracket;
51 Key At;
52 Key Backslash;
53 Key Comma;
54 Key Capslock;
55 Key Pause;
56
57 Key Numpad0;
58 Key Numpad1;
59 Key Numpad2;
60 Key Numpad3;
61 Key Numpad4;
62 Key Numpad5;
63 Key Numpad6;
64 Key Numpad7;
65 Key Numpad8;
66 Key Numpad9;
67 Key Multiply;
68 Key Add;
69 Key Subtract;
70 Key Decimal;
71 Key Divide;
72 Key NUMPADEnter;
73
74 Key F1;
75 Key F2;
76 Key F3;
77 Key F4;
78 Key F5;
79 Key F6;
80 Key F7;
81 Key F8;
82 Key F9;
83 Key F10;
84 Key F11;
85 Key F12;
86
87 Key A;
88 Key B;
89 Key C;
90 Key D;
91 Key E;
92 Key F;
93 Key G;
94 Key H;
95 Key I;
96 Key J;
97 Key K;
98 Key L;
99 Key M;
100 Key N;
101 Key O;
102 Key P;
103 Key Q;
104 Key R;
105 Key S;
106 Key T;
107 Key U;
108 Key V;
109 Key W;
110 Key X;
111 Key Y;
112 Key Z;
113 Key _0;
114 Key _1;
115 Key _2;
116 Key _3;
117 Key _4;
118 Key _5;
119 Key _6;
120 Key _7;
121 Key _8;
122 Key _9;
123
125 void Reset()
126 {
127 Back.Reset();
128 Tab.Reset();
129 Return.Reset();
130 LShift.Reset();
131 RShift.Reset();
132 LControl.Reset();
133 RControl.Reset();
134 Escape.Reset();
135 Space.Reset();
136 PageUp.Reset();
137 PageDown.Reset();
138 End.Reset();
139 Home.Reset();
140 Left.Reset();
141 Up.Reset();
142 Right.Reset();
143 Down.Reset();
144 Insert.Reset();
145 Delete.Reset();
146
147 Minus.Reset();
148 Yen.Reset();
149 PrevTrack.Reset();
150 Period.Reset();
151 Slash.Reset();
152 LAlt.Reset();
153 RAlt.Reset();
154 Scroll.Reset();
155 Semicolon.Reset();
156 Colon.Reset();
157 LBracket.Reset();
158 RBracket.Reset();
159 At.Reset();
160 Backslash.Reset();
161 Comma.Reset();
162 Capslock.Reset();
163 Pause.Reset();
164
165 Numpad0.Reset();
166 Numpad1.Reset();
167 Numpad2.Reset();
168 Numpad3.Reset();
169 Numpad4.Reset();
170 Numpad5.Reset();
171 Numpad6.Reset();
172 Numpad7.Reset();
173 Numpad8.Reset();
174 Numpad9.Reset();
175 Multiply.Reset();
176 Add.Reset();
177 Subtract.Reset();
178 Decimal.Reset();
179 Divide.Reset();
180 NUMPADEnter.Reset();
181
182 F1.Reset();
183 F2.Reset();
184 F3.Reset();
185 F4.Reset();
186 F5.Reset();
187 F6.Reset();
188 F7.Reset();
189 F8.Reset();
190 F9.Reset();
191 F10.Reset();
192 F11.Reset();
193 F12.Reset();
194
195 A.Reset();
196 B.Reset();
197 C.Reset();
198 D.Reset();
199 E.Reset();
200 F.Reset();
201 G.Reset();
202 H.Reset();
203 I.Reset();
204 J.Reset();
205 K.Reset();
206 L.Reset();
207 M.Reset();
208 N.Reset();
209 O.Reset();
210 P.Reset();
211 Q.Reset();
212 R.Reset();
213 S.Reset();
214 T.Reset();
215 U.Reset();
216 V.Reset();
217 W.Reset();
218 X.Reset();
219 Y.Reset();
220 Z.Reset();
221 _0.Reset();
222 _1.Reset();
223 _2.Reset();
224 _3.Reset();
225 _4.Reset();
226 _5.Reset();
227 _6.Reset();
228 _7.Reset();
229 _8.Reset();
230 _9.Reset();
231 }
232
234 void Update()
235 {
236 Back.Update( press[ (int)KeyCode::Back ] );
237 Tab.Update(press[(int)KeyCode::Tab]);
238 Return.Update(press[(int)KeyCode::Return]);
239 LShift.Update(press[(int)KeyCode::LShift]);
240 RShift.Update(press[(int)KeyCode::RShift]);
241 LControl.Update(press[(int)KeyCode::LControl]);
242 RControl.Update(press[(int)KeyCode::RControl]);
243 Escape.Update(press[(int)KeyCode::Escape]);
244 Space.Update(press[(int)KeyCode::Space]);
245 PageUp.Update(press[(int)KeyCode::PageUp]);
246 PageDown.Update(press[(int)KeyCode::PageDown]);
247 End.Update(press[(int)KeyCode::End]);
248 Home.Update(press[(int)KeyCode::Home]);
249 Left.Update(press[(int)KeyCode::Left]);
250 Up.Update(press[(int)KeyCode::Up]);
251 Right.Update(press[(int)KeyCode::Right]);
252 Down.Update(press[(int)KeyCode::Down]);
253 Insert.Update(press[(int)KeyCode::Insert]);
254 Delete.Update(press[(int)KeyCode::Delete]);
255
256 Minus.Update(press[(int)KeyCode::Minus]);
257 Yen.Update(press[(int)KeyCode::Yen]);
258 PrevTrack.Update(press[(int)KeyCode::PrevTrack]);
259 Period.Update(press[(int)KeyCode::Period]);
260 Slash.Update(press[(int)KeyCode::Slash]);
261 LAlt.Update(press[(int)KeyCode::LAlt]);
262 RAlt.Update(press[(int)KeyCode::RAlt]);
263 Scroll.Update(press[(int)KeyCode::Scroll]);
264 Semicolon.Update(press[(int)KeyCode::Semicolon]);
265 Colon.Update(press[(int)KeyCode::Colon]);
266 LBracket.Update(press[(int)KeyCode::LBracket]);
267 RBracket.Update(press[(int)KeyCode::RBracket]);
268 At.Update(press[(int)KeyCode::At]);
269 Backslash.Update(press[(int)KeyCode::Backslash]);
270 Comma.Update(press[(int)KeyCode::Comma]);
271 Capslock.Update(press[(int)KeyCode::Capslock]);
272 Pause.Update(press[(int)KeyCode::Pause]);
273
274 Numpad0.Update(press[(int)KeyCode::Numpad0]);
275 Numpad1.Update(press[(int)KeyCode::Numpad1]);
276 Numpad2.Update(press[(int)KeyCode::Numpad2]);
277 Numpad3.Update(press[(int)KeyCode::Numpad3]);
278 Numpad4.Update(press[(int)KeyCode::Numpad4]);
279 Numpad5.Update(press[(int)KeyCode::Numpad5]);
280 Numpad6.Update(press[(int)KeyCode::Numpad6]);
281 Numpad7.Update(press[(int)KeyCode::Numpad7]);
282 Numpad8.Update(press[(int)KeyCode::Numpad8]);
283 Numpad9.Update(press[(int)KeyCode::Numpad9]);
284 Multiply.Update(press[(int)KeyCode::Multiply]);
285 Add.Update(press[(int)KeyCode::Add]);
286 Subtract.Update(press[(int)KeyCode::Subtract]);
287 Decimal.Update(press[(int)KeyCode::Decimal]);
288 Divide.Update(press[(int)KeyCode::Divide]);
289 NUMPADEnter.Update(press[(int)KeyCode::NUMPADEnter]);
290
291 F1.Update(press[(int)KeyCode::F1]);
292 F2.Update(press[(int)KeyCode::F2]);
293 F3.Update(press[(int)KeyCode::F3]);
294 F4.Update(press[(int)KeyCode::F4]);
295 F5.Update(press[(int)KeyCode::F5]);
296 F6.Update(press[(int)KeyCode::F6]);
297 F7.Update(press[(int)KeyCode::F7]);
298 F8.Update(press[(int)KeyCode::F8]);
299 F9.Update(press[(int)KeyCode::F9]);
300 F10.Update(press[(int)KeyCode::F10]);
301 F11.Update(press[(int)KeyCode::F11]);
302 F12.Update(press[(int)KeyCode::F12]);
303
304 A.Update(press[(int)KeyCode::A]);
305 B.Update(press[(int)KeyCode::B]);
306 C.Update(press[(int)KeyCode::C]);
307 D.Update(press[(int)KeyCode::D]);
308 E.Update(press[(int)KeyCode::E]);
309 F.Update(press[(int)KeyCode::F]);
310 G.Update(press[(int)KeyCode::G]);
311 H.Update(press[(int)KeyCode::H]);
312 I.Update(press[(int)KeyCode::I]);
313 J.Update(press[(int)KeyCode::J]);
314 K.Update(press[(int)KeyCode::K]);
315 L.Update(press[(int)KeyCode::L]);
316 M.Update(press[(int)KeyCode::M]);
317 N.Update(press[(int)KeyCode::N]);
318 O.Update(press[(int)KeyCode::O]);
319 P.Update(press[(int)KeyCode::P]);
320 Q.Update(press[(int)KeyCode::Q]);
321 R.Update(press[(int)KeyCode::R]);
322 S.Update(press[(int)KeyCode::S]);
323 T.Update(press[(int)KeyCode::T]);
324 U.Update(press[(int)KeyCode::U]);
325 V.Update(press[(int)KeyCode::V]);
326 W.Update(press[(int)KeyCode::W]);
327 X.Update(press[(int)KeyCode::X]);
328 Y.Update(press[(int)KeyCode::Y]);
329 Z.Update(press[(int)KeyCode::Z]);
330 _0.Update(press[(int)KeyCode::_0]);
331 _1.Update(press[(int)KeyCode::_1]);
332 _2.Update(press[(int)KeyCode::_2]);
333 _3.Update(press[(int)KeyCode::_3]);
334 _4.Update(press[(int)KeyCode::_4]);
335 _5.Update(press[(int)KeyCode::_5]);
336 _6.Update(press[(int)KeyCode::_6]);
337 _7.Update(press[(int)KeyCode::_7]);
338 _8.Update(press[(int)KeyCode::_8]);
339 _9.Update(press[(int)KeyCode::_9]);
340 }
341
343 static bool HoldAnyKey()
344 {
345 const Uint8 *press = SDL_GetKeyboardState(NULL);
346
347 return(
348 press[(int)KeyCode::Back] ||
349 press[(int)KeyCode::Tab] ||
350 press[(int)KeyCode::Return] ||
351 press[(int)KeyCode::LShift] ||
352 press[(int)KeyCode::RShift] ||
353 press[(int)KeyCode::LControl] ||
354 press[(int)KeyCode::RControl] ||
355 press[(int)KeyCode::Escape] ||
356 press[(int)KeyCode::Space] ||
357 press[(int)KeyCode::PageUp] ||
358 press[(int)KeyCode::PageDown] ||
359 press[(int)KeyCode::End] ||
360 press[(int)KeyCode::Home] ||
361 press[(int)KeyCode::Left] ||
362 press[(int)KeyCode::Up] ||
363 press[(int)KeyCode::Right] ||
364 press[(int)KeyCode::Down] ||
365 press[(int)KeyCode::Insert] ||
366 press[(int)KeyCode::Delete] ||
367
368 press[(int)KeyCode::Minus] ||
369 press[ (int)KeyCode::Yen ] ||
370 press[ (int)KeyCode::PrevTrack ] ||
371 press[(int)KeyCode::Period] ||
372 press[(int)KeyCode::Slash] ||
373 press[(int)KeyCode::LAlt] ||
374 press[(int)KeyCode::RAlt] ||
375 press[(int)KeyCode::Scroll] ||
376 press[(int)KeyCode::Semicolon] ||
377 press[(int)KeyCode::Colon] ||
378 press[(int)KeyCode::LBracket] ||
379 press[(int)KeyCode::RBracket] ||
380 press[(int)KeyCode::At] ||
381 press[(int)KeyCode::Backslash] ||
382 press[(int)KeyCode::Comma] ||
383 press[(int)KeyCode::Capslock] ||
384 press[(int)KeyCode::Pause] ||
385
386 press[(int)KeyCode::Numpad0] ||
387 press[(int)KeyCode::Numpad1] ||
388 press[(int)KeyCode::Numpad2] ||
389 press[(int)KeyCode::Numpad3] ||
390 press[(int)KeyCode::Numpad4] ||
391 press[(int)KeyCode::Numpad5] ||
392 press[(int)KeyCode::Numpad6] ||
393 press[(int)KeyCode::Numpad7] ||
394 press[(int)KeyCode::Numpad8] ||
395 press[(int)KeyCode::Numpad9] ||
396 press[(int)KeyCode::Multiply] ||
397 press[(int)KeyCode::Add] ||
398 press[(int)KeyCode::Subtract] ||
399 press[(int)KeyCode::Decimal] ||
400 press[(int)KeyCode::Divide] ||
401 press[(int)KeyCode::NUMPADEnter] ||
402
403 press[(int)KeyCode::F1] ||
404 press[(int)KeyCode::F2] ||
405 press[(int)KeyCode::F3] ||
406 press[(int)KeyCode::F4] ||
407 press[(int)KeyCode::F5] ||
408 press[(int)KeyCode::F6] ||
409 press[(int)KeyCode::F7] ||
410 press[(int)KeyCode::F8] ||
411 press[(int)KeyCode::F9] ||
412 press[(int)KeyCode::F10] ||
413 press[(int)KeyCode::F11] ||
414 press[(int)KeyCode::F12] ||
415
416 press[(int)KeyCode::A] ||
417 press[(int)KeyCode::B] ||
418 press[(int)KeyCode::C] ||
419 press[(int)KeyCode::D] ||
420 press[(int)KeyCode::E] ||
421 press[(int)KeyCode::F] ||
422 press[(int)KeyCode::G] ||
423 press[(int)KeyCode::H] ||
424 press[(int)KeyCode::I] ||
425 press[(int)KeyCode::J] ||
426 press[(int)KeyCode::K] ||
427 press[(int)KeyCode::L] ||
428 press[(int)KeyCode::M] ||
429 press[(int)KeyCode::N] ||
430 press[(int)KeyCode::O] ||
431 press[(int)KeyCode::P] ||
432 press[(int)KeyCode::Q] ||
433 press[(int)KeyCode::R] ||
434 press[(int)KeyCode::S] ||
435 press[(int)KeyCode::T] ||
436 press[(int)KeyCode::U] ||
437 press[(int)KeyCode::V] ||
438 press[(int)KeyCode::W] ||
439 press[(int)KeyCode::X] ||
440 press[(int)KeyCode::Y] ||
441 press[(int)KeyCode::Z] ||
442 press[(int)KeyCode::_0] ||
443 press[(int)KeyCode::_1] ||
444 press[(int)KeyCode::_2] ||
445 press[(int)KeyCode::_3] ||
446 press[(int)KeyCode::_4] ||
447 press[(int)KeyCode::_5] ||
448 press[(int)KeyCode::_6] ||
449 press[(int)KeyCode::_7] ||
450 press[(int)KeyCode::_8] ||
451 press[(int)KeyCode::_9] );
452 return false;
453 }
454
455 };
456 }
SDX::Keyboard::Reset
void Reset()
状態のリセット.
Definition: Keyboard.h:125
SDX::Keyboard
キーボードの状態を表すクラス.
Definition: Keyboard.h:10
SDX::Keyboard::Update
void Update()
状態の更新.
Definition: Keyboard.h:234
SDX::Key::Reset
void Reset()
キーのリセット.
Definition: Key.h:17
SDX::Key::Update
void Update(int 押下フラグ)
押下状態の更新.
Definition: Key.h:26
SDX::Keyboard::HoldAnyKey
static bool HoldAnyKey()
いずれかのキーが押されているか取得.
Definition: Keyboard.h:343
SDX::Key
各ボタンとキーを表すクラス.
Definition: Key.h:8