LegacyGipGameControllerProvider.GetDeviceFirmwareCorruptionState 方法

定义

检索设备固件是否损坏的状态,如果是,则以何种方式损坏。

public:
 virtual GameControllerFirmwareCorruptReason GetDeviceFirmwareCorruptionState() = GetDeviceFirmwareCorruptionState;
GameControllerFirmwareCorruptReason GetDeviceFirmwareCorruptionState();
public GameControllerFirmwareCorruptReason GetDeviceFirmwareCorruptionState();
function getDeviceFirmwareCorruptionState()
Public Function GetDeviceFirmwareCorruptionState () As GameControllerFirmwareCorruptReason

返回

设备固件是否损坏的状态,如果是,则以何种方式损坏。

示例

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

注解

这应该用于大多数设备,而不是 IsFirmwareCorrupted 大多数设备,因为它受大多数设备支持。 IsFirmwareCorrupted 仅旧版设备支持,仅当不支持时才 GetDeviceFirmwareCorruptionState 应使用。

注意

为了避免损坏设备,固件损坏和更新 API 应仅用于你开发的硬件。

适用于

另请参阅