LegacyGipGameControllerProvider Класс
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Предоставляет набор свойств и функций для администрирования игровых аксессуаров, таких как геймпады и гарнитуры, которые используют протокол GIP (Gaming Input Protocol).
Важно!
Для доступа к этому классу требуется объявление возможности xboxAccessoryManagement
Внимание!
Эти API влияют на все игры в системе и могут привести к проблемам в аксессуаре при неправильном использовании. Корпорация Майкрософт рекомендует использовать эти 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
- Наследование
- Атрибуты
Требования к 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 (Gaming Input Protocol). |
BatteryChargingState |
Возвращает состояние зарядки батареи контроллера. |
BatteryKind |
Возвращает тип батареи контроллера. |
BatteryLevel |
Возвращает уровень заряда батареи контроллера. |
IsFirmwareCorrupted |
Возвращает значение, указывающее, повреждено ли встроенное ПО контроллера. |
IsSyntheticDevice |
Возвращает значение, указывающее, является ли контроллер искусственным или физическим устройством. |
PreferredTypes |
Возвращает набор типов GIP (Gaming Input Protocol), сообщаемых контроллером. |
Методы
ClearPairing(User, String) |
Удаляет все пары copilot для controllerId для данного пользователя. |
ExecuteCommand(DeviceCommand) |
Выполняет команду на устаревшей гарнитуре GIP (Gaming Input Protocol). |
FromGameController(IGameController) |
Создает LegacyGipGameControllerProvider для заданного контроллера. |
FromGameControllerProvider(IGameControllerProvider) |
Создает LegacyGipGameControllerProvider для заданного поставщика контроллера. |
GetDeviceFirmwareCorruptionState() |
Возвращает состояние о том, повреждено ли встроенное ПО устройства, и если да, то каким образом. |
GetExtendedDeviceInfo() |
Извлекает идентификационную информацию для устройства. |
GetHeadsetOperation(HeadsetOperation) |
Извлекает параметр гарнитуры на |
GetStandardControllerButtonRemapping(User, Boolean) |
Извлекает сопоставление кнопок и осей стандартного геймпада для пользователя. |
IsCopilot(User, String) |
Извлекает идентификатор пилотного контроллера, если этот контроллер является копилотом. |
IsInterfaceSupported(Guid) |
Запрашивает, поддерживается ли контроллером заданный guid интерфейса GIP (Gaming Input Protocol). |
IsPilot(User, String) |
Извлекает идентификатор контроллера copilot, если этот контроллер является пилотным. |
PairPilotToCopilot(User, String, String) |
Объединяет контроллеры пилотного проекта и контроллеры copilot для данного пользователя. |
SetHeadsetOperation(HeadsetOperation, Byte[]) |
Задает операцию гарнитуры. |
SetHomeLedIntensity(Byte) |
Задает яркость светодиодного индикатора в кнопке "Домой" контроллера. |
SetStandardControllerButtonRemapping(User, Boolean, IMapView<RemappingButtonCategory,Object>) |
Изменяет сопоставление кнопок и осей стандартного геймпада для пользователя. |