Jaa


UINavigationController.FromGameController(IGameController) Method

Definition

Returns the given game controller as a UI navigation controller.

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

Parameters

gameController
IGameController

The game controller to be returned as a UI navigation controller.

Returns

The UI navigation controller that was returned from the given game controller.

Windows requirements

Device family
Windows 10 Creators Update (introduced in 10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v4.0)

Examples

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

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

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

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

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

    uiNavigationController = 
        UINavigationController::FromGameController(rawGameController);
}

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

Remarks

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

Applies to

See also