From bccf5e8b5a8f3870dbf03bedb0eb46b85b78d5f4 Mon Sep 17 00:00:00 2001 From: Emmanuel Hansen Date: Fri, 8 Jul 2022 18:28:45 +0000 Subject: [PATCH] Avalonia - Use loaded config when assigning controller input (#3447) * Use loaded config when assigning controller input * Fix crash when switch player in controller window --- Ryujinx.Ava/Ui/Windows/ControllerSettingsWindow.axaml.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Ryujinx.Ava/Ui/Windows/ControllerSettingsWindow.axaml.cs b/Ryujinx.Ava/Ui/Windows/ControllerSettingsWindow.axaml.cs index 4ebf04ae4b..0321359963 100644 --- a/Ryujinx.Ava/Ui/Windows/ControllerSettingsWindow.axaml.cs +++ b/Ryujinx.Ava/Ui/Windows/ControllerSettingsWindow.axaml.cs @@ -8,6 +8,7 @@ using Avalonia.Threading; using Avalonia.VisualTree; using Ryujinx.Ava.Common.Locale; using Ryujinx.Ava.Ui.Controls; +using Ryujinx.Ava.Ui.Models; using Ryujinx.Ava.Ui.ViewModels; using Ryujinx.Common.Configuration.Hid; using Ryujinx.Common.Configuration.Hid.Controller; @@ -127,9 +128,7 @@ namespace Ryujinx.Ava.Ui.Windows } else if (device.Type == Models.DeviceType.Controller) { - InputConfig config = ConfigurationState.Instance.Hid.InputConfig.Value.Find(inputConfig => inputConfig.Id == ViewModel.SelectedGamepad.Id); - - assigner = new GamepadButtonAssigner(ViewModel.SelectedGamepad, (config as StandardControllerInputConfig).TriggerThreshold, forStick); + assigner = new GamepadButtonAssigner(ViewModel.SelectedGamepad, (ViewModel.Config as StandardControllerInputConfig).TriggerThreshold, forStick); } else { @@ -184,8 +183,8 @@ namespace Ryujinx.Ava.Ui.Windows if (e.AddedItems.Count > 0) { - (PlayerIndex key, _) = (KeyValuePair)e.AddedItems[0]; - ViewModel.PlayerId = key; + var player = (PlayerModel)e.AddedItems[0]; + ViewModel.PlayerId = player.Id; } } }