- turned joystick defines into variables
authorIngo Ruhnke <grumbel@gmx.de>
Tue, 20 Apr 2004 12:24:28 +0000 (12:24 +0000)
committerIngo Ruhnke <grumbel@gmx.de>
Tue, 20 Apr 2004 12:24:28 +0000 (12:24 +0000)
SVN-Revision: 590

src/defines.h
src/gameloop.cpp
src/globals.cpp
src/globals.h
src/worldmap.cpp

index c86ad5d..1116b5c 100644 (file)
 
 #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
index 4a29e0a..809d9bb 100644 (file)
@@ -280,9 +280,8 @@ GameSession::process_events()
               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;
@@ -298,20 +297,18 @@ GameSession::process_events()
                       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;
index b6096d4..7660620 100644 (file)
 /** 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;
index d4ee960..d80e8cf 100644 (file)
 
 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;
index cd460ac..1cadbc1 100644 (file)
@@ -408,20 +408,19 @@ WorldMap::get_input()
               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;