Share via


FlightStick.FromGameController(IGameController) Method

Definition

Returns the given game controller as a flight stick.

public:
 static FlightStick ^ FromGameController(IGameController ^ gameController);
 static FlightStick FromGameController(IGameController const& gameController);
public static FlightStick FromGameController(IGameController gameController);
function fromGameController(gameController)
Public Shared Function FromGameController (gameController As IGameController) As FlightStick

Parameters

gameController
IGameController

The game controller to be returned as a flight stick.

Returns

The flight stick that was returned from the given game controller.

Examples

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

#include <winrt/Windows.Gaming.Input.h>
using namespace winrt;
using namespace Windows::Gaming::Input;
...
FlightStick flightStick{ nullptr };

if (RawGameController::RawGameControllers().Size() > 0)
{
    RawGameController rawGameController{ RawGameController::RawGameControllers().GetAt(0) };
    flightStick = FlightStick::FromGameController(rawGameController);
}

if (flightStick)
{
    // Assign a standard button mapping to this controller.
}
FlightStick^ flightStick;

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

    flightStick = FlightStick::FromGameController(rawGameController);
}

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

Remarks

This method checks if the provided game controller has a flight stick 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 FlightStick—if so, you can use a default control scheme for flight sticks, otherwise you can let the player do their own input mapping.

Applies to

See also