LegacyGipGameControllerProvider クラス

定義

GIP (ゲーム入力プロトコル) プロトコルを使用するゲーム パッドやヘッドセットなどのゲーム アクセサリを管理するための一連のプロパティと機能を公開します。

重要

このクラスにアクセスするには、xboxAccessoryManagement 機能を宣言する必要があります

注意事項

これらの API は、システム上のすべてのゲームに影響を与え、誤用された場合にアクセサリで問題が発生する可能性があります。 Microsoft では、開発したハードウェアを管理するために、これらの API のみを使用することをお勧めします。

public ref class LegacyGipGameControllerProvider sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Gaming.Input.GamingInputPreviewContract, 131072)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class LegacyGipGameControllerProvider final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Gaming.Input.GamingInputPreviewContract), 131072)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class LegacyGipGameControllerProvider
Public NotInheritable Class LegacyGipGameControllerProvider
継承
Object Platform::Object IInspectable LegacyGipGameControllerProvider
属性

Windows の要件

デバイス ファミリ
Windows Desktop Extension SDK (10.0.23665.0 で導入)
API contract
Windows.Gaming.Input.GamingInputPreviewContract (v2.0 で導入)

コントローラーのプロパティの読み取り

public void EnumerateControllerProperties()
{
    foreach (Gamepad gamepad in Gamepad.Gamepads)
    {
        // Create the provider
        LegacyGipGameControllerProvider legacyGipGameControllerProvider =
            LegacyGipGameControllerProvider.FromGameController(gamepad);
        if (legacyGipGameControllerProvider == null)
        {
            // Not every gamepad is a legacy GIP game controller, continue enumerating
            continue;
        }

        // Check properties
        GameControllerBatteryChargingState chargeState =
            legacyGipGameControllerProvider.BatteryChargingState;
        GameControllerBatteryKind batteryKind =
            legacyGipGameControllerProvider.BatteryKind;
        GameControllerBatteryLevel batteryLevel =
            legacyGipGameControllerProvider.BatteryLevel;
        bool isOldFirmwareCorrupted =
            legacyGipGameControllerProvider.IsFirmwareCorrupted;
        bool isNewFirmwareCorrupted =
            legacyGipGameControllerProvider.GetDeviceFirmwareCorruptionState()
            != GameControllerFirmwareCorruptReason.NotCorrupt;
        bool isSynthetic = legacyGipGameControllerProvider.IsSyntheticDevice;
        byte[] extendedDeviceInfo = legacyGipGameControllerProvider.GetExtendedDeviceInfo();

        // Check for a particular GIP interface
        bool supportsSomeCustomInterface =
            legacyGipGameControllerProvider.IsInterfaceSupported(
                new Guid(
                    0xaaaaaaaa, 0xbbbb, 0xcccc, 0xe, 0xf, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6));

        IReadOnlyList<string> preferredTypes =
            legacyGipGameControllerProvider.PreferredTypes;
        bool isGamepad = preferredTypes.Contains("Windows.Xbox.Input.Gamepad");
        bool isHeadset = preferredTypes.Contains("Windows.Xbox.Input.Headset");

        // Change the LED to half brightness
        legacyGipGameControllerProvider.SetHomeLedIntensity(50);
    }
}

再マップ ボタン

void RemapButtons(IGameController controller, IGameControllerProvider controllerProvider)
{
    LegacyGipGameControllerProvider legacyGipGameControllerProvider =
        LegacyGipGameControllerProvider.FromGameControllerProvider(controllerProvider);

    // Retrieve all current remappings set for standard controllers
    IReadOnlyDictionary<RemappingButtonCategory, object> currentMappings =
        legacyGipGameControllerProvider.GetStandardControllerButtonRemapping(
            controller.User, false);

    // Swap two of the buttons
    Dictionary<RemappingButtonCategory, object> remaps =
        new Dictionary<RemappingButtonCategory, object>();

    // Duplicates are not allowed. Swap two of the buttons
    UInt64 currentButtonMappings =
       (UInt64)currentMappings[RemappingButtonCategory.ButtonSettings];

    // Isolate the buttons we want to remap
    UInt64 lastButton = (currentButtonMappings & 0xf000000000000000);
    UInt64 secondLastButton = currentButtonMappings & 0x0f00000000000000;

    // Swap their positions
    UInt64 newMapping = (lastButton >> 4) | (secondLastButton << 4);

    // Recombine with the original mappings
    UInt64 newButtonMappings = (currentButtonMappings & 0x00ffffffffffffff) | newMapping;

    // Add the new button remappings to the mapping dictionary
    remaps.Add(RemappingButtonCategory.ButtonSettings, newButtonMappings);

    // Update controller mapping
    legacyGipGameControllerProvider.SetStandardControllerButtonRemapping(
        controller.User, false, newButtonMappings);
}

