Example #1
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.");
                }
            }
        }
Example #2
0
        internal static void ChangeDominanceDependantMaps()
        {
            Player player = Utils.localInputPlayer;

            for (int i = 7; i < 11; i++)
            {
                ActionElementMap map  = vrGameplayMap.GetElementMapsWithAction(i)[0];
                int elementIdentifier = map.elementIdentifierId;

                if (elementIdentifier == 8)
                {
                    elementIdentifier = 9;
                }
                else if (elementIdentifier == 9)
                {
                    elementIdentifier = 8;
                }
                else if (elementIdentifier == 10)
                {
                    elementIdentifier = 11;
                }
                else if (elementIdentifier == 11)
                {
                    elementIdentifier = 10;
                }

                bool result = player.controllers.maps.GetMap(vrControllers, vrGameplayMap.id).ReplaceElementMap(map.id, map.actionId, map.axisContribution, elementIdentifier, map.elementType, map.axisRange, map.invert);

                if (!result)
                {
                    VRMod.StaticLogger.LogError("Failed to remap");
                    return;
                }
            }
        }
Example #3
0
        public void setKey()
        {
            string tempTest = "test";

            //tempTest = ReInput.players.GetPlayer(0).controllers.maps.GetFirstButtonMapWithAction(inputKey, true).elementIdentifierName;

            Player player = ReInput.players.GetPlayer(0);


            if (NegativeButton)
            {
                ActionElementMap aem = player.controllers.maps.GetFirstButtonMapWithAction(ControllerType.Keyboard, inputKey, true);

                tempTest = aem.keyCode.ToString();
            }

            else
            {
                foreach (ActionElementMap aem in player.controllers.maps.ButtonMapsWithAction(ControllerType.Keyboard, inputKey, true))
                {
                    Debug.Log("This foreach for " + inputKey);
                    Debug.Log("And this is the code this time " + aem.keyCode.ToString());
                    tempTest = aem.keyCode.ToString();
                }
            }



            ObjectText = setTextParameters(tempTest);
        }
Example #4
0
        private bool IsMenuAxis(int actionId, int axisIndex)
        {
            if (Object.op_Equality((Object)this.rewiredStandaloneInputModule, (Object)null))
            {
                return(false);
            }
            IList <Player> allPlayers = ReInput.get_players().get_AllPlayers();
            int            count1     = ((ICollection <Player>)allPlayers).Count;

            for (int index1 = 0; index1 < count1; ++index1)
            {
                IList <JoystickMap> maps = (IList <JoystickMap>)((Player.ControllerHelper.MapHelper)((Player.ControllerHelper)allPlayers[index1].controllers).maps).GetMaps <JoystickMap>((int)((Controller)this.joystick).id);
                if (maps != null)
                {
                    int count2 = ((ICollection <JoystickMap>)maps).Count;
                    for (int index2 = 0; index2 < count2; ++index2)
                    {
                        IList <ActionElementMap> axisMaps = ((ControllerMapWithAxes)maps[index2]).get_AxisMaps();
                        if (axisMaps != null)
                        {
                            int count3 = ((ICollection <ActionElementMap>)axisMaps).Count;
                            for (int index3 = 0; index3 < count3; ++index3)
                            {
                                ActionElementMap actionElementMap = axisMaps[index3];
                                if (actionElementMap.get_actionId() == actionId && actionElementMap.get_elementIndex() == axisIndex)
                                {
                                    return(true);
                                }
                            }
                        }
                    }
                }
            }
            return(false);
        }
Example #5
0
        private static CustomControllerMap CreateCustomMap(string mapName, int categoryId, int controllerId, List <ActionElementMap> actionElementMaps)
        {
            ReInput.UserData.CreateCustomControllerMap(categoryId, controllerId, 0);

            ControllerMap_Editor newMap = ReInput.UserData.customControllerMaps.Last();

            newMap.name = mapName;

            foreach (ActionElementMap elementMap in actionElementMaps)
            {
                newMap.AddActionElementMap();
                ActionElementMap newElementMap = newMap.GetActionElementMap(newMap.ActionElementMaps.Count() - 1);
                newElementMap.actionId            = elementMap.actionId;
                newElementMap.elementType         = elementMap.elementType;
                newElementMap.elementIdentifierId = elementMap.elementIdentifierId;
                newElementMap.axisContribution    = elementMap.axisContribution;
                if (elementMap.elementType == ControllerElementType.Axis)
                {
                    newElementMap.axisRange = elementMap.axisRange;
                }
                newElementMap.invert = elementMap.invert;
            }

            return(ReInput.UserData.aHYIuJhXpYLorVzIjNgjtAekfzf(categoryId, controllerId, 0));
        }
