annotate TaskManager/Test/test_render/Joystick.cpp @ 191:5e3b0405a44b

fix Joystick Button
author gongo@gendarme.cr.ie.u-ryukyu.ac.jp
date Mon, 12 Jan 2009 10:32:25 +0900
parents 861271089c43
children d61fded0729e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
140
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
1 #include <SDL.h>
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
2 #include "Joystick.h"
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
3
191
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
4 /**
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
5 * PS3 コントローラの配置
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
6 */
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
7 static const int SELECT = 0;
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
8 static const int L3 = 1;
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
9 static const int R3 = 2;
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
10 static const int START = 3;
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
11 static const int UP = 4;
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
12 static const int RIGHT = 5;
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
13 static const int DOWN = 6;
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
14 static const int LEFT = 7;
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
15 static const int L2 = 8;
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
16 static const int R2 = 9;
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
17 static const int L1 = 10;
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
18 static const int R1 = 11;
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
19 static const int TRIANGLE = 12;
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
20 static const int CIRCLE = 13;
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
21 static const int CROSS = 14;
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
22 static const int SQUARE = 15;
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
23 static const int PS = 16;
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
24
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
25 #if 0
140
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
26 static const int CROSS = 0;
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
27 static const int CIRCLE = 1;
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
28 static const int SQUARE = 2;
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
29 static const int TRIANGLE = 3;
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
30 static const int L1 = 4;
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
31 static const int R1 = 5;
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
32 static const int L2 = 6;
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
33 static const int R2 = 7;
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
34 static const int START = 8;
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
35 static const int SELECT = 9;
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
36 static const int L3 = 10;
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
37 static const int R3 = 11;
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
38 static const int UP = 12;
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
39 static const int DOWN = 13;
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
40 static const int RIGHT = 14;
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
41 static const int LEFT = 15;
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
42 static const int ESCAPE = 16;
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
43 static const int SPACE = 17;
191
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
44 #endif
140
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
45
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
46 Joystick::Joystick(SDL_Joystick *j)
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
47 {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
48 joy = j;
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
49 }
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
50
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
51 void
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
52 Joystick::check(void)
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
53 {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
54 SDL_JoystickUpdate();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
55
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
56 if (SDL_JoystickGetButton(joy,CROSS)==SDL_PRESSED) {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
57 cross.push_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
58 } else {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
59 cross.release_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
60 }
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
61
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
62 if (SDL_JoystickGetButton(joy,CIRCLE)==SDL_PRESSED) {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
63 circle.push_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
64 } else {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
65 circle.release_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
66 }
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
67
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
68 if (SDL_JoystickGetButton(joy,SQUARE)==SDL_PRESSED) {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
69 square.push_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
70 } else {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
71 square.release_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
72 }
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
73
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
74 if (SDL_JoystickGetButton(joy,TRIANGLE)==SDL_PRESSED) {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
75 triangle.push_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
76 } else {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
77 triangle.release_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
78 }
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
79
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
80 if (SDL_JoystickGetButton(joy,L1)==SDL_PRESSED) {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
81 l1.push_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
82 } else {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
83 l1.release_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
84 }
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
85
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
86 if (SDL_JoystickGetButton(joy,R1)==SDL_PRESSED) {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
87 r1.push_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
88 } else {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
89 r1.release_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
90 }
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
91
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
92 if (SDL_JoystickGetButton(joy,L2)==SDL_PRESSED) {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
93 l2.push_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
94 } else {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
95 l2.release_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
96 }
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
97
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
98 if (SDL_JoystickGetButton(joy,R2)==SDL_PRESSED) {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
99 r2.push_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
100 } else {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
101 r2.release_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
102 }
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
103
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
104 if (SDL_JoystickGetButton(joy,START)==SDL_PRESSED) {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
105 start.push_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
106 } else {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
107 start.release_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
108 }
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
109
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
110 if (SDL_JoystickGetButton(joy,SELECT)==SDL_PRESSED) {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
111 select.push_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
112 } else {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
113 select.release_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
114 }
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
115
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
116 if (SDL_JoystickGetButton(joy,L3)==SDL_PRESSED) {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
117 l3.push_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
118 } else {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
119 l3.release_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
120 }
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
121
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
122 if (SDL_JoystickGetButton(joy,R3)==SDL_PRESSED) {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
123 r3.push_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
124 } else {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
125 r3.release_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
126 }
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
127
191
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
128 if (SDL_JoystickGetButton(joy,UP)==SDL_PRESSED) {
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
129 up.push_work();
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
130 } else {
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
131 up.release_work();
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
132 }
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
133
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
134 if (SDL_JoystickGetButton(joy,DOWN)==SDL_PRESSED) {
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
135 down.push_work();
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
136 } else {
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
137 down.release_work();
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
138 }
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
139 if (SDL_JoystickGetButton(joy,RIGHT)==SDL_PRESSED) {
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
140 right.push_work();
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
141 } else {
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
142 right.release_work();
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
143 }
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
144 if (SDL_JoystickGetButton(joy,LEFT)==SDL_PRESSED) {
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
145 left.push_work();
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
146 } else {
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
147 left.release_work();
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
148 }
5e3b0405a44b fix Joystick Button
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 140
diff changeset
149
140
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
150 axis = SDL_JoystickGetAxis(joy,0);
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
151 if (axis >= 3200) {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
152 left.release_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
153 right.push_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
154 } else if (axis <= -3200) {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
155 right.release_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
156 left.push_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
157 } else {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
158 left.release_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
159 right.release_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
160 }
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
161
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
162 axis = SDL_JoystickGetAxis(joy,1);
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
163 if (axis>=3200) {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
164 up.release_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
165 down.push_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
166 } else if (axis<=-3200) {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
167 down.release_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
168 up.push_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
169 } else {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
170 up.release_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
171 down.release_work();
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
172 }
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
173 }
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
174
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
175 void
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
176 Joystick::close(void)
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
177 {
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
178 SDL_JoystickClose(joy);
861271089c43 add Controller
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
179 }