diff --git a/stepmania/src/archutils/Darwin/HIDDevice.cpp b/stepmania/src/archutils/Darwin/HIDDevice.cpp index f2ce3d713d..285f8ffad7 100644 --- a/stepmania/src/archutils/Darwin/HIDDevice.cpp +++ b/stepmania/src/archutils/Darwin/HIDDevice.cpp @@ -55,7 +55,11 @@ bool HIDDevice::Open( io_object_t device ) vid = 0; if( !IntValue(pidRef, pid) ) pid = 0; - InitDevice( vid, pid ); + if( !InitDevice(vid, pid) ) + { + CFRelease( properties ); + return false; + } if( object && CFGetTypeID(object) == CFStringGetTypeID() ) m_sDescription = CFStringGetCStringPtr( CFStringRef(object), CFStringGetSystemEncoding() ); diff --git a/stepmania/src/archutils/Darwin/HIDDevice.h b/stepmania/src/archutils/Darwin/HIDDevice.h index 6724beccf6..c88e15a5ca 100644 --- a/stepmania/src/archutils/Darwin/HIDDevice.h +++ b/stepmania/src/archutils/Darwin/HIDDevice.h @@ -75,7 +75,7 @@ protected: /* * Optional. Subclasses can initialize the device, if required. */ - virtual void InitDevice( int vid, int pid ) { } + virtual bool InitDevice( int vid, int pid ) { return true; } // This adds the element with the given cookie to the queue to be notified of state changes. inline void AddElementToQueue( int cookie ) diff --git a/stepmania/src/archutils/Darwin/JoystickDevice.cpp b/stepmania/src/archutils/Darwin/JoystickDevice.cpp index 7f229be235..afd3d25b79 100644 --- a/stepmania/src/archutils/Darwin/JoystickDevice.cpp +++ b/stepmania/src/archutils/Darwin/JoystickDevice.cpp @@ -121,16 +121,17 @@ void JoystickDevice::Open() } } -void JoystickDevice::InitDevice( int vid, int pid ) +bool JoystickDevice::InitDevice( int vid, int pid ) { if( vid != 0x0507 || pid != 0x0011 ) - return; + return true; // It's a Para controller so try to power it on. uint8_t powerOn = 1; IOReturn ret = SetReport( kIOHIDReportTypeFeature, 0, &powerOn, 1, 10 ); if( ret ) LOG->Warn( "Failed to power on the Para controller: %#08x", ret ); + return ret == kIOReturnSuccess; } void JoystickDevice::GetButtonPresses( vector& vPresses, int cookie, int value, const RageTimer& now ) const diff --git a/stepmania/src/archutils/Darwin/JoystickDevice.h b/stepmania/src/archutils/Darwin/JoystickDevice.h index c30738b991..673c61cea5 100644 --- a/stepmania/src/archutils/Darwin/JoystickDevice.h +++ b/stepmania/src/archutils/Darwin/JoystickDevice.h @@ -28,7 +28,7 @@ protected: bool AddLogicalDevice( int usagePage, int usage ); void AddElement( int usagePage, int usage, int cookie, const CFDictionaryRef properties ); void Open(); - void InitDevice( int vid, int pid ); + bool InitDevice( int vid, int pid ); public: void GetButtonPresses( vector& vPresses, int cookie, int value, const RageTimer& now ) const; diff --git a/stepmania/src/archutils/Darwin/PumpDevice.h b/stepmania/src/archutils/Darwin/PumpDevice.h index b493d711a2..42f48f18f3 100644 --- a/stepmania/src/archutils/Darwin/PumpDevice.h +++ b/stepmania/src/archutils/Darwin/PumpDevice.h @@ -13,7 +13,7 @@ protected: void AddElement( int usagePage, int usage, int cookie, const CFDictionaryRef properties ) { } void Open(); - bool SupportsVidPid( int vid, int pid ) { return vid == 0x0d2f && pid == 0x0001; } + bool InitDevice( int vid, int pid ) { return vid == 0x0d2f && pid == 0x0001; } public: void GetButtonPresses( vector& vPresses, int cookie, int value, const RageTimer& now ) const;