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#include "IOHIDEvent.h"
26#include "AppleEmbeddedHIDEventService.h"
27
28
29//===========================================================================
30// AppleEmbeddedHIDEventService class
31#define super IOHIDEventService
32
33OSDefineMetaClassAndAbstractStructors( AppleEmbeddedHIDEventService, IOHIDEventService )
34
35//====================================================================================================
36// AppleEmbeddedHIDEventService::handleStart
37//====================================================================================================
38bool AppleEmbeddedHIDEventService::handleStart(IOService * provider)
39{
40    uint32_t value;
41
42    if ( !super::handleStart(provider) )
43        return FALSE;
44
45    value = getOrientation();
46    if ( value )
47        setProperty(kIOHIDOrientationKey, value, 32);
48
49    value = getPlacement();
50    if ( value )
51        setProperty(kIOHIDPlacementKey, value, 32);
52
53    // RY: all embedded services are built-in
54    setProperty(kIOHIDBuiltInKey, true);
55
56    return TRUE;
57}
58
59
60//====================================================================================================
61// AppleEmbeddedHIDEventService::dispatchAccelerometerEvent
62//====================================================================================================
63void AppleEmbeddedHIDEventService::dispatchAccelerometerEvent(AbsoluteTime timestamp, IOFixed x, IOFixed y, IOFixed z, IOHIDMotionType type, IOHIDMotionPath subType, UInt32 sequence, IOOptionBits options)
64{
65    IOHIDEvent * event = IOHIDEvent::accelerometerEvent(timestamp, x, y, z, type, subType, sequence, options);
66
67    if ( event ) {
68        dispatchEvent(event);
69        event->release();
70    }
71}
72
73
74//====================================================================================================
75// AppleEmbeddedHIDEventService::dispatchGyroEvent
76//====================================================================================================
77void AppleEmbeddedHIDEventService::dispatchGyroEvent(AbsoluteTime timestamp, IOFixed x, IOFixed y, IOFixed z, IOHIDMotionType type, IOHIDMotionPath subType, UInt32 sequence, IOOptionBits options)
78{
79    IOHIDEvent * event = IOHIDEvent::gyroEvent(timestamp, x, y, z, type, subType, sequence, options);
80
81    if ( event ) {
82        dispatchEvent(event);
83        event->release();
84    }
85}
86
87//====================================================================================================
88// AppleEmbeddedHIDEventService::dispatchCompassEvent
89//====================================================================================================
90void AppleEmbeddedHIDEventService::dispatchCompassEvent(AbsoluteTime timestamp, IOFixed x, IOFixed y, IOFixed z, IOHIDMotionType type, IOHIDMotionPath subType, UInt32 sequence, IOOptionBits options)
91{
92    IOHIDEvent * event = IOHIDEvent::compassEvent(timestamp, x, y, z, type, subType, sequence, options);
93
94    if ( event ) {
95        dispatchEvent(event);
96        event->release();
97    }
98}
99
100//====================================================================================================
101// AppleEmbeddedHIDEventService::dispatchProximityEvent
102//====================================================================================================
103void AppleEmbeddedHIDEventService::dispatchProximityEvent(AbsoluteTime timestamp, IOHIDProximityDetectionMask mask, UInt32 level, IOOptionBits options)
104{
105    IOHIDEvent * event = IOHIDEvent::proximityEvent(timestamp, mask, level, options);
106
107    if ( event ) {
108        dispatchEvent(event);
109        event->release();
110    }
111}
112
113//====================================================================================================
114// AppleEmbeddedHIDEventService::dispatchAmbientLightSensorEvent
115//====================================================================================================
116void AppleEmbeddedHIDEventService::dispatchAmbientLightSensorEvent(AbsoluteTime timestamp, UInt32 level, UInt32 channel0, UInt32 channel1, UInt32 channel2, UInt32 channel3, IOOptionBits options)
117{
118    IOHIDEvent * event = IOHIDEvent::ambientLightSensorEvent(timestamp, level, channel0, channel1, channel2, channel3, options);
119
120    if ( event ) {
121        dispatchEvent(event);
122        event->release();
123    }
124}
125
126//====================================================================================================
127// AppleEmbeddedHIDEventService::dispatchTemperatureEvent
128//====================================================================================================
129void AppleEmbeddedHIDEventService::dispatchTemperatureEvent(AbsoluteTime timestamp, IOFixed temperature, IOOptionBits options)
130{
131    IOHIDEvent * event = IOHIDEvent::temperatureEvent(timestamp, temperature, options);
132
133    if ( event ) {
134        dispatchEvent(event);
135        event->release();
136    }
137}
138
139//====================================================================================================
140// AppleEmbeddedHIDEventService::dispatchPowerEvent
141//====================================================================================================
142void AppleEmbeddedHIDEventService::dispatchPowerEvent(AbsoluteTime timestamp, int64_t measurement, IOHIDPowerType powerType, IOHIDPowerSubType powerSubType, IOOptionBits options)
143{
144    IOHIDEvent * event = IOHIDEvent::powerEvent(timestamp, measurement, powerType, powerSubType, options);
145
146    if ( event ) {
147        dispatchEvent(event);
148        event->release();
149    }
150}
151
152//====================================================================================================
153// AppleEmbeddedHIDEventService::dispatchVendorDefinedEvent
154//====================================================================================================
155void AppleEmbeddedHIDEventService::dispatchVendorDefinedEvent(AbsoluteTime timeStamp, UInt32 usagePage, UInt32 usage, UInt32 version, UInt8 * data, UInt32 length, IOOptionBits options)
156{
157    IOHIDEvent * event = IOHIDEvent::vendorDefinedEvent(timeStamp, usagePage, usage, version, data, length, options);
158
159    if ( event ) {
160        dispatchEvent(event);
161        event->release();
162    }
163}
164
165//====================================================================================================
166// AppleEmbeddedHIDEventService::dispatchBiometricEvent
167//====================================================================================================
168void AppleEmbeddedHIDEventService::dispatchBiometricEvent(AbsoluteTime timeStamp, IOFixed level, IOHIDBiometricEventType eventType, IOOptionBits options)
169{
170    IOHIDEvent * event = IOHIDEvent::biometricEvent(timeStamp, level, eventType, options);
171
172    if ( event ) {
173        dispatchEvent(event);
174        event->release();
175    }
176}
177
178//====================================================================================================
179// AppleEmbeddedHIDEventService::dispatchAtmosphericPressureEvent
180//====================================================================================================
181void AppleEmbeddedHIDEventService::dispatchAtmosphericPressureEvent(AbsoluteTime timeStamp, IOFixed level, UInt32 sequence, IOOptionBits options)
182{
183    IOHIDEvent * event = IOHIDEvent::atmosphericPressureEvent(timeStamp, level, sequence, options);
184
185    if ( event ) {
186        dispatchEvent(event);
187        event->release();
188    }
189}
190
191//====================================================================================================
192// AppleEmbeddedHIDEventService::getOrientation
193//====================================================================================================
194IOHIDOrientationType AppleEmbeddedHIDEventService::getOrientation()
195{
196    return 0;
197}
198
199//====================================================================================================
200// AppleEmbeddedHIDEventService::getPlacement
201//====================================================================================================
202IOHIDPlacementType AppleEmbeddedHIDEventService::getPlacement()
203{
204    return 0;
205}
206
207//====================================================================================================
208// AppleEmbeddedHIDEventService::getReportInterval
209//====================================================================================================
210UInt32 AppleEmbeddedHIDEventService::getReportInterval()
211{
212    return 0;
213}
214
215