Example #6
0
        private bool IsMenuAxis(int actionId, int axisIndex)
        {
            if (this.rewiredStandaloneInputModule == null)
            {
                return(false);
            }
            IList <Player> allPlayers = ReInput.players.AllPlayers;
            int            count      = allPlayers.Count;

            for (int i = 0; i < count; i++)
            {
                IList <JoystickMap> maps = allPlayers[i].controllers.maps.GetMaps <JoystickMap>(this.joystick.id);
                if (maps != null)
                {
                    int count2 = maps.Count;
                    for (int j = 0; j < count2; j++)
                    {
                        IList <ActionElementMap> axisMaps = maps[j].AxisMaps;
                        if (axisMaps != null)
                        {
                            int count3 = axisMaps.Count;
                            for (int k = 0; k < count3; k++)
                            {
                                ActionElementMap actionElementMap = axisMaps[k];
                                if (actionElementMap.actionId == actionId && actionElementMap.elementIndex == axisIndex)
                                {
                                    return(true);
                                }
                            }
                        }
                    }
                }
            }
            return(false);
        }
Example #7
0
 public void RefreshLabel()
 {
     _mapped = PlayerInput.RewiredPlayer.controllers.maps.GetFirstButtonMapWithAction(_inputAction.name, true);
     if (_mapped != null)
     {
         _text.text = _mapped.elementIdentifierName;
     }
     else
     {
         _text.text = "Click to bind";
     }
 }
Example #8
0
 public override string GetElementIdentifierName(ActionElementMap actionElementMap)
 {
     if (actionElementMap == null)
     {
         throw new ArgumentNullException("actionElementMap");
     }
     if (actionElementMap.controllerMap.controllerType == ControllerType.Keyboard)
     {
         return(GetElementIdentifierName(actionElementMap.keyCode, actionElementMap.modifierKeyFlags));
     }
     return(GetElementIdentifierName(actionElementMap.controllerMap.controller, actionElementMap.elementIdentifierId, actionElementMap.axisRange));
 }
Example #9
0
 private void Confirm(InputMappingAction.ConflictResolution conflictResolution)
 {
     if (conflictResolution > InputMappingAction.ConflictResolution.Pending)
     {
         if (conflictResolution == InputMappingAction.ConflictResolution.Replace)
         {
             using (IEnumerator <ElementAssignmentConflictInfo> enumerator = ReInput.controllers.conflictChecking.ElementAssignmentConflicts(this._entry.ToElementAssignmentConflictCheck()).GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     ElementAssignmentConflictInfo info = enumerator.Current;
                     if (this._knownActionMaps.Any((KeyValuePair <ActionElementMap, InputActionButton> m) => m.Key.id == info.elementMapId))
                     {
                         ActionElementMap elementMap = this._knownActionMaps.First((KeyValuePair <ActionElementMap, InputActionButton> m) => m.Key.id == info.elementMapId).Key;
                         UnityEngine.Object.Destroy(this._knownActionMaps[elementMap].gameObject);
                         this._knownActionMaps.Remove(elementMap);
                         InputActionRow key = this._actionRowMappingCount.First((KeyValuePair <InputActionRow, int> r) => r.Key._action.id == elementMap.actionId).Key;
                         Dictionary <InputActionRow, int> actionRowMappingCount;
                         InputActionRow key2;
                         (actionRowMappingCount = this._actionRowMappingCount)[key2 = key] = actionRowMappingCount[key2] - 1;
                     }
                 }
             }
             ReInput.controllers.conflictChecking.RemoveElementAssignmentConflicts(this._entry.ToElementAssignmentConflictCheck());
         }
         if (this._entry.changeType != InputMappingAction.ElementAssignmentChangeType.Add)
         {
             this._entry.controllerMapPrevious.DeleteElementMap(this._entry.actionElementMapId);
             this._entry.controllerMapPrevious = null;
             this._knownActionMaps.Remove(this._entry.uiButton._actionElementMap);
             UnityEngine.Object.Destroy(this._entry.uiButton.gameObject);
             if (this._entry.uiRow)
             {
                 Dictionary <InputActionRow, int> actionRowMappingCount;
                 InputActionRow uiRow;
                 (actionRowMappingCount = this._actionRowMappingCount)[uiRow = this._entry.uiRow] = actionRowMappingCount[uiRow] - 1;
             }
             this._entry.changeType = InputMappingAction.ElementAssignmentChangeType.Add;
         }
         this._entry.ReplaceOrCreateActionElementMap(false);
         if (this._entry.changeType == InputMappingAction.ElementAssignmentChangeType.Add)
         {
             ActionElementMap actionElementMap = this._entry.controllerMap.AllMaps.First((ActionElementMap m) => m.actionId == this._entry.actionId && !this._knownActionMaps.ContainsKey(m));
             bool             showInvert       = this._entry.actionType == InputActionType.Axis && actionElementMap.axisType == AxisType.Normal && this._entry.controllerType != ControllerType.Keyboard;
             this.AddActionAssignmentButton(this._entry.uiRow, Input.player.id, ReInput.mapping.GetAction(this._entry.actionId), actionElementMap.axisContribution, this._entry.controllerMap, false, actionElementMap, showInvert);
             this.HideAddActionMapButton(this._entry.uiRow, this._entry.controllerType);
         }
         this._nextChangeTimer = Time.realtimeSinceStartup + this._interChangeDelay;
         this.InitializeUI(false);
         this.StopPollInput();
     }
 }
