Sun Jul 19 19:11:05 2020 UTC ()
Sync with xorg-server.old: Remove #ifdef XKB conditional.

> It has been mandatory on Xorg:
>  https://cgit.freedesktop.org/xorg/xserver/commit/?id=40877c6680863bd6a8475f2bb0c54df55bcf0b0e


(tsutsui)
diff -r1.5 -r1.6 xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kKbd.c

cvs diff -r1.5 -r1.6 xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kKbd.c (switch to unified diff)

--- xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kKbd.c 2020/07/18 15:37:02 1.5
+++ xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kKbd.c 2020/07/19 19:11:05 1.6
@@ -1,415 +1,413 @@ @@ -1,415 +1,413 @@
1/* $NetBSD: x68kKbd.c,v 1.5 2020/07/18 15:37:02 tsutsui Exp $ */ 1/* $NetBSD: x68kKbd.c,v 1.6 2020/07/19 19:11:05 tsutsui Exp $ */
2/*------------------------------------------------------------------------- 2/*-------------------------------------------------------------------------
3 * Copyright (c) 1996 Yasushi Yamasaki 3 * Copyright (c) 1996 Yasushi Yamasaki
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *-----------------------------------------------------------------------*/ 25 *-----------------------------------------------------------------------*/
26 26
27/*- 27/*-
28 * Copyright (c) 1987 by the Regents of the University of California 28 * Copyright (c) 1987 by the Regents of the University of California
29 * 29 *
30 * Permission to use, copy, modify, and distribute this 30 * Permission to use, copy, modify, and distribute this
31 * software and its documentation for any purpose and without 31 * software and its documentation for any purpose and without
32 * fee is hereby granted, provided that the above copyright 32 * fee is hereby granted, provided that the above copyright
33 * notice appear in all copies. The University of California 33 * notice appear in all copies. The University of California
34 * makes no representations about the suitability of this 34 * makes no representations about the suitability of this
35 * software for any purpose. It is provided "as is" without 35 * software for any purpose. It is provided "as is" without
36 * express or implied warranty. 36 * express or implied warranty.
37 */ 37 */
38 38
39/************************************************************ 39/************************************************************
40Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA. 40Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
41 41
42 All Rights Reserved 42 All Rights Reserved
43 43
44Permission to use, copy, modify, and distribute this 44Permission to use, copy, modify, and distribute this
45software and its documentation for any purpose and without 45software and its documentation for any purpose and without
46fee is hereby granted, provided that the above copyright no- 46fee is hereby granted, provided that the above copyright no-
47tice appear in all copies and that both that copyright no- 47tice appear in all copies and that both that copyright no-
48tice and this permission notice appear in supporting docu- 48tice and this permission notice appear in supporting docu-
49mentation, and that the names of Sun or X Consortium 49mentation, and that the names of Sun or X Consortium
50not be used in advertising or publicity pertaining to  50not be used in advertising or publicity pertaining to
51distribution of the software without specific prior  51distribution of the software without specific prior
52written permission. Sun and X Consortium make no  52written permission. Sun and X Consortium make no
53representations about the suitability of this software for  53representations about the suitability of this software for
54any purpose. It is provided "as is" without any express or  54any purpose. It is provided "as is" without any express or
55implied warranty. 55implied warranty.
56 56
57SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 57SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
58INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- 58INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
59NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI- 59NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
60ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 60ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
61ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 61ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
62PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 62PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
63OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH 63OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
64THE USE OR PERFORMANCE OF THIS SOFTWARE. 64THE USE OR PERFORMANCE OF THIS SOFTWARE.
65 65
66********************************************************/ 66********************************************************/
67 67
68#include "x68k.h" 68#include "x68k.h"
69#include "mi.h" 69#include "mi.h"
70 70
71#include <X11/X.h> 71#include <X11/X.h>
72#include <X11/Xproto.h> 72#include <X11/Xproto.h>
73#include <X11/keysym.h> 73#include <X11/keysym.h>
74#include "screenint.h" 74#include "screenint.h"
75#include "inputstr.h" 75#include "inputstr.h"
76#include "eventstr.h" 76#include "eventstr.h"
77#include "misc.h" 77#include "misc.h"
78#include "scrnintstr.h" 78#include "scrnintstr.h"
79#include "servermd.h" 79#include "servermd.h"
80 80
81#include <X11/extensions/XKB.h> 81#include <X11/extensions/XKB.h>
82#include "xkbsrv.h" 82#include "xkbsrv.h"
83 83
84#define MIN_KEYCODE 7 /* necessary to avoid the mouse buttons */ 84#define MIN_KEYCODE 7 /* necessary to avoid the mouse buttons */
85#define MAX_KEYCODE 255 /* limited by the protocol */ 85#define MAX_KEYCODE 255 /* limited by the protocol */
86 86
87X68kKbdPriv x68kKbdPriv; 87X68kKbdPriv x68kKbdPriv;
88DeviceIntPtr x68kKeyboardDevice = NULL; 88DeviceIntPtr x68kKeyboardDevice = NULL;
89 89
90static void x68kKbdHandlerNotify(int, int, void *); 90static void x68kKbdHandlerNotify(int, int, void *);
91static void x68kInitModMap(KeySymsRec *, CARD8 *); 91static void x68kInitModMap(KeySymsRec *, CARD8 *);
92static void x68kInitKbdNames(XkbRMLVOSet *, X68kKbdPrivPtr); 92static void x68kInitKbdNames(XkbRMLVOSet *, X68kKbdPrivPtr);
93static void x68kKbdRingBell(DeviceIntPtr, int, int); 93static void x68kKbdRingBell(DeviceIntPtr, int, int);
94static void x68kKbdBell(int, DeviceIntPtr, pointer, int); 94static void x68kKbdBell(int, DeviceIntPtr, pointer, int);
95static void x68kKbdCtrl(DeviceIntPtr, KeybdCtrl *); 95static void x68kKbdCtrl(DeviceIntPtr, KeybdCtrl *);
96static void x68kSetLeds(X68kKbdPrivPtr, u_char); 96static void x68kSetLeds(X68kKbdPrivPtr, u_char);
97 97
98static void 98static void
99x68kKbdHandlerNotify(int fd __unused, int ready __unused, void *data __unused) 99x68kKbdHandlerNotify(int fd __unused, int ready __unused, void *data __unused)
100{ 100{
101} 101}
102 102
103/*------------------------------------------------------------------------ 103/*------------------------------------------------------------------------
104 * x68kKbdProc -- 104 * x68kKbdProc --
105 * Handle the initialization, etc. of a keyboard. 105 * Handle the initialization, etc. of a keyboard.
106 * 106 *
107 * Results: 107 * Results:
108 * None. 108 * None.
109 * 109 *
110 *----------------------------------------------------------------------*/ 110 *----------------------------------------------------------------------*/
111int 111int
112x68kKbdProc(DeviceIntPtr pDev, /* Keyboard to manipulate */ 112x68kKbdProc(DeviceIntPtr pDev, /* Keyboard to manipulate */
113 int what) /* What to do to it */ 113 int what) /* What to do to it */
114{ 114{
115 DevicePtr pKeyboard = &pDev->public; 115 DevicePtr pKeyboard = &pDev->public;
116 CARD8 x68kModMap[MAP_LENGTH]; 116 CARD8 x68kModMap[MAP_LENGTH];
117 int mode; 117 int mode;
118 XkbRMLVOSet rmlvo; 118 XkbRMLVOSet rmlvo;
119  119
120 switch (what) { 120 switch (what) {
121 case DEVICE_INIT: 121 case DEVICE_INIT:
122 pKeyboard->devicePrivate = (pointer)&x68kKbdPriv; 122 pKeyboard->devicePrivate = (pointer)&x68kKbdPriv;
123 if( (x68kKbdPriv.fd = open("/dev/kbd", O_RDONLY)) == -1 ) { 123 if( (x68kKbdPriv.fd = open("/dev/kbd", O_RDONLY)) == -1 ) {
124 ErrorF("Can't open keyboard device"); 124 ErrorF("Can't open keyboard device");
125 return !Success; 125 return !Success;
126 } 126 }
127 pKeyboard->on = FALSE; 127 pKeyboard->on = FALSE;
128 x68kInitModMap(x68kKeySyms, x68kModMap); 128 x68kInitModMap(x68kKeySyms, x68kModMap);
129 129
130 x68kInitKbdNames(&rmlvo, pKeyboard->devicePrivate); 130 x68kInitKbdNames(&rmlvo, pKeyboard->devicePrivate);
131#if 0 /* XXX How should we setup XKB maps for non PS/2 keyboard!? */ 131#if 0 /* XXX How should we setup XKB maps for non PS/2 keyboard!? */
132 InitKeyboardDeviceStruct(pDev, &rmlvo, 132 InitKeyboardDeviceStruct(pDev, &rmlvo,
133 x68kKbdBell, x68kKbdCtrl); 133 x68kKbdBell, x68kKbdCtrl);
134#else 134#else
135 InitKeyboardDeviceStruct(pDev, NULL, 135 InitKeyboardDeviceStruct(pDev, NULL,
136 x68kKbdBell, x68kKbdCtrl); 136 x68kKbdBell, x68kKbdCtrl);
137 XkbApplyMappingChange(pDev, x68kKeySyms, 137 XkbApplyMappingChange(pDev, x68kKeySyms,
138 x68kKeySyms->minKeyCode, 138 x68kKeySyms->minKeyCode,
139 x68kKeySyms->maxKeyCode - x68kKeySyms->minKeyCode + 1, 139 x68kKeySyms->maxKeyCode - x68kKeySyms->minKeyCode + 1,
140 x68kModMap, serverClient); 140 x68kModMap, serverClient);
141#endif 141#endif
142 break; 142 break;
143 143
144 case DEVICE_ON: 144 case DEVICE_ON:
145 mode = 1; 145 mode = 1;
146 if ( fcntl(x68kKbdPriv.fd, F_SETOWN, getpid()) == -1 || 146 if ( fcntl(x68kKbdPriv.fd, F_SETOWN, getpid()) == -1 ||
147 fcntl(x68kKbdPriv.fd, F_SETFL, O_NONBLOCK|O_ASYNC) == -1 || 147 fcntl(x68kKbdPriv.fd, F_SETFL, O_NONBLOCK|O_ASYNC) == -1 ||
148 ioctl(x68kKbdPriv.fd, KIOCSDIRECT, &mode) == -1 ) { 148 ioctl(x68kKbdPriv.fd, KIOCSDIRECT, &mode) == -1 ) {
149 ErrorF("Async keyboard I/O failed"); 149 ErrorF("Async keyboard I/O failed");
150 return !Success; 150 return !Success;
151 } 151 }
152 x68kSetLeds(&x68kKbdPriv, (u_char)x68kKbdPriv.leds); 152 x68kSetLeds(&x68kKbdPriv, (u_char)x68kKbdPriv.leds);
153 SetNotifyFd(x68kKbdPriv.fd, x68kKbdHandlerNotify, 153 SetNotifyFd(x68kKbdPriv.fd, x68kKbdHandlerNotify,
154 X_NOTIFY_READ, NULL); 154 X_NOTIFY_READ, NULL);
155 pKeyboard->on = TRUE; 155 pKeyboard->on = TRUE;
156 break; 156 break;
157 157
158 case DEVICE_CLOSE: 158 case DEVICE_CLOSE:
159 case DEVICE_OFF: 159 case DEVICE_OFF:
160 RemoveNotifyFd(x68kKbdPriv.fd); 160 RemoveNotifyFd(x68kKbdPriv.fd);
161 pKeyboard->on = FALSE; 161 pKeyboard->on = FALSE;
162 break; 162 break;
163 default: 163 default:
164 FatalError("Unknown keyboard operation\n"); 164 FatalError("Unknown keyboard operation\n");
165 } 165 }
166 return Success; 166 return Success;
167} 167}
168 168
169/*------------------------------------------------------------------------- 169/*-------------------------------------------------------------------------
170 * function "x68kInitModMap" 170 * function "x68kInitModMap"
171 * 171 *
172 * purpose: initialize modmap with keysym table 172 * purpose: initialize modmap with keysym table
173 * argument: (KeySymsRec *)x68kKeySyms : keysym table 173 * argument: (KeySymsRec *)x68kKeySyms : keysym table
174 * (CARD8 *)x68kModMap : result 174 * (CARD8 *)x68kModMap : result
175 * returns: nothing 175 * returns: nothing
176 *-----------------------------------------------------------------------*/ 176 *-----------------------------------------------------------------------*/
177static void 177static void
178x68kInitModMap(KeySymsRec *KeySyms, CARD8 *x68kModMap) 178x68kInitModMap(KeySymsRec *KeySyms, CARD8 *x68kModMap)
179{ 179{
180 int i; 180 int i;
181  181
182 for (i = 0; i < MAP_LENGTH; i++) 182 for (i = 0; i < MAP_LENGTH; i++)
183 x68kModMap[i] = NoSymbol; 183 x68kModMap[i] = NoSymbol;
184 if (KeySyms->minKeyCode < MIN_KEYCODE) { 184 if (KeySyms->minKeyCode < MIN_KEYCODE) {
185 KeySyms->minKeyCode += MIN_KEYCODE; 185 KeySyms->minKeyCode += MIN_KEYCODE;
186 KeySyms->maxKeyCode += MIN_KEYCODE; 186 KeySyms->maxKeyCode += MIN_KEYCODE;
187 } 187 }
188#if 0 188#if 0
189 if (KeySyms->maxKeyCode > MAX_KEYCODE) 189 if (KeySyms->maxKeyCode > MAX_KEYCODE)
190 KeySyms->maxKeyCode += MAX_KEYCODE; 190 KeySyms->maxKeyCode += MAX_KEYCODE;
191#endif 191#endif
192 for (i = KeySyms->minKeyCode; 192 for (i = KeySyms->minKeyCode;
193 i < KeySyms->maxKeyCode; i++) { 193 i < KeySyms->maxKeyCode; i++) {
194 switch (KeySyms->map[(i-KeySyms->minKeyCode)*4]) { 194 switch (KeySyms->map[(i-KeySyms->minKeyCode)*4]) {
195 case XK_Shift_L: 195 case XK_Shift_L:
196 case XK_Shift_R: 196 case XK_Shift_R:
197 x68kModMap[i] = ShiftMask; 197 x68kModMap[i] = ShiftMask;
198 break; 198 break;
199 case XK_Control_L: 199 case XK_Control_L:
200 case XK_Control_R: 200 case XK_Control_R:
201 x68kModMap[i] = ControlMask; 201 x68kModMap[i] = ControlMask;
202 break; 202 break;
203 case XK_Alt_L: 203 case XK_Alt_L:
204 case XK_Alt_R: 204 case XK_Alt_R:
205 x68kModMap[i] = Mod1Mask; 205 x68kModMap[i] = Mod1Mask;
206 break; 206 break;
207 case XK_Meta_L: 207 case XK_Meta_L:
208 case XK_Meta_R: 208 case XK_Meta_R:
209 x68kModMap[i] = Mod2Mask; 209 x68kModMap[i] = Mod2Mask;
210 break; 210 break;
211 case XK_Caps_Lock: 211 case XK_Caps_Lock:
212 x68kModMap[i] = LockMask; 212 x68kModMap[i] = LockMask;
213 break; 213 break;
214 } 214 }
215 } 215 }
216} 216}
217 217
218/*------------------------------------------------------------------------- 218/*-------------------------------------------------------------------------
219 * function "x68kInitKbdNames" 219 * function "x68kInitKbdNames"
220 * 220 *
221 * purpose: store xkb database names 221 * purpose: store xkb database names
222 * argument: (XkbRMLVOSet *)rmlvo 222 * argument: (XkbRMLVOSet *)rmlvo
223 * (X68kKbdPrivPtr)pKbd 223 * (X68kKbdPrivPtr)pKbd
224 * returns: nothing 224 * returns: nothing
225 *-----------------------------------------------------------------------*/ 225 *-----------------------------------------------------------------------*/
226static void 226static void
227x68kInitKbdNames(XkbRMLVOSet *rmlvo, X68kKbdPrivPtr pKbd) 227x68kInitKbdNames(XkbRMLVOSet *rmlvo, X68kKbdPrivPtr pKbd)
228{ 228{
229#if 0 /* XXX How should we setup XKB maps for non PS/2 keyboard!? */ 229#if 0 /* XXX How should we setup XKB maps for non PS/2 keyboard!? */
230 rmlvo->rules = "base"; 230 rmlvo->rules = "base";
231 rmlvo->model = "x68k"; 231 rmlvo->model = "x68k";
232 switch (pKbd->type) { 232 switch (pKbd->type) {
233 case X68K_KB_STANDARD: 233 case X68K_KB_STANDARD:
234 rmlvo->layout = "jp(standard)"; 234 rmlvo->layout = "jp(standard)";
235 break; 235 break;
236 case X68K_KB_ASCII: 236 case X68K_KB_ASCII:
237 rmlvo->layout = "jp(ascii)"; 237 rmlvo->layout = "jp(ascii)";
238 break; 238 break;
239 } 239 }
240 rmlvo->variant = "basic"; 240 rmlvo->variant = "basic";
241 rmlvo->options = ""; 241 rmlvo->options = "";
242#else 242#else
243 rmlvo->rules = "base"; 243 rmlvo->rules = "base";
244 rmlvo->model = NULL; 244 rmlvo->model = NULL;
245 rmlvo->layout = NULL; 245 rmlvo->layout = NULL;
246 rmlvo->variant = NULL; 246 rmlvo->variant = NULL;
247 rmlvo->options = NULL; 247 rmlvo->options = NULL;
248#endif 248#endif
249} 249}
250  250
251/*- 251/*-
252 *----------------------------------------------------------------------- 252 *-----------------------------------------------------------------------
253 * x68kKbdGetEvents -- 253 * x68kKbdGetEvents --
254 * Return the events waiting in the wings for the given keyboard. 254 * Return the events waiting in the wings for the given keyboard.
255 * 255 *
256 * Results: 256 * Results:
257 * A pointer to an array of Firm_events or (Firm_event *)0 if no events 257 * A pointer to an array of Firm_events or (Firm_event *)0 if no events
258 * The number of events contained in the array. 258 * The number of events contained in the array.
259 * A boolean as to whether more events might be available. 259 * A boolean as to whether more events might be available.
260 * 260 *
261 * Side Effects: 261 * Side Effects:
262 * None. 262 * None.
263 *----------------------------------------------------------------------- 263 *-----------------------------------------------------------------------
264 */ 264 */
265Firm_event * 265Firm_event *
266x68kKbdGetEvents(int fd, int *pNumEvents, Bool *pAgain) 266x68kKbdGetEvents(int fd, int *pNumEvents, Bool *pAgain)
267{ 267{
268 int nBytes; /* number of bytes of events available. */ 268 int nBytes; /* number of bytes of events available. */
269 static Firm_event evBuf[X68K_MAXEVENTS]; /* Buffer for Firm_events */ 269 static Firm_event evBuf[X68K_MAXEVENTS]; /* Buffer for Firm_events */
270 270
271 if ((nBytes = read (fd, evBuf, sizeof(evBuf))) == -1) { 271 if ((nBytes = read (fd, evBuf, sizeof(evBuf))) == -1) {
272 if (errno == EWOULDBLOCK) { 272 if (errno == EWOULDBLOCK) {
273 *pNumEvents = 0; 273 *pNumEvents = 0;
274 *pAgain = FALSE; 274 *pAgain = FALSE;
275 } else { 275 } else {
276 ErrorF("Reading keyboard"); 276 ErrorF("Reading keyboard");
277 FatalError ("Could not read the keyboard"); 277 FatalError ("Could not read the keyboard");
278 } 278 }
279 } else { 279 } else {
280 *pNumEvents = nBytes / sizeof (Firm_event); 280 *pNumEvents = nBytes / sizeof (Firm_event);
281 *pAgain = (nBytes == sizeof (evBuf)); 281 *pAgain = (nBytes == sizeof (evBuf));
282 } 282 }
283 return evBuf; 283 return evBuf;
284} 284}
285 285
286/*- 286/*-
287 *----------------------------------------------------------------------- 287 *-----------------------------------------------------------------------
288 * x68kKbdEnqueueEvent -- 288 * x68kKbdEnqueueEvent --
289 * 289 *
290 *----------------------------------------------------------------------- 290 *-----------------------------------------------------------------------
291 */ 291 */
292void 292void
293x68kKbdEnqueueEvent(DeviceIntPtr pDev, Firm_event *fe) 293x68kKbdEnqueueEvent(DeviceIntPtr pDev, Firm_event *fe)
294{ 294{
295 BYTE keycode; 295 BYTE keycode;
296 int type; 296 int type;
297 297
298 type = ((fe->value == VKEY_UP) ? KeyRelease : KeyPress); 298 type = ((fe->value == VKEY_UP) ? KeyRelease : KeyPress);
299 keycode = (fe->id & 0x7f) + MIN_KEYCODE; 299 keycode = (fe->id & 0x7f) + MIN_KEYCODE;
300 QueueKeyboardEvents(pDev, type, keycode); 300 QueueKeyboardEvents(pDev, type, keycode);
301} 301}
302 302
303/*- 303/*-
304 *----------------------------------------------------------------------- 304 *-----------------------------------------------------------------------
305 * x68kKbdBell -- 305 * x68kKbdBell --
306 * Ring the terminal/keyboard bell 306 * Ring the terminal/keyboard bell
307 * 307 *
308 * Results: 308 * Results:
309 * Ring the keyboard bell for an amount of time proportional to 309 * Ring the keyboard bell for an amount of time proportional to
310 * "loudness." 310 * "loudness."
311 * 311 *
312 * Side Effects: 312 * Side Effects:
313 * None, really... 313 * None, really...
314 * 314 *
315 *----------------------------------------------------------------------- 315 *-----------------------------------------------------------------------
316 */ 316 */
317 317
318static void 318static void
319x68kKbdRingBell(DeviceIntPtr pDev, int volume, int duration) 319x68kKbdRingBell(DeviceIntPtr pDev, int volume, int duration)
320{ 320{
321 int kbdCmd; /* Command to give keyboard */ 321 int kbdCmd; /* Command to give keyboard */
322 X68kKbdPrivPtr pPriv = (X68kKbdPrivPtr)pDev->public.devicePrivate; 322 X68kKbdPrivPtr pPriv = (X68kKbdPrivPtr)pDev->public.devicePrivate;
323  323
324 if (volume == 0) 324 if (volume == 0)
325 return; 325 return;
326 326
327 kbdCmd = KBD_CMD_BELL; 327 kbdCmd = KBD_CMD_BELL;
328 if (ioctl (pPriv->fd, KIOCCMD, &kbdCmd) == -1) { 328 if (ioctl (pPriv->fd, KIOCCMD, &kbdCmd) == -1) {
329 ErrorF("Failed to activate bell"); 329 ErrorF("Failed to activate bell");
330 return; 330 return;
331 } 331 }
332 usleep (duration * 1000); 332 usleep (duration * 1000);
333 kbdCmd = KBD_CMD_NOBELL; 333 kbdCmd = KBD_CMD_NOBELL;
334 if (ioctl (pPriv->fd, KIOCCMD, &kbdCmd) == -1) 334 if (ioctl (pPriv->fd, KIOCCMD, &kbdCmd) == -1)
335 ErrorF("Failed to deactivate bell"); 335 ErrorF("Failed to deactivate bell");
336} 336}
337 337
338static void 338static void
339x68kKbdBell(int volume, DeviceIntPtr pDev, pointer ctrl, int unused) 339x68kKbdBell(int volume, DeviceIntPtr pDev, pointer ctrl, int unused)
340{ 340{
341 KeybdCtrl* kctrl = (KeybdCtrl*) ctrl; 341 KeybdCtrl* kctrl = (KeybdCtrl*) ctrl;
342  342
343 if (kctrl->bell == 0) 343 if (kctrl->bell == 0)
344 return; 344 return;
345 345
346 x68kKbdRingBell(pDev, volume, kctrl->bell_duration); 346 x68kKbdRingBell(pDev, volume, kctrl->bell_duration);
347} 347}
348 348
349void 349void
350DDXRingBell(int volume, int pitch, int duration) 350DDXRingBell(int volume, int pitch, int duration)
351{ 351{
352 DeviceIntPtr pKeyboard; 352 DeviceIntPtr pKeyboard;
353 353
354 pKeyboard = x68kKeyboardDevice; 354 pKeyboard = x68kKeyboardDevice;
355 if (pKeyboard != NULL) 355 if (pKeyboard != NULL)
356 x68kKbdRingBell(pKeyboard, volume, duration); 356 x68kKbdRingBell(pKeyboard, volume, duration);
357} 357}
358 358
359/*- 359/*-
360 *----------------------------------------------------------------------- 360 *-----------------------------------------------------------------------
361 * x68kKbdCtrl -- 361 * x68kKbdCtrl --
362 * Alter some of the keyboard control parameters 362 * Alter some of the keyboard control parameters
363 * 363 *
364 * Results: 364 * Results:
365 * None. 365 * None.
366 * 366 *
367 * Side Effects: 367 * Side Effects:
368 * Some... 368 * Some...
369 * 369 *
370 *----------------------------------------------------------------------- 370 *-----------------------------------------------------------------------
371 */ 371 */
372#define XKB_LED_ZENKAKU 0x40 372#define XKB_LED_ZENKAKU 0x40
373#define XKB_LED_HIRAGANA 0x20 373#define XKB_LED_HIRAGANA 0x20
374#define XKB_LED_INSERT 0x10 374#define XKB_LED_INSERT 0x10
375#define XKB_LED_CAPS_LOCK 0x08 375#define XKB_LED_CAPS_LOCK 0x08
376#define XKB_LED_CODE_INPUT 0x04 376#define XKB_LED_CODE_INPUT 0x04
377#define XKB_LED_ROMAJI 0x02 377#define XKB_LED_ROMAJI 0x02
378#define XKB_LED_KANA_LOCK 0x01 378#define XKB_LED_KANA_LOCK 0x01
379 379
380static void 380static void
381x68kKbdCtrl(DeviceIntPtr pDev, KeybdCtrl *ctrl) 381x68kKbdCtrl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
382{ 382{
383 X68kKbdPrivPtr pPriv = (X68kKbdPrivPtr)pDev->public.devicePrivate; 383 X68kKbdPrivPtr pPriv = (X68kKbdPrivPtr)pDev->public.devicePrivate;
384 384
385#ifdef XKB 
386 if (pPriv->leds != ctrl->leds) { 385 if (pPriv->leds != ctrl->leds) {
387 x68kSetLeds(pPriv, (u_char)ctrl->leds); 386 x68kSetLeds(pPriv, (u_char)ctrl->leds);
388 pPriv->leds = ctrl->leds; 387 pPriv->leds = ctrl->leds;
389 } 388 }
390#endif 
391} 389}
392 390
393/*------------------------------------------------------------------------- 391/*-------------------------------------------------------------------------
394 * function "x68kSetLeds" 392 * function "x68kSetLeds"
395 * 393 *
396 * purpose: set keyboard leds to specified state 394 * purpose: set keyboard leds to specified state
397 * argument: (X68kKbdPrivPtr)pPriv 395 * argument: (X68kKbdPrivPtr)pPriv
398 * (u_char)data; 396 * (u_char)data;
399 * returns: nothing 397 * returns: nothing
400 *-----------------------------------------------------------------------*/ 398 *-----------------------------------------------------------------------*/
401static void 399static void
402x68kSetLeds(X68kKbdPrivPtr pPriv, u_char data) 400x68kSetLeds(X68kKbdPrivPtr pPriv, u_char data)
403{ 401{
404 /* bit sequence of led indicator in xkb and hardware are same */ 402 /* bit sequence of led indicator in xkb and hardware are same */
405 if (ioctl(pPriv->fd, KIOCSLED, &data) == -1) 403 if (ioctl(pPriv->fd, KIOCSLED, &data) == -1)
406 ErrorF("Failed to set keyboard lights"); 404 ErrorF("Failed to set keyboard lights");
407}  405}
408 406
409Bool 407Bool
410LegalModifier(unsigned int key, DeviceIntPtr pDev) 408LegalModifier(unsigned int key, DeviceIntPtr pDev)
411{ 409{
412 return TRUE; 410 return TRUE;
413} 411}
414 412
415/* EOF x68kKbd.c */ 413/* EOF x68kKbd.c */