public void InitDefaultSettings()
        {
            settings = new InputSettings();

            settings.MoveForwardMap =
                new AxisInputMap(
                    false,
                    new KeyboardAxisSource(MappableKeys.W, MappableKeys.S),
                    new XboxJoystickAxisSource(XboxJoystickAxis.LeftStickY)
                );

            settings.StrafeRightMap =
                new AxisInputMap(
                    false,
                    new KeyboardAxisSource(MappableKeys.D, MappableKeys.A),
                    new XboxJoystickAxisSource(XboxJoystickAxis.LeftStickX)
                );

            settings.RollLeftMap =
                new AxisInputMap(
                    false,
                    new KeyboardAxisSource(MappableKeys.Q, MappableKeys.E),
                    new XboxJoystickButtonAsAxisSource(XboxJoystickButtons.X, XboxJoystickButtons.B)
                );

            settings.StrafeUpMap =
                new AxisInputMap(
                    false,
                    new KeyboardAxisSource(MappableKeys.R, MappableKeys.F),
                    new XboxJoystickButtonAsAxisSource(XboxJoystickButtons.RightBumper, XboxJoystickButtons.LeftBumper)
                );

            settings.YawDeltaMap =
                new AxisInputMap(
                    false,
                    new MouseAxisSource(MouseAxis.Horizontal),
                    new XboxJoystickAxisSource(XboxJoystickAxis.RightStickX)
                );

            settings.PitchDeltaMap =
                new AxisInputMap(
                    true,
                    new MouseAxisSource(MouseAxis.Vertical),
                    new XboxJoystickAxisSource(XboxJoystickAxis.RightStickY)
                );

            settings.SelectPlasmaGunMap =
                new ButtonInputMap(
                    ButtonState.Down,
                    new KeyboardButtonSource(MappableKeys.Alpha1)
                );

            settings.SelectLaserMap =
                new ButtonInputMap(
                    ButtonState.Down,
                    new KeyboardButtonSource(MappableKeys.Alpha2)
                );

            settings.SelectUnguidedMissilesMap =
                new ButtonInputMap(
                    ButtonState.Down,
                    new KeyboardButtonSource(MappableKeys.Alpha3)
                );

            settings.SelectGuidedMissilesMap =
                new ButtonInputMap(
                    ButtonState.Down,
                    new KeyboardButtonSource(MappableKeys.Alpha4)
                );

            settings.CiclePrimaryWeaponMap =
                new ButtonInputMap(
                    ButtonState.Down,
                    new XboxJoystickDPadButtonSource(XboxJoystickDPad.Right)
                );

            settings.CicleSecondaryWeaponMap =
                new ButtonInputMap(
                    ButtonState.Down,
                    new XboxJoystickDPadButtonSource(XboxJoystickDPad.Left)
                );

            settings.ToggleAutoLevelMap =
                new ButtonInputMap(
                    ButtonState.Down,
                    new MouseButtonSource(MouseButton.Middle),
                    new XboxJoystickButtonSource(XboxJoystickButtons.A)
                );

            settings.ToggleHeadlightsMap =
                new ButtonInputMap(
                    ButtonState.Down,
                    new KeyboardButtonSource(MappableKeys.H),
                    new XboxJoystickButtonSource(XboxJoystickButtons.Y)
                );

            settings.PauseMap =
                new ButtonInputMap(
                    ButtonState.Down,
                    new KeyboardButtonSource(MappableKeys.Escape),
                    new XboxJoystickButtonSource(XboxJoystickButtons.Start)
                );

            settings.ShootPrimaryWeaponMap =
                new ButtonInputMap(
                    ButtonState.On,
                    new MouseButtonSource(MouseButton.Left),
                    new XboxJoystickAxisAsButtonSource(XboxJoystickAxis.RightTrigger)
                );

            settings.ShootSecondaryWeaponMap =
                new ButtonInputMap(
                    ButtonState.On,
                    new MouseButtonSource(MouseButton.Right),
                    new XboxJoystickAxisAsButtonSource(XboxJoystickAxis.LeftTrigger)
                );
        }
        public void Load()
        {
            try
            {
                var path = GetPersistenceFilePath();
                var contents = File.ReadAllText(path);
                settings = JsonConvert.DeserializeObject<InputSettings>(contents, new JsonSerializerSettings{ TypeNameHandling = TypeNameHandling.All });
                Debug.LogFormat("InputManager settings loaded from: {0}", path);
            }
            catch (Exception ex)
            {
                Debug.LogWarningFormat("InputManager loading error: {0}", ex.Message);

                InitDefaultSettings();
                Debug.LogWarning("InputManager using default settings.");
            }
        }
        public void InitDefaultSettings()
        {
            settings = new InputSettings();

            settings.MoveForwardMap =
                new AxisInputMap(
                    false,
                    new KeyboardAxisSource(MappableKeys.W, MappableKeys.S),
                    new XboxJoystickAxisSource(XboxJoystickAxis.LeftStickY)
                    );

            settings.StrafeRightMap =
                new AxisInputMap(
                    false,
                    new KeyboardAxisSource(MappableKeys.D, MappableKeys.A),
                    new XboxJoystickAxisSource(XboxJoystickAxis.LeftStickX)
                    );

            settings.RollLeftMap =
                new AxisInputMap(
                    false,
                    new KeyboardAxisSource(MappableKeys.Q, MappableKeys.E),
                    new XboxJoystickButtonAsAxisSource(XboxJoystickButtons.X, XboxJoystickButtons.B)
                    );

            settings.StrafeUpMap =
                new AxisInputMap(
                    false,
                    new KeyboardAxisSource(MappableKeys.R, MappableKeys.F),
                    new XboxJoystickButtonAsAxisSource(XboxJoystickButtons.RightBumper, XboxJoystickButtons.LeftBumper)
                    );

            settings.YawDeltaMap =
                new AxisInputMap(
                    false,
                    new MouseAxisSource(MouseAxis.Horizontal),
                    new XboxJoystickAxisSource(XboxJoystickAxis.RightStickX)
                    );

            settings.PitchDeltaMap =
                new AxisInputMap(
                    true,
                    new MouseAxisSource(MouseAxis.Vertical),
                    new XboxJoystickAxisSource(XboxJoystickAxis.RightStickY)
                    );

            settings.SelectPlasmaGunMap =
                new ButtonInputMap(
                    ButtonState.Down,
                    new KeyboardButtonSource(MappableKeys.Alpha1)
                    );

            settings.SelectLaserMap =
                new ButtonInputMap(
                    ButtonState.Down,
                    new KeyboardButtonSource(MappableKeys.Alpha2)
                    );

            settings.SelectUnguidedMissilesMap =
                new ButtonInputMap(
                    ButtonState.Down,
                    new KeyboardButtonSource(MappableKeys.Alpha3)
                    );

            settings.SelectGuidedMissilesMap =
                new ButtonInputMap(
                    ButtonState.Down,
                    new KeyboardButtonSource(MappableKeys.Alpha4)
                    );

            settings.CiclePrimaryWeaponMap =
                new ButtonInputMap(
                    ButtonState.Down,
                    new XboxJoystickDPadButtonSource(XboxJoystickDPad.Right)
                    );

            settings.CicleSecondaryWeaponMap =
                new ButtonInputMap(
                    ButtonState.Down,
                    new XboxJoystickDPadButtonSource(XboxJoystickDPad.Left)
                    );

            settings.ToggleAutoLevelMap =
                new ButtonInputMap(
                    ButtonState.Down,
                    new MouseButtonSource(MouseButton.Middle),
                    new XboxJoystickButtonSource(XboxJoystickButtons.A)
                    );

            settings.ToggleHeadlightsMap =
                new ButtonInputMap(
                    ButtonState.Down,
                    new KeyboardButtonSource(MappableKeys.H),
                    new XboxJoystickButtonSource(XboxJoystickButtons.Y)
                    );

            settings.PauseMap =
                new ButtonInputMap(
                    ButtonState.Down,
                    new KeyboardButtonSource(MappableKeys.Escape),
                    new XboxJoystickButtonSource(XboxJoystickButtons.Start)
                    );

            settings.ShootPrimaryWeaponMap =
                new ButtonInputMap(
                    ButtonState.On,
                    new MouseButtonSource(MouseButton.Left),
                    new XboxJoystickAxisAsButtonSource(XboxJoystickAxis.RightTrigger)
                    );

            settings.ShootSecondaryWeaponMap =
                new ButtonInputMap(
                    ButtonState.On,
                    new MouseButtonSource(MouseButton.Right),
                    new XboxJoystickAxisAsButtonSource(XboxJoystickAxis.LeftTrigger)
                    );
        }