Example #10
0
 public void RenderKey(int playerId, InputAction inputAction, AxisRange axisRange, ControllerType controllerType, ControllerMap map, ActionElementMap ele)
 {
     this.controllerType = controllerType;
     context             = new InputMapper.Context()
     {
         actionId                  = inputAction.id,
         actionRange               = axisRange,
         controllerMap             = map,
         actionElementMapToReplace = ele
     };
     this.map   = map;
     elementMap = ele;
     RenderKey();
 }
Example #11
0
    private void ControllerMappingToSetting(ControllerType _controllerType)
    {
        List <ControllerSetting> controllerSettingList = new List <ControllerSetting>();

        switch ((int)_controllerType)
        {
        case 0:
        case 1:
            this.DeleteControllerSetting(_controllerType, (string)null);
            ControllerSetting controllerSetting1 = new ControllerSetting(_controllerType, 0);
            if (_controllerType == null)
            {
                controllerSettingList.Add(controllerSetting1);
                break;
            }
            break;

        case 2:
            for (int index = 0; index < this.joystickCount; ++index)
            {
                ControllerSetting controllerSetting2 = new ControllerSetting(_controllerType, (int)((Controller)this.joysticks[index]).id);
                this.DeleteControllerSetting(_controllerType, controllerSetting2.controllerName);
                controllerSettingList.Add(controllerSetting2);
            }
            break;
        }
        foreach (ControllerSetting controllerSetting2 in controllerSettingList)
        {
            if (controllerSetting2.maps != null)
            {
                this.controllerList.Add(controllerSetting2);
                using (IEnumerator <ControllerMap> enumerator1 = ((IEnumerable <ControllerMap>)controllerSetting2.maps).GetEnumerator())
                {
                    while (((IEnumerator)enumerator1).MoveNext())
                    {
                        using (IEnumerator <ActionElementMap> enumerator2 = ((IEnumerable <ActionElementMap>)enumerator1.Current.get_AllMaps()).GetEnumerator())
                        {
                            while (((IEnumerator)enumerator2).MoveNext())
                            {
                                ActionElementMap current = enumerator2.Current;
                                controllerSetting2.AddElement(new InputSetting(current));
                            }
                        }
                    }
                }
            }
        }
        controllerSettingList.Clear();
    }
Example #12
0
 public InputSetting(ActionElementMap _actionElementMap)
 {
     this.categoryId          = _actionElementMap.get_controllerMap().get_categoryId();
     this.layoutId            = _actionElementMap.get_controllerMap().get_layoutId();
     this.controllerType      = _actionElementMap.get_controllerMap().get_controllerType();
     this.elementType         = _actionElementMap.get_elementType();
     this.elementIdentifierId = _actionElementMap.get_elementIdentifierId();
     this.axisRange           = _actionElementMap.get_axisRange();
     this.keyboardKey         = _actionElementMap.get_keyCode();
     this.modifierKeyFlags    = _actionElementMap.get_modifierKeyFlags();
     this.actionId            = _actionElementMap.get_actionId();
     this.axisContribution    = _actionElementMap.get_axisContribution();
     this.invert       = _actionElementMap.get_invert();
     this.elementMapId = _actionElementMap.get_id();
 }
