diff options
| -rw-r--r-- | Ryujinx.Common/Configuration/Hid/Controller/GenericControllerInputConfig.cs | 10 | ||||
| -rw-r--r-- | Ryujinx.Headless.SDL2/Program.cs | 14 | ||||
| -rw-r--r-- | Ryujinx.Input/HLE/NpadController.cs | 8 | ||||
| -rw-r--r-- | Ryujinx/Configuration/ConfigurationFileFormat.cs | 2 | ||||
| -rw-r--r-- | Ryujinx/Configuration/ConfigurationState.cs | 16 | ||||
| -rw-r--r-- | Ryujinx/Ui/Windows/ControllerWindow.cs | 23 | ||||
| -rw-r--r-- | Ryujinx/Ui/Windows/ControllerWindow.glade | 92 |
7 files changed, 160 insertions, 5 deletions
diff --git a/Ryujinx.Common/Configuration/Hid/Controller/GenericControllerInputConfig.cs b/Ryujinx.Common/Configuration/Hid/Controller/GenericControllerInputConfig.cs index 6c4562cf..aeb09c58 100644 --- a/Ryujinx.Common/Configuration/Hid/Controller/GenericControllerInputConfig.cs +++ b/Ryujinx.Common/Configuration/Hid/Controller/GenericControllerInputConfig.cs @@ -25,6 +25,16 @@ namespace Ryujinx.Common.Configuration.Hid.Controller public float DeadzoneRight { get; set; } /// <summary> + /// Controller Left Analog Stick Range + /// </summary> + public float RangeLeft { get; set; } + + /// <summary> + /// Controller Right Analog Stick Range + /// </summary> + public float RangeRight { get; set; } + + /// <summary> /// Controller Trigger Threshold /// </summary> public float TriggerThreshold { get; set; } diff --git a/Ryujinx.Headless.SDL2/Program.cs b/Ryujinx.Headless.SDL2/Program.cs index 2b169478..6e2172e3 100644 --- a/Ryujinx.Headless.SDL2/Program.cs +++ b/Ryujinx.Headless.SDL2/Program.cs @@ -196,6 +196,8 @@ namespace Ryujinx.Headless.SDL2 ControllerType = ControllerType.JoyconPair, DeadzoneLeft = 0.1f, DeadzoneRight = 0.1f, + RangeLeft = 1.0f, + RangeRight = 1.0f, TriggerThreshold = 0.5f, LeftJoycon = new LeftJoyconCommonConfig<ConfigGamepadInputId> { @@ -299,6 +301,18 @@ namespace Ryujinx.Headless.SDL2 Logger.Info?.Print(LogClass.Application, $"{config.PlayerIndex} configured with {inputTypeName} \"{config.Id}\""); + // If both stick ranges are 0 (usually indicative of an outdated profile load) then both sticks will be set to 1.0. + if (config is StandardControllerInputConfig controllerConfig) + { + if (controllerConfig.RangeLeft <= 0.0f && controllerConfig.RangeRight <= 0.0f) + { + controllerConfig.RangeLeft = 1.0f; + controllerConfig.RangeRight = 1.0f; + + Logger.Info?.Print(LogClass.Application, $"{config.PlayerIndex} stick range reset. Save the profile now to update your configuration"); + } + } + return config; } diff --git a/Ryujinx.Input/HLE/NpadController.cs b/Ryujinx.Input/HLE/NpadController.cs index 79c18ecf..2af114d2 100644 --- a/Ryujinx.Input/HLE/NpadController.cs +++ b/Ryujinx.Input/HLE/NpadController.cs @@ -381,8 +381,8 @@ namespace Ryujinx.Input.HLE (float leftAxisX, float leftAxisY) = State.GetStick(StickInputId.Left); (float rightAxisX, float rightAxisY) = State.GetStick(StickInputId.Right); - state.LStick = ClampToCircle(ApplyDeadzone(leftAxisX, leftAxisY, controllerConfig.DeadzoneLeft)); - state.RStick = ClampToCircle(ApplyDeadzone(rightAxisX, rightAxisY, controllerConfig.DeadzoneRight)); + state.LStick = ClampToCircle(ApplyDeadzone(leftAxisX, leftAxisY, controllerConfig.DeadzoneLeft), controllerConfig.RangeLeft); + state.RStick = ClampToCircle(ApplyDeadzone(rightAxisX, rightAxisY, controllerConfig.DeadzoneRight), controllerConfig.RangeRight); } return state; @@ -412,9 +412,9 @@ namespace Ryujinx.Input.HLE } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static JoystickPosition ClampToCircle(JoystickPosition position) + private static JoystickPosition ClampToCircle(JoystickPosition position, float range) { - Vector2 point = new Vector2(position.Dx, position.Dy); + Vector2 point = new Vector2(position.Dx, position.Dy) * range; if (point.Length() > short.MaxValue) { diff --git a/Ryujinx/Configuration/ConfigurationFileFormat.cs b/Ryujinx/Configuration/ConfigurationFileFormat.cs index b06e04e0..9eb11a9e 100644 --- a/Ryujinx/Configuration/ConfigurationFileFormat.cs +++ b/Ryujinx/Configuration/ConfigurationFileFormat.cs @@ -14,7 +14,7 @@ namespace Ryujinx.Configuration /// <summary> /// The current version of the file format /// </summary> - public const int CurrentVersion = 34; + public const int CurrentVersion = 35; /// <summary> /// Version of the configuration file format diff --git a/Ryujinx/Configuration/ConfigurationState.cs b/Ryujinx/Configuration/ConfigurationState.cs index 90fb3f6f..fdc28201 100644 --- a/Ryujinx/Configuration/ConfigurationState.cs +++ b/Ryujinx/Configuration/ConfigurationState.cs @@ -975,6 +975,22 @@ namespace Ryujinx.Configuration configurationFileUpdated = true; } + if (configurationFileFormat.Version < 35) + { + Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 35."); + + foreach (InputConfig config in configurationFileFormat.InputConfig) + { + if (config is StandardControllerInputConfig controllerConfig) + { + controllerConfig.RangeLeft = 1.0f; + controllerConfig.RangeRight = 1.0f; + } + } + + configurationFileUpdated = true; + } + Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog; Graphics.BackendThreading.Value = configurationFileFormat.BackendThreading; Graphics.ResScale.Value = configurationFileFormat.ResScale; diff --git a/Ryujinx/Ui/Windows/ControllerWindow.cs b/Ryujinx/Ui/Windows/ControllerWindow.cs index 4b7ca363..36a23326 100644 --- a/Ryujinx/Ui/Windows/ControllerWindow.cs +++ b/Ryujinx/Ui/Windows/ControllerWindow.cs @@ -38,6 +38,8 @@ namespace Ryujinx.Ui.Windows [GUI] Adjustment _controllerWeakRumble; [GUI] Adjustment _controllerDeadzoneLeft; [GUI] Adjustment _controllerDeadzoneRight; + [GUI] Adjustment _controllerRangeLeft; + [GUI] Adjustment _controllerRangeRight; [GUI] Adjustment _controllerTriggerThreshold; [GUI] Adjustment _slotNumber; [GUI] Adjustment _altSlotNumber; @@ -59,9 +61,11 @@ namespace Ryujinx.Ui.Windows [GUI] Grid _leftStickKeyboard; [GUI] Grid _leftStickController; [GUI] Box _deadZoneLeftBox; + [GUI] Box _rangeLeftBox; [GUI] Grid _rightStickKeyboard; [GUI] Grid _rightStickController; [GUI] Box _deadZoneRightBox; + [GUI] Box _rangeRightBox; [GUI] Grid _leftSideTriggerBox; [GUI] Grid _rightSideTriggerBox; [GUI] Box _triggerThresholdBox; @@ -316,6 +320,8 @@ namespace Ryujinx.Ui.Windows _rightStickController.Hide(); _deadZoneLeftBox.Hide(); _deadZoneRightBox.Hide(); + _rangeLeftBox.Hide(); + _rangeRightBox.Hide(); _triggerThresholdBox.Hide(); _motionBox.Hide(); _rumbleBox.Hide(); @@ -416,6 +422,8 @@ namespace Ryujinx.Ui.Windows _controllerWeakRumble.Value = 1; _controllerDeadzoneLeft.Value = 0; _controllerDeadzoneRight.Value = 0; + _controllerRangeLeft.Value = 1; + _controllerRangeRight.Value = 1; _controllerTriggerThreshold.Value = 0; _mirrorInput.Active = false; _enableMotion.Active = false; @@ -510,12 +518,23 @@ namespace Ryujinx.Ui.Windows _enableRumble.Active = controllerConfig.Rumble.EnableRumble; _controllerDeadzoneLeft.Value = controllerConfig.DeadzoneLeft; _controllerDeadzoneRight.Value = controllerConfig.DeadzoneRight; + _controllerRangeLeft.Value = controllerConfig.RangeLeft; + _controllerRangeRight.Value = controllerConfig.RangeRight; _controllerTriggerThreshold.Value = controllerConfig.TriggerThreshold; _sensitivity.Value = controllerConfig.Motion.Sensitivity; _gyroDeadzone.Value = controllerConfig.Motion.GyroDeadzone; _enableMotion.Active = controllerConfig.Motion.EnableMotion; _enableCemuHook.Active = controllerConfig.Motion.MotionBackend == MotionInputBackendType.CemuHook; + // If both stick ranges are 0 (usually indicative of an outdated profile load) then both sticks will be set to 1.0. + if (_controllerRangeLeft.Value <= 0.0 && _controllerRangeRight.Value <= 0.0) + { + _controllerRangeLeft.Value = 1.0; + _controllerRangeRight.Value = 1.0; + + Logger.Info?.Print(LogClass.Application, $"{config.PlayerIndex} stick range reset. Save the profile now to update your configuration"); + } + if (controllerConfig.Motion is CemuHookMotionConfigController cemuHookMotionConfig) { _slotNumber.Value = cemuHookMotionConfig.Slot; @@ -678,6 +697,8 @@ namespace Ryujinx.Ui.Windows PlayerIndex = _playerIndex, DeadzoneLeft = (float)_controllerDeadzoneLeft.Value, DeadzoneRight = (float)_controllerDeadzoneRight.Value, + RangeLeft = (float)_controllerRangeLeft.Value, + RangeRight = (float)_controllerRangeRight.Value, TriggerThreshold = (float)_controllerTriggerThreshold.Value, LeftJoycon = new LeftJoyconCommonConfig<ConfigGamepadInputId> { @@ -1013,6 +1034,8 @@ namespace Ryujinx.Ui.Windows ControllerType = ControllerType.JoyconPair, DeadzoneLeft = 0.1f, DeadzoneRight = 0.1f, + RangeLeft = 1.0f, + RangeRight = 1.0f, TriggerThreshold = 0.5f, LeftJoycon = new LeftJoyconCommonConfig<ConfigGamepadInputId> { diff --git a/Ryujinx/Ui/Windows/ControllerWindow.glade b/Ryujinx/Ui/Windows/ControllerWindow.glade index a396df03..ff4c7149 100644 --- a/Ryujinx/Ui/Windows/ControllerWindow.glade +++ b/Ryujinx/Ui/Windows/ControllerWindow.glade @@ -33,6 +33,18 @@ <property name="step_increment">0.01</property> <property name="page_increment">0.10000000000000001</property> </object> + <object class="GtkAdjustment" id="_controllerRangeLeft"> + <property name="upper">2</property> + <property name="value">1.000000000000000003</property> + <property name="step_increment">0.01</property> + <property name="page_increment">0.10000000000000001</property> + </object> + <object class="GtkAdjustment" id="_controllerRangeRight"> + <property name="upper">2</property> + <property name="value">1.000000000000000003</property> + <property name="step_increment">0.01</property> + <property name="page_increment">0.10000000000000001</property> + </object> <object class="GtkAdjustment" id="_controllerTriggerThreshold"> <property name="upper">1</property> <property name="value">0.5</property> @@ -775,6 +787,46 @@ <property name="position">4</property> </packing> </child> + <child> + <object class="GtkBox" id="_rangeLeftBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_top">10</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="label" translatable="yes">Range Left</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkScale"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="adjustment">_controllerRangeLeft</property> + <property name="round_digits">2</property> + <property name="digits">2</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">5</property> + </packing> + </child> </object> <packing> <property name="expand">False</property> @@ -1692,6 +1744,46 @@ <property name="position">4</property> </packing> </child> + <child> + <object class="GtkBox" id="_rangeRightBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_top">10</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="label" translatable="yes">Range Right</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkScale"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="adjustment">_controllerRangeRight</property> + <property name="round_digits">2</property> + <property name="digits">2</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">5</property> + </packing> + </child> </object> <packing> <property name="expand">False</property> |
