LegacyGipGameControllerProvider.SetStandardControllerButtonRemapping Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Changes the button and axis mapping of a standard gamepad for a user.
public:
virtual void SetStandardControllerButtonRemapping(User ^ user, bool previous, IMapView<RemappingButtonCategory, Platform::Object ^> ^ remapping) = SetStandardControllerButtonRemapping;
void SetStandardControllerButtonRemapping(User const& user, bool const& previous, IMapView<RemappingButtonCategory, IInspectable const&> const& remapping);
public void SetStandardControllerButtonRemapping(User user, bool previous, IReadOnlyDictionary<RemappingButtonCategory,object> remapping);
function setStandardControllerButtonRemapping(user, previous, remapping)
Public Sub SetStandardControllerButtonRemapping (user As User, previous As Boolean, remapping As IReadOnlyDictionary(Of RemappingButtonCategory, Object))
Parameters
- user
- User
The user to remap the controller for.
- previous
-
Boolean
bool
True
if the mapping should be stored in the inactive Previous store; false
if the mapping should be applied.
- remapping
-
IMapView<RemappingButtonCategory,Platform::Object>
IMapView<RemappingButtonCategory,IInspectable>
A dictionary matching each RemappingButtonCategory to data that specifies the remapping. The data type is specific to the category as follows:
RemappingButtonCategory | Data Description |
---|---|
ButtonsSettings | A uint64 composed of 16 nibbles. Each nibble represents a button's assignment. The standard assignment is 0xfedcba9876543210 |
AnalogSettings | A uint32 with the following effects: 0x1 : Swaps triggers / 0x2 : Swaps thumbsticks / 0x4 : Inverts the left thumbstick / 0x8 : Inverts the right thumbstick. The standard assignment is 0. |
VibrationSettings | A uint32 with the following effects: 0x01 : Disables vibration. The standard assignment is 0. |
Examples
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);
}
Remarks
The order of the buttons for ButtonSettings from most significant to least significant is: Right Thumbstick, Left Thumbstick, Right Shoulder, Left Shoulder, DPad Right, DPad Left, DPad Down, DPad Up, Y, X, B, A, View, Menu, Guide, and Bind.
Typically, the previous parameter should be false
, which will apply the remapping. It can also be used to save a mapping for later (for example, to save the default mapping before applying a custom mapping, so that the default mapping can be restored later).
Caution
Controller mapping is system-wide and persistent for the given user. This should only be done at the user's direction.