Example #13
0
    private ElementAssignment ToElementAssignment(
        ControllerPollingInfo _pollingInfo,
        ModifierKeyFlags _modifierKeyFlag,
        AxisRange _axisRange,
        int _actionId,
        ActionElementMap _actionElementMap)
    {
        AxisRange axisRange = (AxisRange)1;

        if (((ControllerPollingInfo) ref _pollingInfo).get_elementType() == null)
        {
            axisRange = _axisRange != null ? (((ControllerPollingInfo) ref _pollingInfo).get_axisPole() != null ? (AxisRange)2 : (AxisRange)1) : (AxisRange)0;
        }
        return(new ElementAssignment(((ControllerPollingInfo) ref _pollingInfo).get_controllerType(), ((ControllerPollingInfo) ref _pollingInfo).get_elementType(), ((ControllerPollingInfo) ref _pollingInfo).get_elementIdentifierId(), axisRange, ((ControllerPollingInfo) ref _pollingInfo).get_keyboardKey(), _modifierKeyFlag, _actionId, _axisRange != 2 ? (Pole)0 : (Pole)1, false, _actionElementMap == null ? -1 : _actionElementMap.get_id()));
    }
Example #14
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.");
                    }
                }
            }
        }
Example #15
0
 private static bool TryDeleteElementMap(ActionElementMap actionElementMap)
 {
     try
     {
         if (!actionElementMap.controllerMap.DeleteElementMap(actionElementMap.id))
         {
             throw new InvalidOperationException("Rewire reported failure");
         }
         return(true);
     }
     catch (Exception ex)
     {
         Debug.Log(string.Format("Delete Element Map failed! {0}", ex.Message));
     }
     return(false);
 }
Example #16
0
 private void Confirm(InputMappingAction.ConflictResolution conflictResolution)
 {
     if (conflictResolution > InputMappingAction.ConflictResolution.Pending)
     {
         if (conflictResolution == InputMappingAction.ConflictResolution.Replace)
         {
             foreach (ElementAssignmentConflictInfo info in ReInput.controllers.conflictChecking.ElementAssignmentConflicts(this._entry.ToElementAssignmentConflictCheck()))
             {
                 if (this._knownActionMaps.Any((KeyValuePair <ActionElementMap, InputActionButton> m) => m.Key.id == info.elementMapId))
                 {
                     ActionElementMap elementMap = this._knownActionMaps.First((KeyValuePair <ActionElementMap, InputActionButton> m) => m.Key.id == info.elementMapId).Key;
                     UnityEngine.Object.Destroy(this._knownActionMaps[elementMap].gameObject);
                     this._knownActionMaps.Remove(elementMap);
                     InputActionRow key = this._actionRowMappingCount.First((KeyValuePair <InputActionRow, int> r) => r.Key._action.id == elementMap.actionId).Key;
                     Dictionary <InputActionRow, int> actionRowMappingCount;
                     Dictionary <InputActionRow, int> expr_F3 = actionRowMappingCount = this._actionRowMappingCount;
                     InputActionRow key2;
                     InputActionRow expr_F7 = key2 = key;
                     int            num     = actionRowMappingCount[key2];
                     expr_F3[expr_F7] = num - 1;
                     key._actionGrid.repositionNow = true;
                     this.CheckActionMappingCount(key);
                 }
             }
             ReInput.controllers.conflictChecking.RemoveElementAssignmentConflicts(this._entry.ToElementAssignmentConflictCheck());
         }
         this._entry.ReplaceOrCreateActionElementMap(this._replaceElementMap);
         if (this._entry.changeType == InputMappingAction.ElementAssignmentChangeType.Add)
         {
             ActionElementMap actionElementMap = this._entry.controllerMap.AllMaps.First((ActionElementMap m) => m.actionId == this._entry.actionId && !this._knownActionMaps.ContainsKey(m));
             bool             showInvert       = this._entry.actionType == InputActionType.Axis && actionElementMap.axisType == AxisType.Normal && this._entry.controllerType != ControllerType.Keyboard;
             this.AddActionAssignmentButton(this._entry.uiRow, Input.player.id, ReInput.mapping.GetAction(this._entry.actionId), actionElementMap.axisContribution, this._entry.controllerMap, false, actionElementMap, showInvert);
             this._entry.uiRow._actionGrid.repositionNow = true;
             this.CheckActionMappingCount(this._entry.uiRow);
         }
         else
         {
             this._entry.uiButton._label.text = this._entry.pollingInfo.elementIdentifierName;
         }
         this._selectionScreenTimer.gameObject.SetActive(false);
         this._mappingConflictResolutionKeyLabel.transform.parent.gameObject.SetActive(false);
         this._mappingSystemConflictUI.transform.parent.gameObject.SetActive(false);
         this._nextChangeTimer = Time.realtimeSinceStartup + this._interChangeDelay;
         this.ResetUI();
         this.StopPollInput();
     }
 }
