Пример #1
0
        private static ControllerMap GetMapKB()
        {
            ControllerMap c = new ControllerMap();

            c.ButtonA = "J";
            c.ButtonB = "K";
            c.ButtonX = "L";
            c.ButtonY = "I";

            c.ButtonZ     = "R";
            c.ButtonStart = "SEMICOLON";

            c.MainStickUp    = "W";
            c.MainStickDown  = "S";
            c.MainStickLeft  = "A";
            c.MainStickRight = "D";

            c.CStickUp    = "UP";
            c.CStickDown  = "DOWN";
            c.CStickLeft  = "LEFT";
            c.CStickRight = "RIGHT";

            c.TriggerL = "Q";
            c.TriggerR = "E";

            c.DPadUp    = "``";
            c.DPadDown  = "``";
            c.DPadLeft  = "``";
            c.DPadRight = "``";

            c.Rumble = "``";

            return(c);
        }
Пример #2
0
        private void <ApplyUserProfileBindingsToRewiredPlayer> g__ApplyUserProfileBindingstoRewiredController | 20_0 (Controller controller)
        {
            if (this.userProfile == null)
            {
                return;
            }
            ControllerMap controllerMap = null;
            switch (controller.type)
            {
            case ControllerType.Keyboard:
                controllerMap = this.userProfile.keyboardMap;
                break;

            case ControllerType.Mouse:
                controllerMap = this.userProfile.mouseMap;
                break;

            case ControllerType.Joystick:
                controllerMap = this.userProfile.joystickMap;
                break;
            }
            if (controllerMap != null)
            {
                this.inputPlayer.controllers.maps.AddMap(controller, controllerMap);
            }
        }
Пример #3
0
        internal static void RevertRemap()
        {
            ControllerMap map = Utils.localInputPlayer.controllers.maps.GetMap(vrControllers, vrGameplayMap.id);

            int[] originalSkillBindingIDs = new int[]
            {
                (ModConfig.LeftDominantHand.Value ? 9 : 8),
                (ModConfig.LeftDominantHand.Value ? 8 : 9),
                (ModConfig.LeftDominantHand.Value ? 11 : 10),
                (ModConfig.LeftDominantHand.Value ? 10 : 11)
            };

            for (int i = 0; i < 4; i++)
            {
                ActionElementMap elementMap = vrGameplayMap.GetElementMapsWithAction(7 + i)[0];

                if (elementMap.elementIdentifierId == originalSkillBindingIDs[i])
                {
                    continue;
                }

                if (!map.ReplaceElementMap(elementMap.id, elementMap.actionId, elementMap.axisContribution, originalSkillBindingIDs[i], elementMap.elementType, elementMap.axisRange, elementMap.invert))
                {
                    VRMod.StaticLogger.LogError("An error occured while trying to revert skill binding overrides.");
                }
            }
        }
Пример #4
0
        private static ControllerMap GetMapController(int cid, string layout)
        {
            ControllerMap c = new ControllerMap();

            c.ButtonA = $"`WGInput/{cid}/Xbox 360 Controller for Windows:Button {(layout == "Xbox" ? 'A' : 'B')}`";
            c.ButtonB = $"`WGInput/{cid}/Xbox 360 Controller for Windows:Button {(layout == "Xbox" ? 'B' : 'A')}`";
            c.ButtonX = $"`WGInput/{cid}/Xbox 360 Controller for Windows:Button {(layout == "Xbox" ? 'X' : 'Y')}`";
            c.ButtonY = $"`WGInput/{cid}/Xbox 360 Controller for Windows:Button {(layout == "Xbox" ? 'Y' : 'X')}`";

            c.ButtonZ     = $"`WGInput/{cid}/Xbox 360 Controller for Windows:Bumper R`";
            c.ButtonStart = $"`WGInput/{cid}/Xbox 360 Controller for Windows:Start`";

            c.MainStickUp    = $"`WGInput/{cid}/Xbox 360 Controller for Windows:Left Y+`";
            c.MainStickDown  = $"`WGInput/{cid}/Xbox 360 Controller for Windows:Left Y-`";
            c.MainStickLeft  = $"`WGInput/{cid}/Xbox 360 Controller for Windows:Left X-`";
            c.MainStickRight = $"`WGInput/{cid}/Xbox 360 Controller for Windows:Left X+`";

            c.CStickUp    = $"`WGInput/{cid}/Xbox 360 Controller for Windows:Right Y+`";
            c.CStickDown  = $"`WGInput/{cid}/Xbox 360 Controller for Windows:Right Y-`";
            c.CStickLeft  = $"`WGInput/{cid}/Xbox 360 Controller for Windows:Right X-`";
            c.CStickRight = $"`WGInput/{cid}/Xbox 360 Controller for Windows:Right X+`";

            c.TriggerL = $"`WGInput/{cid}/Xbox 360 Controller for Windows:Trigger L`";
            c.TriggerR = $"`WGInput/{cid}/Xbox 360 Controller for Windows:Trigger R`";

            c.DPadUp    = $"`WGInput/{cid}/Xbox 360 Controller for Windows:Pad N`";
            c.DPadDown  = $"`WGInput/{cid}/Xbox 360 Controller for Windows:Pad S`";
            c.DPadLeft  = $"`WGInput/{cid}/Xbox 360 Controller for Windows:Pad W`";
            c.DPadRight = $"`WGInput/{cid}/Xbox 360 Controller for Windows:Pad E`";

            c.Rumble = $"`WGInput/{cid}/Xbox 360 Controller for Windows:Motor L`|`WGInput/{cid}/Xbox 360 Controller for Windows:Motor R`";

            return(c);
        }
Пример #5
0
        /// <summary>Gets the controller associated with a given content type.</summary>
        /// <param name="contentType">The type of content item whose controller to get.</param>
        /// <returns>A controller name if a controller was found.</returns>
        public string GetControllerName(Type type)
        {
            string name;

            ControllerMap.TryGetValue(type, out name);
            return(name);
        }
Пример #6
0
    private void handleInput()
    {
        _inputAngle = Vector2.Angle(Vector2.up, _stickLocation);

        // up
        if (_inputAngle < 45.0f)
        {
            ControllerMap.SearchForUp();
        }
        // left and right
        else if (_inputAngle > 45.0f && _inputAngle < 135.0f)
        {
            // left
            if (_stickLocation.x > 0)
            {
                ControllerMap.SearchForLeft();
            }
            // right
            else
            {
                ControllerMap.SearchForRight();
            }
        }
        // down
        else
        {
            ControllerMap.SearchForDown();
        }
    }
        private IEnumerator StartListeningDelayed(int index, ControllerMap keyboardMap, ControllerMap mouseMap, int actionElementMapToReplaceId)
        {
            // Don't allow a binding for a short period of time after input field is activated
            // to prevent button bound to UI Submit from binding instantly when input field is activated.
            yield return(new WaitForSeconds(0.1f));

            // Begin listening for input on both keyboard and mouse at the same time

            inputMapper_keyboard.Start(
                new InputMapper.Context()
            {
                actionId                  = rows[index].action.id,
                controllerMap             = keyboardMap,
                actionRange               = rows[index].actionRange,
                actionElementMapToReplace = keyboardMap.GetElementMap(actionElementMapToReplaceId)
            }
                );

            inputMapper_mouse.Start(
                new InputMapper.Context()
            {
                actionId                  = rows[index].action.id,
                controllerMap             = mouseMap,
                actionRange               = rows[index].actionRange,
                actionElementMapToReplace = mouseMap.GetElementMap(actionElementMapToReplaceId)
            }
                );

            // Disable the UI Controller Maps while listening to prevent UI control and submissions.
            player.controllers.maps.SetMapsEnabled(false, uiCategory);

            // Update the UI text
            statusUIText.text = "Listening...";
        }
