src/joystick/bsd/SDL_sysjoystick.c
changeset 6700 c8f3d3f0251e
parent 6698 28ab2ef7bfc9
child 6707 70eeb7e3ec2f
     1.1 --- a/src/joystick/bsd/SDL_sysjoystick.c	Mon Nov 26 22:27:49 2012 -0800
     1.2 +++ b/src/joystick/bsd/SDL_sysjoystick.c	Mon Nov 26 23:41:50 2012 -0800
     1.3 @@ -175,15 +175,14 @@
     1.4  
     1.5          SDL_snprintf(s, SDL_arraysize(s), "/dev/uhid%d", i);
     1.6  
     1.7 -        nj.index = SDL_SYS_numjoysticks;
     1.8 -        joynames[nj.index] = strdup(s);
     1.9 +        joynames[SDL_SYS_numjoysticks] = strdup(s);
    1.10  
    1.11 -        if (SDL_SYS_JoystickOpen(&nj, nj.index) == 0) {
    1.12 +        if (SDL_SYS_JoystickOpen(&nj, SDL_SYS_numjoysticks) == 0) {
    1.13              SDL_SYS_JoystickClose(&nj);
    1.14              SDL_SYS_numjoysticks++;
    1.15          } else {
    1.16 -            SDL_free(joynames[nj.index]);
    1.17 -            joynames[nj.index] = NULL;
    1.18 +            SDL_free(joynames[SDL_SYS_numjoysticks]);
    1.19 +            joynames[SDL_SYS_numjoysticks] = NULL;
    1.20          }
    1.21      }
    1.22      for (i = 0; i < MAX_JOY_JOYS; i++) {
    1.23 @@ -295,7 +294,7 @@
    1.24          joy->nbuttons = 2;
    1.25          joy->nhats = 0;
    1.26          joy->nballs = 0;
    1.27 -        joydevnames[joy->index] = strdup("Gameport joystick");
    1.28 +        joydevnames[device_index] = strdup("Gameport joystick");
    1.29          goto usbend;
    1.30      } else {
    1.31          hw->type = BSDJOY_UHID;
    1.32 @@ -359,8 +358,8 @@
    1.33                      s = hid_usage_in_page(hitem.usage);
    1.34                      sp = SDL_malloc(SDL_strlen(s) + 5);
    1.35                      SDL_snprintf(sp, SDL_strlen(s) + 5, "%s (%d)",
    1.36 -                                 s, joy->index);
    1.37 -                    joydevnames[joy->index] = sp;
    1.38 +                                 s, device_index);
    1.39 +                    joydevnames[device_index] = sp;
    1.40                  }
    1.41              }
    1.42              break;