Example #17
0
        private void OnGUI()
        {
            if (this.textStyle == null)
            {
                this.textStyle = new GUIStyle(GUI.get_skin().get_label());
                this.textStyle.set_fontSize(20);
                this.textStyle.set_wordWrap(true);
            }
            if (this.GetFirstDS4(this.player) == null)
            {
                return;
            }
            GUILayout.BeginArea(new Rect(200f, 100f, (float)Screen.get_width() - 400f, (float)Screen.get_height() - 200f));
            GUILayout.Label("Rotate the Dual Shock 4 to see the model rotate in sync.", this.textStyle, (GUILayoutOption[])Array.Empty <GUILayoutOption>());
            GUILayout.Label("Touch the touchpad to see them appear on the model.", this.textStyle, (GUILayoutOption[])Array.Empty <GUILayoutOption>());
            ActionElementMap elementMapWithAction1 = ((Player.ControllerHelper.MapHelper)((Player.ControllerHelper) this.player.controllers).maps).GetFirstElementMapWithAction((ControllerType)2, "ResetOrientation", true);

            if (elementMapWithAction1 != null)
            {
                GUILayout.Label("Press " + elementMapWithAction1.get_elementIdentifierName() + " to reset the orientation. Hold the gamepad facing the screen with sticks pointing up and press the button.", this.textStyle, (GUILayoutOption[])Array.Empty <GUILayoutOption>());
            }
            ActionElementMap elementMapWithAction2 = ((Player.ControllerHelper.MapHelper)((Player.ControllerHelper) this.player.controllers).maps).GetFirstElementMapWithAction((ControllerType)2, "CycleLight", true);

            if (elementMapWithAction2 != null)
            {
                GUILayout.Label("Press " + elementMapWithAction2.get_elementIdentifierName() + " to change the light color.", this.textStyle, (GUILayoutOption[])Array.Empty <GUILayoutOption>());
            }
            ActionElementMap elementMapWithAction3 = ((Player.ControllerHelper.MapHelper)((Player.ControllerHelper) this.player.controllers).maps).GetFirstElementMapWithAction((ControllerType)2, "ToggleLightFlash", true);

            if (elementMapWithAction3 != null)
            {
                GUILayout.Label("Press " + elementMapWithAction3.get_elementIdentifierName() + " to start or stop the light flashing.", this.textStyle, (GUILayoutOption[])Array.Empty <GUILayoutOption>());
            }
            ActionElementMap elementMapWithAction4 = ((Player.ControllerHelper.MapHelper)((Player.ControllerHelper) this.player.controllers).maps).GetFirstElementMapWithAction((ControllerType)2, "VibrateLeft", true);

            if (elementMapWithAction4 != null)
            {
                GUILayout.Label("Press " + elementMapWithAction4.get_elementIdentifierName() + " vibrate the left motor.", this.textStyle, (GUILayoutOption[])Array.Empty <GUILayoutOption>());
            }
            ActionElementMap elementMapWithAction5 = ((Player.ControllerHelper.MapHelper)((Player.ControllerHelper) this.player.controllers).maps).GetFirstElementMapWithAction((ControllerType)2, "VibrateRight", true);

            if (elementMapWithAction5 != null)
            {
                GUILayout.Label("Press " + elementMapWithAction5.get_elementIdentifierName() + " vibrate the right motor.", this.textStyle, (GUILayoutOption[])Array.Empty <GUILayoutOption>());
            }
            GUILayout.EndArea();
        }
Example #18
0
        private void RefreshControls()
        {
            Controller controller = PlayerInput.RewiredPlayer.controllers.GetLastActiveController();

            if (controller.type == ControllerType.Mouse)
            {
                controller = PlayerInput.RewiredPlayer.controllers.Keyboard;
            }
            var controllerMap = PlayerInput.RewiredPlayer.controllers.maps.GetFirstMapInCategory(controller, 0);

            foreach (InputAction inputAction in ReInput.mapping.ActionsInCategory(0))
            {
                _targetOptions.Add(SetupLabel(_optionControlsTr, inputAction.descriptiveName).gameObject);
                var pivot = ItemPool.SpawnUIPrefab(_horizontalListPrefab, _optionControlsTr);
                _targetOptions.Add(pivot.gameObject);
                var action = inputAction;
                _targetOptions.Add(SetupButton(pivot.transform, "Add New", delegate(int i) {
                    InputMapper.Context context = new InputMapper.Context()
                    {
                        actionId      = action.id,
                        actionRange   = AxisRange.Positive,
                        controllerMap = controllerMap
                    };
                    SetInputListen(context);
                }).gameObject);
                // Write out assigned elements
                for (var i = 0; i < controllerMap.AllMaps.Count; i++)
                {
                    ActionElementMap elementMap = controllerMap.AllMaps[i];
                    if (elementMap.actionId != action.id)
                    {
                        continue;
                    }
                    _targetOptions.Add(SetupButton(pivot.transform, elementMap.elementIdentifierName, delegate(int i1) {
                        InputMapper.Context context = new InputMapper.Context()
                        {
                            actionId                  = action.id,
                            actionRange               = AxisRange.Positive,
                            controllerMap             = controllerMap,
                            actionElementMapToReplace = elementMap
                        };
                        SetInputListen(context);
                    }).gameObject
                                       );
                }
            }
        }
    // Initialize Input Row
    public void InitializeRow(string actionName, ActionElementMap primaryMap,
                              ActionElementMap secondaryMap, int primaryActionID, int secondaryActionID,
                              ControllerType mapControlType, InputElementToImageData buttonData, bool unassigned)
    {
        // Input Name
        inputNameText.text = actionName;
        // Control Type
        controlType = mapControlType;
        // Button Image Data
        buttonImageData = buttonData;
        // Primary Action ID
        iPrimaryActionID = primaryActionID;
        // Secondary Action ID
        iSecondaryActionID = secondaryActionID;

        UpdateRow(primaryMap, secondaryMap, unassigned);
    }
Example #20
0
        private static ActionElementMap[] GetElementMap(InputAction action, bool negativeAxis)
        {
            if (action == null)
            {
                return(null);
            }
            ActionElementMap[]   array = new ActionElementMap[1];
            List <ControllerMap> list  = Input.player.controllers.maps.GetAllMaps().ToList <ControllerMap>();

            foreach (ControllerMap controllerMap in list)
            {
                if (controllerMap.controllerType == ControllerType.Mouse || controllerMap.controllerType == ControllerType.Keyboard)
                {
                    List <ActionElementMap> list2 = (from m in controllerMap.AllMaps
                                                     where m.actionId == action.id
                                                     select m).ToList <ActionElementMap>();
                    foreach (ActionElementMap actionElementMap in list2)
                    {
                        bool flag = actionElementMap.axisContribution == Pole.Negative;
                        if (flag == negativeAxis)
                        {
                            if (actionElementMap.elementType == ControllerElementType.Button || actionElementMap.elementType == ControllerElementType.Axis)
                            {
                                if (array[0] != null)
                                {
                                    Debug.Log(string.Concat(new object[]
                                    {
                                        "Multiple maps! ",
                                        array[0].keyCode,
                                        " & ",
                                        actionElementMap.keyCode
                                    }));
                                }
                                array[0] = actionElementMap;
                            }
                        }
                    }
                }
            }
            if (array[0] == null)
            {
                return(null);
            }
            return(array);
        }
Example #21
0
 private void RedrawUI()
 {
     if (this.controller == null)
     {
         this.ClearUI();
     }
     else
     {
         this.controllerNameUIText.set_text(this.controller.get_name());
         for (int index = 0; index < this.rows.Count; ++index)
         {
             // ISSUE: object of a compiler-generated type is created
             // ISSUE: variable of a compiler-generated type
             SimpleControlRemapping.\u003CRedrawUI\u003Ec__AnonStorey0 redrawUiCAnonStorey0 = new SimpleControlRemapping.\u003CRedrawUI\u003Ec__AnonStorey0();
             // ISSUE: reference to a compiler-generated field
             redrawUiCAnonStorey0.\u0024this = this;
             SimpleControlRemapping.Row row = this.rows[index];
             InputAction action             = this.rows[index].action;
             string      str = string.Empty;
             // ISSUE: reference to a compiler-generated field
             redrawUiCAnonStorey0.actionElementMapId = -1;
             using (IEnumerator <ActionElementMap> enumerator = this.controllerMap.ElementMapsWithAction(action.get_id()).GetEnumerator())
             {
                 while (((IEnumerator)enumerator).MoveNext())
                 {
                     ActionElementMap current = enumerator.Current;
                     if (current.ShowInField(row.actionRange))
                     {
                         str = current.get_elementIdentifierName();
                         // ISSUE: reference to a compiler-generated field
                         redrawUiCAnonStorey0.actionElementMapId = current.get_id();
                         break;
                     }
                 }
             }
             row.text.set_text(str);
             ((UnityEventBase)row.button.get_onClick()).RemoveAllListeners();
             // ISSUE: reference to a compiler-generated field
             redrawUiCAnonStorey0.index = index;
             // ISSUE: method pointer
             ((UnityEvent)row.button.get_onClick()).AddListener(new UnityAction((object)redrawUiCAnonStorey0, __methodptr(\u003C\u003Em__0)));
         }
     }
 }
    // Removes an input from an action map
    public void RemoveInput()
    {
        // Current Action Map
        ActionElementMap map = bAltMap ? aAltElementMaps[currentUIInputRow.PrimaryActionID] :
                               aElementMaps[currentUIInputRow.SecondaryActionID];
        // Assignment Data
        ElementAssignment assignment = new ElementAssignment(controlType, ControllerElementType.Button, -1, map.axisRange,
                                                             KeyCode.None, ModifierKeyFlags.None, map.actionId, map.axisContribution, false, map.id);

        // Remove element based on which map is being assigned to
        if (bAltMap)
        {
            altControlMap.ReplaceElementMap(assignment);

            currentUIInputRow.secondaryButtonText.gameObject.SetActive(true);

            if (controlType == ControllerType.Joystick)
            {
                currentUIInputRow.secondaryButtonIcon.gameObject.SetActive(false);
                currentUIInputRow.secondaryButtonIcon.sprite = null;
            }

            currentUIInputRow.secondaryButtonText.text = "None";
        }
        else
        {
            controlMap.ReplaceElementMap(assignment);

            currentUIInputRow.primaryButtonText.gameObject.SetActive(true);

            if (controlType == ControllerType.Joystick)
            {
                currentUIInputRow.primaryButtonIcon.gameObject.SetActive(false);
                currentUIInputRow.primaryButtonIcon.sprite = null;
            }

            currentUIInputRow.primaryButtonText.text = "None";
        }

        SettingsManager.bOptionChanged = true;
        CloseAssignmentWindow();
    }