Пример #8
0
 /// <summary>
 /// 激活一个按钮集合
 /// </summary>
 /// <param name="btns"></param>
 protected void EnabledControllers(JoystickController[] btns)
 {
     for (int i = 0; i < btns.Length; i++)
     {
         ControllerMap.Find(btns[i].gameObject.name).Enabled = true;
     }
 }
Пример #9
0
            public static bool InitSections(ControllerMap _controllerMap)
            {
                InitLocalization();

                if (_controllerMap.categoryId == CUSTOM_CATEGORY)
                {
                    return(false);
                }

                foreach (var keybindInfo in s_customKeyDict.Values)
                {
                    // If the controller map's control type does not match our action
                    if (!(keybindInfo.controllerType == ControlType.Both ||
                          keybindInfo.controllerType == ControlType.Keyboard && (_controllerMap is KeyboardMap || _controllerMap is MouseMap) ||
                          keybindInfo.controllerType == ControlType.Gamepad && (_controllerMap is JoystickMap)))
                    {
                        // Then skip to next action
                        continue;
                    }

                    // i dont know but this gets the best results
                    if (_controllerMap.categoryId != 5)
                    {
                        // Skip to next action
                        continue;
                    }

                    //SL.LogWarning("Creating element map for '" + keybindInfo.name + "', id: " + _controllerMap.id + ", categoryId: " + _controllerMap.categoryId);

                    _controllerMap.CreateElementMap(keybindInfo.actionID, Pole.Positive, KeyCode.None, ModifierKeyFlags.None);
                }

                // We're done here. Call original implementation
                return(true);
            }
Пример #10
0
    public void SetInputType(string type)
    {
        ControllerMap cUIMap = m_RewiredPlayer.controllers.maps.GetMap(ControllerType.Joystick, 0, "Default", "UI");
        ControllerMap cDMap  = m_RewiredPlayer.controllers.maps.GetMap(ControllerType.Joystick, 0, "Default", "Default");

        if (cUIMap != null && cDMap != null)
        {
        }
        else
        {
            cUIMap = m_RewiredPlayer.controllers.maps.GetMap(ControllerType.Keyboard, 0, "Default", "UI");
            cDMap  = m_RewiredPlayer.controllers.maps.GetMap(ControllerType.Keyboard, 0, "Default", "Default");
        }

        switch (type)
        {
        case "UI":
            cUIMap.enabled = true;
            cDMap.enabled  = false;
            break;

        case "Default":
            cUIMap.enabled = false;
            cDMap.enabled  = true;
            break;
        }
    }
        // Event Handlers

        // Called by the input field UI Button when pressed
        private void OnInputFieldClicked(int index, int actionElementMapToReplaceId)
        {
            if (index < 0 || index >= rows.Count)
            {
                return;                                  // index out of range
            }
            ControllerMap keyboardMap = player.controllers.maps.GetMap(ControllerType.Keyboard, 0, category, layout);
            ControllerMap mouseMap    = player.controllers.maps.GetMap(ControllerType.Mouse, 0, category, layout);

            // Cannot replace a keyboard binding on a Mouse Map or vice versa
            // Replacement cross device has to be done by removing the other
            // binding manually after input is mapped.
            // Determine which map the replacement binding exists on and store that information.
            ControllerMap controllerMapWithReplacement;

            // Determine if the replacement is on the keyboard or mouse map
            if (keyboardMap.ContainsElementMap(actionElementMapToReplaceId))
            {
                controllerMapWithReplacement = keyboardMap;
            }
            else if (mouseMap.ContainsElementMap(actionElementMapToReplaceId))
            {
                controllerMapWithReplacement = mouseMap;
            }
            else
            {
                controllerMapWithReplacement = null;  // not a replacement
            }
            // Store the information about the replacement if any
            _replaceTargetMapping = new TargetMapping()
            {
                actionElementMapId = actionElementMapToReplaceId,
                controllerMap      = controllerMapWithReplacement
            };

            // Begin listening for input on both keyboard and mouse at the same time

            inputMapper_keyboard.Start(
                new InputMapper.Context()
            {
                actionId                  = rows[index].action.id,
                controllerMap             = keyboardMap,
                actionRange               = rows[index].actionRange,
                actionElementMapToReplace = keyboardMap.GetElementMap(actionElementMapToReplaceId)
            }
                );

            inputMapper_mouse.Start(
                new InputMapper.Context()
            {
                actionId                  = rows[index].action.id,
                controllerMap             = mouseMap,
                actionRange               = rows[index].actionRange,
                actionElementMapToReplace = mouseMap.GetElementMap(actionElementMapToReplaceId)
            }
                );

            statusUIText.text = "Listening...";
        }
Пример #12
0
 public InputMapping(string actionName, InputFieldInfo fieldInfo, ControllerMap map, ActionElementMap aem, ControllerType controllerType, int controllerId)
 {
     this.actionName     = actionName;
     this.fieldInfo      = fieldInfo;
     this.map            = map;
     this.aem            = aem;
     this.controllerType = controllerType;
     this.controllerId   = controllerId;
 }
