mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-17 20:26:39 +00:00
Fixed duplicate controller names under Ava
This commit is contained in:
parent
dc3614248c
commit
6aaec6da5d
1 changed files with 21 additions and 9 deletions
|
@ -45,7 +45,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||||
|
|
||||||
private PlayerIndex _playerId;
|
private PlayerIndex _playerId;
|
||||||
private int _controller;
|
private int _controller;
|
||||||
private int _controllerNumber;
|
|
||||||
private string _controllerImage;
|
private string _controllerImage;
|
||||||
private int _device;
|
private int _device;
|
||||||
private object _configViewModel;
|
private object _configViewModel;
|
||||||
|
@ -439,6 +438,24 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||||
|
|
||||||
public void LoadDevices()
|
public void LoadDevices()
|
||||||
{
|
{
|
||||||
|
string GetGamepadName(IGamepad gamepad, int controllerNumber)
|
||||||
|
{
|
||||||
|
return $"{GetShortGamepadName(gamepad.Name)} ({controllerNumber})";
|
||||||
|
}
|
||||||
|
|
||||||
|
string GetUniqueGamepadName(IGamepad gamepad, ref int controllerNumber)
|
||||||
|
{
|
||||||
|
var name = GetGamepadName(gamepad, controllerNumber);
|
||||||
|
|
||||||
|
if (Devices.Any(controller => controller.Name == name))
|
||||||
|
{
|
||||||
|
controllerNumber++;
|
||||||
|
name = GetGamepadName(gamepad, controllerNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
lock (Devices)
|
lock (Devices)
|
||||||
{
|
{
|
||||||
Devices.Clear();
|
Devices.Clear();
|
||||||
|
@ -455,23 +472,18 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var controllerNumber = 0;
|
||||||
foreach (string id in _mainWindow.InputManager.GamepadDriver.GamepadsIds)
|
foreach (string id in _mainWindow.InputManager.GamepadDriver.GamepadsIds)
|
||||||
{
|
{
|
||||||
using IGamepad gamepad = _mainWindow.InputManager.GamepadDriver.GetGamepad(id);
|
using IGamepad gamepad = _mainWindow.InputManager.GamepadDriver.GetGamepad(id);
|
||||||
|
|
||||||
if (gamepad != null)
|
if (gamepad != null)
|
||||||
{
|
{
|
||||||
if (Devices.Any(controller => GetShortGamepadId(controller.Id) == GetShortGamepadId(gamepad.Id)))
|
var name = GetUniqueGamepadName(gamepad, ref controllerNumber);
|
||||||
{
|
Devices.Add((DeviceType.Controller, id, name));
|
||||||
_controllerNumber++;
|
|
||||||
}
|
|
||||||
|
|
||||||
Devices.Add((DeviceType.Controller, id, $"{GetShortGamepadName(gamepad.Name)} ({_controllerNumber})"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_controllerNumber = 0;
|
|
||||||
|
|
||||||
DeviceList.AddRange(Devices.Select(x => x.Name));
|
DeviceList.AddRange(Devices.Select(x => x.Name));
|
||||||
Device = Math.Min(Device, DeviceList.Count);
|
Device = Math.Min(Device, DeviceList.Count);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue