comparison src/haptic/linux/SDL_syshaptic.c @ 3080:4094b4f1c3a1

More verbosity and error checking.
author Edgar Simo <bobbens@gmail.com>
date Sat, 21 Feb 2009 18:03:22 +0000
parents 0906692aa6a4
children 81773a1eac83
comparison
equal deleted inserted replaced
3079:cfc8b35ad6b1 3080:4094b4f1c3a1
393 { 393 {
394 int i; 394 int i;
395 int fd; 395 int fd;
396 int ret; 396 int ret;
397 397
398
398 /* Find the joystick in the haptic list. */ 399 /* Find the joystick in the haptic list. */
399 for (i = 0; i < MAX_HAPTICS; i++) { 400 for (i = 0; i < MAX_HAPTICS; i++) {
400 if (SDL_hapticlist[i].fname != NULL) { 401 if (SDL_hapticlist[i].fname != NULL) {
401 if (SDL_strcmp(SDL_hapticlist[i].fname, joystick->hwdata->fname) 402 if (SDL_strcmp(SDL_hapticlist[i].fname, joystick->hwdata->fname)
402 == 0) { 403 == 0) {
403 haptic->index = i; 404 haptic->index = i;
405 break;
404 } 406 }
405 } 407 }
406 } 408 }
409 if (i >= MAX_HAPTICS) {
410 SDL_SetError("Haptic: Joystick doesn't have Haptic capabilities");
411 return -1;
412 }
407 413
408 fd = open(joystick->hwdata->fname, O_RDWR, 0); 414 fd = open(joystick->hwdata->fname, O_RDWR, 0);
415 if (fd < 0) {
416 SDL_SetError("Haptic: Unable to open %s: %s",
417 joystick->hwdata->fname, strerror(errno));
418 return -1;
419 }
409 ret = SDL_SYS_HapticOpenFromFD(haptic, fd); /* Already closes on error. */ 420 ret = SDL_SYS_HapticOpenFromFD(haptic, fd); /* Already closes on error. */
410 if (ret < 0) { 421 if (ret < 0) {
411 return -1; 422 return -1;
412 } 423 }
413 424