#include <IOKit/hidsystem/IOHIKeyboardMapper.h>

IOKit/hidsystem/IOHIKeyboardMapper.h Kernel.framework

Key ip/down state is tracked in a bit list. Bits are set for key-down, and cleared for key-up. The bit vector and macros for it's manipulation are defined here.
9 macros · 3 typedefs · 2 enums · 2 structs

typedefkbdBitVector

typedef UInt32 * kbdBitVector

macroEVK_BITS_PER_UNIT

#define EVK_BITS_PER_UNIT 32

macroEVK_BITS_MASK

#define EVK_BITS_MASK 31

macroEVK_BITS_SHIFT

#define EVK_BITS_SHIFT 5
1<<5 == 32, for cheap divide

macroEVK_KEYDOWN

#define EVK_KEYDOWN(n, bits) (bits)[((n)>>EVK_BITS_SHIFT)] |= (1 << ((n) & EVK_BITS_MASK))

macroEVK_KEYUP

#define EVK_KEYUP(n, bits) (bits)[((n)>>EVK_BITS_SHIFT)] &= ~(1 << ((n) & EVK_BITS_MASK))

macroEVK_IS_KEYDOWN

#define EVK_IS_KEYDOWN(n, bits) (((bits)[((n)>>EVK_BITS_SHIFT)] & (1 << ((n) & EVK_BITS_MASK))) != 0)

macrokMAX_MODIFIERS

the maximum number of modifier keys sticky keys can hold at once
#define kMAX_MODIFIERS 5

macrokNUM_SHIFTS_TO_ACTIVATE

the number of shift keys in a row that must be depressed to toggle state
#define kNUM_SHIFTS_TO_ACTIVATE 5

macrokDEFAULT_SHIFTEXPIREINTERVAL

the number of milliseconds all the shifts must be pressed in - 30 seconds (30000 mS)
#define kDEFAULT_SHIFTEXPIREINTERVAL 30000

enum(anonymous)

sticky keys state flags
underlying type unsigned int
kState_Disabled_Flag1disabled and will do nothing until this is changed
kState_ShiftActivates_Flag2the 'on' gesture (5 shifts) will activate
kState_On4currently on, will hold down modifiers when pressed
kState_On_ModifiersDown8one or more modifiers being held down
kState_Mask255mask for all states

struct_stickyKeys_ToggleInfo

size 40, align 8
IOByteCountsizesize of this allocation
unsigned inttoggleModifierwhich modifier key we are tracking (using NX_WHICHMODMASK)
unsigned intrepetitionsToTogglethe number of times the modifier must be pressed to toggle
AbsoluteTimeexpireIntervalhow long the user has to press the modifier repetitionsToToggle times the default is 30 seconds
unsigned intcurrentCountthe number of times the modifier used within the alloted time
AbsoluteTime[1]deadlinesthe times that the last shift must occer for this one to be used this array will actually be of size repetitionsToToggle

typedefStickyKeys_ToggleInfo

typedef struct _stickyKeys_ToggleInfo StickyKeys_ToggleInfo;

enum(anonymous)

Flags for each sticky key modifier This will allow for chording of keys and for key locking
underlying type unsigned int
kModifier_DidPerformModifiy1
kModifier_DidKeyUp2
kModifier_Locked4

struct_stickyKeys_ModifierInfo

size 3, align 1
UInt8keyKey code of the sticky modifier
UInt8stateThe state of the sticky modifier
UInt8leftModBitSystem Mod bit of the sticky modifier

typedefStickyKeys_ModifierInfo

typedef struct _stickyKeys_ModifierInfo StickyKeys_ModifierInfo;