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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
|
/*
* Id: vxkbd.c,v 1.1 1999/11/24 08:35:24 keithp Exp $
*
* Copyright © 1999 Network Computing Devices, Inc. All rights reserved.
*
* Author: Keith Packard
*/
#include "kdrive.h"
#include "kkeymap.h"
#include <X11/keysym.h>
#include <inputstr.h>
#define VXWORKS_WIDTH 2
KeySym VxWorksKeymap[] = {
/*7 f1 */ XK_F1, NoSymbol,
/*8 escape */ XK_Escape, NoSymbol,
NoSymbol, NoSymbol,
NoSymbol, NoSymbol,
NoSymbol, NoSymbol,
NoSymbol, NoSymbol,
/*13 tab */ XK_Tab, NoSymbol,
/*14 ` */ XK_grave, XK_asciitilde,
/*15 f2 */ XK_F2, NoSymbol,
NoSymbol, NoSymbol,
/*17 lctrl */ XK_Control_L, NoSymbol,
/*18 lshift */ XK_Shift_L, NoSymbol,
NoSymbol, NoSymbol,
/*20 lock */ XK_Caps_Lock, NoSymbol,
/*21 q */ XK_Q, NoSymbol,
/*22 1 */ XK_1, XK_exclam,
/*23 f3 */ XK_F3, NoSymbol,
NoSymbol, NoSymbol,
/*25 lalt */ XK_Meta_L, XK_Alt_L,
/*26 z */ XK_Z, NoSymbol,
/*27 s */ XK_S, NoSymbol,
/*28 a */ XK_A, NoSymbol,
/*29 w */ XK_W, NoSymbol,
/*30 2 */ XK_2, XK_at,
/*31 f4 */ XK_F4, NoSymbol,
NoSymbol, NoSymbol,
/*33 c */ XK_C, NoSymbol,
/*34 x */ XK_X, NoSymbol,
/*35 d */ XK_D, NoSymbol,
/*36 e */ XK_E, NoSymbol,
/*37 4 */ XK_4, XK_dollar,
/*38 3 */ XK_3, XK_numbersign,
/*39 f5 */ XK_F5, NoSymbol,
NoSymbol, NoSymbol,
/*41 space */ XK_space, NoSymbol,
/*42 v */ XK_V, NoSymbol,
/*43 f */ XK_F, NoSymbol,
/*44 t */ XK_T, NoSymbol,
/*45 r */ XK_R, NoSymbol,
/*46 5 */ XK_5, XK_percent,
/*47 f6 */ XK_F6, NoSymbol,
NoSymbol, NoSymbol,
/*49 n */ XK_N, NoSymbol,
/*50 b */ XK_B, NoSymbol,
/*51 h */ XK_H, NoSymbol,
/*52 g */ XK_G, NoSymbol,
/*53 y */ XK_Y, NoSymbol,
/*54 6 */ XK_6, XK_asciicircum,
/*55 f7 */ XK_F7, NoSymbol,
NoSymbol, NoSymbol,
/*57 ralt */ XK_Meta_R, XK_Alt_R,
/*58 m */ XK_M, NoSymbol,
/*59 j */ XK_J, NoSymbol,
/*60 u */ XK_U, NoSymbol,
/*61 7 */ XK_7, XK_ampersand,
/*62 8 */ XK_8, XK_asterisk,
/*63 f8 */ XK_F8, NoSymbol,
NoSymbol, NoSymbol,
/*65 , */ XK_comma, XK_less,
/*66 k */ XK_K, NoSymbol,
/*67 i */ XK_I, NoSymbol,
/*68 o */ XK_O, NoSymbol,
/*69 0 */ XK_0, XK_parenright,
/*70 9 */ XK_9, XK_parenleft,
/*71 f9 */ XK_F9, NoSymbol,
NoSymbol, NoSymbol,
/*73 . */ XK_period, XK_greater,
/*74 / */ XK_slash, XK_question,
/*75 l */ XK_L, NoSymbol,
/*76 ; */ XK_semicolon, XK_colon,
/*77 p */ XK_P, NoSymbol,
/*78 - */ XK_minus, XK_underscore,
/*79 f10 */ XK_F10, NoSymbol,
NoSymbol, NoSymbol,
NoSymbol, NoSymbol,
/*82 ' */ XK_apostrophe, XK_quotedbl,
NoSymbol, NoSymbol,
/*84 [ */ XK_bracketleft, XK_braceleft,
/*85 = */ XK_equal, XK_plus,
/*86 f11 */ XK_F11, NoSymbol,
/*87 sysrq */ XK_Sys_Req, XK_Print,
/*88 rctrl */ XK_Control_R, NoSymbol,
/*89 rshift */ XK_Shift_R, NoSymbol,
/*90 enter */ XK_Return, NoSymbol,
/*91 ] */ XK_bracketright, XK_braceright,
/*92 \ */ XK_backslash, XK_bar,
NoSymbol, NoSymbol,
/*94 f12 */ XK_F12, NoSymbol,
/*95 scrolllock*/ XK_Scroll_Lock, NoSymbol,
/*96 down */ XK_Down, NoSymbol,
/*97 left */ XK_Left, NoSymbol,
/*98 pause */ XK_Break, XK_Pause,
/*99 up */ XK_Up, NoSymbol,
/*100 delete */ XK_Delete, NoSymbol,
/*101 end */ XK_End, NoSymbol,
/*102 bs */ XK_BackSpace, NoSymbol,
/*103 insert */ XK_Insert, NoSymbol,
NoSymbol, NoSymbol,
/*105 np 1 */ XK_KP_End, XK_KP_1,
/*106 right */ XK_Right, NoSymbol,
/*107 np 4 */ XK_KP_Left, XK_KP_4,
/*108 np 7 */ XK_KP_Home, XK_KP_7,
/*109 pgdn */ XK_Page_Down, NoSymbol,
/*110 home */ XK_Home, NoSymbol,
/*111 pgup */ XK_Page_Up, NoSymbol,
/*112 np 0 */ XK_KP_Insert, XK_KP_0,
/*113 np . */ XK_KP_Delete, XK_KP_Decimal,
/*114 np 2 */ XK_KP_Down, XK_KP_2,
/*115 np 5 */ XK_KP_5, NoSymbol,
/*116 np 6 */ XK_KP_Right, XK_KP_6,
/*117 np 8 */ XK_KP_Up, XK_KP_8,
/*118 numlock */ XK_Num_Lock, NoSymbol,
/*119 np / */ XK_KP_Divide, NoSymbol,
NoSymbol, NoSymbol,
/*121 np enter */ XK_KP_Enter, NoSymbol,
/*122 np 3 */ XK_KP_Page_Down, XK_KP_3,
NoSymbol, NoSymbol,
/*124 np + */ XK_KP_Add, NoSymbol,
/*125 np 9 */ XK_KP_Page_Up, XK_KP_9,
/*126 np * */ XK_KP_Multiply, NoSymbol,
NoSymbol, NoSymbol,
NoSymbol, NoSymbol,
NoSymbol, NoSymbol,
NoSymbol, NoSymbol,
NoSymbol, NoSymbol,
/*132 np - */ XK_KP_Subtract, NoSymbol,
NoSymbol, NoSymbol,
NoSymbol, NoSymbol,
NoSymbol, NoSymbol,
NoSymbol, NoSymbol,
NoSymbol, NoSymbol,
NoSymbol, NoSymbol,
/*139 lwin */ XK_Super_L, NoSymbol,
/*140 rwin */ XK_Super_R, NoSymbol,
/*141 menu */ XK_Menu, NoSymbol,
};
void
VxWorksKeyboardLoad (void)
{
KeySym *k;
kdMinScanCode = 7;
kdKeymapWidth = VXWORKS_WIDTH;
kdMaxScanCode = 141;
memcpy (kdKeymap, VxWorksKeymap, sizeof (VxWorksKeymap));
}
static int kbdFd = -1;
#include <errno.h>
#include <event.h>
#include <kbd_ioctl.h>
extern KeybdCtrl defaultKeyboardControl;
static void
VxWorksSetAutorepeat (unsigned char *repeats, Bool on)
{
int i;
unsigned char mask;
int scan_code;
int key_code;
unsigned char realkc;
if (on)
{
realkc = 1;
ioctl (kbdFd, KBD_ALL_REPEAT, &realkc);
for (scan_code = 7; scan_code <= 141; scan_code++)
{
key_code = scan_code + 1;
i = key_code >> 3;
mask = 1 << (key_code & 7);
if ((repeats[i] & mask) == 0)
{
realkc = scan_code;
ioctl (kbdFd, KBD_NO_REPEAT, &realkc);
}
}
}
else
{
realkc = 0;
ioctl (kbdFd, KBD_ALL_REPEAT, &realkc);
}
}
int
VxWorksKeyboardInit (void)
{
kbdFd = open ("/dev/kbd", O_RDONLY, 0);
if (kbdFd < 0)
ErrorF ("keyboard open failure %d\n", errno);
VxWorksSetAutorepeat (defaultKeyboardControl.autoRepeats, TRUE);
return -1;
}
void
VxWorksKeyboardFini (int fd)
{
if (kbdFd >= 0)
{
close (kbdFd);
kbdFd = -1;
}
}
void
VxWorksKeyboardRead (int fd)
{
}
void
VxWorksKeyboardLeds (int leds)
{
DeviceIntPtr pKeyboard = (DeviceIntPtr) LookupKeyboardDevice ();
KeybdCtrl *ctrl = &pKeyboard->kbdfeed->ctrl;
led_ioctl_info led_info;
int i;
VxWorksSetAutorepeat (ctrl->autoRepeats, ctrl->autoRepeat);
for (i = 0; i < 3; i++)
{
led_info.bit_n = 1 << i;
led_info.OFF_or_ON = (leds & (1 << i)) != 0;
led_info.reversed = 0;
ioctl (kbdFd, KBD_SET_LED, &led_info);
}
}
void
VxWorksKeyboardBell (int volume, int frequency, int duration)
{
}
KdKeyboardFuncs VxWorksKeyboardFuncs = {
VxWorksKeyboardLoad,
VxWorksKeyboardInit,
VxWorksKeyboardRead,
VxWorksKeyboardLeds,
VxWorksKeyboardBell,
VxWorksKeyboardFini,
3,
};
|