Example #1
0
    public Gamer(Team t)
    {
        this.game = t.game;

        canMove = true;

        id = NextGamerId;
        NextGamerId++;
        playerIndex = (PlayerIndex)id;

        game.refs.xboxInputs.NeedToCheck(id);

        if (XboxController == null)
            XboxController = this.game.refs.xboxInputs.controllers[id];

        this.Team = t;
        this.Controlled = t[t.nbUnits / 2];
        this.Controlled.IndicateSelected(true);
        this.Inputs = this.game.settings.Inputs;
    }
Example #2
0
    public Gamer(Team t)
    {
        this.game = t.game;

        canMove = true;

        id = NextGamerId;
        NextGamerId++;
        playerIndex = (PlayerIndex)id;

        game.refs.xboxInputs.NeedToCheck(id);

        if (XboxController == null)
        {
            XboxController = this.game.refs.xboxInputs.controllers[id];
        }

        this.Team       = t;
        this.Controlled = t[t.nbUnits / 2];
        this.Controlled.IndicateSelected(true);
        this.Inputs = this.game.settings.Inputs;
    }
 // Update is called once per frame
 void Update()
 {
     Debug.Log(playerTag);
     Debug.Log(InputSettings.getAction2Button(playerTag));
     Debug.Log(Input.GetButtonDown(InputSettings.getAction2Button(playerTag)));
     if (Input.GetButton(InputSettings.getAction2Button(playerTag)))
     {
         if (Input.GetButton(plusButton))
         {
             Debug.Log("XplusButton pressed");
             if (orientation == Orientation.Up || orientation == Orientation.Down)
             {
                 transform.localPosition += new Vector3(xSpeed, 0, 0) * Time.deltaTime;
             }
             else
             {
                 transform.localPosition += new Vector3(0, 0, xSpeed) * Time.deltaTime;
             }
         }
         else if (Input.GetButton(minusButton))
         {
             Debug.Log("XminusButton pressed");
             if (orientation == Orientation.Up || orientation == Orientation.Down)
             {
                 transform.localPosition += new Vector3(-xSpeed, 0, 0) * Time.deltaTime;
             }
             else
             {
                 transform.localPosition += new Vector3(0, 0, -xSpeed) * Time.deltaTime;
             }
         }
         Debug.Log("nothing pressed");
     }
     else
     {
         Destroy(this);
     }
 }
Example #4
0
    /// <summary>
    /// Goes through all previously selected moves from InputSettings and selects them in the GUI.
    /// </summary>
    public void ReselectMoves()
    {
        List <string> usedButtons = InputSettings.allUsedButtons;

        //For every used button, if the move asigned to it matches that of a panel list item. Mark that list item in GUI.
        foreach (string button in usedButtons)
        {
            string buttonMoveName = InputSettings.GetMoveName(button);
            for (int i = 0; i < listItems.Length; i++)
            {
                MovePanelBehaviour listItem = listItems [i];
                Move panelMove = listItem.getMove();
                if (panelMove == null)
                {
                    continue;
                }
                if (panelMove.GetName().Equals(buttonMoveName))
                {
                    RegisterPlayerMoveToButton(button, i);
                }
            }
        }
    }
Example #5
0
        /// <inheritdoc/>
        public IVirtualButton ToVirtual(InputSettings settings)
        {
            switch (Action)
            {
            case MouseAction.Left:
                return(VirtualButton.Mouse.Left);

            case MouseAction.Right:
                return(VirtualButton.Mouse.Right);

            case MouseAction.Middle:
                return(VirtualButton.Mouse.Middle);

            case MouseAction.DeltaX:
                return(new VirtualMouseAxis(VirtualButton.Mouse.DeltaX, negative: settings.InvertMouseX, mouseSensitivity: settings.MouseSensitivity));

            case MouseAction.DeltaY:
                return(new VirtualMouseAxis(VirtualButton.Mouse.DeltaY, negative: !settings.InvertMouseY, mouseSensitivity: settings.MouseSensitivity));

            default:
                throw new InvalidOperationException($"Provided value ({Action}) has no virtual button representation.");
            }
        }
Example #6
0
 /// <summary>
 /// Minden frame-ben meghívásra kerül, itt történik a billentyűzetről bevitt adatok feldolgozása
 /// </summary>
 void Update()
 {
     if (Input.GetButtonDown(InputSettings.getRightButton(gameObject.tag)))
     {
         MoveRight();
     }
     else if (Input.GetButtonDown(InputSettings.getLeftButton(gameObject.tag)))
     {
         MoveLeft();
     }
     else if (Input.GetButtonDown(InputSettings.getUpButton(gameObject.tag)))
     {
         MoveUp();
     }
     else if (Input.GetButtonDown(InputSettings.getDownButton(gameObject.tag)))
     {
         MoveDown();
     }
     if (Input.GetButtonDown(InputSettings.getAction1Button(gameObject.tag)))
     {
         Select();
     }
 }
        /// <inheritdoc/>
        public IVirtualButton ToVirtual(InputSettings settings)
        {
            switch (Button)
            {
            case GPButton.A: return(VirtualButton.GamePad.A);

            case GPButton.B: return(VirtualButton.GamePad.B);

            case GPButton.X: return(VirtualButton.GamePad.X);

            case GPButton.Y: return(VirtualButton.GamePad.Y);

            case GPButton.Start: return(VirtualButton.GamePad.Start);

            case GPButton.Back: return(VirtualButton.GamePad.Back);

            case GPButton.LeftShoulder: return(VirtualButton.GamePad.LeftShoulder);

            case GPButton.RightShoulder: return(VirtualButton.GamePad.RightShoulder);

            case GPButton.LeftThumb: return(VirtualButton.GamePad.LeftThumb);

            case GPButton.RightThumb: return(VirtualButton.GamePad.RightThumb);

            case GPButton.PadUp: return(VirtualButton.GamePad.PadUp);

            case GPButton.PadDown: return(VirtualButton.GamePad.PadDown);

            case GPButton.PadLeft: return(VirtualButton.GamePad.PadLeft);

            case GPButton.PadRight: return(VirtualButton.GamePad.PadRight);

            default:
                throw new InvalidOperationException($"Provided value ({Button}) has no virtual button representation.");
            }
        }
Example #8
0
 void Update()
 {
     for (int i = 0; i < availableKeys.Length; i++)
     {
         if (Input.GetKeyDown("" + availableKeys [i]))
         {
             string newButton = "" + availableKeys [i];
             InputSettings.RemoveButton(newButton);                                                                           //Remove button where it is currently used so that it is only used once.
             InputSettings.AddButton(newButton, StaticCharacterHolder.characters [currentCharacterNumber - 1], currentIndex); //Add button in its new place.
             this.inputGuiManager.UpdateGUI();                                                                                //Update gui to match current settings.
             gameObject.SetActive(false);                                                                                     //Hide text telling user to press a key.
         }
     }
     foreach (string button in availableControllerButtons)
     {
         if (Input.GetButtonDown(button))
         {
             InputSettings.RemoveButton(button);                                                                           //Remove button where it is currently used so that it is only used once.
             InputSettings.AddButton(button, StaticCharacterHolder.characters [currentCharacterNumber - 1], currentIndex); //Add button in its new place.
             this.inputGuiManager.UpdateGUI();                                                                             //Update gui to match current settings.
             gameObject.SetActive(false);                                                                                  //Hide text telling user to press a key.
         }
     }
 }
