comparison src/haptic/darwin/SDL_syshaptic.c @ 2538:1f9c20580ab4 gsoc2008_force_feedback

Improved correctiveness in CreateEffect. Added UpdateEffect support to darwin.
author Edgar Simo <bobbens@gmail.com>
date Sun, 20 Jul 2008 14:12:52 +0000
parents 8d92ec01f92f
children f2649eaa552e
comparison
equal deleted inserted replaced
2537:8d92ec01f92f 2538:1f9c20580ab4
831 if (type == NULL) { 831 if (type == NULL) {
832 goto err_hweffect; 832 goto err_hweffect;
833 } 833 }
834 834
835 /* Get the effect. */ 835 /* Get the effect. */
836 if (SDL_SYS_ToFFEFFECT(haptic, &effect->hweffect->effect, &effect->effect ) < 0) { 836 if (SDL_SYS_ToFFEFFECT(haptic, &effect->hweffect->effect, base) < 0) {
837 goto err_effectdone; 837 goto err_effectdone;
838 } 838 }
839 839
840 /* Create the actual effect. */ 840 /* Create the actual effect. */
841 ret = FFDeviceCreateEffect( haptic->hwdata->device, type, 841 ret = FFDeviceCreateEffect(haptic->hwdata->device, type,
842 &effect->hweffect->effect, &effect->hweffect->ref ); 842 &effect->hweffect->effect, &effect->hweffect->ref);
843 843
844 if (ret != FF_OK) { 844 if (ret != FF_OK) {
845 SDL_SetError("Haptic: Unable to create effect."); 845 SDL_SetError("Haptic: Unable to create effect.");
846 goto err_effectdone; 846 goto err_effectdone;
847 } 847 }
848 848
849 return 0; 849 return 0;
850 850
851 err_effectdone: 851 err_effectdone:
852 SDL_SYS_HapticFreeFFEFFECT(&effect->hweffect->effect, effect->effect.type); 852 SDL_SYS_HapticFreeFFEFFECT(&effect->hweffect->effect, base->type);
853 err_hweffect: 853 err_hweffect:
854 if (effect->hweffect != NULL) { 854 if (effect->hweffect != NULL) {
855 SDL_free(effect->hweffect); 855 SDL_free(effect->hweffect);
856 effect->hweffect = NULL; 856 effect->hweffect = NULL;
857 } 857 }
864 */ 864 */
865 int 865 int
866 SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic, 866 SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic,
867 struct haptic_effect * effect, SDL_HapticEffect * data) 867 struct haptic_effect * effect, SDL_HapticEffect * data)
868 { 868 {
869 /* TODO */ 869 HRESULT ret;
870 FFEffectParameterFlag flags;
871 FFEFFECT temp;
872
873 /* Get the effect. */
874 SDL_memset(&temp, 0, sizeof(FFEFFECT));
875 if (SDL_SYS_ToFFEFFECT(haptic, &temp, data) < 0) {
876 goto err_update;
877 }
878
879 /* Set the flags. Might be worthwhile to diff temp with loaded effect and
880 * only change those parameters. */
881 flags = FFEP_ALLPARAMS;
882
883 /* Create the actual effect. */
884 ret = FFEffectSetParameters(haptic->hwdata->device, effect->hweffect->ref,
885 &temp, flags);
886
887 if (ret != FF_OK) {
888 SDL_SetError("Haptic: Unable to update effect.");
889 goto err_update;
890 }
891
892 /* Copy it over. */
893 SDL_SYS_HapticFreeFFEFFECT(&effect->hweffect->effect, data->type);
894 SDL_memcpy(&effect->hweffect->effect, &temp, sizeof(FFEFFECT));
895
896 return 0;
897
898 err_update:
899 SDL_SYS_HapticFreeFFEFFECT(&temp, data->type);
870 return -1; 900 return -1;
871 } 901 }
872 902
873 903
874 /* 904 /*