1 /* $NetBSD: mkastosc.c,v 1.11 2003/08/07 11:16:40 agc Exp $ */
4 * Copyright (c) 1988 The Regents of the University of California.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #if defined(__COPYRIGHT) && !defined(lint)
37 __COPYRIGHT("@(#) Copyright (c) 1988\
38 The Regents of the University of California. All rights reserved.");
41 #if defined(__RCSID) && !defined(lint)
43 static char sccsid
[] = "@(#)mkastosc.c 4.2 (Berkeley) 4/26/91";
45 __RCSID("$NetBSD: mkastosc.c,v 1.11 2003/08/07 11:16:40 agc Exp $");
49 #include "../general/general.h"
50 #include "../ctlr/function.h"
63 int main(int, char *[]);
77 struct thing
**attable
;
79 static const char *shiftof
[] =
80 { "0", "SHIFT_UPSHIFT", "SHIFT_ALT", "SHIFT_ALT|SHIFT_UPSHIFT" };
81 char *aidfile
= 0, *fcnfile
= 0;
84 if (argv
[1][0] != '-') {
89 if (argv
[2][0] != '-') {
94 dohits(aidfile
, fcnfile
); /* Set up "Hits" */
97 printf(" * Ascii to scancode conversion table. First\n");
98 printf(" * 128 bytes (0-127) correspond with actual Ascii\n");
99 printf(" * characters; the rest are functions from ctrl/function.h\n");
101 /* Build the ascii part of the table. */
102 for (Ph
= Hits
, scancode
= 0; Ph
<= Hits
+highestof(Hits
);
105 for (i
= 0; i
< 4; i
++) {
106 if (ph
->hit
[i
].ctlrfcn
== FCN_CHARACTER
) {
107 c
= Ph
->name
[i
][0]; /* "name" of this one */
108 if (tbl
[c
].used
== 0) {
110 tbl
[c
].shiftstate
= shiftof
[i
];
111 tbl
[c
].scancode
= scancode
;
116 /* Now, output the table */
117 for (Pt
= tbl
, asciicode
= 0; Pt
<= tbl
+highestof(tbl
); Pt
++, asciicode
++) {
119 if (isprint(asciicode
) && (asciicode
!= ' ')) {
120 fprintf(stderr
, "mkastosc: Unable to produce scancode sequence"
121 " for ASCII character [%c]!", asciicode
);
123 printf("\t{ 0, 0, undefined, 0 },\t");
125 printf("\t{ 0x%02x, %s, FCN_CHARACTER, 0 },",
126 Pt
->scancode
, Pt
->shiftstate
);
128 printf("\t/* 0x%x", asciicode
);
129 if (isprint(asciicode
)) {
130 printf(" [%c]", asciicode
);
136 for (attable
= &table
[0]; attable
<= &table
[highestof(table
)]; attable
++) {
137 for (this = *attable
; this; this = this->next
) {
142 for (i
= 0; i
< 4; i
++) {
143 if ((Ph
->name
[i
] != 0) &&
144 (Ph
->name
[i
][0] == this->name
[0]) &&
145 (strcmp(Ph
->name
[i
], this->name
) == 0)) {
146 printf("\t{ 0x%02lx, %s, ",
147 (u_long
)(Ph
-Hits
), shiftof
[i
]);
148 if (memcmp("AID_", this->name
, 4) == 0) { /* AID key */
151 printf("%s, ", Ph
->name
[i
]);
153 if (memcmp("PF", this->name
+4, 2) == 0) {
154 printf("\"PFK%s\" },\n", Ph
->name
[i
]+4+2);
156 printf("\"%s\" },\n", Ph
->name
[i
]+4);