diff --git a/DS4Windows/App.xaml.cs b/DS4Windows/App.xaml.cs index 93bdbdd06d..2bd8ce495b 100644 --- a/DS4Windows/App.xaml.cs +++ b/DS4Windows/App.xaml.cs @@ -16,6 +16,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +using DS4Windows; using NLog; using System; using System.Collections.Generic; @@ -255,6 +256,22 @@ private void Application_Startup(object sender, StartupEventArgs e) rootHub.CheckHidHidePresence(); } + // Try loading custom devices from disk + CustomDeviceInfo[] customDevs = null; + if (File.Exists(DS4Devices.CustomDevicesJsonFilePath)) { + rootHub.LogDebug(DS4WinWPF.Translations.Strings.CustomDevices_Log_LoadingFile); + try { + customDevs = DS4Windows.DS4Devices.LoadCustomDevicesListFromDisk(); + } + catch { + rootHub.LogDebug(DS4WinWPF.Translations.Strings.CustomDevices_Log_LoadFail); + } + } + if(customDevs != null) { + DS4Devices.SetCustomDevices(customDevs); + } + + rootHub.LoadPermanentSlotsConfig(); window.LateChecks(parser); } diff --git a/DS4Windows/DS4Forms/ControllerRegisterOptionsWindow.xaml b/DS4Windows/DS4Forms/ControllerRegisterOptionsWindow.xaml index 062d5c33cd..aa0b188227 100644 --- a/DS4Windows/DS4Forms/ControllerRegisterOptionsWindow.xaml +++ b/DS4Windows/DS4Forms/ControllerRegisterOptionsWindow.xaml @@ -14,6 +14,8 @@ + + @@ -120,4 +122,11 @@ + + + + + + + diff --git a/DS4Windows/DS4Forms/Converters/HexToIntConverter.cs b/DS4Windows/DS4Forms/Converters/HexToIntConverter.cs new file mode 100644 index 0000000000..de3fdbc722 --- /dev/null +++ b/DS4Windows/DS4Forms/Converters/HexToIntConverter.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace DS4WinWPF.DS4Forms.Converters +{ + internal class HexToIntConverter : IValueConverter + { + // Convert int -> hex string + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is int intValue) + return intValue.ToString("X"); // uppercase hex (no "0x") + return "0"; + } + + // Convert hex string -> int + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is string s && int.TryParse(s, NumberStyles.HexNumber, culture, out int result)) + return result; + + // Optional: fallback to 0 or throw an exception + return 0; + } + } +} diff --git a/DS4Windows/DS4Forms/CustomDevicesEditor.xaml b/DS4Windows/DS4Forms/CustomDevicesEditor.xaml new file mode 100644 index 0000000000..c3e12f0dec --- /dev/null +++ b/DS4Windows/DS4Forms/CustomDevicesEditor.xaml @@ -0,0 +1,399 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +