From ec8bd3921c6ad85dd8101306d920e19e32541680 Mon Sep 17 00:00:00 2001 From: Ryan Norton Date: Sun, 26 Sep 2004 20:35:45 +0000 Subject: [PATCH] hid integration git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29424 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- build/bakefiles/files.bkl | 1 + include/wx/mac/carbon/private/hid.h | 20 ++++++++++-- src/mac/carbon/hid.cpp | 48 +++++++++++++++++++++++------ 3 files changed, 57 insertions(+), 12 deletions(-) diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index 963154d110..0c2cd3fdfc 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -1621,6 +1621,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/mac/carbon/gauge.cpp src/mac/carbon/gdiobj.cpp src/mac/carbon/gsockosx.cpp + src/mac/carbon/hid.cpp src/mac/carbon/icon.cpp src/mac/carbon/listbox.cpp src/mac/carbon/mdi.cpp diff --git a/include/wx/mac/carbon/private/hid.h b/include/wx/mac/carbon/private/hid.h index 2947ee3575..ddc93c2cf2 100644 --- a/include/wx/mac/carbon/private/hid.h +++ b/include/wx/mac/carbon/private/hid.h @@ -1,4 +1,18 @@ -#include +///////////////////////////////////////////////////////////////////////////// +// Name: hid.h +// Purpose: DARWIN HID layer for WX +// Author: Ryan Norton +// Modified by: +// Created: 11/11/2003 +// RCS-ID: $Id$ +// Copyright: (c) Ryan Norton +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#include "wx/defs.h" + +#ifdef __DARWIN__ + #include #include #include @@ -60,4 +74,6 @@ class wxHIDKeyboard : public wxHIDDevice public: bool Create(); virtual void BuildCookies(wxCFArray& Array); -}; \ No newline at end of file +}; + +#endif //__DARWIN__ \ No newline at end of file diff --git a/src/mac/carbon/hid.cpp b/src/mac/carbon/hid.cpp index f4ce8a1874..7b337c9340 100644 --- a/src/mac/carbon/hid.cpp +++ b/src/mac/carbon/hid.cpp @@ -1,4 +1,22 @@ -#include "hid.h" +///////////////////////////////////////////////////////////////////////////// +// Name: hid.cpp +// Purpose: DARWIN HID layer for WX Implementation +// Author: Ryan Norton +// Modified by: +// Created: 11/11/2003 +// RCS-ID: $Id$ +// Copyright: (c) Ryan Norton +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#include "wx/defs.h" + +//DARWIN _ONLY_ +#ifdef __DARWIN__ + +#include "wx/mac/carbon/private/hid.h" +#include "wx/string.h" +#include "wx/log.h" #define wxFORCECHECK_MSG(arg, msg) \ {\ @@ -12,11 +30,18 @@ #define wxKERNCHECK(arg, msg) wxFORCECHECK_MSG(arg != KERN_SUCCESS, msg) #define wxSCHECK(arg, msg) wxFORCECHECK_MSG(arg != S_OK, msg) +#ifdef __WXDEBUG___ +# define wxVERIFY(arg) wxASSERT(arg) +#else +# define wxVERIFY(arg) arg +#endif + +/* void CFShowTypeIDDescription(CFTypeRef pData) { if(!pData) { - wxMessageBox("AHHH!"); + wxASSERT(false); return; } @@ -26,6 +51,7 @@ void CFShowTypeIDDescription(CFTypeRef pData) ) ); } +*/ // ============================================================================ // implementation @@ -46,7 +72,7 @@ bool wxHIDDevice::Create (const int& nClass, const int& nType) //The call to IOServiceMatching filters down the //the services we want to hid services (and also eats the //dictionary up for us (consumes one reference)) - wxASSERT((pDictionary = IOServiceMatching(kIOHIDDeviceKey)) != NULL ); + wxVERIFY((pDictionary = IOServiceMatching(kIOHIDDeviceKey)) != NULL ); //Here we'll filter down the services to what we want if (nType != -1) @@ -73,11 +99,11 @@ bool wxHIDDevice::Create (const int& nClass, const int& nType) io_object_t pObject; while ( (pObject = IOIteratorNext(pIterator)) != NULL) { - wxASSERT(IORegistryEntryCreateCFProperties(pObject, &pDictionary, + wxVERIFY(IORegistryEntryCreateCFProperties(pObject, &pDictionary, kCFAllocatorDefault, kNilOptions) == KERN_SUCCESS); //Just for sanity :) - wxASSERT(CFGetTypeID(CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDProductKey))) == CFStringGetTypeID()); + wxVERIFY(CFGetTypeID(CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDProductKey))) == CFStringGetTypeID()); //Get [product] name m_szName = CFStringGetCStringPtr ( @@ -91,7 +117,7 @@ bool wxHIDDevice::Create (const int& nClass, const int& nType) wxCFArray CookieArray = CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDElementKey)); BuildCookies(CookieArray); if (m_ppQueue != NULL) - wxASSERT((*m_ppQueue)->start(m_ppQueue) == S_OK); + wxVERIFY((*m_ppQueue)->start(m_ppQueue) == S_OK); //Create the interface (good grief - long function names!) SInt32 nScore; @@ -111,7 +137,7 @@ bool wxHIDDevice::Create (const int& nClass, const int& nType) (*ppPlugin)->Release(ppPlugin); //open the HID interface... - wxASSERT((*m_ppDevice)->open(m_ppDevice, 0) == S_OK); + wxVERIFY((*m_ppDevice)->open(m_ppDevice, 0) == S_OK); //cleanup CFRelease(pDictionary); @@ -138,7 +164,7 @@ void wxHIDDevice::AddCookie(CFTypeRef Data, const int& i) void wxHIDDevice::AddCookieInQueue(CFTypeRef Data, const int& i) { AddCookie(Data, i); - wxASSERT((*m_ppQueue)->addElement(m_ppQueue, m_pCookies[i], 0) == S_OK);//3rd Param flags (none yet) + wxVERIFY((*m_ppQueue)->addElement(m_ppQueue, m_pCookies[i], 0) == S_OK);//3rd Param flags (none yet) } void wxHIDDevice::InitCookies(const size_t& dwSize, bool bQueue) @@ -147,8 +173,8 @@ void wxHIDDevice::InitCookies(const size_t& dwSize, bool bQueue) if (bQueue) { wxASSERT( m_ppQueue != NULL); - wxASSERT( (m_ppQueue = (*m_ppDevice)->allocQueue(m_ppDevice)) != NULL); - wxASSERT( (*m_ppQueue)->create(m_ppQueue, 0, 512) == S_OK); //Param 2, flags, none yet + wxVERIFY( (m_ppQueue = (*m_ppDevice)->allocQueue(m_ppDevice)) != NULL); + wxVERIFY( (*m_ppQueue)->create(m_ppQueue, 0, 512) == S_OK); //Param 2, flags, none yet } } @@ -415,3 +441,5 @@ void wxHIDKeyboard::BuildCookies(wxCFArray& Array) } } }//end buildcookies + +#endif //__DARWIN__ -- 2.47.2