1/*
2 *
3 * @APPLE_LICENSE_HEADER_START@
4 *
5 * Copyright (c) 1999-2003 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_IOHIDDEVICE_H
26#define _IOKIT_HID_IOHIDDEVICE_H
27
28#include <IOKit/IOService.h>
29#include <IOKit/IOMessage.h>
30#include <IOKit/IOBufferMemoryDescriptor.h>
31#include <IOKit/hidsystem/IOHIDDescriptorParser.h>
32#include <IOKit/hid/IOHIDKeys.h>
33#include <IOKit/IOEventSource.h>
34
35class   IOHIDSystem;
36class   IOHIDPointing;
37class   IOHIDKeyboard;
38class   IOHIDConsumer;
39class   IOHIDElementPrivate;
40class   IOHIDEventQueue;
41class   IOHIDInterface;
42class   IOHIDDeviceShim;
43struct  IOHIDReportHandler;
44class   IOHIDAsyncReportQueue;
45
46/*!
47    @typedef IOHIDCompletionAction
48    @abstract Function called when set/get report completes
49    @param target The target specified in the IOHIDCompletion struct.
50    @param parameter The parameter specified in the IOHIDCompletion struct.
51    @param status Completion status
52*/
53typedef void (*IOHIDCompletionAction)(
54                void *			target,
55                void *			parameter,
56                IOReturn		status,
57                UInt32			bufferSizeRemaining);
58
59/*!
60    @typedef IOHIDCompletion
61    @abstract Struct spefifying action to perform when set/get report completes.
62    @param target The target to pass to the action function.
63    @param action The function to call.
64    @param parameter The parameter to pass to the action function.
65*/
66typedef struct IOHIDCompletion {
67    void * 			target;
68    IOHIDCompletionAction	action;
69    void *			parameter;
70} IOHIDCompletion;
71
72/*!
73    @enum IOHIDReportOption
74    @abstract Option bits for IOHIDDevice::handleReport,
75    IOHIDDevice::getReport, and IOHIDDevice::setReport
76    @constant kIOHIDReportOptionNotInterrupt Tells method that the report
77    passed was not interrupt driven.
78*/
79enum
80{
81    kIOHIDReportOptionNotInterrupt	= 0x100
82};
83
84
85/*! @class IOHIDDevice : public IOService
86    @abstract IOHIDDevice defines a Human Interface Device (HID) object,
87    which will interact with the HID Manager by publishing static properties
88    in the registry, and also by reporting HID events through shared memory.
89    IOHIDDevice is an abstract class that must be subclassed to support a
90    specific type of HID devices, such as USB HID class devices.
91    <br>
92    Since most HID devices are expected to be USB devices, IOHIDDevice
93    uses the USB HID specification to define the format of the report
94    descriptor, and also reports that are used to communicate with the
95    hardware via some intervening transport layer. However, there is no
96    mandate that the transport layer must be restricted to USB. A subclass
97    may be created to support legacy ADB joysticks, and issue packets on
98    the ADB bus and translate those packets to USB reports, and vice versa.
99    IOHIDDevice does not care how those reports are generated or consumed
100    by the physical device, as long as the reports abide to the USB
101    specification. */
102
103class IOHIDDevice : public IOService
104{
105    OSDeclareDefaultStructors( IOHIDDevice )
106
107    friend class IOHIDLibUserClient;
108    friend class IOHIDDeviceShim;
109
110private:
111    OSArray *                   _elementArray;
112    UInt32                      _dataElementIndex;
113    IORecursiveLock *           _elementLock;
114    IOHIDReportHandler *        _reportHandlers;
115    IOBufferMemoryDescriptor *  _elementValuesDescriptor;
116    bool                        _readyForInputReports;
117    UInt32                      _reportCount;
118    UInt32                      _maxInputReportSize;
119    UInt32                      _maxOutputReportSize;
120    UInt32                      _maxFeatureReportSize;
121
122    struct ExpansionData {
123        OSSet *                 clientSet;
124        IOService *             seizedClient;
125        AbsoluteTime            eventDeadline;
126        OSArray *               inputInterruptElementArray;
127        bool                    performTickle;
128        bool                    performWakeTickle;
129        IOHIDInterface *        interfaceNub;
130        IOHIDElementPrivate *   rollOverElement;
131        OSArray *               hierarchElements;
132        IOHIDAsyncReportQueue * asyncReportQueue;
133        IOWorkLoop *            workLoop;
134        IOEventSource *         eventSource;
135    };
136    /*! @var reserved
137        Reserved for future use.  (Internal use only)  */
138    ExpansionData * _reserved;
139
140    // HID report descriptor parsing support.
141
142    bool linkToParent( const OSArray * array,
143                       UInt32          parentIndex,
144                       UInt32          childIndex );
145
146    bool createCollectionElements( HIDPreparsedDataRef parseData,
147                                   OSArray *           array,
148                                   UInt32              maxCount );
149
150    bool createValueElements( HIDPreparsedDataRef parseData,
151                              OSArray *           array,
152                              UInt32              hidReportType,
153                              IOHIDElementType    elementType,
154                              UInt32              maxCount );
155
156    bool createButtonElements( HIDPreparsedDataRef parseData,
157                               OSArray *           array,
158                               UInt32              hidReportType,
159                               IOHIDElementType    elementType,
160                               UInt32              maxCount );
161
162    bool createReportHandlerElements( HIDPreparsedDataRef parseData);
163
164    bool getReportCountAndSizes( HIDPreparsedDataRef parseData );
165
166    bool setReportSize( UInt8           reportID,
167                        IOHIDReportType reportType,
168                        UInt32          bits );
169
170    IOReturn createElementHierarchy( HIDPreparsedDataRef parseData );
171
172    IOReturn parseReportDescriptor( IOMemoryDescriptor * report,
173                                    IOOptionBits         options = 0 );
174
175    IOBufferMemoryDescriptor * createMemoryForElementValues();
176
177
178    static bool _publishDisplayNotificationHandler(void * target,
179                                                   void * ref,
180                                                   IOService * newService,
181                                                   IONotifier * notifier );
182    static bool _publishDeviceNotificationHandler(void * target,
183                                                  void * refCon,
184                                                  IOService * newService,
185                                                  IONotifier * notifier );
186
187protected:
188
189/*! @function free
190    @abstract Free the IOHIDDevice object.
191    @discussion Release all resources that were previously allocated,
192    then call super::free() to propagate the call to our superclass. */
193
194    virtual void free();
195
196/*! @function handleOpen
197    @abstract Handle a client open on the interface.
198    @discussion This method is called by IOService::open() with the
199    arbitration lock held, and must return true to accept the client open.
200    This method will in turn call handleClientOpen() to qualify the client
201    requesting the open.
202    @param client The client object that requested the open.
203    @param options Options passed to IOService::open().
204    @param argument Argument passed to IOService::open().
205    @result true to accept the client open, false otherwise. */
206
207    virtual bool handleOpen(IOService *  client,
208                            IOOptionBits options,
209                            void *       argument);
210
211/*! @function handleClose
212    @abstract Handle a client close on the interface.
213    @discussion This method is called by IOService::close() with the
214    arbitration lock held. This method will in turn call handleClientClose()
215    to notify interested subclasses about the client close. If this represents
216    the last close, then the interface will also close the controller before
217    this method returns. The controllerWillClose() method will be called before
218    closing the controller. Subclasses should not override this method.
219    @param client The client object that requested the close.
220    @param options Options passed to IOService::close(). */
221
222    virtual void handleClose(IOService * client, IOOptionBits options);
223
224/*! @function handleIsOpen
225    @abstract Query whether a client has an open on the interface.
226    @discussion This method is always called by IOService with the
227    arbitration lock held. Subclasses should not override this method.
228    @result true if the specified client, or any client if none (0) is
229    specified, presently has an open on this object. */
230
231    virtual bool handleIsOpen(const IOService * client) const;
232
233/*! @function handleStart
234    @abstract Prepare the hardware and driver to support I/O operations.
235    @discussion IOHIDDevice will call this method from start() before
236    any I/O operations are issued to the concrete subclass. Methods
237    such as newReportDescriptor() are only called after handleStart()
238    has returned true. A subclass that overrides this method should
239    begin its implementation by calling the version in super, and
240    then check the return value.
241    @param provider The provider argument passed to start().
242    @result True on success, or false otherwise. Returning false will
243    cause start() to fail and return false. */
244
245    virtual bool handleStart( IOService * provider );
246
247/*! @function handleStop
248    @abstract Quiesce the hardware and stop the driver.
249    @discussion IOHIDDevice will call this method from stop() to
250    signal that the hardware should be quiesced and the driver stopped.
251    A subclass that overrides this method should end its implementation
252    by calling the version in super.
253    @param provider The provider argument passed to stop(). */
254
255    virtual void handleStop(  IOService * provider );
256
257/*! @function newUserClient
258    @abstract Handle a request to create a connection for a non kernel
259    client.
260    @discussion Create a new IOUserClient, or a subclass of IOUserClient,
261    to service a connection to a non kernel client. This implementation
262    will simply call the implementation in IOService to handle the call.
263    @param owningTask The mach task requesting the connection.
264    @param security_id A token representing the access level for the task.
265    @param type A constant specifying the type of connection to be created.
266    @param properties A dictionary of additional properties for the connection.
267    @param handler The IOUserClient object returned.
268    @result The return from IOService::newUserClient() is returned. */
269
270    virtual IOReturn newUserClient( task_t          owningTask,
271                                   void *          security_id,
272                                   UInt32          type,
273                                   OSDictionary *  properties,
274                                   IOUserClient ** handler );
275    IOReturn newUserClientGated(task_t          owningTask,
276                                void *          security_id,
277                                OSDictionary *  properties,
278                                IOUserClient ** handler );
279
280/*! @function publishProperties
281    @abstract Publish HID properties to the I/O Kit registry.
282    @discussion Called by the start() method to fetch and publish all
283    HID properties to the I/O Kit registry. These properties will allow
284    the HID Manager to identify all HID device(s) in the system, by
285    iterating through objects that are subclasses of IOHIDDevice, and
286    then fetch their published property values. The implementation in
287    IOHIDDevice will call methods to get each individual HID property,
288    and subclasses will not normally need to override this method.
289    @param provider The provider argument passed to start().
290    @result True to indicate that all properties were discovered and
291    published to the registry, false otherwise. Returning false will
292    cause start() to fail and return false. */
293
294    virtual bool publishProperties( IOService * provider );
295
296public:
297
298/*! @function init
299    @abstract Initialize an IOHIDDevice object.
300    @discussion Prime the IOHIDDevice object and prepare it to support
301    a probe() or a start() call. This implementation will simply call
302    super::init().
303    @param A dictionary A property table associated with this IOHIDDevice
304    instance.
305    @result True on sucess, or false otherwise. */
306
307    virtual bool init( OSDictionary * dictionary = 0 );
308
309/*! @function start
310    @abstract Start up the driver using the given provider.
311    @discussion IOHIDDevice will allocate resources, then call handleStart()
312    before fetching the report descriptor through newReportDescriptor(), and
313    publishing HID properties to the registry. Before returning true to
314    indicate success, registerService() is called to trigger client matching.
315    Subclasses are recommended to override handleStart().
316    @param provider The provider that the driver was matched to, and selected
317    to run with.
318    @result True on success, or false otherwise. */
319
320    virtual bool start( IOService * provider );
321
322/*! @function stop
323    @abstract Called by a provider (during its termination) before detaching
324    all its clients.
325    @discussion IOHIDDevice will call handleStop(), then release allocated
326    resources. Subclasses are recommended to override handleStop().
327    @param provider The provider that the driver was started on. */
328
329    virtual void stop( IOService * provider );
330
331/*! @function matchPropertyTable
332    @abstract Called by the provider during a match
333    @discussion Compare the properties in the supplied table to this
334    object's properties.
335    @param table The property table that this device will match against
336*/
337
338    virtual bool matchPropertyTable(OSDictionary * table, SInt32 * score);
339
340/*! @function message
341    @abstract Receives messages delivered from an attached provider.
342    @discussion Handles the <code>kIOMessageDeviceSignaledWakeup</code> message
343    from a provider identifying the IOHIDDevice as the wakeup source.
344    @param type A type defined in <code>IOMessage.h</code>.
345    @param provider The provider from which the message originates.
346    @param argument An argument defined by the message type.
347    @result An IOReturn code defined by the message type.
348*/
349
350    virtual IOReturn message( UInt32 type, IOService * provider,  void * argument = 0 );
351
352/*! @function newTransportString
353    @abstract Returns a string object that describes the transport
354    layer used by the HID device.
355    @result A string object. The caller must decrement the retain count
356    on the object returned. */
357
358    virtual OSString * newTransportString() const;
359
360/*! @function newManufacturerString
361    @abstract Returns a string object that describes the manufacturer
362    of the HID device.
363    @result A string object. The caller must decrement the retain count
364    on the object returned. */
365
366    virtual OSString * newManufacturerString() const;
367
368/*! @function newProductString
369    @abstract Returns a string object that describes the product
370    of the HID device.
371    @result A string object. The caller must decrement the retain count
372    on the object returned. */
373
374    virtual OSString * newProductString() const;
375
376/*! @function newVendorIDNumber
377    @abstract Returns a number object that describes the vendor ID
378    of the HID device.
379    @result A number object. The caller must decrement the retain count
380    on the object returned. */
381
382    virtual OSNumber * newVendorIDNumber() const;
383
384/*! @function newProductIDNumber
385    @abstract Returns a number object that describes the product ID
386    of the HID device.
387    @result A number object. The caller must decrement the retain count
388    on the object returned. */
389
390    virtual OSNumber * newProductIDNumber() const;
391
392/*! @function newVersionNumber
393    @abstract Returns a number object that describes the version number
394    of the HID device.
395    @result A number object. The caller must decrement the retain count
396    on the object returned. */
397
398    virtual OSNumber * newVersionNumber() const;
399
400//  *** THIS HAS BEEN DEPRECATED.  PLEASE USE newSerialNumberString ***
401/*! @function newSerialNumber
402    @abstract THIS HAS BEEN DEPRECATED.  PLEASE USE newSerialNumberString.
403    @result A number object. The caller must decrement the retain count
404    on the object returned. */
405
406    virtual OSNumber * newSerialNumber() const;
407
408/*! @function newPrimaryUsageNumber
409    @abstract Returns a number object that describes the primary usage
410    of the HID device.
411    @result A number object. The caller must decrement the retain count
412    on the object returned. */
413
414    virtual OSNumber * newPrimaryUsageNumber() const;
415
416/*! @function newPrimaryUsagePageNumber
417    @abstract Returns a number object that describes the primary usage
418    page of the HID device.
419    @result A number object. The caller must decrement the retain count
420    on the object returned. */
421
422    virtual OSNumber * newPrimaryUsagePageNumber() const;
423
424/*! @function newReportDescriptor
425    @abstract Create and return a new memory descriptor that describes the
426    report descriptor for the HID device.
427    @discussion A subclass must override this pure virtual function, and
428    return a memory descriptor that describes the HID report descriptor as
429    defined by the USB Device Class Definition for Human Interface Devices
430    Version 1.1 specification.
431    @param descriptor Pointer to the memory descriptor returned. This
432    memory descriptor will be released by the caller.
433    @result kIOReturnSuccess on success, or an error return otherwise. */
434
435    virtual IOReturn newReportDescriptor(
436                        IOMemoryDescriptor ** descriptor ) const = 0;
437
438/*! @function handleReport
439    @abstract Handle an asynchronous report received from the HID device.
440    @param report A memory descriptor that describes the report.
441    @param reportType The type of report.
442    @param options Options to specify the request. No options are
443    currently defined, and the default value is 0.
444    @result kIOReturnSuccess on success, or an error return otherwise. */
445
446	virtual IOReturn handleReport(
447                     IOMemoryDescriptor * report,
448	                 IOHIDReportType      reportType = kIOHIDReportTypeInput,
449	                 IOOptionBits         options    = 0 );
450
451/*! @function getReport
452    @abstract Get a report from the HID device.
453    @discussion A completion parameter may be added in the future.
454    @param report A memory descriptor that describes the memory to store
455    the report read from the HID device.
456    @param reportType The report type.
457    @param options The lower 8 bits will represent the Report ID.  The
458    other 24 bits are options to specify the request.
459    @result kIOReturnSuccess on success, or an error return otherwise. */
460
461    virtual IOReturn getReport( IOMemoryDescriptor * report,
462                                IOHIDReportType      reportType,
463                                IOOptionBits         options );
464
465/*! @function setReport
466    @abstract Send a report to the HID device.
467    @discussion A completion parameter may be added in the future.
468    @param report A memory descriptor that describes the report to send
469    to the HID device.
470    @param reportType The report type.
471    @param options The lower 8 bits will represent the Report ID.  The
472    other 24 bits are options to specify the request.
473    @result kIOReturnSuccess on success, or an error return otherwise. */
474
475    virtual IOReturn setReport( IOMemoryDescriptor * report,
476                                IOHIDReportType      reportType,
477                                IOOptionBits         options = 0 );
478
479/*! @function getMemoryWithCurrentElementValues
480    @abstract Get a reference to a memory descriptor that describes the
481    memory block containing the current HID element values.
482    @discussion Each HID element that can contribute to an input, output,
483    or feature report, is assigned an area of memory from a common memory
484    block allocated by IOHIDDevice. Each element will use its assigned
485    memory area to store its current value, defined by an IOHIDElementValue
486    structure. The memory described by the memory descriptor may be mapped
487    to user space to allow the HID Manager to poll the current element
488    value without the cost of a user-kernel transition. Subclasses should
489    not override this method.
490    @result A reference to a memory descriptor that describes the current
491    element values, or 0 to indicate a resource shortage. */
492
493    virtual IOMemoryDescriptor * getMemoryWithCurrentElementValues() const;
494
495/*! @function registerElement
496    @abstract A registration function called by a HID element to register
497    itself, and also to obtain an unique cookie identifier
498    (unique per device, not unique system-wide).
499    @discussion An internal data type, an IOHIDElementPrivate, is created to
500    represent each HID element discovered by parsing the HID report
501    descriptor. Each element created will call this method to register
502    itself with its owner (IOHIDDevice), and also to obtain an element
503    cookie that is used by HID Manager to specify and identify the element.
504    Subclasses should not override this method.
505    @param element The element that is requesting registration with its
506    owner.
507    @param cookie Pointer to the returned cookie assigned to this element.
508    @result True on success, or false otherwise. */
509
510    virtual bool registerElement( IOHIDElementPrivate * element,
511                                  IOHIDElementCookie * cookie );
512
513/*! @function startEventDelivery
514    @abstract Start delivering events from a HID element to the event
515    queue specified.
516    @discussion Clients of IOHIDDevice may create an IOHIDEventQueue, and
517    then call this method to register for delivery of events generated by
518    one or more HID elements to that event queue. Subclasses should not
519    override this method.
520    @param queue The event queue that is interested in receiving events
521    generated by the HID element specified. The retain count on the queue
522    will be incremented by one.
523    @param cookie The cookie for a HID element published by the HID device.
524    @param options Options to specify the request. No options are currently
525    defined, and the default value is zero.
526    @result kIOReturnSuccess on success, or kIOReturnBadArgument if the
527    queue or the cookie argument specified is invalid, or kIOReturnNoMemory
528    if a resource shortage was encountered. */
529
530    virtual IOReturn startEventDelivery( IOHIDEventQueue *  queue,
531                                         IOHIDElementCookie cookie,
532                                         IOOptionBits       options = 0 );
533
534/*! @function stopEventDelivery
535    @abstract Stop delivering events from one or more HID elements to the
536    event queue specified.
537    @discussion Clients that called startEventDelivery() must eventually
538    call this method to stop event delivery to its queue from one or more
539    HID elements.
540    @param queue The event queue that no longer wishes to receive events
541    generated by the HID element specified.
542    @param cookie The cookie for a HID element published by the HID device.
543    The default value of zero indicates that the queue should be removed from
544    the event dispatch list of all HID elements published by the HID device.
545    Subclasses should not override this method.
546    @result kIOReturnSuccess if the queue was removed from the event dispatch
547    list for one or more HID elements, or kIOReturnBadArgument if the queue
548    or the cookie argument specified is invalid, or kIOReturnNotFound if the
549    queue was not found. */
550
551    virtual IOReturn stopEventDelivery( IOHIDEventQueue *  queue,
552                                        IOHIDElementCookie cookie = 0 );
553
554/*! @function checkEventDelivery
555    @abstract Check whether events from a HID element will be delivered to
556    the event queue specified.
557    @param queue The event queue.
558    @param cookie The cookie for a HID element published by the HID device.
559    @param isActive Pointer to the return value that is set to true if events
560    generated by the HID element will be delivered to the queue, or false
561    otherwise. This return value is set only if kIOReturnSuccess is
562    returned.
563    @result kIOReturnSuccess on success, or kIOReturnBadArgument if one or
564    more of the arguments provided are invalid. */
565
566    virtual IOReturn checkEventDelivery( IOHIDEventQueue *  queue,
567                                         IOHIDElementCookie cookie,
568                                         bool *             isActive );
569
570/*! @function updateElementValues
571    @abstract Updates element values from a HID device via getReport.
572    @discussion A completion parameter may be added in the future.
573    @param cookies A list of element cookies who's values need to be
574    set on the device.
575    @param cookieCount The number of element cookies.
576    @result kIOReturnSuccess on success, or an error return otherwise. */
577    OSMetaClassDeclareReservedUsed(IOHIDDevice,  0);
578    virtual IOReturn updateElementValues(IOHIDElementCookie * cookies, UInt32 cookieCount = 1);
579
580/*! @function postElementValues
581    @abstract Posts element values to a HID device via setReport.
582    @discussion A completion parameter may be added in the future.
583    @param cookies A list of element cookies who's values need to be
584    set on the device.
585    @param cookieCount The number of element cookies.
586    @result kIOReturnSuccess on success, or an error return otherwise. */
587    OSMetaClassDeclareReservedUsed(IOHIDDevice,  1);
588    virtual IOReturn postElementValues(IOHIDElementCookie * cookies, UInt32 cookieCount = 1);
589
590/*! @function newSerialNumberString
591    @abstract Returns a string object that describes the serial number
592    of the HID device.
593    @result A number object. The caller must decrement the retain count
594    on the object returned. */
595    OSMetaClassDeclareReservedUsed(IOHIDDevice,  2);
596    virtual OSString * newSerialNumberString() const;
597
598/*! @function newLocationIDNumber
599    @abstract Returns a number object that describes the location ID
600    of the HID device.
601    @result A number object. The caller must decrement the retain count
602    on the object returned. */
603    OSMetaClassDeclareReservedUsed(IOHIDDevice,  3);
604    virtual OSNumber * newLocationIDNumber() const;
605
606/*! @function getReport
607    @abstract Get a report from the HID device.
608    @discussion A completion parameter may be added in the future.
609    @param report A memory descriptor that describes the memory to store
610    the report read from the HID device.
611    @param reportType The report type.
612    @param options The lower 8 bits will represent the Report ID.  The
613    other 24 bits are options to specify the request.
614    @param completionTimeout Specifies an amount of time (in ms) after which
615    the command will be aborted if the entire command has not been completed.
616    @param completion Function to call when request completes. If omitted then
617    getReport() executes synchronously, blocking until the request is complete.
618    @result kIOReturnSuccess on success, or an error return otherwise. */
619
620    OSMetaClassDeclareReservedUsed(IOHIDDevice,  4);
621    virtual IOReturn getReport( IOMemoryDescriptor * report,
622                                IOHIDReportType      reportType,
623                                IOOptionBits         options,
624                                UInt32               completionTimeout,
625                                IOHIDCompletion	*    completion = 0);
626
627/*! @function setReport
628    @abstract Send a report to the HID device.
629    @discussion A completion parameter may be added in the future.
630    @param report A memory descriptor that describes the report to send
631    to the HID device.
632    @param reportType The report type.
633    @param options The lower 8 bits will represent the Report ID.  The
634    other 24 bits are options to specify the request.
635    @param completionTimeout Specifies an amount of time (in ms) after which
636    the command will be aborted if the entire command has not been completed.
637    @param completion Function to call when request completes. If omitted then
638    setReport() executes synchronously, blocking until the request is complete.
639    @result kIOReturnSuccess on success, or an error return otherwise. */
640
641    OSMetaClassDeclareReservedUsed(IOHIDDevice,  5);
642    virtual IOReturn setReport( IOMemoryDescriptor * report,
643                                IOHIDReportType      reportType,
644                                IOOptionBits         options,
645                                UInt32               completionTimeout,
646                                IOHIDCompletion	*    completion = 0);
647
648/*! @function newVendorIDSourceNumber
649    @abstract Returns a number object that describes the vendor ID
650    source of the HID device.
651    @result A number object. The caller must decrement the retain count
652    on the object returned. */
653    OSMetaClassDeclareReservedUsed(IOHIDDevice,  6);
654    virtual OSNumber * newVendorIDSourceNumber() const;
655
656/*! @function newCountryCodeNumber
657    @abstract Returns a number object that describes the country code
658    of the HID device.
659    @result A number object. The caller must decrement the retain count
660    on the object returned. */
661    OSMetaClassDeclareReservedUsed(IOHIDDevice,  7);
662    virtual OSNumber * newCountryCodeNumber() const;
663
664
665/*! @function handleReportWithTime
666    @abstract Handle an asynchronous report received from the HID device.
667	@param timeStamp The timestamp of report.
668    @param report A memory descriptor that describes the report.
669    @param reportType The type of report. Currently, only
670    kIOHIDReportTypeInput report type is handled.
671    @param options Options to specify the request. No options are
672    currently defined, and the default value is 0.
673    @result kIOReturnSuccess on success, or an error return otherwise. */
674
675    OSMetaClassDeclareReservedUsed(IOHIDDevice,  8);
676	virtual IOReturn handleReportWithTime(
677                     AbsoluteTime         timeStamp,
678                     IOMemoryDescriptor * report,
679	                 IOHIDReportType      reportType = kIOHIDReportTypeInput,
680	                 IOOptionBits         options    = 0);
681
682/*! @function newReportInterval
683    @abstract Returns a number object that describes the actual polling
684    interval of the HID device in microseconds.
685    @result A number object. The caller must decrement the retain count
686    on the object returned. */
687    OSMetaClassDeclareReservedUsed(IOHIDDevice,  9);
688    virtual OSNumber * newReportIntervalNumber() const;
689
690    OSMetaClassDeclareReservedUsed(IOHIDDevice, 10);
691    virtual IOReturn handleReportWithTimeAsync(
692                                  AbsoluteTime         timeStamp,
693                                  IOMemoryDescriptor * report,
694                                  IOHIDReportType      reportType,
695                                  IOOptionBits         options,
696                                  UInt32               completionTimeout,
697                                  IOHIDCompletion *    completion);
698
699/*! @function newDeviceUsagePairs
700    @abstract Returns an array of usage dictionaries. IOHIDDevice creates
701    create this from the actual report descriptor, and that should be the base
702    for any subclass override.
703    @result A number object. The caller must decrement the retain count
704    on the object returned. */
705    OSMetaClassDeclareReservedUsed(IOHIDDevice, 11);
706    virtual OSArray * newDeviceUsagePairs();
707
708    OSMetaClassDeclareReservedUnused(IOHIDDevice, 12);
709    OSMetaClassDeclareReservedUnused(IOHIDDevice, 13);
710    OSMetaClassDeclareReservedUnused(IOHIDDevice, 14);
711    OSMetaClassDeclareReservedUnused(IOHIDDevice, 15);
712    OSMetaClassDeclareReservedUnused(IOHIDDevice, 16);
713    OSMetaClassDeclareReservedUnused(IOHIDDevice, 17);
714    OSMetaClassDeclareReservedUnused(IOHIDDevice, 18);
715    OSMetaClassDeclareReservedUnused(IOHIDDevice, 19);
716    OSMetaClassDeclareReservedUnused(IOHIDDevice, 20);
717    OSMetaClassDeclareReservedUnused(IOHIDDevice, 21);
718    OSMetaClassDeclareReservedUnused(IOHIDDevice, 22);
719    OSMetaClassDeclareReservedUnused(IOHIDDevice, 23);
720    OSMetaClassDeclareReservedUnused(IOHIDDevice, 24);
721    OSMetaClassDeclareReservedUnused(IOHIDDevice, 25);
722    OSMetaClassDeclareReservedUnused(IOHIDDevice, 26);
723    OSMetaClassDeclareReservedUnused(IOHIDDevice, 27);
724    OSMetaClassDeclareReservedUnused(IOHIDDevice, 28);
725    OSMetaClassDeclareReservedUnused(IOHIDDevice, 29);
726    OSMetaClassDeclareReservedUnused(IOHIDDevice, 30);
727    OSMetaClassDeclareReservedUnused(IOHIDDevice, 31);
728    OSMetaClassDeclareReservedUnused(IOHIDDevice, 32);
729    OSMetaClassDeclareReservedUnused(IOHIDDevice, 33);
730    OSMetaClassDeclareReservedUnused(IOHIDDevice, 34);
731    OSMetaClassDeclareReservedUnused(IOHIDDevice, 35);
732    OSMetaClassDeclareReservedUnused(IOHIDDevice, 36);
733    OSMetaClassDeclareReservedUnused(IOHIDDevice, 37);
734    OSMetaClassDeclareReservedUnused(IOHIDDevice, 38);
735    OSMetaClassDeclareReservedUnused(IOHIDDevice, 39);
736    OSMetaClassDeclareReservedUnused(IOHIDDevice, 40);
737
738};
739
740#endif /* !_IOKIT_HID_IOHIDDEVICE_H */
741