diff --git a/DS4Windows/DS4Windows.csproj b/DS4Windows/DS4Windows.csproj index 9dcfb9e..a69e73e 100644 --- a/DS4Windows/DS4Windows.csproj +++ b/DS4Windows/DS4Windows.csproj @@ -87,6 +87,7 @@ false prompt MinimumRecommendedRules.ruleset + PLATFORM_X64 true diff --git a/DS4Windows/HidLibrary/HidDevice.cs b/DS4Windows/HidLibrary/HidDevice.cs index 4f71cf1..fcf496e 100644 --- a/DS4Windows/HidLibrary/HidDevice.cs +++ b/DS4Windows/HidLibrary/HidDevice.cs @@ -492,7 +492,12 @@ namespace DS4Windows else { byte[] buffer = new byte[126]; - NativeMethods.HidD_GetSerialNumberString(safeReadHandle.DangerousGetHandle(), buffer, (ulong)buffer.Length); +#if PLATFORM_X64 + ulong bufferLen = 126; +#else + uint bufferLen = 126; +#endif + NativeMethods.HidD_GetSerialNumberString(safeReadHandle.DangerousGetHandle(), buffer, bufferLen); string MACAddr = System.Text.Encoding.Unicode.GetString(buffer).Replace("\0", string.Empty).ToUpper(); MACAddr = $"{MACAddr[0]}{MACAddr[1]}:{MACAddr[2]}{MACAddr[3]}:{MACAddr[4]}{MACAddr[5]}:{MACAddr[6]}{MACAddr[7]}:{MACAddr[8]}{MACAddr[9]}:{MACAddr[10]}{MACAddr[11]}"; serial = MACAddr; diff --git a/DS4Windows/HidLibrary/NativeMethods.cs b/DS4Windows/HidLibrary/NativeMethods.cs index 7af70cc..c6b30b9 100644 --- a/DS4Windows/HidLibrary/NativeMethods.cs +++ b/DS4Windows/HidLibrary/NativeMethods.cs @@ -391,7 +391,12 @@ namespace DS4Windows [DllImport("hid.dll")] static internal extern int HidP_GetValueCaps(short reportType, ref byte valueCaps, ref short valueCapsLength, IntPtr preparsedData); +#if PLATFORM_X64 [DllImport("hid.dll")] static internal extern bool HidD_GetSerialNumberString(IntPtr HidDeviceObject, byte[] Buffer, ulong BufferLength); +#else + [DllImport("hid.dll")] + static internal extern bool HidD_GetSerialNumberString(IntPtr HidDeviceObject, byte[] Buffer, uint BufferLength); +#endif } }