#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2013 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #ifndef NUCLEX_INPUT_WINDOWS_XINPUTDEVICEENUMERATOR_H #define NUCLEX_INPUT_WINDOWS_XINPUTDEVICEENUMERATOR_H #define WIN32_LEAN_AND_MEAN #define VC_EXTRALEAN #include #include #include #include // --------------------------------------------------------------------------------------------- // /// Smart pointer to a WBEM locator _COM_SMARTPTR_TYPEDEF(IWbemLocator, IID_IWbemLocator); /// Smart pointer to a WBEM services proxy _COM_SMARTPTR_TYPEDEF(IWbemServices, IID_IWbemServices); /// Smart pointer to a WBEM device instance _COM_SMARTPTR_TYPEDEF(IEnumWbemClassObject, IID_IEnumWbemClassObject); // --------------------------------------------------------------------------------------------- // namespace Nuclex { namespace Input { // ------------------------------------------------------------------------------------------- // /// Enumerates the PnP devices via WMI, looking for XINPUT controllers class XInputDeviceEnumerator { /// Retrieves the VID+PID pairs of all connected XINPUT devices /// A set containing the VID+PID pairs of all connected XINPUT devices public: static std::set GetXInputVidPidPairs(); /// Accesses the WBEM services interface for the local system /// The local system's WBEM services interface private: static IWbemServicesPtr getWbemServices(); /// Creates an enumerator for the device instances in the specified class /// WBEM services an enumerator will be requested from /// Type of devices whose instance will be enumerated /// A new enumerator for the device instances of the specified class private: static IEnumWbemClassObjectPtr createDeviceInstanceEnumerator( const IWbemServicesPtr &services, const _bstr_t &deviceClass ); /// Retrieves the device id of the specified PnP device instance /// Device instance whose name will be retrieved /// The name of the specified device instance private: static std::wstring getDeviceId(IWbemClassObject *deviceInstance); /// Checks if the specified device id is an XINPUT device id /// Device id that will be checked /// True if the specified device id was an XINPUT device id private: static bool isXInputDeviceId(const std::wstring &deviceId); /// Extracts an id from the specified device id /// Device id from which the VID+PID pair will be extracted /// Name of the id that will be extracted from the device id /// The id extracted from the specified device id private: static DWORD extractId(const std::wstring &deviceId, const std::wstring &idName); }; // ------------------------------------------------------------------------------------------- // }} // namespace Nuclex::Input #endif // NUCLEX_INPUT_WINDOWS_XINPUTDEVICEENUMERATOR_H