]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/hidsystem/ev_keymap.h
xnu-123.5.tar.gz
[apple/xnu.git] / iokit / IOKit / hidsystem / ev_keymap.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 /* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved.
23 *
24 * ev_keymap.h
25 * Defines the structure used for parsing keymappings. These structures
26 * and definitions are used by event sources in the kernel and by
27 * applications and utilities which manipulate keymaps.
28 *
29 * HISTORY
30 * 02-Jun-1992 Mike Paquette at NeXT
31 * Created.
32 */
33
34 #ifndef _DEV_EV_KEYMAP_H
35 #define _DEV_EV_KEYMAP_H
36
37 #define NX_NUMKEYCODES 128 /* Highest key code is 0x7f */
38 #define NX_NUMSEQUENCES 128 /* Maximum possible number of sequences */
39 #define NX_NUMMODIFIERS 16 /* Maximum number of modifier bits */
40 #define NX_BYTE_CODES 0 /* If first short 0, all are bytes (else shorts) */
41
42 #define NX_WHICHMODMASK 0x0f /* bits out of keyBits for bucky bits */
43 #define NX_MODMASK 0x10 /* Bit out of keyBits indicates modifier bit */
44 #define NX_CHARGENMASK 0x20 /* bit out of keyBits for char gen */
45 #define NX_SPECIALKEYMASK 0x40 /* bit out of keyBits for specialty key */
46 #define NX_KEYSTATEMASK 0x80 /* OBSOLETE - DO NOT USE IN NEW DESIGNS */
47
48 /*
49 * Special keys currently known to and understood by the system.
50 * If new specialty keys are invented, extend this list as appropriate.
51 * The presence of these keys in a particular implementation is not
52 * guaranteed.
53 */
54 #define NX_NOSPECIALKEY 0xFFFF
55 #define NX_KEYTYPE_SOUND_UP 0
56 #define NX_KEYTYPE_SOUND_DOWN 1
57 #define NX_KEYTYPE_BRIGHTNESS_UP 2
58 #define NX_KEYTYPE_BRIGHTNESS_DOWN 3
59 #define NX_KEYTYPE_CAPS_LOCK 4
60 #define NX_KEYTYPE_HELP 5
61 #define NX_POWER_KEY 6
62 #define NX_KEYTYPE_MUTE 7
63 #define NX_UP_ARROW_KEY 8
64 #define NX_DOWN_ARROW_KEY 9
65 #define NX_KEYTYPE_NUM_LOCK 10
66
67 #define NX_KEYTYPE_CONTRAST_UP 11
68 #define NX_KEYTYPE_CONTRAST_DOWN 12
69 #define NX_KEYTYPE_LAUNCH_PANEL 13
70 #define NX_KEYTYPE_EJECT 14
71
72 #define NX_NUMSPECIALKEYS 15 /* Maximum number of special keys */
73 #define NX_NUM_SCANNED_SPECIALKEYS 15 /* First 15 special keys are */
74 /* actively scanned in kernel */
75
76 /* Mask of special keys that are posted as events */
77
78 #define NX_SPECIALKEY_POST_MASK \
79 ((1 << NX_KEYTYPE_SOUND_UP) | (1 << NX_KEYTYPE_SOUND_DOWN) | \
80 (1 << NX_POWER_KEY) | (1 << NX_KEYTYPE_MUTE) | \
81 (1 << NX_KEYTYPE_BRIGHTNESS_UP) | (1 << NX_KEYTYPE_BRIGHTNESS_DOWN) | \
82 (1 << NX_KEYTYPE_CONTRAST_UP) | (1 << NX_KEYTYPE_CONTRAST_UP) | \
83 (1 << NX_KEYTYPE_LAUNCH_PANEL) | (1 << NX_KEYTYPE_EJECT) | \
84 0)
85
86 /* Modifier key indices into modDefs[] */
87 #define NX_MODIFIERKEY_ALPHALOCK 0
88 #define NX_MODIFIERKEY_SHIFT 1
89 #define NX_MODIFIERKEY_CONTROL 2
90 #define NX_MODIFIERKEY_ALTERNATE 3
91 #define NX_MODIFIERKEY_COMMAND 4
92 #define NX_MODIFIERKEY_NUMERICPAD 5
93 #define NX_MODIFIERKEY_HELP 6
94 #define NX_MODIFIERKEY_SECONDARYFN 7
95 #define NX_MODIFIERKEY_NUMLOCK 8
96
97
98 typedef struct _NXParsedKeyMapping_ {
99 /* If nonzero, all numbers are shorts; if zero, all numbers are bytes*/
100 short shorts;
101
102 /*
103 * For each keycode, low order bit says if the key
104 * generates characters.
105 * High order bit says if the key is assigned to a modifier bit.
106 * The second to low order bit gives the current state of the key.
107 */
108 char keyBits[NX_NUMKEYCODES];
109
110 /* Bit number of highest numbered modifier bit */
111 int maxMod;
112
113 /* Pointers to where the list of keys for each modifiers bit begins,
114 * or NULL.
115 */
116 unsigned char *modDefs[NX_NUMMODIFIERS];
117
118 /* Key code of highest key deinfed to generate characters */
119 int numDefs;
120
121 /* Pointer into the keyMapping where this key's definitions begin */
122 unsigned char *keyDefs[NX_NUMKEYCODES];
123
124 /* number of sequence definitions */
125 int numSeqs;
126
127 /* pointers to sequences */
128 unsigned char *seqDefs[NX_NUMSEQUENCES];
129
130 /* Special key definitions */
131 int numSpecialKeys;
132
133 /* Special key values, or 0xFFFF if none */
134 unsigned short specialKeys[NX_NUMSPECIALKEYS];
135
136 /* Pointer to the original keymapping string */
137 const unsigned char *mapping;
138
139 /* Length of the original string */
140 int mappingLen;
141 } NXParsedKeyMapping;
142
143 #endif /* !_DEV_EV_KEYMAP_H */