Gamepad.FromGameController(IGameController) Gamepad.FromGameController(IGameController) Gamepad.FromGameController(IGameController) Gamepad.FromGameController(IGameController) Gamepad.FromGameController(IGameController) Method

Definition

Returns the given game controller as a gamepad.

public : static Gamepad FromGameController(IGameController gameController)
static Gamepad FromGameController(IGameController gameController) const;
public static Gamepad FromGameController(IGameController gameController)
Public Shared Function FromGameController(gameController As IGameController) As Gamepad
var gamepad = Windows.Gaming.Input.Gamepad.fromGameController(gameController);

Parameters

gameController
IGameController IGameController IGameController

The game controller to be returned as a gamepad.

Returns

The gamepad that was returned from the given game controller.

Additional features and requirements

Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Examples

In the following example, the app gets the first available RawGameController object, and tries to access this game controller via the Gamepad class:

Gamepad^ gamepad;

if (RawGameController::RawGameControllers->Size > 0)
{
    RawGameController^ rawGameController = RawGameController::RawGameControllers->GetAt(0);
    gamepad = Gamepad::FromGameController(rawGameController);
}

if (gamepad != nullptr)
{
    // Assign a standard button mapping to this controller.
}
Gamepad gamepad = null;

if (RawGameController.RawGameControllers.Count > 0)
{
    RawGameController rawGameController = RawGameController.RawGameControllers[0];
    gamepad = Gamepad.FromGameController(rawGameController);
}

if (gamepad != null)
{
    // Assign a standard button mapping to this controller.
}

Remarks

This method checks if the provided game controller has a gamepad implementation, and if so, it returns that implementation. You might use this method if you want to first get the controller as a RawGameController, and then see if it can be used as a Gamepad—if so, you can use a default control scheme for gamepads, otherwise you can let the player do their own input mapping.

See also

  • T:Windows.Gaming.Input.IGameController