Beispiel #1
0
 private void Update()
 {
     OVRInput.Update();
     if (InputMappingIcons.LastController != null)
     {
         Player.ControllerHelper controllers = ReInput.players.GetPlayer(0).controllers;
         if (InputMappingIcons._trackedInputs == null)
         {
             InputMappingIcons._trackedInputs = new Dictionary <string, List <string> >();
         }
         foreach (ControllerMap controllerMap in controllers.maps.GetAllMaps())
         {
             Controller controller = controllers.GetController(controllerMap.controllerType, controllerMap.controllerId);
             string     name       = controller.name;
             if (!InputMappingIcons._trackedInputs.ContainsKey(name))
             {
                 InputMappingIcons._trackedInputs.Add(name, new List <string>());
             }
             List <string> list = InputMappingIcons._trackedInputs[name];
             foreach (ActionElementMap actionElementMap in controllerMap.AllMaps)
             {
                 if (!list.Contains(actionElementMap.elementIdentifierName))
                 {
                     list.Add(actionElementMap.elementIdentifierName);
                 }
             }
         }
     }
     if (TheForest.Utils.Input.IsGamePad)
     {
         Controller lastActiveController = TheForest.Utils.Input.player.controllers.GetLastActiveController();
         if (lastActiveController != InputMappingIcons.LastController && lastActiveController != null)
         {
             if (InputMappingIcons.LastController != null)
             {
                 Debug.Log("===> Changing gamepad icons: currentController=" + lastActiveController.name + ", LastController=" + InputMappingIcons.LastController.name);
             }
             else
             {
                 Debug.Log("===> Init gamepad icons: currentController=" + lastActiveController.name);
             }
             InputMappingIcons.LastController = lastActiveController;
             InputMappingIcons.RefreshMappings();
             InputMappingIcons.Version++;
         }
     }
     if (this._usingGamePadVersion != TheForest.Utils.Input.IsGamePad)
     {
         this._usingGamePadVersion = TheForest.Utils.Input.IsGamePad;
         InputMappingIcons.Version++;
         if (TheForest.Utils.Input.IsGamePad)
         {
             Debug.Log("===> Switching from KM to gamepad     Version=" + InputMappingIcons.Version);
         }
         else
         {
             Debug.Log("===> Switching from gamepad to KM     Version = " + InputMappingIcons.Version);
         }
     }
 }
Beispiel #2
0
        private void ProcessVRViveInputMappings(Player player)
        {
            Player.ControllerHelper     controllers = player.controllers;
            IEnumerable <ControllerMap> enumerable  = controllers.maps.GetAllMaps(ControllerType.Joystick);

            if (enumerable == null)
            {
                enumerable = new List <ControllerMap>();
            }
            foreach (ControllerMap controllerMap in enumerable)
            {
                List <ElementAssignment> list    = new List <ElementAssignment>();
                IList <ActionElementMap> allMaps = controllerMap.AllMaps;
                foreach (ActionElementMap actionElementMap in allMaps)
                {
                    if (actionElementMap.elementIdentifierId == 2 && actionElementMap.elementIdentifierName.Equals("Index Trigger"))
                    {
                        ElementAssignment item = new ElementAssignment(ControllerType.Joystick, ControllerElementType.Button, 7, AxisRange.Full, KeyCode.None, ModifierKeyFlags.None, actionElementMap.actionId, Pole.Positive, false, actionElementMap.id);
                        list.Add(item);
                    }
                }
                foreach (ElementAssignment elementAssignment in list)
                {
                    ActionElementMap actionElementMap2;
                    bool             flag = controllerMap.ReplaceElementMap(elementAssignment, out actionElementMap2);
                }
            }
        }
Beispiel #3
0
        private static void CaptureExistingActionElementRelationships(InputMapCategory sourceCategory, Player player, out Dictionary <int[], List <ActionElementMap> > elementSourceActionLinks, out Dictionary <int, ActionElementMap> storedElementMaps)
        {
            Player.ControllerHelper controllers = player.controllers;
            elementSourceActionLinks = new Dictionary <int[], List <ActionElementMap> >();
            storedElementMaps        = new Dictionary <int, ActionElementMap>();
            IEnumerable <ControllerMap> enumerable = controllers.maps.GetAllMaps(ControllerType.Keyboard);

            if (enumerable == null)
            {
                enumerable = new List <ControllerMap>();
            }
            foreach (ControllerMap controllerMap in enumerable)
            {
                if (controllerMap.categoryId == sourceCategory.id)
                {
                    IList <ActionElementMap> allMaps = controllerMap.AllMaps;
                    foreach (ActionElementMap actionElementMap in allMaps)
                    {
                        elementSourceActionLinks.Add(new int[]
                        {
                            actionElementMap.elementIdentifierId,
                            actionElementMap.actionId,
                            actionElementMap.id
                        }, new List <ActionElementMap>());
                        if (!storedElementMaps.ContainsKey(actionElementMap.id))
                        {
                            storedElementMaps.Add(actionElementMap.id, actionElementMap);
                        }
                    }
                }
            }
            foreach (ControllerMap controllerMap2 in enumerable)
            {
                bool flag = controllerMap2.categoryId == sourceCategory.id;
                if (!flag)
                {
                    IList <ActionElementMap> allMaps2 = controllerMap2.AllMaps;
                    foreach (ActionElementMap actionElementMap2 in allMaps2)
                    {
                        foreach (int[] array in elementSourceActionLinks.Keys)
                        {
                            int  num   = array[0];
                            int  num2  = array[1];
                            bool flag2 = num2 == actionElementMap2.actionId;
                            bool flag3 = num == actionElementMap2.elementIdentifierId;
                            if (flag3 && flag2)
                            {
                                elementSourceActionLinks[array].Add(actionElementMap2);
                            }
                        }
                    }
                }
            }
        }
