Пример #1
0
        public void RestoreDefaults()
        {
            this._mappingManager.ClearAllMaps();
            Input input = UnityEngine.Object.FindObjectOfType <Input>();

            if (input)
            {
                UnityEngine.Object.DestroyImmediate(input.gameObject);
            }
            UnityEngine.Object.FindObjectOfType <RewiredSpawner>().SendMessage("Awake");
            this._mappingManager = UnityEngine.Object.FindObjectOfType <InputMapping>();
            this._mappingManager.LoadAllMaps();
            this.ResetUI();
        }
Пример #2
0
 private void Start()
 {
     if (!this._mappingManager)
     {
         this._mappingManager = UnityEngine.Object.FindObjectOfType <InputMapping>();
     }
     this._actionRowMappingCount = new Dictionary <InputActionRow, int>();
     this._knownActionMaps       = new Dictionary <ActionElementMap, InputActionButton>();
     this.ShowUserAssignableActions();
     this._nextChangeTimer                = Time.realtimeSinceStartup + this._interChangeDelay;
     base.enabled                         = false;
     ReInput.ControllerConnectedEvent    -= new Action <ControllerStatusChangedEventArgs>(this.OnControllerConnectedEvent);
     ReInput.ControllerConnectedEvent    += new Action <ControllerStatusChangedEventArgs>(this.OnControllerConnectedEvent);
     ReInput.ControllerDisconnectedEvent -= new Action <ControllerStatusChangedEventArgs>(this.OnControllerConnectedEvent);
     ReInput.ControllerDisconnectedEvent += new Action <ControllerStatusChangedEventArgs>(this.OnControllerConnectedEvent);
     if (Input.player != null)
     {
         Input.player.controllers.maps.SetMapsEnabled(true, ControllerType.Joystick, "Menu");
     }
 }
Пример #3
0
 private void Awake()
 {
     InputMapping.instance             = this;
     ReInput.ControllerConnectedEvent += new Action <ControllerStatusChangedEventArgs>(this.OnControllerConnectedEvent);
     InputMapping.InitControllers();
 }
Пример #4
0
 private void Awake()
 {
     InputMapping.instance             = this;
     ReInput.ControllerConnectedEvent += this.OnControllerConnectedEvent;
     InputMapping.InitControllers();
 }
Пример #5
0
 private void Awake()
 {
     InputMapping.instance = this;
     ReInput.ControllerConnectedEvent += new Action<ControllerStatusChangedEventArgs>(this.OnControllerConnectedEvent);
     InputMapping.InitControllers();
 }
