comparison src/haptic/darwin/SDL_syshaptic.c @ 2554:2681a04c2d3d gsoc2008_force_feedback

Warn about using button triggers.
author Edgar Simo <bobbens@gmail.com>
date Wed, 30 Jul 2008 14:48:34 +0000
parents 3f853f075bc0
children f5bcc926bac4
comparison
equal deleted inserted replaced
2553:3f853f075bc0 2554:2681a04c2d3d
307 FF_TEST(FFCAP_ET_INERTIA, SDL_HAPTIC_INERTIA); 307 FF_TEST(FFCAP_ET_INERTIA, SDL_HAPTIC_INERTIA);
308 FF_TEST(FFCAP_ET_FRICTION, SDL_HAPTIC_FRICTION); 308 FF_TEST(FFCAP_ET_FRICTION, SDL_HAPTIC_FRICTION);
309 FF_TEST(FFCAP_ET_CUSTOMFORCE, SDL_HAPTIC_CUSTOM); 309 FF_TEST(FFCAP_ET_CUSTOMFORCE, SDL_HAPTIC_CUSTOM);
310 310
311 /* Check if supports gain. */ 311 /* Check if supports gain. */
312 ret = FFDeviceGetForceFeedbackProperty(device, FFPROP_FFGAIN, 312 ret = FFDeviceGetForceFeedbackProperty( device, FFPROP_FFGAIN,
313 &val, sizeof(val)); 313 &val, sizeof(val));
314 if (ret == FF_OK) supported |= SDL_HAPTIC_GAIN; 314 if (ret == FF_OK) supported |= SDL_HAPTIC_GAIN;
315 else if (ret != FFERR_UNSUPPORTED) { 315 else if (ret != FFERR_UNSUPPORTED) {
316 SDL_SetError("Haptic: Unable to get if device supports gain: %s.", 316 SDL_SetError("Haptic: Unable to get if device supports gain: %s.",
317 FFStrError(ret)); 317 FFStrError(ret));
318 return 0; 318 return 0;
508 * Close your haptic devices after usage. */ 508 * Close your haptic devices after usage. */
509 509
510 /* Free the io_service_t */ 510 /* Free the io_service_t */
511 IOObjectRelease(SDL_hapticlist[i].dev); 511 IOObjectRelease(SDL_hapticlist[i].dev);
512 } 512 }
513 }
514
515
516 /*
517 * Converts an SDL trigger button to an FFEFFECT trigger button.
518 */
519 static DWORD
520 FFGetTriggerButton( Uint16 button )
521 {
522 DWORD dwTriggerButton;
523
524 dwTriggerButton = FFEB_NOTRIGGER;
525
526 if (hap_constant->button != 0)
527 dwTriggerButton = FFJOFS_BUTTON(hap_constant->button);
528
529 return dwTriggerButton;
513 } 530 }
514 531
515 532
516 /* 533 /*
517 * Sets the direction. 534 * Sets the direction.
632 dest->cbTypeSpecificParams = sizeof(FFCONSTANTFORCE); 649 dest->cbTypeSpecificParams = sizeof(FFCONSTANTFORCE);
633 dest->lpvTypeSpecificParams = constant; 650 dest->lpvTypeSpecificParams = constant;
634 651
635 /* Generics */ 652 /* Generics */
636 dest->dwDuration = hap_constant->length * 1000; /* In microseconds. */ 653 dest->dwDuration = hap_constant->length * 1000; /* In microseconds. */
637 dest->dwTriggerButton = FFJOFS_BUTTON(hap_constant->button); 654 dest->dwTriggerButton = FFGetTriggerButton(hap_constant->button);
638 dest->dwTriggerRepeatInterval = hap_constant->interval; 655 dest->dwTriggerRepeatInterval = hap_constant->interval;
639 dest->dwStartDelay = hap_constant->delay * 1000; /* In microseconds. */ 656 dest->dwStartDelay = hap_constant->delay * 1000; /* In microseconds. */
640 657
641 /* Direction. */ 658 /* Direction. */
642 if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes) < 0) { 659 if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes) < 0) {
672 dest->cbTypeSpecificParams = sizeof(FFPERIODIC); 689 dest->cbTypeSpecificParams = sizeof(FFPERIODIC);
673 dest->lpvTypeSpecificParams = periodic; 690 dest->lpvTypeSpecificParams = periodic;
674 691
675 /* Generics */ 692 /* Generics */
676 dest->dwDuration = hap_periodic->length * 1000; /* In microseconds. */ 693 dest->dwDuration = hap_periodic->length * 1000; /* In microseconds. */
677 dest->dwTriggerButton = FFJOFS_BUTTON(hap_periodic->button); 694 dest->dwTriggerButton = FFGetTriggerButton(hap_periodic->button);
678 dest->dwTriggerRepeatInterval = hap_periodic->interval; 695 dest->dwTriggerRepeatInterval = hap_periodic->interval;
679 dest->dwStartDelay = hap_periodic->delay * 1000; /* In microseconds. */ 696 dest->dwStartDelay = hap_periodic->delay * 1000; /* In microseconds. */
680 697
681 /* Direction. */ 698 /* Direction. */
682 if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes) < 0) { 699 if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes) < 0) {
715 dest->cbTypeSpecificParams = sizeof(FFCONDITION) * dest->cAxes; 732 dest->cbTypeSpecificParams = sizeof(FFCONDITION) * dest->cAxes;
716 dest->lpvTypeSpecificParams = condition; 733 dest->lpvTypeSpecificParams = condition;
717 734
718 /* Generics */ 735 /* Generics */
719 dest->dwDuration = hap_condition->length * 1000; /* In microseconds. */ 736 dest->dwDuration = hap_condition->length * 1000; /* In microseconds. */
720 dest->dwTriggerButton = FFJOFS_BUTTON(hap_condition->button); 737 dest->dwTriggerButton = FFGetTriggerButton(hap_condition->button);
721 dest->dwTriggerRepeatInterval = hap_condition->interval; 738 dest->dwTriggerRepeatInterval = hap_condition->interval;
722 dest->dwStartDelay = hap_condition->delay * 1000; /* In microseconds. */ 739 dest->dwStartDelay = hap_condition->delay * 1000; /* In microseconds. */
723 740
724 /* Direction. */ 741 /* Direction. */
725 if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes) < 0) { 742 if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes) < 0) {
751 dest->cbTypeSpecificParams = sizeof(FFRAMPFORCE); 768 dest->cbTypeSpecificParams = sizeof(FFRAMPFORCE);
752 dest->lpvTypeSpecificParams = ramp; 769 dest->lpvTypeSpecificParams = ramp;
753 770
754 /* Generics */ 771 /* Generics */
755 dest->dwDuration = hap_ramp->length * 1000; /* In microseconds. */ 772 dest->dwDuration = hap_ramp->length * 1000; /* In microseconds. */
756 dest->dwTriggerButton = FFJOFS_BUTTON(hap_ramp->button); 773 dest->dwTriggerButton = FFGetTriggerButton(hap_ramp->button);
757 dest->dwTriggerRepeatInterval = hap_ramp->interval; 774 dest->dwTriggerRepeatInterval = hap_ramp->interval;
758 dest->dwStartDelay = hap_ramp->delay * 1000; /* In microseconds. */ 775 dest->dwStartDelay = hap_ramp->delay * 1000; /* In microseconds. */
759 776
760 /* Direction. */ 777 /* Direction. */
761 if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) { 778 if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) {
790 dest->cbTypeSpecificParams = sizeof(FFCUSTOMFORCE); 807 dest->cbTypeSpecificParams = sizeof(FFCUSTOMFORCE);
791 dest->lpvTypeSpecificParams = custom; 808 dest->lpvTypeSpecificParams = custom;
792 809
793 /* Generics */ 810 /* Generics */
794 dest->dwDuration = hap_custom->length * 1000; /* In microseconds. */ 811 dest->dwDuration = hap_custom->length * 1000; /* In microseconds. */
795 dest->dwTriggerButton = FFJOFS_BUTTON(hap_custom->button); 812 dest->dwTriggerButton = FFGetTriggerButton(hap_custom->button);
796 dest->dwTriggerRepeatInterval = hap_custom->interval; 813 dest->dwTriggerRepeatInterval = hap_custom->interval;
797 dest->dwStartDelay = hap_custom->delay * 1000; /* In microseconds. */ 814 dest->dwStartDelay = hap_custom->delay * 1000; /* In microseconds. */
798 815
799 /* Direction. */ 816 /* Direction. */
800 if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) < 0) { 817 if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) < 0) {