Beispiel #4
0
 public void DisableMaps(InputSourceType i_Type, string i_Category, string i_Layout)
 {
     if (_RewiredPlayer != null)
     {
         Player.ControllerHelper controllers = _RewiredPlayer.controllers;
         if (controllers != null)
         {
             Player.ControllerHelper.MapHelper maps = controllers.maps;
             if (maps != null)
             {
                 maps.SetMapsEnabled(false, RewiredUtils.Types.GetControllerType(i_Type), i_Category, i_Layout);
             }
         }
     }
 }
Beispiel #5
0
 public void DisableMaps(string i_Category, string i_Layout)
 {
     if (_RewiredPlayer != null)
     {
         Player.ControllerHelper controllers = _RewiredPlayer.controllers;
         if (controllers != null)
         {
             Player.ControllerHelper.MapHelper maps = controllers.maps;
             if (maps != null)
             {
                 maps.SetMapsEnabled(false, i_Category, i_Layout);
             }
         }
     }
 }
Beispiel #6
0
 public void DisableAllMapsFor(InputSourceType i_Type)
 {
     if (_RewiredPlayer != null)
     {
         Player.ControllerHelper controllers = _RewiredPlayer.controllers;
         if (controllers != null)
         {
             Player.ControllerHelper.MapHelper maps = controllers.maps;
             if (maps != null)
             {
                 maps.SetAllMapsEnabled(false, RewiredUtils.Types.GetControllerType(i_Type));
             }
         }
     }
 }
Beispiel #7
0
 public void DisableAllMaps()
 {
     if (_RewiredPlayer != null)
     {
         Player.ControllerHelper controllers = _RewiredPlayer.controllers;
         if (controllers != null)
         {
             Player.ControllerHelper.MapHelper maps = controllers.maps;
             if (maps != null)
             {
                 maps.SetAllMapsEnabled(false);
             }
         }
     }
 }
Beispiel #8
0
 public void EnableMaps(InputSourceType i_Type, int i_Category)
 {
     if (_RewiredPlayer != null)
     {
         Player.ControllerHelper controllers = _RewiredPlayer.controllers;
         if (controllers != null)
         {
             Player.ControllerHelper.MapHelper maps = controllers.maps;
             if (maps != null)
             {
                 maps.SetMapsEnabled(true, RewiredUtils.Types.GetControllerType(i_Type), i_Category);
             }
         }
     }
 }
Beispiel #9
0
 public void EnableMaps(string i_Category)
 {
     if (_RewiredPlayer != null)
     {
         Player.ControllerHelper controllers = _RewiredPlayer.controllers;
         if (controllers != null)
         {
             Player.ControllerHelper.MapHelper maps = controllers.maps;
             if (maps != null)
             {
                 maps.SetMapsEnabled(true, i_Category);
             }
         }
     }
 }