Пример #6
0
        public void LoadAllMaps()
        {
            Debug.Log("Reloading Input Mapping");
            if (!ReInput.isReady)
            {
                return;
            }
            if (ReInput.players == null || ReInput.players.AllPlayers == null)
            {
                return;
            }
            IList <Player> allPlayers = ReInput.players.AllPlayers;

            for (int i = 0; i < allPlayers.Count; i++)
            {
                Player player = allPlayers[i];
                IList <InputBehavior> inputBehaviors = ReInput.mapping.GetInputBehaviors(player.id);
                for (int j = 0; j < inputBehaviors.Count; j++)
                {
                    string inputBehaviorXml = this.GetInputBehaviorXml(player, inputBehaviors[j].id);
                    if (inputBehaviorXml != null && !(inputBehaviorXml == string.Empty))
                    {
                        inputBehaviors[j].ImportXmlString(inputBehaviorXml);
                    }
                }
                List <string>         allControllerMapsXml  = this.GetAllControllerMapsXml(player, true, ControllerType.Keyboard, ReInput.controllers.Keyboard);
                List <string>         allControllerMapsXml2 = this.GetAllControllerMapsXml(player, true, ControllerType.Mouse, ReInput.controllers.Mouse);
                bool                  flag = false;
                List <List <string> > list = new List <List <string> >();
                Debug.Log("Joystick count= " + player.controllers.Joysticks.Count);
                foreach (Rewired.Joystick controller in player.controllers.Joysticks)
                {
                    List <string> allControllerMapsXml3 = this.GetAllControllerMapsXml(player, true, ControllerType.Joystick, controller);
                    list.Add(allControllerMapsXml3);
                    if (allControllerMapsXml3.Count > 0)
                    {
                        flag = true;
                    }
                }
                if (allControllerMapsXml.Count > 0)
                {
                    if (!allControllerMapsXml[0].Contains("<actionId>48</actionId>"))
                    {
                        allControllerMapsXml[0] = allControllerMapsXml[0].Replace("</buttonMaps>", "<ActionElementMap><actionCategoryId>0</actionCategoryId><actionId>48</actionId><elementType>1</elementType><elementIdentifierId>-1</elementIdentifierId><keyboardKeyCode>49</keyboardKeyCode></ActionElementMap></buttonMaps>");
                    }
                    if (!allControllerMapsXml[0].Contains("<actionId>49</actionId>"))
                    {
                        allControllerMapsXml[0] = allControllerMapsXml[0].Replace("</buttonMaps>", "<ActionElementMap><actionCategoryId>0</actionCategoryId><actionId>49</actionId><elementType>1</elementType><elementIdentifierId>-1</elementIdentifierId><keyboardKeyCode>50</keyboardKeyCode></ActionElementMap></buttonMaps>");
                    }
                    if (!allControllerMapsXml[0].Contains("<actionId>50</actionId>"))
                    {
                        allControllerMapsXml[0] = allControllerMapsXml[0].Replace("</buttonMaps>", "<ActionElementMap><actionCategoryId>0</actionCategoryId><actionId>50</actionId><elementType>1</elementType><elementIdentifierId>-1</elementIdentifierId><keyboardKeyCode>51</keyboardKeyCode></ActionElementMap></buttonMaps>");
                    }
                    if (!allControllerMapsXml[0].Contains("<actionId>51</actionId>"))
                    {
                        allControllerMapsXml[0] = allControllerMapsXml[0].Replace("</buttonMaps>", "<ActionElementMap><actionCategoryId>0</actionCategoryId><actionId>51</actionId><elementType>1</elementType><elementIdentifierId>-1</elementIdentifierId><keyboardKeyCode>52</keyboardKeyCode></ActionElementMap></buttonMaps>");
                    }
                }
                if (allControllerMapsXml.Count > 0)
                {
                    InputMapCategory mapCategory = ReInput.mapping.GetMapCategory(0);
                    Dictionary <int[], List <ActionElementMap> > elementSourceActionLinks;
                    Dictionary <int, ActionElementMap>           storedElementMaps;
                    InputMapping.CaptureExistingActionElementRelationships(mapCategory, player, out elementSourceActionLinks, out storedElementMaps);
                    player.controllers.maps.ClearMaps(ControllerType.Keyboard, true);
                    player.controllers.maps.AddMapsFromXml(ControllerType.Keyboard, 0, allControllerMapsXml);
                    InputMapping.UpdateActionElementRelationships(elementSourceActionLinks, storedElementMaps, mapCategory, player);
                }
                if (flag)
                {
                    player.controllers.maps.ClearMaps(ControllerType.Joystick, true);
                }
                int num = 0;
                foreach (Rewired.Joystick joystick in player.controllers.Joysticks)
                {
                    bool flag2 = joystick.name.Contains("DualShock") || joystick.GetExtension <DualShock4Extension>() != null;
                    if (list[num].Count > 0)
                    {
                        if (flag2)
                        {
                            if (!list[num][0].Contains("<actionId>48</actionId>"))
                            {
                                list[num][0] = list[num][0].Replace("</buttonMaps>", "<ActionElementMap><actionCategoryId>0</actionCategoryId><actionId>48</actionId><elementType>1</elementType><elementIdentifierId>21</elementIdentifierId><axisRange>1</axisRange><axisContribution>0</axisContribution><keyboardKeyCode>0</keyboardKeyCode></ActionElementMap></buttonMaps>");
                            }
                            if (!list[num][0].Contains("<actionId>49</actionId>"))
                            {
                                list[num][0] = list[num][0].Replace("</buttonMaps>", "<ActionElementMap><actionCategoryId>0</actionCategoryId><actionId>49</actionId><elementType>1</elementType><elementIdentifierId>20</elementIdentifierId><axisRange>1</axisRange><axisContribution>0</axisContribution><keyboardKeyCode>0</keyboardKeyCode></ActionElementMap></buttonMaps>");
                            }
                            if (!list[num][0].Contains("<actionId>50</actionId>"))
                            {
                                list[num][0] = list[num][0].Replace("</buttonMaps>", "<ActionElementMap><actionCategoryId>0</actionCategoryId><actionId>50</actionId><elementType>1</elementType><elementIdentifierId>19</elementIdentifierId><axisRange>1</axisRange><axisContribution>0</axisContribution><keyboardKeyCode>0</keyboardKeyCode></ActionElementMap></buttonMaps>");
                            }
                            if (!list[num][0].Contains("<actionId>51</actionId>"))
                            {
                                list[num][0] = list[num][0].Replace("</buttonMaps>", "<ActionElementMap><actionCategoryId>0</actionCategoryId><actionId>51</actionId><elementType>1</elementType><elementIdentifierId>18</elementIdentifierId><axisRange>1</axisRange><axisContribution>0</axisContribution><keyboardKeyCode>0</keyboardKeyCode></ActionElementMap></buttonMaps>");
                            }
                            if (!list[num][0].Contains("<actionId>53</actionId>"))
                            {
                                list[num][0] = list[num][0].Replace("</buttonMaps>", "<ActionElementMap><actionCategoryId>2</actionCategoryId><actionId>53</actionId><elementType>1</elementType><elementIdentifierId>4</elementIdentifierId><axisRange>0</axisRange><axisContribution>0</axisContribution><keyboardKeyCode>0</keyboardKeyCode></ActionElementMap></buttonMaps>");
                            }
                            if (!list[num][0].Contains("<actionId>54</actionId>"))
                            {
                                list[num][0] = list[num][0].Replace("</buttonMaps>", "<ActionElementMap><actionCategoryId>2</actionCategoryId><actionId>54</actionId><elementType>1</elementType><elementIdentifierId>6</elementIdentifierId><axisRange>1</axisRange><axisContribution>0</axisContribution><keyboardKeyCode>0</keyboardKeyCode></ActionElementMap></buttonMaps>");
                            }
                        }
                        else
                        {
                            if (!list[num][0].Contains("<actionId>48</actionId>"))
                            {
                                list[num][0] = list[num][0].Replace("</buttonMaps>", "<ActionElementMap><actionCategoryId>0</actionCategoryId><actionId>48</actionId><elementType>1</elementType><elementIdentifierId>19</elementIdentifierId><axisRange>1</axisRange><axisContribution>0</axisContribution><keyboardKeyCode>0</keyboardKeyCode></ActionElementMap></buttonMaps>");
                            }
                            if (!list[num][0].Contains("<actionId>49</actionId>"))
                            {
                                list[num][0] = list[num][0].Replace("</buttonMaps>", "<ActionElementMap><actionCategoryId>0</actionCategoryId><actionId>49</actionId><elementType>1</elementType><elementIdentifierId>18</elementIdentifierId><axisRange>1</axisRange><axisContribution>0</axisContribution><keyboardKeyCode>0</keyboardKeyCode></ActionElementMap></buttonMaps>");
                            }
                            if (!list[num][0].Contains("<actionId>50</actionId>"))
                            {
                                list[num][0] = list[num][0].Replace("</buttonMaps>", "<ActionElementMap><actionCategoryId>0</actionCategoryId><actionId>50</actionId><elementType>1</elementType><elementIdentifierId>17</elementIdentifierId><axisRange>1</axisRange><axisContribution>0</axisContribution><keyboardKeyCode>0</keyboardKeyCode></ActionElementMap></buttonMaps>");
                            }
                            if (!list[num][0].Contains("<actionId>51</actionId>"))
                            {
                                list[num][0] = list[num][0].Replace("</buttonMaps>", "<ActionElementMap><actionCategoryId>0</actionCategoryId><actionId>51</actionId><elementType>1</elementType><elementIdentifierId>16</elementIdentifierId><axisRange>1</axisRange><axisContribution>0</axisContribution><keyboardKeyCode>0</keyboardKeyCode></ActionElementMap></buttonMaps>");
                            }
                            if (!list[num][0].Contains("<actionId>53</actionId>"))
                            {
                                list[num][0] = list[num][0].Replace("</buttonMaps>", "<ActionElementMap><actionCategoryId>2</actionCategoryId><actionId>53</actionId><elementType>1</elementType><elementIdentifierId>4</elementIdentifierId><axisRange>0</axisRange><axisContribution>0</axisContribution><keyboardKeyCode>0</keyboardKeyCode></ActionElementMap></buttonMaps>");
                            }
                            if (!list[num][0].Contains("<actionId>54</actionId>"))
                            {
                                list[num][0] = list[num][0].Replace("</buttonMaps>", "<ActionElementMap><actionCategoryId>2</actionCategoryId><actionId>54</actionId><elementType>1</elementType><elementIdentifierId>6</elementIdentifierId><axisRange>1</axisRange><axisContribution>0</axisContribution><keyboardKeyCode>0</keyboardKeyCode></ActionElementMap></buttonMaps>");
                            }
                        }
                    }
                    player.controllers.maps.AddMapsFromXml(ControllerType.Joystick, joystick.id, list[num]);
                    num++;
                }
                if (allControllerMapsXml2.Count > 0)
                {
                    player.controllers.maps.ClearMaps(ControllerType.Mouse, true);
                }
                player.controllers.maps.AddMapsFromXml(ControllerType.Mouse, 0, allControllerMapsXml2);
                if (ForestVR.Enabled)
                {
                    this.ProcessVRInputMappings(player);
                }
            }
            foreach (Rewired.Joystick joystick2 in ReInput.controllers.Joysticks)
            {
                joystick2.ImportCalibrationMapFromXmlString(this.GetJoystickCalibrationMapXml(joystick2));
            }
            Input.ForceRefreshState();
            InputMappingIcons.RefreshMappings();
        }
