mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-24 23:11:14 +01:00
msvc: enable strictStrings solution-wide for release.
strictStrings is not supported by debug libraries, and indeed breaks the build. Drop wbemidl.h (incompatible with strictStrings) dependency by using SDL-style search for XInput GUIDs.
This commit is contained in:
parent
a09cf1d8f1
commit
9df2127865
@ -5,7 +5,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <wbemidl.h>
|
|
||||||
|
|
||||||
#include "InputCommon/ControllerInterface/DInput/DInput.h"
|
#include "InputCommon/ControllerInterface/DInput/DInput.h"
|
||||||
#include "InputCommon/ControllerInterface/DInput/DInputJoystick.h"
|
#include "InputCommon/ControllerInterface/DInput/DInputJoystick.h"
|
||||||
@ -17,109 +16,14 @@ namespace DInput
|
|||||||
|
|
||||||
#define DATA_BUFFER_SIZE 32
|
#define DATA_BUFFER_SIZE 32
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
static const GUID s_known_xinput_guids[] = {
|
||||||
// Modified some MSDN code to get all the XInput device GUID.Data1 values in a vector,
|
// ValveStreamingGamepad
|
||||||
// faster than checking all the devices for each DirectInput device, like MSDN says to do
|
{ MAKELONG(0x28DE, 0x11FF), 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } },
|
||||||
//-----------------------------------------------------------------------------
|
// IID_X360WiredGamepad
|
||||||
void GetXInputGUIDS( std::vector<DWORD>& guids )
|
{ MAKELONG(0x045E, 0x02A1), 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } },
|
||||||
{
|
// IID_X360WirelessGamepad
|
||||||
|
{ MAKELONG(0x045E, 0x028E), 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } },
|
||||||
#define SAFE_RELEASE(p) { if (p) { (p)->Release(); (p)=nullptr; } }
|
};
|
||||||
|
|
||||||
IWbemLocator* pIWbemLocator = nullptr;
|
|
||||||
IEnumWbemClassObject* pEnumDevices = nullptr;
|
|
||||||
IWbemClassObject* pDevices[20] = {0};
|
|
||||||
IWbemServices* pIWbemServices = nullptr;
|
|
||||||
BSTR bstrNamespace = nullptr;
|
|
||||||
BSTR bstrDeviceID = nullptr;
|
|
||||||
BSTR bstrClassName = nullptr;
|
|
||||||
DWORD uReturned = 0;
|
|
||||||
VARIANT var;
|
|
||||||
HRESULT hr;
|
|
||||||
|
|
||||||
// CoInit if needed
|
|
||||||
hr = CoInitialize(nullptr);
|
|
||||||
bool bCleanupCOM = SUCCEEDED(hr);
|
|
||||||
|
|
||||||
// Create WMI
|
|
||||||
hr = CoCreateInstance(__uuidof(WbemLocator),
|
|
||||||
nullptr,
|
|
||||||
CLSCTX_INPROC_SERVER,
|
|
||||||
__uuidof(IWbemLocator),
|
|
||||||
(LPVOID*) &pIWbemLocator);
|
|
||||||
if (FAILED(hr) || pIWbemLocator == nullptr)
|
|
||||||
goto LCleanup;
|
|
||||||
|
|
||||||
bstrNamespace = SysAllocString(L"\\\\.\\root\\cimv2"); if (bstrNamespace == nullptr) goto LCleanup;
|
|
||||||
bstrClassName = SysAllocString(L"Win32_PNPEntity"); if (bstrClassName == nullptr) goto LCleanup;
|
|
||||||
bstrDeviceID = SysAllocString(L"DeviceID"); if (bstrDeviceID == nullptr) goto LCleanup;
|
|
||||||
|
|
||||||
// Connect to WMI
|
|
||||||
hr = pIWbemLocator->ConnectServer(bstrNamespace, nullptr, nullptr, 0L, 0L, nullptr, nullptr, &pIWbemServices);
|
|
||||||
if (FAILED(hr) || pIWbemServices == nullptr)
|
|
||||||
goto LCleanup;
|
|
||||||
|
|
||||||
// Switch security level to IMPERSONATE.
|
|
||||||
CoSetProxyBlanket(pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, nullptr,
|
|
||||||
RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, nullptr, EOAC_NONE);
|
|
||||||
|
|
||||||
hr = pIWbemServices->CreateInstanceEnum(bstrClassName, 0, nullptr, &pEnumDevices);
|
|
||||||
if (FAILED(hr) || pEnumDevices == nullptr)
|
|
||||||
goto LCleanup;
|
|
||||||
|
|
||||||
// Loop over all devices
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
// Get 20 at a time
|
|
||||||
hr = pEnumDevices->Next(10000, 20, pDevices, &uReturned);
|
|
||||||
if (FAILED(hr) || uReturned == 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
for (UINT iDevice = 0; iDevice < uReturned; ++iDevice)
|
|
||||||
{
|
|
||||||
// For each device, get its device ID
|
|
||||||
hr = pDevices[iDevice]->Get(bstrDeviceID, 0L, &var, nullptr, nullptr);
|
|
||||||
if (SUCCEEDED(hr) && var.vt == VT_BSTR && var.bstrVal != nullptr)
|
|
||||||
{
|
|
||||||
// Check if the device ID contains "IG_". If it does, then it's an XInput device
|
|
||||||
// This information can not be found from DirectInput
|
|
||||||
if (wcsstr(var.bstrVal, L"IG_"))
|
|
||||||
{
|
|
||||||
// If it does, then get the VID/PID from var.bstrVal
|
|
||||||
DWORD dwPid = 0, dwVid = 0;
|
|
||||||
WCHAR* strVid = wcsstr(var.bstrVal, L"VID_");
|
|
||||||
if (strVid && swscanf(strVid, L"VID_%4X", &dwVid) != 1)
|
|
||||||
dwVid = 0;
|
|
||||||
WCHAR* strPid = wcsstr(var.bstrVal, L"PID_");
|
|
||||||
if (strPid && swscanf(strPid, L"PID_%4X", &dwPid) != 1)
|
|
||||||
dwPid = 0;
|
|
||||||
|
|
||||||
// Compare the VID/PID to the DInput device
|
|
||||||
DWORD dwVidPid = MAKELONG(dwVid, dwPid);
|
|
||||||
guids.push_back(dwVidPid);
|
|
||||||
//bIsXinputDevice = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SAFE_RELEASE(pDevices[iDevice]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LCleanup:
|
|
||||||
if (bstrNamespace)
|
|
||||||
SysFreeString(bstrNamespace);
|
|
||||||
if (bstrDeviceID)
|
|
||||||
SysFreeString(bstrDeviceID);
|
|
||||||
if (bstrClassName)
|
|
||||||
SysFreeString(bstrClassName);
|
|
||||||
for (UINT iDevice = 0; iDevice < 20; iDevice++)
|
|
||||||
SAFE_RELEASE(pDevices[iDevice]);
|
|
||||||
SAFE_RELEASE(pEnumDevices);
|
|
||||||
SAFE_RELEASE(pIWbemLocator);
|
|
||||||
SAFE_RELEASE(pIWbemServices);
|
|
||||||
|
|
||||||
if (bCleanupCOM)
|
|
||||||
CoUninitialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
void InitJoystick(IDirectInput8* const idi8, std::vector<Core::Device*>& devices, HWND hwnd)
|
void InitJoystick(IDirectInput8* const idi8, std::vector<Core::Device*>& devices, HWND hwnd)
|
||||||
{
|
{
|
||||||
@ -130,14 +34,14 @@ void InitJoystick(IDirectInput8* const idi8, std::vector<Core::Device*>& devices
|
|||||||
// multiple joysticks with the same name shall get unique ids starting at 0
|
// multiple joysticks with the same name shall get unique ids starting at 0
|
||||||
std::map< std::basic_string<TCHAR>, int> name_counts;
|
std::map< std::basic_string<TCHAR>, int> name_counts;
|
||||||
|
|
||||||
std::vector<DWORD> xinput_guids;
|
|
||||||
GetXInputGUIDS( xinput_guids );
|
|
||||||
|
|
||||||
for (DIDEVICEINSTANCE& joystick : joysticks)
|
for (DIDEVICEINSTANCE& joystick : joysticks)
|
||||||
{
|
{
|
||||||
// skip XInput Devices
|
// skip XInput Devices
|
||||||
if (std::find(xinput_guids.begin(), xinput_guids.end(), joystick.guidProduct.Data1) != xinput_guids.end())
|
if (std::find(std::begin(s_known_xinput_guids), std::end(s_known_xinput_guids),
|
||||||
|
joystick.guidProduct) != std::end(s_known_xinput_guids))
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
LPDIRECTINPUTDEVICE8 js_device;
|
LPDIRECTINPUTDEVICE8 js_device;
|
||||||
if (SUCCEEDED(idi8->CreateDevice(joystick.guidInstance, &js_device, nullptr)))
|
if (SUCCEEDED(idi8->CreateDevice(joystick.guidInstance, &js_device, nullptr)))
|
||||||
@ -248,7 +152,7 @@ Joystick::Joystick( /*const LPCDIDEVICEINSTANCE lpddi, */const LPDIRECTINPUTDEVI
|
|||||||
std::list<DIDEVICEOBJECTINSTANCE> objects;
|
std::list<DIDEVICEOBJECTINSTANCE> objects;
|
||||||
if (SUCCEEDED(m_device->EnumObjects(DIEnumDeviceObjectsCallback, (LPVOID)&objects, DIDFT_AXIS)))
|
if (SUCCEEDED(m_device->EnumObjects(DIEnumDeviceObjectsCallback, (LPVOID)&objects, DIDFT_AXIS)))
|
||||||
{
|
{
|
||||||
InitForceFeedback(m_device, objects.size());
|
InitForceFeedback(m_device, (int)objects.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
ClearInputState();
|
ClearInputState();
|
||||||
|
@ -51,6 +51,8 @@
|
|||||||
<PreprocessorDefinitions Condition="Exists('$(DXSDK_DIR)')">HAVE_DXSDK;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions Condition="Exists('$(DXSDK_DIR)')">HAVE_DXSDK;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<PreprocessorDefinitions>USE_UPNP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>USE_UPNP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<PreprocessorDefinitions>PSAPI_VERSION=1;_M_X86=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<PreprocessorDefinitions Condition="'$(Platform)'=='x64'">_ARCH_64=1;_M_X86_64=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<StructMemberAlignment>16Bytes</StructMemberAlignment>
|
<StructMemberAlignment>16Bytes</StructMemberAlignment>
|
||||||
@ -59,8 +61,8 @@
|
|||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<!--Enforce some behaviors as standards-conformant when they don't default as such-->
|
<!--Enforce some behaviors as standards-conformant when they don't default as such-->
|
||||||
<AdditionalOptions>/Zc:inline /Zc:rvalueCast /volatile:iso %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/Zc:inline /Zc:rvalueCast /volatile:iso %(AdditionalOptions)</AdditionalOptions>
|
||||||
<AdditionalOptions>/Zo /D PSAPI_VERSION=1 /D _M_X86=1 %(AdditionalOptions)</AdditionalOptions>
|
<!--Enable detailed debug info-->
|
||||||
<AdditionalOptions Condition="'$(Platform)'=='x64'">/D _ARCH_64=1 /D _M_X86_64=1 %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/Zo %(AdditionalOptions)</AdditionalOptions>
|
||||||
<DebugInformationFormat>OldStyle</DebugInformationFormat>
|
<DebugInformationFormat>OldStyle</DebugInformationFormat>
|
||||||
<!--
|
<!--
|
||||||
This is for GetVersionEx being marked as depreciated - which is idiotic and there's
|
This is for GetVersionEx being marked as depreciated - which is idiotic and there's
|
||||||
@ -89,6 +91,8 @@
|
|||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||||
<PreprocessorDefinitions>_SECURE_SCL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_SECURE_SCL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<!--This option is not supported in debug mode (for VS2013)-->
|
||||||
|
<AdditionalOptions>/Zc:strictStrings %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<!--Link Base-->
|
<!--Link Base-->
|
||||||
<Link>
|
<Link>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user