Beispiel #10
0
        public static void RefreshMappings()
        {
            if (SteamDSConfig.isDedicatedServer)
            {
                return;
            }
            if (!ReInput.isReady || ReInput.players == null)
            {
                return;
            }
            Player player = ReInput.players.GetPlayer(0);

            if (player == null || player.controllers == null)
            {
                return;
            }
            Player.ControllerHelper controllers = player.controllers;
            foreach (ControllerMap controllerMap in controllers.maps.GetAllMaps(ControllerType.Mouse))
            {
                if (controllerMap.enabled)
                {
                    foreach (ActionElementMap actionElementMap in controllerMap.AllMaps)
                    {
                        if (!string.IsNullOrEmpty(actionElementMap.elementIdentifierName))
                        {
                            try
                            {
                                string      text   = actionElementMap.elementIdentifierName.Replace(' ', '_');
                                InputAction action = ReInput.mapping.GetAction(actionElementMap.actionId);
                                if (action.type == InputActionType.Axis)
                                {
                                    InputMappingIcons.KeyboardMappings[(int)Enum.Parse(typeof(InputMappingIcons.Actions), ((actionElementMap.axisContribution != Pole.Positive) ? action.negativeDescriptiveName : action.positiveDescriptiveName).Replace(' ', '_'))] = text;
                                }
                                InputMappingIcons.KeyboardMappings[(int)Enum.Parse(typeof(InputMappingIcons.Actions), action.name.Replace(' ', '_'))] = text;
                            }
                            catch
                            {
                            }
                        }
                    }
                }
            }
            foreach (ControllerMap controllerMap2 in controllers.maps.GetAllMaps(ControllerType.Keyboard))
            {
                if (controllerMap2.enabled)
                {
                    foreach (ActionElementMap actionElementMap2 in controllerMap2.AllMaps)
                    {
                        if (!string.IsNullOrEmpty(actionElementMap2.elementIdentifierName))
                        {
                            try
                            {
                                string elementIdentifierName = actionElementMap2.elementIdentifierName;
                                string text2;
                                if (elementIdentifierName != null)
                                {
                                    if (elementIdentifierName == "Left Control")
                                    {
                                        text2 = "LCtrl";
                                        goto IL_244;
                                    }
                                    if (elementIdentifierName == "Right Control")
                                    {
                                        text2 = "RCtrl";
                                        goto IL_244;
                                    }
                                }
                                text2 = actionElementMap2.elementIdentifierName;
IL_244:
                                InputAction action2 = ReInput.mapping.GetAction(actionElementMap2.actionId);
                                if (action2.type == InputActionType.Axis)
                                {
                                    InputMappingIcons.KeyboardMappings[(int)Enum.Parse(typeof(InputMappingIcons.Actions), ((actionElementMap2.axisContribution != Pole.Positive) ? action2.negativeDescriptiveName : action2.positiveDescriptiveName).Replace(' ', '_'))] = text2;
                                }
                                InputMappingIcons.KeyboardMappings[(int)Enum.Parse(typeof(InputMappingIcons.Actions), action2.name.Replace(' ', '_'))] = text2;
                            }
                            catch
                            {
                            }
                        }
                    }
                }
            }
            if (InputMappingIcons.LastController != null)
            {
                bool   flag = InputMappingIcons.LastController.name.Contains("DualShock") || InputMappingIcons.LastController.GetExtension <DualShock4Extension>() != null;
                string str;
                if (flag)
                {
                    str = "PS4_";
                }
                else
                {
                    str = InputMappingIcons.GetMappingPrefix(InputMappingIcons.LastController);
                }
                foreach (ControllerMap controllerMap3 in controllers.maps.GetAllMaps(ControllerType.Joystick))
                {
                    if (controllerMap3.enabled && controllerMap3.controllerId == InputMappingIcons.LastController.id)
                    {
                        foreach (ActionElementMap actionElementMap3 in controllerMap3.AllMaps)
                        {
                            if (!string.IsNullOrEmpty(actionElementMap3.elementIdentifierName))
                            {
                                try
                                {
                                    string elementIdentifierName2 = actionElementMap3.elementIdentifierName;
                                    string text3;
                                    if (elementIdentifierName2 != null)
                                    {
                                        if (elementIdentifierName2 == "View")
                                        {
                                            text3 = "Back";
                                            goto IL_4C3;
                                        }
                                        if (elementIdentifierName2 == "Right Stick X" || elementIdentifierName2 == "Right Stick Y")
                                        {
                                            text3 = "Right_Stick_Button";
                                            goto IL_4C3;
                                        }
                                        if (elementIdentifierName2 == "Left Stick X" || elementIdentifierName2 == "Left Stick Y")
                                        {
                                            text3 = "Left_Stick_Button";
                                            goto IL_4C3;
                                        }
                                    }
                                    text3 = actionElementMap3.elementIdentifierName.Replace(" X", string.Empty).Replace(" Y", string.Empty).TrimEnd(new char[]
                                    {
                                        ' ',
                                        '+',
                                        '-'
                                    }).Replace(' ', '_');
IL_4C3:
                                    InputAction action3 = ReInput.mapping.GetAction(actionElementMap3.actionId);
                                    text3 = str + text3;
                                    if (action3.type == InputActionType.Axis && (!string.IsNullOrEmpty(action3.positiveDescriptiveName) || !string.IsNullOrEmpty(action3.negativeDescriptiveName)))
                                    {
                                        InputMappingIcons.GamepadMappings[(int)Enum.Parse(typeof(InputMappingIcons.Actions), ((actionElementMap3.axisContribution != Pole.Positive) ? action3.negativeDescriptiveName : action3.positiveDescriptiveName).Replace(' ', '_'))] = text3;
                                    }
                                    InputMappingIcons.GamepadMappings[(int)Enum.Parse(typeof(InputMappingIcons.Actions), action3.name.Replace(' ', '_'))] = text3;
                                }
                                catch
                                {
                                }
                            }
                        }
                    }
                }
            }
            InputMappingIcons.Version++;
        }