Fixed bsd joystick detection ... again (thanks Wilbern)
1.1 --- a/src/joystick/bsd/SDL_sysjoystick.c Sun Nov 17 18:59:10 2002 +0000
1.2 +++ b/src/joystick/bsd/SDL_sysjoystick.c Sun Nov 17 19:03:05 2002 +0000
1.3 @@ -136,17 +136,24 @@
1.4 memset(joydevnames, NULL, sizeof(joydevnames));
1.5
1.6 for (i = 0; i < MAX_UHID_JOYS; i++) {
1.7 + SDL_Joystick nj;
1.8 +
1.9 sprintf(s, "/dev/uhid%d", i);
1.10 - fd = open(s, O_RDWR);
1.11 - if (fd > 0) {
1.12 - joynames[SDL_numjoysticks++] = strdup(s);
1.13 - close(fd);
1.14 +
1.15 + nj.index = SDL_numjoysticks;
1.16 + joynames[nj.index] = strdup(s);
1.17 +
1.18 + if (SDL_SYS_JoystickOpen(&nj) == 0) {
1.19 + SDL_SYS_JoystickClose(&nj);
1.20 + SDL_numjoysticks++;
1.21 + } else {
1.22 + free(joynames[nj.index]);
1.23 }
1.24 }
1.25 for (i = 0; i < MAX_JOY_JOYS; i++) {
1.26 sprintf(s, "/dev/joy%d", i);
1.27 - fd = open(s, O_RDWR);
1.28 - if (fd > 0) {
1.29 + fd = open(s, O_RDONLY);
1.30 + if (fd != -1) {
1.31 joynames[SDL_numjoysticks++] = strdup(s);
1.32 close(fd);
1.33 }
1.34 @@ -178,7 +185,7 @@
1.35 int fd;
1.36
1.37 fd = open(path, O_RDWR);
1.38 - if (fd < 0) {
1.39 + if (fd == -1) {
1.40 SDL_SetError("%s: %s", path, strerror(errno));
1.41 return (-1);
1.42 }
1.43 @@ -400,9 +407,9 @@
1.44 int len;
1.45
1.46 #ifdef USBHID_NEW
1.47 - len = hid_report_size(rd, repinfo[repind].kind, &r->rid);
1.48 + len = hid_report_size(rd, repinfo[repind].kind, r->rid);
1.49 #else
1.50 - len = hid_report_size(rd, repinfo[repind].kind, r->rid);
1.51 + len = hid_report_size(rd, repinfo[repind].kind, &r->rid);
1.52 #endif
1.53 if (len < 0) {
1.54 SDL_SetError("Negative HID report size");