]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/hidsystem/IOHIKeyboard.h
xnu-124.13.tar.gz
[apple/xnu.git] / iokit / IOKit / hidsystem / IOHIKeyboard.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 1998-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/* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved.
23 *
24 * EventSrcPCKeyboard.h - PC Keyboard EventSrc subclass definition
25 *
26 * HISTORY
27 * 28 Aug 1992 Joe Pasqua
28 * Created.
29 */
30
31#ifndef _IOHIKEYBOARD_H
32#define _IOHIKEYBOARD_H
33
34#include <IOKit/hidsystem/IOHIDevice.h>
35#include <IOKit/hidsystem/IOHIKeyboardMapper.h>
36
37/* Start Action Definitions */
38
39/*
40 * HISTORICAL NOTE:
41 * The following entry points were part of the IOHIKeyboardEvents
42 * protocol.
43 */
44
45typedef void (*KeyboardEventAction)( OSObject * target,
46 /* eventFlags */ unsigned eventType,
47 /* flags */ unsigned flags,
48 /* keyCode */ unsigned key,
49 /* charCode */ unsigned charCode,
50 /* charSet */ unsigned charSet,
51 /* originalCharCode */ unsigned origCharCode,
52 /* originalCharSet */ unsigned origCharSet,
53 /* keyboardType */ unsigned keyboardType,
54 /* repeat */ bool repeat,
55 /* atTime */ AbsoluteTime ts);
56
57typedef void (*KeyboardSpecialEventAction)(OSObject * target,
58 /* eventType */ unsigned eventType,
59 /* flags */ unsigned flags,
60 /* keyCode */ unsigned key,
61 /* specialty */ unsigned flavor,
62 /* source id */ UInt64 guid,
63 /* repeat */ bool repeat,
64 /* atTime */ AbsoluteTime ts);
65
66typedef void (*UpdateEventFlagsAction)( OSObject * target,
67 /* flags */ unsigned flags);
68
69/* End Action Definitions */
70
71
72
73/* Default key repeat parameters */
74#define EV_DEFAULTINITIALREPEAT 500000000ULL // 1/2 sec in nanoseconds
75#define EV_DEFAULTKEYREPEAT 83333333ULL // 1/12 sec in nanoseconds
76#define EV_MINKEYREPEAT 16700000ULL // 1/60 sec
77
78class IOHIKeyboard : public IOHIDevice
79{
80 OSDeclareDefaultStructors(IOHIKeyboard);
81
82protected:
83 IOLock * _deviceLock; // Lock for all device access
84 IOHIKeyboardMapper * _keyMap; // KeyMap instance
85
86 // The following fields describe the kind of keyboard
87 UInt32 _interfaceType;
88 UInt32 _deviceType;
89
90 // The following fields describe the state of the keyboard
91 UInt32 * _keyState; // kbdBitVector
92 IOByteCount _keyStateSize; // kbdBitVector allocated size
93 unsigned _eventFlags; // Current eventFlags
94 bool _alphaLock; // true means alpha lock is on
95 bool _numLock; // true means num lock is on
96 bool _charKeyActive; // true means char gen. key active
97
98 // The following fields are used in performing key repeats
99 bool _isRepeat; // true means we're generating repeat
100 unsigned _codeToRepeat; // What we are repeating
101 bool _calloutPending; // true means we've sched. a callout
102 AbsoluteTime _lastEventTime; // Time last event was dispatched
103 AbsoluteTime _downRepeatTime; // Time when we should next repeat
104 AbsoluteTime _keyRepeat; // Delay between key repeats
105 AbsoluteTime _initialKeyRepeat; // Delay before initial key repeat
106 UInt64 _guid;
107
108 OSObject * _keyboardEventTarget;
109 KeyboardEventAction _keyboardEventAction;
110 OSObject * _keyboardSpecialEventTarget;
111 KeyboardSpecialEventAction _keyboardSpecialEventAction;
112 OSObject * _updateEventFlagsTarget;
113 UpdateEventFlagsAction _updateEventFlagsAction;
114
115protected:
116 virtual void dispatchKeyboardEvent(unsigned int keyCode,
117 /* direction */ bool goingDown,
118 /* timeStamp */ AbsoluteTime time);
119
120public:
121 virtual bool init(OSDictionary * properties = 0);
122 virtual bool start(IOService * provider);
123 virtual void free();
124
125 virtual bool open(IOService * client,
126 IOOptionBits options,
127 KeyboardEventAction keAction,
128 KeyboardSpecialEventAction kseAction,
129 UpdateEventFlagsAction uefAction);
130 virtual void close(IOService * client, IOOptionBits );
131
132 virtual IOHIDKind hidKind();
133 virtual bool updateProperties( void );
134 virtual IOReturn setParamProperties(OSDictionary * dict);
135
136protected: // for subclasses to implement
137 virtual const unsigned char * defaultKeymapOfLength(UInt32 * length);
138 virtual void setAlphaLockFeedback(bool val);
139 virtual void setNumLockFeedback(bool val);
140 virtual UInt32 maxKeyCodes();
141
142
143private:
144 virtual bool resetKeyboard();
145 virtual void scheduleAutoRepeat();
146 static void _autoRepeat(void * arg, void *);
147 virtual void autoRepeat();
148 virtual void setRepeat(unsigned eventType, unsigned keyCode);
149
150/*
151 * HISTORICAL NOTE:
152 * The following methods were part of the KeyMapDelegate protocol;
153 * the declarations have now been merged directly into this class.
154 */
155
156public:
157 virtual void keyboardEvent(unsigned eventType,
158 /* flags */ unsigned flags,
159 /* keyCode */ unsigned keyCode,
160 /* charCode */ unsigned charCode,
161 /* charSet */ unsigned charSet,
162 /* originalCharCode */ unsigned origCharCode,
163 /* originalCharSet */ unsigned origCharSet);
164
165 virtual void keyboardSpecialEvent(unsigned eventType,
166 /* flags */ unsigned flags,
167 /* keyCode */ unsigned keyCode,
168 /* specialty */ unsigned flavor);
169
170 virtual void updateEventFlags(unsigned flags); // Does not generate events
171
172 virtual unsigned eventFlags(); // Global event flags
173 virtual unsigned deviceFlags(); // per-device event flags
174 virtual void setDeviceFlags(unsigned flags); // Set device event flags
175 virtual bool alphaLock(); // current alpha-lock state
176 virtual void setAlphaLock(bool val); // Set current alpha-lock state
177 virtual bool numLock();
178 virtual void setNumLock(bool val);
179 virtual bool charKeyActive(); // Is a character gen. key down?
180 virtual void setCharKeyActive(bool val); // Note that a char gen key is down.
181 virtual bool doesKeyLock(unsigned key); //does key lock physically
182 virtual unsigned getLEDStatus(); //check hardware for LED status
183
184
185};
186
187#endif /* !_IOHIKEYBOARD_H */