]> git.saurik.com Git - apple/xnu.git/blob - iokit/Drivers/hidsystem/drvAppleADBDevices/AppleADBKeyboard.h
038d15c0b5f90309f225a8b3cda7a4d5a5c4dcd6
[apple/xnu.git] / iokit / Drivers / hidsystem / drvAppleADBDevices / AppleADBKeyboard.h
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 #include <IOKit/adb/IOADBDevice.h>
23 #include <IOKit/hidsystem/IOHIKeyboard.h>
24
25 enum {
26 kgestaltPwrBkEKDomKbd = 0xc3,
27 kgestaltPwrBkEKISOKbd = 0xc4,
28 kgestaltPwrBkEKJISKbd = 0xc5,
29 kgestaltPwrBk99JISKbd = 0xc9
30 };
31
32 class AppleADBKeyboard : public IOHIKeyboard
33 {
34 OSDeclareDefaultStructors(AppleADBKeyboard)
35
36 private:
37
38 void setAlphaLockFeedback ( bool to );
39 void setNumLockFeedback ( bool to );
40 UInt32 maxKeyCodes ( void );
41 const unsigned char * defaultKeymapOfLength (UInt32 * length );
42 UInt32 interfaceID ( void );
43 bool doesKeyLock ( unsigned key);
44 unsigned getLEDStatus (void );
45 bool programmerKey;
46 AbsoluteTime programmerKeyTime;
47 AbsoluteTime rebootTime;
48 AbsoluteTime debuggerTime;
49
50 public:
51
52 UInt32 deviceType ( void );
53 IOADBDevice * adbDevice;
54 UInt16 turnLEDon; // used by setAlphaLockFeedback mechanism
55 UInt16 LEDStatus; //For ADB device TALK commands
56
57 bool start ( IOService * theNub );
58 IOReturn packet (UInt8 * data, IOByteCount length, UInt8 adbCommand );
59 void dispatchKeyboardEvent(unsigned int keyCode,
60 /* direction */ bool goingDown,
61 /* timeStamp */ AbsoluteTime time);
62 };
63
64 /*
65 * Special key values
66 */
67
68 #define ADBK_LEFT 0x3B
69 #define ADBK_RIGHT 0x3C
70 #define ADBK_UP 0x3E
71 #define ADBK_DOWN 0x3D
72 #define ADBK_PGUP 0x74
73 #define ADBK_PGDN 0x79
74 #define ADBK_HOME 0x73
75 #define ADBK_END 0x77
76 #define ADBK_CONTROL 0x36
77 #define ADBK_CONTROL_R 0x7D
78 #define ADBK_FLOWER 0x37
79 #define ADBK_SHIFT 0x38
80 #define ADBK_SHIFT_R 0x7B
81 #define ADBK_CAPSLOCK 0x39
82 #define ADBK_OPTION 0x3A
83 #define ADBK_OPTION_R 0x7C
84 #define ADBK_NUMLOCK 0x47
85 #define ADBK_SPACE 0x31
86 #define ADBK_F 0x03
87 #define ADBK_O 0x1F
88 #define ADBK_P 0x23
89 #define ADBK_Q 0x0C
90 #define ADBK_V 0x09
91 #define ADBK_1 0x12
92 #define ADBK_2 0x13
93 #define ADBK_3 0x14
94 #define ADBK_4 0x15
95 #define ADBK_5 0x17
96 #define ADBK_6 0x16
97 #define ADBK_7 0x1A
98 #define ADBK_8 0x1C
99 #define ADBK_9 0x19
100 #define ADBK_0 0x1D
101 #define ADBK_POWER 0x7f /* actual 0x7f 0x7f */
102
103 #define ADBK_KEYVAL(key) ((key) & 0x7f)
104 #define ADBK_PRESS(key) (((key) & 0x80) == 0)
105 #define ADBK_KEYDOWN(key) (key)
106 #define ADBK_KEYUP(key) ((key) | 0x80)
107 #define ADBK_MODIFIER(key) ((((key) & 0x7f) == ADBK_SHIFT) || \
108 (((key) & 0x7f) == ADBK_SHIFT_R) || \
109 (((key) & 0x7f) == ADBK_CONTROL) || \
110 (((key) & 0x7f) == ADBK_CONTROL_R) || \
111 (((key) & 0x7f) == ADBK_FLOWER) || \
112 (((key) & 0x7f) == ADBK_OPTION) || \
113 (((key) & 0x7f) == ADBK_OPTION_R) || \
114 (((key) & 0x7f) == ADBK_NUMLOCK) || \
115 (((key) & 0x7f) == ADBK_CAPSLOCK))
116
117 /* ADB Keyboard Status - ADB Register 2 */
118
119 #define ADBKS_LED_NUMLOCK 0x0001
120 #define ADBKS_LED_CAPSLOCK 0x0002
121 #define ADBKS_LED_SCROLLLOCK 0x0004
122 #define ADBKS_SCROLL_LOCK 0x0040
123 #define ADBKS_NUMLOCK 0x0080
124 /* Bits 3 to 5 are reserved */
125 #define ADBKS_APPLE_CMD 0x0100
126 #define ADBKS_OPTION 0x0200
127 #define ADBKS_SHIFT 0x0400
128 #define ADBKS_CONTROL 0x0800
129 #define ADBKS_CAPSLOCK 0x1000
130 #define ADBKS_RESET 0x2000
131 #define ADBKS_DELETE 0x4000
132 /* bit 16 is reserved */