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 */ 729998Sminshall 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[] = "@(#)mkastosc.c 4.2 (Berkeley) 04/26/91"; 1633811Sbostic #endif /* not lint */ 1731896Sminshall 1829998Sminshall #include <stdio.h> 1931102Sminshall #if defined(unix) 2031065Sminshall #include <strings.h> 2131102Sminshall #else /* defined(unix) */ 2231102Sminshall #include <string.h> 2331102Sminshall #endif /* defined(unix) */ 2429998Sminshall #include <ctype.h> 2529998Sminshall 2631175Sminshall #include "../general/general.h" 2730052Sminshall #include "../ctlr/function.h" 2829998Sminshall 2929998Sminshall #include "dohits.h" 3029998Sminshall 3131102Sminshall static struct tbl { 3231246Sminshall unsigned char 3331246Sminshall scancode, 3431246Sminshall used; 3531246Sminshall char 3631246Sminshall *shiftstate; 3731102Sminshall } tbl[128]; 3829998Sminshall 3931102Sminshall int 4030077Sminshall main(argc, argv) 4130077Sminshall int argc; 4230077Sminshall char *argv[]; 4329998Sminshall { 4429998Sminshall int scancode; 4530052Sminshall int asciicode; 4629998Sminshall int empty; 4729998Sminshall int i; 4830052Sminshall int c; 4929998Sminshall int found; 5029998Sminshall struct hits *ph; 5129998Sminshall struct Hits *Ph; 5229998Sminshall struct thing *this; 5331246Sminshall struct thing **attable; 5431102Sminshall struct tbl *Pt; 5531246Sminshall static char *shiftof[] = 5631246Sminshall { "0", "SHIFT_UPSHIFT", "SHIFT_ALT", "SHIFT_ALT|SHIFT_UPSHIFT" }; 5730077Sminshall char *aidfile = 0, *fcnfile = 0; 5829998Sminshall 5930077Sminshall if (argc > 1) { 6030077Sminshall if (argv[1][0] != '-') { 6130077Sminshall aidfile = argv[1]; 6230077Sminshall } 6330077Sminshall } 6430077Sminshall if (argc > 2) { 6530077Sminshall if (argv[2][0] != '-') { 6630077Sminshall fcnfile = argv[2]; 6730077Sminshall } 6830077Sminshall } 6929998Sminshall 7030077Sminshall dohits(aidfile, fcnfile); /* Set up "Hits" */ 7130077Sminshall 7230052Sminshall printf("/*\n"); 7330052Sminshall printf(" * Ascii to scancode conversion table. First\n"); 7430052Sminshall printf(" * 128 bytes (0-127) correspond with actual Ascii\n"); 7531246Sminshall printf(" * characters; the rest are functions from ctrl/function.h\n"); 7630052Sminshall printf(" */\n"); 7730052Sminshall /* Build the ascii part of the table. */ 7830052Sminshall for (Ph = Hits, scancode = 0; Ph <= Hits+highestof(Hits); 7930052Sminshall Ph++, scancode++) { 8030052Sminshall ph = &Ph->hits; 8130052Sminshall for (i = 0; i < 4; i++) { 8230077Sminshall if (ph->hit[i].ctlrfcn == FCN_CHARACTER) { 8330052Sminshall c = Ph->name[i][0]; /* "name" of this one */ 8431246Sminshall if (tbl[c].used == 0) { 8531246Sminshall tbl[c].used = 1; 8631246Sminshall tbl[c].shiftstate = shiftof[i]; 8730052Sminshall tbl[c].scancode = scancode; 8830052Sminshall } 8930052Sminshall } 9030052Sminshall } 9130052Sminshall } 9230052Sminshall /* Now, output the table */ 9330052Sminshall for (Pt = tbl, asciicode = 0; Pt <= tbl+highestof(tbl); Pt++, asciicode++) { 9431246Sminshall if (Pt->used == 0) { 9530052Sminshall if (isprint(asciicode) && (asciicode != ' ')) { 9630052Sminshall fprintf(stderr, "Unable to produce scancode sequence for"); 9730052Sminshall fprintf(stderr, " ASCII character [%c]!\n", asciicode); 9830052Sminshall } 9931246Sminshall printf("\t{ 0, 0, undefined, 0 },\t"); 10030052Sminshall } else { 10131246Sminshall printf("\t{ 0x%02x, %s, FCN_CHARACTER, 0 },", 10231246Sminshall Pt->scancode, Pt->shiftstate); 10330052Sminshall } 10430052Sminshall printf("\t/* 0x%x", asciicode); 10530052Sminshall if (isprint(asciicode)) { 10630052Sminshall printf(" [%c]", asciicode); 10730052Sminshall } 10830052Sminshall printf(" */\n"); 10930052Sminshall } 11030052Sminshall 11130052Sminshall 11231246Sminshall for (attable = &table[0]; attable <= &table[highestof(table)]; attable++) { 11331246Sminshall for (this = *attable; this; this = this->next) { 11431246Sminshall Ph = this->hits; 11531246Sminshall if (Ph == 0) { 11631246Sminshall continue; 11731246Sminshall } 11831246Sminshall for (i = 0; i < 4; i++) { 11931246Sminshall if ((Ph->name[i] != 0) && 12031246Sminshall (Ph->name[i][0] == this->name[0]) && 12131246Sminshall (strcmp(Ph->name[i], this->name) == 0)) { 12231246Sminshall printf("\t{ 0x%02x, %s, ", 12331246Sminshall Ph-Hits, shiftof[i]); 12431247Sminshall if (memcmp("AID_", this->name, 4) == 0) { /* AID key */ 12531246Sminshall printf("FCN_AID, "); 12631246Sminshall } else { 12731246Sminshall printf("%s, ", Ph->name[i]); 12829998Sminshall } 12931247Sminshall if (memcmp("PF", this->name+4, 2) == 0) { 13031246Sminshall printf("\"PFK%s\" },\n", Ph->name[i]+4+2); 13131246Sminshall } else { 13231246Sminshall printf("\"%s\" },\n", Ph->name[i]+4); 13331246Sminshall } 13429998Sminshall } 13529998Sminshall } 13629998Sminshall } 13729998Sminshall } 13831102Sminshall 13931102Sminshall return 0; 14029998Sminshall } 141