src/haptic/linux/SDL_syshaptic.c
changeset 9251 198989b162d3
parent 9249 35a4fab04296
child 9266 f6355bfca853
equal deleted inserted replaced
9250:50fb32b7f2bd 9251:198989b162d3
   727  * Values above 32767 (for unsigned) are unspecified so we must clamp.
   727  * Values above 32767 (for unsigned) are unspecified so we must clamp.
   728  */
   728  */
   729 static int
   729 static int
   730 SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src)
   730 SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src)
   731 {
   731 {
   732     Uint32 tmp;
       
   733     SDL_HapticConstant *constant;
   732     SDL_HapticConstant *constant;
   734     SDL_HapticPeriodic *periodic;
   733     SDL_HapticPeriodic *periodic;
   735     SDL_HapticCondition *condition;
   734     SDL_HapticCondition *condition;
   736     SDL_HapticRamp *ramp;
   735     SDL_HapticRamp *ramp;
   737     SDL_HapticLeftRight *leftright;
   736     SDL_HapticLeftRight *leftright;
   805         else if (periodic->type == SDL_HAPTIC_SAWTOOTHDOWN)
   804         else if (periodic->type == SDL_HAPTIC_SAWTOOTHDOWN)
   806             dest->u.periodic.waveform = FF_SAW_DOWN;
   805             dest->u.periodic.waveform = FF_SAW_DOWN;
   807         dest->u.periodic.period = CLAMP(periodic->period);
   806         dest->u.periodic.period = CLAMP(periodic->period);
   808         dest->u.periodic.magnitude = periodic->magnitude;
   807         dest->u.periodic.magnitude = periodic->magnitude;
   809         dest->u.periodic.offset = periodic->offset;
   808         dest->u.periodic.offset = periodic->offset;
   810         /* Phase is calculated based of offset from period and then clamped. */
   809         /* Linux phase is defined in interval "[0x0000, 0x10000[", corresponds with "[0deg, 360deg[" phase shift. */
   811         tmp = ((periodic->phase % 36000) * dest->u.periodic.period) / 36000;
   810         dest->u.periodic.phase = ((Uint32)periodic->phase * 0x10000U) / 36000;
   812         dest->u.periodic.phase = CLAMP(tmp);
       
   813 
   811 
   814         /* Envelope */
   812         /* Envelope */
   815         dest->u.periodic.envelope.attack_length =
   813         dest->u.periodic.envelope.attack_length =
   816             CLAMP(periodic->attack_length);
   814             CLAMP(periodic->attack_length);
   817         dest->u.periodic.envelope.attack_level =
   815         dest->u.periodic.envelope.attack_level =