public static void StartLoading(LocalizationManager __instance) { // Nab the localization dictionary that's used for keybind localization Dictionary <string, string> m_generalLocalization = (Dictionary <string, string>)__instance.GetType().GetField("m_generalLocalization", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance); // Go through the added actions and use the user-created action descriptions to name them foreach (int myActionId in CustomKeybindings.myCustomActionIds.Keys) { InputAction myAction = ReInput.mapping.GetAction(myActionId); CustomKeybindings.InputActionDescription myActionDescription = CustomKeybindings.myCustomActionIds[myActionId]; // The first string is the technical name of the action, while the second string is what you want to display in the bindings menu m_generalLocalization.Add("InputAction_" + myAction.name, myActionDescription.name); } }
public static bool InitSections(ControllerMap _controllerMap) { // Loop through our custom actions we added via Rewired foreach (int myActionId in CustomKeybindings.myCustomActionIds.Keys) { // The info that the user specified for this action CustomKeybindings.InputActionDescription myActionDescription = CustomKeybindings.myCustomActionIds[myActionId]; // There are separate keybinding maps for keyboard, mouse, & controllers // We only add our action-to-element mappings to the keybind maps that make sense // For example, if you are adding a key that doesn't make sense to have on a controller, // then skip when _controllerMap is JoystickMap // // (Optional) // You can check if this method is being called for the Keyboard/Mouse bindings panel or // the Controller bindings panel, but I prefer to check the class of the _controllerMap // if (self.ControllerType == ControlMappingPanel.ControlType.Keyboard) { // // If the controller map's control type does not match our action if (!(myActionDescription.controlType == CustomKeybindings.ControlType.Keyboard && (_controllerMap is KeyboardMap || _controllerMap is MouseMap) || myActionDescription.controlType == CustomKeybindings.ControlType.Gamepad && (_controllerMap is JoystickMap) || myActionDescription.controlType == CustomKeybindings.ControlType.Both)) { // Then skip to next action continue; } // If the categoryId of this controller map does not match our action's if (_controllerMap.categoryId != myActionDescription.sectionId) { // Skip to next action continue; } // If we pass the tests, create & add the action-to-element map for this particular action _controllerMap.CreateElementMap(myActionId, Pole.Positive, KeyCode.None, ModifierKeyFlags.None); // Continue the loop... } // We're done here. Call original implementation return(true); }