Пример #7
0
 public void RestoreDefaults()
 {
     this._mappingManager.ClearAllMaps();
     Input input = UnityEngine.Object.FindObjectOfType<Input>();
     if (input)
     {
         UnityEngine.Object.DestroyImmediate(input.gameObject);
     }
     UnityEngine.Object.FindObjectOfType<RewiredSpawner>().SendMessage("Awake");
     this._mappingManager = UnityEngine.Object.FindObjectOfType<InputMapping>();
     this._mappingManager.LoadAllMaps();
     this.ResetUI();
 }
Пример #8
0
 private void Start()
 {
     if (!this._mappingManager)
     {
         this._mappingManager = UnityEngine.Object.FindObjectOfType<InputMapping>();
     }
     this._actionRowMappingCount = new Dictionary<InputActionRow, int>();
     this._knownActionMaps = new Dictionary<ActionElementMap, InputActionButton>();
     this.ShowUserAssignableActions();
     this._nextChangeTimer = Time.realtimeSinceStartup + this._interChangeDelay;
     base.enabled = false;
     ReInput.ControllerConnectedEvent -= new Action<ControllerStatusChangedEventArgs>(this.OnControllerConnectedEvent);
     ReInput.ControllerConnectedEvent += new Action<ControllerStatusChangedEventArgs>(this.OnControllerConnectedEvent);
     ReInput.ControllerDisconnectedEvent -= new Action<ControllerStatusChangedEventArgs>(this.OnControllerConnectedEvent);
     ReInput.ControllerDisconnectedEvent += new Action<ControllerStatusChangedEventArgs>(this.OnControllerConnectedEvent);
     if (Input.player != null)
     {
         Input.player.controllers.maps.SetMapsEnabled(true, ControllerType.Joystick, "Menu");
     }
 }