Game Development Community

GamePad Rumble

by Owes Beck · in Torque X 2D · 09/27/2007 (11:27 am) · 3 replies

Hi,
Just wondering if any one can tell me how to turn on the rumble for the joystick?

Thanks
-Wes

#1
09/27/2007 (3:06 pm)
There's a static method called SetVibration on the GamePad class (Microsoft.XNA.Framework.Input.GamePad).

int playerIndex = 0; // player index
int leftMotor = 0.5f; // value of left motor (0.0 to 1.0)
int rightMotor = 1.0f; // value of right motor (0.0 to 1.0)

// begin the vibration
GamePad.SetVibration(playerIndex, leftMotor, rightMotor);

// stop the vibration
GamePad.SetVibration(playerIndex, 0, 0);

Note that this sets the current vibration. If you wanted to interpolate or turn the vibration on and off over time you would have to do that yourself buy calling SetVibration in increments over time (in a ProcessTick/UpdateAnimation method, or something similar).

EDIT: Clarification in that first sentence.
#2
09/27/2007 (10:46 pm)
Cool...thanks alot Thomas..Worked like a charm
#3
09/28/2007 (3:15 pm)
NP. Glad you got it working. I was curious about that one myself. :)