68 |
mv_fox |
1 |
/*
|
190 |
mateuszvis |
2 |
* This program creates a header file for the SvarDOS installer, that
|
68 |
mv_fox |
3 |
* contains the list of all supported keyboard layouts, along with a way to
|
|
|
4 |
* select sets of keyboard layouts that apply to only a specific region.
|
|
|
5 |
*
|
1177 |
mateusz.vi |
6 |
* Copyright (C) 2016-2023 Mateusz Viste
|
68 |
mv_fox |
7 |
*/
|
|
|
8 |
|
|
|
9 |
/* the kblayouts list is a NULL-terminated array that contains entries in the
|
|
|
10 |
* following format:
|
96 |
mv_fox |
11 |
* human description string <0> layout code string <0> <codepage number as a 16bit value> <ega.sys file number as a single byte> <keyboard.sys file number as a single byte> <sub keyb ID as a 16bit value, zero if none>
|
68 |
mv_fox |
12 |
|
|
|
13 |
char *kblayouts[] = {
|
|
|
14 |
"English (US)\0xxxx",
|
|
|
15 |
"Polish\0pl\0xxxx"};
|
|
|
16 |
};
|
|
|
17 |
*/
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
#include <stdio.h>
|
|
|
21 |
#include <string.h>
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
/* global file pointers */
|
|
|
25 |
FILE *fdkeyb, *fdoff;
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
/* Converts a positive base_10 into base_8 */
|
|
|
29 |
static unsigned int dec2oct(int n) {
|
|
|
30 |
int res=0, digitPos=1;
|
|
|
31 |
while (n) {
|
|
|
32 |
res += (n & 7) * digitPos;
|
|
|
33 |
n >>= 3;
|
|
|
34 |
digitPos *= 10;
|
|
|
35 |
}
|
|
|
36 |
return(res);
|
|
|
37 |
}
|
|
|
38 |
|
|
|
39 |
|
96 |
mv_fox |
40 |
static void addnew(char *countrycode, char *humanlang, char *keybcode, unsigned short cp, unsigned char egafile, unsigned char keybfile, unsigned int subid) {
|
68 |
mv_fox |
41 |
static char lastcountry[4] = {0};
|
|
|
42 |
static int curoffset = 0, curcountryoffset = 0;
|
|
|
43 |
/* if new country, declare an offset */
|
|
|
44 |
if (strcmp(countrycode, lastcountry) != 0) {
|
|
|
45 |
/* close previous one, if any */
|
|
|
46 |
if (lastcountry[0] != 0) {
|
|
|
47 |
fprintf(fdoff, "#define OFFLEN_%s %d\r\n", lastcountry, curoffset - curcountryoffset);
|
|
|
48 |
} else {
|
624 |
mateuszvis |
49 |
fprintf(fdkeyb, "const char *kblayouts[] = {\r\n");
|
68 |
mv_fox |
50 |
}
|
|
|
51 |
/* open new one, if any */
|
|
|
52 |
if (countrycode[0] != 0) {
|
|
|
53 |
fprintf(fdkeyb, " /****** %s ******/\r\n", countrycode);
|
|
|
54 |
curcountryoffset = curoffset;
|
|
|
55 |
fprintf(fdoff, "#define OFFLOC_%s %d\r\n", countrycode, curoffset);
|
|
|
56 |
strcpy(lastcountry, countrycode);
|
|
|
57 |
} else {
|
|
|
58 |
fprintf(fdoff, "#define OFFCOUNT %d\r\n", curoffset);
|
|
|
59 |
}
|
|
|
60 |
}
|
|
|
61 |
/* */
|
|
|
62 |
if (countrycode[0] != 0) {
|
96 |
mv_fox |
63 |
fprintf(fdkeyb, " \"%s\\0%s\\0\\%d\\%d\\%d\\%d\\%d\\%d\",\r\n", humanlang, keybcode, dec2oct(cp >> 8), dec2oct(cp & 0xff), dec2oct(egafile), dec2oct(keybfile), dec2oct(subid >> 8), dec2oct(subid & 0xff));
|
68 |
mv_fox |
64 |
} else {
|
|
|
65 |
fprintf(fdkeyb, " NULL};\r\n");
|
|
|
66 |
}
|
|
|
67 |
curoffset++;
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
int main(void) {
|
|
|
72 |
|
|
|
73 |
/*** open files ***/
|
|
|
74 |
fdkeyb = fopen("keylay.h", "wb");
|
|
|
75 |
fdoff = fopen("keyoff.h", "wb");
|
116 |
mv_fox |
76 |
fprintf(fdkeyb, "/* DO NOT EDIT THIS FILE, IT IS AUTO-GENERATED BY LOCALES.EXE */\r\n");
|
|
|
77 |
fprintf(fdoff, "/* DO NOT EDIT THIS FILE, IT IS AUTO-GENERATED BY LOCALES.EXE */\r\n");
|
68 |
mv_fox |
78 |
|
|
|
79 |
/******************* LAYOUTS LIST START *******************/
|
|
|
80 |
|
118 |
mv_fox |
81 |
/* addnew(countrycode, humanlang, keybcode, cp, egafile, keybfile, subid) */
|
|
|
82 |
|
68 |
mv_fox |
83 |
/* English */
|
96 |
mv_fox |
84 |
addnew("EN", "English (US)", "en", 437, 0, 0, 0);
|
|
|
85 |
addnew("EN", "English (UK)", "uk", 437, 0, 1, 0);
|
68 |
mv_fox |
86 |
|
118 |
mv_fox |
87 |
/* Armenian */
|
|
|
88 |
addnew("HY", "Armenian", "hy", 899, 6, 3, 0);
|
|
|
89 |
|
1177 |
mateusz.vi |
90 |
/* Brazilian */
|
|
|
91 |
addnew("BR", "Brazilian", "br", 850, 1, 1, 0);
|
|
|
92 |
addnew("BR", "Brazilian (US layout)", "br274", 850, 1, 1, 0);
|
|
|
93 |
|
118 |
mv_fox |
94 |
/* Bulgarian */
|
|
|
95 |
addnew("BG", "Bulgarian", "bg", 872, 3, 2, 0);
|
|
|
96 |
|
68 |
mv_fox |
97 |
/* French */
|
96 |
mv_fox |
98 |
addnew("FR", "French (France)", "fr", 858, 1, 1, 0);
|
|
|
99 |
addnew("FR", "French (Canada, standard)", "cf", 863, 9, 1, 0);
|
|
|
100 |
addnew("FR", "French (Canada, legacy)", "cf", 863, 9, 1, 501);
|
1463 |
mateusz.vi |
101 |
addnew("FR", "French (Switzerland)", "sf", 858, 1, 1, 0);
|
68 |
mv_fox |
102 |
|
|
|
103 |
/* German */
|
96 |
mv_fox |
104 |
addnew("DE", "German", "de", 858, 1, 1, 0);
|
68 |
mv_fox |
105 |
|
92 |
mv_fox |
106 |
/* Hungarian */
|
96 |
mv_fox |
107 |
addnew("HU", "Hungarian", "hu", 852, 1, 1, 208);
|
92 |
mv_fox |
108 |
|
118 |
mv_fox |
109 |
/* Italian */
|
|
|
110 |
addnew("IT", "Italian", "it", 858, 1, 1, 0);
|
|
|
111 |
|
|
|
112 |
/* Norvegian */
|
|
|
113 |
addnew("NO", "Norvegian", "no", 858, 9, 1, 0);
|
|
|
114 |
|
68 |
mv_fox |
115 |
/* Polish */
|
118 |
mv_fox |
116 |
addnew("PL", "Polish (Programmer)", "pl", 991, 10, 1, 0);
|
|
|
117 |
addnew("PL", "Polish (Typewriter)", "pl", 991, 10, 1, 214);
|
68 |
mv_fox |
118 |
|
116 |
mv_fox |
119 |
/* Russian */
|
|
|
120 |
addnew("RU", "Russian (Standard)", "ru", 866, 3, 2, 0);
|
|
|
121 |
addnew("RU", "Russian (Typewriter)", "ru", 866, 3, 2, 443);
|
|
|
122 |
|
118 |
mv_fox |
123 |
/* Slovenian */
|
123 |
mv_fox |
124 |
addnew("SI", "Slovenian", "si", 852, 1, 1, 0);
|
118 |
mv_fox |
125 |
|
68 |
mv_fox |
126 |
/* Spanish */
|
96 |
mv_fox |
127 |
addnew("ES", "Spanish", "es", 858, 1, 1, 0);
|
68 |
mv_fox |
128 |
|
118 |
mv_fox |
129 |
/* Swedish */
|
|
|
130 |
addnew("SV", "Swedish", "sv", 858, 1, 1, 0);
|
|
|
131 |
|
68 |
mv_fox |
132 |
/* Turkish */
|
96 |
mv_fox |
133 |
addnew("TR", "Turkish", "tr", 857, 1, 2, 0);
|
68 |
mv_fox |
134 |
|
|
|
135 |
/******************* LAYOUTS LIST STOP *******************/
|
|
|
136 |
|
|
|
137 |
/* end of list - DO NOT REMOVE */
|
96 |
mv_fox |
138 |
addnew("", "", "", 0, 0, 0, 0);
|
68 |
mv_fox |
139 |
|
|
|
140 |
/* close files */
|
|
|
141 |
fclose(fdoff);
|
|
|
142 |
fclose(fdkeyb);
|
|
|
143 |
|
|
|
144 |
return(0);
|
|
|
145 |
}
|