# HG changeset patch # User Sam Lantinga # Date 1037559785 0 # Node ID 2d7373ffd1317fec22829f00b7eb5256f85c9f17 # Parent 522e5202014d00f0842b4159ce5bc9188d09f1d0 Fixed bsd joystick detection ... again (thanks Wilbern) diff -r 522e5202014d -r 2d7373ffd131 src/joystick/bsd/SDL_sysjoystick.c --- a/src/joystick/bsd/SDL_sysjoystick.c Sun Nov 17 18:59:10 2002 +0000 +++ b/src/joystick/bsd/SDL_sysjoystick.c Sun Nov 17 19:03:05 2002 +0000 @@ -136,17 +136,24 @@ memset(joydevnames, NULL, sizeof(joydevnames)); for (i = 0; i < MAX_UHID_JOYS; i++) { + SDL_Joystick nj; + sprintf(s, "/dev/uhid%d", i); - fd = open(s, O_RDWR); - if (fd > 0) { - joynames[SDL_numjoysticks++] = strdup(s); - close(fd); + + nj.index = SDL_numjoysticks; + joynames[nj.index] = strdup(s); + + if (SDL_SYS_JoystickOpen(&nj) == 0) { + SDL_SYS_JoystickClose(&nj); + SDL_numjoysticks++; + } else { + free(joynames[nj.index]); } } for (i = 0; i < MAX_JOY_JOYS; i++) { sprintf(s, "/dev/joy%d", i); - fd = open(s, O_RDWR); - if (fd > 0) { + fd = open(s, O_RDONLY); + if (fd != -1) { joynames[SDL_numjoysticks++] = strdup(s); close(fd); } @@ -178,7 +185,7 @@ int fd; fd = open(path, O_RDWR); - if (fd < 0) { + if (fd == -1) { SDL_SetError("%s: %s", path, strerror(errno)); return (-1); } @@ -400,9 +407,9 @@ int len; #ifdef USBHID_NEW - len = hid_report_size(rd, repinfo[repind].kind, &r->rid); + len = hid_report_size(rd, repinfo[repind].kind, r->rid); #else - len = hid_report_size(rd, repinfo[repind].kind, r->rid); + len = hid_report_size(rd, repinfo[repind].kind, &r->rid); #endif if (len < 0) { SDL_SetError("Negative HID report size");