-
Notifications
You must be signed in to change notification settings - Fork 8
/
ev_keymap.h
169 lines (142 loc) · 6.07 KB
/
ev_keymap.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved.
*
* ev_keymap.h
* Defines the structure used for parsing keymappings. These structures
* and definitions are used by event sources in the kernel and by
* applications and utilities which manipulate keymaps.
*
* HISTORY
* 02-Jun-1992 Mike Paquette at NeXT
* Created.
*/
#ifndef _DEV_EV_KEYMAP_H
#define _DEV_EV_KEYMAP_H
#define NX_NUMKEYCODES 256 /* Highest key code is 0xff. ADB used to use 0x80 for keydown state, but who the heck uses adb anymore. */
#define NX_NUMSEQUENCES 128 /* Maximum possible number of sequences */
#define NX_NUMMODIFIERS 16 /* Maximum number of modifier bits */
#define NX_BYTE_CODES 0 /* If first short 0, all are bytes (else shorts) */
#define NX_WHICHMODMASK 0x0f /* bits out of keyBits for bucky bits */
#define NX_MODMASK 0x10 /* Bit out of keyBits indicates modifier bit */
#define NX_CHARGENMASK 0x20 /* bit out of keyBits for char gen */
#define NX_SPECIALKEYMASK 0x40 /* bit out of keyBits for specialty key */
#define NX_KEYSTATEMASK 0x80 /* OBSOLETE - DO NOT USE IN NEW DESIGNS */
/*
* Special keys currently known to and understood by the system.
* If new specialty keys are invented, extend this list as appropriate.
* The presence of these keys in a particular implementation is not
* guaranteed.
*/
#define NX_NOSPECIALKEY 0xFFFF
#define NX_KEYTYPE_SOUND_UP 0
#define NX_KEYTYPE_SOUND_DOWN 1
#define NX_KEYTYPE_BRIGHTNESS_UP 2
#define NX_KEYTYPE_BRIGHTNESS_DOWN 3
#define NX_KEYTYPE_CAPS_LOCK 4
#define NX_KEYTYPE_HELP 5
#define NX_POWER_KEY 6
#define NX_KEYTYPE_MUTE 7
#define NX_UP_ARROW_KEY 8
#define NX_DOWN_ARROW_KEY 9
#define NX_KEYTYPE_NUM_LOCK 10
#define NX_KEYTYPE_CONTRAST_UP 11
#define NX_KEYTYPE_CONTRAST_DOWN 12
#define NX_KEYTYPE_LAUNCH_PANEL 13
#define NX_KEYTYPE_EJECT 14
#define NX_KEYTYPE_VIDMIRROR 15
#define NX_KEYTYPE_PLAY 16
#define NX_KEYTYPE_NEXT 17
#define NX_KEYTYPE_PREVIOUS 18
#define NX_KEYTYPE_FAST 19
#define NX_KEYTYPE_REWIND 20
#define NX_KEYTYPE_ILLUMINATION_UP 21
#define NX_KEYTYPE_ILLUMINATION_DOWN 22
#define NX_KEYTYPE_ILLUMINATION_TOGGLE 23
#define NX_NUMSPECIALKEYS 24 /* Maximum number of special keys */
#define NX_NUM_SCANNED_SPECIALKEYS 24 /* First 24 special keys are */
/* actively scanned in kernel */
/* Mask of special keys that are posted as events */
#define NX_SPECIALKEY_POST_MASK \
((1 << NX_KEYTYPE_SOUND_UP) | (1 << NX_KEYTYPE_SOUND_DOWN) | \
(1 << NX_POWER_KEY) | (1 << NX_KEYTYPE_MUTE) | \
(1 << NX_KEYTYPE_BRIGHTNESS_UP) | (1 << NX_KEYTYPE_BRIGHTNESS_DOWN) | \
(1 << NX_KEYTYPE_CONTRAST_UP) | (1 << NX_KEYTYPE_CONTRAST_UP) | \
(1 << NX_KEYTYPE_LAUNCH_PANEL) | (1 << NX_KEYTYPE_EJECT) | \
(1 << NX_KEYTYPE_VIDMIRROR) | (1 << NX_KEYTYPE_PLAY) | \
(1 << NX_KEYTYPE_NEXT) | (1 << NX_KEYTYPE_PREVIOUS) | \
(1 << NX_KEYTYPE_FAST) | (1 << NX_KEYTYPE_REWIND) | \
(1 << NX_KEYTYPE_ILLUMINATION_UP) | \
(1 << NX_KEYTYPE_ILLUMINATION_DOWN) | \
(1 << NX_KEYTYPE_ILLUMINATION_TOGGLE) | 0)
/* Modifier key indices into modDefs[] */
#define NX_MODIFIERKEY_ALPHALOCK 0
#define NX_MODIFIERKEY_SHIFT 1
#define NX_MODIFIERKEY_CONTROL 2
#define NX_MODIFIERKEY_ALTERNATE 3
#define NX_MODIFIERKEY_COMMAND 4
#define NX_MODIFIERKEY_NUMERICPAD 5
#define NX_MODIFIERKEY_HELP 6
#define NX_MODIFIERKEY_SECONDARYFN 7
#define NX_MODIFIERKEY_NUMLOCK 8
/* support for right hand modifier */
#define NX_MODIFIERKEY_RSHIFT 9
#define NX_MODIFIERKEY_RCONTROL 10
#define NX_MODIFIERKEY_RALTERNATE 11
#define NX_MODIFIERKEY_RCOMMAND 12
#define NX_MODIFIERKEY_ALPHALOCK_STATELESS 13
#define NX_MODIFIERKEY_LAST_KEY 13
typedef struct _NXParsedKeyMapping_ {
/* If nonzero, all numbers are shorts; if zero, all numbers are bytes*/
short shorts;
/*
* For each keycode, low order bit says if the key
* generates characters.
* High order bit says if the key is assigned to a modifier bit.
* The second to low order bit gives the current state of the key.
*/
char keyBits[NX_NUMKEYCODES];
/* Bit number of highest numbered modifier bit */
int maxMod;
/* Pointers to where the list of keys for each modifiers bit begins,
* or NULL.
*/
unsigned char *modDefs[NX_NUMMODIFIERS];
/* Key code of highest key deinfed to generate characters */
int numDefs;
/* Pointer into the keyMapping where this key's definitions begin */
unsigned char *keyDefs[NX_NUMKEYCODES];
/* number of sequence definitions */
int numSeqs;
/* pointers to sequences */
unsigned char *seqDefs[NX_NUMSEQUENCES];
/* Special key definitions */
int numSpecialKeys;
/* Special key values, or 0xFFFF if none */
unsigned short specialKeys[NX_NUMSPECIALKEYS];
/* Pointer to the original keymapping string */
const unsigned char *mapping;
/* Length of the original string */
int mappingLen;
} NXParsedKeyMapping;
#endif /* !_DEV_EV_KEYMAP_H */