diff --git a/src/dos/dos_keyboard_layout.cpp b/src/dos/dos_keyboard_layout.cpp index 4a26b027..2fa4cb1b 100644 --- a/src/dos/dos_keyboard_layout.cpp +++ b/src/dos/dos_keyboard_layout.cpp @@ -188,6 +188,45 @@ static Bit32u read_kcl_file(const char* kcl_file_name, const char* layout_id) { return 0; } +static Bit32u read_kcl_data(Bit8u * kcl_data, Bit32u kcl_data_size, const char* layout_id) { + // check ID-bytes + if ((kcl_data[0]!=0x4b) || (kcl_data[1]!=0x43) || (kcl_data[2]!=0x46)) { + return 0; + } + + Bit32u dpos=7+kcl_data[6]; + + for (;;) { + if (dpos+5>kcl_data_size) break; + Bit32u cur_pos=dpos; + Bit16u len=host_readw(&kcl_data[dpos]); + Bit8u data_len=kcl_data[dpos+2]; + dpos+=5; + + char lng_codes[256]; + // get all language codes for this layout + for (Bitu i=0; ikcl_data_size) break; + char lc=(char)kcl_data[dpos]; + dpos++; + i++; + if (lc==',') break; + lng_codes[lcpos++]=lc; + } + lng_codes[lcpos]=0; + if (strcasecmp(lng_codes, layout_id)==0) { + // language ID found, return position + return cur_pos; + } + } + dpos=cur_pos+3+len; + } + return 0; +} + Bitu keyboard_layout::read_keyboard_file(const char* keyboard_file_name, Bit32s specific_layout, Bit32s requested_codepage) { this->reset(); @@ -202,72 +241,36 @@ Bitu keyboard_layout::read_keyboard_file(const char* keyboard_file_name, Bit32s sprintf(nbuf, "%s.kl", keyboard_file_name); FILE* tempfile = OpenDosboxFile(nbuf); if (tempfile==NULL) { - // see if build-in keyboard layout is available, then copy it - if (!strncasecmp(keyboard_file_name,"BG",2)) { - read_buf_size=687; - for (Bitu i=0; i