Commit | Line | Data |
---|---|---|
4c6bedc5 GM |
1 | /* |
2 | * This program scans a file which describes a keyboard. The output | |
3 | * of the program is a series of 'C' declarations which describe a | |
4 | * mapping between (scancode, shiftstate, altstate) and 3270 functions, | |
5 | * characters, and AIDs. | |
6 | * | |
7 | * The format of the input file is as follows: | |
8 | * | |
9 | * keynumber [ scancode [ unshifted [ shifted [ alted [ shiftalted ] ] ] ] ] | |
10 | * | |
11 | * keynumber is in decimal, and starts in column 1. | |
12 | * scancode is hexadecimal. | |
13 | * unshifted, etc. - these are either a single ascii character, | |
14 | * or the name of a function or an AID-generating key. | |
15 | * | |
16 | * all fields are separated by a single space. | |
17 | */ | |
18 | ||
19 | #include <stdio.h> | |
20 | #include <string.h> | |
21 | #include <ctype.h> | |
22 | ||
23 | #define LETS_SEE_ASCII | |
24 | #include "../m4.out" | |
25 | #undef LETS_SEE_ASCII | |
26 | ||
27 | #include "../ascebc.h" | |
28 | #include "../ebc_disp.h" | |
29 | #include "../kbd3270.h" | |
30 | ||
31 | #include "dohits.h" | |
32 | ||
33 | ||
34 | void | |
35 | main() | |
36 | { | |
37 | int scancode; | |
38 | int empty; | |
39 | int i; | |
40 | int found; | |
41 | struct hits *ph; | |
42 | struct Hits *Ph; | |
43 | TC_Ascii_t *TC; | |
44 | struct thing *this; | |
45 | ||
46 | dohits(); /* Set up "Hits" */ | |
47 | ||
48 | printf("struct tctokbd {\n\tenum { cantdo, normal, shifted, alted,"); | |
49 | printf(" shiftalted } shift;\n\tunsigned char scancode;"); | |
50 | printf("\n} tctokbd[] = {\n"); | |
51 | for (TC = &TC_Ascii[TC_LOWEST_USER-TC_LOWEST]; | |
52 | TC <= &TC_Ascii[TC_HIGHEST-TC_LOWEST]; TC++) { | |
53 | /* Hack for "PFK" names (which should be "PF") */ | |
54 | if (memcmp(TC->tc_name, "PFK", 3) == 0) { | |
55 | static char PFonly[100] = "PF"; | |
56 | ||
57 | strcpy(PFonly+2, TC->tc_name+3); | |
58 | TC->tc_name = PFonly; | |
59 | } | |
60 | found = 0; | |
61 | for (this = firstentry(TC->tc_name); (!found) && this; | |
62 | this = this->next) { | |
63 | if ((this->name[4] == TC->tc_name[0]) | |
64 | && (strcmp(this->name+4, TC->tc_name) == 0)) { | |
65 | /* this is the entry */ | |
66 | /* What we have is a TC entry matching a scancode entry */ | |
67 | Ph = this->hits; /* now, get hits */ | |
68 | if (Ph == 0) { | |
69 | continue; | |
70 | } | |
71 | for (i = 0; i < 4; i++) { | |
72 | if ((Ph->name[i][4] == TC->tc_name[0]) | |
73 | && (strcmp(Ph->name[i]+4, TC->tc_name) == 0)) { | |
74 | /* This is THE hit! */ | |
75 | found = 1; | |
76 | printf("\t{ "); | |
77 | switch (i) { | |
78 | case 0: | |
79 | printf("normal, "); | |
80 | break; | |
81 | case 1: | |
82 | printf("shifted, "); | |
83 | break; | |
84 | case 2: | |
85 | printf("alted, "); | |
86 | break; | |
87 | case 3: | |
88 | printf("shitfalted, "); | |
89 | break; | |
90 | } | |
91 | printf("0x%x },\n", Ph-Hits); | |
92 | } | |
93 | } | |
94 | } | |
95 | } | |
96 | if (!found) { | |
97 | printf("\t{ cantdo, 0 },\n"); | |
98 | fprintf(stderr, "Unable to produce TC_%s with scan codes!\n", | |
99 | TC->tc_name); | |
100 | } | |
101 | } | |
102 | printf("};\n"); | |
103 | } |