Example #1
0
        private static string GetMappingPrefix(Controller controllerSource)
        {
            if (controllerSource == null)
            {
                return(string.Empty);
            }
            if (ForestVR.Enabled)
            {
                string mappingPrefixVR = InputMappingIcons.GetMappingPrefixVR(controllerSource);
                if (!mappingPrefixVR.NullOrEmpty())
                {
                    return(mappingPrefixVR);
                }
            }
            string name = controllerSource.name;

            string[] matchStrings = new string[]
            {
                "Sony DualShock.*"
            };
            string[] matchStrings2 = new string[]
            {
                ".*Dual Analog Gamepad",
                "Xbox.*Controller"
            };
            if (InputMappingIcons.GetMappingPrefix(name, matchStrings2))
            {
                return("360_");
            }
            if (InputMappingIcons.GetMappingPrefix(name, matchStrings))
            {
                return("PS4_");
            }
            return("360_");
        }
Example #2
0
        private static string GetMappingPrefixVR(Controller controllerSource)
        {
            VRControllerDisplayManager.VRControllerType activeControllerType = VRControllerDisplayManager.GetActiveControllerType();
            if (activeControllerType == VRControllerDisplayManager.VRControllerType.Vive)
            {
                return("VIVE_");
            }
            if (activeControllerType == VRControllerDisplayManager.VRControllerType.OculusTouch)
            {
                return("OCTOUCH_");
            }
            string[] matchStrings = new string[]
            {
                "Oculus Touch.*",
                "Oculus Controller"
            };
            string[] matchStrings2 = new string[]
            {
                "Open VR Controller.*"
            };
            string name = controllerSource.name;

            if (InputMappingIcons.GetMappingPrefix(name, matchStrings))
            {
                return("OCTOUCH_");
            }
            if (InputMappingIcons.GetMappingPrefix(name, matchStrings2))
            {
                return("VIVE_");
            }
            return(null);
        }
Example #3
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++;
        }