diff --git a/src/Ryujinx.Common/Configuration/Hid/InputConfig.cs b/src/Ryujinx.Common/Configuration/Hid/InputConfig.cs index a93b721ad..ccf9ead16 100644 --- a/src/Ryujinx.Common/Configuration/Hid/InputConfig.cs +++ b/src/Ryujinx.Common/Configuration/Hid/InputConfig.cs @@ -21,6 +21,11 @@ namespace Ryujinx.Common.Configuration.Hid /// public string Id { get; set; } + /// + /// Controller name + /// + public string Name { get; set; } + /// /// Controller's Type /// diff --git a/src/Ryujinx/Assets/locales.json b/src/Ryujinx/Assets/locales.json index eebd33ac6..a65af3b31 100644 --- a/src/Ryujinx/Assets/locales.json +++ b/src/Ryujinx/Assets/locales.json @@ -6922,6 +6922,31 @@ "zh_TW": "輸入裝置" } }, + { + "ID": "ControllerSettingsWaitingConnectDevice", + "Translations": { + "ar_SA": "", + "de_DE": "", + "el_GR": "", + "en_US": "Configuration found:\n\nName:\t{0}\nGUID:\t{1}\n\n Waiting for controller connection...", + "es_ES": "", + "fr_FR": "", + "he_IL": "", + "it_IT": "", + "ja_JP": "", + "ko_KR": "", + "no_NO": "", + "pl_PL": "", + "pt_BR": "", + "ru_RU": "", + "sv_SE": "", + "th_TH": "", + "tr_TR": "", + "uk_UA": "", + "zh_CN": "", + "zh_TW": "" + } + }, { "ID": "ControllerSettingsRefresh", "Translations": { @@ -24473,4 +24498,4 @@ } } ] -} +} \ No newline at end of file diff --git a/src/Ryujinx/Systems/Configuration/ConfigurationState.cs b/src/Ryujinx/Systems/Configuration/ConfigurationState.cs index 6fe35c744..b30c43224 100644 --- a/src/Ryujinx/Systems/Configuration/ConfigurationState.cs +++ b/src/Ryujinx/Systems/Configuration/ConfigurationState.cs @@ -269,6 +269,7 @@ namespace Ryujinx.Ava.Systems.Configuration Version = InputConfig.CurrentVersion, Backend = InputBackendType.WindowKeyboard, Id = "0", + Name = "Keyboard", PlayerIndex = PlayerIndex.Player1, ControllerType = ControllerType.ProController, LeftJoycon = new LeftJoyconCommonConfig diff --git a/src/Ryujinx/UI/Models/Input/GamepadInputConfig.cs b/src/Ryujinx/UI/Models/Input/GamepadInputConfig.cs index 300d7977c..5ebfe4654 100644 --- a/src/Ryujinx/UI/Models/Input/GamepadInputConfig.cs +++ b/src/Ryujinx/UI/Models/Input/GamepadInputConfig.cs @@ -22,6 +22,8 @@ namespace Ryujinx.Ava.UI.Models.Input public float StrongRumble { get; set; } public string Id { get; set; } + + public string Name { get; set; } public ControllerType ControllerType { get; set; } public PlayerIndex PlayerIndex { get; set; } @@ -111,6 +113,7 @@ namespace Ryujinx.Ava.UI.Models.Input if (config != null) { Id = config.Id; + Name = config.Name; ControllerType = config.ControllerType; PlayerIndex = config.PlayerIndex; @@ -201,6 +204,7 @@ namespace Ryujinx.Ava.UI.Models.Input StandardControllerInputConfig config = new() { Id = Id, + Name = Name, Backend = InputBackendType.GamepadSDL2, PlayerIndex = PlayerIndex, ControllerType = ControllerType, diff --git a/src/Ryujinx/UI/Models/Input/KeyboardInputConfig.cs b/src/Ryujinx/UI/Models/Input/KeyboardInputConfig.cs index 2d2e95773..a115aa0f2 100644 --- a/src/Ryujinx/UI/Models/Input/KeyboardInputConfig.cs +++ b/src/Ryujinx/UI/Models/Input/KeyboardInputConfig.cs @@ -2,12 +2,14 @@ using CommunityToolkit.Mvvm.ComponentModel; using Ryujinx.Ava.UI.ViewModels; using Ryujinx.Common.Configuration.Hid; using Ryujinx.Common.Configuration.Hid.Keyboard; +using System.Xml.Linq; namespace Ryujinx.Ava.UI.Models.Input { public partial class KeyboardInputConfig : BaseModel { public string Id { get; set; } + public string Name { get; set; } public ControllerType ControllerType { get; set; } public PlayerIndex PlayerIndex { get; set; } @@ -53,6 +55,7 @@ namespace Ryujinx.Ava.UI.Models.Input if (config != null) { Id = config.Id; + Name = config.Name; ControllerType = config.ControllerType; PlayerIndex = config.PlayerIndex; @@ -100,6 +103,7 @@ namespace Ryujinx.Ava.UI.Models.Input StandardKeyboardInputConfig config = new() { Id = Id, + Name = Name, Backend = InputBackendType.WindowKeyboard, PlayerIndex = PlayerIndex, ControllerType = ControllerType, diff --git a/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs b/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs index 52f538a1a..be50113b6 100644 --- a/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs @@ -51,6 +51,8 @@ namespace Ryujinx.Ava.UI.ViewModels.Input private int _device; private object _configViewModel; [ObservableProperty] private string _profileName; + [ObservableProperty] private bool _notificationIsVisible; // Automatically call the NotificationView property with OnPropertyChanged() + [ObservableProperty] private string _notificationText; // Automatically call the NotificationText property with OnPropertyChanged() private bool _isLoaded; private static readonly InputConfigJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions()); @@ -95,6 +97,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input public bool _isChangeTrackingActive; public bool _isModified; + public bool IsModified { get => _isModified; @@ -107,7 +110,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Input public event Action NotifyChangesEvent; - public string _profileChoose; public string ProfileChoose { @@ -288,18 +290,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Input public InputConfig Config { get; set; } - public bool _notificationView; - - public bool NotificationView - { - get => _notificationView; - set - { - _notificationView = value; - OnPropertyChanged(); - } - } - public InputViewModel(UserControl owner) : this() { if (Program.PreviewerDetached) @@ -367,7 +357,18 @@ namespace Ryujinx.Ava.UI.ViewModels.Input // This function allows you to output a message about the device configuration found in the file // NOTE: if the configuration is found, we display the message "Waiting for controller connection", // but only if the id gamepad belongs to the selected player - NotificationView = Config != null && Devices.FirstOrDefault(d => d.Id == Config.Id).Id != Config.Id && Config.PlayerIndex == PlayerId; + NotificationIsVisible = Config != null && Devices.FirstOrDefault(d => d.Id == Config.Id).Id != Config.Id && Config.PlayerIndex == PlayerId; + if (NotificationIsVisible) + { + if (string.IsNullOrEmpty(Config.Name)) + { + NotificationText = $"{LocaleManager.Instance[LocaleKeys.ControllerSettingsWaitingConnectDevice].Format("No information", Config.Id)}"; + } + else + { + NotificationText = $"{LocaleManager.Instance[LocaleKeys.ControllerSettingsWaitingConnectDevice].Format(Config.Name, Config.Id)}"; + } + } } @@ -386,7 +387,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input { // "Disabled" mode is available after unbinding the device // NOTE: the IsModified flag to be able to apply the settings. - NotificationView = false; + NotificationIsVisible = false; IsModified = true; } @@ -656,12 +657,14 @@ namespace Ryujinx.Ava.UI.ViewModels.Input if (activeDevice.Type == DeviceType.Keyboard) { string id = activeDevice.Id; + string name = activeDevice.Name; config = new StandardKeyboardInputConfig { Version = InputConfig.CurrentVersion, Backend = InputBackendType.WindowKeyboard, Id = id, + Name = name, ControllerType = ControllerType.ProController, LeftJoycon = new LeftJoyconCommonConfig { @@ -711,12 +714,14 @@ namespace Ryujinx.Ava.UI.ViewModels.Input bool isNintendoStyle = Devices.ToList().FirstOrDefault(x => x.Id == activeDevice.Id).Name.Contains("Nintendo"); string id = activeDevice.Id.Split(" ")[0]; + string name = activeDevice.Name; config = new StandardControllerInputConfig { Version = InputConfig.CurrentVersion, Backend = InputBackendType.GamepadSDL2, Id = id, + Name = name, ControllerType = ControllerType.ProController, DeadzoneLeft = 0.1f, DeadzoneRight = 0.1f, @@ -991,6 +996,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input : (ConfigViewModel as ControllerInputViewModel).Config.GetConfig(); config.ControllerType = Controllers[_controller].Type; config.PlayerIndex = _playerId; + config.Name = device.Name; int i = newConfig.FindIndex(x => x.PlayerIndex == PlayerId); if (i == -1) diff --git a/src/Ryujinx/UI/Views/Input/InputView.axaml b/src/Ryujinx/UI/Views/Input/InputView.axaml index 4e695afeb..13c0df768 100644 --- a/src/Ryujinx/UI/Views/Input/InputView.axaml +++ b/src/Ryujinx/UI/Views/Input/InputView.axaml @@ -201,17 +201,18 @@ - + + + Text="{Binding NotificationText}" />