Root/
Source at commit 1166 created 13 years 10 days ago. By meklort, Fixed recent Makefile changes. Please do not use /Users/evan/SourceCode/tmp/chameleon/trunk or VPATH. the *only* time you should use /Users/evan/SourceCode/tmp/chameleon/trunk is when setting the SRCROOT variable. Also note that very soon make pkg is going to be removed. The pkg build script in trunk is very out of date. Instead please use the package maker at http://forge.voodooprojects.org/p/chameleonApplications/. Once this is ready for trunk it will be merged. | |
---|---|
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 | /* ␉Copyright (c) 1992 NeXT Computer, Inc. All rights reserved. ␊ |
24 | *␊ |
25 | * EventSrcPCKeyboard.h - PC Keyboard EventSrc subclass definition␊ |
26 | *␊ |
27 | * HISTORY␊ |
28 | * 28 Aug 1992 Joe Pasqua␊ |
29 | * Created. ␊ |
30 | */␊ |
31 | ␊ |
32 | #ifndef _IOHIKEYBOARD_H␊ |
33 | #define _IOHIKEYBOARD_H␊ |
34 | ␊ |
35 | #include <IOKit/hidsystem/IOHIDevice.h>␊ |
36 | #include <IOKit/hidsystem/IOHIKeyboardMapper.h>␊ |
37 | ␊ |
38 | /* Start Action Definitions */␊ |
39 | ␊ |
40 | /*␊ |
41 | * HISTORICAL NOTE:␊ |
42 | * The following entry points were part of the IOHIKeyboardEvents␊ |
43 | * protocol.␊ |
44 | */␊ |
45 | ␊ |
46 | typedef void (*KeyboardEventAction)( OSObject * target,␊ |
47 | /* eventFlags */ unsigned eventType,␊ |
48 | /* flags */ unsigned flags,␊ |
49 | /* keyCode */ unsigned key,␊ |
50 | /* charCode */ unsigned charCode,␊ |
51 | /* charSet */ unsigned charSet,␊ |
52 | /* originalCharCode */ unsigned origCharCode,␊ |
53 | /* originalCharSet */ unsigned origCharSet,␊ |
54 | /* keyboardType */ unsigned keyboardType,␊ |
55 | /* repeat */ bool repeat,␊ |
56 | /* atTime */ AbsoluteTime ts);␊ |
57 | ␊ |
58 | typedef void (*KeyboardSpecialEventAction)(OSObject * target,␊ |
59 | /* eventType */ unsigned eventType,␊ |
60 | /* flags */ unsigned flags,␊ |
61 | /* keyCode */ unsigned key,␊ |
62 | /* specialty */ unsigned flavor,␊ |
63 | /* source id */ UInt64 guid,␊ |
64 | /* repeat */ bool repeat,␊ |
65 | /* atTime */ AbsoluteTime ts);␊ |
66 | ␊ |
67 | typedef void (*UpdateEventFlagsAction)( OSObject * target,␊ |
68 | /* flags */ unsigned flags);␊ |
69 | ␊ |
70 | /* Event Callback Definitions */␊ |
71 | ␊ |
72 | typedef void (*KeyboardEventCallback)(␊ |
73 | /* target */ OSObject * target,␊ |
74 | /* eventFlags */ unsigned eventType,␊ |
75 | /* flags */ unsigned flags,␊ |
76 | /* keyCode */ unsigned key,␊ |
77 | /* charCode */ unsigned charCode,␊ |
78 | /* charSet */ unsigned charSet,␊ |
79 | /* originalCharCode */ unsigned origCharCode,␊ |
80 | /* originalCharSet */ unsigned origCharSet,␊ |
81 | /* keyboardType */ unsigned keyboardType,␊ |
82 | /* repeat */ bool repeat,␊ |
83 | /* atTime */ AbsoluteTime ts,␊ |
84 | /* sender */ OSObject * sender,␊ |
85 | /* refcon */ void * refcon);␊ |
86 | ␊ |
87 | typedef void (*KeyboardSpecialEventCallback)(␊ |
88 | /* target */ OSObject * target,␊ |
89 | /* eventType */ unsigned eventType,␊ |
90 | /* flags */ unsigned flags,␊ |
91 | /* keyCode */ unsigned key,␊ |
92 | /* specialty */ unsigned flavor,␊ |
93 | /* source id */ UInt64 guid,␊ |
94 | /* repeat */ bool repeat,␊ |
95 | /* atTime */ AbsoluteTime ts,␊ |
96 | /* sender */ OSObject * sender,␊ |
97 | /* refcon */ void * refcon);␊ |
98 | ␊ |
99 | typedef void (*UpdateEventFlagsCallback)(␊ |
100 | /* target */ OSObject * target,␊ |
101 | /* flags */ unsigned flags,␊ |
102 | /* sender */ OSObject * sender,␊ |
103 | /* refcon */ void * refcon);␊ |
104 | ␊ |
105 | /* End Action Definitions */␊ |
106 | ␊ |
107 | ␊ |
108 | ␊ |
109 | /* Default key repeat parameters */␊ |
110 | #define EV_DEFAULTINITIALREPEAT 500000000ULL // 1/2 sec in nanoseconds␊ |
111 | #define EV_DEFAULTKEYREPEAT 83333333ULL // 1/12 sec in nanoseconds␊ |
112 | #define EV_MINKEYREPEAT 16700000ULL // 1/60 sec␊ |
113 | ␊ |
114 | class IOHIKeyboard : public IOHIDevice␊ |
115 | {␊ |
116 | OSDeclareDefaultStructors(IOHIKeyboard);␊ |
117 | ␊ |
118 | friend class IOHIDKeyboardDevice;␊ |
119 | ␉friend class IOHIDKeyboard;␊ |
120 | ␉friend class IOHIDConsumer;␊ |
121 | ␊ |
122 | protected:␊ |
123 | IOLock *␉ _deviceLock;␉// Lock for all device access␊ |
124 | IOHIKeyboardMapper * _keyMap;␉// KeyMap instance␊ |
125 | ␊ |
126 | // The following fields describe the kind of keyboard␊ |
127 | UInt32␉␉_interfaceType;␊ |
128 | UInt32␉␉_deviceType;␊ |
129 | ␊ |
130 | // The following fields describe the state of the keyboard␊ |
131 | UInt32 *␉_keyState;␉␉// kbdBitVector␊ |
132 | IOByteCount _keyStateSize;␉␉// kbdBitVector allocated size␊ |
133 | unsigned␉_eventFlags;␉␉// Current eventFlags␊ |
134 | bool␉_alphaLock;␉␉// true means alpha lock is on␊ |
135 | bool␉_numLock;␉␉// true means num lock is on␊ |
136 | bool␉_charKeyActive;␉␉// true means char gen. key active␊ |
137 | ␊ |
138 | // The following fields are used in performing key repeats␊ |
139 | bool ␉_isRepeat;␉␉// true means we're generating repeat␊ |
140 | unsigned␉_codeToRepeat;␉␉// What we are repeating␊ |
141 | bool␉_calloutPending;␉// true means we've sched. a callout␊ |
142 | AbsoluteTime␉_lastEventTime;␉␉// Time last event was dispatched␊ |
143 | AbsoluteTime␉_downRepeatTime;␉// Time when we should next repeat␊ |
144 | AbsoluteTime␉_keyRepeat;␉␉// Delay between key repeats␊ |
145 | AbsoluteTime␉_initialKeyRepeat;␉// Delay before initial key repeat␊ |
146 | UInt64␉␉_guid;␊ |
147 | ␊ |
148 | OSObject * _keyboardEventTarget;␊ |
149 | KeyboardEventAction _keyboardEventAction;␊ |
150 | OSObject * _keyboardSpecialEventTarget;␊ |
151 | KeyboardSpecialEventAction _keyboardSpecialEventAction;␊ |
152 | OSObject * _updateEventFlagsTarget;␊ |
153 | UpdateEventFlagsAction _updateEventFlagsAction;␊ |
154 | ␊ |
155 | protected:␊ |
156 | virtual void dispatchKeyboardEvent(unsigned int keyCode,␊ |
157 | ␉␉ /* direction */ bool goingDown,␊ |
158 | ␉␉ /* timeStamp */ AbsoluteTime time);␊ |
159 | ␊ |
160 | public:␊ |
161 | virtual bool init(OSDictionary * properties = 0);␊ |
162 | virtual bool start(IOService * provider);␊ |
163 | virtual void stop(IOService * provider);␊ |
164 | virtual void free();␊ |
165 | ␊ |
166 | virtual bool open(IOService * client,␊ |
167 | ␉␉ IOOptionBits␉ options,␊ |
168 | KeyboardEventAction keAction,␊ |
169 | KeyboardSpecialEventAction kseAction,␊ |
170 | UpdateEventFlagsAction uefAction);␊ |
171 | ␊ |
172 | bool open( IOService * client,␊ |
173 | ␉␉ IOOptionBits␉ options,␊ |
174 | void *,␊ |
175 | KeyboardEventCallback keCallback,␊ |
176 | KeyboardSpecialEventCallback kseCallback,␊ |
177 | UpdateEventFlagsCallback uefCallback);␊ |
178 | ␊ |
179 | virtual void close(IOService * client, IOOptionBits );␊ |
180 | ␊ |
181 | virtual IOReturn message( UInt32 type, IOService * provider,␊ |
182 | void * argument = 0 );␊ |
183 | ␊ |
184 | virtual IOHIDKind hidKind();␊ |
185 | virtual bool ␉ updateProperties( void );␊ |
186 | virtual IOReturn setParamProperties(OSDictionary * dict);␊ |
187 | virtual IOReturn setProperties( OSObject * properties );␊ |
188 | ␊ |
189 | inline bool␉ isRepeat() {return _isRepeat;}␊ |
190 | ␊ |
191 | protected: // for subclasses to implement␊ |
192 | virtual const unsigned char * defaultKeymapOfLength(UInt32 * length);␊ |
193 | virtual void setAlphaLockFeedback(bool val);␊ |
194 | virtual void setNumLockFeedback(bool val);␊ |
195 | virtual UInt32 maxKeyCodes();␊ |
196 | ␊ |
197 | ␊ |
198 | private:␊ |
199 | virtual bool resetKeyboard();␊ |
200 | virtual void scheduleAutoRepeat();␊ |
201 | static void _autoRepeat(void * arg, void *);␊ |
202 | virtual void autoRepeat();␊ |
203 | virtual void setRepeat(unsigned eventType, unsigned keyCode);␊ |
204 | void setRepeatMode(bool repeat);␊ |
205 | static void _createKeyboardNub(thread_call_param_t param0, thread_call_param_t param1);␊ |
206 | ␊ |
207 | /*␊ |
208 | * HISTORICAL NOTE:␊ |
209 | * The following methods were part of the KeyMapDelegate protocol;␊ |
210 | * the declarations have now been merged directly into this class.␊ |
211 | */␊ |
212 | ␊ |
213 | public:␊ |
214 | virtual void keyboardEvent(unsigned eventType,␊ |
215 | /* flags */ unsigned flags,␊ |
216 | /* keyCode */ unsigned keyCode,␊ |
217 | /* charCode */ unsigned charCode,␊ |
218 | /* charSet */ unsigned charSet,␊ |
219 | /* originalCharCode */ unsigned origCharCode,␊ |
220 | /* originalCharSet */ unsigned origCharSet);␊ |
221 | ␊ |
222 | virtual void keyboardSpecialEvent(unsigned eventType,␊ |
223 | ␉␉ /* flags */ unsigned flags,␊ |
224 | ␉␉ /* keyCode */ unsigned keyCode,␊ |
225 | ␉␉ /* specialty */ unsigned flavor);␊ |
226 | ␊ |
227 | virtual void updateEventFlags(unsigned flags); // Does not generate events␊ |
228 | ␊ |
229 | virtual unsigned eventFlags(); // Global event flags␊ |
230 | virtual unsigned deviceFlags(); // per-device event flags␊ |
231 | virtual void setDeviceFlags(unsigned flags); // Set device event flags␊ |
232 | virtual bool alphaLock(); // current alpha-lock state␊ |
233 | virtual void setAlphaLock(bool val); // Set current alpha-lock state␊ |
234 | virtual bool numLock(); ␊ |
235 | virtual void setNumLock(bool val); ␊ |
236 | virtual bool charKeyActive(); // Is a character gen. key down?␊ |
237 | virtual void setCharKeyActive(bool val); // Note that a char gen key is down.␊ |
238 | virtual bool doesKeyLock(unsigned key); //does key lock physically␊ |
239 | virtual unsigned getLEDStatus(); //check hardware for LED status␊ |
240 | ␊ |
241 | private:␊ |
242 | static void _keyboardEvent( IOHIKeyboard * self,␊ |
243 | ␉␉␉ unsigned eventType,␊ |
244 | /* flags */ unsigned flags,␊ |
245 | /* keyCode */ unsigned key,␊ |
246 | /* charCode */ unsigned charCode,␊ |
247 | /* charSet */ unsigned charSet,␊ |
248 | /* originalCharCode */ unsigned origCharCode,␊ |
249 | /* originalCharSet */ unsigned origCharSet,␊ |
250 | /* keyboardType */ unsigned keyboardType,␊ |
251 | /* repeat */ bool repeat,␊ |
252 | /* atTime */ AbsoluteTime ts);␊ |
253 | static void _keyboardSpecialEvent( ␉␊ |
254 | IOHIKeyboard * self,␊ |
255 | unsigned eventType,␊ |
256 | /* flags */ unsigned flags,␊ |
257 | /* keyCode */ unsigned key,␊ |
258 | /* specialty */ unsigned flavor,␊ |
259 | /* guid */ UInt64 guid,␊ |
260 | /* repeat */ bool repeat,␊ |
261 | /* atTime */ AbsoluteTime ts);␊ |
262 | ␊ |
263 | static void _updateEventFlags( IOHIKeyboard * self,␊ |
264 | ␉␉␉␉unsigned flags); /* Does not generate events */␊ |
265 | ␊ |
266 | };␊ |
267 | ␊ |
268 | #endif /* !_IOHIKEYBOARD_H */␊ |
269 |