Пример #13
0
        public static bool InitSections(ControllerMap _controllerMap)
        {
            //MyLogger.LogDebug("InitSections");
            // 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) {
                //

                bool shouldLog = false;
                if (shouldLog)
                {
                    MyLogger.LogDebug("_controllerMap is keyboard or mouse: " + (_controllerMap is KeyboardMap || _controllerMap is MouseMap));
                    MyLogger.LogDebug("_controllerMap is joystick: " + (_controllerMap is JoystickMap));
                    MyLogger.LogDebug("_controllerMap.categoryId: " + _controllerMap.categoryId);
                    MyLogger.LogDebug("action is keyboard: " + (myActionDescription.controlType == ControlType.Keyboard));
                    MyLogger.LogDebug("action is gamepad: " + (myActionDescription.controlType == ControlType.Gamepad));
                    MyLogger.LogDebug("action is both: " + (myActionDescription.controlType == ControlType.Both));
                    MyLogger.LogDebug("action.sectionId: " + myActionDescription.sectionId);
                }

                // If the controller map's control type does not match our action
                if (!(myActionDescription.controlType == ControlType.Keyboard && (_controllerMap is KeyboardMap || _controllerMap is MouseMap) ||
                      myActionDescription.controlType == ControlType.Gamepad && (_controllerMap is JoystickMap) ||
                      myActionDescription.controlType == 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);
        }
Пример #14
0
    public override void Init()
    {
        base.Init();

        if (ControllerMap == null)
        {
            ControllerMap = JoystickControllerMap.create();
        }

        ControllerMap.Init(GetComponentsInChildren <JoystickController>());
    }
Пример #15
0
        private void AddDefaultMappingsForNewActions(Player player, List <UserDataStore_PlayerPrefs.SavedControllerMapData> savedData, ControllerType controllerType, int controllerId)
        {
            if (player == null || savedData == null)
            {
                return;
            }
            List <int> allActionIds = this.GetAllActionIds();

            for (int i = 0; i < savedData.Count; i++)
            {
                UserDataStore_PlayerPrefs.SavedControllerMapData savedControllerMapData = savedData[i];
                if (savedControllerMapData != null)
                {
                    if (savedControllerMapData.knownActionIds != null && savedControllerMapData.knownActionIds.Count != 0)
                    {
                        ControllerMap controllerMap = ControllerMap.CreateFromXml(controllerType, savedData[i].xml);
                        if (controllerMap != null)
                        {
                            ControllerMap map = player.controllers.maps.GetMap(controllerType, controllerId, controllerMap.categoryId, controllerMap.layoutId);
                            if (map != null)
                            {
                                ControllerMap controllerMapInstance = ReInput.mapping.GetControllerMapInstance(ReInput.controllers.GetController(controllerType, controllerId), controllerMap.categoryId, controllerMap.layoutId);
                                if (controllerMapInstance != null)
                                {
                                    List <int> list = new List <int>();
                                    foreach (int item in allActionIds)
                                    {
                                        if (!savedControllerMapData.knownActionIds.Contains(item))
                                        {
                                            list.Add(item);
                                        }
                                    }
                                    if (list.Count != 0)
                                    {
                                        foreach (ActionElementMap actionElementMap in controllerMapInstance.AllMaps)
                                        {
                                            if (list.Contains(actionElementMap.actionId))
                                            {
                                                if (!map.DoesElementAssignmentConflict(actionElementMap))
                                                {
                                                    ElementAssignment elementAssignment = new ElementAssignment(controllerType, actionElementMap.elementType, actionElementMap.elementIdentifierId, actionElementMap.axisRange, actionElementMap.keyCode, actionElementMap.modifierKeyFlags, actionElementMap.actionId, actionElementMap.axisContribution, actionElementMap.invert);
                                                    map.CreateElementMap(elementAssignment);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #16
0
        private void RedrawUI(ControllerMap map)
        {
            // Update each button label with the currently mapped element identifier
            for (int i = 0; i < Buttons.Count; i++)
            {
                Template.InputButtonTemplate template = Buttons[i];
                InputAction action = Buttons[i].InputAction;

                string name = string.Empty;
                int    actionElementMapId = -1;

                // Find the first ActionElementMap that maps to this action and is compatible with this field type
                foreach (var actionElementMap in map.ElementMapsWithAction(action.id))
                {
                    Debug.Log(actionElementMap.actionDescriptiveName + " | " + actionElementMap.controllerMap.controllerType.ToString());
                    if (actionElementMap.controllerMap.controllerType == ControllerType.Keyboard)
                    {
                        template.IsKeyboard = true;
                    }

                    if (actionElementMap.ShowInField(template.AxisRange))
                    {
                        name = actionElementMap.elementIdentifierName;
                        actionElementMapId = actionElementMap.id;
                        break;
                    }
                }

                if (map.controllerType == ControllerType.Keyboard && template.IsKeyboard)
                {
                    // Set the label for the button
                    template.RemapButtonText.SetText(name);

                    // Set the field button callback
                    template.RemapButton.onClick.RemoveAllListeners(); // clear all events
                    int index = i;                                     // copy the variable for closer
                    template.RemapButton.onClick.AddListener(() => OnInputFieldClicked(index, actionElementMapId, map));
                }
                else if (map.controllerType == ControllerType.Mouse && !template.IsKeyboard)
                {
                    template.transform.SetParent(MouseControlContent);

                    // Set the label for the button
                    template.RemapButtonText.SetText(name);

                    // Set the field button callback
                    template.RemapButton.onClick.RemoveAllListeners(); // clear all events
                    int index = i;                                     // copy the variable for closer
                    template.RemapButton.onClick.AddListener(() => OnInputFieldClicked(index, actionElementMapId, map));
                }
            }
        }
 // Token: 0x06000255 RID: 597 RVA: 0x00037D08 File Offset: 0x00035F08
 public virtual ActionElementMap GetActionElementMapToUse(Controller controller, string theAction, bool positiveAxis)
 {
     if (!RuntimeServices.EqualityOperator(controller, null))
     {
         ControllerMap      map = this.player.controllers.maps.GetMap(controller.type, controller.id, "Default", "Default");
         ActionElementMap[] elementMapsWithAction = map.GetElementMapsWithAction(theAction);
         int i = 0;
         ActionElementMap[] array = elementMapsWithAction;
         int length = array.Length;
         while (i < length)
         {
             if (array[i].axisContribution == ((!positiveAxis) ? Pole.Negative : Pole.Positive))
             {
                 return(array[i]);
             }
             i++;
         }
         map = this.player.controllers.maps.GetMap(controller.type, controller.id, "Motorcycle", "Default");
         if (!RuntimeServices.EqualityOperator(map, null))
         {
             elementMapsWithAction = map.GetElementMapsWithAction(theAction);
             int j = 0;
             ActionElementMap[] array2 = elementMapsWithAction;
             int length2 = array2.Length;
             while (j < length2)
             {
                 if (array2[j].axisContribution == ((!positiveAxis) ? Pole.Negative : Pole.Positive))
                 {
                     return(array2[j]);
                 }
                 j++;
             }
         }
         map = this.player.controllers.maps.GetMap(controller.type, controller.id, "UI Nav", "Default");
         if (!RuntimeServices.EqualityOperator(map, null))
         {
             elementMapsWithAction = map.GetElementMapsWithAction(theAction);
             int k = 0;
             ActionElementMap[] array3 = elementMapsWithAction;
             int length3 = array3.Length;
             while (k < length3)
             {
                 if (array3[k].axisContribution == ((!positiveAxis) ? Pole.Negative : Pole.Positive))
                 {
                     return(array3[k]);
                 }
                 k++;
             }
         }
     }
     return(null);
 }
Пример #18
0
        //Set up a control mapping UI section and bind references

        internal static void InitCustomSection(ControlMappingSection mapSection, ControllerMap _controllerMap, IEnumerable <KeybindInfo> keysToAdd)
        {
            if (_controllerMap == null)
            {
                return;
            }

            // Loop through the custom actions we defined
            foreach (var customKey in keysToAdd)
            {
                // add the actual keybind mapping to this controller in Rewired
                _controllerMap.CreateElementMap(customKey.actionID, Pole.Positive, KeyCode.None, ModifierKeyFlags.None);

                var alreadyKnown = At.GetField(mapSection, "m_actionAlreadyKnown") as List <int>;

                // see if the UI has already been set up for this keybind
                if (alreadyKnown.Contains(customKey.actionID))
                {
                    continue;
                }

                // set up the UI for this keybind (same as how game does it)
                alreadyKnown.Add(customKey.actionID);

                var action = ReInput.mapping.GetAction(customKey.actionID);

                var actTemplate = At.GetField(mapSection, "m_actionTemplate") as ControlMappingAction;

                actTemplate.gameObject.SetActive(true);
                if (action.type == InputActionType.Button)
                {
                    At.Invoke(mapSection, "CreateActionRow", CUSTOM_CATEGORY, action, AxisRange.Positive);
                }
                else
                {
                    if (mapSection.ControllerType == ControlMappingPanel.ControlType.Keyboard)
                    {
                        At.Invoke(mapSection, "CreateActionRow", CUSTOM_CATEGORY, action, AxisRange.Positive);
                        At.Invoke(mapSection, "CreateActionRow", CUSTOM_CATEGORY, action, AxisRange.Negative);
                    }
                    else
                    {
                        At.Invoke(mapSection, "CreateActionRow", CUSTOM_CATEGORY, action, AxisRange.Full);
                    }
                }
                actTemplate.gameObject.SetActive(false);

                // Continue the loop of custom keys...
            }
        }
Пример #19
0
        internal static void ApplyRemaps(string bodyName)
        {
            if (!skillBindingOverrides.Exists(x => x.bodyName == bodyName))
            {
                VRMod.StaticLogger.LogInfo(String.Format("No binding overrides found for \'{0}\'. Using default binding.", bodyName));
                RevertRemap();
                return;
            }

            VRMod.StaticLogger.LogInfo(String.Format("Binding overrides were found for \'{0}\'. Applying overrides.", bodyName));
            SkillBindingOverride bindingOverride = skillBindingOverrides.FirstOrDefault(x => x.bodyName == bodyName);

            if (bindingOverride.bodyName == bodyName)
            {
                int[] originalSkillBindingIDs = new int[]
                {
                    (ModConfig.LeftDominantHand.Value ? 9 : 8),
                    (ModConfig.LeftDominantHand.Value ? 8 : 9),
                    (ModConfig.LeftDominantHand.Value ? 11 : 10),
                    (ModConfig.LeftDominantHand.Value ? 10 : 11)
                };

                ActionElementMap[] newMapOrder = new ActionElementMap[]
                {
                    vrGameplayMap.GetElementMapsWithAction(7 + (int)bindingOverride.dominantTrigger)[0],
                    vrGameplayMap.GetElementMapsWithAction(7 + (int)bindingOverride.nonDominantTrigger)[0],
                    vrGameplayMap.GetElementMapsWithAction(7 + (int)bindingOverride.nonDominantGrip)[0],
                    vrGameplayMap.GetElementMapsWithAction(7 + (int)bindingOverride.dominantGrip)[0]
                };

                ControllerMap controllerMap = Utils.localInputPlayer.controllers.maps.GetMap(vrControllers, vrGameplayMap.id);

                for (int i = 0; i < 4; i++)
                {
                    ActionElementMap elementMap = newMapOrder[i];

                    if (elementMap.elementIdentifierId == originalSkillBindingIDs[i])
                    {
                        continue;
                    }

                    if (!controllerMap.ReplaceElementMap(elementMap.id, elementMap.actionId, elementMap.axisContribution, originalSkillBindingIDs[i], elementMap.elementType, elementMap.axisRange, elementMap.invert))
                    {
                        VRMod.StaticLogger.LogError("An error occured while trying to override skill bindings.");
                    }
                }
            }
        }
        private void RedrawUI()
        {
            // Update joystick name in UI
            controllerNameUIText.text = "Keyboard/Mouse";

            // Update each button label with the currently mapped element identifier
            for (int i = 0; i < rows.Count; i++)
            {
                Row         row    = rows[i];
                InputAction action = rows[i].action;

                string name = string.Empty;
                int    actionElementMapId = -1;

                // Find the first ActionElementMap that maps to this Action and is compatible with this field type
                for (int j = 0; j < 2; j++)
                {
                    // Search the Keyboard Map first, then the Mouse Map
                    ControllerType controllerType = j == 0 ? ControllerType.Keyboard : ControllerType.Mouse;
                    ControllerMap  controllerMap  = player.controllers.maps.GetMap(controllerType, 0, category, layout);
                    foreach (var actionElementMap in controllerMap.ElementMapsWithAction(action.id))
                    {
                        if (actionElementMap.ShowInField(row.actionRange))
                        {
                            name = actionElementMap.elementIdentifierName;
                            actionElementMapId = actionElementMap.id;
                            break;
                        }
                    }

                    if (actionElementMapId >= 0)
                    {
                        break;                          // found one
                    }
                }

                // Set the label in the field button
                row.text.text = name;

                // Set the field button callback
                row.button.onClick.RemoveAllListeners(); // clear the button event listeners first
                int index = i;                           // copy variable for closure
                row.button.onClick.AddListener(() => OnInputFieldClicked(index, actionElementMapId));
            }
        }
Пример #21
0
Файл: App.cs Проект: Koneke/Eien
        private void SetupPadSupport()
        {
            ControllerMap.InitialiseStandardMappings();
            Joystick.Update();

            Controllers = new List <Controller>();

            for (uint i = 0; i < Joystick.Count; i++)
            {
                if (Joystick.IsConnected(i))
                {
                    JoystickConnected(null, i);
                }
            }

            Window.JoystickConnected    += JoystickConnected;
            Window.JoystickDisconnected += JoystickDisconnected;
        }
Пример #22
0
        private void OnInputFieldClicked(int index, int actionElementMapToReplaceId, ControllerMap map)
        {
            if (index < 0 || index >= Buttons.Count)
            {
                return;                                      // index out of range
            }
            // Begin listening for input
            InputMapper.Start(
                new InputMapper.Context()
            {
                actionId                  = Buttons[index].InputAction.id,
                controllerMap             = map,
                actionRange               = Buttons[index].AxisRange,
                actionElementMapToReplace = map.GetElementMap(actionElementMapToReplaceId)
            });

            // SHOW A UI TO TELL WE'RE LISTENING
        }
        private void ToggleInverted(ControllerType inputType, bool value)
        {
            ControllerMap map = rewiredPlayer.controllers.maps.GetMap((int)inputType);

            if (map == null)
            {
                return;
            }

            ActionElementMap[] action = map.GetElementMaps();

            foreach (ActionElementMap actionMap in action)
            {
                if (actionMap.actionId == (int)ACTIONS.VerticalLook)
                {
                    actionMap.invert = value;
                }
            }
        }
    // Initialize Input
    private void InitializeInputSettings()
    {
        playerInput = ReInput.players.GetPlayer(0);
        int controllerID = 0;

        // Control Type Joystick
        if (controlType == ControllerType.Joystick)
        {
            controllerID = ControllerStatusManager.iGamepadID;

            // If there are no controllers connected or no controller selected then set all gamepad fields to 'None'
            if (playerInput.controllers.joystickCount == 0 || controllerID == -1)
            {
                bUnassigned = true;
            }
            else
            {
                bUnassigned = false;
            }
        }
        else
        {
            bUnassigned = false;
        }

        if (!bUnassigned)
        {
            controlMap    = playerInput.controllers.maps.GetFirstMapInCategory(controlType, controllerID, 3);
            altControlMap = playerInput.controllers.maps.GetFirstMapInCategory(controlType, controllerID, 4);

            aElementMaps    = controlMap.AllMaps.ToArray();
            aAltElementMaps = altControlMap.AllMaps.ToArray();
        }

        if (aUIInputRows == null)
        {
            InitializeFields();
        }
        else
        {
            UpdateFields();
        }
    }
Пример #25
0
        public void Setup(Rewired.Player player)
        {
            var iterator = player.controllers.maps.GetAllMaps(ControllerType.Keyboard).GetEnumerator();

            iterator.MoveNext();
            ControllerMap map = iterator.Current;

            ActionElementMap[] buttonMaps = new ActionElementMap[map.buttonMapCount];
            map.ButtonMaps.CopyTo(buttonMaps, 0);
            ActionElementMap up     = Array.Find(buttonMaps, x => x.actionId == 0 && x.axisContribution == Pole.Positive);
            ActionElementMap right  = Array.Find(buttonMaps, x => x.actionId == 1 && x.axisContribution == Pole.Positive);
            ActionElementMap down   = Array.Find(buttonMaps, x => x.actionId == 0 && x.axisContribution == Pole.Negative);
            ActionElementMap left   = Array.Find(buttonMaps, x => x.actionId == 1 && x.axisContribution == Pole.Negative);
            ActionElementMap action = Array.Find(buttonMaps, x => x.actionId == 2);

            SetText(up.keyCode, upKey);
            SetText(right.keyCode, rightKey);
            SetText(down.keyCode, downKey);
            SetText(left.keyCode, leftKey);
            SetText(action.keyCode, regroupKey);
        }
        // Event Handlers

        // Called by the input field UI Button when pressed
        private void OnInputFieldClicked(int index, int actionElementMapToReplaceId)
        {
            if (index < 0 || index >= rows.Count)
            {
                return;                                  // index out of range
            }
            ControllerMap keyboardMap = player.controllers.maps.GetMap(ControllerType.Keyboard, 0, category, layout);
            ControllerMap mouseMap    = player.controllers.maps.GetMap(ControllerType.Mouse, 0, category, layout);

            // Cannot replace a keyboard binding on a Mouse Map or vice versa
            // Replacement cross device has to be done by removing the other
            // binding manually after input is mapped.
            // Determine which map the replacement binding exists on and store that information.
            ControllerMap controllerMapWithReplacement;

            // Determine if the replacement is on the keyboard or mouse map
            if (keyboardMap.ContainsElementMap(actionElementMapToReplaceId))
            {
                controllerMapWithReplacement = keyboardMap;
            }
            else if (mouseMap.ContainsElementMap(actionElementMapToReplaceId))
            {
                controllerMapWithReplacement = mouseMap;
            }
            else
            {
                controllerMapWithReplacement = null;  // not a replacement
            }
            // Store the information about the replacement if any
            _replaceTargetMapping = new TargetMapping()
            {
                actionElementMapId = actionElementMapToReplaceId,
                controllerMap      = controllerMapWithReplacement
            };

            // Begin listening for input, but use a coroutine so it starts only after a short delay to prevent
            // the button bound to UI Submit from binding instantly when the input field is activated.
            StartCoroutine(StartListeningDelayed(index, keyboardMap, mouseMap, actionElementMapToReplaceId));
        }
Пример #27
0
 private static void UpdateActionElementRelationships(Dictionary <int[], List <ActionElementMap> > elementSourceActionLinks, Dictionary <int, ActionElementMap> storedElementMaps, InputMapCategory sourceCategory, Player player)
 {
     foreach (KeyValuePair <int[], List <ActionElementMap> > keyValuePair in elementSourceActionLinks)
     {
         if (keyValuePair.Value.SafeCount <ActionElementMap>() != 0)
         {
             int key = keyValuePair.Key[2];
             ActionElementMap oldElementMap      = storedElementMaps[key];
             KeyboardMap      firstMapInCategory = player.controllers.maps.GetFirstMapInCategory <KeyboardMap>(0, sourceCategory.id);
             if (firstMapInCategory == null)
             {
                 Debug.LogError("newControllerMap is null!");
             }
             else
             {
                 ActionElementMap firstElementMapMatch = firstMapInCategory.GetFirstElementMapMatch((ActionElementMap searchMap) => searchMap.actionId == oldElementMap.actionId);
                 if (firstElementMapMatch == null)
                 {
                     Debug.LogError("sourceMap is null!");
                 }
                 else
                 {
                     foreach (ActionElementMap actionElementMap in keyValuePair.Value)
                     {
                         ControllerMap     controllerMap     = actionElementMap.controllerMap;
                         ElementAssignment elementAssignment = new ElementAssignment(ControllerType.Keyboard, firstElementMapMatch.elementType, firstElementMapMatch.elementIdentifierId, firstElementMapMatch.axisRange, firstElementMapMatch.keyCode, firstElementMapMatch.modifierKeyFlags, firstElementMapMatch.actionId, firstElementMapMatch.axisContribution, firstElementMapMatch.invert, actionElementMap.id);
                         bool             flag = controllerMap.DeleteElementMap(actionElementMap.id);
                         ActionElementMap actionElementMap2;
                         if (!flag || !controllerMap.CreateElementMap(elementAssignment, out actionElementMap2))
                         {
                             Debug.Log("Failed to remap secondary actions");
                         }
                     }
                 }
             }
         }
     }
 }
Пример #28
0
        private void DrawLabels(Player player, InputAction action)
        {
            // Lists first Action bound to each Dual Analog Gamepad Template element

            // Get the first Controller that implements the Dual Analog Gamepad Template from the Player
            Controller controller = player.controllers.GetFirstControllerWithTemplate <IGamepadTemplate>();

            if (controller == null)
            {
                return;
            }

            // Get the first gamepad assigned to the Player
            IGamepadTemplate gamepad = controller.GetTemplate <IGamepadTemplate>();

            // Get the Controller Map in the Default category and layout for this Controller from the Player
            ControllerMap controllerMap = player.controllers.maps.GetMap(controller, "Default", "Default");

            if (controllerMap == null)
            {
                return;
            }

            // Go through each Controller Template element displayed in the UI
            for (int i = 0; i < _uiElementsArray.Length; i++)
            {
                ControllerUIElement uiElement = _uiElementsArray[i].element;
                int elementId = _uiElementsArray[i].id;

                // Get the Controller Template Element from the Controller Template
                IControllerTemplateElement element = gamepad.GetElement(elementId);

                // Draw the label
                DrawLabel(uiElement, action, controllerMap, gamepad, element);
            }
        }
Пример #29
0
    /// <summary>
    /// find a mapping for joystickIndex
    /// </summary>
    void MapToControllerType()
    {
        string[] joystickNames = Input.GetJoystickNames();

        if (joystickIndex < 0 || joystickIndex >= joystickNames.Length) { return; }

        // get the controller's name
        string controllerType = joystickNames[joystickIndex].ToUpper();

        // get ControllerMap list based on platform
        List<ControllerMap> mapList;
        if (Application.platform == RuntimePlatform.OSXPlayer ||
            Application.platform == RuntimePlatform.OSXEditor || 
            Application.platform == RuntimePlatform.OSXWebPlayer)
        {
            mapList = controllerMapsMac;
        }
        else
        {
            mapList = controllerMapsPC;
        }

        // find controllerMap for the current controller
        bool foundController;
        foreach (ControllerMap map in mapList)
        {
            foundController = true;

            // look for all tags
            foreach (string s in map.controllerTags)
            {
                if (!controllerType.Contains(s.ToUpper()))
                {
                    foundController = false;
                    break;
                }
            }

            // if the map contains all the tags
            if (foundController)
            {
                // use the map, setup input polling names
                currentMap = map;
                SetInputPollNames();
                return;
            }
        }

        Debug.LogWarning("no controller mapping found for " + this + ", controller type: " + controllerType + "; defaulting to XBOX 360 (PC)");
        currentMap = controllerMapsPC[0];
        SetInputPollNames();
    }
Пример #30
0
 private void DrawMapCategories()
 {
     if (this.selectedPlayer == null)
     {
         return;
     }
     if (!this.selectedController.hasSelection)
     {
         return;
     }
     bool enabled = GUI.enabled;
     GUILayout.Space(15f);
     GUILayout.Label("Categories:", new GUILayoutOption[0]);
     GUILayout.BeginHorizontal(new GUILayoutOption[0]);
     foreach (InputMapCategory current in ReInput.mapping.UserAssignableMapCategories)
     {
         if (!this.selectedPlayer.controllers.maps.ContainsMapInCategory(this.selectedController.type, current.id))
         {
             GUI.enabled = false;
         }
         else if (this.selectedMapCategoryId < 0)
         {
             this.selectedMapCategoryId = current.id;
             this.selectedMap = this.selectedPlayer.controllers.maps.GetFirstMapInCategory(this.selectedController.type, this.selectedController.id, current.id);
         }
         bool flag = current.id == this.selectedMapCategoryId;
         bool flag2 = GUILayout.Toggle(flag, (!(current.descriptiveName != string.Empty)) ? current.name : current.descriptiveName, "Button", new GUILayoutOption[]
         {
             GUILayout.ExpandWidth(false)
         });
         if (flag2 != flag)
         {
             this.selectedMapCategoryId = current.id;
             this.selectedMap = this.selectedPlayer.controllers.maps.GetFirstMapInCategory(this.selectedController.type, this.selectedController.id, current.id);
         }
         if (GUI.enabled != enabled)
         {
             GUI.enabled = enabled;
         }
     }
     GUILayout.EndHorizontal();
     if (GUI.enabled != enabled)
     {
         GUI.enabled = enabled;
     }
 }
        private void AddDefaultMappingsForNewActions(Player player, List <SavedControllerMapData> savedData, ControllerType controllerType, int controllerId)
        {
            if (player == null || savedData == null)
            {
                return;
            }

            // Check for new Actions added to the default mappings that didn't exist when the Controller Map was saved
            List <int> allActionIds = GetAllActionIds();

            for (int i = 0; i < savedData.Count; i++)
            {
                SavedControllerMapData data = savedData[i];
                if (data == null)
                {
                    continue;
                }
                if (data.knownActionIds == null || data.knownActionIds.Count == 0)
                {
                    continue;
                }

                // Create a map from the Xml so we can get information
                ControllerMap mapFromXml = ControllerMap.CreateFromXml(controllerType, savedData[i].xml);
                if (mapFromXml == null)
                {
                    continue;
                }

                // Load the map that was added to the Player
                ControllerMap mapInPlayer = player.controllers.maps.GetMap(controllerType, controllerId, mapFromXml.categoryId, mapFromXml.layoutId);
                if (mapInPlayer == null)
                {
                    continue;
                }

                // Load default map for comparison
                ControllerMap defaultMap = ReInput.mapping.GetControllerMapInstance(ReInput.controllers.GetController(controllerType, controllerId), mapFromXml.categoryId, mapFromXml.layoutId);
                if (defaultMap == null)
                {
                    continue;
                }

                // Find any new Action ids that didn't exist when the Controller Map was saved
                List <int> unknownActionIds = new List <int>();
                foreach (int id in allActionIds)
                {
                    if (data.knownActionIds.Contains(id))
                    {
                        continue;
                    }
                    unknownActionIds.Add(id);
                }

                if (unknownActionIds.Count == 0)
                {
                    continue;                             // no new Action ids
                }
                // Add all mappings in the default map for previously unknown Action ids
                foreach (ActionElementMap aem in defaultMap.AllMaps)
                {
                    if (!unknownActionIds.Contains(aem.actionId))
                    {
                        continue;
                    }

                    // Skip this ActionElementMap if there's a conflict within the loaded map
                    if (mapInPlayer.DoesElementAssignmentConflict(aem))
                    {
                        continue;
                    }

                    // Create an assignment
                    ElementAssignment assignment = new ElementAssignment(
                        controllerType,
                        aem.elementType,
                        aem.elementIdentifierId,
                        aem.axisRange,
                        aem.keyCode,
                        aem.modifierKeyFlags,
                        aem.actionId,
                        aem.axisContribution,
                        aem.invert
                        );

                    // Assign it
                    mapInPlayer.CreateElementMap(assignment);
                }
            }
        }
Пример #32
0
        private void DrawLabel(ControllerUIElement uiElement, InputAction action, ControllerMap controllerMap,
                               IControllerTemplate template, IControllerTemplateElement element)
        {
            if (element.source == null)
            {
                return;                         // this element cannot map to a source
            }
            ActionElementMap aem;

            // A Controller Template Element Source contains Targets that each point to
            // a Controller.Element or part of a Controller.Element (such as one pole of an Axis).

            // Handle Axis-type Template Element
            if (element.source.type == ControllerTemplateElementSourceType.Axis)
            {
                // Cast the source to an Axis source so we can access the 3 possible Targets
                IControllerTemplateAxisSource source = (element.source as IControllerTemplateAxisSource);

                // A Template axis source can be either a full-axis binding or a split-axis binding

                // Handle split-axis source
                if (source.splitAxis)
                {
                    // A split-axis source has a Positive Target and a Negative Target, one for each side of the axis.

                    // Positive Target
                    aem = controllerMap.GetFirstElementMapWithElementTarget(source.positiveTarget, action.id, true);
                    if (aem != null)
                    {
                        uiElement.SetLabel(aem.actionDescriptiveName, AxisRange.Positive);
                    }

                    // Negative Target
                    aem = controllerMap.GetFirstElementMapWithElementTarget(source.negativeTarget, action.id, true);
                    if (aem != null)
                    {
                        uiElement.SetLabel(aem.actionDescriptiveName, AxisRange.Negative);
                    }

                    // Handle full-axis source
                }
                else
                {
                    // A full-axis sources has just a single full target.

                    // Full Target
                    aem = controllerMap.GetFirstElementMapWithElementTarget(source.fullTarget, action.id, true);
                    if (aem != null)
                    {
                        // a full target was mapped

                        uiElement.SetLabel(aem.actionDescriptiveName, AxisRange.Full);
                    }
                    else
                    {
                        // no full mapping was found, look for separate positive/negative mappings

                        // Positive side
                        aem = controllerMap.GetFirstElementMapWithElementTarget(
                            new ControllerElementTarget(source.fullTarget)
                        {
                            axisRange = AxisRange.Positive
                        },
                            action.id,
                            true
                            );
                        if (aem != null)
                        {
                            uiElement.SetLabel(aem.actionDescriptiveName, AxisRange.Positive);
                        }

                        // Negative side
                        aem = controllerMap.GetFirstElementMapWithElementTarget(
                            new ControllerElementTarget(source.fullTarget)
                        {
                            axisRange = AxisRange.Negative
                        },
                            action.id,
                            true
                            );
                        if (aem != null)
                        {
                            uiElement.SetLabel(aem.actionDescriptiveName, AxisRange.Negative);
                        }
                    }
                }

                // Handle Button-type Template Element
            }
            else if (element.source.type == ControllerTemplateElementSourceType.Button)
            {
                // Cast the source to an button source
                IControllerTemplateButtonSource source = (element.source as IControllerTemplateButtonSource);

                // Target
                aem = controllerMap.GetFirstElementMapWithElementTarget(source.target, action.id, true);
                if (aem != null)
                {
                    uiElement.SetLabel(aem.actionDescriptiveName, AxisRange.Full);
                }
            }
        }
Пример #33
0
 private void ClearMapSelection()
 {
     this.selectedMapCategoryId = -1;
     this.selectedMap = null;
 }
Пример #34
0
 private void DrawAddActionMapButton(int playerId, InputAction action, Pole actionAxisContribution, ControllerSelection controller, ControllerMap controllerMap,
     bool assignFullAxis) {
     if(GUILayout.Button("Add...", GUILayout.ExpandWidth(false))) {
         EnqueueAction(new ElementAssignmentChange(playerId, controller.id, controller.type, controllerMap,
             ElementAssignmentChangeType.Add, -1, action.id, actionAxisContribution, action.type, assignFullAxis, false));
     }
     GUILayout.Space(10);
 }
Пример #35
0
        private void DrawActionAssignmentButton(int playerId, InputAction action, Pole actionAxisContribution, ControllerSelection controller, ControllerMap controllerMap,
            bool assignFullAxis, ActionElementMap elementMap) {

            if(GUILayout.Button(elementMap.elementIdentifierName, GUILayout.ExpandWidth(false), GUILayout.MinWidth(30.0f))) {
                EnqueueAction(new ElementAssignmentChange(playerId, controller.id, controller.type, controllerMap,
                    ElementAssignmentChangeType.ReassignOrRemove, elementMap.id, action.id, actionAxisContribution, action.type, assignFullAxis, elementMap.invert));
            }
            GUILayout.Space(4);
        }
Пример #36
0
 private void DrawInvertButton(int playerId, InputAction action, Pole actionAxisContribution, ControllerSelection controller, ControllerMap controllerMap, ActionElementMap elementMap) {
     bool value = elementMap.invert;
     bool newValue = GUILayout.Toggle(value, "Invert", GUILayout.ExpandWidth(false));
     if(newValue != value) {
         elementMap.invert = newValue;
     }
     GUILayout.Space(10);
 }
Пример #37
0
        private void DrawMapCategories() {
            if(selectedPlayer == null) return;
            if(!selectedController.hasSelection) return;
            bool origGuiEnabled = GUI.enabled; // save GUI state

            GUILayout.Space(15);
            GUILayout.Label("Categories:");
            GUILayout.BeginHorizontal();

            foreach(InputMapCategory category in ReInput.mapping.UserAssignableMapCategories) {
                if(!selectedPlayer.controllers.maps.ContainsMapInCategory(selectedController.type, category.id)) { // if player has no maps in this category for controller don't allow them to select it
                    GUI.enabled = false;
                } else {
                    // Select first available category if none selected
                    if(selectedMapCategoryId < 0) {
                        selectedMapCategoryId = category.id; // if no category selected, select first
                        selectedMap = selectedPlayer.controllers.maps.GetFirstMapInCategory(selectedController.type, selectedController.id, category.id);
                    }
                }

                bool prevValue = category.id == selectedMapCategoryId ? true : false;
                bool value = GUILayout.Toggle(prevValue, category.descriptiveName != string.Empty ? category.descriptiveName : category.name, "Button", GUILayout.ExpandWidth(false));
                if(value != prevValue) { // category changed
                    selectedMapCategoryId = category.id;
                    selectedMap = selectedPlayer.controllers.maps.GetFirstMapInCategory(selectedController.type, selectedController.id, category.id);
                }
                if(GUI.enabled != origGuiEnabled) GUI.enabled = origGuiEnabled;
            }

            GUILayout.EndHorizontal();
            if(GUI.enabled != origGuiEnabled) GUI.enabled = origGuiEnabled; // restore GUI state
        }
Пример #38
0
 public ElementAssignmentChange(
     int playerId,
     int controllerId,
     ControllerType controllerType,
     ControllerMap controllerMap,
     ElementAssignmentChangeType changeType,
     int actionElementMapId,
     int actionId,
     Pole actionAxisContribution,
     InputActionType actionType,
     bool assignFullAxis,
     bool invert
 ) : base(QueueActionType.ElementAssignment) {
     this.playerId = playerId;
     this.controllerId = controllerId;
     this.controllerType = controllerType;
     this.controllerMap = controllerMap;
     this.changeType = changeType;
     this.actionElementMapId = actionElementMapId;
     this.actionId = actionId;
     this.actionAxisContribution = actionAxisContribution;
     this.actionType = actionType;
     this.assignFullAxis = assignFullAxis;
     this.invert = invert;
 }
Пример #39
0
 private void DrawInvertButton(int playerId, InputAction action, Pole actionAxisContribution, ControlRemappingDemo1.ControllerSelection controller, ControllerMap controllerMap, ActionElementMap elementMap)
 {
     bool invert = elementMap.invert;
     bool flag = GUILayout.Toggle(invert, "Invert", new GUILayoutOption[]
     {
         GUILayout.ExpandWidth(false)
     });
     if (flag != invert)
     {
         elementMap.invert = flag;
     }
     GUILayout.Space(10f);
 }
Пример #40
0
    /// <summary>
    /// reads in universal controller mappings from a file located in Resources/txt/
    /// </summary>
    /// <param name="fileName"> the file to be read </param>
    void ReadMapFile(string fileName)
    {
        string totalMappings = (Resources.Load("txt/" + fileName) as TextAsset).text;
        //Debug.Log(totalMappings);

        // intro, pc, and mac split: 0 - intro,  1 - PC, 2 - mac
        string[] firstSplit = totalMappings.Split(new string[] { "$$$" + Environment.NewLine }, StringSplitOptions.None);

        // pc list
        string[] pcSplit = firstSplit[1].Split(new string[] { "***" + Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

        for (int i = 0; i < pcSplit.Length; i++)
        {
            ControllerMap newMapping = new ControllerMap();

            // the lines that make up the mapping info
            string[] lines = pcSplit[i].Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

            // fill tags with first element
            newMapping.controllerTags = lines[0].Split(' ');

            // fill map with mappings
            newMapping.map = new string[lines.Length - 1];
            for (int j = 0; j < newMapping.map.Length; j++)
            {
                newMapping.map[j] = lines[j + 1];
            }

            controllerMapsPC.Add(newMapping);
        }

        // mac list
        string[] macSplit = firstSplit[2].Split(new string[] { "***" + Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
        for (int i = 0; i < macSplit.Length; i++)
        {
            ControllerMap newMapping = new ControllerMap();

            // the lines that make up the mapping info
            string[] lines = macSplit[i].Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

            // fill tags with first element
            newMapping.controllerTags = lines[0].Split(' ');

            // fill map with mappings
            newMapping.map = new string[lines.Length - 1];
            for (int j = 0; j < newMapping.map.Length; j++)
            {
                newMapping.map[j] = lines[j + 1];
            }

            controllerMapsMac.Add(newMapping);
        }
    }
Пример #41
0
 private void AddActionAssignmentButton(InputActionRow uiRow, int playerId, InputAction action, Pole actionAxisContribution, ControllerMap controllerMap, bool assignFullAxis, ActionElementMap elementMap, bool showInvert = false)
 {
     InputActionButton uiButton;
     if (!showInvert)
     {
         uiButton = UnityEngine.Object.Instantiate<InputActionButton>(this._inputActionButtonPrefab);
     }
     else
     {
         uiButton = UnityEngine.Object.Instantiate<InputActionButton>(this._inputAxisActionButtonPrefab);
     }
     uiButton._label.text = elementMap.elementIdentifierName;
     uiButton._actionElementMap = elementMap;
     uiButton._button.onClick.Add(new EventDelegate(delegate
     {
         if (!this.enabled && this._nextChangeTimer < Time.realtimeSinceStartup)
         {
             if (UICamera.currentTouchID == -1)
             {
                 this._replaceElementMap = true;
                 this._entry = new InputMappingAction.ElementAssignmentChange(playerId, InputMappingAction.ElementAssignmentChangeType.ReassignOrRemove, elementMap.id, action.id, actionAxisContribution, action.type, assignFullAxis, elementMap.invert);
                 this._entry.controllerMap = controllerMap;
                 this._entry.uiButton = uiButton;
                 this.StartPollInput();
             }
             else if (UICamera.currentTouchID == -2)
             {
                 this._entry = new InputMappingAction.ElementAssignmentChange(playerId, InputMappingAction.ElementAssignmentChangeType.Remove, elementMap.id, action.id, actionAxisContribution, action.type, assignFullAxis, elementMap.invert);
                 controllerMap.DeleteElementMap(this._entry.actionElementMapId);
                 this._knownActionMaps.Remove(elementMap);
                 UnityEngine.Object.Destroy(uiButton.gameObject);
                 uiRow._actionGrid.repositionNow = true;
                 Dictionary<InputActionRow, int> actionRowMappingCount2;
                 Dictionary<InputActionRow, int> expr_181 = actionRowMappingCount2 = this._actionRowMappingCount;
                 InputActionRow uiRow3;
                 InputActionRow expr_189 = uiRow3 = uiRow;
                 int num2 = actionRowMappingCount2[uiRow3];
                 expr_181[expr_189] = num2 - 1;
                 this.CheckActionMappingCount(uiRow);
                 this._nextChangeTimer = Time.realtimeSinceStartup + this._interChangeDelay;
             }
         }
     }));
     if (showInvert)
     {
         uiButton._invertAxisToggle.gameObject.SetActive(true);
         uiButton._invertAxisToggle.value = uiButton._actionElementMap.invert;
         uiButton._invertAxisToggle.onChange.Add(new EventDelegate(delegate
         {
             if (!this.enabled && this._nextChangeTimer < Time.realtimeSinceStartup)
             {
                 uiButton._actionElementMap.invert = uiButton._invertAxisToggle.value;
             }
         }));
     }
     uiButton.transform.parent = uiRow._actionGrid.transform;
     uiButton.transform.localPosition = Vector3.zero;
     uiButton.transform.localScale = Vector3.one;
     this._knownActionMaps.Add(elementMap, uiButton);
     Dictionary<InputActionRow, int> actionRowMappingCount;
     Dictionary<InputActionRow, int> expr_18C = actionRowMappingCount = this._actionRowMappingCount;
     InputActionRow uiRow2;
     InputActionRow expr_194 = uiRow2 = uiRow;
     int num = actionRowMappingCount[uiRow2];
     expr_18C[expr_194] = num + 1;
 }
Пример #42
0
 private void ClearMapSelection() {
     selectedMapCategoryId = -1; // clear map cat selection
     selectedMap = null;
 }
Пример #43
0
 private void DrawAddActionMapButton(int playerId, InputAction action, Pole actionAxisContribution, ControlRemappingDemo1.ControllerSelection controller, ControllerMap controllerMap, bool assignFullAxis)
 {
     if (GUILayout.Button("Add...", new GUILayoutOption[]
     {
         GUILayout.ExpandWidth(false)
     }))
     {
         this.EnqueueAction(new ControlRemappingDemo1.ElementAssignmentChange(playerId, controller.id, controller.type, controllerMap, ControlRemappingDemo1.ElementAssignmentChangeType.Add, -1, action.id, actionAxisContribution, action.type, assignFullAxis, false));
     }
     GUILayout.Space(10f);
 }