Example #9
0
    void HandleScroll(KeyHandlerInfo khi)
    {
        Dictionary <KeyCode, Vector3> scrollers = new Dictionary <KeyCode, Vector3>
        {
            { InputSettings.GetKeyCode(ePlayerAction.ScrollUp), new Vector3(0, 0, 1) },
            { InputSettings.GetKeyCode(ePlayerAction.ScrollDown), new Vector3(0, 0, -1) },
            { InputSettings.GetKeyCode(ePlayerAction.ScrollLeft), new Vector3(-1, 0, 0) },
            { InputSettings.GetKeyCode(ePlayerAction.ScrollRight), new Vector3(1, 0, 0) }
        };

        Vector3 p    = Camera.main.transform.position;
        Vector3 newP = new Vector3(p.x, p.y, p.z);

        foreach (KeyCode k in scrollers.Keys)
        {
            KeyCodeInfo kci = khi._keysInterfaced[k];
            if (kci._keyCodeInfo[eInput.Down] || kci._keyCodeInfo[eInput.Held])
            {
                Vector3 s = scrollers[k];
                newP = new Vector3(newP.x + s.x, newP.y + s.y, newP.z + s.z);
            }
        }
        Camera.main.transform.position = newP;
    }
Example #10
0
 public bool getButtonDown(InputSettings input)
 {
     return(buttons.Find(x => x.Key == input).Value);
 }
Example #11
0
 public float getAxis(InputSettings input)
 {
     return(axises.Find(x => x.Key == input).Value);
 }
Example #12
0
 public InputSettingValue(InputSettings key, VALUE val)
 {
     this.Key   = key;
     this.Value = val;
 }
        protected override void OnEnable()
        {
            base.OnEnable();

            _inputIds = InputSettings.GetGlobalInputIds();
        }
    /// <summary>
    /// Init this instance. Adds slots for the buttons of the current owner to the list of moves.
    /// This is init and not start because the owner is not set form the start.
    /// </summary>
    void Init()
    {
        //TODO: In case we ever set owner twice, we would have to delete all children of the panel.
        this.inited = true;
        panels      = new List <GameObject> ();
        List <string> character1Buttons = InputSettings.GetCharacterButtons(owner.GetNbr());

        foreach (string characterButton in character1Buttons)
        {
            string previewPath          = "Prefabs" + Path.DirectorySeparatorChar + "MovePanel";
            string previewCharacterPath = "Prefabs" + Path.DirectorySeparatorChar + "Character";

            GameObject previewPanelObject     = (GameObject)Resources.Load(previewPath);
            GameObject previewCharacterObject = (GameObject)Resources.Load(previewCharacterPath);
            previewCharacterObject.GetComponent <CharacterCollisionDetector>().enabled = false;
            GameObject previewPanel = Instantiate(previewPanelObject, previewPanelObject.transform.position, previewPanelObject.transform.rotation, transform);

            if (owner.GetNbr() == 1)
            {
                foreach (Transform child in previewPanel.transform)
                {
                    //Flip all text fields.
                    //The transform of player 1 is flipped. So if all children are not flipped as well, the text is reversed.
                    child.GetComponent <RectTransform> ().localScale = new Vector3(-1, 1, 1);
                }
            }

            //Make selection panel list entries have the default button sprite to make them look less like an interactable list.
            //string defaultButtonPath = "UI/Skin/Background.psd";
            string defaultButtonPath = "Art/Main Menu/button_up_test";
            if (System.IO.File.Exists(defaultButtonPath))
            {
                Debug.Log("foooound! file ");
            }
            //Sprite defaultButtonSprite = AssetDatabase.GetBuiltinExtraResource<Sprite> (defaultButtonPath);
            Sprite defaultButtonSprite = Resources.Load <Sprite>(defaultButtonPath);
            previewPanel.GetComponent <Image> ().sprite = defaultButtonSprite;

            ResetText(previewPanel);

            foreach (Transform child in previewPanel.transform)
            {
                Text text = child.GetComponent <Text> ();
                if (text != null)
                {
                    text.fontSize = 24;
                }
            }

            GameObject previewCharacter = Instantiate(previewCharacterObject, previewCharacterObject.transform.position, previewCharacterObject.transform.rotation, previewPanel.transform);

            previewPanel.GetComponent <MovePanelBehaviour>().addPreviewCharacter(previewCharacter);

            float characterPosition;

            if (owner.GetNbr() == 1)
            {
                characterPosition = 2.4f;
            }
            else
            {
                characterPosition = -2.4f;
            }

            previewCharacter.transform.position   = new Vector2(characterPosition * previewPanel.transform.localScale.x, 0);
            previewCharacter.transform.localScale = new Vector3(3 * -previewPanel.transform.localScale.x, 3, 3);

            previewCharacter.SetActive(false);

            MovePanelBehaviour panelBehaviour = previewPanel.GetComponent <MovePanelBehaviour> ();
            if (owner != null)
            {
                string characterButtonDisplayName = characterButton;
                if (characterButtonDisplayName.Length > 1)
                {
                    characterButtonDisplayName = UnityUtils.ControllerButtonToDisplayName(characterButtonDisplayName);
                }
                panelBehaviour.AssignButton(characterButtonDisplayName, owner.GetColor(), 2);
            }
        }
    }
 /// <inheritdoc/>
 public IVirtualButton ToVirtual(InputSettings settings) => this;