Copilot の設定

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

ヘッドセットの管理

public void SetupHeadset(IGameControllerProvider headsetProvider)
{
    LegacyGipGameControllerProvider legacyGipGameControllerProvider =
        LegacyGipGameControllerProvider.FromGameControllerProvider(headsetProvider);

    // Reset the device
    legacyGipGameControllerProvider.ExecuteCommand(DeviceCommand.Reset);

    // Check the smart mute level
    byte[] smartMuteBuffer =
        legacyGipGameControllerProvider.GetHeadsetOperation(HeadsetOperation.SmartMute);
    HeadsetLevel smartMuteValue = (HeadsetLevel)smartMuteBuffer[0];

    // Set bass boost to 3db
    byte[] bassBuffer = BitConverter.GetBytes((UInt32)3);
    legacyGipGameControllerProvider.SetHeadsetOperation(HeadsetOperation.BassBoostGain,
        bassBuffer);
}

プロパティ

AppCompatVersion

GIP (ゲーム入力プロトコル) ドライバーによって報告されたアプリの互換性バージョンを取得します。

BatteryChargingState

コントローラーのバッテリ充電状態を取得します。

BatteryKind

コントローラーのバッテリーの種類を取得します。

BatteryLevel

コントローラーのバッテリー充電レベルを取得します。

IsFirmwareCorrupted

コントローラー ファームウェアが破損しているかどうかを返します。

IsSyntheticDevice

コントローラーが合成デバイスか物理デバイスかを返します。

PreferredTypes

コントローラーによって報告される GIP (ゲーム入力プロトコル) の種類のセットを取得します。

メソッド

ClearPairing(User, String)

特定のユーザーの controllerId の copilot ペアリングを削除します。

ExecuteCommand(DeviceCommand)

従来の GIP (ゲーム入力プロトコル) ヘッドセットでコマンドを実行します。

FromGameController(IGameController)

指定されたコントローラーの LegacyGipGameControllerProvider を構築します。

FromGameControllerProvider(IGameControllerProvider)

特定のコントローラー プロバイダー の LegacyGipGameControllerProvider を構築します。

GetDeviceFirmwareCorruptionState()

デバイスのファームウェアが破損しているかどうかの状態を取得し、破損している場合は、どのような方法で取得します。

GetExtendedDeviceInfo()

デバイスの識別情報を取得します。

GetHeadsetOperation(HeadsetOperation)

に基づいてヘッドセット設定を operation取得します。

GetStandardControllerButtonRemapping(User, Boolean)

ユーザーの標準ゲームパッドのボタンと軸のマッピングを取得します。

IsCopilot(User, String)

このコントローラーが copilot の場合は、パイロット コントローラーの ID を取得します。

IsInterfaceSupported(Guid)

指定された GIP (Gaming Input Protocol) インターフェイス guid がコントローラーでサポートされているかどうかを照会します。

IsPilot(User, String)

このコントローラーがパイロットである場合は、copilot コントローラーの ID を取得します。

PairPilotToCopilot(User, String, String)

指定されたユーザーに対して、指定されたパイロット コントローラーと copilot コントローラーをペアにします。

SetHeadsetOperation(HeadsetOperation, Byte[])

ヘッドセット操作を設定します。

SetHomeLedIntensity(Byte)

コントローラーのホーム ボタンの LED の明るさを設定します。

SetStandardControllerButtonRemapping(User, Boolean, IMapView<RemappingButtonCategory,Object>)

ユーザーの標準ゲームパッドのボタンと軸のマッピングを変更します。

適用対象

こちらもご覧ください