Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions DS4Windows/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

using DS4Windows;
using NLog;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -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);
}
Expand Down
9 changes: 9 additions & 0 deletions DS4Windows/DS4Forms/ControllerRegisterOptionsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<Window.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
</Window.Resources>
<TabControl>
<TabItem Header="General">
<DockPanel x:Name="devOptionsDockPanel" Margin="4">
<DockPanel>
<StackPanel DockPanel.Dock="Top">
Expand Down Expand Up @@ -120,4 +122,11 @@
</TabItem>
</TabControl>
</DockPanel>
</TabItem>
<TabItem Header="Custom Supported Devices">
<local:CustomDevicesEditor />
</TabItem>

</TabControl>

</Window>
31 changes: 31 additions & 0 deletions DS4Windows/DS4Forms/Converters/HexToIntConverter.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
Loading