Example #23
0
 private bool CreateConflictCheck(
     ElementAssignment _elementAssignment,
     out ElementAssignmentConflictCheck _conflictCheck,
     ActionElementMap _actionElementMap)
 {
     if (this.controllerMap == null || this.player == null)
     {
         _conflictCheck = (ElementAssignmentConflictCheck)null;
         return(false);
     }
     _conflictCheck = ((ElementAssignment) ref _elementAssignment).ToElementAssignmentConflictCheck();
     ((ElementAssignmentConflictCheck) ref _conflictCheck).set_playerId(this.player.get_id());
     ((ElementAssignmentConflictCheck) ref _conflictCheck).set_controllerType(this.controllerMap.get_controllerType());
     ((ElementAssignmentConflictCheck) ref _conflictCheck).set_controllerMapId(this.controllerMap.get_id());
     ((ElementAssignmentConflictCheck) ref _conflictCheck).set_controllerMapCategoryId(this.controllerMap.get_categoryId());
     if (_actionElementMap != null)
     {
         ((ElementAssignmentConflictCheck) ref _conflictCheck).set_elementMapId(_actionElementMap.get_id());
     }
     return(true);
 }
Example #24
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);
        }
Example #25
0
        // Token: 0x06001C2A RID: 7210 RVA: 0x00083660 File Offset: 0x00081860
        public static string GetActionDisplayString(ActionElementMap actionElementMap)
        {
            if (actionElementMap == null)
            {
                return("");
            }
            string elementIdentifierName = actionElementMap.elementIdentifierName;

            if (elementIdentifierName == "Left Mouse Button")
            {
                return("M1");
            }
            if (elementIdentifierName == "Right Mouse Button")
            {
                return("M2");
            }
            if (!(elementIdentifierName == "Left Shift"))
            {
                return(actionElementMap.elementIdentifierName);
            }
            return("Shift");
        }
    // Token: 0x06000256 RID: 598 RVA: 0x00037EB4 File Offset: 0x000360B4
    public virtual string GetInputButtonName(string theAction, bool positiveAxis, bool isKeyboard)
    {
        Controller controllerToUse = this.GetControllerToUse(isKeyboard, false);
        string     result;

        if (!RuntimeServices.EqualityOperator(controllerToUse, null))
        {
            ActionElementMap actionElementMapToUse = this.GetActionElementMapToUse(controllerToUse, theAction, positiveAxis);
            if (RuntimeServices.EqualityOperator(actionElementMapToUse, null))
            {
                if (isKeyboard)
                {
                    controllerToUse = this.GetControllerToUse(isKeyboard, true);
                    if (RuntimeServices.EqualityOperator(controllerToUse, null))
                    {
                        result = this.GetTranslation("inMissing");
                    }
                    else
                    {
                        actionElementMapToUse = this.GetActionElementMapToUse(controllerToUse, theAction, positiveAxis);
                        result = ((!RuntimeServices.EqualityOperator(actionElementMapToUse, null)) ? actionElementMapToUse.elementIdentifierName : "  ");
                    }
                }
                else
                {
                    result = "  ";
                }
            }
            else
            {
                result = actionElementMapToUse.elementIdentifierName;
            }
        }
        else
        {
            result = ((!isKeyboard) ? this.GetTranslation("inNoPad") : this.GetTranslation("inNoKeyb"));
        }
        return(result);
    }
    // Checks the current action map for an existing input
    private void CheckReplaceInput()
    {
        // Current Map
        ActionElementMap map = bAltMap ? aAltElementMaps[currentUIInputRow.PrimaryActionID] :
                               aElementMaps[currentUIInputRow.SecondaryActionID];

        // If the map is empty, start polling for input
        if (map.elementIdentifierName == "None" || map.elementIdentifierName == string.Empty ||
            (!bAltMap && currentUIInputRow.primaryButtonText.gameObject.activeSelf && currentUIInputRow.primaryButtonText.text == "None") ||
            (bAltMap && currentUIInputRow.secondaryButtonText.gameObject.activeSelf && currentUIInputRow.secondaryButtonText.text == "None"))
        {
            StartCoroutine(EnablePolling());
            assignPanelText.text = "Please assign a new input for " + currentUIInputRow.inputNameText.text + ".";
            panelCountdownText.gameObject.SetActive(true);
        }
        else         // Otherwise, ask player is they want to replace or remove the input or cancel the operation
        {
            assignPanelText.text = "There is already an input assigned to " + currentUIInputRow.inputNameText.text + ".";
            goPanelButtons.SetActive(true);
            EventSystem.current.SetSelectedGameObject(goAssignPanelCancelButton);
        }
    }
