#define FPS (1000 / 25)
-
-/* Joystick buttons and axes: */
-
-#define JOY_A 0
-#define JOY_B 1
-#define JOY_START 9
-
-#define JOY_X 0
-#define JOY_Y 1
-
/* Direction (keyboard/joystick) states: */
#define UP 0
break;
case SDL_JOYAXISMOTION:
- switch(event.jaxis.axis)
+ if (event.jaxis.axis == JOY_X)
{
- case JOY_X:
if (event.jaxis.value < -JOYSTICK_DEAD_ZONE)
{
tux.input.left = DOWN;
tux.input.left = DOWN;
tux.input.right = DOWN;
}
- break;
- case JOY_Y:
+ }
+ else if (event.jaxis.axis == JOY_Y)
+ {
if (event.jaxis.value > JOYSTICK_DEAD_ZONE)
tux.input.down = DOWN;
else if (event.jaxis.value < -JOYSTICK_DEAD_ZONE)
tux.input.down = UP;
else
tux.input.down = UP;
-
- break;
- default:
- break;
}
break;
+
case SDL_JOYBUTTONDOWN:
if (event.jbutton.button == JOY_A)
tux.input.up = DOWN;
/** The datadir prefix prepended when loading game data file */
std::string datadir;
+int JOY_A = 0;
+int JOY_B = 1;
+int JOY_START = 9;
+
+int JOY_X = 0;
+int JOY_Y = 1;
+
SDL_Surface * screen;
Text* black_text;
Text* gold_text;
extern std::string datadir;
+/* Joystick buttons and axes: */
+extern int JOY_A;
+extern int JOY_B;
+extern int JOY_START;
+
+extern int JOY_X;
+extern int JOY_Y;
+
extern SDL_Surface * screen;
extern Text* black_text;
extern Text* gold_text;
break;
case SDL_JOYAXISMOTION:
- switch(event.jaxis.axis)
+ if (event.jaxis.axis == JOY_X)
{
- case JOY_X:
if (event.jaxis.value < -JOYSTICK_DEAD_ZONE)
input_direction = WEST;
else if (event.jaxis.value > JOYSTICK_DEAD_ZONE)
input_direction = EAST;
- break;
- case JOY_Y:
+ }
+ else if (event.jaxis.axis == JOY_Y)
+ {
if (event.jaxis.value > JOYSTICK_DEAD_ZONE)
input_direction = SOUTH;
else if (event.jaxis.value < -JOYSTICK_DEAD_ZONE)
input_direction = NORTH;
- break;
}
break;