3 * Daniel Nelson - 8/25/0
5 * Copyright (C) 2000 Daniel Nelson
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 * Daniel Nelson - aluminumangel.org
25 * Keeps track of the button pressing.
28 #include "Controller.h"
36 #include "ActionRecorder.h"
37 #include "MetaState.h"
41 #include "Displayer.h"
45 int Controller::state
;
47 void Controller::gameStart ( )
52 void Controller::keyboardPlay ( unsigned char key
, int x
, int y
)
54 bool keypressed
= true;
56 case GC_LEFT_KEY
: case (GC_LEFT_KEY
- 32):
59 case GC_RIGHT_KEY
: case (GC_RIGHT_KEY
- 32):
62 case GC_UP_KEY
: case (GC_UP_KEY
- 32):
65 case GC_DOWN_KEY
: case (GC_DOWN_KEY
- 32):
68 case GC_SWAP_KEY
: case (GC_SWAP_KEY
- 32): case ' ':
71 case GC_ADVANCE_KEY
: case (GC_ADVANCE_KEY
- 32): case '\r':
74 case GC_PAUSE_KEY
: case (GC_PAUSE_KEY
- 32):
84 Displayer::screenShot();
94 ActionRecorder::addAction(state
);
97 void Controller::keyboardUpPlay ( unsigned char key
, int x
, int y
)
99 bool keypressed
= true;
101 case GC_LEFT_KEY
: case (GC_LEFT_KEY
- 32):
104 case GC_RIGHT_KEY
: case (GC_RIGHT_KEY
- 32):
107 case GC_UP_KEY
: case (GC_UP_KEY
- 32):
110 case GC_DOWN_KEY
: case (GC_DOWN_KEY
- 32):
113 case GC_SWAP_KEY
: case (GC_SWAP_KEY
- 32): case ' ':
116 case GC_ADVANCE_KEY
: case (GC_ADVANCE_KEY
- 32): case '\r':
117 state
&= ~CC_ADVANCE
;
119 case GC_PAUSE_KEY
: case (GC_PAUSE_KEY
- 32):
126 ActionRecorder::addAction(state
);
129 void Controller::specialPlay ( int key
, int x
, int y
)
147 void Controller::specialUpPlay ( int key
, int x
, int y
)
165 void Controller::keyboardMeta ( unsigned char key
, int x
, int y
)
170 Displayer::screenShot(); break;
172 case GC_LEFT_KEY
: case (GC_LEFT_KEY
- 32):
173 case GC_RIGHT_KEY
: case (GC_RIGHT_KEY
- 32):
174 case GC_UP_KEY
: case (GC_UP_KEY
- 32):
175 case GC_DOWN_KEY
: case (GC_DOWN_KEY
- 32):
176 case GC_SWAP_KEY
: case (GC_SWAP_KEY
- 32): case ' ':
177 case GC_ADVANCE_KEY
: case (GC_ADVANCE_KEY
- 32): case '\r':
178 case GC_PAUSE_KEY
: case (GC_PAUSE_KEY
- 32):
179 MESSAGE("game key pressed");
180 MetaState::localKeyPressed(false);
183 MESSAGE("game key not-pressed");
184 MetaState::localKeyPressed(true);
188 void Controller::keyboardUpMeta ( unsigned char key
, int x
, int y
)
192 void Controller::specialMeta ( int key
, int x
, int y
)
194 if (MetaState::mode
* CM_SOLO
)
203 MetaState::localKeyPressed(false);
207 MetaState::localKeyPressed(false);
210 void Controller::specialUpMeta ( int key
, int x
, int y
)
212 assert(MetaState::mode
& CM_SOLO
);
224 void Controller::entry ( int mouse_state
)
226 if (mouse_state
== GLUT_LEFT
)