More verbosity and error checking.
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403546
This commit is contained in:
parent
dd682a6489
commit
5f6b802b96
2 changed files with 22 additions and 4 deletions
|
@ -66,12 +66,19 @@ ValidHaptic(SDL_Haptic * haptic)
|
|||
int valid;
|
||||
|
||||
valid = 0;
|
||||
if (haptic != NULL) {
|
||||
for (i = 0; i < SDL_numhaptics; i++) {
|
||||
if (SDL_haptics[i] == haptic) {
|
||||
valid = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Create the error here. */
|
||||
if (valid == 0) {
|
||||
SDL_SetError("Haptic: Invalid haptic device identifier");
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
|
|
@ -395,17 +395,28 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
|||
int fd;
|
||||
int ret;
|
||||
|
||||
|
||||
/* Find the joystick in the haptic list. */
|
||||
for (i = 0; i < MAX_HAPTICS; i++) {
|
||||
if (SDL_hapticlist[i].fname != NULL) {
|
||||
if (SDL_strcmp(SDL_hapticlist[i].fname, joystick->hwdata->fname)
|
||||
== 0) {
|
||||
haptic->index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i >= MAX_HAPTICS) {
|
||||
SDL_SetError("Haptic: Joystick doesn't have Haptic capabilities");
|
||||
return -1;
|
||||
}
|
||||
|
||||
fd = open(joystick->hwdata->fname, O_RDWR, 0);
|
||||
if (fd < 0) {
|
||||
SDL_SetError("Haptic: Unable to open %s: %s",
|
||||
joystick->hwdata->fname, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
ret = SDL_SYS_HapticOpenFromFD(haptic, fd); /* Already closes on error. */
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue