示例#1
0
        /// <summary>
        /// Sets the gamepad vibration.
        /// </summary>
        /// <param name="userIndex">Index of the user's controller. Can be a value from 0 to 3.</param>
        /// <param name="leftMotor">The level of the left vibration motor. Valid values are between 0.0 and 1.0, where 0.0 signifies no motor use and 1.0 signifies max vibration.</param>
        /// <param name="rightMotor">The level of the right vibration motor. Valid values are between 0.0 and 1.0, where 0.0 signifies no motor use and 1.0 signifies max vibration.</param>
        /// <returns>True if succeed, false otherwise.</returns>
        public static bool SetVibration(int userIndex, float leftMotor, float rightMotor)
        {
            var vibration = new Vibration
            {
                LeftMotorSpeed  = (ushort)(leftMotor * ushort.MaxValue),
                RightMotorSpeed = (ushort)(rightMotor * ushort.MaxValue)
            };

            return(s_xInput.XInputSetState(userIndex, vibration) == 0);
        }
        /// <summary>Sets the vibration.</summary>
        /// <param name="vibration">The vibration.</param>
        /// <returns></returns>
        public Result SetVibration(Vibration vibration)
        {
            Result result = ErrorCodeHelper.ToResult(xinput.XInputSetState((int)this.userIndex, vibration));

            result.CheckError();
            return(result);
        }
示例#3
0
 /// <summary>
 /// Sets the gamepad vibration.
 /// </summary>
 /// <param name="userIndex">Index of the user's controller. Can be a value from 0 to 3.</param>
 /// <param name="vibration">The <see cref="Vibration"/> to set.</param>
 /// <returns>True if succeed, false otherwise.</returns>
 public static bool SetVibration(int userIndex, Vibration vibration)
 {
     return(s_xInput.XInputSetState(userIndex, vibration) == 0);
 }