共用方式為


LegacyGipGameControllerProvider.FromGameController(IGameController) 方法

定義

為指定的控制器建構 LegacyGipGameControllerProvider

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

參數

controller
IGameController

用來建構 LegacyGipGameControllerProvider 的控制器。

傳回

如果控制器是 GIP (遊戲輸入通訊協定) 控制器,則為 LegacyGipGameControllerProvider。 如果控制器不是 GIP 控制器,則為 Null。

範例

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

適用於

另請參閱