Example #16
0
    void Update()
    {
        // Reduce pause time or unpause if pause time has run out.
        if (pauseTime > 0)
        {
            pauseTime -= Time.deltaTime;
        }

        if (pauseTime <= 0 && pausedForTime)
        {
            UnPause();
        }

        if (paused)
        {
            return;             //End method if game is paused.
        }
        // If previous move finished, reset isPlayingMove and enable the animator.
        if (!fightMoveController.IsDoingMove())
        {
            isPlayingMove = false;
            SetAnimatorEnabled(true);
        }

        //Check fight move input.
        if (Input.anyKeyDown)
        {
            string pressedButton = "";
            foreach (string button in InputSettings.allUsedButtons)
            {
                try {
                    if (Input.GetKeyDown(button))
                    {
                        pressedButton = button;
                    }
                }
                catch
                {
                }
                try {
                    if (Input.GetButtonDown(button))
                    {
                        pressedButton = button;
                    }
                }
                catch
                {
                }
            }
            if (InputSettings.HasButton(characterIndex, pressedButton) && !isPlayingMove && !isCrouching && !animator.GetCurrentAnimatorStateInfo(0).IsName("crouch"))
            {
                isPlayingMove = true;
                SetAnimatorEnabled(false);
                string moveName = InputSettings.GetMoveName(pressedButton);
                fightMoveController.DoMove(moveName);
            }
        }

        float horizontal         = Input.GetAxisRaw(horizontalAxis);
        float horizontalJoystick = Input.GetAxisRaw(horizontalAxisJoystick);
        float vertical           = Input.GetAxisRaw(verticalAxis);
        float verticalJoystick   = Input.GetAxisRaw(verticalAxisJoystick);

        //isPlaying is whether a fight move is being played. If it is, don't move the character.
        if (!isPlayingMove)
        {
            // Move sideways
            if ((horizontal < 0 || horizontalJoystick < 0) && !this.isCrouching && !this.animator.GetBool("CrouchWalking"))
            {
                //Time left on doubleclick cooldown means this button press is within time frame of a doubleclick.
                //PressedLeftAndReleased means button has been pressed once, this press is the doubleclick.
                if (leftDoubleClickCooldown > 0 && pressedLeftAndReleased && this.collisionDown)
                {
                    // If dashcooldown is below zero, do a dash, otherwise, do nothing and reset doubleclick cooldown.
                    if (leftDashCoolDown <= 0)
                    {
                        this.movementController.DashLeft();
                        pressedLeftAndReleased  = false;
                        pressedLeft             = false;
                        leftDoubleClickCooldown = 0.0f;
                        leftDashCoolDown        = 0.7f;
                    }
                    else
                    {
                        pressedLeft             = true;
                        leftDoubleClickCooldown = 0.0f;
                        this.movementController.MoveLeft();
                    }
                }
                else
                {
                    pressedLeft             = true;
                    leftDoubleClickCooldown = 0.5f;
                    this.movementController.MoveLeft();
                }
            }
            else if ((horizontal > 0 || horizontalJoystick > 0) && !this.isCrouching && !this.animator.GetBool("CrouchWalking"))
            {
                //Time left on doubleclick cooldown means this button press is within time frame of a doubleclick.
                //PressedRightAndReleased means button has been pressed once, this press is the doubleclick.
                if (rightDoubleClickCooldown > 0 && pressedRightAndReleased && this.collisionDown)
                {
                    // If dashcooldown is below zero, do a dash, otherwise, do nothing and reset doubleclick cooldown.
                    if (rightDashCoolDown <= 0)
                    {
                        this.movementController.DashRight();
                        pressedRightAndReleased  = false;
                        pressedRight             = false;
                        rightDoubleClickCooldown = 0.0f;
                        rightDashCoolDown        = 0.7f;
                    }
                    else
                    {
                        pressedRight             = true;
                        rightDoubleClickCooldown = 0.0f;
                        this.movementController.MoveRight();
                    }
                }
                else
                {
                    pressedRight             = true;
                    rightDoubleClickCooldown = 0.5f;
                    this.movementController.MoveRight();
                }
            }
            else if ((horizontal < 0 || horizontalJoystick < 0) && this.isCrouching)
            {
                this.movementController.CrouchLeft();
            }
            else if ((horizontal > 0 || horizontalJoystick > 0) && this.isCrouching)
            {
                this.movementController.CrouchRight();
            }
            else if (horizontal == 0 || horizontalJoystick == 0)
            {
                this.movementController.Stop();
            }

            if ((vertical > 0 || verticalJoystick < 0) && !movementController.isKnockedBack())
            {
                bool jumpSucessful = jumpController.Jump();

                //Only show jump animation if jump is successful.
                if (jumpSucessful)
                {
                    SetAnimatorBool("Crouching", false);
                    SetAnimatorBool("Jumping", true);
                    this.collisionDown = false;
                }
            }
            else if ((Mathf.Abs(horizontal) > 0 || Mathf.Abs(horizontalJoystick) > 0) && this.collisionDown && !this.isCrouching)
            {
                SetAnimatorBool("Running", true);
                this.isRunning = true;
            }
            else if ((Mathf.Abs(horizontal) > 0 || Mathf.Abs(horizontalJoystick) > 0) && this.collisionDown && this.isCrouching)
            {
                SetAnimatorBool("CrouchWalking", true);
                this.isRunning = true;
            }
            else if (vertical < 0 || verticalJoystick > 0)
            {
                SetAnimatorBool("Crouching", true);
                this.isCrouching = true;
            }

            if (this.collisionDown)             // If character touches the ground, it is not jumping.
            {
                SetAnimatorBool("Jumping", false);
                this.jumpController.jumping = false;
            }

            if (vertical == 0 && verticalJoystick == 0 && collisionDown)
            {
                SetAnimatorBool("CrouchWalking", false);
                SetAnimatorBool("Crouching", false);
                this.isCrouching = false;
            }

            if (Mathf.Abs(horizontal) == 0 && Mathf.Abs(horizontalJoystick) == 0)
            {
                SetAnimatorBool("Running", false);
                SetAnimatorBool("CrouchWalking", false);

                if (pressedLeft)
                {
                    pressedLeftAndReleased = true;
                    pressedLeft            = false;
                }

                if (pressedRight)
                {
                    pressedRightAndReleased = true;
                    pressedRight            = false;
                }
            }

            if (leftDoubleClickCooldown > 0)
            {
                leftDoubleClickCooldown -= 1 * Time.deltaTime;
            }
            else
            {
                pressedLeftAndReleased = false;
                pressedLeft            = false;
            }

            if (rightDoubleClickCooldown > 0)
            {
                rightDoubleClickCooldown -= 1 * Time.deltaTime;
            }
            else
            {
                pressedRightAndReleased = false;
                pressedRight            = false;
            }

            if (leftDashCoolDown > 0)
            {
                leftDashCoolDown -= 1 * Time.deltaTime;
            }
            if (rightDashCoolDown > 0)
            {
                rightDashCoolDown -= 1 * Time.deltaTime;
            }
        }
    }
Example #17
0
 List <KeyCode> GetInputKeys()
 {
     //return Enum.GetValues(typeof(KeyCode)).Cast<KeyCode>().ToList();
     return(InputSettings.GetAllKeyCodes());
 }
Example #18
0
 public void CalibrateClick()
 {
     InputSettings.Calibrate();
 }
Example #19
0
 internal InputManager(Window window, InputSettings settings)
 {
     _settings = settings;
     window.InputActionEvent += BufferInputActionEvent;
     window.InputAxisEvent   += BufferInputAxisEvent;
 }
Example #20
0
 /// <inheritdoc/>
 public IVirtualButton ToVirtual(InputSettings settings)
 {
     return(new VirtualButtonTwoWay(NegativeButton.ToVirtual(settings), PositiveButton.ToVirtual(settings)));
 }
 public ScheduleInputReader(IFileReader fileReader, InputSettings inputSettings)
 {
     _fileReader    = fileReader ?? throw new ArgumentNullException(nameof(fileReader));
     _inputSettings = inputSettings ?? throw new ArgumentNullException(nameof(inputSettings));
 }
