annotate TaskManager/Test/test_render/Keyboard.cpp @ 145:a5138d6e8996 draft

fix
author gongo@gendarme.cr.ie.u-ryukyu.ac.jp
date Tue, 02 Dec 2008 12:46:54 +0900
parents 67a5469dfef2
children b56fb6ac2fc4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
140
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
1 #include <SDL.h>
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
2 #include "Keyboard.h"
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
3
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
4 void
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
5 Keyboard::check(void)
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
6 {
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
7 Uint8 *keys = SDL_GetKeyState(NULL);
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
8
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
9 if (keys[SDLK_UP] == SDL_PRESSED) {
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
10 up.push_work();
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
11 } else {
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
12 up.release_work();
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
13 }
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
14
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
15 if (keys[SDLK_DOWN] == SDL_PRESSED) {
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
16 down.push_work();
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
17 } else {
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
18 down.release_work();
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
19 }
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
20
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
21 if (keys[SDLK_RIGHT] == SDL_PRESSED) {
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
22 right.push_work();
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
23 } else {
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
24 right.release_work();
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
25 }
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
26
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
27 if (keys[SDLK_LEFT] == SDL_PRESSED) {
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
28 left.push_work();
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
29 } else {
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
30 left.release_work();
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
31 }
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
32
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
33 if (keys[SDLK_RETURN] == SDL_PRESSED) {
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
34 start.push_work();
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
35 } else {
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
36 start.release_work();
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
37 }
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
38
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
39 if (keys[SDLK_ESCAPE] == SDL_PRESSED) {
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
40 select.push_work();
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
41 } else {
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
42 select.release_work();
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
43 }
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
44
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
45 if (keys[SDLK_a] == SDL_PRESSED) {
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
46 square.push_work();
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
47 } else {
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
48 square.release_work();
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
49 }
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
50
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
51 if (keys[SDLK_s] == SDL_PRESSED) {
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
52 triangle.push_work();
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
53 } else {
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
54 triangle.release_work();
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
55 }
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
56
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
57 if (keys[SDLK_z] == SDL_PRESSED) {
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
58 cross.push_work();
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
59 } else {
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
60 cross.release_work();
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
61 }
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
62
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
63 if (keys[SDLK_x] == SDL_PRESSED) {
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
64 circle.push_work();
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
65 } else {
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
66 circle.release_work();
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
67 }
67a5469dfef2 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
68 }