Skip to content

Commit

Permalink
Added some USB vendor identification
Browse files Browse the repository at this point in the history
  • Loading branch information
noorus committed Feb 4, 2014
1 parent 7eb264a commit 660e643
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/nilHID.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ extern "C" {

namespace nil {

//! Known USB vendor IDs that might be important.
enum USBKnownVendor: uint16_t {
USBVendor_Microsoft = 0x045E,
USBVendor_Logitech = 0x046D
};

//! \class HIDRecord
//! A Human Interface Device instance currently present in the system.
class HIDRecord {
protected:
String mPath;
Expand All @@ -25,6 +33,8 @@ namespace nil {
public:
HIDRecord( const String& path, HANDLE handle );
bool isXInput() const;
bool isMicrosoft() const;
bool isLogitech() const;
const String& getPath() const;
const String& getName() const;
const String& getManufacturer() const;
Expand All @@ -37,6 +47,8 @@ namespace nil {

typedef list<HIDRecord*> HIDRecordList;

//! \class HIDManager
//! Manages a list of connected Human Interface Devices.
class HIDManager: public PnPListener {
protected:
HIDRecordList mRecords;
Expand Down
3 changes: 3 additions & 0 deletions src/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ namespace nil {

void Device::create()
{
if ( mInstance )
return;

if ( getHandler() == Handler_XInput )
{
XInputDevice* xDevice = dynamic_cast<XInputDevice*>( this );
Expand Down
10 changes: 10 additions & 0 deletions src/HIDRecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ namespace nil {
return mIsXInput;
}

bool HIDRecord::isMicrosoft() const
{
return ( mVendorID == USBVendor_Microsoft );
}

bool HIDRecord::isLogitech() const
{
return ( mVendorID == USBVendor_Logitech );
}

uint32_t HIDRecord::getIdentifier() const
{
return mIdentifier;
Expand Down

0 comments on commit 660e643

Please sign in to comment.