Пример #1
0
        // Use the "most recently set" haptic state for each of light bar/motor.
        private void setHapticState()
        {
            int      i = 0;
            DS4Color lightBarColor = LightBarColor;
            byte     lightBarFlashDurationOn = LightBarOnDuration, lightBarFlashDurationOff = LightBarOffDuration;
            byte     rumbleMotorStrengthLeftHeavySlow = LeftHeavySlowRumble, rumbleMotorStrengthRightLightFast = rightLightFastRumble;

            foreach (DS4HapticState haptic in hapticState)
            {
                if (i++ == hapticStackIndex)
                {
                    break; // rest haven't been used this time
                }
                if (haptic.IsLightBarSet())
                {
                    lightBarColor            = haptic.LightBarColor;
                    lightBarFlashDurationOn  = haptic.LightBarFlashDurationOn;
                    lightBarFlashDurationOff = haptic.LightBarFlashDurationOff;
                }
                if (haptic.IsRumbleSet())
                {
                    rumbleMotorStrengthLeftHeavySlow  = haptic.RumbleMotorStrengthLeftHeavySlow;
                    rumbleMotorStrengthRightLightFast = haptic.RumbleMotorStrengthRightLightFast;
                }
            }
            LightBarColor        = lightBarColor;
            LightBarOnDuration   = lightBarFlashDurationOn;
            LightBarOffDuration  = lightBarFlashDurationOff;
            LeftHeavySlowRumble  = rumbleMotorStrengthLeftHeavySlow;
            RightLightFastRumble = rumbleMotorStrengthRightLightFast;
        }
Пример #2
0
 public static bool TryParse(string value, ref DS4Color ds4color)
 {
     try
     {
         string[] ss = value.Split(',');
         return(byte.TryParse(ss[0], out ds4color.red) && byte.TryParse(ss[1], out ds4color.green) && byte.TryParse(ss[2], out ds4color.blue));
     }
     catch { return(false); }
 }
Пример #3
0
 public override bool Equals(object obj)
 {
     if (obj is DS4Color)
     {
         DS4Color dsc = ((DS4Color)obj);
         return(this.red == dsc.red && this.green == dsc.green && this.blue == dsc.blue);
     }
     else
     {
         return(false);
     }
 }