Mercurial > hg > old > magoroku_racing
annotate controler.cc @ 134:42337585fb7c
fix merge
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 22 Jul 2011 18:32:39 +0900 |
parents | 4f50f5a3b363 |
children |
rev | line source |
---|---|
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
1 /* controler.c */ |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
2 |
91 | 3 #include "libps2.h" |
4 #include "ps2util.h" | |
0 | 5 #include "controler.h" |
90
8edae89a3877
compile on Mac OS X
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
6 #include <stdbool.h> |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
7 #include <SDL.h> |
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
8 |
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
9 #include "matrix_calc.h" |
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
10 #include "TaskManager.h" |
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
11 #include "SceneGraph.h" |
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
12 #include "Application.h" |
0 | 13 |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
14 #include "sjoy.h" // ps2関連ファイルから |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
15 |
0 | 16 |
117 | 17 //キー入力変数 |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
18 struct SGO_PAD pad; |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
19 |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
20 /* |
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
21 SgoexCerium をみながら、改変。 |
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
22 引数を追加して、変数名以外の書き方を似せた |
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
23 */ |
108
68e6cc686f48
delete error of controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
107
diff
changeset
|
24 bool padCheck(SDL_Joystick *joy) { |
0 | 25 |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
26 SDL_JoystickUpdate(); |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
27 |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
28 if (SDL_JoystickGetButton(joy,PS2_START)==SDL_PRESSED) { |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
29 pad.st += (pad.st < 2) ? 1 : 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
30 } else { |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
31 pad.st = 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
32 } |
0 | 33 |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
34 if (SDL_JoystickGetButton(joy,PS2_SELECT)==SDL_PRESSED) { |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
35 pad.se += (pad.se < 2) ? 1 : 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
36 } else { |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
37 pad.se = 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
38 } |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
39 if (SDL_JoystickGetButton(joy,PS2_LEFT)==SDL_PRESSED) { |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
40 pad.left += (pad.left < 2) ? 1 : 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
41 } else { |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
42 pad.left = 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
43 } |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
44 if (SDL_JoystickGetButton(joy,PS2_RIGHT)==SDL_PRESSED) { |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
45 pad.right += (pad.right < 2) ? 1 : 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
46 } else { |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
47 pad.right = 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
48 } |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
49 if (SDL_JoystickGetButton(joy,PS2_UP)==SDL_PRESSED) { |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
50 pad.up += (pad.up < 2) ? 1 : 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
51 } else { |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
52 pad.up = 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
53 } |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
54 if (SDL_JoystickGetButton(joy,PS2_DOWN)==SDL_PRESSED) { |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
55 pad.down += (pad.down < 2) ? 1 : 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
56 } else { |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
57 pad.down = 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
58 } |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
59 if (SDL_JoystickGetButton(joy,PS2_R1)==SDL_PRESSED) { |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
60 pad.r1 += (pad.r1 < 2) ? 1 : 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
61 } else { |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
62 pad.r1 = 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
63 } |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
64 if (SDL_JoystickGetButton(joy,PS2_R2)==SDL_PRESSED) { |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
65 pad.r2 += (pad.r2 < 2) ? 1 : 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
66 } else { |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
67 pad.r2 = 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
68 } |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
69 if (SDL_JoystickGetButton(joy,PS2_L1)==SDL_PRESSED) { |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
70 pad.l1 += (pad.l1 < 2) ? 1 : 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
71 } else { |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
72 pad.l1 = 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
73 } |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
74 if (SDL_JoystickGetButton(joy,PS2_L2)==SDL_PRESSED) { |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
75 pad.l2 += (pad.l2 < 2) ? 1 : 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
76 } else { |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
77 pad.l2 = 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
78 } |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
79 if (SDL_JoystickGetButton(joy,PS2_CROSS)==SDL_PRESSED) { |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
80 pad.cross += (pad.cross < 2) ? 1 : 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
81 } else { |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
82 pad.cross = 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
83 } |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
84 if (SDL_JoystickGetButton(joy,PS2_CIRCLE)==SDL_PRESSED) { |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
85 pad.circle += (pad.circle < 2) ? 1 : 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
86 } else { |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
87 pad.circle = 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
88 } |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
89 if (SDL_JoystickGetButton(joy,PS2_TRIANGLE)==SDL_PRESSED) { |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
90 pad.triangle += (pad.triangle < 2) ? 1 : 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
91 } else { |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
92 pad.triangle = 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
93 } |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
94 if (SDL_JoystickGetButton(joy,PS2_SQUARE)==SDL_PRESSED) { |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
95 pad.square += (pad.square < 2) ? 1 : 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
96 } else { |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
97 pad.square = 0; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
98 } |
0 | 99 |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
100 if ( (SDL_JoystickGetButton(joy,PS2_SELECT)==SDL_PRESSED) |
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
101 && (SDL_JoystickGetButton(joy,PS2_START)==SDL_PRESSED) |
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
102 && (SDL_JoystickGetButton(joy,PS2_L1)==SDL_PRESSED) |
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
103 && (SDL_JoystickGetButton(joy,PS2_R1)==SDL_PRESSED) |
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
104 && (SDL_JoystickGetButton(joy,PS2_L2)==SDL_PRESSED) |
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
105 && (SDL_JoystickGetButton(joy,PS2_R2)==SDL_PRESSED) |
108
68e6cc686f48
delete error of controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
107
diff
changeset
|
106 ){ |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
107 return false; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
108 } |
0 | 109 |
90
8edae89a3877
compile on Mac OS X
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
110 |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
111 return true; |
0 | 112 } |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
113 |
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
114 |
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
115 bool keybord() |
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
116 { |
119 | 117 SDL_PumpEvents(); |
118 Uint8 *keys = SDL_GetKeyState(NULL); | |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
119 |
119 | 120 printf("key--\n"); |
117 | 121 |
119 | 122 if (keys[SDLK_UP]) { |
123 pad.up += (pad.up < 2) ? 1 : 0; | |
124 } else { | |
125 pad.up = 0; | |
126 } | |
127 if (keys[SDLK_DOWN]) { | |
128 pad.down += (pad.down < 2) ? 1 : 0; | |
129 } else { | |
130 pad.down = 0; | |
131 } | |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
132 |
119 | 133 if (keys[SDLK_RIGHT]) { |
134 pad.right += (pad.right < 2) ? 1 : 0; | |
135 } else { | |
136 pad.right = 0; | |
137 } | |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
138 |
119 | 139 if (keys[SDLK_LEFT]) { |
140 pad.left += (pad.left < 2) ? 1 : 0; | |
141 } else { | |
142 pad.left = 0; | |
143 } | |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
144 |
119 | 145 if (keys[SDLK_a]) { |
146 pad.cross += (pad.cross < 2) ? 1 : 0; | |
147 } else { | |
148 pad.cross = 0; | |
149 } | |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
150 |
119 | 151 if (keys[SDLK_z]) { |
152 pad.circle += (pad.circle < 2) ? 1 : 0; | |
153 } else { | |
154 pad.circle = 0; | |
155 } | |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
156 |
119 | 157 if (keys[SDLK_s]) { |
158 pad.square += (pad.square < 2) ? 1 : 0; | |
159 } else { | |
160 pad.square = 0; | |
161 } | |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
162 |
119 | 163 if (keys[SDLK_x]) { |
164 pad.triangle += (pad.triangle < 2) ? 1 : 0; | |
165 } else { | |
166 pad.triangle = 0; | |
167 } | |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
168 |
119 | 169 if (keys[SDLK_r]) { |
170 pad.r2 += (pad.r2 < 2) ? 1 : 0; | |
171 } else { | |
172 pad.r2 = 0; | |
173 } | |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
174 |
119 | 175 if (keys[SDLK_e]) { |
176 pad.r1 += (pad.r1 < 2) ? 1 : 0; | |
177 } else { | |
178 pad.r1 = 0; | |
179 } | |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
180 |
119 | 181 if (keys[SDLK_w]) { |
182 pad.l1 += (pad.l1 < 2) ? 1 : 0; | |
183 } else { | |
184 pad.l1 = 0; | |
185 } | |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
186 |
119 | 187 if (keys[SDLK_q]) { |
188 pad.l1 += (pad.l2 < 2) ? 1 : 0; | |
189 } else { | |
190 pad.l2 = 0; | |
191 } | |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
192 |
119 | 193 // START ボタンは Return が似合う気がする |
194 //if(keys[SDLK_1]) | |
195 if (keys[SDLK_RETURN]) { | |
196 pad.st += (pad.st < 2) ? 1 : 0; | |
197 } else { | |
198 pad.st = 0; | |
199 } | |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
200 |
119 | 201 if (keys[SDLK_2]) { |
202 pad.se += (pad.se < 2) ? 1 : 0; | |
203 } else { | |
204 pad.se = 0; | |
205 } | |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
206 |
119 | 207 if (keys[SDLK_ESCAPE]) { |
130 | 208 |
119 | 209 SDL_Quit(); |
210 exit(1); | |
130 | 211 |
119 | 212 //pad[0].st = 1; |
213 //pad[0].se = 1; | |
214 } | |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
215 |
119 | 216 //SELECT, START, L1, R1, L2, R2 |
217 if ( (keys[SDLK_2]) | |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
218 && (keys[SDLK_RETURN]) |
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
219 && (keys[SDLK_w]) |
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
220 && (keys[SDLK_e]) |
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
221 && (keys[SDLK_q]) |
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
222 && (keys[SDLK_r]) |
119 | 223 ){ |
224 return false; | |
225 } | |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
226 |
119 | 227 return true; |
107
5d231c9754d1
change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
99
diff
changeset
|
228 } |