IOHIKeyboardMapper.h [plain text]
#ifndef _IOHIKEYBOARDMAPPER_H
#define _IOHIKEYBOARDMAPPER_H
#include <IOKit/hidsystem/ev_keymap.h>
#include <IOKit/hidsystem/IOLLEvent.h>
#include <IOKit/IOTimerEventSource.h>
#include <IOKit/IOInterruptEventSource.h>
class IOHIKeyboard;
class IOHIDSystem;
typedef UInt32 * kbdBitVector;
#define EVK_BITS_PER_UNIT 32
#define EVK_BITS_MASK 31
#define EVK_BITS_SHIFT 5 // 1<<5 == 32, for cheap divide
#define EVK_KEYDOWN(n, bits) \
(bits)[((n)>>EVK_BITS_SHIFT)] |= (1 << ((n) & EVK_BITS_MASK))
#define EVK_KEYUP(n, bits) \
(bits)[((n)>>EVK_BITS_SHIFT)] &= ~(1 << ((n) & EVK_BITS_MASK))
#define EVK_IS_KEYDOWN(n, bits) \
(((bits)[((n)>>EVK_BITS_SHIFT)] & (1 << ((n) & EVK_BITS_MASK))) != 0)
#define kMAX_MODIFIERS 5
#define kNUM_SHIFTS_TO_ACTIVATE 5
#define kDEFAULT_SHIFTEXPIREINTERVAL 30000
enum
{
kState_Disabled_Flag = 0x0001, kState_ShiftActivates_Flag = 0x0002, kState_On = 0x0004, kState_On_ModifiersDown = 0x0008, kState_Mask = 0x00FF, };
typedef struct _stickyKeys_ToggleInfo
{
IOByteCount size;
unsigned toggleModifier;
unsigned repetitionsToToggle;
AbsoluteTime expireInterval;
unsigned currentCount;
AbsoluteTime deadlines[1];
} StickyKeys_ToggleInfo;
enum
{
kModifier_DidPerformModifiy = 0x01,
kModifier_DidKeyUp = 0x02,
kModifier_Locked = 0x04,
};
typedef struct _stickyKeys_ModifierInfo
{
UInt8 key; UInt8 state; UInt8 leftModBit; } StickyKeys_ModifierInfo;
class IOHIDKeyboardDevice;
class __kpi_deprecated ("Use DriverKit") IOHIKeyboardMapper : public OSObject
{
OSDeclareDefaultStructors(IOHIKeyboardMapper);
private:
IOHIKeyboard * _delegate; bool _mappingShouldBeFreed; NXParsedKeyMapping _parsedMapping;
struct ExpansionData {
kbdBitVector cached_KeyBits;
UInt32 specialKeyModifierFlags;
SInt32 modifierSwap_Modifiers[NX_NUMMODIFIERS];
unsigned char * cachedAlphaLockModDefs;
};
ExpansionData * _reserved;
public:
static IOHIKeyboardMapper * keyboardMapper(
IOHIKeyboard * delegate,
const UInt8 * mapping,
UInt32 mappingLength,
bool mappingShouldBeFreed );
virtual bool init(IOHIKeyboard * delegate,
const UInt8 * mapping,
UInt32 mappingLength,
bool mappingShouldBeFreed);
virtual void free(void) APPLE_KEXT_OVERRIDE;
virtual const UInt8 * mapping();
virtual UInt32 mappingLength();
virtual bool serialize(OSSerialize *s) const APPLE_KEXT_OVERRIDE;
virtual void translateKeyCode(UInt8 key, bool keyDown, kbdBitVector keyBits);
virtual UInt8 getParsedSpecialKey(UInt8 logical);
virtual void setKeyboardTarget (IOService * keyboardTarget);
virtual bool updateProperties (void);
virtual IOReturn setParamProperties (OSDictionary * dict);
virtual void keyEventPostProcess (void);
private:
static void makeNumberParamProperty( OSDictionary * dict, const char * key,
unsigned long long number, unsigned int bits );
virtual bool parseKeyMapping(const UInt8 * mapping,
UInt32 mappingLength,
NXParsedKeyMapping * parsedMapping) const;
virtual void calcModBit(int bit, kbdBitVector keyBits);
virtual void doModCalc(int key, kbdBitVector keyBits);
virtual void doCharGen(int keyCode, bool down);
private:
void rawTranslateKeyCode (UInt8 key, bool keyDown, kbdBitVector keyBits);
void postKeyboardSpecialEvent (unsigned subtype, unsigned eventType=NX_SYSDEFINED);
private:
private:
public:
OSMetaClassDeclareReservedUsed(IOHIKeyboardMapper, 0);
virtual IOReturn message( UInt32 type, IOService * provider, void * argument = 0 );
OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 1);
OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 2);
OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 3);
OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 4);
OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 5);
OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 6);
OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 7);
OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 8);
OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 9);
OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 10);
OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 11);
OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 12);
OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 13);
OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 14);
OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 15);
};
#endif // _IOHIKEYBOARDMAPPER_H