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,13 +66,20 @@ ValidHaptic(SDL_Haptic * haptic)
|
||||||
int valid;
|
int valid;
|
||||||
|
|
||||||
valid = 0;
|
valid = 0;
|
||||||
for (i = 0; i < SDL_numhaptics; i++) {
|
if (haptic != NULL) {
|
||||||
if (SDL_haptics[i] == haptic) {
|
for (i = 0; i < SDL_numhaptics; i++) {
|
||||||
valid = 1;
|
if (SDL_haptics[i] == haptic) {
|
||||||
break;
|
valid = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Create the error here. */
|
||||||
|
if (valid == 0) {
|
||||||
|
SDL_SetError("Haptic: Invalid haptic device identifier");
|
||||||
|
}
|
||||||
|
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -395,17 +395,28 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
||||||
int fd;
|
int fd;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
|
||||||
/* Find the joystick in the haptic list. */
|
/* Find the joystick in the haptic list. */
|
||||||
for (i = 0; i < MAX_HAPTICS; i++) {
|
for (i = 0; i < MAX_HAPTICS; i++) {
|
||||||
if (SDL_hapticlist[i].fname != NULL) {
|
if (SDL_hapticlist[i].fname != NULL) {
|
||||||
if (SDL_strcmp(SDL_hapticlist[i].fname, joystick->hwdata->fname)
|
if (SDL_strcmp(SDL_hapticlist[i].fname, joystick->hwdata->fname)
|
||||||
== 0) {
|
== 0) {
|
||||||
haptic->index = i;
|
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);
|
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. */
|
ret = SDL_SYS_HapticOpenFromFD(haptic, fd); /* Already closes on error. */
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue