Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Hopefully fixed BSD joystick code
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Nov 27, 2012
1 parent 9e9b99b commit dc6e31d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/joystick/bsd/SDL_sysjoystick.c
Expand Up @@ -175,15 +175,14 @@ SDL_SYS_JoystickInit(void)

SDL_snprintf(s, SDL_arraysize(s), "/dev/uhid%d", i);

nj.index = SDL_SYS_numjoysticks;
joynames[nj.index] = strdup(s);
joynames[SDL_SYS_numjoysticks] = strdup(s);

if (SDL_SYS_JoystickOpen(&nj, nj.index) == 0) {
if (SDL_SYS_JoystickOpen(&nj, SDL_SYS_numjoysticks) == 0) {
SDL_SYS_JoystickClose(&nj);
SDL_SYS_numjoysticks++;
} else {
SDL_free(joynames[nj.index]);
joynames[nj.index] = NULL;
SDL_free(joynames[SDL_SYS_numjoysticks]);
joynames[SDL_SYS_numjoysticks] = NULL;
}
}
for (i = 0; i < MAX_JOY_JOYS; i++) {
Expand Down Expand Up @@ -295,7 +294,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joy, int device_index)
joy->nbuttons = 2;
joy->nhats = 0;
joy->nballs = 0;
joydevnames[joy->index] = strdup("Gameport joystick");
joydevnames[device_index] = strdup("Gameport joystick");
goto usbend;
} else {
hw->type = BSDJOY_UHID;
Expand Down Expand Up @@ -359,8 +358,8 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joy, int device_index)
s = hid_usage_in_page(hitem.usage);
sp = SDL_malloc(SDL_strlen(s) + 5);
SDL_snprintf(sp, SDL_strlen(s) + 5, "%s (%d)",
s, joy->index);
joydevnames[joy->index] = sp;
s, device_index);
joydevnames[device_index] = sp;
}
}
break;
Expand Down

0 comments on commit dc6e31d

Please sign in to comment.