Share via


GamePad.SetVibration Method

Sets the vibration motor speeds on an Xbox 360 Controller.

Namespace: Microsoft.Xna.Framework.Input
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

Syntax

public static bool SetVibration (
         PlayerIndex playerIndex,
         float leftMotor,
         float rightMotor
)

Parameters

  • playerIndex
    Player index that identifies the controller to set.
  • leftMotor
    The speed of the left motor, between 0.0 and 1.0. This motor is a low-frequency motor.
  • rightMotor
    The speed of the right motor, between 0.0 and 1.0. This motor is a high-frequency motor.

Return Value

true if the vibration motors were successfully set; false if the controller was unable to process the request.

Exceptions

Exception type Condition
InvalidOperationException An unknown error has occurred. Verify that the correct playerIndex is being requested.

Remarks

If this method returns false, it means that the controller is either disconnected or too busy to accept the new vibration settings. It is not advisable to loop in wait for this method to return true.

See Also

Tasks

Tutorial 2: Making Your Model Move Using Input
How to: Detect Whether a Controller Button Is Pressed

Reference

GamePad Class
GamePad Members
Microsoft.Xna.Framework.Input Namespace

Platforms

Xbox 360, Windows XP SP2, Windows Vista