comparison src/haptic/darwin/SDL_syshaptic.c @ 2557:30778d9d8bff gsoc2008_force_feedback

Made envelopes behave correctly with length of 0.
author Edgar Simo <bobbens@gmail.com>
date Wed, 30 Jul 2008 15:08:44 +0000
parents fe346eddd3fb
children 42b682e85546
comparison
equal deleted inserted replaced
2556:fe346eddd3fb 2557:30778d9d8bff
660 if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes) < 0) { 660 if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes) < 0) {
661 return -1; 661 return -1;
662 } 662 }
663 663
664 /* Envelope */ 664 /* Envelope */
665 envelope->dwAttackLevel = CONVERT(hap_constant->attack_level); 665 if (envelope->dwAttackTime == 0) {
666 envelope->dwAttackTime = hap_constant->attack_length * 1000; 666 envelope->dwAttackLevel = constant->dwMagnitude
667 envelope->dwFadeLevel = CONVERT(hap_constant->fade_level); 667 }
668 envelope->dwFadeTime = hap_constant->fade_length * 1000; 668 else {
669 envelope->dwAttackLevel = CONVERT(hap_constant->attack_level);
670 envelope->dwAttackTime = hap_constant->attack_length * 1000;
671 }
672 if (envelope->dwFadeTime == 0) {
673 envelope->dwFadeLevel = constant->dwMagnitude
674 }
675 else {
676 envelope->dwFadeLevel = CONVERT(hap_constant->fade_level);
677 envelope->dwFadeTime = hap_constant->fade_length * 1000;
678 }
669 679
670 break; 680 break;
671 681
672 case SDL_HAPTIC_SINE: 682 case SDL_HAPTIC_SINE:
673 case SDL_HAPTIC_SQUARE: 683 case SDL_HAPTIC_SQUARE:
700 if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes) < 0) { 710 if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes) < 0) {
701 return -1; 711 return -1;
702 } 712 }
703 713
704 /* Envelope */ 714 /* Envelope */
705 envelope->dwAttackLevel = CONVERT(hap_periodic->attack_level); 715 if (envelope->dwAttackTime == 0) {
706 envelope->dwAttackTime = hap_periodic->attack_length * 1000; 716 envelope->dwAttackLevel = periodic->dwMagnitude
707 envelope->dwFadeLevel = CONVERT(hap_periodic->fade_level); 717 }
708 envelope->dwFadeTime = hap_periodic->fade_length * 1000; 718 else {
719 envelope->dwAttackLevel = CONVERT(hap_periodic->attack_level);
720 envelope->dwAttackTime = hap_periodic->attack_length * 1000;
721 }
722 if (envelope->dwFadeTime == 0) {
723 envelope->dwFadeLevel = periodic->dwMagnitude
724 }
725 else {
726 envelope->dwFadeLevel = CONVERT(hap_periodic->fade_level);
727 envelope->dwFadeTime = hap_periodic->fade_length * 1000;
728 }
709 729
710 break; 730 break;
711 731
712 case SDL_HAPTIC_SPRING: 732 case SDL_HAPTIC_SPRING:
713 case SDL_HAPTIC_DAMPER: 733 case SDL_HAPTIC_DAMPER:
743 if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes) < 0) { 763 if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes) < 0) {
744 return -1; 764 return -1;
745 } 765 }
746 766
747 /* Envelope */ 767 /* Envelope */
768 SDL_free(dest->lpEnvelope);
769 dest->lpEnvelope = NULL;
748 /* TODO Check is envelope actually used. 770 /* TODO Check is envelope actually used.
749 envelope->dwAttackLevel = CONVERT(hap_condition->attack_level); 771 envelope->dwAttackLevel = CONVERT(hap_condition->attack_level);
750 envelope->dwAttackTime = hap_condition->attack_length * 1000; 772 envelope->dwAttackTime = hap_condition->attack_length * 1000;
751 envelope->dwFadeLevel = CONVERT(hap_condition->fade_level); 773 envelope->dwFadeLevel = CONVERT(hap_condition->fade_level);
752 envelope->dwFadeTime = hap_condition->fade_length * 1000; 774 envelope->dwFadeTime = hap_condition->fade_length * 1000;
779 if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) { 801 if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) {
780 return -1; 802 return -1;
781 } 803 }
782 804
783 /* Envelope */ 805 /* Envelope */
784 envelope->dwAttackLevel = CONVERT(hap_ramp->attack_level); 806 if (envelope->dwAttackTime == 0) {
785 envelope->dwAttackTime = hap_ramp->attack_length * 1000; 807 envelope->dwAttackLevel = ramp->dwMagnitude
786 envelope->dwFadeLevel = CONVERT(hap_ramp->fade_level); 808 }
787 envelope->dwFadeTime = hap_ramp->fade_length * 1000; 809 else {
810 envelope->dwAttackLevel = CONVERT(hap_ramp->attack_level);
811 envelope->dwAttackTime = hap_ramp->attack_length * 1000;
812 }
813 if (envelope->dwFadeTime == 0) {
814 envelope->dwFadeLevel = ramp->dwMagnitude
815 }
816 else {
817 envelope->dwFadeLevel = CONVERT(hap_ramp->fade_level);
818 envelope->dwFadeTime = hap_ramp->fade_length * 1000;
819 }
788 820
789 break; 821 break;
790 822
791 case SDL_HAPTIC_CUSTOM: 823 case SDL_HAPTIC_CUSTOM:
792 hap_custom = &src->custom; 824 hap_custom = &src->custom;
818 if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) < 0) { 850 if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) < 0) {
819 return -1; 851 return -1;
820 } 852 }
821 853
822 /* Envelope */ 854 /* Envelope */
823 envelope->dwAttackLevel = CONVERT(hap_custom->attack_level); 855 if (envelope->dwAttackTime == 0) {
824 envelope->dwAttackTime = hap_custom->attack_length * 1000; 856 envelope->dwAttackLevel = custom->dwMagnitude
825 envelope->dwFadeLevel = CONVERT(hap_custom->fade_level); 857 }
826 envelope->dwFadeTime = hap_custom->fade_length * 1000; 858 else {
859 envelope->dwAttackLevel = CONVERT(hap_custom->attack_level);
860 envelope->dwAttackTime = hap_custom->attack_length * 1000;
861 }
862 if (envelope->dwFadeTime == 0) {
863 envelope->dwFadeLevel = custom->dwMagnitude
864 }
865 else {
866 envelope->dwFadeLevel = CONVERT(hap_custom->fade_level);
867 envelope->dwFadeTime = hap_custom->fade_length * 1000;
868 }
827 869
828 break; 870 break;
829 871
830 872
831 default: 873 default: