deTABified
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35140 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -43,36 +43,36 @@
|
|||||||
|
|
||||||
#define wxFORCECHECK_MSG(arg, msg) \
|
#define wxFORCECHECK_MSG(arg, msg) \
|
||||||
{\
|
{\
|
||||||
if (arg) \
|
if (arg) \
|
||||||
{\
|
{\
|
||||||
wxLogSysError(wxString::Format(wxT("Message:%s\nHID: %s failed!"), wxT(msg), wxT(#arg)));\
|
wxLogSysError(wxString::Format(wxT("Message:%s\nHID: %s failed!"), wxT(msg), wxT(#arg)));\
|
||||||
return false;\
|
return false;\
|
||||||
}\
|
}\
|
||||||
}
|
}
|
||||||
#define wxIOCHECK(arg, msg) wxFORCECHECK_MSG(arg != kIOReturnSuccess, msg)
|
#define wxIOCHECK(arg, msg) wxFORCECHECK_MSG(arg != kIOReturnSuccess, msg)
|
||||||
#define wxKERNCHECK(arg, msg) wxFORCECHECK_MSG(arg != KERN_SUCCESS, msg)
|
#define wxKERNCHECK(arg, msg) wxFORCECHECK_MSG(arg != KERN_SUCCESS, msg)
|
||||||
#define wxSCHECK(arg, msg) wxFORCECHECK_MSG(arg != S_OK, msg)
|
#define wxSCHECK(arg, msg) wxFORCECHECK_MSG(arg != S_OK, msg)
|
||||||
|
|
||||||
#ifdef __WXDEBUG___
|
#ifdef __WXDEBUG___
|
||||||
# define wxVERIFY(arg) wxASSERT(arg)
|
# define wxVERIFY(arg) wxASSERT(arg)
|
||||||
#else
|
#else
|
||||||
# define wxVERIFY(arg) arg
|
# define wxVERIFY(arg) arg
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void CFShowTypeIDDescription(CFTypeRef pData)
|
void CFShowTypeIDDescription(CFTypeRef pData)
|
||||||
{
|
{
|
||||||
if(!pData)
|
if(!pData)
|
||||||
{
|
{
|
||||||
wxASSERT(false);
|
wxASSERT(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMessageBox(
|
wxMessageBox(
|
||||||
CFStringGetCStringPtr(
|
CFStringGetCStringPtr(
|
||||||
CFCopyTypeIDDescription(CFGetTypeID(pData)),CFStringGetSystemEncoding()
|
CFCopyTypeIDDescription(CFGetTypeID(pData)),CFStringGetSystemEncoding()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -86,53 +86,53 @@ void CFShowTypeIDDescription(CFTypeRef pData)
|
|||||||
|
|
||||||
bool wxHIDDevice::Create (int nClass, int nType, int nDev)
|
bool wxHIDDevice::Create (int nClass, int nType, int nDev)
|
||||||
{
|
{
|
||||||
//Create the mach port
|
//Create the mach port
|
||||||
wxIOCHECK(IOMasterPort(bootstrap_port, &m_pPort), "Could not create mach port");
|
wxIOCHECK(IOMasterPort(bootstrap_port, &m_pPort), "Could not create mach port");
|
||||||
|
|
||||||
//Dictionary that will hold first
|
//Dictionary that will hold first
|
||||||
//the matching dictionary for determining which kind of devices we want,
|
//the matching dictionary for determining which kind of devices we want,
|
||||||
//then later some registry properties from an iterator (see below)
|
//then later some registry properties from an iterator (see below)
|
||||||
CFMutableDictionaryRef pDictionary;
|
CFMutableDictionaryRef pDictionary;
|
||||||
|
|
||||||
//Create a dictionary
|
//Create a dictionary
|
||||||
//The call to IOServiceMatching filters down the
|
//The call to IOServiceMatching filters down the
|
||||||
//the services we want to hid services (and also eats the
|
//the services we want to hid services (and also eats the
|
||||||
//dictionary up for us (consumes one reference))
|
//dictionary up for us (consumes one reference))
|
||||||
wxVERIFY((pDictionary = IOServiceMatching(kIOHIDDeviceKey)) != NULL );
|
wxVERIFY((pDictionary = IOServiceMatching(kIOHIDDeviceKey)) != NULL );
|
||||||
|
|
||||||
//Here we'll filter down the services to what we want
|
//Here we'll filter down the services to what we want
|
||||||
if (nType != -1)
|
if (nType != -1)
|
||||||
{
|
{
|
||||||
CFNumberRef pType = CFNumberCreate(kCFAllocatorDefault,
|
CFNumberRef pType = CFNumberCreate(kCFAllocatorDefault,
|
||||||
kCFNumberIntType, &nType);
|
kCFNumberIntType, &nType);
|
||||||
CFDictionarySetValue(pDictionary, CFSTR(kIOHIDPrimaryUsageKey), pType);
|
CFDictionarySetValue(pDictionary, CFSTR(kIOHIDPrimaryUsageKey), pType);
|
||||||
CFRelease(pType);
|
CFRelease(pType);
|
||||||
}
|
}
|
||||||
if (nClass != -1)
|
if (nClass != -1)
|
||||||
{
|
{
|
||||||
CFNumberRef pClass = CFNumberCreate(kCFAllocatorDefault,
|
CFNumberRef pClass = CFNumberCreate(kCFAllocatorDefault,
|
||||||
kCFNumberIntType, &nClass);
|
kCFNumberIntType, &nClass);
|
||||||
CFDictionarySetValue(pDictionary, CFSTR(kIOHIDPrimaryUsagePageKey), pClass);
|
CFDictionarySetValue(pDictionary, CFSTR(kIOHIDPrimaryUsagePageKey), pClass);
|
||||||
CFRelease(pClass);
|
CFRelease(pClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Now get the maching services
|
//Now get the maching services
|
||||||
io_iterator_t pIterator;
|
io_iterator_t pIterator;
|
||||||
wxIOCHECK(IOServiceGetMatchingServices(m_pPort, pDictionary, &pIterator), "No Matching HID Services");
|
wxIOCHECK(IOServiceGetMatchingServices(m_pPort, pDictionary, &pIterator), "No Matching HID Services");
|
||||||
wxASSERT_MSG(pIterator != 0, wxT("No devices found!"));
|
wxASSERT_MSG(pIterator != 0, wxT("No devices found!"));
|
||||||
|
|
||||||
//Now we iterate through them
|
//Now we iterate through them
|
||||||
io_object_t pObject;
|
io_object_t pObject;
|
||||||
while ( (pObject = IOIteratorNext(pIterator)) != 0)
|
while ( (pObject = IOIteratorNext(pIterator)) != 0)
|
||||||
{
|
{
|
||||||
if(--nDev != 0)
|
if(--nDev != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
wxVERIFY(IORegistryEntryCreateCFProperties(pObject, &pDictionary,
|
wxVERIFY(IORegistryEntryCreateCFProperties(pObject, &pDictionary,
|
||||||
kCFAllocatorDefault, kNilOptions) == KERN_SUCCESS);
|
kCFAllocatorDefault, kNilOptions) == KERN_SUCCESS);
|
||||||
|
|
||||||
//Just for sanity :)
|
//Just for sanity :)
|
||||||
wxASSERT(CFGetTypeID(CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDProductKey))) == CFStringGetTypeID());
|
wxASSERT(CFGetTypeID(CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDProductKey))) == CFStringGetTypeID());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
kIOHIDTransportKey;
|
kIOHIDTransportKey;
|
||||||
@@ -149,158 +149,158 @@ idProduct
|
|||||||
idVendor
|
idVendor
|
||||||
USB Product Name
|
USB Product Name
|
||||||
*/
|
*/
|
||||||
//Get [product] name
|
//Get [product] name
|
||||||
m_szProductName = wxMacCFStringHolder( (CFStringRef) CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDProductKey)), false ).AsString();
|
m_szProductName = wxMacCFStringHolder( (CFStringRef) CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDProductKey)), false ).AsString();
|
||||||
|
|
||||||
CFNumberRef nref = (CFNumberRef) CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDProductIDKey));
|
CFNumberRef nref = (CFNumberRef) CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDProductIDKey));
|
||||||
|
|
||||||
if (nref)
|
if (nref)
|
||||||
CFNumberGetValue(
|
CFNumberGetValue(
|
||||||
nref,
|
nref,
|
||||||
kCFNumberIntType,
|
kCFNumberIntType,
|
||||||
&m_nProductId
|
&m_nProductId
|
||||||
);
|
);
|
||||||
|
|
||||||
nref = (CFNumberRef) CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDVendorIDKey));
|
nref = (CFNumberRef) CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDVendorIDKey));
|
||||||
if (nref)
|
if (nref)
|
||||||
CFNumberGetValue(
|
CFNumberGetValue(
|
||||||
nref,
|
nref,
|
||||||
kCFNumberIntType,
|
kCFNumberIntType,
|
||||||
&m_nManufacturerId
|
&m_nManufacturerId
|
||||||
);
|
);
|
||||||
|
|
||||||
//Create the interface (good grief - long function names!)
|
//Create the interface (good grief - long function names!)
|
||||||
SInt32 nScore;
|
SInt32 nScore;
|
||||||
IOCFPlugInInterface** ppPlugin;
|
IOCFPlugInInterface** ppPlugin;
|
||||||
wxIOCHECK(IOCreatePlugInInterfaceForService(pObject, kIOHIDDeviceUserClientTypeID,
|
wxIOCHECK(IOCreatePlugInInterfaceForService(pObject, kIOHIDDeviceUserClientTypeID,
|
||||||
kIOCFPlugInInterfaceID, &ppPlugin, &nScore), "");
|
kIOCFPlugInInterfaceID, &ppPlugin, &nScore), "");
|
||||||
|
|
||||||
//Now, the final thing we can check before we fall back to asserts
|
//Now, the final thing we can check before we fall back to asserts
|
||||||
//(because the dtor only checks if the device is ok, so if anything
|
//(because the dtor only checks if the device is ok, so if anything
|
||||||
//fails from now on the dtor will delete the device anyway, so we can't break from this).
|
//fails from now on the dtor will delete the device anyway, so we can't break from this).
|
||||||
|
|
||||||
//Get the HID interface from the plugin to the mach port
|
//Get the HID interface from the plugin to the mach port
|
||||||
wxSCHECK((*ppPlugin)->QueryInterface(ppPlugin,
|
wxSCHECK((*ppPlugin)->QueryInterface(ppPlugin,
|
||||||
CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (void**) &m_ppDevice), "");
|
CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (void**) &m_ppDevice), "");
|
||||||
|
|
||||||
//release the plugin
|
//release the plugin
|
||||||
(*ppPlugin)->Release(ppPlugin);
|
(*ppPlugin)->Release(ppPlugin);
|
||||||
|
|
||||||
//open the HID interface...
|
//open the HID interface...
|
||||||
wxVERIFY((*m_ppDevice)->open(m_ppDevice, 0) == S_OK);
|
wxVERIFY((*m_ppDevice)->open(m_ppDevice, 0) == S_OK);
|
||||||
|
|
||||||
//
|
//
|
||||||
//Now the hard part - in order to scan things we need "cookies" -
|
//Now the hard part - in order to scan things we need "cookies" -
|
||||||
//
|
//
|
||||||
wxCFArray CookieArray = CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDElementKey));
|
wxCFArray CookieArray = CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDElementKey));
|
||||||
BuildCookies(CookieArray);
|
BuildCookies(CookieArray);
|
||||||
|
|
||||||
//cleanup
|
//cleanup
|
||||||
CFRelease(pDictionary);
|
CFRelease(pDictionary);
|
||||||
IOObjectRelease(pObject);
|
IOObjectRelease(pObject);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//iterator cleanup
|
//iterator cleanup
|
||||||
IOObjectRelease(pIterator);
|
IOObjectRelease(pIterator);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}//end Create()
|
}//end Create()
|
||||||
|
|
||||||
int wxHIDDevice::GetCount (int nClass, int nType)
|
int wxHIDDevice::GetCount (int nClass, int nType)
|
||||||
{
|
{
|
||||||
mach_port_t m_pPort;
|
mach_port_t m_pPort;
|
||||||
|
|
||||||
//Create the mach port
|
//Create the mach port
|
||||||
wxIOCHECK(IOMasterPort(bootstrap_port, &m_pPort), "Could not create mach port");
|
wxIOCHECK(IOMasterPort(bootstrap_port, &m_pPort), "Could not create mach port");
|
||||||
|
|
||||||
//Dictionary that will hold first
|
//Dictionary that will hold first
|
||||||
//the matching dictionary for determining which kind of devices we want,
|
//the matching dictionary for determining which kind of devices we want,
|
||||||
//then later some registry properties from an iterator (see below)
|
//then later some registry properties from an iterator (see below)
|
||||||
CFMutableDictionaryRef pDictionary;
|
CFMutableDictionaryRef pDictionary;
|
||||||
|
|
||||||
//Create a dictionary
|
//Create a dictionary
|
||||||
//The call to IOServiceMatching filters down the
|
//The call to IOServiceMatching filters down the
|
||||||
//the services we want to hid services (and also eats the
|
//the services we want to hid services (and also eats the
|
||||||
//dictionary up for us (consumes one reference))
|
//dictionary up for us (consumes one reference))
|
||||||
wxVERIFY((pDictionary = IOServiceMatching(kIOHIDDeviceKey)) != NULL );
|
wxVERIFY((pDictionary = IOServiceMatching(kIOHIDDeviceKey)) != NULL );
|
||||||
|
|
||||||
//Here we'll filter down the services to what we want
|
//Here we'll filter down the services to what we want
|
||||||
if (nType != -1)
|
if (nType != -1)
|
||||||
{
|
{
|
||||||
CFNumberRef pType = CFNumberCreate(kCFAllocatorDefault,
|
CFNumberRef pType = CFNumberCreate(kCFAllocatorDefault,
|
||||||
kCFNumberIntType, &nType);
|
kCFNumberIntType, &nType);
|
||||||
CFDictionarySetValue(pDictionary, CFSTR(kIOHIDPrimaryUsageKey), pType);
|
CFDictionarySetValue(pDictionary, CFSTR(kIOHIDPrimaryUsageKey), pType);
|
||||||
CFRelease(pType);
|
CFRelease(pType);
|
||||||
}
|
}
|
||||||
if (nClass != -1)
|
if (nClass != -1)
|
||||||
{
|
{
|
||||||
CFNumberRef pClass = CFNumberCreate(kCFAllocatorDefault,
|
CFNumberRef pClass = CFNumberCreate(kCFAllocatorDefault,
|
||||||
kCFNumberIntType, &nClass);
|
kCFNumberIntType, &nClass);
|
||||||
CFDictionarySetValue(pDictionary, CFSTR(kIOHIDPrimaryUsagePageKey), pClass);
|
CFDictionarySetValue(pDictionary, CFSTR(kIOHIDPrimaryUsagePageKey), pClass);
|
||||||
CFRelease(pClass);
|
CFRelease(pClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Now get the maching services
|
//Now get the maching services
|
||||||
io_iterator_t pIterator;
|
io_iterator_t pIterator;
|
||||||
wxIOCHECK(IOServiceGetMatchingServices(m_pPort, pDictionary, &pIterator), "No Matching HID Services");
|
wxIOCHECK(IOServiceGetMatchingServices(m_pPort, pDictionary, &pIterator), "No Matching HID Services");
|
||||||
|
|
||||||
if(pIterator == NULL)
|
if(pIterator == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
//Now we iterate through them
|
//Now we iterate through them
|
||||||
io_object_t pObject;
|
io_object_t pObject;
|
||||||
|
|
||||||
int nCount = 0;
|
int nCount = 0;
|
||||||
|
|
||||||
while ( (pObject = IOIteratorNext(pIterator)) != 0)
|
while ( (pObject = IOIteratorNext(pIterator)) != 0)
|
||||||
++nCount;
|
++nCount;
|
||||||
|
|
||||||
//iterator cleanup
|
//iterator cleanup
|
||||||
IOObjectRelease(pIterator);
|
IOObjectRelease(pIterator);
|
||||||
|
|
||||||
return nCount;
|
return nCount;
|
||||||
}//end Create()
|
}//end Create()
|
||||||
|
|
||||||
void wxHIDDevice::AddCookie(CFTypeRef Data, int i)
|
void wxHIDDevice::AddCookie(CFTypeRef Data, int i)
|
||||||
{
|
{
|
||||||
CFNumberGetValue(
|
CFNumberGetValue(
|
||||||
(CFNumberRef) CFDictionaryGetValue ( (CFDictionaryRef) Data
|
(CFNumberRef) CFDictionaryGetValue ( (CFDictionaryRef) Data
|
||||||
, CFSTR(kIOHIDElementCookieKey)
|
, CFSTR(kIOHIDElementCookieKey)
|
||||||
),
|
),
|
||||||
kCFNumberIntType,
|
kCFNumberIntType,
|
||||||
&m_pCookies[i]
|
&m_pCookies[i]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxHIDDevice::AddCookieInQueue(CFTypeRef Data, int i)
|
void wxHIDDevice::AddCookieInQueue(CFTypeRef Data, int i)
|
||||||
{
|
{
|
||||||
AddCookie(Data, i);
|
AddCookie(Data, i);
|
||||||
wxVERIFY((*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(size_t dwSize, bool bQueue)
|
void wxHIDDevice::InitCookies(size_t dwSize, bool bQueue)
|
||||||
{
|
{
|
||||||
m_pCookies = new IOHIDElementCookie[dwSize];
|
m_pCookies = new IOHIDElementCookie[dwSize];
|
||||||
if (bQueue)
|
if (bQueue)
|
||||||
{
|
{
|
||||||
wxASSERT( m_ppQueue == NULL);
|
wxASSERT( m_ppQueue == NULL);
|
||||||
wxVERIFY( (m_ppQueue = (*m_ppDevice)->allocQueue(m_ppDevice)) != NULL);
|
wxVERIFY( (m_ppQueue = (*m_ppDevice)->allocQueue(m_ppDevice)) != NULL);
|
||||||
wxVERIFY( (*m_ppQueue)->create(m_ppQueue, 0, 512) == S_OK); //Param 2, flags, none yet
|
wxVERIFY( (*m_ppQueue)->create(m_ppQueue, 0, 512) == S_OK); //Param 2, flags, none yet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxHIDDevice::IsActive(int nIndex)
|
bool wxHIDDevice::IsActive(int nIndex)
|
||||||
{
|
{
|
||||||
wxASSERT(m_pCookies[nIndex] != NULL);
|
wxASSERT(m_pCookies[nIndex] != NULL);
|
||||||
IOHIDEventStruct Event;
|
IOHIDEventStruct Event;
|
||||||
(*m_ppDevice)->getElementValue(m_ppDevice, m_pCookies[nIndex], &Event);
|
(*m_ppDevice)->getElementValue(m_ppDevice, m_pCookies[nIndex], &Event);
|
||||||
/*
|
/*
|
||||||
wxString ss;
|
wxString ss;
|
||||||
ss << _T("[") << (int) m_pCookies[nIndex] << _T("] = ") << Event.value << _T(" SIZE:") << Event.longValueSize;
|
ss << _T("[") << (int) m_pCookies[nIndex] << _T("] = ") << Event.value << _T(" SIZE:") << Event.longValueSize;
|
||||||
|
|
||||||
wxLogDebug(ss);
|
wxLogDebug(ss);
|
||||||
*/
|
*/
|
||||||
return !!Event.value;
|
return !!Event.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxHIDDevice::HasElement(int nIndex)
|
bool wxHIDDevice::HasElement(int nIndex)
|
||||||
@@ -310,23 +310,23 @@ bool wxHIDDevice::HasElement(int nIndex)
|
|||||||
|
|
||||||
wxHIDDevice::~wxHIDDevice()
|
wxHIDDevice::~wxHIDDevice()
|
||||||
{
|
{
|
||||||
if (m_ppDevice != NULL)
|
if (m_ppDevice != NULL)
|
||||||
{
|
{
|
||||||
if (m_ppQueue != NULL)
|
if (m_ppQueue != NULL)
|
||||||
{
|
{
|
||||||
(*m_ppQueue)->stop(m_ppQueue);
|
(*m_ppQueue)->stop(m_ppQueue);
|
||||||
(*m_ppQueue)->dispose(m_ppQueue);
|
(*m_ppQueue)->dispose(m_ppQueue);
|
||||||
(*m_ppQueue)->Release(m_ppQueue);
|
(*m_ppQueue)->Release(m_ppQueue);
|
||||||
}
|
}
|
||||||
(*m_ppDevice)->close(m_ppDevice);
|
(*m_ppDevice)->close(m_ppDevice);
|
||||||
(*m_ppDevice)->Release(m_ppDevice);
|
(*m_ppDevice)->Release(m_ppDevice);
|
||||||
mach_port_deallocate(mach_task_self(), m_pPort);
|
mach_port_deallocate(mach_task_self(), m_pPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_pCookies != NULL)
|
if (m_pCookies != NULL)
|
||||||
{
|
{
|
||||||
delete [] m_pCookies;
|
delete [] m_pCookies;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -335,30 +335,30 @@ wxHIDDevice::~wxHIDDevice()
|
|||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
WXK_RSHIFT = 400,
|
WXK_RSHIFT = 400,
|
||||||
WXK_RALT,
|
WXK_RALT,
|
||||||
WXK_RCONTROL,
|
WXK_RCONTROL,
|
||||||
WXK_RMENU
|
WXK_RMENU
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool wxHIDKeyboard::Create()
|
bool wxHIDKeyboard::Create()
|
||||||
{
|
{
|
||||||
return wxHIDDevice::Create(kHIDPage_GenericDesktop, kHIDUsage_GD_Keyboard);
|
return wxHIDDevice::Create(kHIDPage_GenericDesktop, kHIDUsage_GD_Keyboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxHIDKeyboard::BuildCookies(wxCFArray& Array)
|
void wxHIDKeyboard::BuildCookies(wxCFArray& Array)
|
||||||
{
|
{
|
||||||
Array = CFDictionaryGetValue((CFDictionaryRef)Array[0], CFSTR(kIOHIDElementKey));
|
Array = CFDictionaryGetValue((CFDictionaryRef)Array[0], CFSTR(kIOHIDElementKey));
|
||||||
InitCookies(500);
|
InitCookies(500);
|
||||||
int i,
|
int i,
|
||||||
nUsage;
|
nUsage;
|
||||||
bool bEOTriggered = false;
|
bool bEOTriggered = false;
|
||||||
for (i = 0; i < Array.Count(); ++i)
|
for (i = 0; i < Array.Count(); ++i)
|
||||||
{
|
{
|
||||||
CFNumberGetValue(
|
CFNumberGetValue(
|
||||||
(CFNumberRef) CFDictionaryGetValue((CFDictionaryRef) Array[i], CFSTR(kIOHIDElementUsageKey)),
|
(CFNumberRef) CFDictionaryGetValue((CFDictionaryRef) Array[i], CFSTR(kIOHIDElementUsageKey)),
|
||||||
kCFNumberLongType, &nUsage);
|
kCFNumberLongType, &nUsage);
|
||||||
|
|
||||||
//
|
//
|
||||||
// OK, this is strange - basically this kind of strange -
|
// OK, this is strange - basically this kind of strange -
|
||||||
@@ -381,119 +381,119 @@ void wxHIDKeyboard::BuildCookies(wxCFArray& Array)
|
|||||||
/*
|
/*
|
||||||
wxString msg;
|
wxString msg;
|
||||||
int cookie;
|
int cookie;
|
||||||
CFNumberGetValue(
|
CFNumberGetValue(
|
||||||
(CFNumberRef) CFDictionaryGetValue ( (CFDictionaryRef) Array[i]
|
(CFNumberRef) CFDictionaryGetValue ( (CFDictionaryRef) Array[i]
|
||||||
, CFSTR(kIOHIDElementCookieKey)
|
, CFSTR(kIOHIDElementCookieKey)
|
||||||
),
|
),
|
||||||
kCFNumberIntType,
|
kCFNumberIntType,
|
||||||
&cookie
|
&cookie
|
||||||
);
|
);
|
||||||
|
|
||||||
msg << wxT("KEY:") << nUsage << wxT("COOKIE:") << cookie;
|
msg << wxT("KEY:") << nUsage << wxT("COOKIE:") << cookie;
|
||||||
wxLogDebug(msg);
|
wxLogDebug(msg);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (nUsage >= kHIDUsage_KeyboardA && nUsage <= kHIDUsage_KeyboardZ)
|
if (nUsage >= kHIDUsage_KeyboardA && nUsage <= kHIDUsage_KeyboardZ)
|
||||||
AddCookie(Array[i], 'A' + (nUsage - kHIDUsage_KeyboardA) );
|
AddCookie(Array[i], 'A' + (nUsage - kHIDUsage_KeyboardA) );
|
||||||
else if (nUsage >= kHIDUsage_Keyboard1 && nUsage <= kHIDUsage_Keyboard9)
|
else if (nUsage >= kHIDUsage_Keyboard1 && nUsage <= kHIDUsage_Keyboard9)
|
||||||
AddCookie(Array[i], '1' + (nUsage - kHIDUsage_Keyboard1) );
|
AddCookie(Array[i], '1' + (nUsage - kHIDUsage_Keyboard1) );
|
||||||
else if (nUsage >= kHIDUsage_KeyboardF1 && nUsage <= kHIDUsage_KeyboardF12)
|
else if (nUsage >= kHIDUsage_KeyboardF1 && nUsage <= kHIDUsage_KeyboardF12)
|
||||||
AddCookie(Array[i], WXK_F1 + (nUsage - kHIDUsage_KeyboardF1) );
|
AddCookie(Array[i], WXK_F1 + (nUsage - kHIDUsage_KeyboardF1) );
|
||||||
else if (nUsage >= kHIDUsage_KeyboardF13 && nUsage <= kHIDUsage_KeyboardF24)
|
else if (nUsage >= kHIDUsage_KeyboardF13 && nUsage <= kHIDUsage_KeyboardF24)
|
||||||
AddCookie(Array[i], WXK_F13 + (nUsage - kHIDUsage_KeyboardF13) );
|
AddCookie(Array[i], WXK_F13 + (nUsage - kHIDUsage_KeyboardF13) );
|
||||||
else if (nUsage >= kHIDUsage_Keypad1 && nUsage <= kHIDUsage_Keypad9)
|
else if (nUsage >= kHIDUsage_Keypad1 && nUsage <= kHIDUsage_Keypad9)
|
||||||
AddCookie(Array[i], WXK_NUMPAD1 + (nUsage - kHIDUsage_Keypad1) );
|
AddCookie(Array[i], WXK_NUMPAD1 + (nUsage - kHIDUsage_Keypad1) );
|
||||||
else switch (nUsage)
|
else switch (nUsage)
|
||||||
{
|
{
|
||||||
//0's (wx & ascii go 0-9, but HID goes 1-0)
|
//0's (wx & ascii go 0-9, but HID goes 1-0)
|
||||||
case kHIDUsage_Keyboard0:
|
case kHIDUsage_Keyboard0:
|
||||||
AddCookie(Array[i],'0');
|
AddCookie(Array[i],'0');
|
||||||
break;
|
break;
|
||||||
case kHIDUsage_Keypad0:
|
case kHIDUsage_Keypad0:
|
||||||
AddCookie(Array[i],WXK_NUMPAD0);
|
AddCookie(Array[i],WXK_NUMPAD0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//Basic
|
//Basic
|
||||||
case kHIDUsage_KeyboardReturnOrEnter:
|
case kHIDUsage_KeyboardReturnOrEnter:
|
||||||
AddCookie(Array[i], WXK_RETURN);
|
AddCookie(Array[i], WXK_RETURN);
|
||||||
break;
|
break;
|
||||||
case kHIDUsage_KeyboardEscape:
|
case kHIDUsage_KeyboardEscape:
|
||||||
AddCookie(Array[i], WXK_ESCAPE);
|
AddCookie(Array[i], WXK_ESCAPE);
|
||||||
break;
|
break;
|
||||||
case kHIDUsage_KeyboardDeleteOrBackspace:
|
case kHIDUsage_KeyboardDeleteOrBackspace:
|
||||||
AddCookie(Array[i], WXK_BACK);
|
AddCookie(Array[i], WXK_BACK);
|
||||||
break;
|
break;
|
||||||
case kHIDUsage_KeyboardTab:
|
case kHIDUsage_KeyboardTab:
|
||||||
AddCookie(Array[i], WXK_TAB);
|
AddCookie(Array[i], WXK_TAB);
|
||||||
break;
|
break;
|
||||||
case kHIDUsage_KeyboardSpacebar:
|
case kHIDUsage_KeyboardSpacebar:
|
||||||
AddCookie(Array[i], WXK_SPACE);
|
AddCookie(Array[i], WXK_SPACE);
|
||||||
break;
|
break;
|
||||||
case kHIDUsage_KeyboardPageUp:
|
case kHIDUsage_KeyboardPageUp:
|
||||||
AddCookie(Array[i], WXK_PRIOR);
|
AddCookie(Array[i], WXK_PRIOR);
|
||||||
break;
|
break;
|
||||||
case kHIDUsage_KeyboardEnd:
|
case kHIDUsage_KeyboardEnd:
|
||||||
AddCookie(Array[i], WXK_END);
|
AddCookie(Array[i], WXK_END);
|
||||||
break;
|
break;
|
||||||
case kHIDUsage_KeyboardPageDown:
|
case kHIDUsage_KeyboardPageDown:
|
||||||
AddCookie(Array[i], WXK_NEXT);
|
AddCookie(Array[i], WXK_NEXT);
|
||||||
break;
|
break;
|
||||||
case kHIDUsage_KeyboardRightArrow:
|
case kHIDUsage_KeyboardRightArrow:
|
||||||
AddCookie(Array[i], WXK_RIGHT);
|
AddCookie(Array[i], WXK_RIGHT);
|
||||||
break;
|
break;
|
||||||
case kHIDUsage_KeyboardLeftArrow:
|
case kHIDUsage_KeyboardLeftArrow:
|
||||||
AddCookie(Array[i], WXK_LEFT);
|
AddCookie(Array[i], WXK_LEFT);
|
||||||
break;
|
break;
|
||||||
case kHIDUsage_KeyboardDownArrow:
|
case kHIDUsage_KeyboardDownArrow:
|
||||||
AddCookie(Array[i], WXK_DOWN);
|
AddCookie(Array[i], WXK_DOWN);
|
||||||
break;
|
break;
|
||||||
case kHIDUsage_KeyboardUpArrow:
|
case kHIDUsage_KeyboardUpArrow:
|
||||||
AddCookie(Array[i], WXK_UP);
|
AddCookie(Array[i], WXK_UP);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//LEDS
|
//LEDS
|
||||||
case kHIDUsage_KeyboardCapsLock:
|
case kHIDUsage_KeyboardCapsLock:
|
||||||
AddCookie(Array[i],WXK_CAPITAL);
|
AddCookie(Array[i],WXK_CAPITAL);
|
||||||
break;
|
break;
|
||||||
case kHIDUsage_KeypadNumLock:
|
case kHIDUsage_KeypadNumLock:
|
||||||
AddCookie(Array[i],WXK_NUMLOCK);
|
AddCookie(Array[i],WXK_NUMLOCK);
|
||||||
break;
|
break;
|
||||||
case kHIDUsage_KeyboardScrollLock:
|
case kHIDUsage_KeyboardScrollLock:
|
||||||
AddCookie(Array[i],WXK_SCROLL);
|
AddCookie(Array[i],WXK_SCROLL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//Menu keys, Shift, other specials
|
//Menu keys, Shift, other specials
|
||||||
case kHIDUsage_KeyboardLeftControl:
|
case kHIDUsage_KeyboardLeftControl:
|
||||||
AddCookie(Array[i],WXK_CONTROL);
|
AddCookie(Array[i],WXK_CONTROL);
|
||||||
break;
|
break;
|
||||||
case kHIDUsage_KeyboardLeftShift:
|
case kHIDUsage_KeyboardLeftShift:
|
||||||
AddCookie(Array[i],WXK_SHIFT);
|
AddCookie(Array[i],WXK_SHIFT);
|
||||||
break;
|
break;
|
||||||
case kHIDUsage_KeyboardLeftAlt:
|
case kHIDUsage_KeyboardLeftAlt:
|
||||||
AddCookie(Array[i],WXK_ALT);
|
AddCookie(Array[i],WXK_ALT);
|
||||||
break;
|
break;
|
||||||
case kHIDUsage_KeyboardLeftGUI:
|
case kHIDUsage_KeyboardLeftGUI:
|
||||||
AddCookie(Array[i],WXK_MENU);
|
AddCookie(Array[i],WXK_MENU);
|
||||||
break;
|
break;
|
||||||
case kHIDUsage_KeyboardRightControl:
|
case kHIDUsage_KeyboardRightControl:
|
||||||
AddCookie(Array[i],WXK_RCONTROL);
|
AddCookie(Array[i],WXK_RCONTROL);
|
||||||
break;
|
break;
|
||||||
case kHIDUsage_KeyboardRightShift:
|
case kHIDUsage_KeyboardRightShift:
|
||||||
AddCookie(Array[i],WXK_RSHIFT);
|
AddCookie(Array[i],WXK_RSHIFT);
|
||||||
break;
|
break;
|
||||||
case kHIDUsage_KeyboardRightAlt:
|
case kHIDUsage_KeyboardRightAlt:
|
||||||
AddCookie(Array[i],WXK_RALT);
|
AddCookie(Array[i],WXK_RALT);
|
||||||
break;
|
break;
|
||||||
case kHIDUsage_KeyboardRightGUI:
|
case kHIDUsage_KeyboardRightGUI:
|
||||||
AddCookie(Array[i],WXK_RMENU);
|
AddCookie(Array[i],WXK_RMENU);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//Default
|
//Default
|
||||||
default:
|
default:
|
||||||
//not in wx keycodes - do nothing....
|
//not in wx keycodes - do nothing....
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}//end buildcookies
|
}//end buildcookies
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -550,15 +550,15 @@ bool wxGetKeyState (wxKeyCode key)
|
|||||||
return wxHIDModule::sm_keyboard->IsActive(WXK_SHIFT) ||
|
return wxHIDModule::sm_keyboard->IsActive(WXK_SHIFT) ||
|
||||||
wxHIDModule::sm_keyboard->IsActive(WXK_RSHIFT);
|
wxHIDModule::sm_keyboard->IsActive(WXK_RSHIFT);
|
||||||
break;
|
break;
|
||||||
case WXK_ALT:
|
case WXK_ALT:
|
||||||
return wxHIDModule::sm_keyboard->IsActive(WXK_ALT) ||
|
return wxHIDModule::sm_keyboard->IsActive(WXK_ALT) ||
|
||||||
wxHIDModule::sm_keyboard->IsActive(WXK_RALT);
|
wxHIDModule::sm_keyboard->IsActive(WXK_RALT);
|
||||||
break;
|
break;
|
||||||
case WXK_CONTROL:
|
case WXK_CONTROL:
|
||||||
return wxHIDModule::sm_keyboard->IsActive(WXK_CONTROL) ||
|
return wxHIDModule::sm_keyboard->IsActive(WXK_CONTROL) ||
|
||||||
wxHIDModule::sm_keyboard->IsActive(WXK_RCONTROL);
|
wxHIDModule::sm_keyboard->IsActive(WXK_RCONTROL);
|
||||||
break;
|
break;
|
||||||
case WXK_MENU:
|
case WXK_MENU:
|
||||||
return wxHIDModule::sm_keyboard->IsActive(WXK_MENU) ||
|
return wxHIDModule::sm_keyboard->IsActive(WXK_MENU) ||
|
||||||
wxHIDModule::sm_keyboard->IsActive(WXK_RMENU);
|
wxHIDModule::sm_keyboard->IsActive(WXK_RMENU);
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user