2
* Id: kloadmap.c,v 1.1 1999/11/02 03:54:46 keithp Exp $
4
* Copyright � 1999 Keith Packard
6
* Permission to use, copy, modify, distribute, and sell this software and its
7
* documentation for any purpose is hereby granted without fee, provided that
8
* the above copyright notice appear in all copies and that both that
9
* copyright notice and this permission notice appear in supporting
10
* documentation, and that the name of Keith Packard not be used in
11
* advertising or publicity pertaining to distribution of the software without
12
* specific, written prior permission. Keith Packard makes no
13
* representations about the suitability of this software for any purpose. It
14
* is provided "as is" without express or implied warranty.
16
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22
* PERFORMANCE OF THIS SOFTWARE.
24
/* $XFree86: xc/programs/Xserver/hw/kdrive/kloadmap.c,v 1.2 2000/02/23 20:29:54 dawes Exp $ */
33
typedef struct _km_file {
45
NCD_DEBUG ((DEBUG_INIT, "km_fill"));
46
r = ReadFile (kf->handle, kf->buf, KM_BUF,
48
NCD_DEBUG ((DEBUG_INIT, "Got %d", kf->remain));
49
if (!r || !kf->remain)
56
#define km_getchar(kf) ((kf)->remain-- ? *kf->bufptr++ : km_fill (kf))
58
#define km_getchar(kf) getc(kf)
62
km_word (km_file *kf, char *buf, int len)
68
switch (c = km_getchar (kf)) {
83
switch (c = km_getchar (kf)) {
97
km_int (km_file *kf, int *r)
101
if (km_word (kf, word, sizeof (word)))
103
*r = strtol (word, NULL, 0);
109
WCHAR *winKbdExtensions[] = {
114
#define NUM_KBD_EXTENSIONS (sizeof (winKbdExtensions) / sizeof (winKbdExtensions[0]))
119
WCHAR file[32 + KL_NAMELENGTH];
120
WCHAR name[KL_NAMELENGTH];
130
layout = GetKeyboardLayout (0);
132
* Pre-build 46 versions of ThinSTAR software return 0
137
NCD_DEBUG ((DEBUG_INIT, "Keyboard layout 0x%x", layout));
138
for (e = 0; e < NUM_KBD_EXTENSIONS; e++)
140
wstrcpy (file, L"\\Storage Card\\");
141
wsprintf (name, TEXT("%08x"), layout);
142
wstrcat (file, name);
143
wstrcat (file, winKbdExtensions[e]);
144
NCD_DEBUG ((DEBUG_INIT, "Loading keymap from %S", file));
145
kf.handle = CreateFile (file,
147
FILE_SHARE_READ|FILE_SHARE_WRITE,
150
FILE_ATTRIBUTE_NORMAL,
152
if (kf.handle != INVALID_HANDLE_VALUE)
155
if (kf.handle == INVALID_HANDLE_VALUE)
157
NCD_DEBUG ((DEBUG_INIT, "No such file"));
167
* keycode -> keysym array (num_keycodes * width)
169
if (!km_int (&kf, &width))
171
if (width & KEYMAP_FLAGS)
173
CEKeymapFlags = (unsigned long) width;
174
if (!km_int (&kf, &width))
179
if (width > MAX_WIDTH)
181
NCD_DEBUG ((DEBUG_INIT, "Keymap width %d flags 0x%x",
182
width, CEKeymapFlags));
184
for (scancode = MIN_SCANCODE; scancode <= MAX_SCANCODE; scancode++)
186
for (w = 0; w < width; w++)
188
if (!km_int (&kf, m))
195
CEKeySyms.mapWidth = width;
198
CloseHandle (kf.handle);