51 while(SDL_PollEvent(&event)) {
52 if(event.type == SDL_QUIT) {keys[
quit] =
true; cout <<
"Quiting\n";}
53 if(event.type == SDL_MOUSEBUTTONDOWN) {
54 if((event.button.button == SDL_BUTTON_LEFT) && !keys[
mouseleft]) {keys[
mouseleft] =
true; cout <<
"Left mouse button\n";}
55 if((event.button.button == SDL_BUTTON_RIGHT) && !keys[
mouseright]) {keys[
mouseright] =
true; cout <<
"Right mouse button\n";}
56 if((event.button.button == SDL_BUTTON_MIDDLE) && !keys[
mousemiddle]) {keys[
mousemiddle] =
true; cout <<
"Middle mouse button\n";}
58 if(event.type == SDL_MOUSEBUTTONUP) {
59 if((event.button.button == SDL_BUTTON_LEFT) && keys[
mouseleft]) {keys[
mouseleft] =
false; cout <<
"Left mouse button up\n";}
60 if((event.button.button == SDL_BUTTON_RIGHT) && keys[
mouseright]) {keys[
mouseright] =
false; cout <<
"Right mouse button up\n";}
61 if((event.button.button == SDL_BUTTON_MIDDLE) && keys[
mousemiddle]) {keys[
mousemiddle] =
false; cout <<
"Middle mouse button up\n";}
63 if(event.type == SDL_KEYDOWN) {
64 if((event.key.keysym.sym == SDLK_LEFT) && !keys[
left]) {keys[
left] =
true; cout <<
"left\n";}
65 if((event.key.keysym.sym == SDLK_RIGHT) && !keys[
right]) {keys[
right] =
true; cout <<
"right\n";}
66 if((event.key.keysym.sym == SDLK_DOWN) && !keys[
down]) {keys[
down] =
true; cout <<
"down\n";}
67 if((event.key.keysym.sym == SDLK_UP) && !keys[
up]) {keys[
up] =
true; cout <<
"up\n";}
68 if((event.key.keysym.sym == SDLK_a) && !keys[
a]) {keys[
a] =
true; cout <<
"a\n";}
69 if((event.key.keysym.sym == SDLK_b) && !keys[
b]) {keys[
b] =
true; cout <<
"b\n";}
70 if((event.key.keysym.sym == SDLK_c) && !keys[
c]) {keys[
c] =
true; cout <<
"c\n";}
71 if((event.key.keysym.sym == SDLK_d) && !keys[
d]) {keys[
d] =
true; cout <<
"d\n";}
72 if((event.key.keysym.sym == SDLK_e) && !keys[
e]) {keys[
e] =
true; cout <<
"e\n";}
73 if((event.key.keysym.sym == SDLK_f) && !keys[
f]) {keys[
f] =
true; cout <<
"f\n";}
74 if((event.key.keysym.sym == SDLK_g) && !keys[
g]) {keys[
g] =
true; cout <<
"g\n";}
75 if((event.key.keysym.sym == SDLK_h) && !keys[
h]) {keys[
h] =
true; cout <<
"h\n";}
76 if((event.key.keysym.sym == SDLK_i) && !keys[
i]) {keys[
i] =
true; cout <<
"i\n";}
77 if((event.key.keysym.sym == SDLK_j) && !keys[
j]) {keys[
j] =
true; cout <<
"j\n";}
78 if((event.key.keysym.sym == SDLK_k) && !keys[
k]) {keys[
k] =
true; cout <<
"k\n";}
79 if((event.key.keysym.sym == SDLK_l) && !keys[
l]) {keys[
l] =
true; cout <<
"l\n";}
80 if((event.key.keysym.sym == SDLK_m) && !keys[
m]) {keys[
m] =
true; cout <<
"m\n";}
81 if((event.key.keysym.sym == SDLK_n) && !keys[
n]) {keys[
n] =
true; cout <<
"n\n";}
82 if((event.key.keysym.sym == SDLK_o) && !keys[
o]) {keys[
o] =
true; cout <<
"o\n";}
83 if((event.key.keysym.sym == SDLK_p) && !keys[
p]) {keys[
p] =
true; cout <<
"p\n";}
84 if((event.key.keysym.sym == SDLK_q) && !keys[
q]) {keys[
q] =
true; cout <<
"q\n";}
85 if((event.key.keysym.sym == SDLK_r) && !keys[
r]) {keys[
r] =
true; cout <<
"r\n";}
86 if((event.key.keysym.sym == SDLK_s) && !keys[
s]) {keys[
s] =
true; cout <<
"s\n";}
87 if((event.key.keysym.sym == SDLK_t) && !keys[
t]) {keys[
t] =
true; cout <<
"t\n";}
88 if((event.key.keysym.sym == SDLK_u) && !keys[
u]) {keys[
u] =
true; cout <<
"u\n";}
89 if((event.key.keysym.sym == SDLK_v) && !keys[
v]) {keys[
v] =
true; cout <<
"v\n";}
90 if((event.key.keysym.sym == SDLK_w) && !keys[
w]) {keys[
w] =
true; cout <<
"w\n";}
91 if((event.key.keysym.sym == SDLK_x) && !keys[
x]) {keys[
x] =
true; cout <<
"x\n";}
92 if((event.key.keysym.sym == SDLK_y) && !keys[
y]) {keys[
y] =
true; cout <<
"y\n";}
93 if((event.key.keysym.sym == SDLK_z) && !keys[
z]) {keys[
z] =
true; cout <<
"z\n";}
94 if((event.key.keysym.sym == SDLK_ESCAPE) && !keys[
esc]) {keys[
esc] =
true; cout <<
"Esc\n";}
95 if((event.key.keysym.sym == SDLK_1) && !keys[1]) {keys[1] =
true; cout <<
"1\n";}
96 if((event.key.keysym.sym == SDLK_2) && !keys[2]) {keys[2] =
true; cout <<
"2\n";}
97 if((event.key.keysym.sym == SDLK_3) && !keys[3]) {keys[3] =
true; cout <<
"3\n";}
98 if((event.key.keysym.sym == SDLK_4) && !keys[4]) {keys[4] =
true; cout <<
"4\n";}
99 if((event.key.keysym.sym == SDLK_5) && !keys[5]) {keys[5] =
true; cout <<
"5\n";}
100 if((event.key.keysym.sym == SDLK_6) && !keys[6]) {keys[6] =
true; cout <<
"6\n";}
101 if((event.key.keysym.sym == SDLK_7) && !keys[7]) {keys[7] =
true; cout <<
"7\n";}
102 if((event.key.keysym.sym == SDLK_8) && !keys[8]) {keys[8] =
true; cout <<
"8\n";}
103 if((event.key.keysym.sym == SDLK_9) && !keys[9]) {keys[9] =
true; cout <<
"9\n";}
104 if((event.key.keysym.sym == SDLK_0) && !keys[0]) {keys[0] =
true; cout <<
"0\n";}
105 if((event.key.keysym.sym == SDLK_LSHIFT) && !keys[
lshift]) {keys[
lshift] =
true; cout <<
"left shift\n";}
106 if((event.key.keysym.sym == SDLK_RSHIFT) && !keys[
rshift]) {keys[
rshift] =
true; cout <<
"right shift\n";}
108 if(event.type == SDL_KEYUP) {
109 if((event.key.keysym.sym == SDLK_LEFT) && keys[
left]) {keys[
left] =
false; cout <<
"left up\n";}
110 if((event.key.keysym.sym == SDLK_RIGHT) && keys[
right]) {keys[
right] =
false; cout <<
"right up\n";}
111 if((event.key.keysym.sym == SDLK_DOWN) && keys[
down]) {keys[
down] =
false; cout <<
"down up\n";}
112 if((event.key.keysym.sym == SDLK_UP) && keys[
up]) {keys[
up] =
false; cout <<
"up up\n";}
113 if((event.key.keysym.sym == SDLK_a) && keys[
a]) {keys[
a] =
false; cout <<
"a up\n";}
114 if((event.key.keysym.sym == SDLK_b) && keys[
b]) {keys[
b] =
false; cout <<
"b up\n";}
115 if((event.key.keysym.sym == SDLK_c) && keys[
c]) {keys[
c] =
false; cout <<
"c up\n";}
116 if((event.key.keysym.sym == SDLK_d) && keys[
d]) {keys[
d] =
false; cout <<
"d up\n";}
117 if((event.key.keysym.sym == SDLK_e) && keys[
e]) {keys[
e] =
false; cout <<
"e up\n";}
118 if((event.key.keysym.sym == SDLK_f) && keys[
f]) {keys[
f] =
false; cout <<
"f up\n";}
119 if((event.key.keysym.sym == SDLK_g) && keys[
g]) {keys[
g] =
false; cout <<
"g up\n";}
120 if((event.key.keysym.sym == SDLK_h) && keys[
h]) {keys[
h] =
false; cout <<
"h up\n";}
121 if((event.key.keysym.sym == SDLK_i) && keys[
i]) {keys[
i] =
false; cout <<
"i up\n";}
122 if((event.key.keysym.sym == SDLK_j) && keys[
j]) {keys[
j] =
false; cout <<
"j up\n";}
123 if((event.key.keysym.sym == SDLK_k) && keys[
k]) {keys[
k] =
false; cout <<
"k up\n";}
124 if((event.key.keysym.sym == SDLK_l) && keys[
l]) {keys[
l] =
false; cout <<
"l up\n";}
125 if((event.key.keysym.sym == SDLK_m) && keys[
m]) {keys[
m] =
false; cout <<
"m up\n";}
126 if((event.key.keysym.sym == SDLK_n) && keys[
n]) {keys[
n] =
false; cout <<
"n up\n";}
127 if((event.key.keysym.sym == SDLK_o) && keys[
o]) {keys[
o] =
false; cout <<
"o up\n";}
128 if((event.key.keysym.sym == SDLK_p) && keys[
p]) {keys[
p] =
false; cout <<
"p up\n";}
129 if((event.key.keysym.sym == SDLK_q) && keys[
q]) {keys[
q] =
false; cout <<
"q up\n";}
130 if((event.key.keysym.sym == SDLK_r) && keys[
r]) {keys[
r] =
false; cout <<
"r up\n";}
131 if((event.key.keysym.sym == SDLK_s) && keys[
s]) {keys[
s] =
false; cout <<
"s up\n";}
132 if((event.key.keysym.sym == SDLK_t) && keys[
t]) {keys[
t] =
false; cout <<
"t up\n";}
133 if((event.key.keysym.sym == SDLK_u) && keys[
u]) {keys[
u] =
false; cout <<
"u up\n";}
134 if((event.key.keysym.sym == SDLK_v) && keys[
v]) {keys[
v] =
false; cout <<
"v up\n";}
135 if((event.key.keysym.sym == SDLK_w) && keys[
w]) {keys[
w] =
false; cout <<
"w up\n";}
136 if((event.key.keysym.sym == SDLK_x) && keys[
x]) {keys[
x] =
false; cout <<
"x up\n";}
137 if((event.key.keysym.sym == SDLK_y) && keys[
y]) {keys[
y] =
false; cout <<
"y up\n";}
138 if((event.key.keysym.sym == SDLK_z) && keys[
z]) {keys[
z] =
false; cout <<
"z up\n";}
139 if((event.key.keysym.sym == SDLK_ESCAPE) && keys[
esc]) {keys[
esc] =
false; cout <<
"Esc up\n";}
140 if((event.key.keysym.sym == SDLK_1) && keys[1]) {keys[1] =
false; cout <<
"1 up\n";}
141 if((event.key.keysym.sym == SDLK_2) && keys[2]) {keys[2] =
false; cout <<
"2 up\n";}
142 if((event.key.keysym.sym == SDLK_3) && keys[3]) {keys[3] =
false; cout <<
"3 up\n";}
143 if((event.key.keysym.sym == SDLK_4) && keys[4]) {keys[4] =
false; cout <<
"4 up\n";}
144 if((event.key.keysym.sym == SDLK_5) && keys[5]) {keys[5] =
false; cout <<
"5 up\n";}
145 if((event.key.keysym.sym == SDLK_6) && keys[6]) {keys[6] =
false; cout <<
"6 up\n";}
146 if((event.key.keysym.sym == SDLK_7) && keys[7]) {keys[7] =
false; cout <<
"7 up\n";}
147 if((event.key.keysym.sym == SDLK_8) && keys[8]) {keys[8] =
false; cout <<
"8 up\n";}
148 if((event.key.keysym.sym == SDLK_9) && keys[9]) {keys[9] =
false; cout <<
"9 up\n";}
149 if((event.key.keysym.sym == SDLK_0) && keys[0]) {keys[0] =
false; cout <<
"0 up\n";}
150 if((event.key.keysym.sym == SDLK_LSHIFT) && keys[
lshift]) {keys[
lshift] =
false; cout <<
"left shift up\n";}
151 if((event.key.keysym.sym == SDLK_RSHIFT) && keys[
rshift]) {keys[
rshift] =
false; cout <<
"right shift up\n";}
213 SDL_GetMouseState(&mousex, &mousey);
227 for(
int i;
i<
sizeof(keys);
i++) {