RemappingButtonCategory 列舉
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
遊戲板重新對應的類型。
public enum class RemappingButtonCategory
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Gaming.Input.GamingInputPreviewContract, 131072)]
enum class RemappingButtonCategory
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Gaming.Input.GamingInputPreviewContract), 131072)]
public enum RemappingButtonCategory
var value = Windows.Gaming.Input.Preview.RemappingButtonCategory.buttonSettings
Public Enum RemappingButtonCategory
- 繼承
-
RemappingButtonCategory
- 屬性
Windows 需求
裝置系列 |
Windows Desktop Extension SDK (已於 10.0.23665.0 引進)
|
API contract |
Windows.Gaming.Input.GamingInputPreviewContract (已於 v2.0 引進)
|
欄位
AnalogSettings | 1 | 用來交換類比控制件。 |
ButtonSettings | 0 | 用來重新對應按鈕。 |
ShareDoublePress | 9 | 未實作。 |
ShareDoublePressMetaData | 10 | 未實作。 |
ShareDoublePressMetaDataDisplay | 11 | 未實作。 |
ShareLongPress | 6 | 未實作。 |
ShareLongPressMetaData | 7 | 未實作。 |
ShareLongPressMetaDataDisplay | 8 | 未實作。 |
ShareShortPress | 3 | 未實作。 |
ShareShortPressMetaData | 4 | 未實作。 |
ShareShortPressMetaDataDisplay | 5 | 未實作。 |
VibrationSettings | 2 | 用來停用震動。 |
範例
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);
}
備註
警告
控制器對應是指定使用者的全系統且持續。 這應該只會在使用者的指示下完成。