src/haptic/darwin/SDL_syshaptic.c
branchgsoc2008_force_feedback
changeset 2563 be2ea885d70b
parent 2562 c284ce0cd8e0
child 2564 c9348710a98a
equal deleted inserted replaced
2562:c284ce0cd8e0 2563:be2ea885d70b
   653          if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes) < 0) {
   653          if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes) < 0) {
   654             return -1;
   654             return -1;
   655          }
   655          }
   656          
   656          
   657          /* Envelope */
   657          /* Envelope */
   658          if (envelope->dwAttackTime == 0) {
   658          if ((envelope->dwAttackTime == 0) && (envelope->dwFadeTime == 0)) {
   659             envelope->dwAttackLevel = constant->dwMagnitude
   659             SDL_free(envelope);
       
   660             dest->lpEnvelope = NULL;
   660          }
   661          }
   661          else {
   662          else {
   662             envelope->dwAttackLevel = CONVERT(hap_constant->attack_level);
   663             envelope->dwAttackLevel = CONVERT(hap_constant->attack_level);
   663             envelope->dwAttackTime = hap_constant->attack_length * 1000;
   664             envelope->dwAttackTime = hap_constant->attack_length * 1000;
   664          }
       
   665          if (envelope->dwFadeTime == 0) {
       
   666             envelope->dwFadeLevel = constant->dwMagnitude
       
   667          }
       
   668          else {
       
   669             envelope->dwFadeLevel = CONVERT(hap_constant->fade_level);
   665             envelope->dwFadeLevel = CONVERT(hap_constant->fade_level);
   670             envelope->dwFadeTime = hap_constant->fade_length * 1000;
   666             envelope->dwFadeTime = hap_constant->fade_length * 1000;
   671          }
   667          }
   672 
   668 
   673          break;
   669          break;
   703          if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes) < 0) {
   699          if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes) < 0) {
   704             return -1;
   700             return -1;
   705          }
   701          }
   706          
   702          
   707          /* Envelope */
   703          /* Envelope */
   708          if (envelope->dwAttackTime == 0) {
   704          if ((envelope->dwAttackTime == 0) && (envelope->dwFadeTime == 0)) {
   709             envelope->dwAttackLevel = periodic->dwMagnitude
   705             SDL_free(envelope);
       
   706             dest->lpEnvelope = NULL;
   710          }
   707          }
   711          else {
   708          else {
   712             envelope->dwAttackLevel = CONVERT(hap_periodic->attack_level);
   709             envelope->dwAttackLevel = CONVERT(hap_periodic->attack_level);
   713             envelope->dwAttackTime = hap_periodic->attack_length * 1000;
   710             envelope->dwAttackTime = hap_periodic->attack_length * 1000;
   714          }
       
   715          if (envelope->dwFadeTime == 0) {
       
   716             envelope->dwFadeLevel = periodic->dwMagnitude
       
   717          }
       
   718          else {
       
   719             envelope->dwFadeLevel = CONVERT(hap_periodic->fade_level);
   711             envelope->dwFadeLevel = CONVERT(hap_periodic->fade_level);
   720             envelope->dwFadeTime = hap_periodic->fade_length * 1000;
   712             envelope->dwFadeTime = hap_periodic->fade_length * 1000;
   721          }
   713          }
   722 
   714 
   723          break;
   715          break;
   794          if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) {
   786          if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) {
   795             return -1;
   787             return -1;
   796          }
   788          }
   797 
   789 
   798          /* Envelope */
   790          /* Envelope */
   799          if (envelope->dwAttackTime == 0) {
   791          if ((envelope->dwAttackTime == 0) && (envelope->dwFadeTime == 0)) {
   800             envelope->dwAttackLevel = ramp->dwMagnitude
   792             SDL_free(envelope);
   801          }
   793             dest->lpEnvelope = NULL;
   802          else {
   794          else {
   803             envelope->dwAttackLevel = CONVERT(hap_ramp->attack_level);
   795             envelope->dwAttackLevel = CONVERT(hap_ramp->attack_level);
   804             envelope->dwAttackTime = hap_ramp->attack_length * 1000;
   796             envelope->dwAttackTime = hap_ramp->attack_length * 1000;
   805          }
       
   806          if (envelope->dwFadeTime == 0) {
       
   807             envelope->dwFadeLevel = ramp->dwMagnitude
       
   808          }
       
   809          else {
       
   810             envelope->dwFadeLevel = CONVERT(hap_ramp->fade_level);
   797             envelope->dwFadeLevel = CONVERT(hap_ramp->fade_level);
   811             envelope->dwFadeTime = hap_ramp->fade_length * 1000;
   798             envelope->dwFadeTime = hap_ramp->fade_length * 1000;
   812          }
   799          }
   813 
   800 
   814          break;
   801          break;
   843          if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) < 0) {
   830          if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) < 0) {
   844             return -1;
   831             return -1;
   845          }
   832          }
   846          
   833          
   847          /* Envelope */
   834          /* Envelope */
   848          if (envelope->dwAttackTime == 0) {
   835          if ((envelope->dwAttackTime == 0) && (envelope->dwFadeTime == 0)) {
   849             envelope->dwAttackLevel = custom->dwMagnitude
   836             SDL_free(envelope);
       
   837             dest->lpEnvelope = NULL;
   850          }
   838          }
   851          else {
   839          else {
   852             envelope->dwAttackLevel = CONVERT(hap_custom->attack_level);
   840             envelope->dwAttackLevel = CONVERT(hap_custom->attack_level);
   853             envelope->dwAttackTime = hap_custom->attack_length * 1000;
   841             envelope->dwAttackTime = hap_custom->attack_length * 1000;
   854          }
       
   855          if (envelope->dwFadeTime == 0) {
       
   856             envelope->dwFadeLevel = custom->dwMagnitude
       
   857          }
       
   858          else {
       
   859             envelope->dwFadeLevel = CONVERT(hap_custom->fade_level);
   842             envelope->dwFadeLevel = CONVERT(hap_custom->fade_level);
   860             envelope->dwFadeTime = hap_custom->fade_length * 1000;
   843             envelope->dwFadeTime = hap_custom->fade_length * 1000;
   861          }
   844          }
   862 
   845 
   863          break;
   846          break;