Get rid of debug error for x86 build

Related to issue #140. Not a great workaround
This commit is contained in:
Travis Nickles 2017-11-17 01:33:24 -06:00
parent 941479c593
commit 09a7cd8288
3 changed files with 12 additions and 1 deletions

View File

@ -87,6 +87,7 @@
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<DefineConstants>PLATFORM_X64</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>

View File

@ -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;

View File

@ -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
}
}