Commit | Line | Data |
---|---|---|
4c6bedc5 GM |
1 | |
2 | #include <stdio.h> | |
e56fc5cb | 3 | #if defined(unix) |
577b1ba9 | 4 | #include <strings.h> |
e56fc5cb GM |
5 | #else /* defined(unix) */ |
6 | #include <string.h> | |
7 | #endif /* defined(unix) */ | |
4c6bedc5 GM |
8 | #include <ctype.h> |
9 | ||
03bae598 | 10 | #include "../general/general.h" |
bfbc528f | 11 | #include "../ctlr/function.h" |
4c6bedc5 GM |
12 | |
13 | #include "dohits.h" | |
14 | ||
e56fc5cb | 15 | static struct tbl { |
addfa672 GM |
16 | unsigned char |
17 | scancode, | |
18 | used; | |
19 | char | |
20 | *shiftstate; | |
e56fc5cb | 21 | } tbl[128]; |
4c6bedc5 | 22 | |
e56fc5cb | 23 | int |
d5c90a59 GM |
24 | main(argc, argv) |
25 | int argc; | |
26 | char *argv[]; | |
4c6bedc5 GM |
27 | { |
28 | int scancode; | |
bfbc528f | 29 | int asciicode; |
4c6bedc5 GM |
30 | int empty; |
31 | int i; | |
bfbc528f | 32 | int c; |
4c6bedc5 GM |
33 | int found; |
34 | struct hits *ph; | |
35 | struct Hits *Ph; | |
4c6bedc5 | 36 | struct thing *this; |
addfa672 | 37 | struct thing **attable; |
e56fc5cb | 38 | struct tbl *Pt; |
addfa672 GM |
39 | static char *shiftof[] = |
40 | { "0", "SHIFT_UPSHIFT", "SHIFT_ALT", "SHIFT_ALT|SHIFT_UPSHIFT" }; | |
d5c90a59 | 41 | char *aidfile = 0, *fcnfile = 0; |
4c6bedc5 | 42 | |
d5c90a59 GM |
43 | if (argc > 1) { |
44 | if (argv[1][0] != '-') { | |
45 | aidfile = argv[1]; | |
46 | } | |
47 | } | |
48 | if (argc > 2) { | |
49 | if (argv[2][0] != '-') { | |
50 | fcnfile = argv[2]; | |
51 | } | |
52 | } | |
53 | ||
54 | dohits(aidfile, fcnfile); /* Set up "Hits" */ | |
4c6bedc5 | 55 | |
bfbc528f GM |
56 | printf("/*\n"); |
57 | printf(" * Ascii to scancode conversion table. First\n"); | |
58 | printf(" * 128 bytes (0-127) correspond with actual Ascii\n"); | |
addfa672 | 59 | printf(" * characters; the rest are functions from ctrl/function.h\n"); |
bfbc528f | 60 | printf(" */\n"); |
bfbc528f GM |
61 | /* Build the ascii part of the table. */ |
62 | for (Ph = Hits, scancode = 0; Ph <= Hits+highestof(Hits); | |
63 | Ph++, scancode++) { | |
64 | ph = &Ph->hits; | |
65 | for (i = 0; i < 4; i++) { | |
d5c90a59 | 66 | if (ph->hit[i].ctlrfcn == FCN_CHARACTER) { |
bfbc528f | 67 | c = Ph->name[i][0]; /* "name" of this one */ |
addfa672 GM |
68 | if (tbl[c].used == 0) { |
69 | tbl[c].used = 1; | |
70 | tbl[c].shiftstate = shiftof[i]; | |
bfbc528f GM |
71 | tbl[c].scancode = scancode; |
72 | } | |
73 | } | |
74 | } | |
75 | } | |
76 | /* Now, output the table */ | |
77 | for (Pt = tbl, asciicode = 0; Pt <= tbl+highestof(tbl); Pt++, asciicode++) { | |
addfa672 | 78 | if (Pt->used == 0) { |
bfbc528f GM |
79 | if (isprint(asciicode) && (asciicode != ' ')) { |
80 | fprintf(stderr, "Unable to produce scancode sequence for"); | |
81 | fprintf(stderr, " ASCII character [%c]!\n", asciicode); | |
82 | } | |
addfa672 | 83 | printf("\t{ 0, 0, undefined, 0 },\t"); |
bfbc528f | 84 | } else { |
addfa672 GM |
85 | printf("\t{ 0x%02x, %s, FCN_CHARACTER, 0 },", |
86 | Pt->scancode, Pt->shiftstate); | |
bfbc528f GM |
87 | } |
88 | printf("\t/* 0x%x", asciicode); | |
89 | if (isprint(asciicode)) { | |
90 | printf(" [%c]", asciicode); | |
91 | } | |
92 | printf(" */\n"); | |
93 | } | |
94 | ||
95 | ||
addfa672 GM |
96 | for (attable = &table[0]; attable <= &table[highestof(table)]; attable++) { |
97 | for (this = *attable; this; this = this->next) { | |
98 | Ph = this->hits; | |
99 | if (Ph == 0) { | |
100 | continue; | |
101 | } | |
102 | for (i = 0; i < 4; i++) { | |
103 | if ((Ph->name[i] != 0) && | |
104 | (Ph->name[i][0] == this->name[0]) && | |
105 | (strcmp(Ph->name[i], this->name) == 0)) { | |
106 | printf("\t{ 0x%02x, %s, ", | |
107 | Ph-Hits, shiftof[i]); | |
f396c0da | 108 | if (memcmp("AID_", this->name, 4) == 0) { /* AID key */ |
addfa672 GM |
109 | printf("FCN_AID, "); |
110 | } else { | |
111 | printf("%s, ", Ph->name[i]); | |
112 | } | |
f396c0da | 113 | if (memcmp("PF", this->name+4, 2) == 0) { |
addfa672 GM |
114 | printf("\"PFK%s\" },\n", Ph->name[i]+4+2); |
115 | } else { | |
116 | printf("\"%s\" },\n", Ph->name[i]+4); | |
4c6bedc5 GM |
117 | } |
118 | } | |
119 | } | |
120 | } | |
4c6bedc5 | 121 | } |
e56fc5cb GM |
122 | |
123 | return 0; | |
4c6bedc5 | 124 | } |