Guard input profile loading when config is missing

This commit is contained in:
Babib3l
2026-03-21 17:55:04 +01:00
parent 3cbe372b18
commit cd4aa41a8f

View File

@@ -506,6 +506,23 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
return device.Id.Split(" ")[0]; 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() public void LoadControllers()
{ {
Controllers.Clear(); Controllers.Clear();
@@ -864,7 +881,14 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
{ {
_isLoaded = false; _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); LoadConfiguration(config);