Share via


LegacyGipGameControllerProvider.PairPilotToCopilot Method

Definition

Pairs the given pilot and copilot controllers for the given user.

public:
 static void PairPilotToCopilot(User ^ user, Platform::String ^ pilotControllerProviderId, Platform::String ^ copilotControllerProviderId);
 static void PairPilotToCopilot(User const& user, winrt::hstring const& pilotControllerProviderId, winrt::hstring const& copilotControllerProviderId);
public static void PairPilotToCopilot(User user, string pilotControllerProviderId, string copilotControllerProviderId);
function pairPilotToCopilot(user, pilotControllerProviderId, copilotControllerProviderId)
Public Shared Sub PairPilotToCopilot (user As User, pilotControllerProviderId As String, copilotControllerProviderId As String)

Parameters

user
User

User to create a copilot pairing for.

pilotControllerProviderId
String

Platform::String

winrt::hstring

Provider id for the pilot controller.

copilotControllerProviderId
String

Platform::String

winrt::hstring

Provider id for the copilot controller.

Examples

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);
}

Remarks

Once a pilot and copilot controller are paired, all physical inputs from either controller will appear through all input APIs as though they came from the pilot controller.

Caution

Copilot pairing is system-wide and persistent for the given user. This should only be done at the user's direction.

Applies to