How to: Activate the Gamepad Impulse Triggers

To generate vibration effects, activate the impulse triggers, as follows. See also Gamepad Vibration Overview.

To activate the impulse triggers

  1. Use Gamepad.Gamepads to get all connected gamepads.

    C++

    auto gamepads = Gamepad::Gamepads;  
    
  2. Retrieve the desired gamepad from the returned gamepads.

    C++

    // For simplicity, we assume there is only one connected Xbox One Controller.
    // Otherwise, check if the gamepads vector size is > 0 first, by using this: if (gamepads->Size > 0)
    IGamepad^ gamepad0 = gamepads->GetAt(0);
    IGamepadReading^ reading = gamepad0->GetCurrentReading();  
    
  3. Use SetVibration to activate the impulse triggers.

    C++

    auto vibration;
          
    // Valid range for all properties are 0.0f - 1.0f
    vibration.LeftTriggerLevel  = 0.5f; 
    vibration.RightTriggerLevel = 0.5f;
    vibration.LeftMotorLevel    = 0.0f;
    vibration.RightMotorLevel   = 0.0f;
          
    gamepad0->SetVibration(vibration);  
    

See Also

Getting Started with the Gamepad API

How to: Detect Whether a Gamepad Button Is Pressed

How to: Activate Controller Vibration

How to: Get the Pairing Between Bodies and Users by Using an Event-Driven Approach

Programming the Xbox One Gamepad Controller

Gamepad Vibration Overview