140
|
1 #include <SDL.h>
|
|
2 #include "Keyboard.h"
|
|
3
|
|
4 void
|
|
5 Keyboard::check(void)
|
|
6 {
|
|
7 Uint8 *keys = SDL_GetKeyState(NULL);
|
|
8
|
|
9 if (keys[SDLK_UP] == SDL_PRESSED) {
|
|
10 up.push_work();
|
|
11 } else {
|
|
12 up.release_work();
|
|
13 }
|
|
14
|
|
15 if (keys[SDLK_DOWN] == SDL_PRESSED) {
|
|
16 down.push_work();
|
|
17 } else {
|
|
18 down.release_work();
|
|
19 }
|
|
20
|
|
21 if (keys[SDLK_RIGHT] == SDL_PRESSED) {
|
|
22 right.push_work();
|
|
23 } else {
|
|
24 right.release_work();
|
|
25 }
|
|
26
|
|
27 if (keys[SDLK_LEFT] == SDL_PRESSED) {
|
|
28 left.push_work();
|
|
29 } else {
|
|
30 left.release_work();
|
|
31 }
|
|
32
|
|
33 if (keys[SDLK_RETURN] == SDL_PRESSED) {
|
|
34 start.push_work();
|
|
35 } else {
|
|
36 start.release_work();
|
|
37 }
|
|
38
|
|
39 if (keys[SDLK_ESCAPE] == SDL_PRESSED) {
|
|
40 select.push_work();
|
|
41 } else {
|
|
42 select.release_work();
|
|
43 }
|
|
44
|
|
45 if (keys[SDLK_a] == SDL_PRESSED) {
|
|
46 square.push_work();
|
|
47 } else {
|
|
48 square.release_work();
|
|
49 }
|
|
50
|
|
51 if (keys[SDLK_s] == SDL_PRESSED) {
|
|
52 triangle.push_work();
|
|
53 } else {
|
|
54 triangle.release_work();
|
|
55 }
|
|
56
|
|
57 if (keys[SDLK_z] == SDL_PRESSED) {
|
|
58 cross.push_work();
|
|
59 } else {
|
|
60 cross.release_work();
|
|
61 }
|
|
62
|
|
63 if (keys[SDLK_x] == SDL_PRESSED) {
|
|
64 circle.push_work();
|
|
65 } else {
|
|
66 circle.release_work();
|
|
67 }
|
|
68 }
|