Fixed bsd joystick detection ... again (thanks Wilbern)
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40545
This commit is contained in:
parent
5c63a69080
commit
9f15e5f2c2
1 changed files with 16 additions and 9 deletions
|
@ -136,17 +136,24 @@ SDL_SYS_JoystickInit(void)
|
||||||
memset(joydevnames, NULL, sizeof(joydevnames));
|
memset(joydevnames, NULL, sizeof(joydevnames));
|
||||||
|
|
||||||
for (i = 0; i < MAX_UHID_JOYS; i++) {
|
for (i = 0; i < MAX_UHID_JOYS; i++) {
|
||||||
|
SDL_Joystick nj;
|
||||||
|
|
||||||
sprintf(s, "/dev/uhid%d", i);
|
sprintf(s, "/dev/uhid%d", i);
|
||||||
fd = open(s, O_RDWR);
|
|
||||||
if (fd > 0) {
|
nj.index = SDL_numjoysticks;
|
||||||
joynames[SDL_numjoysticks++] = strdup(s);
|
joynames[nj.index] = strdup(s);
|
||||||
close(fd);
|
|
||||||
|
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++) {
|
for (i = 0; i < MAX_JOY_JOYS; i++) {
|
||||||
sprintf(s, "/dev/joy%d", i);
|
sprintf(s, "/dev/joy%d", i);
|
||||||
fd = open(s, O_RDWR);
|
fd = open(s, O_RDONLY);
|
||||||
if (fd > 0) {
|
if (fd != -1) {
|
||||||
joynames[SDL_numjoysticks++] = strdup(s);
|
joynames[SDL_numjoysticks++] = strdup(s);
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
@ -178,7 +185,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick *joy)
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
fd = open(path, O_RDWR);
|
fd = open(path, O_RDWR);
|
||||||
if (fd < 0) {
|
if (fd == -1) {
|
||||||
SDL_SetError("%s: %s", path, strerror(errno));
|
SDL_SetError("%s: %s", path, strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
@ -400,9 +407,9 @@ report_alloc(struct report *r, struct report_desc *rd, int repind)
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
#ifdef USBHID_NEW
|
#ifdef USBHID_NEW
|
||||||
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);
|
||||||
|
#else
|
||||||
|
len = hid_report_size(rd, repinfo[repind].kind, &r->rid);
|
||||||
#endif
|
#endif
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
SDL_SetError("Negative HID report size");
|
SDL_SetError("Negative HID report size");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue