]> git.saurik.com Git - apple/xnu.git/blob - iokit/Families/IOHIDSystem/IOHITablet.cpp
xnu-123.5.tar.gz
[apple/xnu.git] / iokit / Families / IOHIDSystem / IOHITablet.cpp
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 #include <IOKit/hidsystem/IOHITablet.h>
23 #include <IOKit/hidsystem/IOHITabletPointer.h>
24
25 OSDefineMetaClassAndStructors(IOHITablet, IOHIPointing);
26
27 UInt16 IOHITablet::generateTabletID()
28 {
29 static UInt16 _nextTabletID = 0;
30 return _nextTabletID++;
31 }
32
33 bool IOHITablet::init(OSDictionary *propTable)
34 {
35 if (!IOHIPointing::init(propTable)) {
36 return false;
37 }
38
39 _systemTabletID = generateTabletID();
40 setProperty(kIOHISystemTabletID, (unsigned long long)_systemTabletID, 16);
41
42 return true;
43 }
44
45 bool IOHITablet::open(IOService *client,
46 IOOptionBits options,
47 RelativePointerEventAction rpeAction,
48 AbsolutePointerEventAction apeAction,
49 ScrollWheelEventAction sweAction,
50 TabletEventAction tabletAction,
51 ProximityEventAction proximityAction)
52 {
53 if (!IOHIPointing::open(client, options, rpeAction, apeAction, sweAction)) {
54 return false;
55 }
56
57 _tabletEventTarget = client;
58 _tabletEventAction = tabletAction;
59 _proximityEventTarget = client;
60 _proximityEventAction = proximityAction;
61
62 return true;
63 }
64
65 void IOHITablet::dispatchTabletEvent(NXEventData *tabletEvent,
66 AbsoluteTime ts)
67 {
68 if (_tabletEventAction) {
69 (*_tabletEventAction)(_tabletEventTarget,
70 tabletEvent,
71 ts);
72 }
73 }
74
75 void IOHITablet::dispatchProximityEvent(NXEventData *proximityEvent,
76 AbsoluteTime ts)
77 {
78 if (_proximityEventAction) {
79 (*_proximityEventAction)(_proximityEventTarget,
80 proximityEvent,
81 ts);
82 }
83 }
84
85 bool IOHITablet::startTabletPointer(IOHITabletPointer *pointer, OSDictionary *properties)
86 {
87 bool result = false;
88
89 do {
90 if (!pointer)
91 break;
92
93 if (!pointer->init(properties))
94 break;
95
96 if (!pointer->attach(this))
97 break;
98
99 if (!pointer->start(this))
100 break;
101
102 result = true;
103 } while (false);
104
105 return result;
106 }
107