IOHIDLibUserClient.h [plain text]
#ifndef _IOKIT_IOHIDLibUserClient_H_
#define _IOKIT_IOHIDLibUserClient_H_
#include "IOHIDKeys.h"
enum IOHIDLibUserClientMemoryTypes {
kIOHIDLibUserClientElementValuesType = 0
};
enum IOHIDLibUserClientPortTypes {
kIOHIDLibUserClientAsyncPortType = 0,
kIOHIDLibUserClientDeviceValidPortType
};
enum IOHIDLibUserClientAsyncCommandCodes {
kIOHIDLibUserClientSetAsyncPort, kIOHIDLibUserClientSetQueueAsyncPort, kIOHIDLibUserClientAsyncGetReport, kIOHIDLibUserClientAsyncSetReport,
kIOHIDLibUserClientNumAsyncCommands
};
enum IOHIDLibUserClientCommandCodes {
kIOHIDLibUserClientOpen, kIOHIDLibUserClientClose, kIOHIDLibUserClientCreateQueue, kIOHIDLibUserClientDisposeQueue, kIOHIDLibUserClientAddElementToQueue, kIOHIDLibUserClientRemoveElementFromQueue, kIOHIDLibUserClientQueueHasElement, kIOHIDLibUserClientStartQueue, kIOHIDLibUserClientStopQueue, kIOHIDLibUserClientUpdateElementValue, kIOHIDLibUserClientPostElementValue, kIOHIDLibUserClientGetReport, kIOHIDLibUserClientGetReportOOL, kIOHIDLibUserClientSetReport, kIOHIDLibUserClientSetReportOOL, kIOHIDLibUserClientDeviceIsValid,
kIOHIDLibUserClientNumCommands
};
#if 0
struct IOHIDCommandExecuteData {
HIDInfo HIDInfo;
HIDResults *HIDResults;
int kernelHandle;
int sgEntries;
UInt32 timeoutMS;
IOVirtualRange sgList[0];
};
#define kIOHIDCommandExecuteDataMaxSize 1024
#endif
struct IOHIDElementValue
{
IOHIDElementCookie cookie;
UInt32 totalSize;
AbsoluteTime timestamp;
UInt32 generation;
UInt32 value[1];
};
struct IOHIDReportReq
{
UInt32 reportType;
UInt32 reportID;
void *reportBuffer;
UInt32 reportBufferSize;
};
#if KERNEL
#include <mach/mach_types.h>
#include <IOKit/IOUserClient.h>
#include <IOKit/IOInterruptEventSource.h>
class IOHIDDevice;
class IOSyncer;
#if 0
class IOCommandGate;
struct HIDResults;
#endif
enum {
kHIDQueueStateEnable,
kHIDQueueStateDisable,
kHIDQueueStateClear
};
class IOHIDLibUserClient : public IOUserClient
{
OSDeclareDefaultStructors(IOHIDLibUserClient)
bool resourceNotification(void *refCon, IOService *service);
void resourceNotificationGated();
void setStateForQueues(UInt32 state, IOOptionBits options = 0);
void setValid(bool state);
IOReturn dispatchMessage(void* message);
protected:
static const IOExternalMethod
sMethods[kIOHIDLibUserClientNumCommands];
static const IOExternalAsyncMethod
sAsyncMethods[kIOHIDLibUserClientNumAsyncCommands];
IOHIDDevice *fNub;
IOWorkLoop *fWL;
IOCommandGate *fGate;
IOInterruptEventSource * fResourceES;
OSSet * fQueueSet;
UInt32 fPid;
task_t fClient;
mach_port_t fWakePort;
mach_port_t fQueuePort;
mach_port_t fValidPort;
void * fValidMessage;
bool fNubIsTerminated;
bool fNubIsKeyboard;
IONotifier * fResourceNotification;
UInt64 fCachedConsoleUsersSeed;
IOOptionBits fCachedOptionBits;
bool fValid;
UInt32 fGeneration;
virtual bool initWithTask(task_t owningTask, void *security_id, UInt32 type);
virtual IOReturn clientClose(void);
virtual bool start(IOService *provider);
virtual IOExternalMethod * getTargetAndMethodForIndex(IOService **target, UInt32 index);
virtual IOExternalAsyncMethod * getAsyncTargetAndMethodForIndex(IOService **target, UInt32 index);
virtual IOReturn setAsyncPort(OSAsyncReference asyncRef,
void *, void *, void *,
void *, void *, void *);
virtual IOReturn setQueueAsyncPort(OSAsyncReference asyncRef,
void *vInQueue, void *, void *,
void *, void *, void *);
virtual IOReturn open(void * flags);
IOReturn openGated(IOOptionBits flags);
virtual IOReturn close();
IOReturn closeGated();
virtual bool didTerminate( IOService * provider, IOOptionBits options, bool * defer );
virtual void free();
virtual void cleanupGated();
virtual IOReturn message(UInt32 type, IOService * provider, void * argument = 0 );
virtual IOReturn messageGated(UInt32 type, IOService * provider, void * argument = 0 );
virtual IOReturn registerNotificationPort(mach_port_t port, UInt32 type, UInt32 refCon );
virtual IOReturn registerNotificationPortGated(mach_port_t port, UInt32 type, UInt32 refCon );
virtual IOReturn clientMemoryForType(
UInt32 type,
IOOptionBits * options,
IOMemoryDescriptor ** memory );
IOReturn clientMemoryForTypeGated(
UInt32 type,
IOOptionBits * options,
IOMemoryDescriptor ** memory );
virtual IOReturn deviceIsValid(void * vOutStatus, void * vOutGeneration);
IOReturn deviceIsValidGated(void * vOutStatus, void * vOutGeneration);
virtual IOReturn createQueue(void * vInFlags, void * vInDepth, void * vOutQueue);
IOReturn createQueueGated(void * vInFlags, void * vInDepth, void * vOutQueue);
virtual IOReturn disposeQueue(void * vInQueue);
IOReturn disposeQueueGated(void * vInQueue);
virtual IOReturn addElementToQueue(void * vInQueue, void * vInElementCookie, void * vInFlags, void * vSizeChange);
IOReturn addElementToQueueGated(void * vInQueue, void * vInElementCookie, void * vInFlags, void * vSizeChange);
virtual IOReturn removeElementFromQueue (void * vInQueue, void * vInElementCookie, void * vSizeChange);
IOReturn removeElementFromQueueGated (void * vInQueue, void * vInElementCookie, void * vSizeChange);
virtual IOReturn queueHasElement (void * vInQueue, void * vInElementCookie, void * vOutHasElement);
IOReturn queueHasElementGated (void * vInQueue, void * vInElementCookie, void * vOutHasElement);
virtual IOReturn startQueue (void * vInQueue);
IOReturn startQueueGated (void * vInQueue);
virtual IOReturn stopQueue (void * vInQueue);
IOReturn stopQueueGated (void * vInQueue);
virtual IOReturn updateElementValue (void *cookie);
IOReturn updateElementValueGated (void *cookie);
virtual IOReturn postElementValue (void *cookie, void * cookieBytes);
IOReturn postElementValueGated (void *cookie, void * cookieBytes);
virtual IOReturn getReport(void *vReportType, void *vReportID, void *vReportBuffer, void *vReportBufferSize);
IOReturn getReportGated (IOHIDReportType reportType,
UInt32 reportID,
void *reportBuffer,
UInt32 *reportBufferSize);
virtual IOReturn getReportOOL ( void *vReqIn, void *vSizeOut, void * vInCount, void *vOutCount);
IOReturn getReportOOLGated (IOHIDReportReq *reqIn,
UInt32 *sizeOut,
IOByteCount inCount,
IOByteCount *outCount);
virtual IOReturn setReport (void *vReportType, void *vReportID, void *vReportBuffer, void *vReportBufferSize);
IOReturn setReportGated (IOHIDReportType reportType,
UInt32 reportID,
void *reportBuffer,
UInt32 reportBufferSize);
virtual IOReturn setReportOOL (void *vReq, void *vInCount);
IOReturn setReportOOLGated (IOHIDReportReq *req, IOByteCount inCount);
virtual IOReturn asyncGetReport (OSAsyncReference asyncRef,
IOHIDReportType reportType,
UInt32 reportID,
void *reportBuffer,
UInt32 reportBufferSize,
UInt32 completionTimeOutMS);
IOReturn asyncGetReportGated (void * param);
virtual IOReturn asyncSetReport (OSAsyncReference asyncRef,
IOHIDReportType reportType,
UInt32 reportID,
void *reportBuffer,
UInt32 reportBufferSize,
UInt32 completionTimeOutMS);
IOReturn asyncSetReportGated (void * param);
void ReqComplete(void *param, IOReturn status, UInt32 remaining);
void ReqCompleteGated(void *param, IOReturn status, UInt32 remaining);
};
#endif
#endif