1*48763Sbostic /*- 2*48763Sbostic * Copyright (c) 1988 The Regents of the University of California. 333811Sbostic * All rights reserved. 431896Sminshall * 5*48763Sbostic * %sccs.include.redist.c% 631896Sminshall */ 731896Sminshall 831896Sminshall #ifndef lint 933811Sbostic char copyright[] = 10*48763Sbostic "@(#) Copyright (c) 1988 The Regents of the University of California.\n\ 1133811Sbostic All rights reserved.\n"; 1233811Sbostic #endif /* not lint */ 1331896Sminshall 1433811Sbostic #ifndef lint 15*48763Sbostic static char sccsid[] = "@(#)mkhits.c 4.2 (Berkeley) 04/26/91"; 1633811Sbostic #endif /* not lint */ 1733811Sbostic 1831896Sminshall /* 1929996Sminshall * This program scans a file which describes a keyboard. The output 2029996Sminshall * of the program is a series of 'C' declarations which describe a 2129996Sminshall * mapping between (scancode, shiftstate, altstate) and 3270 functions, 2229996Sminshall * characters, and AIDs. 2329996Sminshall * 2429996Sminshall * The format of the input file is as follows: 2529996Sminshall * 2629996Sminshall * keynumber [ scancode [ unshifted [ shifted [ alted [ shiftalted ] ] ] ] ] 2729996Sminshall * 2829996Sminshall * keynumber is in decimal, and starts in column 1. 2929996Sminshall * scancode is hexadecimal. 3029996Sminshall * unshifted, etc. - these are either a single ascii character, 3129996Sminshall * or the name of a function or an AID-generating key. 3229996Sminshall * 3329996Sminshall * all fields are separated by a single space. 3429996Sminshall */ 3529996Sminshall 3629996Sminshall #include <stdio.h> 3731102Sminshall #if defined(unix) 3831065Sminshall #include <strings.h> 3931102Sminshall #else /* defined(unix) */ 4031102Sminshall #include <string.h> 4131102Sminshall #endif /* defined(unix) */ 4229996Sminshall #include <ctype.h> 4330052Sminshall #include "../ctlr/function.h" 4429996Sminshall 4529996Sminshall #include "dohits.h" 4629996Sminshall 4729996Sminshall 4831102Sminshall int 4930077Sminshall main(argc, argv) 5030077Sminshall int argc; 5130077Sminshall char *argv[]; 5229996Sminshall { 5329996Sminshall int scancode; 5429996Sminshall int empty; 5529996Sminshall int i; 5629996Sminshall struct hits *ph; 5729996Sminshall struct Hits *Ph; 5830077Sminshall char *aidfile = 0, *fcnfile = 0; 5929996Sminshall 6030077Sminshall if (argc > 1) { 6130077Sminshall if (argv[1][0] != '-') { 6230077Sminshall aidfile = argv[1]; 6330077Sminshall } 6430077Sminshall } 6530077Sminshall if (argc > 2) { 6630077Sminshall if (argv[2][0] != '-') { 6730077Sminshall fcnfile = argv[2]; 6830077Sminshall } 6930077Sminshall } 7029996Sminshall 7130077Sminshall dohits(aidfile, fcnfile); /* Set up "Hits" */ 7230077Sminshall 7329996Sminshall printf("struct hits hits[] = {\n"); 7429996Sminshall empty = 0; 7529996Sminshall scancode = -1; 7629996Sminshall for (Ph = Hits; Ph < Hits+(sizeof Hits/sizeof Hits[0]); Ph++) { 7729996Sminshall ph = &Ph->hits; 7829996Sminshall scancode++; 7930077Sminshall if ((ph->hit[0].ctlrfcn == undefined) 8030077Sminshall && (ph->hit[1].ctlrfcn == undefined) 8130077Sminshall && (ph->hit[2].ctlrfcn == undefined) 8230077Sminshall && (ph->hit[3].ctlrfcn == undefined)) { 8329996Sminshall empty++; 8429996Sminshall continue; 8529996Sminshall } else { 8629996Sminshall while (empty) { 8730077Sminshall printf("\t{ 0, { {undefined}, {undefined}"); 8830077Sminshall printf(", {undefined}, {undefined} } },\n"); 8929996Sminshall empty--; 9029996Sminshall } 9129996Sminshall } 9229996Sminshall printf("\t{ %d, {\t/* 0x%02x */\n\t", ph->keynumber, scancode); 9329996Sminshall for (i = 0; i < 4; i++) { 9429996Sminshall printf("\t{ "); 9530077Sminshall switch (ph->hit[i].ctlrfcn) { 9629996Sminshall case undefined: 9730077Sminshall printf("undefined"); 9829996Sminshall break; 9930077Sminshall case FCN_CHARACTER: 10030077Sminshall printf("FCN_CHARACTER, 0x%02x", ph->hit[i].code); 10129996Sminshall break; 10230077Sminshall case FCN_AID: 10330077Sminshall printf("FCN_AID, %s", Ph->name[i]); 10429996Sminshall break; 10530077Sminshall case FCN_NULL: 10630077Sminshall default: 10730077Sminshall if ((Ph->name[i] != 0) 10830077Sminshall && (strcmp(Ph->name[i], "FCN_NULL") != 0)) { 10930077Sminshall printf("%s", Ph->name[i]); 11030077Sminshall } else { 11130077Sminshall printf("undefined"); 11230077Sminshall } 11329996Sminshall break; 11429996Sminshall } 11529996Sminshall printf(" },\n\t"); 11629996Sminshall } 11729996Sminshall printf("} },\n"); 11829996Sminshall } 11929996Sminshall printf("};\n"); 12031102Sminshall return 0; 12129996Sminshall } 122