Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Trunk/i386/include/IOKit/hidevent/IOHIDEventService.h

1/*
2 *
3 * @APPLE_LICENSE_HEADER_START@
4 *
5 * Copyright (c) 1999-2009 Apple Computer, Inc. All Rights Reserved.
6 *
7 * This file contains Original Code and/or Modifications of Original Code
8 * as defined in and that are subject to the Apple Public Source License
9 * Version 2.0 (the 'License'). You may not use this file except in
10 * compliance with the License. Please obtain a copy of the License at
11 * http://www.opensource.apple.com/apsl/ and read it before using this
12 * file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 * Please see the License for the specific language governing rights and
20 * limitations under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24
25#ifndef _IOKIT_HID_IOHIDEVENTSERVICE_H
26#define _IOKIT_HID_IOHIDEVENTSERVICE_H
27
28#include <TargetConditionals.h>
29
30#include <IOKit/IOService.h>
31#include <IOKit/IOWorkLoop.h>
32#include <IOKit/IOTimerEventSource.h>
33#include <IOKit/hidsystem/IOHIDTypes.h>
34#include <IOKit/hid/IOHIDInterface.h>
35#include <IOKit/hid/IOHIDElement.h>
36#include <IOKit/hid/IOHIDKeys.h>
37
38#if TARGET_OS_EMBEDDED
39 #include <IOKit/hid/IOHIDEvent.h>
40#endif
41
42enum
43{
44 kHIDDispatchOptionPointerNoAcceleration = 0x01,
45 kHIDDispatchOptionPointerAffixToScreen = 0x02,
46 kHIDDispatchOptionPointerAbsolutToRelative = 0x04
47};
48
49enum
50{
51 kHIDDispatchOptionScrollNoAcceleration = 0x01,
52 kHIDDispatchOptionScrollMomentumContinue = 0x02,
53 kHIDDispatchOptionScrollMomentumStart = 0x04,
54 kHIDDispatchOptionScrollMomentumEnd = 0x08,
55
56 kHIDDispatchOptionScrollMomentumAny = kHIDDispatchOptionScrollMomentumContinue | kHIDDispatchOptionScrollMomentumStart | kHIDDispatchOptionScrollMomentumEnd
57};
58
59enum
60{
61 kHIDDispatchOptionKeyboardNoRepeat = 0x01
62};
63
64/*! @class IOHIDEventService : public IOService
65 @abstract
66 @discussion
67*/
68class IOHIDPointing;
69class IOHIDKeyboard;
70class IOHIDConsumer;
71struct TransducerData;
72
73class IOHIDEventService: public IOService
74{
75 OSDeclareAbstractStructors( IOHIDEventService )
76
77 friend class IOHIDPointing;
78 friend class IOHIDKeyboard;
79 friend class IOHIDConsumer;
80 friend class AppleEmbeddedKeyboard;
81 friend class IOHIDEventServiceUserClient;
82
83private:
84 IOHIDKeyboard * _keyboardNub;
85 IOHIDPointing * _pointingNub;
86 IOHIDConsumer * _consumerNub;
87
88 IONotifier *_publishNotify;
89 IORecursiveLock * _nubLock;
90
91 OSArray * _transducerDataArray;
92
93 bool _readyForInputReports;
94
95
96 struct ExpansionData {
97IOService *provider;
98 IOWorkLoop * workLoop;
99 UInt32 ejectDelayMS;
100 IOTimerEventSource * ejectTimerEventSource;
101 UInt32 ejectState;
102 IOOptionBits ejectOptions;
103 UInt32 capsDelayMS;
104 IOTimerEventSource * capsTimerEventSource;
105 UInt32 capsState;
106 IOOptionBits capsOptions;
107 OSArray * deviceUsagePairs;
108
109#if TARGET_OS_EMBEDDED
110 OSDictionary * clientDict;
111 UInt32 debuggerMask;
112 UInt32 startDebuggerMask;
113 IOTimerEventSource * debuggerTimerEventSource;
114 bool shouldSwapISO;
115#endif
116 };
117 /*! @var reserved
118 Reserved for future use. (Internal use only) */
119 ExpansionData * _reserved;
120
121 IOHIDPointing * newPointingShim (
122 UInt32 buttonCount = 1,
123 IOFixed pointerResolution = (400 << 16),
124 IOFixed scrollResolution = 0,
125 IOOptionBits options = 0 );
126
127 IOHIDKeyboard * newKeyboardShim (
128 UInt32 supportedModifiers = 0,
129 IOOptionBits options = 0 );
130
131 IOHIDConsumer * newConsumerShim ( IOOptionBits options = 0 );
132
133 void parseSupportedElements (
134 OSArray * elementArray,
135 UInt32 bootProtocol );
136
137 void processTabletElement ( IOHIDElement * element );
138
139 void processTransducerData ();
140
141 TransducerData * createTransducerData ( UInt32 tranducerID );
142
143 TransducerData * getTransducerData ( UInt32 tranducerID );
144
145 IOFixed determineResolution ( IOHIDElement * element );
146
147 static bool _publishMatchingNotificationHandler(void * target, void * ref, IOService * newService, IONotifier * notifier);
148
149 void ejectTimerCallback(IOTimerEventSource *sender);
150
151 void capsTimerCallback(IOTimerEventSource *sender);
152
153#if TARGET_OS_EMBEDDED
154 void debuggerTimerCallback(IOTimerEventSource *sender);
155#endif
156voidcalculateCapsLockDelay();
157
158 void calculateStandardType();
159
160protected:
161
162 virtual void free();
163
164/*! @function handleOpen
165 @abstract Handle a client open on the interface.
166 @discussion This method is called by IOService::open() with the
167 arbitration lock held, and must return true to accept the client open.
168 This method will in turn call handleClientOpen() to qualify the client
169 requesting the open.
170 @param client The client object that requested the open.
171 @param options Options passed to IOService::open().
172 @param argument Argument passed to IOService::open().
173 @result true to accept the client open, false otherwise. */
174
175 virtual bool handleOpen(IOService * client,
176 IOOptionBits options,
177 void * argument);
178
179/*! @function handleClose
180 @abstract Handle a client close on the interface.
181 @discussion This method is called by IOService::close() with the
182 arbitration lock held. This method will in turn call handleClientClose()
183 to notify interested subclasses about the client close. If this represents
184 the last close, then the interface will also close the controller before
185 this method returns. The controllerWillClose() method will be called before
186 closing the controller. Subclasses should not override this method.
187 @param client The client object that requested the close.
188 @param options Options passed to IOService::close(). */
189
190 virtual void handleClose(IOService * client, IOOptionBits options);
191
192/*! @function handleIsOpen
193 @abstract Query whether a client has an open on the interface.
194 @discussion This method is always called by IOService with the
195 arbitration lock held. Subclasses should not override this method.
196 @result true if the specified client, or any client if none (0) is
197 specified, presently has an open on this object. */
198
199 virtual bool handleIsOpen(const IOService * client) const;
200
201/*! @function handleStart
202 @abstract Prepare the hardware and driver to support I/O operations.
203 @discussion IOHIDEventService will call this method from start() before
204 any I/O operations are issued to the concrete subclass. Methods
205 such as getReportElements() are only called after handleStart()
206 has returned true. A subclass that overrides this method should
207 begin its implementation by calling the version in super, and
208 then check the return value.
209 @param provider The provider argument passed to start().
210 @result True on success, or false otherwise. Returning false will
211 cause start() to fail and return false. */
212
213 virtual bool handleStart( IOService * provider );
214
215/*! @function handleStop
216 @abstract Quiesce the hardware and stop the driver.
217 @discussion IOHIDEventService will call this method from stop() to
218 signal that the hardware should be quiesced and the driver stopped.
219 A subclass that overrides this method should end its implementation
220 by calling the version in super.
221 @param provider The provider argument passed to stop(). */
222
223 virtual void handleStop( IOService * provider );
224
225 virtual OSString * getTransport ();
226 virtual UInt32 getLocationID ();
227 virtual UInt32 getVendorID ();
228 virtual UInt32 getVendorIDSource ();
229 virtual UInt32 getProductID ();
230 virtual UInt32 getVersion ();
231 virtual UInt32 getCountryCode ();
232 virtual OSString * getManufacturer ();
233 virtual OSString * getProduct ();
234 virtual OSString * getSerialNumber ();
235
236 virtual OSArray * getReportElements();
237
238 virtual void setElementValue (
239 UInt32 usagePage,
240 UInt32 usage,
241 UInt32 value );
242
243 virtual UInt32 getElementValue (
244 UInt32 usagePage,
245 UInt32 usage );
246
247 virtual void dispatchKeyboardEvent(
248 AbsoluteTime timeStamp,
249 UInt32 usagePage,
250 UInt32 usage,
251 UInt32 value,
252 IOOptionBits options = 0 );
253
254 virtual void dispatchRelativePointerEvent(
255 AbsoluteTime timeStamp,
256 SInt32 dx,
257 SInt32 dy,
258 UInt32 buttonState,
259 IOOptionBits options = 0 );
260
261 virtual void dispatchAbsolutePointerEvent(
262 AbsoluteTime timeStamp,
263 SInt32 x,
264 SInt32 y,
265 IOGBounds * bounds,
266 UInt32 buttonState,
267 bool inRange,
268 SInt32 tipPressure,
269 SInt32 tipPressureMin,
270 SInt32 tipPressureMax,
271 IOOptionBits options = 0 );
272
273 virtual void dispatchScrollWheelEvent(
274 AbsoluteTime timeStamp,
275 SInt32 deltaAxis1,
276 SInt32 deltaAxis2,
277 SInt32 deltaAxis3,
278 IOOptionBits options = 0 );
279
280 virtual void dispatchTabletPointerEvent(
281 AbsoluteTime timeStamp,
282 UInt32 tranducerID,
283 SInt32 x,
284 SInt32 y,
285 SInt32 z,
286 IOGBounds * bounds,
287 UInt32 buttonState,
288 SInt32 tipPressure,
289 SInt32 tipPressureMin,
290 SInt32 tipPressureMax,
291 SInt32 barrelPressure,
292 SInt32 barrelPressureMin,
293 SInt32 barrelPressureMax,
294 SInt32 tiltX,
295 SInt32 tiltY,
296 UInt32 twist,
297 IOOptionBits options = 0 );
298
299 virtual void dispatchTabletProximityEvent(
300 AbsoluteTime timeStamp,
301 UInt32 tranducerID,
302 bool inRange,
303 bool invert,
304 UInt32 vendorTransducerUniqueID = 0,
305 UInt32 vendorTransducerSerialNumber = 0,
306 IOOptionBits options = 0 );
307
308public:
309 bool readyForReports();
310
311 virtual bool init(OSDictionary * properties = 0);
312
313 virtual bool start( IOService * provider );
314
315 virtual void stop( IOService * provider );
316
317 virtual bool matchPropertyTable(OSDictionary * table, SInt32 * score);
318
319 virtual IOReturn setSystemProperties( OSDictionary * properties );
320
321 virtual IOReturn setProperties( OSObject * properties );
322
323protected:
324 OSMetaClassDeclareReservedUsed(IOHIDEventService, 0);
325 virtual OSArray * getDeviceUsagePairs();
326
327
328#if TARGET_OS_EMBEDDED
329public:
330 typedef void (*Action)(OSObject *target, OSObject * sender, void *context, OSObject *event, IOOptionBits options);
331
332 OSMetaClassDeclareReservedUsed(IOHIDEventService, 1);
333 virtual bool open(
334 IOService * client,
335 IOOptionBits options,
336 void * context,
337 Action action);
338
339protected:
340 OSMetaClassDeclareReservedUsed(IOHIDEventService, 2);
341 virtual void dispatchEvent(IOHIDEvent * event, IOOptionBits options=0);
342
343 OSMetaClassDeclareReservedUsed(IOHIDEventService, 3);
344 virtual UInt32 getPrimaryUsagePage();
345
346 OSMetaClassDeclareReservedUsed(IOHIDEventService, 4);
347 virtual UInt32 getPrimaryUsage();
348
349 OSMetaClassDeclareReservedUsed(IOHIDEventService, 5);
350 virtual UInt32 getReportInterval();
351
352public:
353 OSMetaClassDeclareReservedUsed(IOHIDEventService, 6);
354 virtual IOHIDEvent * copyEvent(
355 IOHIDEventType type,
356 IOHIDEvent * matching = 0,
357 IOOptionBits options = 0);
358#else
359 OSMetaClassDeclareReservedUnused(IOHIDEventService, 1);
360 OSMetaClassDeclareReservedUnused(IOHIDEventService, 2);
361 OSMetaClassDeclareReservedUnused(IOHIDEventService, 3);
362 OSMetaClassDeclareReservedUnused(IOHIDEventService, 4);
363 OSMetaClassDeclareReservedUnused(IOHIDEventService, 5);
364 OSMetaClassDeclareReservedUnused(IOHIDEventService, 6);
365#endif
366 OSMetaClassDeclareReservedUnused(IOHIDEventService, 7);
367 OSMetaClassDeclareReservedUnused(IOHIDEventService, 8);
368 OSMetaClassDeclareReservedUnused(IOHIDEventService, 9);
369 OSMetaClassDeclareReservedUnused(IOHIDEventService, 10);
370 OSMetaClassDeclareReservedUnused(IOHIDEventService, 11);
371 OSMetaClassDeclareReservedUnused(IOHIDEventService, 12);
372 OSMetaClassDeclareReservedUnused(IOHIDEventService, 13);
373 OSMetaClassDeclareReservedUnused(IOHIDEventService, 14);
374 OSMetaClassDeclareReservedUnused(IOHIDEventService, 15);
375 OSMetaClassDeclareReservedUnused(IOHIDEventService, 16);
376 OSMetaClassDeclareReservedUnused(IOHIDEventService, 17);
377 OSMetaClassDeclareReservedUnused(IOHIDEventService, 18);
378 OSMetaClassDeclareReservedUnused(IOHIDEventService, 19);
379 OSMetaClassDeclareReservedUnused(IOHIDEventService, 20);
380 OSMetaClassDeclareReservedUnused(IOHIDEventService, 21);
381 OSMetaClassDeclareReservedUnused(IOHIDEventService, 22);
382 OSMetaClassDeclareReservedUnused(IOHIDEventService, 23);
383 OSMetaClassDeclareReservedUnused(IOHIDEventService, 24);
384 OSMetaClassDeclareReservedUnused(IOHIDEventService, 25);
385 OSMetaClassDeclareReservedUnused(IOHIDEventService, 26);
386 OSMetaClassDeclareReservedUnused(IOHIDEventService, 27);
387 OSMetaClassDeclareReservedUnused(IOHIDEventService, 28);
388 OSMetaClassDeclareReservedUnused(IOHIDEventService, 29);
389 OSMetaClassDeclareReservedUnused(IOHIDEventService, 30);
390 OSMetaClassDeclareReservedUnused(IOHIDEventService, 31);
391
392};
393
394#endif /* !_IOKIT_HID_IOHIDEVENTSERVICE_H */
395

Archive Download this file

Revision: 1622