Commit 5f6b802b authored by Edgar Simo's avatar Edgar Simo

More verbosity and error checking.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403546
parent dd682a64
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment