UINavigationController.FromGameController(IGameController) 方法

定義

以 UI 流覽控制器的形式傳回指定的遊戲控制器。

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

參數

gameController
IGameController

要以 UI 流覽控制器傳回的遊戲控制器。

傳回

從指定遊戲控制器傳回的 UI 流覽控制器。

Windows 需求

裝置系列
Windows 10 Creators Update (已於 10.0.15063.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v4.0 引進)

範例

在下列範例中,應用程式會取得第一個可用的 RawGameController 物件,並嘗試透過 UINavigationController 類別存取此遊戲控制器。

#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.
}

備註

這個方法會檢查所提供的遊戲控制器是否有 UI 流覽控制器實作,如果是,則會傳回該實作。 如果您想要先取得控制器做為 RawGameController,則可以使用這個方法,然後查看它是否可以當做 UINavigationController使用,如果是的話,您可以使用 UI 流覽控制器的預設控制項配置,否則您可以讓玩家執行自己的輸入對應。

適用於

另請參閱