Example #22
0
    public IEnumerator <WaitCommand> Load()
    {
        /* ======== Load Core ======= */

        {
            // Initialize the unity thread dispatcher on the unity thread
            var unityThreadDispatcher = UnityThreadDispatcher.Instance;
        }

        yield return(SceneManager.LoadSceneAsync("Core", LoadSceneMode.Additive).WaitUntilDone());

        var applicationLifeCycleEvents = new GameObject("ApplicationLifeCycleEvents")
                                         .AddComponent <ComponentLifecycleEvents>();

        ILock applicationLock = GameObject.Find("ApplicationQuitter").GetComponent <ApplicationQuitter>();

        // TODO This needs to move to somewhere inside a scene where we can turn it on/off
        var gameSettingsProvider = Object.FindObjectOfType <GameSettingsProvider>();

        gameSettingsProvider.UpdateGameSettings(GameSettings.ReadSettingsFromDisk());
        var userConfigurableSystems = Object.FindObjectOfType <UserConfigurableSystems>();
        var gameSettingsApplier     = new GameSettingsApplier(userConfigurableSystems);

        gameSettingsProvider.SettingChanges
        .Subscribe(settings => gameSettingsApplier.ApplySettings(settings, gameSettingsProvider.ActiveVrMode));
        gameSettingsProvider.SettingChanges
        .Select(gameSettings => gameSettings.Audio)
        .CombineLatest(FMODUtil.StudioSystem(), (audioSettings, fmodSystem) => audioSettings)
        .Subscribe(audioSettings => {
            gameSettingsApplier.ApplyAudioSettings(audioSettings);
        });

        // TODO This needs to move to somewhere inside a scene where we can turn it on/off
        gameSettingsProvider.SettingChanges
        .Skip(1)
        .Throttle(TimeSpan.FromSeconds(2), Scheduler.ThreadPool)
        .Select(gameSettings => new SerializeTask <GameSettings> {
            FilePath = GameSettings.UserSettingsConfigPath.Value, SerializableValue = gameSettings
        })
        .ObserveOn(Schedulers.FileWriterScheduler)
        .Subscribe(applicationLock.RunWithLock <SerializeTask <GameSettings> >(settingsConfig => {
            var gameSettings = settingsConfig.SerializableValue;
            gameSettings.Serialize2Disk(settingsConfig.FilePath);
        }));

        var inputSettings = gameSettingsProvider.SettingChanges
                            .Select(settings => InputSettings.FromGameSettings(settings.Input));
        var menuActionMapProvider      = Object.FindObjectOfType <MenuActionMapProvider>();
        var pilotActionMapProvider     = Object.FindObjectOfType <PilotActionMapProvider>();
        var parachuteActionMapProvider = Object.FindObjectOfType <ParachuteActionMapProvider>();
        JoystickActivator          joystickActivator = Object.FindObjectOfType <JoystickActivator>();
        InputBindings <MenuAction> menuInputBindings = new InputBindings <MenuAction>(
            MenuInput.Bindings.InitialMapping(),
            inputSettings,
            MenuInput.Bindings.DefaultControllerMappings.Value);
        InputBindings <WingsuitAction> pilotInputBindings = new InputBindings <WingsuitAction>(
            PilotInput.Bindings.InitialMapping(),
            inputSettings,
            PilotInput.Bindings.DefaultControllerMappings.Value);
        InputBindings <SpectatorAction> spectatorInputBindings = new InputBindings <SpectatorAction>(
            SpectatorInput.Bindings.InitialMapping(),
            inputSettings,
            SpectatorInput.Bindings.DefaultControllerMappings.Value);
        InputBindings <ParachuteAction> parachuteInputBindings = new InputBindings <ParachuteAction>(
            ParachuteControls.InitialMapping(),
            inputSettings,
            ParachuteControls.DefaultMappings.Value);

        joystickActivator.ActiveController.Subscribe(controllerId => {
            menuInputBindings.UpdateControllerId(controllerId);
            pilotInputBindings.UpdateControllerId(controllerId);
            spectatorInputBindings.UpdateControllerId(controllerId);
            parachuteInputBindings.UpdateControllerId(controllerId);
        });

        applicationLifeCycleEvents.OnDestroyEvent += () => {
            menuInputBindings.Dispose();
            pilotInputBindings.Dispose();
            parachuteInputBindings.Dispose();
            spectatorInputBindings.Dispose();
        };

        menuActionMapProvider.SetInputMappingSource(menuInputBindings.InputMappingChanges);
        parachuteActionMapProvider.SetInputMappingSource(parachuteInputBindings.InputMappingChanges);
        pilotActionMapProvider.SetInputMappingSource(pilotInputBindings.InputMappingChanges);
        // Spectator input
        var spectatorCamera = GameObject.Find("InGameSpectatorCamera")
                              .GetComponent <SpectatorCamera>();
        var menuClock = GameObject.Find("_RealtimeClock").GetComponent <AbstractUnityClock>();

        spectatorInputBindings.InputMappingChanges.Subscribe(actionMapConfig => {
            spectatorCamera.ActionMap = SpectatorInput.ActionMap.Create(actionMapConfig, menuClock);
        });

        // TODO Create serializer component and add it to the scene
        menuInputBindings.InputMappingChanges
        .Skip(1)
        .Select(
            actionMapConfig => new SerializeTask <InputSourceMapping <MenuAction> > {
            FilePath          = MenuInput.Bindings.CustomInputMappingFilePath.Value,
            SerializableValue = actionMapConfig.InputMapping
        })
        .ObserveOn(Schedulers.FileWriterScheduler)
        .Subscribe(applicationLock.RunWithLock <SerializeTask <InputSourceMapping <MenuAction> > >(mappingConfig => {
            mappingConfig.SerializableValue.Serialize2Disk(mappingConfig.FilePath);
        }));
        pilotInputBindings.InputMappingChanges
        .Skip(1)
        .Select(actionMapConfig => new SerializeTask <InputSourceMapping <WingsuitAction> > {
            FilePath          = PilotInput.Bindings.CustomInputMappingFilePath.Value,
            SerializableValue = actionMapConfig.InputMapping
        })
        .ObserveOn(Schedulers.FileWriterScheduler)
        .Subscribe(applicationLock.RunWithLock <SerializeTask <InputSourceMapping <WingsuitAction> > >(mappingConfig => {
            mappingConfig.SerializableValue.Serialize2Disk(mappingConfig.FilePath);
        }));
        spectatorInputBindings.InputMappingChanges
        .Skip(1)
        .Select(actionMapConfig => new SerializeTask <InputSourceMapping <SpectatorAction> > {
            FilePath          = SpectatorInput.Bindings.CustomInputMappingFilePath.Value,
            SerializableValue = actionMapConfig.InputMapping
        })
        .ObserveOn(Schedulers.FileWriterScheduler)
        .Subscribe(applicationLock.RunWithLock <SerializeTask <InputSourceMapping <SpectatorAction> > >(mappingConfig => {
            mappingConfig.SerializableValue.Serialize2Disk(mappingConfig.FilePath);
        }));
        parachuteInputBindings.InputMappingChanges
        .Skip(1)
        .Select(actionMapConfig => new SerializeTask <InputSourceMapping <ParachuteAction> > {
            FilePath          = ParachuteControls.CustomInputMappingFilePath.Value,
            SerializableValue = actionMapConfig.InputMapping
        })
        .ObserveOn(Schedulers.FileWriterScheduler)
        .Subscribe(applicationLock.RunWithLock <SerializeTask <InputSourceMapping <ParachuteAction> > >(mappingConfig => {
            mappingConfig.SerializableValue.Serialize2Disk(mappingConfig.FilePath);
        }));


        LoadVrConfig(gameSettingsProvider);

        var dependencyResolver = new GameObject("GlobalDependencyResolver").AddComponent <UnityDependencyResolver>();

        dependencyResolver.NonSerializableRefs.Add(new DependencyReference("fileWriterScheduler", Schedulers.FileWriterScheduler));
        dependencyResolver.NonSerializableRefs.Add(new DependencyReference("menuInputBindings", menuInputBindings));
        dependencyResolver.NonSerializableRefs.Add(new DependencyReference("pilotInputBindings", pilotInputBindings));
        dependencyResolver.NonSerializableRefs.Add(new DependencyReference("spectatorInputBindings", spectatorInputBindings));
        dependencyResolver.NonSerializableRefs.Add(new DependencyReference("parachuteInputBindings", parachuteInputBindings));
        dependencyResolver.Resolve();

        // Create and inject the player interface dynamically
        var cameraManager = Object.FindObjectOfType <CameraManager>();

        cameraManager.CreateCameraRig(gameSettingsProvider.ActiveVrMode, dependencyResolver.DependencyContainer);
        var canvasManager = Object.FindObjectOfType <UICanvasManager>();

        canvasManager.Initialize(cameraManager);

        if (gameSettingsProvider.ActiveVrMode == VrMode.Oculus)
        {
            new GameObject("__OculusGlobalEventEmitter").AddComponent <OculusGlobalEventEmitter>();
        }

        // Create a cursor
        var cursor = CreateCursor(gameSettingsProvider.ActiveVrMode, cameraManager.Rig.GetMainCamera());

        dependencyResolver.NonSerializableRefs.Add(new DependencyReference("cursor", cursor));
        var inputModule = GameObject.FindObjectOfType <CursorInputModule>();

        inputModule.Cursor           = cursor;
        inputModule.NavigationDevice = new MenuActionMapCursor(menuActionMapProvider);
        var raycasters = GameObject.FindObjectsOfType <PhysicsRayBasedRaycaster>();

        foreach (var raycaster in raycasters)
        {
            raycaster.SetCamera(cameraManager.Rig.GetMainCamera());
        }

        var hudPositioner = GameObject.Find("HUDElementPositioner").GetComponent <HudElementPositioner>();
        var hudElements   = Object.FindObjectsOfType <HudElement>();

        for (int i = 0; i < hudElements.Length; i++)
        {
            var hudElement = hudElements[i];
            hudPositioner.AddHudElement(hudElement);
        }

//        var courseManager = Object.FindObjectOfType<CourseManager>();
//        courseManager.CameraTransform = cameraManager.Rig.transform;

        var courseEditor = GameObject.Find("CourseEditor");

        courseEditor.SetActive(false);

        /* ======== Load Swiss Alps ======= */

        dependencyResolver.Resolve();

        yield return(SceneManager.LoadSceneAsync("SwissAlps", LoadSceneMode.Additive).WaitUntilDone());

        var windManager   = Object.FindObjectOfType <WindManager>();
        var windEffectors = Object.FindObjectsOfType <WindEffector>();

        for (int i = 0; i < windEffectors.Length; i++)
        {
            windEffectors[i].Manager = windManager;
        }

        var evts    = Object.FindObjectOfType <AbstractUnityEventSystem>();
        var turrets = Object.FindObjectsOfType <Turret>();

        for (int i = 0; i < turrets.Length; i++)
        {
            turrets[i].Initialize(evts);
        }

        dependencyResolver.Resolve();

        gameSettingsApplier.ApplySettings(gameSettingsProvider.ActiveSettings, gameSettingsProvider.ActiveVrMode);

        var optionsMenu = Object.FindObjectOfType <OptionsMenu>();

        optionsMenu.Initialize();

        var challengeManager = GameObject.FindObjectOfType <ChallengeManager>();

        challengeManager.Initialize();

        //        var networkConfig = GameObject.FindObjectOfType<NetworkConfig>();
        //        if (networkConfig.IsServer) {
        //            var server = GameObject.FindObjectOfType<VoloServer>();
        //            server.Host("Silly host name", networkConfig.ServerPort);
        //        }
        //        else {
        //            var client = GameObject.FindObjectOfType<VoloClient>();
        //            client.Join(new IPEndPoint(IPAddress.Parse("127.0.0.1"), networkConfig.ServerPort));
        //        }

        /* Clean up after ourselves, now's a good time */
        GC.Collect();
    }
