Check if the device ID contains "IG_". If (SUCCEEDED(hr) & var.vt = VT_BSTR & var.bstrVal != nullptr) Hr = pEnumDevices->Next(10000, _countof(pDevices), pDevices, &uReturned) įor (size_t iDevice = 0 iDevice Get(bstrDeviceID, 0L, &var, nullptr, nullptr) If (FAILED(hr) || pEnumDevices = nullptr) Hr = pIWbemServices->CreateInstanceEnum(bstrClassName, 0, nullptr, &pEnumDevices) RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, nullptr, If (FAILED(hr) || pIWbemServices = nullptr)
Hr = pIWbemLocator->ConnectServer(bstrNamespace, nullptr, nullptr, 0L, If (FAILED(hr) || pIWbemLocator = nullptr)īstrNamespace = SysAllocString(L"\\\\.\\root\\cimv2") if (bstrNamespace = nullptr) goto LCleanup īstrClassName = SysAllocString(L"Win32_PNPEntity") if (bstrClassName = nullptr) goto LCleanup īstrDeviceID = SysAllocString(L"DeviceID") if (bstrDeviceID = nullptr) goto LCleanup Hr = CoCreateInstance(_uuidof(WbemLocator), So we can call VariantClear() later, even if we never had a successful IWbemClassObject::Get().
IEnumWbemClassObject* pEnumDevices = nullptr Unfortunately this information can not be found by just using DirectInputīOOL IsXInputDevice( const GUID* pGuidProductFromDirectInput ) Enum each PNP device using WMI and check each device ID to see if it contains
To do this, insert this code into your DirectInput enumeration callback: #include You will need to determine which of your DirectInput devices are legacy devices, and which are XInput devices, and remove them from the enumeration of DirectInput devices. All XInput devices will show up as both XInput and DirectInput devices, but they should not be handled through DirectInput. When enumerating your DirectInput devices, all DirectInput devices will enumerate correctly. If you want your game to support legacy DirectInput devices, you may use DirectInput and XInput side by side. XInput and DirectInput Side by Sideīy supporting XInput only, your game will not work with legacy DirectInput devices. In order to test the trigger values separately, you must use XInput. The solution was to combine the triggers, setting one trigger to a positive direction and the other to a negative direction, so no user interaction is indicative to DirectInput of the "control" being at center. Older games would therefore assume user interaction. However, the Xbox controller was designed to register minimum value, not center, when the triggers are not being held. Games have always assumed that DirectInput device axes are centered when there is no user interaction with the device. The combination of the left and right triggers in DirectInput is by design.
The Xbox Controller is properly enumerated on DirectInput, and can be used with the DirectInputAPIs. Using the Xbox Controller with DirectInput
Future controllers released for the Xbox console (that is, steering wheels) will also work on Windows.XInput devices (that is, the Xbox controllers) will have vibration functionality only when using XInput APIs.There will be a large installed base of Xbox controllers.Both Xbox and Windows programming will use the same sets of core APIs, allowing programming to translate cross-platform much easier.XInput is easier to use and requires less setup than DirectInput.There are several advantages to using XInput over DirectInput:
The APIs are available through the DirectX SDK, and the driver is available through Windows Update. This is the new input standard for both the Xbox and Windows. XInput is now available for game development. Use of legacy DirectInput is not recommended, and DirectInput is not available for Windows Store apps.