mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2026-05-25 10:02:25 +00:00
Guard input profile loading when config is missing
This commit is contained in:
parent
14ad72a0a8
commit
c03227814d
1 changed files with 25 additions and 1 deletions
|
|
@ -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();
|
||||
|
|
@ -865,7 +882,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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue