comparison src/haptic/linux/SDL_syshaptic.c @ 2484:666472fd4cb0 gsoc2008_force_feedback

HapticSetGain checks to see if device supports it. Added HapticSetAutocenter().
author Edgar Simo <bobbens@gmail.com>
date Tue, 01 Jul 2008 14:21:09 +0000
parents 9d52368ebcf5
children 67978eea6d10
comparison
equal deleted inserted replaced
2483:9d52368ebcf5 2484:666472fd4cb0
517 struct input_event ie; 517 struct input_event ie;
518 518
519 ie.type = EV_FF; 519 ie.type = EV_FF;
520 ie.code = FF_GAIN; 520 ie.code = FF_GAIN;
521 ie.value = (0xFFFFUL * gain) / 100; 521 ie.value = (0xFFFFUL * gain) / 100;
522 printf("%d\n",ie.value); 522
523 523 if (write(haptic->hwdata->fd, &ie, sizeof(ie)) < 0) {
524 if (write(haptic->hwdata->fd, &ie, sizeof(ie)) == -1) {
525 SDL_SetError("Error setting gain."); 524 SDL_SetError("Error setting gain.");
526 } 525 return -1;
527 526 }
528 } 527
528 return 0;
529 }
530
531
532 /*
533 * Sets the autocentering.
534 */
535 int
536 SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
537 {
538 struct input_event ie;
539
540 ie.type = EV_FF;
541 ie.code = FF_AUTOCENTER;
542 ie.value = (0xFFFFUL * autocenter) / 100;
543
544 if (write(haptic->hwdata->fd, &ie, sizeof(ie)) < 0) {
545 SDL_SetError("Error setting autocenter.");
546 return -1;
547 }
548
549 return 0;
550 }
551
529 552
530 553
531 #endif /* SDL_HAPTIC_LINUX */ 554 #endif /* SDL_HAPTIC_LINUX */