IOHIDEventService.h [plain text]
#ifndef _IOKIT_HID_IOHIDEVENTSERVICE_H
#define _IOKIT_HID_IOHIDEVENTSERVICE_H
#include <TargetConditionals.h>
#include <IOKit/IOService.h>
#include <IOKit/IOWorkLoop.h>
#include <IOKit/IOTimerEventSource.h>
#include <IOKit/hidsystem/IOHIDTypes.h>
#include <IOKit/hid/IOHIDInterface.h>
#include <IOKit/hid/IOHIDElement.h>
#include <IOKit/hid/IOHIDKeys.h>
#include <IOKit/hid/IOHIDEvent.h>
#include "IOHIDUtility.h"
enum
{
kHIDDispatchOptionPointerNoAcceleration = 0x01,
kHIDDispatchOptionPointerDisplayIntegrated = 0x02,
kHIDDispatchOptionPointerAffixToScreen = kHIDDispatchOptionPointerDisplayIntegrated,
kHIDDispatchOptionPointerAbsolutToRelative = 0x04
};
enum
{
kHIDDispatchOptionScrollNoAcceleration = (1<<0),
kHIDDispatchOptionScrollMomentumAny = 0x00e,
kHIDDispatchOptionScrollMomentumContinue = (1<<1),
kHIDDispatchOptionScrollMomentumStart = (1<<2),
kHIDDispatchOptionScrollMomentumEnd = (1<<3),
kHIDDispatchOptionPhaseAny = 0xff0,
kHIDDispatchOptionPhaseBegan = (1<<4),
kHIDDispatchOptionPhaseChanged = (1<<5),
kHIDDispatchOptionPhaseEnded = (1<<6),
kHIDDispatchOptionPhaseCanceled = (1<<7),
kHIDDispatchOptionPhaseMayBegin = (1<<11),
kHIDDispatchOptionDeliveryNotificationForce = (1<<30),
kHIDDispatchOptionDeliveryNotificationSuppress = (1<<31)
};
enum
{
kHIDDispatchOptionKeyboardNoRepeat = (1<<0)
};
enum
{
kHIDShutdownDebugModeStackshots = 1,
kHIDShutdownDebugModePanic,
kHIDShutdownDebugModeDisabled
};
class IOHIDEventService;
class IOHIDPointing;
class IOHIDKeyboard;
class IOHIDConsumer;
struct TransducerData;
struct KeyValueMask {
Key key;
uint32_t mask;
};
typedef void (*DebugKeyActionProc) (IOHIDEventService *self, void * parameter);
struct DebugKeyAction {
uint32_t mask;
DebugKeyActionProc action;
void* parameter;
};
class IOHIDEventService: public IOService
{
OSDeclareAbstractStructors( IOHIDEventService )
friend class IOHIDPointing;
friend class IOHIDKeyboard;
friend class IOHIDConsumer;
friend class AppleEmbeddedKeyboard;
friend class IOHIDEventServiceUserClient;
private:
IOHIDKeyboard * _keyboardNub;
IOHIDPointing * _pointingNub;
IOHIDConsumer * _consumerNub;
IONotifier * _publishNotify;
IORecursiveLock * _nubLock;
void * _reserved0;
bool _readyForInputReports;
struct ExpansionData {
IOService * provider;
IOWorkLoop * workLoop;
OSArray * deviceUsagePairs;
IOCommandGate * commandGate;
OSDictionary * clientDict;
struct {
UInt32 deviceID;
bool range;
bool touch;
SInt32 x;
SInt32 y;
SInt32 z;
} digitizer;
struct {
#if TARGET_OS_EMBEDDED
struct {
UInt32 startMask;
UInt32 mask;
UInt32 nmiMask;
UInt32 nmiDelay;
IOTimerEventSource * nmiTimer;
UInt32 stackshotHeld;
IOTimerEventSource * stackshotTimer;
UInt32 shutdownDebugMode;
UInt32 shutdownDebugKeyMask;
UInt32 shutdownDebugDelay;
IOTimerEventSource * shutdownDebugTimer;
} debug;
bool swapISO;
#else
Key pressedKeys[10];
UInt32 pressedKeysMask;
#endif
bool appleVendorSupported;
} keyboard;
struct {
IOFixed x;
IOFixed y;
IOFixed z;
IOFixed rX;
IOFixed rY;
IOFixed rZ;
UInt32 buttonState;
IOOptionBits options;
IOTimerEventSource * timer;
} multiAxis;
struct {
UInt32 buttonState;
} relativePointer;
#if !TARGET_OS_EMBEDDED
struct {
UInt32 buttonState;
} absolutePointer;
int pointingShim;
int keyboardShim;
#endif
};
#if !TARGET_OS_EMBEDDED
static KeyValueMask keyMonitorTable[];
static DebugKeyAction debugKeyActionTable[];
#endif
ExpansionData * _reserved;
IOHIDPointing * newPointingShim (
UInt32 buttonCount = 1,
IOFixed pointerResolution = (400 << 16),
IOFixed scrollResolution = 0,
IOOptionBits options = 0 );
IOHIDKeyboard * newKeyboardShim (
UInt32 supportedModifiers = 0,
IOOptionBits options = 0 );
IOHIDConsumer * newConsumerShim ( IOOptionBits options = 0 );
void parseSupportedElements (
OSArray * elementArray,
UInt32 bootProtocol );
void processTabletElement ( IOHIDElement * element );
IOFixed determineResolution ( IOHIDElement * element );
static bool _publishMatchingNotificationHandler(void * target, void * ref, IOService * newService, IONotifier * notifier);
#if TARGET_OS_EMBEDDED
void debuggerTimerCallback(IOTimerEventSource *sender);
void stackshotTimerCallback(IOTimerEventSource *sender);
#if TARGET_OS_IPHONE
void forcedShutdownDebugTimerCallback(IOTimerEventSource *sender);
void forcedShutdownDebugInit();
#endif
#endif
void multiAxisTimerCallback(IOTimerEventSource *sender);
void calculateStandardType();
protected:
virtual void free();
virtual bool handleOpen(IOService * client,
IOOptionBits options,
void * argument);
virtual void handleClose(IOService * client, IOOptionBits options);
virtual bool handleIsOpen(const IOService * client) const;
virtual bool handleStart( IOService * provider );
virtual void handleStop( IOService * provider );
virtual OSString * getTransport ();
virtual UInt32 getLocationID ();
virtual UInt32 getVendorID ();
virtual UInt32 getVendorIDSource ();
virtual UInt32 getProductID ();
virtual UInt32 getVersion ();
virtual UInt32 getCountryCode ();
virtual OSString * getManufacturer ();
virtual OSString * getProduct ();
virtual OSString * getSerialNumber ();
virtual OSArray * getReportElements();
virtual IOReturn setElementValue (
UInt32 usagePage,
UInt32 usage,
UInt32 value );
virtual UInt32 getElementValue (
UInt32 usagePage,
UInt32 usage );
virtual void dispatchKeyboardEvent(
AbsoluteTime timeStamp,
UInt32 usagePage,
UInt32 usage,
UInt32 value,
IOOptionBits options = 0 );
virtual void dispatchRelativePointerEvent(
AbsoluteTime timeStamp,
SInt32 dx,
SInt32 dy,
UInt32 buttonState,
IOOptionBits options = 0 );
void dispatchRelativePointerEventWithFixed(
AbsoluteTime timeStamp,
IOFixed dx,
IOFixed dy,
UInt32 buttonState,
IOOptionBits options = 0 );
virtual void dispatchAbsolutePointerEvent(
AbsoluteTime timeStamp,
SInt32 x,
SInt32 y,
IOGBounds * bounds,
UInt32 buttonState,
bool inRange,
SInt32 tipPressure,
SInt32 tipPressureMin,
SInt32 tipPressureMax,
IOOptionBits options = 0 );
virtual void dispatchScrollWheelEvent(
AbsoluteTime timeStamp,
SInt32 deltaAxis1,
SInt32 deltaAxis2,
SInt32 deltaAxis3,
IOOptionBits options = 0 );
void dispatchScrollWheelEventWithFixed(
AbsoluteTime timeStamp,
IOFixed deltaAxis1,
IOFixed deltaAxis2,
IOFixed deltaAxis3,
IOOptionBits options = 0 );
virtual void dispatchTabletPointerEvent(
AbsoluteTime timeStamp,
UInt32 transducerID,
SInt32 x,
SInt32 y,
SInt32 z,
IOGBounds * bounds,
UInt32 buttonState,
SInt32 tipPressure,
SInt32 tipPressureMin,
SInt32 tipPressureMax,
SInt32 barrelPressure,
SInt32 barrelPressureMin,
SInt32 barrelPressureMax,
SInt32 tiltX,
SInt32 tiltY,
UInt32 twist,
IOOptionBits options = 0 );
virtual void dispatchTabletProximityEvent(
AbsoluteTime timeStamp,
UInt32 transducerID,
bool inRange,
bool invert,
UInt32 vendorTransducerUniqueID = 0,
UInt32 vendorTransducerSerialNumber = 0,
IOOptionBits options = 0 );
public:
bool readyForReports();
virtual bool init(OSDictionary * properties = 0);
virtual bool start( IOService * provider );
virtual void stop( IOService * provider );
virtual bool matchPropertyTable(OSDictionary * table, SInt32 * score);
virtual IOReturn setSystemProperties( OSDictionary * properties );
virtual IOReturn setProperties( OSObject * properties );
virtual IOReturn newUserClient(
task_t owningTask,
void * securityID,
UInt32 type,
OSDictionary * properties,
IOUserClient ** handler );
protected:
OSMetaClassDeclareReservedUsed(IOHIDEventService, 0);
virtual OSArray * getDeviceUsagePairs();
OSMetaClassDeclareReservedUsed(IOHIDEventService, 1);
virtual UInt32 getReportInterval();
OSMetaClassDeclareReservedUsed(IOHIDEventService, 2);
enum {
kMultiAxisOptionRotationForTranslation = (1<<0),
kMultiAxisOptionZForScroll = (1<<1)
};
virtual void dispatchMultiAxisPointerEvent(
AbsoluteTime timeStamp,
UInt32 buttonState,
IOFixed x,
IOFixed y,
IOFixed z,
IOFixed rX = 0,
IOFixed rY = 0,
IOFixed rZ = 0,
IOOptionBits options = 0 );
enum {
kDigitizerInvert = (1<<0),
kDigitizerCapabilityButtons = (1<<16),
kDigitizerCapabilityPressure = (1<<16),
kDigitizerCapabilityTangentialPressure = (1<<16),
kDigitizerCapabilityZ = (1<<16),
kDigitizerCapabilityTiltX = (1<<16),
kDigitizerCapabilityTiltY = (1<<16),
kDigitizerCapabilityTwist = (1<<16),
};
enum {
kDigitizerTransducerTypeStylus = 0,
kDigitizerTransducerTypePuck,
kDigitizerTransducerTypeFinger,
kDigitizerTransducerTypeHand
};
typedef UInt32 DigitizerTransducerType;
OSMetaClassDeclareReservedUsed(IOHIDEventService, 3);
virtual void dispatchDigitizerEvent(
AbsoluteTime timeStamp,
UInt32 transducerID,
DigitizerTransducerType type,
bool inRange,
UInt32 buttonState,
IOFixed x,
IOFixed y,
IOFixed z = 0,
IOFixed tipPressure = 0,
IOFixed auxPressure = 0,
IOFixed twist = 0,
IOOptionBits options = 0 );
OSMetaClassDeclareReservedUsed(IOHIDEventService, 4);
virtual void dispatchDigitizerEventWithTiltOrientation(
AbsoluteTime timeStamp,
UInt32 ID,
DigitizerTransducerType type,
bool inRange,
UInt32 buttonState,
IOFixed x,
IOFixed y,
IOFixed z = 0,
IOFixed tipPressure = 0, IOFixed auxPressure = 0, IOFixed twist = 0,
IOFixed tiltX = 0,
IOFixed tiltY = 0,
IOOptionBits options = 0 );
OSMetaClassDeclareReservedUsed(IOHIDEventService, 5);
virtual void dispatchDigitizerEventWithPolarOrientation(
AbsoluteTime timeStamp,
UInt32 transducerID,
DigitizerTransducerType type,
bool inRange,
UInt32 buttonState,
IOFixed x,
IOFixed y,
IOFixed z = 0,
IOFixed tipPressure = 0, IOFixed tanPressure = 0, IOFixed twist = 0,
IOFixed altitude = 0,
IOFixed azimuth = 0,
IOOptionBits options = 0 );
OSMetaClassDeclareReservedUsed(IOHIDEventService, 6);
enum {
kUnicodeEncodingTypeUTF8 = 0,
kUnicodeEncodingTypeUTF16LE,
kUnicodeEncodingTypeUTF16BE,
kUnicodeEncodingTypeUTF32LE,
kUnicodeEncodingTypeUTF32BE,
};
typedef UInt32 UnicodeEncodingType;
virtual void dispatchUnicodeEvent(
AbsoluteTime timeStamp,
UInt8 * payload,
UInt32 length,
UnicodeEncodingType encoding = kUnicodeEncodingTypeUTF16LE,
IOFixed quality = (1<<16),
IOOptionBits options = 0);
private:
enum {
kDigitizerOrientationTypeTilt = 0,
kDigitizerOrientationTypePolar,
kDigitizerOrientationTypeQuality
};
typedef UInt32 DigitizerOrientationType;
void dispatchDigitizerEventWithOrientation(
AbsoluteTime timeStamp,
UInt32 transducerID,
DigitizerTransducerType type,
bool inRange,
UInt32 buttonState,
IOFixed x,
IOFixed y,
IOFixed z = 0,
IOFixed tipPressure = 0,
IOFixed auxPressure = 0,
IOFixed twist = 0,
DigitizerOrientationType orientationType = kDigitizerOrientationTypeTilt,
IOFixed * orientationParams = NULL,
UInt32 orientationParamCount = 0,
IOOptionBits options = 0 );
public:
typedef void (*Action)(OSObject *target, OSObject * sender, void *context, OSObject *event, IOOptionBits options);
OSMetaClassDeclareReservedUsed(IOHIDEventService, 7);
virtual bool open(
IOService * client,
IOOptionBits options,
void * context,
Action action);
protected:
OSMetaClassDeclareReservedUsed(IOHIDEventService, 8);
virtual void dispatchEvent(IOHIDEvent * event, IOOptionBits options=0);
OSMetaClassDeclareReservedUsed(IOHIDEventService, 9);
virtual UInt32 getPrimaryUsagePage();
OSMetaClassDeclareReservedUsed(IOHIDEventService, 10);
virtual UInt32 getPrimaryUsage();
#if !TARGET_OS_EMBEDDED
static void debugActionSysdiagnose(IOHIDEventService* self, void *parameter);
static void debugActionNMI(IOHIDEventService* self, void *parameter);
#endif
public:
OSMetaClassDeclareReservedUsed(IOHIDEventService, 11);
virtual IOHIDEvent * copyEvent(
IOHIDEventType type,
IOHIDEvent * matching = 0,
IOOptionBits options = 0);
protected:
OSMetaClassDeclareReservedUsed(IOHIDEventService, 12);
virtual void dispatchStandardGameControllerEvent(
AbsoluteTime timeStamp,
IOFixed dpadUp,
IOFixed dpadDown,
IOFixed dpadLeft,
IOFixed dpadRight,
IOFixed faceX,
IOFixed faceY,
IOFixed faceA,
IOFixed faceB,
IOFixed shoulderL,
IOFixed shoulderR,
IOOptionBits options = 0 );
OSMetaClassDeclareReservedUsed(IOHIDEventService, 13);
virtual void dispatchExtendedGameControllerEvent(
AbsoluteTime timeStamp,
IOFixed dpadUp,
IOFixed dpadDown,
IOFixed dpadLeft,
IOFixed dpadRight,
IOFixed faceX,
IOFixed faceY,
IOFixed faceA,
IOFixed faceB,
IOFixed shoulderL1,
IOFixed shoulderR1,
IOFixed shoulderL2,
IOFixed shoulderR2,
IOFixed joystickX,
IOFixed joystickY,
IOFixed joystickZ,
IOFixed joystickRz,
IOOptionBits options = 0 );
OSMetaClassDeclareReservedUnused(IOHIDEventService, 14);
OSMetaClassDeclareReservedUnused(IOHIDEventService, 15);
OSMetaClassDeclareReservedUnused(IOHIDEventService, 16);
OSMetaClassDeclareReservedUnused(IOHIDEventService, 17);
OSMetaClassDeclareReservedUnused(IOHIDEventService, 18);
OSMetaClassDeclareReservedUnused(IOHIDEventService, 19);
OSMetaClassDeclareReservedUnused(IOHIDEventService, 20);
OSMetaClassDeclareReservedUnused(IOHIDEventService, 21);
OSMetaClassDeclareReservedUnused(IOHIDEventService, 22);
OSMetaClassDeclareReservedUnused(IOHIDEventService, 23);
OSMetaClassDeclareReservedUnused(IOHIDEventService, 24);
OSMetaClassDeclareReservedUnused(IOHIDEventService, 25);
OSMetaClassDeclareReservedUnused(IOHIDEventService, 26);
OSMetaClassDeclareReservedUnused(IOHIDEventService, 27);
OSMetaClassDeclareReservedUnused(IOHIDEventService, 28);
OSMetaClassDeclareReservedUnused(IOHIDEventService, 29);
OSMetaClassDeclareReservedUnused(IOHIDEventService, 30);
OSMetaClassDeclareReservedUnused(IOHIDEventService, 31);
public:
virtual void close( IOService * forClient, IOOptionBits options = 0 );
private:
bool openGated( IOService *client, IOOptionBits *pOptions, void *context, Action action);
void closeGated( IOService * forClient, IOOptionBits *pOptions);
};
#endif