Example #23
0
    void Update()
    {
        if (controlsActive)
        {
            bool vertical1Up             = Input.GetAxisRaw("Vertical") > 0 && selected;
            bool vertical1Down           = Input.GetAxisRaw("Vertical") < 0 && selected;
            bool vertical2Up             = Input.GetAxisRaw("Vertical2") > 0 && selected;
            bool vertical2Down           = Input.GetAxisRaw("Vertical2") < 0 && selected;
            bool verticalControllerUp    = Input.GetAxisRaw("VerticalJoystick") < 0 && selected;
            bool verticalControllerDown  = Input.GetAxisRaw("VerticalJoystick") > 0 && selected;
            bool verticalController2Up   = Input.GetAxisRaw("VerticalJoystick2") < 0 && selected;
            bool verticalController2Down = Input.GetAxisRaw("VerticalJoystick2") > 0 && selected;

            if (scrollDelay > 0)
            {
                scrollDelay -= Time.deltaTime;
            }
            else
            {
                if (scrollDelay <= 0 && listItems != null)
                {
                    if (vertical1Up || vertical2Up || verticalControllerUp || verticalController2Up)                       //Up pressed
                    {
                        scrollDelay = Parameters.scrollDelay;
                        bool movedOutOfTopPanels = selectedListIndex <= (nbrOfVisiblePanels / 2);
                        MoveSelection(-1);
                        bool movedIntoBotPanels = selectedListIndex >= listItems.Length - (nbrOfVisiblePanels / 2) - 1;
                        if (!movedOutOfTopPanels && !movedIntoBotPanels)
                        {
                            ScrollList(-1);
                        }
                    }
                    else if (vertical1Down || vertical2Down | verticalControllerDown || verticalController2Down)                         //Down pressed
                    {
                        scrollDelay = Parameters.scrollDelay;
                        bool movedOutOfBotPanels = selectedListIndex >= listItems.Length - (nbrOfVisiblePanels / 2) - 1;
                        MoveSelection(1);
                        bool moveIntoTopPanels = selectedListIndex <= nbrOfVisiblePanels / 2;
                        if (!moveIntoTopPanels && !movedOutOfBotPanels)
                        {
                            ScrollList(1);
                        }
                    }
                }

                if (vertical1Up || vertical1Down || verticalControllerUp || verticalControllerDown)
                {
                    PlayAnimation(1);
                }
                else if (vertical2Up || vertical2Down || verticalController2Down || verticalController2Up)
                {
                    PlayAnimation(2);
                }
            }

            bool startPressed      = Input.GetButtonDown("Controller1Button7") || Input.GetButtonDown("Controller2Button7");
            bool enterPressed      = Input.GetKeyDown(KeyCode.KeypadEnter) || Input.GetKeyDown(KeyCode.Return);
            bool playButtonPressed = startPressed || enterPressed;

            if (playButtonPressed && InputSettings.AllButtonsAssigned())
            {
                playTextBehaviour.SwitchScene("FightScene");
            }
            if (Input.GetKeyDown("delete") && selected)
            {
                ShowDeleteMovePanel();
            }
            if (Input.anyKeyDown && selected)
            {
                //Check if any button used in the game has been pressed.
                foreach (string button in InputSettings.allUsedButtons)
                {
                    try {
                        if (Input.GetKeyDown(button))
                        {
                            RegisterPlayerMoveToButton(button);
                        }
                    }
                    catch
                    {
                    }
                    try {
                        if (Input.GetButtonDown(button))
                        {
                            RegisterPlayerMoveToButton(button);
                        }
                    }
                    catch
                    {
                    }
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.Escape) || Input.GetButtonDown("Controller1Button1") || Input.GetButtonDown("Controller2Button1"))
        {
            controlsActive = true;
        }
    }
Example #24
0
 void Start()
 {
     InputSettings.setToDefault();
 }
Example #25
0
    void ReceiveInputSettings(string inputSettingsString)
    {
        InputSettings inputSettings = Jboy.Json.ReadObject <InputSettings>(inputSettingsString);

        inputManager.CopySettingsFrom(inputSettings);
    }
Example #26
0
 // Start is called before the first frame update
 void Start()
 {
     iset = GetComponent <InputSettings>();
     RefreshInputSettings();
 }
Example #27
0
 public override void Start()
 {
     _settings = InputSettings.Get(DataDir);
     InitializeHooks();
     InitializeInputProvider();
 }
Example #28
0
        public static void Update(Game game)
        {
            if (Orts.MultiPlayer.MPManager.IsMultiPlayer() && Orts.MultiPlayer.MPManager.Instance().ComposingText)
            {
                return;
            }
            if (InputSettings == null)
            {
                InputSettings = game.Settings.Input;
            }
            LastKeyboardState = KeyboardState;
            LastMouseState    = MouseState;
            // Make sure we have an "idle" (everything released) keyboard and mouse state if the window isn't active.
            KeyboardState       = game.IsActive ? new KeyboardState(GetKeysWithPrintScreenFix(Keyboard.GetState())) : new KeyboardState();
            MouseState          = game.IsActive ? Mouse.GetState() : new MouseState(0, 0, LastMouseState.ScrollWheelValue, ButtonState.Released, ButtonState.Released, ButtonState.Released, ButtonState.Released, ButtonState.Released);
            MouseButtonsSwapped = System.Windows.Forms.SystemInformation.MouseButtonsSwapped;

            MouseSpeedX = Math.Abs(MouseState.X - LastMouseState.X);
            MouseSpeedY = Math.Abs(MouseState.Y - LastMouseState.Y);

#if DEBUG_RAW_INPUT
            for (Keys key = 0; key <= Keys.OemClear; key++)
            {
                if (LastKeyboardState[key] != KeyboardState[key])
                {
                    Console.WriteLine("Keyboard {0} changed to {1}", key, KeyboardState[key]);
                }
            }
            if (LastMouseState.LeftButton != MouseState.LeftButton)
            {
                Console.WriteLine("Mouse left button changed to {0}", MouseState.LeftButton);
            }
            if (LastMouseState.MiddleButton != MouseState.MiddleButton)
            {
                Console.WriteLine("Mouse middle button changed to {0}", MouseState.MiddleButton);
            }
            if (LastMouseState.RightButton != MouseState.RightButton)
            {
                Console.WriteLine("Mouse right button changed to {0}", MouseState.RightButton);
            }
            if (LastMouseState.XButton1 != MouseState.XButton1)
            {
                Console.WriteLine("Mouse X1 button changed to {0}", MouseState.XButton1);
            }
            if (LastMouseState.XButton2 != MouseState.XButton2)
            {
                Console.WriteLine("Mouse X2 button changed to {0}", MouseState.XButton2);
            }
            if (LastMouseState.ScrollWheelValue != MouseState.ScrollWheelValue)
            {
                Console.WriteLine("Mouse scrollwheel changed by {0}", MouseState.ScrollWheelValue - LastMouseState.ScrollWheelValue);
            }
#endif
#if DEBUG_INPUT
            var newKeys = GetPressedKeys();
            var oldKeys = GetPreviousPressedKeys();
            foreach (var newKey in newKeys)
            {
                if (!oldKeys.Contains(newKey))
                {
                    Console.WriteLine("Keyboard {0} pressed", newKey);
                }
            }
            foreach (var oldKey in oldKeys)
            {
                if (!newKeys.Contains(oldKey))
                {
                    Console.WriteLine("Keyboard {0} released", oldKey);
                }
            }
            if (IsMouseLeftButtonPressed)
            {
                Console.WriteLine("Mouse left button pressed");
            }
            if (IsMouseLeftButtonReleased)
            {
                Console.WriteLine("Mouse left button released");
            }
            if (IsMouseMiddleButtonPressed)
            {
                Console.WriteLine("Mouse middle button pressed");
            }
            if (IsMouseMiddleButtonReleased)
            {
                Console.WriteLine("Mouse middle button released");
            }
            if (IsMouseRightButtonPressed)
            {
                Console.WriteLine("Mouse right button pressed");
            }
            if (IsMouseRightButtonReleased)
            {
                Console.WriteLine("Mouse right button released");
            }
            if (IsMouseWheelChanged)
            {
                Console.WriteLine("Mouse scrollwheel changed by {0}", MouseWheelChange);
            }
#endif
#if DEBUG_USER_INPUT
            foreach (UserCommand command in Enum.GetValues(typeof(UserCommand)))
            {
                if (UserInput.IsPressed(command))
                {
                    Console.WriteLine("Pressed  {0} - {1}", command, InputSettings.Commands[(int)command]);
                }
                if (UserInput.IsReleased(command))
                {
                    Console.WriteLine("Released {0} - {1}", command, InputSettings.Commands[(int)command]);
                }
            }
#endif
        }
Example #29
0
    /// <summary>
    /// Shows the or hide play button depending on wether all characters have registered all moves.
    /// </summary>
    private void ShowOrHideplayText()
    {
        bool showplayText = InputSettings.AllButtonsAssigned();

        playText.SetActive(showplayText);
    }
Example #30
0
        /// <summary>
        /// Creates the instance and initializes it from given xml element.
        /// This is the preferred way to instantiate Neural Preprocessor settings.
        /// </summary>
        /// <param name="elem">
        /// Xml data containing the settings.
        /// Content of xml element is always validated against the xml schema.
        /// </param>
        public NeuralPreprocessorSettings(XElement elem)
        {
            //Validation
            ElemValidator validator     = new ElemValidator();
            Assembly      assemblyRCNet = Assembly.GetExecutingAssembly();

            validator.AddXsdFromResources(assemblyRCNet, "RCNet.Neural.Network.SM.Preprocessing.NeuralPreprocessorSettings.xsd");
            validator.AddXsdFromResources(assemblyRCNet, "RCNet.RCNetTypes.xsd");
            XElement neuralPreprocessorSettingsElem = validator.Validate(elem, "rootElem");

            //Parsing
            //Input
            InputConfig = new InputSettings(neuralPreprocessorSettingsElem.Descendants("input").First());
            //Collect available reservoir settings
            List <ReservoirSettings> availableResSettings = new List <ReservoirSettings>();
            XElement reservoirSettingsContainerElem       = neuralPreprocessorSettingsElem.Descendants("reservoirCfgContainer").First();

            foreach (XElement reservoirSettingsElem in reservoirSettingsContainerElem.Descendants("reservoirCfg"))
            {
                availableResSettings.Add(new ReservoirSettings(reservoirSettingsElem));
            }
            //Mapping of input fields to reservoir settings (future reservoir instance)
            ReservoirInstanceDefinitionCollection = new List <ReservoirInstanceDefinition>();
            XElement reservoirInstancesContainerElem = neuralPreprocessorSettingsElem.Descendants("reservoirInstanceContainer").First();
            int      reservoirInstanceID             = 0;
            int      numOfNeuronsInLargestReservoir  = 0;

            foreach (XElement reservoirInstanceElem in reservoirInstancesContainerElem.Descendants("reservoirInstance"))
            {
                ReservoirInstanceDefinition reservoirInstanceDefinition = new ReservoirInstanceDefinition
                {
                    InstanceID   = reservoirInstanceID,
                    InstanceName = reservoirInstanceElem.Attribute("name").Value,
                    //Select reservoir settings
                    Settings = (from settings in availableResSettings
                                where settings.SettingsName == reservoirInstanceElem.Attribute("cfg").Value
                                select settings).FirstOrDefault(),
                    PredictorsCfg = new HiddenNeuronPredictorsSettings(reservoirInstanceElem.Descendants("predictors").First())
                };
                if (reservoirInstanceDefinition.Settings == null)
                {
                    throw new Exception($"Reservoir settings '{reservoirInstanceElem.Attribute("cfg").Value}' was not found among available settings.");
                }
                //Update number of neurons in the largest reservoir
                int numOfReservoirNeurons = 0;
                foreach (PoolSettings ps in reservoirInstanceDefinition.Settings.PoolSettingsCollection)
                {
                    numOfReservoirNeurons += ps.Dim.Size;
                }
                if (numOfNeuronsInLargestReservoir < numOfReservoirNeurons)
                {
                    numOfNeuronsInLargestReservoir = numOfReservoirNeurons;
                }

                //Distinct input field names and corresponding indexes using by the reservoir instance
                List <string> resInpFieldNameCollection = new List <string>();
                foreach (XElement inputFieldConnectionElem in reservoirInstanceElem.Descendants("inputConnections").First().Descendants("inputConnection"))
                {
                    //Input field name
                    string inputFieldName = inputFieldConnectionElem.Attribute("fieldName").Value;
                    //Index in InputConfig
                    int inputFieldIdx = InputConfig.IndexOf(inputFieldName);
                    //Found?
                    if (inputFieldIdx < 0)
                    {
                        //Not found
                        throw new Exception($"Reservoir instance {reservoirInstanceDefinition.InstanceName}: field name {inputFieldName} is not defined among input fields.");
                    }
                    //Add distinct name to the collection
                    if (resInpFieldNameCollection.IndexOf(inputFieldName) < 0)
                    {
                        reservoirInstanceDefinition.NPInputFieldIdxCollection.Add(inputFieldIdx);
                        resInpFieldNameCollection.Add(inputFieldName);
                    }
                }

                //Connections of the reservoir's input fields to the pools
                foreach (XElement inputConnectionElem in reservoirInstanceElem.Descendants("inputConnections").First().Descendants("inputConnection"))
                {
                    //Input field
                    string inputFieldName = inputConnectionElem.Attribute("fieldName").Value;
                    //Index in resInpFieldNameCollection
                    int resInputFieldIdx = resInpFieldNameCollection.IndexOf(inputFieldName);
                    //Found?
                    if (resInputFieldIdx < 0)
                    {
                        //Not found
                        throw new Exception($"Reservoir instance {reservoirInstanceDefinition.InstanceName}: input field {inputFieldName} is not defined among Reservoir's input fields.");
                    }
                    //Target pool
                    string targetPoolName = inputConnectionElem.Attribute("poolName").Value;
                    int    targetPoolID   = -1;
                    //Find target pool ID (index)
                    for (int idx = 0; idx < reservoirInstanceDefinition.Settings.PoolSettingsCollection.Count; idx++)
                    {
                        if (reservoirInstanceDefinition.Settings.PoolSettingsCollection[idx].Name == targetPoolName)
                        {
                            targetPoolID = idx;
                            break;
                        }
                    }
                    //Found?
                    if (targetPoolID < 0)
                    {
                        //Not found
                        throw new Exception($"Reservoir instance {reservoirInstanceDefinition.InstanceName}: pool {targetPoolName} is not defined among Reservoir pools.");
                    }
                    //Density
                    double density = double.Parse(inputConnectionElem.Attribute("density").Value, CultureInfo.InvariantCulture);
                    //Input synapse settings
                    InputSynapseSettings synapseCfg = new InputSynapseSettings(inputConnectionElem.Descendants("synapse").First());
                    //Add new assignment
                    reservoirInstanceDefinition.InputConnectionCollection.Add(new ReservoirInstanceDefinition.InputConnection(resInputFieldIdx, targetPoolID, density, synapseCfg));
                }
                ReservoirInstanceDefinitionCollection.Add(reservoirInstanceDefinition);
                ++reservoirInstanceID;
            }
            //Finalize boot cycles if necessary
            if (InputConfig.BootCycles == AutomaticBootCycles && InputConfig.FeedingType == NeuralPreprocessor.InputFeedingType.Continuous)
            {
                InputConfig.BootCycles = numOfNeuronsInLargestReservoir;
            }

            return;
        }
Example #31
0
    void Awake()
    {
        // Hack to initialize the thread dispatcher in the unity thread
        {
            var threadDispathcer = UnityThreadDispatcher.Instance;
        }

        var applicationLifeCycleEvents = new GameObject("ApplicationLifeCycleEvents")
                                         .AddComponent <ComponentLifecycleEvents>();

        _gameSettingsProvider.UpdateGameSettings(GameSettings.ReadSettingsFromDisk());
        var gameSettingsApplier = new GameSettingsApplier(_userConfigurableSystems);

        _gameSettingsProvider.SettingChanges
        .Subscribe(settings => gameSettingsApplier.ApplySettings(settings, _gameSettingsProvider.ActiveVrMode));
        _gameSettingsProvider.SettingChanges
        .Select(gameSettings => gameSettings.Audio)
        .CombineLatest(FMODUtil.StudioSystem(), (audioSettings, fmodSystem) => audioSettings)
        .Subscribe(audioSettings => {
            gameSettingsApplier.ApplyAudioSettings(audioSettings);
        });

        _gameSettingsProvider.SettingChanges
        .Skip(1)
        .Throttle(TimeSpan.FromSeconds(2), Scheduler.ThreadPool)
        .Select(gameSettings => new SerializeTask <GameSettings> {
            FilePath = GameSettings.UserSettingsConfigPath.Value, SerializableValue = gameSettings
        })
        .ObserveOn(Schedulers.FileWriterScheduler)
        .Subscribe(_quitter.RunWithLock <SerializeTask <GameSettings> >(settingsConfig => {
            var gameSettings = settingsConfig.SerializableValue;
            gameSettings.Serialize2Disk(settingsConfig.FilePath);
        }));

        var inputSettings = _gameSettingsProvider.SettingChanges
                            .Select(settings => InputSettings.FromGameSettings(settings.Input));
        InputBindings <MenuAction> menuInputBindings = new InputBindings <MenuAction>(
            MenuInput.Bindings.InitialMapping(),
            inputSettings,
            MenuInput.Bindings.DefaultControllerMappings.Value);
        InputBindings <WingsuitAction> pilotInputBindings = new InputBindings <WingsuitAction>(
            PilotInput.Bindings.InitialMapping(),
            inputSettings,
            PilotInput.Bindings.DefaultControllerMappings.Value);
        InputBindings <SpectatorAction> spectatorInputBindings = new InputBindings <SpectatorAction>(
            SpectatorInput.Bindings.InitialMapping(),
            inputSettings,
            SpectatorInput.Bindings.DefaultControllerMappings.Value);
        InputBindings <ParachuteAction> parachuteInputBindings = new InputBindings <ParachuteAction>(
            ParachuteControls.InitialMapping(),
            inputSettings,
            ParachuteControls.DefaultMappings.Value);

        _joystickActivator.ActiveController.Subscribe(controllerId => {
            menuInputBindings.UpdateControllerId(controllerId);
            pilotInputBindings.UpdateControllerId(controllerId);
            spectatorInputBindings.UpdateControllerId(controllerId);
            parachuteInputBindings.UpdateControllerId(controllerId);
        });

        // TODO Inject Inputbindings into options menu

        applicationLifeCycleEvents.OnDestroyEvent += () => {
            menuInputBindings.Dispose();
            parachuteInputBindings.Dispose();
            pilotInputBindings.Dispose();
            spectatorInputBindings.Dispose();
        };

        _menuActionMapProvider.SetInputMappingSource(menuInputBindings.InputMappingChanges);
        _pilotActionMapProvider.SetInputMappingSource(pilotInputBindings.InputMappingChanges);
        _parachuteActionMapProvider.SetInputMappingSource(parachuteInputBindings.InputMappingChanges);

        menuInputBindings.InputMappingChanges
        .Skip(1)
        .Select(actionMapConfig => new SerializeTask <InputSourceMapping <MenuAction> > {
            FilePath          = MenuInput.Bindings.CustomInputMappingFilePath.Value,
            SerializableValue = actionMapConfig.InputMapping
        })
        .ObserveOn(Schedulers.FileWriterScheduler)
        .Subscribe(_quitter.RunWithLock <SerializeTask <InputSourceMapping <MenuAction> > >(mappingConfig => {
            mappingConfig.SerializableValue.Serialize2Disk(mappingConfig.FilePath);
        }));
        pilotInputBindings.InputMappingChanges
        .Skip(1)
        .Select(actionMapConfig => new SerializeTask <InputSourceMapping <WingsuitAction> > {
            FilePath          = PilotInput.Bindings.CustomInputMappingFilePath.Value,
            SerializableValue = actionMapConfig.InputMapping
        })
        .ObserveOn(Schedulers.FileWriterScheduler)
        .Subscribe(_quitter.RunWithLock <SerializeTask <InputSourceMapping <WingsuitAction> > >(mappingConfig => {
            mappingConfig.SerializableValue.Serialize2Disk(mappingConfig.FilePath);
        }));
        spectatorInputBindings.InputMappingChanges
        .Skip(1)
        .Select(actionMapConfig => new SerializeTask <InputSourceMapping <SpectatorAction> > {
            FilePath          = SpectatorInput.Bindings.CustomInputMappingFilePath.Value,
            SerializableValue = actionMapConfig.InputMapping
        })
        .ObserveOn(Schedulers.FileWriterScheduler)
        .Subscribe(_quitter.RunWithLock <SerializeTask <InputSourceMapping <SpectatorAction> > >(mappingConfig => {
            mappingConfig.SerializableValue.Serialize2Disk(mappingConfig.FilePath);
        }));
        parachuteInputBindings.InputMappingChanges
        .Skip(1)
        .Select(actionMapConfig => new SerializeTask <InputSourceMapping <ParachuteAction> > {
            FilePath          = ParachuteControls.CustomInputMappingFilePath.Value,
            SerializableValue = actionMapConfig.InputMapping
        })
        .ObserveOn(Schedulers.FileWriterScheduler)
        .Subscribe(_quitter.RunWithLock <SerializeTask <InputSourceMapping <ParachuteAction> > >(mappingConfig => {
            mappingConfig.SerializableValue.Serialize2Disk(mappingConfig.FilePath);
        }));

        _optionsMenu.MenuInputBindings      = menuInputBindings;
        _optionsMenu.ParachuteInputBindings = parachuteInputBindings;
        _optionsMenu.PilotInputBindings     = pilotInputBindings;
        _optionsMenu.SpectatorInputBindings = spectatorInputBindings;
    }