IOHIDDeviceClass.h [plain text]
#ifndef _IOKIT_IOHIDDeviceClass_H
#define _IOKIT_IOHIDDeviceClass_H
#include "IOHIDLib.h"
#include "IOHIDIUnknown.h"
#define IOHID_PSEUDODEVICE 0
class IOHIDQueueClass;
struct IOHIDElementStruct
{
unsigned long cookie;
long type;
long min;
long max;
long usage;
long usagePage;
long bytes;
#if IOHID_PSEUDODEVICE
long currentValue;
long pauseCount;
long increment;
#else
unsigned long valueLocation;
#endif
};
typedef struct IOHIDElementStruct IOHIDElementStruct;
class IOHIDDeviceClass : public IOHIDIUnknown
{
private:
friend class IOHIDQueueClass;
friend class IOHIDOutputTransactionClass;
IOHIDDeviceClass(IOHIDDeviceClass &src);
void operator =(IOHIDDeviceClass &src);
protected:
IOHIDDeviceClass();
virtual ~IOHIDDeviceClass();
static IOCFPlugInInterface sIOCFPlugInInterfaceV1;
static IOHIDDeviceInterface sHIDDeviceInterfaceV1;
struct InterfaceMap fHIDDevice;
io_service_t fService;
io_connect_t fConnection;
mach_port_t fAsyncPort;
CFRunLoopSourceRef fCFSource;
bool fIsOpen;
bool fIsLUNZero;
vm_address_t fCurrentValuesMappedMemory;
vm_size_t fCurrentValuesMappedMemorySize;
long fElementCount;
IOHIDElementStruct * fElements;
HRESULT queryInterfaceQueue (void **ppv);
HRESULT queryInterfaceOutputTransaction (void **ppv);
IOReturn fillElementValue(IOHIDElementCookie elementCookie,
IOHIDEventStruct * valueEvent);
void convertByteToWord( const UInt8 * src,
UInt32 * dst,
UInt32 bitsToCopy);
void convertWordToByte( const UInt32 * src,
UInt8 * dst,
UInt32 bitsToCopy);
public:
HRESULT attachQueue (IOHIDQueueClass * iohidQueue);
HRESULT detachQueue (IOHIDQueueClass * iohidQueue);
HRESULT attachOutputTransaction (IOHIDOutputTransactionClass * iohidOutputTrans);
HRESULT detachOutputTransaction (IOHIDOutputTransactionClass * iohidOutputTrans);
bool getElement(IOHIDElementCookie elementCookie, IOHIDElementStruct *element);
IOHIDElementType getElementType (IOHIDElementCookie elementCookie);
UInt32 getElementByteSize (IOHIDElementCookie elementCookie);
static IOCFPlugInInterface **alloc();
virtual HRESULT queryInterface(REFIID iid, void **ppv);
virtual IOReturn probe(CFDictionaryRef propertyTable,
io_service_t service, SInt32 *order);
virtual IOReturn start(CFDictionaryRef propertyTable,
io_service_t service);
virtual IOReturn createAsyncEventSource(CFRunLoopSourceRef *source);
virtual CFRunLoopSourceRef getAsyncEventSource();
virtual IOReturn createAsyncPort(mach_port_t *port);
virtual mach_port_t getAsyncPort();
virtual IOReturn open(UInt32 flags);
virtual IOReturn close();
virtual IOReturn setRemovalCallback(
IOHIDCallbackFunction removalCallback,
void * removalTarget,
void * removalRefcon);
virtual IOReturn getElementValue( IOHIDElementCookie elementCookie,
IOHIDEventStruct * valueEvent);
virtual IOReturn setElementValue(
IOHIDElementCookie elementCookie,
IOHIDEventStruct * valueEvent,
UInt32 timeoutMS = 0,
IOHIDElementCallbackFunction * callback = NULL,
void * callbackTargetm = NULL,
void * callbackRefcon = NULL,
bool pushToDevice = false);
virtual IOReturn queryElementValue(
IOHIDElementCookie elementCookie,
IOHIDEventStruct * valueEvent,
UInt32 timeoutMS,
IOHIDElementCallbackFunction * callback,
void * callbackTarget,
void * callbackRefcon);
virtual IOReturn startAllQueues();
virtual IOReturn stopAllQueues();
virtual IOHIDQueueInterface ** allocQueue();
virtual IOHIDOutputTransactionInterface ** allocOutputTransaction();
protected:
static inline IOHIDDeviceClass *getThis(void *self)
{ return (IOHIDDeviceClass *) ((InterfaceMap *) self)->obj; };
static IOReturn deviceProbe(void *self,
CFDictionaryRef propertyTable,
io_service_t service, SInt32 *order);
static IOReturn deviceStart(void *self,
CFDictionaryRef propertyTable,
io_service_t service);
static IOReturn deviceStop(void *self);
static IOReturn deviceCreateAsyncEventSource(void *self,
CFRunLoopSourceRef *source);
static CFRunLoopSourceRef deviceGetAsyncEventSource(void *self);
static IOReturn deviceCreateAsyncPort(void *self, mach_port_t *port);
static mach_port_t deviceGetAsyncPort(void *self);
static IOReturn deviceOpen(void *self, UInt32 flags);
static IOReturn deviceClose(void *self);
static IOReturn deviceSetRemovalCallback(void * self,
IOHIDCallbackFunction removalCallback,
void * removalTarget,
void * removalRefcon);
static IOReturn deviceGetElementValue(void * self,
IOHIDElementCookie elementCookie,
IOHIDEventStruct * valueEvent);
static IOReturn deviceSetElementValue(void * self,
IOHIDElementCookie elementCookie,
IOHIDEventStruct * valueEvent,
UInt32 timeoutMS,
IOHIDElementCallbackFunction * callback,
void * callbackTarget,
void * callbackRefcon);
static IOReturn deviceQueryElementValue(void * self,
IOHIDElementCookie elementCookie,
IOHIDEventStruct * valueEvent,
UInt32 timeoutMS,
IOHIDElementCallbackFunction * callback,
void * callbackTarget,
void * callbackRefcon);
static IOReturn deviceStartAllQueues(void * self);
static IOReturn deviceStopAllQueues(void * self);
static IOHIDQueueInterface ** deviceAllocQueue(void *self);
static IOHIDOutputTransactionInterface ** deviceAllocOutputTransaction (void *self);
static void StaticCountLeafElements (const void * value, void * parameter);
static void StaticCreateLeafElements (const void * value, void * parameter);
kern_return_t BuildElements (CFDictionaryRef properties);
long CountLeafElements (CFDictionaryRef properties, CFTypeRef element);
kern_return_t CreateLeafElements (CFDictionaryRef properties,
CFTypeRef element,
long * allocatedElementCount);
};
#endif