Example #28
0
        private bool IsMenuAxis(int actionId, int axisIndex)
        {
            if (rewiredStandaloneInputModule == null)
            {
                return(false);
            }

            // Determine if menu action is mapped to this axis on any player
            IList <Player> players     = ReInput.players.AllPlayers;
            int            playerCount = players.Count;

            for (int i = 0; i < playerCount; i++)
            {
                IList <JoystickMap> maps = players[i].controllers.maps.GetMaps <JoystickMap>(joystick.id);
                if (maps == null)
                {
                    continue;
                }
                int mapCount = maps.Count;
                for (int j = 0; j < mapCount; j++)
                {
                    IList <ActionElementMap> aems = maps[j].AxisMaps;
                    if (aems == null)
                    {
                        continue;
                    }
                    int aemCount = aems.Count;
                    for (int k = 0; k < aemCount; k++)
                    {
                        ActionElementMap aem = aems[k];
                        if (aem.actionId == actionId && aem.elementIndex == axisIndex)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Example #29
0
    private void UpdateInputCheckMode()
    {
        ControllerPollingInfo _pollingInfo = ((ReInput.ControllerHelper.PollingHelper)ReInput.get_controllers().polling).PollControllerForFirstElementDown(this.selectedControllerType, this.selectedControllerId);

        if (!((ControllerPollingInfo) ref _pollingInfo).get_success() || ((ControllerPollingInfo) ref _pollingInfo).get_elementType() != 1)
        {
            return;
        }
        InputAction       action                      = this.row.action;
        ActionElementMap  _actionElementMap           = !this.controllerMap.ContainsAction(action.get_id()) ? (ActionElementMap)null : this.controllerMap.GetElementMapsWithAction(action.get_id())[0];
        ElementAssignment elementAssignment           = this.ToElementAssignment(_pollingInfo, (ModifierKeyFlags)0, this.row.actionRange, action.get_id(), _actionElementMap);
        ElementAssignmentConflictCheck _conflictCheck = (ElementAssignmentConflictCheck)null;

        if (this.CreateConflictCheck(elementAssignment, out _conflictCheck, _actionElementMap) && !((ReInput.ControllerHelper.ConflictCheckingHelper)ReInput.get_controllers().conflictChecking).DoesElementAssignmentConflict(_conflictCheck))
        {
            this.controllerMap.ReplaceOrCreateElementMap(elementAssignment);
        }
        this.row        = (Remapping.Row)null;
        this.updateMode = Remapping.UpdateMode.ButtonSelectMode;
        ((Selectable)this.controllerSelectDropDown).set_interactable(true);
        this.RedrawUI();
    }
Example #30
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");
                         }
                     }
                 }
             }
         }
     }
 }
Example #31
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;
 }
 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);
 }
 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);
 }
        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);
        }