deactivated game controller debug messages
[rocksndiamonds.git] / src / screens.c
index b13890a1c380161681c9c8f1a387035a83cfd94f..ce99012e898e22f73df30f4ced385cf35b490d33 100644 (file)
 #include "init.h"
 #include "config.h"
 
+
+#define DEBUG_JOYSTICKS                0
+
+
 /* screens on the info screen */
 #define INFO_MODE_MAIN                 0
 #define INFO_MODE_TITLE                        1
@@ -6522,7 +6526,6 @@ static boolean ConfigureJoystickMapButtonsAndAxes(SDL_Joystick *joystick)
   static boolean bitmaps_initialized = FALSE;
   boolean screen_initialized = FALSE;
   static Bitmap *controller, *button, *axis_x, *axis_y;
-  Bitmap *marker;
   char *name;
   boolean success = TRUE;
   boolean done = FALSE, next = FALSE;
@@ -6586,12 +6589,14 @@ static boolean ConfigureJoystickMapButtonsAndAxes(SDL_Joystick *joystick)
 
   name = getFormattedJoystickName(SDL_JoystickName(joystick));
 
+#if DEBUG_JOYSTICKS
   /* print info about the joystick we are watching */
   Error(ERR_DEBUG, "watching joystick %d: (%s)\n",
        SDL_JoystickInstanceID(joystick), name);
   Error(ERR_DEBUG, "joystick has %d axes, %d hats, %d balls, and %d buttons\n",
        SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick),
        SDL_JoystickNumBalls(joystick), SDL_JoystickNumButtons(joystick));
+#endif
 
   /* initialize mapping with GUID and name */
   SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick), temp, sizeof(temp));
@@ -6602,6 +6607,8 @@ static boolean ConfigureJoystickMapButtonsAndAxes(SDL_Joystick *joystick)
   /* loop through all steps (buttons and axes), getting joystick events */
   for (i = 0; i < SDL_arraysize(steps) && !done;)
   {
+    Bitmap *marker = button;   /* initialize with reliable default value */
+
     step = &steps[i];
     strcpy(step->mapping, mapping);
     step->axis = -1;
@@ -6777,14 +6784,19 @@ static boolean ConfigureJoystickMapButtonsAndAxes(SDL_Joystick *joystick)
            if (event.key.keysym.sym == KSYM_BackSpace ||
                event.key.keysym.sym == KSYM_Back)
            {
-             /* undo this step */
-             if (i > 0)
+             if (i == 0)
              {
-               prev_step = &steps[--i];
-               strcpy(mapping, prev_step->mapping);
-               next = TRUE;
+               /* leave screen */
+               success = FALSE;
+               done = TRUE;
              }
 
+             /* undo this step */
+             prev_step = &steps[i - 1];
+             strcpy(mapping, prev_step->mapping);
+             i--;
+             next = TRUE;
+
              break;
            }
 
@@ -6801,6 +6813,7 @@ static boolean ConfigureJoystickMapButtonsAndAxes(SDL_Joystick *joystick)
 
            if (event.key.keysym.sym == KSYM_Escape)
            {
+             /* leave screen */
              success = FALSE;
              done = TRUE;
            }
@@ -6824,7 +6837,9 @@ static boolean ConfigureJoystickMapButtonsAndAxes(SDL_Joystick *joystick)
 
   if (success)
   {
+#if DEBUG_JOYSTICKS
     Error(ERR_DEBUG, "New game controller mapping:\n\n%s\n\n", mapping);
+#endif
 
     // activate mapping for this game
     SDL_GameControllerAddMapping(mapping);