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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
3 #include "libps2.h"
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
4 #include "ps2util.h"
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
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
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
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
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
16
117
9e4100c5d7ec keybord input
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 108
diff changeset
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
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
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
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
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
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
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
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
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
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
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
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
117 SDL_PumpEvents();
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
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
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
120 printf("key--\n");
117
9e4100c5d7ec keybord input
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 108
diff changeset
121
119
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
122 if (keys[SDLK_UP]) {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
123 pad.up += (pad.up < 2) ? 1 : 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
124 } else {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
125 pad.up = 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
126 }
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
127 if (keys[SDLK_DOWN]) {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
128 pad.down += (pad.down < 2) ? 1 : 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
129 } else {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
130 pad.down = 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
131 }
107
5d231c9754d1 change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
132
119
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
133 if (keys[SDLK_RIGHT]) {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
134 pad.right += (pad.right < 2) ? 1 : 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
135 } else {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
136 pad.right = 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
137 }
107
5d231c9754d1 change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
138
119
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
139 if (keys[SDLK_LEFT]) {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
140 pad.left += (pad.left < 2) ? 1 : 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
141 } else {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
142 pad.left = 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
143 }
107
5d231c9754d1 change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
144
119
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
145 if (keys[SDLK_a]) {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
146 pad.cross += (pad.cross < 2) ? 1 : 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
147 } else {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
148 pad.cross = 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
149 }
107
5d231c9754d1 change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
150
119
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
151 if (keys[SDLK_z]) {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
152 pad.circle += (pad.circle < 2) ? 1 : 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
153 } else {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
154 pad.circle = 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
155 }
107
5d231c9754d1 change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
156
119
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
157 if (keys[SDLK_s]) {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
158 pad.square += (pad.square < 2) ? 1 : 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
159 } else {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
160 pad.square = 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
161 }
107
5d231c9754d1 change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
162
119
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
163 if (keys[SDLK_x]) {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
164 pad.triangle += (pad.triangle < 2) ? 1 : 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
165 } else {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
166 pad.triangle = 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
167 }
107
5d231c9754d1 change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
168
119
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
169 if (keys[SDLK_r]) {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
170 pad.r2 += (pad.r2 < 2) ? 1 : 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
171 } else {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
172 pad.r2 = 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
173 }
107
5d231c9754d1 change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
174
119
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
175 if (keys[SDLK_e]) {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
176 pad.r1 += (pad.r1 < 2) ? 1 : 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
177 } else {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
178 pad.r1 = 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
179 }
107
5d231c9754d1 change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
180
119
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
181 if (keys[SDLK_w]) {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
182 pad.l1 += (pad.l1 < 2) ? 1 : 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
183 } else {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
184 pad.l1 = 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
185 }
107
5d231c9754d1 change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
186
119
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
187 if (keys[SDLK_q]) {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
188 pad.l1 += (pad.l2 < 2) ? 1 : 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
189 } else {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
190 pad.l2 = 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
191 }
107
5d231c9754d1 change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
192
119
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
193 // START ボタンは Return が似合う気がする
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
194 //if(keys[SDLK_1])
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
195 if (keys[SDLK_RETURN]) {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
196 pad.st += (pad.st < 2) ? 1 : 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
197 } else {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
198 pad.st = 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
199 }
107
5d231c9754d1 change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
200
119
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
201 if (keys[SDLK_2]) {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
202 pad.se += (pad.se < 2) ? 1 : 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
203 } else {
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
204 pad.se = 0;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
205 }
107
5d231c9754d1 change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
206
119
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
207 if (keys[SDLK_ESCAPE]) {
130
4f50f5a3b363 new repository
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
208
119
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
209 SDL_Quit();
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
210 exit(1);
130
4f50f5a3b363 new repository
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
211
119
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
212 //pad[0].st = 1;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
213 //pad[0].se = 1;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
214 }
107
5d231c9754d1 change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
215
119
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
216 //SELECT, START, L1, R1, L2, R2
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
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
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
223 ){
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
224 return false;
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
225 }
107
5d231c9754d1 change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
226
119
f2e2460b4011 draw_title
e085768
parents: 117
diff changeset
227 return true;
107
5d231c9754d1 change controler.cc
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents: 99
diff changeset
228 }