X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4cb1d3daa2e03b8c6481c9375d30451979170ba7..1d4037aa1f081ee2273468aa6f6cc5918d5e7d14:/src/mac/corefoundation/hid.cpp diff --git a/src/mac/corefoundation/hid.cpp b/src/mac/corefoundation/hid.cpp index 735895bbf5..16c956b207 100644 --- a/src/mac/corefoundation/hid.cpp +++ b/src/mac/corefoundation/hid.cpp @@ -34,6 +34,7 @@ #include "wx/mac/corefoundation/hid.h" #include "wx/string.h" #include "wx/log.h" +#include "wx/mac/corefoundation/cfstring.h" // --------------------------------------------------------------------------- @@ -118,7 +119,7 @@ bool wxHIDDevice::Create (int nClass, int nType, int nDev) //Now get the maching services io_iterator_t pIterator; wxIOCHECK(IOServiceGetMatchingServices(m_pPort, pDictionary, &pIterator), "No Matching HID Services"); - wxASSERT(pIterator != 0); + wxASSERT_MSG(pIterator != 0, wxT("No devices found!")); //Now we iterate through them io_object_t pObject; @@ -133,11 +134,40 @@ bool wxHIDDevice::Create (int nClass, int nType, int nDev) //Just for sanity :) wxASSERT(CFGetTypeID(CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDProductKey))) == CFStringGetTypeID()); +/* + kIOHIDTransportKey; + kIOHIDVendorIDKey; + kIOHIDProductIDKey; + kIOHIDVersionNumberKey; + kIOHIDManufacturerKey; + kIOHIDSerialNumberKey; + if !kIOHIDLocationIDKey + kUSBDevicePropertyLocationID + kIOHIDPrimaryUsageKey +kIOHIDPrimaryUsagePageKey +idProduct +idVendor +USB Product Name +*/ //Get [product] name - m_szName = CFStringGetCStringPtr ( - (CFStringRef) CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDProductKey)), - CFStringGetSystemEncoding() - ); + m_szProductName = wxMacCFStringHolder( (CFStringRef) CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDProductKey)), false ).AsString(); + + CFNumberRef nref = (CFNumberRef) CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDProductIDKey)); + + if (nref) + CFNumberGetValue( + nref, + kCFNumberIntType, + &m_nProductId + ); + + nref = (CFNumberRef) CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDVendorIDKey)); + if (nref) + CFNumberGetValue( + nref, + kCFNumberIntType, + &m_nManufacturerId + ); //Create the interface (good grief - long function names!) SInt32 nScore; @@ -164,8 +194,6 @@ bool wxHIDDevice::Create (int nClass, int nType, int nDev) // wxCFArray CookieArray = CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDElementKey)); BuildCookies(CookieArray); - if (m_ppQueue != NULL) - wxVERIFY((*m_ppQueue)->start(m_ppQueue) == S_OK); //cleanup CFRelease(pDictionary); @@ -215,7 +243,9 @@ int wxHIDDevice::GetCount (int nClass, int nType) //Now get the maching services io_iterator_t pIterator; wxIOCHECK(IOServiceGetMatchingServices(m_pPort, pDictionary, &pIterator), "No Matching HID Services"); - wxASSERT(pIterator != 0); + + if(pIterator == NULL) + return 0; //Now we iterate through them io_object_t pObject;