From cd4aa41a8f6890b957fc19b025c501196f97c32a Mon Sep 17 00:00:00 2001 From: Babib3l Date: Sat, 21 Mar 2026 17:55:04 +0100 Subject: [PATCH] Guard input profile loading when config is missing --- .../UI/ViewModels/Input/InputViewModel.cs | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs b/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs index 1ae54b325..30a1a94d7 100644 --- a/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs @@ -506,6 +506,23 @@ namespace Ryujinx.Ava.UI.ViewModels.Input return device.Id.Split(" ")[0]; } + private string GetCurrentConfigDeviceId() + { + if (_device < 0 || _device >= Devices.Count) + { + return null; + } + + (DeviceType Type, string Id, string Name) device = Devices[_device]; + + return device.Type switch + { + DeviceType.Keyboard => device.Id, + DeviceType.Controller => device.Id.Split(" ")[0], + _ => null, + }; + } + public void LoadControllers() { Controllers.Clear(); @@ -864,7 +881,14 @@ namespace Ryujinx.Ava.UI.ViewModels.Input { _isLoaded = false; - config.Id = Config.Id; // Set current device id instead of changing device(independent profiles) + string currentDeviceId = Config?.Id ?? GetCurrentConfigDeviceId(); + if (string.IsNullOrEmpty(currentDeviceId)) + { + Logger.Warning?.Print(LogClass.Configuration, $"Ignoring profile load for {ProfileName} because no active input device is selected."); + return; + } + + config.Id = currentDeviceId; // Set current device id instead of changing device(independent profiles) LoadConfiguration(config);