共用方式為


LegacyGipGameControllerProvider.IsCopilot(User, String) 方法

定義

如果此控制器是 copilot,擷取試驗控制器的標識碼。

public:
 static Platform::String ^ IsCopilot(User ^ user, Platform::String ^ controllerProviderId);
 static winrt::hstring IsCopilot(User const& user, winrt::hstring const& controllerProviderId);
public static string IsCopilot(User user, string controllerProviderId);
function isCopilot(user, controllerProviderId)
Public Shared Function IsCopilot (user As User, controllerProviderId As String) As String

參數

user
User

要檢查配對的使用者。

controllerProviderId
String

Platform::String

winrt::hstring

控制器要檢查配對的提供者標識碼。

傳回

String

Platform::String

winrt::hstring

如果此控制器是 copilot,則為試驗控制器的標識符;否則為 null。

範例

public void CopilotSample(GipGameControllerProvider pilotProvider,
                                    GipGameControllerProvider copilotProvider)
{
    // Establish a copilot pairing for the given pilot and copilot providers
    string pilotId = GameControllerProviderInfo.GetProviderId(pilotProvider);
    string copilotId = GameControllerProviderInfo.GetProviderId(copilotProvider);
    User user = User.GetDefault();
    LegacyGipGameControllerProvider.PairPilotToCopilot(user, pilotId,
        copilotId);

    // Read copilot properties
    LegacyGipGameControllerProvider.IsPilot(user, pilotId); // Returns copilotId
    LegacyGipGameControllerProvider.IsPilot(user, copilotId); // Returns null
    LegacyGipGameControllerProvider.IsCopilot(user, pilotId); // Returns null
    LegacyGipGameControllerProvider.IsCopilot(user, copilotId); // Returns pilotId

    // Removes the pairing for both controllers
    LegacyGipGameControllerProvider.ClearPairing(user, pilotId);
    // Also removes the pairing for both controllers (unnecessary since the pairing was already removed)
    LegacyGipGameControllerProvider.ClearPairing(user, copilotId);
}

適用於