Root/
Source at commit 1902 created 12 years 4 months ago. By ifabio, Package: - Added fa.po: Farsi Language (44% Completed) - Update ro.po: Russian Language (93% Completed) | |
---|---|
1 | /*␊ |
2 | * @APPLE_LICENSE_HEADER_START@␊ |
3 | * ␊ |
4 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.␊ |
5 | * ␊ |
6 | * This file contains Original Code and/or Modifications of Original Code␊ |
7 | * as defined in and that are subject to the Apple Public Source License␊ |
8 | * Version 2.0 (the 'License'). You may not use this file except in␊ |
9 | * compliance with the License. Please obtain a copy of the License at␊ |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this␊ |
11 | * file.␊ |
12 | * ␊ |
13 | * The Original Code and all software distributed under the License are␊ |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER␊ |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,␊ |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,␊ |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.␊ |
18 | * Please see the License for the specific language governing rights and␊ |
19 | * limitations under the License.␊ |
20 | * ␊ |
21 | * @APPLE_LICENSE_HEADER_END@␊ |
22 | */␊ |
23 | #ifndef _IOHIKEYBOARDMAPPER_H␊ |
24 | #define _IOHIKEYBOARDMAPPER_H␊ |
25 | ␊ |
26 | #include <IOKit/hidsystem/ev_keymap.h>␊ |
27 | #include <IOKit/hidsystem/IOLLEvent.h>␊ |
28 | #include <IOKit/IOTimerEventSource.h>␊ |
29 | #include <IOKit/IOInterruptEventSource.h>␊ |
30 | ␊ |
31 | class IOHIKeyboard;␊ |
32 | class IOHIDSystem;␊ |
33 | ␊ |
34 | /*␊ |
35 | * Key ip/down state is tracked in a bit list. Bits are set␊ |
36 | * for key-down, and cleared for key-up. The bit vector and macros␊ |
37 | * for it's manipulation are defined here.␊ |
38 | */␊ |
39 | ␊ |
40 | typedef␉UInt32 * kbdBitVector;␊ |
41 | ␊ |
42 | #define EVK_BITS_PER_UNIT␉32␊ |
43 | #define EVK_BITS_MASK␉␉31␊ |
44 | #define EVK_BITS_SHIFT␉␉5␉// 1<<5 == 32, for cheap divide␊ |
45 | ␊ |
46 | #define EVK_KEYDOWN(n, bits) \␊ |
47 | ␉(bits)[((n)>>EVK_BITS_SHIFT)] |= (1 << ((n) & EVK_BITS_MASK))␊ |
48 | ␊ |
49 | #define EVK_KEYUP(n, bits) \␊ |
50 | ␉(bits)[((n)>>EVK_BITS_SHIFT)] &= ~(1 << ((n) & EVK_BITS_MASK))␊ |
51 | ␊ |
52 | #define EVK_IS_KEYDOWN(n, bits) \␊ |
53 | ␉(((bits)[((n)>>EVK_BITS_SHIFT)] & (1 << ((n) & EVK_BITS_MASK))) != 0)␊ |
54 | ␊ |
55 | /* the maximum number of modifier keys sticky keys can hold at once */␊ |
56 | #define kMAX_MODIFIERS␉␉␉␉␉5␊ |
57 | ␊ |
58 | /* the number of shift keys in a row that must be depressed to toggle state */␊ |
59 | #define kNUM_SHIFTS_TO_ACTIVATE␉␉␉5␊ |
60 | ␊ |
61 | /* the number of milliseconds all the shifts must be pressed in - 30 seconds (30000 mS)*/␊ |
62 | #define kDEFAULT_SHIFTEXPIREINTERVAL␉30000␊ |
63 | ␊ |
64 | ␊ |
65 | // sticky keys state flags␊ |
66 | enum␊ |
67 | {␊ |
68 | kState_Disabled_Flag␉= 0x0001,␉// disabled and will do nothing until this is changed␊ |
69 | kState_ShiftActivates_Flag␉= 0x0002,␉// the 'on' gesture (5 shifts) will activate␊ |
70 | kState_On␉␉␉= 0x0004,␉// currently on, will hold down modifiers when pressed␊ |
71 | kState_On_ModifiersDown␉= 0x0008,␉// one or more modifiers being held down␊ |
72 | ␊ |
73 | kState_Mask␉␉␉= 0x00FF,␉// mask for all states␊ |
74 | };␊ |
75 | ␊ |
76 | typedef struct _stickyKeys_ToggleInfo␊ |
77 | {␊ |
78 | ␉// size of this allocation␊ |
79 | ␉IOByteCount␉␉size;␊ |
80 | ␊ |
81 | ␉// which modifier key we are tracking (using NX_WHICHMODMASK)␊ |
82 | ␉unsigned␉␉toggleModifier;␊ |
83 | ␊ |
84 | ␉// the number of times the modifier must be pressed to toggle␊ |
85 | ␉unsigned␉␉repetitionsToToggle;␊ |
86 | ␊ |
87 | ␉// how long the user has to press the modifier repetitionsToToggle times␊ |
88 | ␉// the default is 30 seconds␊ |
89 | ␉AbsoluteTime␉expireInterval;␊ |
90 | ␊ |
91 | ␉// the number of times the modifier used within the alloted time␊ |
92 | ␉unsigned␉␉currentCount;␊ |
93 | ␊ |
94 | ␉// the times that the last shift must occer for this one to be used␊ |
95 | ␉// this array will actually be of size repetitionsToToggle␊ |
96 | ␉AbsoluteTime␉deadlines[1];␊ |
97 | } StickyKeys_ToggleInfo;␊ |
98 | ␊ |
99 | // Flags for each sticky key modifier␊ |
100 | // This will allow for chording of keys␊ |
101 | // and for key locking␊ |
102 | enum␊ |
103 | {␊ |
104 | kModifier_DidPerformModifiy␉= 0x01,␊ |
105 | kModifier_DidKeyUp␉␉= 0x02,␊ |
106 | kModifier_Locked␉␉= 0x04,␊ |
107 | };␊ |
108 | typedef struct _stickyKeys_ModifierInfo␊ |
109 | {␊ |
110 | ␉UInt8␉␉key;␉␉// Key code of the sticky modifier␊ |
111 | UInt8␉␉state;␉␉// The state of the sticky modifier␊ |
112 | UInt8␉␉leftModBit;␉// System Mod bit of the sticky modifier␊ |
113 | } StickyKeys_ModifierInfo;␊ |
114 | ␊ |
115 | class IOHIDKeyboardDevice;␊ |
116 | ␊ |
117 | class IOHIKeyboardMapper : public OSObject␊ |
118 | {␊ |
119 | OSDeclareDefaultStructors(IOHIKeyboardMapper);␊ |
120 | ␊ |
121 | private:␊ |
122 | ␉IOHIKeyboard *␉␉_delegate;␉␉␉␉␉// KeyMap delegate␊ |
123 | ␉bool␉␉␉␉_mappingShouldBeFreed;␉␉// true if map can be IOFree'd␊ |
124 | ␉NXParsedKeyMapping␉_parsedMapping;␉␉␉␉// current system-wide keymap␊ |
125 | ␉IOHIDSystem␉ *␉␉_hidSystem;␉␉␉␉␉// target of IOHIKeyboard (should be IOHIDSystem)␊ |
126 | ␉␊ |
127 | ␉// binary compatibility padding␊ |
128 | struct ExpansionData { ␊ |
129 | ␊ |
130 | // This is for F12 eject␊ |
131 | ␉UInt16 ␉␉␉f12Eject_State;␊ |
132 | ␉UInt32 ␉␉␉eject_Delay_MS;␊ |
133 | ␉IOTimerEventSource ␉*ejectTimerEventSource;␊ |
134 | ␊ |
135 | // This is for sticky keys␊ |
136 | kbdBitVector␉␉cached_KeyBits;␊ |
137 | StickyKeys_ModifierInfo stickyKeys_StuckModifiers[kMAX_MODIFIERS];␊ |
138 | IOInterruptEventSource *stickyKeysMouseClickEventSource;␊ |
139 | IOInterruptEventSource␉*stickyKeysSetFnStateEventSource;␊ |
140 | // The following should really be statics, but placing here ␊ |
141 | // to match design by predecesor.␊ |
142 | OSDictionary␉␉*offFnParamDict;␊ |
143 | OSDictionary␉␉*onFnParamDict;␊ |
144 | ␊ |
145 | // This is for SlowKeys␊ |
146 | UInt16␉␉␉slowKeys_State;␊ |
147 | UInt32 ␉␉␉slowKeys_Delay_MS;␊ |
148 | IOTimerEventSource␉*slowKeysTimerEventSource;␊ |
149 | ␊ |
150 | // stored for slowKeysPostProcess␊ |
151 | UInt8␉␉slowKeys_Aborted_Key;␊ |
152 | UInt8␉␉slowKeys_Current_Key; ␊ |
153 | ␊ |
154 | UInt32␉␉specialKeyModifierFlags;␊ |
155 | ␊ |
156 | bool␉␉supportsF12Eject;␊ |
157 | ␊ |
158 | SInt32 modifierSwap_Modifiers[NX_NUMMODIFIERS];␊ |
159 | ␉␉␊ |
160 | ␉␉unsigned char * cachedAlphaLockModDefs;␊ |
161 | };␊ |
162 | ExpansionData * _reserved;␉␉␉␉ // Reserved for future use. (Internal use only)␊ |
163 | ␊ |
164 | public:␊ |
165 | ␉static IOHIKeyboardMapper * keyboardMapper(␊ |
166 | ␉␉␉␉␉␉␉␉␉␉IOHIKeyboard * delegate,␊ |
167 | ␉␉␉␉␉␉␉␉␉␉const UInt8 * mapping,␊ |
168 | ␉␉␉␉␉␉␉␉␉␉UInt32 mappingLength,␊ |
169 | ␉␉␉␉␉␉␉␉␉␉bool mappingShouldBeFreed );␊ |
170 | ␉␊ |
171 | ␉virtual bool init(IOHIKeyboard * delegate,␊ |
172 | ␉␉␉␉␉const UInt8 * mapping,␊ |
173 | ␉␉␉␉␉ UInt32 mappingLength,␊ |
174 | ␉␉␉␉␉ bool mappingShouldBeFreed);␊ |
175 | ␉virtual void free();␊ |
176 | ␉␊ |
177 | ␉virtual const UInt8 * mapping();␊ |
178 | ␉virtual UInt32 mappingLength();␊ |
179 | ␉virtual bool ␉␉ ␉serialize(OSSerialize *s) const;␊ |
180 | ␉␊ |
181 | ␉virtual void ␉␉translateKeyCode(UInt8 key, bool keyDown, kbdBitVector keyBits);␊ |
182 | ␉virtual UInt8 ␉␉getParsedSpecialKey(UInt8 logical); //retrieve a key from _parsedMapping␊ |
183 | ␊ |
184 | ␉virtual␉void␉␉setKeyboardTarget (IOService * keyboardTarget);␊ |
185 | ␉␊ |
186 | ␉virtual bool ␉ updateProperties (void);␊ |
187 | ␉virtual IOReturn ␉setParamProperties (OSDictionary * dict);␊ |
188 | ␉␊ |
189 | ␉// keyEventPostProcess is called while a lock is not held, so a recursive␊ |
190 | ␉// call back into HIKeyboard is possible␊ |
191 | ␉virtual void ␉ keyEventPostProcess (void);␊ |
192 | ␊ |
193 | private:␊ |
194 | ␉static void makeNumberParamProperty( OSDictionary * dict, const char * key,␊ |
195 | unsigned long long number, unsigned int bits );␊ |
196 | ␊ |
197 | ␊ |
198 | ␉virtual bool parseKeyMapping(const UInt8 * mapping,␊ |
199 | ␉␉␉␉␉␉␉␉ UInt32 mappingLength,␊ |
200 | ␉␉␉␉␉␉␉ NXParsedKeyMapping * parsedMapping) const;␊ |
201 | ␉␊ |
202 | ␉virtual void calcModBit(int bit, kbdBitVector keyBits);␊ |
203 | ␉virtual void doModCalc(int key, kbdBitVector keyBits);␊ |
204 | ␉virtual void doCharGen(int keyCode, bool down);␊ |
205 | ␊ |
206 | ␉/* sticky keys functionality */␊ |
207 | private:␊ |
208 | ␉// original translateKeyCode␊ |
209 | ␉void rawTranslateKeyCode (UInt8 key, bool keyDown, kbdBitVector keyBits);␊ |
210 | bool modifierSwapFilterKey(UInt8 * key);␊ |
211 | ␊ |
212 | ␉// the current state of stickyKeys␊ |
213 | ␉UInt32 ␉_stickyKeys_State; ␊ |
214 | ␉␊ |
215 | ␉// the number of modifiers being held down by stickyKeys␊ |
216 | ␉int␉␉ ␉␉_stickyKeys_NumModifiersDown;␊ |
217 | ␊ |
218 | //////////////////////////////////////////////////////////////␊ |
219 | // THE FOLLOWING CLASS VARIABLE HAS BEEN DEPRECATED␊ |
220 | //␊ |
221 | // PLEASE USE _stickyKeys_StuckModifiers␊ |
222 | //␊ |
223 | ␉UInt8␉␉ ␉_stickyKeys_Modifiers[kMAX_MODIFIERS];␊ |
224 | //////////////////////////////////////////////////////////////␊ |
225 | ␉␊ |
226 | ␉// contains the info needed to keep track of shift repetitions␊ |
227 | ␉StickyKeys_ToggleInfo * _stickyKeys_ShiftToggle;␊ |
228 | ␊ |
229 | ␉// contains the info needed to keep track of option repetitions␊ |
230 | ␉StickyKeys_ToggleInfo * _stickyKeys_OptionToggle;␊ |
231 | ␊ |
232 | ␉// dictionaries with cached on and off states, used to set params when state changes␊ |
233 | ␉bool␉␉␉␉_stateDirty;␊ |
234 | ␉OSDictionary *␉␉_onParamDict;␊ |
235 | ␉OSDictionary *␉␉_offParamDict;␊ |
236 | ␊ |
237 | ␉// init/free vars␊ |
238 | ␉bool stickyKeysinit (void);␊ |
239 | ␉void stickyKeysfree (void);␊ |
240 | ␊ |
241 | ␉// allocate/free a StickyKeys_ToggleInfo struct␊ |
242 | ␉static StickyKeys_ToggleInfo * stickyKeysAllocToggleInfo (unsigned maxCount);␊ |
243 | ␉static void stickyKeysFreeToggleInfo (StickyKeys_ToggleInfo * toggleInfo);␊ |
244 | ␊ |
245 | ␉// create on/off dicts as part of init␊ |
246 | ␉bool createParamDicts (void);␊ |
247 | ␊ |
248 | ␉// post special keyboard events thru the event system␊ |
249 | ␉void postKeyboardSpecialEvent (unsigned subtype, unsigned eventType=NX_SYSDEFINED);␊ |
250 | ␊ |
251 | ␉// check any modifier to see if it is pressed 5 times␊ |
252 | ␉// based on StickyKeys_ToggleInfo␊ |
253 | ␉bool stickyKeysModifierToggleCheck(␊ |
254 | ␉␉␉␉␉␉␉StickyKeys_ToggleInfo * toggleInfo,␊ |
255 | ␉␉␉␉␉␉␉UInt8 key,␊ |
256 | ␉␉␉␉␉␉␉bool keyDown,␊ |
257 | ␉␉␉␉␉␉␉kbdBitVector keyBits,␊ |
258 | bool ␉ mouseClick = false);␊ |
259 | ␊ |
260 | ␉// non-modifier key pressed␊ |
261 | ␉void stickyKeysNonModifierKey (UInt8 key, bool keyDown, kbdBitVector keyBits, bool mouseClick = false);␊ |
262 | ␊ |
263 | ␉// modifier key pressed (shift, command, option, control)␊ |
264 | ␉bool stickyKeysModifierKey (UInt8 key, bool keyDown, kbdBitVector keyBits);␊ |
265 | ␊ |
266 | ␉// main entry point, called for all keys (returns true if key handled)␊ |
267 | ␉bool stickyKeysFilterKey (UInt8 key, bool keyDown, kbdBitVector keyBits, bool mouseClick = false);␊ |
268 | ␊ |
269 | // called by interrupt event source to inform sticky keys of mouse down event␊ |
270 | static void stickyKeysMouseUp(IOHIKeyboardMapper *owner, IOEventSource *sender);␊ |
271 | ␊ |
272 | ␉void stickyKeysCleanup();␊ |
273 | ␊ |
274 | // called by interrupt event source to restore prior fn state␊ |
275 | ␉static void stickyKeysSetFnState(IOHIKeyboardMapper *owner, IOEventSource *sender);␊ |
276 | ␊ |
277 | /* F12 Eject Functionality */ ␊ |
278 | private:␊ |
279 | ␊ |
280 | // Determining f12 eject key press␊ |
281 | // Returns true if f12 held down for a predetermined period of time.␊ |
282 | bool f12EjectFilterKey (UInt8 key, bool keyDown, kbdBitVector keyBits);␊ |
283 | ␊ |
284 | // Timer function for eject␊ |
285 | static void performF12Eject(IOHIKeyboardMapper *owner, IOTimerEventSource *sender);␊ |
286 | ␊ |
287 | /* SlowKeys Functionality */␊ |
288 | private:␊ |
289 | // Slow keys methods␊ |
290 | bool slowKeysFilterKey (UInt8 key, bool keyDown, kbdBitVector keyBits);␊ |
291 | ␊ |
292 | static void slowKeysPostProcess (IOHIKeyboardMapper *owner, IOTimerEventSource *sender);␊ |
293 | ␊ |
294 | ␉␊ |
295 | public:␉␊ |
296 | OSMetaClassDeclareReservedUsed(IOHIKeyboardMapper, 0);␊ |
297 | virtual IOReturn message( UInt32 type, IOService * provider, void * argument = 0 );␊ |
298 | ␊ |
299 | ␉// binary compatibility padding␊ |
300 | OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 1);␊ |
301 | OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 2);␊ |
302 | OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 3);␊ |
303 | OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 4);␊ |
304 | OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 5);␊ |
305 | OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 6);␊ |
306 | OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 7);␊ |
307 | OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 8);␊ |
308 | OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 9);␊ |
309 | OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 10);␊ |
310 | OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 11);␊ |
311 | OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 12);␊ |
312 | OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 13);␊ |
313 | OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 14);␊ |
314 | OSMetaClassDeclareReservedUnused(IOHIKeyboardMapper, 15);␊ |
315 | };␊ |
316 | ␊ |
317 | #endif _IOHIKEYBOARDMAPPER_H␊ |
318 | ␊ |
319 | /*␊ |
320 | * HISTORICAL NOTE:␊ |
321 | * The "delegate" object had to respond to the following protocol;␊ |
322 | * this protocol has since been merged into the IOHIKeyboard class.␊ |
323 | *␊ |
324 | * @protocol KeyMapDelegate␊ |
325 | *␊ |
326 | * - keyboardEvent␉:(unsigned)eventType␊ |
327 | * ␉flags␉:(unsigned)flags␊ |
328 | *␉keyCode␉:(unsigned)keyCode␊ |
329 | *␉charCode:(unsigned)charCode␊ |
330 | *␉charSet␉:(unsigned)charSet␊ |
331 | *␉originalCharCode:(unsigned)origCharCode␊ |
332 | *␉originalCharSet:(unsigned)origCharSet;␊ |
333 | * ␊ |
334 | * - keyboardSpecialEvent:(unsigned)eventType␊ |
335 | *␉flags␉ :(unsigned)flags␊ |
336 | *␉keyCode␉:(unsigned)keyCode␊ |
337 | *␉specialty:(unsigned)flavor;␊ |
338 | *␊ |
339 | * - updateEventFlags:(unsigned)flags;␉// Does not generate events␊ |
340 | *␊ |
341 | * - (unsigned)eventFlags;␉␉// Global event flags␊ |
342 | * - (unsigned)deviceFlags;␉␉// per-device event flags␊ |
343 | * - setDeviceFlags:(unsigned)flags;␉// Set device event flags␊ |
344 | * - (bool)alphaLock;␉␉␉// current alpha-lock state␊ |
345 | * - setAlphaLock:(bool)val;␉␉// Set current alpha-lock state␊ |
346 | * - (bool)charKeyActive;␉␉// Is a character gen. key down?␊ |
347 | * - setCharKeyActive:(bool)val;␉// Note that a char gen key is down.␊ |
348 | *␊ |
349 | * @end␊ |
350 | */␊ |
351 |