From c03e246f7b5778c09f8da770d18ccdbfc5351ce6 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 22 May 2023 11:40:55 +0200 Subject: [PATCH 001/327] test --- linux/mcompile/testfile | 1 + 1 file changed, 1 insertion(+) create mode 100644 linux/mcompile/testfile diff --git a/linux/mcompile/testfile b/linux/mcompile/testfile new file mode 100644 index 0000000000..26918572ec --- /dev/null +++ b/linux/mcompile/testfile @@ -0,0 +1 @@ +testfile From 6b8615816228cd0d579e8988831c16e34c0fd144 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 22 May 2023 11:46:19 +0200 Subject: [PATCH 002/327] rename --- linux/mcompile/{testfile => testfile.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename linux/mcompile/{testfile => testfile.txt} (100%) diff --git a/linux/mcompile/testfile b/linux/mcompile/testfile.txt similarity index 100% rename from linux/mcompile/testfile rename to linux/mcompile/testfile.txt From 80b9b51d421a28157f7368d9a3241c6479e2bb5e Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 22 May 2023 11:57:49 +0200 Subject: [PATCH 003/327] deleted testfile --- linux/mcompile/testfile.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 linux/mcompile/testfile.txt diff --git a/linux/mcompile/testfile.txt b/linux/mcompile/testfile.txt deleted file mode 100644 index 26918572ec..0000000000 --- a/linux/mcompile/testfile.txt +++ /dev/null @@ -1 +0,0 @@ -testfile From b3a591ce7b44eda13152526ccfcc2c68fd2ea7ea Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 22 May 2023 12:07:00 +0200 Subject: [PATCH 004/327] feature(linux): create readme.md for the mcompile project --- linux/mcompile/Readme.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 linux/mcompile/Readme.md diff --git a/linux/mcompile/Readme.md b/linux/mcompile/Readme.md new file mode 100644 index 0000000000..f45bdbe1fb --- /dev/null +++ b/linux/mcompile/Readme.md @@ -0,0 +1,3 @@ +This is a proposal to rewrite mcompile for Linux. For this we need to query the base keyboard data from the Linux platform, then rewriting the keyboard .kmx using the same approach as is done in mcompile for Windows, but working from the data from the x11 keyboard on Linux. + +Ideally, we'd rewrite mcompile to be cross-platform (Windows, Linux, macOS), so that the keyboard interrogation would be separated from the .kmx rewriting, at least to some degree. Nevertheless it would probably be easiest to start from a standalone implementation. From 0250b6729e79404780b79613d41c97e303972211 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 23 May 2023 14:52:28 +0200 Subject: [PATCH 005/327] feature(linux): mcompile setup framework for mcompile: read US keyboard, get keysms and push to vector --- linux/mcompile/keymap/README.md | 4 + linux/mcompile/keymap/keymap.h | 12 +++ linux/mcompile/keymap/main.cpp | 148 ++++++++++++++++++++++++++++++ linux/mcompile/keymap/meson.build | 11 +++ 4 files changed, 175 insertions(+) create mode 100644 linux/mcompile/keymap/README.md create mode 100644 linux/mcompile/keymap/keymap.h create mode 100644 linux/mcompile/keymap/main.cpp create mode 100644 linux/mcompile/keymap/meson.build diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md new file mode 100644 index 0000000000..4891de5152 --- /dev/null +++ b/linux/mcompile/keymap/README.md @@ -0,0 +1,4 @@ +# Keymap + +Sample program that loops over the key codes 10-61 and outputs the key +values for groups 0 and 1. diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h new file mode 100644 index 0000000000..7beb5186ae --- /dev/null +++ b/linux/mcompile/keymap/keymap.h @@ -0,0 +1,12 @@ + +#include + +#include +#include +#include +#include + +static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode); +std::vector > > write_US_ToVector(std::string language, const char* text) ; +std::vector CreateCompleteRow_US(FILE* fpp, const char* text, std::string language) ; +void extract_difference(std::vector > > US_vector, std::string lang_Other ) ; diff --git a/linux/mcompile/keymap/main.cpp b/linux/mcompile/keymap/main.cpp new file mode 100644 index 0000000000..b48cd27339 --- /dev/null +++ b/linux/mcompile/keymap/main.cpp @@ -0,0 +1,148 @@ +#include "keymap.h" + +static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) +{ + GdkKeymapKey *maps; + guint *keyvals; + gint count; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return; + + for (int i = 0; i < count; i++) { + if (maps[i].level > 0 || maps[i].group > 1) + continue; + printf(" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); + } + + g_free(keyvals); + g_free(maps); +} + +std::vector > > write_US_ToVector(std::string language, const char* text) { + printf("+++++++ start to open_file \n"); + std::vector > > Vector_split; + std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; + const char* cc = FullPathName.c_str(); + FILE* fp = fopen((cc), "r"); + if ( !fp) + printf("could not open file!"); + else + printf("+++++++ file open OK \n"); + std::vector Vector_complete = CreateCompleteRow_US(fp, text, language); // creates vector of all . TTODO lookup other language files + + fclose(fp); + return Vector_split; +} + +std::vector CreateCompleteRow_US(FILE* fpp, const char* text, std::string language) { + printf("+++++++ start CreateCompleteRow_US\n"); + std::vector complete_List; + int buffer_size = 512; + char buffer[buffer_size]; + bool print_OK = false; + const char* key = "key <"; + std::string str_txt(text); + std::string xbk_mark = "xkb_symbol"; + std::ofstream KeyboardFile("File_" + language + ".txt"); + + printf("Keyboard %s\n", text); + KeyboardFile << "Keyboard" << text << "\n"; + + if (fpp) { + while (fgets(buffer, buffer_size, fpp) != NULL) { + std::string str_buf(buffer); + + // TODO: recursive search for other included Configuration files + // if find "include" -> recursive... + + // stop when finding the mark xkb_symbol + if (std::string(str_buf).find(xbk_mark) != std::string::npos) + print_OK = false; + + // start when finding the mark xkb_symbol + correct layout + if ((std::string(str_buf).find(str_txt) != std::string::npos)) + print_OK = true; + + if ((print_OK) && (std::string(str_buf).find(key) != std::string::npos)) { + printf("... %s", buffer); + complete_List.push_back(buffer); + KeyboardFile << buffer; + } + } + } + printf("end Keyboard %s..........................................\n\n", text); + return complete_List; +} + +void extract_difference(std::vector > > US_vector, std::string lang_Other ) +{ + printf("+++++++ start extract_difference\n"); + /* + std::ofstream Map_File("Map_" + lang_US + "_To_" + lang_Other + ".txt"); + std::string diff; + std::cout <<"key"<< std::setw(26)<< "Char US"<< std::setw(20)<<"Char other" << std::setw(10)<< "diff? \n"; + Map_File <<"key"<< std::setw(26)<< "Char US"<< std::setw(20)<<"Char other" << std::setw(10)<< "diff? \n"; + std::cout <<"---------------------------------------------------------------\n"; + Map_File <<"---------------------------------------------------------------\n"; + + //ToDo for all columns; watchout for empty fields!! + for ( int i =0; i< US_vector.size();i++) + { + for ( int j =0; j< other_vector.size();j++) + { + diff =" \t"; + if( US_vector[i][0] == other_vector[j][0] ) + { + if( US_vector[i][1] != other_vector[j][1] ) diff = " *** "; + std::cout << US_vector[i][0] << std::setw(20)<< US_vector[i][1] << std::setw(20)<< other_vector[j][1] < > > All_Vector = write_US_ToVector(US_language, text_us); + extract_difference(All_Vector,other_language); + +//------------------------------------------ + + + + + gdk_display_close(display); + + return 0; +} diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build new file mode 100644 index 0000000000..7f41bc2f70 --- /dev/null +++ b/linux/mcompile/keymap/meson.build @@ -0,0 +1,11 @@ +project('keymap', 'c', 'cpp', + license: 'MIT', + meson_version: '>=1.0') + +gtk = dependency('gtk+-3.0', version: '>= 2.4') + +keymap = executable( + 'keymap', + sources: ['main.cpp'], + dependencies: [gtk] +) From 9e609dead0aa95e659b02fbae5e8010d471162c1 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 23 May 2023 18:28:45 +0200 Subject: [PATCH 006/327] feature(linux): mcompile replace main.cpp with keymap.cpp --- linux/mcompile/keymap/{main.cpp => Xmain.cpp} | 0 linux/mcompile/keymap/keymap.cpp | 236 ++++++++++++++++++ linux/mcompile/keymap/keymap.h | 14 +- linux/mcompile/keymap/meson.build | 2 +- 4 files changed, 248 insertions(+), 4 deletions(-) rename linux/mcompile/keymap/{main.cpp => Xmain.cpp} (100%) create mode 100644 linux/mcompile/keymap/keymap.cpp diff --git a/linux/mcompile/keymap/main.cpp b/linux/mcompile/keymap/Xmain.cpp similarity index 100% rename from linux/mcompile/keymap/main.cpp rename to linux/mcompile/keymap/Xmain.cpp diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp new file mode 100644 index 0000000000..069fad7fff --- /dev/null +++ b/linux/mcompile/keymap/keymap.cpp @@ -0,0 +1,236 @@ +#include "keymap.h" + +static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) +{ + GdkKeymapKey *maps; + guint *keyvals; + gint count; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return; + + for (int i = 0; i < count; i++) { + if (maps[i].level > 1 || maps[i].group > 4) + continue; + printf(" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); + } + + + g_free(keyvals); + g_free(maps); +} + +v_str_3D write_US_ToVector(std::string language, const char* text) { + + printf("+++++++ start to open_file \n"); + v_str_3D Vector_split; + std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; + + const char* cc = FullPathName.c_str(); + FILE* fp = fopen((cc), "r"); + if ( !fp) + printf("could not open file!"); + else + printf("+++++++ file open OK \n"); + + v_str_1D Vector_completeUS = CreateCompleteRow_US(fp, text, language); // creates vector of all . TTODO lookup other language files + + //here split Vector to 3D vector + Vector_split = SplitTo_3D_Vector( Vector_completeUS); + + printf("+++++++ sizes write_US_ToVector %li..%li..%li\n", Vector_split.size(), Vector_split[0].size(),Vector_split[0][0].size()); + fclose(fp); + return Vector_split; +} + +bool test(v_str_3D V){ + printf("+++++++ stest"); +std::cout << V[0][0][0]<< "..\n" + << V[0][0][1]<< "..\n" + << V[0][0][2]<< "..\n" + << V[0][0][3]<< "..\n" + << V[0][0][4]<< "..\n\n" + + << V[0][1][0]<< "..\n" + << V[0][1][1]<< "..\n" + << V[0][1][2]<< "..\n" + << V[0][1][3]<< "..\n" + << V[0][1][4]<< "..\n\n" + + << V[0][22][0]<< "..\n" + << V[0][22][1]<< "..\n" + << V[0][22][2]<< "..\n" + << V[0][22][3]<< "..\n" + << V[0][22][4]<< "..\n\n" + + << V[0][45][0]<< "..\n" + << V[0][45][1]<< "..\n" + << V[0][45][2]<< "..\n" + << V[0][45][3]<< "..\n" + << V[0][45][4]<< "..\n\n" + + << V[0][46][0]<< "..\n" + << V[0][46][1]<< "..\n" + << V[0][46][2]<< "..\n" + << V[0][46][3]<< "..\n" + << V[0][46][4]<< "..\n\n" + + << V[0][0][0]<< "..\n"; + return true; +} + +v_str_1D CreateCompleteRow_US(FILE* fpp, const char* text, std::string language) { + printf("+++++++ start CreateCompleteRow_US\n"); + v_str_1D complete_List; + int buffer_size = 512; + char buffer[buffer_size]; + bool print_OK = false; + const char* key = "key <"; + std::string str_txt(text); + std::string xbk_mark = "xkb_symbol"; + std::ofstream KeyboardFile("File_" + language + ".txt"); + + printf("Keyboard %s\n", text); + KeyboardFile << "Keyboard" << text << "\n"; + + if (fpp) { + while (fgets(buffer, buffer_size, fpp) != NULL) { + std::string str_buf(buffer); + + // Maybe TODO: recursive search for other included Configuration files + // if find "include" -> recursive... + + // stop when finding the mark xkb_symbol + if (std::string(str_buf).find(xbk_mark) != std::string::npos) + print_OK = false; + + // start when finding the mark xkb_symbol + correct layout + if ((std::string(str_buf).find(str_txt) != std::string::npos)) + print_OK = true; + + if ((print_OK) && (std::string(str_buf).find(key) != std::string::npos)) { + printf("... %s", buffer); + complete_List.push_back(buffer); + KeyboardFile << buffer; + } + } + } + printf("end Keyboard %s..........................................\n\n", text); + return complete_List; +} + +void extract_difference(v_str_3D, std::string lang_Other ) +{ + printf("+++++++ start extract_difference\n"); + /* + std::ofstream Map_File("Map_" + lang_US + "_To_" + lang_Other + ".txt"); + std::string diff; + std::cout <<"key"<< std::setw(26)<< "Char US"<< std::setw(20)<<"Char other" << std::setw(10)<< "diff? \n"; + Map_File <<"key"<< std::setw(26)<< "Char US"<< std::setw(20)<<"Char other" << std::setw(10)<< "diff? \n"; + std::cout <<"---------------------------------------------------------------\n"; + Map_File <<"---------------------------------------------------------------\n"; + + //ToDo for all columns; watchout for empty fields!! + for ( int i =0; i< US_vector.size();i++) + { + for ( int j =0; j< other_vector.size();j++) + { + diff =" \t"; + if( US_vector[i][0] == other_vector[j][0] ) + { + if( US_vector[i][1] != other_vector[j][1] ) diff = " *** "; + std::cout << US_vector[i][0] << std::setw(20)<< US_vector[i][1] << std::setw(20)<< other_vector[j][1] < delim{' ', '[', ']', '}', ';', '\t', '\n'}; + printf("+++++++ start SplitTo_3D_Vector\n"); + char split_bracel = '{'; + char split_char_komma = ','; + std::vector tokens; + std::vector > everything; + v_str_3D all; + + // while starts with key... + for (int k = 0; k < (int)p_completeList.size() - 1; k++) { + + // remove alll unwanted char + for (int i = 0; i < (int) delim.size(); i++) + p_completeList[k].erase(remove(p_completeList[k].begin(), p_completeList[k].end(), delim[i]), p_completeList[k].end()); + + // inly lines with ("key<.. are of interest + if (p_completeList[k].find("key<") != std::string::npos) { + // seperate key<... + std::istringstream split1(p_completeList[k]); + for (std::string each; std::getline(split1, each, split_bracel); tokens.push_back(each)); + + // seperate rest with comma and push to everything + std::istringstream split(tokens[1]); + tokens.pop_back(); + for (std::string each; std::getline(split, each, split_char_komma); tokens.push_back(each)); + everything.push_back(tokens); + tokens.clear(); + } + } + //return everything; + all.push_back(everything); + //printf("+++++++ ssizes %i..%i..%i\n", all.size(), all[0].size ,all[0][0].size); + printf("+++++++ sizes SplitTo_3D_Vector %li..%li..%li\n", all.size(), all[0].size(),all[0][0].size()); + return all; +} + +//-------------------------------------- +int main(gint argc, gchar **argv) +{ + gdk_init(&argc, &argv); + GdkDisplay *display = gdk_display_get_default(); + if (!display) { + printf("ERROR: can't get display\n"); + return 1; + } + GdkKeymap *keymap = gdk_keymap_get_for_display(display); + if (!keymap) { + printf("ERROR: Can't get keymap\n"); + gdk_display_close(display); + return 2; + } + + for (int keycode = 10; keycode <= 61; keycode++) { + printf("-------------------\n"); + printf("Keycode %d:\n", keycode); + PrintKeymapForCode(keymap, keycode); + } +//------------------------------------------ +//GdkKeymap* kmp; +//kmp = gdk_get_default(); + + + std::string US_language = "us"; + const char* text_us = "xkb_symbols \"intl\""; + + std::string other_language = "--"; + // ToDo get other/current language from XKB + // e.g. other_language = 2; +printf("-°°°°°°°° write_US_ToVector\n"); + v_str_3D All_Vector = write_US_ToVector(US_language, text_us); + +printf("-°°°°°°°° test\n"); + //bool ok = test(All_Vector); + +printf("-°°°°°°°° extract_difference\n"); + extract_difference(All_Vector,other_language); + +//------------------------------------------ + + + + + gdk_display_close(display); + + return 0; +} diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 7beb5186ae..67469ef26a 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -5,8 +5,16 @@ #include #include #include +#include +#include + +typedef std::vector v_str_1D; +typedef std::vector > v_str_2D; +typedef std::vector > > v_str_3D; static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode); -std::vector > > write_US_ToVector(std::string language, const char* text) ; -std::vector CreateCompleteRow_US(FILE* fpp, const char* text, std::string language) ; -void extract_difference(std::vector > > US_vector, std::string lang_Other ) ; + +v_str_3D write_US_ToVector(std::string language, const char* text) ; +v_str_1D CreateCompleteRow_US(FILE* fpp, const char* text, std::string language) ; +void extract_difference(v_str_3D US_vector, std::string lang_Other ) ; +v_str_3D SplitTo_3D_Vector(v_str_1D completeListUS); diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index 7f41bc2f70..eb1e03783b 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -6,6 +6,6 @@ gtk = dependency('gtk+-3.0', version: '>= 2.4') keymap = executable( 'keymap', - sources: ['main.cpp'], + sources: ['keymap.cpp'], dependencies: [gtk] ) From fedbfbf7be35d7beb6ec9acad5944a188964737c Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 23 May 2023 14:52:28 +0200 Subject: [PATCH 007/327] feature(linux): mcompile copy keymap-test --- linux/mcompile/keymap/main.cpp | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 linux/mcompile/keymap/main.cpp diff --git a/linux/mcompile/keymap/main.cpp b/linux/mcompile/keymap/main.cpp new file mode 100644 index 0000000000..2fa3409d87 --- /dev/null +++ b/linux/mcompile/keymap/main.cpp @@ -0,0 +1,47 @@ +#include + + +static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) +{ + GdkKeymapKey *maps; + guint *keyvals; + gint count; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return; + + for (int i = 0; i < count; i++) { + if (maps[i].level > 0 || maps[i].group > 1) + continue; + printf(" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); + } + + g_free(keyvals); + g_free(maps); +} + +int main(gint argc, gchar **argv) +{ + gdk_init(&argc, &argv); + GdkDisplay *display = gdk_display_get_default(); + if (!display) { + printf("ERROR: can't get display\n"); + return 1; + } + GdkKeymap *keymap = gdk_keymap_get_for_display(display); + if (!keymap) { + printf("ERROR: Can't get keymap\n"); + gdk_display_close(display); + return 2; + } + + for (int keycode = 10; keycode <= 61; keycode++) { + printf("-------------------\n"); + printf("Keycode %d:\n", keycode); + PrintKeymapForCode(keymap, keycode); + } + + gdk_display_close(display); + + return 0; +} From 441ab3890395e40433f2c15f4a5b08970f2e6f75 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 31 May 2023 09:49:20 +0200 Subject: [PATCH 008/327] feature(Linux): mcompile changes in keymap -> read/write --- linux/mcompile/keymap/keymap.cpp | 438 ++++++++++++++++++++----------- linux/mcompile/keymap/keymap.h | 55 +++- 2 files changed, 336 insertions(+), 157 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 069fad7fff..0295e41e0e 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -1,5 +1,6 @@ #include "keymap.h" + static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) { GdkKeymapKey *maps; @@ -10,182 +11,326 @@ static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) return; for (int i = 0; i < count; i++) { - if (maps[i].level > 1 || maps[i].group > 4) + if (maps[i].level > 0 || maps[i].group > 1) continue; printf(" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); } - g_free(keyvals); g_free(maps); } -v_str_3D write_US_ToVector(std::string language, const char* text) { - - printf("+++++++ start to open_file \n"); - v_str_3D Vector_split; +void write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; const char* cc = FullPathName.c_str(); FILE* fp = fopen((cc), "r"); if ( !fp) printf("could not open file!"); - else - printf("+++++++ file open OK \n"); - v_str_1D Vector_completeUS = CreateCompleteRow_US(fp, text, language); // creates vector of all . TTODO lookup other language files + // create 1D-vector of the complete line + v_str_1D Vector_completeUS; + CreateCompleteRow_US(Vector_completeUS,fp, text, language); - //here split Vector to 3D vector - Vector_split = SplitTo_3D_Vector( Vector_completeUS); + // split contents of 1D Vector to 3D vector + Split_US_To_3D_Vector( vec,Vector_completeUS); - printf("+++++++ sizes write_US_ToVector %li..%li..%li\n", Vector_split.size(), Vector_split[0].size(),Vector_split[0][0].size()); + printf("+++++++ dimensions of Vector after write_US_ToVector\t\t %li..%li..%li\n", vec.size(), vec[0].size(),vec[0][0].size()); fclose(fp); - return Vector_split; } -bool test(v_str_3D V){ - printf("+++++++ stest"); -std::cout << V[0][0][0]<< "..\n" - << V[0][0][1]<< "..\n" - << V[0][0][2]<< "..\n" - << V[0][0][3]<< "..\n" - << V[0][0][4]<< "..\n\n" +void CreateCompleteRow_US(v_str_1D &complete_List, FILE* fpp, const char* text, std::string language) { + // in the Configuration file we find the appopriate paragraph between "xkb_symbol " and the next xkb_symbol + // and then copy all rows starting with "key <" to a v1D-Vector - << V[0][1][0]<< "..\n" - << V[0][1][1]<< "..\n" - << V[0][1][2]<< "..\n" - << V[0][1][3]<< "..\n" - << V[0][1][4]<< "..\n\n" + int buffer_size = 512; + char buffer[buffer_size]; + bool print_OK = false; + const char* key = "key <"; + std::string str_txt(text); + std::string xbk_mark = "xkb_symbol"; + std::ofstream KeyboardFile("File_" + language + ".txt"); - << V[0][22][0]<< "..\n" - << V[0][22][1]<< "..\n" - << V[0][22][2]<< "..\n" - << V[0][22][3]<< "..\n" - << V[0][22][4]<< "..\n\n" + printf("Keyboard %s\n", text); + KeyboardFile << "Keyboard" << text << "\n"; - << V[0][45][0]<< "..\n" - << V[0][45][1]<< "..\n" - << V[0][45][2]<< "..\n" - << V[0][45][3]<< "..\n" - << V[0][45][4]<< "..\n\n" + if (fpp) { + while (fgets(buffer, buffer_size, fpp) != NULL) { + std::string str_buf(buffer); - << V[0][46][0]<< "..\n" - << V[0][46][1]<< "..\n" - << V[0][46][2]<< "..\n" - << V[0][46][3]<< "..\n" - << V[0][46][4]<< "..\n\n" - - << V[0][0][0]<< "..\n"; - return true; -} + // stop when finding the mark xkb_symbol + if (std::string(str_buf).find(xbk_mark) != std::string::npos) + print_OK = false; -v_str_1D CreateCompleteRow_US(FILE* fpp, const char* text, std::string language) { - printf("+++++++ start CreateCompleteRow_US\n"); - v_str_1D complete_List; - int buffer_size = 512; - char buffer[buffer_size]; - bool print_OK = false; - const char* key = "key <"; - std::string str_txt(text); - std::string xbk_mark = "xkb_symbol"; - std::ofstream KeyboardFile("File_" + language + ".txt"); + // start when finding the mark xkb_symbol + correct layout + if ((std::string(str_buf).find(str_txt) != std::string::npos)) + print_OK = true; - printf("Keyboard %s\n", text); - KeyboardFile << "Keyboard" << text << "\n"; - - if (fpp) { - while (fgets(buffer, buffer_size, fpp) != NULL) { - std::string str_buf(buffer); - - // Maybe TODO: recursive search for other included Configuration files - // if find "include" -> recursive... - - // stop when finding the mark xkb_symbol - if (std::string(str_buf).find(xbk_mark) != std::string::npos) - print_OK = false; - - // start when finding the mark xkb_symbol + correct layout - if ((std::string(str_buf).find(str_txt) != std::string::npos)) - print_OK = true; - - if ((print_OK) && (std::string(str_buf).find(key) != std::string::npos)) { - printf("... %s", buffer); - complete_List.push_back(buffer); - KeyboardFile << buffer; - } + // as long as we are in the same xkb_symbol layout and find "key <" we push the whole line into a 1D-vector + if ((print_OK) && (std::string(str_buf).find(key) != std::string::npos)) { + printf("%s", buffer); + complete_List.push_back(buffer); + KeyboardFile << buffer; } } - printf("end Keyboard %s..........................................\n\n", text); - return complete_List; + } + printf("-°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° \n"); } -void extract_difference(v_str_3D, std::string lang_Other ) -{ - printf("+++++++ start extract_difference\n"); - /* - std::ofstream Map_File("Map_" + lang_US + "_To_" + lang_Other + ".txt"); - std::string diff; - std::cout <<"key"<< std::setw(26)<< "Char US"<< std::setw(20)<<"Char other" << std::setw(10)<< "diff? \n"; - Map_File <<"key"<< std::setw(26)<< "Char US"<< std::setw(20)<<"Char other" << std::setw(10)<< "diff? \n"; - std::cout <<"---------------------------------------------------------------\n"; - Map_File <<"---------------------------------------------------------------\n"; +void Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList) { + // first: take the whole line of the 1D-Vector and remove unwanted characters. + // second: split off the name e.g. key and the shiftstates + // third: push Names/Shiftstates to shift_states and then shiftstates to All_US, our 3D-Vector holding all Elements - //ToDo for all columns; watchout for empty fields!! - for ( int i =0; i< US_vector.size();i++) - { - for ( int j =0; j< other_vector.size();j++) - { - diff =" \t"; - if( US_vector[i][0] == other_vector[j][0] ) - { - if( US_vector[i][1] != other_vector[j][1] ) diff = " *** "; - std::cout << US_vector[i][0] << std::setw(20)<< US_vector[i][1] << std::setw(20)<< other_vector[j][1] < delim{' ', '[', ']', '}', ';', '\t', '\n'}; - printf("+++++++ start SplitTo_3D_Vector\n"); + std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; char split_bracel = '{'; char split_char_komma = ','; - std::vector tokens; - std::vector > everything; - v_str_3D all; + std::string empty = "--"; + v_str_1D tokens; + v_str_2D shift_states; - // while starts with key... - for (int k = 0; k < (int)p_completeList.size() - 1; k++) { + // go through the whole vector + for (int k = 0; k < (int)completeList.size() - 1; k++) { - // remove alll unwanted char - for (int i = 0; i < (int) delim.size(); i++) - p_completeList[k].erase(remove(p_completeList[k].begin(), p_completeList[k].end(), delim[i]), p_completeList[k].end()); + // remove all unwanted char + for (int i = 0; i < (int) delim.size(); i++) { + completeList[k].erase(remove(completeList[k].begin(), completeList[k].end(), delim[i]), completeList[k].end()); + } - // inly lines with ("key<.. are of interest - if (p_completeList[k].find("key<") != std::string::npos) { - // seperate key<... - std::istringstream split1(p_completeList[k]); + // only lines with ("key<.. are of interest + if (completeList[k].find("key<") != std::string::npos) { + + //split off the keys names + std::istringstream split1(completeList[k]); for (std::string each; std::getline(split1, each, split_bracel); tokens.push_back(each)); - // seperate rest with comma and push to everything + // replace keys names with number ( with 29,...) + int Keycode_ = replace_PosKey_with_Keycode(tokens[0]); + tokens[0] = std::to_string(Keycode_); + + // seperate rest of the vector to its elements and push to 'states' std::istringstream split(tokens[1]); tokens.pop_back(); for (std::string each; std::getline(split, each, split_char_komma); tokens.push_back(each)); - everything.push_back(tokens); + //printf("### 5 Split_US_To_3D_Vector: tokens: size:%li...tokens[0]-[4]:-name:%s\tShiftstates:%s--%s--%s--%s---.\n", tokens.size(),tokens[0].c_str(),tokens[1].c_str(),tokens[2].c_str(),tokens[3].c_str(),tokens[4].c_str()); + + shift_states.push_back(tokens); tokens.clear(); } } - //return everything; - all.push_back(everything); - //printf("+++++++ ssizes %i..%i..%i\n", all.size(), all[0].size ,all[0][0].size); - printf("+++++++ sizes SplitTo_3D_Vector %li..%li..%li\n", all.size(), all[0].size(),all[0][0].size()); + all_US.push_back(shift_states); + + //printf("### 6 Split_US_To_3D_clearVector %li..%li..%li\n", all_US.size(), all_US[0].size(),all_US[0][0].size()); +} + +int replace_PosKey_with_Keycode(std::string in) { + int out=0; + if ( in == "key") out = 49; //correct ??? + else if ( in == "key") out = 10; + else if ( in == "key") out = 11; + else if ( in == "key") out = 12; + else if ( in == "key") out = 13; + else if ( in == "key") out = 14; + else if ( in == "key") out = 15; + else if ( in == "key") out = 16; + else if ( in == "key") out = 17; + else if ( in == "key") out = 18; + else if ( in == "key") out = 19; + else if ( in == "key") out = 20; + else if ( in == "key") out = 21; + + else if ( in == "key") out = 24; + else if ( in == "key") out = 25; + else if ( in == "key") out = 26; + else if ( in == "key") out = 27; + else if ( in == "key") out = 28; + else if ( in == "key") out = 29; + else if ( in == "key") out = 30; + else if ( in == "key") out = 31; + else if ( in == "key") out = 32; + else if ( in == "key") out = 33; + else if ( in == "key") out = 34; + else if ( in == "key") out = 35; + + else if ( in == "key") out = 38; + else if ( in == "key") out = 39; + else if ( in == "key") out = 40; + else if ( in == "key") out = 41; + else if ( in == "key") out = 42; + else if ( in == "key") out = 43; + else if ( in == "key") out = 44; + else if ( in == "key") out = 45; + else if ( in == "key") out = 46; + else if ( in == "key") out = 47; + else if ( in == "key") out = 48; + else if ( in == "key") out = 49; + + else if ( in == "key") out = 52; + else if ( in == "key") out = 53; + else if ( in == "key") out = 54; + else if ( in == "key") out = 55; + else if ( in == "key") out = 56; + else if ( in == "key") out = 57; + else if ( in == "key") out = 58; + else if ( in == "key") out = 59; + else if ( in == "key") out = 60; + else if ( in == "key") out = 61; + else if ( in == "key") out = 62; //correct ??? + else if ( in == "key") out = 51; //correct ??? + return out; +} + +void append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap) { + + // create a 2D vector all fill0ed with "--" and push to 3D-Vector + v_str_2D Other_Vector2D = create_empty_2D(All_Vector[0].size(),All_Vector[0][0].size()); + All_Vector.push_back(Other_Vector2D); + + printf("+++++++ dimensions of Vector after append_other_ToVector\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); + + for(int i =1; i< (int) All_Vector[1].size()-1;i++) + { + // get key name US stored in [0][i][0] and copy to name in other-block[1][i][0] + All_Vector[1][i][0] = All_Vector[0][i][0]; + + // write this value to 3D- Vector + All_Vector[1][i][0+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),0); //shift state: unshifted:0 + All_Vector[1][i][1+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),1); //shift state: shifted:1 + All_Vector[1][i][2+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),2); //shift state: ? + All_Vector[1][i][3+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),3); //shift state: ? + + //printf("Keycodes US->Other: %d(US): %s %s ---- (other):%s, %s, %s \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str(),All_Vector[1][i][2].c_str(),All_Vector[1][i][3].c_str()); + } +} + +v_str_2D create_empty_2D( int dim_rows,int dim_shifts) +{ + std::string empty = "--"; + v_str_1D shifts; + v_str_2D all; + + for ( int i=0; i< dim_rows;i++) { + for ( int i=0; i< dim_shifts;i++) { + shifts.push_back(empty); + } + all.push_back(shifts); + } return all; } +int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int keyval_value) { + GdkKeymapKey *maps; + guint *keyvals; + gint count; + int out; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return 0; + + out = keyvals[keyval_value]; + + g_free(keyvals); + g_free(maps); + return out; +} + +void extract_difference( v_str_3D &All_Vector) +{ + std::ofstream Map_File("Map_US.txt"); + std::string diff =" "; + + printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); + std::cout << "Nr of \n" ; + std::cout << "Key: " << "\t Character US (no shift) " << " Character US (shift) "<< "\t\tCharacter other (no shift)" << "\tCharacter other (shift) difference \n" ; + printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); + + Map_File <<"--------------------------------------------------------------------------------------------------------------------------------------------\n"; + Map_File << "Nr of \n" ; + Map_File << "Key: " << "\t Character US (no shift) " << " Character US (shift) "<< "\t\tCharacter other (no shift)" << "\tCharacter other (shift) difference \n" ; + Map_File <<"--------------------------------------------------------------------------------------------------------------------------------------------\n"; + + for ( int k=0; k<(int)All_Vector[0].size()-1; k++) { + if (All_Vector[0][k][1] == All_Vector[1][k][1]) + diff =" "; + else + diff =" *** "; + + std::cout << All_Vector[0][k][0] << "\t " <<+(*(All_Vector[0][k][1].c_str()))<< "\t("<< All_Vector[0][k][1] <<")"<1) + std::cout << " row 1 (Other).."< @@ -11,10 +13,53 @@ typedef std::vector v_str_1D; typedef std::vector > v_str_2D; typedef std::vector > > v_str_3D; + +int keyval_value =0; // get first group (0: small letters) +std::vector used_shift_state ={0,1}; // use shiftstate : no shift, shift -static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode); +// read configuration file, split and write to 3D-Vector (Data for US on [0][ ][ ] ) +void write_US_ToVector( v_str_3D &vec,std::string language, const char* text) ; -v_str_3D write_US_ToVector(std::string language, const char* text) ; -v_str_1D CreateCompleteRow_US(FILE* fpp, const char* text, std::string language) ; -void extract_difference(v_str_3D US_vector, std::string lang_Other ) ; -v_str_3D SplitTo_3D_Vector(v_str_1D completeListUS); +//1. step: read complete Row of Configuration file US +void CreateCompleteRow_US(v_str_1D &complete_List ,FILE* fpp, const char* text, std::string language); + +//2nd step: write contents to 3D vector +void Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList); + +// replace Name of Key (e.g. ) wih Keycode ( e.g. 15 ) +int replace_PosKey_with_Keycode(std::string in); + + + +// append characters using GDK to 3D-Vector (Data for Other Language on [1][ ][ ] ) +void append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap); + +// create an empty 2D vector containing "--" in all fields +v_str_2D create_empty_2D( int dim_rows,int dim_shifts); + +// find Keyvals to fill into 2D-Vector of Other Language +int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int keyval_value); + + +// print both sets of characters (US and OtherLanguage) to console and file for comparison +void extract_difference(v_str_3D &All_Vector ) ; + + +// get mapped key from Other (Other->US) +std::string get_Other_Char_FromUS( std::string in , v_str_3D &All_Vector); +// get mapped key from US->Other (US->Other) +std::string get_US_Char_FromOther(std::string in , v_str_3D &All_Vector); +// get KeyNr from US +std::string getKeyNrOf_USChar(std::string in , v_str_3D &All_Vector); +// get KeyNr from Other +std::string getKeyNrOf_OtherChar(std::string in , v_str_3D &All_Vector); + +// test of above functions (character mapping US <-> Other; KeyNr <-> CHaracter) +void test_in_out(v_str_3D &All_Vector); + +// testing of Vector contents ( first row of US and Other) +bool test(v_str_3D &V); + + + +//---------------------------------- From 2a2455c78e8a79275bed289b11141f8b63938c64 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 31 May 2023 10:28:40 +0200 Subject: [PATCH 009/327] feature(Linux): mcompile use US basic instead of US intl --- linux/mcompile/keymap/keymap.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 0295e41e0e..f0882cdc82 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -346,11 +346,11 @@ int main(gint argc, gchar *argv[]) } // write content of xkb_symbols to 3D Vector - // I assume we use Keyboard US intl as base + // I assume we use Keyboard US basic as base printf("-°°°°°°°° write_US_ToVector\n"); std::string US_language = "us"; - const char* text_us = "xkb_symbols \"intl\""; - //const char* text_us = "xkb_symbols \"basic\""; + //const char* text_us = "xkb_symbols \"intl\""; + const char* text_us = "xkb_symbols \"basic\""; v_str_3D All_Vector; write_US_ToVector(All_Vector,US_language, text_us); From 802617b50a8031a7ed97f256c8284911c5953705 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 31 May 2023 15:19:08 +0200 Subject: [PATCH 010/327] feature(Linux): mcompile change readme --- linux/mcompile/keymap/README.md | 3 +-- linux/mcompile/keymap/keymap.cpp | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index 4891de5152..37737b7c3c 100644 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -1,4 +1,3 @@ # Keymap -Sample program that loops over the key codes 10-61 and outputs the key -values for groups 0 and 1. +Sample program that reads US basic keyboard and compares to key value group diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index f0882cdc82..a39a15fa96 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -349,7 +349,6 @@ int main(gint argc, gchar *argv[]) // I assume we use Keyboard US basic as base printf("-°°°°°°°° write_US_ToVector\n"); std::string US_language = "us"; - //const char* text_us = "xkb_symbols \"intl\""; const char* text_us = "xkb_symbols \"basic\""; v_str_3D All_Vector; From 8a2f053d4dacb1adba5b5eb380400b1781847c69 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 31 May 2023 17:30:25 +0200 Subject: [PATCH 011/327] feature(Linux): mcompile write some functions to get map and test --- linux/mcompile/keymap/keymap.cpp | 76 +++++++++++++++++++++++++++----- linux/mcompile/keymap/keymap.h | 7 ++- 2 files changed, 72 insertions(+), 11 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index a39a15fa96..58277f7880 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -1,6 +1,6 @@ #include "keymap.h" - +/* static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) { GdkKeymapKey *maps; @@ -19,6 +19,7 @@ static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) g_free(keyvals); g_free(maps); } +*/ void write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; @@ -256,45 +257,50 @@ void extract_difference( v_str_3D &All_Vector) diff =" *** "; std::cout << All_Vector[0][k][0] << "\t " <<+(*(All_Vector[0][k][1].c_str()))<< "\t("<< All_Vector[0][k][1] <<")"< Other: "<< std::setw(5)< Other: (" << in << ": no match)\n"; return "-"; } std::string get_US_Char_FromOther(std::string in , v_str_3D &All_Vector) { + std::string diff; // find correct row of char in other for( int i=0; i< (int)All_Vector[1].size()-1;i++) { for( int j=0; j< (int)All_Vector[1][0].size()-1;j++) { if ( All_Vector[1][i][j] == in ) { - std::cout << " get_US_Char_FromOther : "<< All_Vector[1][i][j] << " out: " << All_Vector[0][i][j] <<"\n"; - return All_Vector[0][i][j] ; + if ( All_Vector[0][i][j] != All_Vector[1][i][j]) diff =" ** "; + std::cout << "Other -> US: "<< std::setw(5)< US: (" << in << ": no match)\n"; + return "-"; } - return "-"; -} std::string getKeyNrOf_USChar(std::string in , v_str_3D &All_Vector) { // find correct row of char in US for( int i=0; i< (int)All_Vector[0].size()-1;i++) { for( int j=0; j< (int)All_Vector[0][0].size()-1;j++) { if ( All_Vector[0][i][j] == in ) { - std::cout << " getKeyNrOf_USChar : "<< All_Vector[0][i][j] << " out: " << All_Vector[0][i][0] <<"\n"; + std::cout << "KeyNr of US char: \t"<< All_Vector[0][i][j] << " -> " << All_Vector[0][i][0] <<"\n"; return All_Vector[0][i][0] ; } } @@ -307,7 +313,7 @@ std::string getKeyNrOf_OtherChar(std::string in , v_str_3D &All_Vector) { for( int i=0; i< (int)All_Vector[1].size()-1;i++) { for( int j=0; j< (int)All_Vector[1][0].size()-1;j++) { if ( All_Vector[1][i][j] == in ) { - std::cout << " getKeyNrOf_OtherChar : "<< All_Vector[1][i][j] << " out: " << All_Vector[1][i][0] <<"\n"; + std::cout << "KeyNr of Other char : \t"<< All_Vector[1][i][j] << " -> " << All_Vector[1][i][0] <<"\n"; return All_Vector[1][i][0] ; } } @@ -328,6 +334,53 @@ bool test(v_str_3D &V) { return true; } +void test_in_out(v_str_3D &All_Vector) { +std::string diff; + printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); + //checks mapping between US and other + std::string a = get_Other_Char_FromUS( "z", All_Vector); + std::string aa = get_Other_Char_FromUS( "Z", All_Vector); + std::string aaa = get_Other_Char_FromUS( "y", All_Vector); + std::string aaaa = get_Other_Char_FromUS( "Y", All_Vector); + + std::string b = get_US_Char_FromOther( "z", All_Vector); + std::string bb = get_US_Char_FromOther( "Z", All_Vector); + std::string bbb = get_US_Char_FromOther( "y", All_Vector); + std::string bbbb = get_US_Char_FromOther( "Y", All_Vector); + + std::string c = getKeyNrOf_OtherChar( "z", All_Vector); + std::string cc = getKeyNrOf_OtherChar( "Z", All_Vector); + std::string ccc = getKeyNrOf_OtherChar( "y", All_Vector); + std::string cccc = getKeyNrOf_OtherChar( "Y", All_Vector); + + std::string d = getKeyNrOf_USChar( "z", All_Vector); + std::string dd = getKeyNrOf_USChar( "Z", All_Vector); + std::string ddd = getKeyNrOf_USChar( "y", All_Vector); + std::string dddd = getKeyNrOf_USChar( "Y", All_Vector); + + std::cout << "get_Other_Char_FromUS z-Z-y-Y: " << ".." << a<< ".." < v_str_1D; typedef std::vector > v_str_2D; typedef std::vector > > v_str_3D; -int keyval_value =0; // get first group (0: small letters) std::vector used_shift_state ={0,1}; // use shiftstate : no shift, shift // read configuration file, split and write to 3D-Vector (Data for US on [0][ ][ ] ) @@ -54,6 +53,12 @@ std::string getKeyNrOf_USChar(std::string in , v_str_3D &All_Vector); // get KeyNr from Other std::string getKeyNrOf_OtherChar(std::string in , v_str_3D &All_Vector); +// prints out a 1:1 mapping US->Other +void print_simple_map_US(v_str_3D &All_Vector, int shiftstate); + +// prints out a 1:1 mapping Other->US +void print_simple_map_Other(v_str_3D &All_Vector, int shiftstate); + // test of above functions (character mapping US <-> Other; KeyNr <-> CHaracter) void test_in_out(v_str_3D &All_Vector); From da4e71638344b23a5644c5fb812f17759ee2c2ec Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 31 May 2023 17:40:08 +0200 Subject: [PATCH 012/327] feature(Linux): mcompile ToDo added; remove old file --- linux/mcompile/keymap/Xmain.cpp | 148 ------------------------------- linux/mcompile/keymap/keymap.cpp | 1 + 2 files changed, 1 insertion(+), 148 deletions(-) delete mode 100644 linux/mcompile/keymap/Xmain.cpp diff --git a/linux/mcompile/keymap/Xmain.cpp b/linux/mcompile/keymap/Xmain.cpp deleted file mode 100644 index b48cd27339..0000000000 --- a/linux/mcompile/keymap/Xmain.cpp +++ /dev/null @@ -1,148 +0,0 @@ -#include "keymap.h" - -static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) -{ - GdkKeymapKey *maps; - guint *keyvals; - gint count; - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return; - - for (int i = 0; i < count; i++) { - if (maps[i].level > 0 || maps[i].group > 1) - continue; - printf(" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); - } - - g_free(keyvals); - g_free(maps); -} - -std::vector > > write_US_ToVector(std::string language, const char* text) { - printf("+++++++ start to open_file \n"); - std::vector > > Vector_split; - std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; - const char* cc = FullPathName.c_str(); - FILE* fp = fopen((cc), "r"); - if ( !fp) - printf("could not open file!"); - else - printf("+++++++ file open OK \n"); - std::vector Vector_complete = CreateCompleteRow_US(fp, text, language); // creates vector of all . TTODO lookup other language files - - fclose(fp); - return Vector_split; -} - -std::vector CreateCompleteRow_US(FILE* fpp, const char* text, std::string language) { - printf("+++++++ start CreateCompleteRow_US\n"); - std::vector complete_List; - int buffer_size = 512; - char buffer[buffer_size]; - bool print_OK = false; - const char* key = "key <"; - std::string str_txt(text); - std::string xbk_mark = "xkb_symbol"; - std::ofstream KeyboardFile("File_" + language + ".txt"); - - printf("Keyboard %s\n", text); - KeyboardFile << "Keyboard" << text << "\n"; - - if (fpp) { - while (fgets(buffer, buffer_size, fpp) != NULL) { - std::string str_buf(buffer); - - // TODO: recursive search for other included Configuration files - // if find "include" -> recursive... - - // stop when finding the mark xkb_symbol - if (std::string(str_buf).find(xbk_mark) != std::string::npos) - print_OK = false; - - // start when finding the mark xkb_symbol + correct layout - if ((std::string(str_buf).find(str_txt) != std::string::npos)) - print_OK = true; - - if ((print_OK) && (std::string(str_buf).find(key) != std::string::npos)) { - printf("... %s", buffer); - complete_List.push_back(buffer); - KeyboardFile << buffer; - } - } - } - printf("end Keyboard %s..........................................\n\n", text); - return complete_List; -} - -void extract_difference(std::vector > > US_vector, std::string lang_Other ) -{ - printf("+++++++ start extract_difference\n"); - /* - std::ofstream Map_File("Map_" + lang_US + "_To_" + lang_Other + ".txt"); - std::string diff; - std::cout <<"key"<< std::setw(26)<< "Char US"<< std::setw(20)<<"Char other" << std::setw(10)<< "diff? \n"; - Map_File <<"key"<< std::setw(26)<< "Char US"<< std::setw(20)<<"Char other" << std::setw(10)<< "diff? \n"; - std::cout <<"---------------------------------------------------------------\n"; - Map_File <<"---------------------------------------------------------------\n"; - - //ToDo for all columns; watchout for empty fields!! - for ( int i =0; i< US_vector.size();i++) - { - for ( int j =0; j< other_vector.size();j++) - { - diff =" \t"; - if( US_vector[i][0] == other_vector[j][0] ) - { - if( US_vector[i][1] != other_vector[j][1] ) diff = " *** "; - std::cout << US_vector[i][0] << std::setw(20)<< US_vector[i][1] << std::setw(20)<< other_vector[j][1] < > > All_Vector = write_US_ToVector(US_language, text_us); - extract_difference(All_Vector,other_language); - -//------------------------------------------ - - - - - gdk_display_close(display); - - return 0; -} diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 58277f7880..d79763749e 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -194,6 +194,7 @@ void append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap) { // get key name US stored in [0][i][0] and copy to name in other-block[1][i][0] All_Vector[1][i][0] = All_Vector[0][i][0]; + // TODO see that nr of shift states are not out of range !! // write this value to 3D- Vector All_Vector[1][i][0+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),0); //shift state: unshifted:0 All_Vector[1][i][1+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),1); //shift state: shifted:1 From 58962db9ef7c00ff42087442cce63d5e8d43d7e5 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 31 May 2023 17:59:08 +0200 Subject: [PATCH 013/327] feature(Linux): mcompile mor TODOs in Readme.md --- linux/mcompile/keymap/README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index 37737b7c3c..b74985a373 100644 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -1,3 +1,15 @@ # Keymap Sample program that reads US basic keyboard and compares to key value group + + + +TODO check if US basic is the right Keyboard to compare with +TODO non-letter characters don't work OK yet +TODO Umlauts don't work OK yet +TODO Check for use of correct dimensions in Vector/prevent error if dims are not correct +TODO prevent crashes: handle possible Errors in CreateCompleteRow_US, Split_US_To_3D_Vector +TODO check Keycode of TLDE, BKSL, LSGT +TODO append_other_ToVector: ensure shift states of GetKeyvalsFromKeymap are not out of range +TODO remove unnecessary printf/cout +TODO ... From d21c05eb724d284034d98711ab42a222b169faf7 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 2 Jun 2023 08:57:50 +0200 Subject: [PATCH 014/327] feature(Linux): mcompile change variable for nested loop --- linux/mcompile/keymap/keymap.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index d79763749e..67c86b59f9 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -198,8 +198,8 @@ void append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap) { // write this value to 3D- Vector All_Vector[1][i][0+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),0); //shift state: unshifted:0 All_Vector[1][i][1+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),1); //shift state: shifted:1 - All_Vector[1][i][2+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),2); //shift state: ? - All_Vector[1][i][3+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),3); //shift state: ? + //All_Vector[1][i][2+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),2); //shift state: ? + //All_Vector[1][i][3+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),3); //shift state: ? //printf("Keycodes US->Other: %d(US): %s %s ---- (other):%s, %s, %s \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str(),All_Vector[1][i][2].c_str(),All_Vector[1][i][3].c_str()); } @@ -212,11 +212,13 @@ v_str_2D create_empty_2D( int dim_rows,int dim_shifts) v_str_2D all; for ( int i=0; i< dim_rows;i++) { - for ( int i=0; i< dim_shifts;i++) { + for ( int j=0; j< dim_shifts;j++) { shifts.push_back(empty); } all.push_back(shifts); + shifts.clear(); } + //printf("+++++++ dimensions of Vector after create_empty_2D\t\t %li..%li..%li\n", all.size(), all[0].size(),all[1].size()); return all; } From 20c045a65463dde4b7633a150c6f01a13b1d36d4 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 2 Jun 2023 17:27:41 +0200 Subject: [PATCH 015/327] feature(Linux): mcompile : loop variable,check count, rename keyval_value --- linux/mcompile/keymap/README.md | 5 ++++- linux/mcompile/keymap/keymap.cpp | 8 ++++++-- linux/mcompile/keymap/keymap.h | 8 ++------ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index b74985a373..dc65a9d244 100644 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -10,6 +10,9 @@ TODO Umlauts don't work OK yet TODO Check for use of correct dimensions in Vector/prevent error if dims are not correct TODO prevent crashes: handle possible Errors in CreateCompleteRow_US, Split_US_To_3D_Vector TODO check Keycode of TLDE, BKSL, LSGT -TODO append_other_ToVector: ensure shift states of GetKeyvalsFromKeymap are not out of range TODO remove unnecessary printf/cout +TODO path for xkb/symbols absolute->relative in meson +TODO append_other_ToVector: ensure shift states of GetKeyvalsFromKeymap are not out of range +TODO check how many/which shift states we use ( at the moment we read all shiftstate-columns of US, create as many colums for Other ) + but then use only 2 colums (non-shift + shift) TODO ... diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 67c86b59f9..6fa794c1c3 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -110,6 +110,7 @@ void Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList) { tokens[0] = std::to_string(Keycode_); // seperate rest of the vector to its elements and push to 'states' + // TODO define how many/which elements=colums=shift states we use std::istringstream split(tokens[1]); tokens.pop_back(); for (std::string each; std::getline(split, each, split_char_komma); tokens.push_back(each)); @@ -222,7 +223,7 @@ v_str_2D create_empty_2D( int dim_rows,int dim_shifts) return all; } -int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int keyval_value) { +int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; guint *keyvals; gint count; @@ -231,7 +232,10 @@ int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int keyval_value) { if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - out = keyvals[keyval_value]; + if (!(shift_state_pos < count)) + return 0; + + out = keyvals[shift_state_pos]; g_free(keyvals); g_free(maps); diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index eb1bde2e41..ec157736d7 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -14,7 +14,7 @@ typedef std::vector v_str_1D; typedef std::vector > v_str_2D; typedef std::vector > > v_str_3D; -std::vector used_shift_state ={0,1}; // use shiftstate : no shift, shift +int shift_state_count = 2; // use shiftstate : no shift, shift // read configuration file, split and write to 3D-Vector (Data for US on [0][ ][ ] ) void write_US_ToVector( v_str_3D &vec,std::string language, const char* text) ; @@ -37,7 +37,7 @@ void append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap); v_str_2D create_empty_2D( int dim_rows,int dim_shifts); // find Keyvals to fill into 2D-Vector of Other Language -int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int keyval_value); +int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos); // print both sets of characters (US and OtherLanguage) to console and file for comparison @@ -64,7 +64,3 @@ void test_in_out(v_str_3D &All_Vector); // testing of Vector contents ( first row of US and Other) bool test(v_str_3D &V); - - - -//---------------------------------- From 3b2e2d73fba41c2dc0cd56868c6f5b9b479ca2ef Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 5 Jun 2023 16:17:35 +0200 Subject: [PATCH 016/327] feature(Linux): mcompile : fix amount of shift_states to 2 even if layout in xkb has more --- linux/mcompile/keymap/keymap.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index ec157736d7..87627c4954 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -53,14 +53,13 @@ std::string getKeyNrOf_USChar(std::string in , v_str_3D &All_Vector); // get KeyNr from Other std::string getKeyNrOf_OtherChar(std::string in , v_str_3D &All_Vector); + +// for testing/debugging - may be deleted later // prints out a 1:1 mapping US->Other void print_simple_map_US(v_str_3D &All_Vector, int shiftstate); - // prints out a 1:1 mapping Other->US void print_simple_map_Other(v_str_3D &All_Vector, int shiftstate); - // test of above functions (character mapping US <-> Other; KeyNr <-> CHaracter) void test_in_out(v_str_3D &All_Vector); - // testing of Vector contents ( first row of US and Other) bool test(v_str_3D &V); From f1d2c95f0b82f98ac9625b7d68d232ce4167fe08 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 5 Jun 2023 16:52:33 +0200 Subject: [PATCH 017/327] feature(Linux): mcompile : comments, rename variables,... --- linux/mcompile/keymap/README.md | 10 +++-- linux/mcompile/keymap/keymap.cpp | 64 +++++++++++++++++--------------- 2 files changed, 41 insertions(+), 33 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index dc65a9d244..a40b7d4fef 100644 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -11,8 +11,12 @@ TODO Check for use of correct dimensions in Vector/prevent error if dims are not TODO prevent crashes: handle possible Errors in CreateCompleteRow_US, Split_US_To_3D_Vector TODO check Keycode of TLDE, BKSL, LSGT TODO remove unnecessary printf/cout -TODO path for xkb/symbols absolute->relative in meson +TODO path for xkb/symbols as compile time option in meson TODO append_other_ToVector: ensure shift states of GetKeyvalsFromKeymap are not out of range -TODO check how many/which shift states we use ( at the moment we read all shiftstate-columns of US, create as many colums for Other ) - but then use only 2 colums (non-shift + shift) +TODO check how many/which shift states we use ( at the moment we read all shiftstate-columns of US but then use only 2 colums + (non-shift + shift) then use as many colums for Other ) + +TODO define folder to store File_US.txt" in and find better name +TODO get rid of GTK functions that are deprecated and use X11 instead +TODO retrieve name of Other keyboard and use appropriate name instead of "Other" TODO ... diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 6fa794c1c3..109f910933 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -24,14 +24,14 @@ static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) void write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; - const char* cc = FullPathName.c_str(); - FILE* fp = fopen((cc), "r"); + const char* path = FullPathName.c_str(); + FILE* fp = fopen((path), "r"); if ( !fp) printf("could not open file!"); // create 1D-vector of the complete line v_str_1D Vector_completeUS; - CreateCompleteRow_US(Vector_completeUS,fp, text, language); + CreateCompleteRow_US(Vector_completeUS,fp , text, language); // split contents of 1D Vector to 3D vector Split_US_To_3D_Vector( vec,Vector_completeUS); @@ -40,7 +40,7 @@ void write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { fclose(fp); } -void CreateCompleteRow_US(v_str_1D &complete_List, FILE* fpp, const char* text, std::string language) { +void CreateCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, std::string language) { // in the Configuration file we find the appopriate paragraph between "xkb_symbol " and the next xkb_symbol // and then copy all rows starting with "key <" to a v1D-Vector @@ -50,13 +50,14 @@ void CreateCompleteRow_US(v_str_1D &complete_List, FILE* fpp, const char* text, const char* key = "key <"; std::string str_txt(text); std::string xbk_mark = "xkb_symbol"; + // TODO define folder to store File in std::ofstream KeyboardFile("File_" + language + ".txt"); printf("Keyboard %s\n", text); KeyboardFile << "Keyboard" << text << "\n"; - if (fpp) { - while (fgets(buffer, buffer_size, fpp) != NULL) { + if (fp) { + while (fgets(buffer, buffer_size, fp) != NULL) { std::string str_buf(buffer); // stop when finding the mark xkb_symbol @@ -67,7 +68,7 @@ void CreateCompleteRow_US(v_str_1D &complete_List, FILE* fpp, const char* text, if ((std::string(str_buf).find(str_txt) != std::string::npos)) print_OK = true; - // as long as we are in the same xkb_symbol layout and find "key <" we push the whole line into a 1D-vector + // as long as we are in the same xkb_symbol layout block and find "key <" we push the whole line into a 1D-vector if ((print_OK) && (std::string(str_buf).find(key) != std::string::npos)) { printf("%s", buffer); complete_List.push_back(buffer); @@ -79,9 +80,9 @@ void CreateCompleteRow_US(v_str_1D &complete_List, FILE* fpp, const char* text, } void Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList) { - // first: take the whole line of the 1D-Vector and remove unwanted characters. - // second: split off the name e.g. key and the shiftstates - // third: push Names/Shiftstates to shift_states and then shiftstates to All_US, our 3D-Vector holding all Elements + // 1: take the whole line of the 1D-Vector and remove unwanted characters. + // 2: seperate the name e.g. key and the shiftstates + // 3: push Names/Shiftstates to shift_states and then shiftstates to All_US, our 3D-Vector holding all Elements std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; char split_bracel = '{'; @@ -101,27 +102,32 @@ void Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList) { // only lines with ("key<.. are of interest if (completeList[k].find("key<") != std::string::npos) { - //split off the keys names + //split off the key names std::istringstream split1(completeList[k]); for (std::string each; std::getline(split1, each, split_bracel); tokens.push_back(each)); // replace keys names with number ( with 29,...) - int Keycode_ = replace_PosKey_with_Keycode(tokens[0]); - tokens[0] = std::to_string(Keycode_); + int Keycde = replace_PosKey_with_Keycode(tokens[0]); + tokens[0] = std::to_string(Keycde); - // seperate rest of the vector to its elements and push to 'states' - // TODO define how many/which elements=colums=shift states we use + // seperate rest of the vector to its elements and push to 'tokens' std::istringstream split(tokens[1]); tokens.pop_back(); for (std::string each; std::getline(split, each, split_char_komma); tokens.push_back(each)); //printf("### 5 Split_US_To_3D_Vector: tokens: size:%li...tokens[0]-[4]:-name:%s\tShiftstates:%s--%s--%s--%s---.\n", tokens.size(),tokens[0].c_str(),tokens[1].c_str(),tokens[2].c_str(),tokens[3].c_str(),tokens[4].c_str()); + // at the moment we only use the first 2 shiftstates (non-shift+shift) so get rid of all others + int surplus = tokens.size() - shift_state_count -1; + for( int j=0; j < surplus;j++) { + tokens.pop_back(); + } + + // now push result to shift_states shift_states.push_back(tokens); tokens.clear(); } } all_US.push_back(shift_states); - //printf("### 6 Split_US_To_3D_clearVector %li..%li..%li\n", all_US.size(), all_US[0].size(),all_US[0][0].size()); } @@ -195,13 +201,9 @@ void append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap) { // get key name US stored in [0][i][0] and copy to name in other-block[1][i][0] All_Vector[1][i][0] = All_Vector[0][i][0]; - // TODO see that nr of shift states are not out of range !! // write this value to 3D- Vector All_Vector[1][i][0+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),0); //shift state: unshifted:0 All_Vector[1][i][1+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),1); //shift state: shifted:1 - //All_Vector[1][i][2+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),2); //shift state: ? - //All_Vector[1][i][3+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),3); //shift state: ? - //printf("Keycodes US->Other: %d(US): %s %s ---- (other):%s, %s, %s \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str(),All_Vector[1][i][2].c_str(),All_Vector[1][i][3].c_str()); } } @@ -244,6 +246,7 @@ int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) void extract_difference( v_str_3D &All_Vector) { + // TODO define which Folder; find better name std::ofstream Map_File("Map_US.txt"); std::string diff =" "; @@ -264,7 +267,7 @@ void extract_difference( v_str_3D &All_Vector) diff =" *** "; std::cout << All_Vector[0][k][0] << "\t " <<+(*(All_Vector[0][k][1].c_str()))<< "\t("<< All_Vector[0][k][1] <<")"< Other: "<< std::setw(5)< US: "<< std::setw(5)<1) - std::cout << " row 1 (Other).."< Date: Mon, 5 Jun 2023 17:39:08 +0200 Subject: [PATCH 018/327] feature(Linux): mcompile : marked places where checks might be useful --- linux/mcompile/keymap/keymap.cpp | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 109f910933..2101ac12ad 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -22,6 +22,7 @@ static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) */ void write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { + // ? CHECK if ran OK-> return 0/1 std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; const char* path = FullPathName.c_str(); @@ -44,6 +45,7 @@ void CreateCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, // in the Configuration file we find the appopriate paragraph between "xkb_symbol " and the next xkb_symbol // and then copy all rows starting with "key <" to a v1D-Vector + // ? CHECK if ran OK-> return 0/1 int buffer_size = 512; char buffer[buffer_size]; bool print_OK = false; @@ -84,6 +86,7 @@ void Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList) { // 2: seperate the name e.g. key and the shiftstates // 3: push Names/Shiftstates to shift_states and then shiftstates to All_US, our 3D-Vector holding all Elements + // ? CHECK if ran OK-> return 0/1 std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; char split_bracel = '{'; char split_char_komma = ','; @@ -107,6 +110,8 @@ void Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList) { for (std::string each; std::getline(split1, each, split_bracel); tokens.push_back(each)); // replace keys names with number ( with 29,...) + + // ? CHECK if ran OK-> return 0/1 int Keycde = replace_PosKey_with_Keycode(tokens[0]); tokens[0] = std::to_string(Keycde); @@ -128,6 +133,8 @@ void Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList) { } } all_US.push_back(shift_states); + + // ? CHECK if ran OK, vector size is correct -> return 0/1 //printf("### 6 Split_US_To_3D_clearVector %li..%li..%li\n", all_US.size(), all_US[0].size(),all_US[0][0].size()); } @@ -191,6 +198,7 @@ int replace_PosKey_with_Keycode(std::string in) { void append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap) { // create a 2D vector all fill0ed with "--" and push to 3D-Vector + // ? CHECK if ran OK-> return 0/1 v_str_2D Other_Vector2D = create_empty_2D(All_Vector[0].size(),All_Vector[0][0].size()); All_Vector.push_back(Other_Vector2D); @@ -206,6 +214,7 @@ void append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap) { All_Vector[1][i][1+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),1); //shift state: shifted:1 //printf("Keycodes US->Other: %d(US): %s %s ---- (other):%s, %s, %s \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str(),All_Vector[1][i][2].c_str(),All_Vector[1][i][3].c_str()); } + // ? CHECK if ran OK, vector size is correct -> return 0/1 } v_str_2D create_empty_2D( int dim_rows,int dim_shifts) @@ -246,6 +255,7 @@ int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) void extract_difference( v_str_3D &All_Vector) { + // ? CHECK if ran OK-> return 0/1 // TODO define which Folder; find better name std::ofstream Map_File("Map_US.txt"); std::string diff =" "; @@ -265,11 +275,12 @@ void extract_difference( v_str_3D &All_Vector) diff =" "; else diff =" *** "; - - std::cout << All_Vector[0][k][0] << "\t " <<+(*(All_Vector[0][k][1].c_str()))<< "\t("<< All_Vector[0][k][1] <<")"< Other: "<< std::setw(5)< US: "<< std::setw(5)< " << All_Vector[0][i][0] <<"\n"; return All_Vector[0][i][0] ; } @@ -325,6 +339,7 @@ std::string getKeyNrOf_OtherChar(std::string in , v_str_3D &All_Vector) { for( int i=0; i< (int)All_Vector[1].size()-1;i++) { for( int j=0; j< (int)All_Vector[1][0].size()-1;j++) { if ( All_Vector[1][i][j] == in ) { + // ? CHECK if index exists std::cout << "KeyNr of Other char : \t"<< All_Vector[1][i][j] << " -> " << All_Vector[1][i][0] <<"\n"; return All_Vector[1][i][0] ; } @@ -334,7 +349,7 @@ std::string getKeyNrOf_OtherChar(std::string in , v_str_3D &All_Vector) { } bool test(v_str_3D &V) { - +// ? CHECK if index exists printf("\n+++++++++ print some characters of US and Other +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); for ( int k=13; k<43; k++) { @@ -378,7 +393,7 @@ std::string diff; void print_simple_map_US(v_str_3D &All_Vector, int shiftstate){ std::string out,diff; - + // ? CHECK if ran OK-> return 0/1 printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); for ( int i=0; i< (int)All_Vector[0].size();i++) { out =get_Other_Char_FromUS(All_Vector[0][i][shiftstate], All_Vector); @@ -387,14 +402,13 @@ void print_simple_map_US(v_str_3D &All_Vector, int shiftstate){ void print_simple_map_Other(v_str_3D &All_Vector, int shiftstate){ std::string out, diff; - + // ? CHECK if ran OK-> return 0/1 printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); for ( int i=0; i< (int)All_Vector[0].size();i++) { out = get_US_Char_FromOther(All_Vector[0][i][shiftstate], All_Vector); } } //-------------------------------------- - int main(gint argc, gchar *argv[]) { gdk_init(&argc, &argv); @@ -427,7 +441,7 @@ int main(gint argc, gchar *argv[]) //test_in_out(All_Vector); //print_simple_map_US(All_Vector,1); // 1 = non-shift - //print_simple_map_Other(All_Vector,1); // 1 = non-shift + //print_simple_map_Other(All_Vector,1); // 1 = non-shift gdk_display_close(display); From b8554c68db5897df660968278d7e309066cc4c31 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 7 Jun 2023 18:40:09 +0200 Subject: [PATCH 019/327] feature(Linux): mcompile : new function testspecific_Characters , gitignore X_bak_foldercosmetics, comments --- .gitignore | 1 + linux/mcompile/keymap/keymap.cpp | 17 ++++++++-- linux/mcompile/keymap/keymap.h | 56 +++++++++++++++++--------------- 3 files changed, 45 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index 0abec10c3b..a8a74b95f5 100644 --- a/.gitignore +++ b/.gitignore @@ -198,3 +198,4 @@ lcov.info # /developer/src/test/auto/kmcomp/*.kvk # /developer/src/test/auto/kmcomp/*.kvk* # /developer/src/test/auto/kmcomp/*.txt +/linux/mcompile/keymap/X_bak diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 2101ac12ad..397be17f6c 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -242,6 +242,8 @@ int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; + //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + // return 0; if (!(shift_state_pos < count)) return 0; @@ -408,6 +410,17 @@ void print_simple_map_Other(v_str_3D &All_Vector, int shiftstate){ out = get_US_Char_FromOther(All_Vector[0][i][shiftstate], All_Vector); } } + +void test_specific_Characters(v_str_3D &All_Vector){ + printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); + v_str_1D in {"a", "b", "m", "w", "x", "y", "z"}; + std::string out; + for( int i=0; i< (int) in.size()-1; i++) { + out = get_Other_Char_FromUS(in[i], All_Vector); + } +} + + //-------------------------------------- int main(gint argc, gchar *argv[]) { @@ -442,9 +455,9 @@ int main(gint argc, gchar *argv[]) //print_simple_map_US(All_Vector,1); // 1 = non-shift //print_simple_map_Other(All_Vector,1); // 1 = non-shift - + test_specific_Characters(All_Vector); gdk_display_close(display); - printf("-°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° end\n"); + printf("°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° end\n"); return 0; } diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 87627c4954..cfbd5dc1df 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -1,58 +1,58 @@ // In ths program we use a 3D-Vector Vector[language][Keys][Shiftstates] +#pragma once - +#include +#include #include -#include -#include -#include +#include #include #include -#include +#include +#include +#include -typedef std::vector v_str_1D; -typedef std::vector > v_str_2D; +#include "mc_kmxfile.h" +#include "mc_savekeyboard.h" + +typedef std::vector v_str_1D; +typedef std::vector > v_str_2D; typedef std::vector > > v_str_3D; - + int shift_state_count = 2; // use shiftstate : no shift, shift // read configuration file, split and write to 3D-Vector (Data for US on [0][ ][ ] ) -void write_US_ToVector( v_str_3D &vec,std::string language, const char* text) ; +void write_US_ToVector(v_str_3D &vec, std::string language, const char *text); -//1. step: read complete Row of Configuration file US -void CreateCompleteRow_US(v_str_1D &complete_List ,FILE* fpp, const char* text, std::string language); +// 1. step: read complete Row of Configuration file US +void CreateCompleteRow_US(v_str_1D &complete_List, FILE *fpp, const char *text, std::string language); -//2nd step: write contents to 3D vector -void Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList); +// 2nd step: write contents to 3D vector +void Split_US_To_3D_Vector(v_str_3D &all_US, v_str_1D completeList); // replace Name of Key (e.g. ) wih Keycode ( e.g. 15 ) -int replace_PosKey_with_Keycode(std::string in); - - +int replace_PosKey_with_Keycode(std::string in); // append characters using GDK to 3D-Vector (Data for Other Language on [1][ ][ ] ) -void append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap); +void append_other_ToVector(v_str_3D &All_Vector, GdkKeymap *keymap); // create an empty 2D vector containing "--" in all fields -v_str_2D create_empty_2D( int dim_rows,int dim_shifts); +v_str_2D create_empty_2D(int dim_rows, int dim_shifts); // find Keyvals to fill into 2D-Vector of Other Language int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos); - -// print both sets of characters (US and OtherLanguage) to console and file for comparison -void extract_difference(v_str_3D &All_Vector ) ; - +// print both sets of characters (US and OtherLanguage) to console and file for comparison +void extract_difference(v_str_3D &All_Vector); // get mapped key from Other (Other->US) -std::string get_Other_Char_FromUS( std::string in , v_str_3D &All_Vector); +std::string get_Other_Char_FromUS(std::string in, v_str_3D &All_Vector); // get mapped key from US->Other (US->Other) -std::string get_US_Char_FromOther(std::string in , v_str_3D &All_Vector); +std::string get_US_Char_FromOther(std::string in, v_str_3D &All_Vector); // get KeyNr from US -std::string getKeyNrOf_USChar(std::string in , v_str_3D &All_Vector); +std::string getKeyNrOf_USChar(std::string in, v_str_3D &All_Vector); // get KeyNr from Other -std::string getKeyNrOf_OtherChar(std::string in , v_str_3D &All_Vector); - +std::string getKeyNrOf_OtherChar(std::string in, v_str_3D &All_Vector); // for testing/debugging - may be deleted later // prints out a 1:1 mapping US->Other @@ -63,3 +63,5 @@ void print_simple_map_Other(v_str_3D &All_Vector, int shiftstate); void test_in_out(v_str_3D &All_Vector); // testing of Vector contents ( first row of US and Other) bool test(v_str_3D &V); +// writing out mapping of some characters: a,b,m,w,x,y,z +void test_specific_Characters(v_str_3D &All_Vector); From ae80e6f2a516936956d229087000948cef41c50e Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 7 Jun 2023 19:09:12 +0200 Subject: [PATCH 020/327] feature(Linux): mcompile : copy files to mcompiles/keymap which may be needed; ; replace some DataTypes --- linux/mcompile/keymap/km_types.h | 88 +++ linux/mcompile/keymap/kmx_file.h | 384 +++++++++ linux/mcompile/keymap/mc_kmxfile.cpp | 297 +++++++ linux/mcompile/keymap/mc_kmxfile.h | 147 ++++ linux/mcompile/keymap/mc_savekeyboard.cpp | 423 ++++++++++ linux/mcompile/keymap/mc_savekeyboard.h | 18 + linux/mcompile/keymap/mcompile.cpp | 924 ++++++++++++++++++++++ linux/mcompile/keymap/mcompile.h | 51 ++ 8 files changed, 2332 insertions(+) create mode 100644 linux/mcompile/keymap/km_types.h create mode 100644 linux/mcompile/keymap/kmx_file.h create mode 100644 linux/mcompile/keymap/mc_kmxfile.cpp create mode 100644 linux/mcompile/keymap/mc_kmxfile.h create mode 100644 linux/mcompile/keymap/mc_savekeyboard.cpp create mode 100644 linux/mcompile/keymap/mc_savekeyboard.h create mode 100644 linux/mcompile/keymap/mcompile.cpp create mode 100644 linux/mcompile/keymap/mcompile.h diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h new file mode 100644 index 0000000000..5e6c25e813 --- /dev/null +++ b/linux/mcompile/keymap/km_types.h @@ -0,0 +1,88 @@ +#pragma once +#include + +#include + +/* +#if defined(_WIN32) || defined(_WIN64) +#define snprintf _snprintf +#define vsnprintf _vsnprintf +#define strcasecmp _stricmp +#define strncasecmp _strnicmp +#endif +*/ + +#if defined(__LP64__) || defined(_LP64) +/* 64-bit, g++ */ +#define KMX_64BIT +#endif + +#if defined(_WIN64) && !defined(USE_64) +/* 64-bit, Windows */ +#define KMX_64BIT +#endif + +typedef uint32_t KMX_DWORD; +typedef int32_t KMX_BOOL; +typedef uint8_t KMX_BYTE; +typedef uint16_t KMX_WORD; + +#if defined(__cplusplus) +typedef char16_t km_kbp_cp; +typedef char32_t km_kbp_usv; +#else +typedef uint16_t km_kbp_cp; // code point +typedef uint32_t km_kbp_usv; // Unicode Scalar Value +#endif + +typedef km_kbp_cp KMX_WCHAR; // wc, 16-bit UNICODE character + +typedef wchar_t WCHAR; // _S2 needs to be removed/ wchart-> char16 +typedef WCHAR KMX_WCHART; // _S2 needs to be removed/ wchart-> char16 +typedef KMX_WCHAR* PKMX_WCHAR; // _S2 +typedef wchar_t* PWSTR; // _S2 needs to be removed/ wchart-> char16 +typedef PWSTR PKMX_WCHART; // _S2 needs to be removed/ wchart-> char16 + +typedef wchar_t* LPKMX_WCHART; // _S2 needs to be removed/ wchart-> char16 + +typedef char* LPSTR; // _S2 needs to be removed? +typedef LPSTR LPKMX_STR; // _S2 needs to be removed? + +typedef uint8_t* LPBYTE; // _S2 needs to be removed/? +typedef LPBYTE LPKMX_BYTE; // _S2 needs to be removed? + +typedef uint8_t* PBYTE; // _S2 needs to be removed/? +typedef PBYTE PKMX_BYTE; // _S2 needs to be removed? + + // _S2 LPKEYBOARD ok to leave as is?? + +typedef char KMX_CHAR; // _S2 needs to be removed/? +typedef char* PKMX_STR; // _S2 needs to be removed/? + +typedef KMX_CHAR* PKMX_CHAR; // _S2 needs to be removed/? + +typedef uint32_t KMX_UINT; + +typedef KMX_BYTE* PKMX_BYTE; +typedef KMX_WORD* PKMX_WORD; +typedef KMX_DWORD* PKMX_DWORD; + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +// Macros and types to support char16_t vs wchar_t depending on project + +#ifdef USE_CHAR16_T +#define lpuch(x) u ## x +typedef km_kbp_cp KMX_UCHAR; +#else +#define lpuch(x) L ## x +typedef wchar_t KMX_UCHAR; +#endif + +typedef KMX_UCHAR* KMX_PUCHAR; diff --git a/linux/mcompile/keymap/kmx_file.h b/linux/mcompile/keymap/kmx_file.h new file mode 100644 index 0000000000..998c978007 --- /dev/null +++ b/linux/mcompile/keymap/kmx_file.h @@ -0,0 +1,384 @@ +/* + Copyright: Copyright (C) 2003-2018 SIL International. + Authors: mcdurdin +*/ + +#pragma once + +#include + +#ifdef KMN_KBP +// TODO: move this to a common namespace keyman::common::kmx_file or similar in the future +namespace km { +namespace kbp { +namespace kmx { +#endif + +#define KMX_MAX_ALLOWED_FILE_SIZE (128 * 1024 * 1024) /* 128MB */ +/* */ + +#define KEYMAN_LAYOUT_DEFAULT 0x000005FE + +#define KEYMANID_NONKEYMAN 0xFFFFFFFF +#define KEYMANID_IGNORE 0xFFFFFFFE +#define KEYMANID_INVALID 0xFFFFFFFD + +/* Shift flags for hotkeys (version 1.0) */ + +#define SHIFTFLAG 0x2000 +#define CTRLFLAG 0x4000 +#define ALTFLAG 0x8000 + +/* Miscellaneous flags and defines */ + +#define MAXGROUPS 128 + +/* File version identifiers */ + +#define VERSION_30 0x00000300 +#define VERSION_31 0x00000301 +#define VERSION_32 0x00000302 +#define VERSION_40 0x00000400 +#define VERSION_50 0x00000500 +#define VERSION_501 0x00000501 +#define VERSION_60 0x00000600 +#define VERSION_70 0x00000700 +#define VERSION_80 0x00000800 +#define VERSION_90 0x00000900 +#define VERSION_100 0x00000A00 +#define VERSION_140 0x00000E00 +#define VERSION_150 0x00000F00 + +#define VERSION_160 0x00001000 + +#define VERSION_MIN VERSION_50 +#define VERSION_MAX VERSION_160 + +// +// Backspace types +// + +#define BK_DEFAULT 0 +#define BK_DEADKEY 1 + +// Different begin types +#define BEGIN_ANSI 0 +#define BEGIN_UNICODE 1 +#define BEGIN_NEWCONTEXT 2 +#define BEGIN_POSTKEYSTROKE 3 + +#define TSS_NONE 0 +#define TSS_BITMAP 1 +#define TSS_COPYRIGHT 2 +#define TSS_HOTKEY 3 +#define TSS_LANGUAGE 4 +#define TSS_LAYOUT 5 +#define TSS_MESSAGE 6 +#define TSS_NAME 7 +#define TSS_VERSION 8 +#define TSS_CAPSONONLY 9 +#define TSS_CAPSALWAYSOFF 10 +#define TSS_SHIFTFREESCAPS 11 +#define TSS_LANGUAGENAME 12 + +#define TSS_CALLDEFINITION 13 +#define TSS_CALLDEFINITION_LOADFAILED 14 + +#define TSS_ETHNOLOGUECODE 15 + +#define TSS_DEBUG_LINE 16 + +#define TSS_MNEMONIC 17 + +#define TSS_INCLUDECODES 18 + +#define TSS_OLDCHARPOSMATCHING 19 + +#define TSS_COMPILEDVERSION 20 +#define TSS_KEYMANCOPYRIGHT 21 + +#define TSS_CUSTOMKEYMANEDITION 22 +#define TSS_CUSTOMKEYMANEDITIONNAME 23 + +/* Keyman 7.0 system stores */ + +#define TSS__KEYMAN_60_MAX 23 + +#define TSS_VISUALKEYBOARD 24 +#define TSS_KMW_RTL 25 +#define TSS_KMW_HELPFILE 26 +#define TSS_KMW_HELPTEXT 27 +#define TSS_KMW_EMBEDJS 28 + +#define TSS_WINDOWSLANGUAGES 29 + +#define TSS__KEYMAN_70_MAX 29 + +/* Keyman 8.0 system stores */ + +#define TSS_COMPARISON 30 + +#define TSS__KEYMAN_80_MAX 30 + +/* Keyman 9.0 system stores */ + +#define TSS_PLATFORM 31 +#define TSS_BASELAYOUT 32 +#define TSS_LAYER 33 + +#define TSS_PLATFORM_NOMATCH 0x8001 // Reserved for internal use - after platform statement is run, set to either TSS_PLATFORM_NOMATCH or TSS_PLATFORM_MATCH +#define TSS_PLATFORM_MATCH 0x8002 // Reserved for internal use - as the result will never change for the lifetime of the process. + +#define TSS_VKDICTIONARY 34 // Dictionary of virtual key names for v9 dynamic layouts +#define TSS_LAYOUTFILE 35 // Keyman 9 layer-based JSON OSK +#define TSS_KEYBOARDVERSION 36 // &keyboardversion system store // I4140 +#define TSS_KMW_EMBEDCSS 37 + +#define TSS_TARGETS 38 + +#define TSS__KEYMAN_90_MAX 38 + +/* Keyman 14.0 system stores */ + +#define TSS_CASEDKEYS 39 + +#define TSS__KEYMAN_140_MAX 39 + +/* Keyman 15.0 system stores */ + +#define TSS_BEGIN_NEWCONTEXT 40 +#define TSS_BEGIN_POSTKEYSTROKE 41 +#define TSS_NEWLAYER 42 +#define TSS_OLDLAYER 43 + +#define TSS__KEYMAN_150_MAX 43 + +#define TSS__MAX 43 + +/* wm_keyman_control_internal message control codes */ + +#define KMCI_SELECTKEYBOARD 3 // I3933 +#define KMCI_SELECTKEYBOARD_TSF 4 // I3933 +#define KMCI_GETACTIVEKEYBOARD 5 // I3933 +#define KMCI_SETFOREGROUND 6 // I3933 +#define KMCI_SELECTKEYBOARD_BACKGROUND 7 // I4271 +#define KMCI_SELECTKEYBOARD_BACKGROUND_TSF 8 // I4271 + +#define FILEID_COMPILED 0x5354584B + +#define SZMAX_LANGUAGENAME 80 +#define SZMAX_KEYBOARDNAME 80 +#define SZMAX_COPYRIGHT 256 +#define SZMAX_MESSAGE 1024 + +#define UC_SENTINEL 0xFFFF +#define UC_SENTINEL_EXTENDEDEND 0x10 // was ((CODE_LASTCODE)+1)... what was I thinking? + +#define U_UC_SENTINEL u"\uFFFF" + +/* + * VK__MAX defines the highest virtual key code defined in the system = 0xFF. Custom VK codes start at 256 + */ +#define VK__MAX 255 + +#define CODE_ANY 0x01 +#define CODE_INDEX 0x02 +#define CODE_CONTEXT 0x03 +#define CODE_NUL 0x04 +#define CODE_USE 0x05 +#define CODE_RETURN 0x06 +#define CODE_BEEP 0x07 +#define CODE_DEADKEY 0x08 +// 0x09 = bkspace.-- we don't need to keep this separate though with UC_SENTINEL +#define CODE_EXTENDED 0x0A +//#define CODE_EXTENDEDEND 0x0B deprecated +#define CODE_SWITCH 0x0C +#define CODE_KEY 0x0D +#define CODE_CLEARCONTEXT 0x0E +#define CODE_CALL 0x0F +// UC_SENTINEL_EXTENDEDEND 0x10 +#define CODE_CONTEXTEX 0x11 + +#define CODE_NOTANY 0x12 + +#define CODE_KEYMAN70_LASTCODE 0x12 + +#define CODE_SETOPT 0x13 +#define CODE_IFOPT 0x14 +#define CODE_SAVEOPT 0x15 +#define CODE_RESETOPT 0x16 + +#define CODE_KEYMAN80_LASTCODE 0x16 + +/* Keyman 9.0 codes */ + +#define CODE_IFSYSTEMSTORE 0x17 +#define CODE_SETSYSTEMSTORE 0x18 + +#define CODE_LASTCODE 0x18 + +#define U_CODE_ANY u"\u0001" +#define U_CODE_INDEX u"\u0002" +#define U_CODE_CONTEXT u"\u0003" +#define U_CODE_NUL u"\u0004" +#define U_CODE_USE u"\u0005" +#define U_CODE_RETURN u"\u0006" +#define U_CODE_BEEP u"\u0007" +#define U_CODE_DEADKEY u"\u0008" +#define U_CODE_EXTENDED u"\u000A" +#define U_CODE_SWITCH u"\u000C" +#define U_CODE_CLEARCONTEXT u"\u000E" +#define U_CODE_CALL u"\u000F" +#define U_CODE_EXTENDEDEND u"\u0010" +#define U_CODE_CONTEXTEX u"\u0011" +#define U_CODE_NOTANY u"\u0012" +#define U_CODE_SETOPT u"\u0013" +#define U_CODE_IFOPT u"\u0014" +#define U_CODE_SAVEOPT u"\u0015" +#define U_CODE_RESETOPT u"\u0016" +#define U_CODE_IFSYSTEMSTORE u"\u0017" +#define U_CODE_SETSYSTEMSTORE u"\u0018" + +#define C_CODE_ANY(store) U_UC_SENTINEL U_CODE_ANY store +#define C_CODE_INDEX(val1, val2) U_UC_SENTINEL U_CODE_INDEX val1 val2 +#define C_CODE_CONTEXT() U_UC_SENTINEL U_CODE_CONTEXT +#define C_CODE_NUL() U_UC_SENTINEL U_CODE_NUL +#define C_CODE_USE(val) U_UC_SENTINEL U_CODE_USE val +#define C_CODE_RETURN() U_UC_SENTINEL U_CODE_RETURN +#define C_CODE_BEEP() U_UC_SENTINEL U_CODE_BEEP +#define C_CODE_DEADKEY(deadkey) U_UC_SENTINEL U_CODE_DEADKEY deadkey +#define C_CODE_EXTENDED(varargs) U_UC_SENTINEL U_CODE_EXTENDED varargs +#define C_CODE_SWITCH(val) U_UC_SENTINEL U_CODE_SWITCH val +#define C_CODE_CLEARCONTEXT() U_UC_SENTINEL U_CODE_CLEARCONTEXT +#define C_CODE_CALL(val) U_UC_SENTINEL U_CODE_CALL val +#define C_CODE_CONTEXTEX(val) U_UC_SENTINEL U_CODE_CONTEXTEX val +#define C_CODE_NOTANY(val) U_UC_SENTINEL U_CODE_NOTANY val +#define C_CODE_SETOPT(val1, val2) U_UC_SENTINEL U_CODE_SETOPT val1 val2 +#define C_CODE_IFOPT(opt, val1, val2) U_UC_SENTINEL U_CODE_IFOPT opt val1 val2 +#define C_CODE_SAVEOPT(opt) U_UC_SENTINEL U_CODE_SAVEOPT opt +#define C_CODE_RESETOPT(opt) U_UC_SENTINEL U_CODE_RESETOPT opt +#define C_CODE_IFSYSTEMSTORE(store, val1, val2) U_UC_SENTINEL U_CODE_IFSYSTEMSTORE store val1 val2 +#define C_CODE_SETSYSTEMSTORE(store, val) U_UC_SENTINEL U_CODE_SETSYSTEMSTORE store val + +#define KF_SHIFTFREESCAPS 0x0001 +#define KF_CAPSONONLY 0x0002 +#define KF_CAPSALWAYSOFF 0x0004 +#define KF_LOGICALLAYOUT 0x0008 +#define KF_AUTOMATICVERSION 0x0010 + +// 16.0: Support for LDML Keyboards in KMXPlus file format +#define KF_KMXPLUS 0x0020 + +#define HK_ALT 0x00010000 +#define HK_CTRL 0x00020000 +#define HK_SHIFT 0x00040000 + +#define LCTRLFLAG 0x0001 // Left Control flag +#define RCTRLFLAG 0x0002 // Right Control flag +#define LALTFLAG 0x0004 // Left Alt flag +#define RALTFLAG 0x0008 // Right Alt flag +#define K_SHIFTFLAG 0x0010 // Either shift flag +#define K_CTRLFLAG 0x0020 // Either ctrl flag +#define K_ALTFLAG 0x0040 // Either alt flag +//#define K_METAFLAG 0x0080 // Either Meta-key flag (tentative). Not usable in keyboard rules; + // Used internally (currently, only by KMW) to ensure Meta-key + // shortcuts safely bypass rules + // Meta key = Command key on macOS, Windows key on Windows +#define CAPITALFLAG 0x0100 // Caps lock on +#define NOTCAPITALFLAG 0x0200 // Caps lock NOT on +#define NUMLOCKFLAG 0x0400 // Num lock on +#define NOTNUMLOCKFLAG 0x0800 // Num lock NOT on +#define SCROLLFLAG 0x1000 // Scroll lock on +#define NOTSCROLLFLAG 0x2000 // Scroll lock NOT on +#define ISVIRTUALKEY 0x4000 // It is a Virtual Key Sequence +#define VIRTUALCHARKEY 0x8000 // Keyman 6.0: Virtual Key Cap Sequence NOT YET + +#define K_MODIFIERFLAG 0x007F +#define K_NOTMODIFIERFLAG 0xFF00 // I4548 + +struct COMP_STORE { + KMX_DWORD dwSystemID; + KMX_DWORD dpName; + KMX_DWORD dpString; + }; + +struct COMP_KEY { + KMX_WORD Key; + KMX_WORD _reserved; + KMX_DWORD Line; + KMX_DWORD ShiftFlags; + KMX_DWORD dpOutput; + KMX_DWORD dpContext; + }; + +struct COMP_GROUP { + KMX_DWORD dpName; + KMX_DWORD dpKeyArray; // [LPKEY] address of first item in key array + KMX_DWORD dpMatch; + KMX_DWORD dpNoMatch; + KMX_DWORD cxKeyArray; // in array entries + KMX_BOOL fUsingKeys; // group(xx) [using keys] <-- specified or not + }; + +struct COMP_KEYBOARD { + KMX_DWORD dwIdentifier; // 0000 Keyman compiled keyboard id + + KMX_DWORD dwFileVersion; // 0004 Version of the file - Keyman 4.0 is 0x0400 + + KMX_DWORD dwCheckSum; // 0008 As stored in keyboard. DEPRECATED as of 16.0 + KMX_DWORD KeyboardID; // 000C as stored in HKEY_LOCAL_MACHINE//system//currentcontrolset//control//keyboard layouts + KMX_DWORD IsRegistered; // 0010 + KMX_DWORD version; // 0014 keyboard version + + KMX_DWORD cxStoreArray; // 0018 in array entries + KMX_DWORD cxGroupArray; // 001C in array entries + + KMX_DWORD dpStoreArray; // 0020 [LPSTORE] address of first item in store array + KMX_DWORD dpGroupArray; // 0024 [LPGROUP] address of first item in group array + + KMX_DWORD StartGroup[2]; // 0028 index of starting groups [2 of them] + + KMX_DWORD dwFlags; // 0030 Flags for the keyboard file + + KMX_DWORD dwHotKey; // 0034 standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) + + KMX_DWORD dpBitmapOffset; // 0038 offset of the bitmaps in the file + KMX_DWORD dwBitmapSize; // 003C size in bytes of the bitmaps +}; + +struct COMP_KEYBOARD_KMXPLUSINFO { + KMX_DWORD dpKMXPlus; // 0040 offset of KMXPlus data, header is first + KMX_DWORD dwKMXPlusSize; // 0044 size in bytes of entire KMXPlus data +}; + +/** + * Only valid if comp_keyboard.dwFlags&KF_KMXPLUS + */ +struct COMP_KEYBOARD_EX { + COMP_KEYBOARD header; // 0000 see COMP_KEYBOARD + COMP_KEYBOARD_KMXPLUSINFO kmxplus; // 0040 see COMP_KEYBOARD_EXTRA +}; + +typedef COMP_KEYBOARD *PCOMP_KEYBOARD; +typedef COMP_STORE *PCOMP_STORE; +typedef COMP_KEY *PCOMP_KEY; +typedef COMP_GROUP *PCOMP_GROUP; + +extern const int CODE__SIZE[]; +#define CODE__SIZE_MAX 5 + +#define KEYBOARDFILEHEADER_SIZE 64 +#define KEYBOARDFILESTORE_SIZE 12 +#define KEYBOARDFILEGROUP_SIZE 24 +#define KEYBOARDFILEKEY_SIZE 20 + +static_assert(sizeof(COMP_STORE) == KEYBOARDFILESTORE_SIZE, "COMP_STORE must be KEYBOARDFILESTORE_SIZE bytes"); +static_assert(sizeof(COMP_KEY) == KEYBOARDFILEKEY_SIZE, "COMP_KEY must be KEYBOARDFILEKEY_SIZE bytes"); +static_assert(sizeof(COMP_GROUP) == KEYBOARDFILEGROUP_SIZE, "COMP_GROUP must be KEYBOARDFILEGROUP_SIZE bytes"); +static_assert(sizeof(COMP_KEYBOARD) == KEYBOARDFILEHEADER_SIZE, "COMP_KEYBOARD must be KEYBOARDFILEHEADER_SIZE bytes"); + +#ifdef KMN_KBP +} // namespace kmx +} // namespace kbp +} // namespace km +#endif diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp new file mode 100644 index 0000000000..e0a20c34ac --- /dev/null +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -0,0 +1,297 @@ + +#include "mc_kmxfile.h" + +KMX_DWORD TEST2; + +static KMX_BOOL LoadKeyboardFile(LPKMX_STR fileName, LPKEYBOARD *lpKeyboard); + +KMX_BOOL VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz); + +LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); + +/*void Err(wchar_t *s) { + LogError(L"LoadKeyboard: %s, last error = %d\n", s, GetLastError()); +}*/ +/*BOOL LoadKeyboard(LPWSTR fileName, LPKEYBOARD *lpKeyboard) { + DWORD sz; + LPBYTE buf; + HANDLE hFile; + LPKEYBOARD kbp; + PBYTE filebase; + + if(!fileName || !lpKeyboard) { + Err(L"Bad Filename"); + return FALSE; + } + + hFile = CreateFile(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + if(hFile == INVALID_HANDLE_VALUE) { + Err(L"Could not open file"); + return FALSE; + } + + sz = GetFileSize(hFile, NULL); + + buf = new BYTE[sz]; + + if(!buf) { + Err(L"Not allocmem"); + CloseHandle(hFile); + return FALSE; + } + + filebase = buf; + + if(!ReadFile(hFile, filebase, sz, &sz, NULL)) { + Err(L"errReadFile"); + CloseHandle(hFile); + delete[] buf; + return FALSE; + } + CloseHandle(hFile); + + if(!VerifyKeyboard(filebase, sz)) { + Err(L"errVerifyKeyboard"); + delete[] buf; + return FALSE; + } + + kbp = FixupKeyboard(buf, filebase, sz); + if(!kbp) { + Err(L"errFixupKeyboard"); + delete[] buf; + return FALSE; + } + + if(kbp->dwIdentifier != FILEID_COMPILED) { + Err(L"errNotFileID"); + delete[] buf; + return FALSE; + } + + *lpKeyboard = kbp; + return TRUE; +} +*/ + +/*PKMX_WCHART StringOffset(PKMX_BYTE base, KMX_DWORD offset) { + if(offset == 0) return NULL; + return (PKMX_WCHART)(base + offset); +}*/ + + +/*LPKEYBOARD FixupKeyboard(PBYTE bufp, PBYTE base, DWORD dwFileSize) { + UNREFERENCED_PARAMETER(dwFileSize); + + DWORD i, j; + PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD) base; + PCOMP_GROUP cgp; + PCOMP_STORE csp; + PCOMP_KEY ckp; + LPKEYBOARD kbp = (LPKEYBOARD) bufp; + LPSTORE sp; + LPGROUP gp; + LPKEY kp; + + kbp->dpStoreArray = (LPSTORE) (base + ckbp->dpStoreArray); + kbp->dpGroupArray = (LPGROUP) (base + ckbp->dpGroupArray); + + for(sp = kbp->dpStoreArray, csp = (PCOMP_STORE) sp, i = 0; i < kbp->cxStoreArray; i++, sp++, csp++) { + sp->dpName = StringOffset(base, csp->dpName); + sp->dpString = StringOffset(base, csp->dpString); + } + + for(gp = kbp->dpGroupArray, cgp = (PCOMP_GROUP) gp, i = 0; i < kbp->cxGroupArray; i++, gp++, cgp++) { + gp->dpName = StringOffset(base, cgp->dpName); + gp->dpKeyArray = (LPKEY) (base + cgp->dpKeyArray); + if(cgp->dpMatch != NULL) gp->dpMatch = (PWSTR) (base + cgp->dpMatch); + if(cgp->dpNoMatch != NULL) gp->dpNoMatch = (PWSTR) (base + cgp->dpNoMatch); + + for(kp = gp->dpKeyArray, ckp = (PCOMP_KEY) kp, j = 0; j < gp->cxKeyArray; j++, kp++, ckp++) { + kp->dpOutput = (PWSTR) (base + ckp->dpOutput); + kp->dpContext = (PWSTR) (base + ckp->dpContext); + } + } + + return kbp; +} +*/ + + +/*BOOL VerifyKeyboard(LPBYTE filebase, DWORD sz) { + DWORD i; + PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD) filebase; + PCOMP_STORE csp; + + // Check file version // + + if(ckbp->dwFileVersion < VERSION_MIN || + ckbp->dwFileVersion > VERSION_MAX) { + // Old or new version -- identify the desired program version // + for(csp = (PCOMP_STORE)(filebase + ckbp->dpStoreArray), i = 0; i < ckbp->cxStoreArray; i++, csp++) { + if(csp->dwSystemID == TSS_COMPILEDVERSION) { + wchar_t buf2[256]; + if(csp->dpString == 0) { + wsprintf(buf2, L"errWrongFileVersion:NULL"); + } else { + wsprintf(buf2, L"errWrongFileVersion:%10.10ls", StringOffset(filebase, csp->dpString)); + } + Err(buf2); + return FALSE; + } + } + Err(L"errWrongFileVersion"); + return FALSE; + } + + + return TRUE; +}*/ + + +//---------------------old---------------------------------------- +/* +#include "pch.h" + + +static BOOL LoadKeyboardFile(LPSTR fileName, LPKEYBOARD *lpKeyboard); +BOOL VerifyKeyboard(LPBYTE filebase, DWORD sz); + +LPKEYBOARD FixupKeyboard(PBYTE bufp, PBYTE base, DWORD dwFileSize); + +void Err(wchar_t *s) { + LogError(L"LoadKeyboard: %s, last error = %d\n", s, GetLastError()); +} + +BOOL LoadKeyboard(LPWSTR fileName, LPKEYBOARD *lpKeyboard) { + DWORD sz; + LPBYTE buf; + HANDLE hFile; + LPKEYBOARD kbp; + PBYTE filebase; + + if(!fileName || !lpKeyboard) { + Err(L"Bad Filename"); + return FALSE; + } + + hFile = CreateFile(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + if(hFile == INVALID_HANDLE_VALUE) { + Err(L"Could not open file"); + return FALSE; + } + + sz = GetFileSize(hFile, NULL); + + buf = new BYTE[sz]; + + if(!buf) { + Err(L"Not allocmem"); + CloseHandle(hFile); + return FALSE; + } + + filebase = buf; + + if(!ReadFile(hFile, filebase, sz, &sz, NULL)) { + Err(L"errReadFile"); + CloseHandle(hFile); + delete[] buf; + return FALSE; + } + CloseHandle(hFile); + + if(!VerifyKeyboard(filebase, sz)) { + Err(L"errVerifyKeyboard"); + delete[] buf; + return FALSE; + } + + kbp = FixupKeyboard(buf, filebase, sz); + if(!kbp) { + Err(L"errFixupKeyboard"); + delete[] buf; + return FALSE; + } + + if(kbp->dwIdentifier != FILEID_COMPILED) { + Err(L"errNotFileID"); + delete[] buf; + return FALSE; + } + + *lpKeyboard = kbp; + return TRUE; +} + +PWCHAR StringOffset(PBYTE base, DWORD offset) { + if(offset == 0) return NULL; + return (PWCHAR)(base + offset); +} + +LPKEYBOARD FixupKeyboard(PBYTE bufp, PBYTE base, DWORD dwFileSize) { + UNREFERENCED_PARAMETER(dwFileSize); + + DWORD i, j; + PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD) base; + PCOMP_GROUP cgp; + PCOMP_STORE csp; + PCOMP_KEY ckp; + LPKEYBOARD kbp = (LPKEYBOARD) bufp; + LPSTORE sp; + LPGROUP gp; + LPKEY kp; + + kbp->dpStoreArray = (LPSTORE) (base + ckbp->dpStoreArray); + kbp->dpGroupArray = (LPGROUP) (base + ckbp->dpGroupArray); + + for(sp = kbp->dpStoreArray, csp = (PCOMP_STORE) sp, i = 0; i < kbp->cxStoreArray; i++, sp++, csp++) { + sp->dpName = StringOffset(base, csp->dpName); + sp->dpString = StringOffset(base, csp->dpString); + } + + for(gp = kbp->dpGroupArray, cgp = (PCOMP_GROUP) gp, i = 0; i < kbp->cxGroupArray; i++, gp++, cgp++) { + gp->dpName = StringOffset(base, cgp->dpName); + gp->dpKeyArray = (LPKEY) (base + cgp->dpKeyArray); + if(cgp->dpMatch != NULL) gp->dpMatch = (PWSTR) (base + cgp->dpMatch); + if(cgp->dpNoMatch != NULL) gp->dpNoMatch = (PWSTR) (base + cgp->dpNoMatch); + + for(kp = gp->dpKeyArray, ckp = (PCOMP_KEY) kp, j = 0; j < gp->cxKeyArray; j++, kp++, ckp++) { + kp->dpOutput = (PWSTR) (base + ckp->dpOutput); + kp->dpContext = (PWSTR) (base + ckp->dpContext); + } + } + + return kbp; +} + +BOOL VerifyKeyboard(LPBYTE filebase, DWORD sz) { + DWORD i; + PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD) filebase; + PCOMP_STORE csp; + + // Check file version // + + if(ckbp->dwFileVersion < VERSION_MIN || + ckbp->dwFileVersion > VERSION_MAX) { + // Old or new version -- identify the desired program version // + for(csp = (PCOMP_STORE)(filebase + ckbp->dpStoreArray), i = 0; i < ckbp->cxStoreArray; i++, csp++) { + if(csp->dwSystemID == TSS_COMPILEDVERSION) { + wchar_t buf2[256]; + if(csp->dpString == 0) { + wsprintf(buf2, L"errWrongFileVersion:NULL"); + } else { + wsprintf(buf2, L"errWrongFileVersion:%10.10ls", StringOffset(filebase, csp->dpString)); + } + Err(buf2); + return FALSE; + } + } + Err(L"errWrongFileVersion"); + return FALSE; + } + + + return TRUE; +} +*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h new file mode 100644 index 0000000000..2d82db90b1 --- /dev/null +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -0,0 +1,147 @@ +#pragma once +#include "km_types.h" + +KMX_DWORD TEST; + +#ifndef _KMXFILE_H +#define _KMXFILE_H + +typedef struct tagSTORE { + KMX_DWORD dwSystemID; + PKMX_WCHART dpName; + PKMX_WCHART dpString; +} STORE, *LPSTORE; + + +typedef struct tagKEY { + KMX_WCHAR Key; + KMX_DWORD Line; + KMX_DWORD ShiftFlags; + PKMX_WCHART dpOutput; + PKMX_WCHART dpContext; +} KEY, *LPKEY; + + +typedef struct tagGROUP { + PKMX_WCHART dpName; + LPKEY dpKeyArray; // [LPKEY] address of first item in key array + PKMX_WCHART dpMatch; + PKMX_WCHART dpNoMatch; + KMX_DWORD cxKeyArray; // in array entries + KMX_BOOL fUsingKeys; // group(xx) [using keys] <-- specified or not +} GROUP, *LPGROUP; + + + +typedef struct tagKEYBOARD { + KMX_DWORD dwIdentifier; // Keyman compiled keyboard id + + KMX_DWORD dwFileVersion; // Version of the file - Keyman 4.0 is 0x0400 + + KMX_DWORD dwCheckSum; // As stored in keyboard. DEPRECATED as of 16.0 + KMX_DWORD xxkbdlayout; // as stored in HKEY_LOCAL_MACHINE//system//currentcontrolset//control//keyboard layouts + KMX_DWORD IsRegistered; // layout id, from same registry key + KMX_DWORD version; // keyboard version + + KMX_DWORD cxStoreArray; // in array entries + KMX_DWORD cxGroupArray; // in array entries + + LPSTORE dpStoreArray; // [LPSTORE] address of first item in store array, from start of file + LPGROUP dpGroupArray; // [LPGROUP] address of first item in group array, from start of file + + KMX_DWORD StartGroup[2]; // index of starting groups [2 of them] + // Ansi=0, Unicode=1 + + KMX_DWORD dwFlags; // Flags for the keyboard file + + KMX_DWORD dwHotKey; // standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) + + //PKMX_WCHART dpName; // offset of name + //PKMX_WCHART dpLanguageName; // offset of language name; + //PKMX_WCHART dpCopyright; // offset of copyright + //PKMX_WCHART dpMessage; // offset of message in Keyboard About box + + KMX_DWORD dpBitmapOffset; // 0038 offset of the bitmaps in the file + KMX_DWORD dwBitmapSize; // 003C size in bytes of the bitmaps + //HBITMAP hBitmap; // handle to the bitmap in the file; +} KEYBOARD, *LPKEYBOARD; + +KMX_BOOL LoadKeyboard(LPKMX_WCHART fileName, LPKEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? + +#endif + + + + + + +//---------------------old---------------------------------------- +/* +#include + +#ifndef _KMXFILE_H +#define _KMXFILE_H + +typedef struct tagSTORE { + DWORD dwSystemID; + PWSTR dpName; + PWSTR dpString; +} STORE, *LPSTORE; + +typedef struct tagKEY { + WCHAR Key; + DWORD Line; + DWORD ShiftFlags; + PWSTR dpOutput; + PWSTR dpContext; +} KEY, *LPKEY; + + +typedef struct tagGROUP { + PWSTR dpName; + LPKEY dpKeyArray; // [LPKEY] address of first item in key array + PWSTR dpMatch; + PWSTR dpNoMatch; + DWORD cxKeyArray; // in array entries + BOOL fUsingKeys; // group(xx) [using keys] <-- specified or not +} GROUP, *LPGROUP; + + +typedef struct tagKEYBOARD { + DWORD dwIdentifier; // Keyman compiled keyboard id + + DWORD dwFileVersion; // Version of the file - Keyman 4.0 is 0x0400 + + DWORD dwCheckSum; // As stored in keyboard. DEPRECATED as of 16.0 + DWORD xxkbdlayout; // as stored in HKEY_LOCAL_MACHINE//system//currentcontrolset//control//keyboard layouts + DWORD IsRegistered; // layout id, from same registry key + DWORD version; // keyboard version + + DWORD cxStoreArray; // in array entries + DWORD cxGroupArray; // in array entries + + LPSTORE dpStoreArray; // [LPSTORE] address of first item in store array, from start of file + LPGROUP dpGroupArray; // [LPGROUP] address of first item in group array, from start of file + + DWORD StartGroup[2]; // index of starting groups [2 of them] + // Ansi=0, Unicode=1 + + DWORD dwFlags; // Flags for the keyboard file + + DWORD dwHotKey; // standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) + + //PWSTR dpName; // offset of name + //PWSTR dpLanguageName; // offset of language name; + //PWSTR dpCopyright; // offset of copyright + //PWSTR dpMessage; // offset of message in Keyboard About box + + DWORD dpBitmapOffset; // 0038 offset of the bitmaps in the file + DWORD dwBitmapSize; // 003C size in bytes of the bitmaps + //HBITMAP hBitmap; // handle to the bitmap in the file; +} KEYBOARD, *LPKEYBOARD; + +BOOL LoadKeyboard(LPWSTR fileName, LPKEYBOARD *lpKeyboard); + +#endif +*/ + diff --git a/linux/mcompile/keymap/mc_savekeyboard.cpp b/linux/mcompile/keymap/mc_savekeyboard.cpp new file mode 100644 index 0000000000..497f2d4379 --- /dev/null +++ b/linux/mcompile/keymap/mc_savekeyboard.cpp @@ -0,0 +1,423 @@ +#include "mc_savekeyboard.h" + + +/*BOOL SaveKeyboard(LPKEYBOARD kbd, PWSTR filename) { + HANDLE hOutfile = CreateFile(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); + if(hOutfile == INVALID_HANDLE_VALUE) { + LogError(L"Failed to create output file (%d)", GetLastError()); + return FALSE; + } + + DWORD err = WriteCompiledKeyboard(kbd, hOutfile, FALSE); + + CloseHandle(hOutfile); + + if(err != CERR_None) { + LogError(L"Failed to write compiled keyboard with error %d", err); + DeleteFile(filename); + return FALSE; + } + + return TRUE; +}*/ + +/*DWORD WriteCompiledKeyboard(LPKEYBOARD fk, HANDLE hOutfile, BOOL FSaveDebug) +{ + LPGROUP fgp; + LPSTORE fsp; + LPKEY fkp; + + PCOMP_KEYBOARD ck; + PCOMP_GROUP gp; + PCOMP_STORE sp; + PCOMP_KEY kp; + PBYTE buf; + DWORD size, offset; + DWORD i, j; + + // Calculate how much memory to allocate + + size = sizeof(COMP_KEYBOARD) + + fk->cxGroupArray * sizeof(COMP_GROUP) + + fk->cxStoreArray * sizeof(COMP_STORE) + + //wcslen(fk->szName)*2 + 2 + + //wcslen(fk->szCopyright)*2 + 2 + + //wcslen(fk->szLanguageName)*2 + 2 + + //wcslen(fk->szMessage)*2 + 2 + + fk->dwBitmapSize; + + for(i = 0, fgp = fk->dpGroupArray; i < fk->cxGroupArray; i++, fgp++) { + if(fgp->dpName) + size += wcslen(fgp->dpName)*2 + 2; + size += fgp->cxKeyArray * sizeof(COMP_KEY); + for(j = 0, fkp = fgp->dpKeyArray; j < fgp->cxKeyArray; j++, fkp++) { + size += wcslen(fkp->dpOutput)*2 + 2; + size += wcslen(fkp->dpContext)*2 + 2; + } + + if( fgp->dpMatch ) size += wcslen(fgp->dpMatch)*2 + 2; + if( fgp->dpNoMatch ) size += wcslen(fgp->dpNoMatch)*2 + 2; + } + + for(i = 0; i < fk->cxStoreArray; i++) + { + size += wcslen(fk->dpStoreArray[i].dpString)*2 + 2; + if(fk->dpStoreArray[i].dpName) + size += wcslen(fk->dpStoreArray[i].dpName)*2 + 2; + } + + buf = new BYTE[size]; + if(!buf) return CERR_CannotAllocateMemory; + memset(buf, 0, size); + + ck = (PCOMP_KEYBOARD) buf; + + ck->dwIdentifier = FILEID_COMPILED; + + ck->dwFileVersion = fk->dwFileVersion; + ck->dwCheckSum = 0; // No checksum in 16.0, see #7276 + ck->KeyboardID = fk->xxkbdlayout; + ck->IsRegistered = fk->IsRegistered; + ck->cxStoreArray = fk->cxStoreArray; + ck->cxGroupArray = fk->cxGroupArray; + ck->StartGroup[0] = fk->StartGroup[0]; + ck->StartGroup[1] = fk->StartGroup[1]; + ck->dwHotKey = fk->dwHotKey; + + ck->dwFlags = fk->dwFlags; + + offset = sizeof(COMP_KEYBOARD); + + //ck->dpLanguageName = offset; + //wcscpy((PWSTR)(buf + offset), fk->szLanguageName); + //offset += wcslen(fk->szLanguageName)*2 + 2; + + //ck->dpName = offset; + //wcscpy((PWSTR)(buf + offset), fk->szName); + //offset += wcslen(fk->szName)*2 + 2; + + //ck->dpCopyright = offset; + //wcscpy((PWSTR)(buf + offset), fk->szCopyright); + //offset += wcslen(fk->szCopyright)*2 + 2; + + //ck->dpMessage = offset; + //wcscpy((PWSTR)(buf + offset), fk->szMessage); + //offset += wcslen(fk->szMessage)*2 + 2; + + ck->dpStoreArray = offset; + sp = (PCOMP_STORE)(buf+offset); + fsp = fk->dpStoreArray; + offset += sizeof(COMP_STORE) * ck->cxStoreArray; + for(i = 0; i < ck->cxStoreArray; i++, sp++, fsp++) { + sp->dwSystemID = fsp->dwSystemID; + sp->dpString = offset; + wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fsp->dpString); // I3481 // I3641 + offset += wcslen(fsp->dpString)*2 + 2; + + if(!fsp->dpName) { + sp->dpName = 0; + } else { + sp->dpName = offset; + wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fsp->dpName); // I3481 // I3641 + offset += wcslen(fsp->dpName)*2 + 2; + } + } + + ck->dpGroupArray = offset; + gp = (PCOMP_GROUP)(buf+offset); + fgp = fk->dpGroupArray; + + offset += sizeof(COMP_GROUP) * ck->cxGroupArray; + + for(i = 0; i < ck->cxGroupArray; i++, gp++, fgp++) { + gp->cxKeyArray = fgp->cxKeyArray; + gp->fUsingKeys = fgp->fUsingKeys; + + gp->dpMatch = gp->dpNoMatch = 0; + + if(fgp->dpMatch) { + gp->dpMatch = offset; + wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fgp->dpMatch); // I3481 // I3641 + offset += wcslen(fgp->dpMatch)*2 + 2; + } + if(fgp->dpNoMatch) { + gp->dpNoMatch = offset; + wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fgp->dpNoMatch); // I3481 // I3641 + offset += wcslen(fgp->dpNoMatch)*2 + 2; + } + + if(fgp->dpName) { + gp->dpName = offset; + wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fgp->dpName); // I3481 // I3641 + offset += wcslen(fgp->dpName)*2 + 2; + } else { + gp->dpName = 0; + } + + gp->dpKeyArray = offset; + kp = (PCOMP_KEY) (buf + offset); + fkp = fgp->dpKeyArray; + offset += gp->cxKeyArray * sizeof(COMP_KEY); + for(j = 0; j < gp->cxKeyArray; j++, kp++, fkp++) { + kp->Key = fkp->Key; + kp->Line = fkp->Line; + kp->ShiftFlags = fkp->ShiftFlags; + kp->dpOutput = offset; + wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fkp->dpOutput); // I3481 // I3641 + offset += wcslen(fkp->dpOutput)*2 + 2; + + + kp->dpContext = offset; + wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fkp->dpContext); // I3481 // I3641 + offset += wcslen(fkp->dpContext)*2 + 2; + } + } + + if(fk->dwBitmapSize > 0) { + ck->dwBitmapSize = fk->dwBitmapSize; + ck->dpBitmapOffset = offset; + memcpy(buf + offset, ((PBYTE)fk) + fk->dpBitmapOffset, fk->dwBitmapSize); + offset += fk->dwBitmapSize; + } else { + ck->dwBitmapSize = 0; + ck->dpBitmapOffset = 0; + } + + if(offset != size) + { + delete[] buf; + return CERR_SomewhereIGotItWrong; + } + + WriteFile(hOutfile, buf, size, &offset, NULL); + + if(offset != size) + { + delete[] buf; + return CERR_UnableToWriteFully; + } + + delete[] buf; + + return CERR_None; +}*/ + + + + +//---------------------old---------------------------------------- +/*#include "pch.h" + +// These four errors are copied from kmn_compiler_errors.h, because WriteCompiledKeyboard is +// a clone of the compiler's equivalent function. However, the functions +// diverge, as mc_savekeyboard.cpp's version is copying from an existing +// compiled keyboard. The error codes have been kept consistent with those in +// kmn_compiler_errors.h +#define CERR_None 0x00000000 +#define CERR_CannotAllocateMemory 0x00008004 +#define CERR_UnableToWriteFully 0x00008007 +#define CERR_SomewhereIGotItWrong 0x00008009 + +DWORD WriteCompiledKeyboard(LPKEYBOARD fk, HANDLE hOutfile, BOOL FSaveDebug); + +BOOL SaveKeyboard(LPKEYBOARD kbd, PWSTR filename) { + HANDLE hOutfile = CreateFile(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); + if(hOutfile == INVALID_HANDLE_VALUE) { + LogError(L"Failed to create output file (%d)", GetLastError()); + return FALSE; + } + + DWORD err = WriteCompiledKeyboard(kbd, hOutfile, FALSE); + + CloseHandle(hOutfile); + + if(err != CERR_None) { + LogError(L"Failed to write compiled keyboard with error %d", err); + DeleteFile(filename); + return FALSE; + } + + return TRUE; +} + +DWORD WriteCompiledKeyboard(LPKEYBOARD fk, HANDLE hOutfile, BOOL FSaveDebug) +{ + LPGROUP fgp; + LPSTORE fsp; + LPKEY fkp; + + PCOMP_KEYBOARD ck; + PCOMP_GROUP gp; + PCOMP_STORE sp; + PCOMP_KEY kp; + PBYTE buf; + DWORD size, offset; + DWORD i, j; + + // Calculate how much memory to allocate + + size = sizeof(COMP_KEYBOARD) + + fk->cxGroupArray * sizeof(COMP_GROUP) + + fk->cxStoreArray * sizeof(COMP_STORE) + + //wcslen(fk->szName)*2 + 2 + + //wcslen(fk->szCopyright)*2 + 2 + + //wcslen(fk->szLanguageName)*2 + 2 + + //wcslen(fk->szMessage)*2 + 2 + + fk->dwBitmapSize; + + for(i = 0, fgp = fk->dpGroupArray; i < fk->cxGroupArray; i++, fgp++) { + if(fgp->dpName) + size += wcslen(fgp->dpName)*2 + 2; + size += fgp->cxKeyArray * sizeof(COMP_KEY); + for(j = 0, fkp = fgp->dpKeyArray; j < fgp->cxKeyArray; j++, fkp++) { + size += wcslen(fkp->dpOutput)*2 + 2; + size += wcslen(fkp->dpContext)*2 + 2; + } + + if( fgp->dpMatch ) size += wcslen(fgp->dpMatch)*2 + 2; + if( fgp->dpNoMatch ) size += wcslen(fgp->dpNoMatch)*2 + 2; + } + + for(i = 0; i < fk->cxStoreArray; i++) + { + size += wcslen(fk->dpStoreArray[i].dpString)*2 + 2; + if(fk->dpStoreArray[i].dpName) + size += wcslen(fk->dpStoreArray[i].dpName)*2 + 2; + } + + buf = new BYTE[size]; + if(!buf) return CERR_CannotAllocateMemory; + memset(buf, 0, size); + + ck = (PCOMP_KEYBOARD) buf; + + ck->dwIdentifier = FILEID_COMPILED; + + ck->dwFileVersion = fk->dwFileVersion; + ck->dwCheckSum = 0; // No checksum in 16.0, see #7276 + ck->KeyboardID = fk->xxkbdlayout; + ck->IsRegistered = fk->IsRegistered; + ck->cxStoreArray = fk->cxStoreArray; + ck->cxGroupArray = fk->cxGroupArray; + ck->StartGroup[0] = fk->StartGroup[0]; + ck->StartGroup[1] = fk->StartGroup[1]; + ck->dwHotKey = fk->dwHotKey; + + ck->dwFlags = fk->dwFlags; + + offset = sizeof(COMP_KEYBOARD); + + //ck->dpLanguageName = offset; + //wcscpy((PWSTR)(buf + offset), fk->szLanguageName); + //offset += wcslen(fk->szLanguageName)*2 + 2; + + //ck->dpName = offset; + //wcscpy((PWSTR)(buf + offset), fk->szName); + //offset += wcslen(fk->szName)*2 + 2; + + //ck->dpCopyright = offset; + //wcscpy((PWSTR)(buf + offset), fk->szCopyright); + //offset += wcslen(fk->szCopyright)*2 + 2; + + //ck->dpMessage = offset; + //wcscpy((PWSTR)(buf + offset), fk->szMessage); + //offset += wcslen(fk->szMessage)*2 + 2; + + ck->dpStoreArray = offset; + sp = (PCOMP_STORE)(buf+offset); + fsp = fk->dpStoreArray; + offset += sizeof(COMP_STORE) * ck->cxStoreArray; + for(i = 0; i < ck->cxStoreArray; i++, sp++, fsp++) { + sp->dwSystemID = fsp->dwSystemID; + sp->dpString = offset; + wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fsp->dpString); // I3481 // I3641 + offset += wcslen(fsp->dpString)*2 + 2; + + if(!fsp->dpName) { + sp->dpName = 0; + } else { + sp->dpName = offset; + wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fsp->dpName); // I3481 // I3641 + offset += wcslen(fsp->dpName)*2 + 2; + } + } + + ck->dpGroupArray = offset; + gp = (PCOMP_GROUP)(buf+offset); + fgp = fk->dpGroupArray; + + offset += sizeof(COMP_GROUP) * ck->cxGroupArray; + + for(i = 0; i < ck->cxGroupArray; i++, gp++, fgp++) { + gp->cxKeyArray = fgp->cxKeyArray; + gp->fUsingKeys = fgp->fUsingKeys; + + gp->dpMatch = gp->dpNoMatch = 0; + + if(fgp->dpMatch) { + gp->dpMatch = offset; + wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fgp->dpMatch); // I3481 // I3641 + offset += wcslen(fgp->dpMatch)*2 + 2; + } + if(fgp->dpNoMatch) { + gp->dpNoMatch = offset; + wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fgp->dpNoMatch); // I3481 // I3641 + offset += wcslen(fgp->dpNoMatch)*2 + 2; + } + + if(fgp->dpName) { + gp->dpName = offset; + wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fgp->dpName); // I3481 // I3641 + offset += wcslen(fgp->dpName)*2 + 2; + } else { + gp->dpName = 0; + } + + gp->dpKeyArray = offset; + kp = (PCOMP_KEY) (buf + offset); + fkp = fgp->dpKeyArray; + offset += gp->cxKeyArray * sizeof(COMP_KEY); + for(j = 0; j < gp->cxKeyArray; j++, kp++, fkp++) { + kp->Key = fkp->Key; + kp->Line = fkp->Line; + kp->ShiftFlags = fkp->ShiftFlags; + kp->dpOutput = offset; + wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fkp->dpOutput); // I3481 // I3641 + offset += wcslen(fkp->dpOutput)*2 + 2; + + + kp->dpContext = offset; + wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fkp->dpContext); // I3481 // I3641 + offset += wcslen(fkp->dpContext)*2 + 2; + } + } + + if(fk->dwBitmapSize > 0) { + ck->dwBitmapSize = fk->dwBitmapSize; + ck->dpBitmapOffset = offset; + memcpy(buf + offset, ((PBYTE)fk) + fk->dpBitmapOffset, fk->dwBitmapSize); + offset += fk->dwBitmapSize; + } else { + ck->dwBitmapSize = 0; + ck->dpBitmapOffset = 0; + } + + if(offset != size) + { + delete[] buf; + return CERR_SomewhereIGotItWrong; + } + + WriteFile(hOutfile, buf, size, &offset, NULL); + + if(offset != size) + { + delete[] buf; + return CERR_UnableToWriteFully; + } + + delete[] buf; + + return CERR_None; +} +*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/mc_savekeyboard.h b/linux/mcompile/keymap/mc_savekeyboard.h new file mode 100644 index 0000000000..7ac15f4ff1 --- /dev/null +++ b/linux/mcompile/keymap/mc_savekeyboard.h @@ -0,0 +1,18 @@ +#pragma once + +#include "km_types.h" +KMX_DWORD TEST3; +// this file is all new _S2 + +//#include "../../../common/include/km_types.h" + + +#define CERR_None 0x00000000 +#define CERR_CannotAllocateMemory 0x00008004 +#define CERR_UnableToWriteFully 0x00008007 +#define CERR_SomewhereIGotItWrong 0x00008009 +/* +DWORD WriteCompiledKeyboard(LPKEYBOARD fk, HANDLE hOutfile, BOOL FSaveDebug); +BOOL SaveKeyboard(LPKEYBOARD kbd, PWSTR filename) ; +DWORD WriteCompiledKeyboard(LPKEYBOARD fk, HANDLE hOutfile, BOOL FSaveDebug); +*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp new file mode 100644 index 0000000000..b990f02806 --- /dev/null +++ b/linux/mcompile/keymap/mcompile.cpp @@ -0,0 +1,924 @@ +/* + Name: mcompile + Copyright: Copyright (C) SIL International. + Documentation: + Description: + Create Date: 24 Apr 2014 + + Modified Date: 8 Apr 2015 + Authors: mcdurdin + Related Files: + Dependencies: + + Bugs: + Todo: + Notes: + History: 24 Apr 2014 - mcdurdin - I4174 - V9 - mcompile logs should be stored in diag folder + 16 Jun 2014 - mcdurdin - I4273 - V9.0 - Convert keyboards to Unicode before installing + 23 Jun 2014 - mcdurdin - I4279 - V9.0 - mcompile fails to start when converting keyboard to Unicode + 03 Aug 2014 - mcdurdin - I4353 - V9.0 - mnemonic layout recompiler mixes up deadkey rules + 03 Aug 2014 - mcdurdin - I4327 - V9.0 - Mnemonic layout compiler follow-up + 31 Dec 2014 - mcdurdin - I4549 - V9.0 - Mnemonic layout recompiler does not translate Lctrl Ralt for deadkeys correctly + 06 Feb 2015 - mcdurdin - I4552 - V9.0 - Add mnemonic recompile option to ignore deadkeys + 08 Apr 2015 - mcdurdin - I4651 - V9.0 - Mnemonic layout recompiler maps AltGr+VK_BKSLASH rather than VK_OEM_102 +*/ +// +// m-to-p.cpp : Defines the entry point for the console application. +// +// Note: this program deliberately leaks memory as it has a very short life cycle and managing the memory allocations +// for the subcomponents of the compiled keyboard is an unnecessary optimisation. Just so you know. +// + +#include "pch.h" +#include + +#include +#include +#include + +BOOL DoConvert(LPKEYBOARD kbd, PWSTR kbid, BOOL bDeadkeyConversion); +BOOL SaveKeyboard(LPKEYBOARD kbd, PWSTR filename); +bool ImportRules(WCHAR *kbid, LPKEYBOARD kp, std::vector *FDeadkeys, BOOL bDeadkeyConversion); // I4353 // I4327 +BOOL ConvertKeyboardToUnicode(LPKEYBOARD kbd); // I4273 +int run(int argc, wchar_t * argv[]); + +std::vector FDeadkeys; // I4353 + +#define KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE_MCOMPILE KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE ".mcompile" + +int wmain(int argc, wchar_t * argv[]) +{ + return keyman_sentry_wmain(false, KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE_MCOMPILE, argc, argv, run); +} + +int run(int argc, wchar_t * argv[]) +{ + if(argc < 3 || (argc < 5 && wcscmp(argv[1], L"-u") != 0)) { // I4273 + printf( + "Usage: mcompile -u infile.kmx outfile.kmx\n" + " mcompile [-d] infile.kmx kbdfile.dll kbid outfile.kmx\n" + " With -u parameter, converts keyboard from ANSI to Unicode\n" + " Otherwise, mcompile converts a Keyman mnemonic layout to a\n" + " positional one based on the Windows keyboard\n" + " layout file given by kbdfile.dll\n\n" + " kbid should be a hexadecimal number e.g. 409 for US English\n" + " -d convert deadkeys to plain keys\n"); // I4552 + + return 1; + } + + if(wcscmp(argv[1], L"-u") == 0) { // I4273 + wchar_t *infile = argv[2], *outfile = argv[3]; + + LPKEYBOARD kmxfile; + + if(!LoadKeyboard(infile, &kmxfile)) { + LogError(L"Failed to load keyboard (%d)", GetLastError()); + return 3; + } + + if(ConvertKeyboardToUnicode(kmxfile)) { + SaveKeyboard(kmxfile, outfile); + } + + //DeleteReallocatedPointers(kmxfile); :TODO + delete[] kmxfile; + + return 0; // I4279 + } + + int bDeadkeyConversion = wcscmp(argv[1], L"-d") == 0; // I4552 + int n = (bDeadkeyConversion ? 2 : 1); + + wchar_t *infile = argv[n], *indll = argv[n+1], *kbid = argv[n+2], *outfile = argv[n+3]; + + wprintf(L"mcompile%ls \"%ls\" \"%ls\" \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d":L"", infile, indll, kbid, outfile); // I4174 + + // 1. Load the keyman keyboard file + + // 2. For each key on the system layout, determine its output character and perform a + // 1-1 replacement on the keyman keyboard of that character with the base VK + shift + // state. This fixup will transform the char to a vk, which will avoid any issues + // with the key. + // + // --> deadkeys we will attack after the POC + // + // For each deadkey, we need to determine its possible outputs. Then we generate a VK + // rule for that deadkey, e.g. [K_LBRKT] > dk(c101) + // + // Next, update each rule that references the output from that deadkey to add an extra + // context deadkey at the end of the context match, e.g. 'a' dk(c101) + [K_SPACE] > 'b'. + // This will require a memory layout change for the .kmx file, plus fixups on the + // context+output index offsets + // + // --> virtual character keys + // + // [CTRL ' '] : we look at the character, and replace it in the same way, but merely + // switch the shift state from the VIRTUALCHARKEY to VIRTUALKEY, without changing any + // other properties of the key. + // + + // 3. Write the new keyman keyboard file + + if(!LoadNewLibrary(indll)) { + LogError(L"Failed to load keyboard DLL (%d)", GetLastError()); + return 2; + } + + LPKEYBOARD kmxfile; + + if(!LoadKeyboard(infile, &kmxfile)) { + LogError(L"Failed to load keyboard (%d)", GetLastError()); + return 3; + } + + if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552 + SaveKeyboard(kmxfile, outfile); + } + + //DeleteReallocatedPointers(kmxfile); :TODO + delete kmxfile; + + return 0; +} + + +// +// Map of all US English virtual key codes that we can translate +// +const WORD VKMap[] = { + 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', + '0','1','2','3','4','5','6','7','8','9', + VK_SPACE, + VK_ACCENT, VK_HYPHEN, VK_EQUAL, + VK_LBRKT, VK_RBRKT, VK_BKSLASH, + VK_COLON, VK_QUOTE, + VK_COMMA, VK_PERIOD, VK_SLASH, + VK_xDF, VK_OEM_102, + 0 +}; + + +// +// Map of all shift states that we will work with +// +const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; + +// +// TranslateKey +// +// For each key rule on the keyboard, remap its key to the +// correct shift state and key. Adjust the LCTRL+RALT -> RALT if necessary +// +void TranslateKey(LPKEY key, WORD vk, UINT shift, WCHAR ch) { + + // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. + // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" + // to provide an alternate.. + if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) + shift &= ~LCTRLFLAG; + + if(key->ShiftFlags == 0 && key->Key == ch) { + // Key is a mnemonic key with no shift state defined. + // Remap the key according to the character on the key cap. + //LogError(L"Converted mnemonic rule on line %d, + '%c' TO + [%x K_%d]", key->Line, key->Key, shift, vk); + key->ShiftFlags = ISVIRTUALKEY | shift; + key->Key = vk; + } else if(key->ShiftFlags & VIRTUALCHARKEY && key->Key == ch) { + // Key is a virtual character key with a hard-coded shift state. + // Do not remap the shift state, just move the key. + // This will not result in 100% wonderful mappings as there could + // be overlap, depending on how keys are arranged on the target layout. + // But that is up to the designer. + //LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, key->ShiftFlags & ~VIRTUALCHARKEY, vk); + key->ShiftFlags &= ~VIRTUALCHARKEY; + key->Key = vk; + } +} + +void TranslateGroup(LPGROUP group, WORD vk, UINT shift, WCHAR ch) { + for(unsigned int i = 0; i < group->cxKeyArray; i++) { + TranslateKey(&group->dpKeyArray[i], vk, shift, ch); + } +} + +void TranslateKeyboard(LPKEYBOARD kbd, WORD vk, UINT shift, WCHAR ch) { + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + TranslateGroup(&kbd->dpGroupArray[i], vk, shift, ch); + } + } +} + +void ReportUnconvertedKeyRule(LPKEY key) { + if(key->ShiftFlags == 0) { + LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); + } else if(key->ShiftFlags & VIRTUALCHARKEY) { + LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); + } +} + +void ReportUnconvertedGroupRules(LPGROUP group) { + for(unsigned int i = 0; i < group->cxKeyArray; i++) { + ReportUnconvertedKeyRule(&group->dpKeyArray[i]); + } +} + +void ReportUnconvertedKeyboardRules(LPKEYBOARD kbd) { + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + ReportUnconvertedGroupRules(&kbd->dpGroupArray[i]); + } + } +} + +void TranslateDeadkeyKey(LPKEY key, WCHAR deadkey, WORD vk, UINT shift, WORD ch) { + if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { + + // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. + // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" + // to provide an alternate.. + if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4327 + shift &= ~LCTRLFLAG; + + if(key->ShiftFlags == 0) { + //LogError("Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d]", key->Line, key->Key, deadkey, shift, vk); + key->ShiftFlags = ISVIRTUALKEY | shift; + } else { + //LogError("Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO dk(%d) + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, deadkey, key->ShiftFlags & ~VIRTUALCHARKEY, vk); + key->ShiftFlags &= ~VIRTUALCHARKEY; + } + + int len = wcslen(key->dpContext); + PWSTR context = new WCHAR[len + 4]; + memcpy(context, key->dpContext, len * sizeof(WCHAR)); + context[len] = UC_SENTINEL; + context[len+1] = CODE_DEADKEY; + context[len+2] = deadkey; + context[len+3] = 0; + key->dpContext = context; + key->Key = vk; + } +} + +void TranslateDeadkeyGroup(LPGROUP group, WCHAR deadkey, WORD vk, UINT shift, WORD ch) { + for(unsigned int i = 0; i < group->cxKeyArray; i++) { + TranslateDeadkeyKey(&group->dpKeyArray[i], deadkey, vk, shift, ch); + } +} + +void TranslateDeadkeyKeyboard(LPKEYBOARD kbd, WCHAR deadkey, WORD vk, UINT shift, WORD ch) { + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + TranslateDeadkeyGroup(&kbd->dpGroupArray[i], deadkey, vk, shift, ch); + } + } +} + +void AddDeadkeyRule(LPKEYBOARD kbd, WCHAR deadkey, WORD vk, UINT shift) { + // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. + // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" + // to provide an alternate.. + if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4549 + shift &= ~LCTRLFLAG; + + // If the first group is not a matching-keys group, then we need to add into + // each subgroup, otherwise just the match group + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + LPKEY keys = new KEY[kbd->dpGroupArray[i].cxKeyArray + 1]; + memcpy(keys+1, kbd->dpGroupArray[i].dpKeyArray, kbd->dpGroupArray[i].cxKeyArray * sizeof(KEY)); + keys[0].dpContext = new WCHAR[1]; + keys[0].dpContext[0] = 0; + keys[0].dpOutput = new WCHAR[4]; // UC_SENTINEL, CODE_DEADKEY, deadkey_value, 0 + keys[0].dpOutput[0] = UC_SENTINEL; + keys[0].dpOutput[1] = CODE_DEADKEY; + keys[0].dpOutput[2] = deadkey; // TODO: translate to unique index + keys[0].dpOutput[3] = 0; + keys[0].Key = vk; + keys[0].Line = 0; + keys[0].ShiftFlags = shift | ISVIRTUALKEY; + kbd->dpGroupArray[i].dpKeyArray = keys; + kbd->dpGroupArray[i].cxKeyArray++; + //LogError("Add deadkey rule: + [%d K_%d] > dk(%d)", shift, vk, deadkey); + if(i == kbd->StartGroup[1]) break; // If this is the initial group, that's all we need to do. + } + } +} + +WCHAR ScanXStringForMaxDeadkeyID(LPWSTR str) { + WCHAR dkid = 0; + while(str && *str) { + if(*str == UC_SENTINEL) { + switch(*(str+1)) { + case CODE_DEADKEY: + dkid = max(dkid, *(str+2)); + } + } + str = incxstr(str); + } + return dkid; +} + +struct dkidmap { + WCHAR src_deadkey, dst_deadkey; +}; + +WCHAR GetUniqueDeadkeyID(LPKEYBOARD kbd, WCHAR deadkey) { + LPGROUP gp; + LPKEY kp; + LPSTORE sp; + UINT i, j; + WCHAR dkid = 0; + static WCHAR s_next_dkid = 0; + static dkidmap *s_dkids = NULL; + static int s_ndkids = 0; + + if(!kbd) { + if(s_dkids) { + delete s_dkids; + } + s_dkids = NULL; + s_ndkids = 0; + s_next_dkid = 0; + return 0; + } + + for(int i = 0; i < s_ndkids; i++) { + if(s_dkids[i].src_deadkey == deadkey) { + return s_dkids[i].dst_deadkey; + } + } + + if(s_next_dkid != 0) { + s_dkids = (dkidmap*) realloc(s_dkids, sizeof(dkidmap) * (s_ndkids+1)); + s_dkids[s_ndkids].src_deadkey = deadkey; + return s_dkids[s_ndkids++].dst_deadkey = ++s_next_dkid; + } + + for(i = 0, gp = kbd->dpGroupArray; i < kbd->cxGroupArray; i++, gp++) { + for(j = 0, kp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kp++) { + dkid = max(dkid, ScanXStringForMaxDeadkeyID(kp->dpContext)); + dkid = max(dkid, ScanXStringForMaxDeadkeyID(kp->dpOutput)); + } + dkid = max(dkid, ScanXStringForMaxDeadkeyID(gp->dpMatch)); + dkid = max(dkid, ScanXStringForMaxDeadkeyID(gp->dpNoMatch)); + } + + for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { + dkid = max(dkid, ScanXStringForMaxDeadkeyID(sp->dpString)); + } + + s_dkids = (dkidmap*) realloc(s_dkids, sizeof(dkidmap) * (s_ndkids+1)); + s_dkids[s_ndkids].src_deadkey = deadkey; + return s_dkids[s_ndkids++].dst_deadkey = s_next_dkid = ++dkid; +} + + +void ConvertDeadkey(LPKEYBOARD kbd, WORD vk, UINT shift, WCHAR deadkey) { + WORD deadkeys[512], *pdk; + + // Lookup the deadkey table for the deadkey in the physical keyboard + // Then for each character, go through and map it through + + WCHAR dkid = GetUniqueDeadkeyID(kbd, deadkey); + + // Add the deadkey to the mapping table for use in the import rules phase + DeadkeyMapping deadkeyMapping = { deadkey, dkid, shift, vk }; // I4353 + FDeadkeys.push_back(deadkeyMapping); //dkid, vk, shift); // I4353 + + AddDeadkeyRule(kbd, dkid, vk, shift); + + GetDeadkeys(deadkey, pdk = deadkeys); // returns array of [usvk, ch_out] pairs + while(*pdk) { + // Look up the ch + UINT vkUnderlying = VKUnderlyingLayoutToVKUS(*pdk); + TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); + pdk+=3; + } +} + +BOOL SetKeyboardToPositional(LPKEYBOARD kbd) { + LPSTORE sp; + UINT i; + for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { + if(sp->dwSystemID == TSS_MNEMONIC) { + if(!sp->dpString) { + LogError(L"Invalid &mnemoniclayout system store"); + return FALSE; + } + if(wcscmp(sp->dpString, L"1") != 0) { + LogError(L"Keyboard is not a mnemonic layout keyboard"); + return FALSE; + } + *sp->dpString = '0'; + return TRUE; + } + } + + LogError(L"Keyboard is not a mnemonic layout keyboard"); + return FALSE; +} + +BOOL DoConvert(LPKEYBOARD kbd, LPWSTR kbid, BOOL bDeadkeyConversion) { // I4552 + WCHAR DeadKey; + + if(!SetKeyboardToPositional(kbd)) return FALSE; + + // Go through each of the shift states - base, shift, ctrl+alt, ctrl+alt+shift, [caps vs ncaps?] + // Currently, we go in this order so the 102nd key works. But this is not ideal for keyboards without 102nd key: // I4651 + // it catches only the first key that matches a given rule, but multiple keys may match that rule. This is particularly + // evident for the 102nd key on UK, for example, where \ can be generated with VK_OEM_102 or AltGr+VK_QUOTE. + // For now, we get the least shifted version, which is hopefully adequate. + + for(int j = 0; VKShiftState[j] != 0xFFFF; j++) { // I4651 + // Go through each possible key on the keyboard + for(int i = 0; VKMap[i]; i++) { // I4651 + UINT vkUnderlying = VKUSToVKUnderlyingLayout(VKMap[i]); + + WCHAR ch = CharFromVK(vkUnderlying, VKShiftState[j], &DeadKey); + + //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); + + if(bDeadkeyConversion) { // I4552 + if(ch == 0xFFFF) { + ch = DeadKey; + } + } + + switch(ch) { + case 0x0000: break; + case 0xFFFF: ConvertDeadkey(kbd, VKMap[i], VKShiftState[j], DeadKey); break; + default: TranslateKeyboard(kbd, VKMap[i], VKShiftState[j], ch); + } + + // + } + } + + ReportUnconvertedKeyboardRules(kbd); + + if(!ImportRules(kbid, kbd, &FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 + return FALSE; + } + + return TRUE; +} + +void LogError(PWSTR fmt, ...) { + WCHAR fmtbuf[256]; + + va_list vars; + va_start(vars, fmt); + _vsnwprintf_s(fmtbuf, _countof(fmtbuf), _TRUNCATE, fmt, vars); // I2248 // I3547 + fmtbuf[255] = 0; + _putws(fmtbuf); +} + +//---------old------------------------------------------- +/*#include "pch.h" +#include + +#include +#include +#include + +BOOL DoConvert(LPKEYBOARD kbd, PWSTR kbid, BOOL bDeadkeyConversion); +BOOL SaveKeyboard(LPKEYBOARD kbd, PWSTR filename); +bool ImportRules(WCHAR *kbid, LPKEYBOARD kp, std::vector *FDeadkeys, BOOL bDeadkeyConversion); // I4353 // I4327 +BOOL ConvertKeyboardToUnicode(LPKEYBOARD kbd); // I4273 +int run(int argc, wchar_t * argv[]); + +std::vector FDeadkeys; // I4353 + +#define KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE_MCOMPILE KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE ".mcompile" + +int wmain(int argc, wchar_t * argv[]) +{ + return keyman_sentry_wmain(false, KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE_MCOMPILE, argc, argv, run); +} + +int run(int argc, wchar_t * argv[]) +{ + if(argc < 3 || (argc < 5 && wcscmp(argv[1], L"-u") != 0)) { // I4273 + printf( + "Usage: mcompile -u infile.kmx outfile.kmx\n" + " mcompile [-d] infile.kmx kbdfile.dll kbid outfile.kmx\n" + " With -u parameter, converts keyboard from ANSI to Unicode\n" + " Otherwise, mcompile converts a Keyman mnemonic layout to a\n" + " positional one based on the Windows keyboard\n" + " layout file given by kbdfile.dll\n\n" + " kbid should be a hexadecimal number e.g. 409 for US English\n" + " -d convert deadkeys to plain keys\n"); // I4552 + + return 1; + } + + if(wcscmp(argv[1], L"-u") == 0) { // I4273 + wchar_t *infile = argv[2], *outfile = argv[3]; + + LPKEYBOARD kmxfile; + + if(!LoadKeyboard(infile, &kmxfile)) { + LogError(L"Failed to load keyboard (%d)", GetLastError()); + return 3; + } + + if(ConvertKeyboardToUnicode(kmxfile)) { + SaveKeyboard(kmxfile, outfile); + } + + //DeleteReallocatedPointers(kmxfile); :TODO + delete[] kmxfile; + + return 0; // I4279 + } + + int bDeadkeyConversion = wcscmp(argv[1], L"-d") == 0; // I4552 + int n = (bDeadkeyConversion ? 2 : 1); + + wchar_t *infile = argv[n], *indll = argv[n+1], *kbid = argv[n+2], *outfile = argv[n+3]; + + wprintf(L"mcompile%ls \"%ls\" \"%ls\" \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d":L"", infile, indll, kbid, outfile); // I4174 + + // 1. Load the keyman keyboard file + + // 2. For each key on the system layout, determine its output character and perform a + // 1-1 replacement on the keyman keyboard of that character with the base VK + shift + // state. This fixup will transform the char to a vk, which will avoid any issues + // with the key. + // + // --> deadkeys we will attack after the POC + // + // For each deadkey, we need to determine its possible outputs. Then we generate a VK + // rule for that deadkey, e.g. [K_LBRKT] > dk(c101) + // + // Next, update each rule that references the output from that deadkey to add an extra + // context deadkey at the end of the context match, e.g. 'a' dk(c101) + [K_SPACE] > 'b'. + // This will require a memory layout change for the .kmx file, plus fixups on the + // context+output index offsets + // + // --> virtual character keys + // + // [CTRL ' '] : we look at the character, and replace it in the same way, but merely + // switch the shift state from the VIRTUALCHARKEY to VIRTUALKEY, without changing any + // other properties of the key. + // + + // 3. Write the new keyman keyboard file + + if(!LoadNewLibrary(indll)) { + LogError(L"Failed to load keyboard DLL (%d)", GetLastError()); + return 2; + } + + LPKEYBOARD kmxfile; + + if(!LoadKeyboard(infile, &kmxfile)) { + LogError(L"Failed to load keyboard (%d)", GetLastError()); + return 3; + } + + if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552 + SaveKeyboard(kmxfile, outfile); + } + + //DeleteReallocatedPointers(kmxfile); :TODO + delete kmxfile; + + return 0; +} + + +// +// Map of all US English virtual key codes that we can translate +// +const WORD VKMap[] = { + 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', + '0','1','2','3','4','5','6','7','8','9', + VK_SPACE, + VK_ACCENT, VK_HYPHEN, VK_EQUAL, + VK_LBRKT, VK_RBRKT, VK_BKSLASH, + VK_COLON, VK_QUOTE, + VK_COMMA, VK_PERIOD, VK_SLASH, + VK_xDF, VK_OEM_102, + 0 +}; + + +// +// Map of all shift states that we will work with +// +const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; + +// +// TranslateKey +// +// For each key rule on the keyboard, remap its key to the +// correct shift state and key. Adjust the LCTRL+RALT -> RALT if necessary +// +void TranslateKey(LPKEY key, WORD vk, UINT shift, WCHAR ch) { + + // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. + // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" + // to provide an alternate.. + if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) + shift &= ~LCTRLFLAG; + + if(key->ShiftFlags == 0 && key->Key == ch) { + // Key is a mnemonic key with no shift state defined. + // Remap the key according to the character on the key cap. + //LogError(L"Converted mnemonic rule on line %d, + '%c' TO + [%x K_%d]", key->Line, key->Key, shift, vk); + key->ShiftFlags = ISVIRTUALKEY | shift; + key->Key = vk; + } else if(key->ShiftFlags & VIRTUALCHARKEY && key->Key == ch) { + // Key is a virtual character key with a hard-coded shift state. + // Do not remap the shift state, just move the key. + // This will not result in 100% wonderful mappings as there could + // be overlap, depending on how keys are arranged on the target layout. + // But that is up to the designer. + //LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, key->ShiftFlags & ~VIRTUALCHARKEY, vk); + key->ShiftFlags &= ~VIRTUALCHARKEY; + key->Key = vk; + } +} + +void TranslateGroup(LPGROUP group, WORD vk, UINT shift, WCHAR ch) { + for(unsigned int i = 0; i < group->cxKeyArray; i++) { + TranslateKey(&group->dpKeyArray[i], vk, shift, ch); + } +} + +void TranslateKeyboard(LPKEYBOARD kbd, WORD vk, UINT shift, WCHAR ch) { + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + TranslateGroup(&kbd->dpGroupArray[i], vk, shift, ch); + } + } +} + +void ReportUnconvertedKeyRule(LPKEY key) { + if(key->ShiftFlags == 0) { + LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); + } else if(key->ShiftFlags & VIRTUALCHARKEY) { + LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); + } +} + +void ReportUnconvertedGroupRules(LPGROUP group) { + for(unsigned int i = 0; i < group->cxKeyArray; i++) { + ReportUnconvertedKeyRule(&group->dpKeyArray[i]); + } +} + +void ReportUnconvertedKeyboardRules(LPKEYBOARD kbd) { + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + ReportUnconvertedGroupRules(&kbd->dpGroupArray[i]); + } + } +} + +void TranslateDeadkeyKey(LPKEY key, WCHAR deadkey, WORD vk, UINT shift, WORD ch) { + if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { + + // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. + // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" + // to provide an alternate.. + if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4327 + shift &= ~LCTRLFLAG; + + if(key->ShiftFlags == 0) { + //LogError("Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d]", key->Line, key->Key, deadkey, shift, vk); + key->ShiftFlags = ISVIRTUALKEY | shift; + } else { + //LogError("Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO dk(%d) + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, deadkey, key->ShiftFlags & ~VIRTUALCHARKEY, vk); + key->ShiftFlags &= ~VIRTUALCHARKEY; + } + + int len = wcslen(key->dpContext); + PWSTR context = new WCHAR[len + 4]; + memcpy(context, key->dpContext, len * sizeof(WCHAR)); + context[len] = UC_SENTINEL; + context[len+1] = CODE_DEADKEY; + context[len+2] = deadkey; + context[len+3] = 0; + key->dpContext = context; + key->Key = vk; + } +} + +void TranslateDeadkeyGroup(LPGROUP group, WCHAR deadkey, WORD vk, UINT shift, WORD ch) { + for(unsigned int i = 0; i < group->cxKeyArray; i++) { + TranslateDeadkeyKey(&group->dpKeyArray[i], deadkey, vk, shift, ch); + } +} + +void TranslateDeadkeyKeyboard(LPKEYBOARD kbd, WCHAR deadkey, WORD vk, UINT shift, WORD ch) { + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + TranslateDeadkeyGroup(&kbd->dpGroupArray[i], deadkey, vk, shift, ch); + } + } +} + +void AddDeadkeyRule(LPKEYBOARD kbd, WCHAR deadkey, WORD vk, UINT shift) { + // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. + // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" + // to provide an alternate.. + if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4549 + shift &= ~LCTRLFLAG; + + // If the first group is not a matching-keys group, then we need to add into + // each subgroup, otherwise just the match group + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + LPKEY keys = new KEY[kbd->dpGroupArray[i].cxKeyArray + 1]; + memcpy(keys+1, kbd->dpGroupArray[i].dpKeyArray, kbd->dpGroupArray[i].cxKeyArray * sizeof(KEY)); + keys[0].dpContext = new WCHAR[1]; + keys[0].dpContext[0] = 0; + keys[0].dpOutput = new WCHAR[4]; // UC_SENTINEL, CODE_DEADKEY, deadkey_value, 0 + keys[0].dpOutput[0] = UC_SENTINEL; + keys[0].dpOutput[1] = CODE_DEADKEY; + keys[0].dpOutput[2] = deadkey; // TODO: translate to unique index + keys[0].dpOutput[3] = 0; + keys[0].Key = vk; + keys[0].Line = 0; + keys[0].ShiftFlags = shift | ISVIRTUALKEY; + kbd->dpGroupArray[i].dpKeyArray = keys; + kbd->dpGroupArray[i].cxKeyArray++; + //LogError("Add deadkey rule: + [%d K_%d] > dk(%d)", shift, vk, deadkey); + if(i == kbd->StartGroup[1]) break; // If this is the initial group, that's all we need to do. + } + } +} + +WCHAR ScanXStringForMaxDeadkeyID(LPWSTR str) { + WCHAR dkid = 0; + while(str && *str) { + if(*str == UC_SENTINEL) { + switch(*(str+1)) { + case CODE_DEADKEY: + dkid = max(dkid, *(str+2)); + } + } + str = incxstr(str); + } + return dkid; +} + +struct dkidmap { + WCHAR src_deadkey, dst_deadkey; +}; + +WCHAR GetUniqueDeadkeyID(LPKEYBOARD kbd, WCHAR deadkey) { + LPGROUP gp; + LPKEY kp; + LPSTORE sp; + UINT i, j; + WCHAR dkid = 0; + static WCHAR s_next_dkid = 0; + static dkidmap *s_dkids = NULL; + static int s_ndkids = 0; + + if(!kbd) { + if(s_dkids) { + delete s_dkids; + } + s_dkids = NULL; + s_ndkids = 0; + s_next_dkid = 0; + return 0; + } + + for(int i = 0; i < s_ndkids; i++) { + if(s_dkids[i].src_deadkey == deadkey) { + return s_dkids[i].dst_deadkey; + } + } + + if(s_next_dkid != 0) { + s_dkids = (dkidmap*) realloc(s_dkids, sizeof(dkidmap) * (s_ndkids+1)); + s_dkids[s_ndkids].src_deadkey = deadkey; + return s_dkids[s_ndkids++].dst_deadkey = ++s_next_dkid; + } + + for(i = 0, gp = kbd->dpGroupArray; i < kbd->cxGroupArray; i++, gp++) { + for(j = 0, kp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kp++) { + dkid = max(dkid, ScanXStringForMaxDeadkeyID(kp->dpContext)); + dkid = max(dkid, ScanXStringForMaxDeadkeyID(kp->dpOutput)); + } + dkid = max(dkid, ScanXStringForMaxDeadkeyID(gp->dpMatch)); + dkid = max(dkid, ScanXStringForMaxDeadkeyID(gp->dpNoMatch)); + } + + for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { + dkid = max(dkid, ScanXStringForMaxDeadkeyID(sp->dpString)); + } + + s_dkids = (dkidmap*) realloc(s_dkids, sizeof(dkidmap) * (s_ndkids+1)); + s_dkids[s_ndkids].src_deadkey = deadkey; + return s_dkids[s_ndkids++].dst_deadkey = s_next_dkid = ++dkid; +} + + +void ConvertDeadkey(LPKEYBOARD kbd, WORD vk, UINT shift, WCHAR deadkey) { + WORD deadkeys[512], *pdk; + + // Lookup the deadkey table for the deadkey in the physical keyboard + // Then for each character, go through and map it through + + WCHAR dkid = GetUniqueDeadkeyID(kbd, deadkey); + + // Add the deadkey to the mapping table for use in the import rules phase + DeadkeyMapping deadkeyMapping = { deadkey, dkid, shift, vk }; // I4353 + FDeadkeys.push_back(deadkeyMapping); //dkid, vk, shift); // I4353 + + AddDeadkeyRule(kbd, dkid, vk, shift); + + GetDeadkeys(deadkey, pdk = deadkeys); // returns array of [usvk, ch_out] pairs + while(*pdk) { + // Look up the ch + UINT vkUnderlying = VKUnderlyingLayoutToVKUS(*pdk); + TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); + pdk+=3; + } +} + +BOOL SetKeyboardToPositional(LPKEYBOARD kbd) { + LPSTORE sp; + UINT i; + for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { + if(sp->dwSystemID == TSS_MNEMONIC) { + if(!sp->dpString) { + LogError(L"Invalid &mnemoniclayout system store"); + return FALSE; + } + if(wcscmp(sp->dpString, L"1") != 0) { + LogError(L"Keyboard is not a mnemonic layout keyboard"); + return FALSE; + } + *sp->dpString = '0'; + return TRUE; + } + } + + LogError(L"Keyboard is not a mnemonic layout keyboard"); + return FALSE; +} + +BOOL DoConvert(LPKEYBOARD kbd, LPWSTR kbid, BOOL bDeadkeyConversion) { // I4552 + WCHAR DeadKey; + + if(!SetKeyboardToPositional(kbd)) return FALSE; + + // Go through each of the shift states - base, shift, ctrl+alt, ctrl+alt+shift, [caps vs ncaps?] + // Currently, we go in this order so the 102nd key works. But this is not ideal for keyboards without 102nd key: // I4651 + // it catches only the first key that matches a given rule, but multiple keys may match that rule. This is particularly + // evident for the 102nd key on UK, for example, where \ can be generated with VK_OEM_102 or AltGr+VK_QUOTE. + // For now, we get the least shifted version, which is hopefully adequate. + + for(int j = 0; VKShiftState[j] != 0xFFFF; j++) { // I4651 + // Go through each possible key on the keyboard + for(int i = 0; VKMap[i]; i++) { // I4651 + UINT vkUnderlying = VKUSToVKUnderlyingLayout(VKMap[i]); + + WCHAR ch = CharFromVK(vkUnderlying, VKShiftState[j], &DeadKey); + + //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); + + if(bDeadkeyConversion) { // I4552 + if(ch == 0xFFFF) { + ch = DeadKey; + } + } + + switch(ch) { + case 0x0000: break; + case 0xFFFF: ConvertDeadkey(kbd, VKMap[i], VKShiftState[j], DeadKey); break; + default: TranslateKeyboard(kbd, VKMap[i], VKShiftState[j], ch); + } + + // + } + } + + ReportUnconvertedKeyboardRules(kbd); + + if(!ImportRules(kbid, kbd, &FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 + return FALSE; + } + + return TRUE; +} + +void LogError(PWSTR fmt, ...) { + WCHAR fmtbuf[256]; + + va_list vars; + va_start(vars, fmt); + _vsnwprintf_s(fmtbuf, _countof(fmtbuf), _TRUNCATE, fmt, vars); // I2248 // I3547 + fmtbuf[255] = 0; + _putws(fmtbuf); +} +*/ diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h new file mode 100644 index 0000000000..3b1e2abad1 --- /dev/null +++ b/linux/mcompile/keymap/mcompile.h @@ -0,0 +1,51 @@ +/* + Name: mcompile + Copyright: Copyright (C) 2003-2017 SIL International. + Documentation: + Description: + Create Date: 3 Aug 2014 + + Modified Date: 3 Aug 2014 + Authors: mcdurdin + Related Files: + Dependencies: + + Bugs: + Todo: + Notes: + History: 03 Aug 2014 - mcdurdin - I4353 - V9.0 - mnemonic layout recompiler mixes up deadkey rules + +*/ + + + +#include +#include "km_types.h" + +void LogError(PKMX_WCHART message, ...); + + +struct DeadkeyMapping { // I4353 + KMX_WCHART deadkey, dkid; + KMX_UINT shift; + KMX_WORD vk; +}; + +extern std::vector FDeadkeys; // I4353 + + +//--------------------old +/* +#include + +void LogError(PWSTR message, ...); + + +struct DeadkeyMapping { // I4353 + WCHAR deadkey, dkid; + UINT shift; + WORD vk; +}; + +extern std::vector FDeadkeys; // I4353 +*/ From b14ed774fb46ee22d297d326a3861ed752dcfa50 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 12 Jun 2023 14:49:26 +0200 Subject: [PATCH 021/327] feat(linux): mcompile new modules helpers --- linux/mcompile/keymap/helpers.cpp | 15 +++++++++++++++ linux/mcompile/keymap/helpers.h | 8 ++++++++ 2 files changed, 23 insertions(+) create mode 100644 linux/mcompile/keymap/helpers.cpp create mode 100644 linux/mcompile/keymap/helpers.h diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp new file mode 100644 index 0000000000..339c412f28 --- /dev/null +++ b/linux/mcompile/keymap/helpers.cpp @@ -0,0 +1,15 @@ +#pragma once +#include "keymap.h" +#include "helpers.h" + + +void check_avaiability_of_modules_(){ + std::cout << "\n*********************************************************************************************\n"; + if ( X_test == 0xFF1234 ) std::cout << "\t\t\t\t\t\treaching helpers was OK \n"; + if ( !dummytest_keymap() ) std::cout << "\treaching keymap was OK \n"; + if ( !dummytest_mc_kmx_file() ) std::cout << "\treaching mc_kmx_file was OK \n"; + if ( !dummytest_mc_Savekeyboard() ) std::cout << "reaching mc_Savekeyboard was OK \n"; + if ( KEYMANID_NONKEYMAN == 0xFFFFFFFF ) std::cout << "\t\t\t\t\t\treaching kmx_file was OK \n"; + if ( X_test == 0xFF1234 ) std::cout << "\t\t\t\t\t\treaching kmx_types was OK \n"; + std::cout << "*********************************************************************************************\n"; +} \ No newline at end of file diff --git a/linux/mcompile/keymap/helpers.h b/linux/mcompile/keymap/helpers.h new file mode 100644 index 0000000000..ca17b685ee --- /dev/null +++ b/linux/mcompile/keymap/helpers.h @@ -0,0 +1,8 @@ + +#pragma once +#include +#include "mc_savekeyboard.h" +#include "mc_kmxfile.h" +#include "mc_savekeyboard.h" + +void check_avaiability_of_modules_(); \ No newline at end of file From 49f833ada19d049fa5ee5f15ef793d7056aabaf9 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 12 Jun 2023 15:04:31 +0200 Subject: [PATCH 022/327] feat(linux): mcompile #include files to mcompile, comment out most old code, adapt meson.build to use more .cpp-files --- linux/mcompile/keymap/helpers.cpp | 1 - linux/mcompile/keymap/keymap.cpp | 470 ++++++++++++++++++++++ linux/mcompile/keymap/keymap.h | 80 +++- linux/mcompile/keymap/km_types.h | 2 +- linux/mcompile/keymap/mc_kmxfile.cpp | 8 +- linux/mcompile/keymap/mc_kmxfile.h | 5 +- linux/mcompile/keymap/mc_savekeyboard.cpp | 5 + linux/mcompile/keymap/mc_savekeyboard.h | 6 +- linux/mcompile/keymap/mcompile.cpp | 141 ++++++- linux/mcompile/keymap/mcompile.h | 2 +- linux/mcompile/keymap/meson.build | 28 +- 11 files changed, 735 insertions(+), 13 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 339c412f28..e726d1b315 100644 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -1,4 +1,3 @@ -#pragma once #include "keymap.h" #include "helpers.h" diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 397be17f6c..a2c6747131 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -1,5 +1,10 @@ #include "keymap.h" +int dummytest_keymap(){ + std::cout<< " dummytest_keymap is available\t"; + return 0; + } + /* static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) { @@ -20,7 +25,471 @@ static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) g_free(maps); } */ +/* +void write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { + // ? CHECK if ran OK-> return 0/1 + std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; + const char* path = FullPathName.c_str(); + FILE* fp = fopen((path), "r"); + if ( !fp) + printf("could not open file!"); + + // create 1D-vector of the complete line + v_str_1D Vector_completeUS; + CreateCompleteRow_US(Vector_completeUS,fp , text, language); + + // split contents of 1D Vector to 3D vector + Split_US_To_3D_Vector( vec,Vector_completeUS); + + printf("+++++++ dimensions of Vector after write_US_ToVector\t\t %li..%li..%li\n", vec.size(), vec[0].size(),vec[0][0].size()); + fclose(fp); +} + +void CreateCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, std::string language) { + // in the Configuration file we find the appopriate paragraph between "xkb_symbol " and the next xkb_symbol + // and then copy all rows starting with "key <" to a v1D-Vector + + // ? CHECK if ran OK-> return 0/1 + int buffer_size = 512; + char buffer[buffer_size]; + bool print_OK = false; + const char* key = "key <"; + std::string str_txt(text); + std::string xbk_mark = "xkb_symbol"; + // TODO define folder to store File in + std::ofstream KeyboardFile("File_" + language + ".txt"); + + printf("Keyboard %s\n", text); + KeyboardFile << "Keyboard" << text << "\n"; + + if (fp) { + while (fgets(buffer, buffer_size, fp) != NULL) { + std::string str_buf(buffer); + + // stop when finding the mark xkb_symbol + if (std::string(str_buf).find(xbk_mark) != std::string::npos) + print_OK = false; + + // start when finding the mark xkb_symbol + correct layout + if ((std::string(str_buf).find(str_txt) != std::string::npos)) + print_OK = true; + + // as long as we are in the same xkb_symbol layout block and find "key <" we push the whole line into a 1D-vector + if ((print_OK) && (std::string(str_buf).find(key) != std::string::npos)) { + printf("%s", buffer); + complete_List.push_back(buffer); + KeyboardFile << buffer; + } + } + } + printf("-°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° \n"); +} + +void Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList) { + // 1: take the whole line of the 1D-Vector and remove unwanted characters. + // 2: seperate the name e.g. key and the shiftstates + // 3: push Names/Shiftstates to shift_states and then shiftstates to All_US, our 3D-Vector holding all Elements + + // ? CHECK if ran OK-> return 0/1 + std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; + char split_bracel = '{'; + char split_char_komma = ','; + std::string empty = "--"; + v_str_1D tokens; + v_str_2D shift_states; + + // go through the whole vector + for (int k = 0; k < (int)completeList.size() - 1; k++) { + + // remove all unwanted char + for (int i = 0; i < (int) delim.size(); i++) { + completeList[k].erase(remove(completeList[k].begin(), completeList[k].end(), delim[i]), completeList[k].end()); + } + + // only lines with ("key<.. are of interest + if (completeList[k].find("key<") != std::string::npos) { + + //split off the key names + std::istringstream split1(completeList[k]); + for (std::string each; std::getline(split1, each, split_bracel); tokens.push_back(each)); + + // replace keys names with number ( with 29,...) + + // ? CHECK if ran OK-> return 0/1 + int Keycde = replace_PosKey_with_Keycode(tokens[0]); + tokens[0] = std::to_string(Keycde); + + // seperate rest of the vector to its elements and push to 'tokens' + std::istringstream split(tokens[1]); + tokens.pop_back(); + for (std::string each; std::getline(split, each, split_char_komma); tokens.push_back(each)); + //printf("### 5 Split_US_To_3D_Vector: tokens: size:%li...tokens[0]-[4]:-name:%s\tShiftstates:%s--%s--%s--%s---.\n", tokens.size(),tokens[0].c_str(),tokens[1].c_str(),tokens[2].c_str(),tokens[3].c_str(),tokens[4].c_str()); + + // at the moment we only use the first 2 shiftstates (non-shift+shift) so get rid of all others + int surplus = tokens.size() - shift_state_count -1; + for( int j=0; j < surplus;j++) { + tokens.pop_back(); + } + + // now push result to shift_states + shift_states.push_back(tokens); + tokens.clear(); + } + } + all_US.push_back(shift_states); + + // ? CHECK if ran OK, vector size is correct -> return 0/1 + //printf("### 6 Split_US_To_3D_clearVector %li..%li..%li\n", all_US.size(), all_US[0].size(),all_US[0][0].size()); +} + +int replace_PosKey_with_Keycode(std::string in) { + int out=0; + if ( in == "key") out = 49; //correct ??? + else if ( in == "key") out = 10; + else if ( in == "key") out = 11; + else if ( in == "key") out = 12; + else if ( in == "key") out = 13; + else if ( in == "key") out = 14; + else if ( in == "key") out = 15; + else if ( in == "key") out = 16; + else if ( in == "key") out = 17; + else if ( in == "key") out = 18; + else if ( in == "key") out = 19; + else if ( in == "key") out = 20; + else if ( in == "key") out = 21; + + else if ( in == "key") out = 24; + else if ( in == "key") out = 25; + else if ( in == "key") out = 26; + else if ( in == "key") out = 27; + else if ( in == "key") out = 28; + else if ( in == "key") out = 29; + else if ( in == "key") out = 30; + else if ( in == "key") out = 31; + else if ( in == "key") out = 32; + else if ( in == "key") out = 33; + else if ( in == "key") out = 34; + else if ( in == "key") out = 35; + + else if ( in == "key") out = 38; + else if ( in == "key") out = 39; + else if ( in == "key") out = 40; + else if ( in == "key") out = 41; + else if ( in == "key") out = 42; + else if ( in == "key") out = 43; + else if ( in == "key") out = 44; + else if ( in == "key") out = 45; + else if ( in == "key") out = 46; + else if ( in == "key") out = 47; + else if ( in == "key") out = 48; + else if ( in == "key") out = 49; + + else if ( in == "key") out = 52; + else if ( in == "key") out = 53; + else if ( in == "key") out = 54; + else if ( in == "key") out = 55; + else if ( in == "key") out = 56; + else if ( in == "key") out = 57; + else if ( in == "key") out = 58; + else if ( in == "key") out = 59; + else if ( in == "key") out = 60; + else if ( in == "key") out = 61; + else if ( in == "key") out = 62; //correct ??? + else if ( in == "key") out = 51; //correct ??? + return out; +} + +void append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap) { + + // create a 2D vector all fill0ed with "--" and push to 3D-Vector + // ? CHECK if ran OK-> return 0/1 + v_str_2D Other_Vector2D = create_empty_2D(All_Vector[0].size(),All_Vector[0][0].size()); + All_Vector.push_back(Other_Vector2D); + + printf("+++++++ dimensions of Vector after append_other_ToVector\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); + + for(int i =1; i< (int) All_Vector[1].size()-1;i++) + { + // get key name US stored in [0][i][0] and copy to name in other-block[1][i][0] + All_Vector[1][i][0] = All_Vector[0][i][0]; + + // write this value to 3D- Vector + All_Vector[1][i][0+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),0); //shift state: unshifted:0 + All_Vector[1][i][1+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),1); //shift state: shifted:1 + //printf("Keycodes US->Other: %d(US): %s %s ---- (other):%s, %s, %s \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str(),All_Vector[1][i][2].c_str(),All_Vector[1][i][3].c_str()); + } + // ? CHECK if ran OK, vector size is correct -> return 0/1 +} + +v_str_2D create_empty_2D( int dim_rows,int dim_shifts) +{ + std::string empty = "--"; + v_str_1D shifts; + v_str_2D all; + + for ( int i=0; i< dim_rows;i++) { + for ( int j=0; j< dim_shifts;j++) { + shifts.push_back(empty); + } + all.push_back(shifts); + shifts.clear(); + } + //printf("+++++++ dimensions of Vector after create_empty_2D\t\t %li..%li..%li\n", all.size(), all[0].size(),all[1].size()); + return all; +} + +int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { + GdkKeymapKey *maps; + guint *keyvals; + gint count; + int out; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return 0; + //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + // return 0; + + if (!(shift_state_pos < count)) + return 0; + + out = keyvals[shift_state_pos]; + + g_free(keyvals); + g_free(maps); + return out; +} + +void extract_difference( v_str_3D &All_Vector) +{ + // ? CHECK if ran OK-> return 0/1 + // TODO define which Folder; find better name + std::ofstream Map_File("Map_US.txt"); + std::string diff =" "; + + printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); + std::cout << "Nr of \n" ; + std::cout << "Key: " << "\t Character US (no shift) " << " Character US (shift) "<< "\t\tCharacter other (no shift)" << "\tCharacter other (shift) difference \n" ; + printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); + + Map_File <<"--------------------------------------------------------------------------------------------------------------------------------------------\n"; + Map_File << "Nr of \n" ; + Map_File << "Key: " << "\t Character US (no shift) " << " Character US (shift) "<< "\t\tCharacter other (no shift)" << "\tCharacter other (shift) difference \n" ; + Map_File <<"--------------------------------------------------------------------------------------------------------------------------------------------\n"; + + for ( int k=0; k<(int)All_Vector[0].size()-1; k++) { + if (All_Vector[0][k][1] == All_Vector[1][k][1]) + diff =" "; + else + diff =" *** "; + // ? CHECK if index exists + std::cout << All_Vector[0][k][0] << "\t " <<+(*(All_Vector[0][k][1].c_str()))<< "\t("<< All_Vector[0][k][1] <<")"< Other: "<< std::setw(5)< Other: (" << in << ": no match)\n"; + return "-"; +} + +std::string get_US_Char_FromOther(std::string in , v_str_3D &All_Vector) { + std::string diff; + // find correct row of char in other + for( int i=0; i< (int)All_Vector[1].size()-1;i++) { + for( int j=0; j< (int)All_Vector[1][0].size()-1;j++) { + if ( All_Vector[1][i][j] == in ) { + if ( All_Vector[0][i][j] != All_Vector[1][i][j]) + diff =" ** "; + // ? CHECK if Index exists + std::cout << "Other -> US: "<< std::setw(5)< US: (" << in << ": no match)\n"; + return "-"; + } + +std::string getKeyNrOf_USChar(std::string in , v_str_3D &All_Vector) { + // find correct row of char in US + for( int i=0; i< (int)All_Vector[0].size()-1;i++) { + for( int j=0; j< (int)All_Vector[0][0].size()-1;j++) { + if ( All_Vector[0][i][j] == in ) { + // ? CHECK if index exists + std::cout << "KeyNr of US char: \t"<< All_Vector[0][i][j] << " -> " << All_Vector[0][i][0] <<"\n"; + return All_Vector[0][i][0] ; + } + } + } + return "-"; +} + +std::string getKeyNrOf_OtherChar(std::string in , v_str_3D &All_Vector) { + // find correct row of char in US + for( int i=0; i< (int)All_Vector[1].size()-1;i++) { + for( int j=0; j< (int)All_Vector[1][0].size()-1;j++) { + if ( All_Vector[1][i][j] == in ) { + // ? CHECK if index exists + std::cout << "KeyNr of Other char : \t"<< All_Vector[1][i][j] << " -> " << All_Vector[1][i][0] <<"\n"; + return All_Vector[1][i][0] ; + } + } + } + return "-"; +} + +bool test(v_str_3D &V) { +// ? CHECK if index exists + printf("\n+++++++++ print some characters of US and Other +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + + for ( int k=13; k<43; k++) { + std::cout << " row 1 (US)......" << V[0][k][0]<< ".." << V[0][k][1]<< ".."<< V[0][k][2]<< ".." << V[0][k][3]<< ".." << V[0][k][4]<< "..\n" ; + if (V.size()>1) + std::cout << " row 1 (Other).."<< V[1][k][0]<< ".." << V[1][k][1]<< ".."<< V[1][k][2]<< ".." << V[1][k][3]<< ".." << V[1][k][4]<< "..\n" ; + } + printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + return true; +} + +void test_in_out(v_str_3D &All_Vector) { +std::string diff; + printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); + //checks mapping between US and other + std::string a = get_Other_Char_FromUS( "z", All_Vector); + std::string aa = get_Other_Char_FromUS( "Z", All_Vector); + std::string aaa = get_Other_Char_FromUS( "y", All_Vector); + std::string aaaa = get_Other_Char_FromUS( "Y", All_Vector); + + std::string b = get_US_Char_FromOther( "z", All_Vector); + std::string bb = get_US_Char_FromOther( "Z", All_Vector); + std::string bbb = get_US_Char_FromOther( "y", All_Vector); + std::string bbbb = get_US_Char_FromOther( "Y", All_Vector); + + std::string c = getKeyNrOf_OtherChar( "z", All_Vector); + std::string cc = getKeyNrOf_OtherChar( "Z", All_Vector); + std::string ccc = getKeyNrOf_OtherChar( "y", All_Vector); + std::string cccc = getKeyNrOf_OtherChar( "Y", All_Vector); + + std::string d = getKeyNrOf_USChar( "z", All_Vector); + std::string dd = getKeyNrOf_USChar( "Z", All_Vector); + std::string ddd = getKeyNrOf_USChar( "y", All_Vector); + std::string dddd = getKeyNrOf_USChar( "Y", All_Vector); + + std::cout << "get_Other_Char_FromUS z-Z-y-Y: " << ".." << a<< ".." < return 0/1 + printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); + for ( int i=0; i< (int)All_Vector[0].size();i++) { + out =get_Other_Char_FromUS(All_Vector[0][i][shiftstate], All_Vector); + } +} + +void print_simple_map_Other(v_str_3D &All_Vector, int shiftstate){ + std::string out, diff; + // ? CHECK if ran OK-> return 0/1 + printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); + for ( int i=0; i< (int)All_Vector[0].size();i++) { + out = get_US_Char_FromOther(All_Vector[0][i][shiftstate], All_Vector); + } +} + +void test_specific_Characters(v_str_3D &All_Vector){ + printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); + v_str_1D in {"a", "b", "m", "w", "x", "y", "z"}; + std::string out; + for( int i=0; i< (int) in.size()-1; i++) { + out = get_Other_Char_FromUS(in[i], All_Vector); + } +} + + +//-------------------------------------- +int main(gint argc, gchar *argv[]) +{ + gdk_init(&argc, &argv); + GdkDisplay *display = gdk_display_get_default(); + if (!display) { + printf("ERROR: can't get display\n"); + return 1; + } + GdkKeymap *keymap = gdk_keymap_get_for_display(display); + if (!keymap) { + printf("ERROR: Can't get keymap\n"); + gdk_display_close(display); + return 2; + } + + // write content of xkb_symbols to 3D Vector + // I assume we use Keyboard US basic as base + std::string US_language = "us"; + const char* text_us = "xkb_symbols \"basic\""; + + v_str_3D All_Vector; + write_US_ToVector(All_Vector,US_language, text_us); + //test(All_Vector); + + // add contents of other keyboard to vector + append_other_ToVector(All_Vector,keymap); + //test(All_Vector); + + extract_difference(All_Vector); + //test_in_out(All_Vector); + + //print_simple_map_US(All_Vector,1); // 1 = non-shift + //print_simple_map_Other(All_Vector,1); // 1 = non-shift + test_specific_Characters(All_Vector); + gdk_display_close(display); + + printf("°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° end\n"); + return 0; +} +*/ + +// old ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +/* +static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) +{ + GdkKeymapKey *maps; + guint *keyvals; + gint count; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return; + + for (int i = 0; i < count; i++) { + if (maps[i].level > 0 || maps[i].group > 1) + continue; + printf(" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); + } + + g_free(keyvals); + g_free(maps); +} +*/ +/* void write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { // ? CHECK if ran OK-> return 0/1 std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; @@ -461,3 +930,4 @@ int main(gint argc, gchar *argv[]) printf("°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° end\n"); return 0; } +*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index cfbd5dc1df..454ceca593 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -5,6 +5,25 @@ #include #include +#include +#include +#include +#include +#include +#include +#include "mc_kmxfile.h" +#include "kmx_file.h" +#include "mc_savekeyboard.h" +#include "helpers.h" + + +int dummytest_keymap(); + +/* +#include +#include +#include + #include #include #include @@ -64,4 +83,63 @@ void test_in_out(v_str_3D &All_Vector); // testing of Vector contents ( first row of US and Other) bool test(v_str_3D &V); // writing out mapping of some characters: a,b,m,w,x,y,z -void test_specific_Characters(v_str_3D &All_Vector); +void test_specific_Characters(v_str_3D &All_Vector);*/ + + + +// old ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +/* + +#include "mc_kmxfile.h" +#include "mc_savekeyboard.h" + +typedef std::vector v_str_1D; +typedef std::vector > v_str_2D; +typedef std::vector > > v_str_3D; + +int shift_state_count = 2; // use shiftstate : no shift, shift + +// read configuration file, split and write to 3D-Vector (Data for US on [0][ ][ ] ) +void write_US_ToVector(v_str_3D &vec, std::string language, const char *text); + +// 1. step: read complete Row of Configuration file US +void CreateCompleteRow_US(v_str_1D &complete_List, FILE *fpp, const char *text, std::string language); + +// 2nd step: write contents to 3D vector +void Split_US_To_3D_Vector(v_str_3D &all_US, v_str_1D completeList); + +// replace Name of Key (e.g. ) wih Keycode ( e.g. 15 ) +int replace_PosKey_with_Keycode(std::string in); + +// append characters using GDK to 3D-Vector (Data for Other Language on [1][ ][ ] ) +void append_other_ToVector(v_str_3D &All_Vector, GdkKeymap *keymap); + +// create an empty 2D vector containing "--" in all fields +v_str_2D create_empty_2D(int dim_rows, int dim_shifts); + +// find Keyvals to fill into 2D-Vector of Other Language +int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos); + +// print both sets of characters (US and OtherLanguage) to console and file for comparison +void extract_difference(v_str_3D &All_Vector); + +// get mapped key from Other (Other->US) +std::string get_Other_Char_FromUS(std::string in, v_str_3D &All_Vector); +// get mapped key from US->Other (US->Other) +std::string get_US_Char_FromOther(std::string in, v_str_3D &All_Vector); +// get KeyNr from US +std::string getKeyNrOf_USChar(std::string in, v_str_3D &All_Vector); +// get KeyNr from Other +std::string getKeyNrOf_OtherChar(std::string in, v_str_3D &All_Vector); + +// for testing/debugging - may be deleted later +// prints out a 1:1 mapping US->Other +void print_simple_map_US(v_str_3D &All_Vector, int shiftstate); +// prints out a 1:1 mapping Other->US +void print_simple_map_Other(v_str_3D &All_Vector, int shiftstate); +// test of above functions (character mapping US <-> Other; KeyNr <-> CHaracter) +void test_in_out(v_str_3D &All_Vector); +// testing of Vector contents ( first row of US and Other) +bool test(v_str_3D &V); +// writing out mapping of some characters: a,b,m,w,x,y,z +void test_specific_Characters(v_str_3D &All_Vector);*/ diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index 5e6c25e813..da12c302c0 100644 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#define X_test 0xFF1234 /* #if defined(_WIN32) || defined(_WIN64) diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index e0a20c34ac..c61f8b1ec1 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -1,6 +1,12 @@ #include "mc_kmxfile.h" +int dummytest_mc_kmx_file(){ + std::cout<< " dummytest_mc_kmx_file is available\t"; + return 0; + } + +/* KMX_DWORD TEST2; static KMX_BOOL LoadKeyboardFile(LPKMX_STR fileName, LPKEYBOARD *lpKeyboard); @@ -8,7 +14,7 @@ static KMX_BOOL LoadKeyboardFile(LPKMX_STR fileName, LPKEYBOARD *lpKeyboard); KMX_BOOL VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz); LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); - +*/ /*void Err(wchar_t *s) { LogError(L"LoadKeyboard: %s, last error = %d\n", s, GetLastError()); }*/ diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 2d82db90b1..071ac7ee87 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -1,7 +1,10 @@ #pragma once #include "km_types.h" -KMX_DWORD TEST; +#include // _S2 can be removed later + +int dummytest_mc_kmx_file(); +//+++++++++++++++++++++++++++++++++++ #ifndef _KMXFILE_H #define _KMXFILE_H diff --git a/linux/mcompile/keymap/mc_savekeyboard.cpp b/linux/mcompile/keymap/mc_savekeyboard.cpp index 497f2d4379..0c2ed5cad7 100644 --- a/linux/mcompile/keymap/mc_savekeyboard.cpp +++ b/linux/mcompile/keymap/mc_savekeyboard.cpp @@ -1,6 +1,11 @@ #include "mc_savekeyboard.h" +int dummytest_mc_Savekeyboard(){ + std::cout<< " dummytest_mc_Savekeyboard is available\t"; + return 0; + } + //+++++++++++++++++++++++++++++++++++++++++ /*BOOL SaveKeyboard(LPKEYBOARD kbd, PWSTR filename) { HANDLE hOutfile = CreateFile(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); if(hOutfile == INVALID_HANDLE_VALUE) { diff --git a/linux/mcompile/keymap/mc_savekeyboard.h b/linux/mcompile/keymap/mc_savekeyboard.h index 7ac15f4ff1..da612e787d 100644 --- a/linux/mcompile/keymap/mc_savekeyboard.h +++ b/linux/mcompile/keymap/mc_savekeyboard.h @@ -1,7 +1,11 @@ #pragma once #include "km_types.h" -KMX_DWORD TEST3; + +#include +int dummytest_mc_Savekeyboard(); + + // this file is all new _S2 //#include "../../../common/include/km_types.h" diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index b990f02806..9ff129b6aa 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -22,13 +22,150 @@ 06 Feb 2015 - mcdurdin - I4552 - V9.0 - Add mnemonic recompile option to ignore deadkeys 08 Apr 2015 - mcdurdin - I4651 - V9.0 - Mnemonic layout recompiler maps AltGr+VK_BKSLASH rather than VK_OEM_102 */ + +#include "mcompile.h" +#include "helpers.h" + + +int main(gint argc, wchar_t *argv[]) +{ //---------------------------------------- + +// test if all cpps are acccessible: can be removed +check_avaiability_of_modules_(); //_S2 + + if(argc < 3 || (argc < 5 && wcscmp(argv[1], L"-u") != 0)) { // I4273 + printf( + "Usage: mcompile -u infile.kmx outfile.kmx\n" + " mcompile [-d] infile.kmx kbdfile.dll kbid outfile.kmx\n" + " With -u parameter, converts keyboard from ANSI to Unicode\n" + " Otherwise, mcompile converts a Keyman mnemonic layout to a\n" + " positional one based on the Windows keyboard\n" + " layout file given by kbdfile.dll\n\n" + " kbid should be a hexadecimal number e.g. 409 for US English\n" + " -d convert deadkeys to plain keys\n"); // I4552 + + return 1; + } +//----------------------------- + /* if(wcscmp(argv[1], L"-u") == 0) { // I4273 + wchar_t *infile = argv[2], *outfile = argv[3]; + + LPKEYBOARD kmxfile; + + if(!LoadKeyboard(infile, &kmxfile)) { + LogError(L"Failed to load keyboard (%d)", GetLastError()); + return 3; + } + + if(ConvertKeyboardToUnicode(kmxfile)) { + SaveKeyboard(kmxfile, outfile); + } + + //DeleteReallocatedPointers(kmxfile); :TODO + delete[] kmxfile; + + return 0; // I4279 + }*/ +/*//----------------------------- + int bDeadkeyConversion = wcscmp(argv[1], L"-d") == 0; // I4552 + int n = (bDeadkeyConversion ? 2 : 1); + + wchar_t *infile = argv[n], *indll = argv[n+1], *kbid = argv[n+2], *outfile = argv[n+3]; + + wprintf(L"mcompile%ls \"%ls\" \"%ls\" \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d":L"", infile, indll, kbid, outfile); // I4174 + + // 1. Load the keyman keyboard file + + // 2. For each key on the system layout, determine its output character and perform a + // 1-1 replacement on the keyman keyboard of that character with the base VK + shift + // state. This fixup will transform the char to a vk, which will avoid any issues + // with the key. + // + // --> deadkeys we will attack after the POC + // + // For each deadkey, we need to determine its possible outputs. Then we generate a VK + // rule for that deadkey, e.g. [K_LBRKT] > dk(c101) + // + // Next, update each rule that references the output from that deadkey to add an extra + // context deadkey at the end of the context match, e.g. 'a' dk(c101) + [K_SPACE] > 'b'. + // This will require a memory layout change for the .kmx file, plus fixups on the + // context+output index offsets + // + // --> virtual character keys + // + // [CTRL ' '] : we look at the character, and replace it in the same way, but merely + // switch the shift state from the VIRTUALCHARKEY to VIRTUALKEY, without changing any + // other properties of the key. + // + + // 3. Write the new keyman keyboard file + + if(!LoadNewLibrary(indll)) { + LogError(L"Failed to load keyboard DLL (%d)", GetLastError()); + return 2; + } + + LPKEYBOARD kmxfile; + + if(!LoadKeyboard(infile, &kmxfile)) { + LogError(L"Failed to load keyboard (%d)", GetLastError()); + return 3; + } + + if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552 + SaveKeyboard(kmxfile, outfile); + } + + //DeleteReallocatedPointers(kmxfile); :TODO + delete kmxfile; +VM + return 0; + +*/ + + //------------------------------------ + //LoadKeyboard(); + //int out = run_DoConvert_Part1_getMap(argc,argv); + //run_DoConvert_Part2_TranslateKeyboard(); + //SaveKeyboard(); +printf("°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° end\n"); + + return 0 ; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + // // m-to-p.cpp : Defines the entry point for the console application. // // Note: this program deliberately leaks memory as it has a very short life cycle and managing the memory allocations // for the subcomponents of the compiled keyboard is an unnecessary optimisation. Just so you know. // - +/* #include "pch.h" #include @@ -474,7 +611,7 @@ void LogError(PWSTR fmt, ...) { fmtbuf[255] = 0; _putws(fmtbuf); } - +*/ //---------old------------------------------------------- /*#include "pch.h" #include diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 3b1e2abad1..1c367fc406 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -20,7 +20,7 @@ #include -#include "km_types.h" +#include "keymap.h" void LogError(PKMX_WCHART message, ...); diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index eb1e03783b..82eac438cf 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -1,11 +1,31 @@ -project('keymap', 'c', 'cpp', +project('mcompile', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') gtk = dependency('gtk+-3.0', version: '>= 2.4') +cpp_files = files( + 'keymap.cpp', + 'mcompile.cpp', + 'mc_kmxfile.cpp', + 'mc_savekeyboard.cpp', + 'helpers.cpp', +) -keymap = executable( - 'keymap', - sources: ['keymap.cpp'], +mcompile = executable( + 'mcompile', + sources: [cpp_files], dependencies: [gtk] ) + +# old +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +#project('keymap', 'c', 'cpp', +# license: 'MIT', +# meson_version: '>=1.0') + +#gtk = dependency('gtk+-3.0', version: '>= 2.4') + +#keymap = executable( +# 'keymap', +# sources: ['keymap.cpp'], +# dependencies: [gtk] +#) From 0719d5ad2f2b812b97448305e4f8d154774d5e39 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 12 Jun 2023 16:37:43 +0200 Subject: [PATCH 023/327] feat(linux): mcompile make int shift_state_count static --- linux/mcompile/keymap/keymap.h | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 454ceca593..7190312a41 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -19,27 +19,14 @@ int dummytest_keymap(); -/* -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "mc_kmxfile.h" -#include "mc_savekeyboard.h" typedef std::vector v_str_1D; typedef std::vector > v_str_2D; typedef std::vector > > v_str_3D; -int shift_state_count = 2; // use shiftstate : no shift, shift +static int shift_state_count = 2; // use shiftstate : no shift, shift +/* // read configuration file, split and write to 3D-Vector (Data for US on [0][ ][ ] ) void write_US_ToVector(v_str_3D &vec, std::string language, const char *text); From 7eb55796eb490a120e9f2ede69fb3930399c4cc9 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 12 Jun 2023 20:37:00 +0200 Subject: [PATCH 024/327] feat(linux): mcompile add some helper functions, update readme --- linux/mcompile/keymap/README.md | 15 +++++++++++++-- linux/mcompile/keymap/helpers.cpp | 13 +++++++++++++ linux/mcompile/keymap/helpers.h | 8 +++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index a40b7d4fef..8f77d2fb54 100644 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -13,10 +13,21 @@ TODO check Keycode of TLDE, BKSL, LSGT TODO remove unnecessary printf/cout TODO path for xkb/symbols as compile time option in meson TODO append_other_ToVector: ensure shift states of GetKeyvalsFromKeymap are not out of range -TODO check how many/which shift states we use ( at the moment we read all shiftstate-columns of US but then use only 2 colums - (non-shift + shift) then use as many colums for Other ) +TODO check how many/which shift states we use ( at the moment we read all shiftstate-columns of US but then use only 2 colums (non-shift + shift) then use as many colums for Other ) TODO define folder to store File_US.txt" in and find better name TODO get rid of GTK functions that are deprecated and use X11 instead TODO retrieve name of Other keyboard and use appropriate name instead of "Other" +TODO change keymap.cpp->main() to function() +TODO use/adapt TranslateKeyboard() to work on Linux/cross-platform +TODO use/adapt LoadKeyboard() to work on Linux/cross-platform +TODO use/adapt SaveKeyboard() to work on Linux/cross-platform +TODO include deadkeys +TODO use only a-z; no numbers,backsl,... +TODO mcompile.cpp: open mcompile -u - option +TODO replace GetLastError with SetError/AddCompileError/AddCompileWarning TODO ... + +//--------------------------- +TOASK is using string OK, or do we use char, wchar? +TOASK ... \ No newline at end of file diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index e726d1b315..4cc4456aa4 100644 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -11,4 +11,17 @@ void check_avaiability_of_modules_(){ if ( KEYMANID_NONKEYMAN == 0xFFFFFFFF ) std::cout << "\t\t\t\t\t\treaching kmx_file was OK \n"; if ( X_test == 0xFF1234 ) std::cout << "\t\t\t\t\t\treaching kmx_types was OK \n"; std::cout << "*********************************************************************************************\n"; +} + +void MyCout(std::string in, bool end, std::string pre ) { + if (end == true) + std::cout << pre << " " << in << " " << "\n"; + else + std::cout << pre << " " << in; +} + + +void DebugLog_S2(std::wstring txt, std::wstring fileName) { + + wprintf(txt.c_str(), fileName); } \ No newline at end of file diff --git a/linux/mcompile/keymap/helpers.h b/linux/mcompile/keymap/helpers.h index ca17b685ee..8339301e29 100644 --- a/linux/mcompile/keymap/helpers.h +++ b/linux/mcompile/keymap/helpers.h @@ -5,4 +5,10 @@ #include "mc_kmxfile.h" #include "mc_savekeyboard.h" -void check_avaiability_of_modules_(); \ No newline at end of file +void check_avaiability_of_modules_(); + +// My std::cout : writes pre-in ; 1 for end of line +void MyCout(std::string in, bool end, std::string pre = ""); + +//Just for now: wrote my oẃn DebugLog -TODO to be replaced +void DebugLog_S2(std::wstring txt, std::wstring fileName); \ No newline at end of file From b30594a2d48ed7f875969299671b7b592bfd5a52 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 13 Jun 2023 18:14:58 +0200 Subject: [PATCH 025/327] feat(linux): mcompile keymap check for errors; filter function for characters to use --- linux/mcompile/keymap/keymap.cpp | 234 +++++++++++++++++++------------ linux/mcompile/keymap/keymap.h | 46 ++++-- 2 files changed, 185 insertions(+), 95 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index a2c6747131..8040310cf8 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -1,10 +1,5 @@ #include "keymap.h" -int dummytest_keymap(){ - std::cout<< " dummytest_keymap is available\t"; - return 0; - } - /* static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) { @@ -25,32 +20,39 @@ static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) g_free(maps); } */ -/* -void write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { - // ? CHECK if ran OK-> return 0/1 + +bool write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; const char* path = FullPathName.c_str(); FILE* fp = fopen((path), "r"); - if ( !fp) + if ( !fp) { printf("could not open file!"); + return 1; + } // create 1D-vector of the complete line v_str_1D Vector_completeUS; - CreateCompleteRow_US(Vector_completeUS,fp , text, language); + if( CreateCompleteRow_US(Vector_completeUS,fp , text, language)) { + printf("ERROR: can't Create complete row US \n"); + return 1; + } // split contents of 1D Vector to 3D vector - Split_US_To_3D_Vector( vec,Vector_completeUS); + if( Split_US_To_3D_Vector( vec,Vector_completeUS)) { + printf("ERROR: can't Split USto 3D-Vector \n"); + return 1; + } printf("+++++++ dimensions of Vector after write_US_ToVector\t\t %li..%li..%li\n", vec.size(), vec[0].size(),vec[0][0].size()); fclose(fp); + return 0; } -void CreateCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, std::string language) { +bool CreateCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, std::string language) { // in the Configuration file we find the appopriate paragraph between "xkb_symbol " and the next xkb_symbol // and then copy all rows starting with "key <" to a v1D-Vector - // ? CHECK if ran OK-> return 0/1 int buffer_size = 512; char buffer[buffer_size]; bool print_OK = false; @@ -83,15 +85,20 @@ void CreateCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, } } } + + if (complete_List.size() <1) { + printf("ERROR: can't Create complete row US \n"); + return 1; + } printf("-°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° \n"); + return 0; } -void Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList) { +bool Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList) { // 1: take the whole line of the 1D-Vector and remove unwanted characters. - // 2: seperate the name e.g. key and the shiftstates + // 2: seperate the name e.g. key from the shiftstates // 3: push Names/Shiftstates to shift_states and then shiftstates to All_US, our 3D-Vector holding all Elements - // ? CHECK if ran OK-> return 0/1 std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; char split_bracel = '{'; char split_char_komma = ','; @@ -115,37 +122,58 @@ void Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList) { for (std::string each; std::getline(split1, each, split_bracel); tokens.push_back(each)); // replace keys names with number ( with 29,...) - - // ? CHECK if ran OK-> return 0/1 int Keycde = replace_PosKey_with_Keycode(tokens[0]); tokens[0] = std::to_string(Keycde); - // seperate rest of the vector to its elements and push to 'tokens' - std::istringstream split(tokens[1]); - tokens.pop_back(); - for (std::string each; std::getline(split, each, split_char_komma); tokens.push_back(each)); - //printf("### 5 Split_US_To_3D_Vector: tokens: size:%li...tokens[0]-[4]:-name:%s\tShiftstates:%s--%s--%s--%s---.\n", tokens.size(),tokens[0].c_str(),tokens[1].c_str(),tokens[2].c_str(),tokens[3].c_str(),tokens[4].c_str()); + // we use characters a-z, A_Z only at the moment + if (foundCharacterInList(tokens[0])) { - // at the moment we only use the first 2 shiftstates (non-shift+shift) so get rid of all others - int surplus = tokens.size() - shift_state_count -1; - for( int j=0; j < surplus;j++) { + // seperate rest of the vector to its elements and push to 'tokens' + std::istringstream split(tokens[1]); tokens.pop_back(); - } - // now push result to shift_states - shift_states.push_back(tokens); + for (std::string each; std::getline(split, each, split_char_komma); tokens.push_back(each)); + //printf("### 5 Split_US_To_3D_Vector: tokens: size:%li...tokens[0]-[4]:-name:%s\tShiftstates:%s--%s--%s--%s---.\n", tokens.size(),tokens[0].c_str(),tokens[1].c_str(),tokens[2].c_str(),tokens[3].c_str(),tokens[4].c_str()); + + // at the moment we only use the first 2 shiftstates (non-shift+shift) so get rid of all others + int surplus = tokens.size() - shift_state_count -1; + for( int j=0; j < surplus;j++) { + tokens.pop_back(); + } + + // now push result to shift_states + shift_states.push_back(tokens); + } tokens.clear(); } } all_US.push_back(shift_states); - // ? CHECK if ran OK, vector size is correct -> return 0/1 + if ( all_US.size() ==0) { + printf("ERROR: Can't split US to 3D-Vector\n"); + return 1; + } //printf("### 6 Split_US_To_3D_clearVector %li..%li..%li\n", all_US.size(), all_US[0].size(),all_US[0][0].size()); + return 0; +} + +bool foundCharacterInList(std::string tok) { + //TOASK Do we need more and which? + //US keys: Q W E R T Y U I O P A S D F G H J K L : Z X C V B N M + v_str_1D Keysyms { "24","25","26","27","28","29","30","31","32","33","38","39","40","41","42","43","44","45","46","47","52","53","54","55","56","57","58"}; + + for ( int i =0; i< (int) Keysyms.size();i++) { + std::cout << "foundCharacterInList" << i <<"\n"; + if( tok == Keysyms[i]) { + return true; + } + } + return false; } int replace_PosKey_with_Keycode(std::string in) { int out=0; - if ( in == "key") out = 49; //correct ??? + if ( in == "key") out = 49; // TOASK correct ??? else if ( in == "key") out = 10; else if ( in == "key") out = 11; else if ( in == "key") out = 12; @@ -195,35 +223,45 @@ int replace_PosKey_with_Keycode(std::string in) { else if ( in == "key") out = 59; else if ( in == "key") out = 60; else if ( in == "key") out = 61; - else if ( in == "key") out = 62; //correct ??? - else if ( in == "key") out = 51; //correct ??? + else if ( in == "key") out = 62; //TOASK correct ??? + else if ( in == "key") out = 51; //TOASK correct ??? return out; } -void append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap) { +bool append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap) { - // create a 2D vector all fill0ed with "--" and push to 3D-Vector - // ? CHECK if ran OK-> return 0/1 + // create a 2D vector all filled with "--" and push to 3D-Vector v_str_2D Other_Vector2D = create_empty_2D(All_Vector[0].size(),All_Vector[0][0].size()); - All_Vector.push_back(Other_Vector2D); + if (Other_Vector2D.size()==0) { + printf("ERROR: create empty 2D-Vector failed"); + return 1; + } + + All_Vector.push_back(Other_Vector2D); printf("+++++++ dimensions of Vector after append_other_ToVector\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); - for(int i =1; i< (int) All_Vector[1].size()-1;i++) - { + if (All_Vector.size()==0) { + printf("ERROR: creation of 3D-Vector failed"); + return 1; + } + + for(int i =0; i< (int) All_Vector[1].size();i++) { + // get key name US stored in [0][i][0] and copy to name in other-block[1][i][0] All_Vector[1][i][0] = All_Vector[0][i][0]; // write this value to 3D- Vector All_Vector[1][i][0+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),0); //shift state: unshifted:0 All_Vector[1][i][1+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),1); //shift state: shifted:1 - //printf("Keycodes US->Other: %d(US): %s %s ---- (other):%s, %s, %s \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str(),All_Vector[1][i][2].c_str(),All_Vector[1][i][3].c_str()); + + printf(" Keycodes US->Other: %d(US): %s %s ---- (other):%s, \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str()); } - // ? CHECK if ran OK, vector size is correct -> return 0/1 + + return 0; } -v_str_2D create_empty_2D( int dim_rows,int dim_shifts) -{ +v_str_2D create_empty_2D( int dim_rows,int dim_shifts) { std::string empty = "--"; v_str_1D shifts; v_str_2D all; @@ -235,7 +273,6 @@ v_str_2D create_empty_2D( int dim_rows,int dim_shifts) all.push_back(shifts); shifts.clear(); } - //printf("+++++++ dimensions of Vector after create_empty_2D\t\t %li..%li..%li\n", all.size(), all[0].size(),all[1].size()); return all; } @@ -260,9 +297,7 @@ int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) return out; } -void extract_difference( v_str_3D &All_Vector) -{ - // ? CHECK if ran OK-> return 0/1 +bool extract_difference( v_str_3D &All_Vector) { // TODO define which Folder; find better name std::ofstream Map_File("Map_US.txt"); std::string diff =" "; @@ -277,29 +312,37 @@ void extract_difference( v_str_3D &All_Vector) Map_File << "Key: " << "\t Character US (no shift) " << " Character US (shift) "<< "\t\tCharacter other (no shift)" << "\tCharacter other (shift) difference \n" ; Map_File <<"--------------------------------------------------------------------------------------------------------------------------------------------\n"; - for ( int k=0; k<(int)All_Vector[0].size()-1; k++) { + for ( int k=0; k<(int)All_Vector[0].size(); k++) { if (All_Vector[0][k][1] == All_Vector[1][k][1]) diff =" "; else diff =" *** "; - // ? CHECK if index exists + std::cout << All_Vector[0][k][0] << "\t " <<+(*(All_Vector[0][k][1].c_str()))<< "\t("<< All_Vector[0][k][1] <<")"< Other: "<< std::setw(5)< US: "<< std::setw(5)< " << All_Vector[0][i][0] <<"\n"; return All_Vector[0][i][0] ; } @@ -343,10 +384,9 @@ std::string getKeyNrOf_USChar(std::string in , v_str_3D &All_Vector) { std::string getKeyNrOf_OtherChar(std::string in , v_str_3D &All_Vector) { // find correct row of char in US - for( int i=0; i< (int)All_Vector[1].size()-1;i++) { - for( int j=0; j< (int)All_Vector[1][0].size()-1;j++) { + for( int i=0; i< (int)All_Vector[1].size();i++) { + for( int j=1; j< (int)All_Vector[1][0].size();j++) { if ( All_Vector[1][i][j] == in ) { - // ? CHECK if index exists std::cout << "KeyNr of Other char : \t"<< All_Vector[1][i][j] << " -> " << All_Vector[1][i][0] <<"\n"; return All_Vector[1][i][0] ; } @@ -356,15 +396,15 @@ std::string getKeyNrOf_OtherChar(std::string in , v_str_3D &All_Vector) { } bool test(v_str_3D &V) { -// ? CHECK if index exists + printf("+++++++ dimensions of Vector in test()\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); printf("\n+++++++++ print some characters of US and Other +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - for ( int k=13; k<43; k++) { - std::cout << " row 1 (US)......" << V[0][k][0]<< ".." << V[0][k][1]<< ".."<< V[0][k][2]<< ".." << V[0][k][3]<< ".." << V[0][k][4]<< "..\n" ; + for ( int k=0; k<(int)V[0].size(); k++) { + std::cout << " row 1 (US)......" << V[0][k][0]<< ".." << V[0][k][1]<< ".."<< "..\n" ; if (V.size()>1) - std::cout << " row 1 (Other).."<< V[1][k][0]<< ".." << V[1][k][1]<< ".."<< V[1][k][2]<< ".." << V[1][k][3]<< ".." << V[1][k][4]<< "..\n" ; + std::cout << " row 1 (Other).."<< V[1][k][0]<< ".." << V[1][k][1]<< ".."<< "..\n" ; } - printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); return true; } @@ -398,25 +438,23 @@ std::string diff; std::cout << "getKeyNrOf_USChar z-Z-y-Y: " << ".." << d<< ".." < return 0/1 +void print_simple_map_US(v_str_3D &All_Vector, int shiftstate) { + std::string out; printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); for ( int i=0; i< (int)All_Vector[0].size();i++) { out =get_Other_Char_FromUS(All_Vector[0][i][shiftstate], All_Vector); } } -void print_simple_map_Other(v_str_3D &All_Vector, int shiftstate){ - std::string out, diff; - // ? CHECK if ran OK-> return 0/1 +void print_simple_map_Other(v_str_3D &All_Vector, int shiftstate) { + std::string out; printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); for ( int i=0; i< (int)All_Vector[0].size();i++) { out = get_US_Char_FromOther(All_Vector[0][i][shiftstate], All_Vector); } } -void test_specific_Characters(v_str_3D &All_Vector){ +void test_specific_Characters(v_str_3D &All_Vector) { printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); v_str_1D in {"a", "b", "m", "w", "x", "y", "z"}; std::string out; @@ -425,10 +463,9 @@ void test_specific_Characters(v_str_3D &All_Vector){ } } +//TODO needs to take 2 keyboards as input +int run_DoConvert_Part1_getMap(gint argc, gchar *argv[]) { -//-------------------------------------- -int main(gint argc, gchar *argv[]) -{ gdk_init(&argc, &argv); GdkDisplay *display = gdk_display_get_default(); if (!display) { @@ -448,26 +485,51 @@ int main(gint argc, gchar *argv[]) const char* text_us = "xkb_symbols \"basic\""; v_str_3D All_Vector; - write_US_ToVector(All_Vector,US_language, text_us); - //test(All_Vector); + if(write_US_ToVector(All_Vector,US_language, text_us)) { + printf("ERROR: can't write US to Vector \n"); + return 1; + } + test(All_Vector); // add contents of other keyboard to vector - append_other_ToVector(All_Vector,keymap); - //test(All_Vector); + if( append_other_ToVector(All_Vector,keymap)) { + printf("ERROR: can't append other ToVector \n"); + return 1; + } + test(All_Vector); - extract_difference(All_Vector); - //test_in_out(All_Vector); + if( extract_difference(All_Vector)) { + printf("ERROR: can't extract difference \n"); + return 1; + } - //print_simple_map_US(All_Vector,1); // 1 = non-shift - //print_simple_map_Other(All_Vector,1); // 1 = non-shift + test_in_out(All_Vector); + print_simple_map_US(All_Vector,1); // 1 = non-shift, 2 = shift + print_simple_map_Other(All_Vector,2); // 1 = non-shift, 2 = shift test_specific_Characters(All_Vector); + gdk_display_close(display); printf("°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° end\n"); return 0; } -*/ +void LoadKeyboard() {std::cout << "#### LoadKeyboard not implemented yet ! \n";} + +void run_DoConvert_Part2_TranslateKeyboard() {std::cout << "#### TranslateKeyboard not implemented yet ! \n";} + +void SaveKeyboard() {std::cout << "#### SaveKeyboard not implemented yet ! \n";} +//-------------------------------------- + +int main(gint argc, gchar *argv[]) +{ + LoadKeyboard(); + int out = run_DoConvert_Part1_getMap(argc,argv); + run_DoConvert_Part2_TranslateKeyboard(); + SaveKeyboard(); + + return out ; +} // old ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ /* static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 7190312a41..19c77b324e 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -18,29 +18,58 @@ int dummytest_keymap(); +// In ths program we use a 3D-Vector Vector[language][Keys][Shiftstates] +#pragma once +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "mc_kmxfile.h" +#include "mc_savekeyboard.h" typedef std::vector v_str_1D; typedef std::vector > v_str_2D; typedef std::vector > > v_str_3D; -static int shift_state_count = 2; // use shiftstate : no shift, shift +int shift_state_count = 2; // use shiftstate : no shift, shift + +int run_DoConvert_Part1_getMap(gint argc, gchar *argv[]); + +// adapt from mc_kmxfile.cpp +void LoadKeyboard(); + +// use TranslateKeyboard, TranslateGroup,TranslateKey from mcompile +void run_DoConvert_Part2_TranslateKeyboard(); + +// adapt from mc_savekeyboard.cpp +//void SaveKeyboard(); + -/* // read configuration file, split and write to 3D-Vector (Data for US on [0][ ][ ] ) -void write_US_ToVector(v_str_3D &vec, std::string language, const char *text); +bool write_US_ToVector(v_str_3D &vec, std::string language, const char *text); // 1. step: read complete Row of Configuration file US -void CreateCompleteRow_US(v_str_1D &complete_List, FILE *fpp, const char *text, std::string language); +bool CreateCompleteRow_US(v_str_1D &complete_List, FILE *fpp, const char *text, std::string language); // 2nd step: write contents to 3D vector -void Split_US_To_3D_Vector(v_str_3D &all_US, v_str_1D completeList); +bool Split_US_To_3D_Vector(v_str_3D &all_US, v_str_1D completeList); + +// make sure only a-z, A_Z is used +bool foundCharacterInList(std::string tok); // replace Name of Key (e.g. ) wih Keycode ( e.g. 15 ) int replace_PosKey_with_Keycode(std::string in); // append characters using GDK to 3D-Vector (Data for Other Language on [1][ ][ ] ) -void append_other_ToVector(v_str_3D &All_Vector, GdkKeymap *keymap); +bool append_other_ToVector(v_str_3D &All_Vector, GdkKeymap *keymap); // create an empty 2D vector containing "--" in all fields v_str_2D create_empty_2D(int dim_rows, int dim_shifts); @@ -49,7 +78,7 @@ v_str_2D create_empty_2D(int dim_rows, int dim_shifts); int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos); // print both sets of characters (US and OtherLanguage) to console and file for comparison -void extract_difference(v_str_3D &All_Vector); +bool extract_difference(v_str_3D &All_Vector); // get mapped key from Other (Other->US) std::string get_Other_Char_FromUS(std::string in, v_str_3D &All_Vector); @@ -70,8 +99,7 @@ void test_in_out(v_str_3D &All_Vector); // testing of Vector contents ( first row of US and Other) bool test(v_str_3D &V); // writing out mapping of some characters: a,b,m,w,x,y,z -void test_specific_Characters(v_str_3D &All_Vector);*/ - +void test_specific_Characters(v_str_3D &All_Vector); // old ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From 8189ff7863ecd6d746311a3907d9f22f487bd372 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 14 Jun 2023 11:32:35 +0200 Subject: [PATCH 026/327] feat(linux): mcompile adapt meson build --- linux/mcompile/keymap/README.md | 6 +--- linux/mcompile/keymap/meson.build | 48 +++++++++++++------------------ 2 files changed, 21 insertions(+), 33 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index 8f77d2fb54..59746d5c80 100644 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -7,12 +7,9 @@ Sample program that reads US basic keyboard and compares to key value group TODO check if US basic is the right Keyboard to compare with TODO non-letter characters don't work OK yet TODO Umlauts don't work OK yet -TODO Check for use of correct dimensions in Vector/prevent error if dims are not correct -TODO prevent crashes: handle possible Errors in CreateCompleteRow_US, Split_US_To_3D_Vector TODO check Keycode of TLDE, BKSL, LSGT TODO remove unnecessary printf/cout TODO path for xkb/symbols as compile time option in meson -TODO append_other_ToVector: ensure shift states of GetKeyvalsFromKeymap are not out of range TODO check how many/which shift states we use ( at the moment we read all shiftstate-columns of US but then use only 2 colums (non-shift + shift) then use as many colums for Other ) TODO define folder to store File_US.txt" in and find better name @@ -23,11 +20,10 @@ TODO use/adapt TranslateKeyboard() to work on Linux/cross-platform TODO use/adapt LoadKeyboard() to work on Linux/cross-platform TODO use/adapt SaveKeyboard() to work on Linux/cross-platform TODO include deadkeys -TODO use only a-z; no numbers,backsl,... TODO mcompile.cpp: open mcompile -u - option TODO replace GetLastError with SetError/AddCompileError/AddCompileWarning TODO ... //--------------------------- TOASK is using string OK, or do we use char, wchar? -TOASK ... \ No newline at end of file +TOASK a-z, A_Z or more keys? ... diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index 82eac438cf..c5aa797e6f 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -1,31 +1,23 @@ -project('mcompile', 'c', 'cpp', - license: 'MIT', - meson_version: '>=1.0') - -gtk = dependency('gtk+-3.0', version: '>= 2.4') -cpp_files = files( - 'keymap.cpp', - 'mcompile.cpp', - 'mc_kmxfile.cpp', - 'mc_savekeyboard.cpp', - 'helpers.cpp', -) - -mcompile = executable( - 'mcompile', - sources: [cpp_files], - dependencies: [gtk] -) - -# old +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -#project('keymap', 'c', 'cpp', -# license: 'MIT', -# meson_version: '>=1.0') +#project('mcompile', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') #gtk = dependency('gtk+-3.0', version: '>= 2.4') -#keymap = executable( -# 'keymap', -# sources: ['keymap.cpp'], -# dependencies: [gtk] -#) +#cpp_files = files( 'keymap.cpp', 'mcompile.cpp', 'mc_kmxfile.cpp', 'mc_savekeyboard.cpp', 'helpers.cpp',) + +#mcompile = executable( 'mcompile', sources: [cpp_files], dependencies: [gtk]) + +# old +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +#project('keymapWC', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') + +#gtk = dependency('gtk+-3.0', version: '>= 2.4') + +#keymapWC = executable( 'keymapWC', sources: ['keymapWC.cpp'], dependencies: [gtk]) + + + +# old +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +project('keymap', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') + +gtk = dependency('gtk+-3.0', version: '>= 2.4') + +keymap = executable( 'keymap', sources: ['keymap.cpp'], dependencies: [gtk]) From d43c5faca36195c757399bd0e0c9604bf343c342 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 14 Jun 2023 12:03:06 +0200 Subject: [PATCH 027/327] feat(linux): mcompile remove unneccessary #include --- linux/mcompile/keymap/keymap.h | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 19c77b324e..630db94127 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -18,22 +18,6 @@ int dummytest_keymap(); -// In ths program we use a 3D-Vector Vector[language][Keys][Shiftstates] -#pragma once - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "mc_kmxfile.h" -#include "mc_savekeyboard.h" typedef std::vector v_str_1D; typedef std::vector > v_str_2D; From cc62e391331bdbe1980874e5ae383bf4a05aab80 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 14 Jun 2023 18:42:41 +0200 Subject: [PATCH 028/327] feat(linux): mcompile add typedef for char16_t --- linux/mcompile/keymap/README.md | 1 + linux/mcompile/keymap/km_types.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index 59746d5c80..6f7831a394 100644 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -22,6 +22,7 @@ TODO use/adapt SaveKeyboard() to work on Linux/cross-platform TODO include deadkeys TODO mcompile.cpp: open mcompile -u - option TODO replace GetLastError with SetError/AddCompileError/AddCompileWarning +TODO u16.h u16.cpp include fron folder of kmx_u16.h TODO ... //--------------------------- diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index da12c302c0..da45d005b7 100644 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -39,6 +39,8 @@ typedef km_kbp_cp KMX_WCHAR; // wc, 16-bit UNICODE character typedef wchar_t WCHAR; // _S2 needs to be removed/ wchart-> char16 typedef WCHAR KMX_WCHART; // _S2 needs to be removed/ wchart-> char16 + +typedef char16_t KMX_WCHAR; // _S2 typedef KMX_WCHAR* PKMX_WCHAR; // _S2 typedef wchar_t* PWSTR; // _S2 needs to be removed/ wchart-> char16 typedef PWSTR PKMX_WCHART; // _S2 needs to be removed/ wchart-> char16 From 0bca8f60d646c156fef3c551da9eee912db8af1e Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 14 Jun 2023 18:43:39 +0200 Subject: [PATCH 029/327] feat(linux): mcompile runable keymap version for std::string --- linux/mcompile/keymap/keymap.cpp | 6 ++++++ linux/mcompile/keymap/keymap.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 8040310cf8..6bcee97055 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -21,6 +21,12 @@ static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) } */ + +int dummytest_keymap(){ + std::cout<< " dummytest_keymap is available\t"; + return 0; +} + bool write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 630db94127..4e4e56782d 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -23,7 +23,7 @@ typedef std::vector v_str_1D; typedef std::vector > v_str_2D; typedef std::vector > > v_str_3D; -int shift_state_count = 2; // use shiftstate : no shift, shift +static int shift_state_count = 2; // use shiftstate : no shift, shift int run_DoConvert_Part1_getMap(gint argc, gchar *argv[]); From c72f0a451bab07490def07dd379a560d6fa443af Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 14 Jun 2023 18:45:47 +0200 Subject: [PATCH 030/327] feat(linux): mcompile meson.build for 3 different versions to compile --- linux/mcompile/keymap/meson.build | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index c5aa797e6f..39d6f4e5a2 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -1,23 +1,21 @@ + + +# mcompile +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + #project('mcompile', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') - #gtk = dependency('gtk+-3.0', version: '>= 2.4') - #cpp_files = files( 'keymap.cpp', 'mcompile.cpp', 'mc_kmxfile.cpp', 'mc_savekeyboard.cpp', 'helpers.cpp',) - #mcompile = executable( 'mcompile', sources: [cpp_files], dependencies: [gtk]) -# old +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -#project('keymapWC', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') +# keymap_WC +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +#project('keymap_WC', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') #gtk = dependency('gtk+-3.0', version: '>= 2.4') - -#keymapWC = executable( 'keymapWC', sources: ['keymapWC.cpp'], dependencies: [gtk]) +#keymap_WC = executable( 'keymap_WC', sources: ['keymap_WC.cpp'], dependencies: [gtk]) +# keymap +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -# old +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ project('keymap', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') - gtk = dependency('gtk+-3.0', version: '>= 2.4') - keymap = executable( 'keymap', sources: ['keymap.cpp'], dependencies: [gtk]) From 26fbc8daa5d66b76f1632e0863f691c2af1305ff Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 14 Jun 2023 19:16:40 +0200 Subject: [PATCH 031/327] feat(linux): mcompile some comments --- linux/mcompile/keymap/keymap.cpp | 3 ++- linux/mcompile/keymap/meson.build | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 6bcee97055..737944ac33 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -527,7 +527,8 @@ void run_DoConvert_Part2_TranslateKeyboard() {std::cout << "#### TranslateKeyboa void SaveKeyboard() {std::cout << "#### SaveKeyboard not implemented yet ! \n";} //-------------------------------------- -int main(gint argc, gchar *argv[]) +//int main(gint argc, gchar *argv[]) // this is for use of single keymap +int main_keymap(gint argc, gchar *argv[]) // this is for use of keymap together with mcompile { LoadKeyboard(); int out = run_DoConvert_Part1_getMap(argc,argv); diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index 39d6f4e5a2..02294ba03a 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -2,10 +2,10 @@ # mcompile +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -#project('mcompile', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') -#gtk = dependency('gtk+-3.0', version: '>= 2.4') -#cpp_files = files( 'keymap.cpp', 'mcompile.cpp', 'mc_kmxfile.cpp', 'mc_savekeyboard.cpp', 'helpers.cpp',) -#mcompile = executable( 'mcompile', sources: [cpp_files], dependencies: [gtk]) +project('mcompile', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') +gtk = dependency('gtk+-3.0', version: '>= 2.4') +cpp_files = files( 'keymap.cpp', 'mcompile.cpp', 'mc_kmxfile.cpp', 'mc_savekeyboard.cpp', 'helpers.cpp',) +mcompile = executable( 'mcompile', sources: [cpp_files], dependencies: [gtk]) # keymap_WC +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -16,6 +16,6 @@ # keymap +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -project('keymap', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') -gtk = dependency('gtk+-3.0', version: '>= 2.4') -keymap = executable( 'keymap', sources: ['keymap.cpp'], dependencies: [gtk]) +#project('keymap', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') +#gtk = dependency('gtk+-3.0', version: '>= 2.4') +#keymap = executable( 'keymap', sources: ['keymap.cpp'], dependencies: [gtk]) From adb6dba2703422255ebd068303a1afb3b1654cce Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 15 Jun 2023 09:07:38 +0200 Subject: [PATCH 032/327] feat(linux): mcompile include #ifndef's --- linux/mcompile/keymap/helpers.h | 9 +++++++-- linux/mcompile/keymap/keymap.h | 5 +++++ linux/mcompile/keymap/km_types.h | 5 +++++ linux/mcompile/keymap/kmx_file.h | 3 +++ linux/mcompile/keymap/mc_kmxfile.h | 6 ++++++ linux/mcompile/keymap/mcompile.h | 4 ++++ 6 files changed, 30 insertions(+), 2 deletions(-) diff --git a/linux/mcompile/keymap/helpers.h b/linux/mcompile/keymap/helpers.h index 8339301e29..06cc3bbaa2 100644 --- a/linux/mcompile/keymap/helpers.h +++ b/linux/mcompile/keymap/helpers.h @@ -1,14 +1,19 @@ - #pragma once +#ifndef HELPERS_H +#define HELPERS_H + #include #include "mc_savekeyboard.h" #include "mc_kmxfile.h" #include "mc_savekeyboard.h" +int dummytest_helpers(); void check_avaiability_of_modules_(); // My std::cout : writes pre-in ; 1 for end of line void MyCout(std::string in, bool end, std::string pre = ""); //Just for now: wrote my oẃn DebugLog -TODO to be replaced -void DebugLog_S2(std::wstring txt, std::wstring fileName); \ No newline at end of file +void DebugLog_S2(std::wstring txt, std::wstring fileName); + +#endif /* HELPERS_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 4e4e56782d..dea3ebffc4 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -1,5 +1,7 @@ // In ths program we use a 3D-Vector Vector[language][Keys][Shiftstates] #pragma once +#ifndef KEYMAP_H +#define KEYMAP_H #include #include @@ -15,6 +17,7 @@ #include "kmx_file.h" #include "mc_savekeyboard.h" #include "helpers.h" +#include "u16.h" int dummytest_keymap(); @@ -142,3 +145,5 @@ void test_in_out(v_str_3D &All_Vector); bool test(v_str_3D &V); // writing out mapping of some characters: a,b,m,w,x,y,z void test_specific_Characters(v_str_3D &All_Vector);*/ + +# endif /*KEYMAP_H*/ diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index da45d005b7..aef959da10 100644 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -1,4 +1,7 @@ #pragma once +#ifndef KM_TYPES +#define KM_TYPES + #include #define X_test 0xFF1234 @@ -88,3 +91,5 @@ typedef wchar_t KMX_UCHAR; #endif typedef KMX_UCHAR* KMX_PUCHAR; + +#endif /*KM_TYPES*/ diff --git a/linux/mcompile/keymap/kmx_file.h b/linux/mcompile/keymap/kmx_file.h index 998c978007..b25464632d 100644 --- a/linux/mcompile/keymap/kmx_file.h +++ b/linux/mcompile/keymap/kmx_file.h @@ -4,6 +4,8 @@ */ #pragma once +#ifndef KMX_FILE_H +#define KMX_FILE_H #include @@ -382,3 +384,4 @@ static_assert(sizeof(COMP_KEYBOARD) == KEYBOARDFILEHEADER_SIZE, "COMP_KEYBOARD m } // namespace kbp } // namespace km #endif +#endif /*KMX_FILE_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 071ac7ee87..46016361f4 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -1,5 +1,9 @@ #pragma once +#ifndef MC_KMXFILE_H +#define MC_KMXFILE_H + #include "km_types.h" +#include "kmx_file.h" #include // _S2 can be removed later @@ -148,3 +152,5 @@ BOOL LoadKeyboard(LPWSTR fileName, LPKEYBOARD *lpKeyboard); #endif */ + +#endif /*MC_KMXFILE_H*/ diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 1c367fc406..410a7975f4 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -19,6 +19,8 @@ +#ifndef MCOMPILE_H +#define MCOMPILE_H #include #include "keymap.h" @@ -49,3 +51,5 @@ struct DeadkeyMapping { // I4353 extern std::vector FDeadkeys; // I4353 */ + +#endif /*MCOMPILE_H*/ From b2094eefb431680389b4468b11ea2544668a6479 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 15 Jun 2023 09:10:13 +0200 Subject: [PATCH 033/327] feat(linux): mcompile add u16.h/cpp for converting functions adapted meson.build --- linux/mcompile/keymap/helpers.cpp | 11 +- linux/mcompile/keymap/keymap.cpp | 6 +- linux/mcompile/keymap/meson.build | 18 +- linux/mcompile/keymap/u16.cpp | 298 ++++++++++++++++++++++++++++++ linux/mcompile/keymap/u16.h | 46 +++++ 5 files changed, 366 insertions(+), 13 deletions(-) create mode 100644 linux/mcompile/keymap/u16.cpp create mode 100644 linux/mcompile/keymap/u16.h diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 4cc4456aa4..48906c0fc6 100644 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -1,15 +1,20 @@ #include "keymap.h" #include "helpers.h" +int dummytest_helpers(){ + std::cout<< " dummytest_helpers is available\t"; + return 0; +} void check_avaiability_of_modules_(){ std::cout << "\n*********************************************************************************************\n"; - if ( X_test == 0xFF1234 ) std::cout << "\t\t\t\t\t\treaching helpers was OK \n"; + if ( X_test == 0xFF1234 ) std::cout << "\t\t\t\t\t\treaching X_Test was OK \n"; if ( !dummytest_keymap() ) std::cout << "\treaching keymap was OK \n"; + if ( !dummytest_helpers() ) std::cout << "\treaching helpers was OK \n"; + if ( !dummytest_u16() ) std::cout << "\treaching u16 was OK \n"; if ( !dummytest_mc_kmx_file() ) std::cout << "\treaching mc_kmx_file was OK \n"; if ( !dummytest_mc_Savekeyboard() ) std::cout << "reaching mc_Savekeyboard was OK \n"; - if ( KEYMANID_NONKEYMAN == 0xFFFFFFFF ) std::cout << "\t\t\t\t\t\treaching kmx_file was OK \n"; - if ( X_test == 0xFF1234 ) std::cout << "\t\t\t\t\t\treaching kmx_types was OK \n"; + if ( KEYMANID_NONKEYMAN == 0xFFFFFFFF ) std::cout << "\t\t\t\t\t\treaching KEYMANID_NONKEYMAN was OK \n"; std::cout << "*********************************************************************************************\n"; } diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 737944ac33..4f844e59b3 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -169,7 +169,7 @@ bool foundCharacterInList(std::string tok) { v_str_1D Keysyms { "24","25","26","27","28","29","30","31","32","33","38","39","40","41","42","43","44","45","46","47","52","53","54","55","56","57","58"}; for ( int i =0; i< (int) Keysyms.size();i++) { - std::cout << "foundCharacterInList" << i <<"\n"; + //std::cout << "foundCharacterInList" << i <<"\n"; if( tok == Keysyms[i]) { return true; } @@ -530,11 +530,15 @@ void SaveKeyboard() {std::cout << "#### SaveKeyboard not implemented yet ! \n";} //int main(gint argc, gchar *argv[]) // this is for use of single keymap int main_keymap(gint argc, gchar *argv[]) // this is for use of keymap together with mcompile { + check_avaiability_of_modules_(); LoadKeyboard(); + std::cout << "############################################################################################### end LoadKeyboard \n"; + int out = run_DoConvert_Part1_getMap(argc,argv); run_DoConvert_Part2_TranslateKeyboard(); SaveKeyboard(); + std::cout << "################################################################################################################################### end keymap \n"; return out ; } // old ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index 02294ba03a..e67ea279e3 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -2,20 +2,20 @@ # mcompile +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -project('mcompile', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') -gtk = dependency('gtk+-3.0', version: '>= 2.4') -cpp_files = files( 'keymap.cpp', 'mcompile.cpp', 'mc_kmxfile.cpp', 'mc_savekeyboard.cpp', 'helpers.cpp',) -mcompile = executable( 'mcompile', sources: [cpp_files], dependencies: [gtk]) +project('mcompile', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') gtk = dependency('gtk+-3.0', version: '>= 2.4') +cpp_files = files( 'keymap.cpp', 'mcompile.cpp', 'mc_kmxfile.cpp', 'mc_savekeyboard.cpp', 'helpers.cpp', 'u16.cpp',) mcompile = executable( 'mcompile', sources: [cpp_files], dependencies: [gtk]) # keymap_WC +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -#project('keymap_WC', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') -#gtk = dependency('gtk+-3.0', version: '>= 2.4') +#project('keymap_WC', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') #gtk = dependency('gtk+-3.0', version: '>= 2.4') #keymap_WC = executable( 'keymap_WC', sources: ['keymap_WC.cpp'], dependencies: [gtk]) +# keymapWC +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +#project('keymapWC', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') #gtk = dependency('gtk+-3.0', version: '>= 2.4') +cpp_files = files( 'keymapWC.cpp',) #keymapWC = executable( 'keymapWC', sources: [cpp_files], dependencies: [gtk]) # keymap +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -#project('keymap', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') -#gtk = dependency('gtk+-3.0', version: '>= 2.4') -#keymap = executable( 'keymap', sources: ['keymap.cpp'], dependencies: [gtk]) +#project('keymap', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') #gtk = dependency('gtk+-3.0', version: '>= 2.4') +#cpp_files = files( 'keymap.cpp', 'mc_kmxfile.cpp', 'mc_savekeyboard.cpp', 'helpers.cpp', 'u16.cpp',) #keymap = executable( 'keymap', sources: [cpp_files], dependencies: [gtk]) diff --git a/linux/mcompile/keymap/u16.cpp b/linux/mcompile/keymap/u16.cpp new file mode 100644 index 0000000000..f5fe5457e3 --- /dev/null +++ b/linux/mcompile/keymap/u16.cpp @@ -0,0 +1,298 @@ +#include "u16.h" + +//#include +//#include +#include +#include +#include + + +int dummytest_u16(){ + std::cout<< " dummytest_u16 \tis available\t"; + return 0; +} + +//String <- wstring +std::string string_from_wstring(std::wstring const str) { + std::wstring_convert, wchar_t> converter; + return converter.to_bytes(str); +} +//wstring <- string +std::wstring wstring_from_string(std::string const str) { + std::wstring_convert, wchar_t> converter; + return converter.from_bytes(str); +} + +//u16String <- string +std::u16string u16string_from_string(std::string const str) { + std::wstring_convert, char16_t> converter; + return converter.from_bytes(str); +} + +//string <- u16string +std::string string_from_u16string(std::u16string const str) { + std::wstring_convert, char16_t> converter; + return converter.to_bytes(str); +} + +// often used with c_str() e.g. u16fmt( DEBUGSTORE_MATCH).c_str() +// UTF16 (= const char16_t*) -> UTF8 (= std::string) -> UTF16 ( = std::wstring 16 bit) +std::wstring u16fmt(const KMX_WCHAR * str) { + std::wstring_convert, wchar_t> convert_wstring; + std::wstring_convert, char16_t> convert; + + // UTF16 (= const char16_t*) -> UTF8 (= std::string) -> UTF16 ( = std::wstring 16 bit) + std::string utf8str = convert.to_bytes(str); // UTF16 (= const char16_t*) -> UTF8 (= std::string) + std::wstring wstr = convert_wstring.from_bytes(utf8str); // UTF8 (= std::string) -> UTF16 ( = std::wstring 16 bit) + return wstr; +} + +void u16sprintf(KMX_WCHAR * dst, const size_t sz, const wchar_t* fmt, ...) { + // UTF16 (=const wchar_t*) -> -> std::string -> std::u16string -> UTF16 ( = char16_t*) + wchar_t* wbuf = new wchar_t[sz]; + va_list args; + va_start(args, fmt); + vswprintf(wbuf, sz, fmt, args); + va_end(args); + + std::wstring_convert, wchar_t> convert_wstring; + std::wstring_convert, char16_t> convert; + + // UTF16 (=const wchar_t*) -> -> std::string -> std::u16string -> UTF16 ( = char16_t*) + std::string utf8str = convert_wstring.to_bytes(wbuf); // UTF16 ( = const wchar_t*) -> std::string + std::u16string u16str = convert.from_bytes(utf8str); // std::string -> std::u16string + u16ncpy(dst, u16str.c_str(), sz); // std::u16string.c_str() -> char16_t* + delete[] wbuf; +} + + std::wstring convert_pchar16T_To_wstr(KMX_WCHAR *Name){ + // convert char16_t* -> std::u16string -> std::string -> std::wstring + // char16_t* -> std::u16string + std::u16string u16str(Name); + // std::u16string -> std::string + std::string stri = string_from_u16string(u16str); + // std::string -> std::wstring + std::wstring wstr = wstring_from_string(stri); + return wstr; + } + +long int u16tol(const KMX_WCHAR* str, KMX_WCHAR** endptr, int base) +{ + auto s = string_from_u16string(str); + char* t; + long int result = strtol(s.c_str(), &t, base); + if (endptr != nullptr) *endptr = (KMX_WCHAR*)str + (t - s.c_str()); + return result; +} +/* +std::string toHex(int num1) { + if (num1 == 0) + return "0"; + int num = num1; + std::string s = ""; + while (num) { + int temp = num % 16; + if (temp <= 9) + s += (48 + temp); + else + s += (87 + temp); + num = num / 16; + } + reverse(s.begin(), s.end()); + return s; +} +*/ +const KMX_WCHAR * u16ncat(KMX_WCHAR *dst, const KMX_WCHAR *src, size_t max) { + KMX_WCHAR* o = dst; + dst = (KMX_WCHAR*) u16chr(dst, 0); + //max -= (dst-o); + while (*src && max > 0) { + *dst++ = *src++; + max--; + } + if(max > 0) + *dst = 0; + return o; +} + +const KMX_WCHAR* u16rchr_slash(KMX_WCHAR const* Name) +{ + const KMX_WCHAR* cp = NULL; + cp = u16rchr(Name, '\\'); + if (cp == NULL) + cp = u16rchr(Name, '/'); + return cp; +} +/* +KMX_CHAR* strrchr_slash(KMX_CHAR* Name) +{ + KMX_CHAR* cp = NULL; + cp = strrchr(Name, '\\'); + if (cp == NULL) + cp = strrchr(Name, '/'); + return cp; +} +*/ +// u16rchr returns last occurence of ch in p; It returns NULL if ch = '\0' and NULL if ch is not found +const KMX_WCHAR* u16rchr(const KMX_WCHAR* p, KMX_WCHAR ch) { + const KMX_WCHAR* p_end = p + u16len(p) - 1; + + if (ch == '\0') return p_end + 1; + while (p_end >= p) { + if (*p_end == ch) return p_end; + p_end--; + } + return NULL; +} + +const KMX_WCHAR * u16chr(const KMX_WCHAR *p, KMX_WCHAR ch) { + while (*p) { + if (*p == ch) return p; + p++; + } + return ch == 0 ? p : NULL; +} + +const KMX_WCHAR * u16cpy(KMX_WCHAR *dst, const KMX_WCHAR *src) { + KMX_WCHAR *o = dst; + while (*src) { + *dst++ = *src++; + } + *dst = 0; + return o; +} + +const KMX_WCHAR * u16ncpy(KMX_WCHAR *dst, const KMX_WCHAR *src, size_t max) { + KMX_WCHAR *o = dst; + while (*src && max > 0) { + *dst++ = *src++; + max--; + } + while(max > 0) { + *dst++ = 0; + max--; + } + return o; +} + +size_t u16len(const KMX_WCHAR *p) { + int i = 0; + while (*p) { + p++; + i++; + } + return i; +} + +int u16cmp(const KMX_WCHAR *p, const KMX_WCHAR *q) { + while (*p && *q) { + if (*p != *q) return *p - *q; + p++; + q++; + } + return *p - *q; +} + +int u16nicmp(const KMX_WCHAR *p, const KMX_WCHAR *q, size_t count) { + while (*p && *q && count) { + if (toupper(*p) != toupper(*q)) return *p - *q; + p++; + q++; + count--; + } + if (count) + return *p - *q; + return 0; +} + +int u16icmp(const KMX_WCHAR *p, const KMX_WCHAR *q) { + while (*p && *q) { + if (toupper(*p) != toupper(*q)) return *p - *q; + p++; + q++; + } + return *p - *q; +} + +int u16ncmp(const KMX_WCHAR *p, const KMX_WCHAR *q, size_t count) { + while (*p && *q && count) { + if (*p != *q) return *p - *q; + p++; + q++; + count--; + } + if (count) + return *p - *q; + return 0; +} + +KMX_WCHAR * u16tok(KMX_WCHAR *p, KMX_WCHAR ch, KMX_WCHAR **ctx) { + if (!p) { + p = *ctx; + if (!p) return NULL; + } + + KMX_WCHAR *q = p; + while (*q && *q != ch) { + q++; + } + if (*q) { + *q = 0; + q++; + while (*q == ch) q++; + *ctx = q; + } + else { + *ctx = NULL; + } + return p; +} + +KMX_WCHAR * u16tok(KMX_WCHAR* p, KMX_WCHAR* delim, KMX_WCHAR** ctx) { + if (!p) { + p = *ctx; + if (!p) return NULL; + } + + KMX_WCHAR * q = p; + while (*q && !u16chr(delim, *q)) { + q++; + } + if (*q) { + *q = 0; + q++; + while (u16chr(delim, *q)) q++; + *ctx = q; + } + else { + *ctx = NULL; + } + return p; +} + +double u16tof( KMX_WCHAR* str) +{ + double val = 0; + int offsetdot=0; + char digit; + + PKMX_WCHAR q = (PKMX_WCHAR)u16chr(str, '.'); + size_t pos_dot = q-str ; + + if (pos_dot < 0) + pos_dot = u16len(str); + + for (size_t i = 0; i < u16len(str); i++) + { + digit = static_cast(towupper(*str)); + + if (i > pos_dot - 1) + offsetdot = 1; + + if (digit != '.') + val =val+ ((int(digit)) - 48) * pow(10, (pos_dot - 1- i + offsetdot)); + + str++; + } + return val; +} diff --git a/linux/mcompile/keymap/u16.h b/linux/mcompile/keymap/u16.h new file mode 100644 index 0000000000..ad6f07e92c --- /dev/null +++ b/linux/mcompile/keymap/u16.h @@ -0,0 +1,46 @@ +#ifndef U16_H +#define U16_H + +#include + +#include +#include +#include +#include +#include "km_types.h" + + +int dummytest_u16(); + +std::string string_from_wstring(std::wstring const str); +std::wstring wstring_from_string(std::string const str); +std::u16string u16string_from_string(std::string const str); +std::string string_from_u16string(std::u16string const str); + +std::wstring u16fmt(const KMX_WCHAR * str); +void u16sprintf(KMX_WCHAR * dst, const size_t sz, const wchar_t* fmt, ...) ; + +std::wstring convert_pchar16T_To_wstr(KMX_WCHAR *Name); + +size_t u16len(const KMX_WCHAR *p); +int u16cmp(const KMX_WCHAR *p, const KMX_WCHAR *q); +int u16icmp(const KMX_WCHAR *p, const KMX_WCHAR *q); +int u16ncmp(const KMX_WCHAR *p, const KMX_WCHAR *q, size_t count); +int u16nicmp(const KMX_WCHAR *p, const KMX_WCHAR *q, size_t count) ; +const KMX_WCHAR * u16ncpy(KMX_WCHAR *dst, const KMX_WCHAR *src, size_t max); +const KMX_WCHAR * u16cpy(KMX_WCHAR *dst, const KMX_WCHAR *src); +const KMX_WCHAR * u16rchr(const KMX_WCHAR *p, KMX_WCHAR ch) ; +const KMX_WCHAR * u16chr(const KMX_WCHAR *p, KMX_WCHAR ch) ; +const KMX_WCHAR * u16ncat(KMX_WCHAR *dst, const KMX_WCHAR *src, size_t max); +KMX_WCHAR * u16tok(KMX_WCHAR *p, KMX_WCHAR ch, KMX_WCHAR **ctx) ; +KMX_WCHAR * u16tok(KMX_WCHAR* p, KMX_WCHAR* ch, KMX_WCHAR** ctx) ; +long int u16tol(const KMX_WCHAR* str, KMX_WCHAR** endptr, int base) ; +double u16tof( KMX_WCHAR* str); + +KMX_CHAR* strrchr_slash(KMX_CHAR* Name); +const KMX_WCHAR* u16rchr_slash(KMX_WCHAR const* Name); + +std::string toHex(int num1); + + +#endif /* U16_H */ \ No newline at end of file From 3a841c2d933825572ca91327e1e81edaed4e7aa9 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 26 Jun 2023 15:01:20 +0200 Subject: [PATCH 034/327] feat(linux): mcompile add copies, gitignore. Readme --- .gitignore | 1 + linux/mcompile/keymap/README.md | 1 + linux/mcompile/keymap/helpers.cpp | 2 +- linux/mcompile/keymap/helpers.h | 2 + linux/mcompile/keymap/keymapWC.cpp | 585 ++++++++++++ linux/mcompile/keymap/keymapWC.h | 100 ++ linux/mcompile/keymap/mcompile copy.cpp | 1104 +++++++++++++++++++++++ linux/mcompile/keymap/meson.build | 23 +- 8 files changed, 1806 insertions(+), 12 deletions(-) create mode 100644 linux/mcompile/keymap/keymapWC.cpp create mode 100644 linux/mcompile/keymap/keymapWC.h create mode 100644 linux/mcompile/keymap/mcompile copy.cpp diff --git a/.gitignore b/.gitignore index a8a74b95f5..66f87cce1a 100644 --- a/.gitignore +++ b/.gitignore @@ -199,3 +199,4 @@ lcov.info # /developer/src/test/auto/kmcomp/*.kvk* # /developer/src/test/auto/kmcomp/*.txt /linux/mcompile/keymap/X_bak +/linux/mcompile/keymap/anii.* diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index 6f7831a394..f892a5fde1 100644 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -23,6 +23,7 @@ TODO include deadkeys TODO mcompile.cpp: open mcompile -u - option TODO replace GetLastError with SetError/AddCompileError/AddCompileWarning TODO u16.h u16.cpp include fron folder of kmx_u16.h +TOTO use wchar_t* as cmd-lne-par in main TODO ... //--------------------------- diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 48906c0fc6..52739f3680 100644 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -29,4 +29,4 @@ void MyCout(std::string in, bool end, std::string pre ) { void DebugLog_S2(std::wstring txt, std::wstring fileName) { wprintf(txt.c_str(), fileName); -} \ No newline at end of file +} diff --git a/linux/mcompile/keymap/helpers.h b/linux/mcompile/keymap/helpers.h index 06cc3bbaa2..e0dbe2f8ec 100644 --- a/linux/mcompile/keymap/helpers.h +++ b/linux/mcompile/keymap/helpers.h @@ -9,6 +9,8 @@ int dummytest_helpers(); void check_avaiability_of_modules_(); +void check_avaiability_of_modules_mc(); +void check_avaiability_of_modules_WC(); // My std::cout : writes pre-in ; 1 for end of line void MyCout(std::string in, bool end, std::string pre = ""); diff --git a/linux/mcompile/keymap/keymapWC.cpp b/linux/mcompile/keymap/keymapWC.cpp new file mode 100644 index 0000000000..a88d778027 --- /dev/null +++ b/linux/mcompile/keymap/keymapWC.cpp @@ -0,0 +1,585 @@ +// MAY BE REMOVED LATER _S2 +#include "keymapWC.h" + +#include +#include +#include +#include +#include "keymap.h" + +// run with ./keymapWC -d in.kmx bla.dll 0407 out.kmx + + +int dummytest_keymapWC(){ + std::cout<< " dummytest_keymapWC is available\t"; + return 0; +} + +bool write_US_ToVectorWC( v_WC_3D &vec,std::string language, const char* text) { +//std::cout << " in write_US_ToVector \n"; + std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; + + const char* path = FullPathName.c_str(); + //std::cout << " in path"<" and the next xkb_symbol + // and then copy all rows starting with "key <" to a v1D-Vector + + std::cout << " in CreateCompleteRow_USWC "<<" \n"; + int buffer_size = 512; + char buffer[buffer_size]; + char16_t buf16[buffer_size]; + bool print_OK = false; + const char* key = "key <"; + std::string str_txt(text); + std::string xbk_mark = "xkb_symbol"; + // TODO define folder to store File in + std::ofstream KeyboardFile("File_" + language + ".txt"); + + printf("Keyboard %s\n", text); + KeyboardFile << "Keyboard" << text << " "; + + if (fp) { + while (fgets(buffer, buffer_size, fp) != NULL) { + std::string str_buf(buffer); + + //std::cout << " str_buf"< from the shiftstates + // 3: push Names/Shiftstates to shift_states and then shiftstates to All_US, our 3D-Vector holding all Elements + + std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; + char split_bracel = '{'; + char split_char_komma = ','; + std::string empty = "--"; // '-' only !!! + v_str_1D tokens; + v_str_2D shift_states; + + // go through the whole vector + for (int k = 0; k < (int)completeList.size() - 1; k++) { + + // remove all unwanted char + for (int i = 0; i < (int) delim.size(); i++) { + completeList[k].erase(remove(completeList[k].begin(), completeList[k].end(), delim[i]), completeList[k].end()); + } + + // only lines with ("key<.. are of interest + if (completeList[k].find("key<") != std::string::npos) { + + //split off the key names + std::istringstream split1(completeList[k]); + for (std::string each; std::getline(split1, each, split_bracel); tokens.push_back(each)); + + // replace keys names with number ( with 29,...) + int Keycde = replace_PosKey_with_Keycode(tokens[0]); + tokens[0] = std::to_string(Keycde); + + // we use characters a-z, A_Z only at the moment + if (foundCharacterInListWC(tokens[0])) { + + // seperate rest of the vector to its elements and push to 'tokens' + std::istringstream split(tokens[1]); + tokens.pop_back(); + + for (std::string each; std::getline(split, each, split_char_komma); tokens.push_back(each)); + //printf("### 5 Split_US_To_3D_Vector: tokens: size:%li...tokens[0]-[4]:-name:%s\tShiftstates:%s--%s--%s--%s---.\n", tokens.size(),tokens[0].c_str(),tokens[1].c_str(),tokens[2].c_str(),tokens[3].c_str(),tokens[4].c_str()); + + // at the moment we only use the first 2 shiftstates (non-shift+shift) so get rid of all others + int surplus = tokens.size() - shift_state_count -1; + for( int j=0; j < surplus;j++) { + tokens.pop_back(); + } + + // now push result to shift_states + shift_states.push_back(tokens); + } + tokens.clear(); + } + } + all_US.push_back(shift_states); + + if ( all_US.size() ==0) { + printf("ERROR: Can't split US to 3D-Vector\n"); + return 1; + } + //printf("### 6 Split_US_To_3D_clearVector %li..%li..%li\n", all_US.size(), all_US[0].size(),all_US[0][0].size()); + */ +return 0; +} + +/*bool foundCharacterInListWC(std::string tok) { + //TOASK Do we need more and which? + //US keys: Q W E R T Y U I O P A S D F G H J K L : Z X C V B N M + v_str_1D Keysyms { "24","25","26","27","28","29","30","31","32","33","38","39","40","41","42","43","44","45","46","47","52","53","54","55","56","57","58"}; + + for ( int i =0; i< (int) Keysyms.size();i++) { + std::cout << "foundCharacterInList" << i <<"\n"; + if( tok == Keysyms[i]) { + return true; + } + } + return false; +}*/ + +/*int replace_PosKey_with_KeycodeWC(std::string in) { + int out=0; + if ( in == "key") out = 49; // TOASK correct ??? + else if ( in == "key") out = 10; + else if ( in == "key") out = 11; + else if ( in == "key") out = 12; + else if ( in == "key") out = 13; + else if ( in == "key") out = 14; + else if ( in == "key") out = 15; + else if ( in == "key") out = 16; + else if ( in == "key") out = 17; + else if ( in == "key") out = 18; + else if ( in == "key") out = 19; + else if ( in == "key") out = 20; + else if ( in == "key") out = 21; + + else if ( in == "key") out = 24; + else if ( in == "key") out = 25; + else if ( in == "key") out = 26; + else if ( in == "key") out = 27; + else if ( in == "key") out = 28; + else if ( in == "key") out = 29; + else if ( in == "key") out = 30; + else if ( in == "key") out = 31; + else if ( in == "key") out = 32; + else if ( in == "key") out = 33; + else if ( in == "key") out = 34; + else if ( in == "key") out = 35; + + else if ( in == "key") out = 38; + else if ( in == "key") out = 39; + else if ( in == "key") out = 40; + else if ( in == "key") out = 41; + else if ( in == "key") out = 42; + else if ( in == "key") out = 43; + else if ( in == "key") out = 44; + else if ( in == "key") out = 45; + else if ( in == "key") out = 46; + else if ( in == "key") out = 47; + else if ( in == "key") out = 48; + else if ( in == "key") out = 49; + + else if ( in == "key") out = 52; + else if ( in == "key") out = 53; + else if ( in == "key") out = 54; + else if ( in == "key") out = 55; + else if ( in == "key") out = 56; + else if ( in == "key") out = 57; + else if ( in == "key") out = 58; + else if ( in == "key") out = 59; + else if ( in == "key") out = 60; + else if ( in == "key") out = 61; + else if ( in == "key") out = 62; //TOASK correct ??? + else if ( in == "key") out = 51; //TOASK correct ??? + return out; +}*/ + +bool append_other_ToVectorWC(v_WC_3D &All_Vector,GdkKeymap * keymap) { +/*b + // create a 2D vector all filled with "--" and push to 3D-Vector + v_str_2D Other_Vector2D = create_empty_2D(All_Vector[0].size(),All_Vector[0][0].size()); + + if (Other_Vector2D.size()==0) { + printf("ERROR: create empty 2D-Vector failed"); + return 1; + } + + All_Vector.push_back(Other_Vector2D); + printf("+++++++ dimensions of Vector after append_other_ToVector\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); + + if (All_Vector.size()==0) { + printf("ERROR: creation of 3D-Vector failed"); + return 1; + } + + for(int i =0; i< (int) All_Vector[1].size();i++) { + + // get key name US stored in [0][i][0] and copy to name in other-block[1][i][0] + All_Vector[1][i][0] = All_Vector[0][i][0]; + + // write this value to 3D- Vector + All_Vector[1][i][0+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),0); //shift state: unshifted:0 + All_Vector[1][i][1+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),1); //shift state: shifted:1 + + printf(" Keycodes US->Other: %d(US): %s %s ---- (other):%s, \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str()); + } +*/ + return 0; +} + +v_WC_2D create_empty_2DWC( int dim_rows,int dim_shifts) { + char16_t empty = u'-'; + v_WC_1D shifts; + v_WC_2D all; + + for ( int i=0; i< dim_rows;i++) { + for ( int j=0; j< dim_shifts;j++) { + shifts.push_back(empty); + } + all.push_back(shifts); + shifts.clear(); + } + return all; +} + +int GetKeyvalsFromKeymapWC(GdkKeymap *keymap, guint keycode, int shift_state_pos) { + GdkKeymapKey *maps; + guint *keyvals; + gint count; + int out; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return 0; + //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + // return 0; + + if (!(shift_state_pos < count)) + return 0; + + out = keyvals[shift_state_pos]; + + g_free(keyvals); + g_free(maps); + return out; +} + +bool extract_differenceWC( v_WC_3D &All_Vector) { + /* // TODO define which Folder; find better name + std::ofstream Map_File("Map_US.txt"); + std::string diff =" "; + + printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); + std::cout << "Nr of \n" ; + std::cout << "Key: " << "\t Character US (no shift) " << " Character US (shift) "<< "\t\tCharacter other (no shift)" << "\tCharacter other (shift) difference \n" ; + printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); + + Map_File <<"--------------------------------------------------------------------------------------------------------------------------------------------\n"; + Map_File << "Nr of \n" ; + Map_File << "Key: " << "\t Character US (no shift) " << " Character US (shift) "<< "\t\tCharacter other (no shift)" << "\tCharacter other (shift) difference \n" ; + Map_File <<"--------------------------------------------------------------------------------------------------------------------------------------------\n"; + + for ( int k=0; k<(int)All_Vector[0].size(); k++) { + if (All_Vector[0][k][1] == All_Vector[1][k][1]) + diff =" "; + else + diff =" *** "; + + std::cout << All_Vector[0][k][0] << "\t " <<+(*(All_Vector[0][k][1].c_str()))<< "\t("<< All_Vector[0][k][1] <<")"< Other: "; + // find correct row of char in US + for( int i=0; i< (int) All_Vector[0].size();i++) { + for( int j=1; j< (int)All_Vector[0][0].size();j++) { + + //std::cout << "see and compare: "<< "All_Vector[0]["< Other: "; + //std::cout << "US -> Other: "<< std::setw(5)< Other: (" << in << ": no match)\n"; + + + return u'-';*/ +} + +char16_t get_US_Char_FromOtherWC(char16_t in , v_WC_3D &All_Vector) { + /*char16_t diff; + // find correct row of char in other + for( int i=0; i< (int)All_Vector[1].size();i++) { + for( int j=1; j< (int)All_Vector[1][0].size();j++) { + if ( All_Vector[1][i][j] == in ) { + if ( All_Vector[0][i][j] != All_Vector[1][i][j]) + diff = u'*'; + std::wcout << "Other -> US: "<< std::setw(5)< US: (" << in << ": no match)\n"; + + return u'-';*/ + } + +char16_t getKeyNrOf_USCharWC(char16_t in , v_WC_3D &All_Vector) { + /*// find correct row of char in US + for( int i=0; i< (int)All_Vector[0].size();i++) { + for( int j=1; j< (int)All_Vector[0][0].size();j++) { + if ( All_Vector[0][i][j] == in ) { + std::wcout << u"KeyNr of US char: \t"<< All_Vector[0][i][j] << u" -> " << All_Vector[0][i][0] << u"\n"; + return All_Vector[0][i][0] ; + } + } + } + return u'-';*/ +} + +char16_t getKeyNrOf_OtherCharWC(char16_t in , v_str_3D &All_Vector) { + /* // find correct row of char in US + for( int i=0; i< (int)All_Vector[1].size();i++) { + for( int j=1; j< (int)All_Vector[1][0].size();j++) { + if ( All_Vector[1][i][j] == in ) { + std::wcout << u"KeyNr of Other char : \t"<< All_Vector[1][i][j] << u" -> " << All_Vector[1][i][0] <1) + std::wcout << " row 1 (Other).."<< V[1][k][0]<< ".." << V[1][k][1]<< ".."<< "..\n" ; + } + printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + return true; +} + +void test_in_outWC(v_WC_3D &All_Vector) { +/*std::string diff; + printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); + //checks mapping between US and other + std::string a = get_Other_Char_FromUS( "z", All_Vector); + std::string aa = get_Other_Char_FromUS( "Z", All_Vector); + std::string aaa = get_Other_Char_FromUS( "y", All_Vector); + std::string aaaa = get_Other_Char_FromUS( "Y", All_Vector); + + std::string b = get_US_Char_FromOther( "z", All_Vector); + std::string bb = get_US_Char_FromOther( "Z", All_Vector); + std::string bbb = get_US_Char_FromOther( "y", All_Vector); + std::string bbbb = get_US_Char_FromOther( "Y", All_Vector); + + std::string c = getKeyNrOf_OtherChar( "z", All_Vector); + std::string cc = getKeyNrOf_OtherChar( "Z", All_Vector); + std::string ccc = getKeyNrOf_OtherChar( "y", All_Vector); + std::string cccc = getKeyNrOf_OtherChar( "Y", All_Vector); + + std::string d = getKeyNrOf_USChar( "z", All_Vector); + std::string dd = getKeyNrOf_USChar( "Z", All_Vector); + std::string ddd = getKeyNrOf_USChar( "y", All_Vector); + std::string dddd = getKeyNrOf_USChar( "Y", All_Vector); + + std::cout << "get_Other_Char_FromUS z-Z-y-Y: " << ".." << a<< ".." < +#include +#include + +#include +#include +#include +#include +#include +#include +#include "mc_kmxfile.h" +#include "kmx_file.h" +#include "mc_savekeyboard.h" +#include "helpers.h" +#include "u16.h" + + +int dummytest_keymapWC(); +// In ths program we use a 3D-Vector Vector[language][Keys][Shiftstates] + + +typedef std::vector v_str_1D; +typedef std::vector > v_str_2D; +typedef std::vector > > v_str_3D; + +typedef std::vector v_WC_1D; +typedef std::vector > v_WC_2D; +typedef std::vector > > v_WC_3D; + +static int shift_state_count_WC = 2; // use shiftstate : no shift, shift +int run_DoConvert_Part1_getMapWC(int argc, char *argv[]); +// adapt from mc_kmxfile.cpp +void LoadKeyboardWC(); + +// use TranslateKeyboard, TranslateGroup,TranslateKey from mcompile +void run_DoConvert_Part2_TranslateKeyboardWC(); + +// adapt from mc_savekeyboard.cpp +void SaveKeyboardWC(); + + +// read configuration file, split and write to 3D-Vector WC(Data for US on [0][ ][ ] ) +bool write_US_ToVectorWC(v_WC_3D &vec, std::string language, const char *text); + +// 1. step: read complete Row of Configuration file US +bool CreateCompleteRow_USWC(v_WC_1D &complete_List, FILE *fpp, const char *text, std::string language); + +// 2nd step: write contents to 3D vector +bool Split_US_To_3D_VectorWC(v_WC_3D &all_US, v_WC_1D completeList); +/* +// make sure only a-z, A_Z is used +bool foundCharacterInListWC(std::string tok); + +// replace Name of Key WC(e.g. ) wih Keycode WC( e.g. 15 ) +int replace_PosKey_with_KeycodeWC(std::string in); +*/ +// append characters using GDK to 3D-Vector WC(Data for Other Language on [1][ ][ ] ) +bool append_other_ToVectorWC(v_WC_3D &All_Vector, GdkKeymap *keymap); +/* +// create an empty 2D vector containing "--" in all fields +v_str_2D create_empty_2DWC(int dim_rows, int dim_shifts); + +// find Keyvals to fill into 2D-Vector of Other Language +int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos); +*/ +// print both sets of characters WC(US and OtherLanguage) to console and file for comparison +bool extract_differenceWC(v_WC_3D &All_Vector); +/* +// get mapped key from Other WC(Other->US) +std::string get_Other_Char_FromUSWC(std::string in, v_str_3D &All_Vector); +// get mapped key from US->Other WC(US->Other) +std::string get_US_Char_FromOtherWC(std::string in, v_str_3D &All_Vector); +// get KeyNr from US +std::string getKeyNrOf_USCharWC(std::string in, v_str_3D &All_Vector); +// get KeyNr from Other +std::string getKeyNrOf_OtherCharWC(std::string in, v_str_3D &All_Vector); + +// for testing/debugging - may be deleted later +// prints out a 1:1 mapping US->Other +*/ +void print_simple_map_USWC(v_WC_3D &All_Vector, int shiftstate); +// prints out a 1:1 mapping Other->US +void print_simple_map_OtherWC(v_str_3D &All_Vector, int shiftstate); +// test of above functions WC(character mapping US <-> Other; KeyNr <-> CHaracter) +/*vvoid test_in_outWC(v_str_3D &All_Vector); +// testing of Vector contents WC( first row of US and Other) +bool testWC(v_str_3D &V); +*/ +// writing out mapping of some characters: a,b,m,w,x,y,z +void test_specific_CharactersWC(v_WC_3D &All_Vector); + + + +#endif /*KEYMAPWC_H*/ diff --git a/linux/mcompile/keymap/mcompile copy.cpp b/linux/mcompile/keymap/mcompile copy.cpp new file mode 100644 index 0000000000..be01ae6a08 --- /dev/null +++ b/linux/mcompile/keymap/mcompile copy.cpp @@ -0,0 +1,1104 @@ + +// MAY BE REMOVED LATER _S2 +/* + Name: mcompile + Copyright: Copyright (C) SIL International. + Documentation: + Description: + Create Date: 24 Apr 2014 + + Modified Date: 8 Apr 2015 + Authors: mcdurdin + Related Files: + Dependencies: + + Bugs: + Todo: + Notes: + History: 24 Apr 2014 - mcdurdin - I4174 - V9 - mcompile logs should be stored in diag folder + 16 Jun 2014 - mcdurdin - I4273 - V9.0 - Convert keyboards to Unicode before installing + 23 Jun 2014 - mcdurdin - I4279 - V9.0 - mcompile fails to start when converting keyboard to Unicode + 03 Aug 2014 - mcdurdin - I4353 - V9.0 - mnemonic layout recompiler mixes up deadkey rules + 03 Aug 2014 - mcdurdin - I4327 - V9.0 - Mnemonic layout compiler follow-up + 31 Dec 2014 - mcdurdin - I4549 - V9.0 - Mnemonic layout recompiler does not translate Lctrl Ralt for deadkeys correctly + 06 Feb 2015 - mcdurdin - I4552 - V9.0 - Add mnemonic recompile option to ignore deadkeys + 08 Apr 2015 - mcdurdin - I4651 - V9.0 - Mnemonic layout recompiler maps AltGr+VK_BKSLASH rather than VK_OEM_102 + +This is a copy of win/src/eng/mcompile.cpp +there are 2 options to run mcompile + -u ( which will be done later) + -d ( which will be done here ) + +mcompile -d runs 4 important steps: + -LoadKeyboard(); -> started to exchange for being cross platform ( old version is to the right ) + -int out = run_DoConvert_Part1_getMap(argc,argv); -> there is a version for getting the mapping (keymap.cpp) but it uses string. At the end we will need to se char16_t + -run_DoConvert_Part2_TranslateKeyboard(); -> + -SaveKeyboard(); -> + +*/ + +// run with ./mcompile -d in.kmx bla.dll 0407 out.kmx + +#include "mcompile.h" +#include "helpers.h" + +int main(int argc, char *argv[]) +{ //---------------------------------------- + // test if all cpps are acccessible: can be removed + // check_avaiability_of_modules_(); //_S2 + // check Paramtr: + std::wcout << L"arc: " << argc << L"\n"; + for ( int i=0; i deadkeys we will attack after the POC + // + // For each deadkey, we need to determine its possible outputs. Then we generate a VK + // rule for that deadkey, e.g. [K_LBRKT] > dk(c101) + // + // Next, update each rule that references the output from that deadkey to add an extra + // context deadkey at the end of the context match, e.g. 'a' dk(c101) + [K_SPACE] > 'b'. + // This will require a memory layout change for the .kmx file, plus fixups on the + // context+output index offsets + // + // --> virtual character keys + // + // [CTRL ' '] : we look at the character, and replace it in the same way, but merely + // switch the shift state from the VIRTUALCHARKEY to VIRTUALKEY, without changing any + // other properties of the key. + // + + // 3. Write the new keyman keyboard file +*/ + + // _S2 that's for windows -> remove !! + //if(!LoadNewLibrary(indll)) { + // LogError(L"Failed to load keyboard DLL (%d)", GetLastError()); + // return 2; + //} + + LPKEYBOARD kmxfile; +std::wcout << L" before LoadKbd: \n"; +std::wcout << L" before LoadKbd: " << infile_c << L".." << *infile_c <char + char16_t<->wchar_t +*/ + + +std::cout << " ++ UP TO HERE IN STEP 1 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; + +/* if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552 + SaveKeyboard(kmxfile, outfile); + } + + //DeleteReallocatedPointers(kmxfile); :TODO + delete kmxfile; + + return 0; + +*/ + + //------------------------------------ + //LoadKeyboard(); + //int out = run_DoConvert_Part1_getMap(argc,argv); + //run_DoConvert_Part2_TranslateKeyboard(); + //SaveKeyboard(); + std::cout << "################################################################################################################################### end mcompile \n"; + + return 0 ; +} + + +//TODO adapt for cross-platform +void LogError(PWSTR fmt, ...) { + /*WCHAR fmtbuf[256]; + + va_list vars; + va_start(vars, fmt); + _vsnwprintf_s(fmtbuf, _countof(fmtbuf), _TRUNCATE, fmt, vars); // I2248 // I3547 + fmtbuf[255] = 0; + _putws(fmtbuf);*/ +} + + + + + + + + + + + + + + + + + + + + + + + + +// +// m-to-p.cpp : Defines the entry point for the console application. +// +// Note: this program deliberately leaks memory as it has a very short life cycle and managing the memory allocations +// for the subcomponents of the compiled keyboard is an unnecessary optimisation. Just so you know. +// +/* +#include "pch.h" +#include + +#include +#include +#include + +BOOL DoConvert(LPKEYBOARD kbd, PWSTR kbid, BOOL bDeadkeyConversion); +BOOL SaveKeyboard(LPKEYBOARD kbd, PWSTR filename); +bool ImportRules(WCHAR *kbid, LPKEYBOARD kp, std::vector *FDeadkeys, BOOL bDeadkeyConversion); // I4353 // I4327 +BOOL ConvertKeyboardToUnicode(LPKEYBOARD kbd); // I4273 +int run(int argc, wchar_t * argv[]); + +std::vector FDeadkeys; // I4353 + +#define KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE_MCOMPILE KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE ".mcompile" + +int wmain(int argc, wchar_t * argv[]) +{ + return keyman_sentry_wmain(false, KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE_MCOMPILE, argc, argv, run); +} + +int run(int argc, wchar_t * argv[]) +{ + if(argc < 3 || (argc < 5 && wcscmp(argv[1], L"-u") != 0)) { // I4273 + printf( + "Usage: mcompile -u infile.kmx outfile.kmx\n" + " mcompile [-d] infile.kmx kbdfile.dll kbid outfile.kmx\n" + " With -u parameter, converts keyboard from ANSI to Unicode\n" + " Otherwise, mcompile converts a Keyman mnemonic layout to a\n" + " positional one based on the Windows keyboard\n" + " layout file given by kbdfile.dll\n\n" + " kbid should be a hexadecimal number e.g. 409 for US English\n" + " -d convert deadkeys to plain keys\n"); // I4552 + + return 1; + } + + if(wcscmp(argv[1], L"-u") == 0) { // I4273 + wchar_t *infile = argv[2], *outfile = argv[3]; + + LPKEYBOARD kmxfile; + + if(!LoadKeyboard(infile, &kmxfile)) { + LogError(L"Failed to load keyboard (%d)", GetLastError()); + return 3; + } + + if(ConvertKeyboardToUnicode(kmxfile)) { + SaveKeyboard(kmxfile, outfile); + } + + //DeleteReallocatedPointers(kmxfile); :TODO + delete[] kmxfile; + + return 0; // I4279 + } + + int bDeadkeyConversion = wcscmp(argv[1], L"-d") == 0; // I4552 + int n = (bDeadkeyConversion ? 2 : 1); + + wchar_t *infile = argv[n], *indll = argv[n+1], *kbid = argv[n+2], *outfile = argv[n+3]; + + wprintf(L"mcompile%ls \"%ls\" \"%ls\" \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d":L"", infile, indll, kbid, outfile); // I4174 + + // 1. Load the keyman keyboard file + + // 2. For each key on the system layout, determine its output character and perform a + // 1-1 replacement on the keyman keyboard of that character with the base VK + shift + // state. This fixup will transform the char to a vk, which will avoid any issues + // with the key. + // + // --> deadkeys we will attack after the POC + // + // For each deadkey, we need to determine its possible outputs. Then we generate a VK + // rule for that deadkey, e.g. [K_LBRKT] > dk(c101) + // + // Next, update each rule that references the output from that deadkey to add an extra + // context deadkey at the end of the context match, e.g. 'a' dk(c101) + [K_SPACE] > 'b'. + // This will require a memory layout change for the .kmx file, plus fixups on the + // context+output index offsets + // + // --> virtual character keys + // + // [CTRL ' '] : we look at the character, and replace it in the same way, but merely + // switch the shift state from the VIRTUALCHARKEY to VIRTUALKEY, without changing any + // other properties of the key. + // + + // 3. Write the new keyman keyboard file + + if(!LoadNewLibrary(indll)) { + LogError(L"Failed to load keyboard DLL (%d)", GetLastError()); + return 2; + } + + LPKEYBOARD kmxfile; + + if(!LoadKeyboard(infile, &kmxfile)) { + LogError(L"Failed to load keyboard (%d)", GetLastError()); + return 3; + } + + if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552 + SaveKeyboard(kmxfile, outfile); + } + + //DeleteReallocatedPointers(kmxfile); :TODO + delete kmxfile; + + return 0; +} + + +// +// Map of all US English virtual key codes that we can translate +// +const WORD VKMap[] = { + 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', + '0','1','2','3','4','5','6','7','8','9', + VK_SPACE, + VK_ACCENT, VK_HYPHEN, VK_EQUAL, + VK_LBRKT, VK_RBRKT, VK_BKSLASH, + VK_COLON, VK_QUOTE, + VK_COMMA, VK_PERIOD, VK_SLASH, + VK_xDF, VK_OEM_102, + 0 +}; + + +// +// Map of all shift states that we will work with +// +const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; + +// +// TranslateKey +// +// For each key rule on the keyboard, remap its key to the +// correct shift state and key. Adjust the LCTRL+RALT -> RALT if necessary +// +void TranslateKey(LPKEY key, WORD vk, UINT shift, WCHAR ch) { + + // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. + // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" + // to provide an alternate.. + if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) + shift &= ~LCTRLFLAG; + + if(key->ShiftFlags == 0 && key->Key == ch) { + // Key is a mnemonic key with no shift state defined. + // Remap the key according to the character on the key cap. + //LogError(L"Converted mnemonic rule on line %d, + '%c' TO + [%x K_%d]", key->Line, key->Key, shift, vk); + key->ShiftFlags = ISVIRTUALKEY | shift; + key->Key = vk; + } else if(key->ShiftFlags & VIRTUALCHARKEY && key->Key == ch) { + // Key is a virtual character key with a hard-coded shift state. + // Do not remap the shift state, just move the key. + // This will not result in 100% wonderful mappings as there could + // be overlap, depending on how keys are arranged on the target layout. + // But that is up to the designer. + //LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, key->ShiftFlags & ~VIRTUALCHARKEY, vk); + key->ShiftFlags &= ~VIRTUALCHARKEY; + key->Key = vk; + } +} + +void TranslateGroup(LPGROUP group, WORD vk, UINT shift, WCHAR ch) { + for(unsigned int i = 0; i < group->cxKeyArray; i++) { + TranslateKey(&group->dpKeyArray[i], vk, shift, ch); + } +} + +void TranslateKeyboard(LPKEYBOARD kbd, WORD vk, UINT shift, WCHAR ch) { + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + TranslateGroup(&kbd->dpGroupArray[i], vk, shift, ch); + } + } +} + +void ReportUnconvertedKeyRule(LPKEY key) { + if(key->ShiftFlags == 0) { + LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); + } else if(key->ShiftFlags & VIRTUALCHARKEY) { + LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); + } +} + +void ReportUnconvertedGroupRules(LPGROUP group) { + for(unsigned int i = 0; i < group->cxKeyArray; i++) { + ReportUnconvertedKeyRule(&group->dpKeyArray[i]); + } +} + +void ReportUnconvertedKeyboardRules(LPKEYBOARD kbd) { + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + ReportUnconvertedGroupRules(&kbd->dpGroupArray[i]); + } + } +} + +void TranslateDeadkeyKey(LPKEY key, WCHAR deadkey, WORD vk, UINT shift, WORD ch) { + if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { + + // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. + // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" + // to provide an alternate.. + if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4327 + shift &= ~LCTRLFLAG; + + if(key->ShiftFlags == 0) { + //LogError("Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d]", key->Line, key->Key, deadkey, shift, vk); + key->ShiftFlags = ISVIRTUALKEY | shift; + } else { + //LogError("Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO dk(%d) + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, deadkey, key->ShiftFlags & ~VIRTUALCHARKEY, vk); + key->ShiftFlags &= ~VIRTUALCHARKEY; + } + + int len = wcslen(key->dpContext); + PWSTR context = new WCHAR[len + 4]; + memcpy(context, key->dpContext, len * sizeof(WCHAR)); + context[len] = UC_SENTINEL; + context[len+1] = CODE_DEADKEY; + context[len+2] = deadkey; + context[len+3] = 0; + key->dpContext = context; + key->Key = vk; + } +} + +void TranslateDeadkeyGroup(LPGROUP group, WCHAR deadkey, WORD vk, UINT shift, WORD ch) { + for(unsigned int i = 0; i < group->cxKeyArray; i++) { + TranslateDeadkeyKey(&group->dpKeyArray[i], deadkey, vk, shift, ch); + } +} + +void TranslateDeadkeyKeyboard(LPKEYBOARD kbd, WCHAR deadkey, WORD vk, UINT shift, WORD ch) { + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + TranslateDeadkeyGroup(&kbd->dpGroupArray[i], deadkey, vk, shift, ch); + } + } +} + +void AddDeadkeyRule(LPKEYBOARD kbd, WCHAR deadkey, WORD vk, UINT shift) { + // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. + // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" + // to provide an alternate.. + if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4549 + shift &= ~LCTRLFLAG; + + // If the first group is not a matching-keys group, then we need to add into + // each subgroup, otherwise just the match group + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + LPKEY keys = new KEY[kbd->dpGroupArray[i].cxKeyArray + 1]; + memcpy(keys+1, kbd->dpGroupArray[i].dpKeyArray, kbd->dpGroupArray[i].cxKeyArray * sizeof(KEY)); + keys[0].dpContext = new WCHAR[1]; + keys[0].dpContext[0] = 0; + keys[0].dpOutput = new WCHAR[4]; // UC_SENTINEL, CODE_DEADKEY, deadkey_value, 0 + keys[0].dpOutput[0] = UC_SENTINEL; + keys[0].dpOutput[1] = CODE_DEADKEY; + keys[0].dpOutput[2] = deadkey; // TODO: translate to unique index + keys[0].dpOutput[3] = 0; + keys[0].Key = vk; + keys[0].Line = 0; + keys[0].ShiftFlags = shift | ISVIRTUALKEY; + kbd->dpGroupArray[i].dpKeyArray = keys; + kbd->dpGroupArray[i].cxKeyArray++; + //LogError("Add deadkey rule: + [%d K_%d] > dk(%d)", shift, vk, deadkey); + if(i == kbd->StartGroup[1]) break; // If this is the initial group, that's all we need to do. + } + } +} + +WCHAR ScanXStringForMaxDeadkeyID(LPWSTR str) { + WCHAR dkid = 0; + while(str && *str) { + if(*str == UC_SENTINEL) { + switch(*(str+1)) { + case CODE_DEADKEY: + dkid = max(dkid, *(str+2)); + } + } + str = incxstr(str); + } + return dkid; +} + +struct dkidmap { + WCHAR src_deadkey, dst_deadkey; +}; + +WCHAR GetUniqueDeadkeyID(LPKEYBOARD kbd, WCHAR deadkey) { + LPGROUP gp; + LPKEY kp; + LPSTORE sp; + UINT i, j; + WCHAR dkid = 0; + static WCHAR s_next_dkid = 0; + static dkidmap *s_dkids = NULL; + static int s_ndkids = 0; + + if(!kbd) { + if(s_dkids) { + delete s_dkids; + } + s_dkids = NULL; + s_ndkids = 0; + s_next_dkid = 0; + return 0; + } + + for(int i = 0; i < s_ndkids; i++) { + if(s_dkids[i].src_deadkey == deadkey) { + return s_dkids[i].dst_deadkey; + } + } + + if(s_next_dkid != 0) { + s_dkids = (dkidmap*) realloc(s_dkids, sizeof(dkidmap) * (s_ndkids+1)); + s_dkids[s_ndkids].src_deadkey = deadkey; + return s_dkids[s_ndkids++].dst_deadkey = ++s_next_dkid; + } + + for(i = 0, gp = kbd->dpGroupArray; i < kbd->cxGroupArray; i++, gp++) { + for(j = 0, kp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kp++) { + dkid = max(dkid, ScanXStringForMaxDeadkeyID(kp->dpContext)); + dkid = max(dkid, ScanXStringForMaxDeadkeyID(kp->dpOutput)); + } + dkid = max(dkid, ScanXStringForMaxDeadkeyID(gp->dpMatch)); + dkid = max(dkid, ScanXStringForMaxDeadkeyID(gp->dpNoMatch)); + } + + for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { + dkid = max(dkid, ScanXStringForMaxDeadkeyID(sp->dpString)); + } + + s_dkids = (dkidmap*) realloc(s_dkids, sizeof(dkidmap) * (s_ndkids+1)); + s_dkids[s_ndkids].src_deadkey = deadkey; + return s_dkids[s_ndkids++].dst_deadkey = s_next_dkid = ++dkid; +} + + +void ConvertDeadkey(LPKEYBOARD kbd, WORD vk, UINT shift, WCHAR deadkey) { + WORD deadkeys[512], *pdk; + + // Lookup the deadkey table for the deadkey in the physical keyboard + // Then for each character, go through and map it through + + WCHAR dkid = GetUniqueDeadkeyID(kbd, deadkey); + + // Add the deadkey to the mapping table for use in the import rules phase + DeadkeyMapping deadkeyMapping = { deadkey, dkid, shift, vk }; // I4353 + FDeadkeys.push_back(deadkeyMapping); //dkid, vk, shift); // I4353 + + AddDeadkeyRule(kbd, dkid, vk, shift); + + GetDeadkeys(deadkey, pdk = deadkeys); // returns array of [usvk, ch_out] pairs + while(*pdk) { + // Look up the ch + UINT vkUnderlying = VKUnderlyingLayoutToVKUS(*pdk); + TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); + pdk+=3; + } +} + +BOOL SetKeyboardToPositional(LPKEYBOARD kbd) { + LPSTORE sp; + UINT i; + for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { + if(sp->dwSystemID == TSS_MNEMONIC) { + if(!sp->dpString) { + LogError(L"Invalid &mnemoniclayout system store"); + return FALSE; + } + if(wcscmp(sp->dpString, L"1") != 0) { + LogError(L"Keyboard is not a mnemonic layout keyboard"); + return FALSE; + } + *sp->dpString = '0'; + return TRUE; + } + } + + LogError(L"Keyboard is not a mnemonic layout keyboard"); + return FALSE; +} + +BOOL DoConvert(LPKEYBOARD kbd, LPWSTR kbid, BOOL bDeadkeyConversion) { // I4552 + WCHAR DeadKey; + + if(!SetKeyboardToPositional(kbd)) return FALSE; + + // Go through each of the shift states - base, shift, ctrl+alt, ctrl+alt+shift, [caps vs ncaps?] + // Currently, we go in this order so the 102nd key works. But this is not ideal for keyboards without 102nd key: // I4651 + // it catches only the first key that matches a given rule, but multiple keys may match that rule. This is particularly + // evident for the 102nd key on UK, for example, where \ can be generated with VK_OEM_102 or AltGr+VK_QUOTE. + // For now, we get the least shifted version, which is hopefully adequate. + + for(int j = 0; VKShiftState[j] != 0xFFFF; j++) { // I4651 + // Go through each possible key on the keyboard + for(int i = 0; VKMap[i]; i++) { // I4651 + UINT vkUnderlying = VKUSToVKUnderlyingLayout(VKMap[i]); + + WCHAR ch = CharFromVK(vkUnderlying, VKShiftState[j], &DeadKey); + + //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); + + if(bDeadkeyConversion) { // I4552 + if(ch == 0xFFFF) { + ch = DeadKey; + } + } + + switch(ch) { + case 0x0000: break; + case 0xFFFF: ConvertDeadkey(kbd, VKMap[i], VKShiftState[j], DeadKey); break; + default: TranslateKeyboard(kbd, VKMap[i], VKShiftState[j], ch); + } + + // + } + } + + ReportUnconvertedKeyboardRules(kbd); + + if(!ImportRules(kbid, kbd, &FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 + return FALSE; + } + + return TRUE; +} + +*/ +//---------old------------------------------------------- +/*#include "pch.h" +#include + +#include +#include +#include + +BOOL DoConvert(LPKEYBOARD kbd, PWSTR kbid, BOOL bDeadkeyConversion); +BOOL SaveKeyboard(LPKEYBOARD kbd, PWSTR filename); +bool ImportRules(WCHAR *kbid, LPKEYBOARD kp, std::vector *FDeadkeys, BOOL bDeadkeyConversion); // I4353 // I4327 +BOOL ConvertKeyboardToUnicode(LPKEYBOARD kbd); // I4273 +int run(int argc, wchar_t * argv[]); + +std::vector FDeadkeys; // I4353 + +#define KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE_MCOMPILE KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE ".mcompile" + +int wmain(int argc, wchar_t * argv[]) +{ + return keyman_sentry_wmain(false, KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE_MCOMPILE, argc, argv, run); +} + +int run(int argc, wchar_t * argv[]) +{ + if(argc < 3 || (argc < 5 && wcscmp(argv[1], L"-u") != 0)) { // I4273 + printf( + "Usage: mcompile -u infile.kmx outfile.kmx\n" + " mcompile [-d] infile.kmx kbdfile.dll kbid outfile.kmx\n" + " With -u parameter, converts keyboard from ANSI to Unicode\n" + " Otherwise, mcompile converts a Keyman mnemonic layout to a\n" + " positional one based on the Windows keyboard\n" + " layout file given by kbdfile.dll\n\n" + " kbid should be a hexadecimal number e.g. 409 for US English\n" + " -d convert deadkeys to plain keys\n"); // I4552 + + return 1; + } + + if(wcscmp(argv[1], L"-u") == 0) { // I4273 + wchar_t *infile = argv[2], *outfile = argv[3]; + + LPKEYBOARD kmxfile; + + if(!LoadKeyboard(infile, &kmxfile)) { + LogError(L"Failed to load keyboard (%d)", GetLastError()); + return 3; + } + + if(ConvertKeyboardToUnicode(kmxfile)) { + SaveKeyboard(kmxfile, outfile); + } + + //DeleteReallocatedPointers(kmxfile); :TODO + delete[] kmxfile; + + return 0; // I4279 + } + + int bDeadkeyConversion = wcscmp(argv[1], L"-d") == 0; // I4552 + int n = (bDeadkeyConversion ? 2 : 1); + + wchar_t *infile = argv[n], *indll = argv[n+1], *kbid = argv[n+2], *outfile = argv[n+3]; + + wprintf(L"mcompile%ls \"%ls\" \"%ls\" \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d":L"", infile, indll, kbid, outfile); // I4174 + + // 1. Load the keyman keyboard file + + // 2. For each key on the system layout, determine its output character and perform a + // 1-1 replacement on the keyman keyboard of that character with the base VK + shift + // state. This fixup will transform the char to a vk, which will avoid any issues + // with the key. + // + // --> deadkeys we will attack after the POC + // + // For each deadkey, we need to determine its possible outputs. Then we generate a VK + // rule for that deadkey, e.g. [K_LBRKT] > dk(c101) + // + // Next, update each rule that references the output from that deadkey to add an extra + // context deadkey at the end of the context match, e.g. 'a' dk(c101) + [K_SPACE] > 'b'. + // This will require a memory layout change for the .kmx file, plus fixups on the + // context+output index offsets + // + // --> virtual character keys + // + // [CTRL ' '] : we look at the character, and replace it in the same way, but merely + // switch the shift state from the VIRTUALCHARKEY to VIRTUALKEY, without changing any + // other properties of the key. + // + + // 3. Write the new keyman keyboard file + + if(!LoadNewLibrary(indll)) { + LogError(L"Failed to load keyboard DLL (%d)", GetLastError()); + return 2; + } + + LPKEYBOARD kmxfile; + + if(!LoadKeyboard(infile, &kmxfile)) { + LogError(L"Failed to load keyboard (%d)", GetLastError()); + return 3; + } + + if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552 + SaveKeyboard(kmxfile, outfile); + } + + //DeleteReallocatedPointers(kmxfile); :TODO + delete kmxfile; + + return 0; +} + + +// +// Map of all US English virtual key codes that we can translate +// +const WORD VKMap[] = { + 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', + '0','1','2','3','4','5','6','7','8','9', + VK_SPACE, + VK_ACCENT, VK_HYPHEN, VK_EQUAL, + VK_LBRKT, VK_RBRKT, VK_BKSLASH, + VK_COLON, VK_QUOTE, + VK_COMMA, VK_PERIOD, VK_SLASH, + VK_xDF, VK_OEM_102, + 0 +}; + + +// +// Map of all shift states that we will work with +// +const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; + +// +// TranslateKey +// +// For each key rule on the keyboard, remap its key to the +// correct shift state and key. Adjust the LCTRL+RALT -> RALT if necessary +// +void TranslateKey(LPKEY key, WORD vk, UINT shift, WCHAR ch) { + + // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. + // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" + // to provide an alternate.. + if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) + shift &= ~LCTRLFLAG; + + if(key->ShiftFlags == 0 && key->Key == ch) { + // Key is a mnemonic key with no shift state defined. + // Remap the key according to the character on the key cap. + //LogError(L"Converted mnemonic rule on line %d, + '%c' TO + [%x K_%d]", key->Line, key->Key, shift, vk); + key->ShiftFlags = ISVIRTUALKEY | shift; + key->Key = vk; + } else if(key->ShiftFlags & VIRTUALCHARKEY && key->Key == ch) { + // Key is a virtual character key with a hard-coded shift state. + // Do not remap the shift state, just move the key. + // This will not result in 100% wonderful mappings as there could + // be overlap, depending on how keys are arranged on the target layout. + // But that is up to the designer. + //LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, key->ShiftFlags & ~VIRTUALCHARKEY, vk); + key->ShiftFlags &= ~VIRTUALCHARKEY; + key->Key = vk; + } +} + +void TranslateGroup(LPGROUP group, WORD vk, UINT shift, WCHAR ch) { + for(unsigned int i = 0; i < group->cxKeyArray; i++) { + TranslateKey(&group->dpKeyArray[i], vk, shift, ch); + } +} + +void TranslateKeyboard(LPKEYBOARD kbd, WORD vk, UINT shift, WCHAR ch) { + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + TranslateGroup(&kbd->dpGroupArray[i], vk, shift, ch); + } + } +} + +void ReportUnconvertedKeyRule(LPKEY key) { + if(key->ShiftFlags == 0) { + LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); + } else if(key->ShiftFlags & VIRTUALCHARKEY) { + LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); + } +} + +void ReportUnconvertedGroupRules(LPGROUP group) { + for(unsigned int i = 0; i < group->cxKeyArray; i++) { + ReportUnconvertedKeyRule(&group->dpKeyArray[i]); + } +} + +void ReportUnconvertedKeyboardRules(LPKEYBOARD kbd) { + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + ReportUnconvertedGroupRules(&kbd->dpGroupArray[i]); + } + } +} + +void TranslateDeadkeyKey(LPKEY key, WCHAR deadkey, WORD vk, UINT shift, WORD ch) { + if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { + + // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. + // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" + // to provide an alternate.. + if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4327 + shift &= ~LCTRLFLAG; + + if(key->ShiftFlags == 0) { + //LogError("Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d]", key->Line, key->Key, deadkey, shift, vk); + key->ShiftFlags = ISVIRTUALKEY | shift; + } else { + //LogError("Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO dk(%d) + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, deadkey, key->ShiftFlags & ~VIRTUALCHARKEY, vk); + key->ShiftFlags &= ~VIRTUALCHARKEY; + } + + int len = wcslen(key->dpContext); + PWSTR context = new WCHAR[len + 4]; + memcpy(context, key->dpContext, len * sizeof(WCHAR)); + context[len] = UC_SENTINEL; + context[len+1] = CODE_DEADKEY; + context[len+2] = deadkey; + context[len+3] = 0; + key->dpContext = context; + key->Key = vk; + } +} + +void TranslateDeadkeyGroup(LPGROUP group, WCHAR deadkey, WORD vk, UINT shift, WORD ch) { + for(unsigned int i = 0; i < group->cxKeyArray; i++) { + TranslateDeadkeyKey(&group->dpKeyArray[i], deadkey, vk, shift, ch); + } +} + +void TranslateDeadkeyKeyboard(LPKEYBOARD kbd, WCHAR deadkey, WORD vk, UINT shift, WORD ch) { + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + TranslateDeadkeyGroup(&kbd->dpGroupArray[i], deadkey, vk, shift, ch); + } + } +} + +void AddDeadkeyRule(LPKEYBOARD kbd, WCHAR deadkey, WORD vk, UINT shift) { + // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. + // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" + // to provide an alternate.. + if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4549 + shift &= ~LCTRLFLAG; + + // If the first group is not a matching-keys group, then we need to add into + // each subgroup, otherwise just the match group + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + LPKEY keys = new KEY[kbd->dpGroupArray[i].cxKeyArray + 1]; + memcpy(keys+1, kbd->dpGroupArray[i].dpKeyArray, kbd->dpGroupArray[i].cxKeyArray * sizeof(KEY)); + keys[0].dpContext = new WCHAR[1]; + keys[0].dpContext[0] = 0; + keys[0].dpOutput = new WCHAR[4]; // UC_SENTINEL, CODE_DEADKEY, deadkey_value, 0 + keys[0].dpOutput[0] = UC_SENTINEL; + keys[0].dpOutput[1] = CODE_DEADKEY; + keys[0].dpOutput[2] = deadkey; // TODO: translate to unique index + keys[0].dpOutput[3] = 0; + keys[0].Key = vk; + keys[0].Line = 0; + keys[0].ShiftFlags = shift | ISVIRTUALKEY; + kbd->dpGroupArray[i].dpKeyArray = keys; + kbd->dpGroupArray[i].cxKeyArray++; + //LogError("Add deadkey rule: + [%d K_%d] > dk(%d)", shift, vk, deadkey); + if(i == kbd->StartGroup[1]) break; // If this is the initial group, that's all we need to do. + } + } +} + +WCHAR ScanXStringForMaxDeadkeyID(LPWSTR str) { + WCHAR dkid = 0; + while(str && *str) { + if(*str == UC_SENTINEL) { + switch(*(str+1)) { + case CODE_DEADKEY: + dkid = max(dkid, *(str+2)); + } + } + str = incxstr(str); + } + return dkid; +} + +struct dkidmap { + WCHAR src_deadkey, dst_deadkey; +}; + +WCHAR GetUniqueDeadkeyID(LPKEYBOARD kbd, WCHAR deadkey) { + LPGROUP gp; + LPKEY kp; + LPSTORE sp; + UINT i, j; + WCHAR dkid = 0; + static WCHAR s_next_dkid = 0; + static dkidmap *s_dkids = NULL; + static int s_ndkids = 0; + + if(!kbd) { + if(s_dkids) { + delete s_dkids; + } + s_dkids = NULL; + s_ndkids = 0; + s_next_dkid = 0; + return 0; + } + + for(int i = 0; i < s_ndkids; i++) { + if(s_dkids[i].src_deadkey == deadkey) { + return s_dkids[i].dst_deadkey; + } + } + + if(s_next_dkid != 0) { + s_dkids = (dkidmap*) realloc(s_dkids, sizeof(dkidmap) * (s_ndkids+1)); + s_dkids[s_ndkids].src_deadkey = deadkey; + return s_dkids[s_ndkids++].dst_deadkey = ++s_next_dkid; + } + + for(i = 0, gp = kbd->dpGroupArray; i < kbd->cxGroupArray; i++, gp++) { + for(j = 0, kp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kp++) { + dkid = max(dkid, ScanXStringForMaxDeadkeyID(kp->dpContext)); + dkid = max(dkid, ScanXStringForMaxDeadkeyID(kp->dpOutput)); + } + dkid = max(dkid, ScanXStringForMaxDeadkeyID(gp->dpMatch)); + dkid = max(dkid, ScanXStringForMaxDeadkeyID(gp->dpNoMatch)); + } + + for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { + dkid = max(dkid, ScanXStringForMaxDeadkeyID(sp->dpString)); + } + + s_dkids = (dkidmap*) realloc(s_dkids, sizeof(dkidmap) * (s_ndkids+1)); + s_dkids[s_ndkids].src_deadkey = deadkey; + return s_dkids[s_ndkids++].dst_deadkey = s_next_dkid = ++dkid; +} + + +void ConvertDeadkey(LPKEYBOARD kbd, WORD vk, UINT shift, WCHAR deadkey) { + WORD deadkeys[512], *pdk; + + // Lookup the deadkey table for the deadkey in the physical keyboard + // Then for each character, go through and map it through + + WCHAR dkid = GetUniqueDeadkeyID(kbd, deadkey); + + // Add the deadkey to the mapping table for use in the import rules phase + DeadkeyMapping deadkeyMapping = { deadkey, dkid, shift, vk }; // I4353 + FDeadkeys.push_back(deadkeyMapping); //dkid, vk, shift); // I4353 + + AddDeadkeyRule(kbd, dkid, vk, shift); + + GetDeadkeys(deadkey, pdk = deadkeys); // returns array of [usvk, ch_out] pairs + while(*pdk) { + // Look up the ch + UINT vkUnderlying = VKUnderlyingLayoutToVKUS(*pdk); + TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); + pdk+=3; + } +} + +BOOL SetKeyboardToPositional(LPKEYBOARD kbd) { + LPSTORE sp; + UINT i; + for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { + if(sp->dwSystemID == TSS_MNEMONIC) { + if(!sp->dpString) { + LogError(L"Invalid &mnemoniclayout system store"); + return FALSE; + } + if(wcscmp(sp->dpString, L"1") != 0) { + LogError(L"Keyboard is not a mnemonic layout keyboard"); + return FALSE; + } + *sp->dpString = '0'; + return TRUE; + } + } + + LogError(L"Keyboard is not a mnemonic layout keyboard"); + return FALSE; +} + +BOOL DoConvert(LPKEYBOARD kbd, LPWSTR kbid, BOOL bDeadkeyConversion) { // I4552 + WCHAR DeadKey; + + if(!SetKeyboardToPositional(kbd)) return FALSE; + + // Go through each of the shift states - base, shift, ctrl+alt, ctrl+alt+shift, [caps vs ncaps?] + // Currently, we go in this order so the 102nd key works. But this is not ideal for keyboards without 102nd key: // I4651 + // it catches only the first key that matches a given rule, but multiple keys may match that rule. This is particularly + // evident for the 102nd key on UK, for example, where \ can be generated with VK_OEM_102 or AltGr+VK_QUOTE. + // For now, we get the least shifted version, which is hopefully adequate. + + for(int j = 0; VKShiftState[j] != 0xFFFF; j++) { // I4651 + // Go through each possible key on the keyboard + for(int i = 0; VKMap[i]; i++) { // I4651 + UINT vkUnderlying = VKUSToVKUnderlyingLayout(VKMap[i]); + + WCHAR ch = CharFromVK(vkUnderlying, VKShiftState[j], &DeadKey); + + //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); + + if(bDeadkeyConversion) { // I4552 + if(ch == 0xFFFF) { + ch = DeadKey; + } + } + + switch(ch) { + case 0x0000: break; + case 0xFFFF: ConvertDeadkey(kbd, VKMap[i], VKShiftState[j], DeadKey); break; + default: TranslateKeyboard(kbd, VKMap[i], VKShiftState[j], ch); + } + + // + } + } + + ReportUnconvertedKeyboardRules(kbd); + + if(!ImportRules(kbid, kbd, &FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 + return FALSE; + } + + return TRUE; +} + +void LogError(PWSTR fmt, ...) { + WCHAR fmtbuf[256]; + + va_list vars; + va_start(vars, fmt); + _vsnwprintf_s(fmtbuf, _countof(fmtbuf), _TRUNCATE, fmt, vars); // I2248 // I3547 + fmtbuf[255] = 0; + _putws(fmtbuf); +} +*/ diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index e67ea279e3..dbed9d5aab 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -2,20 +2,21 @@ # mcompile +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -project('mcompile', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') gtk = dependency('gtk+-3.0', version: '>= 2.4') -cpp_files = files( 'keymap.cpp', 'mcompile.cpp', 'mc_kmxfile.cpp', 'mc_savekeyboard.cpp', 'helpers.cpp', 'u16.cpp',) mcompile = executable( 'mcompile', sources: [cpp_files], dependencies: [gtk]) - -# keymap_WC +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -#project('keymap_WC', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') #gtk = dependency('gtk+-3.0', version: '>= 2.4') -#keymap_WC = executable( 'keymap_WC', sources: ['keymap_WC.cpp'], dependencies: [gtk]) +project('mcompile', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') +gtk = dependency('gtk+-3.0', version: '>= 2.4') +cpp_files = files( 'keymap.cpp', 'mcompile.cpp', 'mc_kmxfile.cpp', 'mc_savekeyboard.cpp', 'helpers.cpp', 'u16.cpp',) +mcompile = executable( 'mcompile', sources: [cpp_files], dependencies: [gtk]) # keymapWC +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -#project('keymapWC', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') #gtk = dependency('gtk+-3.0', version: '>= 2.4') -cpp_files = files( 'keymapWC.cpp',) #keymapWC = executable( 'keymapWC', sources: [cpp_files], dependencies: [gtk]) +#project('keymapWC', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') +#gtk = dependency('gtk+-3.0', version: '>= 2.4') +#cpp_files = files( 'keymapWC.cpp','mc_kmxfile.cpp', 'mc_savekeyboard.cpp', 'helpers.cpp', 'u16.cpp',) +#keymapWC = executable( 'keymapWC', sources: [cpp_files], dependencies: [gtk]) # keymap +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -#project('keymap', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') #gtk = dependency('gtk+-3.0', version: '>= 2.4') -#cpp_files = files( 'keymap.cpp', 'mc_kmxfile.cpp', 'mc_savekeyboard.cpp', 'helpers.cpp', 'u16.cpp',) #keymap = executable( 'keymap', sources: [cpp_files], dependencies: [gtk]) +#project('keymap', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') +#gtk = dependency('gtk+-3.0', version: '>= 2.4') +#cpp_files = files( 'keymap.cpp', 'mc_kmxfile.cpp', 'mc_savekeyboard.cpp', 'helpers.cpp', 'u16.cpp',) +#keymap = executable( 'keymap', sources: [cpp_files], dependencies: [gtk]) From e8cede8d4fce8e85ab7022efaf9b5bc619dd3a34 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 26 Jun 2023 15:02:14 +0200 Subject: [PATCH 035/327] feat(linux): mcompile add converting function, typedef --- linux/mcompile/keymap/km_types.h | 3 +++ linux/mcompile/keymap/u16.cpp | 7 +++++++ linux/mcompile/keymap/u16.h | 2 ++ 3 files changed, 12 insertions(+) diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index aef959da10..d4415af52f 100644 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -49,6 +49,7 @@ typedef wchar_t* PWSTR; // _S2 needs to be removed/ wchart-> cha typedef PWSTR PKMX_WCHART; // _S2 needs to be removed/ wchart-> char16 typedef wchar_t* LPKMX_WCHART; // _S2 needs to be removed/ wchart-> char16 +typedef const wchar_t* PCKMX_WCHART; // _S2 needs to be removed/? typedef char* LPSTR; // _S2 needs to be removed? typedef LPSTR LPKMX_STR; // _S2 needs to be removed? @@ -66,6 +67,8 @@ typedef char* PKMX_STR; // _S2 needs to be removed/? typedef KMX_CHAR* PKMX_CHAR; // _S2 needs to be removed/? + + typedef uint32_t KMX_UINT; typedef KMX_BYTE* PKMX_BYTE; diff --git a/linux/mcompile/keymap/u16.cpp b/linux/mcompile/keymap/u16.cpp index f5fe5457e3..7ed18a1488 100644 --- a/linux/mcompile/keymap/u16.cpp +++ b/linux/mcompile/keymap/u16.cpp @@ -12,6 +12,13 @@ int dummytest_u16(){ return 0; } +//const wchar_t* <- const char* +wchar_t* wchart_from_char( char* c) { + std::string str(c); + std::wstring wstr = wstring_from_string(str); + wchar_t* wc = (wchar_t*) wstr.c_str(); +} + //String <- wstring std::string string_from_wstring(std::wstring const str) { std::wstring_convert, wchar_t> converter; diff --git a/linux/mcompile/keymap/u16.h b/linux/mcompile/keymap/u16.h index ad6f07e92c..7a7cc39b8d 100644 --- a/linux/mcompile/keymap/u16.h +++ b/linux/mcompile/keymap/u16.h @@ -12,6 +12,8 @@ int dummytest_u16(); +wchar_t* wchart_from_char( char* c) ; + std::string string_from_wstring(std::wstring const str); std::wstring wstring_from_string(std::string const str); std::u16string u16string_from_string(std::string const str); From b62a8140e4ecef355e7891daba679c41709d6ce7 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 27 Jun 2023 12:26:10 +0200 Subject: [PATCH 036/327] feat(linux): mcompile copy and use filesystem.cpp/h --- linux/mcompile/keymap/filesystem.cpp | 188 +++++++++++++++++++++++++++ linux/mcompile/keymap/filesystem.h | 12 ++ linux/mcompile/keymap/meson.build | 2 +- 3 files changed, 201 insertions(+), 1 deletion(-) create mode 100644 linux/mcompile/keymap/filesystem.cpp create mode 100644 linux/mcompile/keymap/filesystem.h diff --git a/linux/mcompile/keymap/filesystem.cpp b/linux/mcompile/keymap/filesystem.cpp new file mode 100644 index 0000000000..a343641acc --- /dev/null +++ b/linux/mcompile/keymap/filesystem.cpp @@ -0,0 +1,188 @@ + +#ifdef __EMSCRIPTEN__ +#include +#include +#endif + +#include +#include +#include +#include "filesystem.h" + +#ifdef _MSC_VER +#include +#else +#include +#endif + +//#define _DEBUG_FOPEN 1 + +#ifdef __EMSCRIPTEN__ + +const std::string get_wasm_file_path(const std::string& filename) { + // Verify that we are passing a fully-qualified path + // TODO: we need to support relative paths based on CWD +#if _DEBUG_FOPEN + std::cout << "get_wasm_file_path ENTER (" << filename << ")" << std::endl; +#endif + + assert( + (filename.length() > 0 && filename.at(0) == '/') || + (filename.length() > 1 && filename.at(1) == ':') + ); + +#if _DEBUG_FOPEN + std::cout << "get_wasm_file_path assert passed " << std::endl; +#endif + + EM_ASM_({ + //console.log('EM_ASM enter'); + let path = Module.UTF8ToString($0); + const isWin32Path = path.match(/^[a-zA-Z]:/); + + //console.log('EM_ASM path = '+path); + let root = '/nodefs-mount'; + if(!FS.analyzePath(root).exists) { + //console.log('EM_ASM mkdir '+root); + FS.mkdir(root); + if(!isWin32Path) { + //console.log('EM_ASM mount '+root); + FS.mount(NODEFS, {root : '/'}, root); + } + } + + if(isWin32Path) { + // Win32 path, one mount per drive + root += "/" + path.charAt(0); + if(!FS.analyzePath(root).exists) { + //console.log('EM_ASM mkdir '+root); + FS.mkdir(root); + //console.log('EM_ASM mount '+root); + FS.mount(NODEFS, {root : path.substr(0,3) }, root); + } + } + }, filename.c_str()); + +#if _DEBUG_FOPEN + std::cout << "get_wasm_file_path EM_ASM_ passed " << std::endl; +#endif + + std::string f = std::string("/nodefs-mount"); + + if(filename.length() > 2 && filename.at(1) == ':') { + f += std::string("/") + filename.at(0) + filename.substr(2); + } else { + f += filename; + } + +#if _DEBUG_FOPEN + std::cout << "get_wasm_file_path opening virtual path: " << f << std::endl; +#endif + + return f; +} + +FILE* fopen_wasm(const std::string& filename, const std::string& mode) { + std::string f = get_wasm_file_path(filename); + FILE* fp = fopen(f.c_str(), mode.c_str()); + +#if _DEBUG_FOPEN + std::cout << "get_wasm_file_path fopen called, returned " << fp << std::endl; +#endif + + return fp; +} + +#endif + +#ifndef _MSC_VER +#ifdef __EMSCRIPTEN__ +#define fopen_wrapper fopen_wasm +#else +#define fopen_wrapper fopen +#endif +#endif + +FILE* Open_File(const KMX_CHAR* Filename, const KMX_CHAR* mode) { +#ifdef _MSC_VER + std::string cpath = Filename; //, cmode = mode; + std::replace(cpath.begin(), cpath.end(), '/', '\\'); + return fopen(cpath.c_str(), (const KMX_CHAR*) mode); +#else + return fopen_wrapper(Filename, mode); + std::string cpath, cmode; + cpath = (const KMX_CHAR*) Filename; + cmode = (const KMX_CHAR*) mode; + return fopen_wrapper(cpath.c_str(), cmode.c_str()); +#endif +}; + +FILE* Open_File(const KMX_WCHART* Filename, const KMX_WCHART* mode) { +#ifdef _MSC_VER + std::wstring cpath = Filename; //, cmode = mode; + std::replace(cpath.begin(), cpath.end(), '/', '\\'); + return _wfsopen(cpath.c_str(), mode, _SH_DENYWR); +#else + std::string cpath, cmode; + cpath = string_from_wstring(Filename); + cmode = string_from_wstring(mode); + return fopen_wrapper(cpath.c_str(), cmode.c_str()); +#endif +}; + +FILE* Open_File(const KMX_WCHAR* Filename, const KMX_WCHAR* mode) { +#ifdef _MSC_VER + std::wstring cpath = convert_pchar16T_To_wstr((KMX_WCHAR*) Filename); + std::wstring cmode = convert_pchar16T_To_wstr((KMX_WCHAR*) mode); + std::replace(cpath.begin(), cpath.end(), '/', '\\'); + return _wfsopen(cpath.c_str(), cmode.c_str(), _SH_DENYWR); +#else + std::string cpath, cmode; + cpath = string_from_u16string(Filename); + cmode = string_from_u16string(mode); + return fopen_wrapper(cpath.c_str(), cmode.c_str()); +#endif +}; + +KMX_BOOL kmcmp_FileExists(const KMX_CHAR *filename) { + +#ifdef _MSC_VER + intptr_t n; + _finddata_t fi; + if((n = _findfirst(filename, &fi)) != -1) { + _findclose(n); + return TRUE; + } +#else //!_MSC_VER + +#ifdef __EMSCRIPTEN__ + std::string f = get_wasm_file_path(filename); +#else //!__EMSCRIPTEN__ + std::string f = filename; +#endif // !__EMSCRIPTEN__ + + if(access(f.c_str(), F_OK) != -1) { + return TRUE; + } + +#endif // !_MSC_VER + + return FALSE; +} + +KMX_BOOL kmcmp_FileExists(const KMX_WCHAR* filename) { +#ifdef _MSC_VER + intptr_t n; + _wfinddata_t fi; + if((n = _wfindfirst((wchar_t*) filename, &fi)) != -1) { + _findclose(n); + return TRUE; + } +#else + std::string cpath; + cpath = string_from_u16string(filename); + return kmcmp_FileExists(cpath.c_str()); +#endif + + return FALSE; +}; diff --git a/linux/mcompile/keymap/filesystem.h b/linux/mcompile/keymap/filesystem.h new file mode 100644 index 0000000000..eec98f9ecf --- /dev/null +++ b/linux/mcompile/keymap/filesystem.h @@ -0,0 +1,12 @@ +#pragma once + +#include +#include "u16.h" + +// Opens files on windows and non-windows platforms. Datatypes for Filename and mode must be the same. +// returns FILE* if file could be opened; FILE needs to be closed in calling function +FILE* Open_File(const KMX_CHAR* Filename, const KMX_CHAR* mode); +FILE* Open_File(const KMX_WCHART* Filename, const KMX_WCHART* mode); +FILE* Open_File(const KMX_WCHAR* Filename, const KMX_WCHAR* mode); +KMX_BOOL kmcmp_FileExists(const KMX_CHAR *filename); +KMX_BOOL kmcmp_FileExists(const KMX_WCHAR *filename); diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index dbed9d5aab..e7e05035b0 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -4,7 +4,7 @@ project('mcompile', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') gtk = dependency('gtk+-3.0', version: '>= 2.4') -cpp_files = files( 'keymap.cpp', 'mcompile.cpp', 'mc_kmxfile.cpp', 'mc_savekeyboard.cpp', 'helpers.cpp', 'u16.cpp',) +cpp_files = files( 'keymap.cpp', 'mcompile.cpp', 'filesystem.cpp', 'mc_kmxfile.cpp', 'mc_savekeyboard.cpp', 'helpers.cpp', 'u16.cpp',) mcompile = executable( 'mcompile', sources: [cpp_files], dependencies: [gtk]) # keymapWC +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From 84fc51bd3d9c6d3230f5dcce92981c2dc1f168f6 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 27 Jun 2023 16:03:53 +0200 Subject: [PATCH 037/327] feat(linux): mcompile loadKeyboard starts VerifyKeyboard&FixupKeyboard-still lots of comments, compiles but not fully functional yet --- linux/mcompile/keymap/README.md | 6 +- linux/mcompile/keymap/kmx_file.h | 3 + linux/mcompile/keymap/mc_kmxfile.cpp | 238 ++++++++++++++++++--------- linux/mcompile/keymap/mc_kmxfile.h | 4 +- linux/mcompile/keymap/mcompile.cpp | 102 +++++++++--- linux/mcompile/keymap/mcompile.h | 1 + 6 files changed, 251 insertions(+), 103 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index f892a5fde1..8560740bc1 100644 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -23,9 +23,13 @@ TODO include deadkeys TODO mcompile.cpp: open mcompile -u - option TODO replace GetLastError with SetError/AddCompileError/AddCompileWarning TODO u16.h u16.cpp include fron folder of kmx_u16.h -TOTO use wchar_t* as cmd-lne-par in main +TOTO use wchar_t* as cmd-lne-par in main ?? +TOTO changes inside VerifyKeyboard() +TOTO changes inside FixupKeyboard() +TODO check if I can use files from some other keyman path instead of a copy in keymap ( e.g. filesystem.h exists elsewhere) TODO ... //--------------------------- TOASK is using string OK, or do we use char, wchar? TOASK a-z, A_Z or more keys? ... +TOASK main/wmain? will we use wchar_t Filenames on Linux? diff --git a/linux/mcompile/keymap/kmx_file.h b/linux/mcompile/keymap/kmx_file.h index b25464632d..df543a2a0e 100644 --- a/linux/mcompile/keymap/kmx_file.h +++ b/linux/mcompile/keymap/kmx_file.h @@ -9,6 +9,9 @@ #include +//_S2 what is this and do we need it??? +#define UNREFERENCED_PARAMETER(P) (P) + #ifdef KMN_KBP // TODO: move this to a common namespace keyman::common::kmx_file or similar in the future namespace km { diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index c61f8b1ec1..d49717b638 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -1,95 +1,35 @@ #include "mc_kmxfile.h" +#include "helpers.h" +#include "u16.h" +#include int dummytest_mc_kmx_file(){ std::cout<< " dummytest_mc_kmx_file is available\t"; return 0; } -/* -KMX_DWORD TEST2; - -static KMX_BOOL LoadKeyboardFile(LPKMX_STR fileName, LPKEYBOARD *lpKeyboard); - KMX_BOOL VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz); LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); -*/ + /*void Err(wchar_t *s) { LogError(L"LoadKeyboard: %s, last error = %d\n", s, GetLastError()); }*/ -/*BOOL LoadKeyboard(LPWSTR fileName, LPKEYBOARD *lpKeyboard) { - DWORD sz; - LPBYTE buf; - HANDLE hFile; - LPKEYBOARD kbp; - PBYTE filebase; - - if(!fileName || !lpKeyboard) { - Err(L"Bad Filename"); - return FALSE; - } - - hFile = CreateFile(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - if(hFile == INVALID_HANDLE_VALUE) { - Err(L"Could not open file"); - return FALSE; - } - - sz = GetFileSize(hFile, NULL); - - buf = new BYTE[sz]; - - if(!buf) { - Err(L"Not allocmem"); - CloseHandle(hFile); - return FALSE; - } - - filebase = buf; - - if(!ReadFile(hFile, filebase, sz, &sz, NULL)) { - Err(L"errReadFile"); - CloseHandle(hFile); - delete[] buf; - return FALSE; - } - CloseHandle(hFile); - - if(!VerifyKeyboard(filebase, sz)) { - Err(L"errVerifyKeyboard"); - delete[] buf; - return FALSE; - } - - kbp = FixupKeyboard(buf, filebase, sz); - if(!kbp) { - Err(L"errFixupKeyboard"); - delete[] buf; - return FALSE; - } - - if(kbp->dwIdentifier != FILEID_COMPILED) { - Err(L"errNotFileID"); - delete[] buf; - return FALSE; - } - - *lpKeyboard = kbp; - return TRUE; -} +/* */ -/*PKMX_WCHART StringOffset(PKMX_BYTE base, KMX_DWORD offset) { +PKMX_WCHART StringOffset(PKMX_BYTE base, KMX_DWORD offset) { if(offset == 0) return NULL; return (PKMX_WCHART)(base + offset); -}*/ +} -/*LPKEYBOARD FixupKeyboard(PBYTE bufp, PBYTE base, DWORD dwFileSize) { +LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize) { + UNREFERENCED_PARAMETER(dwFileSize); - DWORD i, j; + KMX_DWORD i, j; PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD) base; PCOMP_GROUP cgp; PCOMP_STORE csp; @@ -98,7 +38,6 @@ LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); LPSTORE sp; LPGROUP gp; LPKEY kp; - kbp->dpStoreArray = (LPSTORE) (base + ckbp->dpStoreArray); kbp->dpGroupArray = (LPGROUP) (base + ckbp->dpGroupArray); @@ -118,14 +57,157 @@ LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); kp->dpContext = (PWSTR) (base + ckp->dpContext); } } - return kbp; } -*/ -/*BOOL VerifyKeyboard(LPBYTE filebase, DWORD sz) { - DWORD i; +KMX_BOOL VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz); + +KMX_BOOL LoadKeyboard(char* fileName, LPKEYBOARD *lpKeyboard) { + std::cout << "##### LoadKeyboard of mcompile started #####\n"; + std::cout << "fileName: " <dwIdentifier != FILEID_COMPILED) { + Err(L"errNotFileID"); + delete[] buf; + return FALSE; + }*/ + +/* + if(kbp->dwIdentifier != FILEID_COMPILED) { + delete [] buf; + //MyCout("errNotFileID",1); //_S2 ToDo find replacement: DebugLog("errNotFileID"); + // _S2 delete [] buf; ???? + return FALSE; + }*/ +MyCout("##### Line 198",1); + *lpKeyboard = kbp; + // _S2 delete [] buf; ???? + MyCout("##### LoadKeyboard of mcompile ended #####",1); + return TRUE; +} + + +KMX_BOOL VerifyKeyboard(LPBYTE filebase, KMX_DWORD sz) { + /*DWORD i; PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD) filebase; PCOMP_STORE csp; @@ -138,7 +220,7 @@ LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); if(csp->dwSystemID == TSS_COMPILEDVERSION) { wchar_t buf2[256]; if(csp->dpString == 0) { - wsprintf(buf2, L"errWrongFileVersion:NULL"); + wsprintf(buf2, L"errWrongFileVersion:NULL"); } else { wsprintf(buf2, L"errWrongFileVersion:%10.10ls", StringOffset(filebase, csp->dpString)); } @@ -149,10 +231,10 @@ LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); Err(L"errWrongFileVersion"); return FALSE; } - +*/ return TRUE; -}*/ +} //---------------------old---------------------------------------- diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 46016361f4..da2ee938fd 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -4,6 +4,7 @@ #include "km_types.h" #include "kmx_file.h" +#include "filesystem.h" #include // _S2 can be removed later @@ -73,7 +74,8 @@ typedef struct tagKEYBOARD { //HBITMAP hBitmap; // handle to the bitmap in the file; } KEYBOARD, *LPKEYBOARD; -KMX_BOOL LoadKeyboard(LPKMX_WCHART fileName, LPKEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? +KMX_BOOL LoadKeyboard(PCKMX_WCHART fileName, LPKEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? +KMX_BOOL LoadKeyboard(char* fileName, LPKEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? #endif diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 9ff129b6aa..7beab30d01 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -21,19 +21,33 @@ 31 Dec 2014 - mcdurdin - I4549 - V9.0 - Mnemonic layout recompiler does not translate Lctrl Ralt for deadkeys correctly 06 Feb 2015 - mcdurdin - I4552 - V9.0 - Add mnemonic recompile option to ignore deadkeys 08 Apr 2015 - mcdurdin - I4651 - V9.0 - Mnemonic layout recompiler maps AltGr+VK_BKSLASH rather than VK_OEM_102 + +This is a copy of win/src/eng/mcompile.cpp +there are 2 options to run mcompile + -u ( which will be done later) + -d ( which will be done here ) + +mcompile -d runs 4 important steps: + -LoadKeyboard(); -> started to exchange for being cross platform ( old version is to the right ) + -int out = run_DoConvert_Part1_getMap(argc,argv); -> there is a version for getting the mapping (keymap.cpp) but it uses string. At the end we will need to se char16_t + -run_DoConvert_Part2_TranslateKeyboard(); -> + -SaveKeyboard(); -> + */ +// run with ./mcompile -d in.kmx bla.dll 0407 out.kmx +//./mcompile -d /Projects/keyman/keyman/linux/mcompile/keymap/anii.kmx bla.dll 0407 /Projects/keyman/keyman/linux/mcompile/keymap/anii_out.kmx + #include "mcompile.h" #include "helpers.h" - -int main(gint argc, wchar_t *argv[]) +int main(int argc, char *argv[]) { //---------------------------------------- - // test if all cpps are acccessible: can be removed -check_avaiability_of_modules_(); //_S2 +//check_avaiability_of_modules_(); //_S2 - if(argc < 3 || (argc < 5 && wcscmp(argv[1], L"-u") != 0)) { // I4273 + /* //in case we use wmain(...wchar_t*) + if(argc < 3 || (argc < 5 && wcscmp(argv[1], L"-u") != 0)) { // I4273// I4273 printf( "Usage: mcompile -u infile.kmx outfile.kmx\n" " mcompile [-d] infile.kmx kbdfile.dll kbid outfile.kmx\n" @@ -46,7 +60,23 @@ check_avaiability_of_modules_(); //_S2 return 1; } -//----------------------------- + */ + + //in case we use main(...char*) + if(argc < 3 || (argc < 5 && strcmp(argv[1], "-u") != 0)) { // I4273 + printf( + "Usage: mcompile -u infile.kmx outfile.kmx\n" + " mcompile [-d] infile.kmx kbdfile.dll kbid outfile.kmx\n" + " With -u parameter, converts keyboard from ANSI to Unicode\n" + " Otherwise, mcompile converts a Keyman mnemonic layout to a\n" + " positional one based on the Windows keyboard\n" + " layout file given by kbdfile.dll\n\n" + " kbid should be a hexadecimal number e.g. 409 for US English\n" + " -d convert deadkeys to plain keys\n"); // I4552 + + return 1; + } +//--------u option will be done later---------------------- /* if(wcscmp(argv[1], L"-u") == 0) { // I4273 wchar_t *infile = argv[2], *outfile = argv[3]; @@ -66,15 +96,32 @@ check_avaiability_of_modules_(); //_S2 return 0; // I4279 }*/ -/*//----------------------------- +//----------------------------- + +std::cout<<"*********************************************************************************************"; + + +/* //in case we use wmain(...wchar_t*) int bDeadkeyConversion = wcscmp(argv[1], L"-d") == 0; // I4552 int n = (bDeadkeyConversion ? 2 : 1); +*/ - wchar_t *infile = argv[n], *indll = argv[n+1], *kbid = argv[n+2], *outfile = argv[n+3]; + //in case we use main(...char*) and proceed with char + int bDeadkeyConversion = strcmp(argv[1], "-d") == 0; // I4552 + int n = (bDeadkeyConversion ? 2 : 1); + char *infile = argv[n], *indll = argv[n+1], *kbid = argv[n+2], *outfile = argv[n+3]; + printf("mcompile%s \"%s\" \"%s\" \"%s\" \"%s\"\n", bDeadkeyConversion ? " -d":"", infile, indll, kbid, outfile); // I4174 + +/* //in case we use main(...char*) and proceed with wchar_t + int bDeadkeyConversion = strcmp(argv[1], "-d") == 0; // I4552 + int n = (bDeadkeyConversion ? 2 : 1); + char *infile_c = argv[n], *indll_c = argv[n+1], *kbid_c = argv[n+2], *outfile_c = argv[n+3]; + wchar_t *infile = wchart_from_char(infile_c) , *indll = wchart_from_char(indll_c) , *kbid = wchart_from_char(kbid_c) , *outfile = wchart_from_char(outfile_c) ; wprintf(L"mcompile%ls \"%ls\" \"%ls\" \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d":L"", infile, indll, kbid, outfile); // I4174 +*/ - // 1. Load the keyman keyboard file +/* // 1. Load the keyman keyboard file // 2. For each key on the system layout, determine its output character and perform a // 1-1 replacement on the keyman keyboard of that character with the base VK + shift @@ -99,26 +146,34 @@ check_avaiability_of_modules_(); //_S2 // // 3. Write the new keyman keyboard file - - if(!LoadNewLibrary(indll)) { - LogError(L"Failed to load keyboard DLL (%d)", GetLastError()); - return 2; - } +*/ LPKEYBOARD kmxfile; - if(!LoadKeyboard(infile, &kmxfile)) { - LogError(L"Failed to load keyboard (%d)", GetLastError()); + if (!LoadKeyboard(infile, &kmxfile)) { + std::cout << "TODO: Replace: Failed to load keyboard , GetLastError())\n"; //LogError(L"Failed to load keyboard (%d)", GetLastError()); return 3; } - if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552 +/* QUESTIONS / TODO +status: mcompile.cpp: Replacement of LogError +status mc_kmx-file.cpp: + find replacement: DebugLog + find replacement: VerifyKeyboard + wchar<->char + char16_t<->wchar_t +*/ + + +std::cout << " ++ UP TO HERE IN STEP 1 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; + +/* if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552 SaveKeyboard(kmxfile, outfile); } //DeleteReallocatedPointers(kmxfile); :TODO delete kmxfile; -VM + return 0; */ @@ -154,8 +209,6 @@ printf("°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° - - @@ -602,16 +655,19 @@ BOOL DoConvert(LPKEYBOARD kbd, LPWSTR kbid, BOOL bDeadkeyConversion) { // I455 return TRUE; } +*/ + +//TODO adapt for cross-platform void LogError(PWSTR fmt, ...) { - WCHAR fmtbuf[256]; + /*WCHAR fmtbuf[256]; va_list vars; va_start(vars, fmt); _vsnwprintf_s(fmtbuf, _countof(fmtbuf), _TRUNCATE, fmt, vars); // I2248 // I3547 fmtbuf[255] = 0; - _putws(fmtbuf); + _putws(fmtbuf);*/ } -*/ + //---------old------------------------------------------- /*#include "pch.h" #include diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 410a7975f4..4d55e18149 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -24,6 +24,7 @@ #include #include "keymap.h" +//int run(int argc, wchar_t* argv[]); //_S2 Do we need that? void LogError(PKMX_WCHART message, ...); From 925fdb5beba82d13007733259c65d25f325028b8 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 27 Jun 2023 18:39:07 +0200 Subject: [PATCH 038/327] feat(linux): mcompile exchange KMX_WCHART, comment out code --- linux/mcompile/keymap/keymap.cpp | 4 ++-- linux/mcompile/keymap/km_types.h | 2 +- linux/mcompile/keymap/kmx_file.h | 6 +++--- linux/mcompile/keymap/mc_kmxfile.cpp | 28 ++++++++++++---------------- linux/mcompile/keymap/mc_kmxfile.h | 16 ++++++++-------- 5 files changed, 26 insertions(+), 30 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 4f844e59b3..b1d6f473f7 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -528,7 +528,7 @@ void SaveKeyboard() {std::cout << "#### SaveKeyboard not implemented yet ! \n";} //-------------------------------------- //int main(gint argc, gchar *argv[]) // this is for use of single keymap -int main_keymap(gint argc, gchar *argv[]) // this is for use of keymap together with mcompile +/*int main_keymap(gint argc, gchar *argv[]) // this is for use of keymap together with mcompile { check_avaiability_of_modules_(); LoadKeyboard(); @@ -540,7 +540,7 @@ int main_keymap(gint argc, gchar *argv[]) // this is for use of keymap togethe std::cout << "################################################################################################################################### end keymap \n"; return out ; -} +}*/ // old ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ /* static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index d4415af52f..4365a01201 100644 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -48,7 +48,7 @@ typedef KMX_WCHAR* PKMX_WCHAR; // _S2 typedef wchar_t* PWSTR; // _S2 needs to be removed/ wchart-> char16 typedef PWSTR PKMX_WCHART; // _S2 needs to be removed/ wchart-> char16 -typedef wchar_t* LPKMX_WCHART; // _S2 needs to be removed/ wchart-> char16 +//typedef wchar_t* LPKMX_WCHART; // _S2 needs to be removed/ wchart-> char16 typedef const wchar_t* PCKMX_WCHART; // _S2 needs to be removed/? typedef char* LPSTR; // _S2 needs to be removed? diff --git a/linux/mcompile/keymap/kmx_file.h b/linux/mcompile/keymap/kmx_file.h index df543a2a0e..a5478a0389 100644 --- a/linux/mcompile/keymap/kmx_file.h +++ b/linux/mcompile/keymap/kmx_file.h @@ -11,7 +11,7 @@ //_S2 what is this and do we need it??? #define UNREFERENCED_PARAMETER(P) (P) - +#define TRUNCATE ((size_t)-1) #ifdef KMN_KBP // TODO: move this to a common namespace keyman::common::kmx_file or similar in the future namespace km { @@ -308,8 +308,8 @@ struct COMP_STORE { }; struct COMP_KEY { - KMX_WORD Key; - KMX_WORD _reserved; + KMX_WORD Key; + KMX_WORD _reserved; KMX_DWORD Line; KMX_DWORD ShiftFlags; KMX_DWORD dpOutput; diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index d49717b638..4a0c910cf4 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -16,12 +16,10 @@ LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); /*void Err(wchar_t *s) { LogError(L"LoadKeyboard: %s, last error = %d\n", s, GetLastError()); }*/ -/* -*/ -PKMX_WCHART StringOffset(PKMX_BYTE base, KMX_DWORD offset) { +PKMX_WCHAR StringOffset(PKMX_BYTE base, KMX_DWORD offset) { if(offset == 0) return NULL; - return (PKMX_WCHART)(base + offset); + return (PKMX_WCHAR)(base + offset); } @@ -49,20 +47,18 @@ LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize) { for(gp = kbp->dpGroupArray, cgp = (PCOMP_GROUP) gp, i = 0; i < kbp->cxGroupArray; i++, gp++, cgp++) { gp->dpName = StringOffset(base, cgp->dpName); gp->dpKeyArray = (LPKEY) (base + cgp->dpKeyArray); - if(cgp->dpMatch != NULL) gp->dpMatch = (PWSTR) (base + cgp->dpMatch); - if(cgp->dpNoMatch != NULL) gp->dpNoMatch = (PWSTR) (base + cgp->dpNoMatch); + if(cgp->dpMatch != NULL) gp->dpMatch = (PKMX_WCHAR) (base + cgp->dpMatch); + if(cgp->dpNoMatch != NULL) gp->dpNoMatch = (PKMX_WCHAR) (base + cgp->dpNoMatch); for(kp = gp->dpKeyArray, ckp = (PCOMP_KEY) kp, j = 0; j < gp->cxKeyArray; j++, kp++, ckp++) { - kp->dpOutput = (PWSTR) (base + ckp->dpOutput); - kp->dpContext = (PWSTR) (base + ckp->dpContext); + kp->dpOutput = (PKMX_WCHAR) (base + ckp->dpOutput); + kp->dpContext = (PKMX_WCHAR) (base + ckp->dpContext); } } return kbp; } -KMX_BOOL VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz); - KMX_BOOL LoadKeyboard(char* fileName, LPKEYBOARD *lpKeyboard) { std::cout << "##### LoadKeyboard of mcompile started #####\n"; std::cout << "fileName: " <dwSystemID == TSS_COMPILEDVERSION) { wchar_t buf2[256]; if(csp->dpString == 0) { - wsprintf(buf2, L"errWrongFileVersion:NULL"); + // _S2 wsprintf(buf2, L"errWrongFileVersion:NULL"); } else { - wsprintf(buf2, L"errWrongFileVersion:%10.10ls", StringOffset(filebase, csp->dpString)); + // _S2 wsprintf(buf2, L"errWrongFileVersion:%10.10ls", StringOffset(filebase, csp->dpString)); } - Err(buf2); + // _S2 Err(buf2); return FALSE; } } - Err(L"errWrongFileVersion"); + // _S2 Err(L"errWrongFileVersion"); return FALSE; } -*/ +/**/ return TRUE; } diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index da2ee938fd..22cb56baab 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -16,8 +16,8 @@ int dummytest_mc_kmx_file(); typedef struct tagSTORE { KMX_DWORD dwSystemID; - PKMX_WCHART dpName; - PKMX_WCHART dpString; + PKMX_WCHAR dpName; + PKMX_WCHAR dpString; } STORE, *LPSTORE; @@ -25,16 +25,16 @@ typedef struct tagKEY { KMX_WCHAR Key; KMX_DWORD Line; KMX_DWORD ShiftFlags; - PKMX_WCHART dpOutput; - PKMX_WCHART dpContext; + PKMX_WCHAR dpOutput; + PKMX_WCHAR dpContext; } KEY, *LPKEY; typedef struct tagGROUP { - PKMX_WCHART dpName; + PKMX_WCHAR dpName; LPKEY dpKeyArray; // [LPKEY] address of first item in key array - PKMX_WCHART dpMatch; - PKMX_WCHART dpNoMatch; + PKMX_WCHAR dpMatch; + PKMX_WCHAR dpNoMatch; KMX_DWORD cxKeyArray; // in array entries KMX_BOOL fUsingKeys; // group(xx) [using keys] <-- specified or not } GROUP, *LPGROUP; @@ -74,7 +74,7 @@ typedef struct tagKEYBOARD { //HBITMAP hBitmap; // handle to the bitmap in the file; } KEYBOARD, *LPKEYBOARD; -KMX_BOOL LoadKeyboard(PCKMX_WCHART fileName, LPKEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? +//KMX_BOOL LoadKeyboard(PCKMX_WCHART fileName, LPKEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? KMX_BOOL LoadKeyboard(char* fileName, LPKEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? #endif From 762827c96d77445b9138e53e49898073e473429a Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 3 Jul 2023 12:48:02 +0200 Subject: [PATCH 039/327] feat(linux): mcompile use #ifdef around main --- linux/mcompile/keymap/mc_kmxfile.cpp | 224 +++++++++++++++++++++++---- linux/mcompile/keymap/mc_kmxfile.h | 3 +- linux/mcompile/keymap/mcompile.cpp | 125 +++++++++------ linux/mcompile/keymap/mcompile.h | 2 +- linux/mcompile/keymap/u16.cpp | 37 ++++- linux/mcompile/keymap/u16.h | 3 + 6 files changed, 313 insertions(+), 81 deletions(-) diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 4a0c910cf4..d7230b99cd 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -145,62 +145,182 @@ MyCout("#### Line 129 ",1); fclose(fp); -MyCout("##### Line 153",1);; - //_S2 can go: - /* - if(!VerifyKeyboard(filebase, sz)) { - Err(L"errVerifyKeyboard"); - delete[] buf; - return FALSE; - }*/ +MyCout("##### Line 153",1); - if(!VerifyKeyboard(filebase, sz)) return FALSE; //_S2 ToDo find replacement: VerifyKeyboard see further down; finished version in /core/kmx_file.cpp +if(!VerifyKeyboard(filebase, sz)) { + // Err(L"errVerifyKeyboard"); //_S2 ToDo find replacement: Err + // _S2 delete [] buf; ???? + return FALSE; + } - - MyCout("##### Line 166",1); + MyCout("##### Line 157",1); kbp = FixupKeyboard(buf, filebase,sz); - MyCout("##### Line 168",1); + MyCout("##### Line 159",1); std::cout << "kbp: "<dwIdentifier != FILEID_COMPILED) { - Err(L"errNotFileID"); - delete[] buf; - return FALSE; - }*/ + MyCout("##### Line 171 ",1); + //_S2 can go: + /*if(kbp->dwIdentifier != FILEID_COMPILED) { + Err(L"errNotFileID"); + delete[] buf; + return FALSE; + }*/ +std::cout << "kbp->dwIdentifier: "<dwIdentifier<< "\n"; /* if(kbp->dwIdentifier != FILEID_COMPILED) { delete [] buf; //MyCout("errNotFileID",1); //_S2 ToDo find replacement: DebugLog("errNotFileID"); - // _S2 delete [] buf; ???? + // _S2 delete [] buf; ???? return FALSE; }*/ -MyCout("##### Line 198",1); +MyCout("##### Line 187",1); *lpKeyboard = kbp; - // _S2 delete [] buf; ???? + // _S2 delete [] buf; ???? MyCout("##### LoadKeyboard of mcompile ended #####",1); return TRUE; } +// _S2 Version for char16_t filename +KMX_BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD* lpKeyboard) { + std::cout << "##### LoadKeyboard of mcompile started #####\n"; + std::cout << "fileName: " <sz_dw + MyCout("##### Line 299", 1); + + std::cout << "kbp: " << kbp << "\n"; + if (!kbp) { + // Err(L"errFixupKeyboard"); //_S2 ToDo find replacement: Err + // _S2 delete [] buf; ???? + + MyCout("##### errFixupKeyboard ", 1); + return FALSE; + } + + MyCout("##### Line 311 ", 1); + //_S2 can go: + /*if(kbp->dwIdentifier != FILEID_COMPILED) { + Err(L"errNotFileID"); + delete[] buf; + return FALSE; +}*/ + + std::cout << "kbp->dwIdentifier: " << kbp->dwIdentifier << " FILEID_COMPILED: " << FILEID_COMPILED << "\n"; + std::cout << "..xxxxx.\n"; + if (kbp->dwIdentifier != FILEID_COMPILED) { + delete[] buf; + MyCout("errNotFileID", 1); //_S2 ToDo find replacement: DebugLog("errNotFileID"); + return FALSE; + } + MyCout("##### Line 327", 1); + *lpKeyboard = kbp; + // _S2 delete [] buf; ???? + MyCout("##### LoadKeyboard of mcompile ended #####", 1); + return TRUE; +} KMX_BOOL VerifyKeyboard(LPBYTE filebase, KMX_DWORD sz) { KMX_DWORD i; @@ -217,18 +337,62 @@ KMX_BOOL VerifyKeyboard(LPBYTE filebase, KMX_DWORD sz) { wchar_t buf2[256]; if(csp->dpString == 0) { // _S2 wsprintf(buf2, L"errWrongFileVersion:NULL"); + MyCout("errWrongFileVersion",1); } else { // _S2 wsprintf(buf2, L"errWrongFileVersion:%10.10ls", StringOffset(filebase, csp->dpString)); + + MyCout("errWrongFileVersion-offset",1); } + + MyCout("err buf",1); // _S2 Err(buf2); return FALSE; } } + + MyCout("errWrongFileVersion",1); // _S2 Err(L"errWrongFileVersion"); return FALSE; } /**/ +MyCout("will return true",1); + return TRUE; +} + +KMX_BOOL VerifyKeyboard_S2(LPBYTE filebase, KMX_DWORD sz) { + KMX_DWORD i; + PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD)filebase; + PCOMP_STORE csp; + + // Check file version // + + if (ckbp->dwFileVersion < VERSION_MIN || ckbp->dwFileVersion > VERSION_MAX) { + // Old or new version -- identify the desired program version // + for (csp = (PCOMP_STORE)(filebase + ckbp->dpStoreArray), i = 0; i < ckbp->cxStoreArray; i++, csp++) { + if (csp->dwSystemID == TSS_COMPILEDVERSION) { + wchar_t buf2[256]; + if (csp->dpString == 0) { + // _S2 wsprintf(buf2, L"errWrongFileVersion:NULL"); + MyCout("errWrongFileVersion", 1); + } else { + // _S2 wsprintf(buf2, L"errWrongFileVersion:%10.10ls", StringOffset(filebase, csp->dpString)); + + MyCout("errWrongFileVersion-offset", 1); + } + + MyCout("err buf", 1); + // _S2 Err(buf2); + return FALSE; + } + } + + MyCout("errWrongFileVersion", 1); + // _S2 Err(L"errWrongFileVersion"); + return FALSE; + } + /**/ + MyCout("will return true", 1); return TRUE; } diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 22cb56baab..5cb2dd3929 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -74,9 +74,10 @@ typedef struct tagKEYBOARD { //HBITMAP hBitmap; // handle to the bitmap in the file; } KEYBOARD, *LPKEYBOARD; -//KMX_BOOL LoadKeyboard(PCKMX_WCHART fileName, LPKEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? KMX_BOOL LoadKeyboard(char* fileName, LPKEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? +KMX_BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD* lpKeyboard); + #endif diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 7beab30d01..03f5432848 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -40,43 +40,58 @@ mcompile -d runs 4 important steps: #include "mcompile.h" #include "helpers.h" +//------------------------------------------------------------------------------------------------ +//------------------------------------------------------------------------------------------------ +//------------------------------------------------------------------------------------------------ -int main(int argc, char *argv[]) -{ //---------------------------------------- +#if defined(_WIN32) || defined(_WIN64) + int wmain(int argc, wchar_t* argv[]) { + // convert wchar_t-*> char16_t* + // call new run / method() with char16_t + std::vector argv_16 = convert_argvW_to_Vector_u16str( argc, argv); +#else // LINUX + int main(int argc, char* argv[]) { + //MyCout("started Linux-main", 1); + // convert UTF-8 char* to char16_t* + std::vector argv_16 = convert_argv_to_Vector_u16str(argc, argv); +#endif + + std::vector vec_cmdl_par; + + for (int i = 0; i < argc; i++) { + const char16_t* cmdl_par = argv_16[i].c_str(); + vec_cmdl_par.push_back(cmdl_par); + } + + // call new run/ method() with char16_t + run(argc, vec_cmdl_par); + +} +//------ run with char16_t !! ------------------------------------------------------------------------------------------------------------------------- + +int run(int argc, std::vector< const char16_t*> argv) { + //---------------------------------------- // test if all cpps are acccessible: can be removed -//check_avaiability_of_modules_(); //_S2 + //check_avaiability_of_modules_(); //_S2 - /* //in case we use wmain(...wchar_t*) - if(argc < 3 || (argc < 5 && wcscmp(argv[1], L"-u") != 0)) { // I4273// I4273 - printf( - "Usage: mcompile -u infile.kmx outfile.kmx\n" - " mcompile [-d] infile.kmx kbdfile.dll kbid outfile.kmx\n" - " With -u parameter, converts keyboard from ANSI to Unicode\n" - " Otherwise, mcompile converts a Keyman mnemonic layout to a\n" - " positional one based on the Windows keyboard\n" - " layout file given by kbdfile.dll\n\n" - " kbid should be a hexadecimal number e.g. 409 for US English\n" - " -d convert deadkeys to plain keys\n"); // I4552 + printf("_S2 started run for char16_t*\n"); - return 1; - } - */ + if(argc < 3 || (argc < 5 && u16cmp(argv[1], u"-u") != 0)) { // I4273// I4273 + printf( + "Usage: mcompile -u infile.kmx outfile.kmx\n" + " mcompile [-d] infile.kmx kbdfile.dll kbid outfile.kmx\n" + " With -u parameter, converts keyboard from ANSI to Unicode\n" + " Otherwise, mcompile converts a Keyman mnemonic layout to a\n" + " positional one based on the Windows keyboard\n" + " layout file given by kbdfile.dll\n\n" + " kbid should be a hexadecimal number e.g. 409 for US English\n" + " -d convert deadkeys to plain keys\n"); // I4552 - //in case we use main(...char*) - if(argc < 3 || (argc < 5 && strcmp(argv[1], "-u") != 0)) { // I4273 - printf( - "Usage: mcompile -u infile.kmx outfile.kmx\n" - " mcompile [-d] infile.kmx kbdfile.dll kbid outfile.kmx\n" - " With -u parameter, converts keyboard from ANSI to Unicode\n" - " Otherwise, mcompile converts a Keyman mnemonic layout to a\n" - " positional one based on the Windows keyboard\n" - " layout file given by kbdfile.dll\n\n" - " kbid should be a hexadecimal number e.g. 409 for US English\n" - " -d convert deadkeys to plain keys\n"); // I4552 + return 1; + } + +//-_S2 -------u option will be done later---------------------- - return 1; - } -//--------u option will be done later---------------------- /* if(wcscmp(argv[1], L"-u") == 0) { // I4273 wchar_t *infile = argv[2], *outfile = argv[3]; @@ -98,28 +113,42 @@ int main(int argc, char *argv[]) }*/ //----------------------------- -std::cout<<"*********************************************************************************************"; + +printf("_S2 *********************************************************************************************\n"); + + int bDeadkeyConversion = u16cmp(argv[1], u"-d") == 0; // I4552 + int n = (bDeadkeyConversion ? 2 : 1); + + char16_t* infile = (char16_t*) argv[n], *indll = (char16_t*) argv[n+1], *kbid = (char16_t*) argv[n+2], *outfile = (char16_t*) argv[n+3]; -/* //in case we use wmain(...wchar_t*) - int bDeadkeyConversion = wcscmp(argv[1], L"-d") == 0; // I4552 - int n = (bDeadkeyConversion ? 2 : 1); +// _S2 TODO print + //setlocale(LC_ALL, ""); +printf("_S2 * TUp to here crocc-platform ******************************************************\n"); +printf("_S2 * TODO print infile/outfile to console ******************************************************\n"); +/*wchar_t* wcp=wchart_from_char16(infile); +Print_wchar_t(wcp); */ +/*wchar_t wt =wchart_from_char16(kbid); +wchar_t* p_wt = &wt; +const wchar_t* pr= (const wchar_t*) p_wt; +std::wstring blub(pr); +printf("%ls",blub); - //in case we use main(...char*) and proceed with char - int bDeadkeyConversion = strcmp(argv[1], "-d") == 0; // I4552 - int n = (bDeadkeyConversion ? 2 : 1); - char *infile = argv[n], *indll = argv[n+1], *kbid = argv[n+2], *outfile = argv[n+3]; - printf("mcompile%s \"%s\" \"%s\" \"%s\" \"%s\"\n", bDeadkeyConversion ? " -d":"", infile, indll, kbid, outfile); // I4174 - - -/* //in case we use main(...char*) and proceed with wchar_t - int bDeadkeyConversion = strcmp(argv[1], "-d") == 0; // I4552 - int n = (bDeadkeyConversion ? 2 : 1); - char *infile_c = argv[n], *indll_c = argv[n+1], *kbid_c = argv[n+2], *outfile_c = argv[n+3]; - wchar_t *infile = wchart_from_char(infile_c) , *indll = wchart_from_char(indll_c) , *kbid = wchart_from_char(kbid_c) , *outfile = wchart_from_char(outfile_c) ; - wprintf(L"mcompile%ls \"%ls\" \"%ls\" \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d":L"", infile, indll, kbid, outfile); // I4174 +int tukli=345678; */ +// wprintf(L"mcompile%ls \"%ls\" \"%ls\" \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d":L"", wchart_from_char16(infile), +// wchart_from_char16(indll), wchart_from_char16(kbid), wchart_from_char16(outfile)); // I4174 +// std::wcout << L"mcompile "; +// if( bDeadkeyConversion ) std::wcout << L" -d"; +// else std::wcout << wchart_from_char16(infile)<< wchart_from_char16(indll)<< wchart_from_char16(kbid)<< +// wchart_from_char16(outfile); // I4174 + + + + + + /* // 1. Load the keyman keyboard file diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 4d55e18149..28a9f98bdc 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -24,7 +24,7 @@ #include #include "keymap.h" -//int run(int argc, wchar_t* argv[]); //_S2 Do we need that? +int run(int argc, std::vector< const char16_t*> argv); void LogError(PKMX_WCHART message, ...); diff --git a/linux/mcompile/keymap/u16.cpp b/linux/mcompile/keymap/u16.cpp index 7ed18a1488..082d4b340d 100644 --- a/linux/mcompile/keymap/u16.cpp +++ b/linux/mcompile/keymap/u16.cpp @@ -12,13 +12,41 @@ int dummytest_u16(){ return 0; } + +std::vector convert_argv_to_Vector_u16str(int argc, char* argv[]) { + std::vector vector_u16; + int i; + + // for each arg convert to u16string and push to vector + for (char** arg = argv, i=0; *arg; ++arg,i++) { + std::string S(*arg); + vector_u16.push_back(u16string_from_string(S)); + } + return vector_u16; +} + +std::vector convert_argvW_to_Vector_u16str(int argc, wchar_t* argv[]) { + std::vector vector_u16; + int i; + + // for each arg convert to u16string and push to vector + for (wchar_t** arg = argv, i=0; *arg; ++arg,i++) { + std::wstring S(*arg); + vector_u16.push_back(u16string_from_wstring(S)); + } + return vector_u16; +} + + + +/* _S" does this work?? //const wchar_t* <- const char* wchar_t* wchart_from_char( char* c) { std::string str(c); std::wstring wstr = wstring_from_string(str); wchar_t* wc = (wchar_t*) wstr.c_str(); } - +*/ //String <- wstring std::string string_from_wstring(std::wstring const str) { std::wstring_convert, wchar_t> converter; @@ -30,6 +58,13 @@ std::wstring wstring_from_string(std::string const str) { return converter.from_bytes(str); } +// u16String <- wstring +std::u16string u16string_from_wstring(std::wstring const wstr) { + std::string str= string_from_wstring(wstr); + std::u16string str16 = u16string_from_string(str); + return str16; +} + //u16String <- string std::u16string u16string_from_string(std::string const str) { std::wstring_convert, char16_t> converter; diff --git a/linux/mcompile/keymap/u16.h b/linux/mcompile/keymap/u16.h index 7a7cc39b8d..937f2c4a91 100644 --- a/linux/mcompile/keymap/u16.h +++ b/linux/mcompile/keymap/u16.h @@ -11,12 +11,15 @@ int dummytest_u16(); +std::vector convert_argvW_to_Vector_u16str(int argc, wchar_t* argv[]) ; +std::vector convert_argv_to_Vector_u16str(int argc, char* argv[]); wchar_t* wchart_from_char( char* c) ; std::string string_from_wstring(std::wstring const str); std::wstring wstring_from_string(std::string const str); std::u16string u16string_from_string(std::string const str); +std::u16string u16string_from_wstring(std::wstring const wstr); std::string string_from_u16string(std::u16string const str); std::wstring u16fmt(const KMX_WCHAR * str); From d567cbdebded0c99bb4d9b91fbdc55e7ea71546c Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 3 Jul 2023 12:49:24 +0200 Subject: [PATCH 040/327] feat(linux): mcompile use remove unneccessary function --- linux/mcompile/keymap/mc_kmxfile.cpp | 42 +--------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index d7230b99cd..173687a98e 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -279,8 +279,7 @@ KMX_BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD* lpKeyboard) { KMX_DWORD sz_dw = (KMX_DWORD)sz; //_S2 size_t sz_t = (size_t)sz; //_S2 // shold call VerifyKeyboard_M of class - // if(!VerifyKeyboard(filebase, sz_t)) { - if (!VerifyKeyboard_S2(filebase, sz_t)) { + if (!VerifyKeyboard(filebase, sz_t)) { MyCout("##### errVerifyKeyboard", 1); // Err(L"errVerifyKeyboard"); //_S2 ToDo find replacement: Err // _S2 delete [] buf; ???? @@ -358,45 +357,6 @@ KMX_BOOL VerifyKeyboard(LPBYTE filebase, KMX_DWORD sz) { MyCout("will return true",1); return TRUE; } - - -KMX_BOOL VerifyKeyboard_S2(LPBYTE filebase, KMX_DWORD sz) { - KMX_DWORD i; - PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD)filebase; - PCOMP_STORE csp; - - // Check file version // - - if (ckbp->dwFileVersion < VERSION_MIN || ckbp->dwFileVersion > VERSION_MAX) { - // Old or new version -- identify the desired program version // - for (csp = (PCOMP_STORE)(filebase + ckbp->dpStoreArray), i = 0; i < ckbp->cxStoreArray; i++, csp++) { - if (csp->dwSystemID == TSS_COMPILEDVERSION) { - wchar_t buf2[256]; - if (csp->dpString == 0) { - // _S2 wsprintf(buf2, L"errWrongFileVersion:NULL"); - MyCout("errWrongFileVersion", 1); - } else { - // _S2 wsprintf(buf2, L"errWrongFileVersion:%10.10ls", StringOffset(filebase, csp->dpString)); - - MyCout("errWrongFileVersion-offset", 1); - } - - MyCout("err buf", 1); - // _S2 Err(buf2); - return FALSE; - } - } - - MyCout("errWrongFileVersion", 1); - // _S2 Err(L"errWrongFileVersion"); - return FALSE; - } - /**/ - MyCout("will return true", 1); - return TRUE; -} - - //---------------------old---------------------------------------- /* #include "pch.h" From 223865d74d5dbc9710b318afc150dbb34d65f81b Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 5 Jul 2023 16:52:36 +0200 Subject: [PATCH 041/327] feat(linux): mcompile exchange Err(), LogError(), DebugLog() with KMX_Log use wchar for output everywhere --- linux/mcompile/keymap/helpers.cpp | 7 ++ linux/mcompile/keymap/helpers.h | 1 + linux/mcompile/keymap/mc_kmxfile.cpp | 122 ++++++++++++++++++++++++++- linux/mcompile/keymap/mc_kmxfile.h | 1 + linux/mcompile/keymap/mcompile.cpp | 90 +++++--------------- linux/mcompile/keymap/mcompile.h | 2 +- linux/mcompile/keymap/u16.cpp | 25 ++++-- linux/mcompile/keymap/u16.h | 20 +++-- 8 files changed, 183 insertions(+), 85 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 52739f3680..189db7add7 100644 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -25,6 +25,13 @@ void MyCout(std::string in, bool end, std::string pre ) { std::cout << pre << " " << in; } +void MyCoutW(std::wstring in, bool end, std::wstring pre) { + if (end == true) + std::wcout << pre << L" " << in << L" " << L"\n"; + else + std::wcout << pre << L" " << in; +} + void DebugLog_S2(std::wstring txt, std::wstring fileName) { diff --git a/linux/mcompile/keymap/helpers.h b/linux/mcompile/keymap/helpers.h index e0dbe2f8ec..7ca0b07b9d 100644 --- a/linux/mcompile/keymap/helpers.h +++ b/linux/mcompile/keymap/helpers.h @@ -14,6 +14,7 @@ void check_avaiability_of_modules_WC(); // My std::cout : writes pre-in ; 1 for end of line void MyCout(std::string in, bool end, std::string pre = ""); +void MyCoutW(std::wstring in, bool end, std::wstring pre =L""); //Just for now: wrote my oẃn DebugLog -TODO to be replaced void DebugLog_S2(std::wstring txt, std::wstring fileName); diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 173687a98e..bf669eca7b 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -191,8 +191,124 @@ MyCout("##### Line 187",1); return TRUE; } -// _S2 Version for char16_t filename KMX_BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD* lpKeyboard) { + std::wcout << "##### LoadKeyboard of mcompile started #####\n"; + + LPKMX_BYTE buf; + FILE* fp; + LPKEYBOARD kbp; + PKMX_BYTE filebase; + + wprintf(L"Loading file '%ls'\n", u16fmt((const char16_t*) fileName).c_str()); + + if(!fileName || !lpKeyboard) { + KMX_LogError(L"LogError1: Bad Filename\n" ); + return FALSE; + } + + fp = Open_File((const KMX_WCHAR*)fileName, u"rb"); + + if(fp == NULL) { + KMX_LogError(L"LogError1: Could not open file\n" ); + return FALSE; + } + + if (fseek(fp, 0, SEEK_END) != 0) { + fclose(fp); + KMX_LogError(L"LogError1: Could not fseek file\n" ); + return FALSE; + } + + auto sz = ftell(fp); + if (sz < 0) { + fclose(fp); + return FALSE; + } + + if (fseek(fp, 0, SEEK_SET) != 0) { + fclose(fp); + KMX_LogError(L"LogErr1: Could not fseek(set) file\n" ); + return FALSE; + } + + // #ifdef KMX_64BIT + // allocate enough memory for expanded data structure + original data. + // Expanded data structure is double the size of data on disk (8-byte + // pointers) - on disk the "pointers" are relative to the beginning of + // the file. + // We save the original data at the end of buf; we don't copy strings, so + // those will remain in the location at the end of the buffer. + // buf = new KMX_BYTE[sz * 3]; + // #else + buf = new KMX_BYTE[sz]; + // #endif + + MyCoutW(L"#### Line 260 ", 1); + if (!buf) { + fclose(fp); + KMX_LogError(L"LogErr1: Not allocmem\n" ); + // _S2 delete [] buf; ???? + return FALSE; + } + + // #ifdef KMX_64BIT + // ilebase = buf + sz*2; + // #else + filebase = buf; + // #endif + + if (fread(filebase, 1, sz, fp) < (size_t)sz) { + KMX_LogError(L"LogError1: Could not read file\n" ); + fclose(fp); + // _S2 delete [] buf; ???? + return FALSE; + } + + fclose(fp); + + MyCoutW(L"##### Line 285", 1); + ; + KMX_DWORD sz_dw = (KMX_DWORD)sz; //_S2 + size_t sz_t = (size_t)sz; //_S2 + // if(!VerifyKeyboard(filebase, sz_t)) { + if (!VerifyKeyboard(filebase, sz_t)) { + KMX_LogError(L"LogError1: errVerifyKeyboard\n" ); + // _S2 delete [] buf; ???? + return FALSE; + } + + MyCoutW(L"##### Line 297", 1); + kbp = FixupKeyboard(buf, filebase, sz_dw); // _S" changed from sz->sz_dw + MyCoutW(L"##### Line 299", 1); + + if (!kbp) { + KMX_LogError(L"LogError1: errFixupKeyboard\n" ); + // _S2 delete [] buf; ???? + + MyCoutW(L"##### errFixupKeyboard ", 1); + return FALSE; + } + + MyCoutW(L"##### Line 311 ", 1); + + std::wcout << "kbp->dwIdentifier: " << kbp->dwIdentifier << " FILEID_COMPILED: " << FILEID_COMPILED << "\n"; + + if (kbp->dwIdentifier != FILEID_COMPILED) { + delete[] buf; + KMX_LogError(L"LogError1: errNotFileID\n" ); + return FALSE; + } + MyCoutW(L"##### Line 327", 1); + *lpKeyboard = kbp; + // _S2 delete [] buf; ???? + MyCoutW(L"##### LoadKeyboard of mcompile ended #####", 1); + return TRUE; +} + + + +// _S2 Version for char16_t filename +/*KMX_BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD* lpKeyboard) { std::cout << "##### LoadKeyboard of mcompile started #####\n"; std::cout << "fileName: " <dwIdentifier: " << kbp->dwIdentifier << " FILEID_COMPILED: " << FILEID_COMPILED << "\n"; std::cout << "..xxxxx.\n"; @@ -320,7 +436,7 @@ KMX_BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD* lpKeyboard) { MyCout("##### LoadKeyboard of mcompile ended #####", 1); return TRUE; } - +*/ KMX_BOOL VerifyKeyboard(LPBYTE filebase, KMX_DWORD sz) { KMX_DWORD i; PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD) filebase; diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 5cb2dd3929..95cdd77fd0 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -5,6 +5,7 @@ #include "km_types.h" #include "kmx_file.h" #include "filesystem.h" +#include "mcompile.h" #include // _S2 can be removed later diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 03f5432848..16219f5c87 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -46,23 +46,17 @@ mcompile -d runs 4 important steps: #if defined(_WIN32) || defined(_WIN64) int wmain(int argc, wchar_t* argv[]) { - // convert wchar_t-*> char16_t* - // call new run / method() with char16_t std::vector argv_16 = convert_argvW_to_Vector_u16str( argc, argv); #else // LINUX int main(int argc, char* argv[]) { - //MyCout("started Linux-main", 1); - // convert UTF-8 char* to char16_t* std::vector argv_16 = convert_argv_to_Vector_u16str(argc, argv); #endif std::vector vec_cmdl_par; - for (int i = 0; i < argc; i++) { const char16_t* cmdl_par = argv_16[i].c_str(); vec_cmdl_par.push_back(cmdl_par); } - // call new run/ method() with char16_t run(argc, vec_cmdl_par); @@ -74,18 +68,18 @@ int run(int argc, std::vector< const char16_t*> argv) { // test if all cpps are acccessible: can be removed //check_avaiability_of_modules_(); //_S2 - printf("_S2 started run for char16_t*\n"); + wprintf(L"_S2 started run for char16_t*\n"); if(argc < 3 || (argc < 5 && u16cmp(argv[1], u"-u") != 0)) { // I4273// I4273 - printf( - "Usage: mcompile -u infile.kmx outfile.kmx\n" - " mcompile [-d] infile.kmx kbdfile.dll kbid outfile.kmx\n" - " With -u parameter, converts keyboard from ANSI to Unicode\n" - " Otherwise, mcompile converts a Keyman mnemonic layout to a\n" - " positional one based on the Windows keyboard\n" - " layout file given by kbdfile.dll\n\n" - " kbid should be a hexadecimal number e.g. 409 for US English\n" - " -d convert deadkeys to plain keys\n"); // I4552 + wprintf( + L"Usage: mcompile -u infile.kmx outfile.kmx\n" + L" mcompile [-d] infile.kmx kbdfile.dll kbid outfile.kmx\n" + L" With -u parameter, converts keyboard from ANSI to Unicode\n" + L" Otherwise, mcompile converts a Keyman mnemonic layout to a\n" + L" positional one based on the Windows keyboard\n" + L" layout file given by kbdfile.dll\n\n" + L" kbid should be a hexadecimal number e.g. 409 for US English\n" + L" -d convert deadkeys to plain keys\n"); // I4552 return 1; } @@ -99,6 +93,7 @@ int run(int argc, std::vector< const char16_t*> argv) { if(!LoadKeyboard(infile, &kmxfile)) { LogError(L"Failed to load keyboard (%d)", GetLastError()); + // replaced by _S2 KMX_LogError(L"Failed to load keyboard (%d)\n", errno ); return 3; } @@ -113,42 +108,12 @@ int run(int argc, std::vector< const char16_t*> argv) { }*/ //----------------------------- - -printf("_S2 *********************************************************************************************\n"); - int bDeadkeyConversion = u16cmp(argv[1], u"-d") == 0; // I4552 int n = (bDeadkeyConversion ? 2 : 1); char16_t* infile = (char16_t*) argv[n], *indll = (char16_t*) argv[n+1], *kbid = (char16_t*) argv[n+2], *outfile = (char16_t*) argv[n+3]; - -// _S2 TODO print - //setlocale(LC_ALL, ""); -printf("_S2 * TUp to here crocc-platform ******************************************************\n"); -printf("_S2 * TODO print infile/outfile to console ******************************************************\n"); -/*wchar_t* wcp=wchart_from_char16(infile); -Print_wchar_t(wcp); -*/ -/*wchar_t wt =wchart_from_char16(kbid); -wchar_t* p_wt = &wt; -const wchar_t* pr= (const wchar_t*) p_wt; -std::wstring blub(pr); -printf("%ls",blub); - -int tukli=345678; -*/ -// wprintf(L"mcompile%ls \"%ls\" \"%ls\" \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d":L"", wchart_from_char16(infile), -// wchart_from_char16(indll), wchart_from_char16(kbid), wchart_from_char16(outfile)); // I4174 -// std::wcout << L"mcompile "; -// if( bDeadkeyConversion ) std::wcout << L" -d"; -// else std::wcout << wchart_from_char16(infile)<< wchart_from_char16(indll)<< wchart_from_char16(kbid)<< -// wchart_from_char16(outfile); // I4174 - - - - - - + wprintf(L"mcompile%ls \"%ls\" \"%ls\" \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d" : L"", u16fmt((const char16_t*) infile).c_str(), u16fmt((const char16_t*) indll).c_str(), u16fmt((const char16_t*) kbid).c_str(), u16fmt((const char16_t*) outfile).c_str() ); // I4174 /* // 1. Load the keyman keyboard file @@ -177,21 +142,20 @@ int tukli=345678; // 3. Write the new keyman keyboard file */ +wprintf(L"_S2 * Up to here cross-platform xx :-))))) ******************************************************\n"); + LPKEYBOARD kmxfile; if (!LoadKeyboard(infile, &kmxfile)) { - std::cout << "TODO: Replace: Failed to load keyboard , GetLastError())\n"; //LogError(L"Failed to load keyboard (%d)", GetLastError()); + KMX_LogError(L"Failed to load keyboard (%d)\n", errno ); return 3; } -/* QUESTIONS / TODO -status: mcompile.cpp: Replacement of LogError -status mc_kmx-file.cpp: - find replacement: DebugLog - find replacement: VerifyKeyboard - wchar<->char - char16_t<->wchar_t -*/ + /* QUESTIONS / TODO + status mc_kmx-file.cpp: + find replacement: VerifyKeyboard_S2 + wrong entries in : VerifyKeyboard + */ std::cout << " ++ UP TO HERE IN STEP 1 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; @@ -212,8 +176,7 @@ std::cout << " ++ UP TO HERE IN STEP 1 +++++++++++++++++++++++++++++++++++++++++ //int out = run_DoConvert_Part1_getMap(argc,argv); //run_DoConvert_Part2_TranslateKeyboard(); //SaveKeyboard(); -printf("°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° end\n"); - + wprintf(L"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm end\n"); return 0 ; } @@ -686,15 +649,8 @@ BOOL DoConvert(LPKEYBOARD kbd, LPWSTR kbid, BOOL bDeadkeyConversion) { // I455 */ -//TODO adapt for cross-platform -void LogError(PWSTR fmt, ...) { - /*WCHAR fmtbuf[256]; - - va_list vars; - va_start(vars, fmt); - _vsnwprintf_s(fmtbuf, _countof(fmtbuf), _TRUNCATE, fmt, vars); // I2248 // I3547 - fmtbuf[255] = 0; - _putws(fmtbuf);*/ +void KMX_LogError(const KMX_WCHART* m1,int m2) { + wprintf((PWSTR)m1, m2); } //---------old------------------------------------------- diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 28a9f98bdc..5f6cab2458 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -25,7 +25,7 @@ #include "keymap.h" int run(int argc, std::vector< const char16_t*> argv); -void LogError(PKMX_WCHART message, ...); +void KMX_LogError(const KMX_WCHART* m1, int m2 = 0); struct DeadkeyMapping { // I4353 diff --git a/linux/mcompile/keymap/u16.cpp b/linux/mcompile/keymap/u16.cpp index 082d4b340d..c30a187d91 100644 --- a/linux/mcompile/keymap/u16.cpp +++ b/linux/mcompile/keymap/u16.cpp @@ -39,14 +39,23 @@ std::vector convert_argvW_to_Vector_u16str(int argc, wchar_t* ar -/* _S" does this work?? +// _S" does this work?? //const wchar_t* <- const char* +/* wchar_t* wchart_from_char( char* c) { - std::string str(c); + std::string str(*c); std::wstring wstr = wstring_from_string(str); - wchar_t* wc = (wchar_t*) wstr.c_str(); -} -*/ + wchar_t* wc = (wchar_t*) wstr.c_str(); + return wc; +}*/ + +/* _S2 does this work ??? +wchar_t* wchart_from_char16( char16_t** c) { + std::u16string str(*c); + std::wstring wstr = wstring_from_u16string((std::u16string const) str); + return (wchar_t*) wstr.c_str(); +}*/ + //String <- wstring std::string string_from_wstring(std::wstring const str) { std::wstring_convert, wchar_t> converter; @@ -76,6 +85,12 @@ std::string string_from_u16string(std::u16string const str) { std::wstring_convert, char16_t> converter; return converter.to_bytes(str); } +//wstring <- u16string +std::wstring wstring_from_u16string(std::u16string const str16) { + std::string str = string_from_u16string(str16); + std::wstring wstr = wstring_from_string( str); + return wstr; +} // often used with c_str() e.g. u16fmt( DEBUGSTORE_MATCH).c_str() // UTF16 (= const char16_t*) -> UTF8 (= std::string) -> UTF16 ( = std::wstring 16 bit) diff --git a/linux/mcompile/keymap/u16.h b/linux/mcompile/keymap/u16.h index 937f2c4a91..fc83a26e0b 100644 --- a/linux/mcompile/keymap/u16.h +++ b/linux/mcompile/keymap/u16.h @@ -11,19 +11,21 @@ int dummytest_u16(); -std::vector convert_argvW_to_Vector_u16str(int argc, wchar_t* argv[]) ; +std::vector convert_argvW_to_Vector_u16str(int argc, wchar_t* argv[]); std::vector convert_argv_to_Vector_u16str(int argc, char* argv[]); -wchar_t* wchart_from_char( char* c) ; +wchar_t* wchart_from_char( char* c); +wchar_t* wchart_from_char16( char16_t** c); std::string string_from_wstring(std::wstring const str); std::wstring wstring_from_string(std::string const str); +std::wstring wstring_from_u16string(std::u16string const str16); std::u16string u16string_from_string(std::string const str); std::u16string u16string_from_wstring(std::wstring const wstr); std::string string_from_u16string(std::u16string const str); std::wstring u16fmt(const KMX_WCHAR * str); -void u16sprintf(KMX_WCHAR * dst, const size_t sz, const wchar_t* fmt, ...) ; +void u16sprintf(KMX_WCHAR * dst, const size_t sz, const wchar_t* fmt, ...); std::wstring convert_pchar16T_To_wstr(KMX_WCHAR *Name); @@ -31,15 +33,15 @@ size_t u16len(const KMX_WCHAR *p); int u16cmp(const KMX_WCHAR *p, const KMX_WCHAR *q); int u16icmp(const KMX_WCHAR *p, const KMX_WCHAR *q); int u16ncmp(const KMX_WCHAR *p, const KMX_WCHAR *q, size_t count); -int u16nicmp(const KMX_WCHAR *p, const KMX_WCHAR *q, size_t count) ; +int u16nicmp(const KMX_WCHAR *p, const KMX_WCHAR *q, size_t count); const KMX_WCHAR * u16ncpy(KMX_WCHAR *dst, const KMX_WCHAR *src, size_t max); const KMX_WCHAR * u16cpy(KMX_WCHAR *dst, const KMX_WCHAR *src); -const KMX_WCHAR * u16rchr(const KMX_WCHAR *p, KMX_WCHAR ch) ; -const KMX_WCHAR * u16chr(const KMX_WCHAR *p, KMX_WCHAR ch) ; +const KMX_WCHAR * u16rchr(const KMX_WCHAR *p, KMX_WCHAR ch); +const KMX_WCHAR * u16chr(const KMX_WCHAR *p, KMX_WCHAR ch); const KMX_WCHAR * u16ncat(KMX_WCHAR *dst, const KMX_WCHAR *src, size_t max); -KMX_WCHAR * u16tok(KMX_WCHAR *p, KMX_WCHAR ch, KMX_WCHAR **ctx) ; -KMX_WCHAR * u16tok(KMX_WCHAR* p, KMX_WCHAR* ch, KMX_WCHAR** ctx) ; -long int u16tol(const KMX_WCHAR* str, KMX_WCHAR** endptr, int base) ; +KMX_WCHAR * u16tok(KMX_WCHAR *p, KMX_WCHAR ch, KMX_WCHAR **ctx); +KMX_WCHAR * u16tok(KMX_WCHAR* p, KMX_WCHAR* ch, KMX_WCHAR** ctx); +long int u16tol(const KMX_WCHAR* str, KMX_WCHAR** endptr, int base); double u16tof( KMX_WCHAR* str); KMX_CHAR* strrchr_slash(KMX_CHAR* Name); From c67b7d3e464db20e6bfe801bc8f60a2f88c2ddc7 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 6 Jul 2023 13:56:41 +0200 Subject: [PATCH 042/327] feat(linux): mcompile cosmetics --- linux/mcompile/keymap/mc_kmxfile.cpp | 28 ++++++++++++++++++---------- linux/mcompile/keymap/mcompile.cpp | 10 +++++----- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index bf669eca7b..527e1e8ddd 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -25,6 +25,7 @@ PKMX_WCHAR StringOffset(PKMX_BYTE base, KMX_DWORD offset) { LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize) { + MyCoutW(L" ##### FixupKeyboard started", 1); UNREFERENCED_PARAMETER(dwFileSize); KMX_DWORD i, j; @@ -39,26 +40,32 @@ LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize) { kbp->dpStoreArray = (LPSTORE) (base + ckbp->dpStoreArray); kbp->dpGroupArray = (LPGROUP) (base + ckbp->dpGroupArray); + MyCoutW(L" ##### first assignment finished", 1); for(sp = kbp->dpStoreArray, csp = (PCOMP_STORE) sp, i = 0; i < kbp->cxStoreArray; i++, sp++, csp++) { sp->dpName = StringOffset(base, csp->dpName); sp->dpString = StringOffset(base, csp->dpString); } + MyCoutW(L" ##### sp filled", 1); for(gp = kbp->dpGroupArray, cgp = (PCOMP_GROUP) gp, i = 0; i < kbp->cxGroupArray; i++, gp++, cgp++) { gp->dpName = StringOffset(base, cgp->dpName); gp->dpKeyArray = (LPKEY) (base + cgp->dpKeyArray); if(cgp->dpMatch != NULL) gp->dpMatch = (PKMX_WCHAR) (base + cgp->dpMatch); if(cgp->dpNoMatch != NULL) gp->dpNoMatch = (PKMX_WCHAR) (base + cgp->dpNoMatch); + MyCoutW(L" ##### gp, cgp filled", 1); for(kp = gp->dpKeyArray, ckp = (PCOMP_KEY) kp, j = 0; j < gp->cxKeyArray; j++, kp++, ckp++) { kp->dpOutput = (PKMX_WCHAR) (base + ckp->dpOutput); kp->dpContext = (PKMX_WCHAR) (base + ckp->dpContext); } } + + MyCoutW(L" ##### kp filled", 1); + MyCoutW(L" ##### FixupKeyboard ended", 1); return kbp; } - +/* KMX_BOOL LoadKeyboard(char* fileName, LPKEYBOARD *lpKeyboard) { std::cout << "##### LoadKeyboard of mcompile started #####\n"; std::cout << "fileName: " <dwIdentifier: "<dwIdentifier<< "\n"; +//std::cout << "kbp->dwIdentifier: "<dwIdentifier<< "\n"; /* if(kbp->dwIdentifier != FILEID_COMPILED) { delete [] buf; //MyCout("errNotFileID",1); //_S2 ToDo find replacement: DebugLog("errNotFileID"); // _S2 delete [] buf; ???? return FALSE; - }*/ + }*//* MyCout("##### Line 187",1); *lpKeyboard = kbp; // _S2 delete [] buf; ???? MyCout("##### LoadKeyboard of mcompile ended #####",1); return TRUE; } +*/ KMX_BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD* lpKeyboard) { std::wcout << "##### LoadKeyboard of mcompile started #####\n"; @@ -243,7 +251,7 @@ KMX_BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD* lpKeyboard) { buf = new KMX_BYTE[sz]; // #endif - MyCoutW(L"#### Line 260 ", 1); + MyCoutW(L"#### Line 246 ", 1); if (!buf) { fclose(fp); KMX_LogError(L"LogErr1: Not allocmem\n" ); @@ -266,7 +274,7 @@ KMX_BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD* lpKeyboard) { fclose(fp); - MyCoutW(L"##### Line 285", 1); + MyCoutW(L"##### Line 269", 1); ; KMX_DWORD sz_dw = (KMX_DWORD)sz; //_S2 size_t sz_t = (size_t)sz; //_S2 @@ -277,9 +285,9 @@ KMX_BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD* lpKeyboard) { return FALSE; } - MyCoutW(L"##### Line 297", 1); + MyCoutW(L"##### Line 280", 1); kbp = FixupKeyboard(buf, filebase, sz_dw); // _S" changed from sz->sz_dw - MyCoutW(L"##### Line 299", 1); + MyCoutW(L"##### Line 282", 1); if (!kbp) { KMX_LogError(L"LogError1: errFixupKeyboard\n" ); @@ -289,16 +297,16 @@ KMX_BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD* lpKeyboard) { return FALSE; } - MyCoutW(L"##### Line 311 ", 1); + MyCoutW(L"##### Line 292 ", 1); - std::wcout << "kbp->dwIdentifier: " << kbp->dwIdentifier << " FILEID_COMPILED: " << FILEID_COMPILED << "\n"; + std::wcout << "##### kbp->dwIdentifier: " << kbp->dwIdentifier << " FILEID_COMPILED: " << FILEID_COMPILED << "\n"; if (kbp->dwIdentifier != FILEID_COMPILED) { delete[] buf; KMX_LogError(L"LogError1: errNotFileID\n" ); return FALSE; } - MyCoutW(L"##### Line 327", 1); + MyCoutW(L"##### Line 301", 1); *lpKeyboard = kbp; // _S2 delete [] buf; ???? MyCoutW(L"##### LoadKeyboard of mcompile ended #####", 1); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 16219f5c87..18f3c944e8 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -108,12 +108,12 @@ int run(int argc, std::vector< const char16_t*> argv) { }*/ //----------------------------- - int bDeadkeyConversion = u16cmp(argv[1], u"-d") == 0; // I4552 - int n = (bDeadkeyConversion ? 2 : 1); + int bDeadkeyConversion = u16cmp(argv[1], u"-d") == 0; // I4552 + int n = (bDeadkeyConversion ? 2 : 1); - char16_t* infile = (char16_t*) argv[n], *indll = (char16_t*) argv[n+1], *kbid = (char16_t*) argv[n+2], *outfile = (char16_t*) argv[n+3]; + char16_t* infile = (char16_t*) argv[n], *indll = (char16_t*) argv[n+1], *kbid = (char16_t*) argv[n+2], *outfile = (char16_t*) argv[n+3]; - wprintf(L"mcompile%ls \"%ls\" \"%ls\" \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d" : L"", u16fmt((const char16_t*) infile).c_str(), u16fmt((const char16_t*) indll).c_str(), u16fmt((const char16_t*) kbid).c_str(), u16fmt((const char16_t*) outfile).c_str() ); // I4174 + wprintf(L"mcompile%ls \"%ls\" \"%ls\" \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d" : L"", u16fmt((const char16_t*) infile).c_str(), u16fmt((const char16_t*) indll).c_str(), u16fmt((const char16_t*) kbid).c_str(), u16fmt((const char16_t*) outfile).c_str() ); // I4174 /* // 1. Load the keyman keyboard file @@ -146,7 +146,7 @@ wprintf(L"_S2 * Up to here cross-platform xx :-))))) ************************** LPKEYBOARD kmxfile; - if (!LoadKeyboard(infile, &kmxfile)) { + if(!LoadKeyboard(infile, &kmxfile)) { KMX_LogError(L"Failed to load keyboard (%d)\n", errno ); return 3; } From 30c82a7685c0305da6e9a2559046fa717dc4d5bd Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 11 Jul 2023 11:26:33 +0200 Subject: [PATCH 043/327] feat(linux): mcompile add KMX_Datatypes --- linux/mcompile/keymap/km_types.h | 14 +- linux/mcompile/keymap/kmx_file.h | 137 +++++++++++---- linux/mcompile/keymap/mc_kmxfile.cpp | 254 ++++++++++++++++++++++++--- linux/mcompile/keymap/mc_kmxfile.h | 113 +++++++++--- linux/mcompile/keymap/mcompile.cpp | 4 +- 5 files changed, 435 insertions(+), 87 deletions(-) diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index 4365a01201..a9c90d5eca 100644 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -29,6 +29,10 @@ typedef uint32_t KMX_DWORD; typedef int32_t KMX_BOOL; typedef uint8_t KMX_BYTE; typedef uint16_t KMX_WORD; +typedef uint32_t DWORD; +typedef int32_t BOOL; +typedef uint8_t BYTE; +typedef uint16_t WORD; #if defined(__cplusplus) typedef char16_t km_kbp_cp; @@ -55,10 +59,11 @@ typedef char* LPSTR; // _S2 needs to be removed? typedef LPSTR LPKMX_STR; // _S2 needs to be removed? typedef uint8_t* LPBYTE; // _S2 needs to be removed/? -typedef LPBYTE LPKMX_BYTE; // _S2 needs to be removed? +typedef uint8_t* LPKMX_BYTE; // _S2 needs to be removed? + typedef uint8_t* PBYTE; // _S2 needs to be removed/? -typedef PBYTE PKMX_BYTE; // _S2 needs to be removed? +typedef uint8_t* PKMX_BYTE; // _S2 needs to be removed? // _S2 LPKEYBOARD ok to leave as is?? @@ -67,13 +72,14 @@ typedef char* PKMX_STR; // _S2 needs to be removed/? typedef KMX_CHAR* PKMX_CHAR; // _S2 needs to be removed/? - - typedef uint32_t KMX_UINT; typedef KMX_BYTE* PKMX_BYTE; typedef KMX_WORD* PKMX_WORD; typedef KMX_DWORD* PKMX_DWORD; +typedef BYTE* PBYTE; +typedef WORD* PWORD; +typedef DWORD* PDWORD; #ifndef FALSE #define FALSE 0 diff --git a/linux/mcompile/keymap/kmx_file.h b/linux/mcompile/keymap/kmx_file.h index a5478a0389..5dd1f439ea 100644 --- a/linux/mcompile/keymap/kmx_file.h +++ b/linux/mcompile/keymap/kmx_file.h @@ -302,73 +302,143 @@ namespace kmx { #define K_NOTMODIFIERFLAG 0xFF00 // I4548 struct COMP_STORE { - KMX_DWORD dwSystemID; - KMX_DWORD dpName; - KMX_DWORD dpString; - }; + DWORD dwSystemID; + DWORD dpName; + DWORD dpString; +}; + + struct KMX_COMP_STORE { + KMX_DWORD dwSystemID; + KMX_DWORD dpName; + KMX_DWORD dpString; + }; struct COMP_KEY { KMX_WORD Key; KMX_WORD _reserved; - KMX_DWORD Line; - KMX_DWORD ShiftFlags; - KMX_DWORD dpOutput; - KMX_DWORD dpContext; + DWORD Line; + DWORD ShiftFlags; + DWORD dpOutput; + DWORD dpContext; }; + struct KMX_COMP_KEY { + KMX_WORD Key; + KMX_WORD _reserved; + KMX_DWORD Line; + KMX_DWORD ShiftFlags; + KMX_DWORD dpOutput; + KMX_DWORD dpContext; + }; + + struct COMP_GROUP { - KMX_DWORD dpName; - KMX_DWORD dpKeyArray; // [LPKEY] address of first item in key array - KMX_DWORD dpMatch; - KMX_DWORD dpNoMatch; - KMX_DWORD cxKeyArray; // in array entries - KMX_BOOL fUsingKeys; // group(xx) [using keys] <-- specified or not + DWORD dpName; + DWORD dpKeyArray; // [LPKEY] address of first item in key array + DWORD dpMatch; + DWORD dpNoMatch; + DWORD cxKeyArray; // in array entries + BOOL fUsingKeys; // group(xx) [using keys] <-- specified or not }; + struct KMX_COMP_GROUP { + KMX_DWORD dpName; + KMX_DWORD dpKeyArray; // [LPKEY] address of first item in key array + KMX_DWORD dpMatch; + KMX_DWORD dpNoMatch; + KMX_DWORD cxKeyArray; // in array entries + KMX_BOOL fUsingKeys; // group(xx) [using keys] <-- specified or not + }; + + struct COMP_KEYBOARD { - KMX_DWORD dwIdentifier; // 0000 Keyman compiled keyboard id + DWORD dwIdentifier; // 0000 Keyman compiled keyboard id - KMX_DWORD dwFileVersion; // 0004 Version of the file - Keyman 4.0 is 0x0400 + DWORD dwFileVersion; // 0004 Version of the file - Keyman 4.0 is 0x0400 - KMX_DWORD dwCheckSum; // 0008 As stored in keyboard. DEPRECATED as of 16.0 - KMX_DWORD KeyboardID; // 000C as stored in HKEY_LOCAL_MACHINE//system//currentcontrolset//control//keyboard layouts - KMX_DWORD IsRegistered; // 0010 - KMX_DWORD version; // 0014 keyboard version + DWORD dwCheckSum; // 0008 As stored in keyboard. DEPRECATED as of 16.0 + DWORD KeyboardID; // 000C as stored in HKEY_LOCAL_MACHINE//system//currentcontrolset//control//keyboard layouts + DWORD IsRegistered; // 0010 + DWORD version; // 0014 keyboard version - KMX_DWORD cxStoreArray; // 0018 in array entries - KMX_DWORD cxGroupArray; // 001C in array entries + DWORD cxStoreArray; // 0018 in array entries + DWORD cxGroupArray; // 001C in array entries - KMX_DWORD dpStoreArray; // 0020 [LPSTORE] address of first item in store array - KMX_DWORD dpGroupArray; // 0024 [LPGROUP] address of first item in group array + DWORD dpStoreArray; // 0020 [LPSTORE] address of first item in store array + DWORD dpGroupArray; // 0024 [LPGROUP] address of first item in group array - KMX_DWORD StartGroup[2]; // 0028 index of starting groups [2 of them] + DWORD StartGroup[2]; // 0028 index of starting groups [2 of them] - KMX_DWORD dwFlags; // 0030 Flags for the keyboard file + DWORD dwFlags; // 0030 Flags for the keyboard file - KMX_DWORD dwHotKey; // 0034 standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) + DWORD dwHotKey; // 0034 standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) - KMX_DWORD dpBitmapOffset; // 0038 offset of the bitmaps in the file - KMX_DWORD dwBitmapSize; // 003C size in bytes of the bitmaps + DWORD dpBitmapOffset; // 0038 offset of the bitmaps in the file + DWORD dwBitmapSize; // 003C size in bytes of the bitmaps }; + struct KMX_COMP_KEYBOARD { + KMX_DWORD dwIdentifier; // 0000 Keyman compiled keyboard id + + KMX_DWORD dwFileVersion; // 0004 Version of the file - Keyman 4.0 is 0x0400 + + KMX_DWORD dwCheckSum; // 0008 As stored in keyboard. DEPRECATED as of 16.0 + KMX_DWORD KeyboardID; // 000C as stored in HKEY_LOCAL_MACHINE//system//currentcontrolset//control//keyboard layouts + KMX_DWORD IsRegistered; // 0010 + KMX_DWORD version; // 0014 keyboard version + + KMX_DWORD cxStoreArray; // 0018 in array entries + KMX_DWORD cxGroupArray; // 001C in array entries + + KMX_DWORD dpStoreArray; // 0020 [LPSTORE] address of first item in store array + KMX_DWORD dpGroupArray; // 0024 [LPGROUP] address of first item in group array + + KMX_DWORD StartGroup[2]; // 0028 index of starting groups [2 of them] + + KMX_DWORD dwFlags; // 0030 Flags for the keyboard file + + KMX_DWORD dwHotKey; // 0034 standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) + + KMX_DWORD dpBitmapOffset; // 0038 offset of the bitmaps in the file + KMX_DWORD dwBitmapSize; // 003C size in bytes of the bitmaps + }; + struct COMP_KEYBOARD_KMXPLUSINFO { - KMX_DWORD dpKMXPlus; // 0040 offset of KMXPlus data, header is first - KMX_DWORD dwKMXPlusSize; // 0044 size in bytes of entire KMXPlus data + DWORD dpKMXPlus; // 0040 offset of KMXPlus data, header is first + DWORD dwKMXPlusSize; // 0044 size in bytes of entire KMXPlus data }; + struct KMX_COMP_KEYBOARD_KMXPLUSINFO { + KMX_DWORD dpKMXPlus; // 0040 offset of KMXPlus data, header is first + KMX_DWORD dwKMXPlusSize; // 0044 size in bytes of entire KMXPlus data + }; + + /** * Only valid if comp_keyboard.dwFlags&KF_KMXPLUS */ + struct COMP_KEYBOARD_EX { COMP_KEYBOARD header; // 0000 see COMP_KEYBOARD COMP_KEYBOARD_KMXPLUSINFO kmxplus; // 0040 see COMP_KEYBOARD_EXTRA }; + struct KMX_COMP_KEYBOARD_EX { + KMX_COMP_KEYBOARD header; // 0000 see COMP_KEYBOARD + KMX_COMP_KEYBOARD_KMXPLUSINFO kmxplus; // 0040 see COMP_KEYBOARD_EXTRA + }; + typedef COMP_KEYBOARD *PCOMP_KEYBOARD; typedef COMP_STORE *PCOMP_STORE; typedef COMP_KEY *PCOMP_KEY; typedef COMP_GROUP *PCOMP_GROUP; + typedef KMX_COMP_KEYBOARD *PKMX_COMP_KEYBOARD; + typedef KMX_COMP_STORE *PKMX_COMP_STORE; + typedef KMX_COMP_KEY *PKMX_COMP_KEY; + typedef KMX_COMP_GROUP *PKMX_COMP_GROUP; + + extern const int CODE__SIZE[]; #define CODE__SIZE_MAX 5 @@ -382,6 +452,11 @@ static_assert(sizeof(COMP_KEY) == KEYBOARDFILEKEY_SIZE, "COMP_KEY must be KEYBOA static_assert(sizeof(COMP_GROUP) == KEYBOARDFILEGROUP_SIZE, "COMP_GROUP must be KEYBOARDFILEGROUP_SIZE bytes"); static_assert(sizeof(COMP_KEYBOARD) == KEYBOARDFILEHEADER_SIZE, "COMP_KEYBOARD must be KEYBOARDFILEHEADER_SIZE bytes"); + static_assert(sizeof(KMX_COMP_STORE) == KEYBOARDFILESTORE_SIZE, "COMP_STORE must be KEYBOARDFILESTORE_SIZE bytes"); + static_assert(sizeof(KMX_COMP_KEY) == KEYBOARDFILEKEY_SIZE, "COMP_KEY must be KEYBOARDFILEKEY_SIZE bytes"); + static_assert(sizeof(KMX_COMP_GROUP) == KEYBOARDFILEGROUP_SIZE, "COMP_GROUP must be KEYBOARDFILEGROUP_SIZE bytes"); + static_assert(sizeof(KMX_COMP_KEYBOARD) == KEYBOARDFILEHEADER_SIZE, "COMP_KEYBOARD must be KEYBOARDFILEHEADER_SIZE bytes"); + #ifdef KMN_KBP } // namespace kmx } // namespace kbp diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 527e1e8ddd..92b702d9ae 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -10,18 +10,27 @@ int dummytest_mc_kmx_file(){ } KMX_BOOL VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz); +KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz); +BOOL VerifyKeyboard(LPBYTE filebase, DWORD sz); LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); +LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); /*void Err(wchar_t *s) { LogError(L"LoadKeyboard: %s, last error = %d\n", s, GetLastError()); }*/ -PKMX_WCHAR StringOffset(PKMX_BYTE base, KMX_DWORD offset) { +PWSTR StringOffset(PBYTE base, DWORD offset) { if(offset == 0) return NULL; - return (PKMX_WCHAR)(base + offset); + return (PWSTR)(base + offset); } +PKMX_WCHART KMX_StringOffset(PKMX_BYTE base, KMX_DWORD offset) { + if(offset == 0) return NULL; + return (PKMX_WCHART)(base + offset); +} + + LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize) { @@ -50,13 +59,13 @@ LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize) { for(gp = kbp->dpGroupArray, cgp = (PCOMP_GROUP) gp, i = 0; i < kbp->cxGroupArray; i++, gp++, cgp++) { gp->dpName = StringOffset(base, cgp->dpName); gp->dpKeyArray = (LPKEY) (base + cgp->dpKeyArray); - if(cgp->dpMatch != NULL) gp->dpMatch = (PKMX_WCHAR) (base + cgp->dpMatch); - if(cgp->dpNoMatch != NULL) gp->dpNoMatch = (PKMX_WCHAR) (base + cgp->dpNoMatch); + if(cgp->dpMatch != NULL) gp->dpMatch = (PKMX_WCHART) (base + cgp->dpMatch); // _S2 Warning about NULL !! + if(cgp->dpNoMatch != NULL) gp->dpNoMatch = (PKMX_WCHART) (base + cgp->dpNoMatch); // _S2 Warning about NULL !! MyCoutW(L" ##### gp, cgp filled", 1); for(kp = gp->dpKeyArray, ckp = (PCOMP_KEY) kp, j = 0; j < gp->cxKeyArray; j++, kp++, ckp++) { - kp->dpOutput = (PKMX_WCHAR) (base + ckp->dpOutput); - kp->dpContext = (PKMX_WCHAR) (base + ckp->dpContext); + kp->dpOutput = (PKMX_WCHART) (base + ckp->dpOutput); + kp->dpContext = (PKMX_WCHART) (base + ckp->dpContext); } } @@ -65,6 +74,43 @@ LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize) { return kbp; } +LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize) { + MyCoutW(L" ##### KMX_FixupKeyboard of mc_kmxfile started",1); + UNREFERENCED_PARAMETER(dwFileSize); + + KMX_DWORD i, j; + PKMX_COMP_KEYBOARD ckbp = (PKMX_COMP_KEYBOARD) base; + PKMX_COMP_GROUP cgp; + PKMX_COMP_STORE csp; + PKMX_COMP_KEY ckp; + LPKMX_KEYBOARD kbp = (LPKMX_KEYBOARD) bufp; + LPKMX_STORE sp; + LPKMX_GROUP gp; + LPKMX_KEY kp; + + kbp->dpStoreArray = (LPKMX_STORE) (base + ckbp->dpStoreArray); + kbp->dpGroupArray = (LPKMX_GROUP) (base + ckbp->dpGroupArray); + + for(sp = kbp->dpStoreArray, csp = (PKMX_COMP_STORE) sp, i = 0; i < kbp->cxStoreArray; i++, sp++, csp++) { + sp->dpName = KMX_StringOffset(base, csp->dpName); + sp->dpString = KMX_StringOffset(base, csp->dpString); + } + + for(gp = kbp->dpGroupArray, cgp = (PKMX_COMP_GROUP) gp, i = 0; i < kbp->cxGroupArray; i++, gp++, cgp++) { + gp->dpName = KMX_StringOffset(base, cgp->dpName); + gp->dpKeyArray = (LPKMX_KEY) (base + cgp->dpKeyArray); + if(cgp->dpMatch != NULL) gp->dpMatch = (PKMX_WCHART) (base + cgp->dpMatch); + if(cgp->dpNoMatch != NULL) gp->dpNoMatch = (PKMX_WCHART) (base + cgp->dpNoMatch); + + for(kp = gp->dpKeyArray, ckp = (PKMX_COMP_KEY) kp, j = 0; j < gp->cxKeyArray; j++, kp++, ckp++) { + kp->dpOutput = (PKMX_WCHART) (base + ckp->dpOutput); + kp->dpContext = (PKMX_WCHART) (base + ckp->dpContext); + } + } + # + MyCoutW(L" ##### KMX_FixupKeyboard of mc_kmxfile ended",1); + return kbp; +} /* KMX_BOOL LoadKeyboard(char* fileName, LPKEYBOARD *lpKeyboard) { std::cout << "##### LoadKeyboard of mcompile started #####\n"; @@ -177,20 +223,20 @@ std::cout << "kbp: "<dwIdentifier != FILEID_COMPILED) { - Err(L"errNotFileID"); - delete[] buf; - return FALSE; - }*/ + // if(kbp->dwIdentifier != FILEID_COMPILED) { + // Err(L"errNotFileID"); + // delete[] buf; + // return FALSE; + //} //std::cout << "kbp->dwIdentifier: "<dwIdentifier<< "\n"; -/* + if(kbp->dwIdentifier != FILEID_COMPILED) { delete [] buf; //MyCout("errNotFileID",1); //_S2 ToDo find replacement: DebugLog("errNotFileID"); // _S2 delete [] buf; ???? return FALSE; - }*//* + } MyCout("##### Line 187",1); *lpKeyboard = kbp; // _S2 delete [] buf; ???? @@ -274,7 +320,7 @@ KMX_BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD* lpKeyboard) { fclose(fp); - MyCoutW(L"##### Line 269", 1); + MyCoutW(L"##### Line 328", 1); ; KMX_DWORD sz_dw = (KMX_DWORD)sz; //_S2 size_t sz_t = (size_t)sz; //_S2 @@ -285,9 +331,9 @@ KMX_BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD* lpKeyboard) { return FALSE; } - MyCoutW(L"##### Line 280", 1); + MyCoutW(L"##### Line 339", 1); kbp = FixupKeyboard(buf, filebase, sz_dw); // _S" changed from sz->sz_dw - MyCoutW(L"##### Line 282", 1); + MyCoutW(L"##### Line 341", 1); if (!kbp) { KMX_LogError(L"LogError1: errFixupKeyboard\n" ); @@ -297,7 +343,7 @@ KMX_BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD* lpKeyboard) { return FALSE; } - MyCoutW(L"##### Line 292 ", 1); + MyCoutW(L"##### Line 351 ", 1); std::wcout << "##### kbp->dwIdentifier: " << kbp->dwIdentifier << " FILEID_COMPILED: " << FILEID_COMPILED << "\n"; @@ -306,7 +352,7 @@ KMX_BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD* lpKeyboard) { KMX_LogError(L"LogError1: errNotFileID\n" ); return FALSE; } - MyCoutW(L"##### Line 301", 1); + MyCoutW(L"##### Line 360", 1); *lpKeyboard = kbp; // _S2 delete [] buf; ???? MyCoutW(L"##### LoadKeyboard of mcompile ended #####", 1); @@ -314,6 +360,122 @@ KMX_BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD* lpKeyboard) { } +KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { + std::wcout << "##### KMX_LoadKeyboard of mcompile started #####\n"; + + LPKMX_BYTE buf; + FILE* fp; + LPKMX_KEYBOARD kbp; + PKMX_BYTE filebase; + + wprintf(L"Loading file '%ls'\n", u16fmt((const char16_t*) fileName).c_str()); + + if(!fileName || !lpKeyboard) { + KMX_LogError(L"LogError1: Bad Filename\n" ); + return FALSE; + } + + fp = Open_File((const KMX_WCHAR*)fileName, u"rb"); + + if(fp == NULL) { + KMX_LogError(L"LogError1: Could not open file\n" ); + return FALSE; + } + + if (fseek(fp, 0, SEEK_END) != 0) { + fclose(fp); + KMX_LogError(L"LogError1: Could not fseek file\n" ); + return FALSE; + } + + auto sz = ftell(fp); + if (sz < 0) { + fclose(fp); + return FALSE; + } + + if (fseek(fp, 0, SEEK_SET) != 0) { + fclose(fp); + KMX_LogError(L"LogErr1: Could not fseek(set) file\n" ); + return FALSE; + } + + // #ifdef KMX_64BIT + // allocate enough memory for expanded data structure + original data. + // Expanded data structure is double the size of data on disk (8-byte + // pointers) - on disk the "pointers" are relative to the beginning of + // the file. + // We save the original data at the end of buf; we don't copy strings, so + // those will remain in the location at the end of the buffer. + // buf = new KMX_BYTE[sz * 3]; + // #else + buf = new KMX_BYTE[sz]; + // #endif + + MyCoutW(L"#### Line 435 ", 1); + if (!buf) { + fclose(fp); + KMX_LogError(L"LogErr1: Not allocmem\n" ); + // _S2 delete [] buf; ???? + return FALSE; + } + + // #ifdef KMX_64BIT + // ilebase = buf + sz*2; + // #else + filebase = buf; + // #endif + + if (fread(filebase, 1, sz, fp) < (size_t)sz) { + KMX_LogError(L"LogError1: Could not read file\n" ); + fclose(fp); + // _S2 delete [] buf; ???? + return FALSE; + } + + fclose(fp); + + MyCoutW(L"##### Line 443", 1); + ; + KMX_DWORD sz_dw = (KMX_DWORD)sz; //_S2 + size_t sz_t = (size_t)sz; //_S2 + // if(!VerifyKeyboard(filebase, sz_t)) { + //if (!VerifyKeyboard_S2(filebase, sz_t)) { + if (!KMX_VerifyKeyboard(filebase, sz_t)) { + KMX_LogError(L"LogError1: errVerifyKeyboard\n" ); + // _S2 delete [] buf; ???? + return FALSE; + } + + MyCoutW(L"##### Line 455", 1); + //kbp = FixupKeyboard(buf, filebase, sz_dw); // _S" changed from sz->sz_dw + kbp = KMX_FixupKeyboard(buf, filebase, sz_dw); // _S" changed from sz->sz_dw + MyCoutW(L"##### Line 458", 1); + + if (!kbp) { + KMX_LogError(L"LogError1: errFixupKeyboard\n" ); + // _S2 delete [] buf; ???? + + MyCoutW(L"##### errFixupKeyboard ", 1); + return FALSE; + } + + MyCoutW(L"##### Line 468 ", 1); + + std::wcout << "kbp->dwIdentifier: " << kbp->dwIdentifier << " FILEID_COMPILED: " << FILEID_COMPILED << "\n"; + + if (kbp->dwIdentifier != FILEID_COMPILED) { + delete[] buf; + KMX_LogError(L"LogError1: errNotFileID\n" ); + return FALSE; + } + MyCoutW(L"##### Line 477", 1); + *lpKeyboard = kbp; + // _S2 delete [] buf; ???? + MyCoutW(L"##### LoadKeyboard of mcompile ended #####", 1); + return TRUE; +} + // _S2 Version for char16_t filename /*KMX_BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD* lpKeyboard) { @@ -425,11 +587,12 @@ KMX_BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD* lpKeyboard) { MyCout("##### Line 311 ", 1); //_S2 can go: - /*if(kbp->dwIdentifier != FILEID_COMPILED) { - Err(L"errNotFileID"); - delete[] buf; - return FALSE; -}*//* + //if(kbp->dwIdentifier != FILEID_COMPILED) { + //Err(L"errNotFileID"); + //delete[] buf; + //return FALSE; +//} + std::cout << "kbp->dwIdentifier: " << kbp->dwIdentifier << " FILEID_COMPILED: " << FILEID_COMPILED << "\n"; std::cout << "..xxxxx.\n"; @@ -457,7 +620,7 @@ KMX_BOOL VerifyKeyboard(LPBYTE filebase, KMX_DWORD sz) { // Old or new version -- identify the desired program version // for(csp = (PCOMP_STORE)(filebase + ckbp->dpStoreArray), i = 0; i < ckbp->cxStoreArray; i++, csp++) { if(csp->dwSystemID == TSS_COMPILEDVERSION) { - wchar_t buf2[256]; + //wchar_t buf2[256]; if(csp->dpString == 0) { // _S2 wsprintf(buf2, L"errWrongFileVersion:NULL"); MyCout("errWrongFileVersion",1); @@ -481,6 +644,49 @@ KMX_BOOL VerifyKeyboard(LPBYTE filebase, KMX_DWORD sz) { MyCout("will return true",1); return TRUE; } + +KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz){ + + MyCoutW(L" #### KMX_VerifyKeyboard of mc_kmxfile started", 1); + KMX_DWORD i; + PKMX_COMP_KEYBOARD ckbp = (PKMX_COMP_KEYBOARD)filebase; + PKMX_COMP_STORE csp; + + // Check file version // + + if (ckbp->dwFileVersion < VERSION_MIN || ckbp->dwFileVersion > VERSION_MAX) { + // Old or new version -- identify the desired program version // + for (csp = (PKMX_COMP_STORE)(filebase + ckbp->dpStoreArray), i = 0; i < ckbp->cxStoreArray; i++, csp++) { + if (csp->dwSystemID == TSS_COMPILEDVERSION) { + //wchar_t buf2[256]; + if (csp->dpString == 0) { + // _S2 wsprintf(buf2, L"errWrongFileVersion:NULL"); + MyCout("errWrongFileVersion", 1); + } else { + // _S2 wsprintf(buf2, L"errWrongFileVersion:%10.10ls", StringOffset(filebase, csp->dpString)); + + MyCout("errWrongFileVersion-offset", 1); + } + + MyCout("err buf", 1); + // _S2 Err(buf2); + return FALSE; + } + } + + MyCout("errWrongFileVersion", 1); + // _S2 Err(L"errWrongFileVersion"); + return FALSE; + } + /**/ + MyCout("will return true", 1); + + MyCoutW(L" #### KMX_VerifyKeyboard of mc_kmxfile ended", 1); + return TRUE; +} + + + //---------------------old---------------------------------------- /* #include "pch.h" diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 95cdd77fd0..9a4b5d390a 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -16,68 +16,129 @@ int dummytest_mc_kmx_file(); #define _KMXFILE_H typedef struct tagSTORE { - KMX_DWORD dwSystemID; - PKMX_WCHAR dpName; - PKMX_WCHAR dpString; + DWORD dwSystemID; + PWSTR dpName; + PWSTR dpString; } STORE, *LPSTORE; + typedef struct KMX_tagSTORE { + KMX_DWORD dwSystemID; + PKMX_WCHART dpName; + PKMX_WCHART dpString; + } KMX_STORE, *LPKMX_STORE; + typedef struct tagKEY { - KMX_WCHAR Key; + KMX_WCHART Key; KMX_DWORD Line; KMX_DWORD ShiftFlags; - PKMX_WCHAR dpOutput; - PKMX_WCHAR dpContext; + PKMX_WCHART dpOutput; + PKMX_WCHART dpContext; } KEY, *LPKEY; + typedef struct KMX_tagKEY { + KMX_WCHART Key; + KMX_DWORD Line; + KMX_DWORD ShiftFlags; + PKMX_WCHART dpOutput; + PKMX_WCHART dpContext; + } KMX_KEY, *LPKMX_KEY; + typedef struct tagGROUP { - PKMX_WCHAR dpName; + wchar_t* dpName; LPKEY dpKeyArray; // [LPKEY] address of first item in key array - PKMX_WCHAR dpMatch; - PKMX_WCHAR dpNoMatch; - KMX_DWORD cxKeyArray; // in array entries - KMX_BOOL fUsingKeys; // group(xx) [using keys] <-- specified or not + PWSTR dpMatch; + PWSTR dpNoMatch; + uint32_t cxKeyArray; // in array entries // _S2 was DWORD + int fUsingKeys; // group(xx) [using keys] <-- specified or not } GROUP, *LPGROUP; + typedef struct KMX_tagGROUP { + KMX_WCHART* dpName; + LPKMX_KEY dpKeyArray; // [LPKEY] address of first item in key array + PKMX_WCHART dpMatch; + PKMX_WCHART dpNoMatch; + uint32_t cxKeyArray; // in array entries // _S2 was DWORD + int fUsingKeys; // group(xx) [using keys] <-- specified or not + } KMX_GROUP, *LPKMX_GROUP; + + typedef struct tagKEYBOARD { - KMX_DWORD dwIdentifier; // Keyman compiled keyboard id + DWORD dwIdentifier; // Keyman compiled keyboard id - KMX_DWORD dwFileVersion; // Version of the file - Keyman 4.0 is 0x0400 + DWORD dwFileVersion; // Version of the file - Keyman 4.0 is 0x0400 - KMX_DWORD dwCheckSum; // As stored in keyboard. DEPRECATED as of 16.0 - KMX_DWORD xxkbdlayout; // as stored in HKEY_LOCAL_MACHINE//system//currentcontrolset//control//keyboard layouts - KMX_DWORD IsRegistered; // layout id, from same registry key - KMX_DWORD version; // keyboard version + DWORD dwCheckSum; // As stored in keyboard. DEPRECATED as of 16.0 + DWORD xxkbdlayout; // as stored in HKEY_LOCAL_MACHINE//system//currentcontrolset//control//keyboard layouts + DWORD IsRegistered; // layout id, from same registry key + DWORD version; // keyboard version - KMX_DWORD cxStoreArray; // in array entries - KMX_DWORD cxGroupArray; // in array entries + DWORD cxStoreArray; // in array entries + DWORD cxGroupArray; // in array entries LPSTORE dpStoreArray; // [LPSTORE] address of first item in store array, from start of file LPGROUP dpGroupArray; // [LPGROUP] address of first item in group array, from start of file - KMX_DWORD StartGroup[2]; // index of starting groups [2 of them] + DWORD StartGroup[2]; // index of starting groups [2 of them] // Ansi=0, Unicode=1 - KMX_DWORD dwFlags; // Flags for the keyboard file + DWORD dwFlags; // Flags for the keyboard file - KMX_DWORD dwHotKey; // standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) + DWORD dwHotKey; // standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) //PKMX_WCHART dpName; // offset of name //PKMX_WCHART dpLanguageName; // offset of language name; //PKMX_WCHART dpCopyright; // offset of copyright //PKMX_WCHART dpMessage; // offset of message in Keyboard About box - KMX_DWORD dpBitmapOffset; // 0038 offset of the bitmaps in the file - KMX_DWORD dwBitmapSize; // 003C size in bytes of the bitmaps + DWORD dpBitmapOffset; // 0038 offset of the bitmaps in the file + DWORD dwBitmapSize; // 003C size in bytes of the bitmaps //HBITMAP hBitmap; // handle to the bitmap in the file; } KEYBOARD, *LPKEYBOARD; -KMX_BOOL LoadKeyboard(char* fileName, LPKEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? + typedef struct KMX_tagKEYBOARD { + KMX_DWORD dwIdentifier; // Keyman compiled keyboard id + + KMX_DWORD dwFileVersion; // Version of the file - Keyman 4.0 is 0x0400 + + KMX_DWORD dwCheckSum; // As stored in keyboard. DEPRECATED as of 16.0 + KMX_DWORD xxkbdlayout; // as stored in HKEY_LOCAL_MACHINE//system//currentcontrolset//control//keyboard layouts + KMX_DWORD IsRegistered; // layout id, from same registry key + KMX_DWORD version; // keyboard version + + KMX_DWORD cxStoreArray; // in array entries + KMX_DWORD cxGroupArray; // in array entries + + LPKMX_STORE dpStoreArray; // [LPSTORE] address of first item in store array, from start of file + LPKMX_GROUP dpGroupArray; // [LPGROUP] address of first item in group array, from start of file + + KMX_DWORD StartGroup[2]; // index of starting groups [2 of them] + // Ansi=0, Unicode=1 + + KMX_DWORD dwFlags; // Flags for the keyboard file + + KMX_DWORD dwHotKey; // standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) + + //PKMX_WCHART dpName; // offset of name + //PKMX_WCHART dpLanguageName; // offset of language name; + //PKMX_WCHART dpCopyright; // offset of copyright + //PKMX_WCHART dpMessage; // offset of message in Keyboard About box + + KMX_DWORD dpBitmapOffset; // 0038 offset of the bitmaps in the file + KMX_DWORD dwBitmapSize; // 003C size in bytes of the bitmaps + //HBITMAP hBitmap; // handle to the bitmap in the file; + } KMX_KEYBOARD, *LPKMX_KEYBOARD; + +BOOL LoadKeyboard(char* fileName, LPKEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? +BOOL LoadKeyboard(wchar_t* fileName, LPKEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? +BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? + KMX_BOOL KMX_LoadKeyboard(char* fileName, LPKMX_KEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? + KMX_BOOL KMX_LoadKeyboard(wchar_t* fileName, LPKMX_KEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? + KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? -KMX_BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD* lpKeyboard); #endif diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 18f3c944e8..a7d4c9af34 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -144,9 +144,9 @@ int run(int argc, std::vector< const char16_t*> argv) { wprintf(L"_S2 * Up to here cross-platform xx :-))))) ******************************************************\n"); - LPKEYBOARD kmxfile; + LPKMX_KEYBOARD kmxfile; - if(!LoadKeyboard(infile, &kmxfile)) { + if(!KMX_LoadKeyboard(infile, &kmxfile)) { KMX_LogError(L"Failed to load keyboard (%d)\n", errno ); return 3; } From e6365d4d6d806eab27014e9ab7bd60ffea839a01 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 11 Jul 2023 12:43:10 +0200 Subject: [PATCH 044/327] feat(linux): mcompile use loadKeyboard->CopyKeyboard for 64bit --- linux/mcompile/keymap/km_types.h | 20 +-- linux/mcompile/keymap/kmx_file.h | 16 +- linux/mcompile/keymap/mc_kmxfile.cpp | 241 ++++++++++++++++++++++----- linux/mcompile/keymap/mc_kmxfile.h | 34 ++-- 4 files changed, 232 insertions(+), 79 deletions(-) diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index a9c90d5eca..5e4b39206a 100644 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -29,10 +29,6 @@ typedef uint32_t KMX_DWORD; typedef int32_t KMX_BOOL; typedef uint8_t KMX_BYTE; typedef uint16_t KMX_WORD; -typedef uint32_t DWORD; -typedef int32_t BOOL; -typedef uint8_t BYTE; -typedef uint16_t WORD; #if defined(__cplusplus) typedef char16_t km_kbp_cp; @@ -51,8 +47,6 @@ typedef char16_t KMX_WCHAR; // _S2 typedef KMX_WCHAR* PKMX_WCHAR; // _S2 typedef wchar_t* PWSTR; // _S2 needs to be removed/ wchart-> char16 typedef PWSTR PKMX_WCHART; // _S2 needs to be removed/ wchart-> char16 - -//typedef wchar_t* LPKMX_WCHART; // _S2 needs to be removed/ wchart-> char16 typedef const wchar_t* PCKMX_WCHART; // _S2 needs to be removed/? typedef char* LPSTR; // _S2 needs to be removed? @@ -61,25 +55,27 @@ typedef LPSTR LPKMX_STR; // _S2 needs to be removed? typedef uint8_t* LPBYTE; // _S2 needs to be removed/? typedef uint8_t* LPKMX_BYTE; // _S2 needs to be removed? - typedef uint8_t* PBYTE; // _S2 needs to be removed/? typedef uint8_t* PKMX_BYTE; // _S2 needs to be removed? - // _S2 LPKEYBOARD ok to leave as is?? - typedef char KMX_CHAR; // _S2 needs to be removed/? typedef char* PKMX_STR; // _S2 needs to be removed/? +typedef unsigned char BYTE; // _S2 needs to be removed? +typedef unsigned long DWORD; // _S2 needs to be removed/? +typedef unsigned short WORD; // _S2 needs to be removed/? +typedef wchar_t* LPWSTR; // _S2 needs to be removed/? +typedef WCHAR* PWCHAR; // _S2 needs to be removed/? + typedef KMX_CHAR* PKMX_CHAR; // _S2 needs to be removed/? +typedef int BOOL; // _S2 needs to be removed/? or is it int32_t?? + typedef uint32_t KMX_UINT; typedef KMX_BYTE* PKMX_BYTE; typedef KMX_WORD* PKMX_WORD; typedef KMX_DWORD* PKMX_DWORD; -typedef BYTE* PBYTE; -typedef WORD* PWORD; -typedef DWORD* PDWORD; #ifndef FALSE #define FALSE 0 diff --git a/linux/mcompile/keymap/kmx_file.h b/linux/mcompile/keymap/kmx_file.h index 5dd1f439ea..777880ab59 100644 --- a/linux/mcompile/keymap/kmx_file.h +++ b/linux/mcompile/keymap/kmx_file.h @@ -314,8 +314,7 @@ struct COMP_STORE { }; struct COMP_KEY { - KMX_WORD Key; - KMX_WORD _reserved; + WORD Key; DWORD Line; DWORD ShiftFlags; DWORD dpOutput; @@ -447,15 +446,10 @@ extern const int CODE__SIZE[]; #define KEYBOARDFILEGROUP_SIZE 24 #define KEYBOARDFILEKEY_SIZE 20 -static_assert(sizeof(COMP_STORE) == KEYBOARDFILESTORE_SIZE, "COMP_STORE must be KEYBOARDFILESTORE_SIZE bytes"); -static_assert(sizeof(COMP_KEY) == KEYBOARDFILEKEY_SIZE, "COMP_KEY must be KEYBOARDFILEKEY_SIZE bytes"); -static_assert(sizeof(COMP_GROUP) == KEYBOARDFILEGROUP_SIZE, "COMP_GROUP must be KEYBOARDFILEGROUP_SIZE bytes"); -static_assert(sizeof(COMP_KEYBOARD) == KEYBOARDFILEHEADER_SIZE, "COMP_KEYBOARD must be KEYBOARDFILEHEADER_SIZE bytes"); - - static_assert(sizeof(KMX_COMP_STORE) == KEYBOARDFILESTORE_SIZE, "COMP_STORE must be KEYBOARDFILESTORE_SIZE bytes"); - static_assert(sizeof(KMX_COMP_KEY) == KEYBOARDFILEKEY_SIZE, "COMP_KEY must be KEYBOARDFILEKEY_SIZE bytes"); - static_assert(sizeof(KMX_COMP_GROUP) == KEYBOARDFILEGROUP_SIZE, "COMP_GROUP must be KEYBOARDFILEGROUP_SIZE bytes"); - static_assert(sizeof(KMX_COMP_KEYBOARD) == KEYBOARDFILEHEADER_SIZE, "COMP_KEYBOARD must be KEYBOARDFILEHEADER_SIZE bytes"); +static_assert(sizeof(KMX_COMP_STORE) == KEYBOARDFILESTORE_SIZE, "COMP_STORE must be KEYBOARDFILESTORE_SIZE bytes"); +static_assert(sizeof(KMX_COMP_KEY) == KEYBOARDFILEKEY_SIZE, "COMP_KEY must be KEYBOARDFILEKEY_SIZE bytes"); +static_assert(sizeof(KMX_COMP_GROUP) == KEYBOARDFILEGROUP_SIZE, "COMP_GROUP must be KEYBOARDFILEGROUP_SIZE bytes"); +static_assert(sizeof(KMX_COMP_KEYBOARD) == KEYBOARDFILEHEADER_SIZE, "COMP_KEYBOARD must be KEYBOARDFILEHEADER_SIZE bytes"); #ifdef KMN_KBP } // namespace kmx diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 92b702d9ae..b6fc5bdb78 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -2,6 +2,7 @@ #include "mc_kmxfile.h" #include "helpers.h" #include "u16.h" +#include "filesystem.h" // _S2 needed? #include int dummytest_mc_kmx_file(){ @@ -9,30 +10,40 @@ int dummytest_mc_kmx_file(){ return 0; } -KMX_BOOL VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz); +//KMX_BOOL VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz); KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz); -BOOL VerifyKeyboard(LPBYTE filebase, DWORD sz); +//BOOL VerifyKeyboard(LPBYTE filebase, DWORD sz); + +//LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); -LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); /*void Err(wchar_t *s) { LogError(L"LoadKeyboard: %s, last error = %d\n", s, GetLastError()); }*/ -PWSTR StringOffset(PBYTE base, DWORD offset) { +/*PWSTR StringOffset(PBYTE base, DWORD offset) { + if(offset == 0) return NULL; + return (PWSTR)(base + offset); +}*/ + +/*PWCHAR StringOffset(PBYTE base, DWORD offset) { if(offset == 0) return NULL; return (PWSTR)(base + offset); } +*/ -PKMX_WCHART KMX_StringOffset(PKMX_BYTE base, KMX_DWORD offset) { +/*PKMX_WCHART KMX_StringOffset(PKMX_BYTE base, KMX_DWORD offset) { if(offset == 0) return NULL; return (PKMX_WCHART)(base + offset); +}*/ + +PKMX_WCHAR KMX_StringOffset(PKMX_BYTE base, KMX_DWORD offset) { + if(offset == 0) return NULL; + return (PKMX_WCHAR)(base + offset); } - - -LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize) { +/*LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize) { MyCoutW(L" ##### FixupKeyboard started", 1); UNREFERENCED_PARAMETER(dwFileSize); @@ -71,10 +82,151 @@ LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize) { MyCoutW(L" ##### kp filled", 1); MyCoutW(L" ##### FixupKeyboard ended", 1); + return kbp; +}*/ + + +#ifdef KMX_64BIT +/** + CopyKeyboard will copy the data read into bufp from x86-sized structures into + x64-sized structures starting at `base` + * After this function finishes, we still need to keep the original data because + we don't copy the strings + This method is used on 64-bit architectures. +*/ +LPKMX_KEYBOARD KMX_CopyKeyboard(PKMX_BYTE bufp, PKMX_BYTE base) +{ + PKMX_COMP_KEYBOARD ckbp = (PKMX_COMP_KEYBOARD) base; + + /* Copy keyboard structure */ + + LPKMX_KEYBOARD kbp = (LPKMX_KEYBOARD) bufp; + bufp += sizeof(KMX_KEYBOARD); + + kbp->dwIdentifier = ckbp->dwIdentifier; + kbp->dwFileVersion = ckbp->dwFileVersion; + kbp->dwCheckSum = ckbp->dwCheckSum; + kbp->xxkbdlayout = ckbp->KeyboardID; + kbp->IsRegistered = ckbp->IsRegistered; + kbp->version = ckbp->version; + kbp->cxStoreArray = ckbp->cxStoreArray; + kbp->cxGroupArray = ckbp->cxGroupArray; + kbp->StartGroup[0] = ckbp->StartGroup[0]; + kbp->StartGroup[1] = ckbp->StartGroup[1]; + kbp->dwFlags = ckbp->dwFlags; + kbp->dwHotKey = ckbp->dwHotKey; + + kbp->dpStoreArray = (LPKMX_STORE) bufp; + bufp += sizeof(KMX_STORE) * kbp->cxStoreArray; + + kbp->dpGroupArray = (LPKMX_GROUP) bufp; + bufp += sizeof(KMX_GROUP) * kbp->cxGroupArray; + + PKMX_COMP_STORE csp; + LPKMX_STORE sp; + KMX_DWORD i; + + for( + csp = (PKMX_COMP_STORE)(base + ckbp->dpStoreArray), sp = kbp->dpStoreArray, i = 0; + i < kbp->cxStoreArray; + i++, sp++, csp++) + { + sp->dwSystemID = csp->dwSystemID; + sp->dpName = KMX_StringOffset(base, csp->dpName); + sp->dpString = KMX_StringOffset(base, csp->dpString); + } + + PKMX_COMP_GROUP cgp; + LPKMX_GROUP gp; + + for( + cgp = (PKMX_COMP_GROUP)(base + ckbp->dpGroupArray), gp = kbp->dpGroupArray, i = 0; + i < kbp->cxGroupArray; + i++, gp++, cgp++) + { + gp->dpName = KMX_StringOffset(base, cgp->dpName); + gp->dpKeyArray = cgp->cxKeyArray > 0 ? (LPKMX_KEY) bufp : NULL; + gp->cxKeyArray = cgp->cxKeyArray; + bufp += sizeof(KMX_KEY) * gp->cxKeyArray; + gp->dpMatch = KMX_StringOffset(base, cgp->dpMatch); + gp->dpNoMatch = KMX_StringOffset(base, cgp->dpNoMatch); + gp->fUsingKeys = cgp->fUsingKeys; + + PKMX_COMP_KEY ckp; + LPKMX_KEY kp; + KMX_DWORD j; + + for( + ckp = (PKMX_COMP_KEY)(base + cgp->dpKeyArray), kp = gp->dpKeyArray, j = 0; + j < gp->cxKeyArray; + j++, kp++, ckp++) + { + kp->Key = ckp->Key; + kp->Line = ckp->Line; + kp->ShiftFlags = ckp->ShiftFlags; + kp->dpOutput = KMX_StringOffset(base, ckp->dpOutput); + kp->dpContext = KMX_StringOffset(base, ckp->dpContext); + } + } + return kbp; } +// else KMX_FixupKeyboard +#else +/** + Fixup the keyboard by expanding pointers. On disk the pointers are stored relative to the + beginning of the file, but we need real pointers. This method is used on 32-bit architectures. +*/ + LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize) { + MyCoutW(L" ##### KMX_FixupKeyboard of mcompile started",1); + UNREFERENCED_PARAMETER(dwFileSize); + + KMX_DWORD i, j; + PKMX_COMP_KEYBOARD ckbp = (PKMX_COMP_KEYBOARD) base; + PKMX_COMP_GROUP cgp; + PKMX_COMP_STORE csp; + PKMX_COMP_KEY ckp; + LPKMX_KEYBOARD kbp = (LPKMX_KEYBOARD) bufp; + LPKMX_STORE sp; + LPKMX_GROUP gp; + LPKMX_KEY kp; + + kbp->dpStoreArray = (LPKMX_STORE) (base + ckbp->dpStoreArray); + kbp->dpGroupArray = (LPKMX_GROUP) (base + ckbp->dpGroupArray); + + for(sp = kbp->dpStoreArray, csp = (PKMX_COMP_STORE) sp, i = 0; i < kbp->cxStoreArray; i++, sp++, csp++) { + sp->dpName = KMX_StringOffset(base, csp->dpName); + sp->dpString = KMX_StringOffset(base, csp->dpString); + } + + for(gp = kbp->dpGroupArray, cgp = (PKMX_COMP_GROUP) gp, i = 0; i < kbp->cxGroupArray; i++, gp++, cgp++) { + gp->dpName = KMX_StringOffset(base, cgp->dpName); + gp->dpKeyArray = (LPKMX_KEY) (base + cgp->dpKeyArray); + if(cgp->dpMatch != NULL) gp->dpMatch = (PKMX_WCHAR) (base + cgp->dpMatch); + if(cgp->dpNoMatch != NULL) gp->dpNoMatch = (PKMX_WCHAR) (base + cgp->dpNoMatch); + + // _S2 Version of kmx_file v + /*gp->dpName = StringOffset(base, cgp->dpName); + gp->dpKeyArray = cgp->cxKeyArray > 0 ? (LPKEY) (base + cgp->dpKeyArray) : NULL; + gp->dpMatch = StringOffset(base, cgp->dpMatch); + gp->dpNoMatch = StringOffset(base, cgp->dpNoMatch);*/ + // _S2 Version of kmx_file ^ + + for(kp = gp->dpKeyArray, ckp = (PKMX_COMP_KEY) kp, j = 0; j < gp->cxKeyArray; j++, kp++, ckp++) { + kp->dpOutput = (PKMX_WCHAR) (base + ckp->dpOutput); + kp->dpContext = (PKMX_WCHAR) (base + ckp->dpContext); + } + } + + MyCoutW(L" ##### KMX_FixupKeyboard of mcompile ended",1); + return kbp; +} +#endif + + +/*LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize) { MyCoutW(L" ##### KMX_FixupKeyboard of mc_kmxfile started",1); UNREFERENCED_PARAMETER(dwFileSize); @@ -110,9 +262,9 @@ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFil # MyCoutW(L" ##### KMX_FixupKeyboard of mc_kmxfile ended",1); return kbp; -} -/* -KMX_BOOL LoadKeyboard(char* fileName, LPKEYBOARD *lpKeyboard) { +}*/ + +/*KMX_BOOL LoadKeyboard(char* fileName, LPKEYBOARD *lpKeyboard) { std::cout << "##### LoadKeyboard of mcompile started #####\n"; std::cout << "fileName: " <sz_dw - kbp = KMX_FixupKeyboard(buf, filebase, sz_dw); // _S" changed from sz->sz_dw - MyCoutW(L"##### Line 458", 1); +#ifdef KMX_64BIT // _S2 opened for copyKeyboard-Version + kbp = KMX_CopyKeyboard(buf, filebase); // _S2 opened for copyKeyboard-Version +#else // _S2 opened for copyKeyboard-Version + MyCoutW(L"##### Line 469", 1); + kbp = KMX_FixupKeyboard(buf, filebase, sz); // _S2 changed from sz->sz_dw + MyCoutW(L"##### Line 471", 1); +#endif // _S2 opened for copyKeyboard-Version + if (!kbp) { KMX_LogError(L"LogError1: errFixupKeyboard\n" ); @@ -608,7 +769,8 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { return TRUE; } */ -KMX_BOOL VerifyKeyboard(LPBYTE filebase, KMX_DWORD sz) { + +/*KMX_BOOL VerifyKeyboard(LPBYTE filebase, KMX_DWORD sz) { KMX_DWORD i; PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD) filebase; PCOMP_STORE csp; @@ -640,10 +802,11 @@ KMX_BOOL VerifyKeyboard(LPBYTE filebase, KMX_DWORD sz) { // _S2 Err(L"errWrongFileVersion"); return FALSE; } -/**/ + MyCout("will return true",1); return TRUE; } +*/ KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz){ diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 9a4b5d390a..8888e94589 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -23,44 +23,44 @@ typedef struct tagSTORE { typedef struct KMX_tagSTORE { KMX_DWORD dwSystemID; - PKMX_WCHART dpName; - PKMX_WCHART dpString; + PKMX_WCHAR dpName; + PKMX_WCHAR dpString; } KMX_STORE, *LPKMX_STORE; typedef struct tagKEY { - KMX_WCHART Key; - KMX_DWORD Line; - KMX_DWORD ShiftFlags; - PKMX_WCHART dpOutput; - PKMX_WCHART dpContext; + WCHAR Key; + DWORD Line; + DWORD ShiftFlags; + PWSTR dpOutput; + PWSTR dpContext; } KEY, *LPKEY; typedef struct KMX_tagKEY { - KMX_WCHART Key; + KMX_WCHAR Key; KMX_DWORD Line; KMX_DWORD ShiftFlags; - PKMX_WCHART dpOutput; - PKMX_WCHART dpContext; + PKMX_WCHAR dpOutput; + PKMX_WCHAR dpContext; } KMX_KEY, *LPKMX_KEY; typedef struct tagGROUP { - wchar_t* dpName; + PWSTR dpName; LPKEY dpKeyArray; // [LPKEY] address of first item in key array PWSTR dpMatch; PWSTR dpNoMatch; - uint32_t cxKeyArray; // in array entries // _S2 was DWORD + DWORD cxKeyArray; // in array entries int fUsingKeys; // group(xx) [using keys] <-- specified or not } GROUP, *LPGROUP; typedef struct KMX_tagGROUP { - KMX_WCHART* dpName; + KMX_WCHAR* dpName; LPKMX_KEY dpKeyArray; // [LPKEY] address of first item in key array - PKMX_WCHART dpMatch; - PKMX_WCHART dpNoMatch; - uint32_t cxKeyArray; // in array entries // _S2 was DWORD - int fUsingKeys; // group(xx) [using keys] <-- specified or not + PKMX_WCHAR dpMatch; + PKMX_WCHAR dpNoMatch; + KMX_DWORD cxKeyArray; // in array entries // _S2 was DWORD + int32_t fUsingKeys; // group(xx) [using keys] <-- specified or not } KMX_GROUP, *LPKMX_GROUP; From 51d67c482ef13302d8e25ce1eb24181750ac95fe Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 11 Jul 2023 13:44:24 +0200 Subject: [PATCH 045/327] feat(linux): mcompile tidy up code --- linux/mcompile/keymap/mc_kmxfile.cpp | 550 +-------------------------- linux/mcompile/keymap/mc_kmxfile.h | 16 +- linux/mcompile/keymap/mcompile.cpp | 7 - linux/mcompile/keymap/mcompile.h | 2 +- 4 files changed, 19 insertions(+), 556 deletions(-) diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index b6fc5bdb78..db813613f8 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -10,82 +10,19 @@ int dummytest_mc_kmx_file(){ return 0; } -//KMX_BOOL VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz); -KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz); -//BOOL VerifyKeyboard(LPBYTE filebase, DWORD sz); +KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard); -//LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); +KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz); LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); -/*void Err(wchar_t *s) { - LogError(L"LoadKeyboard: %s, last error = %d\n", s, GetLastError()); -}*/ -/*PWSTR StringOffset(PBYTE base, DWORD offset) { - if(offset == 0) return NULL; - return (PWSTR)(base + offset); -}*/ - -/*PWCHAR StringOffset(PBYTE base, DWORD offset) { - if(offset == 0) return NULL; - return (PWSTR)(base + offset); -} -*/ - -/*PKMX_WCHART KMX_StringOffset(PKMX_BYTE base, KMX_DWORD offset) { - if(offset == 0) return NULL; - return (PKMX_WCHART)(base + offset); -}*/ PKMX_WCHAR KMX_StringOffset(PKMX_BYTE base, KMX_DWORD offset) { if(offset == 0) return NULL; return (PKMX_WCHAR)(base + offset); } -/*LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize) { - - MyCoutW(L" ##### FixupKeyboard started", 1); - UNREFERENCED_PARAMETER(dwFileSize); - - KMX_DWORD i, j; - PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD) base; - PCOMP_GROUP cgp; - PCOMP_STORE csp; - PCOMP_KEY ckp; - LPKEYBOARD kbp = (LPKEYBOARD) bufp; - LPSTORE sp; - LPGROUP gp; - LPKEY kp; - kbp->dpStoreArray = (LPSTORE) (base + ckbp->dpStoreArray); - kbp->dpGroupArray = (LPGROUP) (base + ckbp->dpGroupArray); - - MyCoutW(L" ##### first assignment finished", 1); - for(sp = kbp->dpStoreArray, csp = (PCOMP_STORE) sp, i = 0; i < kbp->cxStoreArray; i++, sp++, csp++) { - sp->dpName = StringOffset(base, csp->dpName); - sp->dpString = StringOffset(base, csp->dpString); - } - - MyCoutW(L" ##### sp filled", 1); - for(gp = kbp->dpGroupArray, cgp = (PCOMP_GROUP) gp, i = 0; i < kbp->cxGroupArray; i++, gp++, cgp++) { - gp->dpName = StringOffset(base, cgp->dpName); - gp->dpKeyArray = (LPKEY) (base + cgp->dpKeyArray); - if(cgp->dpMatch != NULL) gp->dpMatch = (PKMX_WCHART) (base + cgp->dpMatch); // _S2 Warning about NULL !! - if(cgp->dpNoMatch != NULL) gp->dpNoMatch = (PKMX_WCHART) (base + cgp->dpNoMatch); // _S2 Warning about NULL !! - - MyCoutW(L" ##### gp, cgp filled", 1); - for(kp = gp->dpKeyArray, ckp = (PCOMP_KEY) kp, j = 0; j < gp->cxKeyArray; j++, kp++, ckp++) { - kp->dpOutput = (PKMX_WCHART) (base + ckp->dpOutput); - kp->dpContext = (PKMX_WCHART) (base + ckp->dpContext); - } - } - - MyCoutW(L" ##### kp filled", 1); - MyCoutW(L" ##### FixupKeyboard ended", 1); - return kbp; -}*/ - - #ifdef KMX_64BIT /** CopyKeyboard will copy the data read into bufp from x86-sized structures into @@ -225,294 +162,8 @@ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFil } #endif - -/*LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize) { - MyCoutW(L" ##### KMX_FixupKeyboard of mc_kmxfile started",1); - UNREFERENCED_PARAMETER(dwFileSize); - - KMX_DWORD i, j; - PKMX_COMP_KEYBOARD ckbp = (PKMX_COMP_KEYBOARD) base; - PKMX_COMP_GROUP cgp; - PKMX_COMP_STORE csp; - PKMX_COMP_KEY ckp; - LPKMX_KEYBOARD kbp = (LPKMX_KEYBOARD) bufp; - LPKMX_STORE sp; - LPKMX_GROUP gp; - LPKMX_KEY kp; - - kbp->dpStoreArray = (LPKMX_STORE) (base + ckbp->dpStoreArray); - kbp->dpGroupArray = (LPKMX_GROUP) (base + ckbp->dpGroupArray); - - for(sp = kbp->dpStoreArray, csp = (PKMX_COMP_STORE) sp, i = 0; i < kbp->cxStoreArray; i++, sp++, csp++) { - sp->dpName = KMX_StringOffset(base, csp->dpName); - sp->dpString = KMX_StringOffset(base, csp->dpString); - } - - for(gp = kbp->dpGroupArray, cgp = (PKMX_COMP_GROUP) gp, i = 0; i < kbp->cxGroupArray; i++, gp++, cgp++) { - gp->dpName = KMX_StringOffset(base, cgp->dpName); - gp->dpKeyArray = (LPKMX_KEY) (base + cgp->dpKeyArray); - if(cgp->dpMatch != NULL) gp->dpMatch = (PKMX_WCHART) (base + cgp->dpMatch); - if(cgp->dpNoMatch != NULL) gp->dpNoMatch = (PKMX_WCHART) (base + cgp->dpNoMatch); - - for(kp = gp->dpKeyArray, ckp = (PKMX_COMP_KEY) kp, j = 0; j < gp->cxKeyArray; j++, kp++, ckp++) { - kp->dpOutput = (PKMX_WCHART) (base + ckp->dpOutput); - kp->dpContext = (PKMX_WCHART) (base + ckp->dpContext); - } - } - # - MyCoutW(L" ##### KMX_FixupKeyboard of mc_kmxfile ended",1); - return kbp; -}*/ - -/*KMX_BOOL LoadKeyboard(char* fileName, LPKEYBOARD *lpKeyboard) { - std::cout << "##### LoadKeyboard of mcompile started #####\n"; - std::cout << "fileName: " <dwIdentifier != FILEID_COMPILED) { - // Err(L"errNotFileID"); - // delete[] buf; - // return FALSE; - //} - -//std::cout << "kbp->dwIdentifier: "<dwIdentifier<< "\n"; - - if(kbp->dwIdentifier != FILEID_COMPILED) { - delete [] buf; - //MyCout("errNotFileID",1); //_S2 ToDo find replacement: DebugLog("errNotFileID"); - // _S2 delete [] buf; ???? - return FALSE; - } -MyCout("##### Line 187",1); - *lpKeyboard = kbp; - // _S2 delete [] buf; ???? - MyCout("##### LoadKeyboard of mcompile ended #####",1); - return TRUE; -}*/ - -/*KMX_BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD* lpKeyboard) { - std::wcout << "##### LoadKeyboard of mcompile started #####\n"; - - LPKMX_BYTE buf; - FILE* fp; - LPKEYBOARD kbp; - PKMX_BYTE filebase; - - wprintf(L"Loading file '%ls'\n", u16fmt((const char16_t*) fileName).c_str()); - - if(!fileName || !lpKeyboard) { - KMX_LogError(L"LogError1: Bad Filename\n" ); - return FALSE; - } - - fp = Open_File((const KMX_WCHAR*)fileName, u"rb"); - - if(fp == NULL) { - KMX_LogError(L"LogError1: Could not open file\n" ); - return FALSE; - } - - if (fseek(fp, 0, SEEK_END) != 0) { - fclose(fp); - KMX_LogError(L"LogError1: Could not fseek file\n" ); - return FALSE; - } - - auto sz = ftell(fp); - if (sz < 0) { - fclose(fp); - return FALSE; - } - - if (fseek(fp, 0, SEEK_SET) != 0) { - fclose(fp); - KMX_LogError(L"LogErr1: Could not fseek(set) file\n" ); - return FALSE; - } - - // #ifdef KMX_64BIT - // allocate enough memory for expanded data structure + original data. - // Expanded data structure is double the size of data on disk (8-byte - // pointers) - on disk the "pointers" are relative to the beginning of - // the file. - // We save the original data at the end of buf; we don't copy strings, so - // those will remain in the location at the end of the buffer. - // buf = new KMX_BYTE[sz * 3]; - // #else - buf = new KMX_BYTE[sz]; - // #endif - - MyCoutW(L"#### Line 246 ", 1); - if (!buf) { - fclose(fp); - KMX_LogError(L"LogErr1: Not allocmem\n" ); - // _S2 delete [] buf; ???? - return FALSE; - } - - // #ifdef KMX_64BIT - // ilebase = buf + sz*2; - // #else - filebase = buf; - // #endif - - if (fread(filebase, 1, sz, fp) < (size_t)sz) { - KMX_LogError(L"LogError1: Could not read file\n" ); - fclose(fp); - // _S2 delete [] buf; ???? - return FALSE; - } - - fclose(fp); - - MyCoutW(L"##### Line 328", 1); - ; - KMX_DWORD sz_dw = (KMX_DWORD)sz; //_S2 - size_t sz_t = (size_t)sz; //_S2 - // if(!VerifyKeyboard(filebase, sz_t)) { - if (!VerifyKeyboard(filebase, sz_t)) { - KMX_LogError(L"LogError1: errVerifyKeyboard\n" ); - // _S2 delete [] buf; ???? - return FALSE; - } - - MyCoutW(L"##### Line 339", 1); - kbp = FixupKeyboard(buf, filebase, sz_dw); // _S" changed from sz->sz_dw - MyCoutW(L"##### Line 341", 1); - - if (!kbp) { - KMX_LogError(L"LogError1: errFixupKeyboard\n" ); - // _S2 delete [] buf; ???? - - MyCoutW(L"##### errFixupKeyboard ", 1); - return FALSE; - } - - MyCoutW(L"##### Line 351 ", 1); - - std::wcout << "##### kbp->dwIdentifier: " << kbp->dwIdentifier << " FILEID_COMPILED: " << FILEID_COMPILED << "\n"; - - if (kbp->dwIdentifier != FILEID_COMPILED) { - delete[] buf; - KMX_LogError(L"LogError1: errNotFileID\n" ); - return FALSE; - } - MyCoutW(L"##### Line 360", 1); - *lpKeyboard = kbp; - // _S2 delete [] buf; ???? - MyCoutW(L"##### LoadKeyboard of mcompile ended #####", 1); - return TRUE; -} -*/ - KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { - std::wcout << "##### KMX_LoadKeyboard of mcompile started #####\n"; + std::wcout << "##### KMX_LoadKeyboard of mc_kmxfile started #####\n"; PKMX_BYTE buf; FILE* fp; @@ -637,180 +288,7 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { return TRUE; } - -// _S2 Version for char16_t filename -/*KMX_BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD* lpKeyboard) { - std::cout << "##### LoadKeyboard of mcompile started #####\n"; - std::cout << "fileName: " <sz_dw - MyCout("##### Line 299", 1); - - std::cout << "kbp: " << kbp << "\n"; - if (!kbp) { - // Err(L"errFixupKeyboard"); //_S2 ToDo find replacement: Err - // _S2 delete [] buf; ???? - - MyCout("##### errFixupKeyboard ", 1); - return FALSE; - } - - MyCout("##### Line 311 ", 1); - //_S2 can go: - //if(kbp->dwIdentifier != FILEID_COMPILED) { - //Err(L"errNotFileID"); - //delete[] buf; - //return FALSE; -//} - - - std::cout << "kbp->dwIdentifier: " << kbp->dwIdentifier << " FILEID_COMPILED: " << FILEID_COMPILED << "\n"; - std::cout << "..xxxxx.\n"; - if (kbp->dwIdentifier != FILEID_COMPILED) { - delete[] buf; - MyCout("errNotFileID", 1); //_S2 ToDo find replacement: DebugLog("errNotFileID"); - return FALSE; - } - MyCout("##### Line 327", 1); - *lpKeyboard = kbp; - // _S2 delete [] buf; ???? - MyCout("##### LoadKeyboard of mcompile ended #####", 1); - return TRUE; -} -*/ - -/*KMX_BOOL VerifyKeyboard(LPBYTE filebase, KMX_DWORD sz) { - KMX_DWORD i; - PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD) filebase; - PCOMP_STORE csp; - - // Check file version // - - if(ckbp->dwFileVersion < VERSION_MIN || - ckbp->dwFileVersion > VERSION_MAX) { - // Old or new version -- identify the desired program version // - for(csp = (PCOMP_STORE)(filebase + ckbp->dpStoreArray), i = 0; i < ckbp->cxStoreArray; i++, csp++) { - if(csp->dwSystemID == TSS_COMPILEDVERSION) { - //wchar_t buf2[256]; - if(csp->dpString == 0) { - // _S2 wsprintf(buf2, L"errWrongFileVersion:NULL"); - MyCout("errWrongFileVersion",1); - } else { - // _S2 wsprintf(buf2, L"errWrongFileVersion:%10.10ls", StringOffset(filebase, csp->dpString)); - - MyCout("errWrongFileVersion-offset",1); - } - - MyCout("err buf",1); - // _S2 Err(buf2); - return FALSE; - } - } - - MyCout("errWrongFileVersion",1); - // _S2 Err(L"errWrongFileVersion"); - return FALSE; - } - -MyCout("will return true",1); - return TRUE; -} -*/ - KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz){ - - MyCoutW(L" #### KMX_VerifyKeyboard of mc_kmxfile started", 1); KMX_DWORD i; PKMX_COMP_KEYBOARD ckbp = (PKMX_COMP_KEYBOARD)filebase; PKMX_COMP_STORE csp; @@ -821,30 +299,22 @@ KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz){ // Old or new version -- identify the desired program version // for (csp = (PKMX_COMP_STORE)(filebase + ckbp->dpStoreArray), i = 0; i < ckbp->cxStoreArray; i++, csp++) { if (csp->dwSystemID == TSS_COMPILEDVERSION) { - //wchar_t buf2[256]; + wchar_t buf2[256]; if (csp->dpString == 0) { - // _S2 wsprintf(buf2, L"errWrongFileVersion:NULL"); - MyCout("errWrongFileVersion", 1); + KMX_LogError(L"LogErr1: errWrongFileVersion:NULL"); } else { - // _S2 wsprintf(buf2, L"errWrongFileVersion:%10.10ls", StringOffset(filebase, csp->dpString)); - - MyCout("errWrongFileVersion-offset", 1); + wprintf(L"LogErr1: errWrongFileVersion:%10.10ls",(const PKMX_WCHAR) KMX_StringOffset((PKMX_BYTE)filebase, csp->dpString)); } - - MyCout("err buf", 1); - // _S2 Err(buf2); return FALSE; } } - - MyCout("errWrongFileVersion", 1); - // _S2 Err(L"errWrongFileVersion"); + KMX_LogError(L"LogErr1: errWrongFileVersion"); return FALSE; } - /**/ - MyCout("will return true", 1); - MyCoutW(L" #### KMX_VerifyKeyboard of mc_kmxfile ended", 1); + MyCout("will return true", 1); + MyCoutW(L" #### KMX_VerifyKeyboard of mc_kmxfile ended", 1); + return TRUE; } diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 8888e94589..94be306f11 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -89,10 +89,10 @@ typedef struct tagKEYBOARD { DWORD dwHotKey; // standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) - //PKMX_WCHART dpName; // offset of name - //PKMX_WCHART dpLanguageName; // offset of language name; - //PKMX_WCHART dpCopyright; // offset of copyright - //PKMX_WCHART dpMessage; // offset of message in Keyboard About box + //PWSTR dpName; // offset of name + //PWSTR dpLanguageName; // offset of language name; + //PWSTR dpCopyright; // offset of copyright + //PWSTR dpMessage; // offset of message in Keyboard About box DWORD dpBitmapOffset; // 0038 offset of the bitmaps in the file DWORD dwBitmapSize; // 003C size in bytes of the bitmaps @@ -122,10 +122,10 @@ typedef struct tagKEYBOARD { KMX_DWORD dwHotKey; // standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) - //PKMX_WCHART dpName; // offset of name - //PKMX_WCHART dpLanguageName; // offset of language name; - //PKMX_WCHART dpCopyright; // offset of copyright - //PKMX_WCHART dpMessage; // offset of message in Keyboard About box + //PWSTR dpName; // offset of name + //PWSTR dpLanguageName; // offset of language name; + //PWSTR dpCopyright; // offset of copyright + //PWSTR dpMessage; // offset of message in Keyboard About box KMX_DWORD dpBitmapOffset; // 0038 offset of the bitmaps in the file KMX_DWORD dwBitmapSize; // 003C size in bytes of the bitmaps diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index a7d4c9af34..591441bf9c 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -151,13 +151,6 @@ wprintf(L"_S2 * Up to here cross-platform xx :-))))) ************************** return 3; } - /* QUESTIONS / TODO - status mc_kmx-file.cpp: - find replacement: VerifyKeyboard_S2 - wrong entries in : VerifyKeyboard - */ - - std::cout << " ++ UP TO HERE IN STEP 1 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; /* if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552 diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 5f6cab2458..5e136cc82f 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -29,7 +29,7 @@ void KMX_LogError(const KMX_WCHART* m1, int m2 = 0); struct DeadkeyMapping { // I4353 - KMX_WCHART deadkey, dkid; + KMX_WCHAR deadkey, dkid; KMX_UINT shift; KMX_WORD vk; }; From 560fa6ab89062399e7fbb3a1b5cac5b04cb3cb79 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 11 Jul 2023 13:44:24 +0200 Subject: [PATCH 046/327] feat(linux): mcompile tidy up code --- linux/mcompile/keymap/README.md | 14 +- linux/mcompile/keymap/keymapWC.cpp | 585 --------------------------- linux/mcompile/keymap/keymapWC.h | 100 ----- linux/mcompile/keymap/mc_kmxfile.cpp | 550 +------------------------ linux/mcompile/keymap/mc_kmxfile.h | 16 +- linux/mcompile/keymap/mcompile.cpp | 7 - linux/mcompile/keymap/mcompile.h | 2 +- 7 files changed, 23 insertions(+), 1251 deletions(-) delete mode 100644 linux/mcompile/keymap/keymapWC.cpp delete mode 100644 linux/mcompile/keymap/keymapWC.h diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index 8560740bc1..f96a6b8d69 100644 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -1,8 +1,10 @@ -# Keymap +This is a proposal to rewrite mcompile for Linux. For this we need to query the base keyboard data from the Linux platform, then rewriting the keyboard .kmx using the same approach as is done in mcompile for Windows, but working from the data from the x11 keyboard on Linux. + +Ideally, we'd rewrite mcompile to be cross-platform (Windows, Linux, macOS), so that the keyboard interrogation would be separated from the .kmx rewriting, at least to some degree. Nevertheless it would probably be easiest to start from a standalone implementation. Sample program that reads US basic keyboard and compares to key value group - +# Keymap TODO check if US basic is the right Keyboard to compare with TODO non-letter characters don't work OK yet @@ -17,19 +19,11 @@ TODO get rid of GTK functions that are deprecated and use X11 instead TODO retrieve name of Other keyboard and use appropriate name instead of "Other" TODO change keymap.cpp->main() to function() TODO use/adapt TranslateKeyboard() to work on Linux/cross-platform -TODO use/adapt LoadKeyboard() to work on Linux/cross-platform TODO use/adapt SaveKeyboard() to work on Linux/cross-platform -TODO include deadkeys TODO mcompile.cpp: open mcompile -u - option -TODO replace GetLastError with SetError/AddCompileError/AddCompileWarning -TODO u16.h u16.cpp include fron folder of kmx_u16.h -TOTO use wchar_t* as cmd-lne-par in main ?? -TOTO changes inside VerifyKeyboard() -TOTO changes inside FixupKeyboard() TODO check if I can use files from some other keyman path instead of a copy in keymap ( e.g. filesystem.h exists elsewhere) TODO ... //--------------------------- TOASK is using string OK, or do we use char, wchar? TOASK a-z, A_Z or more keys? ... -TOASK main/wmain? will we use wchar_t Filenames on Linux? diff --git a/linux/mcompile/keymap/keymapWC.cpp b/linux/mcompile/keymap/keymapWC.cpp deleted file mode 100644 index a88d778027..0000000000 --- a/linux/mcompile/keymap/keymapWC.cpp +++ /dev/null @@ -1,585 +0,0 @@ -// MAY BE REMOVED LATER _S2 -#include "keymapWC.h" - -#include -#include -#include -#include -#include "keymap.h" - -// run with ./keymapWC -d in.kmx bla.dll 0407 out.kmx - - -int dummytest_keymapWC(){ - std::cout<< " dummytest_keymapWC is available\t"; - return 0; -} - -bool write_US_ToVectorWC( v_WC_3D &vec,std::string language, const char* text) { -//std::cout << " in write_US_ToVector \n"; - std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; - - const char* path = FullPathName.c_str(); - //std::cout << " in path"<" and the next xkb_symbol - // and then copy all rows starting with "key <" to a v1D-Vector - - std::cout << " in CreateCompleteRow_USWC "<<" \n"; - int buffer_size = 512; - char buffer[buffer_size]; - char16_t buf16[buffer_size]; - bool print_OK = false; - const char* key = "key <"; - std::string str_txt(text); - std::string xbk_mark = "xkb_symbol"; - // TODO define folder to store File in - std::ofstream KeyboardFile("File_" + language + ".txt"); - - printf("Keyboard %s\n", text); - KeyboardFile << "Keyboard" << text << " "; - - if (fp) { - while (fgets(buffer, buffer_size, fp) != NULL) { - std::string str_buf(buffer); - - //std::cout << " str_buf"< from the shiftstates - // 3: push Names/Shiftstates to shift_states and then shiftstates to All_US, our 3D-Vector holding all Elements - - std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; - char split_bracel = '{'; - char split_char_komma = ','; - std::string empty = "--"; // '-' only !!! - v_str_1D tokens; - v_str_2D shift_states; - - // go through the whole vector - for (int k = 0; k < (int)completeList.size() - 1; k++) { - - // remove all unwanted char - for (int i = 0; i < (int) delim.size(); i++) { - completeList[k].erase(remove(completeList[k].begin(), completeList[k].end(), delim[i]), completeList[k].end()); - } - - // only lines with ("key<.. are of interest - if (completeList[k].find("key<") != std::string::npos) { - - //split off the key names - std::istringstream split1(completeList[k]); - for (std::string each; std::getline(split1, each, split_bracel); tokens.push_back(each)); - - // replace keys names with number ( with 29,...) - int Keycde = replace_PosKey_with_Keycode(tokens[0]); - tokens[0] = std::to_string(Keycde); - - // we use characters a-z, A_Z only at the moment - if (foundCharacterInListWC(tokens[0])) { - - // seperate rest of the vector to its elements and push to 'tokens' - std::istringstream split(tokens[1]); - tokens.pop_back(); - - for (std::string each; std::getline(split, each, split_char_komma); tokens.push_back(each)); - //printf("### 5 Split_US_To_3D_Vector: tokens: size:%li...tokens[0]-[4]:-name:%s\tShiftstates:%s--%s--%s--%s---.\n", tokens.size(),tokens[0].c_str(),tokens[1].c_str(),tokens[2].c_str(),tokens[3].c_str(),tokens[4].c_str()); - - // at the moment we only use the first 2 shiftstates (non-shift+shift) so get rid of all others - int surplus = tokens.size() - shift_state_count -1; - for( int j=0; j < surplus;j++) { - tokens.pop_back(); - } - - // now push result to shift_states - shift_states.push_back(tokens); - } - tokens.clear(); - } - } - all_US.push_back(shift_states); - - if ( all_US.size() ==0) { - printf("ERROR: Can't split US to 3D-Vector\n"); - return 1; - } - //printf("### 6 Split_US_To_3D_clearVector %li..%li..%li\n", all_US.size(), all_US[0].size(),all_US[0][0].size()); - */ -return 0; -} - -/*bool foundCharacterInListWC(std::string tok) { - //TOASK Do we need more and which? - //US keys: Q W E R T Y U I O P A S D F G H J K L : Z X C V B N M - v_str_1D Keysyms { "24","25","26","27","28","29","30","31","32","33","38","39","40","41","42","43","44","45","46","47","52","53","54","55","56","57","58"}; - - for ( int i =0; i< (int) Keysyms.size();i++) { - std::cout << "foundCharacterInList" << i <<"\n"; - if( tok == Keysyms[i]) { - return true; - } - } - return false; -}*/ - -/*int replace_PosKey_with_KeycodeWC(std::string in) { - int out=0; - if ( in == "key") out = 49; // TOASK correct ??? - else if ( in == "key") out = 10; - else if ( in == "key") out = 11; - else if ( in == "key") out = 12; - else if ( in == "key") out = 13; - else if ( in == "key") out = 14; - else if ( in == "key") out = 15; - else if ( in == "key") out = 16; - else if ( in == "key") out = 17; - else if ( in == "key") out = 18; - else if ( in == "key") out = 19; - else if ( in == "key") out = 20; - else if ( in == "key") out = 21; - - else if ( in == "key") out = 24; - else if ( in == "key") out = 25; - else if ( in == "key") out = 26; - else if ( in == "key") out = 27; - else if ( in == "key") out = 28; - else if ( in == "key") out = 29; - else if ( in == "key") out = 30; - else if ( in == "key") out = 31; - else if ( in == "key") out = 32; - else if ( in == "key") out = 33; - else if ( in == "key") out = 34; - else if ( in == "key") out = 35; - - else if ( in == "key") out = 38; - else if ( in == "key") out = 39; - else if ( in == "key") out = 40; - else if ( in == "key") out = 41; - else if ( in == "key") out = 42; - else if ( in == "key") out = 43; - else if ( in == "key") out = 44; - else if ( in == "key") out = 45; - else if ( in == "key") out = 46; - else if ( in == "key") out = 47; - else if ( in == "key") out = 48; - else if ( in == "key") out = 49; - - else if ( in == "key") out = 52; - else if ( in == "key") out = 53; - else if ( in == "key") out = 54; - else if ( in == "key") out = 55; - else if ( in == "key") out = 56; - else if ( in == "key") out = 57; - else if ( in == "key") out = 58; - else if ( in == "key") out = 59; - else if ( in == "key") out = 60; - else if ( in == "key") out = 61; - else if ( in == "key") out = 62; //TOASK correct ??? - else if ( in == "key") out = 51; //TOASK correct ??? - return out; -}*/ - -bool append_other_ToVectorWC(v_WC_3D &All_Vector,GdkKeymap * keymap) { -/*b - // create a 2D vector all filled with "--" and push to 3D-Vector - v_str_2D Other_Vector2D = create_empty_2D(All_Vector[0].size(),All_Vector[0][0].size()); - - if (Other_Vector2D.size()==0) { - printf("ERROR: create empty 2D-Vector failed"); - return 1; - } - - All_Vector.push_back(Other_Vector2D); - printf("+++++++ dimensions of Vector after append_other_ToVector\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); - - if (All_Vector.size()==0) { - printf("ERROR: creation of 3D-Vector failed"); - return 1; - } - - for(int i =0; i< (int) All_Vector[1].size();i++) { - - // get key name US stored in [0][i][0] and copy to name in other-block[1][i][0] - All_Vector[1][i][0] = All_Vector[0][i][0]; - - // write this value to 3D- Vector - All_Vector[1][i][0+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),0); //shift state: unshifted:0 - All_Vector[1][i][1+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),1); //shift state: shifted:1 - - printf(" Keycodes US->Other: %d(US): %s %s ---- (other):%s, \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str()); - } -*/ - return 0; -} - -v_WC_2D create_empty_2DWC( int dim_rows,int dim_shifts) { - char16_t empty = u'-'; - v_WC_1D shifts; - v_WC_2D all; - - for ( int i=0; i< dim_rows;i++) { - for ( int j=0; j< dim_shifts;j++) { - shifts.push_back(empty); - } - all.push_back(shifts); - shifts.clear(); - } - return all; -} - -int GetKeyvalsFromKeymapWC(GdkKeymap *keymap, guint keycode, int shift_state_pos) { - GdkKeymapKey *maps; - guint *keyvals; - gint count; - int out; - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return 0; - //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - // return 0; - - if (!(shift_state_pos < count)) - return 0; - - out = keyvals[shift_state_pos]; - - g_free(keyvals); - g_free(maps); - return out; -} - -bool extract_differenceWC( v_WC_3D &All_Vector) { - /* // TODO define which Folder; find better name - std::ofstream Map_File("Map_US.txt"); - std::string diff =" "; - - printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); - std::cout << "Nr of \n" ; - std::cout << "Key: " << "\t Character US (no shift) " << " Character US (shift) "<< "\t\tCharacter other (no shift)" << "\tCharacter other (shift) difference \n" ; - printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); - - Map_File <<"--------------------------------------------------------------------------------------------------------------------------------------------\n"; - Map_File << "Nr of \n" ; - Map_File << "Key: " << "\t Character US (no shift) " << " Character US (shift) "<< "\t\tCharacter other (no shift)" << "\tCharacter other (shift) difference \n" ; - Map_File <<"--------------------------------------------------------------------------------------------------------------------------------------------\n"; - - for ( int k=0; k<(int)All_Vector[0].size(); k++) { - if (All_Vector[0][k][1] == All_Vector[1][k][1]) - diff =" "; - else - diff =" *** "; - - std::cout << All_Vector[0][k][0] << "\t " <<+(*(All_Vector[0][k][1].c_str()))<< "\t("<< All_Vector[0][k][1] <<")"< Other: "; - // find correct row of char in US - for( int i=0; i< (int) All_Vector[0].size();i++) { - for( int j=1; j< (int)All_Vector[0][0].size();j++) { - - //std::cout << "see and compare: "<< "All_Vector[0]["< Other: "; - //std::cout << "US -> Other: "<< std::setw(5)< Other: (" << in << ": no match)\n"; - - - return u'-';*/ -} - -char16_t get_US_Char_FromOtherWC(char16_t in , v_WC_3D &All_Vector) { - /*char16_t diff; - // find correct row of char in other - for( int i=0; i< (int)All_Vector[1].size();i++) { - for( int j=1; j< (int)All_Vector[1][0].size();j++) { - if ( All_Vector[1][i][j] == in ) { - if ( All_Vector[0][i][j] != All_Vector[1][i][j]) - diff = u'*'; - std::wcout << "Other -> US: "<< std::setw(5)< US: (" << in << ": no match)\n"; - - return u'-';*/ - } - -char16_t getKeyNrOf_USCharWC(char16_t in , v_WC_3D &All_Vector) { - /*// find correct row of char in US - for( int i=0; i< (int)All_Vector[0].size();i++) { - for( int j=1; j< (int)All_Vector[0][0].size();j++) { - if ( All_Vector[0][i][j] == in ) { - std::wcout << u"KeyNr of US char: \t"<< All_Vector[0][i][j] << u" -> " << All_Vector[0][i][0] << u"\n"; - return All_Vector[0][i][0] ; - } - } - } - return u'-';*/ -} - -char16_t getKeyNrOf_OtherCharWC(char16_t in , v_str_3D &All_Vector) { - /* // find correct row of char in US - for( int i=0; i< (int)All_Vector[1].size();i++) { - for( int j=1; j< (int)All_Vector[1][0].size();j++) { - if ( All_Vector[1][i][j] == in ) { - std::wcout << u"KeyNr of Other char : \t"<< All_Vector[1][i][j] << u" -> " << All_Vector[1][i][0] <1) - std::wcout << " row 1 (Other).."<< V[1][k][0]<< ".." << V[1][k][1]<< ".."<< "..\n" ; - } - printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - return true; -} - -void test_in_outWC(v_WC_3D &All_Vector) { -/*std::string diff; - printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); - //checks mapping between US and other - std::string a = get_Other_Char_FromUS( "z", All_Vector); - std::string aa = get_Other_Char_FromUS( "Z", All_Vector); - std::string aaa = get_Other_Char_FromUS( "y", All_Vector); - std::string aaaa = get_Other_Char_FromUS( "Y", All_Vector); - - std::string b = get_US_Char_FromOther( "z", All_Vector); - std::string bb = get_US_Char_FromOther( "Z", All_Vector); - std::string bbb = get_US_Char_FromOther( "y", All_Vector); - std::string bbbb = get_US_Char_FromOther( "Y", All_Vector); - - std::string c = getKeyNrOf_OtherChar( "z", All_Vector); - std::string cc = getKeyNrOf_OtherChar( "Z", All_Vector); - std::string ccc = getKeyNrOf_OtherChar( "y", All_Vector); - std::string cccc = getKeyNrOf_OtherChar( "Y", All_Vector); - - std::string d = getKeyNrOf_USChar( "z", All_Vector); - std::string dd = getKeyNrOf_USChar( "Z", All_Vector); - std::string ddd = getKeyNrOf_USChar( "y", All_Vector); - std::string dddd = getKeyNrOf_USChar( "Y", All_Vector); - - std::cout << "get_Other_Char_FromUS z-Z-y-Y: " << ".." << a<< ".." < -#include -#include - -#include -#include -#include -#include -#include -#include -#include "mc_kmxfile.h" -#include "kmx_file.h" -#include "mc_savekeyboard.h" -#include "helpers.h" -#include "u16.h" - - -int dummytest_keymapWC(); -// In ths program we use a 3D-Vector Vector[language][Keys][Shiftstates] - - -typedef std::vector v_str_1D; -typedef std::vector > v_str_2D; -typedef std::vector > > v_str_3D; - -typedef std::vector v_WC_1D; -typedef std::vector > v_WC_2D; -typedef std::vector > > v_WC_3D; - -static int shift_state_count_WC = 2; // use shiftstate : no shift, shift -int run_DoConvert_Part1_getMapWC(int argc, char *argv[]); -// adapt from mc_kmxfile.cpp -void LoadKeyboardWC(); - -// use TranslateKeyboard, TranslateGroup,TranslateKey from mcompile -void run_DoConvert_Part2_TranslateKeyboardWC(); - -// adapt from mc_savekeyboard.cpp -void SaveKeyboardWC(); - - -// read configuration file, split and write to 3D-Vector WC(Data for US on [0][ ][ ] ) -bool write_US_ToVectorWC(v_WC_3D &vec, std::string language, const char *text); - -// 1. step: read complete Row of Configuration file US -bool CreateCompleteRow_USWC(v_WC_1D &complete_List, FILE *fpp, const char *text, std::string language); - -// 2nd step: write contents to 3D vector -bool Split_US_To_3D_VectorWC(v_WC_3D &all_US, v_WC_1D completeList); -/* -// make sure only a-z, A_Z is used -bool foundCharacterInListWC(std::string tok); - -// replace Name of Key WC(e.g. ) wih Keycode WC( e.g. 15 ) -int replace_PosKey_with_KeycodeWC(std::string in); -*/ -// append characters using GDK to 3D-Vector WC(Data for Other Language on [1][ ][ ] ) -bool append_other_ToVectorWC(v_WC_3D &All_Vector, GdkKeymap *keymap); -/* -// create an empty 2D vector containing "--" in all fields -v_str_2D create_empty_2DWC(int dim_rows, int dim_shifts); - -// find Keyvals to fill into 2D-Vector of Other Language -int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos); -*/ -// print both sets of characters WC(US and OtherLanguage) to console and file for comparison -bool extract_differenceWC(v_WC_3D &All_Vector); -/* -// get mapped key from Other WC(Other->US) -std::string get_Other_Char_FromUSWC(std::string in, v_str_3D &All_Vector); -// get mapped key from US->Other WC(US->Other) -std::string get_US_Char_FromOtherWC(std::string in, v_str_3D &All_Vector); -// get KeyNr from US -std::string getKeyNrOf_USCharWC(std::string in, v_str_3D &All_Vector); -// get KeyNr from Other -std::string getKeyNrOf_OtherCharWC(std::string in, v_str_3D &All_Vector); - -// for testing/debugging - may be deleted later -// prints out a 1:1 mapping US->Other -*/ -void print_simple_map_USWC(v_WC_3D &All_Vector, int shiftstate); -// prints out a 1:1 mapping Other->US -void print_simple_map_OtherWC(v_str_3D &All_Vector, int shiftstate); -// test of above functions WC(character mapping US <-> Other; KeyNr <-> CHaracter) -/*vvoid test_in_outWC(v_str_3D &All_Vector); -// testing of Vector contents WC( first row of US and Other) -bool testWC(v_str_3D &V); -*/ -// writing out mapping of some characters: a,b,m,w,x,y,z -void test_specific_CharactersWC(v_WC_3D &All_Vector); - - - -#endif /*KEYMAPWC_H*/ diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index b6fc5bdb78..db813613f8 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -10,82 +10,19 @@ int dummytest_mc_kmx_file(){ return 0; } -//KMX_BOOL VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz); -KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz); -//BOOL VerifyKeyboard(LPBYTE filebase, DWORD sz); +KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard); -//LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); +KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz); LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); -/*void Err(wchar_t *s) { - LogError(L"LoadKeyboard: %s, last error = %d\n", s, GetLastError()); -}*/ -/*PWSTR StringOffset(PBYTE base, DWORD offset) { - if(offset == 0) return NULL; - return (PWSTR)(base + offset); -}*/ - -/*PWCHAR StringOffset(PBYTE base, DWORD offset) { - if(offset == 0) return NULL; - return (PWSTR)(base + offset); -} -*/ - -/*PKMX_WCHART KMX_StringOffset(PKMX_BYTE base, KMX_DWORD offset) { - if(offset == 0) return NULL; - return (PKMX_WCHART)(base + offset); -}*/ PKMX_WCHAR KMX_StringOffset(PKMX_BYTE base, KMX_DWORD offset) { if(offset == 0) return NULL; return (PKMX_WCHAR)(base + offset); } -/*LPKEYBOARD FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize) { - - MyCoutW(L" ##### FixupKeyboard started", 1); - UNREFERENCED_PARAMETER(dwFileSize); - - KMX_DWORD i, j; - PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD) base; - PCOMP_GROUP cgp; - PCOMP_STORE csp; - PCOMP_KEY ckp; - LPKEYBOARD kbp = (LPKEYBOARD) bufp; - LPSTORE sp; - LPGROUP gp; - LPKEY kp; - kbp->dpStoreArray = (LPSTORE) (base + ckbp->dpStoreArray); - kbp->dpGroupArray = (LPGROUP) (base + ckbp->dpGroupArray); - - MyCoutW(L" ##### first assignment finished", 1); - for(sp = kbp->dpStoreArray, csp = (PCOMP_STORE) sp, i = 0; i < kbp->cxStoreArray; i++, sp++, csp++) { - sp->dpName = StringOffset(base, csp->dpName); - sp->dpString = StringOffset(base, csp->dpString); - } - - MyCoutW(L" ##### sp filled", 1); - for(gp = kbp->dpGroupArray, cgp = (PCOMP_GROUP) gp, i = 0; i < kbp->cxGroupArray; i++, gp++, cgp++) { - gp->dpName = StringOffset(base, cgp->dpName); - gp->dpKeyArray = (LPKEY) (base + cgp->dpKeyArray); - if(cgp->dpMatch != NULL) gp->dpMatch = (PKMX_WCHART) (base + cgp->dpMatch); // _S2 Warning about NULL !! - if(cgp->dpNoMatch != NULL) gp->dpNoMatch = (PKMX_WCHART) (base + cgp->dpNoMatch); // _S2 Warning about NULL !! - - MyCoutW(L" ##### gp, cgp filled", 1); - for(kp = gp->dpKeyArray, ckp = (PCOMP_KEY) kp, j = 0; j < gp->cxKeyArray; j++, kp++, ckp++) { - kp->dpOutput = (PKMX_WCHART) (base + ckp->dpOutput); - kp->dpContext = (PKMX_WCHART) (base + ckp->dpContext); - } - } - - MyCoutW(L" ##### kp filled", 1); - MyCoutW(L" ##### FixupKeyboard ended", 1); - return kbp; -}*/ - - #ifdef KMX_64BIT /** CopyKeyboard will copy the data read into bufp from x86-sized structures into @@ -225,294 +162,8 @@ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFil } #endif - -/*LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize) { - MyCoutW(L" ##### KMX_FixupKeyboard of mc_kmxfile started",1); - UNREFERENCED_PARAMETER(dwFileSize); - - KMX_DWORD i, j; - PKMX_COMP_KEYBOARD ckbp = (PKMX_COMP_KEYBOARD) base; - PKMX_COMP_GROUP cgp; - PKMX_COMP_STORE csp; - PKMX_COMP_KEY ckp; - LPKMX_KEYBOARD kbp = (LPKMX_KEYBOARD) bufp; - LPKMX_STORE sp; - LPKMX_GROUP gp; - LPKMX_KEY kp; - - kbp->dpStoreArray = (LPKMX_STORE) (base + ckbp->dpStoreArray); - kbp->dpGroupArray = (LPKMX_GROUP) (base + ckbp->dpGroupArray); - - for(sp = kbp->dpStoreArray, csp = (PKMX_COMP_STORE) sp, i = 0; i < kbp->cxStoreArray; i++, sp++, csp++) { - sp->dpName = KMX_StringOffset(base, csp->dpName); - sp->dpString = KMX_StringOffset(base, csp->dpString); - } - - for(gp = kbp->dpGroupArray, cgp = (PKMX_COMP_GROUP) gp, i = 0; i < kbp->cxGroupArray; i++, gp++, cgp++) { - gp->dpName = KMX_StringOffset(base, cgp->dpName); - gp->dpKeyArray = (LPKMX_KEY) (base + cgp->dpKeyArray); - if(cgp->dpMatch != NULL) gp->dpMatch = (PKMX_WCHART) (base + cgp->dpMatch); - if(cgp->dpNoMatch != NULL) gp->dpNoMatch = (PKMX_WCHART) (base + cgp->dpNoMatch); - - for(kp = gp->dpKeyArray, ckp = (PKMX_COMP_KEY) kp, j = 0; j < gp->cxKeyArray; j++, kp++, ckp++) { - kp->dpOutput = (PKMX_WCHART) (base + ckp->dpOutput); - kp->dpContext = (PKMX_WCHART) (base + ckp->dpContext); - } - } - # - MyCoutW(L" ##### KMX_FixupKeyboard of mc_kmxfile ended",1); - return kbp; -}*/ - -/*KMX_BOOL LoadKeyboard(char* fileName, LPKEYBOARD *lpKeyboard) { - std::cout << "##### LoadKeyboard of mcompile started #####\n"; - std::cout << "fileName: " <dwIdentifier != FILEID_COMPILED) { - // Err(L"errNotFileID"); - // delete[] buf; - // return FALSE; - //} - -//std::cout << "kbp->dwIdentifier: "<dwIdentifier<< "\n"; - - if(kbp->dwIdentifier != FILEID_COMPILED) { - delete [] buf; - //MyCout("errNotFileID",1); //_S2 ToDo find replacement: DebugLog("errNotFileID"); - // _S2 delete [] buf; ???? - return FALSE; - } -MyCout("##### Line 187",1); - *lpKeyboard = kbp; - // _S2 delete [] buf; ???? - MyCout("##### LoadKeyboard of mcompile ended #####",1); - return TRUE; -}*/ - -/*KMX_BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD* lpKeyboard) { - std::wcout << "##### LoadKeyboard of mcompile started #####\n"; - - LPKMX_BYTE buf; - FILE* fp; - LPKEYBOARD kbp; - PKMX_BYTE filebase; - - wprintf(L"Loading file '%ls'\n", u16fmt((const char16_t*) fileName).c_str()); - - if(!fileName || !lpKeyboard) { - KMX_LogError(L"LogError1: Bad Filename\n" ); - return FALSE; - } - - fp = Open_File((const KMX_WCHAR*)fileName, u"rb"); - - if(fp == NULL) { - KMX_LogError(L"LogError1: Could not open file\n" ); - return FALSE; - } - - if (fseek(fp, 0, SEEK_END) != 0) { - fclose(fp); - KMX_LogError(L"LogError1: Could not fseek file\n" ); - return FALSE; - } - - auto sz = ftell(fp); - if (sz < 0) { - fclose(fp); - return FALSE; - } - - if (fseek(fp, 0, SEEK_SET) != 0) { - fclose(fp); - KMX_LogError(L"LogErr1: Could not fseek(set) file\n" ); - return FALSE; - } - - // #ifdef KMX_64BIT - // allocate enough memory for expanded data structure + original data. - // Expanded data structure is double the size of data on disk (8-byte - // pointers) - on disk the "pointers" are relative to the beginning of - // the file. - // We save the original data at the end of buf; we don't copy strings, so - // those will remain in the location at the end of the buffer. - // buf = new KMX_BYTE[sz * 3]; - // #else - buf = new KMX_BYTE[sz]; - // #endif - - MyCoutW(L"#### Line 246 ", 1); - if (!buf) { - fclose(fp); - KMX_LogError(L"LogErr1: Not allocmem\n" ); - // _S2 delete [] buf; ???? - return FALSE; - } - - // #ifdef KMX_64BIT - // ilebase = buf + sz*2; - // #else - filebase = buf; - // #endif - - if (fread(filebase, 1, sz, fp) < (size_t)sz) { - KMX_LogError(L"LogError1: Could not read file\n" ); - fclose(fp); - // _S2 delete [] buf; ???? - return FALSE; - } - - fclose(fp); - - MyCoutW(L"##### Line 328", 1); - ; - KMX_DWORD sz_dw = (KMX_DWORD)sz; //_S2 - size_t sz_t = (size_t)sz; //_S2 - // if(!VerifyKeyboard(filebase, sz_t)) { - if (!VerifyKeyboard(filebase, sz_t)) { - KMX_LogError(L"LogError1: errVerifyKeyboard\n" ); - // _S2 delete [] buf; ???? - return FALSE; - } - - MyCoutW(L"##### Line 339", 1); - kbp = FixupKeyboard(buf, filebase, sz_dw); // _S" changed from sz->sz_dw - MyCoutW(L"##### Line 341", 1); - - if (!kbp) { - KMX_LogError(L"LogError1: errFixupKeyboard\n" ); - // _S2 delete [] buf; ???? - - MyCoutW(L"##### errFixupKeyboard ", 1); - return FALSE; - } - - MyCoutW(L"##### Line 351 ", 1); - - std::wcout << "##### kbp->dwIdentifier: " << kbp->dwIdentifier << " FILEID_COMPILED: " << FILEID_COMPILED << "\n"; - - if (kbp->dwIdentifier != FILEID_COMPILED) { - delete[] buf; - KMX_LogError(L"LogError1: errNotFileID\n" ); - return FALSE; - } - MyCoutW(L"##### Line 360", 1); - *lpKeyboard = kbp; - // _S2 delete [] buf; ???? - MyCoutW(L"##### LoadKeyboard of mcompile ended #####", 1); - return TRUE; -} -*/ - KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { - std::wcout << "##### KMX_LoadKeyboard of mcompile started #####\n"; + std::wcout << "##### KMX_LoadKeyboard of mc_kmxfile started #####\n"; PKMX_BYTE buf; FILE* fp; @@ -637,180 +288,7 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { return TRUE; } - -// _S2 Version for char16_t filename -/*KMX_BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD* lpKeyboard) { - std::cout << "##### LoadKeyboard of mcompile started #####\n"; - std::cout << "fileName: " <sz_dw - MyCout("##### Line 299", 1); - - std::cout << "kbp: " << kbp << "\n"; - if (!kbp) { - // Err(L"errFixupKeyboard"); //_S2 ToDo find replacement: Err - // _S2 delete [] buf; ???? - - MyCout("##### errFixupKeyboard ", 1); - return FALSE; - } - - MyCout("##### Line 311 ", 1); - //_S2 can go: - //if(kbp->dwIdentifier != FILEID_COMPILED) { - //Err(L"errNotFileID"); - //delete[] buf; - //return FALSE; -//} - - - std::cout << "kbp->dwIdentifier: " << kbp->dwIdentifier << " FILEID_COMPILED: " << FILEID_COMPILED << "\n"; - std::cout << "..xxxxx.\n"; - if (kbp->dwIdentifier != FILEID_COMPILED) { - delete[] buf; - MyCout("errNotFileID", 1); //_S2 ToDo find replacement: DebugLog("errNotFileID"); - return FALSE; - } - MyCout("##### Line 327", 1); - *lpKeyboard = kbp; - // _S2 delete [] buf; ???? - MyCout("##### LoadKeyboard of mcompile ended #####", 1); - return TRUE; -} -*/ - -/*KMX_BOOL VerifyKeyboard(LPBYTE filebase, KMX_DWORD sz) { - KMX_DWORD i; - PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD) filebase; - PCOMP_STORE csp; - - // Check file version // - - if(ckbp->dwFileVersion < VERSION_MIN || - ckbp->dwFileVersion > VERSION_MAX) { - // Old or new version -- identify the desired program version // - for(csp = (PCOMP_STORE)(filebase + ckbp->dpStoreArray), i = 0; i < ckbp->cxStoreArray; i++, csp++) { - if(csp->dwSystemID == TSS_COMPILEDVERSION) { - //wchar_t buf2[256]; - if(csp->dpString == 0) { - // _S2 wsprintf(buf2, L"errWrongFileVersion:NULL"); - MyCout("errWrongFileVersion",1); - } else { - // _S2 wsprintf(buf2, L"errWrongFileVersion:%10.10ls", StringOffset(filebase, csp->dpString)); - - MyCout("errWrongFileVersion-offset",1); - } - - MyCout("err buf",1); - // _S2 Err(buf2); - return FALSE; - } - } - - MyCout("errWrongFileVersion",1); - // _S2 Err(L"errWrongFileVersion"); - return FALSE; - } - -MyCout("will return true",1); - return TRUE; -} -*/ - KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz){ - - MyCoutW(L" #### KMX_VerifyKeyboard of mc_kmxfile started", 1); KMX_DWORD i; PKMX_COMP_KEYBOARD ckbp = (PKMX_COMP_KEYBOARD)filebase; PKMX_COMP_STORE csp; @@ -821,30 +299,22 @@ KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz){ // Old or new version -- identify the desired program version // for (csp = (PKMX_COMP_STORE)(filebase + ckbp->dpStoreArray), i = 0; i < ckbp->cxStoreArray; i++, csp++) { if (csp->dwSystemID == TSS_COMPILEDVERSION) { - //wchar_t buf2[256]; + wchar_t buf2[256]; if (csp->dpString == 0) { - // _S2 wsprintf(buf2, L"errWrongFileVersion:NULL"); - MyCout("errWrongFileVersion", 1); + KMX_LogError(L"LogErr1: errWrongFileVersion:NULL"); } else { - // _S2 wsprintf(buf2, L"errWrongFileVersion:%10.10ls", StringOffset(filebase, csp->dpString)); - - MyCout("errWrongFileVersion-offset", 1); + wprintf(L"LogErr1: errWrongFileVersion:%10.10ls",(const PKMX_WCHAR) KMX_StringOffset((PKMX_BYTE)filebase, csp->dpString)); } - - MyCout("err buf", 1); - // _S2 Err(buf2); return FALSE; } } - - MyCout("errWrongFileVersion", 1); - // _S2 Err(L"errWrongFileVersion"); + KMX_LogError(L"LogErr1: errWrongFileVersion"); return FALSE; } - /**/ - MyCout("will return true", 1); - MyCoutW(L" #### KMX_VerifyKeyboard of mc_kmxfile ended", 1); + MyCout("will return true", 1); + MyCoutW(L" #### KMX_VerifyKeyboard of mc_kmxfile ended", 1); + return TRUE; } diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 8888e94589..94be306f11 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -89,10 +89,10 @@ typedef struct tagKEYBOARD { DWORD dwHotKey; // standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) - //PKMX_WCHART dpName; // offset of name - //PKMX_WCHART dpLanguageName; // offset of language name; - //PKMX_WCHART dpCopyright; // offset of copyright - //PKMX_WCHART dpMessage; // offset of message in Keyboard About box + //PWSTR dpName; // offset of name + //PWSTR dpLanguageName; // offset of language name; + //PWSTR dpCopyright; // offset of copyright + //PWSTR dpMessage; // offset of message in Keyboard About box DWORD dpBitmapOffset; // 0038 offset of the bitmaps in the file DWORD dwBitmapSize; // 003C size in bytes of the bitmaps @@ -122,10 +122,10 @@ typedef struct tagKEYBOARD { KMX_DWORD dwHotKey; // standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) - //PKMX_WCHART dpName; // offset of name - //PKMX_WCHART dpLanguageName; // offset of language name; - //PKMX_WCHART dpCopyright; // offset of copyright - //PKMX_WCHART dpMessage; // offset of message in Keyboard About box + //PWSTR dpName; // offset of name + //PWSTR dpLanguageName; // offset of language name; + //PWSTR dpCopyright; // offset of copyright + //PWSTR dpMessage; // offset of message in Keyboard About box KMX_DWORD dpBitmapOffset; // 0038 offset of the bitmaps in the file KMX_DWORD dwBitmapSize; // 003C size in bytes of the bitmaps diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index a7d4c9af34..591441bf9c 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -151,13 +151,6 @@ wprintf(L"_S2 * Up to here cross-platform xx :-))))) ************************** return 3; } - /* QUESTIONS / TODO - status mc_kmx-file.cpp: - find replacement: VerifyKeyboard_S2 - wrong entries in : VerifyKeyboard - */ - - std::cout << " ++ UP TO HERE IN STEP 1 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; /* if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552 diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 5f6cab2458..5e136cc82f 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -29,7 +29,7 @@ void KMX_LogError(const KMX_WCHART* m1, int m2 = 0); struct DeadkeyMapping { // I4353 - KMX_WCHART deadkey, dkid; + KMX_WCHAR deadkey, dkid; KMX_UINT shift; KMX_WORD vk; }; From 20c380f820515fd08503858fbf6e8521580e69cd Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 12 Jul 2023 14:57:11 +0200 Subject: [PATCH 047/327] feat(linux): mcompile add/remove wcout --- linux/mcompile/keymap/mc_kmxfile.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index db813613f8..f49404cc1c 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -33,6 +33,7 @@ PKMX_WCHAR KMX_StringOffset(PKMX_BYTE base, KMX_DWORD offset) { */ LPKMX_KEYBOARD KMX_CopyKeyboard(PKMX_BYTE bufp, PKMX_BYTE base) { + MyCoutW(L" #### KMX_CopyKeyboard of mc_kmxfile started", 1); PKMX_COMP_KEYBOARD ckbp = (PKMX_COMP_KEYBOARD) base; /* Copy keyboard structure */ @@ -106,6 +107,7 @@ LPKMX_KEYBOARD KMX_CopyKeyboard(PKMX_BYTE bufp, PKMX_BYTE base) } } + MyCoutW(L" #### KMX_CopyKeyboard of mc_kmxfile ended", 1); return kbp; } @@ -214,7 +216,6 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { buf = new KMX_BYTE[sz]; #endif // _S2 opened for copyKeyboard-Version - MyCoutW(L"#### Line 435 ", 1); if (!buf) { fclose(fp); KMX_LogError(L"LogErr1: Not allocmem\n" ); @@ -247,8 +248,6 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { } // _S2 opened for copyKeyboard-Version ^ - MyCoutW(L"##### Line 458", 1); - if (!KMX_VerifyKeyboard(filebase, sz)) { KMX_LogError(L"LogError1: errVerifyKeyboard\n" ); // _S2 delete [] buf; ???? @@ -258,9 +257,7 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { #ifdef KMX_64BIT // _S2 opened for copyKeyboard-Version kbp = KMX_CopyKeyboard(buf, filebase); // _S2 opened for copyKeyboard-Version #else // _S2 opened for copyKeyboard-Version - MyCoutW(L"##### Line 469", 1); kbp = KMX_FixupKeyboard(buf, filebase, sz); // _S2 changed from sz->sz_dw - MyCoutW(L"##### Line 471", 1); #endif // _S2 opened for copyKeyboard-Version @@ -272,8 +269,6 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { return FALSE; } - MyCoutW(L"##### Line 468 ", 1); - std::wcout << "kbp->dwIdentifier: " << kbp->dwIdentifier << " FILEID_COMPILED: " << FILEID_COMPILED << "\n"; if (kbp->dwIdentifier != FILEID_COMPILED) { @@ -281,7 +276,6 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { KMX_LogError(L"LogError1: errNotFileID\n" ); return FALSE; } - MyCoutW(L"##### Line 477", 1); *lpKeyboard = kbp; // _S2 delete [] buf; ???? MyCoutW(L"##### LoadKeyboard of mcompile ended #####", 1); @@ -289,6 +283,7 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { } KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz){ + MyCoutW(L" #### KMX_VerifyKeyboard of mc_kmxfile started", 1); KMX_DWORD i; PKMX_COMP_KEYBOARD ckbp = (PKMX_COMP_KEYBOARD)filebase; PKMX_COMP_STORE csp; From 44d8a4ce4233bd3f32946774da98263fe41572d7 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 12 Jul 2023 15:07:52 +0200 Subject: [PATCH 048/327] feat(linux): mcompile remove duplicate file --- linux/mcompile/keymap/mcompile copy.cpp | 1104 ----------------------- 1 file changed, 1104 deletions(-) delete mode 100644 linux/mcompile/keymap/mcompile copy.cpp diff --git a/linux/mcompile/keymap/mcompile copy.cpp b/linux/mcompile/keymap/mcompile copy.cpp deleted file mode 100644 index be01ae6a08..0000000000 --- a/linux/mcompile/keymap/mcompile copy.cpp +++ /dev/null @@ -1,1104 +0,0 @@ - -// MAY BE REMOVED LATER _S2 -/* - Name: mcompile - Copyright: Copyright (C) SIL International. - Documentation: - Description: - Create Date: 24 Apr 2014 - - Modified Date: 8 Apr 2015 - Authors: mcdurdin - Related Files: - Dependencies: - - Bugs: - Todo: - Notes: - History: 24 Apr 2014 - mcdurdin - I4174 - V9 - mcompile logs should be stored in diag folder - 16 Jun 2014 - mcdurdin - I4273 - V9.0 - Convert keyboards to Unicode before installing - 23 Jun 2014 - mcdurdin - I4279 - V9.0 - mcompile fails to start when converting keyboard to Unicode - 03 Aug 2014 - mcdurdin - I4353 - V9.0 - mnemonic layout recompiler mixes up deadkey rules - 03 Aug 2014 - mcdurdin - I4327 - V9.0 - Mnemonic layout compiler follow-up - 31 Dec 2014 - mcdurdin - I4549 - V9.0 - Mnemonic layout recompiler does not translate Lctrl Ralt for deadkeys correctly - 06 Feb 2015 - mcdurdin - I4552 - V9.0 - Add mnemonic recompile option to ignore deadkeys - 08 Apr 2015 - mcdurdin - I4651 - V9.0 - Mnemonic layout recompiler maps AltGr+VK_BKSLASH rather than VK_OEM_102 - -This is a copy of win/src/eng/mcompile.cpp -there are 2 options to run mcompile - -u ( which will be done later) - -d ( which will be done here ) - -mcompile -d runs 4 important steps: - -LoadKeyboard(); -> started to exchange for being cross platform ( old version is to the right ) - -int out = run_DoConvert_Part1_getMap(argc,argv); -> there is a version for getting the mapping (keymap.cpp) but it uses string. At the end we will need to se char16_t - -run_DoConvert_Part2_TranslateKeyboard(); -> - -SaveKeyboard(); -> - -*/ - -// run with ./mcompile -d in.kmx bla.dll 0407 out.kmx - -#include "mcompile.h" -#include "helpers.h" - -int main(int argc, char *argv[]) -{ //---------------------------------------- - // test if all cpps are acccessible: can be removed - // check_avaiability_of_modules_(); //_S2 - // check Paramtr: - std::wcout << L"arc: " << argc << L"\n"; - for ( int i=0; i deadkeys we will attack after the POC - // - // For each deadkey, we need to determine its possible outputs. Then we generate a VK - // rule for that deadkey, e.g. [K_LBRKT] > dk(c101) - // - // Next, update each rule that references the output from that deadkey to add an extra - // context deadkey at the end of the context match, e.g. 'a' dk(c101) + [K_SPACE] > 'b'. - // This will require a memory layout change for the .kmx file, plus fixups on the - // context+output index offsets - // - // --> virtual character keys - // - // [CTRL ' '] : we look at the character, and replace it in the same way, but merely - // switch the shift state from the VIRTUALCHARKEY to VIRTUALKEY, without changing any - // other properties of the key. - // - - // 3. Write the new keyman keyboard file -*/ - - // _S2 that's for windows -> remove !! - //if(!LoadNewLibrary(indll)) { - // LogError(L"Failed to load keyboard DLL (%d)", GetLastError()); - // return 2; - //} - - LPKEYBOARD kmxfile; -std::wcout << L" before LoadKbd: \n"; -std::wcout << L" before LoadKbd: " << infile_c << L".." << *infile_c <char - char16_t<->wchar_t -*/ - - -std::cout << " ++ UP TO HERE IN STEP 1 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; - -/* if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552 - SaveKeyboard(kmxfile, outfile); - } - - //DeleteReallocatedPointers(kmxfile); :TODO - delete kmxfile; - - return 0; - -*/ - - //------------------------------------ - //LoadKeyboard(); - //int out = run_DoConvert_Part1_getMap(argc,argv); - //run_DoConvert_Part2_TranslateKeyboard(); - //SaveKeyboard(); - std::cout << "################################################################################################################################### end mcompile \n"; - - return 0 ; -} - - -//TODO adapt for cross-platform -void LogError(PWSTR fmt, ...) { - /*WCHAR fmtbuf[256]; - - va_list vars; - va_start(vars, fmt); - _vsnwprintf_s(fmtbuf, _countof(fmtbuf), _TRUNCATE, fmt, vars); // I2248 // I3547 - fmtbuf[255] = 0; - _putws(fmtbuf);*/ -} - - - - - - - - - - - - - - - - - - - - - - - - -// -// m-to-p.cpp : Defines the entry point for the console application. -// -// Note: this program deliberately leaks memory as it has a very short life cycle and managing the memory allocations -// for the subcomponents of the compiled keyboard is an unnecessary optimisation. Just so you know. -// -/* -#include "pch.h" -#include - -#include -#include -#include - -BOOL DoConvert(LPKEYBOARD kbd, PWSTR kbid, BOOL bDeadkeyConversion); -BOOL SaveKeyboard(LPKEYBOARD kbd, PWSTR filename); -bool ImportRules(WCHAR *kbid, LPKEYBOARD kp, std::vector *FDeadkeys, BOOL bDeadkeyConversion); // I4353 // I4327 -BOOL ConvertKeyboardToUnicode(LPKEYBOARD kbd); // I4273 -int run(int argc, wchar_t * argv[]); - -std::vector FDeadkeys; // I4353 - -#define KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE_MCOMPILE KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE ".mcompile" - -int wmain(int argc, wchar_t * argv[]) -{ - return keyman_sentry_wmain(false, KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE_MCOMPILE, argc, argv, run); -} - -int run(int argc, wchar_t * argv[]) -{ - if(argc < 3 || (argc < 5 && wcscmp(argv[1], L"-u") != 0)) { // I4273 - printf( - "Usage: mcompile -u infile.kmx outfile.kmx\n" - " mcompile [-d] infile.kmx kbdfile.dll kbid outfile.kmx\n" - " With -u parameter, converts keyboard from ANSI to Unicode\n" - " Otherwise, mcompile converts a Keyman mnemonic layout to a\n" - " positional one based on the Windows keyboard\n" - " layout file given by kbdfile.dll\n\n" - " kbid should be a hexadecimal number e.g. 409 for US English\n" - " -d convert deadkeys to plain keys\n"); // I4552 - - return 1; - } - - if(wcscmp(argv[1], L"-u") == 0) { // I4273 - wchar_t *infile = argv[2], *outfile = argv[3]; - - LPKEYBOARD kmxfile; - - if(!LoadKeyboard(infile, &kmxfile)) { - LogError(L"Failed to load keyboard (%d)", GetLastError()); - return 3; - } - - if(ConvertKeyboardToUnicode(kmxfile)) { - SaveKeyboard(kmxfile, outfile); - } - - //DeleteReallocatedPointers(kmxfile); :TODO - delete[] kmxfile; - - return 0; // I4279 - } - - int bDeadkeyConversion = wcscmp(argv[1], L"-d") == 0; // I4552 - int n = (bDeadkeyConversion ? 2 : 1); - - wchar_t *infile = argv[n], *indll = argv[n+1], *kbid = argv[n+2], *outfile = argv[n+3]; - - wprintf(L"mcompile%ls \"%ls\" \"%ls\" \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d":L"", infile, indll, kbid, outfile); // I4174 - - // 1. Load the keyman keyboard file - - // 2. For each key on the system layout, determine its output character and perform a - // 1-1 replacement on the keyman keyboard of that character with the base VK + shift - // state. This fixup will transform the char to a vk, which will avoid any issues - // with the key. - // - // --> deadkeys we will attack after the POC - // - // For each deadkey, we need to determine its possible outputs. Then we generate a VK - // rule for that deadkey, e.g. [K_LBRKT] > dk(c101) - // - // Next, update each rule that references the output from that deadkey to add an extra - // context deadkey at the end of the context match, e.g. 'a' dk(c101) + [K_SPACE] > 'b'. - // This will require a memory layout change for the .kmx file, plus fixups on the - // context+output index offsets - // - // --> virtual character keys - // - // [CTRL ' '] : we look at the character, and replace it in the same way, but merely - // switch the shift state from the VIRTUALCHARKEY to VIRTUALKEY, without changing any - // other properties of the key. - // - - // 3. Write the new keyman keyboard file - - if(!LoadNewLibrary(indll)) { - LogError(L"Failed to load keyboard DLL (%d)", GetLastError()); - return 2; - } - - LPKEYBOARD kmxfile; - - if(!LoadKeyboard(infile, &kmxfile)) { - LogError(L"Failed to load keyboard (%d)", GetLastError()); - return 3; - } - - if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552 - SaveKeyboard(kmxfile, outfile); - } - - //DeleteReallocatedPointers(kmxfile); :TODO - delete kmxfile; - - return 0; -} - - -// -// Map of all US English virtual key codes that we can translate -// -const WORD VKMap[] = { - 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', - '0','1','2','3','4','5','6','7','8','9', - VK_SPACE, - VK_ACCENT, VK_HYPHEN, VK_EQUAL, - VK_LBRKT, VK_RBRKT, VK_BKSLASH, - VK_COLON, VK_QUOTE, - VK_COMMA, VK_PERIOD, VK_SLASH, - VK_xDF, VK_OEM_102, - 0 -}; - - -// -// Map of all shift states that we will work with -// -const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; - -// -// TranslateKey -// -// For each key rule on the keyboard, remap its key to the -// correct shift state and key. Adjust the LCTRL+RALT -> RALT if necessary -// -void TranslateKey(LPKEY key, WORD vk, UINT shift, WCHAR ch) { - - // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. - // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" - // to provide an alternate.. - if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) - shift &= ~LCTRLFLAG; - - if(key->ShiftFlags == 0 && key->Key == ch) { - // Key is a mnemonic key with no shift state defined. - // Remap the key according to the character on the key cap. - //LogError(L"Converted mnemonic rule on line %d, + '%c' TO + [%x K_%d]", key->Line, key->Key, shift, vk); - key->ShiftFlags = ISVIRTUALKEY | shift; - key->Key = vk; - } else if(key->ShiftFlags & VIRTUALCHARKEY && key->Key == ch) { - // Key is a virtual character key with a hard-coded shift state. - // Do not remap the shift state, just move the key. - // This will not result in 100% wonderful mappings as there could - // be overlap, depending on how keys are arranged on the target layout. - // But that is up to the designer. - //LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, key->ShiftFlags & ~VIRTUALCHARKEY, vk); - key->ShiftFlags &= ~VIRTUALCHARKEY; - key->Key = vk; - } -} - -void TranslateGroup(LPGROUP group, WORD vk, UINT shift, WCHAR ch) { - for(unsigned int i = 0; i < group->cxKeyArray; i++) { - TranslateKey(&group->dpKeyArray[i], vk, shift, ch); - } -} - -void TranslateKeyboard(LPKEYBOARD kbd, WORD vk, UINT shift, WCHAR ch) { - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { - TranslateGroup(&kbd->dpGroupArray[i], vk, shift, ch); - } - } -} - -void ReportUnconvertedKeyRule(LPKEY key) { - if(key->ShiftFlags == 0) { - LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); - } else if(key->ShiftFlags & VIRTUALCHARKEY) { - LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); - } -} - -void ReportUnconvertedGroupRules(LPGROUP group) { - for(unsigned int i = 0; i < group->cxKeyArray; i++) { - ReportUnconvertedKeyRule(&group->dpKeyArray[i]); - } -} - -void ReportUnconvertedKeyboardRules(LPKEYBOARD kbd) { - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { - ReportUnconvertedGroupRules(&kbd->dpGroupArray[i]); - } - } -} - -void TranslateDeadkeyKey(LPKEY key, WCHAR deadkey, WORD vk, UINT shift, WORD ch) { - if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { - - // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. - // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" - // to provide an alternate.. - if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4327 - shift &= ~LCTRLFLAG; - - if(key->ShiftFlags == 0) { - //LogError("Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d]", key->Line, key->Key, deadkey, shift, vk); - key->ShiftFlags = ISVIRTUALKEY | shift; - } else { - //LogError("Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO dk(%d) + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, deadkey, key->ShiftFlags & ~VIRTUALCHARKEY, vk); - key->ShiftFlags &= ~VIRTUALCHARKEY; - } - - int len = wcslen(key->dpContext); - PWSTR context = new WCHAR[len + 4]; - memcpy(context, key->dpContext, len * sizeof(WCHAR)); - context[len] = UC_SENTINEL; - context[len+1] = CODE_DEADKEY; - context[len+2] = deadkey; - context[len+3] = 0; - key->dpContext = context; - key->Key = vk; - } -} - -void TranslateDeadkeyGroup(LPGROUP group, WCHAR deadkey, WORD vk, UINT shift, WORD ch) { - for(unsigned int i = 0; i < group->cxKeyArray; i++) { - TranslateDeadkeyKey(&group->dpKeyArray[i], deadkey, vk, shift, ch); - } -} - -void TranslateDeadkeyKeyboard(LPKEYBOARD kbd, WCHAR deadkey, WORD vk, UINT shift, WORD ch) { - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { - TranslateDeadkeyGroup(&kbd->dpGroupArray[i], deadkey, vk, shift, ch); - } - } -} - -void AddDeadkeyRule(LPKEYBOARD kbd, WCHAR deadkey, WORD vk, UINT shift) { - // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. - // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" - // to provide an alternate.. - if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4549 - shift &= ~LCTRLFLAG; - - // If the first group is not a matching-keys group, then we need to add into - // each subgroup, otherwise just the match group - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { - LPKEY keys = new KEY[kbd->dpGroupArray[i].cxKeyArray + 1]; - memcpy(keys+1, kbd->dpGroupArray[i].dpKeyArray, kbd->dpGroupArray[i].cxKeyArray * sizeof(KEY)); - keys[0].dpContext = new WCHAR[1]; - keys[0].dpContext[0] = 0; - keys[0].dpOutput = new WCHAR[4]; // UC_SENTINEL, CODE_DEADKEY, deadkey_value, 0 - keys[0].dpOutput[0] = UC_SENTINEL; - keys[0].dpOutput[1] = CODE_DEADKEY; - keys[0].dpOutput[2] = deadkey; // TODO: translate to unique index - keys[0].dpOutput[3] = 0; - keys[0].Key = vk; - keys[0].Line = 0; - keys[0].ShiftFlags = shift | ISVIRTUALKEY; - kbd->dpGroupArray[i].dpKeyArray = keys; - kbd->dpGroupArray[i].cxKeyArray++; - //LogError("Add deadkey rule: + [%d K_%d] > dk(%d)", shift, vk, deadkey); - if(i == kbd->StartGroup[1]) break; // If this is the initial group, that's all we need to do. - } - } -} - -WCHAR ScanXStringForMaxDeadkeyID(LPWSTR str) { - WCHAR dkid = 0; - while(str && *str) { - if(*str == UC_SENTINEL) { - switch(*(str+1)) { - case CODE_DEADKEY: - dkid = max(dkid, *(str+2)); - } - } - str = incxstr(str); - } - return dkid; -} - -struct dkidmap { - WCHAR src_deadkey, dst_deadkey; -}; - -WCHAR GetUniqueDeadkeyID(LPKEYBOARD kbd, WCHAR deadkey) { - LPGROUP gp; - LPKEY kp; - LPSTORE sp; - UINT i, j; - WCHAR dkid = 0; - static WCHAR s_next_dkid = 0; - static dkidmap *s_dkids = NULL; - static int s_ndkids = 0; - - if(!kbd) { - if(s_dkids) { - delete s_dkids; - } - s_dkids = NULL; - s_ndkids = 0; - s_next_dkid = 0; - return 0; - } - - for(int i = 0; i < s_ndkids; i++) { - if(s_dkids[i].src_deadkey == deadkey) { - return s_dkids[i].dst_deadkey; - } - } - - if(s_next_dkid != 0) { - s_dkids = (dkidmap*) realloc(s_dkids, sizeof(dkidmap) * (s_ndkids+1)); - s_dkids[s_ndkids].src_deadkey = deadkey; - return s_dkids[s_ndkids++].dst_deadkey = ++s_next_dkid; - } - - for(i = 0, gp = kbd->dpGroupArray; i < kbd->cxGroupArray; i++, gp++) { - for(j = 0, kp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kp++) { - dkid = max(dkid, ScanXStringForMaxDeadkeyID(kp->dpContext)); - dkid = max(dkid, ScanXStringForMaxDeadkeyID(kp->dpOutput)); - } - dkid = max(dkid, ScanXStringForMaxDeadkeyID(gp->dpMatch)); - dkid = max(dkid, ScanXStringForMaxDeadkeyID(gp->dpNoMatch)); - } - - for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { - dkid = max(dkid, ScanXStringForMaxDeadkeyID(sp->dpString)); - } - - s_dkids = (dkidmap*) realloc(s_dkids, sizeof(dkidmap) * (s_ndkids+1)); - s_dkids[s_ndkids].src_deadkey = deadkey; - return s_dkids[s_ndkids++].dst_deadkey = s_next_dkid = ++dkid; -} - - -void ConvertDeadkey(LPKEYBOARD kbd, WORD vk, UINT shift, WCHAR deadkey) { - WORD deadkeys[512], *pdk; - - // Lookup the deadkey table for the deadkey in the physical keyboard - // Then for each character, go through and map it through - - WCHAR dkid = GetUniqueDeadkeyID(kbd, deadkey); - - // Add the deadkey to the mapping table for use in the import rules phase - DeadkeyMapping deadkeyMapping = { deadkey, dkid, shift, vk }; // I4353 - FDeadkeys.push_back(deadkeyMapping); //dkid, vk, shift); // I4353 - - AddDeadkeyRule(kbd, dkid, vk, shift); - - GetDeadkeys(deadkey, pdk = deadkeys); // returns array of [usvk, ch_out] pairs - while(*pdk) { - // Look up the ch - UINT vkUnderlying = VKUnderlyingLayoutToVKUS(*pdk); - TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); - pdk+=3; - } -} - -BOOL SetKeyboardToPositional(LPKEYBOARD kbd) { - LPSTORE sp; - UINT i; - for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { - if(sp->dwSystemID == TSS_MNEMONIC) { - if(!sp->dpString) { - LogError(L"Invalid &mnemoniclayout system store"); - return FALSE; - } - if(wcscmp(sp->dpString, L"1") != 0) { - LogError(L"Keyboard is not a mnemonic layout keyboard"); - return FALSE; - } - *sp->dpString = '0'; - return TRUE; - } - } - - LogError(L"Keyboard is not a mnemonic layout keyboard"); - return FALSE; -} - -BOOL DoConvert(LPKEYBOARD kbd, LPWSTR kbid, BOOL bDeadkeyConversion) { // I4552 - WCHAR DeadKey; - - if(!SetKeyboardToPositional(kbd)) return FALSE; - - // Go through each of the shift states - base, shift, ctrl+alt, ctrl+alt+shift, [caps vs ncaps?] - // Currently, we go in this order so the 102nd key works. But this is not ideal for keyboards without 102nd key: // I4651 - // it catches only the first key that matches a given rule, but multiple keys may match that rule. This is particularly - // evident for the 102nd key on UK, for example, where \ can be generated with VK_OEM_102 or AltGr+VK_QUOTE. - // For now, we get the least shifted version, which is hopefully adequate. - - for(int j = 0; VKShiftState[j] != 0xFFFF; j++) { // I4651 - // Go through each possible key on the keyboard - for(int i = 0; VKMap[i]; i++) { // I4651 - UINT vkUnderlying = VKUSToVKUnderlyingLayout(VKMap[i]); - - WCHAR ch = CharFromVK(vkUnderlying, VKShiftState[j], &DeadKey); - - //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); - - if(bDeadkeyConversion) { // I4552 - if(ch == 0xFFFF) { - ch = DeadKey; - } - } - - switch(ch) { - case 0x0000: break; - case 0xFFFF: ConvertDeadkey(kbd, VKMap[i], VKShiftState[j], DeadKey); break; - default: TranslateKeyboard(kbd, VKMap[i], VKShiftState[j], ch); - } - - // - } - } - - ReportUnconvertedKeyboardRules(kbd); - - if(!ImportRules(kbid, kbd, &FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 - return FALSE; - } - - return TRUE; -} - -*/ -//---------old------------------------------------------- -/*#include "pch.h" -#include - -#include -#include -#include - -BOOL DoConvert(LPKEYBOARD kbd, PWSTR kbid, BOOL bDeadkeyConversion); -BOOL SaveKeyboard(LPKEYBOARD kbd, PWSTR filename); -bool ImportRules(WCHAR *kbid, LPKEYBOARD kp, std::vector *FDeadkeys, BOOL bDeadkeyConversion); // I4353 // I4327 -BOOL ConvertKeyboardToUnicode(LPKEYBOARD kbd); // I4273 -int run(int argc, wchar_t * argv[]); - -std::vector FDeadkeys; // I4353 - -#define KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE_MCOMPILE KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE ".mcompile" - -int wmain(int argc, wchar_t * argv[]) -{ - return keyman_sentry_wmain(false, KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE_MCOMPILE, argc, argv, run); -} - -int run(int argc, wchar_t * argv[]) -{ - if(argc < 3 || (argc < 5 && wcscmp(argv[1], L"-u") != 0)) { // I4273 - printf( - "Usage: mcompile -u infile.kmx outfile.kmx\n" - " mcompile [-d] infile.kmx kbdfile.dll kbid outfile.kmx\n" - " With -u parameter, converts keyboard from ANSI to Unicode\n" - " Otherwise, mcompile converts a Keyman mnemonic layout to a\n" - " positional one based on the Windows keyboard\n" - " layout file given by kbdfile.dll\n\n" - " kbid should be a hexadecimal number e.g. 409 for US English\n" - " -d convert deadkeys to plain keys\n"); // I4552 - - return 1; - } - - if(wcscmp(argv[1], L"-u") == 0) { // I4273 - wchar_t *infile = argv[2], *outfile = argv[3]; - - LPKEYBOARD kmxfile; - - if(!LoadKeyboard(infile, &kmxfile)) { - LogError(L"Failed to load keyboard (%d)", GetLastError()); - return 3; - } - - if(ConvertKeyboardToUnicode(kmxfile)) { - SaveKeyboard(kmxfile, outfile); - } - - //DeleteReallocatedPointers(kmxfile); :TODO - delete[] kmxfile; - - return 0; // I4279 - } - - int bDeadkeyConversion = wcscmp(argv[1], L"-d") == 0; // I4552 - int n = (bDeadkeyConversion ? 2 : 1); - - wchar_t *infile = argv[n], *indll = argv[n+1], *kbid = argv[n+2], *outfile = argv[n+3]; - - wprintf(L"mcompile%ls \"%ls\" \"%ls\" \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d":L"", infile, indll, kbid, outfile); // I4174 - - // 1. Load the keyman keyboard file - - // 2. For each key on the system layout, determine its output character and perform a - // 1-1 replacement on the keyman keyboard of that character with the base VK + shift - // state. This fixup will transform the char to a vk, which will avoid any issues - // with the key. - // - // --> deadkeys we will attack after the POC - // - // For each deadkey, we need to determine its possible outputs. Then we generate a VK - // rule for that deadkey, e.g. [K_LBRKT] > dk(c101) - // - // Next, update each rule that references the output from that deadkey to add an extra - // context deadkey at the end of the context match, e.g. 'a' dk(c101) + [K_SPACE] > 'b'. - // This will require a memory layout change for the .kmx file, plus fixups on the - // context+output index offsets - // - // --> virtual character keys - // - // [CTRL ' '] : we look at the character, and replace it in the same way, but merely - // switch the shift state from the VIRTUALCHARKEY to VIRTUALKEY, without changing any - // other properties of the key. - // - - // 3. Write the new keyman keyboard file - - if(!LoadNewLibrary(indll)) { - LogError(L"Failed to load keyboard DLL (%d)", GetLastError()); - return 2; - } - - LPKEYBOARD kmxfile; - - if(!LoadKeyboard(infile, &kmxfile)) { - LogError(L"Failed to load keyboard (%d)", GetLastError()); - return 3; - } - - if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552 - SaveKeyboard(kmxfile, outfile); - } - - //DeleteReallocatedPointers(kmxfile); :TODO - delete kmxfile; - - return 0; -} - - -// -// Map of all US English virtual key codes that we can translate -// -const WORD VKMap[] = { - 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', - '0','1','2','3','4','5','6','7','8','9', - VK_SPACE, - VK_ACCENT, VK_HYPHEN, VK_EQUAL, - VK_LBRKT, VK_RBRKT, VK_BKSLASH, - VK_COLON, VK_QUOTE, - VK_COMMA, VK_PERIOD, VK_SLASH, - VK_xDF, VK_OEM_102, - 0 -}; - - -// -// Map of all shift states that we will work with -// -const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; - -// -// TranslateKey -// -// For each key rule on the keyboard, remap its key to the -// correct shift state and key. Adjust the LCTRL+RALT -> RALT if necessary -// -void TranslateKey(LPKEY key, WORD vk, UINT shift, WCHAR ch) { - - // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. - // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" - // to provide an alternate.. - if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) - shift &= ~LCTRLFLAG; - - if(key->ShiftFlags == 0 && key->Key == ch) { - // Key is a mnemonic key with no shift state defined. - // Remap the key according to the character on the key cap. - //LogError(L"Converted mnemonic rule on line %d, + '%c' TO + [%x K_%d]", key->Line, key->Key, shift, vk); - key->ShiftFlags = ISVIRTUALKEY | shift; - key->Key = vk; - } else if(key->ShiftFlags & VIRTUALCHARKEY && key->Key == ch) { - // Key is a virtual character key with a hard-coded shift state. - // Do not remap the shift state, just move the key. - // This will not result in 100% wonderful mappings as there could - // be overlap, depending on how keys are arranged on the target layout. - // But that is up to the designer. - //LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, key->ShiftFlags & ~VIRTUALCHARKEY, vk); - key->ShiftFlags &= ~VIRTUALCHARKEY; - key->Key = vk; - } -} - -void TranslateGroup(LPGROUP group, WORD vk, UINT shift, WCHAR ch) { - for(unsigned int i = 0; i < group->cxKeyArray; i++) { - TranslateKey(&group->dpKeyArray[i], vk, shift, ch); - } -} - -void TranslateKeyboard(LPKEYBOARD kbd, WORD vk, UINT shift, WCHAR ch) { - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { - TranslateGroup(&kbd->dpGroupArray[i], vk, shift, ch); - } - } -} - -void ReportUnconvertedKeyRule(LPKEY key) { - if(key->ShiftFlags == 0) { - LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); - } else if(key->ShiftFlags & VIRTUALCHARKEY) { - LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); - } -} - -void ReportUnconvertedGroupRules(LPGROUP group) { - for(unsigned int i = 0; i < group->cxKeyArray; i++) { - ReportUnconvertedKeyRule(&group->dpKeyArray[i]); - } -} - -void ReportUnconvertedKeyboardRules(LPKEYBOARD kbd) { - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { - ReportUnconvertedGroupRules(&kbd->dpGroupArray[i]); - } - } -} - -void TranslateDeadkeyKey(LPKEY key, WCHAR deadkey, WORD vk, UINT shift, WORD ch) { - if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { - - // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. - // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" - // to provide an alternate.. - if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4327 - shift &= ~LCTRLFLAG; - - if(key->ShiftFlags == 0) { - //LogError("Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d]", key->Line, key->Key, deadkey, shift, vk); - key->ShiftFlags = ISVIRTUALKEY | shift; - } else { - //LogError("Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO dk(%d) + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, deadkey, key->ShiftFlags & ~VIRTUALCHARKEY, vk); - key->ShiftFlags &= ~VIRTUALCHARKEY; - } - - int len = wcslen(key->dpContext); - PWSTR context = new WCHAR[len + 4]; - memcpy(context, key->dpContext, len * sizeof(WCHAR)); - context[len] = UC_SENTINEL; - context[len+1] = CODE_DEADKEY; - context[len+2] = deadkey; - context[len+3] = 0; - key->dpContext = context; - key->Key = vk; - } -} - -void TranslateDeadkeyGroup(LPGROUP group, WCHAR deadkey, WORD vk, UINT shift, WORD ch) { - for(unsigned int i = 0; i < group->cxKeyArray; i++) { - TranslateDeadkeyKey(&group->dpKeyArray[i], deadkey, vk, shift, ch); - } -} - -void TranslateDeadkeyKeyboard(LPKEYBOARD kbd, WCHAR deadkey, WORD vk, UINT shift, WORD ch) { - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { - TranslateDeadkeyGroup(&kbd->dpGroupArray[i], deadkey, vk, shift, ch); - } - } -} - -void AddDeadkeyRule(LPKEYBOARD kbd, WCHAR deadkey, WORD vk, UINT shift) { - // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. - // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" - // to provide an alternate.. - if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4549 - shift &= ~LCTRLFLAG; - - // If the first group is not a matching-keys group, then we need to add into - // each subgroup, otherwise just the match group - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { - LPKEY keys = new KEY[kbd->dpGroupArray[i].cxKeyArray + 1]; - memcpy(keys+1, kbd->dpGroupArray[i].dpKeyArray, kbd->dpGroupArray[i].cxKeyArray * sizeof(KEY)); - keys[0].dpContext = new WCHAR[1]; - keys[0].dpContext[0] = 0; - keys[0].dpOutput = new WCHAR[4]; // UC_SENTINEL, CODE_DEADKEY, deadkey_value, 0 - keys[0].dpOutput[0] = UC_SENTINEL; - keys[0].dpOutput[1] = CODE_DEADKEY; - keys[0].dpOutput[2] = deadkey; // TODO: translate to unique index - keys[0].dpOutput[3] = 0; - keys[0].Key = vk; - keys[0].Line = 0; - keys[0].ShiftFlags = shift | ISVIRTUALKEY; - kbd->dpGroupArray[i].dpKeyArray = keys; - kbd->dpGroupArray[i].cxKeyArray++; - //LogError("Add deadkey rule: + [%d K_%d] > dk(%d)", shift, vk, deadkey); - if(i == kbd->StartGroup[1]) break; // If this is the initial group, that's all we need to do. - } - } -} - -WCHAR ScanXStringForMaxDeadkeyID(LPWSTR str) { - WCHAR dkid = 0; - while(str && *str) { - if(*str == UC_SENTINEL) { - switch(*(str+1)) { - case CODE_DEADKEY: - dkid = max(dkid, *(str+2)); - } - } - str = incxstr(str); - } - return dkid; -} - -struct dkidmap { - WCHAR src_deadkey, dst_deadkey; -}; - -WCHAR GetUniqueDeadkeyID(LPKEYBOARD kbd, WCHAR deadkey) { - LPGROUP gp; - LPKEY kp; - LPSTORE sp; - UINT i, j; - WCHAR dkid = 0; - static WCHAR s_next_dkid = 0; - static dkidmap *s_dkids = NULL; - static int s_ndkids = 0; - - if(!kbd) { - if(s_dkids) { - delete s_dkids; - } - s_dkids = NULL; - s_ndkids = 0; - s_next_dkid = 0; - return 0; - } - - for(int i = 0; i < s_ndkids; i++) { - if(s_dkids[i].src_deadkey == deadkey) { - return s_dkids[i].dst_deadkey; - } - } - - if(s_next_dkid != 0) { - s_dkids = (dkidmap*) realloc(s_dkids, sizeof(dkidmap) * (s_ndkids+1)); - s_dkids[s_ndkids].src_deadkey = deadkey; - return s_dkids[s_ndkids++].dst_deadkey = ++s_next_dkid; - } - - for(i = 0, gp = kbd->dpGroupArray; i < kbd->cxGroupArray; i++, gp++) { - for(j = 0, kp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kp++) { - dkid = max(dkid, ScanXStringForMaxDeadkeyID(kp->dpContext)); - dkid = max(dkid, ScanXStringForMaxDeadkeyID(kp->dpOutput)); - } - dkid = max(dkid, ScanXStringForMaxDeadkeyID(gp->dpMatch)); - dkid = max(dkid, ScanXStringForMaxDeadkeyID(gp->dpNoMatch)); - } - - for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { - dkid = max(dkid, ScanXStringForMaxDeadkeyID(sp->dpString)); - } - - s_dkids = (dkidmap*) realloc(s_dkids, sizeof(dkidmap) * (s_ndkids+1)); - s_dkids[s_ndkids].src_deadkey = deadkey; - return s_dkids[s_ndkids++].dst_deadkey = s_next_dkid = ++dkid; -} - - -void ConvertDeadkey(LPKEYBOARD kbd, WORD vk, UINT shift, WCHAR deadkey) { - WORD deadkeys[512], *pdk; - - // Lookup the deadkey table for the deadkey in the physical keyboard - // Then for each character, go through and map it through - - WCHAR dkid = GetUniqueDeadkeyID(kbd, deadkey); - - // Add the deadkey to the mapping table for use in the import rules phase - DeadkeyMapping deadkeyMapping = { deadkey, dkid, shift, vk }; // I4353 - FDeadkeys.push_back(deadkeyMapping); //dkid, vk, shift); // I4353 - - AddDeadkeyRule(kbd, dkid, vk, shift); - - GetDeadkeys(deadkey, pdk = deadkeys); // returns array of [usvk, ch_out] pairs - while(*pdk) { - // Look up the ch - UINT vkUnderlying = VKUnderlyingLayoutToVKUS(*pdk); - TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); - pdk+=3; - } -} - -BOOL SetKeyboardToPositional(LPKEYBOARD kbd) { - LPSTORE sp; - UINT i; - for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { - if(sp->dwSystemID == TSS_MNEMONIC) { - if(!sp->dpString) { - LogError(L"Invalid &mnemoniclayout system store"); - return FALSE; - } - if(wcscmp(sp->dpString, L"1") != 0) { - LogError(L"Keyboard is not a mnemonic layout keyboard"); - return FALSE; - } - *sp->dpString = '0'; - return TRUE; - } - } - - LogError(L"Keyboard is not a mnemonic layout keyboard"); - return FALSE; -} - -BOOL DoConvert(LPKEYBOARD kbd, LPWSTR kbid, BOOL bDeadkeyConversion) { // I4552 - WCHAR DeadKey; - - if(!SetKeyboardToPositional(kbd)) return FALSE; - - // Go through each of the shift states - base, shift, ctrl+alt, ctrl+alt+shift, [caps vs ncaps?] - // Currently, we go in this order so the 102nd key works. But this is not ideal for keyboards without 102nd key: // I4651 - // it catches only the first key that matches a given rule, but multiple keys may match that rule. This is particularly - // evident for the 102nd key on UK, for example, where \ can be generated with VK_OEM_102 or AltGr+VK_QUOTE. - // For now, we get the least shifted version, which is hopefully adequate. - - for(int j = 0; VKShiftState[j] != 0xFFFF; j++) { // I4651 - // Go through each possible key on the keyboard - for(int i = 0; VKMap[i]; i++) { // I4651 - UINT vkUnderlying = VKUSToVKUnderlyingLayout(VKMap[i]); - - WCHAR ch = CharFromVK(vkUnderlying, VKShiftState[j], &DeadKey); - - //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); - - if(bDeadkeyConversion) { // I4552 - if(ch == 0xFFFF) { - ch = DeadKey; - } - } - - switch(ch) { - case 0x0000: break; - case 0xFFFF: ConvertDeadkey(kbd, VKMap[i], VKShiftState[j], DeadKey); break; - default: TranslateKeyboard(kbd, VKMap[i], VKShiftState[j], ch); - } - - // - } - } - - ReportUnconvertedKeyboardRules(kbd); - - if(!ImportRules(kbid, kbd, &FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 - return FALSE; - } - - return TRUE; -} - -void LogError(PWSTR fmt, ...) { - WCHAR fmtbuf[256]; - - va_list vars; - va_start(vars, fmt); - _vsnwprintf_s(fmtbuf, _countof(fmtbuf), _TRUNCATE, fmt, vars); // I2248 // I3547 - fmtbuf[255] = 0; - _putws(fmtbuf); -} -*/ From 99f6f7d695868f9d7905df3c91bbba99082e00e9 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 17 Jul 2023 13:19:18 +0200 Subject: [PATCH 049/327] feat(linux): mcompile edit Readme.h --- linux/mcompile/keymap/README.md | 1 + linux/mcompile/keymap/helpers.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index f96a6b8d69..4d0689a69a 100644 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -27,3 +27,4 @@ TODO ... //--------------------------- TOASK is using string OK, or do we use char, wchar? TOASK a-z, A_Z or more keys? ... +TOASK ado we need mcompile -u option? diff --git a/linux/mcompile/keymap/helpers.h b/linux/mcompile/keymap/helpers.h index 7ca0b07b9d..62fdef9b07 100644 --- a/linux/mcompile/keymap/helpers.h +++ b/linux/mcompile/keymap/helpers.h @@ -5,7 +5,6 @@ #include #include "mc_savekeyboard.h" #include "mc_kmxfile.h" -#include "mc_savekeyboard.h" int dummytest_helpers(); void check_avaiability_of_modules_(); From 4b653d30b3ec8e450b7add5717464dd81c9d290e Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 17 Jul 2023 13:48:19 +0200 Subject: [PATCH 050/327] feat(linux): mcompile KMX_saveKeyboard, KMX_WriteCompiledKeyboard --- linux/.gitignore | 5 + linux/mcompile/keymap/mc_kmxfile.cpp | 219 ++++++++++++++++++++++++++- linux/mcompile/keymap/mc_kmxfile.h | 4 +- linux/mcompile/keymap/mcompile.cpp | 15 +- 4 files changed, 234 insertions(+), 9 deletions(-) diff --git a/linux/.gitignore b/linux/.gitignore index 478f418b60..84a642d7a7 100644 --- a/linux/.gitignore +++ b/linux/.gitignore @@ -38,3 +38,8 @@ help/reference/ # Debian watch file - we generate it from watch.in watch + +#sabine +*.kmx +*.kvk +*.bak diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index f49404cc1c..41ded295c0 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -1,4 +1,3 @@ - #include "mc_kmxfile.h" #include "helpers.h" #include "u16.h" @@ -16,6 +15,220 @@ KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz); LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); +KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, PKMX_WCHAR filename) { + + MyCoutW(L"#### KMX_SaveKeyboard of mcompile started", 1); + FILE *fp; + fp = Open_File(filename, u"wb"); + + if(fp == NULL) + { + KMX_LogError(L"Failed to create output file (%d)", errno); + return FALSE; + } + + KMX_DWORD err = KMX_WriteCompiledKeyboard(kbd, fp, FALSE); + fclose(fp); + + if(err != CERR_None) { + KMX_LogError(L"Failed to write compiled keyboard with error %d", err); + + std::u16string u16_filname(filename); + std::string s = string_from_u16string(u16_filname); + + remove(s.c_str()); + return FALSE; + } + + MyCoutW(L"#### KMX_SaveKeyboard of mcompile ended", 1); + return TRUE; +} + +KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL FSaveDebug) +{ + + MyCoutW(L" #### KMX_WriteCompiledKeyboard of mcompile started", 1); + LPKMX_GROUP fgp; + LPKMX_STORE fsp; + LPKMX_KEY fkp; + + PKMX_COMP_KEYBOARD ck; + PKMX_COMP_GROUP gp; + PKMX_COMP_STORE sp; + PKMX_COMP_KEY kp; + PKMX_BYTE buf; + KMX_DWORD size, offset; + DWORD i, j; + + // Calculate how much memory to allocate + size = sizeof(KMX_COMP_KEYBOARD) + + fk->cxGroupArray * sizeof(KMX_COMP_GROUP) + + fk->cxStoreArray * sizeof(KMX_COMP_STORE) + + //wcslen(fk->szName)*2 + 2 + + //wcslen(fk->szCopyright)*2 + 2 + + //wcslen(fk->szLanguageName)*2 + 2 + + //wcslen(fk->szMessage)*2 + 2 + + fk->dwBitmapSize; + + for(i = 0, fgp = fk->dpGroupArray; i < fk->cxGroupArray; i++, fgp++) { + if(fgp->dpName) + size += u16len(fgp->dpName)*2 + 2; + size += fgp->cxKeyArray * sizeof(KMX_COMP_KEY); + for(j = 0, fkp = fgp->dpKeyArray; j < fgp->cxKeyArray; j++, fkp++) { + size += u16len(fkp->dpOutput)*2 + 2; + size += u16len(fkp->dpContext)*2 + 2; + } + + if( fgp->dpMatch ) size += u16len(fgp->dpMatch)*2 + 2; + if( fgp->dpNoMatch ) size += u16len(fgp->dpNoMatch)*2 + 2; + } + + + for(i = 0; i < fk->cxStoreArray; i++) + { + size += u16len(fk->dpStoreArray[i].dpString)*2 + 2; + if(fk->dpStoreArray[i].dpName) + size += u16len(fk->dpStoreArray[i].dpName)*2 + 2; + } + + buf = new KMX_BYTE[size]; + if(!buf) return CERR_CannotAllocateMemory; + memset(buf, 0, size); + + ck = (PKMX_COMP_KEYBOARD) buf; + + ck->dwIdentifier = FILEID_COMPILED; + + ck->dwFileVersion = fk->dwFileVersion; + ck->dwCheckSum = 0; // No checksum in 16.0, see #7276 + ck->KeyboardID = fk->xxkbdlayout; + ck->IsRegistered = fk->IsRegistered; + ck->cxStoreArray = fk->cxStoreArray; + ck->cxGroupArray = fk->cxGroupArray; + ck->StartGroup[0] = fk->StartGroup[0]; + ck->StartGroup[1] = fk->StartGroup[1]; + ck->dwHotKey = fk->dwHotKey; + + ck->dwFlags = fk->dwFlags; + + offset = sizeof(KMX_COMP_KEYBOARD); + + // ck->dpLanguageName = offset; + //wcscpy((PWSTR)(buf + offset), fk->szLanguageName); + //offset += wcslen(fk->szLanguageName)*2 + 2; + + //ck->dpName = offset; + //wcscpy((PWSTR)(buf + offset), fk->szName); + //offset += wcslen(fk->szName)*2 + 2; + + //ck->dpCopyright = offset; + //wcscpy((PWSTR)(buf + offset), fk->szCopyright); + //offset += wcslen(fk->szCopyright)*2 + 2; + + //ck->dpMessage = offset; + //wcscpy((PWSTR)(buf + offset), fk->szMessage); + //offset += wcslen(fk->szMessage)*2 + 2; + + + ck->dpStoreArray = offset; + sp = (PKMX_COMP_STORE)(buf+offset); + fsp = fk->dpStoreArray; + offset += sizeof(KMX_COMP_STORE) * ck->cxStoreArray; + for(i = 0; i < ck->cxStoreArray; i++, sp++, fsp++) { + sp->dwSystemID = fsp->dwSystemID; + sp->dpString = offset; + u16ncpy((PKMX_WCHAR)(buf+offset), fsp->dpString, (size-offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 + offset += u16len(fsp->dpString)*2 + 2; + + if(!fsp->dpName) { + sp->dpName = 0; + } else { + sp->dpName = offset; + u16ncpy((PKMX_WCHAR)(buf+offset), fsp->dpName, (size-offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 + offset += u16len(fsp->dpName)*2 + 2; + } + } + + ck->dpGroupArray = offset; + gp = (PKMX_COMP_GROUP)(buf+offset); + fgp = fk->dpGroupArray; + + offset += sizeof(KMX_COMP_GROUP) * ck->cxGroupArray; + + for(i = 0; i < ck->cxGroupArray; i++, gp++, fgp++) { + gp->cxKeyArray = fgp->cxKeyArray; + gp->fUsingKeys = fgp->fUsingKeys; + + gp->dpMatch = gp->dpNoMatch = 0; + + if(fgp->dpMatch) { + gp->dpMatch = offset; + u16ncpy((PKMX_WCHAR)(buf+offset), fgp->dpMatch, (size-offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 + offset += u16len(fgp->dpMatch)*2 + 2; + } + if(fgp->dpNoMatch) { + gp->dpNoMatch = offset; + u16ncpy((PKMX_WCHAR)(buf+offset), fgp->dpNoMatch, (size-offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 + offset += u16len(fgp->dpNoMatch)*2 + 2; + } + + if(fgp->dpName) { + gp->dpName = offset; + u16ncpy((PKMX_WCHAR)(buf+offset), fgp->dpName, (size-offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 + offset += u16len(fgp->dpName)*2 + 2; + } else { + gp->dpName = 0; + } + + gp->dpKeyArray = offset; + kp = (PKMX_COMP_KEY) (buf + offset); + fkp = fgp->dpKeyArray; + offset += gp->cxKeyArray * sizeof(KMX_COMP_KEY); + for(j = 0; j < gp->cxKeyArray; j++, kp++, fkp++) { + kp->Key = fkp->Key; + kp->Line = fkp->Line; + kp->ShiftFlags = fkp->ShiftFlags; + kp->dpOutput = offset; + + + u16ncpy((PKMX_WCHAR)(buf+offset), fkp->dpOutput, (size-offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 + offset += u16len(fkp->dpOutput)*2 + 2; + + + kp->dpContext = offset; + u16ncpy((PKMX_WCHAR)(buf+offset), fkp->dpContext, (size-offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 + offset += u16len(fkp->dpContext)*2 + 2; + } + } + + if(fk->dwBitmapSize > 0) { + ck->dwBitmapSize = fk->dwBitmapSize; + ck->dpBitmapOffset = offset; + memcpy(buf + offset, ((PKMX_BYTE)fk) + fk->dpBitmapOffset, fk->dwBitmapSize); + offset += fk->dwBitmapSize; + } else { + ck->dwBitmapSize = 0; + ck->dpBitmapOffset = 0; + } + + if(offset != size) + { + delete[] buf; + return CERR_SomewhereIGotItWrong; + } + + fwrite(buf, size,1,hOutfile); + if(offset != size) + { + delete[] buf; + return CERR_UnableToWriteFully; + } + + delete[] buf; + + MyCoutW(L" #### KMX_WriteCompiledKeyboard of mcompile ended", 1); + return CERR_None; +} PKMX_WCHAR KMX_StringOffset(PKMX_BYTE base, KMX_DWORD offset) { @@ -172,7 +385,7 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { LPKMX_KEYBOARD kbp; PKMX_BYTE filebase; - wprintf(L"Loading file '%ls'\n", u16fmt((const char16_t*) fileName).c_str()); + wprintf(L" Loading file '%ls'\n", u16fmt((const char16_t*) fileName).c_str()); if(!fileName || !lpKeyboard) { KMX_LogError(L"LogError1: Bad Filename\n" ); @@ -269,7 +482,7 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { return FALSE; } - std::wcout << "kbp->dwIdentifier: " << kbp->dwIdentifier << " FILEID_COMPILED: " << FILEID_COMPILED << "\n"; + std::wcout << " kbp->dwIdentifier: " << kbp->dwIdentifier << " FILEID_COMPILED: " << FILEID_COMPILED << "\n"; if (kbp->dwIdentifier != FILEID_COMPILED) { delete[] buf; diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 94be306f11..54712b1e25 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -139,14 +139,14 @@ BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD *lpKeyboard); // _S2 LPKEYBOAR KMX_BOOL KMX_LoadKeyboard(wchar_t* fileName, LPKMX_KEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? - +KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, PKMX_WCHAR filename); +KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL FSaveDebug); #endif - //---------------------old---------------------------------------- /* #include diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 591441bf9c..b9fcadbc7b 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -37,6 +37,7 @@ mcompile -d runs 4 important steps: // run with ./mcompile -d in.kmx bla.dll 0407 out.kmx //./mcompile -d /Projects/keyman/keyman/linux/mcompile/keymap/anii.kmx bla.dll 0407 /Projects/keyman/keyman/linux/mcompile/keymap/anii_out.kmx +//./mcompile -d /Projects/keyman/keyman/linux/mcompile/keymap/sil_ipa_o.kmx bla.dll 0407 /Projects/keyman/keyman/linux/mcompile/keymap/sil_ipa_o_out2.kmx #include "mcompile.h" #include "helpers.h" @@ -52,13 +53,13 @@ mcompile -d runs 4 important steps: std::vector argv_16 = convert_argv_to_Vector_u16str(argc, argv); #endif - std::vector vec_cmdl_par; + std::vector v_argv_16; for (int i = 0; i < argc; i++) { const char16_t* cmdl_par = argv_16[i].c_str(); - vec_cmdl_par.push_back(cmdl_par); + v_argv_16.push_back(cmdl_par); } // call new run/ method() with char16_t - run(argc, vec_cmdl_par); + run(argc, v_argv_16); } //------ run with char16_t !! ------------------------------------------------------------------------------------------------------------------------- @@ -151,7 +152,13 @@ wprintf(L"_S2 * Up to here cross-platform xx :-))))) ************************** return 3; } -std::cout << " ++ UP TO HERE IN STEP 1 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; +std::wcout << " ++ UP TO HERE IN STEP 1 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; +// _S2 this is only for testing- remove and use SaveKeyboard in block below + +std::wcout << " ++ will start KMX_SaveKeyboard +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; + KMX_SaveKeyboard(kmxfile, outfile); +std::wcout << " ++ ended KMX_SaveKeyboard +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; + /* if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552 SaveKeyboard(kmxfile, outfile); From 88e3f16b2c9fca01d0bed9e6e65532c55cbdde32 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 18 Jul 2023 11:58:29 +0200 Subject: [PATCH 051/327] feat(linux): mcompile meson add files --- linux/.gitignore | 1 + linux/mcompile/keymap/meson.build | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/linux/.gitignore b/linux/.gitignore index 84a642d7a7..c8e08190f2 100644 --- a/linux/.gitignore +++ b/linux/.gitignore @@ -40,6 +40,7 @@ help/reference/ watch #sabine +*.kmn *.kmx *.kvk *.bak diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index e7e05035b0..4c9a5e8cb2 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -18,5 +18,5 @@ mcompile = executable( 'mcompile', sources: [cpp_files], dependencies: [gtk]) #project('keymap', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') #gtk = dependency('gtk+-3.0', version: '>= 2.4') -#cpp_files = files( 'keymap.cpp', 'mc_kmxfile.cpp', 'mc_savekeyboard.cpp', 'helpers.cpp', 'u16.cpp',) +#cpp_files = files( 'keymap.cpp', 'mcompile.cpp', 'filesystem.cpp', 'mc_kmxfile.cpp', 'mc_savekeyboard.cpp', 'helpers.cpp', 'u16.cpp',) #keymap = executable( 'keymap', sources: [cpp_files], dependencies: [gtk]) From b254f9b4ebcdcf72d5ca7d8c0025b7a7354c7ad8 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 18 Jul 2023 12:02:21 +0200 Subject: [PATCH 052/327] feat(linux): mcompile mcompile.cpp starts keymap --- linux/mcompile/keymap/mcompile.cpp | 58 +++++++++++++++++++++--------- linux/mcompile/keymap/mcompile.h | 2 +- 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index b9fcadbc7b..8481703dd7 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -35,9 +35,12 @@ mcompile -d runs 4 important steps: */ -// run with ./mcompile -d in.kmx bla.dll 0407 out.kmx +// REMEMBER in this VM only run with meson compile is possible NOT with F5 !!! +// run with: +//./mcompile -d in.kmx bla.dll 0407 out.kmx //./mcompile -d /Projects/keyman/keyman/linux/mcompile/keymap/anii.kmx bla.dll 0407 /Projects/keyman/keyman/linux/mcompile/keymap/anii_out.kmx //./mcompile -d /Projects/keyman/keyman/linux/mcompile/keymap/sil_ipa_o.kmx bla.dll 0407 /Projects/keyman/keyman/linux/mcompile/keymap/sil_ipa_o_out2.kmx +//./mcompile -d /Projects/keyman/keyman/linux/mcompile/keymap/mcompile_test.kmx bla.dll 0407 /Projects/keyman/keyman/linux/mcompile/keymap/mcompile_test_out.kmx #include "mcompile.h" #include "helpers.h" @@ -47,24 +50,27 @@ mcompile -d runs 4 important steps: #if defined(_WIN32) || defined(_WIN64) int wmain(int argc, wchar_t* argv[]) { - std::vector argv_16 = convert_argvW_to_Vector_u16str( argc, argv); + std::vector str_argv_16 = convert_argvW_to_Vector_u16str( argc, argv); + run(argc, str_argv_16); + #else // LINUX int main(int argc, char* argv[]) { - std::vector argv_16 = convert_argv_to_Vector_u16str(argc, argv); + std::vector str_argv_16 = convert_argv_to_Vector_u16str(argc, argv); + run(argc, str_argv_16, argv); #endif - std::vector v_argv_16; - for (int i = 0; i < argc; i++) { - const char16_t* cmdl_par = argv_16[i].c_str(); - v_argv_16.push_back(cmdl_par); - } - // call new run/ method() with char16_t - run(argc, v_argv_16); } //------ run with char16_t !! ------------------------------------------------------------------------------------------------------------------------- +int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ + + // convert std::vector to std::vector + std::vector argv; + for (int i = 0; i < argc; i++) { + const char16_t* cmdl_par = str_argv[i].c_str(); + argv.push_back(cmdl_par); + } -int run(int argc, std::vector< const char16_t*> argv) { //---------------------------------------- // test if all cpps are acccessible: can be removed //check_avaiability_of_modules_(); //_S2 @@ -143,7 +149,6 @@ int run(int argc, std::vector< const char16_t*> argv) { // 3. Write the new keyman keyboard file */ -wprintf(L"_S2 * Up to here cross-platform xx :-))))) ******************************************************\n"); LPKMX_KEYBOARD kmxfile; @@ -152,16 +157,35 @@ wprintf(L"_S2 * Up to here cross-platform xx :-))))) ************************** return 3; } +wprintf(L"_S2 * Up to here cross-platform xx :-))))) ******************************************************\n"); std::wcout << " ++ UP TO HERE IN STEP 1 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; +std::wcout << " ++ will start KMX_SaveKeyboard ++++++++++++++++++++++++++++++++++++++++++++++++\n"; // _S2 this is only for testing- remove and use SaveKeyboard in block below - -std::wcout << " ++ will start KMX_SaveKeyboard +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; KMX_SaveKeyboard(kmxfile, outfile); -std::wcout << " ++ ended KMX_SaveKeyboard +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; +std::wcout << " ++ ended KMX_SaveKeyboard ###############################################\n"; + +dummytest_keymap(); -/* if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552 - SaveKeyboard(kmxfile, outfile); +#if defined(_WIN32) || defined(_WIN64) + // DoConvert for windows needs to be done later ( can it be copied from engine/mcompile ?) + /* + if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552F + KMX_SaveKeyboard(kmxfile, outfile); + }*/ +#else // LINUX + // _S2 this is only for testing- remove and use SaveKeyboard in block below + run_DoConvert_Part1_getMap(argc, (gchar**) argv_ch); +/* + if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552F + KMX_SaveKeyboard(kmxfile, outfile); + }*/ +#endif + + +/* + if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552F + KMX_SaveKeyboard(kmxfile, outfile); } //DeleteReallocatedPointers(kmxfile); :TODO diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 5e136cc82f..12aa452d40 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -24,7 +24,7 @@ #include #include "keymap.h" -int run(int argc, std::vector< const char16_t*> argv); +int run(int argc, std::vector str_argv, char* argv[]); void KMX_LogError(const KMX_WCHART* m1, int m2 = 0); From dd2322abff7a957bd20142c827697e2bc8d63738 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 18 Jul 2023 12:06:06 +0200 Subject: [PATCH 053/327] feat(linux): mcompile add wcouts --- linux/mcompile/keymap/keymap.cpp | 104 ++++++++++++++++++++++++++----- 1 file changed, 87 insertions(+), 17 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index b1d6f473f7..968aaa1fa9 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -23,17 +23,20 @@ static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) int dummytest_keymap(){ - std::cout<< " dummytest_keymap is available\t"; + std::wcout<< " dummytest_keymap is available\n"; return 0; } - bool write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { + + MyCoutW(L" #### write_US_ToVector of keymap started", 1); + + // _S2 relative path !! std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; const char* path = FullPathName.c_str(); FILE* fp = fopen((path), "r"); if ( !fp) { - printf("could not open file!"); + wprintf(L"could not open file!"); return 1; } @@ -50,7 +53,8 @@ bool write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { return 1; } - printf("+++++++ dimensions of Vector after write_US_ToVector\t\t %li..%li..%li\n", vec.size(), vec[0].size(),vec[0][0].size()); + wprintf(L" +++++++ dimensions of Vector after write_US_ToVector (languages..characters..shiftstates)\t\t %li..%li..%li\n", vec.size(), vec[0].size(),vec[0][0].size()); + MyCoutW(L" #### write_US_ToVector of keymap ended", 1); fclose(fp); return 0; } @@ -59,6 +63,7 @@ bool CreateCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, // in the Configuration file we find the appopriate paragraph between "xkb_symbol " and the next xkb_symbol // and then copy all rows starting with "key <" to a v1D-Vector + MyCoutW(L" #### CreateCompleteRow_US of keymap started", 1); int buffer_size = 512; char buffer[buffer_size]; bool print_OK = false; @@ -93,18 +98,19 @@ bool CreateCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, } if (complete_List.size() <1) { - printf("ERROR: can't Create complete row US \n"); + wprintf(L"ERROR: can't Create complete row US \n"); return 1; } - printf("-°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° \n"); - return 0; + + MyCoutW(L" #### CreateCompleteRow_US of keymap ended", 1); + return 0; } bool Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList) { // 1: take the whole line of the 1D-Vector and remove unwanted characters. // 2: seperate the name e.g. key from the shiftstates // 3: push Names/Shiftstates to shift_states and then shiftstates to All_US, our 3D-Vector holding all Elements - +MyCoutW(L" #### Split_US_To_3D_Vector of keymap started", 1); std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; char split_bracel = '{'; char split_char_komma = ','; @@ -159,11 +165,13 @@ bool Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList) { printf("ERROR: Can't split US to 3D-Vector\n"); return 1; } + MyCoutW(L" #### Split_US_To_3D_Vector of keymap ended", 1); //printf("### 6 Split_US_To_3D_clearVector %li..%li..%li\n", all_US.size(), all_US[0].size(),all_US[0][0].size()); return 0; } bool foundCharacterInList(std::string tok) { + MyCoutW(L" #### foundCharacterInList of keymap started", 1); //TOASK Do we need more and which? //US keys: Q W E R T Y U I O P A S D F G H J K L : Z X C V B N M v_str_1D Keysyms { "24","25","26","27","28","29","30","31","32","33","38","39","40","41","42","43","44","45","46","47","52","53","54","55","56","57","58"}; @@ -174,10 +182,14 @@ bool foundCharacterInList(std::string tok) { return true; } } + + MyCoutW(L" #### foundCharacterInList of keymap ended", 1); return false; } int replace_PosKey_with_Keycode(std::string in) { + + MyCoutW(L" #### replace_PosKey_with_Keycode of keymap started", 1); int out=0; if ( in == "key") out = 49; // TOASK correct ??? else if ( in == "key") out = 10; @@ -231,24 +243,27 @@ int replace_PosKey_with_Keycode(std::string in) { else if ( in == "key") out = 61; else if ( in == "key") out = 62; //TOASK correct ??? else if ( in == "key") out = 51; //TOASK correct ??? + + MyCoutW(L" #### replace_PosKey_with_Keycode of keymap ended", 1); return out; } bool append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap) { + MyCoutW(L" #### append_other_ToVector of keymap started", 1); // create a 2D vector all filled with "--" and push to 3D-Vector v_str_2D Other_Vector2D = create_empty_2D(All_Vector[0].size(),All_Vector[0][0].size()); if (Other_Vector2D.size()==0) { - printf("ERROR: create empty 2D-Vector failed"); + wprintf(L"ERROR: create empty 2D-Vector failed"); return 1; } All_Vector.push_back(Other_Vector2D); - printf("+++++++ dimensions of Vector after append_other_ToVector\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); + wprintf(L"+++++++ dimensions of Vector after append_other_ToVector\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); if (All_Vector.size()==0) { - printf("ERROR: creation of 3D-Vector failed"); + wprintf(L"ERROR: creation of 3D-Vector failed"); return 1; } @@ -261,13 +276,16 @@ bool append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap) { All_Vector[1][i][0+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),0); //shift state: unshifted:0 All_Vector[1][i][1+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),1); //shift state: shifted:1 - printf(" Keycodes US->Other: %d(US): %s %s ---- (other):%s, \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str()); + wprintf(L" Keycodes US->Other: %d(US): %s %s ---- (other):%s, \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str()); } + MyCoutW(L" #### append_other_ToVector of keymap ended", 1); return 0; } v_str_2D create_empty_2D( int dim_rows,int dim_shifts) { + + MyCoutW(L" #### create_empty_2D of keymap started", 1); std::string empty = "--"; v_str_1D shifts; v_str_2D all; @@ -279,10 +297,14 @@ v_str_2D create_empty_2D( int dim_rows,int dim_shifts) { all.push_back(shifts); shifts.clear(); } + + MyCoutW(L" #### create_empty_2D of keymap ended", 1); return all; } int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { + + MyCoutW(L" #### GetKeyvalsFromKeymap of keymap started", 1); GdkKeymapKey *maps; guint *keyvals; gint count; @@ -300,18 +322,22 @@ int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) g_free(keyvals); g_free(maps); + + MyCoutW(L" #### GetKeyvalsFromKeymap of keymap ended", 1); return out; } bool extract_difference( v_str_3D &All_Vector) { + + MyCoutW(L" #### extract_difference of keymap started", 1); // TODO define which Folder; find better name std::ofstream Map_File("Map_US.txt"); std::string diff =" "; printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); - std::cout << "Nr of \n" ; - std::cout << "Key: " << "\t Character US (no shift) " << " Character US (shift) "<< "\t\tCharacter other (no shift)" << "\tCharacter other (shift) difference \n" ; - printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); + std::wcout << "Nr of \n" ; + std::wcout << "Key: " << "\t Character US (no shift) " << " Character US (shift) "<< "\t\tCharacter other (no shift)" << "\tCharacter other (shift) difference \n" ; + wprintf(L"-----------------------------------------------------------------------------------------------------------------------------------------------\n"); Map_File <<"--------------------------------------------------------------------------------------------------------------------------------------------\n"; Map_File << "Nr of \n" ; @@ -336,10 +362,14 @@ bool extract_difference( v_str_3D &All_Vector) { } Map_File.close(); + + MyCoutW(L" #### extract_difference of keymap ended", 1); return 0; } std::string get_Other_Char_FromUS( std::string in , v_str_3D &All_Vector) { + + MyCoutW(L" #### get_Other_Char_FromUS of keymap started", 1); std::string diff; // find correct row of char in US for( int i=0; i< (int) All_Vector[0].size();i++) { @@ -355,10 +385,14 @@ std::string get_Other_Char_FromUS( std::string in , v_str_3D &All_Vector) { } } std::cout << "US -> Other: (" << in << ": no match)\n"; + + MyCoutW(L" #### get_Other_Char_FromUS of keymap ended", 1); return "-"; } std::string get_US_Char_FromOther(std::string in , v_str_3D &All_Vector) { + + MyCoutW(L" #### get_US_Char_FromOther of keymap started", 1); std::string diff; // find correct row of char in other for( int i=0; i< (int)All_Vector[1].size();i++) { @@ -372,10 +406,14 @@ std::string get_US_Char_FromOther(std::string in , v_str_3D &All_Vector) { } } std::cout << "Other -> US: (" << in << ": no match)\n"; + + MyCoutW(L" #### get_US_Char_FromOther of keymap ended", 1); return "-"; } std::string getKeyNrOf_USChar(std::string in , v_str_3D &All_Vector) { + + MyCoutW(L" #### getKeyNrOf_USChar of keymap started", 1); // find correct row of char in US for( int i=0; i< (int)All_Vector[0].size();i++) { for( int j=1; j< (int)All_Vector[0][0].size();j++) { @@ -385,10 +423,13 @@ std::string getKeyNrOf_USChar(std::string in , v_str_3D &All_Vector) { } } } + MyCoutW(L" #### getKeyNrOf_USChar of keymap ended", 1); return "-"; } std::string getKeyNrOf_OtherChar(std::string in , v_str_3D &All_Vector) { + + MyCoutW(L" #### getKeyNrOf_OtherChar of keymap started", 1); // find correct row of char in US for( int i=0; i< (int)All_Vector[1].size();i++) { for( int j=1; j< (int)All_Vector[1][0].size();j++) { @@ -398,10 +439,13 @@ std::string getKeyNrOf_OtherChar(std::string in , v_str_3D &All_Vector) { } } } + MyCoutW(L" #### getKeyNrOf_OtherChar of keymap ended", 1); return "-"; } bool test(v_str_3D &V) { + + MyCoutW(L" #### test of keymap started", 1); printf("+++++++ dimensions of Vector in test()\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); printf("\n+++++++++ print some characters of US and Other +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); @@ -411,10 +455,14 @@ bool test(v_str_3D &V) { std::cout << " row 1 (Other).."<< V[1][k][0]<< ".." << V[1][k][1]<< ".."<< "..\n" ; } printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + + MyCoutW(L" #### test of keymap ended", 1); return true; } void test_in_out(v_str_3D &All_Vector) { + + MyCoutW(L" #### test_in_out of keymap started", 1); std::string diff; printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); //checks mapping between US and other @@ -442,35 +490,52 @@ std::string diff; std::cout << "get_US_Char_FromOther z-Z-y-Y: " << ".." << b<< ".." < Date: Tue, 18 Jul 2023 17:55:03 +0200 Subject: [PATCH 054/327] feat(linux): mcompile mcompile starts keymap --- linux/mcompile/keymap/README.md | 3 ++ linux/mcompile/keymap/keymap.cpp | 62 +++++++++++++++++++------------- 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index 4d0689a69a..59a10e3d25 100644 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -22,6 +22,9 @@ TODO use/adapt TranslateKeyboard() to work on Linux/cross-platform TODO use/adapt SaveKeyboard() to work on Linux/cross-platform TODO mcompile.cpp: open mcompile -u - option TODO check if I can use files from some other keyman path instead of a copy in keymap ( e.g. filesystem.h exists elsewhere) +TODO remove kbdid and kbd for Linux +TODO remove unneccessary testing fungctions in keymap.cpp/h +TODO remove helpers.cpp/h TODO ... //--------------------------- diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 968aaa1fa9..2d739f3f0b 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -173,8 +173,8 @@ MyCoutW(L" #### Split_US_To_3D_Vector of keymap started", 1); bool foundCharacterInList(std::string tok) { MyCoutW(L" #### foundCharacterInList of keymap started", 1); //TOASK Do we need more and which? - //US keys: Q W E R T Y U I O P A S D F G H J K L : Z X C V B N M - v_str_1D Keysyms { "24","25","26","27","28","29","30","31","32","33","38","39","40","41","42","43","44","45","46","47","52","53","54","55","56","57","58"}; + //US keys: Q W E R T Y U I O P A S D F G H J K L Z X C V B N M + v_str_1D Keysyms { "24","25","26","27","28","29","30","31","32","33","38","39","40","41","42","43","44","45","46","52","53","54","55","56","57","58"}; for ( int i =0; i< (int) Keysyms.size();i++) { //std::cout << "foundCharacterInList" << i <<"\n"; @@ -262,21 +262,21 @@ bool append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap) { All_Vector.push_back(Other_Vector2D); wprintf(L"+++++++ dimensions of Vector after append_other_ToVector\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); - if (All_Vector.size()==0) { + if (All_Vector.size() < 2) { wprintf(L"ERROR: creation of 3D-Vector failed"); return 1; } for(int i =0; i< (int) All_Vector[1].size();i++) { - // get key name US stored in [0][i][0] and copy to name in other-block[1][i][0] + // get key name US stored in [0][i][0] and copy to name in "other"-block[1][i][0] All_Vector[1][i][0] = All_Vector[0][i][0]; - // write this value to 3D- Vector + // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] All_Vector[1][i][0+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),0); //shift state: unshifted:0 All_Vector[1][i][1+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),1); //shift state: shifted:1 - wprintf(L" Keycodes US->Other: %d(US): %s %s ---- (other):%s, \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str()); + wprintf(L" Keycodes US->Other: %d(US): %s, %s ---- (other):%s, %s \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str(),All_Vector[1][i][2].c_str()); } MyCoutW(L" #### append_other_ToVector of keymap ended", 1); @@ -304,7 +304,7 @@ v_str_2D create_empty_2D( int dim_rows,int dim_shifts) { int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { - MyCoutW(L" #### GetKeyvalsFromKeymap of keymap started", 1); + //MyCoutW(L" #### GetKeyvalsFromKeymap of keymap started", 1); GdkKeymapKey *maps; guint *keyvals; gint count; @@ -323,7 +323,7 @@ int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) g_free(keyvals); g_free(maps); - MyCoutW(L" #### GetKeyvalsFromKeymap of keymap ended", 1); + //MyCoutW(L" #### GetKeyvalsFromKeymap of keymap ended", 1); return out; } @@ -333,25 +333,30 @@ bool extract_difference( v_str_3D &All_Vector) { // TODO define which Folder; find better name std::ofstream Map_File("Map_US.txt"); std::string diff =" "; + std::wstring diff_w = L" "; - printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); - std::wcout << "Nr of \n" ; - std::wcout << "Key: " << "\t Character US (no shift) " << " Character US (shift) "<< "\t\tCharacter other (no shift)" << "\tCharacter other (shift) difference \n" ; + wprintf(L"-----------------------------------------------------------------------------------------------------------------------------------------------\n"); + std::wcout << "Nr of " << "\tCharacter US"<< "\tCharacter US"<<"\t\tCharacter Other"<<"\t Character Other"<< "\tdifference\n"; + std::wcout << "Key: " << "\t(no shift) " << "\t(shift) "<< "\t\t(no shift)" << "\t (shift)\n" ; wprintf(L"-----------------------------------------------------------------------------------------------------------------------------------------------\n"); Map_File <<"--------------------------------------------------------------------------------------------------------------------------------------------\n"; - Map_File << "Nr of \n" ; - Map_File << "Key: " << "\t Character US (no shift) " << " Character US (shift) "<< "\t\tCharacter other (no shift)" << "\tCharacter other (shift) difference \n" ; + Map_File << "Nr of " << "\tCharacter US"<< "\t Character US"<<"\t\tCharacter Other"<<"\t Character Other"<< "\tdifference\n"; + Map_File << "Key: " << "\t(no shift) " << "\t (shift) "<< "\t\t (no shift)" << "\t (shift)\n" ; Map_File <<"--------------------------------------------------------------------------------------------------------------------------------------------\n"; for ( int k=0; k<(int)All_Vector[0].size(); k++) { - if (All_Vector[0][k][1] == All_Vector[1][k][1]) - diff =" "; - else - diff =" *** "; + if (All_Vector[0][k][1] == All_Vector[1][k][1]) { + diff = " "; + diff_w = L" "; + } + else { + diff = "*** "; + diff_w = L"*** "; + } - std::cout << All_Vector[0][k][0] << "\t " <<+(*(All_Vector[0][k][1].c_str()))<< "\t("<< All_Vector[0][k][1] <<")"< Date: Tue, 18 Jul 2023 18:35:19 +0200 Subject: [PATCH 055/327] feat(linux): mcompile open DoConvert in mcompile which starts DoConvertPart1 and DoConvertPart2 --- linux/mcompile/keymap/mcompile.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 8481703dd7..c06c54ccda 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -48,6 +48,8 @@ mcompile -d runs 4 important steps: //------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------ +KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]); + #if defined(_WIN32) || defined(_WIN64) int wmain(int argc, wchar_t* argv[]) { std::vector str_argv_16 = convert_argvW_to_Vector_u16str( argc, argv); @@ -159,10 +161,6 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL) wprintf(L"_S2 * Up to here cross-platform xx :-))))) ******************************************************\n"); std::wcout << " ++ UP TO HERE IN STEP 1 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; -std::wcout << " ++ will start KMX_SaveKeyboard ++++++++++++++++++++++++++++++++++++++++++++++++\n"; -// _S2 this is only for testing- remove and use SaveKeyboard in block below - KMX_SaveKeyboard(kmxfile, outfile); -std::wcout << " ++ ended KMX_SaveKeyboard ###############################################\n"; dummytest_keymap(); @@ -175,11 +173,9 @@ dummytest_keymap(); }*/ #else // LINUX // _S2 this is only for testing- remove and use SaveKeyboard in block below - run_DoConvert_Part1_getMap(argc, (gchar**) argv_ch); -/* - if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552F + if(KMX_DoConvert( kmxfile, kbid, bDeadkeyConversion, argc, (gchar**) argv_ch)) { // I4552F KMX_SaveKeyboard(kmxfile, outfile); - }*/ +} #endif @@ -214,7 +210,15 @@ dummytest_keymap(); + KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]) { + if (!(run_DoConvert_Part1_getMap(argc, argv))) + //run_DoConvert_Part2_TranslateKeyboard(); + + //if (!(run_DoConvert_Part1_getMap(argc, argv)) && (!run_DoConvert_Part2_TranslateKeyboard()) ) + + return true; + } From 52c115b8479901338b3d1667242ae1da736ebeb6 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 18 Jul 2023 19:15:46 +0200 Subject: [PATCH 056/327] feat(linux): mcompile SetKeyboardToPositional opened/included --- linux/mcompile/keymap/mcompile.cpp | 117 +++++++++++++++++++---------- 1 file changed, 77 insertions(+), 40 deletions(-) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index c06c54ccda..296939fe45 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -160,42 +160,23 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL) } wprintf(L"_S2 * Up to here cross-platform xx :-))))) ******************************************************\n"); -std::wcout << " ++ UP TO HERE IN STEP 1 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; - -dummytest_keymap(); - #if defined(_WIN32) || defined(_WIN64) - // DoConvert for windows needs to be done later ( can it be copied from engine/mcompile ?) - /* - if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552F - KMX_SaveKeyboard(kmxfile, outfile); + // _S2 DoConvert for windows needs to be done later ( can it be copied from engine/mcompile ?) + /*if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552F + KMX_SaveKeyboard(kmxfile, outfile); }*/ + #else // LINUX - // _S2 this is only for testing- remove and use SaveKeyboard in block below +// _S2 do I need all parameters?-no if(KMX_DoConvert( kmxfile, kbid, bDeadkeyConversion, argc, (gchar**) argv_ch)) { // I4552F KMX_SaveKeyboard(kmxfile, outfile); } #endif - -/* - if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552F - KMX_SaveKeyboard(kmxfile, outfile); - } - - //DeleteReallocatedPointers(kmxfile); :TODO + //DeleteReallocatedPointers(kmxfile); :TODO // _S2 not my ToDo :-) delete kmxfile; - return 0; - -*/ - - //------------------------------------ - //LoadKeyboard(); - //int out = run_DoConvert_Part1_getMap(argc,argv); - //run_DoConvert_Part2_TranslateKeyboard(); - //SaveKeyboard(); wprintf(L"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm end\n"); return 0 ; } @@ -207,29 +188,88 @@ dummytest_keymap(); +KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { + MyCoutW(L"#### KMX_SetKeyboardToPositional of keymap started", 1); + LPKMX_STORE sp; + KMX_UINT i; + for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { + if(sp->dwSystemID == TSS_MNEMONIC) { + if(!sp->dpString) { + KMX_LogError(L"Invalid &mnemoniclayout system store"); + MyCoutW(L" #### KMX_SetKeyboardToPositional Invalid &mnemoniclayout system store", 1); + return FALSE; + } + if(u16cmp((const KMX_WCHAR*)sp->dpString, u"1") != 0) { + KMX_LogError(L"Keyboard is not a mnemonic layout keyboard"); + MyCoutW(L" #### KMX_SetKeyboardToPositional Keyboard is not a mnemonic layout keyboard", 1); + return FALSE; + } + *sp->dpString = '0'; + MyCoutW(L" #### KMX_SetKeyboardToPositional Keyboard all good !!", 1); + return TRUE; + } + } + + KMX_LogError(L"Keyboard is not a mnemonic layout keyboard"); + + MyCoutW(L"#### KMX_SetKeyboardToPositional of keymap ended", 1); + return FALSE; +} + + KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]) { - if (!(run_DoConvert_Part1_getMap(argc, argv))) - //run_DoConvert_Part2_TranslateKeyboard(); + KMX_WCHART DeadKey; + + if(!KMX_SetKeyboardToPositional(kbd)) return FALSE; + + // Go through each of the shift states - base, shift, ctrl+alt, ctrl+alt+shift, [caps vs ncaps?] + // Currently, we go in this order so the 102nd key works. But this is not ideal for keyboards without 102nd key: // I4651 + // it catches only the first key that matches a given rule, but multiple keys may match that rule. This is particularly + // evident for the 102nd key on UK, for example, where \ can be generated with VK_OEM_102 or AltGr+VK_QUOTE. + // For now, we get the least shifted version, which is hopefully adequate. + /* + for(int j = 0; VKShiftState[j] != 0xFFFF; j++) { // I4651 + // Go through each possible key on the keyboard + for(int i = 0; VKMap[i]; i++) { // I4651 + UINT vkUnderlying = VKUSToVKUnderlyingLayout(VKMap[i]); + + WCHAR ch = CharFromVK(vkUnderlying, VKShiftState[j], &DeadKey); + + //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); + + if(bDeadkeyConversion) { // I4552 + if(ch == 0xFFFF) { + ch = DeadKey; + } + } + + switch(ch) { + case 0x0000: break; + case 0xFFFF: ConvertDeadkey(kbd, VKMap[i], VKShiftState[j], DeadKey); break; + default: TranslateKeyboard(kbd, VKMap[i], VKShiftState[j], ch); + } + + // + }*/ + + //if (!(run_DoConvert_Part1_getMap(argc, argv)) && (!run_DoConvert_Part2_TranslateKeyboard()) ) + if (!(run_DoConvert_Part1_getMap(argc, argv))) + int do_something; + return true; } - - - - - - - - - - +void KMX_LogError(const KMX_WCHART* m1,int m2) { + wprintf((PWSTR)m1, m2); +} +// ---- old ---------------------------------------------------------- // @@ -677,9 +717,6 @@ BOOL DoConvert(LPKEYBOARD kbd, LPWSTR kbid, BOOL bDeadkeyConversion) { // I455 */ -void KMX_LogError(const KMX_WCHART* m1,int m2) { - wprintf((PWSTR)m1, m2); -} //---------old------------------------------------------- /*#include "pch.h" From fce512ce4cbe8f0c35880ee4d41c3a2e649d406a Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 19 Jul 2023 16:36:59 +0200 Subject: [PATCH 057/327] feat(linux): mcompile first version to use gtk --- linux/mcompile/keymap/km_types.h | 17 +++++ linux/mcompile/keymap/mcompile.cpp | 119 ++++++++++++++++++++--------- 2 files changed, 99 insertions(+), 37 deletions(-) diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index 5e4b39206a..01cae33a70 100644 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -68,6 +68,7 @@ typedef wchar_t* LPWSTR; // _S2 needs to be removed/? typedef WCHAR* PWCHAR; // _S2 needs to be removed/? typedef KMX_CHAR* PKMX_CHAR; // _S2 needs to be removed/? +typedef unsigned int UINT; // _S2 needs to be removed/? typedef int BOOL; // _S2 needs to be removed/? or is it int32_t?? @@ -97,4 +98,20 @@ typedef wchar_t KMX_UCHAR; typedef KMX_UCHAR* KMX_PUCHAR; +// _S2 do we need this ? +#define VK_SPACE 0x20 +#define VK_COLON 0xBA +#define VK_EQUAL 0xBB +#define VK_COMMA 0xBC +#define VK_HYPHEN 0xBD +#define VK_PERIOD 0xBE +#define VK_SLASH 0xBF +#define VK_ACCENT 0xC0 +#define VK_LBRKT 0xDB +#define VK_BKSLASH 0xDC +#define VK_RBRKT 0xDD +#define VK_QUOTE 0xDE +#define VK_xDF 0xDF +#define VK_OEM_102 0xE2 // "<>" or "\|" on RT 102-key kbd. + #endif /*KM_TYPES*/ diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 296939fe45..5af4af28b5 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -50,6 +50,19 @@ mcompile -d runs 4 important steps: KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]); +// +// Map of all shift states that we will work with +// +//const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; +const UINT VKShiftState[] = {0, 1, 0xFFFF}; + + +// Map of all US English virtual key codes that we can translate +// US Keys: Q W E R T Y U I O P A S D F G H J K L Z X C V B N M +const DWORD VKMap_US_Keycode[] = { 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 , 33 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 52 , 53 , 54 , 55 , 56 , 57 , 58 }; + + + #if defined(_WIN32) || defined(_WIN64) int wmain(int argc, wchar_t* argv[]) { std::vector str_argv_16 = convert_argvW_to_Vector_u16str( argc, argv); @@ -216,55 +229,87 @@ KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { return FALSE; } +//UINT KMX_VKUSToVKUnderlyingLayout(const DWORD US_Keycode, GdkDisplay *display){ +UINT KMX_VKUSToVKUnderlyingLayout(const DWORD US_Keycode, GdkDisplay *display){ + uint ret =88; +/* + ret = XkbKeycodeToKeysym(display, US_Keycode,0) + MyCoutW(L"#### KMX_VKUSToVKUnderlyingLayout of mcompile ended", 0); + MyCoutW(ret, 1);*/ + return US_Keycode-1; +} - - - - KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]) { +KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]) { KMX_WCHART DeadKey; if(!KMX_SetKeyboardToPositional(kbd)) return FALSE; - // Go through each of the shift states - base, shift, ctrl+alt, ctrl+alt+shift, [caps vs ncaps?] - // Currently, we go in this order so the 102nd key works. But this is not ideal for keyboards without 102nd key: // I4651 - // it catches only the first key that matches a given rule, but multiple keys may match that rule. This is particularly - // evident for the 102nd key on UK, for example, where \ can be generated with VK_OEM_102 or AltGr+VK_QUOTE. - // For now, we get the least shifted version, which is hopefully adequate. - /* - for(int j = 0; VKShiftState[j] != 0xFFFF; j++) { // I4651 - // Go through each possible key on the keyboard - for(int i = 0; VKMap[i]; i++) { // I4651 - UINT vkUnderlying = VKUSToVKUnderlyingLayout(VKMap[i]); + MyCoutW(L"#### KMX_DoConvert of keymap started", 1); - WCHAR ch = CharFromVK(vkUnderlying, VKShiftState[j], &DeadKey); - - //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); - - if(bDeadkeyConversion) { // I4552 - if(ch == 0xFFFF) { - ch = DeadKey; - } + gdk_init(&argc, &argv); + GdkDisplay *display = gdk_display_get_default(); + if (!display) { + printf("ERROR: can't get display\n"); + return 1; + } + GdkKeymap *keymap = gdk_keymap_get_for_display(display); + if (!keymap) { + printf("ERROR: Can't get keymap\n"); + gdk_display_close(display); + return 2; } - switch(ch) { - case 0x0000: break; - case 0xFFFF: ConvertDeadkey(kbd, VKMap[i], VKShiftState[j], DeadKey); break; - default: TranslateKeyboard(kbd, VKMap[i], VKShiftState[j], ch); + MyCoutW(L" # Top checks of keymap OK", 1); + + // Go through each of the shift states - base, shift, ctrl+alt, ctrl+alt+shift, [caps vs ncaps?] + // Currently, we go in this order so the 102nd key works. But this is not ideal for keyboards without 102nd key: // I4651 + // it catches only the first key that matches a given rule, but multiple keys may match that rule. This is particularly + // evident for the 102nd key on UK, for example, where \ can be generated with VK_OEM_102 or AltGr+VK_QUOTE. + // For now, we get the least shifted version, which is hopefully adequate. + + for (int j = 0; VKShiftState[j] != 0xFFFF; j++) { // I4651 + wprintf(L" +++++++ VKShiftState Nr: %i \n", j); + // Go through each possible key on the keyboard + for (int i = 0; VKMap_US_Keycode[i]; i++) { // I4651 + wprintf(L" +++++++ VKMap_US_Keycode Nr: %i , value %i \n", i,VKMap_US_Keycode[i]); + //UINT vkUnderlying = KMX_VKUSToVKUnderlyingLayout(VKMap_US_Keycode[i], display); + UINT vkUnderlying = KMX_VKUSToVKUnderlyingLayout(VKMap_US_Keycode[i], display); + wprintf(L" +++++++ back from KMX_VKUSToVKUnderlyingLayout: %i \n", vkUnderlying); + + // WCHAR ch = CharFromVK(vkUnderlying, VKShiftState[j], &DeadKey); + + +/* + + + //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); + + if (bDeadkeyConversion) { // I4552 + if (ch == 0xFFFF) { + ch = DeadKey; } + } - // - }*/ - - - - //if (!(run_DoConvert_Part1_getMap(argc, argv)) && (!run_DoConvert_Part2_TranslateKeyboard()) ) - - if (!(run_DoConvert_Part1_getMap(argc, argv))) - int do_something; - - return true; + switch (ch) { + case 0x0000: break; + case 0xFFFF: ConvertDeadkey(kbd, VKMap[i], VKShiftState[j], DeadKey); break; + default: TranslateKeyboard(kbd, VKMap[i], VKShiftState[j], ch); + } +*/ + } } +/* + ReportUnconvertedKeyboardRules(kbd); + + if(!ImportRules(kbid, kbd, &FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 + return FALSE; + } +*/ + return TRUE; +} + + void KMX_LogError(const KMX_WCHART* m1,int m2) { wprintf((PWSTR)m1, m2); From 7bb002ba86ba7bc1ee9c78b569ee87554b718105 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 19 Jul 2023 16:53:11 +0200 Subject: [PATCH 058/327] feat(linux): mcompile tidy up --- linux/mcompile/keymap/keymap.cpp | 18 ++---------- linux/mcompile/keymap/keymap.h | 4 --- linux/mcompile/keymap/main.cpp | 47 ------------------------------ linux/mcompile/keymap/mc_kmxfile.h | 6 ---- linux/mcompile/keymap/mcompile.cpp | 9 ------ 5 files changed, 2 insertions(+), 82 deletions(-) delete mode 100644 linux/mcompile/keymap/main.cpp diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 2d739f3f0b..1a89ebea8b 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -26,6 +26,7 @@ int dummytest_keymap(){ std::wcout<< " dummytest_keymap is available\n"; return 0; } + bool write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { MyCoutW(L" #### write_US_ToVector of keymap started", 1); @@ -536,9 +537,7 @@ void test_specific_Characters(v_str_3D &All_Vector) { MyCoutW(L" #### test_specific_Characters of keymap ended", 1); } -//TODO needs to take 2 keyboards as input int run_DoConvert_Part1_getMap(gint argc, gchar *argv[]) { -//int main(gint argc, gchar *argv[]) { MyCoutW(L"#### run_DoConvert_Part1_getMap of keymap started", 1); @@ -604,6 +603,7 @@ int run_DoConvert_Part1_getMap(gint argc, gchar *argv[]) { printf("°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° end\n"); return 0; } + void LoadKeyboard() {std::cout << "#### LoadKeyboard not implemented yet ! \n";} void run_DoConvert_Part2_TranslateKeyboard() {std::cout << "#### TranslateKeyboard not implemented yet ! \n";} @@ -611,20 +611,6 @@ void run_DoConvert_Part2_TranslateKeyboard() {std::cout << "#### TranslateKeyboa void SaveKeyboard() {std::cout << "#### SaveKeyboard not implemented yet ! \n";} //-------------------------------------- -//int main(gint argc, gchar *argv[]) // this is for use of single keymap -/*int main_keymap(gint argc, gchar *argv[]) // this is for use of keymap together with mcompile -{ - check_avaiability_of_modules_(); - LoadKeyboard(); - std::cout << "############################################################################################### end LoadKeyboard \n"; - - int out = run_DoConvert_Part1_getMap(argc,argv); - run_DoConvert_Part2_TranslateKeyboard(); - SaveKeyboard(); - - std::cout << "################################################################################################################################### end keymap \n"; - return out ; -}*/ // old ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ /* static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index dea3ebffc4..4c7502b27a 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -36,10 +36,6 @@ void LoadKeyboard(); // use TranslateKeyboard, TranslateGroup,TranslateKey from mcompile void run_DoConvert_Part2_TranslateKeyboard(); -// adapt from mc_savekeyboard.cpp -//void SaveKeyboard(); - - // read configuration file, split and write to 3D-Vector (Data for US on [0][ ][ ] ) bool write_US_ToVector(v_str_3D &vec, std::string language, const char *text); diff --git a/linux/mcompile/keymap/main.cpp b/linux/mcompile/keymap/main.cpp deleted file mode 100644 index 2fa3409d87..0000000000 --- a/linux/mcompile/keymap/main.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include - - -static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) -{ - GdkKeymapKey *maps; - guint *keyvals; - gint count; - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return; - - for (int i = 0; i < count; i++) { - if (maps[i].level > 0 || maps[i].group > 1) - continue; - printf(" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); - } - - g_free(keyvals); - g_free(maps); -} - -int main(gint argc, gchar **argv) -{ - gdk_init(&argc, &argv); - GdkDisplay *display = gdk_display_get_default(); - if (!display) { - printf("ERROR: can't get display\n"); - return 1; - } - GdkKeymap *keymap = gdk_keymap_get_for_display(display); - if (!keymap) { - printf("ERROR: Can't get keymap\n"); - gdk_display_close(display); - return 2; - } - - for (int keycode = 10; keycode <= 61; keycode++) { - printf("-------------------\n"); - printf("Keycode %d:\n", keycode); - PrintKeymapForCode(keymap, keycode); - } - - gdk_display_close(display); - - return 0; -} diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 54712b1e25..71e8aac11d 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -64,8 +64,6 @@ typedef struct tagGROUP { } KMX_GROUP, *LPKMX_GROUP; - - typedef struct tagKEYBOARD { DWORD dwIdentifier; // Keyman compiled keyboard id @@ -143,10 +141,6 @@ KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, PKMX_WCHAR filename); KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL FSaveDebug); #endif - - - - //---------------------old---------------------------------------- /* #include diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 5af4af28b5..ccc7b91fa6 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -86,10 +86,6 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL) argv.push_back(cmdl_par); } - //---------------------------------------- -// test if all cpps are acccessible: can be removed - //check_avaiability_of_modules_(); //_S2 - wprintf(L"_S2 started run for char16_t*\n"); if(argc < 3 || (argc < 5 && u16cmp(argv[1], u"-u") != 0)) { // I4273// I4273 @@ -202,23 +198,19 @@ wprintf(L"_S2 * Up to here cross-platform xx :-))))) ************************** KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { - MyCoutW(L"#### KMX_SetKeyboardToPositional of keymap started", 1); LPKMX_STORE sp; KMX_UINT i; for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { if(sp->dwSystemID == TSS_MNEMONIC) { if(!sp->dpString) { KMX_LogError(L"Invalid &mnemoniclayout system store"); - MyCoutW(L" #### KMX_SetKeyboardToPositional Invalid &mnemoniclayout system store", 1); return FALSE; } if(u16cmp((const KMX_WCHAR*)sp->dpString, u"1") != 0) { KMX_LogError(L"Keyboard is not a mnemonic layout keyboard"); - MyCoutW(L" #### KMX_SetKeyboardToPositional Keyboard is not a mnemonic layout keyboard", 1); return FALSE; } *sp->dpString = '0'; - MyCoutW(L" #### KMX_SetKeyboardToPositional Keyboard all good !!", 1); return TRUE; } } @@ -229,7 +221,6 @@ KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { return FALSE; } -//UINT KMX_VKUSToVKUnderlyingLayout(const DWORD US_Keycode, GdkDisplay *display){ UINT KMX_VKUSToVKUnderlyingLayout(const DWORD US_Keycode, GdkDisplay *display){ uint ret =88; /* From 891f04e79117190db57def12c28bf474e5ab1ce9 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 21 Jul 2023 20:50:30 +0200 Subject: [PATCH 059/327] feat(linux): mcompile commentary in keymap.cpp/h --- linux/mcompile/keymap/keymap.cpp | 12 ++++++------ linux/mcompile/keymap/keymap.h | 6 ++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 1a89ebea8b..5b6daf990d 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -277,7 +277,7 @@ bool append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap) { All_Vector[1][i][0+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),0); //shift state: unshifted:0 All_Vector[1][i][1+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),1); //shift state: shifted:1 - wprintf(L" Keycodes US->Other: %d(US): %s, %s ---- (other):%s, %s \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str(),All_Vector[1][i][2].c_str()); + wprintf(L" Keycodes US->Other: %d (US):%s, %s ---- (other):%s, %s \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str(),All_Vector[1][i][2].c_str()); } MyCoutW(L" #### append_other_ToVector of keymap ended", 1); @@ -375,8 +375,8 @@ bool extract_difference( v_str_3D &All_Vector) { std::string get_Other_Char_FromUS( std::string in , v_str_3D &All_Vector) { - //MyCoutW(L" #### get_Other_Char_FromUS of keymap started", 1); - std::string diff; + MyCoutW(L" #### get_Other_Char_FromUS of keymap started", 1); + std::wstring diff; // find correct row of char in US for( int i=0; i< (int) All_Vector[0].size();i++) { for( int j=1; j< (int)All_Vector[0][0].size();j++) { @@ -384,15 +384,15 @@ std::string get_Other_Char_FromUS( std::string in , v_str_3D &All_Vector) { //std::cout << "see and compare: "<< "All_Vector[0]["< Other: "<< std::setw(5)< Other: %d (US): %s, %s ---- (other):%s, %s \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str(),All_Vector[1][i][2].c_str()); return All_Vector[1][i][j] ; } } } std::cout << "US -> Other: (" << in << ": no match)\n"; - MyCoutW(L" #### get_Other_Char_FromUS of keymap ended", 1); + MyCoutW(L" #### get_Other_Char_FromUS of keymap ended", 1); return "-"; } diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 4c7502b27a..202b7cdc2c 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -33,6 +33,12 @@ int run_DoConvert_Part1_getMap(gint argc, gchar *argv[]); // adapt from mc_kmxfile.cpp void LoadKeyboard(); +// initialize GDK +bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); + +// create a Vector with all entries of both keymaps +bool createVectorForBothKeyboards(v_str_3D &All_Vector,GdkKeymap *keymap); + // use TranslateKeyboard, TranslateGroup,TranslateKey from mcompile void run_DoConvert_Part2_TranslateKeyboard(); From 5e62bed2183d2272835c1b27d371906a803b66b5 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 21 Jul 2023 22:09:06 +0200 Subject: [PATCH 060/327] feat(linux): mcompile tidy up --- linux/mcompile/keymap/keymap.cpp | 66 +--- linux/mcompile/keymap/mcompile.cpp | 487 +++++++++++++++++++++++++---- linux/mcompile/keymap/meson.build | 8 +- 3 files changed, 448 insertions(+), 113 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 5b6daf990d..603579d759 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -29,7 +29,7 @@ int dummytest_keymap(){ bool write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { - MyCoutW(L" #### write_US_ToVector of keymap started", 1); + //MyCoutW(L" #### write_US_ToVector of keymap started", 1); // _S2 relative path !! std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; @@ -55,7 +55,7 @@ bool write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { } wprintf(L" +++++++ dimensions of Vector after write_US_ToVector (languages..characters..shiftstates)\t\t %li..%li..%li\n", vec.size(), vec[0].size(),vec[0][0].size()); - MyCoutW(L" #### write_US_ToVector of keymap ended", 1); + //MyCoutW(L" #### write_US_ToVector of keymap ended", 1); fclose(fp); return 0; } @@ -64,7 +64,7 @@ bool CreateCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, // in the Configuration file we find the appopriate paragraph between "xkb_symbol " and the next xkb_symbol // and then copy all rows starting with "key <" to a v1D-Vector - MyCoutW(L" #### CreateCompleteRow_US of keymap started", 1); + //MyCoutW(L" #### CreateCompleteRow_US of keymap started", 1); int buffer_size = 512; char buffer[buffer_size]; bool print_OK = false; @@ -103,7 +103,7 @@ bool CreateCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, return 1; } - MyCoutW(L" #### CreateCompleteRow_US of keymap ended", 1); + //MyCoutW(L" #### CreateCompleteRow_US of keymap ended", 1); return 0; } @@ -111,7 +111,8 @@ bool Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList) { // 1: take the whole line of the 1D-Vector and remove unwanted characters. // 2: seperate the name e.g. key from the shiftstates // 3: push Names/Shiftstates to shift_states and then shiftstates to All_US, our 3D-Vector holding all Elements -MyCoutW(L" #### Split_US_To_3D_Vector of keymap started", 1); + +//MyCoutW(L" #### Split_US_To_3D_Vector of keymap started", 1); std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; char split_bracel = '{'; char split_char_komma = ','; @@ -166,13 +167,13 @@ MyCoutW(L" #### Split_US_To_3D_Vector of keymap started", 1); printf("ERROR: Can't split US to 3D-Vector\n"); return 1; } - MyCoutW(L" #### Split_US_To_3D_Vector of keymap ended", 1); + //MyCoutW(L" #### Split_US_To_3D_Vector of keymap ended", 1); //printf("### 6 Split_US_To_3D_clearVector %li..%li..%li\n", all_US.size(), all_US[0].size(),all_US[0][0].size()); return 0; } bool foundCharacterInList(std::string tok) { - MyCoutW(L" #### foundCharacterInList of keymap started", 1); + //MyCoutW(L" #### foundCharacterInList of keymap started", 1); //TOASK Do we need more and which? //US keys: Q W E R T Y U I O P A S D F G H J K L Z X C V B N M v_str_1D Keysyms { "24","25","26","27","28","29","30","31","32","33","38","39","40","41","42","43","44","45","46","52","53","54","55","56","57","58"}; @@ -184,13 +185,12 @@ bool foundCharacterInList(std::string tok) { } } - MyCoutW(L" #### foundCharacterInList of keymap ended", 1); + //MyCoutW(L" #### foundCharacterInList of keymap ended", 1); return false; } int replace_PosKey_with_Keycode(std::string in) { - MyCoutW(L" #### replace_PosKey_with_Keycode of keymap started", 1); int out=0; if ( in == "key") out = 49; // TOASK correct ??? else if ( in == "key") out = 10; @@ -245,13 +245,12 @@ int replace_PosKey_with_Keycode(std::string in) { else if ( in == "key") out = 62; //TOASK correct ??? else if ( in == "key") out = 51; //TOASK correct ??? - MyCoutW(L" #### replace_PosKey_with_Keycode of keymap ended", 1); return out; } bool append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap) { - MyCoutW(L" #### append_other_ToVector of keymap started", 1); + //MyCoutW(L" #### append_other_ToVector of keymap started", 1); // create a 2D vector all filled with "--" and push to 3D-Vector v_str_2D Other_Vector2D = create_empty_2D(All_Vector[0].size(),All_Vector[0][0].size()); @@ -280,13 +279,12 @@ bool append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap) { wprintf(L" Keycodes US->Other: %d (US):%s, %s ---- (other):%s, %s \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str(),All_Vector[1][i][2].c_str()); } - MyCoutW(L" #### append_other_ToVector of keymap ended", 1); + //MyCoutW(L" #### append_other_ToVector of keymap ended", 1); return 0; } v_str_2D create_empty_2D( int dim_rows,int dim_shifts) { - MyCoutW(L" #### create_empty_2D of keymap started", 1); std::string empty = "--"; v_str_1D shifts; v_str_2D all; @@ -298,14 +296,11 @@ v_str_2D create_empty_2D( int dim_rows,int dim_shifts) { all.push_back(shifts); shifts.clear(); } - - MyCoutW(L" #### create_empty_2D of keymap ended", 1); return all; } int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { - //MyCoutW(L" #### GetKeyvalsFromKeymap of keymap started", 1); GdkKeymapKey *maps; guint *keyvals; gint count; @@ -324,7 +319,6 @@ int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) g_free(keyvals); g_free(maps); - //MyCoutW(L" #### GetKeyvalsFromKeymap of keymap ended", 1); return out; } @@ -375,7 +369,6 @@ bool extract_difference( v_str_3D &All_Vector) { std::string get_Other_Char_FromUS( std::string in , v_str_3D &All_Vector) { - MyCoutW(L" #### get_Other_Char_FromUS of keymap started", 1); std::wstring diff; // find correct row of char in US for( int i=0; i< (int) All_Vector[0].size();i++) { @@ -391,14 +384,11 @@ std::string get_Other_Char_FromUS( std::string in , v_str_3D &All_Vector) { } } std::cout << "US -> Other: (" << in << ": no match)\n"; - - MyCoutW(L" #### get_Other_Char_FromUS of keymap ended", 1); return "-"; } std::string get_US_Char_FromOther(std::string in , v_str_3D &All_Vector) { - //MyCoutW(L" #### get_US_Char_FromOther of keymap started", 1); std::string diff; // find correct row of char in other for( int i=0; i< (int)All_Vector[1].size();i++) { @@ -412,14 +402,11 @@ std::string get_US_Char_FromOther(std::string in , v_str_3D &All_Vector) { } } std::cout << "Other -> US: (" << in << ": no match)\n"; - - MyCoutW(L" #### get_US_Char_FromOther of keymap ended", 1); return "-"; } std::string getKeyNrOf_USChar(std::string in , v_str_3D &All_Vector) { - //MyCoutW(L" #### getKeyNrOf_USChar of keymap started", 1); // find correct row of char in US for( int i=0; i< (int)All_Vector[0].size();i++) { for( int j=1; j< (int)All_Vector[0][0].size();j++) { @@ -429,13 +416,11 @@ std::string getKeyNrOf_USChar(std::string in , v_str_3D &All_Vector) { } } } - MyCoutW(L" #### getKeyNrOf_USChar of keymap ended", 1); return "-"; } std::string getKeyNrOf_OtherChar(std::string in , v_str_3D &All_Vector) { - //MyCoutW(L" #### getKeyNrOf_OtherChar of keymap started", 1); // find correct row of char in US for( int i=0; i< (int)All_Vector[1].size();i++) { for( int j=1; j< (int)All_Vector[1][0].size();j++) { @@ -445,13 +430,11 @@ std::string getKeyNrOf_OtherChar(std::string in , v_str_3D &All_Vector) { } } } - MyCoutW(L" #### getKeyNrOf_OtherChar of keymap ended", 1); return "-"; } bool test(v_str_3D &V) { - MyCoutW(L" #### test of keymap started", 1); printf("+++++++ dimensions of Vector in test()\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); printf("\n+++++++++ print some characters of US and Other +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); @@ -462,13 +445,11 @@ bool test(v_str_3D &V) { } printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - MyCoutW(L" #### test of keymap ended", 1); return true; } void test_in_out(v_str_3D &All_Vector) { - MyCoutW(L" #### test_in_out of keymap started", 1); std::string diff; printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); //checks mapping between US and other @@ -497,47 +478,37 @@ std::string diff; std::cout << "getKeyNrOf_OtherChar z-Z-y-Y: " << ".." << c<< ".." < // _S2 do I need that??? + //------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------ @@ -59,7 +62,11 @@ const UINT VKShiftState[] = {0, 1, 0xFFFF}; // Map of all US English virtual key codes that we can translate // US Keys: Q W E R T Y U I O P A S D F G H J K L Z X C V B N M -const DWORD VKMap_US_Keycode[] = { 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 , 33 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 52 , 53 , 54 , 55 , 56 , 57 , 58 }; +const DWORD VKMap_US_Keycode[] = { 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 , 33 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 52 , 53 , 54 , 55 , 56 , 57 , 77 ,0}; + +// Map of all US English virtual key codes that we can translate +// US Keys: 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 , 33 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 47, 52 , 53 , 54 , 55 , 56 , 57 , 77 , 0 +const char VKMap_US_Keysym[] = { 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '0'}; @@ -192,11 +199,6 @@ wprintf(L"_S2 * Up to here cross-platform xx :-))))) ************************** - - - - - KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { LPKMX_STORE sp; KMX_UINT i; @@ -216,18 +218,71 @@ KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { } KMX_LogError(L"Keyboard is not a mnemonic layout keyboard"); - - MyCoutW(L"#### KMX_SetKeyboardToPositional of keymap ended", 1); return FALSE; } -UINT KMX_VKUSToVKUnderlyingLayout(const DWORD US_Keycode, GdkDisplay *display){ - uint ret =88; -/* - ret = XkbKeycodeToKeysym(display, US_Keycode,0) - MyCoutW(L"#### KMX_VKUSToVKUnderlyingLayout of mcompile ended", 0); - MyCoutW(ret, 1);*/ - return US_Keycode-1; +bool get_OtherKeysym_From_US_Keysym(v_str_3D &All_Vector,int inUS,int &outOther){ + + //MyCoutW(L" #### get_OtherKeysym_From_US_Keysym of keymap started", 1); + // loop and find char in US; then find char of Other + for( int i=0; i< (int)All_Vector[1].size();i++) { + for( int j=0; j< (int)All_Vector[1][0].size();j++) { + + int KeysymUS = (int) *All_Vector[0][i][j].c_str(); + int KeysymOther = (int) *All_Vector[1][i][j].c_str(); + std::wstring KeysymUS_wstr = wstring_from_string(All_Vector[0][i][j]); + + if( inUS == KeysymUS ) { + //wprintf(L" FOUND Value in OTHER !!!!! : Other in: %i ( %s ) -- Keycode : %s -- US out ########: %i ( %s ) \n", KeysymUS,All_Vector[0][i][j].c_str(), All_Vector[1][i][0].c_str() , KeysymOther,All_Vector[1][i][j].c_str()); + wprintf(L" get_OtherKeysym_From_US_Keysym FOUND Value in US !!!!! : Other in: %i ( %s ) -- Keycode : %s -- US out ########: %i ( %s ) \n", + KeysymUS,All_Vector[0][i][j].c_str(), All_Vector[1][i][0].c_str() , KeysymOther,All_Vector[1][i][j].c_str()); + outOther = KeysymOther; + + //MyCoutW(L" #### get_OtherKeysym_From_US_Keysym of keymap ended", 1); + return true; + } + } + } + return true; +} + +bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]){ +// get keymap of keyboard layout in use + + gdk_init(&argc, &argv); + GdkDisplay *display = gdk_display_get_default(); + if (!display) { + printf("ERROR: can't get display\n"); + return 1; + } + + *keymap = gdk_keymap_get_for_display(display); + if (!keymap) { + printf("ERROR: Can't get keymap\n"); + gdk_display_close(display); + return 2; + } + + return 0; +} + +bool createVectorForBothKeyboards(v_str_3D &All_Vector,GdkKeymap *keymap){ + + std::string US_language = "us"; + const char* text_us = "xkb_symbols \"basic\""; + + if(write_US_ToVector(All_Vector,US_language, text_us)) { + printf("ERROR: can't write US to Vector \n"); + return 1; + } + + // add contents of other keyboard to All_Vector + if( append_other_ToVector(All_Vector,keymap)) { + printf("ERROR: can't append other ToVector \n"); + return 1; + } + test(All_Vector); + return 0; } KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]) { @@ -236,60 +291,44 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon if(!KMX_SetKeyboardToPositional(kbd)) return FALSE; - MyCoutW(L"#### KMX_DoConvert of keymap started", 1); - - gdk_init(&argc, &argv); - GdkDisplay *display = gdk_display_get_default(); - if (!display) { - printf("ERROR: can't get display\n"); - return 1; - } - GdkKeymap *keymap = gdk_keymap_get_for_display(display); - if (!keymap) { - printf("ERROR: Can't get keymap\n"); - gdk_display_close(display); - return 2; - } - - MyCoutW(L" # Top checks of keymap OK", 1); - // Go through each of the shift states - base, shift, ctrl+alt, ctrl+alt+shift, [caps vs ncaps?] // Currently, we go in this order so the 102nd key works. But this is not ideal for keyboards without 102nd key: // I4651 // it catches only the first key that matches a given rule, but multiple keys may match that rule. This is particularly // evident for the 102nd key on UK, for example, where \ can be generated with VK_OEM_102 or AltGr+VK_QUOTE. // For now, we get the least shifted version, which is hopefully adequate. + // first version with GTK - change later to XklGetGroupNames und XklGetCurrentState as Eberhard suggested + //_ init gdk + GdkKeymap *keymap; + if(InitializeGDK(&keymap , argc, argv) ) + printf("ERROR: can't InitializeGDK\n"); + + // create vector + v_str_3D All_Vector; + if(createVectorForBothKeyboards(All_Vector,keymap) ) + printf("ERROR: can't createVectorForBothKeyboards\n"); + + +//-------------------------------------------------------------------------------- + for (int j = 0; VKShiftState[j] != 0xFFFF; j++) { // I4651 - wprintf(L" +++++++ VKShiftState Nr: %i \n", j); + // Go through each possible key on the keyboard - for (int i = 0; VKMap_US_Keycode[i]; i++) { // I4651 - wprintf(L" +++++++ VKMap_US_Keycode Nr: %i , value %i \n", i,VKMap_US_Keycode[i]); - //UINT vkUnderlying = KMX_VKUSToVKUnderlyingLayout(VKMap_US_Keycode[i], display); - UINT vkUnderlying = KMX_VKUSToVKUnderlyingLayout(VKMap_US_Keycode[i], display); - wprintf(L" +++++++ back from KMX_VKUSToVKUnderlyingLayout: %i \n", vkUnderlying); + for (int i = 0;VKMap_US_Keysym[i]; i++) { // I4651 - // WCHAR ch = CharFromVK(vkUnderlying, VKShiftState[j], &DeadKey); + //wprintf(L" +++++++ VKMap_US_Keycode Nr: %i , i \n", i, VKMap_US_Keycode[i]); + // _S2 why not merging the 2 functions KMX_VKUSToVKUnderlyingLayout, CharFromVK? + // UINT vkUnderlying = KMX_VKUSToVKUnderlyingLayout(VKMap_US_Keycode[i], display); + int vkUnderlying; + //wprintf(L" ########: will steart with 1 get_US_Keysym_From_OtherKeysym inxx: %i outxx: \n", VKMap_US_Keysym[i]); + bool ranOK = get_OtherKeysym_From_US_Keysym(All_Vector,(int) VKMap_US_Keysym[i],vkUnderlying ); -/* - - - //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); - - if (bDeadkeyConversion) { // I4552 - if (ch == 0xFFFF) { - ch = DeadKey; - } - } - - switch (ch) { - case 0x0000: break; - case 0xFFFF: ConvertDeadkey(kbd, VKMap[i], VKShiftState[j], DeadKey); break; - default: TranslateKeyboard(kbd, VKMap[i], VKShiftState[j], ch); - } -*/ + //wprintf(L" +++++++ back from KMX_VKUSToVKUnderlyingLayout: %i \n", vkUnderlying); + // WCHAR ch = CharFromVK(vkUnderlying, VKShiftState[j], &DeadKey); } } + /* ReportUnconvertedKeyboardRules(kbd); @@ -300,11 +339,10 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon return TRUE; } - - void KMX_LogError(const KMX_WCHART* m1,int m2) { wprintf((PWSTR)m1, m2); } + // ---- old ---------------------------------------------------------- @@ -433,8 +471,8 @@ int run(int argc, wchar_t * argv[]) // Map of all US English virtual key codes that we can translate // const WORD VKMap[] = { - 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', - '0','1','2','3','4','5','6','7','8','9', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', VK_SPACE, VK_ACCENT, VK_HYPHEN, VK_EQUAL, VK_LBRKT, VK_RBRKT, VK_BKSLASH, @@ -873,8 +911,8 @@ int run(int argc, wchar_t * argv[]) // Map of all US English virtual key codes that we can translate // const WORD VKMap[] = { - 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', - '0','1','2','3','4','5','6','7','8','9', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', VK_SPACE, VK_ACCENT, VK_HYPHEN, VK_EQUAL, VK_LBRKT, VK_RBRKT, VK_BKSLASH, @@ -1201,3 +1239,328 @@ void LogError(PWSTR fmt, ...) { _putws(fmtbuf); } */ + + + + +// _S2 maybe I will need that later?? + +/* static xkb_keysym_t get_ascii(struct xkb_state *state, xkb_keycode_t keycode) { + struct xkb_keymap *keymap; + xkb_layout_index_t num_layouts; + xkb_layout_index_t layout; + xkb_level_index_t level; + const xkb_keysym_t *syms; + int num_syms; + + keymap = xkb_state_get_keymap(state); + num_layouts = xkb_keymap_num_layouts_for_key(keymap, keycode); + + for (layout = 0; layout < num_layouts; layout++) { + level = xkb_state_key_get_level(state, keycode, layout); + num_syms = xkb_keymap_key_get_syms_by_level(keymap, keycode, + layout, level, &syms); + if (num_syms != 1) + continue; + + if (syms[0] > 0 && xkb_keysym_to_utf32(syms[0]) < 128) + return syms[0]; + } + + return XKB_KEY_NoSymbol; +} +*/ + + + /*static xkb_keysym_t get_ascii_SAB(xkb_keycode_t keycode) { + + xkb_layout_index_t num_layouts; + xkb_layout_index_t layout; + xkb_level_index_t level; + const xkb_keysym_t *syms; + int num_syms; + + struct xkb_context *ctx; + + ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS); + if (!ctx) + MyCoutW(L" # Error in xkb_context_new", 1); + + + + +// get a keymap from a given name ( is) +struct xkb_keymap *keymap_is; + struct xkb_rule_names names = { + // Example RMLVO for Icelandic Dvorak. + .rules = NULL, + .model = "pc105", + .layout = "is", + .variant = "dvorak", + .options = "terminate:ctrl_alt_bksp" + }; + keymap_is = xkb_keymap_new_from_names(ctx, &names, XKB_KEYMAP_COMPILE_NO_FLAGS); + + if (!keymap_is) + MyCoutW(L" # Error in xkb_keymap_new_from_names", 1); + + // how many layouts are in keymap ( here is: 4) + num_layouts = xkb_keymap_num_layouts_for_key(keymap_is, keycode); + std::wcout << L" num_layouts: " << num_layouts << L"\n"; + + for (layout = 0; layout < num_layouts; layout++) { + + // how many levels do we have per key e.g. [a, A, ä, ascitilde ] + std::wcout << L" layout: Nr" << layout << L"\n"; + xkb_level_index_t level = xkb_keymap_num_levels_for_key ( keymap_is, keycode, layout ) ; + std::wcout << L" we have level nr of : " << level << L"\n"; + +for( int j=0; j< level;j++) +{ + std::wcout << L" j: " << j << L"\n"; + // get the keysym(characzter) in level level ( get a for level 1; A for level 2;) + num_syms = xkb_keymap_key_get_syms_by_level(keymap_is, keycode, layout, j, &syms); + std::wcout << L" num_syms(j): " << num_syms << L"\n"; + + // if no entry for this level + if (num_syms != 1) + continue; + + if (syms[0] > 0 && xkb_keysym_to_utf32(syms[0]) < 128) + return syms[0]; + + } + } + + return XKB_KEY_NoSymbol; +}*/ +// bak all tries for DoConvert here: +/* + +//#include "XKeyboard.h" +#include "/usr/include/libxklavier/xklavier.h" +#include "/usr/include/libxklavier/xkl_config_item.h" +#include "/usr/include/libxklavier/xkl_config_rec.h +#include "/usr/include/libxklavier/xkl_config_registry.h +#include "/usr/include/libxklavier/xkl_engine.h +#include "/usr/include/libxklavier/xkl_engine_marshal.h +#include "/usr/include/libxklavier/xkl-enum-types.h +#include "/usr/include/libxklavier/xklavier.h" +#include "/usr/include/libxklavier/xklavier.h" + + + + +std::wcout << L"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\n"; +std::string st = std::locale("").name() ; +std::wstring wstr = wstring_from_string(st); + +std::wcout << wstr; +std::wcout << L"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\n"; +xklgetg +//const char** ccc = XklGetGroupNames ( ) ; +//xkl_engine_get_groups_names +//const char** cccc = XkbGetNames ( ) ; +/* + Display *dpy = XOpenDisplay(NULL); + + if (dpy == NULL) { + fprintf(stderr, "Cannot open display\n"); + exit(1); + } + + XkbStateRec state; + XkbGetState(dpy, XkbUseCoreKbd, &state); + + XkbDescPtr desc = XkbGetKeyboard(dpy, XkbAllComponentsMask, XkbUseCoreKbd); + char*symbols = XGetAtomName(dpy, desc->names->symbols); + //char *group = XGetAtomName(dpy, desc->names->groups[state.group]); + //printf("Full name: %s\n", group); + +XKeyboard xkb; + +std::string cGrpName=xkb.currentGroupName(); //return somethings like "USA" +std::string cGrpSymb=xkb.currentGroupSymbol(); //return somethings like "us" + +xkb.setGroupByNum(0);//set keyboard layout to first layout in available ones + +//wprintf(L"Full name: %s\n", symbols); + +//std::wcout << L"qqqqqqqqqqqqqqqqqqqq: " << *symbols; + + + + + xkb_keysym_t in; + xkb_keysym_t out; + +std::vector < int > vi ={34,39,43,47,48,61,57}; +for( int i=0; i vi ={34,39,43,47,48,61,57}; +for( int i=0; i 0 && xkb_keysym_to_utf32(syms[0]) < 128) + return syms[0]; + + + } + + + //return XKB_KEY_NoSymbol; + + + MyCoutW(L" # XKB get syn OK", 1); + + // https://cpp.hotexamples.com/examples/-/-/xkb_state_get_keymap/cpp-xkb_state_get_keymap-function-examples.html + + int num; + lv = xkb_state_key_get_level(state, code + KBDXKB_SHIFT, lo); + num = xkb_keymap_key_get_syms_by_level(keymap, code + KBDXKB_SHIFT, lo, lv, &s); + + + +*/ + +/*int get_OtherKeysym_From_US_Keysym(v_str_3D &All_Vector,int inUS){ + int outOther; + MyCoutW(L" #### get_OtherKeysym_From_US_Keysym of keymap started", 1); + wprintf(L" in Us ##################### %i and KeysymsUS : \n", inUS ); + // loop and find char in US; then find char of Other + for( int i=0; i< (int)All_Vector[1].size();i++) { + for( int j=0; j< (int)All_Vector[1][0].size();j++) { + + int KeysymUS = (int) *All_Vector[0][i][j].c_str(); + int KeysymOther = (int) *All_Vector[1][i][j].c_str(); + std::wstring KeysymUS_wstr = wstring_from_string(All_Vector[0][i][j]); + //if ( inUS == 58) +wprintf(L" in Us %i and KeysymsUS %i : \n", inUS ,KeysymUS ); +//wprintf(L" ................................................................................... inxx: %s outxx: %s %s\n", All_Vector[0][25][2].c_str(),All_Vector[1][25][0].c_str(),All_Vector[1][25][2].c_str()); + if( inUS == KeysymUS ) { + //wprintf(L" FOUND Value in US !!!!! : %i out ########: %S \n", inUS,KeysymUS_wstr.c_str()); + //wprintf(L" FOUND Value in US !!!!! : %i out ########: %S \n", inUS,KeysymUS_wstr.c_str()); + // wprintf(L" FOUND Value in OTHER !!!!! : Other in: %i ( %s ) -- Keycode : %s -- US out ########: %i ( %s ) \n", KeysymUS,All_Vector[0][i][j].c_str(), All_Vector[1][i][0].c_str() , KeysymOther,All_Vector[1][i][j].c_str()); + wprintf(L" get_OtherKeysym_From_US_Keysym FOUND Value in US !!!!! : Other in: %i ( %s ) -- Keycode : %s -- US out ########: %i ( %s ) \n", + KeysymUS,All_Vector[0][i][j].c_str(), All_Vector[1][i][0].c_str() , KeysymOther,All_Vector[1][i][j].c_str()); + + + //wprintf(L" FOUND 2 Value in OTHER !!!!! : Other in: %i ( %s ) -- Keycode : %s -- US out ########: %i ( %s ) \n", KeysymOther,All_Vector[1][i][j].c_str(), All_Vector[1][i][0].c_str() , KeysymUS,All_Vector[0][i][j].c_str()); + + outOther = KeysymOther; + + MyCoutW(L" #### get_OtherKeysym_From_US_Keysym of keymap ended", 1); + + return outOther; + } + } + } + MyCoutW(L" #### get_US_Char_FromOther of keymap ended", 1); + return true; +} +*/ + + + +/* // _S2 maybe not needed +bool get_US_Keysym_From_OtherKeysym(v_str_3D &All_Vector, int inOther, int &OutUS){ + + MyCoutW(L" #### get_US_Char_FromOther of keymap started", 1); + // loop and find char in Other; then find char of US + for( int i=0; i< All_Vector[1].size();i++) { + for( int j=1; j< (int)All_Vector[1][0].size();j++) { + + int KeysymUS = (int) *All_Vector[0][i][j].c_str(); + int KeysymOther = (int) *All_Vector[1][i][j].c_str(); + std::wstring KeysymUS_wstr = wstring_from_string(All_Vector[1][i][j]); + + if( inOther == KeysymOther ) { + OutUS = KeysymUS; + return true; + } + } + } + MyCoutW(L" #### get_US_Char_FromOther of keymap ended", 1); + return true; +}*/ + diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index 4c9a5e8cb2..405cdb879c 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -4,8 +4,14 @@ project('mcompile', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') gtk = dependency('gtk+-3.0', version: '>= 2.4') +x11 = dependency('x11', version: '>= 1.6') +xkb = dependency('xkbcommon', version: '>= 0.0') +libxklavier = dependency('libxklavier', version: '>= 0.0') + +deps = [gtk, x11, xkb,libxklavier] + cpp_files = files( 'keymap.cpp', 'mcompile.cpp', 'filesystem.cpp', 'mc_kmxfile.cpp', 'mc_savekeyboard.cpp', 'helpers.cpp', 'u16.cpp',) -mcompile = executable( 'mcompile', sources: [cpp_files], dependencies: [gtk]) +mcompile = executable( 'mcompile', sources: [cpp_files], dependencies: deps) # keymapWC +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From 3c37ca0ceef84506b3d5701aa2592128b4434805 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 24 Jul 2023 18:03:58 +0200 Subject: [PATCH 061/327] feat(linux): new functions KMX_VKUSToVKUnderlyingLayout and KMX_CharFromVK; return correct char --- linux/mcompile/keymap/keymap.h | 4 +- linux/mcompile/keymap/mcompile.cpp | 64 ++++++++++++++++++++++-------- 2 files changed, 49 insertions(+), 19 deletions(-) diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 202b7cdc2c..1552948748 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -27,9 +27,9 @@ typedef std::vector > v_str_2D; typedef std::vector > > v_str_3D; static int shift_state_count = 2; // use shiftstate : no shift, shift - +/* int run_DoConvert_Part1_getMap(gint argc, gchar *argv[]); - +*/ // adapt from mc_kmxfile.cpp void LoadKeyboard(); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 0080d2bdc8..b06c05a317 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -57,8 +57,8 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon // Map of all shift states that we will work with // //const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; -const UINT VKShiftState[] = {0, 1, 0xFFFF}; - +const UINT VKShiftState[] = {0, 1, 2,0xFFFF}; +// _S2 shiftstate from systems-file // Map of all US English virtual key codes that we can translate // US Keys: Q W E R T Y U I O P A S D F G H J K L Z X C V B N M @@ -69,7 +69,6 @@ const DWORD VKMap_US_Keycode[] = { 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 , const char VKMap_US_Keysym[] = { 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '0'}; - #if defined(_WIN32) || defined(_WIN64) int wmain(int argc, wchar_t* argv[]) { std::vector str_argv_16 = convert_argvW_to_Vector_u16str( argc, argv); @@ -220,7 +219,7 @@ KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { KMX_LogError(L"Keyboard is not a mnemonic layout keyboard"); return FALSE; } - +/* bool get_OtherKeysym_From_US_Keysym(v_str_3D &All_Vector,int inUS,int &outOther){ //MyCoutW(L" #### get_OtherKeysym_From_US_Keysym of keymap started", 1); @@ -246,6 +245,43 @@ bool get_OtherKeysym_From_US_Keysym(v_str_3D &All_Vector,int inUS,int &outOther) return true; } +*/ + + +// takes capital letter of US returns cpital character of Other keyboard +int KMX_VKUSToVKUnderlyingLayout(v_str_3D &All_Vector,int inUS) { + // loop and find char in US; then find char of Other + for( int i=0; i< (int)All_Vector[1].size();i++) { + for( int j=0; j< (int)All_Vector[1][0].size();j++) { + int KeysymUS = (int) *All_Vector[0][i][j].c_str(); + if( inUS == KeysymUS ) { + if(All_Vector[1][i].size() >2 ) { + int KeysymOther = (int) *All_Vector[1][i][2].c_str(); + return KeysymOther; + } + } + } + } + return inUS; +} + +// takes cpital character of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] +KMX_WCHAR KMX_CharFromVK(v_str_3D &All_Vector,int vkUnderlying, WCHAR VKShiftState, KMX_WCHAR* DeadKey){ + // loop and find vkUnderlying in Other; then return char with correct shiftstate + for( int i=0; i< (int)All_Vector[1].size();i++) { + for( int j=0; j< (int)All_Vector[1][0].size();j++) { + int CharOther = (int) *All_Vector[1][i][j].c_str(); + if( vkUnderlying == CharOther ) { + int CharOtherShifted = (int) *All_Vector[1][i][VKShiftState].c_str(); + return CharOtherShifted; + } + } + } + return vkUnderlying; +} + + + bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]){ // get keymap of keyboard layout in use @@ -287,7 +323,7 @@ bool createVectorForBothKeyboards(v_str_3D &All_Vector,GdkKeymap *keymap){ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]) { - KMX_WCHART DeadKey; + KMX_WCHAR DeadKey; if(!KMX_SetKeyboardToPositional(kbd)) return FALSE; @@ -297,7 +333,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon // evident for the 102nd key on UK, for example, where \ can be generated with VK_OEM_102 or AltGr+VK_QUOTE. // For now, we get the least shifted version, which is hopefully adequate. - // first version with GTK - change later to XklGetGroupNames und XklGetCurrentState as Eberhard suggested + // _S2 first version with GTK - change later to XklGetGroupNames und XklGetCurrentState as Eberhard suggested //_ init gdk GdkKeymap *keymap; if(InitializeGDK(&keymap , argc, argv) ) @@ -311,21 +347,15 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon //-------------------------------------------------------------------------------- - for (int j = 0; VKShiftState[j] != 0xFFFF; j++) { // I4651 + for (int j = 1; VKShiftState[j] != 0xFFFF; j++) { // I4651 // Go through each possible key on the keyboard for (int i = 0;VKMap_US_Keysym[i]; i++) { // I4651 + int vkUnderlying = KMX_VKUSToVKUnderlyingLayout(All_Vector,(int) VKMap_US_Keysym[i] ); + wprintf(L" !!!!! KMX_VKUSToVKUnderlyingLayout xx in: :%i ---> %i " , (int) VKMap_US_Keysym[i], vkUnderlying ); - //wprintf(L" +++++++ VKMap_US_Keycode Nr: %i , i \n", i, VKMap_US_Keycode[i]); - // _S2 why not merging the 2 functions KMX_VKUSToVKUnderlyingLayout, CharFromVK? - // UINT vkUnderlying = KMX_VKUSToVKUnderlyingLayout(VKMap_US_Keycode[i], display); - - int vkUnderlying; - //wprintf(L" ########: will steart with 1 get_US_Keysym_From_OtherKeysym inxx: %i outxx: \n", VKMap_US_Keysym[i]); - bool ranOK = get_OtherKeysym_From_US_Keysym(All_Vector,(int) VKMap_US_Keysym[i],vkUnderlying ); - - //wprintf(L" +++++++ back from KMX_VKUSToVKUnderlyingLayout: %i \n", vkUnderlying); - // WCHAR ch = CharFromVK(vkUnderlying, VKShiftState[j], &DeadKey); + KMX_WCHAR ch = KMX_CharFromVK(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey); + wprintf(L" ( %i ) --- :%i ---- > %i ( %i)\n", VKShiftState[j] , vkUnderlying, ch , ( vkUnderlying-ch)); } } From 1da2ef3d27255078cc1b25eec09fce0cdb00cf02 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 24 Jul 2023 18:55:12 +0200 Subject: [PATCH 062/327] feature-(linux): mcompile remove unneccassary code --- linux/mcompile/keymap/keymap.cpp | 571 +---------------------------- linux/mcompile/keymap/keymap.h | 73 +--- linux/mcompile/keymap/mcompile.cpp | 130 ++++--- 3 files changed, 108 insertions(+), 666 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 603579d759..11ef9be0ca 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -29,7 +29,6 @@ int dummytest_keymap(){ bool write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { - //MyCoutW(L" #### write_US_ToVector of keymap started", 1); // _S2 relative path !! std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; @@ -55,7 +54,6 @@ bool write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { } wprintf(L" +++++++ dimensions of Vector after write_US_ToVector (languages..characters..shiftstates)\t\t %li..%li..%li\n", vec.size(), vec[0].size(),vec[0][0].size()); - //MyCoutW(L" #### write_US_ToVector of keymap ended", 1); fclose(fp); return 0; } @@ -64,7 +62,6 @@ bool CreateCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, // in the Configuration file we find the appopriate paragraph between "xkb_symbol " and the next xkb_symbol // and then copy all rows starting with "key <" to a v1D-Vector - //MyCoutW(L" #### CreateCompleteRow_US of keymap started", 1); int buffer_size = 512; char buffer[buffer_size]; bool print_OK = false; @@ -103,7 +100,6 @@ bool CreateCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, return 1; } - //MyCoutW(L" #### CreateCompleteRow_US of keymap ended", 1); return 0; } @@ -322,6 +318,24 @@ int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) return out; } +bool test(v_str_3D &V) { + + printf("+++++++ dimensions of Vector in test()\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); + printf("\n+++++++++ print some characters of US and Other +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + + for ( int k=0; k<(int)V[0].size(); k++) { + std::cout << " row 1 (US)......" << V[0][k][0]<< ".." << V[0][k][1]<< ".."<< "..\n" ; + if (V.size()>1) + std::cout << " row 1 (Other).."<< V[1][k][0]<< ".." << V[1][k][1]<< ".."<< "..\n" ; + } + printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + + return true; +} + + +// _S2 unused +/* bool extract_difference( v_str_3D &All_Vector) { MyCoutW(L" #### extract_difference of keymap started", 1); @@ -366,7 +380,7 @@ bool extract_difference( v_str_3D &All_Vector) { MyCoutW(L" #### extract_difference of keymap ended", 1); return 0; } - +*//* std::string get_Other_Char_FromUS( std::string in , v_str_3D &All_Vector) { std::wstring diff; @@ -433,21 +447,6 @@ std::string getKeyNrOf_OtherChar(std::string in , v_str_3D &All_Vector) { return "-"; } -bool test(v_str_3D &V) { - - printf("+++++++ dimensions of Vector in test()\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); - printf("\n+++++++++ print some characters of US and Other +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - - for ( int k=0; k<(int)V[0].size(); k++) { - std::cout << " row 1 (US)......" << V[0][k][0]<< ".." << V[0][k][1]<< ".."<< "..\n" ; - if (V.size()>1) - std::cout << " row 1 (Other).."<< V[1][k][0]<< ".." << V[1][k][1]<< ".."<< "..\n" ; - } - printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - - return true; -} - void test_in_out(v_str_3D &All_Vector) { std::string diff; @@ -507,536 +506,4 @@ void test_specific_Characters(v_str_3D &All_Vector) { out = get_Other_Char_FromUS(in[i], All_Vector); } } - -/*int run_DoConvert_Part1_getMap(gint argc, gchar *argv[]) { - - MyCoutW(L"#### run_DoConvert_Part1_getMap of keymap started", 1); - - gdk_init(&argc, &argv); - GdkDisplay *display = gdk_display_get_default(); - if (!display) { - printf("ERROR: can't get display\n"); - return 1; - } - GdkKeymap *keymap = gdk_keymap_get_for_display(display); - if (!keymap) { - printf("ERROR: Can't get keymap\n"); - gdk_display_close(display); - return 2; - } - - MyCoutW(L" # Top checks of keymap OK", 1); - - // write content of xkb_symbols to 3D Vector - // I assume we use Keyboard US basic as base - - // All_Vector[ language ][ Key ][ shiftstate ] - // we use a 3D vector All_Vector to store the Character values of the US keyboard and the "Other" Keyboard. - // All_Vector[ 0 ][..][..] and All_Vector[ 1 ][..][..] hold the name of the key which is the same for both keyboards(US and Other) - // e.g. All_Vector[ 0 ][..][ 0 ] = "y" for the US-Keyboard (0: unshifted) - // All_Vector[ 1 ][..][ 0 ] = "z" for the Other Keyboard (german in this case) (0: unshifted) - // All_Vector[ 0 ][..][ 1 ] = "Y" for the US-Keyboard (1: shifted) - // All_Vector[ 1 ][..][ 1 ] = "Z" for the Other Keyboard (german in this case) (1: shifted) - - std::string US_language = "us"; - const char* text_us = "xkb_symbols \"basic\""; - - v_str_3D All_Vector; - if(write_US_ToVector(All_Vector,US_language, text_us)) { - printf("ERROR: can't write US to Vector \n"); - return 1; - } - test(All_Vector); - - //MyCoutW(L" # write_US_ToVector of keymap OK", 1); - // add contents of other keyboard to All_Vector - if( append_other_ToVector(All_Vector,keymap)) { - printf("ERROR: can't append other ToVector \n"); - return 1; - } - test(All_Vector); - - //MyCoutW(L" # append_other_ToVector of keymap OK", 1); - - if( extract_difference(All_Vector)) { - printf("ERROR: can't extract difference \n"); - return 1; - } - - test_in_out(All_Vector); - print_simple_map_US(All_Vector,1); // 1 = non-shift, 2 = shift - print_simple_map_Other(All_Vector,2); // 1 = non-shift, 2 = shift - test_specific_Characters(All_Vector); - - gdk_display_close(display); - - MyCoutW(L"#### run_DoConvert_Part1_getMap of keymap ended", 1); - printf("°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° end\n"); - return 0; -} -*/ -//-------------------------------------- - -// old ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -/* -static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) -{ - GdkKeymapKey *maps; - guint *keyvals; - gint count; - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return; - - for (int i = 0; i < count; i++) { - if (maps[i].level > 0 || maps[i].group > 1) - continue; - printf(" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); - } - - g_free(keyvals); - g_free(maps); -} -*/ -/* -void write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { - // ? CHECK if ran OK-> return 0/1 - std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; - - const char* path = FullPathName.c_str(); - FILE* fp = fopen((path), "r"); - if ( !fp) - printf("could not open file!"); - - // create 1D-vector of the complete line - v_str_1D Vector_completeUS; - CreateCompleteRow_US(Vector_completeUS,fp , text, language); - - // split contents of 1D Vector to 3D vector - Split_US_To_3D_Vector( vec,Vector_completeUS); - - printf("+++++++ dimensions of Vector after write_US_ToVector\t\t %li..%li..%li\n", vec.size(), vec[0].size(),vec[0][0].size()); - fclose(fp); -} - -void CreateCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, std::string language) { - // in the Configuration file we find the appopriate paragraph between "xkb_symbol " and the next xkb_symbol - // and then copy all rows starting with "key <" to a v1D-Vector - - // ? CHECK if ran OK-> return 0/1 - int buffer_size = 512; - char buffer[buffer_size]; - bool print_OK = false; - const char* key = "key <"; - std::string str_txt(text); - std::string xbk_mark = "xkb_symbol"; - // TODO define folder to store File in - std::ofstream KeyboardFile("File_" + language + ".txt"); - - printf("Keyboard %s\n", text); - KeyboardFile << "Keyboard" << text << "\n"; - - if (fp) { - while (fgets(buffer, buffer_size, fp) != NULL) { - std::string str_buf(buffer); - - // stop when finding the mark xkb_symbol - if (std::string(str_buf).find(xbk_mark) != std::string::npos) - print_OK = false; - - // start when finding the mark xkb_symbol + correct layout - if ((std::string(str_buf).find(str_txt) != std::string::npos)) - print_OK = true; - - // as long as we are in the same xkb_symbol layout block and find "key <" we push the whole line into a 1D-vector - if ((print_OK) && (std::string(str_buf).find(key) != std::string::npos)) { - printf("%s", buffer); - complete_List.push_back(buffer); - KeyboardFile << buffer; - } - } - } - printf("-°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° \n"); -} - -void Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList) { - // 1: take the whole line of the 1D-Vector and remove unwanted characters. - // 2: seperate the name e.g. key and the shiftstates - // 3: push Names/Shiftstates to shift_states and then shiftstates to All_US, our 3D-Vector holding all Elements - - // ? CHECK if ran OK-> return 0/1 - std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; - char split_bracel = '{'; - char split_char_komma = ','; - std::string empty = "--"; - v_str_1D tokens; - v_str_2D shift_states; - - // go through the whole vector - for (int k = 0; k < (int)completeList.size() - 1; k++) { - - // remove all unwanted char - for (int i = 0; i < (int) delim.size(); i++) { - completeList[k].erase(remove(completeList[k].begin(), completeList[k].end(), delim[i]), completeList[k].end()); - } - - // only lines with ("key<.. are of interest - if (completeList[k].find("key<") != std::string::npos) { - - //split off the key names - std::istringstream split1(completeList[k]); - for (std::string each; std::getline(split1, each, split_bracel); tokens.push_back(each)); - - // replace keys names with number ( with 29,...) - - // ? CHECK if ran OK-> return 0/1 - int Keycde = replace_PosKey_with_Keycode(tokens[0]); - tokens[0] = std::to_string(Keycde); - - // seperate rest of the vector to its elements and push to 'tokens' - std::istringstream split(tokens[1]); - tokens.pop_back(); - for (std::string each; std::getline(split, each, split_char_komma); tokens.push_back(each)); - //printf("### 5 Split_US_To_3D_Vector: tokens: size:%li...tokens[0]-[4]:-name:%s\tShiftstates:%s--%s--%s--%s---.\n", tokens.size(),tokens[0].c_str(),tokens[1].c_str(),tokens[2].c_str(),tokens[3].c_str(),tokens[4].c_str()); - - // at the moment we only use the first 2 shiftstates (non-shift+shift) so get rid of all others - int surplus = tokens.size() - shift_state_count -1; - for( int j=0; j < surplus;j++) { - tokens.pop_back(); - } - - // now push result to shift_states - shift_states.push_back(tokens); - tokens.clear(); - } - } - all_US.push_back(shift_states); - - // ? CHECK if ran OK, vector size is correct -> return 0/1 - //printf("### 6 Split_US_To_3D_clearVector %li..%li..%li\n", all_US.size(), all_US[0].size(),all_US[0][0].size()); -} - -int replace_PosKey_with_Keycode(std::string in) { - int out=0; - if ( in == "key") out = 49; //correct ??? - else if ( in == "key") out = 10; - else if ( in == "key") out = 11; - else if ( in == "key") out = 12; - else if ( in == "key") out = 13; - else if ( in == "key") out = 14; - else if ( in == "key") out = 15; - else if ( in == "key") out = 16; - else if ( in == "key") out = 17; - else if ( in == "key") out = 18; - else if ( in == "key") out = 19; - else if ( in == "key") out = 20; - else if ( in == "key") out = 21; - - else if ( in == "key") out = 24; - else if ( in == "key") out = 25; - else if ( in == "key") out = 26; - else if ( in == "key") out = 27; - else if ( in == "key") out = 28; - else if ( in == "key") out = 29; - else if ( in == "key") out = 30; - else if ( in == "key") out = 31; - else if ( in == "key") out = 32; - else if ( in == "key") out = 33; - else if ( in == "key") out = 34; - else if ( in == "key") out = 35; - - else if ( in == "key") out = 38; - else if ( in == "key") out = 39; - else if ( in == "key") out = 40; - else if ( in == "key") out = 41; - else if ( in == "key") out = 42; - else if ( in == "key") out = 43; - else if ( in == "key") out = 44; - else if ( in == "key") out = 45; - else if ( in == "key") out = 46; - else if ( in == "key") out = 47; - else if ( in == "key") out = 48; - else if ( in == "key") out = 49; - - else if ( in == "key") out = 52; - else if ( in == "key") out = 53; - else if ( in == "key") out = 54; - else if ( in == "key") out = 55; - else if ( in == "key") out = 56; - else if ( in == "key") out = 57; - else if ( in == "key") out = 58; - else if ( in == "key") out = 59; - else if ( in == "key") out = 60; - else if ( in == "key") out = 61; - else if ( in == "key") out = 62; //correct ??? - else if ( in == "key") out = 51; //correct ??? - return out; -} - -void append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap) { - - // create a 2D vector all fill0ed with "--" and push to 3D-Vector - // ? CHECK if ran OK-> return 0/1 - v_str_2D Other_Vector2D = create_empty_2D(All_Vector[0].size(),All_Vector[0][0].size()); - All_Vector.push_back(Other_Vector2D); - - printf("+++++++ dimensions of Vector after append_other_ToVector\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); - - for(int i =1; i< (int) All_Vector[1].size()-1;i++) - { - // get key name US stored in [0][i][0] and copy to name in other-block[1][i][0] - All_Vector[1][i][0] = All_Vector[0][i][0]; - - // write this value to 3D- Vector - All_Vector[1][i][0+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),0); //shift state: unshifted:0 - All_Vector[1][i][1+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),1); //shift state: shifted:1 - //printf("Keycodes US->Other: %d(US): %s %s ---- (other):%s, %s, %s \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str(),All_Vector[1][i][2].c_str(),All_Vector[1][i][3].c_str()); - } - // ? CHECK if ran OK, vector size is correct -> return 0/1 -} - -v_str_2D create_empty_2D( int dim_rows,int dim_shifts) -{ - std::string empty = "--"; - v_str_1D shifts; - v_str_2D all; - - for ( int i=0; i< dim_rows;i++) { - for ( int j=0; j< dim_shifts;j++) { - shifts.push_back(empty); - } - all.push_back(shifts); - shifts.clear(); - } - //printf("+++++++ dimensions of Vector after create_empty_2D\t\t %li..%li..%li\n", all.size(), all[0].size(),all[1].size()); - return all; -} - -int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { - GdkKeymapKey *maps; - guint *keyvals; - gint count; - int out; - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return 0; - //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - // return 0; - - if (!(shift_state_pos < count)) - return 0; - - out = keyvals[shift_state_pos]; - - g_free(keyvals); - g_free(maps); - return out; -} - -void extract_difference( v_str_3D &All_Vector) -{ - // ? CHECK if ran OK-> return 0/1 - // TODO define which Folder; find better name - std::ofstream Map_File("Map_US.txt"); - std::string diff =" "; - - printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); - std::cout << "Nr of \n" ; - std::cout << "Key: " << "\t Character US (no shift) " << " Character US (shift) "<< "\t\tCharacter other (no shift)" << "\tCharacter other (shift) difference \n" ; - printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); - - Map_File <<"--------------------------------------------------------------------------------------------------------------------------------------------\n"; - Map_File << "Nr of \n" ; - Map_File << "Key: " << "\t Character US (no shift) " << " Character US (shift) "<< "\t\tCharacter other (no shift)" << "\tCharacter other (shift) difference \n" ; - Map_File <<"--------------------------------------------------------------------------------------------------------------------------------------------\n"; - - for ( int k=0; k<(int)All_Vector[0].size()-1; k++) { - if (All_Vector[0][k][1] == All_Vector[1][k][1]) - diff =" "; - else - diff =" *** "; - // ? CHECK if index exists - std::cout << All_Vector[0][k][0] << "\t " <<+(*(All_Vector[0][k][1].c_str()))<< "\t("<< All_Vector[0][k][1] <<")"< Other: "<< std::setw(5)< Other: (" << in << ": no match)\n"; - return "-"; -} - -std::string get_US_Char_FromOther(std::string in , v_str_3D &All_Vector) { - std::string diff; - // find correct row of char in other - for( int i=0; i< (int)All_Vector[1].size()-1;i++) { - for( int j=0; j< (int)All_Vector[1][0].size()-1;j++) { - if ( All_Vector[1][i][j] == in ) { - if ( All_Vector[0][i][j] != All_Vector[1][i][j]) - diff =" ** "; - // ? CHECK if Index exists - std::cout << "Other -> US: "<< std::setw(5)< US: (" << in << ": no match)\n"; - return "-"; - } - -std::string getKeyNrOf_USChar(std::string in , v_str_3D &All_Vector) { - // find correct row of char in US - for( int i=0; i< (int)All_Vector[0].size()-1;i++) { - for( int j=0; j< (int)All_Vector[0][0].size()-1;j++) { - if ( All_Vector[0][i][j] == in ) { - // ? CHECK if index exists - std::cout << "KeyNr of US char: \t"<< All_Vector[0][i][j] << " -> " << All_Vector[0][i][0] <<"\n"; - return All_Vector[0][i][0] ; - } - } - } - return "-"; -} - -std::string getKeyNrOf_OtherChar(std::string in , v_str_3D &All_Vector) { - // find correct row of char in US - for( int i=0; i< (int)All_Vector[1].size()-1;i++) { - for( int j=0; j< (int)All_Vector[1][0].size()-1;j++) { - if ( All_Vector[1][i][j] == in ) { - // ? CHECK if index exists - std::cout << "KeyNr of Other char : \t"<< All_Vector[1][i][j] << " -> " << All_Vector[1][i][0] <<"\n"; - return All_Vector[1][i][0] ; - } - } - } - return "-"; -} - -bool test(v_str_3D &V) { -// ? CHECK if index exists - printf("\n+++++++++ print some characters of US and Other +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - - for ( int k=13; k<43; k++) { - std::cout << " row 1 (US)......" << V[0][k][0]<< ".." << V[0][k][1]<< ".."<< V[0][k][2]<< ".." << V[0][k][3]<< ".." << V[0][k][4]<< "..\n" ; - if (V.size()>1) - std::cout << " row 1 (Other).."<< V[1][k][0]<< ".." << V[1][k][1]<< ".."<< V[1][k][2]<< ".." << V[1][k][3]<< ".." << V[1][k][4]<< "..\n" ; - } - printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - return true; -} - -void test_in_out(v_str_3D &All_Vector) { -std::string diff; - printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); - //checks mapping between US and other - std::string a = get_Other_Char_FromUS( "z", All_Vector); - std::string aa = get_Other_Char_FromUS( "Z", All_Vector); - std::string aaa = get_Other_Char_FromUS( "y", All_Vector); - std::string aaaa = get_Other_Char_FromUS( "Y", All_Vector); - - std::string b = get_US_Char_FromOther( "z", All_Vector); - std::string bb = get_US_Char_FromOther( "Z", All_Vector); - std::string bbb = get_US_Char_FromOther( "y", All_Vector); - std::string bbbb = get_US_Char_FromOther( "Y", All_Vector); - - std::string c = getKeyNrOf_OtherChar( "z", All_Vector); - std::string cc = getKeyNrOf_OtherChar( "Z", All_Vector); - std::string ccc = getKeyNrOf_OtherChar( "y", All_Vector); - std::string cccc = getKeyNrOf_OtherChar( "Y", All_Vector); - - std::string d = getKeyNrOf_USChar( "z", All_Vector); - std::string dd = getKeyNrOf_USChar( "Z", All_Vector); - std::string ddd = getKeyNrOf_USChar( "y", All_Vector); - std::string dddd = getKeyNrOf_USChar( "Y", All_Vector); - - std::cout << "get_Other_Char_FromUS z-Z-y-Y: " << ".." << a<< ".." < return 0/1 - printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); - for ( int i=0; i< (int)All_Vector[0].size();i++) { - out =get_Other_Char_FromUS(All_Vector[0][i][shiftstate], All_Vector); - } -} - -void print_simple_map_Other(v_str_3D &All_Vector, int shiftstate){ - std::string out, diff; - // ? CHECK if ran OK-> return 0/1 - printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); - for ( int i=0; i< (int)All_Vector[0].size();i++) { - out = get_US_Char_FromOther(All_Vector[0][i][shiftstate], All_Vector); - } -} - -void test_specific_Characters(v_str_3D &All_Vector){ - printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); - v_str_1D in {"a", "b", "m", "w", "x", "y", "z"}; - std::string out; - for( int i=0; i< (int) in.size()-1; i++) { - out = get_Other_Char_FromUS(in[i], All_Vector); - } -} - - -//-------------------------------------- -int main(gint argc, gchar *argv[]) -{ - gdk_init(&argc, &argv); - GdkDisplay *display = gdk_display_get_default(); - if (!display) { - printf("ERROR: can't get display\n"); - return 1; - } - GdkKeymap *keymap = gdk_keymap_get_for_display(display); - if (!keymap) { - printf("ERROR: Can't get keymap\n"); - gdk_display_close(display); - return 2; - } - - // write content of xkb_symbols to 3D Vector - // I assume we use Keyboard US basic as base - std::string US_language = "us"; - const char* text_us = "xkb_symbols \"basic\""; - - v_str_3D All_Vector; - write_US_ToVector(All_Vector,US_language, text_us); - //test(All_Vector); - - // add contents of other keyboard to vector - append_other_ToVector(All_Vector,keymap); - //test(All_Vector); - - extract_difference(All_Vector); - //test_in_out(All_Vector); - - //print_simple_map_US(All_Vector,1); // 1 = non-shift - //print_simple_map_Other(All_Vector,1); // 1 = non-shift - test_specific_Characters(All_Vector); - gdk_display_close(display); - - printf("°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° end\n"); - return 0; -} */ \ No newline at end of file diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 1552948748..d8f7892b1c 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -27,11 +27,6 @@ typedef std::vector > v_str_2D; typedef std::vector > > v_str_3D; static int shift_state_count = 2; // use shiftstate : no shift, shift -/* -int run_DoConvert_Part1_getMap(gint argc, gchar *argv[]); -*/ -// adapt from mc_kmxfile.cpp -void LoadKeyboard(); // initialize GDK bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); @@ -39,9 +34,6 @@ bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); // create a Vector with all entries of both keymaps bool createVectorForBothKeyboards(v_str_3D &All_Vector,GdkKeymap *keymap); -// use TranslateKeyboard, TranslateGroup,TranslateKey from mcompile -void run_DoConvert_Part2_TranslateKeyboard(); - // read configuration file, split and write to 3D-Vector (Data for US on [0][ ][ ] ) bool write_US_ToVector(v_str_3D &vec, std::string language, const char *text); @@ -66,6 +58,10 @@ v_str_2D create_empty_2D(int dim_rows, int dim_shifts); // find Keyvals to fill into 2D-Vector of Other Language int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos); +// testing of Vector contents ( first row of US and Other) +bool test(v_str_3D &V); + +/* // print both sets of characters (US and OtherLanguage) to console and file for comparison bool extract_difference(v_str_3D &All_Vector); @@ -85,67 +81,8 @@ void print_simple_map_US(v_str_3D &All_Vector, int shiftstate); void print_simple_map_Other(v_str_3D &All_Vector, int shiftstate); // test of above functions (character mapping US <-> Other; KeyNr <-> CHaracter) void test_in_out(v_str_3D &All_Vector); -// testing of Vector contents ( first row of US and Other) -bool test(v_str_3D &V); // writing out mapping of some characters: a,b,m,w,x,y,z void test_specific_Characters(v_str_3D &All_Vector); - - -// old ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -/* - -#include "mc_kmxfile.h" -#include "mc_savekeyboard.h" - -typedef std::vector v_str_1D; -typedef std::vector > v_str_2D; -typedef std::vector > > v_str_3D; - -int shift_state_count = 2; // use shiftstate : no shift, shift - -// read configuration file, split and write to 3D-Vector (Data for US on [0][ ][ ] ) -void write_US_ToVector(v_str_3D &vec, std::string language, const char *text); - -// 1. step: read complete Row of Configuration file US -void CreateCompleteRow_US(v_str_1D &complete_List, FILE *fpp, const char *text, std::string language); - -// 2nd step: write contents to 3D vector -void Split_US_To_3D_Vector(v_str_3D &all_US, v_str_1D completeList); - -// replace Name of Key (e.g. ) wih Keycode ( e.g. 15 ) -int replace_PosKey_with_Keycode(std::string in); - -// append characters using GDK to 3D-Vector (Data for Other Language on [1][ ][ ] ) -void append_other_ToVector(v_str_3D &All_Vector, GdkKeymap *keymap); - -// create an empty 2D vector containing "--" in all fields -v_str_2D create_empty_2D(int dim_rows, int dim_shifts); - -// find Keyvals to fill into 2D-Vector of Other Language -int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos); - -// print both sets of characters (US and OtherLanguage) to console and file for comparison -void extract_difference(v_str_3D &All_Vector); - -// get mapped key from Other (Other->US) -std::string get_Other_Char_FromUS(std::string in, v_str_3D &All_Vector); -// get mapped key from US->Other (US->Other) -std::string get_US_Char_FromOther(std::string in, v_str_3D &All_Vector); -// get KeyNr from US -std::string getKeyNrOf_USChar(std::string in, v_str_3D &All_Vector); -// get KeyNr from Other -std::string getKeyNrOf_OtherChar(std::string in, v_str_3D &All_Vector); - -// for testing/debugging - may be deleted later -// prints out a 1:1 mapping US->Other -void print_simple_map_US(v_str_3D &All_Vector, int shiftstate); -// prints out a 1:1 mapping Other->US -void print_simple_map_Other(v_str_3D &All_Vector, int shiftstate); -// test of above functions (character mapping US <-> Other; KeyNr <-> CHaracter) -void test_in_out(v_str_3D &All_Vector); -// testing of Vector contents ( first row of US and Other) -bool test(v_str_3D &V); -// writing out mapping of some characters: a,b,m,w,x,y,z -void test_specific_Characters(v_str_3D &All_Vector);*/ +*/ # endif /*KEYMAP_H*/ diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index b06c05a317..185ae6f97a 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -53,22 +53,6 @@ mcompile -d runs 4 important steps: KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]); -// -// Map of all shift states that we will work with -// -//const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; -const UINT VKShiftState[] = {0, 1, 2,0xFFFF}; -// _S2 shiftstate from systems-file - -// Map of all US English virtual key codes that we can translate -// US Keys: Q W E R T Y U I O P A S D F G H J K L Z X C V B N M -const DWORD VKMap_US_Keycode[] = { 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 , 33 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 52 , 53 , 54 , 55 , 56 , 57 , 77 ,0}; - -// Map of all US English virtual key codes that we can translate -// US Keys: 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 , 33 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 47, 52 , 53 , 54 , 55 , 56 , 57 , 77 , 0 -const char VKMap_US_Keysym[] = { 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '0'}; - - #if defined(_WIN32) || defined(_WIN64) int wmain(int argc, wchar_t* argv[]) { std::vector str_argv_16 = convert_argvW_to_Vector_u16str( argc, argv); @@ -196,7 +180,38 @@ wprintf(L"_S2 * Up to here cross-platform xx :-))))) ************************** return 0 ; } +/*// Map of all US English virtual key codes that we can translate +// +const WORD VKMap[] = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + VK_SPACE, + VK_ACCENT, VK_HYPHEN, VK_EQUAL, + VK_LBRKT, VK_RBRKT, VK_BKSLASH, + VK_COLON, VK_QUOTE, + VK_COMMA, VK_PERIOD, VK_SLASH, + VK_xDF, VK_OEM_102, + 0 +}; +*/ +// Map of all US English virtual key codes that we can translate +// US Keys: Q W E R T Y U I O P A S D F G H J K L Z X C V B N M +const DWORD VKMap_US_Keycode[] = { 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 , 33 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 52 , 53 , 54 , 55 , 56 , 57 , 77 ,0}; + +// Map of all US English virtual key codes that we can translate +// US Keys: 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 , 33 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 47, 52 , 53 , 54 , 55 , 56 , 57 , 77 , 0 +const char VKMap_US_Keysym[] = { 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '0'}; + +// Map of all shift states that we will work with +// +//const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; +const UINT VKShiftState[] = {0, 1, 2,0xFFFF}; +// _S2 shiftstate from systems-file + +void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, DWORD vk, UINT shift, KMX_WCHAR ch) { + wprintf(L"KMX_TranslateKeyboard not implemented yet\n"); +} KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { LPKMX_STORE sp; @@ -219,34 +234,6 @@ KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { KMX_LogError(L"Keyboard is not a mnemonic layout keyboard"); return FALSE; } -/* -bool get_OtherKeysym_From_US_Keysym(v_str_3D &All_Vector,int inUS,int &outOther){ - - //MyCoutW(L" #### get_OtherKeysym_From_US_Keysym of keymap started", 1); - // loop and find char in US; then find char of Other - for( int i=0; i< (int)All_Vector[1].size();i++) { - for( int j=0; j< (int)All_Vector[1][0].size();j++) { - - int KeysymUS = (int) *All_Vector[0][i][j].c_str(); - int KeysymOther = (int) *All_Vector[1][i][j].c_str(); - std::wstring KeysymUS_wstr = wstring_from_string(All_Vector[0][i][j]); - - if( inUS == KeysymUS ) { - //wprintf(L" FOUND Value in OTHER !!!!! : Other in: %i ( %s ) -- Keycode : %s -- US out ########: %i ( %s ) \n", KeysymUS,All_Vector[0][i][j].c_str(), All_Vector[1][i][0].c_str() , KeysymOther,All_Vector[1][i][j].c_str()); - wprintf(L" get_OtherKeysym_From_US_Keysym FOUND Value in US !!!!! : Other in: %i ( %s ) -- Keycode : %s -- US out ########: %i ( %s ) \n", - KeysymUS,All_Vector[0][i][j].c_str(), All_Vector[1][i][0].c_str() , KeysymOther,All_Vector[1][i][j].c_str()); - outOther = KeysymOther; - - //MyCoutW(L" #### get_OtherKeysym_From_US_Keysym of keymap ended", 1); - return true; - } - } - } - return true; -} - -*/ - // takes capital letter of US returns cpital character of Other keyboard int KMX_VKUSToVKUnderlyingLayout(v_str_3D &All_Vector,int inUS) { @@ -281,7 +268,6 @@ KMX_WCHAR KMX_CharFromVK(v_str_3D &All_Vector,int vkUnderlying, WCHAR VKShiftSta } - bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]){ // get keymap of keyboard layout in use @@ -302,6 +288,7 @@ bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]){ return 0; } + bool createVectorForBothKeyboards(v_str_3D &All_Vector,GdkKeymap *keymap){ std::string US_language = "us"; @@ -321,6 +308,7 @@ bool createVectorForBothKeyboards(v_str_3D &All_Vector,GdkKeymap *keymap){ return 0; } + KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]) { KMX_WCHAR DeadKey; @@ -355,7 +343,25 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon wprintf(L" !!!!! KMX_VKUSToVKUnderlyingLayout xx in: :%i ---> %i " , (int) VKMap_US_Keysym[i], vkUnderlying ); KMX_WCHAR ch = KMX_CharFromVK(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey); - wprintf(L" ( %i ) --- :%i ---- > %i ( %i)\n", VKShiftState[j] , vkUnderlying, ch , ( vkUnderlying-ch)); + wprintf(L" ( %i ) --- :%i ---- > %i ( %i)\n", VKShiftState[j] , vkUnderlying, ch , ( vkUnderlying-ch)); + + //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); + + if(bDeadkeyConversion) { // I4552 + if(ch == 0xFFFF) { + ch = DeadKey; + } + } + + switch(ch) { + case 0x0000: break; + // _S2 deadkeys will be done later + //case 0xFFFF: ConvertDeadkey(kbd, VKMap[i], VKShiftState[j], DeadKey); break; + + //default: TranslateKeyboard(kbd, VKMap[i], VKShiftState[j], ch); + default: KMX_TranslateKeyboard(kbd, VKMap_US_Keysym[i], VKShiftState[j], ch); + } + } } @@ -369,10 +375,42 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon return TRUE; } + void KMX_LogError(const KMX_WCHART* m1,int m2) { wprintf((PWSTR)m1, m2); } + +/* unused _S2 + +bool get_OtherKeysym_From_US_Keysym(v_str_3D &All_Vector,int inUS,int &outOther){ + + //MyCoutW(L" #### get_OtherKeysym_From_US_Keysym of keymap started", 1); + // loop and find char in US; then find char of Other + for( int i=0; i< (int)All_Vector[1].size();i++) { + for( int j=0; j< (int)All_Vector[1][0].size();j++) { + + int KeysymUS = (int) *All_Vector[0][i][j].c_str(); + int KeysymOther = (int) *All_Vector[1][i][j].c_str(); + std::wstring KeysymUS_wstr = wstring_from_string(All_Vector[0][i][j]); + + if( inUS == KeysymUS ) { + //wprintf(L" FOUND Value in OTHER !!!!! : Other in: %i ( %s ) -- Keycode : %s -- US out ########: %i ( %s ) \n", KeysymUS,All_Vector[0][i][j].c_str(), All_Vector[1][i][0].c_str() , KeysymOther,All_Vector[1][i][j].c_str()); + wprintf(L" get_OtherKeysym_From_US_Keysym FOUND Value in US !!!!! : Other in: %i ( %s ) -- Keycode : %s -- US out ########: %i ( %s ) \n", + KeysymUS,All_Vector[0][i][j].c_str(), All_Vector[1][i][0].c_str() , KeysymOther,All_Vector[1][i][j].c_str()); + outOther = KeysymOther; + + //MyCoutW(L" #### get_OtherKeysym_From_US_Keysym of keymap ended", 1); + return true; + } + } + } + return true; +} + +*/ + + // ---- old ---------------------------------------------------------- From 2d3d1065a982982af9e90f1c6998b6206e4a5f72 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 24 Jul 2023 18:56:26 +0200 Subject: [PATCH 063/327] feature-(linux): mcompile remove more unneccassary code --- linux/mcompile/keymap/keymap.cpp | 12 ------------ linux/mcompile/keymap/mc_kmxfile.cpp | 11 ----------- 2 files changed, 23 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 11ef9be0ca..b0029e1b92 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -108,7 +108,6 @@ bool Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList) { // 2: seperate the name e.g. key from the shiftstates // 3: push Names/Shiftstates to shift_states and then shiftstates to All_US, our 3D-Vector holding all Elements -//MyCoutW(L" #### Split_US_To_3D_Vector of keymap started", 1); std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; char split_bracel = '{'; char split_char_komma = ','; @@ -163,13 +162,10 @@ bool Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList) { printf("ERROR: Can't split US to 3D-Vector\n"); return 1; } - //MyCoutW(L" #### Split_US_To_3D_Vector of keymap ended", 1); - //printf("### 6 Split_US_To_3D_clearVector %li..%li..%li\n", all_US.size(), all_US[0].size(),all_US[0][0].size()); return 0; } bool foundCharacterInList(std::string tok) { - //MyCoutW(L" #### foundCharacterInList of keymap started", 1); //TOASK Do we need more and which? //US keys: Q W E R T Y U I O P A S D F G H J K L Z X C V B N M v_str_1D Keysyms { "24","25","26","27","28","29","30","31","32","33","38","39","40","41","42","43","44","45","46","52","53","54","55","56","57","58"}; @@ -180,8 +176,6 @@ bool foundCharacterInList(std::string tok) { return true; } } - - //MyCoutW(L" #### foundCharacterInList of keymap ended", 1); return false; } @@ -246,7 +240,6 @@ int replace_PosKey_with_Keycode(std::string in) { bool append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap) { - //MyCoutW(L" #### append_other_ToVector of keymap started", 1); // create a 2D vector all filled with "--" and push to 3D-Vector v_str_2D Other_Vector2D = create_empty_2D(All_Vector[0].size(),All_Vector[0][0].size()); @@ -274,8 +267,6 @@ bool append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap) { wprintf(L" Keycodes US->Other: %d (US):%s, %s ---- (other):%s, %s \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str(),All_Vector[1][i][2].c_str()); } - - //MyCoutW(L" #### append_other_ToVector of keymap ended", 1); return 0; } @@ -338,7 +329,6 @@ bool test(v_str_3D &V) { /* bool extract_difference( v_str_3D &All_Vector) { - MyCoutW(L" #### extract_difference of keymap started", 1); // TODO define which Folder; find better name std::ofstream Map_File("Map_US.txt"); std::string diff =" "; @@ -376,8 +366,6 @@ bool extract_difference( v_str_3D &All_Vector) { } Map_File.close(); - - MyCoutW(L" #### extract_difference of keymap ended", 1); return 0; } *//* diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 41ded295c0..784f87ac60 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -230,7 +230,6 @@ KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL return CERR_None; } - PKMX_WCHAR KMX_StringOffset(PKMX_BYTE base, KMX_DWORD offset) { if(offset == 0) return NULL; return (PKMX_WCHAR)(base + offset); @@ -246,7 +245,6 @@ PKMX_WCHAR KMX_StringOffset(PKMX_BYTE base, KMX_DWORD offset) { */ LPKMX_KEYBOARD KMX_CopyKeyboard(PKMX_BYTE bufp, PKMX_BYTE base) { - MyCoutW(L" #### KMX_CopyKeyboard of mc_kmxfile started", 1); PKMX_COMP_KEYBOARD ckbp = (PKMX_COMP_KEYBOARD) base; /* Copy keyboard structure */ @@ -319,8 +317,6 @@ LPKMX_KEYBOARD KMX_CopyKeyboard(PKMX_BYTE bufp, PKMX_BYTE base) kp->dpContext = KMX_StringOffset(base, ckp->dpContext); } } - - MyCoutW(L" #### KMX_CopyKeyboard of mc_kmxfile ended", 1); return kbp; } @@ -478,7 +474,6 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { KMX_LogError(L"LogError1: errFixupKeyboard\n" ); // _S2 delete [] buf; ???? - MyCoutW(L"##### errFixupKeyboard ", 1); return FALSE; } @@ -491,12 +486,10 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { } *lpKeyboard = kbp; // _S2 delete [] buf; ???? - MyCoutW(L"##### LoadKeyboard of mcompile ended #####", 1); return TRUE; } KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz){ - MyCoutW(L" #### KMX_VerifyKeyboard of mc_kmxfile started", 1); KMX_DWORD i; PKMX_COMP_KEYBOARD ckbp = (PKMX_COMP_KEYBOARD)filebase; PKMX_COMP_STORE csp; @@ -519,10 +512,6 @@ KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz){ KMX_LogError(L"LogErr1: errWrongFileVersion"); return FALSE; } - - MyCout("will return true", 1); - MyCoutW(L" #### KMX_VerifyKeyboard of mc_kmxfile ended", 1); - return TRUE; } From 128a281c094aae26ea8851f93aa289dbca7df6f2 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 25 Jul 2023 17:07:26 +0200 Subject: [PATCH 064/327] feature-(linux): mcompile edit wprintf --- linux/mcompile/keymap/mcompile.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 185ae6f97a..b9224f2453 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -210,7 +210,7 @@ const UINT VKShiftState[] = {0, 1, 2,0xFFFF}; // _S2 shiftstate from systems-file void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, DWORD vk, UINT shift, KMX_WCHAR ch) { - wprintf(L"KMX_TranslateKeyboard not implemented yet\n"); + //wprintf(L"KMX_TranslateKeyboard not implemented yet\n"); } KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { @@ -340,11 +340,10 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon // Go through each possible key on the keyboard for (int i = 0;VKMap_US_Keysym[i]; i++) { // I4651 int vkUnderlying = KMX_VKUSToVKUnderlyingLayout(All_Vector,(int) VKMap_US_Keysym[i] ); - wprintf(L" !!!!! KMX_VKUSToVKUnderlyingLayout xx in: :%i ---> %i " , (int) VKMap_US_Keysym[i], vkUnderlying ); KMX_WCHAR ch = KMX_CharFromVK(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey); - wprintf(L" ( %i ) --- :%i ---- > %i ( %i)\n", VKShiftState[j] , vkUnderlying, ch , ( vkUnderlying-ch)); + wprintf(L" KMX_VKUSToVKUnderlyingLayout/KMX_CharFromVK i: %i (VKMap_US_Keysym): %i (%c) ---> vkUnderlying: %i (%c) shiftstate: ( %i ) ---- > ch: %i (%c) ( %i) %ls\n" , i,(int) VKMap_US_Keysym[i],(int)VKMap_US_Keysym[i], vkUnderlying,vkUnderlying, VKShiftState[j] , ch ,ch , ( vkUnderlying-ch), ((int) vkUnderlying != (int) VKMap_US_Keysym[i] ) ? L" *** ": L""); //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); if(bDeadkeyConversion) { // I4552 From 4ff67ca9dbd2c299b7fabc835de538fa59c09406 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 25 Jul 2023 17:07:26 +0200 Subject: [PATCH 065/327] feat-(linux): mcompile edit agin --- linux/mcompile/keymap/mcompile.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 185ae6f97a..60b8d791f5 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -210,7 +210,7 @@ const UINT VKShiftState[] = {0, 1, 2,0xFFFF}; // _S2 shiftstate from systems-file void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, DWORD vk, UINT shift, KMX_WCHAR ch) { - wprintf(L"KMX_TranslateKeyboard not implemented yet\n"); + //wprintf(L"KMX_TranslateKeyboard not implemented yet\n"); } KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { @@ -332,7 +332,6 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon if(createVectorForBothKeyboards(All_Vector,keymap) ) printf("ERROR: can't createVectorForBothKeyboards\n"); - //-------------------------------------------------------------------------------- for (int j = 1; VKShiftState[j] != 0xFFFF; j++) { // I4651 @@ -340,11 +339,10 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon // Go through each possible key on the keyboard for (int i = 0;VKMap_US_Keysym[i]; i++) { // I4651 int vkUnderlying = KMX_VKUSToVKUnderlyingLayout(All_Vector,(int) VKMap_US_Keysym[i] ); - wprintf(L" !!!!! KMX_VKUSToVKUnderlyingLayout xx in: :%i ---> %i " , (int) VKMap_US_Keysym[i], vkUnderlying ); KMX_WCHAR ch = KMX_CharFromVK(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey); - wprintf(L" ( %i ) --- :%i ---- > %i ( %i)\n", VKShiftState[j] , vkUnderlying, ch , ( vkUnderlying-ch)); + wprintf(L" KMX_VKUSToVKUnderlyingLayout/KMX_CharFromVK i: %i (VKMap_US_Keysym): %i (%c) ---> vkUnderlying: %i (%c) shiftstate: ( %i ) ---- > ch: %i (%c) ( %i) %ls\n" , i,(int) VKMap_US_Keysym[i],(int)VKMap_US_Keysym[i], vkUnderlying,vkUnderlying, VKShiftState[j] , ch ,ch , ( vkUnderlying-ch), ((int) vkUnderlying != (int) VKMap_US_Keysym[i] ) ? L" *** ": L""); //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); if(bDeadkeyConversion) { // I4552 From d13413db5a33e67b534db126222f3194f78c9b7e Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 28 Jul 2023 17:03:11 +0200 Subject: [PATCH 066/327] feat(linux): mcompile finish DoConvert-read --- linux/mcompile/keymap/README.md | 10 ++- linux/mcompile/keymap/helpers.cpp | 2 +- linux/mcompile/keymap/keymap.cpp | 114 +++++++++++++++------------ linux/mcompile/keymap/keymap.h | 19 ++++- linux/mcompile/keymap/mc_kmxfile.cpp | 14 ++-- linux/mcompile/keymap/mc_kmxfile.h | 4 +- linux/mcompile/keymap/mcompile.cpp | 89 ++++++++++----------- 7 files changed, 139 insertions(+), 113 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index 59a10e3d25..a30c95269d 100644 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -9,22 +9,24 @@ Sample program that reads US basic keyboard and compares to key value group TODO check if US basic is the right Keyboard to compare with TODO non-letter characters don't work OK yet TODO Umlauts don't work OK yet -TODO check Keycode of TLDE, BKSL, LSGT TODO remove unnecessary printf/cout TODO path for xkb/symbols as compile time option in meson TODO check how many/which shift states we use ( at the moment we read all shiftstate-columns of US but then use only 2 colums (non-shift + shift) then use as many colums for Other ) - TODO define folder to store File_US.txt" in and find better name TODO get rid of GTK functions that are deprecated and use X11 instead TODO retrieve name of Other keyboard and use appropriate name instead of "Other" -TODO change keymap.cpp->main() to function() TODO use/adapt TranslateKeyboard() to work on Linux/cross-platform -TODO use/adapt SaveKeyboard() to work on Linux/cross-platform TODO mcompile.cpp: open mcompile -u - option TODO check if I can use files from some other keyman path instead of a copy in keymap ( e.g. filesystem.h exists elsewhere) TODO remove kbdid and kbd for Linux TODO remove unneccessary testing fungctions in keymap.cpp/h TODO remove helpers.cpp/h +TODO usw only wprintf check if printf is used somewhere... +ToDo remove std::cout std::wcout +TODO several Versions of KMX_LoadKeyboard +TODO shiftstate-count +TODO keymap SplitToV.cpp exchange 4 with genaerated shiftcount +TODO shift-statevector TODO ... //--------------------------- diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 189db7add7..0abb77dee7 100644 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -20,7 +20,7 @@ void check_avaiability_of_modules_(){ void MyCout(std::string in, bool end, std::string pre ) { if (end == true) - std::cout << pre << " " << in << " " << "\n"; + std::cout << pre << "" << in << " " << "\n"; else std::cout << pre << " " << in; } diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index b0029e1b92..6494c18acc 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -27,8 +27,8 @@ int dummytest_keymap(){ return 0; } -bool write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { +bool write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { // _S2 relative path !! std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; @@ -52,8 +52,10 @@ bool write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { printf("ERROR: can't Split USto 3D-Vector \n"); return 1; } - + wprintf(L"\n ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); wprintf(L" +++++++ dimensions of Vector after write_US_ToVector (languages..characters..shiftstates)\t\t %li..%li..%li\n", vec.size(), vec[0].size(),vec[0][0].size()); + + //test_single(vec); fclose(fp); return 0; } @@ -68,7 +70,7 @@ bool CreateCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, const char* key = "key <"; std::string str_txt(text); std::string xbk_mark = "xkb_symbol"; - // TODO define folder to store File in + // _S2 TODO define folder to store File in std::ofstream KeyboardFile("File_" + language + ".txt"); printf("Keyboard %s\n", text); @@ -115,7 +117,7 @@ bool Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList) { v_str_1D tokens; v_str_2D shift_states; - // go through the whole vector + // loop through the whole vector for (int k = 0; k < (int)completeList.size() - 1; k++) { // remove all unwanted char @@ -134,25 +136,22 @@ bool Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList) { int Keycde = replace_PosKey_with_Keycode(tokens[0]); tokens[0] = std::to_string(Keycde); - // we use characters a-z, A_Z only at the moment - if (foundCharacterInList(tokens[0])) { + // seperate rest of the vector to its elements and push to 'tokens' + std::istringstream split(tokens[1]); + tokens.pop_back(); - // seperate rest of the vector to its elements and push to 'tokens' - std::istringstream split(tokens[1]); + for (std::string each; std::getline(split, each, split_char_komma); tokens.push_back(each)); + // _S2 do we still need that?? + // at the moment we only use the first 4 shiftstates (non-shift+shift) so get rid of all others + //int surplus = tokens.size() - shift_state_count -1; + int surplus = tokens.size() - 4 -1; + for ( int j=0; j < surplus; j++) { tokens.pop_back(); - - for (std::string each; std::getline(split, each, split_char_komma); tokens.push_back(each)); - //printf("### 5 Split_US_To_3D_Vector: tokens: size:%li...tokens[0]-[4]:-name:%s\tShiftstates:%s--%s--%s--%s---.\n", tokens.size(),tokens[0].c_str(),tokens[1].c_str(),tokens[2].c_str(),tokens[3].c_str(),tokens[4].c_str()); - - // at the moment we only use the first 2 shiftstates (non-shift+shift) so get rid of all others - int surplus = tokens.size() - shift_state_count -1; - for( int j=0; j < surplus;j++) { - tokens.pop_back(); - } - - // now push result to shift_states - shift_states.push_back(tokens); } + + // now push result to shift_states + shift_states.push_back(tokens); + tokens.clear(); } } @@ -165,20 +164,6 @@ bool Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList) { return 0; } -bool foundCharacterInList(std::string tok) { - //TOASK Do we need more and which? - //US keys: Q W E R T Y U I O P A S D F G H J K L Z X C V B N M - v_str_1D Keysyms { "24","25","26","27","28","29","30","31","32","33","38","39","40","41","42","43","44","45","46","52","53","54","55","56","57","58"}; - - for ( int i =0; i< (int) Keysyms.size();i++) { - //std::cout << "foundCharacterInList" << i <<"\n"; - if( tok == Keysyms[i]) { - return true; - } - } - return false; -} - int replace_PosKey_with_Keycode(std::string in) { int out=0; @@ -232,8 +217,8 @@ int replace_PosKey_with_Keycode(std::string in) { else if ( in == "key") out = 59; else if ( in == "key") out = 60; else if ( in == "key") out = 61; - else if ( in == "key") out = 62; //TOASK correct ??? - else if ( in == "key") out = 51; //TOASK correct ??? + else if ( in == "key") out = 51; + else if ( in == "key") out = 94; return out; } @@ -249,7 +234,8 @@ bool append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap) { } All_Vector.push_back(Other_Vector2D); - wprintf(L"+++++++ dimensions of Vector after append_other_ToVector\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); + wprintf(L" +++++++ dimensions of Vector after append_other_ToVector\t\t\t\t\t\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); + wprintf(L" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n"); if (All_Vector.size() < 2) { wprintf(L"ERROR: creation of 3D-Vector failed"); @@ -265,8 +251,10 @@ bool append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap) { All_Vector[1][i][0+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),0); //shift state: unshifted:0 All_Vector[1][i][1+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),1); //shift state: shifted:1 - wprintf(L" Keycodes US->Other: %d (US):%s, %s ---- (other):%s, %s \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str(),All_Vector[1][i][2].c_str()); + //wprintf(L" Keycodes US : %d (US):%s, %s ---- (other):%s, %s \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str(),All_Vector[1][i][2].c_str()); + //wprintf(L" Keycodes ->Other:-: %d (US):%s, %s ,%s, %s \n\n",stoi(All_Vector[1][i][0]),All_Vector[1][i][1].c_str(),All_Vector[1][i][2].c_str(),All_Vector[1][i][3].c_str(),All_Vector[1][i][4].c_str()); } + return 0; } @@ -274,20 +262,19 @@ v_str_2D create_empty_2D( int dim_rows,int dim_shifts) { std::string empty = "--"; v_str_1D shifts; - v_str_2D all; + v_str_2D all_2D; for ( int i=0; i< dim_rows;i++) { for ( int j=0; j< dim_shifts;j++) { shifts.push_back(empty); } - all.push_back(shifts); + all_2D.push_back(shifts); shifts.clear(); } - return all; + return all_2D; } int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { - GdkKeymapKey *maps; guint *keyvals; gint count; @@ -303,6 +290,12 @@ int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) out = keyvals[shift_state_pos]; + //wprintf(L" GetKeyvalsFromKeymap: in %i -- out : %i \n", (int)keycode, out); + + // _S2 if out of range of ascii return 0 or other value ? + if (out > 127) + out = 0; + g_free(keyvals); g_free(maps); @@ -311,16 +304,39 @@ int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) bool test(v_str_3D &V) { - printf("+++++++ dimensions of Vector in test()\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); - printf("\n+++++++++ print some characters of US and Other +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + std::string extra = " "; + wprintf(L"+++++++ dimensions of whole Vector in test()\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); + wprintf(L"\n+++++++++ print some characters of US and Other ++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); for ( int k=0; k<(int)V[0].size(); k++) { - std::cout << " row 1 (US)......" << V[0][k][0]<< ".." << V[0][k][1]<< ".."<< "..\n" ; - if (V.size()>1) - std::cout << " row 1 (Other).."<< V[1][k][0]<< ".." << V[1][k][1]<< ".."<< "..\n" ; - } - printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + if(V[0][k][2] != V[1][k][2] ) + extra = " *** "; + else + extra = " "; + if (V[0].size()>0) { + wprintf(L" row 1 xx(US) ...... %s .. %s .. %s .. %s .. %s --- ", V[0][k][0].c_str(), V[0][k][1].c_str() , V[0][k][2].c_str() , V[0][k][3].c_str() , V[0][k][4].c_str() ); + wprintf(L" \n"); + wprintf(L" row 1 xx(Other)..... %s .. %s .. %s .. %s .. %s %s \n", V[1][k][0].c_str(), V[1][k][1].c_str() , V[1][k][2].c_str() , V[1][k][3].c_str() , V[1][k][4].c_str() , extra.c_str()); + wprintf(L" \n"); + } + } + wprintf(L"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + return true; +} + +bool test_single(v_str_3D &V) { + + std::string extra = " "; + wprintf(L"+++++++ dimensions of single Vector in test()\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); + wprintf(L"\n+++++++++ print characters of SINGLE +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + + for ( int k=0; k<(int)V[0].size(); k++) { + if (V[0].size()>0) { + wprintf(L" row 1 (US) ...... %s .. %s .. %s .. %s .. %s --- \n", V[0][k][0].c_str(), V[0][k][1].c_str() , V[0][k][2].c_str() , V[0][k][3].c_str() , V[0][k][4].c_str() ); + } + } + wprintf(L"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); return true; } diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index d8f7892b1c..0927099952 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -28,6 +28,21 @@ typedef std::vector > > v_str_3D; static int shift_state_count = 2; // use shiftstate : no shift, shift +// Map of all US English virtual key codes that we can translate +// +const WORD KMX_VKMap[] = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + + //_S2 those might not work yet*/ + VK_SPACE, + VK_ACCENT, VK_HYPHEN, VK_EQUAL, + VK_LBRKT, VK_RBRKT, VK_BKSLASH, + VK_COLON, VK_QUOTE, + VK_COMMA, VK_PERIOD, VK_SLASH, + VK_xDF, VK_OEM_102, + 0 +}; // initialize GDK bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); @@ -43,9 +58,6 @@ bool CreateCompleteRow_US(v_str_1D &complete_List, FILE *fpp, const char *text, // 2nd step: write contents to 3D vector bool Split_US_To_3D_Vector(v_str_3D &all_US, v_str_1D completeList); -// make sure only a-z, A_Z is used -bool foundCharacterInList(std::string tok); - // replace Name of Key (e.g. ) wih Keycode ( e.g. 15 ) int replace_PosKey_with_Keycode(std::string in); @@ -60,6 +72,7 @@ int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos); // testing of Vector contents ( first row of US and Other) bool test(v_str_3D &V); +bool test_single(v_str_3D &V) ; /* // print both sets of characters (US and OtherLanguage) to console and file for comparison diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 784f87ac60..fff3aa5023 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -17,7 +17,7 @@ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFil KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, PKMX_WCHAR filename) { - MyCoutW(L"#### KMX_SaveKeyboard of mcompile started", 1); + MyCoutW(L"#### KMX_SaveKeyboard of mc_kmxfile started", 1); FILE *fp; fp = Open_File(filename, u"wb"); @@ -40,14 +40,14 @@ KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, PKMX_WCHAR filename) { return FALSE; } - MyCoutW(L"#### KMX_SaveKeyboard of mcompile ended", 1); + MyCoutW(L"#### KMX_SaveKeyboard of mc_kmxfile ended", 1); return TRUE; } KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL FSaveDebug) { - MyCoutW(L" #### KMX_WriteCompiledKeyboard of mcompile started", 1); + MyCoutW(L" ##### KMX_WriteCompiledKeyboard of mc_kmxfile started", 1); LPKMX_GROUP fgp; LPKMX_STORE fsp; LPKMX_KEY fkp; @@ -226,7 +226,7 @@ KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL delete[] buf; - MyCoutW(L" #### KMX_WriteCompiledKeyboard of mcompile ended", 1); + MyCoutW(L" ##### KMX_WriteCompiledKeyboard of mc_kmxfile ended", 1); return CERR_None; } @@ -374,7 +374,7 @@ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFil #endif KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { - std::wcout << "##### KMX_LoadKeyboard of mc_kmxfile started #####\n"; + std::wcout << "\n##### KMX_LoadKeyboard of mc_kmxfile started #####\n"; PKMX_BYTE buf; FILE* fp; @@ -477,8 +477,6 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { return FALSE; } - std::wcout << " kbp->dwIdentifier: " << kbp->dwIdentifier << " FILEID_COMPILED: " << FILEID_COMPILED << "\n"; - if (kbp->dwIdentifier != FILEID_COMPILED) { delete[] buf; KMX_LogError(L"LogError1: errNotFileID\n" ); @@ -486,6 +484,8 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { } *lpKeyboard = kbp; // _S2 delete [] buf; ???? + + std::wcout << "##### KMX_LoadKeyboard of mc_kmxfile ended #####\n"; return TRUE; } diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 71e8aac11d..64ebf0e811 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -133,8 +133,8 @@ typedef struct tagKEYBOARD { BOOL LoadKeyboard(char* fileName, LPKEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? BOOL LoadKeyboard(wchar_t* fileName, LPKEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? - KMX_BOOL KMX_LoadKeyboard(char* fileName, LPKMX_KEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? - KMX_BOOL KMX_LoadKeyboard(wchar_t* fileName, LPKMX_KEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? + //KMX_BOOL KMX_LoadKeyboard(char* fileName, LPKMX_KEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? + //KMX_BOOL KMX_LoadKeyboard(wchar_t* fileName, LPKMX_KEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, PKMX_WCHAR filename); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 60b8d791f5..62e693c89e 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -180,33 +180,16 @@ wprintf(L"_S2 * Up to here cross-platform xx :-))))) ************************** return 0 ; } -/*// Map of all US English virtual key codes that we can translate -// -const WORD VKMap[] = { - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - VK_SPACE, - VK_ACCENT, VK_HYPHEN, VK_EQUAL, - VK_LBRKT, VK_RBRKT, VK_BKSLASH, - VK_COLON, VK_QUOTE, - VK_COMMA, VK_PERIOD, VK_SLASH, - VK_xDF, VK_OEM_102, - 0 -}; -*/ - -// Map of all US English virtual key codes that we can translate -// US Keys: Q W E R T Y U I O P A S D F G H J K L Z X C V B N M -const DWORD VKMap_US_Keycode[] = { 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 , 33 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 52 , 53 , 54 , 55 , 56 , 57 , 77 ,0}; - -// Map of all US English virtual key codes that we can translate -// US Keys: 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 , 33 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 47, 52 , 53 , 54 , 55 , 56 , 57 , 77 , 0 -const char VKMap_US_Keysym[] = { 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '0'}; // Map of all shift states that we will work with // //const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; -const UINT VKShiftState[] = {0, 1, 2,0xFFFF}; + +// Ubuntu: Each of the 4 columns specifies a different modifier: unmodified, shift, right alt (altgr), shift+right alt(altgr) +// we have assigned these to columns 1-4 ( column o holds the keycode) +// some hold up to 8 what are those ??? +const UINT VKShiftState[] = {0, 1, 2, 3, 4, 0xFFFF}; +//cconst UINT VKShiftState[] = {0, 1, 2, 0xFFFF}; // _S2 shiftstate from systems-file void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, DWORD vk, UINT shift, KMX_WCHAR ch) { @@ -237,15 +220,17 @@ KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { // takes capital letter of US returns cpital character of Other keyboard int KMX_VKUSToVKUnderlyingLayout(v_str_3D &All_Vector,int inUS) { + +int KeysymOther = inUS; // loop and find char in US; then find char of Other - for( int i=0; i< (int)All_Vector[1].size();i++) { - for( int j=0; j< (int)All_Vector[1][0].size();j++) { + for( int i=0; i< (int)All_Vector[0].size();i++) { + // lists entries of all_vector + for( int j=1; j< (int)All_Vector[0][0].size();j++) { int KeysymUS = (int) *All_Vector[0][i][j].c_str(); - if( inUS == KeysymUS ) { - if(All_Vector[1][i].size() >2 ) { - int KeysymOther = (int) *All_Vector[1][i][2].c_str(); - return KeysymOther; - } + + if( ( All_Vector[0][i][j].size() == 1 ) && inUS == KeysymUS ) { + KeysymOther = (int) *All_Vector[1][i][2].c_str(); + return KeysymOther; } } } @@ -254,20 +239,18 @@ int KMX_VKUSToVKUnderlyingLayout(v_str_3D &All_Vector,int inUS) { // takes cpital character of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] KMX_WCHAR KMX_CharFromVK(v_str_3D &All_Vector,int vkUnderlying, WCHAR VKShiftState, KMX_WCHAR* DeadKey){ + // loop and find vkUnderlying in Other; then return char with correct shiftstate for( int i=0; i< (int)All_Vector[1].size();i++) { - for( int j=0; j< (int)All_Vector[1][0].size();j++) { - int CharOther = (int) *All_Vector[1][i][j].c_str(); + int CharOther = (int) *All_Vector[1][i][2].c_str(); if( vkUnderlying == CharOther ) { - int CharOtherShifted = (int) *All_Vector[1][i][VKShiftState].c_str(); - return CharOtherShifted; + int CharOtherShifted = (int) *All_Vector[1][i][VKShiftState].c_str(); + return CharOtherShifted; } - } } return vkUnderlying; } - bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]){ // get keymap of keyboard layout in use @@ -288,11 +271,11 @@ bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]){ return 0; } - bool createVectorForBothKeyboards(v_str_3D &All_Vector,GdkKeymap *keymap){ std::string US_language = "us"; - const char* text_us = "xkb_symbols \"basic\""; + //const char* text_us = "xkb_symbols \"basic\""; + const char* text_us = "xkb_symbols \"intl\""; if(write_US_ToVector(All_Vector,US_language, text_us)) { printf("ERROR: can't write US to Vector \n"); @@ -304,13 +287,13 @@ bool createVectorForBothKeyboards(v_str_3D &All_Vector,GdkKeymap *keymap){ printf("ERROR: can't append other ToVector \n"); return 1; } - test(All_Vector); + return 0; } - KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]) { + std::wcout << "\n##### KMX_DoConvert of mcompile started #####\n"; KMX_WCHAR DeadKey; if(!KMX_SetKeyboardToPositional(kbd)) return FALSE; @@ -331,18 +314,30 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon v_str_3D All_Vector; if(createVectorForBothKeyboards(All_Vector,keymap) ) printf("ERROR: can't createVectorForBothKeyboards\n"); + //test(All_Vector); //-------------------------------------------------------------------------------- +// _S2 for 1-> VKShiftState or shift_state_count ??? +//0,1,2,3,4,ff + const wchar_t* ERROR = L" "; for (int j = 1; VKShiftState[j] != 0xFFFF; j++) { // I4651 - // Go through each possible key on the keyboard - for (int i = 0;VKMap_US_Keysym[i]; i++) { // I4651 - int vkUnderlying = KMX_VKUSToVKUnderlyingLayout(All_Vector,(int) VKMap_US_Keysym[i] ); + // Loop through each possible key on the keyboard + for (int i = 0;KMX_VKMap[i]; i++) { // I4651 + + // _S2 why not in 1 step ?? + int vkUnderlying = KMX_VKUSToVKUnderlyingLayout(All_Vector,(int) KMX_VKMap[i] ); KMX_WCHAR ch = KMX_CharFromVK(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey); - wprintf(L" KMX_VKUSToVKUnderlyingLayout/KMX_CharFromVK i: %i (VKMap_US_Keysym): %i (%c) ---> vkUnderlying: %i (%c) shiftstate: ( %i ) ---- > ch: %i (%c) ( %i) %ls\n" , i,(int) VKMap_US_Keysym[i],(int)VKMap_US_Keysym[i], vkUnderlying,vkUnderlying, VKShiftState[j] , ch ,ch , ( vkUnderlying-ch), ((int) vkUnderlying != (int) VKMap_US_Keysym[i] ) ? L" *** ": L""); + //_S2 mark if difference is not 32= (unshifted-shifted ) + if (!( ((int) KMX_VKMap[i] == ch ) || ((int) KMX_VKMap[i] == (int) ch -32) ) ) + ERROR = L" !!!"; + else + ERROR = L" "; + + wprintf(L" DoConvert-read i: %i (KMX_VKMap): %i (%c) ---> vkUnderlying: %i (%c) shiftstate: ( %i ) ---- > ch: %i (%c) %ls %ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); if(bDeadkeyConversion) { // I4552 @@ -357,9 +352,8 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon //case 0xFFFF: ConvertDeadkey(kbd, VKMap[i], VKShiftState[j], DeadKey); break; //default: TranslateKeyboard(kbd, VKMap[i], VKShiftState[j], ch); - default: KMX_TranslateKeyboard(kbd, VKMap_US_Keysym[i], VKShiftState[j], ch); + default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); } - } } @@ -370,10 +364,11 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon return FALSE; } */ + + std::wcout << "\n##### KMX_DoConvert of mcompile ended #####\n"; return TRUE; } - void KMX_LogError(const KMX_WCHART* m1,int m2) { wprintf((PWSTR)m1, m2); } From e3fed21dd1c332f9f20b18235acd46dd8d0e3f23 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 28 Jul 2023 17:20:28 +0200 Subject: [PATCH 067/327] feat(linux): mcompile replace std::cout, std::wcout, MyCout, printf and use wprintf --- linux/mcompile/keymap/README.md | 1 - linux/mcompile/keymap/keymap.cpp | 6 +++--- linux/mcompile/keymap/mc_kmxfile.cpp | 16 ++++++++-------- linux/mcompile/keymap/mcompile.cpp | 14 +++++++------- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index a30c95269d..07f5344652 100644 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -9,7 +9,6 @@ Sample program that reads US basic keyboard and compares to key value group TODO check if US basic is the right Keyboard to compare with TODO non-letter characters don't work OK yet TODO Umlauts don't work OK yet -TODO remove unnecessary printf/cout TODO path for xkb/symbols as compile time option in meson TODO check how many/which shift states we use ( at the moment we read all shiftstate-columns of US but then use only 2 colums (non-shift + shift) then use as many colums for Other ) TODO define folder to store File_US.txt" in and find better name diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 6494c18acc..1c03b2fcb2 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -43,13 +43,13 @@ bool write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { // create 1D-vector of the complete line v_str_1D Vector_completeUS; if( CreateCompleteRow_US(Vector_completeUS,fp , text, language)) { - printf("ERROR: can't Create complete row US \n"); + wprintf(L"ERROR: can't Create complete row US \n"); return 1; } // split contents of 1D Vector to 3D vector if( Split_US_To_3D_Vector( vec,Vector_completeUS)) { - printf("ERROR: can't Split USto 3D-Vector \n"); + wprintf(L"ERROR: can't Split USto 3D-Vector \n"); return 1; } wprintf(L"\n ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); @@ -158,7 +158,7 @@ bool Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList) { all_US.push_back(shift_states); if ( all_US.size() ==0) { - printf("ERROR: Can't split US to 3D-Vector\n"); + wprintf(L"ERROR: Can't split US to 3D-Vector\n"); return 1; } return 0; diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index fff3aa5023..a7ca9a6cd4 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -17,7 +17,7 @@ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFil KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, PKMX_WCHAR filename) { - MyCoutW(L"#### KMX_SaveKeyboard of mc_kmxfile started", 1); + wprintf(L"#### KMX_SaveKeyboard of mc_kmxfile started"); FILE *fp; fp = Open_File(filename, u"wb"); @@ -40,14 +40,14 @@ KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, PKMX_WCHAR filename) { return FALSE; } - MyCoutW(L"#### KMX_SaveKeyboard of mc_kmxfile ended", 1); + wprintf(L"#### KMX_SaveKeyboard of mc_kmxfile ended"); return TRUE; } KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL FSaveDebug) { - MyCoutW(L" ##### KMX_WriteCompiledKeyboard of mc_kmxfile started", 1); + wprintf(L" ##### KMX_WriteCompiledKeyboard of mc_kmxfile started"); LPKMX_GROUP fgp; LPKMX_STORE fsp; LPKMX_KEY fkp; @@ -226,7 +226,7 @@ KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL delete[] buf; - MyCoutW(L" ##### KMX_WriteCompiledKeyboard of mc_kmxfile ended", 1); + wprintf(L" ##### KMX_WriteCompiledKeyboard of mc_kmxfile ended"); return CERR_None; } @@ -328,7 +328,7 @@ LPKMX_KEYBOARD KMX_CopyKeyboard(PKMX_BYTE bufp, PKMX_BYTE base) */ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize) { - MyCoutW(L" ##### KMX_FixupKeyboard of mcompile started",1); + wprintf(L" ##### KMX_FixupKeyboard of mcompile started"); UNREFERENCED_PARAMETER(dwFileSize); KMX_DWORD i, j; @@ -368,13 +368,13 @@ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFil } } - MyCoutW(L" ##### KMX_FixupKeyboard of mcompile ended",1); + wprintf(L" ##### KMX_FixupKeyboard of mcompile ended"); return kbp; } #endif KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { - std::wcout << "\n##### KMX_LoadKeyboard of mc_kmxfile started #####\n"; + wprintf(L"\n##### KMX_LoadKeyboard of mc_kmxfile started #####\n"); PKMX_BYTE buf; FILE* fp; @@ -485,7 +485,7 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { *lpKeyboard = kbp; // _S2 delete [] buf; ???? - std::wcout << "##### KMX_LoadKeyboard of mc_kmxfile ended #####\n"; + wprintf(L"##### KMX_LoadKeyboard of mc_kmxfile ended #####\n"); return TRUE; } diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 62e693c89e..f579757151 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -257,13 +257,13 @@ bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]){ gdk_init(&argc, &argv); GdkDisplay *display = gdk_display_get_default(); if (!display) { - printf("ERROR: can't get display\n"); + wprintf(L"ERROR: can't get display\n"); return 1; } *keymap = gdk_keymap_get_for_display(display); if (!keymap) { - printf("ERROR: Can't get keymap\n"); + wprintf(L"ERROR: Can't get keymap\n"); gdk_display_close(display); return 2; } @@ -278,13 +278,13 @@ bool createVectorForBothKeyboards(v_str_3D &All_Vector,GdkKeymap *keymap){ const char* text_us = "xkb_symbols \"intl\""; if(write_US_ToVector(All_Vector,US_language, text_us)) { - printf("ERROR: can't write US to Vector \n"); + wprintf(L"ERROR: can't write US to Vector \n"); return 1; } // add contents of other keyboard to All_Vector if( append_other_ToVector(All_Vector,keymap)) { - printf("ERROR: can't append other ToVector \n"); + wprintf(L"ERROR: can't append other ToVector \n"); return 1; } @@ -308,12 +308,12 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon //_ init gdk GdkKeymap *keymap; if(InitializeGDK(&keymap , argc, argv) ) - printf("ERROR: can't InitializeGDK\n"); + wprintf(L"ERROR: can't InitializeGDK\n"); // create vector v_str_3D All_Vector; if(createVectorForBothKeyboards(All_Vector,keymap) ) - printf("ERROR: can't createVectorForBothKeyboards\n"); + wprintf(L"ERROR: can't createVectorForBothKeyboards\n"); //test(All_Vector); //-------------------------------------------------------------------------------- @@ -365,7 +365,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon } */ - std::wcout << "\n##### KMX_DoConvert of mcompile ended #####\n"; + wprintf(L"\n##### KMX_DoConvert of mcompile ended #####\n"); return TRUE; } From d50322a995e870282ea298724d4927a3ad185d49 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 28 Jul 2023 18:25:50 +0200 Subject: [PATCH 068/327] feat(linux): mcompile tidy up: remove unneccessary code --- linux/mcompile/keymap/README.md | 8 ++++++ linux/mcompile/keymap/helpers.cpp | 4 --- linux/mcompile/keymap/helpers.h | 2 -- linux/mcompile/keymap/keymap.h | 2 +- linux/mcompile/keymap/mc_kmxfile.cpp | 1 - linux/mcompile/keymap/mcompile.cpp | 43 +++++++++++++++++++--------- linux/mcompile/keymap/meson.build | 41 +++++++++++++------------- linux/mcompile/keymap/u16.cpp | 26 ++--------------- 8 files changed, 62 insertions(+), 65 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index 07f5344652..aad31d4823 100644 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -25,7 +25,15 @@ ToDo remove std::cout std::wcout TODO several Versions of KMX_LoadKeyboard TODO shiftstate-count TODO keymap SplitToV.cpp exchange 4 with genaerated shiftcount +TODO check if part with surplus is neccessary TODO shift-statevector +TODO meson.build do I need version of dependency?? +TODO meson remove helpers.cpp +TODO remove mc_savekeyboard.cpp/h +TODO remove dummytest() +TODO see which functions I need from u16.cpp/h +TODO see which data types I can remove from km_types.h +TODO replace/remove old structs or move kmx_structs to the left side of file TODO ... //--------------------------- diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 0abb77dee7..ef8af0c7b2 100644 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -33,7 +33,3 @@ void MyCoutW(std::wstring in, bool end, std::wstring pre) { } -void DebugLog_S2(std::wstring txt, std::wstring fileName) { - - wprintf(txt.c_str(), fileName); -} diff --git a/linux/mcompile/keymap/helpers.h b/linux/mcompile/keymap/helpers.h index 62fdef9b07..eb4335f2b3 100644 --- a/linux/mcompile/keymap/helpers.h +++ b/linux/mcompile/keymap/helpers.h @@ -15,7 +15,5 @@ void check_avaiability_of_modules_WC(); void MyCout(std::string in, bool end, std::string pre = ""); void MyCoutW(std::wstring in, bool end, std::wstring pre =L""); -//Just for now: wrote my oẃn DebugLog -TODO to be replaced -void DebugLog_S2(std::wstring txt, std::wstring fileName); #endif /* HELPERS_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 0927099952..cb767bd4f2 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -26,7 +26,7 @@ typedef std::vector v_str_1D; typedef std::vector > v_str_2D; typedef std::vector > > v_str_3D; -static int shift_state_count = 2; // use shiftstate : no shift, shift +//static int shift_state_count = 2; // use shiftstate : no shift, shift // Map of all US English virtual key codes that we can translate // diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index a7ca9a6cd4..d65135e05c 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -500,7 +500,6 @@ KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz){ // Old or new version -- identify the desired program version // for (csp = (PKMX_COMP_STORE)(filebase + ckbp->dpStoreArray), i = 0; i < ckbp->cxStoreArray; i++, csp++) { if (csp->dwSystemID == TSS_COMPILEDVERSION) { - wchar_t buf2[256]; if (csp->dpString == 0) { KMX_LogError(L"LogErr1: errWrongFileVersion:NULL"); } else { diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index f579757151..377c72f54f 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -64,7 +64,6 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon run(argc, str_argv_16, argv); #endif - } //------ run with char16_t !! ------------------------------------------------------------------------------------------------------------------------- int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ @@ -220,25 +219,23 @@ KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { // takes capital letter of US returns cpital character of Other keyboard int KMX_VKUSToVKUnderlyingLayout(v_str_3D &All_Vector,int inUS) { - -int KeysymOther = inUS; // loop and find char in US; then find char of Other for( int i=0; i< (int)All_Vector[0].size();i++) { // lists entries of all_vector for( int j=1; j< (int)All_Vector[0][0].size();j++) { int KeysymUS = (int) *All_Vector[0][i][j].c_str(); - if( ( All_Vector[0][i][j].size() == 1 ) && inUS == KeysymUS ) { - KeysymOther = (int) *All_Vector[1][i][2].c_str(); - return KeysymOther; + if( ( All_Vector[0][i][j].size() == 1 ) && (inUS == KeysymUS )) { + inUS = (int) *All_Vector[1][i][2].c_str(); + return inUS; } } } return inUS; } -// takes cpital character of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] -KMX_WCHAR KMX_CharFromVK(v_str_3D &All_Vector,int vkUnderlying, WCHAR VKShiftState, KMX_WCHAR* DeadKey){ +/*// takes cpital character of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] +int KMX_CharFromVK(v_str_3D &All_Vector,int vkUnderlying, WCHAR VKShiftState, KMX_WCHAR* DeadKey){ // loop and find vkUnderlying in Other; then return char with correct shiftstate for( int i=0; i< (int)All_Vector[1].size();i++) { @@ -249,6 +246,24 @@ KMX_WCHAR KMX_CharFromVK(v_str_3D &All_Vector,int vkUnderlying, WCHAR VKShiftSta } } return vkUnderlying; +}*/ +// takes cpital character of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] + +KMX_WCHAR KMX_CharFromVK(v_str_3D &All_Vector,int vkUnderlying, WCHAR VKShiftState, KMX_WCHAR* DeadKey){ + + //_S2 can I cast int to KMX_WCHAR?? + // _S2 careful if we had strings with more than 1 char in our vector elements: CharOther would only take the first CHARACTR!! + // loop and find vkUnderlying in Other; then return char with correct shiftstate + for( int i=0; i< (int)All_Vector[1].size();i++) { + int CharOther = (int) *All_Vector[1][i][2].c_str(); + + //if( vkUnderlying == CharOther ) { + if( ( All_Vector[1][i][2].size() == 1 ) && (vkUnderlying == CharOther )) { + int CharOtherShifted = (int) *All_Vector[1][i][VKShiftState].c_str(); + return (KMX_WCHAR) CharOtherShifted; + } + } + return (KMX_WCHAR) vkUnderlying; } bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]){ @@ -294,9 +309,9 @@ bool createVectorForBothKeyboards(v_str_3D &All_Vector,GdkKeymap *keymap){ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]) { std::wcout << "\n##### KMX_DoConvert of mcompile started #####\n"; - KMX_WCHAR DeadKey; + KMX_WCHAR DeadKey; - if(!KMX_SetKeyboardToPositional(kbd)) return FALSE; + if(!KMX_SetKeyboardToPositional(kbd)) return FALSE; // Go through each of the shift states - base, shift, ctrl+alt, ctrl+alt+shift, [caps vs ncaps?] // Currently, we go in this order so the 102nd key works. But this is not ideal for keyboards without 102nd key: // I4651 @@ -317,29 +332,29 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon //test(All_Vector); //-------------------------------------------------------------------------------- -// _S2 for 1-> VKShiftState or shift_state_count ??? -//0,1,2,3,4,ff const wchar_t* ERROR = L" "; + for (int j = 1; VKShiftState[j] != 0xFFFF; j++) { // I4651 // Loop through each possible key on the keyboard for (int i = 0;KMX_VKMap[i]; i++) { // I4651 - // _S2 why not in 1 step ?? + // _S2 why were those 2 functions originally not done in 1 step ?? int vkUnderlying = KMX_VKUSToVKUnderlyingLayout(All_Vector,(int) KMX_VKMap[i] ); KMX_WCHAR ch = KMX_CharFromVK(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey); + //_S2 mark if difference is not 32= (unshifted-shifted ) if (!( ((int) KMX_VKMap[i] == ch ) || ((int) KMX_VKMap[i] == (int) ch -32) ) ) ERROR = L" !!!"; else ERROR = L" "; - wprintf(L" DoConvert-read i: %i (KMX_VKMap): %i (%c) ---> vkUnderlying: %i (%c) shiftstate: ( %i ) ---- > ch: %i (%c) %ls %ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); + if(bDeadkeyConversion) { // I4552 if(ch == 0xFFFF) { ch = DeadKey; diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index 405cdb879c..7143d0f8ec 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -1,28 +1,29 @@ -# mcompile +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +project('mcompile', 'c', 'cpp', + license: 'MIT', + meson_version: '>=1.0') -project('mcompile', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') -gtk = dependency('gtk+-3.0', version: '>= 2.4') -x11 = dependency('x11', version: '>= 1.6') -xkb = dependency('xkbcommon', version: '>= 0.0') -libxklavier = dependency('libxklavier', version: '>= 0.0') +#do I need a Version of dependency? +gtk = dependency('gtk+-3.0', version: '>= 2.4') +x11 = dependency('x11', version: '>= 1.6') +xkb = dependency('xkbcommon', version: '>= 0.0') +libxklavier = dependency('libxklavier', version: '>= 0.0') deps = [gtk, x11, xkb,libxklavier] -cpp_files = files( 'keymap.cpp', 'mcompile.cpp', 'filesystem.cpp', 'mc_kmxfile.cpp', 'mc_savekeyboard.cpp', 'helpers.cpp', 'u16.cpp',) -mcompile = executable( 'mcompile', sources: [cpp_files], dependencies: deps) +cpp_files = files( + 'keymap.cpp', + 'mcompile.cpp', + 'filesystem.cpp', + 'mc_kmxfile.cpp', + 'mc_savekeyboard.cpp', + 'helpers.cpp', + 'u16.cpp',) -# keymapWC +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +mcompile = executable( + 'mcompile', + sources: [cpp_files], + dependencies: deps + ) -#project('keymapWC', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') -#gtk = dependency('gtk+-3.0', version: '>= 2.4') -#cpp_files = files( 'keymapWC.cpp','mc_kmxfile.cpp', 'mc_savekeyboard.cpp', 'helpers.cpp', 'u16.cpp',) -#keymapWC = executable( 'keymapWC', sources: [cpp_files], dependencies: [gtk]) - -# keymap +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -#project('keymap', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') -#gtk = dependency('gtk+-3.0', version: '>= 2.4') -#cpp_files = files( 'keymap.cpp', 'mcompile.cpp', 'filesystem.cpp', 'mc_kmxfile.cpp', 'mc_savekeyboard.cpp', 'helpers.cpp', 'u16.cpp',) -#keymap = executable( 'keymap', sources: [cpp_files], dependencies: [gtk]) diff --git a/linux/mcompile/keymap/u16.cpp b/linux/mcompile/keymap/u16.cpp index c30a187d91..28d61a1d39 100644 --- a/linux/mcompile/keymap/u16.cpp +++ b/linux/mcompile/keymap/u16.cpp @@ -15,7 +15,6 @@ int dummytest_u16(){ std::vector convert_argv_to_Vector_u16str(int argc, char* argv[]) { std::vector vector_u16; - int i; // for each arg convert to u16string and push to vector for (char** arg = argv, i=0; *arg; ++arg,i++) { @@ -27,7 +26,6 @@ std::vector convert_argv_to_Vector_u16str(int argc, char* argv[] std::vector convert_argvW_to_Vector_u16str(int argc, wchar_t* argv[]) { std::vector vector_u16; - int i; // for each arg convert to u16string and push to vector for (wchar_t** arg = argv, i=0; *arg; ++arg,i++) { @@ -37,30 +35,12 @@ std::vector convert_argvW_to_Vector_u16str(int argc, wchar_t* ar return vector_u16; } - - -// _S" does this work?? -//const wchar_t* <- const char* -/* -wchar_t* wchart_from_char( char* c) { - std::string str(*c); - std::wstring wstr = wstring_from_string(str); - wchar_t* wc = (wchar_t*) wstr.c_str(); - return wc; -}*/ - -/* _S2 does this work ??? -wchar_t* wchart_from_char16( char16_t** c) { - std::u16string str(*c); - std::wstring wstr = wstring_from_u16string((std::u16string const) str); - return (wchar_t*) wstr.c_str(); -}*/ - //String <- wstring std::string string_from_wstring(std::wstring const str) { std::wstring_convert, wchar_t> converter; return converter.to_bytes(str); } + //wstring <- string std::wstring wstring_from_string(std::string const str) { std::wstring_convert, wchar_t> converter; @@ -157,8 +137,8 @@ std::string toHex(int num1) { } reverse(s.begin(), s.end()); return s; -} -*/ +}*/ + const KMX_WCHAR * u16ncat(KMX_WCHAR *dst, const KMX_WCHAR *src, size_t max) { KMX_WCHAR* o = dst; dst = (KMX_WCHAR*) u16chr(dst, 0); From 2371f5924065785438c28aad98eafab047f2b5d6 Mon Sep 17 00:00:00 2001 From: Sabine Date: Sat, 29 Jul 2023 20:46:25 +0200 Subject: [PATCH 069/327] feat(linux): mcompile Version using Vector of KMX_DWORD (instead of Vector of std::string) --- linux/mcompile/keymap/keymap.cpp | 236 +++++++++++++++++++++++++++ linux/mcompile/keymap/keymap.h | 18 +- linux/mcompile/keymap/mc_kmxfile.cpp | 12 +- linux/mcompile/keymap/mcompile.cpp | 82 ++++++++-- 4 files changed, 326 insertions(+), 22 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 1c03b2fcb2..6344c18eea 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -60,6 +60,39 @@ bool write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { return 0; } +bool write_US_ToVector_dw( v_dw_3D &vec,std::string language, const char* text) { + + // _S2 relative path !! + std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; + + const char* path = FullPathName.c_str(); + FILE* fp = fopen((path), "r"); + if ( !fp) { + wprintf(L"could not open file!"); + return 1; + } + + // create 1D-vector of the complete line + v_str_1D Vector_completeUS; + if( CreateCompleteRow_US(Vector_completeUS,fp , text, language)) { + wprintf(L"ERROR: can't Create complete row US \n"); + return 1; + } + + // split contents of 1D Vector to 3D vector + if( Split_US_To_3D_Vector_dw( vec,Vector_completeUS)) { + wprintf(L"ERROR: can't Split USto 3D-Vector \n"); + return 1; + } + wprintf(L"\n ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + wprintf(L" +++++++ dimensions of Vector after write_US_ToVector_dw (languages..characters..shiftstates)\t\t %li..%li..%li\n", vec.size(), vec[0].size(),vec[0][0].size()); + + //test_single(vec); + test_single_dw(vec); + fclose(fp); + return 0; +} + bool CreateCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, std::string language) { // in the Configuration file we find the appopriate paragraph between "xkb_symbol " and the next xkb_symbol // and then copy all rows starting with "key <" to a v1D-Vector @@ -164,6 +197,112 @@ bool Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList) { return 0; } +std::wstring replaceNamesWithCharacter(std::wstring tok_wstr){ + + std::wstring tok_wstr_out; + //Names of Characters we use: + std::wstring UsableCharacters[10][2] = { + {L"exclam", L"!"} , + {L"at", L"@"} , + {L"numbersign", L"#"} , + {L"dollar", L"$"} , + {L"percent", L"%"} , + {L"dead_circumflex", L"^"} , + {L"ampersand", L"&"} , + {L"asterisk", L"*"} , + {L"parenleft", L"("} , + {L"parenright", L")"} }; + + int size_arr = sizeof(UsableCharacters)/sizeof(UsableCharacters[0]); + + for ( int i =0; i< size_arr;i++) { + if (tok_wstr == UsableCharacters[i][0]) { + tok_wstr_out = UsableCharacters[i][1]; + return UsableCharacters[i][1]; + } + } + + return tok_wstr; +} + +bool Split_US_To_3D_Vector_dw(v_dw_3D &all_US,v_str_1D completeList) { + // 1: take the whole line of the 1D-Vector and remove unwanted characters. + // 2: seperate the name e.g. key from the shiftstates + // 3: convert to DWORD + // 4: push Names/Shiftstates to shift_states and then shiftstates to All_US, our 3D-Vector holding all Elements + + std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; + char split_bracel = '{'; + char split_char_komma = ','; + int ValueInvalid = 32; // _S2 do we use space, 0, FFFF for a char we cannot use ?? + int Keycde; + v_str_1D tokens; + v_dw_1D tokens_dw; + v_dw_2D shift_states_dw; + KMX_DWORD tokens_int; + std::wstring tok_wstr; + + // loop through the whole vector + for (int k = 0; k < (int)completeList.size() - 1; k++) { + + // remove all unwanted char + for (int i = 0; i < (int) delim.size(); i++) { + completeList[k].erase(remove(completeList[k].begin(), completeList[k].end(), delim[i]), completeList[k].end()); + } + + // only lines with ("key<.. are of interest + if (completeList[k].find("key<") != std::string::npos) { + + //split off the key names + std::istringstream split1(completeList[k]); + for (std::string each; std::getline(split1, each, split_bracel); tokens.push_back(each)); + + // replace keys names with Keycode ( with 29,...) + Keycde = replace_PosKey_with_Keycode(tokens[0]); + tokens[0] = std::to_string(Keycde); + + // seperate rest of the vector to its elements and push to 'tokens' + std::istringstream split(tokens[1]); + tokens.pop_back(); + + for (std::string each; std::getline(split, each, split_char_komma); tokens.push_back(each)); + + + // now convert all to KMX_DWORD and fill tokens_dw + tokens_dw.push_back((KMX_DWORD) Keycde); + + for ( int i = 1; i< tokens.size();i++) { + + // check if a name can be replaced with a single character + tok_wstr = replaceNamesWithCharacter( wstring_from_string(tokens[i])); + + // for single char: copy value of char + if ( tok_wstr.size() == 1) { + tokens_int = (KMX_DWORD) ( *tok_wstr.c_str() ); + } + else { + tokens_int = ValueInvalid; + } + tokens_dw.push_back(tokens_int); + + wprintf(L"<<< %i (%c) %i (%c) %i (%c) %i (%c) \n", tokens_dw[0],tokens_dw[0],tokens_dw[1],tokens_dw[1], tokens_dw[2], tokens_dw[2], tokens_dw[3],tokens_dw[3]); + } + + // now push result to shift_states + shift_states_dw.push_back(tokens_dw); + tokens_dw.clear(); + tokens.clear(); + } + } + all_US.push_back(shift_states_dw); + + if ( all_US.size() ==0) { + wprintf(L"ERROR: Can't split US to 3D-Vector\n"); + return 1; + } + return 0; +} + int replace_PosKey_with_Keycode(std::string in) { int out=0; @@ -258,6 +397,48 @@ bool append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap) { return 0; } +bool append_other_ToVector_dw(v_dw_3D &All_Vector,GdkKeymap * keymap) { + + // create a 2D vector all filled with "--" and push to 3D-Vector + v_dw_2D Other_Vector2D = create_empty_2D_dw(All_Vector[0].size(),All_Vector[0][0].size()); + + if (Other_Vector2D.size()==0) { + wprintf(L"ERROR: create empty 2D-Vector failed"); + return 1; + } + + All_Vector.push_back(Other_Vector2D); + wprintf(L" +++++++ dimensions of Vector after append_other_ToVector_dw\t\t\t\t\t\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); + wprintf(L" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n"); + + if (All_Vector.size() < 2) { + wprintf(L"ERROR: creation of 3D-Vector failed"); + return 1; + } + + for(int i =0; i< (int) All_Vector[1].size();i++) { + + // get key name US stored in [0][i][0] and copy to name in "other"-block[1][i][0] + All_Vector[1][i][0] = All_Vector[0][i][0]; + + // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] + All_Vector[1][i][0+1] = GetKeyvalsFromKeymap(keymap,(All_Vector[1][i][0]),0); //shift state: unshifted:0 + All_Vector[1][i][1+1] = GetKeyvalsFromKeymap(keymap,(All_Vector[1][i][0]),1); //shift state: shifted:1 + + //std::wcout << L" after GetKeyvalsFromKeymap " << All_Vector[1][i][0+1]<< L" ... "<Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); + + //wprintf(L" Keycodes ->Other dw:-: %d (US):%i (%c) %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); + + //wprintf(L" Keycodes US dw : %d (US):%s, %s ---- (other):%s, %s \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str(),All_Vector[1][i][2].c_str()); + //wprintf(L" Keycodes ->Other dw:-: %d (US):%s, %s ,%s, %s \n\n",stoi(All_Vector[1][i][0]),All_Vector[1][i][1].c_str(),All_Vector[1][i][2].c_str(),All_Vector[1][i][3].c_str(),All_Vector[1][i][4].c_str()); + } + return 0; +} + v_str_2D create_empty_2D( int dim_rows,int dim_shifts) { std::string empty = "--"; @@ -274,6 +455,22 @@ v_str_2D create_empty_2D( int dim_rows,int dim_shifts) { return all_2D; } +v_dw_2D create_empty_2D_dw( int dim_rows,int dim_shifts) { + + KMX_DWORD empty = 32; + v_dw_1D shifts; + v_dw_2D all_2D; + + for ( int i=0; i< dim_rows;i++) { + for ( int j=0; j< dim_shifts;j++) { + shifts.push_back(empty); + } + all_2D.push_back(shifts); + shifts.clear(); + } + return all_2D; +} + int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; guint *keyvals; @@ -341,6 +538,45 @@ bool test_single(v_str_3D &V) { } +bool test_dw(v_dw_3D &V) { + + std::string extra = " "; + wprintf(L"+++++++ dimensions of whole Vector in test()\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); + wprintf(L"\n+++++++++ print some characters of US and Other ++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + + for ( int k=0; k<(int)V[0].size(); k++) { + if(V[0][k][2] != V[1][k][2] ) + extra = " *** "; + else + extra = " "; + + if (V[0].size()>0) { + wprintf(L" row 1 xx(US) ...... %i .. %i (%c) .. %i (%c) .. --- ",V[0][k][0] , V[0][k][1] , V[0][k][1] , V[0][k][2] , V[0][k][2] ); + wprintf(L" \n"); + wprintf(L" row 1 xx(Other)..... %i .. %i (%c) .. %i (%c) .. %s \n", V[1][k][0] , V[1][k][1], V[1][k][1] , V[1][k][2], V[1][k][2] , extra.c_str()); + wprintf(L" \n"); + } + } + wprintf(L"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + return true; +} + +bool test_single_dw(v_dw_3D &V) { + + std::string extra = " "; + wprintf(L" +++++++ dimensions of single Vector in test_single_dw()\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); + wprintf(L"\n +++++++++ print characters of SINGLE DW +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + + for ( int k=0; k<(int)V[0].size(); k++) { + if (V[0].size()>0) { + wprintf(L" row 1 (US) ...... %i .. %i (%c) .. %i (%c) ........ %i (%c).. %i (%c) --- \n", V[0][k][0] , V[0][k][1] ,V[0][k][1] , V[0][k][2], V[0][k][2] , V[0][k][3] , V[0][k][3] , V[0][k][4] , V[0][k][4] ); + } + } + wprintf(L"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + return true; +} + + // _S2 unused /* bool extract_difference( v_str_3D &All_Vector) { diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index cb767bd4f2..44b44c4d10 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -26,11 +26,15 @@ typedef std::vector v_str_1D; typedef std::vector > v_str_2D; typedef std::vector > > v_str_3D; +typedef std::vector v_dw_1D; +typedef std::vector > v_dw_2D; +typedef std::vector > > v_dw_3D; + //static int shift_state_count = 2; // use shiftstate : no shift, shift // Map of all US English virtual key codes that we can translate // -const WORD KMX_VKMap[] = { +const KMX_DWORD KMX_VKMap[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', @@ -43,36 +47,48 @@ const WORD KMX_VKMap[] = { VK_xDF, VK_OEM_102, 0 }; + + +std::wstring replaceNamesWithCharacter(std::wstring tok_wstr); // initialize GDK bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); // create a Vector with all entries of both keymaps bool createVectorForBothKeyboards(v_str_3D &All_Vector,GdkKeymap *keymap); +bool createVectorForBothKeyboards_dw(v_dw_3D &All_Vector,GdkKeymap *keymap); // read configuration file, split and write to 3D-Vector (Data for US on [0][ ][ ] ) bool write_US_ToVector(v_str_3D &vec, std::string language, const char *text); +bool write_US_ToVector_dw(v_dw_3D &vec, std::string language, const char *text); // 1. step: read complete Row of Configuration file US bool CreateCompleteRow_US(v_str_1D &complete_List, FILE *fpp, const char *text, std::string language); // 2nd step: write contents to 3D vector bool Split_US_To_3D_Vector(v_str_3D &all_US, v_str_1D completeList); +bool Split_US_To_3D_Vector_dw(v_dw_3D &all_US, v_str_1D completeList); + + // replace Name of Key (e.g. ) wih Keycode ( e.g. 15 ) int replace_PosKey_with_Keycode(std::string in); // append characters using GDK to 3D-Vector (Data for Other Language on [1][ ][ ] ) bool append_other_ToVector(v_str_3D &All_Vector, GdkKeymap *keymap); +bool append_other_ToVector_dw(v_dw_3D &All_Vector, GdkKeymap *keymap); // create an empty 2D vector containing "--" in all fields v_str_2D create_empty_2D(int dim_rows, int dim_shifts); +v_dw_2D create_empty_2D_dw(int dim_rows, int dim_shifts); // find Keyvals to fill into 2D-Vector of Other Language int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos); // testing of Vector contents ( first row of US and Other) bool test(v_str_3D &V); +bool test_dw(v_dw_3D &V); bool test_single(v_str_3D &V) ; +bool test_single_dw(v_dw_3D &V) ; /* // print both sets of characters (US and OtherLanguage) to console and file for comparison diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index d65135e05c..c471e79fda 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -17,7 +17,7 @@ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFil KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, PKMX_WCHAR filename) { - wprintf(L"#### KMX_SaveKeyboard of mc_kmxfile started"); + wprintf(L"#### KMX_SaveKeyboard of mc_kmxfile started\n"); FILE *fp; fp = Open_File(filename, u"wb"); @@ -40,14 +40,14 @@ KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, PKMX_WCHAR filename) { return FALSE; } - wprintf(L"#### KMX_SaveKeyboard of mc_kmxfile ended"); + wprintf(L"#### KMX_SaveKeyboard of mc_kmxfile ended\n"); return TRUE; } KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL FSaveDebug) { - wprintf(L" ##### KMX_WriteCompiledKeyboard of mc_kmxfile started"); + wprintf(L" ##### KMX_WriteCompiledKeyboard of mc_kmxfile started\n"); LPKMX_GROUP fgp; LPKMX_STORE fsp; LPKMX_KEY fkp; @@ -226,7 +226,7 @@ KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL delete[] buf; - wprintf(L" ##### KMX_WriteCompiledKeyboard of mc_kmxfile ended"); + wprintf(L" ##### KMX_WriteCompiledKeyboard of mc_kmxfile ended\n"); return CERR_None; } @@ -328,7 +328,7 @@ LPKMX_KEYBOARD KMX_CopyKeyboard(PKMX_BYTE bufp, PKMX_BYTE base) */ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize) { - wprintf(L" ##### KMX_FixupKeyboard of mcompile started"); + wprintf(L" ##### KMX_FixupKeyboard of mcompile started\n"); UNREFERENCED_PARAMETER(dwFileSize); KMX_DWORD i, j; @@ -368,7 +368,7 @@ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFil } } - wprintf(L" ##### KMX_FixupKeyboard of mcompile ended"); + wprintf(L" ##### KMX_FixupKeyboard of mcompile ended\n"); return kbp; } #endif diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 377c72f54f..bfa2469d76 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -234,19 +234,36 @@ int KMX_VKUSToVKUnderlyingLayout(v_str_3D &All_Vector,int inUS) { return inUS; } -/*// takes cpital character of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] -int KMX_CharFromVK(v_str_3D &All_Vector,int vkUnderlying, WCHAR VKShiftState, KMX_WCHAR* DeadKey){ +// takes capital letter of US returns cpital character of Other keyboard +int KMX_VKUSToVKUnderlyingLayout_dw(v_dw_3D &All_Vector,KMX_DWORD inUS) { + // loop and find char in US; then find char of Other + for( int i=0; i< (int)All_Vector[0].size();i++) { + // lists entries of all_vector + for( int j=1; j< (int)All_Vector[0][0].size();j++) { + KMX_DWORD KeysymUS = All_Vector[0][i][j]; + + if((inUS == KeysymUS )) { + inUS = All_Vector[1][i][2]; + return inUS; + } + } + } + return inUS; +} + +// takes cpital character of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] +KMX_DWORD KMX_CharFromVK_dw(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, WCHAR VKShiftState, KMX_WCHAR* DeadKey){ // loop and find vkUnderlying in Other; then return char with correct shiftstate for( int i=0; i< (int)All_Vector[1].size();i++) { - int CharOther = (int) *All_Vector[1][i][2].c_str(); + KMX_DWORD CharOther = All_Vector[1][i][2]; if( vkUnderlying == CharOther ) { - int CharOtherShifted = (int) *All_Vector[1][i][VKShiftState].c_str(); + KMX_DWORD CharOtherShifted = All_Vector[1][i][VKShiftState]; return CharOtherShifted; } } return vkUnderlying; -}*/ +} // takes cpital character of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] KMX_WCHAR KMX_CharFromVK(v_str_3D &All_Vector,int vkUnderlying, WCHAR VKShiftState, KMX_WCHAR* DeadKey){ @@ -306,6 +323,30 @@ bool createVectorForBothKeyboards(v_str_3D &All_Vector,GdkKeymap *keymap){ return 0; } +bool createVectorForBothKeyboards_dw(v_dw_3D &All_Vector,GdkKeymap *keymap){ + + std::string US_language = "us"; + const char* text_us = "xkb_symbols \"basic\""; + //const char* text_us = "xkb_symbols \"intl\""; + + if(write_US_ToVector_dw(All_Vector,US_language, text_us)) { + wprintf(L"ERROR: can't write US to Vector \n"); + return 1; + } + + // add contents of other keyboard to All_Vector + if( append_other_ToVector_dw(All_Vector,keymap)) { + wprintf(L"ERROR: can't append other ToVector \n"); + return 1; + } +/**/ + return 0; +} + + + + + KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]) { std::wcout << "\n##### KMX_DoConvert of mcompile started #####\n"; @@ -326,11 +367,19 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon wprintf(L"ERROR: can't InitializeGDK\n"); // create vector - v_str_3D All_Vector; + /* v_str_3D All_Vector; if(createVectorForBothKeyboards(All_Vector,keymap) ) - wprintf(L"ERROR: can't createVectorForBothKeyboards\n"); + wprintf(L"ERROR: can't createVectorForBothKeyboards\n");*/ //test(All_Vector); + // create vector + v_dw_3D All_Vector_dw; + if(createVectorForBothKeyboards_dw(All_Vector_dw,keymap) ) + wprintf(L"ERROR: can't createVectorForBothKeyboardsDWORD\n"); + + test_dw(All_Vector_dw); + + //-------------------------------------------------------------------------------- const wchar_t* ERROR = L" "; @@ -341,33 +390,36 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon for (int i = 0;KMX_VKMap[i]; i++) { // I4651 // _S2 why were those 2 functions originally not done in 1 step ?? - int vkUnderlying = KMX_VKUSToVKUnderlyingLayout(All_Vector,(int) KMX_VKMap[i] ); + //int vkUnderlying = KMX_VKUSToVKUnderlyingLayout(All_Vector,(int) KMX_VKMap[i] ); + KMX_DWORD vkUnderlying_dw = KMX_VKUSToVKUnderlyingLayout_dw(All_Vector_dw,(int) KMX_VKMap[i] ); - KMX_WCHAR ch = KMX_CharFromVK(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey); + // KMX_WCHAR ch = KMX_CharFromVK(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey); + KMX_WCHAR ch_dw = KMX_CharFromVK_dw(All_Vector_dw,vkUnderlying_dw, VKShiftState[j], &DeadKey); //_S2 mark if difference is not 32= (unshifted-shifted ) - if (!( ((int) KMX_VKMap[i] == ch ) || ((int) KMX_VKMap[i] == (int) ch -32) ) ) + if (!( ((int) KMX_VKMap[i] == ch_dw ) || ((int) KMX_VKMap[i] == (int) ch_dw -32) ) ) ERROR = L" !!!"; else ERROR = L" "; - wprintf(L" DoConvert-read i: %i (KMX_VKMap): %i (%c) ---> vkUnderlying: %i (%c) shiftstate: ( %i ) ---- > ch: %i (%c) %ls %ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); + //wprintf(L" DoConvert-read i: %i (KMX_VKMap): %i (%c) ---> vkUnderlying: %i (%c) shiftstate: ( %i ) ---- > ch: %i (%c) %ls %ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); + wprintf(L" dw DoConvert-read i: %i (KMX_VKMap): %i (%c) ---> vkUnderlying: %i (%c) shiftstate: ( %i ) ---- > ch: %i (%c) %ls %ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying_dw,vkUnderlying_dw, VKShiftState[j] , ch_dw ,ch_dw , ((int) vkUnderlying_dw != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); if(bDeadkeyConversion) { // I4552 - if(ch == 0xFFFF) { - ch = DeadKey; + if(ch_dw == 0xFFFF) { + ch_dw = DeadKey; } } - switch(ch) { + switch(ch_dw) { case 0x0000: break; // _S2 deadkeys will be done later //case 0xFFFF: ConvertDeadkey(kbd, VKMap[i], VKShiftState[j], DeadKey); break; //default: TranslateKeyboard(kbd, VKMap[i], VKShiftState[j], ch); - default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); + default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch_dw); } } } From a3daee80b5370e38c0ada8f88a5bf7abe4f676c2 Mon Sep 17 00:00:00 2001 From: Sabine Date: Sat, 29 Jul 2023 21:31:19 +0200 Subject: [PATCH 070/327] feat(linux): mcompile tidy up --- linux/mcompile/keymap/keymap.cpp | 66 +++++++++++++----------------- linux/mcompile/keymap/keymap.h | 2 - linux/mcompile/keymap/mcompile.cpp | 12 +++--- 3 files changed, 33 insertions(+), 47 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 6344c18eea..a8e9abe2ca 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -62,7 +62,7 @@ bool write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { bool write_US_ToVector_dw( v_dw_3D &vec,std::string language, const char* text) { - // _S2 relative path !! + // _S2 relative path !! std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; const char* path = FullPathName.c_str(); @@ -87,7 +87,6 @@ bool write_US_ToVector_dw( v_dw_3D &vec,std::string language, const char* text) wprintf(L"\n ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); wprintf(L" +++++++ dimensions of Vector after write_US_ToVector_dw (languages..characters..shiftstates)\t\t %li..%li..%li\n", vec.size(), vec[0].size(),vec[0][0].size()); - //test_single(vec); test_single_dw(vec); fclose(fp); return 0; @@ -242,7 +241,7 @@ bool Split_US_To_3D_Vector_dw(v_dw_3D &all_US,v_str_1D completeList) { KMX_DWORD tokens_int; std::wstring tok_wstr; - // loop through the whole vector + // loop through the whole vector for (int k = 0; k < (int)completeList.size() - 1; k++) { // remove all unwanted char @@ -267,7 +266,6 @@ bool Split_US_To_3D_Vector_dw(v_dw_3D &all_US,v_str_1D completeList) { for (std::string each; std::getline(split, each, split_char_komma); tokens.push_back(each)); - // now convert all to KMX_DWORD and fill tokens_dw tokens_dw.push_back((KMX_DWORD) Keycde); @@ -284,10 +282,10 @@ bool Split_US_To_3D_Vector_dw(v_dw_3D &all_US,v_str_1D completeList) { tokens_int = ValueInvalid; } tokens_dw.push_back(tokens_int); - - wprintf(L"<<< %i (%c) %i (%c) %i (%c) %i (%c) \n", tokens_dw[0],tokens_dw[0],tokens_dw[1],tokens_dw[1], tokens_dw[2], tokens_dw[2], tokens_dw[3],tokens_dw[3]); } + wprintf(L" Keyval %i: %i (%c) --- %i (%c) \n", tokens_dw[0],tokens_dw[1],tokens_dw[1], tokens_dw[2], tokens_dw[2]); + // now push result to shift_states shift_states_dw.push_back(tokens_dw); tokens_dw.clear(); @@ -425,16 +423,8 @@ bool append_other_ToVector_dw(v_dw_3D &All_Vector,GdkKeymap * keymap) { All_Vector[1][i][0+1] = GetKeyvalsFromKeymap(keymap,(All_Vector[1][i][0]),0); //shift state: unshifted:0 All_Vector[1][i][1+1] = GetKeyvalsFromKeymap(keymap,(All_Vector[1][i][0]),1); //shift state: shifted:1 - //std::wcout << L" after GetKeyvalsFromKeymap " << All_Vector[1][i][0+1]<< L" ... "<Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); - - //wprintf(L" Keycodes ->Other dw:-: %d (US):%i (%c) %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); - - //wprintf(L" Keycodes US dw : %d (US):%s, %s ---- (other):%s, %s \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str(),All_Vector[1][i][2].c_str()); - //wprintf(L" Keycodes ->Other dw:-: %d (US):%s, %s ,%s, %s \n\n",stoi(All_Vector[1][i][0]),All_Vector[1][i][1].c_str(),All_Vector[1][i][2].c_str(),All_Vector[1][i][3].c_str(),All_Vector[1][i][4].c_str()); + //wprintf(L" Keycodes US dw : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); + //wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); } return 0; } @@ -489,8 +479,8 @@ int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) //wprintf(L" GetKeyvalsFromKeymap: in %i -- out : %i \n", (int)keycode, out); - // _S2 if out of range of ascii return 0 or other value ? - if (out > 127) + // _S2 if out of range of what ( ascii??) return 0 or other value ? + if (out > 255) out = 0; g_free(keyvals); @@ -512,28 +502,28 @@ bool test(v_str_3D &V) { extra = " "; if (V[0].size()>0) { - wprintf(L" row 1 xx(US) ...... %s .. %s .. %s .. %s .. %s --- ", V[0][k][0].c_str(), V[0][k][1].c_str() , V[0][k][2].c_str() , V[0][k][3].c_str() , V[0][k][4].c_str() ); - wprintf(L" \n"); - wprintf(L" row 1 xx(Other)..... %s .. %s .. %s .. %s .. %s %s \n", V[1][k][0].c_str(), V[1][k][1].c_str() , V[1][k][2].c_str() , V[1][k][3].c_str() , V[1][k][4].c_str() , extra.c_str()); - wprintf(L" \n"); + //wprintf(L" row (US) ...... %s .. %s .. %s .. %s .. %s --- ", V[0][k][0].c_str(), V[0][k][1].c_str() , V[0][k][2].c_str() , V[0][k][3].c_str() , V[0][k][4].c_str() ); + //wprintf(L" \n"); + //wprintf(L" row (Other)..... %s .. %s .. %s .. %s .. %s %s \n", V[1][k][0].c_str(), V[1][k][1].c_str() , V[1][k][2].c_str() , V[1][k][3].c_str() , V[1][k][4].c_str() , extra.c_str()); + //wprintf(L" \n"); } } - wprintf(L"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + wprintf(L" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); return true; } bool test_single(v_str_3D &V) { std::string extra = " "; - wprintf(L"+++++++ dimensions of single Vector in test()\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); - wprintf(L"\n+++++++++ print characters of SINGLE +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + //wprintf(L" +++++++ dimensions of single Vector in test()\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); + //wprintf(L"\n+++++++++ print characters of SINGLE +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); for ( int k=0; k<(int)V[0].size(); k++) { if (V[0].size()>0) { - wprintf(L" row 1 (US) ...... %s .. %s .. %s .. %s .. %s --- \n", V[0][k][0].c_str(), V[0][k][1].c_str() , V[0][k][2].c_str() , V[0][k][3].c_str() , V[0][k][4].c_str() ); + //wprintf(L" row 1 (US) ...... %s .. %s .. %s .. %s .. %s --- \n", V[0][k][0].c_str(), V[0][k][1].c_str() , V[0][k][2].c_str() , V[0][k][3].c_str() , V[0][k][4].c_str() ); } } - wprintf(L"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + wprintf(L" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); return true; } @@ -541,8 +531,8 @@ bool test_single(v_str_3D &V) { bool test_dw(v_dw_3D &V) { std::string extra = " "; - wprintf(L"+++++++ dimensions of whole Vector in test()\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); - wprintf(L"\n+++++++++ print some characters of US and Other ++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + wprintf(L" +++++++ dimensions of whole Vector in test_dw()\t\t\t\t\t\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); + wprintf(L"\n+++++++++ print some characters of US and Other +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); for ( int k=0; k<(int)V[0].size(); k++) { if(V[0][k][2] != V[1][k][2] ) @@ -551,28 +541,28 @@ bool test_dw(v_dw_3D &V) { extra = " "; if (V[0].size()>0) { - wprintf(L" row 1 xx(US) ...... %i .. %i (%c) .. %i (%c) .. --- ",V[0][k][0] , V[0][k][1] , V[0][k][1] , V[0][k][2] , V[0][k][2] ); - wprintf(L" \n"); - wprintf(L" row 1 xx(Other)..... %i .. %i (%c) .. %i (%c) .. %s \n", V[1][k][0] , V[1][k][1], V[1][k][1] , V[1][k][2], V[1][k][2] , extra.c_str()); - wprintf(L" \n"); + //wprintf(L" row (US) ...... %i .. %i (%c) .. %i (%c) .. --- ",V[0][k][0] , V[0][k][1] , V[0][k][1] , V[0][k][2] , V[0][k][2] ); + //wprintf(L" \n"); + //wprintf(L" row (Other)..... %i .. %i (%c) .. %i (%c) .. %s \n", V[1][k][0] , V[1][k][1], V[1][k][1] , V[1][k][2], V[1][k][2] , extra.c_str()); + //wprintf(L" \n"); } } - wprintf(L"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + wprintf(L"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); return true; } bool test_single_dw(v_dw_3D &V) { std::string extra = " "; - wprintf(L" +++++++ dimensions of single Vector in test_single_dw()\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); - wprintf(L"\n +++++++++ print characters of SINGLE DW +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + wprintf(L" +++++++ dimensions of single Vector in test_single_dw()\t\t\t\t\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); + wprintf(L"\n +++++++++ print characters of SINGLE DW ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); for ( int k=0; k<(int)V[0].size(); k++) { if (V[0].size()>0) { - wprintf(L" row 1 (US) ...... %i .. %i (%c) .. %i (%c) ........ %i (%c).. %i (%c) --- \n", V[0][k][0] , V[0][k][1] ,V[0][k][1] , V[0][k][2], V[0][k][2] , V[0][k][3] , V[0][k][3] , V[0][k][4] , V[0][k][4] ); + wprintf(L" row (US) ...... %i .. %i (%c) .. %i (%c) ........ \n", V[0][k][0] , V[0][k][1] ,V[0][k][1] , V[0][k][2], V[0][k][2] ); } } - wprintf(L"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + wprintf(L" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); return true; } diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 44b44c4d10..f1c5cdbfec 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -68,8 +68,6 @@ bool CreateCompleteRow_US(v_str_1D &complete_List, FILE *fpp, const char *text, bool Split_US_To_3D_Vector(v_str_3D &all_US, v_str_1D completeList); bool Split_US_To_3D_Vector_dw(v_dw_3D &all_US, v_str_1D completeList); - - // replace Name of Key (e.g. ) wih Keycode ( e.g. 15 ) int replace_PosKey_with_Keycode(std::string in); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index bfa2469d76..1d3decfd7c 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -187,8 +187,8 @@ wprintf(L"_S2 * Up to here cross-platform xx :-))))) ************************** // Ubuntu: Each of the 4 columns specifies a different modifier: unmodified, shift, right alt (altgr), shift+right alt(altgr) // we have assigned these to columns 1-4 ( column o holds the keycode) // some hold up to 8 what are those ??? -const UINT VKShiftState[] = {0, 1, 2, 3, 4, 0xFFFF}; -//cconst UINT VKShiftState[] = {0, 1, 2, 0xFFFF}; +//const UINT VKShiftState[] = {0, 1, 2, 3, 4, 0xFFFF}; +const UINT VKShiftState[] = {0, 1, 2, 0xFFFF}; // _S2 shiftstate from systems-file void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, DWORD vk, UINT shift, KMX_WCHAR ch) { @@ -244,7 +244,7 @@ int KMX_VKUSToVKUnderlyingLayout_dw(v_dw_3D &All_Vector,KMX_DWORD inUS) { if((inUS == KeysymUS )) { inUS = All_Vector[1][i][2]; - return inUS; + //return inUS; } } } @@ -258,8 +258,7 @@ KMX_DWORD KMX_CharFromVK_dw(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, WCHAR VK for( int i=0; i< (int)All_Vector[1].size();i++) { KMX_DWORD CharOther = All_Vector[1][i][2]; if( vkUnderlying == CharOther ) { - KMX_DWORD CharOtherShifted = All_Vector[1][i][VKShiftState]; - return CharOtherShifted; + return All_Vector[1][i][VKShiftState]; } } return vkUnderlying; @@ -339,7 +338,6 @@ bool createVectorForBothKeyboards_dw(v_dw_3D &All_Vector,GdkKeymap *keymap){ wprintf(L"ERROR: can't append other ToVector \n"); return 1; } -/**/ return 0; } @@ -403,7 +401,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon else ERROR = L" "; //wprintf(L" DoConvert-read i: %i (KMX_VKMap): %i (%c) ---> vkUnderlying: %i (%c) shiftstate: ( %i ) ---- > ch: %i (%c) %ls %ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); - wprintf(L" dw DoConvert-read i: %i (KMX_VKMap): %i (%c) ---> vkUnderlying: %i (%c) shiftstate: ( %i ) ---- > ch: %i (%c) %ls %ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying_dw,vkUnderlying_dw, VKShiftState[j] , ch_dw ,ch_dw , ((int) vkUnderlying_dw != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); + wprintf(L" dw DoConvert-read i: %i \t(KMX_VKMap): %i (%c) \t---> vkUnderlying: %i (%c) \tshiftstate: ( %i ) \t---- > ch: %i (%c) \t%ls \t%ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying_dw,vkUnderlying_dw, VKShiftState[j] , ch_dw ,ch_dw , ((int) vkUnderlying_dw != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); From 669d3389a9ae1d74379c18af400b584dafaddae9 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 31 Jul 2023 23:07:08 +0200 Subject: [PATCH 071/327] feat(linux): mcompile use std::map in replaceNamesWithCharacter --- linux/mcompile/keymap/keymap.cpp | 58 ++++++++++++++++++++++++------ linux/mcompile/keymap/keymap.h | 4 ++- linux/mcompile/keymap/mcompile.cpp | 16 ++++----- 3 files changed, 58 insertions(+), 20 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index a8e9abe2ca..9d56dfa000 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -224,6 +224,52 @@ std::wstring replaceNamesWithCharacter(std::wstring tok_wstr){ return tok_wstr; } + KMX_DWORD replaceNamesWithCharacterInt(std::wstring tok_wstr){ + KMX_DWORD returnn_default =32; // _S2 32 as default? + KMX_DWORD tokens_int; + std::map first; + + //initializing + first[L"exclam"] = 33; + first[L"at"] = 64; + first[L"numbersign"] = 35; + first[L"dollar"] = 36; + first[L"percent"] = 37; + first[L"dead_circumflex"] = 94; /* _S2 ??? */ + first[L"ampersand"] = 38; + first[L"asterisk"] = 42; + first[L"parenleft"] = 40; + first[L"parenright"] = 41; + + first[L"equal"] = VK_EQUAL; /* BB = 187 */ + first[L"backslash"] = VK_BKSLASH; /* DC = 220 */ + first[L"bracketleft"] = VK_LBRKT; /* DB = 219 */ + first[L"bracketright"] = VK_RBRKT; /* DD = 221 */ + first[L"parenright"] = VK_COLON; /* BA = 186 */ + first[L"comma"] = VK_COMMA; /* BC = 188 */ + first[L"period"] = VK_PERIOD; /* BE = 190 */ + first[L"slash"] = VK_SLASH; /* BF = 191 */ + first[L"ssharp"] = VK_xDF; /* DF = 223 ß */ + + // _S2 ?? VK_SPACE, VK_ACCENT, VK_HYPHEN, VK_QUOTE, VK_OEM_102, + + if ( tok_wstr.size() == 1) { + tokens_int = (KMX_DWORD) ( *tok_wstr.c_str() ); + return tokens_int; + } + else { + std::map ::iterator it; + for (it = first.begin(); it != first.end(); ++it) { + std::wcout << it->first << " => " << it->second << '\n'; + if (it->first == tok_wstr) + return it->second; + } + } + + tokens_int = returnn_default; + return tokens_int; +} + bool Split_US_To_3D_Vector_dw(v_dw_3D &all_US,v_str_1D completeList) { // 1: take the whole line of the 1D-Vector and remove unwanted characters. // 2: seperate the name e.g. key from the shiftstates @@ -271,16 +317,8 @@ bool Split_US_To_3D_Vector_dw(v_dw_3D &all_US,v_str_1D completeList) { for ( int i = 1; i< tokens.size();i++) { - // check if a name can be replaced with a single character - tok_wstr = replaceNamesWithCharacter( wstring_from_string(tokens[i])); - - // for single char: copy value of char - if ( tok_wstr.size() == 1) { - tokens_int = (KMX_DWORD) ( *tok_wstr.c_str() ); - } - else { - tokens_int = ValueInvalid; - } + // replace a name with a single character ( a -> a ; equal -> = ) + tokens_int = replaceNamesWithCharacterInt( wstring_from_string(tokens[i])); tokens_dw.push_back(tokens_int); } diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index f1c5cdbfec..8e1804cbb0 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -18,7 +18,7 @@ #include "mc_savekeyboard.h" #include "helpers.h" #include "u16.h" - +#include int dummytest_keymap(); @@ -50,6 +50,7 @@ const KMX_DWORD KMX_VKMap[] = { std::wstring replaceNamesWithCharacter(std::wstring tok_wstr); +KMX_DWORD replaceNamesWithCharacterInt(std::wstring tok_wstr); // initialize GDK bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); @@ -85,6 +86,7 @@ int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos); // testing of Vector contents ( first row of US and Other) bool test(v_str_3D &V); bool test_dw(v_dw_3D &V); + bool test_single(v_str_3D &V) ; bool test_single_dw(v_dw_3D &V) ; diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 1d3decfd7c..63d477c725 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -53,6 +53,8 @@ mcompile -d runs 4 important steps: KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]); + + #if defined(_WIN32) || defined(_WIN64) int wmain(int argc, wchar_t* argv[]) { std::vector str_argv_16 = convert_argvW_to_Vector_u16str( argc, argv); @@ -236,15 +238,16 @@ int KMX_VKUSToVKUnderlyingLayout(v_str_3D &All_Vector,int inUS) { // takes capital letter of US returns cpital character of Other keyboard int KMX_VKUSToVKUnderlyingLayout_dw(v_dw_3D &All_Vector,KMX_DWORD inUS) { + KMX_DWORD outOther; // loop and find char in US; then find char of Other for( int i=0; i< (int)All_Vector[0].size();i++) { // lists entries of all_vector for( int j=1; j< (int)All_Vector[0][0].size();j++) { KMX_DWORD KeysymUS = All_Vector[0][i][j]; - if((inUS == KeysymUS )) { - inUS = All_Vector[1][i][2]; - //return inUS; + if((inUS == All_Vector[0][i][j] )) { + outOther = All_Vector[1][i][2]; + return All_Vector[1][i][2]; } } } @@ -341,10 +344,6 @@ bool createVectorForBothKeyboards_dw(v_dw_3D &All_Vector,GdkKeymap *keymap){ return 0; } - - - - KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]) { std::wcout << "\n##### KMX_DoConvert of mcompile started #####\n"; @@ -375,8 +374,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon if(createVectorForBothKeyboards_dw(All_Vector_dw,keymap) ) wprintf(L"ERROR: can't createVectorForBothKeyboardsDWORD\n"); - test_dw(All_Vector_dw); - + //test_dw(All_Vector_dw); //-------------------------------------------------------------------------------- From 06db40aa214ee3a10fa0a07742c1f61080bf7a64 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 1 Aug 2023 00:09:52 +0200 Subject: [PATCH 072/327] feat(linux): mcompile rename functions +tidy up --- linux/mcompile/keymap/keymap.cpp | 260 ++------------------------- linux/mcompile/keymap/keymap.h | 35 ++-- linux/mcompile/keymap/mc_kmxfile.cpp | 2 +- linux/mcompile/keymap/mcompile.cpp | 109 +++-------- 4 files changed, 51 insertions(+), 355 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 9d56dfa000..e8f335ef2b 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -27,8 +27,7 @@ int dummytest_keymap(){ return 0; } - -bool write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { +bool write_US_ToVector( v_dw_3D &vec,std::string language, const char* text) { // _S2 relative path !! std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; @@ -55,39 +54,6 @@ bool write_US_ToVector( v_str_3D &vec,std::string language, const char* text) { wprintf(L"\n ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); wprintf(L" +++++++ dimensions of Vector after write_US_ToVector (languages..characters..shiftstates)\t\t %li..%li..%li\n", vec.size(), vec[0].size(),vec[0][0].size()); - //test_single(vec); - fclose(fp); - return 0; -} - -bool write_US_ToVector_dw( v_dw_3D &vec,std::string language, const char* text) { - - // _S2 relative path !! - std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; - - const char* path = FullPathName.c_str(); - FILE* fp = fopen((path), "r"); - if ( !fp) { - wprintf(L"could not open file!"); - return 1; - } - - // create 1D-vector of the complete line - v_str_1D Vector_completeUS; - if( CreateCompleteRow_US(Vector_completeUS,fp , text, language)) { - wprintf(L"ERROR: can't Create complete row US \n"); - return 1; - } - - // split contents of 1D Vector to 3D vector - if( Split_US_To_3D_Vector_dw( vec,Vector_completeUS)) { - wprintf(L"ERROR: can't Split USto 3D-Vector \n"); - return 1; - } - wprintf(L"\n ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - wprintf(L" +++++++ dimensions of Vector after write_US_ToVector_dw (languages..characters..shiftstates)\t\t %li..%li..%li\n", vec.size(), vec[0].size(),vec[0][0].size()); - - test_single_dw(vec); fclose(fp); return 0; } @@ -137,96 +103,8 @@ bool CreateCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, return 0; } -bool Split_US_To_3D_Vector(v_str_3D &all_US,v_str_1D completeList) { - // 1: take the whole line of the 1D-Vector and remove unwanted characters. - // 2: seperate the name e.g. key from the shiftstates - // 3: push Names/Shiftstates to shift_states and then shiftstates to All_US, our 3D-Vector holding all Elements - - std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; - char split_bracel = '{'; - char split_char_komma = ','; - std::string empty = "--"; - v_str_1D tokens; - v_str_2D shift_states; - - // loop through the whole vector - for (int k = 0; k < (int)completeList.size() - 1; k++) { - - // remove all unwanted char - for (int i = 0; i < (int) delim.size(); i++) { - completeList[k].erase(remove(completeList[k].begin(), completeList[k].end(), delim[i]), completeList[k].end()); - } - - // only lines with ("key<.. are of interest - if (completeList[k].find("key<") != std::string::npos) { - - //split off the key names - std::istringstream split1(completeList[k]); - for (std::string each; std::getline(split1, each, split_bracel); tokens.push_back(each)); - - // replace keys names with number ( with 29,...) - int Keycde = replace_PosKey_with_Keycode(tokens[0]); - tokens[0] = std::to_string(Keycde); - - // seperate rest of the vector to its elements and push to 'tokens' - std::istringstream split(tokens[1]); - tokens.pop_back(); - - for (std::string each; std::getline(split, each, split_char_komma); tokens.push_back(each)); - // _S2 do we still need that?? - // at the moment we only use the first 4 shiftstates (non-shift+shift) so get rid of all others - //int surplus = tokens.size() - shift_state_count -1; - int surplus = tokens.size() - 4 -1; - for ( int j=0; j < surplus; j++) { - tokens.pop_back(); - } - - // now push result to shift_states - shift_states.push_back(tokens); - - tokens.clear(); - } - } - all_US.push_back(shift_states); - - if ( all_US.size() ==0) { - wprintf(L"ERROR: Can't split US to 3D-Vector\n"); - return 1; - } - return 0; -} - -std::wstring replaceNamesWithCharacter(std::wstring tok_wstr){ - - std::wstring tok_wstr_out; - //Names of Characters we use: - std::wstring UsableCharacters[10][2] = { - {L"exclam", L"!"} , - {L"at", L"@"} , - {L"numbersign", L"#"} , - {L"dollar", L"$"} , - {L"percent", L"%"} , - {L"dead_circumflex", L"^"} , - {L"ampersand", L"&"} , - {L"asterisk", L"*"} , - {L"parenleft", L"("} , - {L"parenright", L")"} }; - - int size_arr = sizeof(UsableCharacters)/sizeof(UsableCharacters[0]); - - for ( int i =0; i< size_arr;i++) { - if (tok_wstr == UsableCharacters[i][0]) { - tok_wstr_out = UsableCharacters[i][1]; - return UsableCharacters[i][1]; - } - } - - return tok_wstr; -} - - KMX_DWORD replaceNamesWithCharacterInt(std::wstring tok_wstr){ - KMX_DWORD returnn_default =32; // _S2 32 as default? - KMX_DWORD tokens_int; +KMX_DWORD replaceNamesWithCharacterInt(std::wstring tok_wstr){ + KMX_DWORD ValueInvalid = 32; // _S2 do we use space, 0, FFFF for a char we cannot use ?? std::map first; //initializing @@ -254,23 +132,19 @@ std::wstring replaceNamesWithCharacter(std::wstring tok_wstr){ // _S2 ?? VK_SPACE, VK_ACCENT, VK_HYPHEN, VK_QUOTE, VK_OEM_102, if ( tok_wstr.size() == 1) { - tokens_int = (KMX_DWORD) ( *tok_wstr.c_str() ); - return tokens_int; + return (KMX_DWORD) ( *tok_wstr.c_str() );; } else { std::map ::iterator it; for (it = first.begin(); it != first.end(); ++it) { - std::wcout << it->first << " => " << it->second << '\n'; if (it->first == tok_wstr) return it->second; } } - - tokens_int = returnn_default; - return tokens_int; + return ValueInvalid; } -bool Split_US_To_3D_Vector_dw(v_dw_3D &all_US,v_str_1D completeList) { +bool Split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { // 1: take the whole line of the 1D-Vector and remove unwanted characters. // 2: seperate the name e.g. key from the shiftstates // 3: convert to DWORD @@ -279,11 +153,10 @@ bool Split_US_To_3D_Vector_dw(v_dw_3D &all_US,v_str_1D completeList) { std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; char split_bracel = '{'; char split_char_komma = ','; - int ValueInvalid = 32; // _S2 do we use space, 0, FFFF for a char we cannot use ?? int Keycde; v_str_1D tokens; v_dw_1D tokens_dw; - v_dw_2D shift_states_dw; + v_dw_2D shift_states; KMX_DWORD tokens_int; std::wstring tok_wstr; @@ -312,25 +185,25 @@ bool Split_US_To_3D_Vector_dw(v_dw_3D &all_US,v_str_1D completeList) { for (std::string each; std::getline(split, each, split_char_komma); tokens.push_back(each)); - // now convert all to KMX_DWORD and fill tokens_dw + // now convert all to KMX_DWORD and fill tokens tokens_dw.push_back((KMX_DWORD) Keycde); - for ( int i = 1; i< tokens.size();i++) { + for ( int i = 1; i< (int) tokens.size();i++) { // replace a name with a single character ( a -> a ; equal -> = ) tokens_int = replaceNamesWithCharacterInt( wstring_from_string(tokens[i])); tokens_dw.push_back(tokens_int); } - wprintf(L" Keyval %i: %i (%c) --- %i (%c) \n", tokens_dw[0],tokens_dw[1],tokens_dw[1], tokens_dw[2], tokens_dw[2]); + //wprintf(L" Keyval %i: %i (%c) --- %i (%c) \n", tokens_dw[0],tokens_dw[1],tokens_dw[1], tokens_dw[2], tokens_dw[2]); // now push result to shift_states - shift_states_dw.push_back(tokens_dw); + shift_states.push_back(tokens_dw); tokens_dw.clear(); tokens.clear(); } } - all_US.push_back(shift_states_dw); + all_US.push_back(shift_states); if ( all_US.size() ==0) { wprintf(L"ERROR: Can't split US to 3D-Vector\n"); @@ -340,7 +213,6 @@ bool Split_US_To_3D_Vector_dw(v_dw_3D &all_US,v_str_1D completeList) { } int replace_PosKey_with_Keycode(std::string in) { - int out=0; if ( in == "key") out = 49; // TOASK correct ??? else if ( in == "key") out = 10; @@ -398,10 +270,9 @@ int replace_PosKey_with_Keycode(std::string in) { return out; } -bool append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap) { - +bool append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { // create a 2D vector all filled with "--" and push to 3D-Vector - v_str_2D Other_Vector2D = create_empty_2D(All_Vector[0].size(),All_Vector[0][0].size()); + v_dw_2D Other_Vector2D = create_empty_2D(All_Vector[0].size(),All_Vector[0][0].size()); if (Other_Vector2D.size()==0) { wprintf(L"ERROR: create empty 2D-Vector failed"); @@ -417,41 +288,6 @@ bool append_other_ToVector(v_str_3D &All_Vector,GdkKeymap * keymap) { return 1; } - for(int i =0; i< (int) All_Vector[1].size();i++) { - - // get key name US stored in [0][i][0] and copy to name in "other"-block[1][i][0] - All_Vector[1][i][0] = All_Vector[0][i][0]; - - // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] - All_Vector[1][i][0+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),0); //shift state: unshifted:0 - All_Vector[1][i][1+1] = GetKeyvalsFromKeymap(keymap,stoi(All_Vector[1][i][0]),1); //shift state: shifted:1 - - //wprintf(L" Keycodes US : %d (US):%s, %s ---- (other):%s, %s \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str(),All_Vector[1][i][2].c_str()); - //wprintf(L" Keycodes ->Other:-: %d (US):%s, %s ,%s, %s \n\n",stoi(All_Vector[1][i][0]),All_Vector[1][i][1].c_str(),All_Vector[1][i][2].c_str(),All_Vector[1][i][3].c_str(),All_Vector[1][i][4].c_str()); - } - - return 0; -} - -bool append_other_ToVector_dw(v_dw_3D &All_Vector,GdkKeymap * keymap) { - - // create a 2D vector all filled with "--" and push to 3D-Vector - v_dw_2D Other_Vector2D = create_empty_2D_dw(All_Vector[0].size(),All_Vector[0][0].size()); - - if (Other_Vector2D.size()==0) { - wprintf(L"ERROR: create empty 2D-Vector failed"); - return 1; - } - - All_Vector.push_back(Other_Vector2D); - wprintf(L" +++++++ dimensions of Vector after append_other_ToVector_dw\t\t\t\t\t\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); - wprintf(L" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n"); - - if (All_Vector.size() < 2) { - wprintf(L"ERROR: creation of 3D-Vector failed"); - return 1; - } - for(int i =0; i< (int) All_Vector[1].size();i++) { // get key name US stored in [0][i][0] and copy to name in "other"-block[1][i][0] @@ -467,24 +303,7 @@ bool append_other_ToVector_dw(v_dw_3D &All_Vector,GdkKeymap * keymap) { return 0; } -v_str_2D create_empty_2D( int dim_rows,int dim_shifts) { - - std::string empty = "--"; - v_str_1D shifts; - v_str_2D all_2D; - - for ( int i=0; i< dim_rows;i++) { - for ( int j=0; j< dim_shifts;j++) { - shifts.push_back(empty); - } - all_2D.push_back(shifts); - shifts.clear(); - } - return all_2D; -} - -v_dw_2D create_empty_2D_dw( int dim_rows,int dim_shifts) { - +v_dw_2D create_empty_2D( int dim_rows,int dim_shifts) { KMX_DWORD empty = 32; v_dw_1D shifts; v_dw_2D all_2D; @@ -527,49 +346,9 @@ int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) return out; } -bool test(v_str_3D &V) { - +bool test(v_dw_3D &V) { std::string extra = " "; - wprintf(L"+++++++ dimensions of whole Vector in test()\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); - wprintf(L"\n+++++++++ print some characters of US and Other ++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - - for ( int k=0; k<(int)V[0].size(); k++) { - if(V[0][k][2] != V[1][k][2] ) - extra = " *** "; - else - extra = " "; - - if (V[0].size()>0) { - //wprintf(L" row (US) ...... %s .. %s .. %s .. %s .. %s --- ", V[0][k][0].c_str(), V[0][k][1].c_str() , V[0][k][2].c_str() , V[0][k][3].c_str() , V[0][k][4].c_str() ); - //wprintf(L" \n"); - //wprintf(L" row (Other)..... %s .. %s .. %s .. %s .. %s %s \n", V[1][k][0].c_str(), V[1][k][1].c_str() , V[1][k][2].c_str() , V[1][k][3].c_str() , V[1][k][4].c_str() , extra.c_str()); - //wprintf(L" \n"); - } - } - wprintf(L" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - return true; -} - -bool test_single(v_str_3D &V) { - - std::string extra = " "; - //wprintf(L" +++++++ dimensions of single Vector in test()\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); - //wprintf(L"\n+++++++++ print characters of SINGLE +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - - for ( int k=0; k<(int)V[0].size(); k++) { - if (V[0].size()>0) { - //wprintf(L" row 1 (US) ...... %s .. %s .. %s .. %s .. %s --- \n", V[0][k][0].c_str(), V[0][k][1].c_str() , V[0][k][2].c_str() , V[0][k][3].c_str() , V[0][k][4].c_str() ); - } - } - wprintf(L" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - return true; -} - - -bool test_dw(v_dw_3D &V) { - - std::string extra = " "; - wprintf(L" +++++++ dimensions of whole Vector in test_dw()\t\t\t\t\t\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); + wprintf(L" +++++++ dimensions of whole Vector in test()\t\t\t\t\t\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); wprintf(L"\n+++++++++ print some characters of US and Other +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); for ( int k=0; k<(int)V[0].size(); k++) { @@ -589,10 +368,9 @@ bool test_dw(v_dw_3D &V) { return true; } -bool test_single_dw(v_dw_3D &V) { - +bool test_single(v_dw_3D &V) { std::string extra = " "; - wprintf(L" +++++++ dimensions of single Vector in test_single_dw()\t\t\t\t\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); + wprintf(L" +++++++ dimensions of single Vector in test_single()\t\t\t\t\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); wprintf(L"\n +++++++++ print characters of SINGLE DW ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); for ( int k=0; k<(int)V[0].size(); k++) { diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 8e1804cbb0..e62cc7bf5e 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -18,20 +19,15 @@ #include "mc_savekeyboard.h" #include "helpers.h" #include "u16.h" -#include int dummytest_keymap(); typedef std::vector v_str_1D; -typedef std::vector > v_str_2D; -typedef std::vector > > v_str_3D; typedef std::vector v_dw_1D; typedef std::vector > v_dw_2D; typedef std::vector > > v_dw_3D; -//static int shift_state_count = 2; // use shiftstate : no shift, shift - // Map of all US English virtual key codes that we can translate // const KMX_DWORD KMX_VKMap[] = { @@ -39,56 +35,47 @@ const KMX_DWORD KMX_VKMap[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', //_S2 those might not work yet*/ - VK_SPACE, + /*VK_SPACE, VK_ACCENT, VK_HYPHEN, VK_EQUAL, VK_LBRKT, VK_RBRKT, VK_BKSLASH, VK_COLON, VK_QUOTE, VK_COMMA, VK_PERIOD, VK_SLASH, - VK_xDF, VK_OEM_102, + VK_xDF, VK_OEM_102,*/ 0 }; - -std::wstring replaceNamesWithCharacter(std::wstring tok_wstr); KMX_DWORD replaceNamesWithCharacterInt(std::wstring tok_wstr); + // initialize GDK bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); // create a Vector with all entries of both keymaps -bool createVectorForBothKeyboards(v_str_3D &All_Vector,GdkKeymap *keymap); -bool createVectorForBothKeyboards_dw(v_dw_3D &All_Vector,GdkKeymap *keymap); +bool createVectorForBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap); // read configuration file, split and write to 3D-Vector (Data for US on [0][ ][ ] ) -bool write_US_ToVector(v_str_3D &vec, std::string language, const char *text); -bool write_US_ToVector_dw(v_dw_3D &vec, std::string language, const char *text); +bool write_US_ToVector(v_dw_3D &vec, std::string language, const char *text); // 1. step: read complete Row of Configuration file US bool CreateCompleteRow_US(v_str_1D &complete_List, FILE *fpp, const char *text, std::string language); // 2nd step: write contents to 3D vector -bool Split_US_To_3D_Vector(v_str_3D &all_US, v_str_1D completeList); -bool Split_US_To_3D_Vector_dw(v_dw_3D &all_US, v_str_1D completeList); +bool Split_US_To_3D_Vector(v_dw_3D &all_US, v_str_1D completeList); // replace Name of Key (e.g. ) wih Keycode ( e.g. 15 ) int replace_PosKey_with_Keycode(std::string in); // append characters using GDK to 3D-Vector (Data for Other Language on [1][ ][ ] ) -bool append_other_ToVector(v_str_3D &All_Vector, GdkKeymap *keymap); -bool append_other_ToVector_dw(v_dw_3D &All_Vector, GdkKeymap *keymap); +bool append_other_ToVector(v_dw_3D &All_Vector, GdkKeymap *keymap); // create an empty 2D vector containing "--" in all fields -v_str_2D create_empty_2D(int dim_rows, int dim_shifts); -v_dw_2D create_empty_2D_dw(int dim_rows, int dim_shifts); +v_dw_2D create_empty_2D(int dim_rows, int dim_shifts); // find Keyvals to fill into 2D-Vector of Other Language int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos); // testing of Vector contents ( first row of US and Other) -bool test(v_str_3D &V); -bool test_dw(v_dw_3D &V); - -bool test_single(v_str_3D &V) ; -bool test_single_dw(v_dw_3D &V) ; +bool test(v_dw_3D &V); +bool test_single(v_dw_3D &V) ; /* // print both sets of characters (US and OtherLanguage) to console and file for comparison diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index c471e79fda..37852bfc78 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -466,7 +466,7 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { #ifdef KMX_64BIT // _S2 opened for copyKeyboard-Version kbp = KMX_CopyKeyboard(buf, filebase); // _S2 opened for copyKeyboard-Version #else // _S2 opened for copyKeyboard-Version - kbp = KMX_FixupKeyboard(buf, filebase, sz); // _S2 changed from sz->sz_dw + kbp = KMX_FixupKeyboard(buf, filebase, sz); // _S2 changed from sz->sz_dw #endif // _S2 opened for copyKeyboard-Version diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 63d477c725..2854c24bbd 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -189,8 +189,8 @@ wprintf(L"_S2 * Up to here cross-platform xx :-))))) ************************** // Ubuntu: Each of the 4 columns specifies a different modifier: unmodified, shift, right alt (altgr), shift+right alt(altgr) // we have assigned these to columns 1-4 ( column o holds the keycode) // some hold up to 8 what are those ??? -//const UINT VKShiftState[] = {0, 1, 2, 3, 4, 0xFFFF}; -const UINT VKShiftState[] = {0, 1, 2, 0xFFFF}; +const UINT VKShiftState[] = {0, 1, 2, 3, 4, 0xFFFF}; +//const UINT VKShiftState[] = {0, 1, 2, 0xFFFF}; // _S2 shiftstate from systems-file void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, DWORD vk, UINT shift, KMX_WCHAR ch) { @@ -220,33 +220,12 @@ KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { } // takes capital letter of US returns cpital character of Other keyboard -int KMX_VKUSToVKUnderlyingLayout(v_str_3D &All_Vector,int inUS) { - // loop and find char in US; then find char of Other +int KMX_VKUSToVKUnderlyingLayout(v_dw_3D &All_Vector,KMX_DWORD inUS) { + // loop and find char in US; then return char of Other for( int i=0; i< (int)All_Vector[0].size();i++) { // lists entries of all_vector for( int j=1; j< (int)All_Vector[0][0].size();j++) { - int KeysymUS = (int) *All_Vector[0][i][j].c_str(); - - if( ( All_Vector[0][i][j].size() == 1 ) && (inUS == KeysymUS )) { - inUS = (int) *All_Vector[1][i][2].c_str(); - return inUS; - } - } - } - return inUS; -} - -// takes capital letter of US returns cpital character of Other keyboard -int KMX_VKUSToVKUnderlyingLayout_dw(v_dw_3D &All_Vector,KMX_DWORD inUS) { - KMX_DWORD outOther; - // loop and find char in US; then find char of Other - for( int i=0; i< (int)All_Vector[0].size();i++) { - // lists entries of all_vector - for( int j=1; j< (int)All_Vector[0][0].size();j++) { - KMX_DWORD KeysymUS = All_Vector[0][i][j]; - if((inUS == All_Vector[0][i][j] )) { - outOther = All_Vector[1][i][2]; return All_Vector[1][i][2]; } } @@ -255,8 +234,7 @@ int KMX_VKUSToVKUnderlyingLayout_dw(v_dw_3D &All_Vector,KMX_DWORD inUS) { } // takes cpital character of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] -KMX_DWORD KMX_CharFromVK_dw(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, WCHAR VKShiftState, KMX_WCHAR* DeadKey){ - +KMX_DWORD KMX_CharFromVK(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, WCHAR VKShiftState, KMX_WCHAR* DeadKey){ // loop and find vkUnderlying in Other; then return char with correct shiftstate for( int i=0; i< (int)All_Vector[1].size();i++) { KMX_DWORD CharOther = All_Vector[1][i][2]; @@ -266,24 +244,6 @@ KMX_DWORD KMX_CharFromVK_dw(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, WCHAR VK } return vkUnderlying; } -// takes cpital character of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] - -KMX_WCHAR KMX_CharFromVK(v_str_3D &All_Vector,int vkUnderlying, WCHAR VKShiftState, KMX_WCHAR* DeadKey){ - - //_S2 can I cast int to KMX_WCHAR?? - // _S2 careful if we had strings with more than 1 char in our vector elements: CharOther would only take the first CHARACTR!! - // loop and find vkUnderlying in Other; then return char with correct shiftstate - for( int i=0; i< (int)All_Vector[1].size();i++) { - int CharOther = (int) *All_Vector[1][i][2].c_str(); - - //if( vkUnderlying == CharOther ) { - if( ( All_Vector[1][i][2].size() == 1 ) && (vkUnderlying == CharOther )) { - int CharOtherShifted = (int) *All_Vector[1][i][VKShiftState].c_str(); - return (KMX_WCHAR) CharOtherShifted; - } - } - return (KMX_WCHAR) vkUnderlying; -} bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]){ // get keymap of keyboard layout in use @@ -305,11 +265,11 @@ bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]){ return 0; } -bool createVectorForBothKeyboards(v_str_3D &All_Vector,GdkKeymap *keymap){ +bool createVectorForBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ std::string US_language = "us"; - //const char* text_us = "xkb_symbols \"basic\""; - const char* text_us = "xkb_symbols \"intl\""; + const char* text_us = "xkb_symbols \"basic\""; + //const char* text_us = "xkb_symbols \"intl\""; if(write_US_ToVector(All_Vector,US_language, text_us)) { wprintf(L"ERROR: can't write US to Vector \n"); @@ -321,26 +281,6 @@ bool createVectorForBothKeyboards(v_str_3D &All_Vector,GdkKeymap *keymap){ wprintf(L"ERROR: can't append other ToVector \n"); return 1; } - - return 0; -} - -bool createVectorForBothKeyboards_dw(v_dw_3D &All_Vector,GdkKeymap *keymap){ - - std::string US_language = "us"; - const char* text_us = "xkb_symbols \"basic\""; - //const char* text_us = "xkb_symbols \"intl\""; - - if(write_US_ToVector_dw(All_Vector,US_language, text_us)) { - wprintf(L"ERROR: can't write US to Vector \n"); - return 1; - } - - // add contents of other keyboard to All_Vector - if( append_other_ToVector_dw(All_Vector,keymap)) { - wprintf(L"ERROR: can't append other ToVector \n"); - return 1; - } return 0; } @@ -364,58 +304,49 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon wprintf(L"ERROR: can't InitializeGDK\n"); // create vector - /* v_str_3D All_Vector; + v_dw_3D All_Vector; if(createVectorForBothKeyboards(All_Vector,keymap) ) - wprintf(L"ERROR: can't createVectorForBothKeyboards\n");*/ - //test(All_Vector); - - // create vector - v_dw_3D All_Vector_dw; - if(createVectorForBothKeyboards_dw(All_Vector_dw,keymap) ) wprintf(L"ERROR: can't createVectorForBothKeyboardsDWORD\n"); - //test_dw(All_Vector_dw); + //test(All_Vector); //-------------------------------------------------------------------------------- const wchar_t* ERROR = L" "; for (int j = 1; VKShiftState[j] != 0xFFFF; j++) { // I4651 + wprintf(L"\n"); // Loop through each possible key on the keyboard for (int i = 0;KMX_VKMap[i]; i++) { // I4651 // _S2 why were those 2 functions originally not done in 1 step ?? - //int vkUnderlying = KMX_VKUSToVKUnderlyingLayout(All_Vector,(int) KMX_VKMap[i] ); - KMX_DWORD vkUnderlying_dw = KMX_VKUSToVKUnderlyingLayout_dw(All_Vector_dw,(int) KMX_VKMap[i] ); - - // KMX_WCHAR ch = KMX_CharFromVK(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey); - KMX_WCHAR ch_dw = KMX_CharFromVK_dw(All_Vector_dw,vkUnderlying_dw, VKShiftState[j], &DeadKey); + KMX_DWORD vkUnderlying = KMX_VKUSToVKUnderlyingLayout(All_Vector,(int) KMX_VKMap[i] ); + KMX_WCHAR ch = KMX_CharFromVK(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey); //_S2 mark if difference is not 32= (unshifted-shifted ) - if (!( ((int) KMX_VKMap[i] == ch_dw ) || ((int) KMX_VKMap[i] == (int) ch_dw -32) ) ) + if (!( ((int) KMX_VKMap[i] == ch ) || ((int) KMX_VKMap[i] == (int) ch -32) ) ) ERROR = L" !!!"; else ERROR = L" "; - //wprintf(L" DoConvert-read i: %i (KMX_VKMap): %i (%c) ---> vkUnderlying: %i (%c) shiftstate: ( %i ) ---- > ch: %i (%c) %ls %ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); - wprintf(L" dw DoConvert-read i: %i \t(KMX_VKMap): %i (%c) \t---> vkUnderlying: %i (%c) \tshiftstate: ( %i ) \t---- > ch: %i (%c) \t%ls \t%ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying_dw,vkUnderlying_dw, VKShiftState[j] , ch_dw ,ch_dw , ((int) vkUnderlying_dw != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); + + wprintf(L" dw DoConvert-read i: %i \t(KMX_VKMap): %i (%c) \t---> vkUnderlying: %i (%c) \tshiftstate: ( %i ) \t---- > ch: %i (%c) \t%ls \t%ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); - if(bDeadkeyConversion) { // I4552 - if(ch_dw == 0xFFFF) { - ch_dw = DeadKey; + if(ch == 0xFFFF) { + ch = DeadKey; } } - switch(ch_dw) { + switch(ch) { case 0x0000: break; // _S2 deadkeys will be done later //case 0xFFFF: ConvertDeadkey(kbd, VKMap[i], VKShiftState[j], DeadKey); break; //default: TranslateKeyboard(kbd, VKMap[i], VKShiftState[j], ch); - default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch_dw); + default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); } } } From 509649890058862929ceefb62fe863d1c6200c32 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 1 Aug 2023 09:22:05 +0200 Subject: [PATCH 073/327] feat(linux): mcompile tidy up wprintf, function names/variable names --- linux/mcompile/keymap/keymap.cpp | 49 ++++++++++++++---------------- linux/mcompile/keymap/keymap.h | 19 +++++++----- linux/mcompile/keymap/mcompile.cpp | 23 +++++++------- 3 files changed, 47 insertions(+), 44 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index e8f335ef2b..cd6019cb83 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -27,7 +27,7 @@ int dummytest_keymap(){ return 0; } -bool write_US_ToVector( v_dw_3D &vec,std::string language, const char* text) { +int write_US_ToVector( v_dw_3D &vec,std::string language, const char* text) { // _S2 relative path !! std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; @@ -35,30 +35,29 @@ bool write_US_ToVector( v_dw_3D &vec,std::string language, const char* text) { const char* path = FullPathName.c_str(); FILE* fp = fopen((path), "r"); if ( !fp) { - wprintf(L"could not open file!"); + wprintf(L"ERROR: could not open file!"); return 1; } // create 1D-vector of the complete line v_str_1D Vector_completeUS; - if( CreateCompleteRow_US(Vector_completeUS,fp , text, language)) { + if( createCompleteRow_US(Vector_completeUS,fp , text, language)) { wprintf(L"ERROR: can't Create complete row US \n"); return 1; } // split contents of 1D Vector to 3D vector - if( Split_US_To_3D_Vector( vec,Vector_completeUS)) { - wprintf(L"ERROR: can't Split USto 3D-Vector \n"); + if( split_US_To_3D_Vector( vec,Vector_completeUS)) { return 1; } wprintf(L"\n ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - wprintf(L" +++++++ dimensions of Vector after write_US_ToVector (languages..characters..shiftstates)\t\t %li..%li..%li\n", vec.size(), vec[0].size(),vec[0][0].size()); + wprintf(L" +++++++ dimensions of Vector after split_US_To_3D_Vector (languages..characters..shiftstates)\t\t %li..%li..%li\n", vec.size(), vec[0].size(),vec[0][0].size()); fclose(fp); return 0; } -bool CreateCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, std::string language) { +bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, std::string language) { // in the Configuration file we find the appopriate paragraph between "xkb_symbol " and the next xkb_symbol // and then copy all rows starting with "key <" to a v1D-Vector @@ -96,16 +95,15 @@ bool CreateCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, } if (complete_List.size() <1) { - wprintf(L"ERROR: can't Create complete row US \n"); + wprintf(L"ERROR: can't create complete row US \n"); return 1; } return 0; } -KMX_DWORD replaceNamesWithCharacterInt(std::wstring tok_wstr){ - KMX_DWORD ValueInvalid = 32; // _S2 do we use space, 0, FFFF for a char we cannot use ?? - std::map first; +KMX_DWORD convertNamesToValue(std::wstring tok_wstr){ + std::map first; //initializing first[L"exclam"] = 33; @@ -135,16 +133,16 @@ KMX_DWORD replaceNamesWithCharacterInt(std::wstring tok_wstr){ return (KMX_DWORD) ( *tok_wstr.c_str() );; } else { - std::map ::iterator it; + std::map ::iterator it; for (it = first.begin(); it != first.end(); ++it) { if (it->first == tok_wstr) return it->second; } } - return ValueInvalid; + return returnIfCharInvalid; } -bool Split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { +bool split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { // 1: take the whole line of the 1D-Vector and remove unwanted characters. // 2: seperate the name e.g. key from the shiftstates // 3: convert to DWORD @@ -191,7 +189,7 @@ bool Split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { for ( int i = 1; i< (int) tokens.size();i++) { // replace a name with a single character ( a -> a ; equal -> = ) - tokens_int = replaceNamesWithCharacterInt( wstring_from_string(tokens[i])); + tokens_int = convertNamesToValue( wstring_from_string(tokens[i])); tokens_dw.push_back(tokens_int); } @@ -213,7 +211,7 @@ bool Split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { } int replace_PosKey_with_Keycode(std::string in) { - int out=0; + int out = returnIfCharInvalid; if ( in == "key") out = 49; // TOASK correct ??? else if ( in == "key") out = 10; else if ( in == "key") out = 11; @@ -275,7 +273,7 @@ bool append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { v_dw_2D Other_Vector2D = create_empty_2D(All_Vector[0].size(),All_Vector[0][0].size()); if (Other_Vector2D.size()==0) { - wprintf(L"ERROR: create empty 2D-Vector failed"); + wprintf(L"ERROR: can't create empty 2D-Vector"); return 1; } @@ -294,8 +292,8 @@ bool append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { All_Vector[1][i][0] = All_Vector[0][i][0]; // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] - All_Vector[1][i][0+1] = GetKeyvalsFromKeymap(keymap,(All_Vector[1][i][0]),0); //shift state: unshifted:0 - All_Vector[1][i][1+1] = GetKeyvalsFromKeymap(keymap,(All_Vector[1][i][0]),1); //shift state: shifted:1 + All_Vector[1][i][0+1] = getKeyvalsFromKeymap(keymap,(All_Vector[1][i][0]),0); //shift state: unshifted:0 + All_Vector[1][i][1+1] = getKeyvalsFromKeymap(keymap,(All_Vector[1][i][0]),1); //shift state: shifted:1 //wprintf(L" Keycodes US dw : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); //wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); @@ -304,21 +302,20 @@ bool append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { } v_dw_2D create_empty_2D( int dim_rows,int dim_shifts) { - KMX_DWORD empty = 32; v_dw_1D shifts; - v_dw_2D all_2D; + v_dw_2D Vector_2D; for ( int i=0; i< dim_rows;i++) { for ( int j=0; j< dim_shifts;j++) { - shifts.push_back(empty); + shifts.push_back(returnIfCharInvalid); } - all_2D.push_back(shifts); + Vector_2D.push_back(shifts); shifts.clear(); } - return all_2D; + return Vector_2D; } -int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { +int getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; guint *keyvals; gint count; @@ -334,7 +331,7 @@ int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) out = keyvals[shift_state_pos]; - //wprintf(L" GetKeyvalsFromKeymap: in %i -- out : %i \n", (int)keycode, out); + //wprintf(L" getKeyvalsFromKeymap: in %i -- out : %i \n", (int)keycode, out); // _S2 if out of range of what ( ascii??) return 0 or other value ? if (out > 255) diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index e62cc7bf5e..eb30be1f1f 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -34,7 +34,7 @@ const KMX_DWORD KMX_VKMap[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - //_S2 those might not work yet*/ + //_S2 those might not work correctly yet*/ /*VK_SPACE, VK_ACCENT, VK_HYPHEN, VK_EQUAL, VK_LBRKT, VK_RBRKT, VK_BKSLASH, @@ -44,22 +44,27 @@ const KMX_DWORD KMX_VKMap[] = { 0 }; -KMX_DWORD replaceNamesWithCharacterInt(std::wstring tok_wstr); +//_S2 Which character do we use? 0 or FFFF or ?? +// this is what we return when we find an invalid character +static KMX_DWORD returnIfCharInvalid = 32; + +// takes a std::wstring (=contents of line symbols-file ) and returns the value of the character +KMX_DWORD convertNamesToValue(std::wstring tok_wstr); // initialize GDK bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); // create a Vector with all entries of both keymaps -bool createVectorForBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap); +bool createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap); // read configuration file, split and write to 3D-Vector (Data for US on [0][ ][ ] ) -bool write_US_ToVector(v_dw_3D &vec, std::string language, const char *text); +int write_US_ToVector(v_dw_3D &vec, std::string language, const char *text); // 1. step: read complete Row of Configuration file US -bool CreateCompleteRow_US(v_str_1D &complete_List, FILE *fpp, const char *text, std::string language); +bool createCompleteRow_US(v_str_1D &complete_List, FILE *fpp, const char *text, std::string language); // 2nd step: write contents to 3D vector -bool Split_US_To_3D_Vector(v_dw_3D &all_US, v_str_1D completeList); +bool split_US_To_3D_Vector(v_dw_3D &all_US, v_str_1D completeList); // replace Name of Key (e.g. ) wih Keycode ( e.g. 15 ) int replace_PosKey_with_Keycode(std::string in); @@ -71,7 +76,7 @@ bool append_other_ToVector(v_dw_3D &All_Vector, GdkKeymap *keymap); v_dw_2D create_empty_2D(int dim_rows, int dim_shifts); // find Keyvals to fill into 2D-Vector of Other Language -int GetKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos); +int getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos); // testing of Vector contents ( first row of US and Other) bool test(v_dw_3D &V); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 2854c24bbd..ee9bab9734 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -77,7 +77,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL) argv.push_back(cmdl_par); } - wprintf(L"_S2 started run for char16_t*\n"); + wprintf(L"##### started run for char16_t*\n"); if(argc < 3 || (argc < 5 && u16cmp(argv[1], u"-u") != 0)) { // I4273// I4273 wprintf( @@ -188,9 +188,10 @@ wprintf(L"_S2 * Up to here cross-platform xx :-))))) ************************** // Ubuntu: Each of the 4 columns specifies a different modifier: unmodified, shift, right alt (altgr), shift+right alt(altgr) // we have assigned these to columns 1-4 ( column o holds the keycode) + // some hold up to 8 what are those ??? -const UINT VKShiftState[] = {0, 1, 2, 3, 4, 0xFFFF}; -//const UINT VKShiftState[] = {0, 1, 2, 0xFFFF}; +//const UINT VKShiftState[] = {0, 1, 2, 3, 4, 0xFFFF}; +const UINT VKShiftState[] = {0, 1, 2, 0xFFFF}; // _S2 shiftstate from systems-file void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, DWORD vk, UINT shift, KMX_WCHAR ch) { @@ -220,7 +221,7 @@ KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { } // takes capital letter of US returns cpital character of Other keyboard -int KMX_VKUSToVKUnderlyingLayout(v_dw_3D &All_Vector,KMX_DWORD inUS) { +KMX_DWORD KMX_VKUSToVKUnderlyingLayout(v_dw_3D &All_Vector,KMX_DWORD inUS) { // loop and find char in US; then return char of Other for( int i=0; i< (int)All_Vector[0].size();i++) { // lists entries of all_vector @@ -265,7 +266,7 @@ bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]){ return 0; } -bool createVectorForBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ +bool createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ std::string US_language = "us"; const char* text_us = "xkb_symbols \"basic\""; @@ -278,7 +279,7 @@ bool createVectorForBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ // add contents of other keyboard to All_Vector if( append_other_ToVector(All_Vector,keymap)) { - wprintf(L"ERROR: can't append other ToVector \n"); + wprintf(L"ERROR: can't append Other ToVector \n"); return 1; } return 0; @@ -301,12 +302,12 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon //_ init gdk GdkKeymap *keymap; if(InitializeGDK(&keymap , argc, argv) ) - wprintf(L"ERROR: can't InitializeGDK\n"); + wprintf(L"ERROR: can't Initialize GDK\n"); // create vector v_dw_3D All_Vector; - if(createVectorForBothKeyboards(All_Vector,keymap) ) - wprintf(L"ERROR: can't createVectorForBothKeyboardsDWORD\n"); + if(createOneVectorFromBothKeyboards(All_Vector,keymap) ) + wprintf(L"ERROR: can't create one vector from both keyboards\n"); //test(All_Vector); @@ -325,13 +326,13 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon KMX_WCHAR ch = KMX_CharFromVK(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey); - //_S2 mark if difference is not 32= (unshifted-shifted ) + //_S2 mark if difference is not 32= (unshifted-shifted ) - can go later if (!( ((int) KMX_VKMap[i] == ch ) || ((int) KMX_VKMap[i] == (int) ch -32) ) ) ERROR = L" !!!"; else ERROR = L" "; - wprintf(L" dw DoConvert-read i: %i \t(KMX_VKMap): %i (%c) \t---> vkUnderlying: %i (%c) \tshiftstate: ( %i ) \t---- > ch: %i (%c) \t%ls \t%ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); + wprintf(L" DoConvert-read i: %i \t(KMX_VKMap): %i (%c) \t---> vkUnderlying: %i (%c) \tshiftstate: ( %i ) \t---- > ch: %i (%c) \t%ls \t%ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); if(bDeadkeyConversion) { // I4552 From 1904947f32020cc58f74cb97c616706d14fd0e1b Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 1 Aug 2023 13:08:34 +0200 Subject: [PATCH 074/327] feat(linux): mcompile change type return value of functions from KMX_BOOL/bool to int/KMX_DWORD --- linux/mcompile/keymap/keymap.cpp | 18 +++++++++--------- linux/mcompile/keymap/keymap.h | 8 ++++---- linux/mcompile/keymap/mcompile.cpp | 13 +++++++++---- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index cd6019cb83..3f22a66f9a 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -35,7 +35,7 @@ int write_US_ToVector( v_dw_3D &vec,std::string language, const char* text) { const char* path = FullPathName.c_str(); FILE* fp = fopen((path), "r"); if ( !fp) { - wprintf(L"ERROR: could not open file!"); + wprintf(L"ERROR: could not open file!\n"); return 1; } @@ -95,7 +95,7 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, } if (complete_List.size() <1) { - wprintf(L"ERROR: can't create complete row US \n"); + wprintf(L"ERROR: can't create row from US \n"); return 1; } @@ -142,7 +142,7 @@ KMX_DWORD convertNamesToValue(std::wstring tok_wstr){ return returnIfCharInvalid; } -bool split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { +int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { // 1: take the whole line of the 1D-Vector and remove unwanted characters. // 2: seperate the name e.g. key from the shiftstates // 3: convert to DWORD @@ -268,12 +268,12 @@ int replace_PosKey_with_Keycode(std::string in) { return out; } -bool append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { +int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { // create a 2D vector all filled with "--" and push to 3D-Vector v_dw_2D Other_Vector2D = create_empty_2D(All_Vector[0].size(),All_Vector[0][0].size()); if (Other_Vector2D.size()==0) { - wprintf(L"ERROR: can't create empty 2D-Vector"); + wprintf(L"ERROR: can't create empty 2D-Vector\n"); return 1; } @@ -282,7 +282,7 @@ bool append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { wprintf(L" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n"); if (All_Vector.size() < 2) { - wprintf(L"ERROR: creation of 3D-Vector failed"); + wprintf(L"ERROR: creation of 3D-Vector failed\n"); return 1; } @@ -315,11 +315,11 @@ v_dw_2D create_empty_2D( int dim_rows,int dim_shifts) { return Vector_2D; } -int getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { +KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; guint *keyvals; gint count; - int out; + KMX_DWORD out; if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; @@ -329,7 +329,7 @@ int getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) if (!(shift_state_pos < count)) return 0; - out = keyvals[shift_state_pos]; + out =(KMX_DWORD) keyvals[shift_state_pos]; //wprintf(L" getKeyvalsFromKeymap: in %i -- out : %i \n", (int)keycode, out); diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index eb30be1f1f..463f1feb66 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -55,7 +55,7 @@ KMX_DWORD convertNamesToValue(std::wstring tok_wstr); bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); // create a Vector with all entries of both keymaps -bool createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap); +int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap); // read configuration file, split and write to 3D-Vector (Data for US on [0][ ][ ] ) int write_US_ToVector(v_dw_3D &vec, std::string language, const char *text); @@ -64,19 +64,19 @@ int write_US_ToVector(v_dw_3D &vec, std::string language, const char *text); bool createCompleteRow_US(v_str_1D &complete_List, FILE *fpp, const char *text, std::string language); // 2nd step: write contents to 3D vector -bool split_US_To_3D_Vector(v_dw_3D &all_US, v_str_1D completeList); +int split_US_To_3D_Vector(v_dw_3D &all_US, v_str_1D completeList); // replace Name of Key (e.g. ) wih Keycode ( e.g. 15 ) int replace_PosKey_with_Keycode(std::string in); // append characters using GDK to 3D-Vector (Data for Other Language on [1][ ][ ] ) -bool append_other_ToVector(v_dw_3D &All_Vector, GdkKeymap *keymap); +int append_other_ToVector(v_dw_3D &All_Vector, GdkKeymap *keymap); // create an empty 2D vector containing "--" in all fields v_dw_2D create_empty_2D(int dim_rows, int dim_shifts); // find Keyvals to fill into 2D-Vector of Other Language -int getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos); +KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos); // testing of Vector contents ( first row of US and Other) bool test(v_dw_3D &V); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index ee9bab9734..2b8a7ed7f1 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -266,7 +266,7 @@ bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]){ return 0; } -bool createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ +int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ std::string US_language = "us"; const char* text_us = "xkb_symbols \"basic\""; @@ -280,7 +280,7 @@ bool createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ // add contents of other keyboard to All_Vector if( append_other_ToVector(All_Vector,keymap)) { wprintf(L"ERROR: can't append Other ToVector \n"); - return 1; + return 2; } return 0; } @@ -301,13 +301,18 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon // _S2 first version with GTK - change later to XklGetGroupNames und XklGetCurrentState as Eberhard suggested //_ init gdk GdkKeymap *keymap; - if(InitializeGDK(&keymap , argc, argv) ) + if(InitializeGDK(&keymap , argc, argv)) { wprintf(L"ERROR: can't Initialize GDK\n"); + return FALSE; + + } // create vector v_dw_3D All_Vector; - if(createOneVectorFromBothKeyboards(All_Vector,keymap) ) + if(createOneVectorFromBothKeyboards(All_Vector,keymap)){ wprintf(L"ERROR: can't create one vector from both keyboards\n"); + return FALSE; + } //test(All_Vector); From 1c8ca69de398e562774920c9cb60d2465db78445 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 10 Aug 2023 15:43:33 +0200 Subject: [PATCH 075/327] feat(linux): mcompile remove helpers.h --- linux/mcompile/keymap/helpers.cpp | 35 ---------------------------- linux/mcompile/keymap/helpers.h | 19 --------------- linux/mcompile/keymap/keymap.h | 1 - linux/mcompile/keymap/mc_kmxfile.cpp | 1 - linux/mcompile/keymap/meson.build | 1 - 5 files changed, 57 deletions(-) delete mode 100644 linux/mcompile/keymap/helpers.cpp delete mode 100644 linux/mcompile/keymap/helpers.h diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp deleted file mode 100644 index ef8af0c7b2..0000000000 --- a/linux/mcompile/keymap/helpers.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "keymap.h" -#include "helpers.h" - -int dummytest_helpers(){ - std::cout<< " dummytest_helpers is available\t"; - return 0; -} - -void check_avaiability_of_modules_(){ - std::cout << "\n*********************************************************************************************\n"; - if ( X_test == 0xFF1234 ) std::cout << "\t\t\t\t\t\treaching X_Test was OK \n"; - if ( !dummytest_keymap() ) std::cout << "\treaching keymap was OK \n"; - if ( !dummytest_helpers() ) std::cout << "\treaching helpers was OK \n"; - if ( !dummytest_u16() ) std::cout << "\treaching u16 was OK \n"; - if ( !dummytest_mc_kmx_file() ) std::cout << "\treaching mc_kmx_file was OK \n"; - if ( !dummytest_mc_Savekeyboard() ) std::cout << "reaching mc_Savekeyboard was OK \n"; - if ( KEYMANID_NONKEYMAN == 0xFFFFFFFF ) std::cout << "\t\t\t\t\t\treaching KEYMANID_NONKEYMAN was OK \n"; - std::cout << "*********************************************************************************************\n"; -} - -void MyCout(std::string in, bool end, std::string pre ) { - if (end == true) - std::cout << pre << "" << in << " " << "\n"; - else - std::cout << pre << " " << in; -} - -void MyCoutW(std::wstring in, bool end, std::wstring pre) { - if (end == true) - std::wcout << pre << L" " << in << L" " << L"\n"; - else - std::wcout << pre << L" " << in; -} - - diff --git a/linux/mcompile/keymap/helpers.h b/linux/mcompile/keymap/helpers.h deleted file mode 100644 index eb4335f2b3..0000000000 --- a/linux/mcompile/keymap/helpers.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#ifndef HELPERS_H -#define HELPERS_H - -#include -#include "mc_savekeyboard.h" -#include "mc_kmxfile.h" - -int dummytest_helpers(); -void check_avaiability_of_modules_(); -void check_avaiability_of_modules_mc(); -void check_avaiability_of_modules_WC(); - -// My std::cout : writes pre-in ; 1 for end of line -void MyCout(std::string in, bool end, std::string pre = ""); -void MyCoutW(std::wstring in, bool end, std::wstring pre =L""); - - -#endif /* HELPERS_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 463f1feb66..8489b4d178 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -17,7 +17,6 @@ #include "mc_kmxfile.h" #include "kmx_file.h" #include "mc_savekeyboard.h" -#include "helpers.h" #include "u16.h" int dummytest_keymap(); diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 37852bfc78..e87393c86c 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -1,5 +1,4 @@ #include "mc_kmxfile.h" -#include "helpers.h" #include "u16.h" #include "filesystem.h" // _S2 needed? #include diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index 7143d0f8ec..83d5314f54 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -18,7 +18,6 @@ cpp_files = files( 'filesystem.cpp', 'mc_kmxfile.cpp', 'mc_savekeyboard.cpp', - 'helpers.cpp', 'u16.cpp',) mcompile = executable( From 0fa6f6680c7bd47e14eaa5c19de2667d7180f725 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 10 Aug 2023 15:45:10 +0200 Subject: [PATCH 076/327] feat(linux): mcompile -adapt translateKeyboard --- linux/mcompile/keymap/mcompile.cpp | 65 +++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 5 deletions(-) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 2b8a7ed7f1..6bba9b8ac9 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -43,7 +43,6 @@ mcompile -d runs 4 important steps: //./mcompile -d /Projects/keyman/keyman/linux/mcompile/keymap/mcompile_test.kmx bla.dll 0407 /Projects/keyman/keyman/linux/mcompile/keymap/mcompile_test_out.kmx #include "mcompile.h" -#include "helpers.h" #include // _S2 do I need that??? @@ -67,6 +66,65 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon #endif } + + +// +// TranslateKey +// +// For each key rule on the keyboard, remap its key to the +// correct shift state and key. Adjust the LCTRL+RALT -> RALT if necessary +// +void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { + + wprintf(L"\n ##### KMX_TranslateKey of mcompile started #### "); + // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. + // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" + // to provide an alternate.. + if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) + shift &= ~LCTRLFLAG; + + if(key->ShiftFlags == 0 && key->Key == ch) { + // Key is a mnemonic key with no shift state defined. + // Remap the key according to the character on the key cap. + //LogError(L"Converted mnemonic rule on line %d, + '%c' TO + [%x K_%d]", key->Line, key->Key, shift, vk); + key->ShiftFlags = ISVIRTUALKEY | shift; + key->Key = vk; + wprintf(L" 1 and changed, %i (%c) %i (%c) ", ch,ch, vk,vk); + } else if(key->ShiftFlags & VIRTUALCHARKEY && key->Key == ch) { + // Key is a virtual character key with a hard-coded shift state. + // Do not remap the shift state, just move the key. + // This will not result in 100% wonderful mappings as there could + // be overlap, depending on how keys are arranged on the target layout. + // But that is up to the designer. + //LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, key->ShiftFlags & ~VIRTUALCHARKEY, vk); + key->ShiftFlags &= ~VIRTUALCHARKEY; + key->Key = vk; + wprintf(L" 2 and changed, vk: %i (%c) ---> %i (%c) ", vk,vk, ch,ch); + } + + wprintf(L"\n ##### KMX_TranslateKey of mcompile ended ##### \n"); +} + +void KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { + + wprintf(L"\n ##### KMX_TranslateGroup of mcompile started #####\n"); + for(unsigned int i = 0; i < group->cxKeyArray; i++) { + KMX_TranslateKey(&group->dpKeyArray[i], vk, shift, ch); + } + + wprintf(L" ##### KMX_TranslateGroup of mcompile ended #####\n"); +} + +void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { + wprintf(L"\n ##### KMX_TranslateKeyboard of mcompile started #####\n"); + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + KMX_TranslateGroup(&kbd->dpGroupArray[i], vk, shift, ch); + } + } + wprintf(L" ##### KMX_TranslateKeyboard of mcompile ended #####\n"); +} + //------ run with char16_t !! ------------------------------------------------------------------------------------------------------------------------- int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ @@ -194,9 +252,6 @@ wprintf(L"_S2 * Up to here cross-platform xx :-))))) ************************** const UINT VKShiftState[] = {0, 1, 2, 0xFFFF}; // _S2 shiftstate from systems-file -void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, DWORD vk, UINT shift, KMX_WCHAR ch) { - //wprintf(L"KMX_TranslateKeyboard not implemented yet\n"); -} KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { LPKMX_STORE sp; @@ -287,7 +342,7 @@ int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]) { - std::wcout << "\n##### KMX_DoConvert of mcompile started #####\n"; + wprintf(L"\n##### KMX_DoConvert of mcompile started #####\n"); KMX_WCHAR DeadKey; if(!KMX_SetKeyboardToPositional(kbd)) return FALSE; From cd853716bf834b0bba831cff19ca2b4866d8ed34 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 10 Aug 2023 16:40:19 +0200 Subject: [PATCH 077/327] feat(linux): mcompile remove old/unused code --- linux/mcompile/keymap/keymap.cpp | 223 ++----------- linux/mcompile/keymap/keymap.h | 30 +- linux/mcompile/keymap/km_types.h | 1 - linux/mcompile/keymap/mc_kmxfile.cpp | 5 - linux/mcompile/keymap/mc_kmxfile.h | 137 +++----- linux/mcompile/keymap/mc_savekeyboard.cpp | 5 - linux/mcompile/keymap/mc_savekeyboard.h | 1 - linux/mcompile/keymap/mcompile.cpp | 368 +++------------------- linux/mcompile/keymap/mcompile.h | 1 - linux/mcompile/keymap/meson.build | 6 +- linux/mcompile/keymap/u16.cpp | 6 - linux/mcompile/keymap/u16.h | 6 - 12 files changed, 108 insertions(+), 681 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 3f22a66f9a..4a2c9fa349 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -21,12 +21,6 @@ static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) } */ - -int dummytest_keymap(){ - std::wcout<< " dummytest_keymap is available\n"; - return 0; -} - int write_US_ToVector( v_dw_3D &vec,std::string language, const char* text) { // _S2 relative path !! @@ -98,34 +92,33 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, wprintf(L"ERROR: can't create row from US \n"); return 1; } - - return 0; + return 0; } KMX_DWORD convertNamesToValue(std::wstring tok_wstr){ std::map first; //initializing - first[L"exclam"] = 33; - first[L"at"] = 64; - first[L"numbersign"] = 35; - first[L"dollar"] = 36; - first[L"percent"] = 37; - first[L"dead_circumflex"] = 94; /* _S2 ??? */ - first[L"ampersand"] = 38; - first[L"asterisk"] = 42; - first[L"parenleft"] = 40; - first[L"parenright"] = 41; + first[L"exclam"] = 33; + first[L"at"] = 64; + first[L"numbersign"] = 35; + first[L"dollar"] = 36; + first[L"percent"] = 37; + first[L"dead_circumflex"] = 94; /* _S2 ??? */ + first[L"ampersand"] = 38; + first[L"asterisk"] = 42; + first[L"parenleft"] = 40; + first[L"parenright"] = 41; - first[L"equal"] = VK_EQUAL; /* BB = 187 */ - first[L"backslash"] = VK_BKSLASH; /* DC = 220 */ - first[L"bracketleft"] = VK_LBRKT; /* DB = 219 */ - first[L"bracketright"] = VK_RBRKT; /* DD = 221 */ - first[L"parenright"] = VK_COLON; /* BA = 186 */ - first[L"comma"] = VK_COMMA; /* BC = 188 */ - first[L"period"] = VK_PERIOD; /* BE = 190 */ - first[L"slash"] = VK_SLASH; /* BF = 191 */ - first[L"ssharp"] = VK_xDF; /* DF = 223 ß */ + first[L"equal"] = VK_EQUAL; /* BB = 187 */ + first[L"backslash"] = VK_BKSLASH; /* DC = 220 */ + first[L"bracketleft"] = VK_LBRKT; /* DB = 219 */ + first[L"bracketright"] = VK_RBRKT; /* DD = 221 */ + first[L"parenright"] = VK_COLON; /* BA = 186 */ + first[L"comma"] = VK_COMMA; /* BC = 188 */ + first[L"period"] = VK_PERIOD; /* BE = 190 */ + first[L"slash"] = VK_SLASH; /* BF = 191 */ + first[L"ssharp"] = VK_xDF; /* DF = 223 ß */ // _S2 ?? VK_SPACE, VK_ACCENT, VK_HYPHEN, VK_QUOTE, VK_OEM_102, @@ -145,7 +138,7 @@ KMX_DWORD convertNamesToValue(std::wstring tok_wstr){ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { // 1: take the whole line of the 1D-Vector and remove unwanted characters. // 2: seperate the name e.g. key from the shiftstates - // 3: convert to DWORD + // 3: convert to KMX_DWORD // 4: push Names/Shiftstates to shift_states and then shiftstates to All_US, our 3D-Vector holding all Elements std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; @@ -377,176 +370,4 @@ bool test_single(v_dw_3D &V) { } wprintf(L" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); return true; -} - - -// _S2 unused -/* -bool extract_difference( v_str_3D &All_Vector) { - - // TODO define which Folder; find better name - std::ofstream Map_File("Map_US.txt"); - std::string diff =" "; - std::wstring diff_w = L" "; - - wprintf(L"-----------------------------------------------------------------------------------------------------------------------------------------------\n"); - std::wcout << "Nr of " << "\tCharacter US"<< "\tCharacter US"<<"\t\tCharacter Other"<<"\t Character Other"<< "\tdifference\n"; - std::wcout << "Key: " << "\t(no shift) " << "\t(shift) "<< "\t\t(no shift)" << "\t (shift)\n" ; - wprintf(L"-----------------------------------------------------------------------------------------------------------------------------------------------\n"); - - Map_File <<"--------------------------------------------------------------------------------------------------------------------------------------------\n"; - Map_File << "Nr of " << "\tCharacter US"<< "\t Character US"<<"\t\tCharacter Other"<<"\t Character Other"<< "\tdifference\n"; - Map_File << "Key: " << "\t(no shift) " << "\t (shift) "<< "\t\t (no shift)" << "\t (shift)\n" ; - Map_File <<"--------------------------------------------------------------------------------------------------------------------------------------------\n"; - - for ( int k=0; k<(int)All_Vector[0].size(); k++) { - if (All_Vector[0][k][1] == All_Vector[1][k][1]) { - diff = " "; - diff_w = L" "; - } - else { - diff = "*** "; - diff_w = L"*** "; - } - - wprintf(L" %d\t%s\t\t%s\t\t|\t%s\t\t %s\t\t\t%S\n", stoi(All_Vector[1][k][0]), All_Vector[0][k][1].c_str(), All_Vector[0][k][2].c_str(), All_Vector[1][k][1].c_str(), All_Vector[1][k][2].c_str(), diff_w.c_str()); - Map_File << All_Vector[0][k][0] << " \t"<<+(*(All_Vector[0][k][1].c_str()))<< "\t("<< All_Vector[0][k][1] <<")"< Other: %d (US): %s, %s ---- (other):%s, %s \n",stoi(All_Vector[1][i][0]),All_Vector[0][i][1].c_str(),All_Vector[0][i][2].c_str(),All_Vector[1][i][1].c_str(),All_Vector[1][i][2].c_str()); - return All_Vector[1][i][j] ; - } - } - } - std::cout << "US -> Other: (" << in << ": no match)\n"; - return "-"; -} - -std::string get_US_Char_FromOther(std::string in , v_str_3D &All_Vector) { - - std::string diff; - // find correct row of char in other - for( int i=0; i< (int)All_Vector[1].size();i++) { - for( int j=1; j< (int)All_Vector[1][0].size();j++) { - if ( All_Vector[1][i][j] == in ) { - if ( All_Vector[0][i][j] != All_Vector[1][i][j]) - diff =" ** "; - std::cout << "Other -> US: "<< std::setw(5)< US: (" << in << ": no match)\n"; - return "-"; - } - -std::string getKeyNrOf_USChar(std::string in , v_str_3D &All_Vector) { - - // find correct row of char in US - for( int i=0; i< (int)All_Vector[0].size();i++) { - for( int j=1; j< (int)All_Vector[0][0].size();j++) { - if ( All_Vector[0][i][j] == in ) { - std::cout << "KeyNr of US char: \t"<< All_Vector[0][i][j] << " -> " << All_Vector[0][i][0] <<"\n"; - return All_Vector[0][i][0] ; - } - } - } - return "-"; -} - -std::string getKeyNrOf_OtherChar(std::string in , v_str_3D &All_Vector) { - - // find correct row of char in US - for( int i=0; i< (int)All_Vector[1].size();i++) { - for( int j=1; j< (int)All_Vector[1][0].size();j++) { - if ( All_Vector[1][i][j] == in ) { - std::cout << "KeyNr of Other char : \t"<< All_Vector[1][i][j] << " -> " << All_Vector[1][i][0] <<"\n"; - return All_Vector[1][i][0] ; - } - } - } - return "-"; -} - -void test_in_out(v_str_3D &All_Vector) { - -std::string diff; - printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n"); - //checks mapping between US and other - std::string a = get_Other_Char_FromUS( "z", All_Vector); - std::string aa = get_Other_Char_FromUS( "Z", All_Vector); - std::string aaa = get_Other_Char_FromUS( "y", All_Vector); - std::string aaaa = get_Other_Char_FromUS( "Y", All_Vector); - - std::string b = get_US_Char_FromOther( "z", All_Vector); - std::string bb = get_US_Char_FromOther( "Z", All_Vector); - std::string bbb = get_US_Char_FromOther( "y", All_Vector); - std::string bbbb = get_US_Char_FromOther( "Y", All_Vector); - - std::string c = getKeyNrOf_OtherChar( "z", All_Vector); - std::string cc = getKeyNrOf_OtherChar( "Z", All_Vector); - std::string ccc = getKeyNrOf_OtherChar( "y", All_Vector); - std::string cccc = getKeyNrOf_OtherChar( "Y", All_Vector); - - std::string d = getKeyNrOf_USChar( "z", All_Vector); - std::string dd = getKeyNrOf_USChar( "Z", All_Vector); - std::string ddd = getKeyNrOf_USChar( "y", All_Vector); - std::string dddd = getKeyNrOf_USChar( "Y", All_Vector); - - std::cout << "get_Other_Char_FromUS z-Z-y-Y: " << ".." << a<< ".." < v_str_1D; typedef std::vector v_dw_1D; @@ -43,11 +41,11 @@ const KMX_DWORD KMX_VKMap[] = { 0 }; -//_S2 Which character do we use? 0 or FFFF or ?? // this is what we return when we find an invalid character +//_S2 Which character do we use in that case? 0 or FFFF or 32 or ?? static KMX_DWORD returnIfCharInvalid = 32; -// takes a std::wstring (=contents of line symbols-file ) and returns the value of the character +// takes a std::wstring (=contents of line symbols-file ) and returns the (int) value of the character KMX_DWORD convertNamesToValue(std::wstring tok_wstr); // initialize GDK @@ -81,28 +79,4 @@ KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state bool test(v_dw_3D &V); bool test_single(v_dw_3D &V) ; -/* -// print both sets of characters (US and OtherLanguage) to console and file for comparison -bool extract_difference(v_str_3D &All_Vector); - -// get mapped key from Other (Other->US) -std::string get_Other_Char_FromUS(std::string in, v_str_3D &All_Vector); -// get mapped key from US->Other (US->Other) -std::string get_US_Char_FromOther(std::string in, v_str_3D &All_Vector); -// get KeyNr from US -std::string getKeyNrOf_USChar(std::string in, v_str_3D &All_Vector); -// get KeyNr from Other -std::string getKeyNrOf_OtherChar(std::string in, v_str_3D &All_Vector); - -// for testing/debugging - may be deleted later -// prints out a 1:1 mapping US->Other -void print_simple_map_US(v_str_3D &All_Vector, int shiftstate); -// prints out a 1:1 mapping Other->US -void print_simple_map_Other(v_str_3D &All_Vector, int shiftstate); -// test of above functions (character mapping US <-> Other; KeyNr <-> CHaracter) -void test_in_out(v_str_3D &All_Vector); -// writing out mapping of some characters: a,b,m,w,x,y,z -void test_specific_Characters(v_str_3D &All_Vector); -*/ - # endif /*KEYMAP_H*/ diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index 01cae33a70..0bac8233fd 100644 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -98,7 +98,6 @@ typedef wchar_t KMX_UCHAR; typedef KMX_UCHAR* KMX_PUCHAR; -// _S2 do we need this ? #define VK_SPACE 0x20 #define VK_COLON 0xBA #define VK_EQUAL 0xBB diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index e87393c86c..b80483b26c 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -3,11 +3,6 @@ #include "filesystem.h" // _S2 needed? #include -int dummytest_mc_kmx_file(){ - std::cout<< " dummytest_mc_kmx_file is available\t"; - return 0; - } - KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard); KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz); diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 64ebf0e811..e2e09c484f 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -9,133 +9,74 @@ #include // _S2 can be removed later -int dummytest_mc_kmx_file(); //+++++++++++++++++++++++++++++++++++ #ifndef _KMXFILE_H #define _KMXFILE_H -typedef struct tagSTORE { - DWORD dwSystemID; - PWSTR dpName; - PWSTR dpString; -} STORE, *LPSTORE; - typedef struct KMX_tagSTORE { - KMX_DWORD dwSystemID; - PKMX_WCHAR dpName; - PKMX_WCHAR dpString; - } KMX_STORE, *LPKMX_STORE; +typedef struct KMX_tagSTORE { + KMX_DWORD dwSystemID; + PKMX_WCHAR dpName; + PKMX_WCHAR dpString; +} KMX_STORE, *LPKMX_STORE; -typedef struct tagKEY { - WCHAR Key; - DWORD Line; - DWORD ShiftFlags; - PWSTR dpOutput; - PWSTR dpContext; -} KEY, *LPKEY; - - typedef struct KMX_tagKEY { - KMX_WCHAR Key; - KMX_DWORD Line; - KMX_DWORD ShiftFlags; - PKMX_WCHAR dpOutput; - PKMX_WCHAR dpContext; - } KMX_KEY, *LPKMX_KEY; +typedef struct KMX_tagKEY { + KMX_WCHAR Key; + KMX_DWORD Line; + KMX_DWORD ShiftFlags; + PKMX_WCHAR dpOutput; + PKMX_WCHAR dpContext; +} KMX_KEY, *LPKMX_KEY; -typedef struct tagGROUP { - PWSTR dpName; - LPKEY dpKeyArray; // [LPKEY] address of first item in key array - PWSTR dpMatch; - PWSTR dpNoMatch; - DWORD cxKeyArray; // in array entries - int fUsingKeys; // group(xx) [using keys] <-- specified or not -} GROUP, *LPGROUP; - typedef struct KMX_tagGROUP { - KMX_WCHAR* dpName; - LPKMX_KEY dpKeyArray; // [LPKEY] address of first item in key array - PKMX_WCHAR dpMatch; - PKMX_WCHAR dpNoMatch; - KMX_DWORD cxKeyArray; // in array entries // _S2 was DWORD - int32_t fUsingKeys; // group(xx) [using keys] <-- specified or not - } KMX_GROUP, *LPKMX_GROUP; +typedef struct KMX_tagGROUP { + KMX_WCHAR* dpName; + LPKMX_KEY dpKeyArray; // [LPKEY] address of first item in key array + PKMX_WCHAR dpMatch; + PKMX_WCHAR dpNoMatch; + KMX_DWORD cxKeyArray; // in array entries // _S2 was DWORD + int32_t fUsingKeys; // group(xx) [using keys] <-- specified or not +} KMX_GROUP, *LPKMX_GROUP; -typedef struct tagKEYBOARD { - DWORD dwIdentifier; // Keyman compiled keyboard id - DWORD dwFileVersion; // Version of the file - Keyman 4.0 is 0x0400 +typedef struct KMX_tagKEYBOARD { + KMX_DWORD dwIdentifier; // Keyman compiled keyboard id - DWORD dwCheckSum; // As stored in keyboard. DEPRECATED as of 16.0 - DWORD xxkbdlayout; // as stored in HKEY_LOCAL_MACHINE//system//currentcontrolset//control//keyboard layouts - DWORD IsRegistered; // layout id, from same registry key - DWORD version; // keyboard version + KMX_DWORD dwFileVersion; // Version of the file - Keyman 4.0 is 0x0400 - DWORD cxStoreArray; // in array entries - DWORD cxGroupArray; // in array entries + KMX_DWORD dwCheckSum; // As stored in keyboard. DEPRECATED as of 16.0 + KMX_DWORD xxkbdlayout; // as stored in HKEY_LOCAL_MACHINE//system//currentcontrolset//control//keyboard layouts + KMX_DWORD IsRegistered; // layout id, from same registry key + KMX_DWORD version; // keyboard version - LPSTORE dpStoreArray; // [LPSTORE] address of first item in store array, from start of file - LPGROUP dpGroupArray; // [LPGROUP] address of first item in group array, from start of file + KMX_DWORD cxStoreArray; // in array entries + KMX_DWORD cxGroupArray; // in array entries - DWORD StartGroup[2]; // index of starting groups [2 of them] + LPKMX_STORE dpStoreArray; // [LPSTORE] address of first item in store array, from start of file + LPKMX_GROUP dpGroupArray; // [LPGROUP] address of first item in group array, from start of file + + KMX_DWORD StartGroup[2]; // index of starting groups [2 of them] // Ansi=0, Unicode=1 - DWORD dwFlags; // Flags for the keyboard file + KMX_DWORD dwFlags; // Flags for the keyboard file - DWORD dwHotKey; // standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) + KMX_DWORD dwHotKey; // standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) //PWSTR dpName; // offset of name //PWSTR dpLanguageName; // offset of language name; //PWSTR dpCopyright; // offset of copyright //PWSTR dpMessage; // offset of message in Keyboard About box - DWORD dpBitmapOffset; // 0038 offset of the bitmaps in the file - DWORD dwBitmapSize; // 003C size in bytes of the bitmaps + KMX_DWORD dpBitmapOffset; // 0038 offset of the bitmaps in the file + KMX_DWORD dwBitmapSize; // 003C size in bytes of the bitmaps //HBITMAP hBitmap; // handle to the bitmap in the file; -} KEYBOARD, *LPKEYBOARD; +} KMX_KEYBOARD, *LPKMX_KEYBOARD; - typedef struct KMX_tagKEYBOARD { - KMX_DWORD dwIdentifier; // Keyman compiled keyboard id - - KMX_DWORD dwFileVersion; // Version of the file - Keyman 4.0 is 0x0400 - - KMX_DWORD dwCheckSum; // As stored in keyboard. DEPRECATED as of 16.0 - KMX_DWORD xxkbdlayout; // as stored in HKEY_LOCAL_MACHINE//system//currentcontrolset//control//keyboard layouts - KMX_DWORD IsRegistered; // layout id, from same registry key - KMX_DWORD version; // keyboard version - - KMX_DWORD cxStoreArray; // in array entries - KMX_DWORD cxGroupArray; // in array entries - - LPKMX_STORE dpStoreArray; // [LPSTORE] address of first item in store array, from start of file - LPKMX_GROUP dpGroupArray; // [LPGROUP] address of first item in group array, from start of file - - KMX_DWORD StartGroup[2]; // index of starting groups [2 of them] - // Ansi=0, Unicode=1 - - KMX_DWORD dwFlags; // Flags for the keyboard file - - KMX_DWORD dwHotKey; // standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) - - //PWSTR dpName; // offset of name - //PWSTR dpLanguageName; // offset of language name; - //PWSTR dpCopyright; // offset of copyright - //PWSTR dpMessage; // offset of message in Keyboard About box - - KMX_DWORD dpBitmapOffset; // 0038 offset of the bitmaps in the file - KMX_DWORD dwBitmapSize; // 003C size in bytes of the bitmaps - //HBITMAP hBitmap; // handle to the bitmap in the file; - } KMX_KEYBOARD, *LPKMX_KEYBOARD; - -BOOL LoadKeyboard(char* fileName, LPKEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? -BOOL LoadKeyboard(wchar_t* fileName, LPKEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? -BOOL LoadKeyboard(char16_t* fileName, LPKEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? - //KMX_BOOL KMX_LoadKeyboard(char* fileName, LPKMX_KEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? - //KMX_BOOL KMX_LoadKeyboard(wchar_t* fileName, LPKMX_KEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? - KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? +KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, PKMX_WCHAR filename); KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL FSaveDebug); diff --git a/linux/mcompile/keymap/mc_savekeyboard.cpp b/linux/mcompile/keymap/mc_savekeyboard.cpp index 0c2ed5cad7..e7c6cd9cfd 100644 --- a/linux/mcompile/keymap/mc_savekeyboard.cpp +++ b/linux/mcompile/keymap/mc_savekeyboard.cpp @@ -1,10 +1,5 @@ #include "mc_savekeyboard.h" -int dummytest_mc_Savekeyboard(){ - std::cout<< " dummytest_mc_Savekeyboard is available\t"; - return 0; - } - //+++++++++++++++++++++++++++++++++++++++++ /*BOOL SaveKeyboard(LPKEYBOARD kbd, PWSTR filename) { HANDLE hOutfile = CreateFile(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); diff --git a/linux/mcompile/keymap/mc_savekeyboard.h b/linux/mcompile/keymap/mc_savekeyboard.h index da612e787d..faf9a3810b 100644 --- a/linux/mcompile/keymap/mc_savekeyboard.h +++ b/linux/mcompile/keymap/mc_savekeyboard.h @@ -3,7 +3,6 @@ #include "km_types.h" #include -int dummytest_mc_Savekeyboard(); // this file is all new _S2 diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 6bba9b8ac9..6c6f94f5de 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -44,14 +44,15 @@ mcompile -d runs 4 important steps: #include "mcompile.h" -#include // _S2 do I need that??? - //------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]); +void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch); +void KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) ; +void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) ; #if defined(_WIN32) || defined(_WIN64) @@ -67,65 +68,6 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon } - -// -// TranslateKey -// -// For each key rule on the keyboard, remap its key to the -// correct shift state and key. Adjust the LCTRL+RALT -> RALT if necessary -// -void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { - - wprintf(L"\n ##### KMX_TranslateKey of mcompile started #### "); - // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. - // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" - // to provide an alternate.. - if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) - shift &= ~LCTRLFLAG; - - if(key->ShiftFlags == 0 && key->Key == ch) { - // Key is a mnemonic key with no shift state defined. - // Remap the key according to the character on the key cap. - //LogError(L"Converted mnemonic rule on line %d, + '%c' TO + [%x K_%d]", key->Line, key->Key, shift, vk); - key->ShiftFlags = ISVIRTUALKEY | shift; - key->Key = vk; - wprintf(L" 1 and changed, %i (%c) %i (%c) ", ch,ch, vk,vk); - } else if(key->ShiftFlags & VIRTUALCHARKEY && key->Key == ch) { - // Key is a virtual character key with a hard-coded shift state. - // Do not remap the shift state, just move the key. - // This will not result in 100% wonderful mappings as there could - // be overlap, depending on how keys are arranged on the target layout. - // But that is up to the designer. - //LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, key->ShiftFlags & ~VIRTUALCHARKEY, vk); - key->ShiftFlags &= ~VIRTUALCHARKEY; - key->Key = vk; - wprintf(L" 2 and changed, vk: %i (%c) ---> %i (%c) ", vk,vk, ch,ch); - } - - wprintf(L"\n ##### KMX_TranslateKey of mcompile ended ##### \n"); -} - -void KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { - - wprintf(L"\n ##### KMX_TranslateGroup of mcompile started #####\n"); - for(unsigned int i = 0; i < group->cxKeyArray; i++) { - KMX_TranslateKey(&group->dpKeyArray[i], vk, shift, ch); - } - - wprintf(L" ##### KMX_TranslateGroup of mcompile ended #####\n"); -} - -void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { - wprintf(L"\n ##### KMX_TranslateKeyboard of mcompile started #####\n"); - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { - KMX_TranslateGroup(&kbd->dpGroupArray[i], vk, shift, ch); - } - } - wprintf(L" ##### KMX_TranslateKeyboard of mcompile ended #####\n"); -} - -//------ run with char16_t !! ------------------------------------------------------------------------------------------------------------------------- int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ // convert std::vector to std::vector @@ -135,7 +77,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL) argv.push_back(cmdl_par); } - wprintf(L"##### started run for char16_t*\n"); + wprintf(L"##### started run\n"); if(argc < 3 || (argc < 5 && u16cmp(argv[1], u"-u") != 0)) { // I4273// I4273 wprintf( @@ -182,7 +124,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL) wprintf(L"mcompile%ls \"%ls\" \"%ls\" \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d" : L"", u16fmt((const char16_t*) infile).c_str(), u16fmt((const char16_t*) indll).c_str(), u16fmt((const char16_t*) kbid).c_str(), u16fmt((const char16_t*) outfile).c_str() ); // I4174 -/* // 1. Load the keyman keyboard file + // 1. Load the keyman keyboard file // 2. For each key on the system layout, determine its output character and perform a // 1-1 replacement on the keyman keyboard of that character with the base VK + shift @@ -207,7 +149,6 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL) // // 3. Write the new keyman keyboard file -*/ LPKMX_KEYBOARD kmxfile; @@ -217,8 +158,6 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL) return 3; } -wprintf(L"_S2 * Up to here cross-platform xx :-))))) ******************************************************\n"); - #if defined(_WIN32) || defined(_WIN64) // _S2 DoConvert for windows needs to be done later ( can it be copied from engine/mcompile ?) /*if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552F @@ -239,19 +178,16 @@ wprintf(L"_S2 * Up to here cross-platform xx :-))))) ************************** return 0 ; } - +// comment from win-version // Map of all shift states that we will work with -// //const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; +// my comment for Lin version // Ubuntu: Each of the 4 columns specifies a different modifier: unmodified, shift, right alt (altgr), shift+right alt(altgr) // we have assigned these to columns 1-4 ( column o holds the keycode) - // some hold up to 8 what are those ??? //const UINT VKShiftState[] = {0, 1, 2, 3, 4, 0xFFFF}; const UINT VKShiftState[] = {0, 1, 2, 0xFFFF}; -// _S2 shiftstate from systems-file - KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { LPKMX_STORE sp; @@ -359,7 +295,6 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon if(InitializeGDK(&keymap , argc, argv)) { wprintf(L"ERROR: can't Initialize GDK\n"); return FALSE; - } // create vector @@ -369,8 +304,6 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon return FALSE; } - //test(All_Vector); - //-------------------------------------------------------------------------------- const wchar_t* ERROR = L" "; @@ -386,7 +319,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon KMX_WCHAR ch = KMX_CharFromVK(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey); - //_S2 mark if difference is not 32= (unshifted-shifted ) - can go later + //_S2 marker in output if difference is not 32= (unshifted-shifted ) - can go later if (!( ((int) KMX_VKMap[i] == ch ) || ((int) KMX_VKMap[i] == (int) ch -32) ) ) ERROR = L" !!!"; else @@ -406,8 +339,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon // _S2 deadkeys will be done later //case 0xFFFF: ConvertDeadkey(kbd, VKMap[i], VKShiftState[j], DeadKey); break; - //default: TranslateKeyboard(kbd, VKMap[i], VKShiftState[j], ch); - default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); + //default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); } } } @@ -429,189 +361,15 @@ void KMX_LogError(const KMX_WCHART* m1,int m2) { } -/* unused _S2 - -bool get_OtherKeysym_From_US_Keysym(v_str_3D &All_Vector,int inUS,int &outOther){ - - //MyCoutW(L" #### get_OtherKeysym_From_US_Keysym of keymap started", 1); - // loop and find char in US; then find char of Other - for( int i=0; i< (int)All_Vector[1].size();i++) { - for( int j=0; j< (int)All_Vector[1][0].size();j++) { - - int KeysymUS = (int) *All_Vector[0][i][j].c_str(); - int KeysymOther = (int) *All_Vector[1][i][j].c_str(); - std::wstring KeysymUS_wstr = wstring_from_string(All_Vector[0][i][j]); - - if( inUS == KeysymUS ) { - //wprintf(L" FOUND Value in OTHER !!!!! : Other in: %i ( %s ) -- Keycode : %s -- US out ########: %i ( %s ) \n", KeysymUS,All_Vector[0][i][j].c_str(), All_Vector[1][i][0].c_str() , KeysymOther,All_Vector[1][i][j].c_str()); - wprintf(L" get_OtherKeysym_From_US_Keysym FOUND Value in US !!!!! : Other in: %i ( %s ) -- Keycode : %s -- US out ########: %i ( %s ) \n", - KeysymUS,All_Vector[0][i][j].c_str(), All_Vector[1][i][0].c_str() , KeysymOther,All_Vector[1][i][j].c_str()); - outOther = KeysymOther; - - //MyCoutW(L" #### get_OtherKeysym_From_US_Keysym of keymap ended", 1); - return true; - } - } - } - return true; -} - -*/ - - -// ---- old ---------------------------------------------------------- - - -// -// m-to-p.cpp : Defines the entry point for the console application. -// -// Note: this program deliberately leaks memory as it has a very short life cycle and managing the memory allocations -// for the subcomponents of the compiled keyboard is an unnecessary optimisation. Just so you know. -// -/* -#include "pch.h" -#include - -#include -#include -#include - -BOOL DoConvert(LPKEYBOARD kbd, PWSTR kbid, BOOL bDeadkeyConversion); -BOOL SaveKeyboard(LPKEYBOARD kbd, PWSTR filename); -bool ImportRules(WCHAR *kbid, LPKEYBOARD kp, std::vector *FDeadkeys, BOOL bDeadkeyConversion); // I4353 // I4327 -BOOL ConvertKeyboardToUnicode(LPKEYBOARD kbd); // I4273 -int run(int argc, wchar_t * argv[]); - -std::vector FDeadkeys; // I4353 - -#define KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE_MCOMPILE KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE ".mcompile" - -int wmain(int argc, wchar_t * argv[]) -{ - return keyman_sentry_wmain(false, KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE_MCOMPILE, argc, argv, run); -} - -int run(int argc, wchar_t * argv[]) -{ - if(argc < 3 || (argc < 5 && wcscmp(argv[1], L"-u") != 0)) { // I4273 - printf( - "Usage: mcompile -u infile.kmx outfile.kmx\n" - " mcompile [-d] infile.kmx kbdfile.dll kbid outfile.kmx\n" - " With -u parameter, converts keyboard from ANSI to Unicode\n" - " Otherwise, mcompile converts a Keyman mnemonic layout to a\n" - " positional one based on the Windows keyboard\n" - " layout file given by kbdfile.dll\n\n" - " kbid should be a hexadecimal number e.g. 409 for US English\n" - " -d convert deadkeys to plain keys\n"); // I4552 - - return 1; - } - - if(wcscmp(argv[1], L"-u") == 0) { // I4273 - wchar_t *infile = argv[2], *outfile = argv[3]; - - LPKEYBOARD kmxfile; - - if(!LoadKeyboard(infile, &kmxfile)) { - LogError(L"Failed to load keyboard (%d)", GetLastError()); - return 3; - } - - if(ConvertKeyboardToUnicode(kmxfile)) { - SaveKeyboard(kmxfile, outfile); - } - - //DeleteReallocatedPointers(kmxfile); :TODO - delete[] kmxfile; - - return 0; // I4279 - } - - int bDeadkeyConversion = wcscmp(argv[1], L"-d") == 0; // I4552 - int n = (bDeadkeyConversion ? 2 : 1); - - wchar_t *infile = argv[n], *indll = argv[n+1], *kbid = argv[n+2], *outfile = argv[n+3]; - - wprintf(L"mcompile%ls \"%ls\" \"%ls\" \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d":L"", infile, indll, kbid, outfile); // I4174 - - // 1. Load the keyman keyboard file - - // 2. For each key on the system layout, determine its output character and perform a - // 1-1 replacement on the keyman keyboard of that character with the base VK + shift - // state. This fixup will transform the char to a vk, which will avoid any issues - // with the key. - // - // --> deadkeys we will attack after the POC - // - // For each deadkey, we need to determine its possible outputs. Then we generate a VK - // rule for that deadkey, e.g. [K_LBRKT] > dk(c101) - // - // Next, update each rule that references the output from that deadkey to add an extra - // context deadkey at the end of the context match, e.g. 'a' dk(c101) + [K_SPACE] > 'b'. - // This will require a memory layout change for the .kmx file, plus fixups on the - // context+output index offsets - // - // --> virtual character keys - // - // [CTRL ' '] : we look at the character, and replace it in the same way, but merely - // switch the shift state from the VIRTUALCHARKEY to VIRTUALKEY, without changing any - // other properties of the key. - // - - // 3. Write the new keyman keyboard file - - if(!LoadNewLibrary(indll)) { - LogError(L"Failed to load keyboard DLL (%d)", GetLastError()); - return 2; - } - - LPKEYBOARD kmxfile; - - if(!LoadKeyboard(infile, &kmxfile)) { - LogError(L"Failed to load keyboard (%d)", GetLastError()); - return 3; - } - - if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552 - SaveKeyboard(kmxfile, outfile); - } - - //DeleteReallocatedPointers(kmxfile); :TODO - delete kmxfile; - - return 0; -} - - -// -// Map of all US English virtual key codes that we can translate -// -const WORD VKMap[] = { - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - VK_SPACE, - VK_ACCENT, VK_HYPHEN, VK_EQUAL, - VK_LBRKT, VK_RBRKT, VK_BKSLASH, - VK_COLON, VK_QUOTE, - VK_COMMA, VK_PERIOD, VK_SLASH, - VK_xDF, VK_OEM_102, - 0 -}; - - -// -// Map of all shift states that we will work with -// -const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; - // // TranslateKey // // For each key rule on the keyboard, remap its key to the // correct shift state and key. Adjust the LCTRL+RALT -> RALT if necessary // -void TranslateKey(LPKEY key, WORD vk, UINT shift, WCHAR ch) { +void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { + wprintf(L"\n ##### KMX_TranslateKey of mcompile started #### "); // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. @@ -624,6 +382,7 @@ void TranslateKey(LPKEY key, WORD vk, UINT shift, WCHAR ch) { //LogError(L"Converted mnemonic rule on line %d, + '%c' TO + [%x K_%d]", key->Line, key->Key, shift, vk); key->ShiftFlags = ISVIRTUALKEY | shift; key->Key = vk; + wprintf(L" 1 and changed, %i (%c) %i (%c) ", ch,ch, vk,vk); } else if(key->ShiftFlags & VIRTUALCHARKEY && key->Key == ch) { // Key is a virtual character key with a hard-coded shift state. // Do not remap the shift state, just move the key. @@ -633,23 +392,49 @@ void TranslateKey(LPKEY key, WORD vk, UINT shift, WCHAR ch) { //LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, key->ShiftFlags & ~VIRTUALCHARKEY, vk); key->ShiftFlags &= ~VIRTUALCHARKEY; key->Key = vk; + wprintf(L" 2 and changed, vk: %i (%c) ---> %i (%c) ", vk,vk, ch,ch); } + + wprintf(L"\n ##### KMX_TranslateKey of mcompile ended ##### \n"); } -void TranslateGroup(LPGROUP group, WORD vk, UINT shift, WCHAR ch) { +void KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { + + wprintf(L"\n ##### KMX_TranslateGroup of mcompile started #####\n"); for(unsigned int i = 0; i < group->cxKeyArray; i++) { - TranslateKey(&group->dpKeyArray[i], vk, shift, ch); + KMX_TranslateKey(&group->dpKeyArray[i], vk, shift, ch); } + + wprintf(L" ##### KMX_TranslateGroup of mcompile ended #####\n"); } -void TranslateKeyboard(LPKEYBOARD kbd, WORD vk, UINT shift, WCHAR ch) { +void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { + wprintf(L"\n ##### KMX_TranslateKeyboard of mcompile started #####\n"); for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { if(kbd->dpGroupArray[i].fUsingKeys) { - TranslateGroup(&kbd->dpGroupArray[i], vk, shift, ch); + KMX_TranslateGroup(&kbd->dpGroupArray[i], vk, shift, ch); } } + wprintf(L" ##### KMX_TranslateKeyboard of mcompile ended #####\n"); } +// ---- old copy code from here ---------------------------------------------------------- + + +/* +bool ImportRules(WCHAR *kbid, LPKEYBOARD kp, std::vector *FDeadkeys, BOOL bDeadkeyConversion); // I4353 // I4327 +BOOL ConvertKeyboardToUnicode(LPKEYBOARD kbd); // I4273 + +std::vector FDeadkeys; // I4353 + +#define KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE_MCOMPILE KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE ".mcompile" + +// +// Map of all shift states that we will work with +// +const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; + + void ReportUnconvertedKeyRule(LPKEY key) { if(key->ShiftFlags == 0) { LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); @@ -838,77 +623,10 @@ void ConvertDeadkey(LPKEYBOARD kbd, WORD vk, UINT shift, WCHAR deadkey) { } } -BOOL SetKeyboardToPositional(LPKEYBOARD kbd) { - LPSTORE sp; - UINT i; - for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { - if(sp->dwSystemID == TSS_MNEMONIC) { - if(!sp->dpString) { - LogError(L"Invalid &mnemoniclayout system store"); - return FALSE; - } - if(wcscmp(sp->dpString, L"1") != 0) { - LogError(L"Keyboard is not a mnemonic layout keyboard"); - return FALSE; - } - *sp->dpString = '0'; - return TRUE; - } - } - - LogError(L"Keyboard is not a mnemonic layout keyboard"); - return FALSE; -} - -BOOL DoConvert(LPKEYBOARD kbd, LPWSTR kbid, BOOL bDeadkeyConversion) { // I4552 - WCHAR DeadKey; - - if(!SetKeyboardToPositional(kbd)) return FALSE; - - // Go through each of the shift states - base, shift, ctrl+alt, ctrl+alt+shift, [caps vs ncaps?] - // Currently, we go in this order so the 102nd key works. But this is not ideal for keyboards without 102nd key: // I4651 - // it catches only the first key that matches a given rule, but multiple keys may match that rule. This is particularly - // evident for the 102nd key on UK, for example, where \ can be generated with VK_OEM_102 or AltGr+VK_QUOTE. - // For now, we get the least shifted version, which is hopefully adequate. - - for(int j = 0; VKShiftState[j] != 0xFFFF; j++) { // I4651 - // Go through each possible key on the keyboard - for(int i = 0; VKMap[i]; i++) { // I4651 - UINT vkUnderlying = VKUSToVKUnderlyingLayout(VKMap[i]); - - WCHAR ch = CharFromVK(vkUnderlying, VKShiftState[j], &DeadKey); - - //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); - - if(bDeadkeyConversion) { // I4552 - if(ch == 0xFFFF) { - ch = DeadKey; - } - } - - switch(ch) { - case 0x0000: break; - case 0xFFFF: ConvertDeadkey(kbd, VKMap[i], VKShiftState[j], DeadKey); break; - default: TranslateKeyboard(kbd, VKMap[i], VKShiftState[j], ch); - } - - // - } - } - - ReportUnconvertedKeyboardRules(kbd); - - if(!ImportRules(kbid, kbd, &FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 - return FALSE; - } - - return TRUE; -} - */ -//---------old------------------------------------------- +//---------old- - original code------------------------------------------ /*#include "pch.h" #include diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 12aa452d40..481723efa6 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -27,7 +27,6 @@ int run(int argc, std::vector str_argv, char* argv[]); void KMX_LogError(const KMX_WCHART* m1, int m2 = 0); - struct DeadkeyMapping { // I4353 KMX_WCHAR deadkey, dkid; KMX_UINT shift; diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index 83d5314f54..4beec48897 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -1,5 +1,3 @@ - - project('mcompile', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') @@ -7,8 +5,8 @@ project('mcompile', 'c', 'cpp', #do I need a Version of dependency? gtk = dependency('gtk+-3.0', version: '>= 2.4') x11 = dependency('x11', version: '>= 1.6') -xkb = dependency('xkbcommon', version: '>= 0.0') -libxklavier = dependency('libxklavier', version: '>= 0.0') +xkb = dependency('xkbcommon') +libxklavier = dependency('libxklavier') deps = [gtk, x11, xkb,libxklavier] diff --git a/linux/mcompile/keymap/u16.cpp b/linux/mcompile/keymap/u16.cpp index 28d61a1d39..2fbe03da5f 100644 --- a/linux/mcompile/keymap/u16.cpp +++ b/linux/mcompile/keymap/u16.cpp @@ -7,12 +7,6 @@ #include -int dummytest_u16(){ - std::cout<< " dummytest_u16 \tis available\t"; - return 0; -} - - std::vector convert_argv_to_Vector_u16str(int argc, char* argv[]) { std::vector vector_u16; diff --git a/linux/mcompile/keymap/u16.h b/linux/mcompile/keymap/u16.h index fc83a26e0b..34cc5f275b 100644 --- a/linux/mcompile/keymap/u16.h +++ b/linux/mcompile/keymap/u16.h @@ -2,21 +2,15 @@ #define U16_H #include - #include #include #include #include #include "km_types.h" - -int dummytest_u16(); std::vector convert_argvW_to_Vector_u16str(int argc, wchar_t* argv[]); std::vector convert_argv_to_Vector_u16str(int argc, char* argv[]); -wchar_t* wchart_from_char( char* c); -wchar_t* wchart_from_char16( char16_t** c); - std::string string_from_wstring(std::wstring const str); std::wstring wstring_from_string(std::string const str); std::wstring wstring_from_u16string(std::u16string const str16); From e697a5f0aee9cf9f1f5ca2dd7ba138010137fdd0 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 10 Aug 2023 17:03:45 +0200 Subject: [PATCH 078/327] feat(linux): mcompile remove more old/unused code --- linux/mcompile/keymap/README.md | 20 +- linux/mcompile/keymap/keymap.cpp | 2 - linux/mcompile/keymap/kmx_file.h | 157 +++----- linux/mcompile/keymap/mc_kmxfile.cpp | 35 +- linux/mcompile/keymap/mc_savekeyboard.cpp | 423 ---------------------- linux/mcompile/keymap/mc_savekeyboard.h | 14 +- linux/mcompile/keymap/mcompile.cpp | 29 +- 7 files changed, 79 insertions(+), 601 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index aad31d4823..dc6715dec6 100644 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -7,36 +7,26 @@ Sample program that reads US basic keyboard and compares to key value group # Keymap TODO check if US basic is the right Keyboard to compare with -TODO non-letter characters don't work OK yet -TODO Umlauts don't work OK yet +TODO deadkeys don't work yet TODO path for xkb/symbols as compile time option in meson TODO check how many/which shift states we use ( at the moment we read all shiftstate-columns of US but then use only 2 colums (non-shift + shift) then use as many colums for Other ) TODO define folder to store File_US.txt" in and find better name TODO get rid of GTK functions that are deprecated and use X11 instead TODO retrieve name of Other keyboard and use appropriate name instead of "Other" -TODO use/adapt TranslateKeyboard() to work on Linux/cross-platform TODO mcompile.cpp: open mcompile -u - option TODO check if I can use files from some other keyman path instead of a copy in keymap ( e.g. filesystem.h exists elsewhere) TODO remove kbdid and kbd for Linux -TODO remove unneccessary testing fungctions in keymap.cpp/h -TODO remove helpers.cpp/h -TODO usw only wprintf check if printf is used somewhere... -ToDo remove std::cout std::wcout -TODO several Versions of KMX_LoadKeyboard TODO shiftstate-count TODO keymap SplitToV.cpp exchange 4 with genaerated shiftcount TODO check if part with surplus is neccessary TODO shift-statevector -TODO meson.build do I need version of dependency?? -TODO meson remove helpers.cpp -TODO remove mc_savekeyboard.cpp/h -TODO remove dummytest() -TODO see which functions I need from u16.cpp/h -TODO see which data types I can remove from km_types.h -TODO replace/remove old structs or move kmx_structs to the left side of file TODO ... //--------------------------- TOASK is using string OK, or do we use char, wchar? TOASK a-z, A_Z or more keys? ... TOASK ado we need mcompile -u option? + +./mcompile -d /Projects/keyman/keyman/linux/mcompile/keymap/mcompile_test.kmx bla.dll 0407 /Projects/keyman/keyman/linux/mcompile/keymap/mcompile_test_out.kmx + +./mcompile -d /home/mcompileTest/Source/mcompile_test.kmx bla.dll 0407 /home/mcompileTest/Source_after_run_mcompile/mcompile_test_out.kmx diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 4a2c9fa349..51ef063773 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -64,7 +64,6 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, // _S2 TODO define folder to store File in std::ofstream KeyboardFile("File_" + language + ".txt"); - printf("Keyboard %s\n", text); KeyboardFile << "Keyboard" << text << "\n"; if (fp) { @@ -81,7 +80,6 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, // as long as we are in the same xkb_symbol layout block and find "key <" we push the whole line into a 1D-vector if ((print_OK) && (std::string(str_buf).find(key) != std::string::npos)) { - printf("%s", buffer); complete_List.push_back(buffer); KeyboardFile << buffer; } diff --git a/linux/mcompile/keymap/kmx_file.h b/linux/mcompile/keymap/kmx_file.h index 777880ab59..5187f09683 100644 --- a/linux/mcompile/keymap/kmx_file.h +++ b/linux/mcompile/keymap/kmx_file.h @@ -301,141 +301,76 @@ namespace kmx { #define K_MODIFIERFLAG 0x007F #define K_NOTMODIFIERFLAG 0xFF00 // I4548 -struct COMP_STORE { - DWORD dwSystemID; - DWORD dpName; - DWORD dpString; -}; - - struct KMX_COMP_STORE { - KMX_DWORD dwSystemID; - KMX_DWORD dpName; - KMX_DWORD dpString; - }; - -struct COMP_KEY { - WORD Key; - DWORD Line; - DWORD ShiftFlags; - DWORD dpOutput; - DWORD dpContext; +struct KMX_COMP_STORE { + KMX_DWORD dwSystemID; + KMX_DWORD dpName; + KMX_DWORD dpString; }; - struct KMX_COMP_KEY { - KMX_WORD Key; - KMX_WORD _reserved; - KMX_DWORD Line; - KMX_DWORD ShiftFlags; - KMX_DWORD dpOutput; - KMX_DWORD dpContext; - }; - - -struct COMP_GROUP { - DWORD dpName; - DWORD dpKeyArray; // [LPKEY] address of first item in key array - DWORD dpMatch; - DWORD dpNoMatch; - DWORD cxKeyArray; // in array entries - BOOL fUsingKeys; // group(xx) [using keys] <-- specified or not +struct KMX_COMP_KEY { + KMX_WORD Key; + KMX_WORD _reserved; + KMX_DWORD Line; + KMX_DWORD ShiftFlags; + KMX_DWORD dpOutput; + KMX_DWORD dpContext; }; - struct KMX_COMP_GROUP { - KMX_DWORD dpName; - KMX_DWORD dpKeyArray; // [LPKEY] address of first item in key array - KMX_DWORD dpMatch; - KMX_DWORD dpNoMatch; - KMX_DWORD cxKeyArray; // in array entries - KMX_BOOL fUsingKeys; // group(xx) [using keys] <-- specified or not - }; +struct KMX_COMP_GROUP { + KMX_DWORD dpName; + KMX_DWORD dpKeyArray; // [LPKEY] address of first item in key array + KMX_DWORD dpMatch; + KMX_DWORD dpNoMatch; + KMX_DWORD cxKeyArray; // in array entries + KMX_BOOL fUsingKeys; // group(xx) [using keys] <-- specified or not + }; -struct COMP_KEYBOARD { - DWORD dwIdentifier; // 0000 Keyman compiled keyboard id +struct KMX_COMP_KEYBOARD { + KMX_DWORD dwIdentifier; // 0000 Keyman compiled keyboard id - DWORD dwFileVersion; // 0004 Version of the file - Keyman 4.0 is 0x0400 + KMX_DWORD dwFileVersion; // 0004 Version of the file - Keyman 4.0 is 0x0400 - DWORD dwCheckSum; // 0008 As stored in keyboard. DEPRECATED as of 16.0 - DWORD KeyboardID; // 000C as stored in HKEY_LOCAL_MACHINE//system//currentcontrolset//control//keyboard layouts - DWORD IsRegistered; // 0010 - DWORD version; // 0014 keyboard version + KMX_DWORD dwCheckSum; // 0008 As stored in keyboard. DEPRECATED as of 16.0 + KMX_DWORD KeyboardID; // 000C as stored in HKEY_LOCAL_MACHINE//system//currentcontrolset//control//keyboard layouts + KMX_DWORD IsRegistered; // 0010 + KMX_DWORD version; // 0014 keyboard version - DWORD cxStoreArray; // 0018 in array entries - DWORD cxGroupArray; // 001C in array entries + KMX_DWORD cxStoreArray; // 0018 in array entries + KMX_DWORD cxGroupArray; // 001C in array entries - DWORD dpStoreArray; // 0020 [LPSTORE] address of first item in store array - DWORD dpGroupArray; // 0024 [LPGROUP] address of first item in group array + KMX_DWORD dpStoreArray; // 0020 [LPSTORE] address of first item in store array + KMX_DWORD dpGroupArray; // 0024 [LPGROUP] address of first item in group array - DWORD StartGroup[2]; // 0028 index of starting groups [2 of them] + KMX_DWORD StartGroup[2]; // 0028 index of starting groups [2 of them] - DWORD dwFlags; // 0030 Flags for the keyboard file + KMX_DWORD dwFlags; // 0030 Flags for the keyboard file - DWORD dwHotKey; // 0034 standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) + KMX_DWORD dwHotKey; // 0034 standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) - DWORD dpBitmapOffset; // 0038 offset of the bitmaps in the file - DWORD dwBitmapSize; // 003C size in bytes of the bitmaps + KMX_DWORD dpBitmapOffset; // 0038 offset of the bitmaps in the file + KMX_DWORD dwBitmapSize; // 003C size in bytes of the bitmaps }; - struct KMX_COMP_KEYBOARD { - KMX_DWORD dwIdentifier; // 0000 Keyman compiled keyboard id - - KMX_DWORD dwFileVersion; // 0004 Version of the file - Keyman 4.0 is 0x0400 - - KMX_DWORD dwCheckSum; // 0008 As stored in keyboard. DEPRECATED as of 16.0 - KMX_DWORD KeyboardID; // 000C as stored in HKEY_LOCAL_MACHINE//system//currentcontrolset//control//keyboard layouts - KMX_DWORD IsRegistered; // 0010 - KMX_DWORD version; // 0014 keyboard version - - KMX_DWORD cxStoreArray; // 0018 in array entries - KMX_DWORD cxGroupArray; // 001C in array entries - - KMX_DWORD dpStoreArray; // 0020 [LPSTORE] address of first item in store array - KMX_DWORD dpGroupArray; // 0024 [LPGROUP] address of first item in group array - - KMX_DWORD StartGroup[2]; // 0028 index of starting groups [2 of them] - - KMX_DWORD dwFlags; // 0030 Flags for the keyboard file - - KMX_DWORD dwHotKey; // 0034 standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) - - KMX_DWORD dpBitmapOffset; // 0038 offset of the bitmaps in the file - KMX_DWORD dwBitmapSize; // 003C size in bytes of the bitmaps - }; - -struct COMP_KEYBOARD_KMXPLUSINFO { - DWORD dpKMXPlus; // 0040 offset of KMXPlus data, header is first - DWORD dwKMXPlusSize; // 0044 size in bytes of entire KMXPlus data +struct KMX_COMP_KEYBOARD_KMXPLUSINFO { + KMX_DWORD dpKMXPlus; // 0040 offset of KMXPlus data, header is first + KMX_DWORD dwKMXPlusSize; // 0044 size in bytes of entire KMXPlus data }; - struct KMX_COMP_KEYBOARD_KMXPLUSINFO { - KMX_DWORD dpKMXPlus; // 0040 offset of KMXPlus data, header is first - KMX_DWORD dwKMXPlusSize; // 0044 size in bytes of entire KMXPlus data - }; - - /** * Only valid if comp_keyboard.dwFlags&KF_KMXPLUS */ -struct COMP_KEYBOARD_EX { - COMP_KEYBOARD header; // 0000 see COMP_KEYBOARD - COMP_KEYBOARD_KMXPLUSINFO kmxplus; // 0040 see COMP_KEYBOARD_EXTRA + +struct KMX_COMP_KEYBOARD_EX { + KMX_COMP_KEYBOARD header; // 0000 see COMP_KEYBOARD + KMX_COMP_KEYBOARD_KMXPLUSINFO kmxplus; // 0040 see COMP_KEYBOARD_EXTRA }; - struct KMX_COMP_KEYBOARD_EX { - KMX_COMP_KEYBOARD header; // 0000 see COMP_KEYBOARD - KMX_COMP_KEYBOARD_KMXPLUSINFO kmxplus; // 0040 see COMP_KEYBOARD_EXTRA - }; - -typedef COMP_KEYBOARD *PCOMP_KEYBOARD; -typedef COMP_STORE *PCOMP_STORE; -typedef COMP_KEY *PCOMP_KEY; -typedef COMP_GROUP *PCOMP_GROUP; - - typedef KMX_COMP_KEYBOARD *PKMX_COMP_KEYBOARD; - typedef KMX_COMP_STORE *PKMX_COMP_STORE; - typedef KMX_COMP_KEY *PKMX_COMP_KEY; - typedef KMX_COMP_GROUP *PKMX_COMP_GROUP; +typedef KMX_COMP_KEYBOARD *PKMX_COMP_KEYBOARD; +typedef KMX_COMP_STORE *PKMX_COMP_STORE; +typedef KMX_COMP_KEY *PKMX_COMP_KEY; +typedef KMX_COMP_GROUP *PKMX_COMP_GROUP; extern const int CODE__SIZE[]; diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index b80483b26c..5b6231f259 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -38,8 +38,7 @@ KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, PKMX_WCHAR filename) { return TRUE; } -KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL FSaveDebug) -{ +KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL FSaveDebug) { wprintf(L" ##### KMX_WriteCompiledKeyboard of mc_kmxfile started\n"); LPKMX_GROUP fgp; @@ -123,7 +122,6 @@ KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL //wcscpy((PWSTR)(buf + offset), fk->szMessage); //offset += wcslen(fk->szMessage)*2 + 2; - ck->dpStoreArray = offset; sp = (PKMX_COMP_STORE)(buf+offset); fsp = fk->dpStoreArray; @@ -184,11 +182,9 @@ KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL kp->ShiftFlags = fkp->ShiftFlags; kp->dpOutput = offset; - u16ncpy((PKMX_WCHAR)(buf+offset), fkp->dpOutput, (size-offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 offset += u16len(fkp->dpOutput)*2 + 2; - kp->dpContext = offset; u16ncpy((PKMX_WCHAR)(buf+offset), fkp->dpContext, (size-offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 offset += u16len(fkp->dpContext)*2 + 2; @@ -407,17 +403,17 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { return FALSE; } - #ifdef KMX_64BIT // _S2 opened for copyKeyboard-Version + #ifdef KMX_64BIT // allocate enough memory for expanded data structure + original data. // Expanded data structure is double the size of data on disk (8-byte // pointers) - on disk the "pointers" are relative to the beginning of // the file. // We save the original data at the end of buf; we don't copy strings, so // those will remain in the location at the end of the buffer. - buf = new KMX_BYTE[sz * 3]; // _S2 opened for copyKeyboard-Version - #else // _S2 opened for copyKeyboard-Version + buf = new KMX_BYTE[sz * 3]; + #else buf = new KMX_BYTE[sz]; - #endif // _S2 opened for copyKeyboard-Version + #endif if (!buf) { fclose(fp); @@ -426,12 +422,11 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { return FALSE; } - #ifdef KMX_64BIT // _S2 opened for copyKeyboard-Version - filebase = buf + sz*2; // _S2 opened for copyKeyboard-Version - #else // _S2 opened for copyKeyboard-Version + #ifdef KMX_64BIT + filebase = buf + sz*2; + #else filebase = buf; - #endif // _S2 opened for copyKeyboard-Version - + #endif if (fread(filebase, 1, sz, fp) < (size_t)sz) { KMX_LogError(L"LogError1: Could not read file\n" ); @@ -442,14 +437,12 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { fclose(fp); - // _S2 opened for copyKeyboard-Version v if(*PKMX_DWORD(filebase) != KMX_DWORD(FILEID_COMPILED)) { delete [] buf; KMX_LogError(L"Invalid file - signature is invalid\n"); return FALSE; } - // _S2 opened for copyKeyboard-Version ^ if (!KMX_VerifyKeyboard(filebase, sz)) { KMX_LogError(L"LogError1: errVerifyKeyboard\n" ); @@ -457,11 +450,11 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { return FALSE; } -#ifdef KMX_64BIT // _S2 opened for copyKeyboard-Version - kbp = KMX_CopyKeyboard(buf, filebase); // _S2 opened for copyKeyboard-Version -#else // _S2 opened for copyKeyboard-Version - kbp = KMX_FixupKeyboard(buf, filebase, sz); // _S2 changed from sz->sz_dw -#endif // _S2 opened for copyKeyboard-Version +#ifdef KMX_64BIT + kbp = KMX_CopyKeyboard(buf, filebase); +#else + kbp = KMX_FixupKeyboard(buf, filebase, sz); +#endif if (!kbp) { diff --git a/linux/mcompile/keymap/mc_savekeyboard.cpp b/linux/mcompile/keymap/mc_savekeyboard.cpp index e7c6cd9cfd..e69de29bb2 100644 --- a/linux/mcompile/keymap/mc_savekeyboard.cpp +++ b/linux/mcompile/keymap/mc_savekeyboard.cpp @@ -1,423 +0,0 @@ -#include "mc_savekeyboard.h" - - //+++++++++++++++++++++++++++++++++++++++++ -/*BOOL SaveKeyboard(LPKEYBOARD kbd, PWSTR filename) { - HANDLE hOutfile = CreateFile(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); - if(hOutfile == INVALID_HANDLE_VALUE) { - LogError(L"Failed to create output file (%d)", GetLastError()); - return FALSE; - } - - DWORD err = WriteCompiledKeyboard(kbd, hOutfile, FALSE); - - CloseHandle(hOutfile); - - if(err != CERR_None) { - LogError(L"Failed to write compiled keyboard with error %d", err); - DeleteFile(filename); - return FALSE; - } - - return TRUE; -}*/ - -/*DWORD WriteCompiledKeyboard(LPKEYBOARD fk, HANDLE hOutfile, BOOL FSaveDebug) -{ - LPGROUP fgp; - LPSTORE fsp; - LPKEY fkp; - - PCOMP_KEYBOARD ck; - PCOMP_GROUP gp; - PCOMP_STORE sp; - PCOMP_KEY kp; - PBYTE buf; - DWORD size, offset; - DWORD i, j; - - // Calculate how much memory to allocate - - size = sizeof(COMP_KEYBOARD) + - fk->cxGroupArray * sizeof(COMP_GROUP) + - fk->cxStoreArray * sizeof(COMP_STORE) + - //wcslen(fk->szName)*2 + 2 + - //wcslen(fk->szCopyright)*2 + 2 + - //wcslen(fk->szLanguageName)*2 + 2 + - //wcslen(fk->szMessage)*2 + 2 + - fk->dwBitmapSize; - - for(i = 0, fgp = fk->dpGroupArray; i < fk->cxGroupArray; i++, fgp++) { - if(fgp->dpName) - size += wcslen(fgp->dpName)*2 + 2; - size += fgp->cxKeyArray * sizeof(COMP_KEY); - for(j = 0, fkp = fgp->dpKeyArray; j < fgp->cxKeyArray; j++, fkp++) { - size += wcslen(fkp->dpOutput)*2 + 2; - size += wcslen(fkp->dpContext)*2 + 2; - } - - if( fgp->dpMatch ) size += wcslen(fgp->dpMatch)*2 + 2; - if( fgp->dpNoMatch ) size += wcslen(fgp->dpNoMatch)*2 + 2; - } - - for(i = 0; i < fk->cxStoreArray; i++) - { - size += wcslen(fk->dpStoreArray[i].dpString)*2 + 2; - if(fk->dpStoreArray[i].dpName) - size += wcslen(fk->dpStoreArray[i].dpName)*2 + 2; - } - - buf = new BYTE[size]; - if(!buf) return CERR_CannotAllocateMemory; - memset(buf, 0, size); - - ck = (PCOMP_KEYBOARD) buf; - - ck->dwIdentifier = FILEID_COMPILED; - - ck->dwFileVersion = fk->dwFileVersion; - ck->dwCheckSum = 0; // No checksum in 16.0, see #7276 - ck->KeyboardID = fk->xxkbdlayout; - ck->IsRegistered = fk->IsRegistered; - ck->cxStoreArray = fk->cxStoreArray; - ck->cxGroupArray = fk->cxGroupArray; - ck->StartGroup[0] = fk->StartGroup[0]; - ck->StartGroup[1] = fk->StartGroup[1]; - ck->dwHotKey = fk->dwHotKey; - - ck->dwFlags = fk->dwFlags; - - offset = sizeof(COMP_KEYBOARD); - - //ck->dpLanguageName = offset; - //wcscpy((PWSTR)(buf + offset), fk->szLanguageName); - //offset += wcslen(fk->szLanguageName)*2 + 2; - - //ck->dpName = offset; - //wcscpy((PWSTR)(buf + offset), fk->szName); - //offset += wcslen(fk->szName)*2 + 2; - - //ck->dpCopyright = offset; - //wcscpy((PWSTR)(buf + offset), fk->szCopyright); - //offset += wcslen(fk->szCopyright)*2 + 2; - - //ck->dpMessage = offset; - //wcscpy((PWSTR)(buf + offset), fk->szMessage); - //offset += wcslen(fk->szMessage)*2 + 2; - - ck->dpStoreArray = offset; - sp = (PCOMP_STORE)(buf+offset); - fsp = fk->dpStoreArray; - offset += sizeof(COMP_STORE) * ck->cxStoreArray; - for(i = 0; i < ck->cxStoreArray; i++, sp++, fsp++) { - sp->dwSystemID = fsp->dwSystemID; - sp->dpString = offset; - wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fsp->dpString); // I3481 // I3641 - offset += wcslen(fsp->dpString)*2 + 2; - - if(!fsp->dpName) { - sp->dpName = 0; - } else { - sp->dpName = offset; - wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fsp->dpName); // I3481 // I3641 - offset += wcslen(fsp->dpName)*2 + 2; - } - } - - ck->dpGroupArray = offset; - gp = (PCOMP_GROUP)(buf+offset); - fgp = fk->dpGroupArray; - - offset += sizeof(COMP_GROUP) * ck->cxGroupArray; - - for(i = 0; i < ck->cxGroupArray; i++, gp++, fgp++) { - gp->cxKeyArray = fgp->cxKeyArray; - gp->fUsingKeys = fgp->fUsingKeys; - - gp->dpMatch = gp->dpNoMatch = 0; - - if(fgp->dpMatch) { - gp->dpMatch = offset; - wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fgp->dpMatch); // I3481 // I3641 - offset += wcslen(fgp->dpMatch)*2 + 2; - } - if(fgp->dpNoMatch) { - gp->dpNoMatch = offset; - wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fgp->dpNoMatch); // I3481 // I3641 - offset += wcslen(fgp->dpNoMatch)*2 + 2; - } - - if(fgp->dpName) { - gp->dpName = offset; - wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fgp->dpName); // I3481 // I3641 - offset += wcslen(fgp->dpName)*2 + 2; - } else { - gp->dpName = 0; - } - - gp->dpKeyArray = offset; - kp = (PCOMP_KEY) (buf + offset); - fkp = fgp->dpKeyArray; - offset += gp->cxKeyArray * sizeof(COMP_KEY); - for(j = 0; j < gp->cxKeyArray; j++, kp++, fkp++) { - kp->Key = fkp->Key; - kp->Line = fkp->Line; - kp->ShiftFlags = fkp->ShiftFlags; - kp->dpOutput = offset; - wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fkp->dpOutput); // I3481 // I3641 - offset += wcslen(fkp->dpOutput)*2 + 2; - - - kp->dpContext = offset; - wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fkp->dpContext); // I3481 // I3641 - offset += wcslen(fkp->dpContext)*2 + 2; - } - } - - if(fk->dwBitmapSize > 0) { - ck->dwBitmapSize = fk->dwBitmapSize; - ck->dpBitmapOffset = offset; - memcpy(buf + offset, ((PBYTE)fk) + fk->dpBitmapOffset, fk->dwBitmapSize); - offset += fk->dwBitmapSize; - } else { - ck->dwBitmapSize = 0; - ck->dpBitmapOffset = 0; - } - - if(offset != size) - { - delete[] buf; - return CERR_SomewhereIGotItWrong; - } - - WriteFile(hOutfile, buf, size, &offset, NULL); - - if(offset != size) - { - delete[] buf; - return CERR_UnableToWriteFully; - } - - delete[] buf; - - return CERR_None; -}*/ - - - - -//---------------------old---------------------------------------- -/*#include "pch.h" - -// These four errors are copied from kmn_compiler_errors.h, because WriteCompiledKeyboard is -// a clone of the compiler's equivalent function. However, the functions -// diverge, as mc_savekeyboard.cpp's version is copying from an existing -// compiled keyboard. The error codes have been kept consistent with those in -// kmn_compiler_errors.h -#define CERR_None 0x00000000 -#define CERR_CannotAllocateMemory 0x00008004 -#define CERR_UnableToWriteFully 0x00008007 -#define CERR_SomewhereIGotItWrong 0x00008009 - -DWORD WriteCompiledKeyboard(LPKEYBOARD fk, HANDLE hOutfile, BOOL FSaveDebug); - -BOOL SaveKeyboard(LPKEYBOARD kbd, PWSTR filename) { - HANDLE hOutfile = CreateFile(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); - if(hOutfile == INVALID_HANDLE_VALUE) { - LogError(L"Failed to create output file (%d)", GetLastError()); - return FALSE; - } - - DWORD err = WriteCompiledKeyboard(kbd, hOutfile, FALSE); - - CloseHandle(hOutfile); - - if(err != CERR_None) { - LogError(L"Failed to write compiled keyboard with error %d", err); - DeleteFile(filename); - return FALSE; - } - - return TRUE; -} - -DWORD WriteCompiledKeyboard(LPKEYBOARD fk, HANDLE hOutfile, BOOL FSaveDebug) -{ - LPGROUP fgp; - LPSTORE fsp; - LPKEY fkp; - - PCOMP_KEYBOARD ck; - PCOMP_GROUP gp; - PCOMP_STORE sp; - PCOMP_KEY kp; - PBYTE buf; - DWORD size, offset; - DWORD i, j; - - // Calculate how much memory to allocate - - size = sizeof(COMP_KEYBOARD) + - fk->cxGroupArray * sizeof(COMP_GROUP) + - fk->cxStoreArray * sizeof(COMP_STORE) + - //wcslen(fk->szName)*2 + 2 + - //wcslen(fk->szCopyright)*2 + 2 + - //wcslen(fk->szLanguageName)*2 + 2 + - //wcslen(fk->szMessage)*2 + 2 + - fk->dwBitmapSize; - - for(i = 0, fgp = fk->dpGroupArray; i < fk->cxGroupArray; i++, fgp++) { - if(fgp->dpName) - size += wcslen(fgp->dpName)*2 + 2; - size += fgp->cxKeyArray * sizeof(COMP_KEY); - for(j = 0, fkp = fgp->dpKeyArray; j < fgp->cxKeyArray; j++, fkp++) { - size += wcslen(fkp->dpOutput)*2 + 2; - size += wcslen(fkp->dpContext)*2 + 2; - } - - if( fgp->dpMatch ) size += wcslen(fgp->dpMatch)*2 + 2; - if( fgp->dpNoMatch ) size += wcslen(fgp->dpNoMatch)*2 + 2; - } - - for(i = 0; i < fk->cxStoreArray; i++) - { - size += wcslen(fk->dpStoreArray[i].dpString)*2 + 2; - if(fk->dpStoreArray[i].dpName) - size += wcslen(fk->dpStoreArray[i].dpName)*2 + 2; - } - - buf = new BYTE[size]; - if(!buf) return CERR_CannotAllocateMemory; - memset(buf, 0, size); - - ck = (PCOMP_KEYBOARD) buf; - - ck->dwIdentifier = FILEID_COMPILED; - - ck->dwFileVersion = fk->dwFileVersion; - ck->dwCheckSum = 0; // No checksum in 16.0, see #7276 - ck->KeyboardID = fk->xxkbdlayout; - ck->IsRegistered = fk->IsRegistered; - ck->cxStoreArray = fk->cxStoreArray; - ck->cxGroupArray = fk->cxGroupArray; - ck->StartGroup[0] = fk->StartGroup[0]; - ck->StartGroup[1] = fk->StartGroup[1]; - ck->dwHotKey = fk->dwHotKey; - - ck->dwFlags = fk->dwFlags; - - offset = sizeof(COMP_KEYBOARD); - - //ck->dpLanguageName = offset; - //wcscpy((PWSTR)(buf + offset), fk->szLanguageName); - //offset += wcslen(fk->szLanguageName)*2 + 2; - - //ck->dpName = offset; - //wcscpy((PWSTR)(buf + offset), fk->szName); - //offset += wcslen(fk->szName)*2 + 2; - - //ck->dpCopyright = offset; - //wcscpy((PWSTR)(buf + offset), fk->szCopyright); - //offset += wcslen(fk->szCopyright)*2 + 2; - - //ck->dpMessage = offset; - //wcscpy((PWSTR)(buf + offset), fk->szMessage); - //offset += wcslen(fk->szMessage)*2 + 2; - - ck->dpStoreArray = offset; - sp = (PCOMP_STORE)(buf+offset); - fsp = fk->dpStoreArray; - offset += sizeof(COMP_STORE) * ck->cxStoreArray; - for(i = 0; i < ck->cxStoreArray; i++, sp++, fsp++) { - sp->dwSystemID = fsp->dwSystemID; - sp->dpString = offset; - wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fsp->dpString); // I3481 // I3641 - offset += wcslen(fsp->dpString)*2 + 2; - - if(!fsp->dpName) { - sp->dpName = 0; - } else { - sp->dpName = offset; - wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fsp->dpName); // I3481 // I3641 - offset += wcslen(fsp->dpName)*2 + 2; - } - } - - ck->dpGroupArray = offset; - gp = (PCOMP_GROUP)(buf+offset); - fgp = fk->dpGroupArray; - - offset += sizeof(COMP_GROUP) * ck->cxGroupArray; - - for(i = 0; i < ck->cxGroupArray; i++, gp++, fgp++) { - gp->cxKeyArray = fgp->cxKeyArray; - gp->fUsingKeys = fgp->fUsingKeys; - - gp->dpMatch = gp->dpNoMatch = 0; - - if(fgp->dpMatch) { - gp->dpMatch = offset; - wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fgp->dpMatch); // I3481 // I3641 - offset += wcslen(fgp->dpMatch)*2 + 2; - } - if(fgp->dpNoMatch) { - gp->dpNoMatch = offset; - wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fgp->dpNoMatch); // I3481 // I3641 - offset += wcslen(fgp->dpNoMatch)*2 + 2; - } - - if(fgp->dpName) { - gp->dpName = offset; - wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fgp->dpName); // I3481 // I3641 - offset += wcslen(fgp->dpName)*2 + 2; - } else { - gp->dpName = 0; - } - - gp->dpKeyArray = offset; - kp = (PCOMP_KEY) (buf + offset); - fkp = fgp->dpKeyArray; - offset += gp->cxKeyArray * sizeof(COMP_KEY); - for(j = 0; j < gp->cxKeyArray; j++, kp++, fkp++) { - kp->Key = fkp->Key; - kp->Line = fkp->Line; - kp->ShiftFlags = fkp->ShiftFlags; - kp->dpOutput = offset; - wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fkp->dpOutput); // I3481 // I3641 - offset += wcslen(fkp->dpOutput)*2 + 2; - - - kp->dpContext = offset; - wcscpy_s((PWSTR)(buf+offset), (size-offset) / sizeof(WCHAR), fkp->dpContext); // I3481 // I3641 - offset += wcslen(fkp->dpContext)*2 + 2; - } - } - - if(fk->dwBitmapSize > 0) { - ck->dwBitmapSize = fk->dwBitmapSize; - ck->dpBitmapOffset = offset; - memcpy(buf + offset, ((PBYTE)fk) + fk->dpBitmapOffset, fk->dwBitmapSize); - offset += fk->dwBitmapSize; - } else { - ck->dwBitmapSize = 0; - ck->dpBitmapOffset = 0; - } - - if(offset != size) - { - delete[] buf; - return CERR_SomewhereIGotItWrong; - } - - WriteFile(hOutfile, buf, size, &offset, NULL); - - if(offset != size) - { - delete[] buf; - return CERR_UnableToWriteFully; - } - - delete[] buf; - - return CERR_None; -} -*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/mc_savekeyboard.h b/linux/mcompile/keymap/mc_savekeyboard.h index faf9a3810b..0907dcff5d 100644 --- a/linux/mcompile/keymap/mc_savekeyboard.h +++ b/linux/mcompile/keymap/mc_savekeyboard.h @@ -1,21 +1,9 @@ #pragma once #include "km_types.h" - #include - -// this file is all new _S2 - -//#include "../../../common/include/km_types.h" - - #define CERR_None 0x00000000 #define CERR_CannotAllocateMemory 0x00008004 #define CERR_UnableToWriteFully 0x00008007 -#define CERR_SomewhereIGotItWrong 0x00008009 -/* -DWORD WriteCompiledKeyboard(LPKEYBOARD fk, HANDLE hOutfile, BOOL FSaveDebug); -BOOL SaveKeyboard(LPKEYBOARD kbd, PWSTR filename) ; -DWORD WriteCompiledKeyboard(LPKEYBOARD fk, HANDLE hOutfile, BOOL FSaveDebug); -*/ \ No newline at end of file +#define CERR_SomewhereIGotItWrong 0x00008009 \ No newline at end of file diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 6c6f94f5de..1400d13036 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -57,7 +57,7 @@ void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_ #if defined(_WIN32) || defined(_WIN64) int wmain(int argc, wchar_t* argv[]) { - std::vector str_argv_16 = convert_argvW_to_Vector_u16str( argc, argv); + std::vector str_argv_16 = convert_argvW_to_Vector_u16str( argc, argv); run(argc, str_argv_16); #else // LINUX @@ -68,7 +68,7 @@ void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_ } -int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ +int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ // convert std::vector to std::vector std::vector argv; @@ -95,7 +95,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL) //-_S2 -------u option will be done later---------------------- - /* if(wcscmp(argv[1], L"-u") == 0) { // I4273 + /* if(wcscmp(argv[1], L"-u") == 0) { // I4273 wchar_t *infile = argv[2], *outfile = argv[3]; LPKEYBOARD kmxfile; @@ -117,12 +117,12 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL) }*/ //----------------------------- - int bDeadkeyConversion = u16cmp(argv[1], u"-d") == 0; // I4552 + int bDeadkeyConversion = u16cmp(argv[1], u"-d") == 0; // I4552 int n = (bDeadkeyConversion ? 2 : 1); - char16_t* infile = (char16_t*) argv[n], *indll = (char16_t*) argv[n+1], *kbid = (char16_t*) argv[n+2], *outfile = (char16_t*) argv[n+3]; + char16_t* infile = (char16_t*) argv[n], *indll = (char16_t*) argv[n+1], *kbid = (char16_t*) argv[n+2], *outfile = (char16_t*) argv[n+3]; - wprintf(L"mcompile%ls \"%ls\" \"%ls\" \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d" : L"", u16fmt((const char16_t*) infile).c_str(), u16fmt((const char16_t*) indll).c_str(), u16fmt((const char16_t*) kbid).c_str(), u16fmt((const char16_t*) outfile).c_str() ); // I4174 + wprintf(L"mcompile%ls \"%ls\" \"%ls\" \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d" : L"", u16fmt((const char16_t*) infile).c_str(), u16fmt((const char16_t*) indll).c_str(), u16fmt((const char16_t*) kbid).c_str(), u16fmt((const char16_t*) outfile).c_str() ); // I4174 // 1. Load the keyman keyboard file @@ -166,7 +166,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL) #else // LINUX // _S2 do I need all parameters?-no - if(KMX_DoConvert( kmxfile, kbid, bDeadkeyConversion, argc, (gchar**) argv_ch)) { // I4552F + if(KMX_DoConvert( kmxfile, kbid, bDeadkeyConversion, argc, (gchar**) argv_ch)) { // I4552F KMX_SaveKeyboard(kmxfile, outfile); } #endif @@ -308,11 +308,11 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon const wchar_t* ERROR = L" "; - for (int j = 1; VKShiftState[j] != 0xFFFF; j++) { // I4651 + for (int j = 1; VKShiftState[j] != 0xFFFF; j++) { // I4651 wprintf(L"\n"); // Loop through each possible key on the keyboard - for (int i = 0;KMX_VKMap[i]; i++) { // I4651 + for (int i = 0;KMX_VKMap[i]; i++) { // I4651 // _S2 why were those 2 functions originally not done in 1 step ?? KMX_DWORD vkUnderlying = KMX_VKUSToVKUnderlyingLayout(All_Vector,(int) KMX_VKMap[i] ); @@ -422,10 +422,10 @@ void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_ /* -bool ImportRules(WCHAR *kbid, LPKEYBOARD kp, std::vector *FDeadkeys, BOOL bDeadkeyConversion); // I4353 // I4327 -BOOL ConvertKeyboardToUnicode(LPKEYBOARD kbd); // I4273 +bool ImportRules(WCHAR *kbid, LPKEYBOARD kp, std::vector *FDeadkeys, BOOL bDeadkeyConversion); // I4353 // I4327 +BOOL ConvertKeyboardToUnicode(LPKEYBOARD kbd); // I4273 -std::vector FDeadkeys; // I4353 +std::vector FDeadkeys; // I4353 #define KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE_MCOMPILE KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE ".mcompile" @@ -504,7 +504,7 @@ void AddDeadkeyRule(LPKEYBOARD kbd, WCHAR deadkey, WORD vk, UINT shift) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. - if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4549 + if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4549 shift &= ~LCTRLFLAG; // If the first group is not a matching-keys group, then we need to add into @@ -1074,9 +1074,6 @@ void LogError(PWSTR fmt, ...) { } */ - - - // _S2 maybe I will need that later?? /* static xkb_keysym_t get_ascii(struct xkb_state *state, xkb_keycode_t keycode) { From c0d859e2d2a669dbec2f8e4b84ba09d23b9bf36c Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 15 Aug 2023 16:20:13 +0200 Subject: [PATCH 079/327] feat(linux): mcompile open ReportUnconvertedKeyboardRules() --- linux/mcompile/keymap/mcompile.cpp | 105 ++++++++++++++++++++++------- linux/mcompile/keymap/mcompile.h | 3 + 2 files changed, 84 insertions(+), 24 deletions(-) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 1400d13036..97609598b2 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -54,6 +54,9 @@ void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch); void KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) ; void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) ; +void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key); +void KMX_ReportUnconvertedGroupRules(LPKMX_GROUP group); +void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) ; #if defined(_WIN32) || defined(_WIN64) int wmain(int argc, wchar_t* argv[]) { @@ -180,14 +183,13 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ // comment from win-version // Map of all shift states that we will work with -//const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; +const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; // my comment for Lin version // Ubuntu: Each of the 4 columns specifies a different modifier: unmodified, shift, right alt (altgr), shift+right alt(altgr) -// we have assigned these to columns 1-4 ( column o holds the keycode) // some hold up to 8 what are those ??? -//const UINT VKShiftState[] = {0, 1, 2, 3, 4, 0xFFFF}; -const UINT VKShiftState[] = {0, 1, 2, 0xFFFF}; +// we have assigned these to columns 1-4 ( column o holds the keycode) +//const UINT VKShiftState[] = {0, 1, 2, 3, 0xFFFF}; KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { LPKMX_STORE sp; @@ -226,12 +228,19 @@ KMX_DWORD KMX_VKUSToVKUnderlyingLayout(v_dw_3D &All_Vector,KMX_DWORD inUS) { } // takes cpital character of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] -KMX_DWORD KMX_CharFromVK(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, WCHAR VKShiftState, KMX_WCHAR* DeadKey){ +KMX_DWORD KMX_CharFromVK(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey){ + +KMX_UINT VKShiftState_lin; +if (VKShiftState == 0 ) VKShiftState_lin =0; +if (VKShiftState == 16) VKShiftState_lin =1; +if (VKShiftState == 9 ) VKShiftState_lin =2; +if (VKShiftState == 25) VKShiftState_lin =3; + // loop and find vkUnderlying in Other; then return char with correct shiftstate for( int i=0; i< (int)All_Vector[1].size();i++) { KMX_DWORD CharOther = All_Vector[1][i][2]; if( vkUnderlying == CharOther ) { - return All_Vector[1][i][VKShiftState]; + return All_Vector[1][i][VKShiftState_lin+1]; // [VKShiftState_lin+1] because we have the name of the key in All_Vector[1][i][0], so we need to get the one after this } } return vkUnderlying; @@ -303,12 +312,12 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon wprintf(L"ERROR: can't create one vector from both keyboards\n"); return FALSE; } - +//test(All_Vector); //-------------------------------------------------------------------------------- const wchar_t* ERROR = L" "; - for (int j = 1; VKShiftState[j] != 0xFFFF; j++) { // I4651 + for (int j = 0; VKShiftState[j] != 0xFFFF; j++) { // I4651 wprintf(L"\n"); // Loop through each possible key on the keyboard @@ -325,28 +334,30 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon else ERROR = L" "; - wprintf(L" DoConvert-read i: %i \t(KMX_VKMap): %i (%c) \t---> vkUnderlying: %i (%c) \tshiftstate: ( %i ) \t---- > ch: %i (%c) \t%ls \t%ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); + //printf(L"\n DoConvert-read i: %i \t(KMX_VKMap): %i (%c) \t---> vkUnderlying: %i (%c) \tshiftstate[%i]: ( %i ) \t---- > ch: %i (%c) \t%ls \t%ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, j, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); - + /* if(bDeadkeyConversion) { // I4552 if(ch == 0xFFFF) { ch = DeadKey; } - } + }*/ + //wprintf(L" switch with ch: %i (%c)......\n" , ch,ch); switch(ch) { + case 0x0000: break; + // _S2 deadkeys will be done later //case 0xFFFF: ConvertDeadkey(kbd, VKMap[i], VKShiftState[j], DeadKey); break; - - //default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); + default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); } } } +wprintf(L"\n##### KMX_ReportUnconvertedKeyboardRules of mcompile will start #####\n"); + KMX_ReportUnconvertedKeyboardRules(kbd); /* - ReportUnconvertedKeyboardRules(kbd); - if(!ImportRules(kbid, kbd, &FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 return FALSE; } @@ -359,7 +370,11 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon void KMX_LogError(const KMX_WCHART* m1,int m2) { wprintf((PWSTR)m1, m2); } - +/* +void KMX_LogError(const KMX_WCHART* m1,int m2, LPKMX_KEY key) { + wprintf((PWSTR)m1, m2); +} +*/ // // TranslateKey @@ -369,7 +384,7 @@ void KMX_LogError(const KMX_WCHART* m1,int m2) { // void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { - wprintf(L"\n ##### KMX_TranslateKey of mcompile started #### "); + //wprintf(L"\n ##### KMX_TranslateKey of mcompile started #### with vk: %i (%c) shift: %i ch: %i (%c)......" , vk,vk, shift, ch,ch); // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. @@ -382,7 +397,9 @@ void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) //LogError(L"Converted mnemonic rule on line %d, + '%c' TO + [%x K_%d]", key->Line, key->Key, shift, vk); key->ShiftFlags = ISVIRTUALKEY | shift; key->Key = vk; - wprintf(L" 1 and changed, %i (%c) %i (%c) ", ch,ch, vk,vk); + +//wprintf(L"ISVIRTUALKEY: %i , shift: %i, key->ShiftFlags for mnemonic= %i\n", ISVIRTUALKEY,shift, key->ShiftFlags); + //wprintf(L" 1 and changed, %i (%c) %i (%c) ", ch,ch, vk,vk); } else if(key->ShiftFlags & VIRTUALCHARKEY && key->Key == ch) { // Key is a virtual character key with a hard-coded shift state. // Do not remap the shift state, just move the key. @@ -392,32 +409,72 @@ void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) //LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, key->ShiftFlags & ~VIRTUALCHARKEY, vk); key->ShiftFlags &= ~VIRTUALCHARKEY; key->Key = vk; - wprintf(L" 2 and changed, vk: %i (%c) ---> %i (%c) ", vk,vk, ch,ch); + +//wprintf(L"key->ShiftFlags for VIRTUALCHARKEY= %i", key->ShiftFlags); + //wprintf(L" 2 and changed, vk: %i (%c) ---> %i (%c) ", vk,vk, ch,ch); } - wprintf(L"\n ##### KMX_TranslateKey of mcompile ended ##### \n"); + //wprintf(L"\n ##### KMX_TranslateKey of mcompile ended ##### \n"); + //wprintf(L"key->ShiftFlags: %i, key->Key: %i\n", key->ShiftFlags,key->Key); } void KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { - wprintf(L"\n ##### KMX_TranslateGroup of mcompile started #####\n"); + //wprintf(L"\n ##### KMX_TranslateGroup of mcompile started #####\n"); for(unsigned int i = 0; i < group->cxKeyArray; i++) { KMX_TranslateKey(&group->dpKeyArray[i], vk, shift, ch); } - wprintf(L" ##### KMX_TranslateGroup of mcompile ended #####\n"); + //wprintf(L" ##### KMX_TranslateGroup of mcompile ended #####\n"); } void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { - wprintf(L"\n ##### KMX_TranslateKeyboard of mcompile started #####\n"); + //wprintf(L"\n ##### KMX_TranslateKeyboard of mcompile started #####\n"); +//if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)){ + //wprintf(L" ##### KMX_TranslateKeyboard of mcompile started #### with vk: %i (%c) shift: %i ch: %i (%c)......(shift & (LCTRLFLAG|RALTFLAG)) %i == (LCTRLFLAG|RALTFLAG)%i): %i \n" , vk,vk, shift, ch,ch, (shift & (LCTRLFLAG|RALTFLAG)) , (LCTRLFLAG|RALTFLAG), (shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)); for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { if(kbd->dpGroupArray[i].fUsingKeys) { KMX_TranslateGroup(&kbd->dpGroupArray[i], vk, shift, ch); } } - wprintf(L" ##### KMX_TranslateKeyboard of mcompile ended #####\n"); + //wprintf(L" ##### KMX_TranslateKeyboard of mcompile ended #####\n"); } +void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key) { + if(key->ShiftFlags == 0) { + //KMX_LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); + wprintf(L" Sab Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); + //MX_LogError(L"Did not find a match for mnemonic rule on line %d,\n", key->Line); + } else if(key->ShiftFlags & VIRTUALCHARKEY) { + //KMX_LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); + wprintf(L"SAB Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); + //KMX_LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, \n", key->Line); + } +} + +void KMX_ReportUnconvertedGroupRules(LPKMX_GROUP group) { + wprintf(L"\n ##### KMX_ReportUnconvertedGroupRules of mcompile started #####\n"); + for(unsigned int i = 0; i < group->cxKeyArray; i++) { + KMX_ReportUnconvertedKeyRule(&group->dpKeyArray[i]); + } + wprintf(L"\n ##### KMX_ReportUnconvertedGroupRules of mcompile ended #####\n"); +} + +void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { + wprintf(L"\n ##### KMX_ReportUnconvertedKeyboardRules of mcompile started #####\n"); + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + KMX_ReportUnconvertedGroupRules(&kbd->dpGroupArray[i]); + } + } + wprintf(L"\n ##### KMX_ReportUnconvertedKeyboardRules of mcompile ended #####\n"); +} + + + + + + // ---- old copy code from here ---------------------------------------------------------- diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 481723efa6..01d47b9f70 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -24,8 +24,11 @@ #include #include "keymap.h" +#include "mc_kmxfile.h" + int run(int argc, std::vector str_argv, char* argv[]); void KMX_LogError(const KMX_WCHART* m1, int m2 = 0); +//void KMX_LogError(const KMX_WCHART* m1, int m2 = 0, LPKMX_KEY key =NULL); struct DeadkeyMapping { // I4353 KMX_WCHAR deadkey, dkid; From 515b42015c9e090346e1a657e67e1c1f5e41216a Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 18 Aug 2023 19:07:38 +0200 Subject: [PATCH 080/327] feat(linux): mcompile start importRules --- linux/.gitignore | 1 + linux/mcompile/keymap/mc_import_rules.cpp | 789 ++++++++++++++++++++++ linux/mcompile/keymap/mcompile.h | 4 +- linux/mcompile/keymap/meson.build | 1 + 4 files changed, 793 insertions(+), 2 deletions(-) create mode 100644 linux/mcompile/keymap/mc_import_rules.cpp diff --git a/linux/.gitignore b/linux/.gitignore index c8e08190f2..4d72bb16f4 100644 --- a/linux/.gitignore +++ b/linux/.gitignore @@ -44,3 +44,4 @@ watch *.kmx *.kvk *.bak +*.txt diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp new file mode 100644 index 0000000000..82504d01e1 --- /dev/null +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -0,0 +1,789 @@ +/* + Name: mc_import_rules + Copyright: Copyright (C) SIL International. + Documentation: + Description: + Create Date: 3 Aug 2014 + + Modified Date: 6 Feb 2015 + Authors: mcdurdin + Related Files: + Dependencies: + + Bugs: + Todo: + Notes: + History: 03 Aug 2014 - mcdurdin - I4327 - V9.0 - Mnemonic layout compiler follow-up + 03 Aug 2014 - mcdurdin - I4353 - V9.0 - mnemonic layout recompiler mixes up deadkey rules + 31 Dec 2014 - mcdurdin - I4550 - V9.0 - logical flaw in mnemonic layout recompiler means that AltGr base keys are never processed + 06 Feb 2015 - mcdurdin - I4552 - V9.0 - Add mnemonic recompile option to ignore deadkeys +*/ + + +#include +#include +#include +#include "km_types.h" +#include "mc_kmxfile.h" +/* +enum ShiftState { + Base = 0, // 0 + Shft = 1, // 1 + Ctrl = 2, // 2 + ShftCtrl = Shft | Ctrl, // 3 + Menu = 4, // 4 -- NOT USED + ShftMenu = Shft | Menu, // 5 -- NOT USED + MenuCtrl = Menu | Ctrl, // 6 + ShftMenuCtrl = Shft | Menu | Ctrl, // 7 + Xxxx = 8, // 8 + ShftXxxx = Shft | Xxxx, // 9 +}; + +const int ShiftStateMap[] = { + ISVIRTUALKEY, + ISVIRTUALKEY | K_SHIFTFLAG, + ISVIRTUALKEY | K_CTRLFLAG, + ISVIRTUALKEY | K_SHIFTFLAG | K_CTRLFLAG, + 0, + 0, + ISVIRTUALKEY | RALTFLAG, + ISVIRTUALKEY | RALTFLAG | K_SHIFTFLAG, + 0, + 0}; + +class DeadKey { +private: + WCHAR m_deadchar; + std::vector m_rgbasechar; + std::vector m_rgcombchar; + +public: + DeadKey(WCHAR deadCharacter) { + this->m_deadchar = deadCharacter; + } + + WCHAR DeadCharacter() { + return this->m_deadchar; + } + + void AddDeadKeyRow(WCHAR baseCharacter, WCHAR combinedCharacter) { + this->m_rgbasechar.push_back(baseCharacter); + this->m_rgcombchar.push_back(combinedCharacter); + } + + int Count() { + return this->m_rgbasechar.size(); + } + + WCHAR GetBaseCharacter(int index) { + return this->m_rgbasechar[index]; + } + + WCHAR GetCombinedCharacter(int index) { + return this->m_rgcombchar[index]; + } + + bool ContainsBaseCharacter(WCHAR baseCharacter) { + std::vector::iterator it; + for(it=this->m_rgbasechar.begin(); it *deadkeys, int deadkeyBase, std::vector *deadkeyMappings) { // I4327 // I4353 + for(size_t i = 0; i < deadkeyMappings->size(); i++) { + if((*deadkeyMappings)[i].deadkey == index) { + return (*deadkeyMappings)[i].dkid; + } + } + + for(size_t i = 0; i < deadkeys->size(); i++) { + if((*deadkeys)[i]->DeadCharacter() == index) { + return deadkeyBase + i; + } + } + return 0xFFFF; +} + +class VirtualKey { +private: + HKL m_hkl; + UINT m_vk; + UINT m_sc; + bool m_rgfDeadKey[10][2]; + std::wstring m_rgss[10][2]; + +public: + VirtualKey(HKL hkl, UINT virtualKey) { + this->m_sc = MapVirtualKeyEx(virtualKey, 0, hkl); + this->m_hkl = hkl; + this->m_vk = virtualKey; + memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); + } + + VirtualKey(UINT scanCode, HKL hkl) { + this->m_vk = MapVirtualKeyEx(scanCode, 1, hkl); + this->m_hkl = hkl; + this->m_sc = scanCode; + } + + UINT VK() { + return this->m_vk; + } + + UINT SC() { + return this->m_sc; + } + + std::wstring GetShiftState(ShiftState shiftState, bool capsLock) { + return this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)]; + } + + void SetShiftState(ShiftState shiftState, std::wstring value, bool isDeadKey, bool capsLock) { + this->m_rgfDeadKey[(UINT)shiftState][(capsLock ? 1 : 0)] = isDeadKey; + this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; + } + + bool IsSGCAPS() { + std::wstring stBase = this->GetShiftState(Base, false); + std::wstring stShift = this->GetShiftState(Shft, false); + std::wstring stCaps = this->GetShiftState(Base, true); + std::wstring stShiftCaps = this->GetShiftState(Shft, true); + return ( + ((stCaps.size() > 0) && + (stBase.compare(stCaps) != 0) && + (stShift.compare(stCaps) != 0)) || + ((stShiftCaps.size() > 0) && + (stBase.compare(stShiftCaps) != 0) && + (stShift.compare(stShiftCaps) != 0))); + } + + bool IsCapsEqualToShift() { + std::wstring stBase = this->GetShiftState(Base, false); + std::wstring stShift = this->GetShiftState(Shft, false); + std::wstring stCaps = this->GetShiftState(Base, true); + return ( + (stBase.size() > 0) && + (stShift.size() > 0) && + (stBase.compare(stShift) != 0) && + (stShift.compare(stCaps) == 0)); + } + + bool IsAltGrCapsEqualToAltGrShift() { + std::wstring stBase = this->GetShiftState(MenuCtrl, false); + std::wstring stShift = this->GetShiftState(ShftMenuCtrl, false); + std::wstring stCaps = this->GetShiftState(MenuCtrl, true); + return ( + (stBase.size() > 0) && + (stShift.size() > 0) && + (stBase.compare(stShift) != 0) && + (stShift.compare(stCaps) == 0)); + } + + bool IsXxxxGrCapsEqualToXxxxShift() { + std::wstring stBase = this->GetShiftState(Xxxx, false); + std::wstring stShift = this->GetShiftState(ShftXxxx, false); + std::wstring stCaps = this->GetShiftState(Xxxx, true); + return ( + (stBase.size() > 0) && + (stShift.size() > 0) && + (stBase.compare(stShift) != 0) && + (stShift.compare(stCaps) == 0)); + } + + bool IsEmpty() { + for (int i = 0; i < 10; i++) { + for (int j = 0; j <= 1; j++) { + if (this->GetShiftState((ShiftState)i, (j == 1)).size() > 0) { + return (false); + } + } + } + return true; + } + + bool IsKeymanUsedKey() { + return (this->m_vk >= 0x20 && this->m_vk <= 0x5F) || (this->m_vk >= 0x88); + } + + UINT GetShiftStateValue(int capslock, int caps, ShiftState ss) { + return + ShiftStateMap[(int)ss] | + (capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0); + } + + int GetKeyCount(int MaxShiftState) { + int nkeys = 0; + + // Get the CAPSLOCK value + int capslock = + (this->IsCapsEqualToShift() ? 1 : 0) | + (this->IsSGCAPS() ? 2 : 0) | + (this->IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | + (this->IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + + for (int ss = 0; ss <= MaxShiftState; ss++) { + if (ss == Menu || ss == ShftMenu) { + // Alt and Shift+Alt don't work, so skip them + continue; + } + for (int caps = 0; caps <= 1; caps++) { + std::wstring st = this->GetShiftState((ShiftState) ss, (caps == 1)); + + if (st.size() == 0) { + // No character assigned here + } else if (this->m_rgfDeadKey[(int)ss][caps]) { + // It's a dead key, append an @ sign. + nkeys++; + } else { + bool isvalid = true; + for (size_t ich = 0; ich < st.size(); ich++) { + if(st[ich] < 0x20 || st[ich] == 0x7F) { isvalid=false; break; } + } + + if(isvalid) { + nkeys++; + } + } + } + } + return nkeys; + } + + bool LayoutRow(int MaxShiftState, LPKEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion) { // I4552 + // Get the CAPSLOCK value + int capslock = + (this->IsCapsEqualToShift() ? 1 : 0) | + (this->IsSGCAPS() ? 2 : 0) | + (this->IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | + (this->IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + + for (int ss = 0; ss <= MaxShiftState; ss++) { + if (ss == Menu || ss == ShftMenu) { + // Alt and Shift+Alt don't work, so skip them + continue; + } + for (int caps = 0; caps <= 1; caps++) { + std::wstring st = this->GetShiftState((ShiftState) ss, (caps == 1)); + PWSTR p; + + if (st.size() == 0) { + // No character assigned here + } else if (this->m_rgfDeadKey[(int)ss][caps]) { + // It's a dead key, append an @ sign. + key->dpContext = new WCHAR[1]; + *key->dpContext = 0; + key->ShiftFlags = this->GetShiftStateValue(capslock, caps, (ShiftState) ss); + key->Key = VKUnderlyingLayoutToVKUS(this->VK()); + key->Line = 0; + + if(bDeadkeyConversion) { // I4552 + p = key->dpOutput = new WCHAR[2]; + *p++ = st[0]; + *p = 0; + } else { + p = key->dpOutput = new WCHAR[4]; + *p++ = UC_SENTINEL; + *p++ = CODE_DEADKEY; + *p++ = DeadKeyMap(st[0], deadkeys, deadkeyBase, &FDeadkeys); // I4353 + *p = 0; + } + key++; + } else { + bool isvalid = true; + for (size_t ich = 0; ich < st.size(); ich++) { + if(st[ich] < 0x20 || st[ich] == 0x7F) { isvalid=false; break; } + } + + if(isvalid) { + key->Key = VKUnderlyingLayoutToVKUS(this->VK()); + key->Line = 0; + key->ShiftFlags = this->GetShiftStateValue(capslock, caps, (ShiftState) ss); + key->dpContext = new WCHAR; *key->dpContext = 0; + p = key->dpOutput = new WCHAR[st.size() + 1]; + for(size_t ich = 0; ich < st.size(); ich++) *p++ = st[ich]; + *p = 0; + key++; + } + } + } + } + return true; + } +}; +*/ +class KMX_Loader { +private: + KMX_BYTE lpKeyStateNull[256]; + KMX_UINT m_XxxxVk; +/* +public: + KMX_Loader() { + m_XxxxVk = 0; + memset(lpKeyStateNull, 0, sizeof(lpKeyStateNull)); + } + + UINT Get_XxxxVk() { + return m_XxxxVk; + } + + void Set_XxxxVk(UINT value) { + m_XxxxVk = value; + } + + ShiftState MaxShiftState() { + return (Get_XxxxVk() == 0 ? ShftMenuCtrl : ShftXxxx); + } + + void FillKeyState(BYTE *lpKeyState, ShiftState ss, bool fCapsLock) { + lpKeyState[VK_SHIFT] = (((ss & Shft) != 0) ? 0x80 : 0x00); + lpKeyState[VK_CONTROL] = (((ss & Ctrl) != 0) ? 0x80 : 0x00); + lpKeyState[VK_MENU] = (((ss & Menu) != 0) ? 0x80 : 0x00); + if (Get_XxxxVk() != 0) { + // The Xxxx key has been assigned, so let's include it + lpKeyState[Get_XxxxVk()] = (((ss & Xxxx) != 0) ? 0x80 : 0x00); + } + lpKeyState[VK_CAPITAL] = (fCapsLock ? 0x01 : 0x00); + } + + bool IsControlChar(wchar_t ch) { + return (ch < 0x0020) || (ch >= 0x007F && ch <= 0x009F); + } + + DeadKey *ProcessDeadKey( + UINT iKeyDead, // The index into the VirtualKey of the dead key + ShiftState shiftStateDead, // The shiftstate that contains the dead key + BYTE *lpKeyStateDead, // The key state for the dead key + std::vector rgKey, // Our array of dead keys + bool fCapsLock, // Was the caps lock key pressed? + HKL hkl) { // The keyboard layout + + BYTE lpKeyState[256]; + DeadKey *deadKey = new DeadKey(rgKey[iKeyDead]->GetShiftState(shiftStateDead, fCapsLock)[0]); + + for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { + if (rgKey[iKey] != NULL) { + WCHAR sbBuffer[16]; + + for (ShiftState ss = Base; ss <= MaxShiftState(); ss = (ShiftState)((int)ss+1)) { + int rc = 0; + if (ss == Menu || ss == ShftMenu) { + // Alt and Shift+Alt don't work, so skip them + continue; + } + + for (int caps = 0; caps <= 1; caps++) { + // First the dead key + while (rc >= 0) { + // We know that this is a dead key coming up, otherwise + // this function would never have been called. If we do + // *not* get a dead key then that means the state is + // messed up so we run again and again to clear it up. + // Risk is technically an infinite loop but per Hiroyama + // that should be impossible here. + rc = ToUnicodeEx(rgKey[iKeyDead]->VK(), rgKey[iKeyDead]->SC(), lpKeyStateDead, sbBuffer, _countof(sbBuffer), 0, hkl); + } + + // Now fill the key state for the potential base character + FillKeyState(lpKeyState, ss, (caps != 0)); + + rc = ToUnicodeEx(rgKey[iKey]->VK(), rgKey[iKey]->SC(), lpKeyState, sbBuffer, _countof(sbBuffer), 0, hkl); + if (rc == 1) { + // That was indeed a base character for our dead key. + // And we now have a composite character. Let's run + // through one more time to get the actual base + // character that made it all possible? + WCHAR combchar = sbBuffer[0]; + rc = ToUnicodeEx(rgKey[iKey]->VK(), rgKey[iKey]->SC(), lpKeyState, sbBuffer, _countof(sbBuffer), 0, hkl); + + WCHAR basechar = sbBuffer[0]; + + if (deadKey->DeadCharacter() == combchar) { + // Since the combined character is the same as the dead key, + // we must clear out the keyboard buffer. + ClearKeyboardBuffer(VK_DECIMAL, rgKey[VK_DECIMAL]->SC(), hkl); + } + + if ((((ss == Ctrl) || (ss == ShftCtrl)) && + (IsControlChar(basechar))) || + (basechar == combchar)) { + // ToUnicodeEx has an internal knowledge about those + // VK_A ~ VK_Z keys to produce the control characters, + // when the conversion rule is not provided in keyboard + // layout files + + // Additionally, dead key state is lost for some of these + // character combinations, for unknown reasons. + + // Therefore, if the base character and combining are equal, + // and its a CTRL or CTRL+SHIFT state, and a control character + // is returned, then we do not add this "dead key" (which + // is not really a dead key). + continue; + } + + if (!deadKey->ContainsBaseCharacter(basechar)) { + deadKey->AddDeadKeyRow(basechar, combchar); + } + } else if (rc > 1) { + // Not a valid dead key combination, sorry! We just ignore it. + } else if (rc < 0) { + // It's another dead key, so we ignore it (other than to flush it from the state) + ClearKeyboardBuffer(VK_DECIMAL, rgKey[VK_DECIMAL]->SC(), hkl); + } + } + } + } + } + return deadKey; + } + + void ClearKeyboardBuffer(UINT vk, UINT sc, HKL hkl) { + WCHAR sb[16]; + int rc = 0; + do { + rc = ::ToUnicodeEx(vk, sc, lpKeyStateNull, sb, _countof(sb), 0, hkl); + } while(rc != 1 && rc != 0); + }*/ +}; +/* +int GetMaxDeadkeyIndex(WCHAR *p) { + int n = 0; + while(p && *p) { + if(*p == UC_SENTINEL && *(p+1) == CODE_DEADKEY) + n = max(n, *(p+2)); + p = incxstr(p); + } + return n; +} +*/ +bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 + wprintf(L"\n ##### KMX_ImportRules of mc_import_rules started #####\n"); + KMX_Loader loader; + const size_t BUF_sz= 256; + + KMX_WCHAR inputHKL[12]; + u16sprintf(inputHKL,BUF_sz ,L"%08.8x", (unsigned int) u16tol(kbid, NULL, 16)); // _S2 wsprintf(inputHKL, L"%08.8x", (unsigned int) wcstol(kbid, NULL, 16)); +/* + int cKeyboards = GetKeyboardLayoutList(0, NULL); + HKL *rghkl = new HKL[cKeyboards]; + GetKeyboardLayoutList(cKeyboards, rghkl); + HKL hkl = LoadKeyboardLayout(inputHKL, KLF_NOTELLSHELL); + if(hkl == NULL) { + puts("Sorry, that keyboard does not seem to be valid."); + delete[] rghkl; + return false; + } + + BYTE lpKeyState[256];// = new KeysEx[256]; + std::vector rgKey; //= new VirtualKey[256]; + std::vector alDead; + + rgKey.resize(256); + + // Scroll through the Scan Code (SC) values and get the valid Virtual Key (VK) + // values in it. Then, store the SC in each valid VK so it can act as both a + // flag that the VK is valid, and it can store the SC value. + for(UINT sc = 0x01; sc <= 0x7f; sc++) { + VirtualKey *key = new VirtualKey(sc, hkl); + if(key->VK() != 0) { + rgKey[key->VK()] = key; + } else { + delete key; + } + } + + // add the special keys that do not get added from the code above + for(UINT ke = VK_NUMPAD0; ke <= VK_NUMPAD9; ke++) { + rgKey[ke] = new VirtualKey(hkl, ke); + } + rgKey[VK_DIVIDE] = new VirtualKey(hkl, VK_DIVIDE); + rgKey[VK_CANCEL] = new VirtualKey(hkl, VK_CANCEL); + rgKey[VK_DECIMAL] = new VirtualKey(hkl, VK_DECIMAL); + + // See if there is a special shift state added + for(UINT vk = 0; vk <= VK_OEM_CLEAR; vk++) { + UINT sc = MapVirtualKeyEx(vk, 0, hkl); + UINT vkL = MapVirtualKeyEx(sc, 1, hkl); + UINT vkR = MapVirtualKeyEx(sc, 3, hkl); + if((vkL != vkR) && + (vk != vkL)) { + switch(vk) { + case VK_LCONTROL: + case VK_RCONTROL: + case VK_LSHIFT: + case VK_RSHIFT: + case VK_LMENU: + case VK_RMENU: + break; + + default: + loader.Set_XxxxVk(vk); + break; + } + } + } + + for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { + if(rgKey[iKey] != NULL) { + WCHAR sbBuffer[256]; // Scratchpad we use many places + + for(ShiftState ss = Base; ss <= loader.MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { + if(ss == Menu || ss == ShftMenu) { + // Alt and Shift+Alt don't work, so skip them + continue; + } + + for(int caps = 0; caps <= 1; caps++) { + loader.ClearKeyboardBuffer(VK_DECIMAL, rgKey[VK_DECIMAL]->SC(), hkl); + ////FillKeyState(lpKeyState, ss, (caps != 0)); //http://blogs.msdn.com/michkap/archive/2006/04/18/578557.aspx + loader.FillKeyState(lpKeyState, ss, (caps == 0)); + //sbBuffer = new StringBuilder(10); + int rc = ToUnicodeEx(rgKey[iKey]->VK(), rgKey[iKey]->SC(), lpKeyState, sbBuffer, _countof(sbBuffer), 0, hkl); + if(rc > 0) { + if(*sbBuffer == 0) { + // Someone defined NULL on the keyboard; let's coddle them + ////rgKey[iKey].SetShiftState(ss, "\u0000", false, (caps != 0)); + rgKey[iKey]->SetShiftState(ss, L"", false, (caps == 0)); + } + else { + if((rc == 1) && + (ss == Ctrl || ss == ShftCtrl) && + (rgKey[iKey]->VK() == ((UINT)sbBuffer[0] + 0x40))) { + // ToUnicodeEx has an internal knowledge about those + // VK_A ~ VK_Z keys to produce the control characters, + // when the conversion rule is not provided in keyboard + // layout files + continue; + } + sbBuffer[rc] = 0; + //rgKey[iKey].SetShiftState(ss, sbBuffer.ToString().Substring(0, rc), false, (caps != 0)); + rgKey[iKey]->SetShiftState(ss, sbBuffer, false, (caps == 0)); + + } + } + else if(rc < 0) { + //rgKey[iKey].SetShiftState(ss, sbBuffer.ToString().Substring(0, 1), true, (caps != 0)); + sbBuffer[2] = 0; + rgKey[iKey]->SetShiftState(ss, sbBuffer, true, (caps == 0)); + + // It's a dead key; let's flush out whats stored in the keyboard state. + loader.ClearKeyboardBuffer(VK_DECIMAL, rgKey[VK_DECIMAL]->SC(), hkl); + DeadKey *dk = NULL; + for(UINT iDead = 0; iDead < alDead.size(); iDead++) { + dk = alDead[iDead]; + if(dk->DeadCharacter() == rgKey[iKey]->GetShiftState(ss, caps == 0)[0]) { + break; + } + dk = NULL; + } + if(dk == NULL) { + alDead.push_back(loader.ProcessDeadKey(iKey, ss, lpKeyState, rgKey, caps == 0, hkl)); + } + } + } + } + } + } + + for(int i = 0; i < cKeyboards; i++) { + if(hkl == rghkl[i]) { + hkl = NULL; + break; + } + } + + if(hkl != NULL) { + UnloadKeyboardLayout(hkl); + } + + delete[] rghkl; + + //------------------------------------------------------------- + // Now that we've collected the key data, we need to + // translate it to kmx and append to the existing keyboard + //------------------------------------------------------------- + + int nDeadkey = 0; + + LPGROUP gp = new GROUP[kp->cxGroupArray+2]; // leave space for old + memcpy(gp, kp->dpGroupArray, sizeof(GROUP) * kp->cxGroupArray); + + // + // Find the current highest deadkey index + // + + kp->dpGroupArray = gp; + for(UINT i = 0; i < kp->cxGroupArray; i++, gp++) { + //if(gp->fUsingKeys && gp->dpNoMatch == NULL) { // I4550 + // WCHAR *p = gp->dpNoMatch = new WCHAR[4]; + // *p++ = UC_SENTINEL; + // *p++ = CODE_USE; + // *p++ = (WCHAR)(kp->cxGroupArray + 1); + // *p = 0; + } + LPKEY kkp = gp->dpKeyArray; + for(UINT j = 0; j < gp->cxKeyArray; j++, kkp++) { + nDeadkey = max(nDeadkey, GetMaxDeadkeyIndex(kkp->dpContext)); + nDeadkey = max(nDeadkey, GetMaxDeadkeyIndex(kkp->dpOutput)); + } + } + kp->cxGroupArray++; + gp = &kp->dpGroupArray[kp->cxGroupArray-1]; + + UINT nKeys = 0; + for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { + if ((rgKey[iKey] != NULL) && rgKey[iKey]->IsKeymanUsedKey() && (!rgKey[iKey]->IsEmpty())) { + nKeys+= rgKey[iKey]->GetKeyCount(loader.MaxShiftState()); + } + } + + nDeadkey++; // ensure a 1-based index above the max deadkey value already in the keyboard + + gp->fUsingKeys = TRUE; + gp->dpMatch = NULL; + gp->dpName = NULL; + gp->dpNoMatch = NULL; + gp->cxKeyArray = nKeys; + gp->dpKeyArray = new KEY[gp->cxKeyArray]; + nKeys = 0; + + // + // Fill in the new rules + // + + for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { + if ((rgKey[iKey] != NULL) && rgKey[iKey]->IsKeymanUsedKey() && (!rgKey[iKey]->IsEmpty())) { + // for each item, + if(rgKey[iKey]->LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion)) { // I4552 + nKeys+=rgKey[iKey]->GetKeyCount(loader.MaxShiftState()); + } + } + } + + gp->cxKeyArray = nKeys; + + // + // Add nomatch control to each terminating 'using keys' group // I4550 + // + LPGROUP gp2 = kp->dpGroupArray; + for(UINT i = 0; i < kp->cxGroupArray - 1; i++, gp2++) { + if(gp2->fUsingKeys && gp2->dpNoMatch == NULL) { + WCHAR *p = gp2->dpNoMatch = new WCHAR[4]; + *p++ = UC_SENTINEL; + *p++ = CODE_USE; + *p++ = (WCHAR)(kp->cxGroupArray); + *p = 0; + + // + // I4550 - Each place we have a nomatch > use(baselayout) (this last group), we need to add all + // the AltGr and ShiftAltGr combinations as rules to allow them to be matched as well. Yes, this + // loop is not very efficient but it's not worthy of optimisation. + // + UINT j; + LPKEY kkp; + for(j = 0, kkp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kkp++) { + if((kkp->ShiftFlags & (K_CTRLFLAG|K_ALTFLAG|LCTRLFLAG|LALTFLAG|RCTRLFLAG|RALTFLAG)) != 0) { + gp2->cxKeyArray++; + LPKEY kkp2 = new KEY[gp2->cxKeyArray]; + memcpy(kkp2, gp2->dpKeyArray, sizeof(KEY)*(gp2->cxKeyArray-1)); + gp2->dpKeyArray = kkp2; + kkp2 = &kkp2[gp2->cxKeyArray-1]; + kkp2->dpContext = new WCHAR; *kkp2->dpContext = 0; + kkp2->Key = kkp->Key; + kkp2->ShiftFlags = kkp->ShiftFlags; + kkp2->Line = 0; + WCHAR *p = kkp2->dpOutput = new WCHAR[4]; + *p++ = UC_SENTINEL; + *p++ = CODE_USE; + *p++ = (WCHAR)(kp->cxGroupArray); + *p = 0; + } + } + } + } + + // + // If we have deadkeys, then add a new group to translate the deadkeys per the deadkey tables + // We only do this if not in deadkey conversion mode + // + + if (alDead.size() > 0 && !bDeadkeyConversion) { // I4552 + kp->cxGroupArray++; + + WCHAR *p = gp->dpMatch = new WCHAR[4]; + *p++ = UC_SENTINEL; + *p++ = CODE_USE; + *p++ = (WCHAR) kp->cxGroupArray; + *p = 0; + + gp++; + + gp->fUsingKeys = FALSE; + gp->dpMatch = NULL; + gp->dpName = NULL; + gp->dpNoMatch = NULL; + gp->cxKeyArray = alDead.size(); + LPKEY kkp = gp->dpKeyArray = new KEY[alDead.size()]; + + LPSTORE sp = new STORE[kp->cxStoreArray + alDead.size() * 2]; + memcpy(sp, kp->dpStoreArray, sizeof(STORE) * kp->cxStoreArray); + + kp->dpStoreArray = sp; + + sp = &sp[kp->cxStoreArray]; + int nStoreBase = kp->cxStoreArray; + kp->cxStoreArray += alDead.size() * 2; + + for(UINT i = 0; i < alDead.size(); i++) { + DeadKey *dk = alDead[i]; + + sp->dpName = NULL; + sp->dwSystemID = 0; + sp->dpString = new WCHAR[dk->Count() + 1]; + for(int j = 0; j < dk->Count(); j++) + sp->dpString[j] = dk->GetBaseCharacter(j); + sp->dpString[dk->Count()] = 0; + sp++; + + sp->dpName = NULL; + sp->dwSystemID = 0; + sp->dpString = new WCHAR[dk->Count() + 1]; + for(int j = 0; j < dk->Count(); j++) + sp->dpString[j] = dk->GetCombinedCharacter(j); + sp->dpString[dk->Count()] = 0; + sp++; + + kkp->Line = 0; + kkp->ShiftFlags = 0; + kkp->Key = 0; + WCHAR *p = kkp->dpContext = new WCHAR[8]; + *p++ = UC_SENTINEL; + *p++ = CODE_DEADKEY; + *p++ = DeadKeyMap(dk->DeadCharacter(), &alDead, nDeadkey, FDeadkeys); // I4353 + //*p++ = nDeadkey+i; + *p++ = UC_SENTINEL; + *p++ = CODE_ANY; + *p++ = nStoreBase + i*2 + 1; + *p = 0; + + p = kkp->dpOutput = new WCHAR[5]; + *p++ = UC_SENTINEL; + *p++ = CODE_INDEX; + *p++ = nStoreBase + i*2 + 2; + *p++ = 2; + *p = 0; + + kkp++; + } + } + */ +wprintf(L"\n ##### KMX_ImportRules of mc_import_rules ended #####\n"); + return true; +} + diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 01d47b9f70..f94d0f6ae5 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -30,13 +30,13 @@ int run(int argc, std::vector str_argv, char* argv[]); void KMX_LogError(const KMX_WCHART* m1, int m2 = 0); //void KMX_LogError(const KMX_WCHART* m1, int m2 = 0, LPKMX_KEY key =NULL); -struct DeadkeyMapping { // I4353 +struct KMX_DeadkeyMapping { // I4353 KMX_WCHAR deadkey, dkid; KMX_UINT shift; KMX_WORD vk; }; -extern std::vector FDeadkeys; // I4353 +extern std::vector KMX_FDeadkeys; // I4353 //--------------------old diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index 4beec48897..96c479351b 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -16,6 +16,7 @@ cpp_files = files( 'filesystem.cpp', 'mc_kmxfile.cpp', 'mc_savekeyboard.cpp', + 'mc_import_rules.cpp', 'u16.cpp',) mcompile = executable( From 48df4231146b8ae5e33e68094a02f84435100f32 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 18 Aug 2023 19:08:52 +0200 Subject: [PATCH 081/327] feat(linux): mcompile helper functions(write load/compare Vector of keys) --- linux/mcompile/keymap/keymap.cpp | 104 ++++++++++++++++++++++++++++- linux/mcompile/keymap/keymap.h | 5 ++ linux/mcompile/keymap/mcompile.cpp | 22 ++++-- 3 files changed, 122 insertions(+), 9 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 51ef063773..49299f2f6e 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -117,8 +117,11 @@ KMX_DWORD convertNamesToValue(std::wstring tok_wstr){ first[L"period"] = VK_PERIOD; /* BE = 190 */ first[L"slash"] = VK_SLASH; /* BF = 191 */ first[L"ssharp"] = VK_xDF; /* DF = 223 ß */ + first[L"minus"] = VK_HYPHEN; /* BD = 189 ? */ + first[L"dead_acute"] = VK_ACCENT; /* C0 = 192 ? */ + first[L"space"] = VK_SPACE; /* 20 = 32 ? */ - // _S2 ?? VK_SPACE, VK_ACCENT, VK_HYPHEN, VK_QUOTE, VK_OEM_102, + // _S2 ?? VK_QUOTE, VK_OEM_102, if ( tok_wstr.size() == 1) { return (KMX_DWORD) ( *tok_wstr.c_str() );; @@ -184,7 +187,7 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { tokens_dw.push_back(tokens_int); } - //wprintf(L" Keyval %i: %i (%c) --- %i (%c) \n", tokens_dw[0],tokens_dw[1],tokens_dw[1], tokens_dw[2], tokens_dw[2]); + wprintf(L" Keyval %i: %i (%c) --- %i (%c) \n", tokens_dw[0],tokens_dw[1],tokens_dw[1], tokens_dw[2], tokens_dw[2]); // now push result to shift_states shift_states.push_back(tokens_dw); @@ -368,4 +371,101 @@ bool test_single(v_dw_3D &V) { } wprintf(L" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); return true; +} + + bool writeVectorToFile(v_dw_3D V) { + std::string TxtFileName = "/Projects/keyman/keyman/linux/mcompile/keymap/VectorFile.txt" ; + WCHAR DeadKey; + std::ofstream TxTFile(TxtFileName); + //TxTFile << "\n kbid << VKShiftState[j] << US VKMap[i] < delim{' ', '[', ']', '}', ';', '\t', '\n'}; + v_str_1D complete_List; + v_dw_1D tokens_dw; + v_dw_2D shift_states; + int k = -1; + + /* opening file for reading */ + fp = fopen("/Projects/keyman/keyman/linux/mcompile/keymap/VectorFile.txt" , "r"); + if(fp == NULL) { + perror("Error opening file"); + return(-1); + } + + while (fgets(str, 600, fp) != NULL) { + k++; + //puts(str); + complete_List.push_back(str); + if (strcmp(str, "Language 2\n") ==0){ + complete_Vector.push_back(shift_states); + shift_states.clear(); + continue; + } + + // remove all unwanted char + for (int i = 0; i < (int)delim.size(); i++) { + complete_List[k].erase(remove(complete_List[k].begin(), complete_List[k].end(), delim[i]), complete_List[k].end()); + } + + // split into numbers ( delimiter -) + std::stringstream ss(complete_List[k]); + int end = complete_List[k].find("-"); + while (end != -1) { // Loop until no delimiter is left in the string. + tokens_dw.push_back((DWORD)stoi(complete_List[k].substr(0, end))); + complete_List[k].erase(complete_List[k].begin(), complete_List[k].begin() + end + 1); + end = complete_List[k].find("-"); + } + shift_states.push_back(tokens_dw); + tokens_dw.clear(); + } + complete_Vector.push_back(shift_states); + shift_states.clear(); + + fclose(fp); + return(0); +} + +bool CompareVector_To_VectorOfFile(v_dw_3D All_Vector,v_dw_3D File_Vector){ + wprintf(L" #### CompareVector_To_VectorOfFile started: "); + wprintf(L" #### dimensions: %i %i %i -- %i %i %i \n", All_Vector.size() ,All_Vector[0].size(), All_Vector[0][0].size(),File_Vector.size() ,File_Vector[0].size(), File_Vector[0][0].size()); + + if (!(All_Vector.size() == File_Vector.size()) )return false; + if (!(All_Vector[0].size() == File_Vector[0].size())) return false; + if (!(All_Vector[0][0].size() == File_Vector[0][0].size())) return false; + + wprintf(L" #### CompareVector_To_VectorOfFile dimensions OK \n"); + for ( int i=0; i< All_Vector.size();i++) { + for ( int j=0; j< All_Vector[i].size();j++) { + for ( int k=0; k< All_Vector[i][j].size();k++){ + wprintf(L" All_Vector[%i][%i][%i]: %i File_Vector[i][j][k]\n", i,j,k, All_Vector[i][j][k], File_Vector[i][j][k]); + if(( All_Vector[i][j][k] == File_Vector[i][j][k])) return true; + } + return false; + } + } + + wprintf(L" #### CompareVector_To_VectorOfFile ended \n"); + return false; } \ No newline at end of file diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index e1d8cf0d64..9a647ed805 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -79,4 +79,9 @@ KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state bool test(v_dw_3D &V); bool test_single(v_dw_3D &V) ; + +bool writeVectorToFile(v_dw_3D V); +bool writeFileToVector(v_dw_3D& complete_Vector, const char* infile); +bool CompareVector_To_VectorOfFile(v_dw_3D All_Vector,v_dw_3D File_Vector); + # endif /*KEYMAP_H*/ diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 97609598b2..8ceeed4b0c 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -50,6 +50,10 @@ mcompile -d runs 4 important steps: KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]); +bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp, std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 + +std::vector KMX_FDeadkeys; // I4353 + void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch); void KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) ; void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) ; @@ -312,7 +316,13 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon wprintf(L"ERROR: can't create one vector from both keyboards\n"); return FALSE; } -//test(All_Vector); + + v_dw_3D complete_Vector; + bool writeVec_OK = writeVectorToFile(All_Vector); + bool WriteFileOK = writeFileToVector( complete_Vector,"/Projects/keyman/keyman/linux/mcompile/keymap/VectorFile.txt" ); + bool isEqual= CompareVector_To_VectorOfFile( All_Vector, complete_Vector); + wprintf(L" vectors are equal: %i\n",isEqual); +test(All_Vector); //-------------------------------------------------------------------------------- const wchar_t* ERROR = L" "; @@ -334,7 +344,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon else ERROR = L" "; - //printf(L"\n DoConvert-read i: %i \t(KMX_VKMap): %i (%c) \t---> vkUnderlying: %i (%c) \tshiftstate[%i]: ( %i ) \t---- > ch: %i (%c) \t%ls \t%ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, j, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); + wprintf(L" DoConvert-read i: %i \t(KMX_VKMap): %i (%c) \t---> vkUnderlying: %i (%c) \tshiftstate[%i]: ( %i ) \t---- > ch: %i (%c) \t%ls \t%ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, j, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); /* if(bDeadkeyConversion) { // I4552 @@ -358,7 +368,7 @@ wprintf(L"\n##### KMX_ReportUnconvertedKeyboardRules of mcompile will start #### KMX_ReportUnconvertedKeyboardRules(kbd); /* - if(!ImportRules(kbid, kbd, &FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 + if(!KMX_ImportRules(kbid, kbd, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 return FALSE; } */ @@ -443,11 +453,11 @@ void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_ void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key) { if(key->ShiftFlags == 0) { //KMX_LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); - wprintf(L" Sab Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); + //wprintf(L" Sab Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); //MX_LogError(L"Did not find a match for mnemonic rule on line %d,\n", key->Line); } else if(key->ShiftFlags & VIRTUALCHARKEY) { //KMX_LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); - wprintf(L"SAB Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); + //wprintf(L"SAB Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); //KMX_LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, \n", key->Line); } } @@ -479,10 +489,8 @@ void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { /* -bool ImportRules(WCHAR *kbid, LPKEYBOARD kp, std::vector *FDeadkeys, BOOL bDeadkeyConversion); // I4353 // I4327 BOOL ConvertKeyboardToUnicode(LPKEYBOARD kbd); // I4273 -std::vector FDeadkeys; // I4353 #define KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE_MCOMPILE KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE ".mcompile" From aa53755a34e89a5653cb886db261e65d95a6490d Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 19 Sep 2023 09:27:51 +0200 Subject: [PATCH 082/327] feat(linux): mcompile new function InsertKeyvalsFromKeymap() --- linux/mcompile/keymap/keymap.cpp | 11 +++++++---- linux/mcompile/keymap/keymap.h | 8 +++++++- linux/mcompile/keymap/mcompile.cpp | 4 +++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 49299f2f6e..8fde002e43 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -265,7 +265,6 @@ int replace_PosKey_with_Keycode(std::string in) { int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { // create a 2D vector all filled with "--" and push to 3D-Vector v_dw_2D Other_Vector2D = create_empty_2D(All_Vector[0].size(),All_Vector[0][0].size()); - if (Other_Vector2D.size()==0) { wprintf(L"ERROR: can't create empty 2D-Vector\n"); return 1; @@ -274,14 +273,19 @@ int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { All_Vector.push_back(Other_Vector2D); wprintf(L" +++++++ dimensions of Vector after append_other_ToVector\t\t\t\t\t\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); wprintf(L" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n"); - if (All_Vector.size() < 2) { wprintf(L"ERROR: creation of 3D-Vector failed\n"); return 1; } - for(int i =0; i< (int) All_Vector[1].size();i++) { + InsertKeyvalsFromKeymap(All_Vector,keymap); + return 0; +} + +bool InsertKeyvalsFromKeymap(v_dw_3D &All_Vector,GdkKeymap * keymap){ + // get the keyvals using GDK and copy into All_Vector + for(int i =0; i< (int) All_Vector[1].size();i++) { // get key name US stored in [0][i][0] and copy to name in "other"-block[1][i][0] All_Vector[1][i][0] = All_Vector[0][i][0]; @@ -292,7 +296,6 @@ int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { //wprintf(L" Keycodes US dw : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); //wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); } - return 0; } v_dw_2D create_empty_2D( int dim_rows,int dim_shifts) { diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 9a647ed805..c0c87dbbd6 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -72,6 +72,9 @@ int append_other_ToVector(v_dw_3D &All_Vector, GdkKeymap *keymap); // create an empty 2D vector containing "--" in all fields v_dw_2D create_empty_2D(int dim_rows, int dim_shifts); +// get Keyvals from keymap and insert into All_Vector +bool InsertKeyvalsFromKeymap(v_dw_3D &All_Vector,GdkKeymap * keymap); + // find Keyvals to fill into 2D-Vector of Other Language KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos); @@ -79,7 +82,10 @@ KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state bool test(v_dw_3D &V); bool test_single(v_dw_3D &V) ; - +// this is for using mcompile without gdk to be able to debug in VSCode: (can be deleted later) +// In mcompile using gdk: Read values of keyboard with help of GDK. +// in mcompile WITHOUT using GDK: use gdk once to read values-> store them in file Vectorfile.txt +// Vectorfile.txt will then be used to find & append Values of OtherKeyboard to Vector bool writeVectorToFile(v_dw_3D V); bool writeFileToVector(v_dw_3D& complete_Vector, const char* infile); bool CompareVector_To_VectorOfFile(v_dw_3D All_Vector,v_dw_3D File_Vector); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 8ceeed4b0c..c0b3d22d68 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -35,7 +35,8 @@ mcompile -d runs 4 important steps: */ -// REMEMBER in this VM only run with meson compile is possible NOT with F5 !!! +// REMEMBER in this VM only runing with meson compile is possible NOT with F5 !!! +// in /Projects/keyman/keyman/linux/mcompile/keymap/build_mcompile // run with: //./mcompile -d in.kmx bla.dll 0407 out.kmx //./mcompile -d /Projects/keyman/keyman/linux/mcompile/keymap/anii.kmx bla.dll 0407 /Projects/keyman/keyman/linux/mcompile/keymap/anii_out.kmx @@ -317,6 +318,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon return FALSE; } + //_S2 this is to use a file and a vector instead of GDK-functions so debugging is easier...not needed later... v_dw_3D complete_Vector; bool writeVec_OK = writeVectorToFile(All_Vector); bool WriteFileOK = writeFileToVector( complete_Vector,"/Projects/keyman/keyman/linux/mcompile/keymap/VectorFile.txt" ); From 00944bc00b84640829bc3a631a121e2bfcd71121 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 19 Sep 2023 09:50:24 +0200 Subject: [PATCH 083/327] feat(linux): mcompile add #preprocessor identifier to use mcompile with file or GDK --- linux/mcompile/keymap/keymap.cpp | 6 +++++- linux/mcompile/keymap/keymap.h | 3 +++ linux/mcompile/keymap/mcompile.cpp | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 8fde002e43..63013ff687 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -277,8 +277,12 @@ int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { wprintf(L"ERROR: creation of 3D-Vector failed\n"); return 1; } - +#if USE_GDK + wprintf(L"USE_GDK is 1 ****************************************** \n"); InsertKeyvalsFromKeymap(All_Vector,keymap); +#else + wprintf(L"USE_GDK is 0 ****************************************** \n"); +#endif return 0; } diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index c0c87dbbd6..2bae4a76ef 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -3,6 +3,9 @@ #ifndef KEYMAP_H #define KEYMAP_H +// _S2 can go later; is for use of mcompile with GDK or with VectorFile +#define USE_GDK 1 + #include #include #include diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index c0b3d22d68..38dee254e9 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -303,6 +303,8 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon // evident for the 102nd key on UK, for example, where \ can be generated with VK_OEM_102 or AltGr+VK_QUOTE. // For now, we get the least shifted version, which is hopefully adequate. +#if USE_GDK + wprintf(L"USE_GDK is 1 ****************************************** \n"); // _S2 first version with GTK - change later to XklGetGroupNames und XklGetCurrentState as Eberhard suggested //_ init gdk GdkKeymap *keymap; @@ -310,6 +312,9 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon wprintf(L"ERROR: can't Initialize GDK\n"); return FALSE; } +#else + wprintf(L"USE_GDK is 0 ****************************************** \n"); +#endif // create vector v_dw_3D All_Vector; From d4b852a12de5c38734cd7fb3ed2479cc9d534d45 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 19 Sep 2023 15:22:43 +0200 Subject: [PATCH 084/327] feat(linux): mcompile usable with or without GDK depending on #USE_GDK --- linux/mcompile/keymap/keymap.cpp | 109 +++++++++++++++++++++++++---- linux/mcompile/keymap/keymap.h | 30 +++++--- linux/mcompile/keymap/mcompile.cpp | 43 +++++++++--- 3 files changed, 150 insertions(+), 32 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 63013ff687..f8b68b4008 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -187,7 +187,7 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { tokens_dw.push_back(tokens_int); } - wprintf(L" Keyval %i: %i (%c) --- %i (%c) \n", tokens_dw[0],tokens_dw[1],tokens_dw[1], tokens_dw[2], tokens_dw[2]); + //wprintf(L" Keyval %i: %i (%c) --- %i (%c) \n", tokens_dw[0],tokens_dw[1],tokens_dw[1], tokens_dw[2], tokens_dw[2]); // now push result to shift_states shift_states.push_back(tokens_dw); @@ -262,9 +262,18 @@ int replace_PosKey_with_Keycode(std::string in) { return out; } +int append_other_ToVector(v_dw_3D &All_Vector) { + + InsertKeyvalsFromVectorFile(All_Vector); + return 0; +} + +#if USE_GDK + int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { // create a 2D vector all filled with "--" and push to 3D-Vector v_dw_2D Other_Vector2D = create_empty_2D(All_Vector[0].size(),All_Vector[0][0].size()); + if (Other_Vector2D.size()==0) { wprintf(L"ERROR: can't create empty 2D-Vector\n"); return 1; @@ -273,17 +282,24 @@ int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { All_Vector.push_back(Other_Vector2D); wprintf(L" +++++++ dimensions of Vector after append_other_ToVector\t\t\t\t\t\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); wprintf(L" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n"); + if (All_Vector.size() < 2) { wprintf(L"ERROR: creation of 3D-Vector failed\n"); return 1; } -#if USE_GDK - wprintf(L"USE_GDK is 1 ****************************************** \n"); - InsertKeyvalsFromKeymap(All_Vector,keymap); -#else - wprintf(L"USE_GDK is 0 ****************************************** \n"); -#endif + for(int i =0; i< (int) All_Vector[1].size();i++) { + + // get key name US stored in [0][i][0] and copy to name in "other"-block[1][i][0] + All_Vector[1][i][0] = All_Vector[0][i][0]; + + // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] + All_Vector[1][i][0+1] = getKeyvalsFromKeymap(keymap,(All_Vector[1][i][0]),0); //shift state: unshifted:0 + All_Vector[1][i][1+1] = getKeyvalsFromKeymap(keymap,(All_Vector[1][i][0]),1); //shift state: shifted:1 + + //wprintf(L" Keycodes US dw : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); + //wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); + } return 0; } @@ -301,6 +317,61 @@ bool InsertKeyvalsFromKeymap(v_dw_3D &All_Vector,GdkKeymap * keymap){ //wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); } } +#endif +bool InsertKeyvalsFromVectorFile(v_dw_3D &complete_Vector) { + std::string TxtFileName = "/Projects/keyman/keyman/linux/mcompile/keymap/VectorFile.txt" ; + + //wprintf(L" +++++++ dimensions of Vector at beginning of writeFileToVector (languages..characters..shiftstates)\t\t %li..%li..%li\n", complete_Vector.size(), complete_Vector.size(),complete_Vector.size()); + //wprintf(L" #### InsertKeyvalsFromVectorFile started: \n"); + + FILE *fp; + char str[600]; + std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; + v_str_1D complete_List; + v_dw_1D tokens_dw; + v_dw_2D shift_states; + int k = -1; + + /* opening file for reading */ + fp = fopen(TxtFileName.c_str() , "r"); + if(fp == NULL) { + perror("Error opening file"); + return(-1); + } + + while (fgets(str, 600, fp) != NULL) { + k++; + //puts(str); + complete_List.push_back(str); + if (strcmp(str, "Language 2\n") ==0){ + complete_Vector.push_back(shift_states); + shift_states.clear(); + continue; + } + + // remove all unwanted char + for (int i = 0; i < (int)delim.size(); i++) { + complete_List[k].erase(remove(complete_List[k].begin(), complete_List[k].end(), delim[i]), complete_List[k].end()); + } + + // split into numbers ( delimiter -) + std::stringstream ss(complete_List[k]); + int end = complete_List[k].find("-"); + while (end != -1) { // Loop until no delimiter is left in the string. + tokens_dw.push_back((DWORD)stoi(complete_List[k].substr(0, end))); + complete_List[k].erase(complete_List[k].begin(), complete_List[k].begin() + end + 1); + end = complete_List[k].find("-"); + } + shift_states.push_back(tokens_dw); + tokens_dw.clear(); + } + complete_Vector.push_back(shift_states); + shift_states.clear(); + + fclose(fp); + //wprintf(L" #### InsertKeyvalsFromVectorFile ended: \n"); + //wprintf(L" +++++++ dimensions of Vector at END of writeFileToVector (languages..characters..shiftstates)\t\t %li..%li..%li\n", complete_Vector.size(), complete_Vector[0].size(),complete_Vector[0][0].size()); +} v_dw_2D create_empty_2D( int dim_rows,int dim_shifts) { v_dw_1D shifts; @@ -315,7 +386,7 @@ v_dw_2D create_empty_2D( int dim_rows,int dim_shifts) { } return Vector_2D; } - +#if USE_GDK KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; guint *keyvals; @@ -343,7 +414,10 @@ KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state return out; } +#endif + +// _S2 not needed later bool test(v_dw_3D &V) { std::string extra = " "; wprintf(L" +++++++ dimensions of whole Vector in test()\t\t\t\t\t\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); @@ -380,7 +454,7 @@ bool test_single(v_dw_3D &V) { return true; } - bool writeVectorToFile(v_dw_3D V) { +bool writeVectorToFile(v_dw_3D V) { std::string TxtFileName = "/Projects/keyman/keyman/linux/mcompile/keymap/VectorFile.txt" ; WCHAR DeadKey; std::ofstream TxTFile(TxtFileName); @@ -406,6 +480,9 @@ bool test_single(v_dw_3D &V) { } bool writeFileToVector(v_dw_3D& complete_Vector, const char* infile) { + wprintf(L" +++++++ dimensions of Vector at beginning of writeFileToVector (languages..characters..shiftstates)\t\t %li..%li..%li\n", complete_Vector.size(), complete_Vector.size(),complete_Vector.size()); + wprintf(L" #### writeFileToVector started: \n"); + FILE *fp; char str[600]; std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; @@ -450,7 +527,10 @@ bool writeFileToVector(v_dw_3D& complete_Vector, const char* infile) { complete_Vector.push_back(shift_states); shift_states.clear(); + wprintf(L" #### writeFileToVector ended: \n"); fclose(fp); + wprintf(L" +++++++ dimensions of Vector at END of writeFileToVector (languages..characters..shiftstates)\t\t %li..%li..%li\n", complete_Vector.size(), complete_Vector[0].size(),complete_Vector[0][0].size()); + return(0); } @@ -466,13 +546,16 @@ bool CompareVector_To_VectorOfFile(v_dw_3D All_Vector,v_dw_3D File_Vector){ for ( int i=0; i< All_Vector.size();i++) { for ( int j=0; j< All_Vector[i].size();j++) { for ( int k=0; k< All_Vector[i][j].size();k++){ - wprintf(L" All_Vector[%i][%i][%i]: %i File_Vector[i][j][k]\n", i,j,k, All_Vector[i][j][k], File_Vector[i][j][k]); - if(( All_Vector[i][j][k] == File_Vector[i][j][k])) return true; + if(( All_Vector[i][j][k] != File_Vector[i][j][k])) { + wprintf(L" All_Vector[%i][%i][%i]: %i %i File_Vector[i][j][k]\n", i,j,k, All_Vector[i][j][k], File_Vector[i][j][k]); + wprintf(L" DIFFERENT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); + return false; + } } - return false; } } + return true; wprintf(L" #### CompareVector_To_VectorOfFile ended \n"); return false; -} \ No newline at end of file +} diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 2bae4a76ef..bd511419cd 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -4,7 +4,7 @@ #define KEYMAP_H // _S2 can go later; is for use of mcompile with GDK or with VectorFile -#define USE_GDK 1 +#define USE_GDK 0 #include #include @@ -23,7 +23,6 @@ #include "u16.h" typedef std::vector v_str_1D; - typedef std::vector v_dw_1D; typedef std::vector > v_dw_2D; typedef std::vector > > v_dw_3D; @@ -51,11 +50,8 @@ static KMX_DWORD returnIfCharInvalid = 32; // takes a std::wstring (=contents of line symbols-file ) and returns the (int) value of the character KMX_DWORD convertNamesToValue(std::wstring tok_wstr); -// initialize GDK -bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); - -// create a Vector with all entries of both keymaps -int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap); +// create a Vector with all entries of Vector+ keymap +int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector); // read configuration file, split and write to 3D-Vector (Data for US on [0][ ][ ] ) int write_US_ToVector(v_dw_3D &vec, std::string language, const char *text); @@ -69,17 +65,33 @@ int split_US_To_3D_Vector(v_dw_3D &all_US, v_str_1D completeList); // replace Name of Key (e.g. ) wih Keycode ( e.g. 15 ) int replace_PosKey_with_Keycode(std::string in); -// append characters using GDK to 3D-Vector (Data for Other Language on [1][ ][ ] ) -int append_other_ToVector(v_dw_3D &All_Vector, GdkKeymap *keymap); +// append characters using VectorFile (Data for Other Language on [1][ ][ ] ) +int append_other_ToVector(v_dw_3D &All_Vector) ; // create an empty 2D vector containing "--" in all fields v_dw_2D create_empty_2D(int dim_rows, int dim_shifts); +// get Keyvals from VectorFile.txt and insert into All_Vector +bool InsertKeyvalsFromVectorFile(v_dw_3D &All_Vector); + +#if USE_GDK + +// initialize GDK +bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); + +// create a Vector with all entries of both keymaps +int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap); + +// append characters using GDK to 3D-Vector (Data for Other Language on [1][ ][ ] ) +int append_other_ToVector(v_dw_3D &All_Vector, GdkKeymap *keymap); + // get Keyvals from keymap and insert into All_Vector bool InsertKeyvalsFromKeymap(v_dw_3D &All_Vector,GdkKeymap * keymap); // find Keyvals to fill into 2D-Vector of Other Language KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos); +#endif + // testing of Vector contents ( first row of US and Other) bool test(v_dw_3D &V); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 38dee254e9..941e0c8a94 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -188,7 +188,8 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ // comment from win-version // Map of all shift states that we will work with -const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; +//const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; +const UINT VKShiftState[] = {0, K_SHIFTFLAG, 0xFFFF}; // my comment for Lin version // Ubuntu: Each of the 4 columns specifies a different modifier: unmodified, shift, right alt (altgr), shift+right alt(altgr) @@ -235,11 +236,11 @@ KMX_DWORD KMX_VKUSToVKUnderlyingLayout(v_dw_3D &All_Vector,KMX_DWORD inUS) { // takes cpital character of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] KMX_DWORD KMX_CharFromVK(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey){ -KMX_UINT VKShiftState_lin; -if (VKShiftState == 0 ) VKShiftState_lin =0; -if (VKShiftState == 16) VKShiftState_lin =1; -if (VKShiftState == 9 ) VKShiftState_lin =2; -if (VKShiftState == 25) VKShiftState_lin =3; + KMX_UINT VKShiftState_lin; + if (VKShiftState == 0 ) VKShiftState_lin =0; + if (VKShiftState == 16) VKShiftState_lin =1; + if (VKShiftState == 9 ) VKShiftState_lin =2; + if (VKShiftState == 25) VKShiftState_lin =3; // loop and find vkUnderlying in Other; then return char with correct shiftstate for( int i=0; i< (int)All_Vector[1].size();i++) { @@ -251,6 +252,7 @@ if (VKShiftState == 25) VKShiftState_lin =3; return vkUnderlying; } +#if USE_GDK bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]){ // get keymap of keyboard layout in use @@ -289,6 +291,20 @@ int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ } return 0; } +#endif + +int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector){ + // here we copy all contents of the FILE ( US and other already available in the file) to All_Vector + //wprintf(L" +++++++ dimensions of Vector in createOneVectorFromBothKeyboards 2 \t\t\t\t\t\t %li..%li..%li\n", All_Vector.size(), All_Vector.size(),All_Vector.size()); + + // add contents of file to All_Vector + if( append_other_ToVector(All_Vector)) { + wprintf(L"ERROR: can't append Other ToVector \n"); + return 2; + } + //wprintf(L" +++++++ dimensions of Vector in createOneVectorFromBothKeyboards 3 \t\t\t\t\t\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); + return 0; +} KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]) { @@ -312,9 +328,6 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon wprintf(L"ERROR: can't Initialize GDK\n"); return FALSE; } -#else - wprintf(L"USE_GDK is 0 ****************************************** \n"); -#endif // create vector v_dw_3D All_Vector; @@ -322,13 +335,23 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon wprintf(L"ERROR: can't create one vector from both keyboards\n"); return FALSE; } +#else + wprintf(L"USE_GDK is 0 ****************************************** \n"); + // create vector + v_dw_3D All_Vector; + if(createOneVectorFromBothKeyboards(All_Vector)){ + wprintf(L"ERROR: can't create one vector from both keyboards\n"); + return FALSE; + } +#endif +/* //_S2 this is to use a file and a vector instead of GDK-functions so debugging is easier...not needed later... v_dw_3D complete_Vector; bool writeVec_OK = writeVectorToFile(All_Vector); bool WriteFileOK = writeFileToVector( complete_Vector,"/Projects/keyman/keyman/linux/mcompile/keymap/VectorFile.txt" ); bool isEqual= CompareVector_To_VectorOfFile( All_Vector, complete_Vector); - wprintf(L" vectors are equal: %i\n",isEqual); + wprintf(L" vectors are equal: %i\n",isEqual);*/ test(All_Vector); //-------------------------------------------------------------------------------- From 17a311841f128f80e254faa1dbeb7ff310fe7f07 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 20 Sep 2023 13:48:00 +0200 Subject: [PATCH 085/327] feat(linux): mcompile small change in mc_import_rules --- linux/mcompile/keymap/mc_import_rules.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 82504d01e1..95ee56bf6b 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -766,7 +766,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp, std::vectorDeadCharacter(), &alDead, nDeadkey, FDeadkeys); // I4353 - //*p++ = nDeadkey+i; + // *p++ = nDeadkey+i; *p++ = UC_SENTINEL; *p++ = CODE_ANY; *p++ = nStoreBase + i*2 + 1; From bf9d20fde749a11df1394716766e28d11e95d89f Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 21 Sep 2023 14:14:26 +0200 Subject: [PATCH 086/327] feat(linux): mcompile move all functions that use VectorFile.txt to helpers --- linux/mcompile/keymap/helpers.cpp | 80 ++++++++++++++++++++++++++ linux/mcompile/keymap/helpers.h | 28 +++++++++ linux/mcompile/keymap/keymap.cpp | 91 +++++------------------------- linux/mcompile/keymap/keymap.h | 2 - linux/mcompile/keymap/mcompile.cpp | 20 +++---- linux/mcompile/keymap/mcompile.h | 1 + linux/mcompile/keymap/meson.build | 1 + 7 files changed, 131 insertions(+), 92 deletions(-) create mode 100644 linux/mcompile/keymap/helpers.cpp create mode 100644 linux/mcompile/keymap/helpers.h diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp new file mode 100644 index 0000000000..3e8a66a7ef --- /dev/null +++ b/linux/mcompile/keymap/helpers.cpp @@ -0,0 +1,80 @@ + +#include "helpers.h" + +int test_helpers(){ + wprintf(L"##### test_helpers is here and USE_GDK is %i\n", USE_GDK); +} + +int append_other_ToVector(v_dw_3D &All_Vector) { + + InsertKeyvalsFromVectorFile(All_Vector); + return 0; +} + +bool InsertKeyvalsFromVectorFile(v_dw_3D &complete_Vector) { + std::string TxtFileName = "/Projects/keyman/keyman/linux/mcompile/keymap/VectorFile.txt" ; + + //wprintf(L" +++++++ dimensions of Vector at beginning of writeFileToVector (languages..characters..shiftstates)\t\t %li..%li..%li\n", complete_Vector.size(), complete_Vector.size(),complete_Vector.size()); + //wprintf(L" #### InsertKeyvalsFromVectorFile started: \n"); + + FILE *fp; + char str[600]; + std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; + v_str_1D complete_List; + v_dw_1D tokens_dw; + v_dw_2D shift_states; + int k = -1; + + /* opening file for reading */ + fp = fopen(TxtFileName.c_str() , "r"); + if(fp == NULL) { + perror("Error opening file"); + return(-1); + } + + while (fgets(str, 600, fp) != NULL) { + k++; + //puts(str); + complete_List.push_back(str); + if (strcmp(str, "Language 2\n") ==0){ + complete_Vector.push_back(shift_states); + shift_states.clear(); + continue; + } + + // remove all unwanted char + for (int i = 0; i < (int)delim.size(); i++) { + complete_List[k].erase(remove(complete_List[k].begin(), complete_List[k].end(), delim[i]), complete_List[k].end()); + } + + // split into numbers ( delimiter -) + std::stringstream ss(complete_List[k]); + int end = complete_List[k].find("-"); + while (end != -1) { // Loop until no delimiter is left in the string. + tokens_dw.push_back((DWORD)stoi(complete_List[k].substr(0, end))); + complete_List[k].erase(complete_List[k].begin(), complete_List[k].begin() + end + 1); + end = complete_List[k].find("-"); + } + shift_states.push_back(tokens_dw); + tokens_dw.clear(); + } + complete_Vector.push_back(shift_states); + shift_states.clear(); + + fclose(fp); + //wprintf(L" #### InsertKeyvalsFromVectorFile ended: \n"); + //wprintf(L" +++++++ dimensions of Vector at END of writeFileToVector (languages..characters..shiftstates)\t\t %li..%li..%li\n", complete_Vector.size(), complete_Vector[0].size(),complete_Vector[0][0].size()); +} + +int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector){ + // here we copy all contents of the FILE ( US and other already available in the file) to All_Vector + //wprintf(L" +++++++ dimensions of Vector in createOneVectorFromBothKeyboards 2 \t\t\t\t\t\t %li..%li..%li\n", All_Vector.size(), All_Vector.size(),All_Vector.size()); + + // add contents of file to All_Vector + if( append_other_ToVector(All_Vector)) { + wprintf(L"ERROR: can't append Other ToVector \n"); + return 2; + } + //wprintf(L" +++++++ dimensions of Vector in createOneVectorFromBothKeyboards 3 \t\t\t\t\t\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); + return 0; +} diff --git a/linux/mcompile/keymap/helpers.h b/linux/mcompile/keymap/helpers.h new file mode 100644 index 0000000000..7ac8d22a74 --- /dev/null +++ b/linux/mcompile/keymap/helpers.h @@ -0,0 +1,28 @@ +#pragma once +#ifndef HELPERS_H +#define HELPERS_H + +#include +#include "mc_savekeyboard.h" +#include "mc_kmxfile.h" +#include "keymap.h" + +// why again here? +typedef std::vector v_str_1D; +typedef std::vector v_dw_1D; +typedef std::vector > v_dw_2D; +typedef std::vector > > v_dw_3D; + + +int test_helpers(); + +// append characters using VectorFile (Data for Other Language on [1][ ][ ] ) +int append_other_ToVector(v_dw_3D &All_Vector) ; + +// get Keyvals from File and insert into All_Vector +bool InsertKeyvalsFromVectorFile(v_dw_3D &complete_Vector) ; + +// create a Vector with all entries of file +int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector); + +#endif /* HELPERS_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index f8b68b4008..faa894c179 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -262,15 +262,22 @@ int replace_PosKey_with_Keycode(std::string in) { return out; } -int append_other_ToVector(v_dw_3D &All_Vector) { +v_dw_2D create_empty_2D( int dim_rows,int dim_shifts) { + v_dw_1D shifts; + v_dw_2D Vector_2D; - InsertKeyvalsFromVectorFile(All_Vector); - return 0; + for ( int i=0; i< dim_rows;i++) { + for ( int j=0; j< dim_shifts;j++) { + shifts.push_back(returnIfCharInvalid); + } + Vector_2D.push_back(shifts); + shifts.clear(); + } + return Vector_2D; } #if USE_GDK - -int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { + int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { // create a 2D vector all filled with "--" and push to 3D-Vector v_dw_2D Other_Vector2D = create_empty_2D(All_Vector[0].size(),All_Vector[0][0].size()); @@ -303,7 +310,7 @@ int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { return 0; } -bool InsertKeyvalsFromKeymap(v_dw_3D &All_Vector,GdkKeymap * keymap){ + bool InsertKeyvalsFromKeymap(v_dw_3D &All_Vector,GdkKeymap * keymap){ // get the keyvals using GDK and copy into All_Vector for(int i =0; i< (int) All_Vector[1].size();i++) { // get key name US stored in [0][i][0] and copy to name in "other"-block[1][i][0] @@ -317,77 +324,8 @@ bool InsertKeyvalsFromKeymap(v_dw_3D &All_Vector,GdkKeymap * keymap){ //wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); } } -#endif -bool InsertKeyvalsFromVectorFile(v_dw_3D &complete_Vector) { - std::string TxtFileName = "/Projects/keyman/keyman/linux/mcompile/keymap/VectorFile.txt" ; - //wprintf(L" +++++++ dimensions of Vector at beginning of writeFileToVector (languages..characters..shiftstates)\t\t %li..%li..%li\n", complete_Vector.size(), complete_Vector.size(),complete_Vector.size()); - //wprintf(L" #### InsertKeyvalsFromVectorFile started: \n"); - - FILE *fp; - char str[600]; - std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; - v_str_1D complete_List; - v_dw_1D tokens_dw; - v_dw_2D shift_states; - int k = -1; - - /* opening file for reading */ - fp = fopen(TxtFileName.c_str() , "r"); - if(fp == NULL) { - perror("Error opening file"); - return(-1); - } - - while (fgets(str, 600, fp) != NULL) { - k++; - //puts(str); - complete_List.push_back(str); - if (strcmp(str, "Language 2\n") ==0){ - complete_Vector.push_back(shift_states); - shift_states.clear(); - continue; - } - - // remove all unwanted char - for (int i = 0; i < (int)delim.size(); i++) { - complete_List[k].erase(remove(complete_List[k].begin(), complete_List[k].end(), delim[i]), complete_List[k].end()); - } - - // split into numbers ( delimiter -) - std::stringstream ss(complete_List[k]); - int end = complete_List[k].find("-"); - while (end != -1) { // Loop until no delimiter is left in the string. - tokens_dw.push_back((DWORD)stoi(complete_List[k].substr(0, end))); - complete_List[k].erase(complete_List[k].begin(), complete_List[k].begin() + end + 1); - end = complete_List[k].find("-"); - } - shift_states.push_back(tokens_dw); - tokens_dw.clear(); - } - complete_Vector.push_back(shift_states); - shift_states.clear(); - - fclose(fp); - //wprintf(L" #### InsertKeyvalsFromVectorFile ended: \n"); - //wprintf(L" +++++++ dimensions of Vector at END of writeFileToVector (languages..characters..shiftstates)\t\t %li..%li..%li\n", complete_Vector.size(), complete_Vector[0].size(),complete_Vector[0][0].size()); -} - -v_dw_2D create_empty_2D( int dim_rows,int dim_shifts) { - v_dw_1D shifts; - v_dw_2D Vector_2D; - - for ( int i=0; i< dim_rows;i++) { - for ( int j=0; j< dim_shifts;j++) { - shifts.push_back(returnIfCharInvalid); - } - Vector_2D.push_back(shifts); - shifts.clear(); - } - return Vector_2D; -} -#if USE_GDK -KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { + KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; guint *keyvals; gint count; @@ -416,7 +354,6 @@ KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state } #endif - // _S2 not needed later bool test(v_dw_3D &V) { std::string extra = " "; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index bd511419cd..cbaca1c4cf 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -65,8 +65,6 @@ int split_US_To_3D_Vector(v_dw_3D &all_US, v_str_1D completeList); // replace Name of Key (e.g. ) wih Keycode ( e.g. 15 ) int replace_PosKey_with_Keycode(std::string in); -// append characters using VectorFile (Data for Other Language on [1][ ][ ] ) -int append_other_ToVector(v_dw_3D &All_Vector) ; // create an empty 2D vector containing "--" in all fields v_dw_2D create_empty_2D(int dim_rows, int dim_shifts); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 941e0c8a94..f257f931f6 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -35,7 +35,12 @@ mcompile -d runs 4 important steps: */ -// REMEMBER in this VM only runing with meson compile is possible NOT with F5 !!! +// REMEMBER in this VM now debugs with meson compile AND with F5 !!! ( because launch.json has configuration: "Debug with Meson") +// To debug with VSC (F5): +// cd to: /Projects/keyman/keyman/linux/mcompile/keymap/build_mcompile +// run : meson compile ( executable is created - TODO after each change !) +// cursor in mcompile.cpp: F5 + // in /Projects/keyman/keyman/linux/mcompile/keymap/build_mcompile // run with: //./mcompile -d in.kmx bla.dll 0407 out.kmx @@ -86,6 +91,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ } wprintf(L"##### started run\n"); + test_helpers(); if(argc < 3 || (argc < 5 && u16cmp(argv[1], u"-u") != 0)) { // I4273// I4273 wprintf( @@ -293,18 +299,6 @@ int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ } #endif -int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector){ - // here we copy all contents of the FILE ( US and other already available in the file) to All_Vector - //wprintf(L" +++++++ dimensions of Vector in createOneVectorFromBothKeyboards 2 \t\t\t\t\t\t %li..%li..%li\n", All_Vector.size(), All_Vector.size(),All_Vector.size()); - - // add contents of file to All_Vector - if( append_other_ToVector(All_Vector)) { - wprintf(L"ERROR: can't append Other ToVector \n"); - return 2; - } - //wprintf(L" +++++++ dimensions of Vector in createOneVectorFromBothKeyboards 3 \t\t\t\t\t\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); - return 0; -} KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]) { diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index f94d0f6ae5..431d8d5998 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -23,6 +23,7 @@ #define MCOMPILE_H #include #include "keymap.h" +#include "helpers.h" #include "mc_kmxfile.h" diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index 96c479351b..49f75b2885 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -11,6 +11,7 @@ libxklavier = dependency('libxklavier') deps = [gtk, x11, xkb,libxklavier] cpp_files = files( + 'helpers.cpp', 'keymap.cpp', 'mcompile.cpp', 'filesystem.cpp', From 9a88b6349bba4db5eb3252564f5fb24ac9c24941 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 22 Sep 2023 11:56:53 +0200 Subject: [PATCH 087/327] feat(linux): mcompile add more functions to helpers.cpp/.h --- linux/mcompile/keymap/helpers.cpp | 161 ++++++++++++++++++++++++++++++ linux/mcompile/keymap/helpers.h | 6 ++ 2 files changed, 167 insertions(+) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 3e8a66a7ef..10c7a314de 100644 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -78,3 +78,164 @@ int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector){ //wprintf(L" +++++++ dimensions of Vector in createOneVectorFromBothKeyboards 3 \t\t\t\t\t\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); return 0; } + + +bool writeVectorToFile(v_dw_3D V) { + std::string TxtFileName = "/Projects/keyman/keyman/linux/mcompile/keymap/VectorFile2.txt" ; + WCHAR DeadKey; + std::ofstream TxTFile(TxtFileName); + //TxTFile << "\n kbid << VKShiftState[j] << US VKMap[i] < delim{' ', '[', ']', '}', ';', '\t', '\n'}; + v_str_1D complete_List; + v_dw_1D tokens_dw; + v_dw_2D shift_states; + int k = -1; + + /* opening file for reading */ + fp = fopen("/Projects/keyman/keyman/linux/mcompile/keymap/VectorFile.txt" , "r"); + if(fp == NULL) { + perror("Error opening file"); + return(-1); + } + + while (fgets(str, 600, fp) != NULL) { + k++; + //puts(str); + complete_List.push_back(str); + if (strcmp(str, "Language 2\n") ==0){ + complete_Vector.push_back(shift_states); + shift_states.clear(); + continue; + } + + // remove all unwanted char + for (int i = 0; i < (int)delim.size(); i++) { + complete_List[k].erase(remove(complete_List[k].begin(), complete_List[k].end(), delim[i]), complete_List[k].end()); + } + + // split into numbers ( delimiter -) + std::stringstream ss(complete_List[k]); + int end = complete_List[k].find("-"); + while (end != -1) { // Loop until no delimiter is left in the string. + tokens_dw.push_back((DWORD)stoi(complete_List[k].substr(0, end))); + complete_List[k].erase(complete_List[k].begin(), complete_List[k].begin() + end + 1); + end = complete_List[k].find("-"); + } + shift_states.push_back(tokens_dw); + tokens_dw.clear(); + } + complete_Vector.push_back(shift_states); + shift_states.clear(); + + wprintf(L" #### writeFileToVector ended: \n"); + fclose(fp); + wprintf(L" +++++++ dimensions of Vector at END of writeFileToVector (languages..characters..shiftstates)\t\t %li..%li..%li\n", complete_Vector.size(), complete_Vector[0].size(),complete_Vector[0][0].size()); + + return(0); +} + +bool CompareVector_To_VectorOfFile(v_dw_3D All_Vector,v_dw_3D File_Vector){ + wprintf(L" #### CompareVector_To_VectorOfFile started: "); + wprintf(L" #### dimensions: %i %i %i -- %i %i %i \n", All_Vector.size() ,All_Vector[0].size(), All_Vector[0][0].size(),File_Vector.size() ,File_Vector[0].size(), File_Vector[0][0].size()); + + if (!(All_Vector.size() == File_Vector.size()) )return false; + if (!(All_Vector[0].size() == File_Vector[0].size())) return false; + if (!(All_Vector[0][0].size() == File_Vector[0][0].size())) return false; + + wprintf(L" #### CompareVector_To_VectorOfFile dimensions OK \n"); + for ( int i=0; i< All_Vector.size();i++) { + for ( int j=0; j< All_Vector[i].size();j++) { + for ( int k=0; k< All_Vector[i][j].size();k++){ + if(( All_Vector[i][j][k] != File_Vector[i][j][k])) { + wprintf(L" All_Vector[%i][%i][%i]: %i %i File_Vector[i][j][k]\n", i,j,k, All_Vector[i][j][k], File_Vector[i][j][k]); + wprintf(L" DIFFERENT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); + return false; + } + } + } + } + + return true; + wprintf(L" #### CompareVector_To_VectorOfFile ended \n"); + return false; +} + + +bool test_In_Out(v_dw_3D All_Vector){ + + for ( int i=0; i<61;i++) + { + KMX_DWORD out_Other= get_VirtualKey_Other_From_SC(i,All_Vector); + KMX_DWORD out_US= get_VirtualKey_US_From_SC(i,All_Vector); + + if (out_Other==out_US) { + const wchar_t* ADD = L" "; + + wprintf(L" out = %i --- %i (%c) ", out_Other, out_US, *ADD); } + else { + const wchar_t* ADD = L"*" ; + wprintf(L" out = %i --- %i (%c) ", out_Other, out_US, *ADD); } + + wprintf(L"\n"); + } + + wprintf(L"*****************************************\n"); + for ( int i=0; i<61;i++) + { + KMX_DWORD VK_Other= get_VirtualKey_Other_From_SC(i,All_Vector); + KMX_DWORD SC_Other= get_SC_From_VirtualKey_Other(VK_Other,All_Vector); + + if (i==SC_Other) { + const wchar_t* ADD = L" "; + wprintf(L"in %i ---> %i(%c) ---> %i (%c) \n", i, VK_Other,VK_Other, SC_Other ,*ADD); + } + + else { + const wchar_t* ADD = L"!"; + wprintf(L"in %i ---> %i(%c) ---> %i (%c) \n", i, VK_Other,VK_Other, SC_Other ,*ADD); + } + } + + wprintf(L" 3 *****************************************\n"); + for ( int i=0; i<61;i++) + { + KMX_DWORD VK_Other= get_VirtualKey_US_From_SC(i,All_Vector); + KMX_DWORD SC_Other= get_SC_From_VirtualKey_US(VK_Other,All_Vector); + + if (i==SC_Other) { + const wchar_t* ADD = L" "; + wprintf(L"IN %i ---> %i(%c) ---> %i (%c) \n", i, VK_Other,VK_Other, SC_Other ,*ADD); + } + + else { + const wchar_t* ADD = L"!"; + wprintf(L"IN %i ---> %i(%c) ---> %i (%c) \n", i, VK_Other,VK_Other, SC_Other ,*ADD); + } + } +} \ No newline at end of file diff --git a/linux/mcompile/keymap/helpers.h b/linux/mcompile/keymap/helpers.h index 7ac8d22a74..028361ef4d 100644 --- a/linux/mcompile/keymap/helpers.h +++ b/linux/mcompile/keymap/helpers.h @@ -25,4 +25,10 @@ bool InsertKeyvalsFromVectorFile(v_dw_3D &complete_Vector) ; // create a Vector with all entries of file int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector); + +bool writeVectorToFile(v_dw_3D V) ; +bool writeFileToVector(v_dw_3D& complete_Vector, const char* infile); +bool CompareVector_To_VectorOfFile(v_dw_3D All_Vector,v_dw_3D File_Vector); +bool test_In_Out(v_dw_3D All_Vector); + #endif /* HELPERS_H*/ \ No newline at end of file From 9ddd4192d82f2b61c1299d3b0f5e0e27576280f6 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 22 Sep 2023 11:59:16 +0200 Subject: [PATCH 088/327] feat(linux): mcompile add functions to query Vector --- linux/mcompile/keymap/keymap.cpp | 148 ++++++++++--------------------- linux/mcompile/keymap/keymap.h | 10 +++ 2 files changed, 58 insertions(+), 100 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index faa894c179..eddee4b900 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -367,10 +367,10 @@ bool test(v_dw_3D &V) { extra = " "; if (V[0].size()>0) { - //wprintf(L" row (US) ...... %i .. %i (%c) .. %i (%c) .. --- ",V[0][k][0] , V[0][k][1] , V[0][k][1] , V[0][k][2] , V[0][k][2] ); - //wprintf(L" \n"); - //wprintf(L" row (Other)..... %i .. %i (%c) .. %i (%c) .. %s \n", V[1][k][0] , V[1][k][1], V[1][k][1] , V[1][k][2], V[1][k][2] , extra.c_str()); - //wprintf(L" \n"); + /*wprintf(L" row (US) ...... SC= %i .. %i (%c) .. %i (%c) .. --- ",V[0][k][0] , V[0][k][1] , V[0][k][1] , V[0][k][2] , V[0][k][2] ); + wprintf(L" \n"); + wprintf(L" row (Other)..... SC= %i .. %i (%c) .. %i (%c) .. %s \n", V[1][k][0] , V[1][k][1], V[1][k][1] , V[1][k][2], V[1][k][2] , extra.c_str()); + wprintf(L" \n");*/ } } wprintf(L"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); @@ -391,108 +391,56 @@ bool test_single(v_dw_3D &V) { return true; } -bool writeVectorToFile(v_dw_3D V) { - std::string TxtFileName = "/Projects/keyman/keyman/linux/mcompile/keymap/VectorFile.txt" ; - WCHAR DeadKey; - std::ofstream TxTFile(TxtFileName); - //TxTFile << "\n kbid << VKShiftState[j] << US VKMap[i] < delim{' ', '[', ']', '}', ';', '\t', '\n'}; - v_str_1D complete_List; - v_dw_1D tokens_dw; - v_dw_2D shift_states; - int k = -1; - - /* opening file for reading */ - fp = fopen("/Projects/keyman/keyman/linux/mcompile/keymap/VectorFile.txt" , "r"); - if(fp == NULL) { - perror("Error opening file"); - return(-1); - } - - while (fgets(str, 600, fp) != NULL) { - k++; - //puts(str); - complete_List.push_back(str); - if (strcmp(str, "Language 2\n") ==0){ - complete_Vector.push_back(shift_states); - shift_states.clear(); - continue; +// query All_Vector +// return RETURN NON SHIFTED CHAR [1] the VirtualKey of the Other Keyboard for given Scancode +KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ + // find correct row of char in US + for( int i=0; i< (int)All_Vector[1].size()-1;i++) { + if ( All_Vector[1][i][0] == SC ) { + wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- \n",SC , i, All_Vector[1][i][0] , All_Vector[1][i][1] ,All_Vector[1][i][1] , All_Vector[1][i][2] , All_Vector[1][i][2] ); + return All_Vector[1][i][1] ; + //return All_Vector[1][i][2] ; // would be shifted version } - - // remove all unwanted char - for (int i = 0; i < (int)delim.size(); i++) { - complete_List[k].erase(remove(complete_List[k].begin(), complete_List[k].end(), delim[i]), complete_List[k].end()); - } - - // split into numbers ( delimiter -) - std::stringstream ss(complete_List[k]); - int end = complete_List[k].find("-"); - while (end != -1) { // Loop until no delimiter is left in the string. - tokens_dw.push_back((DWORD)stoi(complete_List[k].substr(0, end))); - complete_List[k].erase(complete_List[k].begin(), complete_List[k].begin() + end + 1); - end = complete_List[k].find("-"); - } - shift_states.push_back(tokens_dw); - tokens_dw.clear(); } - complete_Vector.push_back(shift_states); - shift_states.clear(); - - wprintf(L" #### writeFileToVector ended: \n"); - fclose(fp); - wprintf(L" +++++++ dimensions of Vector at END of writeFileToVector (languages..characters..shiftstates)\t\t %li..%li..%li\n", complete_Vector.size(), complete_Vector[0].size(),complete_Vector[0][0].size()); - - return(0); + return 98; //_S2 what do I return if not found?? } -bool CompareVector_To_VectorOfFile(v_dw_3D All_Vector,v_dw_3D File_Vector){ - wprintf(L" #### CompareVector_To_VectorOfFile started: "); - wprintf(L" #### dimensions: %i %i %i -- %i %i %i \n", All_Vector.size() ,All_Vector[0].size(), All_Vector[0][0].size(),File_Vector.size() ,File_Vector[0].size(), File_Vector[0][0].size()); - if (!(All_Vector.size() == File_Vector.size()) )return false; - if (!(All_Vector[0].size() == File_Vector[0].size())) return false; - if (!(All_Vector[0][0].size() == File_Vector[0][0].size())) return false; - - wprintf(L" #### CompareVector_To_VectorOfFile dimensions OK \n"); - for ( int i=0; i< All_Vector.size();i++) { - for ( int j=0; j< All_Vector[i].size();j++) { - for ( int k=0; k< All_Vector[i][j].size();k++){ - if(( All_Vector[i][j][k] != File_Vector[i][j][k])) { - wprintf(L" All_Vector[%i][%i][%i]: %i %i File_Vector[i][j][k]\n", i,j,k, All_Vector[i][j][k], File_Vector[i][j][k]); - wprintf(L" DIFFERENT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); - return false; - } - } +// return RETURN NON SHIFTED CHAR [1] the VirtualKey of the US Keyboard for given Scancode +KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ + // find correct row of char in US + for( int i=0; i< (int)All_Vector[0].size()-1;i++) { + if ( All_Vector[0][i][0] == SC ) { + wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- ",SC , i, All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2] ); + return All_Vector[0][i][1] ; + //return All_Vector[0][i][2] ; // would be shifted version } } - - return true; - wprintf(L" #### CompareVector_To_VectorOfFile ended \n"); - return false; + return 987; //_S2 what do I return if not found?? +} + + +// return the Scancode of for given VirtualKey of Other Keyboard +KMX_DWORD get_SC_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector){ + // find correct row of char in US + for( int i=0; i< (int)All_Vector[1].size()-1;i++) { + if ( All_Vector[1][i][1] == VK_Other ) { + wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- ",VK_Other , i, All_Vector[1][i][0] , All_Vector[1][i][1] ,All_Vector[1][i][1] , All_Vector[1][i][2] , All_Vector[1][i][2] ); + return All_Vector[1][i][0] ; + } + } + return 9876; //_S2 what do I return if not found?? +} + +// return the Scancode of for given VirtualKey of Other US +KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ + // find correct row of char in US + for( int i=0; i< (int)All_Vector[0].size()-1;i++) { + if ( All_Vector[0][i][1] == VK_US ) { + wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- \n",VK_US , i, All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2] ); + return All_Vector[0][i][0] ; + } + } + return 98765; //_S2 what do I return if not found?? } diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index cbaca1c4cf..844b23921c 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -72,6 +72,16 @@ v_dw_2D create_empty_2D(int dim_rows, int dim_shifts); // get Keyvals from VectorFile.txt and insert into All_Vector bool InsertKeyvalsFromVectorFile(v_dw_3D &All_Vector); +// query All_Vector +// return the VirtualKey of the Other Keyboard for given Scancode +KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); +// return the VirtualKey of the US Keyboard for given Scancode +KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); +// return the Scancode of for given VirtualKey of Other Keyboard +KMX_DWORD get_SC_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector); +// return the Scancode of for given VirtualKey of Other US +KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector); + #if USE_GDK // initialize GDK From feb472d334492a1bf4df156541d07266ce2e2839 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 22 Sep 2023 12:01:45 +0200 Subject: [PATCH 089/327] feat(linux): mcompile start to adapt ImportRules --- linux/mcompile/keymap/km_types.h | 6 +++ linux/mcompile/keymap/mc_import_rules.cpp | 61 +++++++++++++++-------- linux/mcompile/keymap/mcompile.cpp | 16 ++++-- 3 files changed, 57 insertions(+), 26 deletions(-) diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index 0bac8233fd..d8c253143e 100644 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -72,6 +72,12 @@ typedef unsigned int UINT; // _S2 needs to be removed/? typedef int BOOL; // _S2 needs to be removed/? or is it int32_t?? + // in WIN: + // PVOID A pointer to any type. + // typedef PVOID HANDLE; + // typedef HANDLE HKL; +typedef void* KMX_HKL; // _S2 what is the equivalent to HKL and do I need it?? I assume a void* + typedef uint32_t KMX_UINT; typedef KMX_BYTE* PKMX_BYTE; diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 95ee56bf6b..b1fea63e15 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -50,13 +50,13 @@ const int ShiftStateMap[] = { ISVIRTUALKEY | RALTFLAG | K_SHIFTFLAG, 0, 0}; - + */ class DeadKey { private: WCHAR m_deadchar; std::vector m_rgbasechar; std::vector m_rgcombchar; - +/* public: DeadKey(WCHAR deadCharacter) { this->m_deadchar = deadCharacter; @@ -91,9 +91,9 @@ public: } } return false; - } + }*/ }; - +/* int DeadKeyMap(int index, std::vector *deadkeys, int deadkeyBase, std::vector *deadkeyMappings) { // I4327 // I4353 for(size_t i = 0; i < deadkeyMappings->size(); i++) { @@ -109,15 +109,15 @@ int DeadKeyMap(int index, std::vector *deadkeys, int deadkeyBase, std } return 0xFFFF; } - +*/ class VirtualKey { private: - HKL m_hkl; + KMX_HKL m_hkl; // _S2 do I need this and is void* OK to assume? UINT m_vk; UINT m_sc; bool m_rgfDeadKey[10][2]; std::wstring m_rgss[10][2]; - +/* public: VirtualKey(HKL hkl, UINT virtualKey) { this->m_sc = MapVirtualKeyEx(virtualKey, 0, hkl); @@ -315,8 +315,9 @@ public: } return true; } -}; + */ +}; class KMX_Loader { private: KMX_BYTE lpKeyStateNull[256]; @@ -467,30 +468,38 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp, std::vector rgKey; //= new VirtualKey[256]; std::vector alDead; rgKey.resize(256); +int STOP = 0; +/* + // _S2 scroll through OTHER // Scroll through the Scan Code (SC) values and get the valid Virtual Key (VK) // values in it. Then, store the SC in each valid VK so it can act as both a // flag that the VK is valid, and it can store the SC value. for(UINT sc = 0x01; sc <= 0x7f; sc++) { - VirtualKey *key = new VirtualKey(sc, hkl); + VirtualKey *key = new VirtualKey(sc, hkl); // _S2 get this from my Vector if(key->VK() != 0) { rgKey[key->VK()] = key; } else { @@ -498,6 +507,8 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp, std::vectorVK(), rgKey[iKey]->SC(), lpKeyState, sbBuffer, _countof(sbBuffer), 0, hkl); if(rc > 0) { if(*sbBuffer == 0) { @@ -591,6 +605,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp, std::vector vkUnderlying: %i (%c) \tshiftstate[%i]: ( %i ) \t---- > ch: %i (%c) \t%ls \t%ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, j, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); - /* + + /* _S2 ToDo if(bDeadkeyConversion) { // I4552 if(ch == 0xFFFF) { ch = DeadKey; @@ -391,11 +396,14 @@ test(All_Vector); wprintf(L"\n##### KMX_ReportUnconvertedKeyboardRules of mcompile will start #####\n"); KMX_ReportUnconvertedKeyboardRules(kbd); -/* + +// _S2 convert mcompile Step1: use (wrong) Datatype WCHAR (=wchar_t) +// _S2 convert mcompile Step2: use (OK) Datatype KMX_WCHAR (=char16_t) + if(!KMX_ImportRules(kbid, kbd, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 return FALSE; } -*/ +/**/ wprintf(L"\n##### KMX_DoConvert of mcompile ended #####\n"); return TRUE; From 4dfec70bf66f0efc1e2997b2c1e817840aedd38e Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 22 Sep 2023 18:11:31 +0200 Subject: [PATCH 090/327] feat(linux): mcompile use All_Vector for constructor of KMX_VirtualKey for rgkeys --- linux/mcompile/keymap/README.md | 7 +++- linux/mcompile/keymap/keymap.cpp | 31 +++++++++----- linux/mcompile/keymap/mc_import_rules.cpp | 50 +++++++++++++++-------- linux/mcompile/keymap/mcompile.cpp | 6 +-- 4 files changed, 63 insertions(+), 31 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index dc6715dec6..d0a78b0f9f 100644 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -13,13 +13,18 @@ TODO check how many/which shift states we use ( at the moment we read all shifts TODO define folder to store File_US.txt" in and find better name TODO get rid of GTK functions that are deprecated and use X11 instead TODO retrieve name of Other keyboard and use appropriate name instead of "Other" -TODO mcompile.cpp: open mcompile -u - option +TODO mcompile.cpp: open mcompile -u - option - do we need that? TODO check if I can use files from some other keyman path instead of a copy in keymap ( e.g. filesystem.h exists elsewhere) TODO remove kbdid and kbd for Linux TODO shiftstate-count TODO keymap SplitToV.cpp exchange 4 with genaerated shiftcount TODO check if part with surplus is neccessary TODO shift-statevector +TODO Do I need HKL for Linux / can I just use a void* ?? +TODO typeddef of KMX_HKL - van I delete all m_hkl from classes? +TODO define what to return when SC/VK is not found in get_VirtualKey_Other_From_SC,... +TODO check if passed All_Vectpor as ptr/ref not as value e.g. in KMX_CharFromVK, KMX_VKUSToVKUnderlyingLayout, KMX_ImportRules +ToDo in get_VirtualKey_Other_From_SC: what if we use column 3(altgr) and 4 (shift+altgr) ?? TODO ... //--------------------------- diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index eddee4b900..d3f97173a7 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -396,14 +396,25 @@ bool test_single(v_dw_3D &V) { // return RETURN NON SHIFTED CHAR [1] the VirtualKey of the Other Keyboard for given Scancode KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ // find correct row of char in US - for( int i=0; i< (int)All_Vector[1].size()-1;i++) { - if ( All_Vector[1][i][0] == SC ) { - wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- \n",SC , i, All_Vector[1][i][0] , All_Vector[1][i][1] ,All_Vector[1][i][1] , All_Vector[1][i][2] , All_Vector[1][i][2] ); - return All_Vector[1][i][1] ; - //return All_Vector[1][i][2] ; // would be shifted version + for( int k=0; k< (int)All_Vector.size()-1;k++) { + for( int i=0; i< (int)All_Vector[1].size()-1;i++) { + + // _S2 what if we use column 3(altgr) and 4 (shift+altgr) ?? + + // unshifted values e.g. "q" (=113) are stored in column All_Vector[1][i][ 1 ] + if ( All_Vector[k][i][0] == (SC- All_Vector[0].size() )) { + wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); + return All_Vector[1][i][1] ; + } + + // shifted values e.g. "Q" (=81) are stored in column All_Vector[1][i][ 2 ] + if ( All_Vector[k][i][0] == SC ) { + wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][2],All_Vector[1][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); + return All_Vector[1][i][2] ; + } } } - return 98; //_S2 what do I return if not found?? + return 0; //_S2 what do I return if not found?? } @@ -413,11 +424,11 @@ KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ for( int i=0; i< (int)All_Vector[0].size()-1;i++) { if ( All_Vector[0][i][0] == SC ) { wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- ",SC , i, All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2] ); - return All_Vector[0][i][1] ; + return All_Vector[0][i][1] ; // shouldn this be [0][i][2]? //return All_Vector[0][i][2] ; // would be shifted version } } - return 987; //_S2 what do I return if not found?? + return 0; //_S2 what do I return if not found?? } @@ -430,7 +441,7 @@ KMX_DWORD get_SC_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector) return All_Vector[1][i][0] ; } } - return 9876; //_S2 what do I return if not found?? + return 0; //_S2 what do I return if not found?? } // return the Scancode of for given VirtualKey of Other US @@ -442,5 +453,5 @@ KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ return All_Vector[0][i][0] ; } } - return 98765; //_S2 what do I return if not found?? + return 0; //_S2 what do I return if not found?? } diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index b1fea63e15..ab6c2ab985 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -110,24 +110,36 @@ int DeadKeyMap(int index, std::vector *deadkeys, int deadkeyBase, std return 0xFFFF; } */ -class VirtualKey { +class KMX_VirtualKey { private: KMX_HKL m_hkl; // _S2 do I need this and is void* OK to assume? UINT m_vk; UINT m_sc; bool m_rgfDeadKey[10][2]; std::wstring m_rgss[10][2]; -/* + public: - VirtualKey(HKL hkl, UINT virtualKey) { + KMX_VirtualKey(KMX_HKL hkl, UINT KMX_virtualKey) {/* this->m_sc = MapVirtualKeyEx(virtualKey, 0, hkl); this->m_hkl = hkl; - this->m_vk = virtualKey; - memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); + this->m_vk = KMX_virtualKey; + memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey));*/ + } + // _S2 can be deleted later + KMX_VirtualKey(UINT scanCode, KMX_HKL hkl) { + // this->m_vk = MapVirtualKeyEx(scanCode, 1, hkl); + this->m_hkl = hkl; + this->m_sc = scanCode; } - VirtualKey(UINT scanCode, HKL hkl) { - this->m_vk = MapVirtualKeyEx(scanCode, 1, hkl); + KMX_VirtualKey(UINT scanCode, KMX_HKL hkl, v_dw_3D All_Vector) { + // this->m_vk = MapVirtualKeyEx(scanCode, 1, hkl); // second para= 1: MAPVK_VSC_TO_VK =1 + // The first parameter is a scan code and is + // translated into a virtual-key code that does not + // distinguish between left- and right-hand keys. + // If there is no translation, the function returns 0. + // SC -> VK + this->m_vk = get_VirtualKey_Other_From_SC(scanCode, All_Vector); this->m_hkl = hkl; this->m_sc = scanCode; } @@ -139,7 +151,7 @@ public: UINT SC() { return this->m_sc; } - +/* std::wstring GetShiftState(ShiftState shiftState, bool capsLock) { return this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)]; } @@ -463,7 +475,8 @@ int GetMaxDeadkeyIndex(WCHAR *p) { return n; } */ -bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 + +bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 wprintf(L"\n ##### KMX_ImportRules of mc_import_rules started #####\n"); KMX_Loader loader; const size_t BUF_sz= 256; @@ -486,28 +499,31 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp, std::vector rgKey; //= new VirtualKey[256]; + std::vector rgKey; //= new VirtualKey[256]; std::vector alDead; rgKey.resize(256); -int STOP = 0; -/* // _S2 scroll through OTHER // Scroll through the Scan Code (SC) values and get the valid Virtual Key (VK) // values in it. Then, store the SC in each valid VK so it can act as both a // flag that the VK is valid, and it can store the SC value. for(UINT sc = 0x01; sc <= 0x7f; sc++) { - VirtualKey *key = new VirtualKey(sc, hkl); // _S2 get this from my Vector + KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector); // _S2 get this from my Vector if(key->VK() != 0) { rgKey[key->VK()] = key; } else { delete key; - } + }/**/ } - +int STOP = 0; +/* +_S2 use KMX_VirtualKey !! // _S2 do I need NUMPAD + SPECIAL_SHIFT for first draft ?? // add the special keys that do not get added from the code above for(UINT ke = VK_NUMPAD0; ke <= VK_NUMPAD9; ke++) { @@ -605,7 +621,7 @@ int STOP = 0; } } - // _S2 do I need this for UNIX?? + // _S2 do I need this for Linux?? for(int i = 0; i < cKeyboards; i++) { if(hkl == rghkl[i]) { hkl = NULL; @@ -613,7 +629,7 @@ int STOP = 0; } } - // _S2 do I need this for UNIX?? + // _S2 do I need this for Linux?? if(hkl != NULL) { UnloadKeyboardLayout(hkl); } diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index e148336fcd..45fc37d9b3 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -56,7 +56,7 @@ mcompile -d runs 4 important steps: KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]); -bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp, std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 +bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 std::vector KMX_FDeadkeys; // I4353 @@ -347,7 +347,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon bool WriteFileOK = writeFileToVector( complete_Vector,"/Projects/keyman/keyman/linux/mcompile/keymap/VectorFile2.txt" ); bool isEqual= CompareVector_To_VectorOfFile( All_Vector, complete_Vector); wprintf(L" vectors are equal: %i\n",isEqual);*/ -test(All_Vector); +//test(All_Vector); //test_In_Out(All_Vector); @@ -400,7 +400,7 @@ wprintf(L"\n##### KMX_ReportUnconvertedKeyboardRules of mcompile will start #### // _S2 convert mcompile Step1: use (wrong) Datatype WCHAR (=wchar_t) // _S2 convert mcompile Step2: use (OK) Datatype KMX_WCHAR (=char16_t) - if(!KMX_ImportRules(kbid, kbd, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 + if(!KMX_ImportRules(kbid, kbd, All_Vector, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 return FALSE; } /**/ From 85d7b871754305efcbf6b197236c9b75e77bd065 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 26 Sep 2023 14:06:52 +0200 Subject: [PATCH 091/327] feat(linux): mcompile some new functions to test content of rgKey; start adding numpad to rgkey --- linux/mcompile/keymap/helpers.cpp | 130 +++++++++++++++++++++- linux/mcompile/keymap/helpers.h | 5 + linux/mcompile/keymap/keymap.cpp | 33 +++++- linux/mcompile/keymap/km_types.h | 14 +++ linux/mcompile/keymap/mc_import_rules.cpp | 86 +++++++++++--- 5 files changed, 248 insertions(+), 20 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 10c7a314de..c2c0e39c37 100644 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -182,10 +182,134 @@ bool CompareVector_To_VectorOfFile(v_dw_3D All_Vector,v_dw_3D File_Vector){ } return true; - wprintf(L" #### CompareVector_To_VectorOfFile ended \n"); - return false; + wprintf(L" #### CompareVector_To_VectorOfFile ended \n"); //_S2 kommt hier nie hin + return false; //_S2 kommt hier nie hin } +bool CompareVector_To_VectorOfFile_RGKEY(v_dw_2D Win_Vector,v_dw_2D Lin_Vector, v_dw_2D Map_Vector){ + wprintf(L" #### CompareVector_To_VectorOfFile started: "); + wprintf(L" #### dimensions: %i %i -- %i %i \n", Win_Vector.size() ,Win_Vector[0].size(), Lin_Vector.size() ,Lin_Vector[0].size()); + KMX_DWORD SC_Win, SC_Lin; + if (!(Win_Vector.size() == Lin_Vector.size()) )return false; + if (!(Win_Vector[0].size() == Lin_Vector[0].size())) return false; + + // loop through both vectors and compare VK ( " e.g. do both vectors contain character "Q" ? ( that is VK = 81)) + for ( int i=0; i< Lin_Vector.size();i++) { + + // for capital letters A-Z + if ( (i >64) && (i<91)) { + if( Lin_Vector[i][1] == (Win_Vector[i][1] +8 )) { + //wprintf(L" GOOD entry for Win/Lin_Vector[%i][0]: Win_Vector[%i][1] (%i/ %c) <--> Lin_Vector[%i][1] (%i/ %c)\n", i, i,Win_Vector[i][0] ,Win_Vector[i][0], i,Lin_Vector[i][0],Lin_Vector[i][0]); + continue; + } + else + wprintf(L" WRONG entry for Win/Lin_Vector[%i][0]: Win_Vector[%i][1] (%i/ %c) <--> Lin_Vector[%i][1] (%i/ %c)\n", i, i,Win_Vector[i][0] ,Win_Vector[i][0], i,Lin_Vector[i][0],Lin_Vector[i][0]); + return false; + } + + /* + // for unshifted letters a-z + else if ( (i >96) && (i<123)) { + } + + // for all other characters + else { + } + */ + } + return true; + } + + +/*bool CompareVector_To_VectorOfFile_RGKEY(v_dw_2D Win_Vector,v_dw_2D Lin_Vector, v_dw_2D Map_Vector){ + wprintf(L" #### CompareVector_To_VectorOfFile started: "); + wprintf(L" #### dimensions: %i %i -- %i %i \n", Win_Vector.size() ,Win_Vector[0].size(), Lin_Vector.size() ,Lin_Vector[0].size()); + KMX_DWORD SC_Win, SC_Lin; + if (!(Win_Vector.size() == Lin_Vector.size()) )return false; + if (!(Win_Vector[0].size() == Lin_Vector[0].size())) return false; + + +// loop through both vectors and compare VK ( " e.g. do both vectors contain character "Q" ? ( that is VK = 81)) +for ( int i=0; i< Lin_Vector.size();i++) { + KMX_DWORD ValueOfVLin = Lin_Vector[i][0]; + if ( ValueOfVLin == 999) + continue; + + for ( int j=0; j< Win_Vector.size();j++) { + KMX_DWORD ValueOfVWin = Win_Vector[j][0]; + if (ValueOfVWin ==ValueOfVLin) { + wprintf(L" same value found: %i; (Lin): %i-%i %i--%i (Win) \n", ValueOfVLin,Lin_Vector[i][0],Lin_Vector[i][1],Win_Vector[i][1],Win_Vector[i][0] ); + + + // do I find these 2 SC as a pair (in a line) in map.txt + SC_Win = Win_Vector[j][0]; + SC_Lin = Lin_Vector[i][0]; + for( int k=0; k< Map_Vector.size(); k++) { + if((SC_Win == Map_Vector[k][1]) && ( SC_Lin== Map_Vector[k][1])) + wprintf(L" ....same value found: %i; (Lin): %i-%i %i--%i (Win) \n", ValueOfVLin,Lin_Vector[i][0],Lin_Vector[i][1],Win_Vector[i][1],Win_Vector[i][0] ); + + //wprintf(L" ... That EXISTS in map \n"); + //else + //wprintf(L" ... That DOES NOT EXIST in map \n"); + } + continue; + } + //else + wprintf(L" same value NOT found: %i\n", ValueOfVLin);// + } +} + return true; +}*/ + +bool write_RGKEY_FileToVector(v_dw_2D& shift_states, const char* infile) { + FILE *fp; + char str[600]; + std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; + v_str_1D complete_List; + v_dw_1D tokens_dw; + int k = -1; + + for ( int i =0; i< 266;i++) { + tokens_dw.push_back(999); + tokens_dw.push_back(999); + shift_states.push_back(tokens_dw); + tokens_dw.clear(); + } + + fp = fopen(infile , "r"); + + if(fp == NULL) { + perror("Error opening file"); + return(-1); + } + + while (fgets(str, 600, fp) != NULL) { + k++; + complete_List.push_back(str); + + // remove all unwanted char + for (int i = 0; i < (int)delim.size(); i++) { + complete_List[k].erase(remove(complete_List[k].begin(), complete_List[k].end(), delim[i]), complete_List[k].end()); + } + + std::stringstream ss(complete_List[k]); + int dash = complete_List[k].find("-"); + int len2 =( (complete_List[k].size())-dash-2); + int size_l= sizeof(complete_List[k]); + + tokens_dw.push_back((DWORD)stoi(complete_List[k].substr(0, dash))); + tokens_dw.push_back((DWORD)stoi(complete_List[k].substr(dash+1, (len2)))); + int posInVec = tokens_dw[0]; + + shift_states[posInVec]=tokens_dw; + tokens_dw.clear(); + } + fclose(fp); + return(0); +} + + + bool test_In_Out(v_dw_3D All_Vector){ @@ -238,4 +362,4 @@ bool test_In_Out(v_dw_3D All_Vector){ wprintf(L"IN %i ---> %i(%c) ---> %i (%c) \n", i, VK_Other,VK_Other, SC_Other ,*ADD); } } -} \ No newline at end of file +} diff --git a/linux/mcompile/keymap/helpers.h b/linux/mcompile/keymap/helpers.h index 028361ef4d..b266631ff5 100644 --- a/linux/mcompile/keymap/helpers.h +++ b/linux/mcompile/keymap/helpers.h @@ -7,6 +7,7 @@ #include "mc_kmxfile.h" #include "keymap.h" + // why again here? typedef std::vector v_str_1D; typedef std::vector v_dw_1D; @@ -31,4 +32,8 @@ bool writeFileToVector(v_dw_3D& complete_Vector, const char* infile); bool CompareVector_To_VectorOfFile(v_dw_3D All_Vector,v_dw_3D File_Vector); bool test_In_Out(v_dw_3D All_Vector); +// to check if content of Vector is ok +bool write_RGKEY_FileToVector(v_dw_2D& shift_states, const char* infile) ; +bool CompareVector_To_VectorOfFile_RGKEY(v_dw_2D Win_Vector,v_dw_2D Lin_Vector, v_dw_2D Map_Vector); + #endif /* HELPERS_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index d3f97173a7..717d8eb1d0 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -394,6 +394,37 @@ bool test_single(v_dw_3D &V) { // query All_Vector // return RETURN NON SHIFTED CHAR [1] the VirtualKey of the Other Keyboard for given Scancode +KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ + + // find correct row of char in US + for( int k=0; k< (int)All_Vector.size()-1;k++) { + for( int i=0; i< (int)All_Vector[1].size()-1;i++) { + + // _S2 what if we use column 3(altgr) and 4 (shift+altgr) ?? + + /*// unshifted values e.g. "q" (=113) are stored in column All_Vector[1][i][ 1 ] + if ( All_Vector[k][i][0] == (SC- All_Vector[0].size() )) { + wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); + return All_Vector[1][i][1] ; + }*/ + + // shifted values e.g. "Q" (=81) are stored in column All_Vector[1][i][ 2 ] + if ( All_Vector[k][i][0] == SC ) { + wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][2],All_Vector[1][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); + KMX_DWORD returnval= All_Vector[1][i][2]; + + return All_Vector[1][i][2]; + } + } + } + return 0; //_S2 what do I return if not found?? +} + + + + +/*// query All_Vector +// return RETURN NON SHIFTED CHAR [1] the VirtualKey of the Other Keyboard for given Scancode KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ // find correct row of char in US for( int k=0; k< (int)All_Vector.size()-1;k++) { @@ -415,7 +446,7 @@ KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ } } return 0; //_S2 what do I return if not found?? -} +}*/ // return RETURN NON SHIFTED CHAR [1] the VirtualKey of the US Keyboard for given Scancode diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index d8c253143e..98ab7bf3a5 100644 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -119,4 +119,18 @@ typedef KMX_UCHAR* KMX_PUCHAR; #define VK_xDF 0xDF #define VK_OEM_102 0xE2 // "<>" or "\|" on RT 102-key kbd. +#define VK_NUMPAD0 0xFFB0 +#define VK_NUMPAD1 0xFFB1 +#define VK_NUMPAD2 0xFFB2 +#define VK_NUMPAD3 0xFFB3 +#define VK_NUMPAD4 0xFFB4 +#define VK_NUMPAD5 0xFFB5 +#define VK_NUMPAD6 0xFFB6 +#define VK_NUMPAD7 0xFFB7 +#define VK_NUMPAD8 0xFFB8 +#define VK_NUMPAD9 0xFFB9 +#define VK_DIVIDE 0xFFAF +#define VK_CANCEL 0xFF1B +#define VK_DECIMAL 0xFFAC + #endif /*KM_TYPES*/ diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index ab6c2ab985..21929deef9 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -25,7 +25,7 @@ #include #include "km_types.h" #include "mc_kmxfile.h" -/* + enum ShiftState { Base = 0, // 0 Shft = 1, // 1 @@ -38,7 +38,7 @@ enum ShiftState { Xxxx = 8, // 8 ShftXxxx = Shft | Xxxx, // 9 }; - +/* const int ShiftStateMap[] = { ISVIRTUALKEY, ISVIRTUALKEY | K_SHIFTFLAG, @@ -119,6 +119,7 @@ private: std::wstring m_rgss[10][2]; public: +// _S2 can be deleted later KMX_VirtualKey(KMX_HKL hkl, UINT KMX_virtualKey) {/* this->m_sc = MapVirtualKeyEx(virtualKey, 0, hkl); this->m_hkl = hkl; @@ -132,8 +133,28 @@ public: this->m_sc = scanCode; } + + KMX_VirtualKey(KMX_HKL hkl, UINT KMX_virtualKey, v_dw_3D All_Vector) {/* + this->m_sc = MapVirtualKeyEx(virtualKey, 0, hkl); // second para =0: MAPVK_VK_TO_VSC=1 + //the uCode parameter is a virtual-key code and is + //translated into a scan code. If it is a virtual-key + //code that does not distinguish between left- and + //right-hand keys, the left-hand scan code is returned. + //If there is no translation, the function returns 0. + this->m_hkl = hkl; + this->m_vk = KMX_virtualKey; + memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey));*/ + + +/* + this->m_sc = MapVirtualKeyEx(virtualKey, 0, hkl); + this->m_hkl = hkl; + this->m_vk = KMX_virtualKey; + memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey));*/ + } + KMX_VirtualKey(UINT scanCode, KMX_HKL hkl, v_dw_3D All_Vector) { - // this->m_vk = MapVirtualKeyEx(scanCode, 1, hkl); // second para= 1: MAPVK_VSC_TO_VK =1 + // _S2 this->m_vk = MapVirtualKeyEx(scanCode, 1, hkl); // second para= 1: MAPVK_VSC_TO_VK =1 // The first parameter is a scan code and is // translated into a virtual-key code that does not // distinguish between left- and right-hand keys. @@ -334,7 +355,7 @@ class KMX_Loader { private: KMX_BYTE lpKeyStateNull[256]; KMX_UINT m_XxxxVk; -/* + public: KMX_Loader() { m_XxxxVk = 0; @@ -352,7 +373,7 @@ public: ShiftState MaxShiftState() { return (Get_XxxxVk() == 0 ? ShftMenuCtrl : ShftXxxx); } - +/* void FillKeyState(BYTE *lpKeyState, ShiftState ss, bool fCapsLock) { lpKeyState[VK_SHIFT] = (((ss & Shft) != 0) ? 0x80 : 0x00); lpKeyState[VK_CONTROL] = (((ss & Ctrl) != 0) ? 0x80 : 0x00); @@ -476,6 +497,23 @@ int GetMaxDeadkeyIndex(WCHAR *p) { } */ + +// _S2 has to go !! +bool write_rgKey_ToFile(std::vector rgKey ){ + std::string RGKey_FileName="/Projects/keyman/keyman/linux/mcompile/keymap/rgKey_lin.txt"; + + std::ofstream TxTFile(RGKey_FileName); + for ( int i=0; i< rgKey.size();i++) { + if(rgKey[i] != NULL) { + TxTFile << rgKey[i]->VK() << "-" << rgKey[i]->SC()<< "-"; + TxTFile << "\n"; + } + } + TxTFile.close(); + return true; +} + + bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 wprintf(L"\n ##### KMX_ImportRules of mc_import_rules started #####\n"); KMX_Loader loader; @@ -514,25 +552,28 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std // flag that the VK is valid, and it can store the SC value. for(UINT sc = 0x01; sc <= 0x7f; sc++) { KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector); // _S2 get this from my Vector - if(key->VK() != 0) { + uint key_vk = key->VK() ; + if(key->VK() != 0) { rgKey[key->VK()] = key; } else { delete key; - }/**/ + } } -int STOP = 0; /* -_S2 use KMX_VirtualKey !! + // _S2 do we need NUMPAD now or later? +// _S2 use KMX_VirtualKey !! // _S2 do I need NUMPAD + SPECIAL_SHIFT for first draft ?? // add the special keys that do not get added from the code above for(UINT ke = VK_NUMPAD0; ke <= VK_NUMPAD9; ke++) { - rgKey[ke] = new VirtualKey(hkl, ke); + rgKey[ke] = new KMX_VirtualKey(hkl, ke, All_Vector); } - rgKey[VK_DIVIDE] = new VirtualKey(hkl, VK_DIVIDE); - rgKey[VK_CANCEL] = new VirtualKey(hkl, VK_CANCEL); - rgKey[VK_DECIMAL] = new VirtualKey(hkl, VK_DECIMAL); + rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE, All_Vector); + rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL, All_Vector); + rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL, All_Vector); + */ +/* // _S2 do we need special shift state now or later? // See if there is a special shift state added for(UINT vk = 0; vk <= VK_OEM_CLEAR; vk++) { UINT sc = MapVirtualKeyEx(vk, 0, hkl); @@ -555,6 +596,8 @@ _S2 use KMX_VirtualKey !! } } } +*/ + for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { if(rgKey[iKey] != NULL) { @@ -566,6 +609,16 @@ _S2 use KMX_VirtualKey !! continue; } +// _S2 can go later: check if all correct +write_rgKey_ToFile(rgKey) ; +v_dw_2D V_lin,V_win,V_map; +write_RGKEY_FileToVector(V_win, "rgKey_win_first.txt"); +write_RGKEY_FileToVector(V_lin, "rgKey_lin.txt"); +//write_RGKEY_FileToVector(V_map, "map.txt"); +CompareVector_To_VectorOfFile_RGKEY( V_win, V_lin,V_map); + +int STOP = 0; +/* for(int caps = 0; caps <= 1; caps++) { loader.ClearKeyboardBuffer(VK_DECIMAL, rgKey[VK_DECIMAL]->SC(), hkl); ////FillKeyState(lpKeyState, ss, (caps != 0)); //http://blogs.msdn.com/michkap/archive/2006/04/18/578557.aspx @@ -617,10 +670,11 @@ _S2 use KMX_VirtualKey !! } } } +*/ } } } - +/* // _S2 do I need this for Linux?? for(int i = 0; i < cKeyboards; i++) { if(hkl == rghkl[i]) { @@ -636,12 +690,12 @@ _S2 use KMX_VirtualKey !! // _S2 do I need that for Linux?? delete[] rghkl; - +*/ //------------------------------------------------------------- // Now that we've collected the key data, we need to // translate it to kmx and append to the existing keyboard //------------------------------------------------------------- - +/* int nDeadkey = 0; LPGROUP gp = new GROUP[kp->cxGroupArray+2]; // leave space for old From 218004d99d9f00d2733919acb7e44307cd81d77c Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 28 Sep 2023 12:29:59 +0200 Subject: [PATCH 092/327] feat(linux): mcompile use keycodes from \linux\ibus-keyman\src\keycodes.h --- linux/mcompile/keymap/README.md | 3 +++ linux/mcompile/keymap/km_types.h | 41 ++++++++++++++++++++---------- linux/mcompile/keymap/mcompile.cpp | 6 ++--- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index d0a78b0f9f..8d726982be 100644 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -25,6 +25,9 @@ TODO typeddef of KMX_HKL - van I delete all m_hkl from classes? TODO define what to return when SC/VK is not found in get_VirtualKey_Other_From_SC,... TODO check if passed All_Vectpor as ptr/ref not as value e.g. in KMX_CharFromVK, KMX_VKUSToVKUnderlyingLayout, KMX_ImportRules ToDo in get_VirtualKey_Other_From_SC: what if we use column 3(altgr) and 4 (shift+altgr) ?? +TODO where to store VK_CANCEL.... in km_types.h or elsewhere? +ToDo check up to 8 shiftstates ( find symbols-file with 8) +TODO get_position_From_VirtualKey_US: take care of the other shiftstates TODO ... //--------------------------- diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index 98ab7bf3a5..d26b2bed8a 100644 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -119,18 +119,33 @@ typedef KMX_UCHAR* KMX_PUCHAR; #define VK_xDF 0xDF #define VK_OEM_102 0xE2 // "<>" or "\|" on RT 102-key kbd. -#define VK_NUMPAD0 0xFFB0 -#define VK_NUMPAD1 0xFFB1 -#define VK_NUMPAD2 0xFFB2 -#define VK_NUMPAD3 0xFFB3 -#define VK_NUMPAD4 0xFFB4 -#define VK_NUMPAD5 0xFFB5 -#define VK_NUMPAD6 0xFFB6 -#define VK_NUMPAD7 0xFFB7 -#define VK_NUMPAD8 0xFFB8 -#define VK_NUMPAD9 0xFFB9 -#define VK_DIVIDE 0xFFAF -#define VK_CANCEL 0xFF1B -#define VK_DECIMAL 0xFFAC +/*#define VK_NUMPAD0 0x5A +#define VK_NUMPAD1 0x57 +#define VK_NUMPAD2 0x58 +#define VK_NUMPAD3 0x59 +#define VK_NUMPAD4 0x53 +#define VK_NUMPAD5 0x54 +#define VK_NUMPAD6 0x55 +#define VK_NUMPAD7 0x4F +#define VK_NUMPAD8 0x50 +#define VK_NUMPAD9 0x51 +#define VK_DIVIDE 0x6A +#define VK_CANCEL 0x09 +#define VK_DECIMAL 0x5B*/ + + +#define VK_NUMPAD0 96 +#define VK_NUMPAD1 97 +#define VK_NUMPAD2 98 +#define VK_NUMPAD3 99 +#define VK_NUMPAD4 100 +#define VK_NUMPAD5 101 +#define VK_NUMPAD6 102 +#define VK_NUMPAD7 103 +#define VK_NUMPAD8 104 +#define VK_NUMPAD9 105 +#define VK_DIVIDE 111 +#define VK_CANCEL 3 +#define VK_DECIMAL 110 #endif /*KM_TYPES*/ diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 45fc37d9b3..3df3bafd82 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -343,10 +343,10 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon /* //_S2 this is to use a file and a vector instead of GDK-functions so debugging is easier...not needed later... v_dw_3D complete_Vector; - bool writeVec_OK = writeVectorToFile(All_Vector); - bool WriteFileOK = writeFileToVector( complete_Vector,"/Projects/keyman/keyman/linux/mcompile/keymap/VectorFile2.txt" ); + //bool writeVec_OK = writeVectorToFile(All_Vector); + bool WriteFileOK = writeFileToVector( complete_Vector,"/Projects/keyman/keyman/linux/mcompile/keymap/VectorFile.txt" ); bool isEqual= CompareVector_To_VectorOfFile( All_Vector, complete_Vector); - wprintf(L" vectors are equal: %i\n",isEqual);*/ + wprintf(L" vectors are equal: %i\n",isEqual); // this mmeans both file are equal and All_Vector contains correct data*/ //test(All_Vector); //test_In_Out(All_Vector); From a414542887c00db1a0cecd703068de34b7afe7ae Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 28 Sep 2023 12:31:50 +0200 Subject: [PATCH 093/327] feat(linux): mcompile use keycodes from \linux\ibus-keyman\src\key --- linux/mcompile/keymap/keymap.cpp | 74 +++++++++++++++++++++++++++++++- linux/mcompile/keymap/keymap.h | 2 + 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 717d8eb1d0..433f0d7098 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -203,6 +203,65 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { } return 0; } +/* +int replace_PosKey_with_Keycode(std::string in) { + int out = returnIfCharInvalid; + if ( in == "key") out = 49; // TOASK correct ??? + else if ( in == "key") out = 10; + else if ( in == "key") out = 11; + else if ( in == "key") out = 12; + else if ( in == "key") out = 13; + else if ( in == "key") out = 14; + else if ( in == "key") out = 15; + else if ( in == "key") out = 16; + else if ( in == "key") out = 17; + else if ( in == "key") out = 18; + else if ( in == "key") out = 19; + else if ( in == "key") out = 20; + else if ( in == "key") out = 21; + + else if ( in == "key") out = 16; + else if ( in == "key") out = 17; + else if ( in == "key") out = 18; + else if ( in == "key") out = 19; + else if ( in == "key") out = 20; + else if ( in == "key") out = 21; + else if ( in == "key") out = 22; + else if ( in == "key") out = 23; + else if ( in == "key") out = 24; + else if ( in == "key") out = 25; + else if ( in == "key") out = 26; + else if ( in == "key") out = 27; + + else if ( in == "key") out = 30; + else if ( in == "key") out = 31; + else if ( in == "key") out = 32; + else if ( in == "key") out = 33; + else if ( in == "key") out = 34; + else if ( in == "key") out = 35; + else if ( in == "key") out = 36; + else if ( in == "key") out = 37; + else if ( in == "key") out = 38; + else if ( in == "key") out = 39; + else if ( in == "key") out = 40; + else if ( in == "key") out = 41; + + else if ( in == "key") out = 44; + else if ( in == "key") out = 45; + else if ( in == "key") out = 46; + else if ( in == "key") out = 47; + else if ( in == "key") out = 48; + else if ( in == "key") out = 49; + else if ( in == "key") out = 50; + else if ( in == "key") out = 51; + else if ( in == "key") out = 52; + else if ( in == "key") out = 53; + else if ( in == "key") out = 54; + else if ( in == "key") out = 55; + + return out; +} +*/ int replace_PosKey_with_Keycode(std::string in) { int out = returnIfCharInvalid; @@ -479,10 +538,23 @@ KMX_DWORD get_SC_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector) KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ // find correct row of char in US for( int i=0; i< (int)All_Vector[0].size()-1;i++) { - if ( All_Vector[0][i][1] == VK_US ) { + if ( All_Vector[0][i][2] == VK_US ) { wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- \n",VK_US , i, All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2] ); return All_Vector[0][i][0] ; } } return 0; //_S2 what do I return if not found?? } + + +// return the Scancode of for given VirtualKey of Other US +KMX_DWORD get_position_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ + // find correct row of char in US + for( int i=0; i< (int)All_Vector[0].size()-1;i++) { + if ( All_Vector[0][i][2] == VK_US ) { + wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- \n",VK_US , i, All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2] ); + return i; + } + } + return 0; //_S2 what do I return if not found?? +} diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 844b23921c..5139488b88 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -81,6 +81,8 @@ KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); KMX_DWORD get_SC_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector); // return the Scancode of for given VirtualKey of Other US KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector); +// return the Scancode of for given VirtualKey of Other US +KMX_DWORD get_position_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector); #if USE_GDK From 5d57ee714ca16d55618e588df5b1edc02cb66bc9 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 28 Sep 2023 16:50:48 +0200 Subject: [PATCH 094/327] feat(linux): mcompile ImportRules- fill rgkeys finished --- linux/mcompile/keymap/helpers.cpp | 8 +- linux/mcompile/keymap/mc_import_rules.cpp | 180 ++++++++++------------ 2 files changed, 88 insertions(+), 100 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index c2c0e39c37..e31e744d11 100644 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -217,6 +217,8 @@ bool CompareVector_To_VectorOfFile_RGKEY(v_dw_2D Win_Vector,v_dw_2D Lin_Vector, } */ } + wprintf(L" No Difference found in A-Z :-) SC have an offset of 8 "); + return true; } @@ -264,7 +266,7 @@ for ( int i=0; i< Lin_Vector.size();i++) { bool write_RGKEY_FileToVector(v_dw_2D& shift_states, const char* infile) { FILE *fp; char str[600]; - std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; + std::vector delim{' ', '[', ']', '}','*', ')','(','>', '\t', '\n'}; v_str_1D complete_List; v_dw_1D tokens_dw; int k = -1; @@ -329,7 +331,7 @@ bool test_In_Out(v_dw_3D All_Vector){ wprintf(L"\n"); } - wprintf(L"*****************************************\n"); + wprintf(L"-------------**\n"); for ( int i=0; i<61;i++) { KMX_DWORD VK_Other= get_VirtualKey_Other_From_SC(i,All_Vector); @@ -346,7 +348,7 @@ bool test_In_Out(v_dw_3D All_Vector){ } } - wprintf(L" 3 *****************************************\n"); + wprintf(L" 3 -------------**\n"); for ( int i=0; i<61;i++) { KMX_DWORD VK_Other= get_VirtualKey_US_From_SC(i,All_Vector); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 21929deef9..b21ffea1a7 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -140,17 +140,14 @@ public: //translated into a scan code. If it is a virtual-key //code that does not distinguish between left- and //right-hand keys, the left-hand scan code is returned. - //If there is no translation, the function returns 0. - this->m_hkl = hkl; - this->m_vk = KMX_virtualKey; - memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey));*/ + //If there is no translation, the function returns 0.*/ -/* - this->m_sc = MapVirtualKeyEx(virtualKey, 0, hkl); + + this->m_sc = get_SC_From_VirtualKey_Other(KMX_virtualKey, All_Vector); this->m_hkl = hkl; this->m_vk = KMX_virtualKey; - memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey));*/ + memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); } KMX_VirtualKey(UINT scanCode, KMX_HKL hkl, v_dw_3D All_Vector) { @@ -172,8 +169,8 @@ public: UINT SC() { return this->m_sc; } -/* - std::wstring GetShiftState(ShiftState shiftState, bool capsLock) { + + std::wstring KMX_GetShiftState(ShiftState shiftState, bool capsLock) { return this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)]; } @@ -182,6 +179,7 @@ public: this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; } +/* bool IsSGCAPS() { std::wstring stBase = this->GetShiftState(Base, false); std::wstring stShift = this->GetShiftState(Shft, false); @@ -477,7 +475,7 @@ public: return deadKey; } - void ClearKeyboardBuffer(UINT vk, UINT sc, HKL hkl) { + void KMX_ClearKeyboardBuffer(UINT vk, UINT sc, HKL hkl) { WCHAR sb[16]; int rc = 0; do { @@ -502,10 +500,11 @@ int GetMaxDeadkeyIndex(WCHAR *p) { bool write_rgKey_ToFile(std::vector rgKey ){ std::string RGKey_FileName="/Projects/keyman/keyman/linux/mcompile/keymap/rgKey_lin.txt"; - std::ofstream TxTFile(RGKey_FileName); + std::wofstream TxTFile(RGKey_FileName); for ( int i=0; i< rgKey.size();i++) { if(rgKey[i] != NULL) { - TxTFile << rgKey[i]->VK() << "-" << rgKey[i]->SC()<< "-"; + TxTFile << rgKey[i]->VK() << "-" << rgKey[i]->SC()<< " -> ( " << rgKey[i]->KMX_GetShiftState(Base, 0) << "-" << rgKey[i]->KMX_GetShiftState(Base, 1) << " )" + << " *-* ( " << rgKey[i]->KMX_GetShiftState(Shft, 0) << "-" << rgKey[i]->KMX_GetShiftState(Shft, 1) << " )"; TxTFile << "\n"; } } @@ -514,6 +513,28 @@ bool write_rgKey_ToFile(std::vector rgKey ){ } +// _S2 where to put this?? +std::wstring get_VirtualKey_US_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &caps, v_dw_3D &All_Vector) { + + int icaps; + KMX_DWORD SC_ = get_position_From_VirtualKey_US(iKey, All_Vector); + + if (ss >9) + return L""; + + if( ss < All_Vector[0][SC_].size()-1) { + + if ( ss % 2 == 0) + icaps = ss+2-caps; + + if ( ss % 2 == 1) + icaps = ss+caps; + + return std::wstring(1, (int) All_Vector[0][SC_][icaps]); + } + return L""; +} + bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 wprintf(L"\n ##### KMX_ImportRules of mc_import_rules started #####\n"); KMX_Loader loader; @@ -560,18 +581,19 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std } } -/* - // _S2 do we need NUMPAD now or later? + /* // where in rgkey do I store Numpad??? + // _S2 do we need NUMPAD now or later? If so we need to add Numpad values to All_Vector ( which has only values a-z) // _S2 use KMX_VirtualKey !! // _S2 do I need NUMPAD + SPECIAL_SHIFT for first draft ?? // add the special keys that do not get added from the code above for(UINT ke = VK_NUMPAD0; ke <= VK_NUMPAD9; ke++) { rgKey[ke] = new KMX_VirtualKey(hkl, ke, All_Vector); } + rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE, All_Vector); rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL, All_Vector); rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL, All_Vector); - */ + */ /* // _S2 do we need special shift state now or later? // See if there is a special shift state added @@ -598,99 +620,63 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std } */ - + // _S2 skip shiftstates 4, 5, 8, 9 for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { - if(rgKey[iKey] != NULL) { - WCHAR sbBuffer[256]; // Scratchpad we use many places + if(rgKey[iKey] != NULL) { + WCHAR sbBuffer[256]; // Scratchpad we use many places - for(ShiftState ss = Base; ss <= loader.MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { - if(ss == Menu || ss == ShftMenu) { - // Alt and Shift+Alt don't work, so skip them - continue; - } + for(ShiftState ss = Base; ss <= loader.MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { + if(ss == Menu || ss == ShftMenu) { + // Alt and Shift+Alt don't work, so skip them + continue; + } -// _S2 can go later: check if all correct -write_rgKey_ToFile(rgKey) ; -v_dw_2D V_lin,V_win,V_map; -write_RGKEY_FileToVector(V_win, "rgKey_win_first.txt"); -write_RGKEY_FileToVector(V_lin, "rgKey_lin.txt"); -//write_RGKEY_FileToVector(V_map, "map.txt"); -CompareVector_To_VectorOfFile_RGKEY( V_win, V_lin,V_map); + for(int caps = 0; caps <= 1; caps++) { -int STOP = 0; -/* - for(int caps = 0; caps <= 1; caps++) { - loader.ClearKeyboardBuffer(VK_DECIMAL, rgKey[VK_DECIMAL]->SC(), hkl); - ////FillKeyState(lpKeyState, ss, (caps != 0)); //http://blogs.msdn.com/michkap/archive/2006/04/18/578557.aspx - loader.FillKeyState(lpKeyState, ss, (caps == 0)); - //sbBuffer = new StringBuilder(10); + //_S2 get char - do I need rc ?? ( was rc = ToUnicodeEx...) + std::wstring char_for_input = get_VirtualKey_US_from_iKey(iKey, ss, caps, All_Vector); + + //do I need that ?? + //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { + if(char_for_input == L"") { + rgKey[iKey]->SetShiftState(ss, L"", false, (caps == 0)); + } + + //else // if rc ==1 : it got 1 char && something { + if( (ss == Ctrl || ss == ShftCtrl) /*&& something? */) { + continue; + } + + // fill m_rgss and m_rgfDeadkey ( m_rgfDeadkey will be done later) + rgKey[iKey]->SetShiftState(ss, char_for_input, false, (caps == 0)); + //} // from rc==1 + // } // from rc > 0 - // _S2 do I need ToUnicodeEx() or can I use my Vector?? - int rc = ToUnicodeEx(rgKey[iKey]->VK(), rgKey[iKey]->SC(), lpKeyState, sbBuffer, _countof(sbBuffer), 0, hkl); - if(rc > 0) { - if(*sbBuffer == 0) { - // Someone defined NULL on the keyboard; let's coddle them - ////rgKey[iKey].SetShiftState(ss, "\u0000", false, (caps != 0)); - rgKey[iKey]->SetShiftState(ss, L"", false, (caps == 0)); - } - else { - if((rc == 1) && - (ss == Ctrl || ss == ShftCtrl) && - (rgKey[iKey]->VK() == ((UINT)sbBuffer[0] + 0x40))) { - // ToUnicodeEx has an internal knowledge about those - // VK_A ~ VK_Z keys to produce the control characters, - // when the conversion rule is not provided in keyboard - // layout files - continue; - } - sbBuffer[rc] = 0; - //rgKey[iKey].SetShiftState(ss, sbBuffer.ToString().Substring(0, rc), false, (caps != 0)); - rgKey[iKey]->SetShiftState(ss, sbBuffer, false, (caps == 0)); - - } - } - else if(rc < 0) { - //rgKey[iKey].SetShiftState(ss, sbBuffer.ToString().Substring(0, 1), true, (caps != 0)); - sbBuffer[2] = 0; - rgKey[iKey]->SetShiftState(ss, sbBuffer, true, (caps == 0)); - - // It's a dead key; let's flush out whats stored in the keyboard state. - loader.ClearKeyboardBuffer(VK_DECIMAL, rgKey[VK_DECIMAL]->SC(), hkl); - DeadKey *dk = NULL; - for(UINT iDead = 0; iDead < alDead.size(); iDead++) { - dk = alDead[iDead]; - if(dk->DeadCharacter() == rgKey[iKey]->GetShiftState(ss, caps == 0)[0]) { - break; - } - dk = NULL; - } - if(dk == NULL) { - alDead.push_back(loader.ProcessDeadKey(iKey, ss, lpKeyState, rgKey, caps == 0, hkl)); - } - } - } -*/ - } + // _S2 handle deadkeys later + // if rc <0: it got a deadkey { + // fill m_rgss and m_rgfDeadkey + //SET_SHIFTSTATES( deadkey) //sbuffer is value out of ToUnicodeEx / AllVector + // do more stuff for deadkeys... + // } from rc<0 + } } - } -/* - // _S2 do I need this for Linux?? - for(int i = 0; i < cKeyboards; i++) { - if(hkl == rghkl[i]) { - hkl = NULL; - break; } } - // _S2 do I need this for Linux?? - if(hkl != NULL) { - UnloadKeyboardLayout(hkl); - } - // _S2 do I need that for Linux?? - delete[] rghkl; -*/ + + // _S2 can go later: check if all correct + /*write_rgKey_ToFile(rgKey) ; + v_dw_2D V_lin,V_win,V_map; + write_RGKEY_FileToVector(V_lin, "rgKey_lin.txt"); + write_RGKEY_FileToVector(V_win, "rgKey_Win.txt"); + write_RGKEY_FileToVector(V_map, "map.txt"); + CompareVector_To_VectorOfFile_RGKEY( V_win, V_lin,V_map);*/ + + int STOP = 0; + + //------------------------------------------------------------- // Now that we've collected the key data, we need to // translate it to kmx and append to the existing keyboard From 5786137d014e884de944b0d4578016e80563e23a Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 29 Sep 2023 13:07:45 +0200 Subject: [PATCH 095/327] feat(linux): mcompile start of translate key --- linux/mcompile/keymap/mc_import_rules.cpp | 60 ++++++++++++++--------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index b21ffea1a7..e19605f76b 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -174,7 +174,7 @@ public: return this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)]; } - void SetShiftState(ShiftState shiftState, std::wstring value, bool isDeadKey, bool capsLock) { + void KMX_SetShiftState(ShiftState shiftState, std::wstring value, bool isDeadKey, bool capsLock) { this->m_rgfDeadKey[(UINT)shiftState][(capsLock ? 1 : 0)] = isDeadKey; this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; } @@ -517,12 +517,12 @@ bool write_rgKey_ToFile(std::vector rgKey ){ std::wstring get_VirtualKey_US_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &caps, v_dw_3D &All_Vector) { int icaps; - KMX_DWORD SC_ = get_position_From_VirtualKey_US(iKey, All_Vector); + KMX_DWORD pos = get_position_From_VirtualKey_US(iKey, All_Vector); if (ss >9) return L""; - if( ss < All_Vector[0][SC_].size()-1) { + if( ss < All_Vector[0][pos].size()-1) { if ( ss % 2 == 0) icaps = ss+2-caps; @@ -530,7 +530,7 @@ std::wstring get_VirtualKey_US_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &c if ( ss % 2 == 1) icaps = ss+caps; - return std::wstring(1, (int) All_Vector[0][SC_][icaps]); + return std::wstring(1, (int) All_Vector[0][pos][icaps]); } return L""; } @@ -620,7 +620,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std } */ - // _S2 skip shiftstates 4, 5, 8, 9 + // _S2 in this part we skip shiftstates 4, 5, 8, 9 for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { if(rgKey[iKey] != NULL) { WCHAR sbBuffer[256]; // Scratchpad we use many places @@ -633,26 +633,33 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std for(int caps = 0; caps <= 1; caps++) { + //_S2 TODO //_S2 get char - do I need rc ?? ( was rc = ToUnicodeEx...) - std::wstring char_for_input = get_VirtualKey_US_from_iKey(iKey, ss, caps, All_Vector); + std::wstring VK_US = get_VirtualKey_US_from_iKey(iKey, ss, caps, All_Vector); + //_S2 TODO //do I need that ?? //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { - if(char_for_input == L"") { - rgKey[iKey]->SetShiftState(ss, L"", false, (caps == 0)); + if(VK_US == L"") { + rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); } - //else // if rc ==1 : it got 1 char && something { - if( (ss == Ctrl || ss == ShftCtrl) /*&& something? */) { + //_S2 TODO + //else // if rc ==1 : it got 1 char && +40 in Buffer CTRl pressed { + //It's dealing with control characters. If ToUnicodeEx gets VK_A with the Ctrl key pressed, + //it will write 0x01 to sBuffer[0] , without Ctrl it's 0x41. The if detects this case. + if( (ss == Ctrl || ss == ShftCtrl) /*&& CTRl +0x40 in the buffer ( which indicates a ctrl press) */) { continue; } + //_S2 TODO // fill m_rgss and m_rgfDeadkey ( m_rgfDeadkey will be done later) - rgKey[iKey]->SetShiftState(ss, char_for_input, false, (caps == 0)); + rgKey[iKey]->KMX_SetShiftState(ss, VK_US, false, (caps == 0)); //} // from rc==1 // } // from rc > 0 + //_S2 TODO // _S2 handle deadkeys later // if rc <0: it got a deadkey { // fill m_rgss and m_rgfDeadkey @@ -674,18 +681,17 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std write_RGKEY_FileToVector(V_map, "map.txt"); CompareVector_To_VectorOfFile_RGKEY( V_win, V_lin,V_map);*/ - int STOP = 0; //------------------------------------------------------------- // Now that we've collected the key data, we need to // translate it to kmx and append to the existing keyboard //------------------------------------------------------------- -/* + int nDeadkey = 0; - LPGROUP gp = new GROUP[kp->cxGroupArray+2]; // leave space for old - memcpy(gp, kp->dpGroupArray, sizeof(GROUP) * kp->cxGroupArray); + LPKMX_GROUP gp = new KMX_GROUP[kp->cxGroupArray+4]; // leave space for old + memcpy(gp, kp->dpGroupArray, sizeof(KMX_GROUP) * kp->cxGroupArray); // // Find the current highest deadkey index @@ -699,13 +705,22 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std // *p++ = CODE_USE; // *p++ = (WCHAR)(kp->cxGroupArray + 1); // *p = 0; + //} + LPKMX_KEY kkp = gp->dpKeyArray; + +int STOP=0; + /*for(UINT j = 0; j < gp->cxKeyArray; j++, kkp++) { + nDeadkey = max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpContext)); + nDeadkey = max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpOutput)); } - LPKEY kkp = gp->dpKeyArray; - for(UINT j = 0; j < gp->cxKeyArray; j++, kkp++) { - nDeadkey = max(nDeadkey, GetMaxDeadkeyIndex(kkp->dpContext)); - nDeadkey = max(nDeadkey, GetMaxDeadkeyIndex(kkp->dpOutput)); - } + */ } + + + +int STOP2=0; + + /* kp->cxGroupArray++; gp = &kp->dpGroupArray[kp->cxGroupArray-1]; @@ -855,8 +870,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std kkp++; } } - */ +*/ wprintf(L"\n ##### KMX_ImportRules of mc_import_rules ended #####\n"); - return true; +return true; } - From 461ade9633f30c46c23ef2c897fead24e820db4d Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 29 Sep 2023 16:33:41 +0200 Subject: [PATCH 096/327] feat(linux): mcompile in translate key open functions+rename to KMX_... -> program will run but won`t give the right results yet --- linux/mcompile/keymap/mc_import_rules.cpp | 235 ++++++++++++++-------- linux/mcompile/keymap/mcompile.cpp | 7 + linux/mcompile/keymap/mcompile.h | 2 + 3 files changed, 161 insertions(+), 83 deletions(-) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index e19605f76b..c7cb771b0b 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -38,8 +38,8 @@ enum ShiftState { Xxxx = 8, // 8 ShftXxxx = Shft | Xxxx, // 9 }; -/* -const int ShiftStateMap[] = { + +const int KMX_ShiftStateMap[] = { ISVIRTUALKEY, ISVIRTUALKEY | K_SHIFTFLAG, ISVIRTUALKEY | K_CTRLFLAG, @@ -50,22 +50,22 @@ const int ShiftStateMap[] = { ISVIRTUALKEY | RALTFLAG | K_SHIFTFLAG, 0, 0}; - */ + class DeadKey { private: - WCHAR m_deadchar; - std::vector m_rgbasechar; - std::vector m_rgcombchar; -/* + KMX_WCHAR m_deadchar; + std::vector m_rgbasechar; + std::vector m_rgcombchar; + public: - DeadKey(WCHAR deadCharacter) { +/* DeadKey(WCHAR deadCharacter) { this->m_deadchar = deadCharacter; } - - WCHAR DeadCharacter() { +*/ + KMX_WCHAR KMX_DeadCharacter() { return this->m_deadchar; } - +/* void AddDeadKeyRow(WCHAR baseCharacter, WCHAR combinedCharacter) { this->m_rgbasechar.push_back(baseCharacter); this->m_rgcombchar.push_back(combinedCharacter); @@ -93,9 +93,9 @@ public: return false; }*/ }; -/* -int DeadKeyMap(int index, std::vector *deadkeys, int deadkeyBase, std::vector *deadkeyMappings) { // I4327 // I4353 + +int KMX_DeadKeyMap(int index, std::vector *deadkeys, int deadkeyBase, std::vector *deadkeyMappings) { // I4327 // I4353 for(size_t i = 0; i < deadkeyMappings->size(); i++) { if((*deadkeyMappings)[i].deadkey == index) { return (*deadkeyMappings)[i].dkid; @@ -103,13 +103,13 @@ int DeadKeyMap(int index, std::vector *deadkeys, int deadkeyBase, std } for(size_t i = 0; i < deadkeys->size(); i++) { - if((*deadkeys)[i]->DeadCharacter() == index) { + if((*deadkeys)[i]->KMX_DeadCharacter() == index) { return deadkeyBase + i; } } return 0xFFFF; } -*/ + class KMX_VirtualKey { private: KMX_HKL m_hkl; // _S2 do I need this and is void* OK to assume? @@ -179,12 +179,12 @@ public: this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; } -/* - bool IsSGCAPS() { - std::wstring stBase = this->GetShiftState(Base, false); - std::wstring stShift = this->GetShiftState(Shft, false); - std::wstring stCaps = this->GetShiftState(Base, true); - std::wstring stShiftCaps = this->GetShiftState(Shft, true); + + bool KMX_IsSGCAPS() { + std::wstring stBase = this->KMX_GetShiftState(Base, false); + std::wstring stShift = this->KMX_GetShiftState(Shft, false); + std::wstring stCaps = this->KMX_GetShiftState(Base, true); + std::wstring stShiftCaps = this->KMX_GetShiftState(Shft, true); return ( ((stCaps.size() > 0) && (stBase.compare(stCaps) != 0) && @@ -194,10 +194,10 @@ public: (stShift.compare(stShiftCaps) != 0))); } - bool IsCapsEqualToShift() { - std::wstring stBase = this->GetShiftState(Base, false); - std::wstring stShift = this->GetShiftState(Shft, false); - std::wstring stCaps = this->GetShiftState(Base, true); + bool KMX_IsCapsEqualToShift() { + std::wstring stBase = this->KMX_GetShiftState(Base, false); + std::wstring stShift = this->KMX_GetShiftState(Shft, false); + std::wstring stCaps = this->KMX_GetShiftState(Base, true); return ( (stBase.size() > 0) && (stShift.size() > 0) && @@ -205,10 +205,10 @@ public: (stShift.compare(stCaps) == 0)); } - bool IsAltGrCapsEqualToAltGrShift() { - std::wstring stBase = this->GetShiftState(MenuCtrl, false); - std::wstring stShift = this->GetShiftState(ShftMenuCtrl, false); - std::wstring stCaps = this->GetShiftState(MenuCtrl, true); + bool KMX_IsAltGrCapsEqualToAltGrShift() { + std::wstring stBase = this->KMX_GetShiftState(MenuCtrl, false); + std::wstring stShift = this->KMX_GetShiftState(ShftMenuCtrl, false); + std::wstring stCaps = this->KMX_GetShiftState(MenuCtrl, true); return ( (stBase.size() > 0) && (stShift.size() > 0) && @@ -216,10 +216,10 @@ public: (stShift.compare(stCaps) == 0)); } - bool IsXxxxGrCapsEqualToXxxxShift() { - std::wstring stBase = this->GetShiftState(Xxxx, false); - std::wstring stShift = this->GetShiftState(ShftXxxx, false); - std::wstring stCaps = this->GetShiftState(Xxxx, true); + bool KMX_IsXxxxGrCapsEqualToXxxxShift() { + std::wstring stBase = this->KMX_GetShiftState(Xxxx, false); + std::wstring stShift = this->KMX_GetShiftState(ShftXxxx, false); + std::wstring stCaps = this->KMX_GetShiftState(Xxxx, true); return ( (stBase.size() > 0) && (stShift.size() > 0) && @@ -227,36 +227,36 @@ public: (stShift.compare(stCaps) == 0)); } - bool IsEmpty() { + bool KMX_IsEmpty() { for (int i = 0; i < 10; i++) { for (int j = 0; j <= 1; j++) { - if (this->GetShiftState((ShiftState)i, (j == 1)).size() > 0) { + if (this->KMX_GetShiftState((ShiftState)i, (j == 1)).size() > 0) { return (false); } } } return true; } - - bool IsKeymanUsedKey() { + + bool KMX_IsKeymanUsedKey() { return (this->m_vk >= 0x20 && this->m_vk <= 0x5F) || (this->m_vk >= 0x88); } - UINT GetShiftStateValue(int capslock, int caps, ShiftState ss) { + UINT KMX_GetShiftStateValue(int capslock, int caps, ShiftState ss) { return - ShiftStateMap[(int)ss] | + KMX_ShiftStateMap[(int)ss] | (capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0); } - int GetKeyCount(int MaxShiftState) { + int KMX_GetKeyCount(int MaxShiftState) { int nkeys = 0; // Get the CAPSLOCK value int capslock = - (this->IsCapsEqualToShift() ? 1 : 0) | - (this->IsSGCAPS() ? 2 : 0) | - (this->IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + (this->KMX_IsCapsEqualToShift() ? 1 : 0) | + (this->KMX_IsSGCAPS() ? 2 : 0) | + (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | + (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); for (int ss = 0; ss <= MaxShiftState; ss++) { if (ss == Menu || ss == ShftMenu) { @@ -264,7 +264,7 @@ public: continue; } for (int caps = 0; caps <= 1; caps++) { - std::wstring st = this->GetShiftState((ShiftState) ss, (caps == 1)); + std::wstring st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); if (st.size() == 0) { // No character assigned here @@ -286,13 +286,13 @@ public: return nkeys; } - bool LayoutRow(int MaxShiftState, LPKEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion) { // I4552 + bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion) { // I4552 // Get the CAPSLOCK value int capslock = - (this->IsCapsEqualToShift() ? 1 : 0) | - (this->IsSGCAPS() ? 2 : 0) | - (this->IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + (this->KMX_IsCapsEqualToShift() ? 1 : 0) | + (this->KMX_IsSGCAPS() ? 2 : 0) | + (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | + (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); for (int ss = 0; ss <= MaxShiftState; ss++) { if (ss == Menu || ss == ShftMenu) { @@ -300,28 +300,28 @@ public: continue; } for (int caps = 0; caps <= 1; caps++) { - std::wstring st = this->GetShiftState((ShiftState) ss, (caps == 1)); - PWSTR p; + std::wstring st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); + PKMX_WCHAR p; // was PWSTR p; if (st.size() == 0) { // No character assigned here } else if (this->m_rgfDeadKey[(int)ss][caps]) { // It's a dead key, append an @ sign. - key->dpContext = new WCHAR[1]; + key->dpContext = new KMX_WCHAR[1]; *key->dpContext = 0; - key->ShiftFlags = this->GetShiftStateValue(capslock, caps, (ShiftState) ss); - key->Key = VKUnderlyingLayoutToVKUS(this->VK()); + key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); + key->Key = KMX_VKUnderlyingLayoutToVKUS(this->VK()); key->Line = 0; if(bDeadkeyConversion) { // I4552 - p = key->dpOutput = new WCHAR[2]; + p = key->dpOutput = new KMX_WCHAR[2]; *p++ = st[0]; *p = 0; } else { - p = key->dpOutput = new WCHAR[4]; + p = key->dpOutput = new KMX_WCHAR[4]; *p++ = UC_SENTINEL; *p++ = CODE_DEADKEY; - *p++ = DeadKeyMap(st[0], deadkeys, deadkeyBase, &FDeadkeys); // I4353 + *p++ = KMX_DeadKeyMap(st[0], deadkeys, deadkeyBase, &KMX_FDeadkeys); // I4353 *p = 0; } key++; @@ -332,11 +332,11 @@ public: } if(isvalid) { - key->Key = VKUnderlyingLayoutToVKUS(this->VK()); + key->Key = KMX_VKUnderlyingLayoutToVKUS(this->VK()); key->Line = 0; - key->ShiftFlags = this->GetShiftStateValue(capslock, caps, (ShiftState) ss); - key->dpContext = new WCHAR; *key->dpContext = 0; - p = key->dpOutput = new WCHAR[st.size() + 1]; + key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); + key->dpContext = new KMX_WCHAR; *key->dpContext = 0; + p = key->dpOutput = new KMX_WCHAR[st.size() + 1]; for(size_t ich = 0; ich < st.size(); ich++) *p++ = st[ich]; *p = 0; key++; @@ -346,9 +346,8 @@ public: } return true; } - -*/ }; + class KMX_Loader { private: KMX_BYTE lpKeyStateNull[256]; @@ -483,17 +482,87 @@ public: } while(rc != 1 && rc != 0); }*/ }; -/* -int GetMaxDeadkeyIndex(WCHAR *p) { + +// _S2 where to put this?? +const int CODE__SIZE[] = { + -1, // undefined 0x00 + 1, // CODE_ANY 0x01 + 2, // CODE_INDEX 0x02 + 0, // CODE_CONTEXT 0x03 + 0, // CODE_NUL 0x04 + 1, // CODE_USE 0x05 + 0, // CODE_RETURN 0x06 + 0, // CODE_BEEP 0x07 + 1, // CODE_DEADKEY 0x08 + -1, // unused 0x09 + 2, // CODE_EXTENDED 0x0A + -1, // CODE_EXTENDEDEND 0x0B (unused) + 1, // CODE_SWITCH 0x0C + -1, // CODE_KEY 0x0D (never used) + 0, // CODE_CLEARCONTEXT 0x0E + 1, // CODE_CALL 0x0F + -1, // UC_SENTINEL_EXTENDEDEND 0x10 (not valid with UC_SENTINEL) + 1, // CODE_CONTEXTEX 0x11 + 1, // CODE_NOTANY 0x12 + 2, // CODE_SETOPT 0x13 + 3, // CODE_IFOPT 0x14 + 1, // CODE_SAVEOPT 0x15 + 1, // CODE_RESETOPT 0x16 + 3, // CODE_IFSYSTEMSTORE 0x17 + 2 // CODE_SETSYSTEMSTORE 0x18 +}; + +// _S2 where to put this?? +PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p) { + + if (*p == 0) + return p; + if (*p != UC_SENTINEL) { + if (*p >= 0xD800 && *p <= 0xDBFF && *(p + 1) >= 0xDC00 && *(p + 1) <= 0xDFFF) + return p + 2; + return p + 1; + } + // UC_SENTINEL(FFFF) with UC_SENTINEL_EXTENDEDEND(0x10) == variable length + if (*(p + 1) == CODE_EXTENDED) { + p += 2; + while (*p && *p != UC_SENTINEL_EXTENDEDEND) + p++; + + if (*p == 0) return p; + return p + 1; + } + + if (*(p + 1) > CODE_LASTCODE || CODE__SIZE[*(p + 1)] == -1) { + return p + 1; + } + + int deltaptr = 2 + CODE__SIZE[*(p + 1)]; + + // check for \0 between UC_SENTINEL(FFFF) and next printable character + for (int i = 0; i < deltaptr; i++) { + if (*p == 0) + return p; + p++; + } + return p; +} + + + +int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { int n = 0; while(p && *p) { if(*p == UC_SENTINEL && *(p+1) == CODE_DEADKEY) - n = max(n, *(p+2)); - p = incxstr(p); + + // n = max(n, *(p+2)); + if( !(n > (*p+2))) // _S2 p+4 ?? + n= (*p+2); + + p = KMX_incxstr(p); } return n; } -*/ + // _S2 has to go !! @@ -709,25 +778,21 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std LPKMX_KEY kkp = gp->dpKeyArray; int STOP=0; - /*for(UINT j = 0; j < gp->cxKeyArray; j++, kkp++) { - nDeadkey = max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpContext)); - nDeadkey = max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpOutput)); + for(UINT j = 0; j < gp->cxKeyArray; j++, kkp++) { + nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpContext)); + nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpOutput)); } - */ } - -int STOP2=0; - - /* kp->cxGroupArray++; gp = &kp->dpGroupArray[kp->cxGroupArray-1]; +// _S2 need to change mapping win-lin before i can get correct values here! UINT nKeys = 0; for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { - if ((rgKey[iKey] != NULL) && rgKey[iKey]->IsKeymanUsedKey() && (!rgKey[iKey]->IsEmpty())) { - nKeys+= rgKey[iKey]->GetKeyCount(loader.MaxShiftState()); + if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { + nKeys+= rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); } } @@ -738,7 +803,7 @@ int STOP2=0; gp->dpName = NULL; gp->dpNoMatch = NULL; gp->cxKeyArray = nKeys; - gp->dpKeyArray = new KEY[gp->cxKeyArray]; + gp->dpKeyArray = new KMX_KEY[gp->cxKeyArray]; nKeys = 0; // @@ -746,14 +811,18 @@ int STOP2=0; // for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { - if ((rgKey[iKey] != NULL) && rgKey[iKey]->IsKeymanUsedKey() && (!rgKey[iKey]->IsEmpty())) { + if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { // for each item, - if(rgKey[iKey]->LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion)) { // I4552 - nKeys+=rgKey[iKey]->GetKeyCount(loader.MaxShiftState()); + if(rgKey[iKey]->KMX_LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion)) { // I4552 + nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); } } } + +int STOP2=0; + + /* gp->cxKeyArray = nKeys; // diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 3df3bafd82..5eadab21b4 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -239,6 +239,13 @@ KMX_DWORD KMX_VKUSToVKUnderlyingLayout(v_dw_3D &All_Vector,KMX_DWORD inUS) { return inUS; } +// _S2 this will definitely give wrong results!!!! +KMX_WORD KMX_VKUnderlyingLayoutToVKUS(KMX_WORD VKey) { + // _S2 TODO adapt for mcompile linux + return VKey; +} + + // takes cpital character of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] KMX_DWORD KMX_CharFromVK(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey){ diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 431d8d5998..b4edd3c0bc 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -39,6 +39,8 @@ struct KMX_DeadkeyMapping { // I4353 extern std::vector KMX_FDeadkeys; // I4353 +// _S2 is this correct here??? +KMX_WORD KMX_VKUnderlyingLayoutToVKUS(KMX_WORD VKey) ; //--------------------old /* From d321ef0a5b47d0c232930cb530e922e4ac27d334 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 29 Sep 2023 16:43:41 +0200 Subject: [PATCH 097/327] feat(linux): mcompile in translate key more open functions+rename to KMX_... --- linux/mcompile/keymap/mc_import_rules.cpp | 69 +++++++++++------------ 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index c7cb771b0b..41bd3938a4 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -70,19 +70,19 @@ public: this->m_rgbasechar.push_back(baseCharacter); this->m_rgcombchar.push_back(combinedCharacter); } - - int Count() { +*/ + int KMX_Count() { return this->m_rgbasechar.size(); } - WCHAR GetBaseCharacter(int index) { + KMX_WCHAR KMX_GetBaseCharacter(int index) { return this->m_rgbasechar[index]; } - WCHAR GetCombinedCharacter(int index) { + KMX_WCHAR KMX_GetCombinedCharacter(int index) { return this->m_rgcombchar[index]; } - +/* bool ContainsBaseCharacter(WCHAR baseCharacter) { std::vector::iterator it; for(it=this->m_rgbasechar.begin(); itcxGroupArray++; gp = &kp->dpGroupArray[kp->cxGroupArray-1]; +int STOP2=0; + // _S2 need to change mapping win-lin before i can get correct values here! UINT nKeys = 0; for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { @@ -819,22 +821,18 @@ int STOP=0; } } - -int STOP2=0; - - /* gp->cxKeyArray = nKeys; // // Add nomatch control to each terminating 'using keys' group // I4550 // - LPGROUP gp2 = kp->dpGroupArray; + LPKMX_GROUP gp2 = kp->dpGroupArray; for(UINT i = 0; i < kp->cxGroupArray - 1; i++, gp2++) { if(gp2->fUsingKeys && gp2->dpNoMatch == NULL) { - WCHAR *p = gp2->dpNoMatch = new WCHAR[4]; + KMX_WCHAR *p = gp2->dpNoMatch = new KMX_WCHAR[4]; *p++ = UC_SENTINEL; *p++ = CODE_USE; - *p++ = (WCHAR)(kp->cxGroupArray); + *p++ = (KMX_WCHAR)(kp->cxGroupArray); *p = 0; // @@ -843,22 +841,22 @@ int STOP2=0; // loop is not very efficient but it's not worthy of optimisation. // UINT j; - LPKEY kkp; + LPKMX_KEY kkp; for(j = 0, kkp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kkp++) { if((kkp->ShiftFlags & (K_CTRLFLAG|K_ALTFLAG|LCTRLFLAG|LALTFLAG|RCTRLFLAG|RALTFLAG)) != 0) { gp2->cxKeyArray++; - LPKEY kkp2 = new KEY[gp2->cxKeyArray]; - memcpy(kkp2, gp2->dpKeyArray, sizeof(KEY)*(gp2->cxKeyArray-1)); + LPKMX_KEY kkp2 = new KMX_KEY[gp2->cxKeyArray]; + memcpy(kkp2, gp2->dpKeyArray, sizeof(KMX_KEY)*(gp2->cxKeyArray-1)); gp2->dpKeyArray = kkp2; kkp2 = &kkp2[gp2->cxKeyArray-1]; - kkp2->dpContext = new WCHAR; *kkp2->dpContext = 0; + kkp2->dpContext = new KMX_WCHAR; *kkp2->dpContext = 0; kkp2->Key = kkp->Key; kkp2->ShiftFlags = kkp->ShiftFlags; kkp2->Line = 0; - WCHAR *p = kkp2->dpOutput = new WCHAR[4]; + KMX_WCHAR *p = kkp2->dpOutput = new KMX_WCHAR[4]; *p++ = UC_SENTINEL; *p++ = CODE_USE; - *p++ = (WCHAR)(kp->cxGroupArray); + *p++ = (KMX_WCHAR)(kp->cxGroupArray); *p = 0; } } @@ -873,10 +871,10 @@ int STOP2=0; if (alDead.size() > 0 && !bDeadkeyConversion) { // I4552 kp->cxGroupArray++; - WCHAR *p = gp->dpMatch = new WCHAR[4]; + KMX_WCHAR *p = gp->dpMatch = new KMX_WCHAR[4]; *p++ = UC_SENTINEL; *p++ = CODE_USE; - *p++ = (WCHAR) kp->cxGroupArray; + *p++ = (KMX_WCHAR) kp->cxGroupArray; *p = 0; gp++; @@ -886,10 +884,10 @@ int STOP2=0; gp->dpName = NULL; gp->dpNoMatch = NULL; gp->cxKeyArray = alDead.size(); - LPKEY kkp = gp->dpKeyArray = new KEY[alDead.size()]; + LPKMX_KEY kkp = gp->dpKeyArray = new KMX_KEY[alDead.size()]; - LPSTORE sp = new STORE[kp->cxStoreArray + alDead.size() * 2]; - memcpy(sp, kp->dpStoreArray, sizeof(STORE) * kp->cxStoreArray); + LPKMX_STORE sp = new KMX_STORE[kp->cxStoreArray + alDead.size() * 2]; + memcpy(sp, kp->dpStoreArray, sizeof(KMX_STORE) * kp->cxStoreArray); kp->dpStoreArray = sp; @@ -902,34 +900,34 @@ int STOP2=0; sp->dpName = NULL; sp->dwSystemID = 0; - sp->dpString = new WCHAR[dk->Count() + 1]; - for(int j = 0; j < dk->Count(); j++) - sp->dpString[j] = dk->GetBaseCharacter(j); - sp->dpString[dk->Count()] = 0; + sp->dpString = new KMX_WCHAR[dk->KMX_Count() + 1]; + for(int j = 0; j < dk->KMX_Count(); j++) + sp->dpString[j] = dk->KMX_GetBaseCharacter(j); + sp->dpString[dk->KMX_Count()] = 0; sp++; sp->dpName = NULL; sp->dwSystemID = 0; - sp->dpString = new WCHAR[dk->Count() + 1]; - for(int j = 0; j < dk->Count(); j++) - sp->dpString[j] = dk->GetCombinedCharacter(j); - sp->dpString[dk->Count()] = 0; + sp->dpString = new KMX_WCHAR[dk->KMX_Count() + 1]; + for(int j = 0; j < dk->KMX_Count(); j++) + sp->dpString[j] = dk->KMX_GetCombinedCharacter(j); + sp->dpString[dk->KMX_Count()] = 0; sp++; kkp->Line = 0; kkp->ShiftFlags = 0; kkp->Key = 0; - WCHAR *p = kkp->dpContext = new WCHAR[8]; + KMX_WCHAR *p = kkp->dpContext = new KMX_WCHAR[8]; *p++ = UC_SENTINEL; *p++ = CODE_DEADKEY; - *p++ = DeadKeyMap(dk->DeadCharacter(), &alDead, nDeadkey, FDeadkeys); // I4353 + *p++ = KMX_DeadKeyMap(dk->KMX_DeadCharacter(), &alDead, nDeadkey, FDeadkeys); // I4353 // *p++ = nDeadkey+i; *p++ = UC_SENTINEL; *p++ = CODE_ANY; *p++ = nStoreBase + i*2 + 1; *p = 0; - p = kkp->dpOutput = new WCHAR[5]; + p = kkp->dpOutput = new KMX_WCHAR[5]; *p++ = UC_SENTINEL; *p++ = CODE_INDEX; *p++ = nStoreBase + i*2 + 2; @@ -939,7 +937,8 @@ int STOP2=0; kkp++; } } -*/ + + wprintf(L"\n ##### KMX_ImportRules of mc_import_rules ended #####\n"); return true; } From 2a46b6fc44a7c39d3d2bc76aa64a9e09246445ac Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 2 Oct 2023 19:27:56 +0200 Subject: [PATCH 098/327] feat(linux): mcompile use mapping Lin-Win that is available already in keyman --- linux/mcompile/keymap/README.md | 15 +++- linux/mcompile/keymap/keymap.cpp | 128 ++++++++++++++------------- linux/mcompile/keymap/keymap.h | 145 ++++++++++++++++++++++++++++++- 3 files changed, 227 insertions(+), 61 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index 8d726982be..35e0aeec43 100644 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -20,14 +20,25 @@ TODO shiftstate-count TODO keymap SplitToV.cpp exchange 4 with genaerated shiftcount TODO check if part with surplus is neccessary TODO shift-statevector -TODO Do I need HKL for Linux / can I just use a void* ?? -TODO typeddef of KMX_HKL - van I delete all m_hkl from classes? +TODO Do I need HKL for Linux / can I just use a void* or remove HKL ?? +TODO typeddef of KMX_HKL - can I delete all m_hkl from classes? TODO define what to return when SC/VK is not found in get_VirtualKey_Other_From_SC,... TODO check if passed All_Vectpor as ptr/ref not as value e.g. in KMX_CharFromVK, KMX_VKUSToVKUnderlyingLayout, KMX_ImportRules ToDo in get_VirtualKey_Other_From_SC: what if we use column 3(altgr) and 4 (shift+altgr) ?? TODO where to store VK_CANCEL.... in km_types.h or elsewhere? ToDo check up to 8 shiftstates ( find symbols-file with 8) TODO get_position_From_VirtualKey_US: take care of the other shiftstates +ToDo make this better!!! get_VirtualKey_Other_From_SC + +TODO next: + change mapping (win-lin) for writing All_Vector + compare entries in rgKey ( are the same rgKey[]filled? it is OK from rgKey[65]-rgkey[90] but for other values??? ) + mc_import-rules (from ~ l. 790) see if everything gives the same result on win-Lin + check if I use char16_t everywhere instead of wchar_t or char + replace GDK + see in which files I can put some functions (e.g. incxstr) that were duplicated or even #include their original location + remove testing functions + remove USE_GDK TODO ... //--------------------------- diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 433f0d7098..4d674f9e4d 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -203,67 +203,70 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { } return 0; } -/* + int replace_PosKey_with_Keycode(std::string in) { int out = returnIfCharInvalid; - if ( in == "key") out = 49; // TOASK correct ??? - else if ( in == "key") out = 10; - else if ( in == "key") out = 11; - else if ( in == "key") out = 12; - else if ( in == "key") out = 13; - else if ( in == "key") out = 14; - else if ( in == "key") out = 15; - else if ( in == "key") out = 16; - else if ( in == "key") out = 17; - else if ( in == "key") out = 18; - else if ( in == "key") out = 19; - else if ( in == "key") out = 20; - else if ( in == "key") out = 21; - else if ( in == "key") out = 16; - else if ( in == "key") out = 17; - else if ( in == "key") out = 18; - else if ( in == "key") out = 19; - else if ( in == "key") out = 20; - else if ( in == "key") out = 21; - else if ( in == "key") out = 22; - else if ( in == "key") out = 23; - else if ( in == "key") out = 24; - else if ( in == "key") out = 25; - else if ( in == "key") out = 26; - else if ( in == "key") out = 27; +// _S2 these are the Scancode-Values we use in Keyman ( = like the windows scancodes) - else if ( in == "key") out = 30; - else if ( in == "key") out = 31; - else if ( in == "key") out = 32; - else if ( in == "key") out = 33; - else if ( in == "key") out = 34; - else if ( in == "key") out = 35; - else if ( in == "key") out = 36; - else if ( in == "key") out = 37; - else if ( in == "key") out = 38; - else if ( in == "key") out = 39; - else if ( in == "key") out = 40; - else if ( in == "key") out = 41; + if ( in == "key") out = 49; /* 0X VK_ */ // TOASK correct ??? + else if ( in == "key") out = 1; /* 0X02 VK_1 */ + else if ( in == "key") out = 2; /* 0X03 VK_2 */ + else if ( in == "key") out = 3; /* 0X04 VK_3 */ + else if ( in == "key") out = 4; /* 0X05 VK_4 */ + else if ( in == "key") out = 5; /* 0X06 VK_5 */ + else if ( in == "key") out = 6; /* 0X07 VK_6 */ + else if ( in == "key") out = 7; /* 0X08 VK_7 */ + else if ( in == "key") out = 8; /* 0X09 VK_8 */ + else if ( in == "key") out = 9; /* 0X0A VK_9 */ + else if ( in == "key") out = 10; /* 0X0B VK_0 */ + else if ( in == "key") out = 12; /* 0X0C VK_MINUS */ + else if ( in == "key") out = 13; /* 0X0D VK_EQUALS */ - else if ( in == "key") out = 44; - else if ( in == "key") out = 45; - else if ( in == "key") out = 46; - else if ( in == "key") out = 47; - else if ( in == "key") out = 48; - else if ( in == "key") out = 49; - else if ( in == "key") out = 50; - else if ( in == "key") out = 51; - else if ( in == "key") out = 52; - else if ( in == "key") out = 53; - else if ( in == "key") out = 54; - else if ( in == "key") out = 55; + else if ( in == "key") out = 16; /* 0X10 VK_Q */ + else if ( in == "key") out = 17; /* 0X11 VK_W */ + else if ( in == "key") out = 18; /* 0X12 VK_E */ + else if ( in == "key") out = 19; /* 0X13 VK_R */ + else if ( in == "key") out = 20; /* 0X14 VK_T */ + else if ( in == "key") out = 21; /* 0X15 VK_Y */ + else if ( in == "key") out = 22; /* 0X16 VK_U */ + else if ( in == "key") out = 23; /* 0X17 VK_I */ + else if ( in == "key") out = 24; /* 0X18 VK_O */ + else if ( in == "key") out = 25; /* 0X19 VK_P */ + else if ( in == "key") out = 26; /* 0X1A VK_LEFTBRACE */ + else if ( in == "key") out = 27; /* 0X1B VK_RIGHTBRACE */ + + else if ( in == "key") out = 30; /* 0X1E VK_A */ + else if ( in == "key") out = 31; /* 0X1F VK_S */ + else if ( in == "key") out = 32; /* 0X20 VK_D */ + else if ( in == "key") out = 33; /* 0X21 VK_F */ + else if ( in == "key") out = 34; /* 0X22 VK_G */ + else if ( in == "key") out = 35; /* 0X23 VK_H */ + else if ( in == "key") out = 36; /* 0X24 VK_J */ + else if ( in == "key") out = 37; /* 0X25 VK_K */ + else if ( in == "key") out = 38; /* 0X26 VK_L */ + else if ( in == "key") out = 39; /* 0X27 VK_SEMICOLON */ + else if ( in == "key") out = 40; /* 0X28 VK_APOSTROPHE */ + else if ( in == "key") out = 41; /* 0X29 VK_GRAVE */ + + else if ( in == "key") out = 44; /* 0X2C VK_Z */ + else if ( in == "key") out = 45; /* 0X2D VK_X */ + else if ( in == "key") out = 46; /* 0X2E VK_C */ + else if ( in == "key") out = 47; /* 0X2F VK_V */ + else if ( in == "key") out = 48; /* 0X30 VK_B */ + else if ( in == "key") out = 49; /* 0X31 VK_N */ + else if ( in == "key") out = 50; /* 0X32 VK_M */ + else if ( in == "key") out = 51; /* 0X33 VK_ COMMA */ + else if ( in == "key") out = 52; /* 0X34 VK_DOT */ + else if ( in == "key") out = 53; /* 0X35 VK_SLASH */ + else if ( in == "key") out = 54; /* 0X36 VK_RIGHTSHIFT */ + else if ( in == "key") out = 55; /* 0X37 VK_RIGHTSHIFT */ return out; } -*/ -int replace_PosKey_with_Keycode(std::string in) { +/* +int replace_PosKey_with_Keycode_old(std::string in) { int out = returnIfCharInvalid; if ( in == "key") out = 49; // TOASK correct ??? else if ( in == "key") out = 10; @@ -320,7 +323,7 @@ int replace_PosKey_with_Keycode(std::string in) { return out; } - +*/ v_dw_2D create_empty_2D( int dim_rows,int dim_shifts) { v_dw_1D shifts; v_dw_2D Vector_2D; @@ -360,11 +363,11 @@ v_dw_2D create_empty_2D( int dim_rows,int dim_shifts) { All_Vector[1][i][0] = All_Vector[0][i][0]; // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] - All_Vector[1][i][0+1] = getKeyvalsFromKeymap(keymap,(All_Vector[1][i][0]),0); //shift state: unshifted:0 - All_Vector[1][i][1+1] = getKeyvalsFromKeymap(keymap,(All_Vector[1][i][0]),1); //shift state: shifted:1 + All_Vector[1][i][0+1] = getKeyvalsFromKeymap(keymap,keycode_map[All_Vector[0][i][0]],0); //shift state: unshifted:0 + All_Vector[1][i][1+1] = getKeyvalsFromKeymap(keymap,keycode_map[All_Vector[0][i][0]],1); //shift state: shifted:1 - //wprintf(L" Keycodes US dw : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); - //wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); + wprintf(L" Keycodes US dw : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); + wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); } return 0; } @@ -450,7 +453,7 @@ bool test_single(v_dw_3D &V) { return true; } - +// _S2 ToDo something does not work yet // query All_Vector // return RETURN NON SHIFTED CHAR [1] the VirtualKey of the Other Keyboard for given Scancode KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ @@ -467,6 +470,15 @@ KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ return All_Vector[1][i][1] ; }*/ + if(( SC < 10) && (SC >= 0)){ + // values for numbers are stored in column All_Vector[1][i][ 1 ] + if ( All_Vector[k][i][0] == SC ) { + wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][2],All_Vector[1][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); + KMX_DWORD returnval= All_Vector[1][i][1]; + return All_Vector[1][i][1]; + } + } + // shifted values e.g. "Q" (=81) are stored in column All_Vector[1][i][ 2 ] if ( All_Vector[k][i][0] == SC ) { wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][2],All_Vector[1][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 5139488b88..8e782c36bd 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -4,7 +4,7 @@ #define KEYMAP_H // _S2 can go later; is for use of mcompile with GDK or with VectorFile -#define USE_GDK 0 +#define USE_GDK 1 #include #include @@ -43,6 +43,149 @@ const KMX_DWORD KMX_VKMap[] = { 0 }; +// mapping between Linux keycodes and keyman SC +const int keycode_map_old[67]={ + 0, /* */ + 0, /* */ + 0, /* */ + 0, /* */ + 0, /* */ + 0, /* */ + 0, /* */ + 0, /* */ + 0, /* */ + 0, /* */ + 2, /*10. 1 */ + 3, /*11. 2 */ + 4, /*12. 3 */ + 5, /*13. 4 */ + 6, /*14. 5 */ + 7, /*15. 6 */ + 8, /*16. 7 */ + 9, /*17. 8 */ + 10, /*18. 9 */ + 11, /*19. 0 */ + 12, /*20. MINUS */ + 13, /*21. EQUALS*/ + 14, /*22. BACKSPACE*/ + 15, /*23. TAB*/ + 16, /* 24. Q */ + 17, /* 25. W */ + 18, /* 26. E */ + 19, /* 27. R */ + 20, /* 28. T */ + 21, /* 29. Z */ + 22, /* 30. U */ + 23, /* 31. I*/ + 24, /* 32. O*/ + 25, /* 33. P*/ + 26, /*34. LEFTBRACE*/ + 27, /*35. RIGHTBRACE*/ + 28, /*36. ENTER*/ + 29, /*37. LEFTCTRL*/ + 30, /* 38. A */ + 31, /* 39. S */ + 32, /* 40. D */ + 33, /* 41. F */ + 34, /* 42. G */ + 35, /* 43. H */ + 36, /* 44. J */ + 37, /* 45. K */ + 38, /* 46. L */ + 39, /*47. SEMICOLON*/ + 40, /*48. APOSTROPHE*/ + 41, /*49. GRAVE*/ + 42, /*50. LEFTSHIFT*/ + 43, /*51. BACKSLASH*/ + 44, /*52. Z */ + 45, /*53. X */ + 46, /*54. C */ + 47, /*55. V */ + 48, /*56. B */ + 49, /*57. N */ + 50, /*58. M */ + 51, /*59. COMMA */ + 52, /*60. DOT */ + 53, /*61. SLASH */ + 54, /*62. R_SHIFT */ + 55, /*63. * */ + 56, /*64. LEFTALT*/ + 57, /*65. SPACE*/ + 58 /*66. CAPSLOCK*/ +}; + + +// mapping between Linux keycodes and keyman SC +const int keycode_map[67]={ + 0, /* */ + 10, /*10. 1 */ + 11, /*11. 2 */ + 12, /*12. 3 */ + 13, /*13. 4 */ + 14, /*14. 5 */ + 15, /*15. 6 */ + 16, /*16. 7 */ + 17, /*17. 8 */ + 18, /*18. 9 */ + 19, /*19. 0 */ + 20, /*20. MINUS */ + 21, /*21. EQUALS*/ + 22, /*22. BACKSPACE*/ + 23, /*23. TAB*/ + 0, /* */ + 24, /* 16.. Q */ + 25, /* 7. W */ + 26, /* 18. E */ + 27, /* 19. R */ + 28, /* 20. T */ + 29, /* 21. Z */ + 30, /* 22. U */ + 31, /* 23. I*/ + 32, /* 24. O*/ + 33, /* 25. P*/ + 34, /*26. LEFTBRACE*/ + 35, /*27. RIGHTBRACE*/ + 36, /*28. ENTER*/ + 37, /*29. LEFTCTRL*/ + 38, /* 30. A */ + 39, /* 31. S */ + 40, /* 32. D */ + 41, /* 33. F */ + 42, /* 34. G */ + 43, /* 35. H */ + 44, /* 36. J */ + 45, /* 37. K */ + 46, /* 38. L */ + 47, /*39. SEMICOLON*/ + 48, /*40. APOSTROPHE*/ + 49, /*41. GRAVE*/ + 50, /*42. LEFTSHIFT*/ + 51, /*43. BACKSLASH*/ + 52, /*44. Z */ + 53, /*45. X */ + 54, /*46. C */ + 55, /*47. V */ + 56, /*48. B */ + 57, /*49. N */ + 58, /*50. M */ + 59, /*51. COMMA */ + 60, /*52. DOT */ + 61, /*53. SLASH */ + 62, /*54. R_SHIFT */ + 63, /*55. * */ + 64, /*56. LEFTALT*/ + 65, /*57. SPACE*/ + 66 , /*58. CAPSLOCK*/ + 0, /* */ + 0, /* */ + 0, /* */ + 0, /* */ + 0, /* */ + 0, /* */ + 0, /* */ + 0 /* */ +}; + // this is what we return when we find an invalid character //_S2 Which character do we use in that case? 0 or FFFF or 32 or ?? static KMX_DWORD returnIfCharInvalid = 32; From 050e80aa8675b50ee591f1ba373d893f3f8e0bb2 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 4 Oct 2023 16:34:52 +0200 Subject: [PATCH 099/327] feat(linux): mcompile use correct mapping for numbers --- linux/mcompile/keymap/README.md | 16 +++++------ linux/mcompile/keymap/keymap.cpp | 34 ++++++++++------------- linux/mcompile/keymap/mc_import_rules.cpp | 2 ++ 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index 35e0aeec43..89cea81ad1 100644 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -31,14 +31,14 @@ TODO get_position_From_VirtualKey_US: take care of the other shiftstates ToDo make this better!!! get_VirtualKey_Other_From_SC TODO next: - change mapping (win-lin) for writing All_Vector - compare entries in rgKey ( are the same rgKey[]filled? it is OK from rgKey[65]-rgkey[90] but for other values??? ) - mc_import-rules (from ~ l. 790) see if everything gives the same result on win-Lin - check if I use char16_t everywhere instead of wchar_t or char - replace GDK - see in which files I can put some functions (e.g. incxstr) that were duplicated or even #include their original location - remove testing functions - remove USE_GDK + - change mapping (win-lin) for writing All_Vector + - compare entries in rgKey ( are the same rgKey[]filled? it is OK from rgKey[65]-rgkey[90] but for other values??? ) + - mc_import-rules (from ~ l. 790) see if everything gives the same result on win-Lin + - check if I use char16_t everywhere instead of wchar_t or char + - replace GDK + - see in which files I can put some functions (e.g. incxstr) that were duplicated or even #include their original location + - remove testing functions + - remove USE_GDK TODO ... //--------------------------- diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 4d674f9e4d..b803f53596 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -112,7 +112,7 @@ KMX_DWORD convertNamesToValue(std::wstring tok_wstr){ first[L"backslash"] = VK_BKSLASH; /* DC = 220 */ first[L"bracketleft"] = VK_LBRKT; /* DB = 219 */ first[L"bracketright"] = VK_RBRKT; /* DD = 221 */ - first[L"parenright"] = VK_COLON; /* BA = 186 */ + first[L"colon"] = VK_COLON; /* BA = 186 */ first[L"comma"] = VK_COMMA; /* BC = 188 */ first[L"period"] = VK_PERIOD; /* BE = 190 */ first[L"slash"] = VK_SLASH; /* BF = 191 */ @@ -167,7 +167,7 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { std::istringstream split1(completeList[k]); for (std::string each; std::getline(split1, each, split_bracel); tokens.push_back(each)); - // replace keys names with Keycode ( with 29,...) + // replace keys names with Keycode ( with 21,...) Keycde = replace_PosKey_with_Keycode(tokens[0]); tokens[0] = std::to_string(Keycde); @@ -464,26 +464,20 @@ KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ // _S2 what if we use column 3(altgr) and 4 (shift+altgr) ?? - /*// unshifted values e.g. "q" (=113) are stored in column All_Vector[1][i][ 1 ] - if ( All_Vector[k][i][0] == (SC- All_Vector[0].size() )) { - wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); - return All_Vector[1][i][1] ; - }*/ - - if(( SC < 10) && (SC >= 0)){ + if( SC < 12) { // values for numbers are stored in column All_Vector[1][i][ 1 ] - if ( All_Vector[k][i][0] == SC ) { - wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][2],All_Vector[1][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); - KMX_DWORD returnval= All_Vector[1][i][1]; - return All_Vector[1][i][1]; - } + if ( All_Vector[k][i][0] == SC ) { + wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][2],All_Vector[1][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); + //KMX_DWORD returnval= All_Vector[1][i][1]; + // we could return All_Vector[0][i][1]; since win version uses us numbers here + return All_Vector[1][i][1]; + } } // shifted values e.g. "Q" (=81) are stored in column All_Vector[1][i][ 2 ] - if ( All_Vector[k][i][0] == SC ) { + else if ( All_Vector[k][i][0] == SC ) { wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][2],All_Vector[1][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); - KMX_DWORD returnval= All_Vector[1][i][2]; - + //KMX_DWORD returnval= All_Vector[1][i][2]; return All_Vector[1][i][2]; } } @@ -563,8 +557,10 @@ KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ KMX_DWORD get_position_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ // find correct row of char in US for( int i=0; i< (int)All_Vector[0].size()-1;i++) { - if ( All_Vector[0][i][2] == VK_US ) { - wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- \n",VK_US , i, All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2] ); + if ( ( All_Vector[0][i][1] == VK_US ) || ( All_Vector[0][i][2] == VK_US )) { + wprintf(L" VK_US= %i .. i= %i .. %i\t\t %i (%c) : %i (%c) +++ %i\t\t %i (%c) : %i (%c) \n",VK_US , i, + All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2], + All_Vector[1][i][0] , All_Vector[1][i][1] ,All_Vector[1][i][1] , All_Vector[1][i][2] , All_Vector[1][i][2] ); return i; } } diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 41bd3938a4..12b4b56a7f 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -592,6 +592,7 @@ std::wstring get_VirtualKey_US_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &c return L""; if( ss < All_Vector[0][pos].size()-1) { + //if( ss < All_Vector[1][pos].size()-1) { // _S2 numbers need this if ( ss % 2 == 0) icaps = ss+2-caps; @@ -600,6 +601,7 @@ std::wstring get_VirtualKey_US_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &c icaps = ss+caps; return std::wstring(1, (int) All_Vector[0][pos][icaps]); + //return std::wstring(1, (int) All_Vector[1][pos][icaps]); } return L""; } From 1d0bba6320cc726e9d6529a03242d747d58eca20 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 4 Oct 2023 18:39:26 +0200 Subject: [PATCH 100/327] feat(linux): mcompile tidy up --- linux/mcompile/keymap/helpers.cpp | 8 +- linux/mcompile/keymap/helpers.h | 4 +- linux/mcompile/keymap/keymap.cpp | 114 +++------------------- linux/mcompile/keymap/keymap.h | 106 +++----------------- linux/mcompile/keymap/km_types.h | 8 +- linux/mcompile/keymap/kmx_file.h | 8 +- linux/mcompile/keymap/mc_import_rules.cpp | 38 +++----- linux/mcompile/keymap/mc_kmxfile.cpp | 2 +- linux/mcompile/keymap/mc_kmxfile.h | 8 +- linux/mcompile/keymap/mc_savekeyboard.cpp | 2 + linux/mcompile/keymap/mc_savekeyboard.h | 2 +- linux/mcompile/keymap/mcompile.cpp | 18 ++-- linux/mcompile/keymap/mcompile.h | 2 + 13 files changed, 70 insertions(+), 250 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index e31e744d11..b9540a18a0 100644 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -1,12 +1,13 @@ #include "helpers.h" +//_S2 do not review - all this will be deleted later + int test_helpers(){ wprintf(L"##### test_helpers is here and USE_GDK is %i\n", USE_GDK); } int append_other_ToVector(v_dw_3D &All_Vector) { - InsertKeyvalsFromVectorFile(All_Vector); return 0; } @@ -79,7 +80,6 @@ int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector){ return 0; } - bool writeVectorToFile(v_dw_3D V) { std::string TxtFileName = "/Projects/keyman/keyman/linux/mcompile/keymap/VectorFile2.txt" ; WCHAR DeadKey; @@ -222,7 +222,6 @@ bool CompareVector_To_VectorOfFile_RGKEY(v_dw_2D Win_Vector,v_dw_2D Lin_Vector, return true; } - /*bool CompareVector_To_VectorOfFile_RGKEY(v_dw_2D Win_Vector,v_dw_2D Lin_Vector, v_dw_2D Map_Vector){ wprintf(L" #### CompareVector_To_VectorOfFile started: "); wprintf(L" #### dimensions: %i %i -- %i %i \n", Win_Vector.size() ,Win_Vector[0].size(), Lin_Vector.size() ,Lin_Vector[0].size()); @@ -310,9 +309,6 @@ bool write_RGKEY_FileToVector(v_dw_2D& shift_states, const char* infile) { return(0); } - - - bool test_In_Out(v_dw_3D All_Vector){ for ( int i=0; i<61;i++) diff --git a/linux/mcompile/keymap/helpers.h b/linux/mcompile/keymap/helpers.h index b266631ff5..60d0b150ba 100644 --- a/linux/mcompile/keymap/helpers.h +++ b/linux/mcompile/keymap/helpers.h @@ -8,13 +8,14 @@ #include "keymap.h" +//_S2 do not review - all this will be deleted later + // why again here? typedef std::vector v_str_1D; typedef std::vector v_dw_1D; typedef std::vector > v_dw_2D; typedef std::vector > > v_dw_3D; - int test_helpers(); // append characters using VectorFile (Data for Other Language on [1][ ][ ] ) @@ -26,7 +27,6 @@ bool InsertKeyvalsFromVectorFile(v_dw_3D &complete_Vector) ; // create a Vector with all entries of file int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector); - bool writeVectorToFile(v_dw_3D V) ; bool writeFileToVector(v_dw_3D& complete_Vector, const char* infile); bool CompareVector_To_VectorOfFile(v_dw_3D All_Vector,v_dw_3D File_Vector); diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index b803f53596..c6fb6c6f8b 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -53,7 +53,7 @@ int write_US_ToVector( v_dw_3D &vec,std::string language, const char* text) { bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, std::string language) { // in the Configuration file we find the appopriate paragraph between "xkb_symbol " and the next xkb_symbol - // and then copy all rows starting with "key <" to a v1D-Vector + // and then copy all rows starting with "key <" to a 1D-Vector int buffer_size = 512; char buffer[buffer_size]; @@ -140,7 +140,7 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { // 1: take the whole line of the 1D-Vector and remove unwanted characters. // 2: seperate the name e.g. key from the shiftstates // 3: convert to KMX_DWORD - // 4: push Names/Shiftstates to shift_states and then shiftstates to All_US, our 3D-Vector holding all Elements + // 4: push Names/Shiftstates to shift_states and then shift_states to All_US, our 3D-Vector holding all Elements std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; char split_bracel = '{'; @@ -197,7 +197,7 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { } all_US.push_back(shift_states); - if ( all_US.size() ==0) { + if ( all_US.size() == 0) { wprintf(L"ERROR: Can't split US to 3D-Vector\n"); return 1; } @@ -209,7 +209,7 @@ int replace_PosKey_with_Keycode(std::string in) { // _S2 these are the Scancode-Values we use in Keyman ( = like the windows scancodes) - if ( in == "key") out = 49; /* 0X VK_ */ // TOASK correct ??? + if ( in == "key") out = 49; /* 0X VK_ */ // TOASK correct ??? else if ( in == "key") out = 1; /* 0X02 VK_1 */ else if ( in == "key") out = 2; /* 0X03 VK_2 */ else if ( in == "key") out = 3; /* 0X04 VK_3 */ @@ -218,7 +218,7 @@ int replace_PosKey_with_Keycode(std::string in) { else if ( in == "key") out = 6; /* 0X07 VK_6 */ else if ( in == "key") out = 7; /* 0X08 VK_7 */ else if ( in == "key") out = 8; /* 0X09 VK_8 */ - else if ( in == "key") out = 9; /* 0X0A VK_9 */ + else if ( in == "key") out = 9; /* 0X0A VK_9 */ else if ( in == "key") out = 10; /* 0X0B VK_0 */ else if ( in == "key") out = 12; /* 0X0C VK_MINUS */ else if ( in == "key") out = 13; /* 0X0D VK_EQUALS */ @@ -265,66 +265,9 @@ int replace_PosKey_with_Keycode(std::string in) { return out; } -/* -int replace_PosKey_with_Keycode_old(std::string in) { - int out = returnIfCharInvalid; - if ( in == "key") out = 49; // TOASK correct ??? - else if ( in == "key") out = 10; - else if ( in == "key") out = 11; - else if ( in == "key") out = 12; - else if ( in == "key") out = 13; - else if ( in == "key") out = 14; - else if ( in == "key") out = 15; - else if ( in == "key") out = 16; - else if ( in == "key") out = 17; - else if ( in == "key") out = 18; - else if ( in == "key") out = 19; - else if ( in == "key") out = 20; - else if ( in == "key") out = 21; - else if ( in == "key") out = 24; - else if ( in == "key") out = 25; - else if ( in == "key") out = 26; - else if ( in == "key") out = 27; - else if ( in == "key") out = 28; - else if ( in == "key") out = 29; - else if ( in == "key") out = 30; - else if ( in == "key") out = 31; - else if ( in == "key") out = 32; - else if ( in == "key") out = 33; - else if ( in == "key") out = 34; - else if ( in == "key") out = 35; - - else if ( in == "key") out = 38; - else if ( in == "key") out = 39; - else if ( in == "key") out = 40; - else if ( in == "key") out = 41; - else if ( in == "key") out = 42; - else if ( in == "key") out = 43; - else if ( in == "key") out = 44; - else if ( in == "key") out = 45; - else if ( in == "key") out = 46; - else if ( in == "key") out = 47; - else if ( in == "key") out = 48; - else if ( in == "key") out = 49; - - else if ( in == "key") out = 52; - else if ( in == "key") out = 53; - else if ( in == "key") out = 54; - else if ( in == "key") out = 55; - else if ( in == "key") out = 56; - else if ( in == "key") out = 57; - else if ( in == "key") out = 58; - else if ( in == "key") out = 59; - else if ( in == "key") out = 60; - else if ( in == "key") out = 61; - else if ( in == "key") out = 51; - else if ( in == "key") out = 94; - - return out; -} -*/ v_dw_2D create_empty_2D( int dim_rows,int dim_shifts) { + v_dw_1D shifts; v_dw_2D Vector_2D; @@ -339,11 +282,12 @@ v_dw_2D create_empty_2D( int dim_rows,int dim_shifts) { } #if USE_GDK - int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { - // create a 2D vector all filled with "--" and push to 3D-Vector +int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { + + // create a 2D vector all filled with " " and push to 3D-Vector v_dw_2D Other_Vector2D = create_empty_2D(All_Vector[0].size(),All_Vector[0][0].size()); - if (Other_Vector2D.size()==0) { + if (Other_Vector2D.size() == 0) { wprintf(L"ERROR: can't create empty 2D-Vector\n"); return 1; } @@ -372,7 +316,8 @@ v_dw_2D create_empty_2D( int dim_rows,int dim_shifts) { return 0; } - bool InsertKeyvalsFromKeymap(v_dw_3D &All_Vector,GdkKeymap * keymap){ +bool InsertKeyvalsFromKeymap(v_dw_3D &All_Vector,GdkKeymap * keymap){ + // get the keyvals using GDK and copy into All_Vector for(int i =0; i< (int) All_Vector[1].size();i++) { // get key name US stored in [0][i][0] and copy to name in "other"-block[1][i][0] @@ -387,7 +332,7 @@ v_dw_2D create_empty_2D( int dim_rows,int dim_shifts) { } } - KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { +KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; guint *keyvals; gint count; @@ -469,7 +414,7 @@ KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ if ( All_Vector[k][i][0] == SC ) { wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][2],All_Vector[1][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); //KMX_DWORD returnval= All_Vector[1][i][1]; - // we could return All_Vector[0][i][1]; since win version uses us numbers here + // we could return All_Vector[0][i][1]; since win version uses US numbers here return All_Vector[1][i][1]; } } @@ -485,35 +430,6 @@ KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ return 0; //_S2 what do I return if not found?? } - - - -/*// query All_Vector -// return RETURN NON SHIFTED CHAR [1] the VirtualKey of the Other Keyboard for given Scancode -KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ - // find correct row of char in US - for( int k=0; k< (int)All_Vector.size()-1;k++) { - for( int i=0; i< (int)All_Vector[1].size()-1;i++) { - - // _S2 what if we use column 3(altgr) and 4 (shift+altgr) ?? - - // unshifted values e.g. "q" (=113) are stored in column All_Vector[1][i][ 1 ] - if ( All_Vector[k][i][0] == (SC- All_Vector[0].size() )) { - wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); - return All_Vector[1][i][1] ; - } - - // shifted values e.g. "Q" (=81) are stored in column All_Vector[1][i][ 2 ] - if ( All_Vector[k][i][0] == SC ) { - wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][2],All_Vector[1][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); - return All_Vector[1][i][2] ; - } - } - } - return 0; //_S2 what do I return if not found?? -}*/ - - // return RETURN NON SHIFTED CHAR [1] the VirtualKey of the US Keyboard for given Scancode KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ // find correct row of char in US @@ -527,7 +443,6 @@ KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ return 0; //_S2 what do I return if not found?? } - // return the Scancode of for given VirtualKey of Other Keyboard KMX_DWORD get_SC_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector){ // find correct row of char in US @@ -552,7 +467,6 @@ KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ return 0; //_S2 what do I return if not found?? } - // return the Scancode of for given VirtualKey of Other US KMX_DWORD get_position_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ // find correct row of char in US diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 8e782c36bd..3438c29fa6 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -44,88 +44,16 @@ const KMX_DWORD KMX_VKMap[] = { }; // mapping between Linux keycodes and keyman SC -const int keycode_map_old[67]={ +const int keycode_map[60]={ 0, /* */ - 0, /* */ - 0, /* */ - 0, /* */ - 0, /* */ - 0, /* */ - 0, /* */ - 0, /* */ - 0, /* */ - 0, /* */ - 2, /*10. 1 */ - 3, /*11. 2 */ - 4, /*12. 3 */ - 5, /*13. 4 */ - 6, /*14. 5 */ - 7, /*15. 6 */ - 8, /*16. 7 */ - 9, /*17. 8 */ - 10, /*18. 9 */ - 11, /*19. 0 */ - 12, /*20. MINUS */ - 13, /*21. EQUALS*/ - 14, /*22. BACKSPACE*/ - 15, /*23. TAB*/ - 16, /* 24. Q */ - 17, /* 25. W */ - 18, /* 26. E */ - 19, /* 27. R */ - 20, /* 28. T */ - 21, /* 29. Z */ - 22, /* 30. U */ - 23, /* 31. I*/ - 24, /* 32. O*/ - 25, /* 33. P*/ - 26, /*34. LEFTBRACE*/ - 27, /*35. RIGHTBRACE*/ - 28, /*36. ENTER*/ - 29, /*37. LEFTCTRL*/ - 30, /* 38. A */ - 31, /* 39. S */ - 32, /* 40. D */ - 33, /* 41. F */ - 34, /* 42. G */ - 35, /* 43. H */ - 36, /* 44. J */ - 37, /* 45. K */ - 38, /* 46. L */ - 39, /*47. SEMICOLON*/ - 40, /*48. APOSTROPHE*/ - 41, /*49. GRAVE*/ - 42, /*50. LEFTSHIFT*/ - 43, /*51. BACKSLASH*/ - 44, /*52. Z */ - 45, /*53. X */ - 46, /*54. C */ - 47, /*55. V */ - 48, /*56. B */ - 49, /*57. N */ - 50, /*58. M */ - 51, /*59. COMMA */ - 52, /*60. DOT */ - 53, /*61. SLASH */ - 54, /*62. R_SHIFT */ - 55, /*63. * */ - 56, /*64. LEFTALT*/ - 57, /*65. SPACE*/ - 58 /*66. CAPSLOCK*/ -}; - - -// mapping between Linux keycodes and keyman SC -const int keycode_map[67]={ - 0, /* */ - 10, /*10. 1 */ - 11, /*11. 2 */ - 12, /*12. 3 */ - 13, /*13. 4 */ - 14, /*14. 5 */ - 15, /*15. 6 */ - 16, /*16. 7 */ - 17, /*17. 8 */ + 10, /*10. 1 */ + 11, /*11. 2 */ + 12, /*12. 3 */ + 13, /*13. 4 */ + 14, /*14. 5 */ + 15, /*15. 6 */ + 16, /*16. 7 */ + 17, /*17. 8 */ 18, /*18. 9 */ 19, /*19. 0 */ 20, /*20. MINUS */ @@ -133,7 +61,7 @@ const int keycode_map[67]={ 22, /*22. BACKSPACE*/ 23, /*23. TAB*/ 0, /* */ - 24, /* 16.. Q */ + 24, /* 16.. Q */ 25, /* 7. W */ 26, /* 18. E */ 27, /* 19. R */ @@ -156,8 +84,8 @@ const int keycode_map[67]={ 44, /* 36. J */ 45, /* 37. K */ 46, /* 38. L */ - 47, /*39. SEMICOLON*/ - 48, /*40. APOSTROPHE*/ + 47, /*39. SEMICOLON*/ + 48, /*40. APOSTROPHE*/ 49, /*41. GRAVE*/ 50, /*42. LEFTSHIFT*/ 51, /*43. BACKSLASH*/ @@ -177,13 +105,6 @@ const int keycode_map[67]={ 65, /*57. SPACE*/ 66 , /*58. CAPSLOCK*/ 0, /* */ - 0, /* */ - 0, /* */ - 0, /* */ - 0, /* */ - 0, /* */ - 0, /* */ - 0 /* */ }; // this is what we return when we find an invalid character @@ -208,12 +129,11 @@ int split_US_To_3D_Vector(v_dw_3D &all_US, v_str_1D completeList); // replace Name of Key (e.g. ) wih Keycode ( e.g. 15 ) int replace_PosKey_with_Keycode(std::string in); - // create an empty 2D vector containing "--" in all fields v_dw_2D create_empty_2D(int dim_rows, int dim_shifts); // get Keyvals from VectorFile.txt and insert into All_Vector -bool InsertKeyvalsFromVectorFile(v_dw_3D &All_Vector); +//bool InsertKeyvalsFromVectorFile(v_dw_3D &All_Vector); // query All_Vector // return the VirtualKey of the Other Keyboard for given Scancode diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index d26b2bed8a..6a26c2c7d5 100644 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -4,8 +4,6 @@ #include -#define X_test 0xFF1234 - /* #if defined(_WIN32) || defined(_WIN64) #define snprintf _snprintf @@ -47,7 +45,7 @@ typedef char16_t KMX_WCHAR; // _S2 typedef KMX_WCHAR* PKMX_WCHAR; // _S2 typedef wchar_t* PWSTR; // _S2 needs to be removed/ wchart-> char16 typedef PWSTR PKMX_WCHART; // _S2 needs to be removed/ wchart-> char16 -typedef const wchar_t* PCKMX_WCHART; // _S2 needs to be removed/? +//typedef const wchar_t* PCKMX_WCHART; // _S2 needs to be removed/? typedef char* LPSTR; // _S2 needs to be removed? typedef LPSTR LPKMX_STR; // _S2 needs to be removed? @@ -61,6 +59,7 @@ typedef uint8_t* PKMX_BYTE; // _S2 needs to be removed? typedef char KMX_CHAR; // _S2 needs to be removed/? typedef char* PKMX_STR; // _S2 needs to be removed/? +typedef unsigned int UINT; // _S2 needs to be removed/? typedef unsigned char BYTE; // _S2 needs to be removed? typedef unsigned long DWORD; // _S2 needs to be removed/? typedef unsigned short WORD; // _S2 needs to be removed/? @@ -68,7 +67,6 @@ typedef wchar_t* LPWSTR; // _S2 needs to be removed/? typedef WCHAR* PWCHAR; // _S2 needs to be removed/? typedef KMX_CHAR* PKMX_CHAR; // _S2 needs to be removed/? -typedef unsigned int UINT; // _S2 needs to be removed/? typedef int BOOL; // _S2 needs to be removed/? or is it int32_t?? @@ -133,7 +131,7 @@ typedef KMX_UCHAR* KMX_PUCHAR; #define VK_CANCEL 0x09 #define VK_DECIMAL 0x5B*/ - +// _S2 correct?? Do I need NUMPAD?? #define VK_NUMPAD0 96 #define VK_NUMPAD1 97 #define VK_NUMPAD2 98 diff --git a/linux/mcompile/keymap/kmx_file.h b/linux/mcompile/keymap/kmx_file.h index 5187f09683..4ab43c38a8 100644 --- a/linux/mcompile/keymap/kmx_file.h +++ b/linux/mcompile/keymap/kmx_file.h @@ -308,8 +308,8 @@ struct KMX_COMP_STORE { }; struct KMX_COMP_KEY { - KMX_WORD Key; - KMX_WORD _reserved; + KMX_WORD Key; + KMX_WORD _reserved; KMX_DWORD Line; KMX_DWORD ShiftFlags; KMX_DWORD dpOutput; @@ -360,8 +360,6 @@ struct KMX_COMP_KEYBOARD_KMXPLUSINFO { /** * Only valid if comp_keyboard.dwFlags&KF_KMXPLUS */ - - struct KMX_COMP_KEYBOARD_EX { KMX_COMP_KEYBOARD header; // 0000 see COMP_KEYBOARD KMX_COMP_KEYBOARD_KMXPLUSINFO kmxplus; // 0040 see COMP_KEYBOARD_EXTRA @@ -391,4 +389,4 @@ static_assert(sizeof(KMX_COMP_KEYBOARD) == KEYBOARDFILEHEADER_SIZE, "COMP_KEYBOA } // namespace kbp } // namespace km #endif -#endif /*KMX_FILE_H*/ \ No newline at end of file +#endif /*KMX_FILE_H*/ diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 12b4b56a7f..38995b237e 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -27,16 +27,16 @@ #include "mc_kmxfile.h" enum ShiftState { - Base = 0, // 0 - Shft = 1, // 1 - Ctrl = 2, // 2 - ShftCtrl = Shft | Ctrl, // 3 - Menu = 4, // 4 -- NOT USED - ShftMenu = Shft | Menu, // 5 -- NOT USED - MenuCtrl = Menu | Ctrl, // 6 - ShftMenuCtrl = Shft | Menu | Ctrl, // 7 - Xxxx = 8, // 8 - ShftXxxx = Shft | Xxxx, // 9 + Base = 0, // 0 + Shft = 1, // 1 + Ctrl = 2, // 2 + ShftCtrl = Shft | Ctrl, // 3 + Menu = 4, // 4 -- NOT USED + ShftMenu = Shft | Menu, // 5 -- NOT USED + MenuCtrl = Menu | Ctrl, // 6 + ShftMenuCtrl = Shft | Menu | Ctrl, // 7 + Xxxx = 8, // 8 + ShftXxxx = Shft | Xxxx, // 9 }; const int KMX_ShiftStateMap[] = { @@ -49,7 +49,8 @@ const int KMX_ShiftStateMap[] = { ISVIRTUALKEY | RALTFLAG, ISVIRTUALKEY | RALTFLAG | K_SHIFTFLAG, 0, - 0}; + 0 +}; class DeadKey { private: @@ -179,7 +180,6 @@ public: this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; } - bool KMX_IsSGCAPS() { std::wstring stBase = this->KMX_GetShiftState(Base, false); std::wstring stShift = this->KMX_GetShiftState(Shft, false); @@ -547,8 +547,6 @@ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p) { return p; } - - int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { int n = 0; while(p && *p) { @@ -563,8 +561,6 @@ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { return n; } - - // _S2 has to go !! bool write_rgKey_ToFile(std::vector rgKey ){ std::string RGKey_FileName="/Projects/keyman/keyman/linux/mcompile/keymap/rgKey_lin.txt"; @@ -631,7 +627,6 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std KMX_HKL hkl = NULL; //_S2 added: but can I do this?? hkl is not needed in Linux?? - BYTE lpKeyState[256];// = new KeysEx[256]; std::vector rgKey; //= new VirtualKey[256]; std::vector alDead; @@ -779,20 +774,15 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std //} LPKMX_KEY kkp = gp->dpKeyArray; -int STOP=0; for(UINT j = 0; j < gp->cxKeyArray; j++, kkp++) { nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpContext)); nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpOutput)); } } - kp->cxGroupArray++; gp = &kp->dpGroupArray[kp->cxGroupArray-1]; -int STOP2=0; - -// _S2 need to change mapping win-lin before i can get correct values here! UINT nKeys = 0; for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { @@ -837,7 +827,7 @@ int STOP2=0; *p++ = (KMX_WCHAR)(kp->cxGroupArray); *p = 0; - // + // _S2 TODO not sure if this works OK -> we need to use more shiftstates than base+Shift // I4550 - Each place we have a nomatch > use(baselayout) (this last group), we need to add all // the AltGr and ShiftAltGr combinations as rules to allow them to be matched as well. Yes, this // loop is not very efficient but it's not worthy of optimisation. @@ -865,7 +855,7 @@ int STOP2=0; } } - // + // _S2 TODO not sure if this works OK -> we need to use deadkeys... // If we have deadkeys, then add a new group to translate the deadkeys per the deadkey tables // We only do this if not in deadkey conversion mode // diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 5b6231f259..6f4ebe88af 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -76,7 +76,6 @@ KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL if( fgp->dpNoMatch ) size += u16len(fgp->dpNoMatch)*2 + 2; } - for(i = 0; i < fk->cxStoreArray; i++) { size += u16len(fk->dpStoreArray[i].dpString)*2 + 2; @@ -226,6 +225,7 @@ PKMX_WCHAR KMX_StringOffset(PKMX_BYTE base, KMX_DWORD offset) { } #ifdef KMX_64BIT + /** CopyKeyboard will copy the data read into bufp from x86-sized structures into x64-sized structures starting at `base` diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index e2e09c484f..9d5aaaddef 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -9,8 +9,6 @@ #include // _S2 can be removed later -//+++++++++++++++++++++++++++++++++++ - #ifndef _KMXFILE_H #define _KMXFILE_H @@ -31,7 +29,6 @@ typedef struct KMX_tagKEY { } KMX_KEY, *LPKMX_KEY; - typedef struct KMX_tagGROUP { KMX_WCHAR* dpName; LPKMX_KEY dpKeyArray; // [LPKEY] address of first item in key array @@ -42,7 +39,6 @@ typedef struct KMX_tagGROUP { } KMX_GROUP, *LPKMX_GROUP; - typedef struct KMX_tagKEYBOARD { KMX_DWORD dwIdentifier; // Keyman compiled keyboard id @@ -76,9 +72,11 @@ typedef struct KMX_tagKEYBOARD { //HBITMAP hBitmap; // handle to the bitmap in the file; } KMX_KEYBOARD, *LPKMX_KEYBOARD; -KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? + +KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD *lpKeyboard); KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, PKMX_WCHAR filename); + KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL FSaveDebug); #endif diff --git a/linux/mcompile/keymap/mc_savekeyboard.cpp b/linux/mcompile/keymap/mc_savekeyboard.cpp index e69de29bb2..571e919f89 100644 --- a/linux/mcompile/keymap/mc_savekeyboard.cpp +++ b/linux/mcompile/keymap/mc_savekeyboard.cpp @@ -0,0 +1,2 @@ + +// moved to mc_kmxfile.cpp/.h diff --git a/linux/mcompile/keymap/mc_savekeyboard.h b/linux/mcompile/keymap/mc_savekeyboard.h index 0907dcff5d..71f2e43749 100644 --- a/linux/mcompile/keymap/mc_savekeyboard.h +++ b/linux/mcompile/keymap/mc_savekeyboard.h @@ -6,4 +6,4 @@ #define CERR_None 0x00000000 #define CERR_CannotAllocateMemory 0x00008004 #define CERR_UnableToWriteFully 0x00008007 -#define CERR_SomewhereIGotItWrong 0x00008009 \ No newline at end of file +#define CERR_SomewhereIGotItWrong 0x00008009 diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 5eadab21b4..be3771f7a7 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -107,7 +107,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ return 1; } -//-_S2 -------u option will be done later---------------------- +//-_S2 -------u option will be done later DFo we need it?? ---------------------- /* if(wcscmp(argv[1], L"-u") == 0) { // I4273 wchar_t *infile = argv[2], *outfile = argv[3]; @@ -245,15 +245,19 @@ KMX_WORD KMX_VKUnderlyingLayoutToVKUS(KMX_WORD VKey) { return VKey; } - // takes cpital character of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] KMX_DWORD KMX_CharFromVK(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey){ KMX_UINT VKShiftState_lin; - if (VKShiftState == 0 ) VKShiftState_lin =0; - if (VKShiftState == 16) VKShiftState_lin =1; - if (VKShiftState == 9 ) VKShiftState_lin =2; - if (VKShiftState == 25) VKShiftState_lin =3; + + /* 0000 0000 */ + if (VKShiftState == 0 ) VKShiftState_lin = 0; + /* 0001 0000 */ + if (VKShiftState == 16) VKShiftState_lin = 1; + /* 0000 1001 */ + if (VKShiftState == 9 ) VKShiftState_lin = 2; + /* 0001 1001 */ + if (VKShiftState == 25) VKShiftState_lin = 3; // loop and find vkUnderlying in Other; then return char with correct shiftstate for( int i=0; i< (int)All_Vector[1].size();i++) { @@ -368,7 +372,6 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon // Loop through each possible key on the keyboard for (int i = 0;KMX_VKMap[i]; i++) { // I4651 - // _S2 why were those 2 functions originally not done in 1 step ?? KMX_DWORD vkUnderlying = KMX_VKUSToVKUnderlyingLayout(All_Vector,(int) KMX_VKMap[i] ); KMX_WCHAR ch = KMX_CharFromVK(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey); @@ -410,7 +413,6 @@ wprintf(L"\n##### KMX_ReportUnconvertedKeyboardRules of mcompile will start #### if(!KMX_ImportRules(kbid, kbd, All_Vector, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 return FALSE; } -/**/ wprintf(L"\n##### KMX_DoConvert of mcompile ended #####\n"); return TRUE; diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index b4edd3c0bc..b8c7780a87 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -28,7 +28,9 @@ #include "mc_kmxfile.h" int run(int argc, std::vector str_argv, char* argv[]); + void KMX_LogError(const KMX_WCHART* m1, int m2 = 0); + //void KMX_LogError(const KMX_WCHART* m1, int m2 = 0, LPKMX_KEY key =NULL); struct KMX_DeadkeyMapping { // I4353 From 41cc7180b7096de24b917eb5143830a8208016c2 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 4 Oct 2023 18:48:03 +0200 Subject: [PATCH 101/327] feat(linux): mcompile more tidy up --- linux/mcompile/keymap/helpers.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index b9540a18a0..944b52ea80 100644 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -182,8 +182,6 @@ bool CompareVector_To_VectorOfFile(v_dw_3D All_Vector,v_dw_3D File_Vector){ } return true; - wprintf(L" #### CompareVector_To_VectorOfFile ended \n"); //_S2 kommt hier nie hin - return false; //_S2 kommt hier nie hin } bool CompareVector_To_VectorOfFile_RGKEY(v_dw_2D Win_Vector,v_dw_2D Lin_Vector, v_dw_2D Map_Vector){ From 0256c98434874a1bf4c290b668d602e982658c14 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 5 Oct 2023 17:16:11 +0200 Subject: [PATCH 102/327] feat(linux): mcompile fill rgkey: numbers and A-Z are filled OK --- linux/mcompile/keymap/README.md | 6 +- linux/mcompile/keymap/keymap.cpp | 129 ++++++++++++++++++++-- linux/mcompile/keymap/keymap.h | 11 +- linux/mcompile/keymap/mc_import_rules.cpp | 29 ++++- 4 files changed, 152 insertions(+), 23 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index 89cea81ad1..781f88de97 100644 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -18,7 +18,6 @@ TODO check if I can use files from some other keyman path instead of a copy in k TODO remove kbdid and kbd for Linux TODO shiftstate-count TODO keymap SplitToV.cpp exchange 4 with genaerated shiftcount -TODO check if part with surplus is neccessary TODO shift-statevector TODO Do I need HKL for Linux / can I just use a void* or remove HKL ?? TODO typeddef of KMX_HKL - can I delete all m_hkl from classes? @@ -39,12 +38,9 @@ TODO next: - see in which files I can put some functions (e.g. incxstr) that were duplicated or even #include their original location - remove testing functions - remove USE_GDK + - what is wrong with kp->dpBitmapOffset/BitmapSize ? TODO ... -//--------------------------- -TOASK is using string OK, or do we use char, wchar? -TOASK a-z, A_Z or more keys? ... -TOASK ado we need mcompile -u option? ./mcompile -d /Projects/keyman/keyman/linux/mcompile/keymap/mcompile_test.kmx bla.dll 0407 /Projects/keyman/keyman/linux/mcompile/keymap/mcompile_test_out.kmx diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index c6fb6c6f8b..0df4b2b382 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -168,7 +168,7 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { for (std::string each; std::getline(split1, each, split_bracel); tokens.push_back(each)); // replace keys names with Keycode ( with 21,...) - Keycde = replace_PosKey_with_Keycode(tokens[0]); + Keycde = replace_PosKey_with_Keycode_use_Lin(tokens[0]); tokens[0] = std::to_string(Keycde); // seperate rest of the vector to its elements and push to 'tokens' @@ -265,6 +265,67 @@ int replace_PosKey_with_Keycode(std::string in) { return out; } +int replace_PosKey_with_Keycode_use_Lin(std::string in) { + int out = returnIfCharInvalid; + +// _S2 these are the Scancode-Values we use in Keyman ( = like the windows scancodes) + + if ( in == "key") out = 49; /* 0X VK_ */ // TOASK correct ??? + else if ( in == "key") out = 10; /* 0X02 VK_1 */ + else if ( in == "key") out = 11; /* 0X03 VK_2 */ + else if ( in == "key") out = 12; /* 0X04 VK_3 */ + else if ( in == "key") out = 13; /* 0X05 VK_4 */ + else if ( in == "key") out = 14; /* 0X06 VK_5 */ + else if ( in == "key") out = 15; /* 0X07 VK_6 */ + else if ( in == "key") out = 16; /* 0X08 VK_7 */ + else if ( in == "key") out = 17; /* 0X09 VK_8 */ + else if ( in == "key") out = 18; /* 0X0A VK_9 */ + else if ( in == "key") out = 19; /* 0X0B VK_0 */ + else if ( in == "key") out = 20; /* 0X0C VK_MINUS */ + else if ( in == "key") out = 21; /* 0X0D VK_EQUALS */ + + else if ( in == "key") out = 24; /* 0X10 VK_Q */ + else if ( in == "key") out = 25; /* 0X11 VK_W */ + else if ( in == "key") out = 26; /* 0X12 VK_E */ + else if ( in == "key") out = 27; /* 0X13 VK_R */ + else if ( in == "key") out = 28; /* 0X14 VK_T */ + else if ( in == "key") out = 29; /* 0X15 VK_Y */ + else if ( in == "key") out = 30; /* 0X16 VK_U */ + else if ( in == "key") out = 31; /* 0X17 VK_I */ + else if ( in == "key") out = 32; /* 0X18 VK_O */ + else if ( in == "key") out = 33; /* 0X19 VK_P */ + else if ( in == "key") out = 34; /* 0X1A VK_LEFTBRACE */ + else if ( in == "key") out = 35; /* 0X1B VK_RIGHTBRACE */ + + else if ( in == "key") out = 38; /* 0X1E VK_A */ + else if ( in == "key") out = 39; /* 0X1F VK_S */ + else if ( in == "key") out = 40; /* 0X20 VK_D */ + else if ( in == "key") out = 41; /* 0X21 VK_F */ + else if ( in == "key") out = 42; /* 0X22 VK_G */ + else if ( in == "key") out = 43; /* 0X23 VK_H */ + else if ( in == "key") out = 44; /* 0X24 VK_J */ + else if ( in == "key") out = 45; /* 0X25 VK_K */ + else if ( in == "key") out = 46; /* 0X26 VK_L */ + else if ( in == "key") out = 47; /* 0X27 VK_SEMICOLON */ + else if ( in == "key") out = 48; /* 0X28 VK_APOSTROPHE */ + else if ( in == "key") out = 49; /* 0X29 VK_GRAVE */ + + else if ( in == "key") out = 52; /* 0X2C VK_Z */ + else if ( in == "key") out = 53; /* 0X2D VK_X */ + else if ( in == "key") out = 54; /* 0X2E VK_C */ + else if ( in == "key") out = 55; /* 0X2F VK_V */ + else if ( in == "key") out = 56; /* 0X30 VK_B */ + else if ( in == "key") out = 57; /* 0X31 VK_N */ + else if ( in == "key") out = 58; /* 0X32 VK_M */ + else if ( in == "key") out = 59; /* 0X33 VK_ COMMA */ + else if ( in == "key") out = 60; /* 0X34 VK_DOT */ + else if ( in == "key") out = 61; /* 0X35 VK_SLASH */ + else if ( in == "key") out = 62; /* 0X36 VK_RIGHTSHIFT */ + else if ( in == "key") out = 63; /* 0X37 VK_RIGHTSHIFT */ + + return out; +} + v_dw_2D create_empty_2D( int dim_rows,int dim_shifts) { @@ -282,8 +343,13 @@ v_dw_2D create_empty_2D( int dim_rows,int dim_shifts) { } #if USE_GDK +KMX_DWORD writeKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos); int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { + + + writeKeyvalsFromKeymap(keymap,1, 0); + // create a 2D vector all filled with " " and push to 3D-Vector v_dw_2D Other_Vector2D = create_empty_2D(All_Vector[0].size(),All_Vector[0][0].size()); @@ -305,13 +371,35 @@ int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { // get key name US stored in [0][i][0] and copy to name in "other"-block[1][i][0] All_Vector[1][i][0] = All_Vector[0][i][0]; - +/* // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] All_Vector[1][i][0+1] = getKeyvalsFromKeymap(keymap,keycode_map[All_Vector[0][i][0]],0); //shift state: unshifted:0 All_Vector[1][i][1+1] = getKeyvalsFromKeymap(keymap,keycode_map[All_Vector[0][i][0]],1); //shift state: shifted:1 - wprintf(L" Keycodes US dw : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); - wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); +KMX_DWORD inValue = All_Vector[0][i][0]; +KMX_DWORD KeycodeMapped_inValue = keycode_map[All_Vector[0][i][0]]; +KMX_DWORD resultOf_GETKEYVALS = getKeyvalsFromKeymap(keymap,keycode_map[All_Vector[0][i][0]],0); +KMX_DWORD resultOf_GETKEYVALS_shift = getKeyvalsFromKeymap(keymap,keycode_map[All_Vector[0][i][0]],1); + +wprintf(L" inValue: %i -KeycodeMapped_inValue: %i, resultOf_GETKEYVALS: %i , resultOf_GETKEYVALS_shift: %i : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",inValue,KeycodeMapped_inValue,resultOf_GETKEYVALS,resultOf_GETKEYVALS_shift,(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); +*/ + // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] + All_Vector[1][i][0+1] = getKeyvalsFromKeymap(keymap,All_Vector[0][i][0],0); //shift state: unshifted:0 + All_Vector[1][i][1+1] = getKeyvalsFromKeymap(keymap,All_Vector[0][i][0],1); //shift state: shifted:1 + +KMX_DWORD inValue = All_Vector[0][i][0]; +KMX_DWORD KeycodeMapped_inValue = All_Vector[0][i][0]; +KMX_DWORD resultOf_GETKEYVALS = getKeyvalsFromKeymap(keymap,All_Vector[0][i][0],0); +KMX_DWORD resultOf_GETKEYVALS_shift = getKeyvalsFromKeymap(keymap,All_Vector[0][i][0],1); + +wprintf(L" inValue: %i -KeycodeMapped_inValue: %i, resultOf_GETKEYVALS: %i , resultOf_GETKEYVALS_shift: %i : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",inValue,KeycodeMapped_inValue,resultOf_GETKEYVALS,resultOf_GETKEYVALS_shift,(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); + + + + + //wprintf(L" Keycodes US dw : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); + //wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); + int enxdfghj=9; } return 0; } @@ -332,6 +420,21 @@ bool InsertKeyvalsFromKeymap(v_dw_3D &All_Vector,GdkKeymap * keymap){ } } +// _S2 can go later +KMX_DWORD writeKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { + GdkKeymapKey *maps; + guint *keyvals; + gint count; + KMX_DWORD out; + for ( int ii =1; ii< 255;ii++) { + + KMX_DWORD out = getKeyvalsFromKeymap(keymap,ii,0); + KMX_DWORD out2= getKeyvalsFromKeymap(keymap,ii,1); + wprintf(L" ii = %i --> keymap = %i (%c)..%i(%c) \n",ii, out,out, out2,out2); + } + +} + KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; guint *keyvals; @@ -409,22 +512,24 @@ KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ // _S2 what if we use column 3(altgr) and 4 (shift+altgr) ?? - if( SC < 12) { + if( SC < 20) { // values for numbers are stored in column All_Vector[1][i][ 1 ] if ( All_Vector[k][i][0] == SC ) { - wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][2],All_Vector[1][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); - //KMX_DWORD returnval= All_Vector[1][i][1]; + wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[k][i][2],All_Vector[k][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); + KMX_DWORD returnval= All_Vector[k][i][1]; // we could return All_Vector[0][i][1]; since win version uses US numbers here - return All_Vector[1][i][1]; + return All_Vector[k][i][1]; } } - + else { // shifted values e.g. "Q" (=81) are stored in column All_Vector[1][i][ 2 ] - else if ( All_Vector[k][i][0] == SC ) { + if ( All_Vector[k][i][0] == SC ) { wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][2],All_Vector[1][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); - //KMX_DWORD returnval= All_Vector[1][i][2]; + KMX_DWORD returnval= All_Vector[1][i][2]; return All_Vector[1][i][2]; } + } +//hier All_Vector[1][i][1]; ergibt , und . aber kleinbuchstaben ode ; und : aber grossbuchstaben } } return 0; //_S2 what do I return if not found?? @@ -467,11 +572,13 @@ KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ return 0; //_S2 what do I return if not found?? } +// ToDo write 2 func for return pos of Key_US and Pos of Key_Other // return the Scancode of for given VirtualKey of Other US KMX_DWORD get_position_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ // find correct row of char in US for( int i=0; i< (int)All_Vector[0].size()-1;i++) { if ( ( All_Vector[0][i][1] == VK_US ) || ( All_Vector[0][i][2] == VK_US )) { + //if ( ( All_Vector[0][i][1] == VK_US ) ) { wprintf(L" VK_US= %i .. i= %i .. %i\t\t %i (%c) : %i (%c) +++ %i\t\t %i (%c) : %i (%c) \n",VK_US , i, All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2], All_Vector[1][i][0] , All_Vector[1][i][1] ,All_Vector[1][i][1] , All_Vector[1][i][2] , All_Vector[1][i][2] ); diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 3438c29fa6..8c7b1ed02a 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -34,12 +34,12 @@ const KMX_DWORD KMX_VKMap[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', //_S2 those might not work correctly yet*/ - /*VK_SPACE, + VK_SPACE, VK_ACCENT, VK_HYPHEN, VK_EQUAL, VK_LBRKT, VK_RBRKT, VK_BKSLASH, VK_COLON, VK_QUOTE, VK_COMMA, VK_PERIOD, VK_SLASH, - VK_xDF, VK_OEM_102,*/ + VK_xDF, VK_OEM_102,/**/ 0 }; @@ -61,8 +61,8 @@ const int keycode_map[60]={ 22, /*22. BACKSPACE*/ 23, /*23. TAB*/ 0, /* */ - 24, /* 16.. Q */ - 25, /* 7. W */ + 24, /* 16. Q */ + 25, /* 17. W */ 26, /* 18. E */ 27, /* 19. R */ 28, /* 20. T */ @@ -126,8 +126,9 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE *fpp, const char *text, // 2nd step: write contents to 3D vector int split_US_To_3D_Vector(v_dw_3D &all_US, v_str_1D completeList); -// replace Name of Key (e.g. ) wih Keycode ( e.g. 15 ) +// replace Name of Key (e.g. ) wih Keycode ( e.g. 0x15 ) int replace_PosKey_with_Keycode(std::string in); +int replace_PosKey_with_Keycode_use_Lin(std::string in); // create an empty 2D vector containing "--" in all fields v_dw_2D create_empty_2D(int dim_rows, int dim_shifts); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 38995b237e..f80a5dbf20 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -602,6 +602,30 @@ std::wstring get_VirtualKey_US_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &c return L""; } +// _S2 where to put this?? +std::wstring get_VirtualKey_Other_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &caps, v_dw_3D &All_Vector) { + + int icaps; + KMX_DWORD pos = get_position_From_VirtualKey_US(iKey, All_Vector); + + if (ss >9) + return L""; + + if( ss < All_Vector[1][pos].size()-1) { + //if( ss < All_Vector[1][pos].size()-1) { // _S2 numbers need this + + if ( ss % 2 == 0) + icaps = ss+2-caps; + + if ( ss % 2 == 1) + icaps = ss+caps; + + return std::wstring(1, (int) All_Vector[1][pos][icaps]); + //return std::wstring(1, (int) All_Vector[1][pos][icaps]); + } + return L""; +} + bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 wprintf(L"\n ##### KMX_ImportRules of mc_import_rules started #####\n"); KMX_Loader loader; @@ -702,11 +726,12 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std //_S2 TODO //_S2 get char - do I need rc ?? ( was rc = ToUnicodeEx...) std::wstring VK_US = get_VirtualKey_US_from_iKey(iKey, ss, caps, All_Vector); + std::wstring VK_Other = get_VirtualKey_Other_from_iKey(iKey, ss, caps, All_Vector); //_S2 TODO //do I need that ?? //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { - if(VK_US == L"") { + if(VK_Other == L"") { rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); } @@ -720,7 +745,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std //_S2 TODO // fill m_rgss and m_rgfDeadkey ( m_rgfDeadkey will be done later) - rgKey[iKey]->KMX_SetShiftState(ss, VK_US, false, (caps == 0)); + rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps == 0)); //} // from rc==1 // } // from rc > 0 From 2ead73ba11dec06f4593db90ab4f50843820e652 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 12 Oct 2023 21:29:46 +0200 Subject: [PATCH 103/327] feat(linux): mcompile fill rgkey OEM-Keys --- linux/mcompile/keymap/helpers.cpp | 105 +++++++++++ linux/mcompile/keymap/helpers.h | 4 + linux/mcompile/keymap/keymap.cpp | 201 +++++++++++----------- linux/mcompile/keymap/keymap.h | 86 ++++++++- linux/mcompile/keymap/mc_import_rules.cpp | 82 +++++---- 5 files changed, 349 insertions(+), 129 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 944b52ea80..c15628000d 100644 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -359,3 +359,108 @@ bool test_In_Out(v_dw_3D All_Vector){ } } } + +// ToDo write 2 func for return pos of Key_US and Pos of Key_Other +// return the Scancode of for given VirtualKey of Other US +KMX_DWORD get_position_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ + // find correct row of char in US + for( int i=0; i< (int)All_Vector[0].size()-1;i++) { + if ( ( All_Vector[0][i][1] == VK_US ) || ( All_Vector[0][i][2] == VK_US )) { + //if ( ( All_Vector[0][i][1] == VK_US ) ) { + //wprintf(L" VK_US= %i .. i= %i .. %i\t\t %i (%c) : %i (%c) +++ %i\t\t %i (%c) : %i (%c) \n",VK_US , i, + // All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2], + //All_Vector[1][i][0] , All_Vector[1][i][1] ,All_Vector[1][i][1] , All_Vector[1][i][2] , All_Vector[1][i][2] ); + return i; + } + } + return 0; //_S2 what do I return if not found?? +} + +/* +// _S2 where to put this?? +std::wstring get_VirtualKey_US_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &caps, v_dw_3D &All_Vector) { + + int icaps; + KMX_DWORD pos = get_position_From_VirtualKey_US(iKey, All_Vector); + + if (ss >9) + return L""; + + if( ss < All_Vector[0][pos].size()-1) { + //if( ss < All_Vector[1][pos].size()-1) { // _S2 numbers need this + + if ( ss % 2 == 0) + icaps = ss+2-caps; + + if ( ss % 2 == 1) + icaps = ss+caps; + + return std::wstring(1, (int) All_Vector[0][pos][icaps]); + //return std::wstring(1, (int) All_Vector[1][pos][icaps]); + } + return L""; +} +*/ + + +int replace_PosKey_with_Keycode(std::string in) { + int out = returnIfCharInvalid; + +// _S2 these are the Scancode-Values we use in Keyman ( = like the windows scancodes) + + if ( in == "key") out = 49; /* 0X VK_ */ // TOASK correct ??? + else if ( in == "key") out = 1; /* 0X02 VK_1 */ + else if ( in == "key") out = 2; /* 0X03 VK_2 */ + else if ( in == "key") out = 3; /* 0X04 VK_3 */ + else if ( in == "key") out = 4; /* 0X05 VK_4 */ + else if ( in == "key") out = 5; /* 0X06 VK_5 */ + else if ( in == "key") out = 6; /* 0X07 VK_6 */ + else if ( in == "key") out = 7; /* 0X08 VK_7 */ + else if ( in == "key") out = 8; /* 0X09 VK_8 */ + else if ( in == "key") out = 9; /* 0X0A VK_9 */ + else if ( in == "key") out = 10; /* 0X0B VK_0 */ + else if ( in == "key") out = 12; /* 0X0C VK_MINUS */ + else if ( in == "key") out = 13; /* 0X0D VK_EQUALS */ + + else if ( in == "key") out = 16; /* 0X10 VK_Q */ + else if ( in == "key") out = 17; /* 0X11 VK_W */ + else if ( in == "key") out = 18; /* 0X12 VK_E */ + else if ( in == "key") out = 19; /* 0X13 VK_R */ + else if ( in == "key") out = 20; /* 0X14 VK_T */ + else if ( in == "key") out = 21; /* 0X15 VK_Y */ + else if ( in == "key") out = 22; /* 0X16 VK_U */ + else if ( in == "key") out = 23; /* 0X17 VK_I */ + else if ( in == "key") out = 24; /* 0X18 VK_O */ + else if ( in == "key") out = 25; /* 0X19 VK_P */ + else if ( in == "key") out = 26; /* 0X1A VK_LEFTBRACE */ + else if ( in == "key") out = 27; /* 0X1B VK_RIGHTBRACE */ + + else if ( in == "key") out = 30; /* 0X1E VK_A */ + else if ( in == "key") out = 31; /* 0X1F VK_S */ + else if ( in == "key") out = 32; /* 0X20 VK_D */ + else if ( in == "key") out = 33; /* 0X21 VK_F */ + else if ( in == "key") out = 34; /* 0X22 VK_G */ + else if ( in == "key") out = 35; /* 0X23 VK_H */ + else if ( in == "key") out = 36; /* 0X24 VK_J */ + else if ( in == "key") out = 37; /* 0X25 VK_K */ + else if ( in == "key") out = 38; /* 0X26 VK_L */ + else if ( in == "key") out = 39; /* 0X27 VK_SEMICOLON */ + else if ( in == "key") out = 40; /* 0X28 VK_APOSTROPHE */ + else if ( in == "key") out = 41; /* 0X29 VK_GRAVE */ + + else if ( in == "key") out = 44; /* 0X2C VK_Z */ + else if ( in == "key") out = 45; /* 0X2D VK_X */ + else if ( in == "key") out = 46; /* 0X2E VK_C */ + else if ( in == "key") out = 47; /* 0X2F VK_V */ + else if ( in == "key") out = 48; /* 0X30 VK_B */ + else if ( in == "key") out = 49; /* 0X31 VK_N */ + else if ( in == "key") out = 50; /* 0X32 VK_M */ + else if ( in == "key") out = 51; /* 0X33 VK_ COMMA */ + else if ( in == "key") out = 52; /* 0X34 VK_DOT */ + else if ( in == "key") out = 53; /* 0X35 VK_SLASH */ + else if ( in == "key") out = 54; /* 0X36 VK_RIGHTSHIFT */ + else if ( in == "key") out = 55; /* 0X37 VK_RIGHTSHIFT */ + else if ( in == "key") out = 65; /* 0X20 VK_SPACE */ + + return out; +} diff --git a/linux/mcompile/keymap/helpers.h b/linux/mcompile/keymap/helpers.h index 60d0b150ba..69b3f228b1 100644 --- a/linux/mcompile/keymap/helpers.h +++ b/linux/mcompile/keymap/helpers.h @@ -35,5 +35,9 @@ bool test_In_Out(v_dw_3D All_Vector); // to check if content of Vector is ok bool write_RGKEY_FileToVector(v_dw_2D& shift_states, const char* infile) ; bool CompareVector_To_VectorOfFile_RGKEY(v_dw_2D Win_Vector,v_dw_2D Lin_Vector, v_dw_2D Map_Vector); +KMX_DWORD get_position_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector); +int replace_PosKey_with_Keycode(std::string in); + +//std::wstring get_VirtualKey_US_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &caps, v_dw_3D &All_Vector); #endif /* HELPERS_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 0df4b2b382..44b3ed3ed2 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -1,5 +1,7 @@ #include "keymap.h" +#include + /* static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) { @@ -9,13 +11,14 @@ static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return; - +// group0 D, group1 fr, group2, group3 US, for (int i = 0; i < count; i++) { - if (maps[i].level > 0 || maps[i].group > 1) - continue; - printf(" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); + //if (maps[i].level > 0 || maps[i].group > 1) + // continue; + wprintf(L" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", + i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); } - + //xkb_keymap_key_get_syms_by_level(keymap, keycode, ) g_free(keyvals); g_free(maps); } @@ -85,6 +88,8 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, } } } + complete_List.push_back(" key { [ space, space] };"); + complete_List.push_back(" key { [ backslash, bar ] };"); if (complete_List.size() <1) { wprintf(L"ERROR: can't create row from US \n"); @@ -97,12 +102,25 @@ KMX_DWORD convertNamesToValue(std::wstring tok_wstr){ std::map first; //initializing + //first[L"grave"] 96 = /*FE50; ???*/; + //first[L"apostrophe"] = /*27;*/; + //first[L"braceleft"] = /*7B;*/; + //first[L"braceright"] = /*7D ;*/; + first[L"underscore"] = 95 /*5F;*/; + first[L"plus"] = 43 /*2B;*/; + first[L"semicolon"] = 59/*3B;*/; + first[L"quotedbl"] = 34 /*22;*/; + first[L"less"] = 60/* 3C;*/; + first[L"greater"] = 62 /*3E ;*/; + first[L"question"] = 63 /*3F*/; + first[L"bar"] = 124 /*7C*/; + first[L"exclam"] = 33; first[L"at"] = 64; first[L"numbersign"] = 35; first[L"dollar"] = 36; first[L"percent"] = 37; - first[L"dead_circumflex"] = 94; /* _S2 ??? */ + first[L"dead_circumflex"] = 94; /* _S2 ??? 0XFE52 */ first[L"ampersand"] = 38; first[L"asterisk"] = 42; first[L"parenleft"] = 40; @@ -118,9 +136,10 @@ KMX_DWORD convertNamesToValue(std::wstring tok_wstr){ first[L"slash"] = VK_SLASH; /* BF = 191 */ first[L"ssharp"] = VK_xDF; /* DF = 223 ß */ first[L"minus"] = VK_HYPHEN; /* BD = 189 ? */ - first[L"dead_acute"] = VK_ACCENT; /* C0 = 192 ? */ + //first[L"dead_acute"] = VK_ACCENT; /* C0 = 192 ? */ + first[L"dead_grave"] = VK_ACCENT; /* C0 = 192 ? */ first[L"space"] = VK_SPACE; /* 20 = 32 ? */ - + // _S2 ?? VK_QUOTE, VK_OEM_102, if ( tok_wstr.size() == 1) { @@ -153,7 +172,7 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { std::wstring tok_wstr; // loop through the whole vector - for (int k = 0; k < (int)completeList.size() - 1; k++) { + for (int k = 0; k < (int)completeList.size() ; k++) { // remove all unwanted char for (int i = 0; i < (int) delim.size(); i++) { @@ -203,72 +222,11 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { } return 0; } - -int replace_PosKey_with_Keycode(std::string in) { - int out = returnIfCharInvalid; - -// _S2 these are the Scancode-Values we use in Keyman ( = like the windows scancodes) - - if ( in == "key") out = 49; /* 0X VK_ */ // TOASK correct ??? - else if ( in == "key") out = 1; /* 0X02 VK_1 */ - else if ( in == "key") out = 2; /* 0X03 VK_2 */ - else if ( in == "key") out = 3; /* 0X04 VK_3 */ - else if ( in == "key") out = 4; /* 0X05 VK_4 */ - else if ( in == "key") out = 5; /* 0X06 VK_5 */ - else if ( in == "key") out = 6; /* 0X07 VK_6 */ - else if ( in == "key") out = 7; /* 0X08 VK_7 */ - else if ( in == "key") out = 8; /* 0X09 VK_8 */ - else if ( in == "key") out = 9; /* 0X0A VK_9 */ - else if ( in == "key") out = 10; /* 0X0B VK_0 */ - else if ( in == "key") out = 12; /* 0X0C VK_MINUS */ - else if ( in == "key") out = 13; /* 0X0D VK_EQUALS */ - - else if ( in == "key") out = 16; /* 0X10 VK_Q */ - else if ( in == "key") out = 17; /* 0X11 VK_W */ - else if ( in == "key") out = 18; /* 0X12 VK_E */ - else if ( in == "key") out = 19; /* 0X13 VK_R */ - else if ( in == "key") out = 20; /* 0X14 VK_T */ - else if ( in == "key") out = 21; /* 0X15 VK_Y */ - else if ( in == "key") out = 22; /* 0X16 VK_U */ - else if ( in == "key") out = 23; /* 0X17 VK_I */ - else if ( in == "key") out = 24; /* 0X18 VK_O */ - else if ( in == "key") out = 25; /* 0X19 VK_P */ - else if ( in == "key") out = 26; /* 0X1A VK_LEFTBRACE */ - else if ( in == "key") out = 27; /* 0X1B VK_RIGHTBRACE */ - - else if ( in == "key") out = 30; /* 0X1E VK_A */ - else if ( in == "key") out = 31; /* 0X1F VK_S */ - else if ( in == "key") out = 32; /* 0X20 VK_D */ - else if ( in == "key") out = 33; /* 0X21 VK_F */ - else if ( in == "key") out = 34; /* 0X22 VK_G */ - else if ( in == "key") out = 35; /* 0X23 VK_H */ - else if ( in == "key") out = 36; /* 0X24 VK_J */ - else if ( in == "key") out = 37; /* 0X25 VK_K */ - else if ( in == "key") out = 38; /* 0X26 VK_L */ - else if ( in == "key") out = 39; /* 0X27 VK_SEMICOLON */ - else if ( in == "key") out = 40; /* 0X28 VK_APOSTROPHE */ - else if ( in == "key") out = 41; /* 0X29 VK_GRAVE */ - - else if ( in == "key") out = 44; /* 0X2C VK_Z */ - else if ( in == "key") out = 45; /* 0X2D VK_X */ - else if ( in == "key") out = 46; /* 0X2E VK_C */ - else if ( in == "key") out = 47; /* 0X2F VK_V */ - else if ( in == "key") out = 48; /* 0X30 VK_B */ - else if ( in == "key") out = 49; /* 0X31 VK_N */ - else if ( in == "key") out = 50; /* 0X32 VK_M */ - else if ( in == "key") out = 51; /* 0X33 VK_ COMMA */ - else if ( in == "key") out = 52; /* 0X34 VK_DOT */ - else if ( in == "key") out = 53; /* 0X35 VK_SLASH */ - else if ( in == "key") out = 54; /* 0X36 VK_RIGHTSHIFT */ - else if ( in == "key") out = 55; /* 0X37 VK_RIGHTSHIFT */ - - return out; -} - int replace_PosKey_with_Keycode_use_Lin(std::string in) { int out = returnIfCharInvalid; // _S2 these are the Scancode-Values we use in Keyman ( = like the windows scancodes) + // NAME IN SYMBOLS-FILE KEYCODE (LIN STYLE) (WIN STYLE) VK_US VK_DE if ( in == "key") out = 49; /* 0X VK_ */ // TOASK correct ??? else if ( in == "key") out = 10; /* 0X02 VK_1 */ @@ -281,8 +239,8 @@ int replace_PosKey_with_Keycode_use_Lin(std::string in) { else if ( in == "key") out = 17; /* 0X09 VK_8 */ else if ( in == "key") out = 18; /* 0X0A VK_9 */ else if ( in == "key") out = 19; /* 0X0B VK_0 */ - else if ( in == "key") out = 20; /* 0X0C VK_MINUS */ - else if ( in == "key") out = 21; /* 0X0D VK_EQUALS */ + else if ( in == "key") out = 20; /* 0X0C VK_MINUS de ẞ*/ + else if ( in == "key") out = 21; /* 0X0D VK_EQUALS DE ' */ else if ( in == "key") out = 24; /* 0X10 VK_Q */ else if ( in == "key") out = 25; /* 0X11 VK_W */ @@ -294,8 +252,8 @@ int replace_PosKey_with_Keycode_use_Lin(std::string in) { else if ( in == "key") out = 31; /* 0X17 VK_I */ else if ( in == "key") out = 32; /* 0X18 VK_O */ else if ( in == "key") out = 33; /* 0X19 VK_P */ - else if ( in == "key") out = 34; /* 0X1A VK_LEFTBRACE */ - else if ( in == "key") out = 35; /* 0X1B VK_RIGHTBRACE */ + else if ( in == "key") out = 34; /* 0X1A VK_LEFTBRACE DE Ü */ + else if ( in == "key") out = 35; /* 0X1B VK_RIGHTBRACE DE + */ else if ( in == "key") out = 38; /* 0X1E VK_A */ else if ( in == "key") out = 39; /* 0X1F VK_S */ @@ -306,9 +264,9 @@ int replace_PosKey_with_Keycode_use_Lin(std::string in) { else if ( in == "key") out = 44; /* 0X24 VK_J */ else if ( in == "key") out = 45; /* 0X25 VK_K */ else if ( in == "key") out = 46; /* 0X26 VK_L */ - else if ( in == "key") out = 47; /* 0X27 VK_SEMICOLON */ - else if ( in == "key") out = 48; /* 0X28 VK_APOSTROPHE */ - else if ( in == "key") out = 49; /* 0X29 VK_GRAVE */ + else if ( in == "key") out = 47; /* 0X27 VK_SEMICOLON DE Ö*/ + else if ( in == "key") out = 48; /* 0X28 VK_APOSTROPHE DE Ä */ + else if ( in == "key") out = 49; /* 0X29 VK_GRAVE DE # */ else if ( in == "key") out = 52; /* 0X2C VK_Z */ else if ( in == "key") out = 53; /* 0X2D VK_X */ @@ -319,9 +277,10 @@ int replace_PosKey_with_Keycode_use_Lin(std::string in) { else if ( in == "key") out = 58; /* 0X32 VK_M */ else if ( in == "key") out = 59; /* 0X33 VK_ COMMA */ else if ( in == "key") out = 60; /* 0X34 VK_DOT */ - else if ( in == "key") out = 61; /* 0X35 VK_SLASH */ - else if ( in == "key") out = 62; /* 0X36 VK_RIGHTSHIFT */ + else if ( in == "key") out = 61; /* 0X35 VK_SLASH DE - */ + else if ( in == "key") out = 62; /* 0X36 VK_BKSLASH */ else if ( in == "key") out = 63; /* 0X37 VK_RIGHTSHIFT */ + else if ( in == "key") out = 65; /* 0X20 ?? 39? VK_SPACE */ return out; } @@ -347,8 +306,11 @@ KMX_DWORD writeKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_sta int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { +// _S2 can go later + //PrintKeymapForCode(keymap, 52); + //Try_EberhardsXKB(); - writeKeyvalsFromKeymap(keymap,1, 0); + //writeKeyvalsFromKeymap(keymap,1, 0); // create a 2D vector all filled with " " and push to 3D-Vector v_dw_2D Other_Vector2D = create_empty_2D(All_Vector[0].size(),All_Vector[0][0].size()); @@ -444,7 +406,7 @@ KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - // return 0; + // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html if (!(shift_state_pos < count)) return 0; @@ -454,8 +416,8 @@ KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state //wprintf(L" getKeyvalsFromKeymap: in %i -- out : %i \n", (int)keycode, out); // _S2 if out of range of what ( ascii??) return 0 or other value ? - if (out > 255) - out = 0; + /*if (out > 255) + out = 0;*/ g_free(keyvals); g_free(maps); @@ -512,7 +474,7 @@ KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ // _S2 what if we use column 3(altgr) and 4 (shift+altgr) ?? - if( SC < 20) { + if( SC < 65) { // values for numbers are stored in column All_Vector[1][i][ 1 ] if ( All_Vector[k][i][0] == SC ) { wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[k][i][2],All_Vector[k][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); @@ -527,12 +489,16 @@ KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][2],All_Vector[1][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); KMX_DWORD returnval= All_Vector[1][i][2]; return All_Vector[1][i][2]; + } } - } -//hier All_Vector[1][i][1]; ergibt , und . aber kleinbuchstaben ode ; und : aber grossbuchstaben + + //hier All_Vector[1][i][1]; ergibt , und . aber kleinbuchstaben ode ; und : aber grossbuchstaben + + if( IsKeyIn_VKMap(SC)) + return SC; //_S2 what do I return if not found?? } } - return 0; //_S2 what do I return if not found?? + return 0; } // return RETURN NON SHIFTED CHAR [1] the VirtualKey of the US Keyboard for given Scancode @@ -572,18 +538,61 @@ KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ return 0; //_S2 what do I return if not found?? } -// ToDo write 2 func for return pos of Key_US and Pos of Key_Other -// return the Scancode of for given VirtualKey of Other US -KMX_DWORD get_position_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ + +KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector){ // find correct row of char in US for( int i=0; i< (int)All_Vector[0].size()-1;i++) { - if ( ( All_Vector[0][i][1] == VK_US ) || ( All_Vector[0][i][2] == VK_US )) { + if ( ( All_Vector[1][i][1] == VK_Other ) || ( All_Vector[1][i][2] == VK_Other )) { //if ( ( All_Vector[0][i][1] == VK_US ) ) { - wprintf(L" VK_US= %i .. i= %i .. %i\t\t %i (%c) : %i (%c) +++ %i\t\t %i (%c) : %i (%c) \n",VK_US , i, - All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2], - All_Vector[1][i][0] , All_Vector[1][i][1] ,All_Vector[1][i][1] , All_Vector[1][i][2] , All_Vector[1][i][2] ); - return i; + //wprintf(L" VK_Other= %i .. i= %i .. %i\t\t %i (%c) : %i (%c) +++ %i\t\t %i (%c) : %i (%c) \n",VK_Other , i, + // All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2], + // All_Vector[1][i][0] , All_Vector[1][i][1] ,All_Vector[1][i][1] , All_Vector[1][i][2] , All_Vector[1][i][2] ); + return i; } } return 0; //_S2 what do I return if not found?? } + +KMX_DWORD get_position_From_VirtualKey_Other_2(KMX_DWORD VK_Other , v_dw_3D &All_Vector){ + + return VK_Other; //_S2 what do I return if not found?? +} + +bool IsKeyIn_VKMap(UINT SC) { + for (int i=0; i< sizeof( KMX_VKMap)/sizeof( KMX_VKMap[0]); i++) { + if ( SC == KMX_VKMap[i]) + return true; + } + return false; +} + + +const int Lin_KM__map(int i) { + + // MAP: + // VK KEYMAN-STYLE -> KEYCODE LINUX-STYLE + // e.g 188 -> 59 + //All_Vector_[ 1 ][ in which line of US did find the value 58 ][ take second or third column wherever I find 58 ]] + // finds 59th row (not value 59) + + //if (i == 32 ) return ; /* */ + if (i == 186 ) return 252; /* SEMI/COLON */ + if (i == 187 ) return 43; /* */ + if (i == 188 ) return 59; /* COMMA */ + if (i == 189 ) return 45; /* */ + if (i == 190 ) return 58; /* PERIOD */ + if (i == 191 ) return 51; /* SLASH */ + //if (i == 191 ) return 63; /* */ + if (i == 192 ) return 246; /* */ + if (i == 219 ) return 223; /* */ + if (i == 220 ) return 92; /* BACKSLASH */ + if (i == 221 ) return 180; /* */ + if (i == 222 ) return 228; /* */ + //if (i == 223 ) return ; /* */ + if (i == 226 ) return 60; /* */ + + if (i == 65105 ) + return 92; /* */ + + return i; +} diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 8c7b1ed02a..98168a8c16 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -42,7 +42,7 @@ const KMX_DWORD KMX_VKMap[] = { VK_xDF, VK_OEM_102,/**/ 0 }; - +// _S2 how many fielsds do I need?? // mapping between Linux keycodes and keyman SC const int keycode_map[60]={ 0, /* */ @@ -107,6 +107,85 @@ const int keycode_map[60]={ 0, /* */ }; +// _S2 how many fielsds do I need?? +const int Lin_KM__map_arr[70]={ + 0, /* */ + 1, /* */ + 2, /* */ + 3, /* */ + 4, /* */ + 5, /* */ + 6, /* */ + 7, /* */ + 8, /* */ + 9, /* */ + + 10, /*10. 1 */ + 11, /*11. 2 */ + 12, /*12. 3 */ + 13, /*13. 4 */ + 14, /*14. 5 */ + 15, /*15. 6 */ + 16, /*16. 7 */ + 17, /*17. 8 */ + 18, /*18. 9 */ + 19, /*19. 0 */ + + 20, /*20. MINUS */ + 21, /*21. EQUALS*/ + 22, /*22. BACKSPACE*/ + 23, /*23. TAB*/ + 24, /* 16. Q */ + 25, /* 17. W */ + 26, /* 18. E */ + 27, /* 19. R */ + 28, /* 20. T */ + 29, /* 21. Z */ + + 30, /* 22. U */ + 31, /* 23. I*/ + 32, /* 24. O*/ + 33, /* 25. P*/ + 34, /*26. LEFTBRACE*/ + 35, /*27. RIGHTBRACE*/ + 36, /*28. ENTER*/ + 37, /*29. LEFTCTRL*/ + 38, /* 30. A */ + 39, /* 31. S */ + + 40, /* 32. D */ + 41, /* 33. F */ + 42, /* 34. G */ + 43, /* 35. H */ + 44, /* 36. J */ + 45, /* 37. K */ + 46, /* 38. L */ + 47, /*39. SEMICOLON*/ + 48, /*40. APOSTROPHE*/ + 49, /*41. GRAVE*/ + + 50, /*42. LEFTSHIFT*/ + 51, /*43. BACKSLASH*/ + 52, /*44. Z */ + 53, /*45. X */ + 54, /*46. C */ + 55, /*47. V */ + 56, /*48. B */ + 57, /*49. N */ + 58, /*50. M */ + 188, /*51. COMMA */ + + 190, /*52. DOT */ + 61, /*53. SLASH */ + 62, /*54. R_SHIFT */ + 63, /*55. * */ + 64, /*56. LEFTALT*/ + 65, /*57. SPACE*/ + 66 , /*58. CAPSLOCK*/ +}; + +const int Lin_KM__map(int i); + // this is what we return when we find an invalid character //_S2 Which character do we use in that case? 0 or FFFF or 32 or ?? static KMX_DWORD returnIfCharInvalid = 32; @@ -127,7 +206,6 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE *fpp, const char *text, int split_US_To_3D_Vector(v_dw_3D &all_US, v_str_1D completeList); // replace Name of Key (e.g. ) wih Keycode ( e.g. 0x15 ) -int replace_PosKey_with_Keycode(std::string in); int replace_PosKey_with_Keycode_use_Lin(std::string in); // create an empty 2D vector containing "--" in all fields @@ -146,7 +224,9 @@ KMX_DWORD get_SC_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector) // return the Scancode of for given VirtualKey of Other US KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector); // return the Scancode of for given VirtualKey of Other US -KMX_DWORD get_position_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector); +KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_US , v_dw_3D &All_Vector); + +bool IsKeyIn_VKMap(UINT SC); #if USE_GDK diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index f80a5dbf20..f01e23bd57 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -25,6 +25,7 @@ #include #include "km_types.h" #include "mc_kmxfile.h" +#include "keymap.h" enum ShiftState { Base = 0, // 0 @@ -577,51 +578,46 @@ bool write_rgKey_ToFile(std::vector rgKey ){ return true; } +bool VK_Neither_DigitNorChar(int pos, v_dw_3D & All_Vector){ + if((!( All_Vector[1][pos][1] == All_Vector[1][pos][2] + 32) && (!((All_Vector[1][pos][1] >= 48 && All_Vector[1][pos][1] <= 57) || (All_Vector[1][pos][1] >= 65 && All_Vector[1][pos][1] <= 90))))) + return true; -// _S2 where to put this?? -std::wstring get_VirtualKey_US_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &caps, v_dw_3D &All_Vector) { - - int icaps; - KMX_DWORD pos = get_position_From_VirtualKey_US(iKey, All_Vector); - - if (ss >9) - return L""; - - if( ss < All_Vector[0][pos].size()-1) { - //if( ss < All_Vector[1][pos].size()-1) { // _S2 numbers need this - - if ( ss % 2 == 0) - icaps = ss+2-caps; - - if ( ss % 2 == 1) - icaps = ss+caps; - - return std::wstring(1, (int) All_Vector[0][pos][icaps]); - //return std::wstring(1, (int) All_Vector[1][pos][icaps]); - } - return L""; + else + return false; } +bool is_lowercase_alphabetic(int pos, v_dw_3D & All_Vector){ + + if(( All_Vector[1][pos][1] == All_Vector[1][pos][2] + 32) && ( (All_Vector[1][pos][1] >= 97 && All_Vector[1][pos][1] <= 122) )) + return true; + else + return false; + } + + // _S2 where to put this?? std::wstring get_VirtualKey_Other_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &caps, v_dw_3D &All_Vector) { int icaps; - KMX_DWORD pos = get_position_From_VirtualKey_US(iKey, All_Vector); + // _S2 this will find the correct row in All_Vector + //( e.g. get_position_From_VirtualKey_Other(65 ,All_Vector ) returns 25 + // All_Vector[25] contains SC(38), unshifted A (97) shifted A (65) ) + KMX_DWORD pos = get_position_From_VirtualKey_Other(iKey, All_Vector); if (ss >9) return L""; if( ss < All_Vector[1][pos].size()-1) { - //if( ss < All_Vector[1][pos].size()-1) { // _S2 numbers need this + // ss 0,2,4... if ( ss % 2 == 0) icaps = ss+2-caps; + // ss 1,3,5... if ( ss % 2 == 1) icaps = ss+caps; return std::wstring(1, (int) All_Vector[1][pos][icaps]); - //return std::wstring(1, (int) All_Vector[1][pos][icaps]); } return L""; } @@ -648,7 +644,6 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std return false; } */ - KMX_HKL hkl = NULL; //_S2 added: but can I do this?? hkl is not needed in Linux?? BYTE lpKeyState[256];// = new KeysEx[256]; @@ -661,7 +656,8 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std // Scroll through the Scan Code (SC) values and get the valid Virtual Key (VK) // values in it. Then, store the SC in each valid VK so it can act as both a // flag that the VK is valid, and it can store the SC value. - for(UINT sc = 0x01; sc <= 0x7f; sc++) { + //for(UINT sc = 0x01; sc <= 0x7f; sc++) { + for(UINT sc = 0x0; sc <= 0xff; sc++) { KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector); // _S2 get this from my Vector uint key_vk = key->VK() ; if(key->VK() != 0) { @@ -715,6 +711,9 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std if(rgKey[iKey] != NULL) { WCHAR sbBuffer[256]; // Scratchpad we use many places + //UINT mapped_ikey = Lin_KM__map[iKey]; + UINT mapped_ikey = Lin_KM__map(iKey); + for(ShiftState ss = Base; ss <= loader.MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { if(ss == Menu || ss == ShftMenu) { // Alt and Shift+Alt don't work, so skip them @@ -725,14 +724,19 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std //_S2 TODO //_S2 get char - do I need rc ?? ( was rc = ToUnicodeEx...) - std::wstring VK_US = get_VirtualKey_US_from_iKey(iKey, ss, caps, All_Vector); - std::wstring VK_Other = get_VirtualKey_Other_from_iKey(iKey, ss, caps, All_Vector); + //std::wstring VK_US = get_VirtualKey_US_from_iKey(iKey, ss, caps, All_Vector); + std::wstring VK_Other = get_VirtualKey_Other_from_iKey(mapped_ikey, ss, caps, All_Vector); + + //std::wstring VK_Other = get_VirtualKey_Other_from_iKey(iKey, ss, caps, All_Vector); + wprintf(L"ikey : %i (mapped to %i ) SS (%i) caps(%i) ----> returns %s (%i)\n", + iKey, mapped_ikey , ss, caps, VK_Other.c_str(), (int) *( VK_Other.c_str())); //_S2 TODO //do I need that ?? //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { if(VK_Other == L"") { rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); + //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); } //_S2 TODO @@ -745,7 +749,9 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std //_S2 TODO // fill m_rgss and m_rgfDeadkey ( m_rgfDeadkey will be done later) - rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps == 0)); + //rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps == 0)); + rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps == 0)); + //rgKey[196]->KMX_SetShiftState(ss, VK_Other, false, (caps == 0)); //} // from rc==1 // } // from rc > 0 @@ -773,6 +779,22 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std CompareVector_To_VectorOfFile_RGKEY( V_win, V_lin,V_map);*/ +int zz; +zz = 54; +wprintf(L"Results for %i: %s, %s, %s, %s \n", zz, rgKey[zz]->KMX_GetShiftState(Base,0).c_str(), rgKey[zz]->KMX_GetShiftState(Base,1).c_str() ,rgKey[zz]->KMX_GetShiftState(Shft,0).c_str(), rgKey[zz]->KMX_GetShiftState(Shft,1).c_str()); +zz = 65; +wprintf(L"Results for %i: %s, %s, %s, %s \n", zz, rgKey[zz]->KMX_GetShiftState(Base,0).c_str(), rgKey[zz]->KMX_GetShiftState(Base,1).c_str() ,rgKey[zz]->KMX_GetShiftState(Shft,0).c_str(), rgKey[zz]->KMX_GetShiftState(Shft,1).c_str()); +zz = 189; +wprintf(L"Results for %i: %s, %s, %s, %s \n", zz, rgKey[zz]->KMX_GetShiftState(Base,0).c_str(), rgKey[zz]->KMX_GetShiftState(Base,1).c_str() ,rgKey[zz]->KMX_GetShiftState(Shft,0).c_str(), rgKey[zz]->KMX_GetShiftState(Shft,1).c_str()); +zz = 188; +wprintf(L"Results for %i: %lS, %lS, %lS, %lS \n", zz, rgKey[zz]->KMX_GetShiftState(Base,0).c_str(), rgKey[zz]->KMX_GetShiftState(Base,1).c_str() ,rgKey[zz]->KMX_GetShiftState(Shft,0).c_str(), rgKey[zz]->KMX_GetShiftState(Shft,1).c_str()); +/* +zz = 191; +wprintf(L"Results for %i: %S, %S, %S, %S \n", zz, rgKey[zz]->KMX_GetShiftState(Base,0).c_str(), rgKey[zz]->KMX_GetShiftState(Base,1).c_str() ,rgKey[zz]->KMX_GetShiftState(Shft,0).c_str(), rgKey[zz]->KMX_GetShiftState(Shft,1).c_str()); + +zz = 186; +wprintf(L"Results for %i: %s, %s, %s, %s \n", zz, rgKey[zz]->KMX_GetShiftState(Base,0).c_str(), rgKey[zz]->KMX_GetShiftState(Base,1).c_str() ,rgKey[zz]->KMX_GetShiftState(Shft,0).c_str(), rgKey[zz]->KMX_GetShiftState(Shft,1).c_str()); +*/ //------------------------------------------------------------- // Now that we've collected the key data, we need to From 90fb32160cb46baa69f22923d689258c731d6715 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 12 Oct 2023 21:42:21 +0200 Subject: [PATCH 104/327] feat(linux): mcompile tidy up --- linux/mcompile/keymap/keymap.cpp | 6 +++--- linux/mcompile/keymap/mc_import_rules.cpp | 7 +------ linux/mcompile/keymap/mcompile.cpp | 18 ------------------ 3 files changed, 4 insertions(+), 27 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 44b3ed3ed2..c87bb2a1c2 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -354,7 +354,7 @@ KMX_DWORD KeycodeMapped_inValue = All_Vector[0][i][0]; KMX_DWORD resultOf_GETKEYVALS = getKeyvalsFromKeymap(keymap,All_Vector[0][i][0],0); KMX_DWORD resultOf_GETKEYVALS_shift = getKeyvalsFromKeymap(keymap,All_Vector[0][i][0],1); -wprintf(L" inValue: %i -KeycodeMapped_inValue: %i, resultOf_GETKEYVALS: %i , resultOf_GETKEYVALS_shift: %i : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",inValue,KeycodeMapped_inValue,resultOf_GETKEYVALS,resultOf_GETKEYVALS_shift,(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); +//wprintf(L" inValue: %i -KeycodeMapped_inValue: %i, resultOf_GETKEYVALS: %i , resultOf_GETKEYVALS_shift: %i : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",inValue,KeycodeMapped_inValue,resultOf_GETKEYVALS,resultOf_GETKEYVALS_shift,(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); @@ -477,7 +477,7 @@ KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ if( SC < 65) { // values for numbers are stored in column All_Vector[1][i][ 1 ] if ( All_Vector[k][i][0] == SC ) { - wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[k][i][2],All_Vector[k][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); + //wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[k][i][2],All_Vector[k][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); KMX_DWORD returnval= All_Vector[k][i][1]; // we could return All_Vector[0][i][1]; since win version uses US numbers here return All_Vector[k][i][1]; @@ -486,7 +486,7 @@ KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ else { // shifted values e.g. "Q" (=81) are stored in column All_Vector[1][i][ 2 ] if ( All_Vector[k][i][0] == SC ) { - wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][2],All_Vector[1][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); + //wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][2],All_Vector[1][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); KMX_DWORD returnval= All_Vector[1][i][2]; return All_Vector[1][i][2]; } diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index f01e23bd57..3815d21e29 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -623,7 +623,6 @@ std::wstring get_VirtualKey_Other_from_iKey(KMX_DWORD iKey, ShiftState &ss, int } bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 - wprintf(L"\n ##### KMX_ImportRules of mc_import_rules started #####\n"); KMX_Loader loader; const size_t BUF_sz= 256; @@ -728,8 +727,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std std::wstring VK_Other = get_VirtualKey_Other_from_iKey(mapped_ikey, ss, caps, All_Vector); //std::wstring VK_Other = get_VirtualKey_Other_from_iKey(iKey, ss, caps, All_Vector); - wprintf(L"ikey : %i (mapped to %i ) SS (%i) caps(%i) ----> returns %s (%i)\n", - iKey, mapped_ikey , ss, caps, VK_Other.c_str(), (int) *( VK_Other.c_str())); + //wprintf(L"ikey : %i (mapped to %i ) SS (%i) caps(%i) ----> returns %s (%i)\n", iKey, mapped_ikey , ss, caps, VK_Other.c_str(), (int) *( VK_Other.c_str())); //_S2 TODO //do I need that ?? @@ -976,8 +974,5 @@ wprintf(L"Results for %i: %s, %s, %s, %s \n", zz, rgKey[zz]->KMX_GetShiftState kkp++; } } - - -wprintf(L"\n ##### KMX_ImportRules of mc_import_rules ended #####\n"); return true; } diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index be3771f7a7..7626af13ab 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -313,7 +313,6 @@ int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]) { - wprintf(L"\n##### KMX_DoConvert of mcompile started #####\n"); KMX_WCHAR DeadKey; if(!KMX_SetKeyboardToPositional(kbd)) return FALSE; @@ -403,7 +402,6 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon } } } -wprintf(L"\n##### KMX_ReportUnconvertedKeyboardRules of mcompile will start #####\n"); KMX_ReportUnconvertedKeyboardRules(kbd); @@ -413,8 +411,6 @@ wprintf(L"\n##### KMX_ReportUnconvertedKeyboardRules of mcompile will start #### if(!KMX_ImportRules(kbid, kbd, All_Vector, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 return FALSE; } - - wprintf(L"\n##### KMX_DoConvert of mcompile ended #####\n"); return TRUE; } @@ -435,7 +431,6 @@ void KMX_LogError(const KMX_WCHART* m1,int m2, LPKMX_KEY key) { // void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { - //wprintf(L"\n ##### KMX_TranslateKey of mcompile started #### with vk: %i (%c) shift: %i ch: %i (%c)......" , vk,vk, shift, ch,ch); // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. @@ -464,31 +459,22 @@ void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) //wprintf(L"key->ShiftFlags for VIRTUALCHARKEY= %i", key->ShiftFlags); //wprintf(L" 2 and changed, vk: %i (%c) ---> %i (%c) ", vk,vk, ch,ch); } - - //wprintf(L"\n ##### KMX_TranslateKey of mcompile ended ##### \n"); - //wprintf(L"key->ShiftFlags: %i, key->Key: %i\n", key->ShiftFlags,key->Key); } void KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { - //wprintf(L"\n ##### KMX_TranslateGroup of mcompile started #####\n"); for(unsigned int i = 0; i < group->cxKeyArray; i++) { KMX_TranslateKey(&group->dpKeyArray[i], vk, shift, ch); } - - //wprintf(L" ##### KMX_TranslateGroup of mcompile ended #####\n"); } void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { - //wprintf(L"\n ##### KMX_TranslateKeyboard of mcompile started #####\n"); //if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)){ - //wprintf(L" ##### KMX_TranslateKeyboard of mcompile started #### with vk: %i (%c) shift: %i ch: %i (%c)......(shift & (LCTRLFLAG|RALTFLAG)) %i == (LCTRLFLAG|RALTFLAG)%i): %i \n" , vk,vk, shift, ch,ch, (shift & (LCTRLFLAG|RALTFLAG)) , (LCTRLFLAG|RALTFLAG), (shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)); for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { if(kbd->dpGroupArray[i].fUsingKeys) { KMX_TranslateGroup(&kbd->dpGroupArray[i], vk, shift, ch); } } - //wprintf(L" ##### KMX_TranslateKeyboard of mcompile ended #####\n"); } void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key) { @@ -504,21 +490,17 @@ void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key) { } void KMX_ReportUnconvertedGroupRules(LPKMX_GROUP group) { - wprintf(L"\n ##### KMX_ReportUnconvertedGroupRules of mcompile started #####\n"); for(unsigned int i = 0; i < group->cxKeyArray; i++) { KMX_ReportUnconvertedKeyRule(&group->dpKeyArray[i]); } - wprintf(L"\n ##### KMX_ReportUnconvertedGroupRules of mcompile ended #####\n"); } void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { - wprintf(L"\n ##### KMX_ReportUnconvertedKeyboardRules of mcompile started #####\n"); for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { if(kbd->dpGroupArray[i].fUsingKeys) { KMX_ReportUnconvertedGroupRules(&kbd->dpGroupArray[i]); } } - wprintf(L"\n ##### KMX_ReportUnconvertedKeyboardRules of mcompile ended #####\n"); } From 54b8a1f2ab5f2c312058174510718135238e0f3f Mon Sep 17 00:00:00 2001 From: Sabine Date: Sat, 14 Oct 2023 22:00:01 +0200 Subject: [PATCH 105/327] feat(linux): mcompile fill rgkey --- linux/mcompile/keymap/keymap.cpp | 5 -- linux/mcompile/keymap/km_types.h | 8 +++ linux/mcompile/keymap/mc_import_rules.cpp | 75 +++++++++++------------ 3 files changed, 45 insertions(+), 43 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index c87bb2a1c2..1f284cb5ba 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -478,8 +478,6 @@ KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ // values for numbers are stored in column All_Vector[1][i][ 1 ] if ( All_Vector[k][i][0] == SC ) { //wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[k][i][2],All_Vector[k][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); - KMX_DWORD returnval= All_Vector[k][i][1]; - // we could return All_Vector[0][i][1]; since win version uses US numbers here return All_Vector[k][i][1]; } } @@ -487,13 +485,10 @@ KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ // shifted values e.g. "Q" (=81) are stored in column All_Vector[1][i][ 2 ] if ( All_Vector[k][i][0] == SC ) { //wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][2],All_Vector[1][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); - KMX_DWORD returnval= All_Vector[1][i][2]; return All_Vector[1][i][2]; } } - //hier All_Vector[1][i][1]; ergibt , und . aber kleinbuchstaben ode ; und : aber grossbuchstaben - if( IsKeyIn_VKMap(SC)) return SC; //_S2 what do I return if not found?? } diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index 6a26c2c7d5..53f5485740 100644 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -146,4 +146,12 @@ typedef KMX_UCHAR* KMX_PUCHAR; #define VK_CANCEL 3 #define VK_DECIMAL 110 +#define VK_OEM_CLEAR 0xFE +#define VK_LSHIFT 0xA0 +#define VK_RSHIFT 0xA1 +#define VK_LCONTROL 0xA2 +#define VK_RCONTROL 0xA3 +#define VK_LMENU 0xA4 +#define VK_RMENU 0xA5 + #endif /*KM_TYPES*/ diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 3815d21e29..c718f059a8 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -578,45 +578,56 @@ bool write_rgKey_ToFile(std::vector rgKey ){ return true; } -bool VK_Neither_DigitNorChar(int pos, v_dw_3D & All_Vector){ - if((!( All_Vector[1][pos][1] == All_Vector[1][pos][2] + 32) && (!((All_Vector[1][pos][1] >= 48 && All_Vector[1][pos][1] <= 57) || (All_Vector[1][pos][1] >= 65 && All_Vector[1][pos][1] <= 90))))) - return true; - - else - return false; +bool is_Letter(int pos, v_dw_3D & All_Vector){ + if( ( All_Vector[1][pos][1] == All_Vector[1][pos][2] + 32) ) + return true; + return false; } -bool is_lowercase_alphabetic(int pos, v_dw_3D & All_Vector){ - - if(( All_Vector[1][pos][1] == All_Vector[1][pos][2] + 32) && ( (All_Vector[1][pos][1] >= 97 && All_Vector[1][pos][1] <= 122) )) +bool is_Number(int pos, v_dw_3D & All_Vector){ + if( (pos > 0 && pos < 11 ) ) return true; - else - return false; - } + return false; +} +bool is_Special(int pos, v_dw_3D & All_Vector){ + if( !is_Number && !is_Letter) + return true; + return false; +} // _S2 where to put this?? std::wstring get_VirtualKey_Other_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &caps, v_dw_3D &All_Vector) { - int icaps; // _S2 this will find the correct row in All_Vector //( e.g. get_position_From_VirtualKey_Other(65 ,All_Vector ) returns 25 // All_Vector[25] contains SC(38), unshifted A (97) shifted A (65) ) KMX_DWORD pos = get_position_From_VirtualKey_Other(iKey, All_Vector); + int icaps; if (ss >9) return L""; if( ss < All_Vector[1][pos].size()-1) { // ss 0,2,4... - if ( ss % 2 == 0) - icaps = ss+2-caps; + if ( ss % 2 == 0) { + + if ( is_Letter(pos, All_Vector) || is_Number(pos, All_Vector)) + icaps = ss+2-caps; + + else + icaps = ss+1; + } // ss 1,3,5... - if ( ss % 2 == 1) - icaps = ss+caps; + if ( ss % 2 == 1) { + if ( is_Letter(pos, All_Vector) || is_Number(pos, All_Vector)) + icaps = ss+caps; + else + icaps = ss+1; + } return std::wstring(1, (int) All_Vector[1][pos][icaps]); } return L""; @@ -656,7 +667,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std // values in it. Then, store the SC in each valid VK so it can act as both a // flag that the VK is valid, and it can store the SC value. //for(UINT sc = 0x01; sc <= 0x7f; sc++) { - for(UINT sc = 0x0; sc <= 0xff; sc++) { + for(UINT sc = 0x0; sc <= 0x7f; sc++) { KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector); // _S2 get this from my Vector uint key_vk = key->VK() ; if(key->VK() != 0) { @@ -666,7 +677,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std } } - /* // where in rgkey do I store Numpad??? + // where in rgkey do I store Numpad??? // _S2 do we need NUMPAD now or later? If so we need to add Numpad values to All_Vector ( which has only values a-z) // _S2 use KMX_VirtualKey !! // _S2 do I need NUMPAD + SPECIAL_SHIFT for first draft ?? @@ -678,9 +689,9 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE, All_Vector); rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL, All_Vector); rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL, All_Vector); - */ -/* // _S2 do we need special shift state now or later? +/* + // _S2 do we need special shift state now or later? // See if there is a special shift state added for(UINT vk = 0; vk <= VK_OEM_CLEAR; vk++) { UINT sc = MapVirtualKeyEx(vk, 0, hkl); @@ -723,7 +734,6 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std //_S2 TODO //_S2 get char - do I need rc ?? ( was rc = ToUnicodeEx...) - //std::wstring VK_US = get_VirtualKey_US_from_iKey(iKey, ss, caps, All_Vector); std::wstring VK_Other = get_VirtualKey_Other_from_iKey(mapped_ikey, ss, caps, All_Vector); //std::wstring VK_Other = get_VirtualKey_Other_from_iKey(iKey, ss, caps, All_Vector); @@ -734,7 +744,6 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { if(VK_Other == L"") { rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); - //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); } //_S2 TODO @@ -777,22 +786,12 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std CompareVector_To_VectorOfFile_RGKEY( V_win, V_lin,V_map);*/ -int zz; -zz = 54; -wprintf(L"Results for %i: %s, %s, %s, %s \n", zz, rgKey[zz]->KMX_GetShiftState(Base,0).c_str(), rgKey[zz]->KMX_GetShiftState(Base,1).c_str() ,rgKey[zz]->KMX_GetShiftState(Shft,0).c_str(), rgKey[zz]->KMX_GetShiftState(Shft,1).c_str()); -zz = 65; -wprintf(L"Results for %i: %s, %s, %s, %s \n", zz, rgKey[zz]->KMX_GetShiftState(Base,0).c_str(), rgKey[zz]->KMX_GetShiftState(Base,1).c_str() ,rgKey[zz]->KMX_GetShiftState(Shft,0).c_str(), rgKey[zz]->KMX_GetShiftState(Shft,1).c_str()); -zz = 189; -wprintf(L"Results for %i: %s, %s, %s, %s \n", zz, rgKey[zz]->KMX_GetShiftState(Base,0).c_str(), rgKey[zz]->KMX_GetShiftState(Base,1).c_str() ,rgKey[zz]->KMX_GetShiftState(Shft,0).c_str(), rgKey[zz]->KMX_GetShiftState(Shft,1).c_str()); -zz = 188; -wprintf(L"Results for %i: %lS, %lS, %lS, %lS \n", zz, rgKey[zz]->KMX_GetShiftState(Base,0).c_str(), rgKey[zz]->KMX_GetShiftState(Base,1).c_str() ,rgKey[zz]->KMX_GetShiftState(Shft,0).c_str(), rgKey[zz]->KMX_GetShiftState(Shft,1).c_str()); -/* -zz = 191; -wprintf(L"Results for %i: %S, %S, %S, %S \n", zz, rgKey[zz]->KMX_GetShiftState(Base,0).c_str(), rgKey[zz]->KMX_GetShiftState(Base,1).c_str() ,rgKey[zz]->KMX_GetShiftState(Shft,0).c_str(), rgKey[zz]->KMX_GetShiftState(Shft,1).c_str()); +std::vector< int > TestValues = {49,54,65,89,189,188}; + +for ( int i=0; i < TestValues.size();i++) { + wprintf(L"Results for %i\t: %s %s %s %s \n", TestValues[i], rgKey[TestValues[i]]->KMX_GetShiftState(Base,0).c_str(), rgKey[TestValues[i]]->KMX_GetShiftState(Base,1).c_str() , rgKey[TestValues[i]]->KMX_GetShiftState(Shft,0).c_str(), rgKey[TestValues[i]]->KMX_GetShiftState(Shft,1).c_str()); +} -zz = 186; -wprintf(L"Results for %i: %s, %s, %s, %s \n", zz, rgKey[zz]->KMX_GetShiftState(Base,0).c_str(), rgKey[zz]->KMX_GetShiftState(Base,1).c_str() ,rgKey[zz]->KMX_GetShiftState(Shft,0).c_str(), rgKey[zz]->KMX_GetShiftState(Shft,1).c_str()); -*/ //------------------------------------------------------------- // Now that we've collected the key data, we need to From 70163eb5faf3cbead05557fc336d49e9b3e6cfe8 Mon Sep 17 00:00:00 2001 From: Sabine Date: Sat, 21 Oct 2023 11:59:07 +0200 Subject: [PATCH 106/327] feat(linux): mcompile small changes wprintf+ implement+use KMX_VKUnderlyingLayoutToVKUS --- linux/mcompile/keymap/keymap.cpp | 6 ++--- linux/mcompile/keymap/mc_import_rules.cpp | 29 +++++++++++++++++------ linux/mcompile/keymap/mcompile.cpp | 17 +++++++++---- linux/mcompile/keymap/mcompile.h | 3 ++- 4 files changed, 39 insertions(+), 16 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 1f284cb5ba..a7dc0108dc 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -501,7 +501,7 @@ KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ // find correct row of char in US for( int i=0; i< (int)All_Vector[0].size()-1;i++) { if ( All_Vector[0][i][0] == SC ) { - wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- ",SC , i, All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2] ); + //wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- ",SC , i, All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2] ); return All_Vector[0][i][1] ; // shouldn this be [0][i][2]? //return All_Vector[0][i][2] ; // would be shifted version } @@ -514,7 +514,7 @@ KMX_DWORD get_SC_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector) // find correct row of char in US for( int i=0; i< (int)All_Vector[1].size()-1;i++) { if ( All_Vector[1][i][1] == VK_Other ) { - wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- ",VK_Other , i, All_Vector[1][i][0] , All_Vector[1][i][1] ,All_Vector[1][i][1] , All_Vector[1][i][2] , All_Vector[1][i][2] ); + //wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- ",VK_Other , i, All_Vector[1][i][0] , All_Vector[1][i][1] ,All_Vector[1][i][1] , All_Vector[1][i][2] , All_Vector[1][i][2] ); return All_Vector[1][i][0] ; } } @@ -526,7 +526,7 @@ KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ // find correct row of char in US for( int i=0; i< (int)All_Vector[0].size()-1;i++) { if ( All_Vector[0][i][2] == VK_US ) { - wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- \n",VK_US , i, All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2] ); + //wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- \n",VK_US , i, All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2] ); return All_Vector[0][i][0] ; } } diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index c718f059a8..7f8b5d775a 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -287,7 +287,7 @@ public: return nkeys; } - bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion) { // I4552 + bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,v_dw_3D &All_Vector) { // I4552 // Get the CAPSLOCK value int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | @@ -306,12 +306,14 @@ public: if (st.size() == 0) { // No character assigned here - } else if (this->m_rgfDeadKey[(int)ss][caps]) { + } + // _S2 deadkeys don work yet + else if (this->m_rgfDeadKey[(int)ss][caps]) { // It's a dead key, append an @ sign. key->dpContext = new KMX_WCHAR[1]; *key->dpContext = 0; key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); - key->Key = KMX_VKUnderlyingLayoutToVKUS(this->VK()); + key->Key = KMX_VKUnderlyingLayoutToVKUS(All_Vector,this->VK()); key->Line = 0; if(bDeadkeyConversion) { // I4552 @@ -333,7 +335,7 @@ public: } if(isvalid) { - key->Key = KMX_VKUnderlyingLayoutToVKUS(this->VK()); + key->Key = KMX_VKUnderlyingLayoutToVKUS(All_Vector,this->VK()); key->Line = 0; key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); key->dpContext = new KMX_WCHAR; *key->dpContext = 0; @@ -585,7 +587,7 @@ bool is_Letter(int pos, v_dw_3D & All_Vector){ } bool is_Number(int pos, v_dw_3D & All_Vector){ - if( (pos > 0 && pos < 11 ) ) + if( (All_Vector[1][pos][1] >= 48) && (All_Vector[1][pos][1] <= 57) ) return true; return false; } @@ -596,6 +598,13 @@ bool is_Special(int pos, v_dw_3D & All_Vector){ return false; } +bool is_Edges(int pos, v_dw_3D & All_Vector){ + if( (All_Vector[1][pos][1] == 48)) + return true; + return false; +} + + // _S2 where to put this?? std::wstring get_VirtualKey_Other_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &caps, v_dw_3D &All_Vector) { @@ -613,18 +622,22 @@ std::wstring get_VirtualKey_Other_from_iKey(KMX_DWORD iKey, ShiftState &ss, int // ss 0,2,4... if ( ss % 2 == 0) { + // aAAa 4$$4 if ( is_Letter(pos, All_Vector) || is_Number(pos, All_Vector)) icaps = ss+2-caps; + // ..:: ##'' else icaps = ss+1; } // ss 1,3,5... if ( ss % 2 == 1) { + // aAAa 4$$4 if ( is_Letter(pos, All_Vector) || is_Number(pos, All_Vector)) icaps = ss+caps; + // ..:: ##'' else icaps = ss+1; } @@ -786,7 +799,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std CompareVector_To_VectorOfFile_RGKEY( V_win, V_lin,V_map);*/ -std::vector< int > TestValues = {49,54,65,89,189,188}; +std::vector< int > TestValues = {48,49,50,52,53,54,55,56,57,54,65,89,189,188}; for ( int i=0; i < TestValues.size();i++) { wprintf(L"Results for %i\t: %s %s %s %s \n", TestValues[i], rgKey[TestValues[i]]->KMX_GetShiftState(Base,0).c_str(), rgKey[TestValues[i]]->KMX_GetShiftState(Base,1).c_str() , rgKey[TestValues[i]]->KMX_GetShiftState(Shft,0).c_str(), rgKey[TestValues[i]]->KMX_GetShiftState(Shft,1).c_str()); @@ -847,11 +860,13 @@ for ( int i=0; i < TestValues.size();i++) { // // Fill in the new rules // +int STOP; for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { + wprintf(L"********************************* I use Key Nr %i\n",iKey); // for each item, - if(rgKey[iKey]->KMX_LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion)) { // I4552 + if(rgKey[iKey]->KMX_LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector)) { // I4552 nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); } } diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 7626af13ab..2e0c276b0d 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -229,7 +229,6 @@ KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { KMX_DWORD KMX_VKUSToVKUnderlyingLayout(v_dw_3D &All_Vector,KMX_DWORD inUS) { // loop and find char in US; then return char of Other for( int i=0; i< (int)All_Vector[0].size();i++) { - // lists entries of all_vector for( int j=1; j< (int)All_Vector[0][0].size();j++) { if((inUS == All_Vector[0][i][j] )) { return All_Vector[1][i][2]; @@ -239,12 +238,20 @@ KMX_DWORD KMX_VKUSToVKUnderlyingLayout(v_dw_3D &All_Vector,KMX_DWORD inUS) { return inUS; } -// _S2 this will definitely give wrong results!!!! -KMX_WORD KMX_VKUnderlyingLayoutToVKUS(KMX_WORD VKey) { - // _S2 TODO adapt for mcompile linux - return VKey; +// takes capital letter of Other returns cpital character of US keyboard +KMX_WORD KMX_VKUnderlyingLayoutToVKUS(v_dw_3D &All_Vector,KMX_DWORD inOther) { + // loop and find char in Other; then return char of US + for( int i=0; i< (int)All_Vector[1].size();i++) { + for( int j=1; j< (int)All_Vector[1][0].size();j++) { + if((inOther == All_Vector[1][i][j] )) { + return All_Vector[0][i][2]; + } + } + } + return inOther; } + // takes cpital character of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] KMX_DWORD KMX_CharFromVK(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey){ diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index b8c7780a87..e7f4e8c8b7 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -42,7 +42,8 @@ struct KMX_DeadkeyMapping { // I4353 extern std::vector KMX_FDeadkeys; // I4353 // _S2 is this correct here??? -KMX_WORD KMX_VKUnderlyingLayoutToVKUS(KMX_WORD VKey) ; +KMX_WORD KMX_VKUnderlyingLayoutToVKUS(KMX_WORD VKey); +KMX_WORD KMX_VKUnderlyingLayoutToVKUS(v_dw_3D &All_Vector,KMX_DWORD inOther); //--------------------old /* From 652a1b56b603dd827aede8219903c8823d6d4b89 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 26 Oct 2023 19:54:35 +0200 Subject: [PATCH 107/327] feat(linux): mcompile fill rgKey 186-192, 219, 222 --- linux/mcompile/keymap/keymap.cpp | 346 ++++++++++++++++------ linux/mcompile/keymap/keymap.h | 27 +- linux/mcompile/keymap/mc_import_rules.cpp | 32 +- 3 files changed, 292 insertions(+), 113 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index a7dc0108dc..6a4611cc5f 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -89,7 +89,7 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, } } complete_List.push_back(" key { [ space, space] };"); - complete_List.push_back(" key { [ backslash, bar ] };"); + //complete_List.push_back(" key { [ backslash, bar ] };"); if (complete_List.size() <1) { wprintf(L"ERROR: can't create row from US \n"); @@ -125,22 +125,42 @@ KMX_DWORD convertNamesToValue(std::wstring tok_wstr){ first[L"asterisk"] = 42; first[L"parenleft"] = 40; first[L"parenright"] = 41; + first[L"braceleft"] = 123; /* { */ + first[L"braceright"] = 125; /* } */ - first[L"equal"] = VK_EQUAL; /* BB = 187 */ - first[L"backslash"] = VK_BKSLASH; /* DC = 220 */ - first[L"bracketleft"] = VK_LBRKT; /* DB = 219 */ - first[L"bracketright"] = VK_RBRKT; /* DD = 221 */ - first[L"colon"] = VK_COLON; /* BA = 186 */ - first[L"comma"] = VK_COMMA; /* BC = 188 */ - first[L"period"] = VK_PERIOD; /* BE = 190 */ - first[L"slash"] = VK_SLASH; /* BF = 191 */ - first[L"ssharp"] = VK_xDF; /* DF = 223 ß */ - first[L"minus"] = VK_HYPHEN; /* BD = 189 ? */ - //first[L"dead_acute"] = VK_ACCENT; /* C0 = 192 ? */ +//todo dieser block ist nötig; nicht dieVK-Nr + first[L"equal"] = 61; /* BB = 187 VK_OEM_PLUS*/ + first[L"backslash"] = 92; /* DC = 220 \ | VK_OEM_5 */ + first[L"bracketleft"] = 91; /* DB = 219 [ { VK_OEM_4 */ + first[L"bracketright"] = 93; /* DD = 221 ] } VK_OEM_6 */ + first[L"colon"] = 58; /* BA = 186 ; VK_OEM_1 */ + first[L"comma"] = 44; /* BC = 188 , VK_OEM_COMMA */ + first[L"period"] = 46; /* BE = 190 . VK_OEM_PERIOD */ + first[L"slash"] = 47; /* BF = 191 / ? VK_OEM_2 */ + first[L"minus"] = 45; /* BD = 189 - VK_OEM_MINUS */ + first[L"space"] = 32; /* 20 = 32 ? */ + first[L"apostrophe"] = 39; /* DE = 222 ' " ? VK_OEM_7 */ + first[L"dead_acute"] = VK_ACCENT; /* C0 = 192 ` ~ VK_OEM_3 */ first[L"dead_grave"] = VK_ACCENT; /* C0 = 192 ? */ - first[L"space"] = VK_SPACE; /* 20 = 32 ? */ - - // _S2 ?? VK_QUOTE, VK_OEM_102, + first[L"ssharp"] = VK_xDF; /* DF = 223 ß */ + + //first[L"equal"] = VK_EQUAL; /* BB = 187 VK_OEM_PLUS*/ + //first[L"backslash"] = VK_BKSLASH; /* DC = 220 \ | VK_OEM_5 */ + //first[L"bracketleft"] = VK_LBRKT; /* DB = 219 [ { VK_OEM_4 */ + //first[L"bracketright"] = VK_RBRKT; /* DD = 221 ] } VK_OEM_6 */ + //first[L"colon"] = VK_COLON; /* BA = 186 ; VK_OEM_1 */ + //first[L"comma"] = VK_COMMA; /* BC = 188 , VK_OEM_COMMA */ + //first[L"period"] = VK_PERIOD; /* BE = 190 . VK_OEM_PERIOD */ + //first[L"slash"] = VK_SLASH; /* BF = 191 / ? VK_OEM_2 */ + //first[L"ssharp"] = VK_xDF; /* DF = 223 ß */ + //first[L"minus"] = VK_HYPHEN; /* BD = 189 - VK_OEM_MINUS */ + //first[L"dead_acute"] = VK_ACCENT; /* C0 = 192 ` ~ VK_OEM_3 */ + //first[L"dead_grave"] = VK_ACCENT; /* C0 = 192 ? */ + //first[L"space"] = VK_SPACE; /* 20 = 32 ? */ + //first[L"apostrophe"] = VK_QUOTE; /* DE = 222 ' " ? VK_OEM_7 */ + + //first[L" ?? "] = VK_OEM_102; /* DE = 226 ' " ? VK_OEM_102 */ + if ( tok_wstr.size() == 1) { return (KMX_DWORD) ( *tok_wstr.c_str() );; @@ -227,60 +247,60 @@ int replace_PosKey_with_Keycode_use_Lin(std::string in) { // _S2 these are the Scancode-Values we use in Keyman ( = like the windows scancodes) // NAME IN SYMBOLS-FILE KEYCODE (LIN STYLE) (WIN STYLE) VK_US VK_DE + /*on US keyb;*/ + if ( in == "key") out = 49; /* 0X VK_ */ // TOASK correct ??? + else if ( in == "key") out = 10; /* 0X02 VK_1 */ + else if ( in == "key") out = 11; /* 0X03 VK_2 */ + else if ( in == "key") out = 12; /* 0X04 VK_3 */ + else if ( in == "key") out = 13; /* 0X05 VK_4 */ + else if ( in == "key") out = 14; /* 0X06 VK_5 */ + else if ( in == "key") out = 15; /* 0X07 VK_6 */ + else if ( in == "key") out = 16; /* 0X08 VK_7 */ + else if ( in == "key") out = 17; /* 0X09 VK_8 */ + else if ( in == "key") out = 18; /* 0X0A VK_9 */ + else if ( in == "key") out = 19; /* 0X0B VK_0 */ + else if ( in == "key") out = 20; /*out = 61;*/ /* 0X0C VK_MINUS de ẞ*/ + else if ( in == "key") out = 21; /* 0X0D VK_EQUALS DE ' */ - if ( in == "key") out = 49; /* 0X VK_ */ // TOASK correct ??? - else if ( in == "key") out = 10; /* 0X02 VK_1 */ - else if ( in == "key") out = 11; /* 0X03 VK_2 */ - else if ( in == "key") out = 12; /* 0X04 VK_3 */ - else if ( in == "key") out = 13; /* 0X05 VK_4 */ - else if ( in == "key") out = 14; /* 0X06 VK_5 */ - else if ( in == "key") out = 15; /* 0X07 VK_6 */ - else if ( in == "key") out = 16; /* 0X08 VK_7 */ - else if ( in == "key") out = 17; /* 0X09 VK_8 */ - else if ( in == "key") out = 18; /* 0X0A VK_9 */ - else if ( in == "key") out = 19; /* 0X0B VK_0 */ - else if ( in == "key") out = 20; /* 0X0C VK_MINUS de ẞ*/ - else if ( in == "key") out = 21; /* 0X0D VK_EQUALS DE ' */ + else if ( in == "key") out = 24; /* 0X10 VK_Q */ + else if ( in == "key") out = 25; /* 0X11 VK_W */ + else if ( in == "key") out = 26; /* 0X12 VK_E */ + else if ( in == "key") out = 27; /* 0X13 VK_R */ + else if ( in == "key") out = 28; /* 0X14 VK_T */ + else if ( in == "key") out = 29; /*out = 52;*/ /* 0X15 VK_Y */ + else if ( in == "key") out = 30; /* 0X16 VK_U */ + else if ( in == "key") out = 31; /* 0X17 VK_I */ + else if ( in == "key") out = 32; /* 0X18 VK_O */ + else if ( in == "key") out = 33; /* 0X19 VK_P */ + else if ( in == "key") out = 34; /*out = 17;*/ /* 0X1A VK_LEFTBRACE DE Ü */ + else if ( in == "key") out = 35; /*out = 18;*/ /* 0X1B VK_RIGHTBRACE DE + */ - else if ( in == "key") out = 24; /* 0X10 VK_Q */ - else if ( in == "key") out = 25; /* 0X11 VK_W */ - else if ( in == "key") out = 26; /* 0X12 VK_E */ - else if ( in == "key") out = 27; /* 0X13 VK_R */ - else if ( in == "key") out = 28; /* 0X14 VK_T */ - else if ( in == "key") out = 29; /* 0X15 VK_Y */ - else if ( in == "key") out = 30; /* 0X16 VK_U */ - else if ( in == "key") out = 31; /* 0X17 VK_I */ - else if ( in == "key") out = 32; /* 0X18 VK_O */ - else if ( in == "key") out = 33; /* 0X19 VK_P */ - else if ( in == "key") out = 34; /* 0X1A VK_LEFTBRACE DE Ü */ - else if ( in == "key") out = 35; /* 0X1B VK_RIGHTBRACE DE + */ + else if ( in == "key") out = 38; /* 0X1E VK_A */ + else if ( in == "key") out = 39; /* 0X1F VK_S */ + else if ( in == "key") out = 40; /* 0X20 VK_D */ + else if ( in == "key") out = 41; /* 0X21 VK_F */ + else if ( in == "key") out = 42; /* 0X22 VK_G */ + else if ( in == "key") out = 43; /* 0X23 VK_H */ + else if ( in == "key") out = 44; /* 0X24 VK_J */ + else if ( in == "key") out = 45; /* 0X25 VK_K */ + else if ( in == "key") out = 46; /* 0X26 VK_L */ + else if ( in == "key") out = 47; /*out = 59;*/ /* 0X27 VK_SEMICOLON DE Ö*/ + else if ( in == "key") out = 48; /*out = 51;*/ /* 0X28 VK_APOSTROPHE DE Ä */ + //else if ( in == "key") out = 51; /*out = 20;*/ /* 0X29 VK_GRAVE DE # */ - else if ( in == "key") out = 38; /* 0X1E VK_A */ - else if ( in == "key") out = 39; /* 0X1F VK_S */ - else if ( in == "key") out = 40; /* 0X20 VK_D */ - else if ( in == "key") out = 41; /* 0X21 VK_F */ - else if ( in == "key") out = 42; /* 0X22 VK_G */ - else if ( in == "key") out = 43; /* 0X23 VK_H */ - else if ( in == "key") out = 44; /* 0X24 VK_J */ - else if ( in == "key") out = 45; /* 0X25 VK_K */ - else if ( in == "key") out = 46; /* 0X26 VK_L */ - else if ( in == "key") out = 47; /* 0X27 VK_SEMICOLON DE Ö*/ - else if ( in == "key") out = 48; /* 0X28 VK_APOSTROPHE DE Ä */ - else if ( in == "key") out = 49; /* 0X29 VK_GRAVE DE # */ - - else if ( in == "key") out = 52; /* 0X2C VK_Z */ - else if ( in == "key") out = 53; /* 0X2D VK_X */ - else if ( in == "key") out = 54; /* 0X2E VK_C */ - else if ( in == "key") out = 55; /* 0X2F VK_V */ - else if ( in == "key") out = 56; /* 0X30 VK_B */ - else if ( in == "key") out = 57; /* 0X31 VK_N */ - else if ( in == "key") out = 58; /* 0X32 VK_M */ - else if ( in == "key") out = 59; /* 0X33 VK_ COMMA */ - else if ( in == "key") out = 60; /* 0X34 VK_DOT */ - else if ( in == "key") out = 61; /* 0X35 VK_SLASH DE - */ - else if ( in == "key") out = 62; /* 0X36 VK_BKSLASH */ - else if ( in == "key") out = 63; /* 0X37 VK_RIGHTSHIFT */ - else if ( in == "key") out = 65; /* 0X20 ?? 39? VK_SPACE */ + else if ( in == "key") out = 52; /*out = 29;*/ /* 0X2C VK_Z */ + else if ( in == "key") out = 53; /* 0X2D VK_X */ + else if ( in == "key") out = 54; /* 0X2E VK_C */ + else if ( in == "key") out = 55; /* 0X2F VK_V */ + else if ( in == "key") out = 56; /* 0X30 VK_B */ + else if ( in == "key") out = 57; /* 0X31 VK_N */ + else if ( in == "key") out = 58; /* 0X32 VK_M */ + else if ( in == "key") out = 59; /* 0X33 VK_ COMMA */ + else if ( in == "key") out = 60; /* 0X34 VK_DOT */ + else if ( in == "key") out = 61; /*out = 16;*/ /* 0X35 VK_SLASH DE - */ + else if ( in == "key") out = 51; /* 0X29 VK_BKSLASH */ + else if ( in == "key") out = 63; /* 0X37 VK_RIGHTSHIFT */ + else if ( in == "key") out = 65; /* 0X20 ?? 39? VK_SPACE */ return out; } @@ -408,16 +428,19 @@ KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html - if (!(shift_state_pos < count)) + if (!(shift_state_pos <= count)) return 0; out =(KMX_DWORD) keyvals[shift_state_pos]; //wprintf(L" getKeyvalsFromKeymap: in %i -- out : %i \n", (int)keycode, out); + // _S2 what is 65104-65106, 65506, 21840 // _S2 if out of range of what ( ascii??) return 0 or other value ? - /*if (out > 255) - out = 0;*/ + if (out > 255) { + wprintf(L"out of range: found value out( %i) for keycode = %i /shift_state_pos %i (49= TLDE 21= VK_EQUALS 62 = RSHIFT on US keyboard) \n", out,keycode,shift_state_pos); + out = 0; + } g_free(keyvals); g_free(maps); @@ -462,23 +485,26 @@ bool test_single(v_dw_3D &V) { wprintf(L" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); return true; } - // _S2 ToDo something does not work yet // query All_Vector // return RETURN NON SHIFTED CHAR [1] the VirtualKey of the Other Keyboard for given Scancode -KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ - +KMX_DWORD get_VirtualKey_Other_From_SC_BAK(KMX_DWORD SC , v_dw_3D &All_Vector){ // find correct row of char in US for( int k=0; k< (int)All_Vector.size()-1;k++) { for( int i=0; i< (int)All_Vector[1].size()-1;i++) { // _S2 what if we use column 3(altgr) and 4 (shift+altgr) ?? - if( SC < 65) { + int unshiftedchar = All_Vector[k][i][1]; + if (unshiftedchar < 57) { + // if (SC < 57) { + // if( true) { // values for numbers are stored in column All_Vector[1][i][ 1 ] - if ( All_Vector[k][i][0] == SC ) { + //if ( All_Vector[k][i][0] == SC ) { + if ( All_Vector[0][i][0] == SC ) { //wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[k][i][2],All_Vector[k][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); - return All_Vector[k][i][1]; + //return All_Vector[k][i][1]; + return All_Vector[1][i][1]; } } else { @@ -489,8 +515,120 @@ KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ } } - if( IsKeyIn_VKMap(SC)) - return SC; //_S2 what do I return if not found?? + /*if (IsKeyIn_VKMap(SC)) + return SC; //_S2 what do I return if not found??*/ + } + } + return 0; +} + +KMX_DWORD map_VK(KMX_DWORD SC ){ + if ( SC == 20) return VK_HYPHEN; /* ; 189 = - oder ß */ + if ( SC == 21) return VK_EQUAL; /* ; 187 = oder ' */ + + if ( SC == 34) return VK_LBRKT; /* ; 186 VK_OEM_4 [ oder ü */ + if ( SC == 35) return VK_RBRKT; /* ; 221 = ] oder + */ + + if ( SC == 47) return VK_COLON; /* ; 192 VK_OEM_1 : oder ö */ + if ( SC == 48) return VK_QUOTE; /* ' 222 VK_OEM_7 " oder Ä */ + if ( SC == 51) return VK_BKSLASH; /* ; 220 = \ oder # */ + + if ( SC == 59) return VK_COMMA; /* ; 188 = , oder , */ + if ( SC == 60) return VK_PERIOD; /* ; 190 = . oder . */ + if ( SC == 61) return VK_SLASH; /* ; 191 = / oder - */ + + if ( SC == 65) return VK_SPACE; /* ; 32 VK_SPACE = oder */ + else + return SC; +} + +KMX_DWORD map_SC(KMX_DWORD VK ){ + if ( VK == VK_HYPHEN) return 20; /* ; = oder */ + if ( VK == VK_EQUAL) return 21; /* ; 187 = oder ' */ + + if ( VK == VK_LBRKT) return 34; /* ; 186 VK_OEM_4 [ oder ü */ + if ( VK == VK_RBRKT) return 35; /* ; VK_RBRKT = oder */ + + if ( VK == VK_ACCENT) return 47; /* ; 192 VK_OEM_1 : oder ö */ + if ( VK == VK_QUOTE) return 48; /* ' 222 VK_OEM_7 " oder Ä */ + if ( VK == VK_BKSLASH) return 51; /* ; = oder */ + + if ( VK == VK_COMMA) return 59; /* ; = oder */ + if ( VK == VK_PERIOD) return 60; /* ; = oder */ + if ( VK == VK_SLASH) return 61; /* ; = oder */ + + if ( VK == VK_SPACE) return 65; /* ; VK_SPACE = oder */ + else + return VK; +} + +// _S2 ToDo something does not work yet +// query All_Vector +// return RETURN NON SHIFTED CHAR [1] the VirtualKey of the Other Keyboard for given Scancode +KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ + + for( int i=0; i< (int)All_Vector[0].size();i++) { + + //number keys return unshifted value ( e.g. 1 not !) + if(SC <= 19) { + if ( All_Vector[0][i][0] == SC) + return All_Vector[1][i][1]; + } + + // other keys + if((SC > 19) ) { + if ( All_Vector[0][i][0] == map_SC(SC)) { + // normal capital characters return the value of capital char ( e.g. A) + if ((All_Vector[1][i][2] >= 65 ) && (All_Vector[1][i][2] < 91 )) { + //int sdfghj= map_SC(SC); + //int sdfgheuj= map_VK(SC); + return All_Vector[1][i][2]; + } + // special characters return Keyman defined values (e.g. VK_ACCENT) + else { + //int test = map_SC(SC); + //int sdfghj= map_VK(SC); + return map_VK(SC); + } + } + } + } +return 0; +} + +// _S2 ToDo something does not work yet +// query All_Vector +// return RETURN NON SHIFTED CHAR [1] the VirtualKey of the Other Keyboard for given Scancode +KMX_DWORD get_VirtualKey_Other_From_SC_BAK2(KMX_DWORD SC , v_dw_3D &All_Vector){ + // find correct row of char in US + for( int k=1; k< (int)All_Vector.size();k++) { + for( int i=0; i< (int)All_Vector[1].size()-1;i++) { + + // _S2 what if we use column 3(altgr) and 4 (shift+altgr) ?? + + int unshiftedchar = All_Vector[k][i][1]; + if (unshiftedchar < 57) { + // if (SC < 57) { + // if( true) { + // values for numbers are stored in column All_Vector[1][i][ 1 ] + //if ( All_Vector[k][i][0] == SC ) { + if ( All_Vector[0][i][0] == SC ) { + //wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[k][i][2],All_Vector[k][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); + //return All_Vector[k][i][1]; + //return All_Vector[1][i][1]; + return map_VK( SC); + } + } + else { + // shifted values e.g. "Q" (=81) are stored in column All_Vector[1][i][ 2 ] + if ( All_Vector[k][i][0] == SC ) { + //wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][2],All_Vector[1][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); + return map_VK(SC); + } + } + + /*if (IsKeyIn_VKMap(SC)) + return SC; //_S2 what do I return if not found??*/ } } return 0; @@ -570,24 +708,44 @@ const int Lin_KM__map(int i) { //All_Vector_[ 1 ][ in which line of US did find the value 58 ][ take second or third column wherever I find 58 ]] // finds 59th row (not value 59) - //if (i == 32 ) return ; /* */ - if (i == 186 ) return 252; /* SEMI/COLON */ - if (i == 187 ) return 43; /* */ - if (i == 188 ) return 59; /* COMMA */ - if (i == 189 ) return 45; /* */ - if (i == 190 ) return 58; /* PERIOD */ - if (i == 191 ) return 51; /* SLASH */ - //if (i == 191 ) return 63; /* */ - if (i == 192 ) return 246; /* */ - if (i == 219 ) return 223; /* */ - if (i == 220 ) return 92; /* BACKSLASH */ - if (i == 221 ) return 180; /* */ - if (i == 222 ) return 228; /* */ - //if (i == 223 ) return ; /* */ - if (i == 226 ) return 60; /* */ + //if (i == 32 ) return ; /* */5 + //if (i == 186 ) return 252; /* Ü */ + if (i == 187 ) + return 43; /* + * */ + if (i == 188 ) + return 59; /* COMMA */ + // if (i == 189 ) + // return 45; /* - _ */ + if (i == 190 ) + return 58; /* PERIOD */ + if (i == 191 ) + return 35; /* # ' */ + //if (i == 191 ) return 63; /* */ + + //if (i == 214 ) return 192; /* Ö */ + if (i == 219 ) + return 223; /* Sharp-S+ ? */ + if (i == 220 ) + return 92; /* ^ ° */ + //if (i == 221 ) + //return 180; /* ' ` */ + + //if (i == 223 ) return ; /* */ + if (i == 226 ) + return 60; /* < > */ - if (i == 65105 ) - return 92; /* */ + if (i == 65105 ) + return 92; /* */ + + // das is t nötig, damit werte in rgkey[]rg_ss[0,1] geschrieben werden + // this is?? this is pos of rgKey[pos] + if (i == 192 ) + return 214; /* Ö */ + if (i == 186 ) + return 220; /* Ü */ + //if (i == 222 ) return 228; /* Ä */ + if (i == 222 ) + return 196; /* Ä */ return i; } diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 98168a8c16..eeea5655bf 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -34,12 +34,27 @@ const KMX_DWORD KMX_VKMap[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', //_S2 those might not work correctly yet*/ - VK_SPACE, - VK_ACCENT, VK_HYPHEN, VK_EQUAL, - VK_LBRKT, VK_RBRKT, VK_BKSLASH, - VK_COLON, VK_QUOTE, - VK_COMMA, VK_PERIOD, VK_SLASH, - VK_xDF, VK_OEM_102,/**/ + + VK_ACCENT, /* 192 VK_OEM_3 */ + VK_HYPHEN, /* - 189 VK_OEM_MINUS */ + VK_EQUAL, /* = 187 VK_OEM_PLUS */ + + VK_LBRKT, /* [ 219 VK_OEM_4 */ + VK_RBRKT, /* ] 221 VK_OEM_6 */ + VK_BKSLASH, /* \ 220 VK_OEM_5 */ + + VK_COLON, /* ; 186 VK_OEM_1 or ö */ + VK_QUOTE, /* ' 222 VK_OEM_7 or Ä */ + + VK_COMMA, /* , 188 VK_OEM_COMMA */ + VK_PERIOD, /* . 190 VK_OEM_PERIOD */ + VK_SLASH, /* / 191 VK_OEM_2 */ + + VK_SPACE, /* 32 */ + + VK_xDF, /* ß (?) 223*/ + VK_OEM_102, /* < > | 226 */ + 0 }; // _S2 how many fielsds do I need?? diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 7f8b5d775a..f1b8431b95 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -679,10 +679,13 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std // Scroll through the Scan Code (SC) values and get the valid Virtual Key (VK) // values in it. Then, store the SC in each valid VK so it can act as both a // flag that the VK is valid, and it can store the SC value. + // _S2 this does not find exactly the same keys as the windows version does(windows finds more) + // but the ones we need for mcompile are there //for(UINT sc = 0x01; sc <= 0x7f; sc++) { for(UINT sc = 0x0; sc <= 0x7f; sc++) { KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector); // _S2 get this from my Vector uint key_vk = key->VK() ; + wprintf(L" sc= %i --- VK = %i (%c)\n",sc,key_vk,key_vk); if(key->VK() != 0) { rgKey[key->VK()] = key; } else { @@ -690,11 +693,6 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std } } - // where in rgkey do I store Numpad??? - // _S2 do we need NUMPAD now or later? If so we need to add Numpad values to All_Vector ( which has only values a-z) -// _S2 use KMX_VirtualKey !! - // _S2 do I need NUMPAD + SPECIAL_SHIFT for first draft ?? - // add the special keys that do not get added from the code above for(UINT ke = VK_NUMPAD0; ke <= VK_NUMPAD9; ke++) { rgKey[ke] = new KMX_VirtualKey(hkl, ke, All_Vector); } @@ -728,6 +726,13 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std } } */ +// _S2 test rgkey can go later + for(UINT iKey = 160; iKey < rgKey.size(); iKey++) { + if(rgKey[iKey] != NULL) { + wprintf(L" Key Nr %i is available\n",iKey); + } + } + // _S2 in this part we skip shiftstates 4, 5, 8, 9 for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { @@ -745,6 +750,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std for(int caps = 0; caps <= 1; caps++) { + wprintf(L"this was ss %i - ikey %i\n",ss ,iKey); //_S2 TODO //_S2 get char - do I need rc ?? ( was rc = ToUnicodeEx...) std::wstring VK_Other = get_VirtualKey_Other_from_iKey(mapped_ikey, ss, caps, All_Vector); @@ -771,7 +777,6 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std // fill m_rgss and m_rgfDeadkey ( m_rgfDeadkey will be done later) //rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps == 0)); rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps == 0)); - //rgKey[196]->KMX_SetShiftState(ss, VK_Other, false, (caps == 0)); //} // from rc==1 // } // from rc > 0 @@ -798,13 +803,14 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std write_RGKEY_FileToVector(V_map, "map.txt"); CompareVector_To_VectorOfFile_RGKEY( V_win, V_lin,V_map);*/ - -std::vector< int > TestValues = {48,49,50,52,53,54,55,56,57,54,65,89,189,188}; - -for ( int i=0; i < TestValues.size();i++) { - wprintf(L"Results for %i\t: %s %s %s %s \n", TestValues[i], rgKey[TestValues[i]]->KMX_GetShiftState(Base,0).c_str(), rgKey[TestValues[i]]->KMX_GetShiftState(Base,1).c_str() , rgKey[TestValues[i]]->KMX_GetShiftState(Shft,0).c_str(), rgKey[TestValues[i]]->KMX_GetShiftState(Shft,1).c_str()); -} - + //std::vector< int > TestValues = {48,49,50,52,53,54,55,56,57,54,65,89,189,188}; + //std::vector< int > TestValues = {48,49,50,52,53,54,55,56}; + wprintf(L"-----------------\nNow the tests:\n"); + std::vector< int > TestValues = {65}; + for ( int i=0; i < TestValues.size();i++) { + wprintf(L"Results for %i\t: %s %s %s %s \n", TestValues[i], rgKey[TestValues[i]]->KMX_GetShiftState(Base,0).c_str(), rgKey[TestValues[i]]->KMX_GetShiftState(Base,1).c_str() , rgKey[TestValues[i]]->KMX_GetShiftState(Shft,0).c_str(), rgKey[TestValues[i]]->KMX_GetShiftState(Shft,1).c_str()); + } + wprintf(L"-----------------\n"); //------------------------------------------------------------- // Now that we've collected the key data, we need to From ee328bb7a2a2e29bb0724afcf6c019c65807ad6a Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 27 Oct 2023 22:52:24 +0200 Subject: [PATCH 108/327] feat(linux): mcompile fill rgKey 220 (221) --- linux/mcompile/keymap/keymap.cpp | 358 ++++++++-------------- linux/mcompile/keymap/keymap.h | 9 +- linux/mcompile/keymap/mc_import_rules.cpp | 34 +- linux/mcompile/keymap/mcompile.cpp | 6 +- 4 files changed, 153 insertions(+), 254 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 6a4611cc5f..55dba6edbd 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -103,17 +103,6 @@ KMX_DWORD convertNamesToValue(std::wstring tok_wstr){ //initializing //first[L"grave"] 96 = /*FE50; ???*/; - //first[L"apostrophe"] = /*27;*/; - //first[L"braceleft"] = /*7B;*/; - //first[L"braceright"] = /*7D ;*/; - first[L"underscore"] = 95 /*5F;*/; - first[L"plus"] = 43 /*2B;*/; - first[L"semicolon"] = 59/*3B;*/; - first[L"quotedbl"] = 34 /*22;*/; - first[L"less"] = 60/* 3C;*/; - first[L"greater"] = 62 /*3E ;*/; - first[L"question"] = 63 /*3F*/; - first[L"bar"] = 124 /*7C*/; first[L"exclam"] = 33; first[L"at"] = 64; @@ -125,24 +114,33 @@ KMX_DWORD convertNamesToValue(std::wstring tok_wstr){ first[L"asterisk"] = 42; first[L"parenleft"] = 40; first[L"parenright"] = 41; - first[L"braceleft"] = 123; /* { */ - first[L"braceright"] = 125; /* } */ -//todo dieser block ist nötig; nicht dieVK-Nr - first[L"equal"] = 61; /* BB = 187 VK_OEM_PLUS*/ - first[L"backslash"] = 92; /* DC = 220 \ | VK_OEM_5 */ - first[L"bracketleft"] = 91; /* DB = 219 [ { VK_OEM_4 */ - first[L"bracketright"] = 93; /* DD = 221 ] } VK_OEM_6 */ - first[L"colon"] = 58; /* BA = 186 ; VK_OEM_1 */ - first[L"comma"] = 44; /* BC = 188 , VK_OEM_COMMA */ - first[L"period"] = 46; /* BE = 190 . VK_OEM_PERIOD */ - first[L"slash"] = 47; /* BF = 191 / ? VK_OEM_2 */ - first[L"minus"] = 45; /* BD = 189 - VK_OEM_MINUS */ - first[L"space"] = 32; /* 20 = 32 ? */ - first[L"apostrophe"] = 39; /* DE = 222 ' " ? VK_OEM_7 */ - first[L"dead_acute"] = VK_ACCENT; /* C0 = 192 ` ~ VK_OEM_3 */ - first[L"dead_grave"] = VK_ACCENT; /* C0 = 192 ? */ - first[L"ssharp"] = VK_xDF; /* DF = 223 ß */ + first[L"minus"] = 45; /* BD = 189 - VK_OEM_MINUS */ + first[L"underscore"] = 95; /* 5F = 95 _;*/ + first[L"equal"] = 61; /* BB = 187 = VK_OEM_PLUS*/ + first[L"plus"] = 43; /* 2B = 43 + ;*/ + first[L"bracketleft"] = 91; /* DB = 219 [ { VK_OEM_4 */ + first[L"braceleft"] = 123; /* 7B = 123 { */ + first[L"bracketright"] = 93; /* DD = 221 ] } VK_OEM_6 */ + first[L"braceright"] = 125; /* 7d = 125 } */ + first[L"semicolon"] = 59; /* 3B = 59 ; ;*/ + first[L"colon"] = 58; /* BA = 186 ; VK_OEM_1 */ + first[L"apostrophe"] = 39; /* DE = 222 ' " ? VK_OEM_7 */ + first[L"quotedbl"] = 34; /* 22 = 34 " ;*/ + first[L"backslash"] = 92; /* DC = 220 \ | VK_OEM_5 */ + first[L"bar"] = 124; /* 7C = 124 | */ + first[L"comma"] = 44; /* BC = 188 , VK_OEM_COMMA */ + first[L"less"] = 60; /* 3C = 60 < ;*/ + first[L"period"] = 46; /* BE = 190 . VK_OEM_PERIOD */ + first[L"greater"] = 62; /* 3E = 62 > ;*/ + first[L"slash"] = 47; /* BF = 191 / ? VK_OEM_2 */ + first[L"question"] = 63; /* 3F = 63 ? */ + first[L"space"] = 32; /* 20 = 32 */ + + first[L"dead_acute"] = 180; /* C0 = 192 ` ~ VK_OEM_3 */ + first[L"grave"] = 96; /* C0 = 192 ? */ + first[L"ssharp"] = 223; /* DF = 223 ß */ + //first[L"equal"] = VK_EQUAL; /* BB = 187 VK_OEM_PLUS*/ //first[L"backslash"] = VK_BKSLASH; /* DC = 220 \ | VK_OEM_5 */ @@ -246,21 +244,21 @@ int replace_PosKey_with_Keycode_use_Lin(std::string in) { int out = returnIfCharInvalid; // _S2 these are the Scancode-Values we use in Keyman ( = like the windows scancodes) - // NAME IN SYMBOLS-FILE KEYCODE (LIN STYLE) (WIN STYLE) VK_US VK_DE - /*on US keyb;*/ - if ( in == "key") out = 49; /* 0X VK_ */ // TOASK correct ??? - else if ( in == "key") out = 10; /* 0X02 VK_1 */ - else if ( in == "key") out = 11; /* 0X03 VK_2 */ - else if ( in == "key") out = 12; /* 0X04 VK_3 */ - else if ( in == "key") out = 13; /* 0X05 VK_4 */ - else if ( in == "key") out = 14; /* 0X06 VK_5 */ - else if ( in == "key") out = 15; /* 0X07 VK_6 */ - else if ( in == "key") out = 16; /* 0X08 VK_7 */ - else if ( in == "key") out = 17; /* 0X09 VK_8 */ - else if ( in == "key") out = 18; /* 0X0A VK_9 */ - else if ( in == "key") out = 19; /* 0X0B VK_0 */ - else if ( in == "key") out = 20; /*out = 61;*/ /* 0X0C VK_MINUS de ẞ*/ - else if ( in == "key") out = 21; /* 0X0D VK_EQUALS DE ' */ + // NAME IN SYMBOLS-FILE KEYCODE (LIN STYLE) (WIN STYLE) VK_US VK_DE + /*on US keyb;*/ + if ( in == "key") out = 49; /* VK_ */ // TOASK correct ??? + else if ( in == "key") out = 10; /* 0X02 VK_1 */ + else if ( in == "key") out = 11; /* 0X03 VK_2 */ + else if ( in == "key") out = 12; /* 0X04 VK_3 */ + else if ( in == "key") out = 13; /* 0X05 VK_4 */ + else if ( in == "key") out = 14; /* 0X06 VK_5 */ + else if ( in == "key") out = 15; /* 0X07 VK_6 */ + else if ( in == "key") out = 16; /* 0X08 VK_7 */ + else if ( in == "key") out = 17; /* 0X09 VK_8 */ + else if ( in == "key") out = 18; /* 0X0A VK_9 */ + else if ( in == "key") out = 19; /* 0X0B VK_0 */ + else if ( in == "key") out = 20; /*out = 61;*/ /* 0X0C VK_MINUS de ẞ*/ + else if ( in == "key") out = 21; /* 0X0D VK_EQUALS DE ' */ else if ( in == "key") out = 24; /* 0X10 VK_Q */ else if ( in == "key") out = 25; /* 0X11 VK_W */ @@ -353,31 +351,17 @@ int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { // get key name US stored in [0][i][0] and copy to name in "other"-block[1][i][0] All_Vector[1][i][0] = All_Vector[0][i][0]; -/* - // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] - All_Vector[1][i][0+1] = getKeyvalsFromKeymap(keymap,keycode_map[All_Vector[0][i][0]],0); //shift state: unshifted:0 - All_Vector[1][i][1+1] = getKeyvalsFromKeymap(keymap,keycode_map[All_Vector[0][i][0]],1); //shift state: shifted:1 -KMX_DWORD inValue = All_Vector[0][i][0]; -KMX_DWORD KeycodeMapped_inValue = keycode_map[All_Vector[0][i][0]]; -KMX_DWORD resultOf_GETKEYVALS = getKeyvalsFromKeymap(keymap,keycode_map[All_Vector[0][i][0]],0); -KMX_DWORD resultOf_GETKEYVALS_shift = getKeyvalsFromKeymap(keymap,keycode_map[All_Vector[0][i][0]],1); - -wprintf(L" inValue: %i -KeycodeMapped_inValue: %i, resultOf_GETKEYVALS: %i , resultOf_GETKEYVALS_shift: %i : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",inValue,KeycodeMapped_inValue,resultOf_GETKEYVALS,resultOf_GETKEYVALS_shift,(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); -*/ // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] All_Vector[1][i][0+1] = getKeyvalsFromKeymap(keymap,All_Vector[0][i][0],0); //shift state: unshifted:0 All_Vector[1][i][1+1] = getKeyvalsFromKeymap(keymap,All_Vector[0][i][0],1); //shift state: shifted:1 -KMX_DWORD inValue = All_Vector[0][i][0]; -KMX_DWORD KeycodeMapped_inValue = All_Vector[0][i][0]; -KMX_DWORD resultOf_GETKEYVALS = getKeyvalsFromKeymap(keymap,All_Vector[0][i][0],0); -KMX_DWORD resultOf_GETKEYVALS_shift = getKeyvalsFromKeymap(keymap,All_Vector[0][i][0],1); - -//wprintf(L" inValue: %i -KeycodeMapped_inValue: %i, resultOf_GETKEYVALS: %i , resultOf_GETKEYVALS_shift: %i : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",inValue,KeycodeMapped_inValue,resultOf_GETKEYVALS,resultOf_GETKEYVALS_shift,(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); - - + //KMX_DWORD inValue = All_Vector[0][i][0]; + //KMX_DWORD KeycodeMapped_inValue = All_Vector[0][i][0]; + //KMX_DWORD resultOf_GETKEYVALS = getKeyvalsFromKeymap(keymap,All_Vector[0][i][0],0); + //KMX_DWORD resultOf_GETKEYVALS_shift = getKeyvalsFromKeymap(keymap,All_Vector[0][i][0],1); + //wprintf(L" inValue: %i -KeycodeMapped_inValue: %i, resultOf_GETKEYVALS: %i , resultOf_GETKEYVALS_shift: %i : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",inValue,KeycodeMapped_inValue,resultOf_GETKEYVALS,resultOf_GETKEYVALS_shift,(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); //wprintf(L" Keycodes US dw : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); //wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); @@ -414,7 +398,6 @@ KMX_DWORD writeKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_sta KMX_DWORD out2= getKeyvalsFromKeymap(keymap,ii,1); wprintf(L" ii = %i --> keymap = %i (%c)..%i(%c) \n",ii, out,out, out2,out2); } - } KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { @@ -438,7 +421,7 @@ KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state // _S2 what is 65104-65106, 65506, 21840 // _S2 if out of range of what ( ascii??) return 0 or other value ? if (out > 255) { - wprintf(L"out of range: found value out( %i) for keycode = %i /shift_state_pos %i (49= TLDE 21= VK_EQUALS 62 = RSHIFT on US keyboard) \n", out,keycode,shift_state_pos); + wprintf(L"out of range: found value out( %i) for keycode = %i /shift_state_pos %i (49= TLDE 21= VK_EQUALS on US keyboard) \n", out,keycode,shift_state_pos); out = 0; } @@ -485,163 +468,94 @@ bool test_single(v_dw_3D &V) { wprintf(L" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); return true; } -// _S2 ToDo something does not work yet -// query All_Vector -// return RETURN NON SHIFTED CHAR [1] the VirtualKey of the Other Keyboard for given Scancode -KMX_DWORD get_VirtualKey_Other_From_SC_BAK(KMX_DWORD SC , v_dw_3D &All_Vector){ - // find correct row of char in US - for( int k=0; k< (int)All_Vector.size()-1;k++) { - for( int i=0; i< (int)All_Vector[1].size()-1;i++) { - // _S2 what if we use column 3(altgr) and 4 (shift+altgr) ?? +KMX_DWORD map_To_VK(KMX_DWORD SC ){ + // if there is a Keyman VK.. defined map to Keyman VKcode - int unshiftedchar = All_Vector[k][i][1]; - if (unshiftedchar < 57) { - // if (SC < 57) { - // if( true) { - // values for numbers are stored in column All_Vector[1][i][ 1 ] - //if ( All_Vector[k][i][0] == SC ) { - if ( All_Vector[0][i][0] == SC ) { - //wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[k][i][2],All_Vector[k][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); - //return All_Vector[k][i][1]; - return All_Vector[1][i][1]; - } - } - else { - // shifted values e.g. "Q" (=81) are stored in column All_Vector[1][i][ 2 ] - if ( All_Vector[k][i][0] == SC ) { - //wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][2],All_Vector[1][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); - return All_Vector[1][i][2]; - } - } + if ( SC == 49) return VK_BKSLASH; /* ; 220 = ` oder ^ */ + if ( SC == 20) return VK_LBRKT; /* ; 219 = - oder ß */ + if ( SC == 21) return VK_RBRKT; /* ; 221 = = oder ' */ - /*if (IsKeyIn_VKMap(SC)) - return SC; //_S2 what do I return if not found??*/ - } - } - return 0; -} + if ( SC == 34) return VK_COLON; /* ; 186 VK_OEM_4 = [ oder ü */ + if ( SC == 35) return VK_EQUAL; /* ; 187 = ] oder + */ -KMX_DWORD map_VK(KMX_DWORD SC ){ - if ( SC == 20) return VK_HYPHEN; /* ; 189 = - oder ß */ - if ( SC == 21) return VK_EQUAL; /* ; 187 = oder ' */ + if ( SC == 47) return VK_ACCENT; /* ; 192 VK_OEM_1 = : oder ö */ + if ( SC == 48) return VK_QUOTE; /* ' 222 VK_OEM_7 = " oder Ä */ + if ( SC == 51) return VK_SLASH; /* ; 191 = \ oder # */ - if ( SC == 34) return VK_LBRKT; /* ; 186 VK_OEM_4 [ oder ü */ - if ( SC == 35) return VK_RBRKT; /* ; 221 = ] oder + */ + if ( SC == 59) return VK_COMMA; /* ; 188 = , oder , */ + if ( SC == 60) return VK_PERIOD; /* ; 190 = . oder . */ + if ( SC == 61) return VK_HYPHEN; /* ; 189 = / oder - */ - if ( SC == 47) return VK_COLON; /* ; 192 VK_OEM_1 : oder ö */ - if ( SC == 48) return VK_QUOTE; /* ' 222 VK_OEM_7 " oder Ä */ - if ( SC == 51) return VK_BKSLASH; /* ; 220 = \ oder # */ - - if ( SC == 59) return VK_COMMA; /* ; 188 = , oder , */ - if ( SC == 60) return VK_PERIOD; /* ; 190 = . oder . */ - if ( SC == 61) return VK_SLASH; /* ; 191 = / oder - */ - - if ( SC == 65) return VK_SPACE; /* ; 32 VK_SPACE = oder */ + if ( SC == 65) return VK_SPACE; /* ; 32 VK_SPACE = oder */ else return SC; } -KMX_DWORD map_SC(KMX_DWORD VK ){ - if ( VK == VK_HYPHEN) return 20; /* ; = oder */ - if ( VK == VK_EQUAL) return 21; /* ; 187 = oder ' */ +// return RETURN NON SHIFTED CHAR [1] the VirtualKey of the US Keyboard for given Scancode +KMX_DWORD get_VirtualKey_Other_Layer1_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ + // find correct row of char in US + for( int i=0; i< (int)All_Vector[0].size()-1;i++) { + if ( All_Vector[0][i][0] == SC ) { + //wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- ",SC , i, All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2] ); + return All_Vector[1][i][1] ; + } + } + return 0; //_S2 what do I return if not found?? +} +// return RETURN NON SHIFTED CHAR [1] the VirtualKey of the US Keyboard for given Scancode +KMX_DWORD get_VirtualKey_Other_Layer2_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ + // find correct row of char in US + for( int i=0; i< (int)All_Vector[0].size()-1;i++) { + if ( All_Vector[0][i][0] == SC ) { + //wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- ",SC , i, All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2] ); + return All_Vector[1][i][2] ; + } + int ertzu=99; + } - if ( VK == VK_LBRKT) return 34; /* ; 186 VK_OEM_4 [ oder ü */ - if ( VK == VK_RBRKT) return 35; /* ; VK_RBRKT = oder */ + int ertzwrtu=99; + return 0; //_S2 what do I return if not found?? - if ( VK == VK_ACCENT) return 47; /* ; 192 VK_OEM_1 : oder ö */ - if ( VK == VK_QUOTE) return 48; /* ' 222 VK_OEM_7 " oder Ä */ - if ( VK == VK_BKSLASH) return 51; /* ; = oder */ - - if ( VK == VK_COMMA) return 59; /* ; = oder */ - if ( VK == VK_PERIOD) return 60; /* ; = oder */ - if ( VK == VK_SLASH) return 61; /* ; = oder */ - - if ( VK == VK_SPACE) return 65; /* ; VK_SPACE = oder */ - else - return VK; + int eerurziurtzu=99; } -// _S2 ToDo something does not work yet // query All_Vector // return RETURN NON SHIFTED CHAR [1] the VirtualKey of the Other Keyboard for given Scancode KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ for( int i=0; i< (int)All_Vector[0].size();i++) { - //number keys return unshifted value ( e.g. 1 not !) if(SC <= 19) { if ( All_Vector[0][i][0] == SC) return All_Vector[1][i][1]; } - + // other keys if((SC > 19) ) { - if ( All_Vector[0][i][0] == map_SC(SC)) { + if ( All_Vector[0][i][0] == SC) { + // normal capital characters return the value of capital char ( e.g. A) - if ((All_Vector[1][i][2] >= 65 ) && (All_Vector[1][i][2] < 91 )) { - //int sdfghj= map_SC(SC); - //int sdfgheuj= map_VK(SC); + if ((All_Vector[1][i][2] >= 65 ) && (All_Vector[1][i][2] < 91 )) return All_Vector[1][i][2]; - } + // special characters return Keyman defined values (e.g. VK_ACCENT) - else { - //int test = map_SC(SC); - //int sdfghj= map_VK(SC); - return map_VK(SC); - } + else + //return All_Vector[1][i][1]; + return map_To_VK(SC); } } } return 0; } - -// _S2 ToDo something does not work yet -// query All_Vector -// return RETURN NON SHIFTED CHAR [1] the VirtualKey of the Other Keyboard for given Scancode -KMX_DWORD get_VirtualKey_Other_From_SC_BAK2(KMX_DWORD SC , v_dw_3D &All_Vector){ - // find correct row of char in US - for( int k=1; k< (int)All_Vector.size();k++) { - for( int i=0; i< (int)All_Vector[1].size()-1;i++) { - - // _S2 what if we use column 3(altgr) and 4 (shift+altgr) ?? - - int unshiftedchar = All_Vector[k][i][1]; - if (unshiftedchar < 57) { - // if (SC < 57) { - // if( true) { - // values for numbers are stored in column All_Vector[1][i][ 1 ] - //if ( All_Vector[k][i][0] == SC ) { - if ( All_Vector[0][i][0] == SC ) { - //wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[k][i][2],All_Vector[k][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); - //return All_Vector[k][i][1]; - //return All_Vector[1][i][1]; - return map_VK( SC); - } - } - else { - // shifted values e.g. "Q" (=81) are stored in column All_Vector[1][i][ 2 ] - if ( All_Vector[k][i][0] == SC ) { - //wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][2],All_Vector[1][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); - return map_VK(SC); - } - } - - /*if (IsKeyIn_VKMap(SC)) - return SC; //_S2 what do I return if not found??*/ - } - } - return 0; -} - +// _S2 not needed, can go later // return RETURN NON SHIFTED CHAR [1] the VirtualKey of the US Keyboard for given Scancode KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ // find correct row of char in US for( int i=0; i< (int)All_Vector[0].size()-1;i++) { if ( All_Vector[0][i][0] == SC ) { //wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- ",SC , i, All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2] ); - return All_Vector[0][i][1] ; // shouldn this be [0][i][2]? - //return All_Vector[0][i][2] ; // would be shifted version + return All_Vector[0][i][1] ; } } return 0; //_S2 what do I return if not found?? @@ -671,26 +585,18 @@ KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ return 0; //_S2 what do I return if not found?? } - +// return the position of the VK in Other in All_Vector KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector){ // find correct row of char in US for( int i=0; i< (int)All_Vector[0].size()-1;i++) { if ( ( All_Vector[1][i][1] == VK_Other ) || ( All_Vector[1][i][2] == VK_Other )) { - //if ( ( All_Vector[0][i][1] == VK_US ) ) { - //wprintf(L" VK_Other= %i .. i= %i .. %i\t\t %i (%c) : %i (%c) +++ %i\t\t %i (%c) : %i (%c) \n",VK_Other , i, - // All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2], - // All_Vector[1][i][0] , All_Vector[1][i][1] ,All_Vector[1][i][1] , All_Vector[1][i][2] , All_Vector[1][i][2] ); return i; } } return 0; //_S2 what do I return if not found?? } -KMX_DWORD get_position_From_VirtualKey_Other_2(KMX_DWORD VK_Other , v_dw_3D &All_Vector){ - - return VK_Other; //_S2 what do I return if not found?? -} - +// _S2 maybe not needed bool IsKeyIn_VKMap(UINT SC) { for (int i=0; i< sizeof( KMX_VKMap)/sizeof( KMX_VKMap[0]); i++) { if ( SC == KMX_VKMap[i]) @@ -699,53 +605,49 @@ bool IsKeyIn_VKMap(UINT SC) { return false; } - -const int Lin_KM__map(int i) { - +const int Lin_KM__map(int i, v_dw_3D &All_Vector) { // MAP: // VK KEYMAN-STYLE -> KEYCODE LINUX-STYLE // e.g 188 -> 59 //All_Vector_[ 1 ][ in which line of US did find the value 58 ][ take second or third column wherever I find 58 ]] // finds 59th row (not value 59) + +//int vk0 = get_VirtualKey_Other_From_SC(dw, All_Vector); +//int vk1 = get_VirtualKey_US_From_SC(dw, All_Vector); +//int vk2 = get_VirtualKey_Other_Layer1_From_SC(dw, All_Vector); +int vk3 = get_VirtualKey_Other_Layer2_From_SC(dw, All_Vector); + +if ( i>160) +{ + wprintf(L"dw = %i i=%i ----> vk3=%i\n",dw,i, vk3); +} + +//return vk3; + + + //if (i == 32 ) return ; /* */5 //if (i == 186 ) return 252; /* Ü */ - if (i == 187 ) - return 43; /* + * */ - if (i == 188 ) - return 59; /* COMMA */ - // if (i == 189 ) - // return 45; /* - _ */ - if (i == 190 ) - return 58; /* PERIOD */ - if (i == 191 ) - return 35; /* # ' */ - //if (i == 191 ) return 63; /* */ - - //if (i == 214 ) return 192; /* Ö */ - if (i == 219 ) - return 223; /* Sharp-S+ ? */ - if (i == 220 ) - return 92; /* ^ ° */ - //if (i == 221 ) - //return 180; /* ' ` */ - - //if (i == 223 ) return ; /* */ - if (i == 226 ) - return 60; /* < > */ + if (i == 187 ) {wprintf(L" swapped: i (%i) to 43 \n",dw,i); return 43; }/* + * */ + if (i == 188 ) {wprintf(L" swapped: i (%i) to 59 \n",dw,i); return 59; }/* COMMA */ + if (i == 189 ) {wprintf(L" swapped: i (%i) to 95 \n",dw,i); return 95; }/* - _ */ + if (i == 190 ) {wprintf(L" swapped: i (%i) to 58 \n",dw,i); return 58; }/* PERIOD */ + if (i == 191 ) {wprintf(L" swapped: i (%i) to 35 \n",dw,i); return 35; }/* # ' */ + //if (i == 191 ) {wprintf(L" swapped: i (%i) to 63 \n",dw,i); return 63; }/* */ + //if (i == 214 ) {wprintf(L" swapped: i (%i) to 192 \n",dw,i); return 192; }/* Ö */ + if (i == 219 ) {wprintf(L" swapped: i (%i) to 223 \n",dw,i); return 223; }/* Sharp-S+ ? */ + if (i == 220 ) {wprintf(L" swapped: i (%i) to 92 \n",dw,i); return 92; }/* ^ ° */ + //if (i == 221 ) {wprintf(L" swapped: i (%i) to 180 \n",dw,i); return 180; }/* ' ` */ + //if (i == 223 ) {wprintf(L" swapped: i (%i) to 59 \n",dw,i); return ; }/* */ - if (i == 65105 ) - return 92; /* */ + if (i == 226 ) {wprintf(L" swapped: i (%i) to 60 \n",dw,i); return 60; }/* < > */ + if (i == 65105 ) {wprintf(L" swapped: i (%i) to 92 \n",dw,i); return 92; }/* */ - // das is t nötig, damit werte in rgkey[]rg_ss[0,1] geschrieben werden - // this is?? this is pos of rgKey[pos] - if (i == 192 ) - return 214; /* Ö */ - if (i == 186 ) - return 220; /* Ü */ - //if (i == 222 ) return 228; /* Ä */ - if (i == 222 ) - return 196; /* Ä */ + // e.g. rgKey[192] contains character 214 + if (i == 192 ) {wprintf(L" swapped: i (%i) to 214 \n",dw,i); return 214; }/* Ö */ + if (i == 186 ) {wprintf(L" swapped: i (%i) to 220 \n",dw,i); return 220; }/* Ü */ + if (i == 222 ) {wprintf(L" swapped: i (%i) to 196 \n",dw,i); return 196; }/* Ä */ return i; } diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index eeea5655bf..4f71463f18 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -57,7 +57,7 @@ const KMX_DWORD KMX_VKMap[] = { 0 }; -// _S2 how many fielsds do I need?? +// _S2 how many fields do I need?? // mapping between Linux keycodes and keyman SC const int keycode_map[60]={ 0, /* */ @@ -122,6 +122,7 @@ const int keycode_map[60]={ 0, /* */ }; +// _S2 not used-can go later // _S2 how many fielsds do I need?? const int Lin_KM__map_arr[70]={ 0, /* */ @@ -200,6 +201,7 @@ const int Lin_KM__map_arr[70]={ }; const int Lin_KM__map(int i); +const int Lin_KM__map(int i, v_dw_3D &All_Vector); // this is what we return when we find an invalid character //_S2 Which character do we use in that case? 0 or FFFF or 32 or ?? @@ -226,12 +228,13 @@ int replace_PosKey_with_Keycode_use_Lin(std::string in); // create an empty 2D vector containing "--" in all fields v_dw_2D create_empty_2D(int dim_rows, int dim_shifts); -// get Keyvals from VectorFile.txt and insert into All_Vector -//bool InsertKeyvalsFromVectorFile(v_dw_3D &All_Vector); // query All_Vector // return the VirtualKey of the Other Keyboard for given Scancode KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); +KMX_DWORD get_VirtualKey_Other_Layer1_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); +KMX_DWORD get_VirtualKey_Other_Layer2_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); + // return the VirtualKey of the US Keyboard for given Scancode KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); // return the Scancode of for given VirtualKey of Other Keyboard diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index f1b8431b95..c767c70982 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -144,8 +144,6 @@ public: //right-hand keys, the left-hand scan code is returned. //If there is no translation, the function returns 0.*/ - - this->m_sc = get_SC_From_VirtualKey_Other(KMX_virtualKey, All_Vector); this->m_hkl = hkl; this->m_vk = KMX_virtualKey; @@ -488,7 +486,7 @@ public: // _S2 where to put this?? const int CODE__SIZE[] = { - -1, // undefined 0x00 + -1, // undefined 0x00 1, // CODE_ANY 0x01 2, // CODE_INDEX 0x02 0, // CODE_CONTEXT 0x03 @@ -497,14 +495,14 @@ const int CODE__SIZE[] = { 0, // CODE_RETURN 0x06 0, // CODE_BEEP 0x07 1, // CODE_DEADKEY 0x08 - -1, // unused 0x09 + -1, // unused 0x09 2, // CODE_EXTENDED 0x0A - -1, // CODE_EXTENDEDEND 0x0B (unused) + -1, // CODE_EXTENDEDEND 0x0B (unused) 1, // CODE_SWITCH 0x0C - -1, // CODE_KEY 0x0D (never used) + -1, // CODE_KEY 0x0D (never used) 0, // CODE_CLEARCONTEXT 0x0E 1, // CODE_CALL 0x0F - -1, // UC_SENTINEL_EXTENDEDEND 0x10 (not valid with UC_SENTINEL) + -1, // UC_SENTINEL_EXTENDEDEND 0x10 (not valid with UC_SENTINEL) 1, // CODE_CONTEXTEX 0x11 1, // CODE_NOTANY 0x12 2, // CODE_SETOPT 0x13 @@ -621,11 +619,9 @@ std::wstring get_VirtualKey_Other_from_iKey(KMX_DWORD iKey, ShiftState &ss, int // ss 0,2,4... if ( ss % 2 == 0) { - // aAAa 4$$4 if ( is_Letter(pos, All_Vector) || is_Number(pos, All_Vector)) icaps = ss+2-caps; - // ..:: ##'' else icaps = ss+1; @@ -636,11 +632,11 @@ std::wstring get_VirtualKey_Other_from_iKey(KMX_DWORD iKey, ShiftState &ss, int // aAAa 4$$4 if ( is_Letter(pos, All_Vector) || is_Number(pos, All_Vector)) icaps = ss+caps; - // ..:: ##'' else icaps = ss+1; } + return std::wstring(1, (int) All_Vector[1][pos][icaps]); } return L""; @@ -726,13 +722,12 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std } } */ -// _S2 test rgkey can go later - for(UINT iKey = 160; iKey < rgKey.size(); iKey++) { - if(rgKey[iKey] != NULL) { - wprintf(L" Key Nr %i is available\n",iKey); - } - } - + // _S2 test rgkey can go later + for(UINT iKey = 160; iKey < rgKey.size(); iKey++) { + if(rgKey[iKey] != NULL) { + wprintf(L" Key Nr %i is available\n",iKey); + } + } // _S2 in this part we skip shiftstates 4, 5, 8, 9 for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { @@ -740,7 +735,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std WCHAR sbBuffer[256]; // Scratchpad we use many places //UINT mapped_ikey = Lin_KM__map[iKey]; - UINT mapped_ikey = Lin_KM__map(iKey); + UINT mapped_ikey = Lin_KM__map(iKey, All_Vector); for(ShiftState ss = Base; ss <= loader.MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { if(ss == Menu || ss == ShftMenu) { @@ -750,7 +745,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std for(int caps = 0; caps <= 1; caps++) { - wprintf(L"this was ss %i - ikey %i\n",ss ,iKey); + //wprintf(L"this was ss %i - ikey %i\n",ss ,iKey); //_S2 TODO //_S2 get char - do I need rc ?? ( was rc = ToUnicodeEx...) std::wstring VK_Other = get_VirtualKey_Other_from_iKey(mapped_ikey, ss, caps, All_Vector); @@ -790,6 +785,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std // } from rc<0 } } + wprintf(L" Values for SC: %i\t: VK: %i \n", rgKey[iKey]->SC(),rgKey[iKey]->VK() ); } } diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 2e0c276b0d..006ef3095c 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -167,6 +167,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ LPKMX_KEYBOARD kmxfile; + if(!KMX_LoadKeyboard(infile, &kmxfile)) { KMX_LogError(L"Failed to load keyboard (%d)\n", errno ); return 3; @@ -388,7 +389,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon else ERROR = L" "; - wprintf(L" DoConvert-read i: %i \t(KMX_VKMap): %i (%c) \t---> vkUnderlying: %i (%c) \tshiftstate[%i]: ( %i ) \t---- > ch: %i (%c) \t%ls \t%ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, j, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); + wprintf(L" DoConvert-read i: %i \t(KMX_VKMap): %i (%c) \t---> vkUnderlying: %i (%c) \tshiftstate[%i]: ( %i ) \t---- > ch: %i (%c) \t%ls \t%ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, j, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); /* _S2 ToDo @@ -412,9 +413,6 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon KMX_ReportUnconvertedKeyboardRules(kbd); -// _S2 convert mcompile Step1: use (wrong) Datatype WCHAR (=wchar_t) -// _S2 convert mcompile Step2: use (OK) Datatype KMX_WCHAR (=char16_t) - if(!KMX_ImportRules(kbid, kbd, All_Vector, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 return FALSE; } From 1d7f8c4bc25fcbed073b063a7a14e750b8790f50 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 31 Oct 2023 17:37:34 +0100 Subject: [PATCH 109/327] feat(linux): mcompile use GDK to fill rgKeys --- linux/mcompile/keymap/keymap.cpp | 137 ++++++++++++++++++++-- linux/mcompile/keymap/keymap.h | 16 ++- linux/mcompile/keymap/mc_import_rules.cpp | 25 ++-- linux/mcompile/keymap/mcompile.cpp | 4 +- 4 files changed, 152 insertions(+), 30 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 55dba6edbd..1ab1b9840f 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -2,27 +2,144 @@ #include -/* -static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) -{ +std::wstring PrintKeymapForCodeReturnKeySym(GdkKeymap *keymap,guint VK, ShiftState ss, int caps ){ + //GdkKeymap *keymap; + GdkModifierType consumed; GdkKeymapKey *maps; + GdkEventKey* event; guint *keyvals; + gint *n_entries; + gint count; + guint keycode; + + GdkKeymapKey* keys; + gint n_keys; + + gdk_keymap_get_entries_for_keyval(keymap, VK,&keys,&n_keys); + + if( keys !=NULL) { + keycode = keys[n_keys-1].keycode; + + for( int k=0; k< n_keys; k++) { + guint kc= keys[n_keys-1].keycode; + } + } + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return L"1"; + + + //unshifted + if (( ss == Base ) && ( caps == 0 )) { + GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + } + + //SHIFT+CAPS + else if ( ( ss == Shft ) && ( caps ==1 )) { + GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + + } + + //Shift + else if (( ss == Shft ) && ( caps == 0 )) { + GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + + } + + //caps + else if (( ss == Base ) && ( caps == 1 )) { + GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + + } + + /*//ALT-GR + else if { + GdkModifierType MOD_AltGr = (GdkModifierType) ( GDK_MOD5_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + return *keyvals; + }*/ + + else + return L"0"; +} + +static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) { + GdkModifierType consumed; + GdkKeymapKey *maps; + GdkEventKey* event; + guint *keyvals; + guint *keyvalsReturn; + gint *n_entries; gint count; if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return; -// group0 D, group1 fr, group2, group3 US, + for (int i = 0; i < count; i++) { //if (maps[i].level > 0 || maps[i].group > 1) // continue; wprintf(L" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); } - //xkb_keymap_key_get_syms_by_level(keymap, keycode, ) + + for( int ii=10; ii<63; ii++) { + + //unshifted + GdkModifierType A1 = (GdkModifierType) (event->state & GDK_MODIFIER_MASK); + gdk_keymap_translate_keyboard_state (keymap, ii, (A1 ) , 0,keyvalsReturn, NULL, NULL, & consumed); + wprintf(L"\n ngdk_keymap_translate_keyboard_state: \t keycodeS=%u , n_entries %i\tUNSH: %s(%i)\t", ii, *n_entries, keyvalsReturn, *keyvalsReturn); + + //caps + gdk_keymap_translate_keyboard_state (keymap, ii, GDK_LOCK_MASK , 0,keyvalsReturn, NULL, NULL, & consumed); + wprintf(L" CAPS: %s(%i)\t", keyvalsReturn, *keyvalsReturn); + + //Shift + gdk_keymap_translate_keyboard_state (keymap, ii, GDK_SHIFT_MASK , 0,keyvalsReturn, NULL, NULL, & consumed); + wprintf(L" SH: %s(%i)\t", keyvalsReturn, *keyvalsReturn); + + //SHIFT+CAPS + GdkModifierType A4 = (GdkModifierType) (event->state | (GDK_SHIFT_MASK | GDK_LOCK_MASK)); + gdk_keymap_translate_keyboard_state (keymap, ii, A4 , 0,keyvalsReturn, NULL, NULL, & consumed); + wprintf(L" SH+CAPS: %s(%i) \t", keyvalsReturn, *keyvalsReturn); + + //ALT-GR + gdk_keymap_translate_keyboard_state (keymap, ii, GDK_MOD5_MASK , 0,keyvalsReturn, NULL, NULL, & consumed); + //wprintf(L"\n NEU1 ngdk_keymap_translate_keyboard_state: \t hardware_keycodeS=%u, keyvalsReturn: %s\n", 52, keyvalsReturn); + wprintf(L" ALTGR: %s(%i)", keyvalsReturn, *keyvalsReturn); + + //?? + gdk_keymap_translate_keyboard_state (keymap, ii, GDK_MOD1_MASK , 0,keyvalsReturn, NULL, NULL, & consumed); + // wprintf(L" NEU1 ngdk_keymap_translate_keyboard_state: \t hardware_keycodeS=%u, keyvalsReturn: %s\n", 52, keyvalsReturn); + //wprintf(L" A5: %s(%i)", keyvalsReturn, *keyvalsReturn); + + //?? + gdk_keymap_translate_keyboard_state (keymap, ii, GDK_MOD2_MASK , 0,keyvalsReturn, NULL, NULL, & consumed); + //wprintf(L" NEU1 ngdk_keymap_translate_keyboard_state: \t hardware_keycodeS=%u, keyvalsReturn: %s\n", 52, keyvalsReturn); + //wprintf(L" A6: %s(%i)", keyvalsReturn, *keyvalsReturn); + + //?? + gdk_keymap_translate_keyboard_state (keymap, ii, GDK_MOD3_MASK , 0,keyvalsReturn, NULL, NULL, & consumed); + // wprintf(L" NEU1 ngdk_keymap_translate_keyboard_state: \t hardware_keycodeS=%u, keyvalsReturn: %s\n", 52, keyvalsReturn); + // wprintf(L" A7: %s(%i)", keyvalsReturn, *keyvalsReturn); + + //?? + GdkModifierType A8 = (GdkModifierType) (event->state & ~consumed & GDK_MODIFIER_MASK); + gdk_keymap_translate_keyboard_state (keymap, ii, GDK_MOD4_MASK , 0,keyvalsReturn, NULL, NULL, & consumed); + //wprintf(L" NEU1 ngdk_keymap_translate_keyboard_state: \t hardware_keycodeS=%u, keyvalsReturn: %s\n", 52, keyvalsReturn); + //wprintf(L" A8: %s(%i)", keyvalsReturn, *keyvalsReturn); + } + g_free(keyvals); g_free(maps); } -*/ int write_US_ToVector( v_dw_3D &vec,std::string language, const char* text) { @@ -323,8 +440,7 @@ v_dw_2D create_empty_2D( int dim_rows,int dim_shifts) { KMX_DWORD writeKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos); int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { - -// _S2 can go later + // _S2 can go later //PrintKeymapForCode(keymap, 52); //Try_EberhardsXKB(); @@ -337,7 +453,6 @@ int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { wprintf(L"ERROR: can't create empty 2D-Vector\n"); return 1; } - All_Vector.push_back(Other_Vector2D); wprintf(L" +++++++ dimensions of Vector after append_other_ToVector\t\t\t\t\t\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); wprintf(L" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n"); @@ -616,12 +731,12 @@ const int Lin_KM__map(int i, v_dw_3D &All_Vector) { //int vk0 = get_VirtualKey_Other_From_SC(dw, All_Vector); //int vk1 = get_VirtualKey_US_From_SC(dw, All_Vector); //int vk2 = get_VirtualKey_Other_Layer1_From_SC(dw, All_Vector); -int vk3 = get_VirtualKey_Other_Layer2_From_SC(dw, All_Vector); +/*int vk3 = get_VirtualKey_Other_Layer2_From_SC(dw, All_Vector); if ( i>160) { wprintf(L"dw = %i i=%i ----> vk3=%i\n",dw,i, vk3); -} +}*/ //return vk3; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 4f71463f18..fac03855a4 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -27,6 +27,20 @@ typedef std::vector v_dw_1D; typedef std::vector > v_dw_2D; typedef std::vector > > v_dw_3D; + +enum ShiftState { + Base = 0, // 0 + Shft = 1, // 1 + Ctrl = 2, // 2 + ShftCtrl = Shft | Ctrl, // 3 + Menu = 4, // 4 -- NOT USED + ShftMenu = Shft | Menu, // 5 -- NOT USED + MenuCtrl = Menu | Ctrl, // 6 + ShftMenuCtrl = Shft | Menu | Ctrl, // 7 + Xxxx = 8, // 8 + ShftXxxx = Shft | Xxxx, // 9 +}; + // Map of all US English virtual key codes that we can translate // const KMX_DWORD KMX_VKMap[] = { @@ -202,7 +216,7 @@ const int Lin_KM__map_arr[70]={ const int Lin_KM__map(int i); const int Lin_KM__map(int i, v_dw_3D &All_Vector); - +std::wstring PrintKeymapForCodeReturnKeySym(GdkKeymap *keymap,guint keycode, ShiftState ss, int caps ); // this is what we return when we find an invalid character //_S2 Which character do we use in that case? 0 or FFFF or 32 or ?? static KMX_DWORD returnIfCharInvalid = 32; diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index c767c70982..d527f7f3d0 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -27,19 +27,6 @@ #include "mc_kmxfile.h" #include "keymap.h" -enum ShiftState { - Base = 0, // 0 - Shft = 1, // 1 - Ctrl = 2, // 2 - ShftCtrl = Shft | Ctrl, // 3 - Menu = 4, // 4 -- NOT USED - ShftMenu = Shft | Menu, // 5 -- NOT USED - MenuCtrl = Menu | Ctrl, // 6 - ShftMenuCtrl = Shft | Menu | Ctrl, // 7 - Xxxx = 8, // 8 - ShftXxxx = Shft | Xxxx, // 9 -}; - const int KMX_ShiftStateMap[] = { ISVIRTUALKEY, ISVIRTUALKEY | K_SHIFTFLAG, @@ -642,7 +629,7 @@ std::wstring get_VirtualKey_Other_from_iKey(KMX_DWORD iKey, ShiftState &ss, int return L""; } -bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 +bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 KMX_Loader loader; const size_t BUF_sz= 256; @@ -748,7 +735,14 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std //wprintf(L"this was ss %i - ikey %i\n",ss ,iKey); //_S2 TODO //_S2 get char - do I need rc ?? ( was rc = ToUnicodeEx...) - std::wstring VK_Other = get_VirtualKey_Other_from_iKey(mapped_ikey, ss, caps, All_Vector); + std::wstring VK_Other_OLD = get_VirtualKey_Other_from_iKey(mapped_ikey, ss, caps, All_Vector); + std::wstring VK_Other= PrintKeymapForCodeReturnKeySym( *keymap, mapped_ikey, ss, caps==0); + + + if ( VK_Other_OLD != VK_Other) { + if(VK_Other_OLD!=L"" ) + wprintf(L"\nVK`s are different :-( %s <--> %s ",VK_Other_OLD.c_str() ,VK_Other.c_str()); + } //std::wstring VK_Other = get_VirtualKey_Other_from_iKey(iKey, ss, caps, All_Vector); //wprintf(L"ikey : %i (mapped to %i ) SS (%i) caps(%i) ----> returns %s (%i)\n", iKey, mapped_ikey , ss, caps, VK_Other.c_str(), (int) *( VK_Other.c_str())); @@ -814,7 +808,6 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std //------------------------------------------------------------- int nDeadkey = 0; - LPKMX_GROUP gp = new KMX_GROUP[kp->cxGroupArray+4]; // leave space for old memcpy(gp, kp->dpGroupArray, sizeof(KMX_GROUP) * kp->cxGroupArray); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 006ef3095c..78dee2818b 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -56,7 +56,7 @@ mcompile -d runs 4 important steps: KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]); -bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 +bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 std::vector KMX_FDeadkeys; // I4353 @@ -413,7 +413,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon KMX_ReportUnconvertedKeyboardRules(kbd); - if(!KMX_ImportRules(kbid, kbd, All_Vector, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 + if(!KMX_ImportRules(kbid, kbd, All_Vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 return FALSE; } return TRUE; From 6ff02e8b52ade717010ee4bec1cb918d69eba126 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 2 Nov 2023 16:29:22 +0100 Subject: [PATCH 110/327] feat(linux): mcompile use GDK to fill rgKeys nr+char OK, OEM still ToDo --- linux/mcompile/keymap/keymap.cpp | 291 +++++++++++++++++++++- linux/mcompile/keymap/keymap.h | 14 +- linux/mcompile/keymap/mc_import_rules.cpp | 70 +++++- 3 files changed, 355 insertions(+), 20 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 1ab1b9840f..db80a273e7 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -1,13 +1,39 @@ #include "keymap.h" #include +void GDK_Check(guint keyval){ -std::wstring PrintKeymapForCodeReturnKeySym(GdkKeymap *keymap,guint VK, ShiftState ss, int caps ){ - //GdkKeymap *keymap; +gchar * gg = gdk_keyval_name (keyval); +guint to_up = gdk_keyval_to_upper ( keyval); + +guint to_low =gdk_keyval_to_lower ( keyval); +gboolean is_up= gdk_keyval_is_upper ( keyval); +gboolean is_low=gdk_keyval_is_lower ( keyval); +guint kv__frrom= gdk_keyval_from_name ((const gchar *) gg); +guint32 uni= gdk_keyval_to_unicode ( keyval); + +gchar * gg1 = gdk_keyval_name (keyval); +guint lower; +guint upper; +gdk_keyval_convert_case (*gg1, &lower,&upper); +gdk_keyval_convert_case (GDK_KEY_A, &lower,&upper); +gdk_keyval_convert_case (66, &lower,&upper); + + +/*guint *lower; guint *upper; +gdk_keyval_convert_case (GDK_KEY_A, lower,upper); +gdk_keyval_convert_case (GDK_KEY_a, lower,upper); +gdk_keyval_convert_case (GDK_KEY_4, lower,upper); +gdk_keyval_convert_case (GDK_KEY_dollar, lower,upper);*/ +} + +std::wstring PrintKeymapForCodeReturnKeySym(GdkKeymap *keymap, guint VK, v_dw_3D &All_Vector, ShiftState ss, int caps ){ +//GdkKeymap *keymap; GdkModifierType consumed; GdkKeymapKey *maps; GdkEventKey* event; guint *keyvals; + guint *keyvals_shift; gint *n_entries; gint count; guint keycode; @@ -15,16 +41,134 @@ std::wstring PrintKeymapForCodeReturnKeySym(GdkKeymap *keymap,guint VK, ShiftSt GdkKeymapKey* keys; gint n_keys; +/*GDK_Check(38); +GDK_Check(17);*/ + + gdk_keymap_get_entries_for_keyval(keymap, VK,&keys,&n_keys); - if( keys !=NULL) { - keycode = keys[n_keys-1].keycode; - for( int k=0; k< n_keys; k++) { - guint kc= keys[n_keys-1].keycode; - } + int pos_1 =get_position_From_VirtualKey_Other(VK , All_Vector, 99); + // wprintf(L" get_position_From_VirtualKey_Other %i of VK%i (%c) \n", pos_1, VK,VK); + keycode = All_Vector[1][pos_1][0]; + + +GDK_Check(keycode); + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return L"1"; + + + //unshifted + if (( ss == Base ) && ( caps == 0 )) { + GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); + + + std::wstring rV1= std::wstring(1, (int) *keyvals); + + gchar * gg1 = gdk_keyval_name (*keyvals); + guint lower; + guint upper; + gdk_keyval_convert_case (*gg1, &lower,&upper); + std::wstring rv2= std::wstring(1, (int) upper); + std::wstring rv1= std::wstring(1, (int) *keyvals); + + //return rv2; + return std::wstring(1, (int) *keyvals); } + //SHIFT+CAPS + else if ( ( ss == Shft ) && ( caps ==1 )) { + GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); + + std::wstring rV1= std::wstring(1, (int) *keyvals); + + gchar * gg1 = gdk_keyval_name (*keyvals); + guint lower; + guint upper; + gdk_keyval_convert_case (*gg1, &lower,&upper); + std::wstring rv2= std::wstring(1, (int) upper); + + std::wstring rv1= std::wstring(1, (int) *keyvals); + //return rv2; + return std::wstring(1, (int) *keyvals); + + } + + //Shift + else if (( ss == Shft ) && ( caps == 0 )) { + GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + + std::wstring rV1= std::wstring(1, (int) *keyvals); + + +gchar * gg1 = gdk_keyval_name (*keyvals); +guint lower; +guint upper; +gdk_keyval_convert_case (*gg1, &lower,&upper); + + +//keyvals_shift = gg1; + std::wstring rv2= std::wstring(1, (int) upper); + + std::wstring rv1= std::wstring(1, (int) *keyvals); + return std::wstring(1, (int) *keyvals); + + } + + //caps + else if (( ss == Base ) && ( caps == 1 )) { + GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); + + std::wstring rV1= std::wstring(1, (int) *keyvals); + + gchar * gg1 = gdk_keyval_name (*keyvals); + guint lower; + guint upper; + gdk_keyval_convert_case (*gg1, &lower,&upper); + std::wstring rv2= std::wstring(1, (int) upper); + std::wstring rv1= std::wstring(1, (int) *keyvals); + + //return rv2; + return std::wstring(1, (int) *keyvals); + + } + éÉ22 + /*//ALT-GR + else if { + GdkModifierType MOD_AltGr = (GdkModifierType) ( GDK_MOD5_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + return *keyvals; + }*/ + + else + return L"0"; +} + + +std::wstring PrintKeymapForCodeReturnKeySym2(GdkKeymap *keymap, guint VK, v_dw_3D &All_Vector, ShiftState ss, int caps ){ + + GdkModifierType consumed; + GdkKeymapKey *maps; + GdkEventKey* event; + guint *keyvals; + guint *keyvals_shift; + gint *n_entries; + gint count; + guint keycode; + + GdkKeymapKey* keys; + gint n_keys; + + gdk_keymap_get_entries_for_keyval(keymap, VK,&keys,&n_keys); + + int pos_1 =get_position_From_VirtualKey_Other(VK , All_Vector, 99); + wprintf(L" get_position_From_VirtualKey_Other %i of VK%i (%c) \n", pos_1, VK,VK); + keycode = All_Vector[1][pos_1][0]; + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return L"1"; @@ -33,6 +177,7 @@ std::wstring PrintKeymapForCodeReturnKeySym(GdkKeymap *keymap,guint VK, ShiftSt if (( ss == Base ) && ( caps == 0 )) { GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); } @@ -48,6 +193,19 @@ std::wstring PrintKeymapForCodeReturnKeySym(GdkKeymap *keymap,guint VK, ShiftSt else if (( ss == Shft ) && ( caps == 0 )) { GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + + std::wstring rV1= std::wstring(1, (int) *keyvals); + +/* +gchar * gg1 = gdk_keyval_name (*keyvals); +guint lower; +guint upper; +gdk_keyval_convert_case (*gg1, &lower,&upper); + + +//keyvals_shift = gg1; + std::wstring rv2= std::wstring(1, (int) upper);*/ + return std::wstring(1, (int) *keyvals); } @@ -635,6 +793,65 @@ KMX_DWORD get_VirtualKey_Other_Layer2_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector int eerurziurtzu=99; } +// query All_Vector +// return RETURN NON SHIFTED CHAR [1] the VirtualKey of the Other Keyboard for given Scancode +KMX_DWORD get_VirtualKey_Other_From_SC_NEW(KMX_DWORD SC , v_dw_3D &All_Vector,GdkKeymap **keymap, KMX_DWORD SC1,KMX_DWORD SC2){ + //GdkKeymap *keymap; + GdkModifierType consumed; + GdkKeymapKey *maps; + GdkEventKey* event; + guint *keyvals; + gint *n_entries; + gint count; + guint keycode; + + GdkKeymapKey* keys; + gint n_keys; + +//GdkKeymap* keymap1 =keymap; +//GdkKeymap *keymap2=keymap;; +GdkKeymap **keymap3=keymap; +GdkKeymap *keymap4 = * keymap; +KMX_DWORD SC_geht = 38; + + //unshifted + GdkModifierType MOD_base = (GdkModifierType) ( GDK_SHIFT_MASK ); + + int asdfghj=9; + gdk_keymap_translate_keyboard_state (keymap4, SC_geht, MOD_base , 0, keyvals, NULL, NULL, & consumed); + + g_free(keyvals); + g_free(maps); + + KMX_DWORD retVal= (KMX_DWORD) 97; + return retVal; + + + for( int i=0; i< (int)All_Vector[0].size();i++) { + //number keys return unshifted value ( e.g. 1 not !) + if(SC <= 19) { + if ( All_Vector[0][i][0] == SC) + return All_Vector[1][i][1]; + } + + // other keys + if((SC > 19) ) { + if ( All_Vector[0][i][0] == SC) { + + // normal capital characters return the value of capital char ( e.g. A) + if ((All_Vector[1][i][2] >= 65 ) && (All_Vector[1][i][2] < 91 )) + return All_Vector[1][i][2]; + + // special characters return Keyman defined values (e.g. VK_ACCENT) + else + //return All_Vector[1][i][1]; + return map_To_VK(SC); + } + } + } +return 0; +} + // query All_Vector // return RETURN NON SHIFTED CHAR [1] the VirtualKey of the Other Keyboard for given Scancode KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ @@ -663,6 +880,38 @@ KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ } return 0; } + + +// query All_Vector +// return RETURN NON SHIFTED CHAR [1] the VirtualKey of the Other Keyboard for given Scancode +KMX_DWORD get_VirtualKey_Other_From_SC_BAK(KMX_DWORD SC , v_dw_3D &All_Vector){ + + for( int i=0; i< (int)All_Vector[0].size();i++) { + //number keys return unshifted value ( e.g. 1 not !) + if(SC <= 19) { + if ( All_Vector[0][i][0] == SC) + return All_Vector[1][i][1]; + } + + // other keys + if((SC > 19) ) { + if ( All_Vector[0][i][0] == SC) { + + // normal capital characters return the value of capital char ( e.g. A) + if ((All_Vector[1][i][2] >= 65 ) && (All_Vector[1][i][2] < 91 )) + return All_Vector[1][i][2]; + + // special characters return Keyman defined values (e.g. VK_ACCENT) + else + //return All_Vector[1][i][1]; + return map_To_VK(SC); + } + } + } +return 0; +} + + // _S2 not needed, can go later // return RETURN NON SHIFTED CHAR [1] the VirtualKey of the US Keyboard for given Scancode KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ @@ -710,6 +959,32 @@ KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_V } return 0; //_S2 what do I return if not found?? } +KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector, int which_columns) { + // find correct row of char in US +if((which_columns <1 ) ) + return 0; + +// search all columns +if(which_columns >(int)All_Vector[1][0].size()) { + for( int i=0; i< (int)All_Vector[1][0].size();i++) { + for( int j=0; j< (int)All_Vector[1].size()-1;j++) { + if ( ( All_Vector[1][j][i] == VK_Other ) ) + return j; + } + } +} + +else { + for( int j=0; j< (int)All_Vector[1].size()-1;j++) { + if ( ( All_Vector[1][j][which_columns] == VK_Other ) ) + return j; + } +} + + return 0; //_S2 what do I return if not found?? + +} + // _S2 maybe not needed bool IsKeyIn_VKMap(UINT SC) { @@ -740,7 +1015,7 @@ if ( i>160) //return vk3; - +int dw=0; //if (i == 32 ) return ; /* */5 //if (i == 186 ) return 252; /* Ü */ diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index fac03855a4..68dc8e640f 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -217,6 +217,9 @@ const int Lin_KM__map_arr[70]={ const int Lin_KM__map(int i); const int Lin_KM__map(int i, v_dw_3D &All_Vector); std::wstring PrintKeymapForCodeReturnKeySym(GdkKeymap *keymap,guint keycode, ShiftState ss, int caps ); +std::wstring PrintKeymapForCodeReturnKeySym(GdkKeymap *keymap, guint VK, v_dw_3D &All_Vector, ShiftState ss, int caps ); +std::wstring PrintKeymapForCodeReturnKeySym2(GdkKeymap *keymap, guint VK, v_dw_3D &All_Vector, ShiftState ss, int caps ); + // this is what we return when we find an invalid character //_S2 Which character do we use in that case? 0 or FFFF or 32 or ?? static KMX_DWORD returnIfCharInvalid = 32; @@ -245,18 +248,25 @@ v_dw_2D create_empty_2D(int dim_rows, int dim_shifts); // query All_Vector // return the VirtualKey of the Other Keyboard for given Scancode +KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector, GdkKeymap **keymap); KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); +KMX_DWORD get_VirtualKey_Other_From_SC_GDK(KMX_DWORD SC , v_dw_3D &All_Vector); +KMX_DWORD get_VirtualKey_Other_From_SC_NEW(KMX_DWORD SC , v_dw_3D &All_Vector,GdkKeymap **keymap,KMX_DWORD SC1,KMX_DWORD SC2); KMX_DWORD get_VirtualKey_Other_Layer1_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); KMX_DWORD get_VirtualKey_Other_Layer2_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); +KMX_DWORD get_VirtualKey_Other_From_SC_GDK_dw(v_dw_3D &All_Vector, GdkKeymap **keymap, KMX_DWORD keycode , guint VK); + // return the VirtualKey of the US Keyboard for given Scancode KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); // return the Scancode of for given VirtualKey of Other Keyboard KMX_DWORD get_SC_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector); -// return the Scancode of for given VirtualKey of Other US +// return the Scancode of for given VirtualKey of US KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector); -// return the Scancode of for given VirtualKey of Other US +// return the Scancode of for given VirtualKey of Other KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_US , v_dw_3D &All_Vector); +// return the Scancode of for given VirtualKey of Other in specific column. If column > available columns look in all columns; +KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector, int which_columns); bool IsKeyIn_VKMap(UINT SC); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index d527f7f3d0..6283fb1ab9 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -145,10 +145,32 @@ public: // If there is no translation, the function returns 0. // SC -> VK this->m_vk = get_VirtualKey_Other_From_SC(scanCode, All_Vector); + // this->m_vk = get_VirtualKey_Other_From_SC_NEW(scanCode, All_Vector, keymap, scanCode,scanCode); + //this->m_vk = get_VirtualKey_Other_From_SC_GDK_dw( All_Vector, keymap, scanCode,scanCode); // use gdk to get vk`s + this->m_hkl = hkl; this->m_sc = scanCode; } + KMX_VirtualKey(UINT scanCode, KMX_HKL hkl, v_dw_3D All_Vector, GdkKeymap **keymap) { + // _S2 this->m_vk = MapVirtualKeyEx(scanCode, 1, hkl); // second para= 1: MAPVK_VSC_TO_VK =1 + // The first parameter is a scan code and is + // translated into a virtual-key code that does not + // distinguish between left- and right-hand keys. + // If there is no translation, the function returns 0. + // SC -> VK + this->m_vk = get_VirtualKey_Other_From_SC(scanCode, All_Vector); + this->m_hkl = hkl; + this->m_sc = scanCode ; + } + +void set_SC(UINT value){ + this->m_sc = value; +} +void set_VK(UINT value){ + this->m_vk = value; +} + UINT VK() { return this->m_vk; } @@ -596,8 +618,11 @@ std::wstring get_VirtualKey_Other_from_iKey(KMX_DWORD iKey, ShiftState &ss, int // _S2 this will find the correct row in All_Vector //( e.g. get_position_From_VirtualKey_Other(65 ,All_Vector ) returns 25 // All_Vector[25] contains SC(38), unshifted A (97) shifted A (65) ) - KMX_DWORD pos = get_position_From_VirtualKey_Other(iKey, All_Vector); - + KMX_DWORD pos = get_position_From_VirtualKey_Other(iKey, All_Vector,99); + /*KMX_DWORD pos0 = get_position_From_VirtualKey_Other(iKey, All_Vector,0); + KMX_DWORD pos1 = get_position_From_VirtualKey_Other(iKey, All_Vector,1); + KMX_DWORD pos2 = get_position_From_VirtualKey_Other(iKey, All_Vector,2); + KMX_DWORD pos3 = get_position_From_VirtualKey_Other(iKey, All_Vector,99);*/ int icaps; if (ss >9) return L""; @@ -665,15 +690,29 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd // _S2 this does not find exactly the same keys as the windows version does(windows finds more) // but the ones we need for mcompile are there //for(UINT sc = 0x01; sc <= 0x7f; sc++) { - for(UINT sc = 0x0; sc <= 0x7f; sc++) { - KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector); // _S2 get this from my Vector + +//should be 54 (= unshifted) +//KMX_VirtualKey *key1 = new KMX_VirtualKey(15, hkl, All_Vector, keymap); +//should be 65 (=shifted) +//KMX_VirtualKey *key2 = new KMX_VirtualKey(38, hkl, All_Vector, keymap); + + + for(UINT sc = 0x01; sc <= 0x7f; sc++) { + // KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector); // _S2 get this from my Vector + KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector, keymap); // _S2 get this from my Vector uint key_vk = key->VK() ; + std::wstring s= PrintKeymapForCodeReturnKeySym2( *keymap, (guint) sc , All_Vector, Shft, 0 ); + if ( !s.empty() ); + UINT in1_dw = (UINT)(*s.c_str()); + + key->set_VK( in1_dw) ; wprintf(L" sc= %i --- VK = %i (%c)\n",sc,key_vk,key_vk); - if(key->VK() != 0) { - rgKey[key->VK()] = key; + if((key->VK() != 0) && (key->VK() <256)) { + rgKey[key->VK()] = key; } else { - delete key; + delete key; } + } for(UINT ke = VK_NUMPAD0; ke <= VK_NUMPAD9; ke++) { @@ -710,7 +749,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd } */ // _S2 test rgkey can go later - for(UINT iKey = 160; iKey < rgKey.size(); iKey++) { + for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { if(rgKey[iKey] != NULL) { wprintf(L" Key Nr %i is available\n",iKey); } @@ -730,13 +769,24 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd continue; } +int Keypos = get_position_From_VirtualKey_Other(mapped_ikey , All_Vector, 2); +UINT pp = (UINT) All_Vector[1][Keypos][0]; + + + for(int caps = 0; caps <= 1; caps++) { //wprintf(L"this was ss %i - ikey %i\n",ss ,iKey); //_S2 TODO //_S2 get char - do I need rc ?? ( was rc = ToUnicodeEx...) std::wstring VK_Other_OLD = get_VirtualKey_Other_from_iKey(mapped_ikey, ss, caps, All_Vector); - std::wstring VK_Other= PrintKeymapForCodeReturnKeySym( *keymap, mapped_ikey, ss, caps==0); + //std::wstring VK_Other= PrintKeymapForCodeReturnKeySym( *keymap, mapped_ikey, All_Vector, ss, caps); + std::wstring VK_Other= PrintKeymapForCodeReturnKeySym( *keymap, pp, All_Vector, ss, caps); + + + + + if ( VK_Other_OLD != VK_Other) { @@ -765,7 +815,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd //_S2 TODO // fill m_rgss and m_rgfDeadkey ( m_rgfDeadkey will be done later) //rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps == 0)); - rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps == 0)); + rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps)); //} // from rc==1 // } // from rc > 0 From 17058633c10bee4e714e404acdd229f5a4fd3d57 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 7 Nov 2023 12:59:15 +0100 Subject: [PATCH 111/327] feat(linux): mcompile unchanged files --- linux/mcompile/keymap/filesystem.cpp | 0 linux/mcompile/keymap/filesystem.h | 0 linux/mcompile/keymap/mc_savekeyboard.cpp | 2 ++ linux/mcompile/keymap/meson.build | 0 linux/mcompile/keymap/u16.cpp | 0 linux/mcompile/keymap/u16.h | 0 6 files changed, 2 insertions(+) mode change 100644 => 100755 linux/mcompile/keymap/filesystem.cpp mode change 100644 => 100755 linux/mcompile/keymap/filesystem.h mode change 100644 => 100755 linux/mcompile/keymap/mc_savekeyboard.cpp mode change 100644 => 100755 linux/mcompile/keymap/meson.build mode change 100644 => 100755 linux/mcompile/keymap/u16.cpp mode change 100644 => 100755 linux/mcompile/keymap/u16.h diff --git a/linux/mcompile/keymap/filesystem.cpp b/linux/mcompile/keymap/filesystem.cpp old mode 100644 new mode 100755 diff --git a/linux/mcompile/keymap/filesystem.h b/linux/mcompile/keymap/filesystem.h old mode 100644 new mode 100755 diff --git a/linux/mcompile/keymap/mc_savekeyboard.cpp b/linux/mcompile/keymap/mc_savekeyboard.cpp old mode 100644 new mode 100755 index e69de29bb2..571e919f89 --- a/linux/mcompile/keymap/mc_savekeyboard.cpp +++ b/linux/mcompile/keymap/mc_savekeyboard.cpp @@ -0,0 +1,2 @@ + +// moved to mc_kmxfile.cpp/.h diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build old mode 100644 new mode 100755 diff --git a/linux/mcompile/keymap/u16.cpp b/linux/mcompile/keymap/u16.cpp old mode 100644 new mode 100755 diff --git a/linux/mcompile/keymap/u16.h b/linux/mcompile/keymap/u16.h old mode 100644 new mode 100755 From bee3f4a8f982fb5c1c18693566b20efd14ba568a Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 7 Nov 2023 13:00:30 +0100 Subject: [PATCH 112/327] feat(linux): mcompile minor changes --- linux/mcompile/keymap/README.md | 22 +- linux/mcompile/keymap/helpers.cpp | 439 +++++++++++++++++++++++- linux/mcompile/keymap/helpers.h | 8 +- linux/mcompile/keymap/kmx_file.h | 8 +- linux/mcompile/keymap/mc_savekeyboard.h | 2 +- 5 files changed, 447 insertions(+), 32 deletions(-) mode change 100644 => 100755 linux/mcompile/keymap/README.md mode change 100644 => 100755 linux/mcompile/keymap/helpers.cpp mode change 100644 => 100755 linux/mcompile/keymap/helpers.h mode change 100644 => 100755 linux/mcompile/keymap/kmx_file.h mode change 100644 => 100755 linux/mcompile/keymap/mc_savekeyboard.h diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md old mode 100644 new mode 100755 index 35e0aeec43..781f88de97 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -18,7 +18,6 @@ TODO check if I can use files from some other keyman path instead of a copy in k TODO remove kbdid and kbd for Linux TODO shiftstate-count TODO keymap SplitToV.cpp exchange 4 with genaerated shiftcount -TODO check if part with surplus is neccessary TODO shift-statevector TODO Do I need HKL for Linux / can I just use a void* or remove HKL ?? TODO typeddef of KMX_HKL - can I delete all m_hkl from classes? @@ -31,20 +30,17 @@ TODO get_position_From_VirtualKey_US: take care of the other shiftstates ToDo make this better!!! get_VirtualKey_Other_From_SC TODO next: - change mapping (win-lin) for writing All_Vector - compare entries in rgKey ( are the same rgKey[]filled? it is OK from rgKey[65]-rgkey[90] but for other values??? ) - mc_import-rules (from ~ l. 790) see if everything gives the same result on win-Lin - check if I use char16_t everywhere instead of wchar_t or char - replace GDK - see in which files I can put some functions (e.g. incxstr) that were duplicated or even #include their original location - remove testing functions - remove USE_GDK + - change mapping (win-lin) for writing All_Vector + - compare entries in rgKey ( are the same rgKey[]filled? it is OK from rgKey[65]-rgkey[90] but for other values??? ) + - mc_import-rules (from ~ l. 790) see if everything gives the same result on win-Lin + - check if I use char16_t everywhere instead of wchar_t or char + - replace GDK + - see in which files I can put some functions (e.g. incxstr) that were duplicated or even #include their original location + - remove testing functions + - remove USE_GDK + - what is wrong with kp->dpBitmapOffset/BitmapSize ? TODO ... -//--------------------------- -TOASK is using string OK, or do we use char, wchar? -TOASK a-z, A_Z or more keys? ... -TOASK ado we need mcompile -u option? ./mcompile -d /Projects/keyman/keyman/linux/mcompile/keymap/mcompile_test.kmx bla.dll 0407 /Projects/keyman/keyman/linux/mcompile/keymap/mcompile_test_out.kmx diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp old mode 100644 new mode 100755 index e31e744d11..bee2d764f6 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -1,12 +1,10 @@ #include "helpers.h" -int test_helpers(){ - wprintf(L"##### test_helpers is here and USE_GDK is %i\n", USE_GDK); -} +//_S2 do not review - all this will be deleted later + int append_other_ToVector(v_dw_3D &All_Vector) { - InsertKeyvalsFromVectorFile(All_Vector); return 0; } @@ -79,7 +77,6 @@ int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector){ return 0; } - bool writeVectorToFile(v_dw_3D V) { std::string TxtFileName = "/Projects/keyman/keyman/linux/mcompile/keymap/VectorFile2.txt" ; WCHAR DeadKey; @@ -182,8 +179,6 @@ bool CompareVector_To_VectorOfFile(v_dw_3D All_Vector,v_dw_3D File_Vector){ } return true; - wprintf(L" #### CompareVector_To_VectorOfFile ended \n"); //_S2 kommt hier nie hin - return false; //_S2 kommt hier nie hin } bool CompareVector_To_VectorOfFile_RGKEY(v_dw_2D Win_Vector,v_dw_2D Lin_Vector, v_dw_2D Map_Vector){ @@ -222,7 +217,6 @@ bool CompareVector_To_VectorOfFile_RGKEY(v_dw_2D Win_Vector,v_dw_2D Lin_Vector, return true; } - /*bool CompareVector_To_VectorOfFile_RGKEY(v_dw_2D Win_Vector,v_dw_2D Lin_Vector, v_dw_2D Map_Vector){ wprintf(L" #### CompareVector_To_VectorOfFile started: "); wprintf(L" #### dimensions: %i %i -- %i %i \n", Win_Vector.size() ,Win_Vector[0].size(), Lin_Vector.size() ,Lin_Vector[0].size()); @@ -310,9 +304,6 @@ bool write_RGKEY_FileToVector(v_dw_2D& shift_states, const char* infile) { return(0); } - - - bool test_In_Out(v_dw_3D All_Vector){ for ( int i=0; i<61;i++) @@ -365,3 +356,429 @@ bool test_In_Out(v_dw_3D All_Vector){ } } } + +// ToDo write 2 func for return pos of Key_US and Pos of Key_Other +// return the Scancode of for given VirtualKey of Other US +KMX_DWORD get_position_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ + // find correct row of char in US + for( int i=0; i< (int)All_Vector[0].size()-1;i++) { + if ( ( All_Vector[0][i][1] == VK_US ) || ( All_Vector[0][i][2] == VK_US )) { + //if ( ( All_Vector[0][i][1] == VK_US ) ) { + //wprintf(L" VK_US= %i .. i= %i .. %i\t\t %i (%c) : %i (%c) +++ %i\t\t %i (%c) : %i (%c) \n",VK_US , i, + // All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2], + //All_Vector[1][i][0] , All_Vector[1][i][1] ,All_Vector[1][i][1] , All_Vector[1][i][2] , All_Vector[1][i][2] ); + return i; + } + } + return 0; //_S2 what do I return if not found?? +} + +/* +// _S2 where to put this?? +std::wstring get_VirtualKey_US_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &caps, v_dw_3D &All_Vector) { + + int icaps; + KMX_DWORD pos = get_position_From_VirtualKey_US(iKey, All_Vector); + + if (ss >9) + return L""; + + if( ss < All_Vector[0][pos].size()-1) { + //if( ss < All_Vector[1][pos].size()-1) { // _S2 numbers need this + + if ( ss % 2 == 0) + icaps = ss+2-caps; + + if ( ss % 2 == 1) + icaps = ss+caps; + + return std::wstring(1, (int) All_Vector[0][pos][icaps]); + //return std::wstring(1, (int) All_Vector[1][pos][icaps]); + } + return L""; +} +*/ + + +int replace_PosKey_with_Keycode(std::string in) { + int out = returnIfCharInvalid; + +// _S2 these are the Scancode-Values we use in Keyman ( = like the windows scancodes) + + if ( in == "key") out = 49; /* 0X VK_ */ // TOASK correct ??? + else if ( in == "key") out = 1; /* 0X02 VK_1 */ + else if ( in == "key") out = 2; /* 0X03 VK_2 */ + else if ( in == "key") out = 3; /* 0X04 VK_3 */ + else if ( in == "key") out = 4; /* 0X05 VK_4 */ + else if ( in == "key") out = 5; /* 0X06 VK_5 */ + else if ( in == "key") out = 6; /* 0X07 VK_6 */ + else if ( in == "key") out = 7; /* 0X08 VK_7 */ + else if ( in == "key") out = 8; /* 0X09 VK_8 */ + else if ( in == "key") out = 9; /* 0X0A VK_9 */ + else if ( in == "key") out = 10; /* 0X0B VK_0 */ + else if ( in == "key") out = 12; /* 0X0C VK_MINUS */ + else if ( in == "key") out = 13; /* 0X0D VK_EQUALS */ + + else if ( in == "key") out = 16; /* 0X10 VK_Q */ + else if ( in == "key") out = 17; /* 0X11 VK_W */ + else if ( in == "key") out = 18; /* 0X12 VK_E */ + else if ( in == "key") out = 19; /* 0X13 VK_R */ + else if ( in == "key") out = 20; /* 0X14 VK_T */ + else if ( in == "key") out = 21; /* 0X15 VK_Y */ + else if ( in == "key") out = 22; /* 0X16 VK_U */ + else if ( in == "key") out = 23; /* 0X17 VK_I */ + else if ( in == "key") out = 24; /* 0X18 VK_O */ + else if ( in == "key") out = 25; /* 0X19 VK_P */ + else if ( in == "key") out = 26; /* 0X1A VK_LEFTBRACE */ + else if ( in == "key") out = 27; /* 0X1B VK_RIGHTBRACE */ + + else if ( in == "key") out = 30; /* 0X1E VK_A */ + else if ( in == "key") out = 31; /* 0X1F VK_S */ + else if ( in == "key") out = 32; /* 0X20 VK_D */ + else if ( in == "key") out = 33; /* 0X21 VK_F */ + else if ( in == "key") out = 34; /* 0X22 VK_G */ + else if ( in == "key") out = 35; /* 0X23 VK_H */ + else if ( in == "key") out = 36; /* 0X24 VK_J */ + else if ( in == "key") out = 37; /* 0X25 VK_K */ + else if ( in == "key") out = 38; /* 0X26 VK_L */ + else if ( in == "key") out = 39; /* 0X27 VK_SEMICOLON */ + else if ( in == "key") out = 40; /* 0X28 VK_APOSTROPHE */ + else if ( in == "key") out = 41; /* 0X29 VK_GRAVE */ + + else if ( in == "key") out = 44; /* 0X2C VK_Z */ + else if ( in == "key") out = 45; /* 0X2D VK_X */ + else if ( in == "key") out = 46; /* 0X2E VK_C */ + else if ( in == "key") out = 47; /* 0X2F VK_V */ + else if ( in == "key") out = 48; /* 0X30 VK_B */ + else if ( in == "key") out = 49; /* 0X31 VK_N */ + else if ( in == "key") out = 50; /* 0X32 VK_M */ + else if ( in == "key") out = 51; /* 0X33 VK_ COMMA */ + else if ( in == "key") out = 52; /* 0X34 VK_DOT */ + else if ( in == "key") out = 53; /* 0X35 VK_SLASH */ + else if ( in == "key") out = 54; /* 0X36 VK_RIGHTSHIFT */ + else if ( in == "key") out = 55; /* 0X37 VK_RIGHTSHIFT */ + else if ( in == "key") out = 65; /* 0X20 VK_SPACE */ + + return out; +} +// return RETURN NON SHIFTED CHAR [1] the VirtualKey of the US Keyboard for given Scancode +KMX_DWORD get_VirtualKey_Other_Layer1_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ + // find correct row of char in US + for( int i=0; i< (int)All_Vector[0].size()-1;i++) { + if ( All_Vector[0][i][0] == SC ) { + //wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- ",SC , i, All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2] ); + return All_Vector[1][i][1] ; + } + } + return 0; //_S2 what do I return if not found?? +} +// return RETURN NON SHIFTED CHAR [1] the VirtualKey of the US Keyboard for given Scancode +KMX_DWORD get_VirtualKey_Other_Layer2_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ + // find correct row of char in US + for( int i=0; i< (int)All_Vector[0].size()-1;i++) { + if ( All_Vector[0][i][0] == SC ) { + //wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- ",SC , i, All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2] ); + return All_Vector[1][i][2] ; + } + int ertzu=99; + } + + int ertzwrtu=99; + return 0; //_S2 what do I return if not found?? + + int eerurziurtzu=99; +} +// query All_Vector +// return RETURN NON SHIFTED CHAR [1] the VirtualKey of the Other Keyboard for given Scancode + + +void GDK_Check(guint keyval){ + +gchar * gg = gdk_keyval_name (keyval); +guint to_up = gdk_keyval_to_upper ( keyval); + +guint to_low =gdk_keyval_to_lower ( keyval); +gboolean is_up= gdk_keyval_is_upper ( keyval); +gboolean is_low=gdk_keyval_is_lower ( keyval); +guint kv__frrom= gdk_keyval_from_name ((const gchar *) gg); +guint32 uni= gdk_keyval_to_unicode ( keyval); + +gchar * gg1 = gdk_keyval_name (keyval); +guint lower; +guint upper; +gdk_keyval_convert_case (*gg1, &lower,&upper); +gdk_keyval_convert_case (GDK_KEY_A, &lower,&upper); +gdk_keyval_convert_case (66, &lower,&upper); + + +/*guint *lower; guint *upper; +gdk_keyval_convert_case (GDK_KEY_A, lower,upper); +gdk_keyval_convert_case (GDK_KEY_a, lower,upper); +gdk_keyval_convert_case (GDK_KEY_4, lower,upper); +gdk_keyval_convert_case (GDK_KEY_dollar, lower,upper);*/ +} + + +static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) { + GdkModifierType consumed; + GdkKeymapKey *maps; + GdkEventKey* event; + guint *keyvals; + guint *keyvalsReturn; + gint *n_entries; + gint count; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return; + + for (int i = 0; i < count; i++) { + //if (maps[i].level > 0 || maps[i].group > 1) + // continue; + wprintf(L" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", + i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); + } + + for( int ii=10; ii<63; ii++) { + + //unshifted + GdkModifierType A1 = (GdkModifierType) (event->state & GDK_MODIFIER_MASK); + gdk_keymap_translate_keyboard_state (keymap, ii, (A1 ) , 0,keyvalsReturn, NULL, NULL, & consumed); + wprintf(L"\n ngdk_keymap_translate_keyboard_state: \t keycodeS=%u , n_entries %i\tUNSH: %s(%i)\t", ii, *n_entries, keyvalsReturn, *keyvalsReturn); + + //caps + gdk_keymap_translate_keyboard_state (keymap, ii, GDK_LOCK_MASK , 0,keyvalsReturn, NULL, NULL, & consumed); + wprintf(L" CAPS: %s(%i)\t", keyvalsReturn, *keyvalsReturn); + + //Shift + gdk_keymap_translate_keyboard_state (keymap, ii, GDK_SHIFT_MASK , 0,keyvalsReturn, NULL, NULL, & consumed); + wprintf(L" SH: %s(%i)\t", keyvalsReturn, *keyvalsReturn); + + //SHIFT+CAPS + GdkModifierType A4 = (GdkModifierType) (event->state | (GDK_SHIFT_MASK | GDK_LOCK_MASK)); + gdk_keymap_translate_keyboard_state (keymap, ii, A4 , 0,keyvalsReturn, NULL, NULL, & consumed); + wprintf(L" SH+CAPS: %s(%i) \t", keyvalsReturn, *keyvalsReturn); + + //ALT-GR + gdk_keymap_translate_keyboard_state (keymap, ii, GDK_MOD5_MASK , 0,keyvalsReturn, NULL, NULL, & consumed); + //wprintf(L"\n NEU1 ngdk_keymap_translate_keyboard_state: \t hardware_keycodeS=%u, keyvalsReturn: %s\n", 52, keyvalsReturn); + wprintf(L" ALTGR: %s(%i)", keyvalsReturn, *keyvalsReturn); + + //?? + gdk_keymap_translate_keyboard_state (keymap, ii, GDK_MOD1_MASK , 0,keyvalsReturn, NULL, NULL, & consumed); + // wprintf(L" NEU1 ngdk_keymap_translate_keyboard_state: \t hardware_keycodeS=%u, keyvalsReturn: %s\n", 52, keyvalsReturn); + //wprintf(L" A5: %s(%i)", keyvalsReturn, *keyvalsReturn); + + //?? + gdk_keymap_translate_keyboard_state (keymap, ii, GDK_MOD2_MASK , 0,keyvalsReturn, NULL, NULL, & consumed); + //wprintf(L" NEU1 ngdk_keymap_translate_keyboard_state: \t hardware_keycodeS=%u, keyvalsReturn: %s\n", 52, keyvalsReturn); + //wprintf(L" A6: %s(%i)", keyvalsReturn, *keyvalsReturn); + + //?? + gdk_keymap_translate_keyboard_state (keymap, ii, GDK_MOD3_MASK , 0,keyvalsReturn, NULL, NULL, & consumed); + // wprintf(L" NEU1 ngdk_keymap_translate_keyboard_state: \t hardware_keycodeS=%u, keyvalsReturn: %s\n", 52, keyvalsReturn); + // wprintf(L" A7: %s(%i)", keyvalsReturn, *keyvalsReturn); + + //?? + GdkModifierType A8 = (GdkModifierType) (event->state & ~consumed & GDK_MODIFIER_MASK); + gdk_keymap_translate_keyboard_state (keymap, ii, GDK_MOD4_MASK , 0,keyvalsReturn, NULL, NULL, & consumed); + //wprintf(L" NEU1 ngdk_keymap_translate_keyboard_state: \t hardware_keycodeS=%u, keyvalsReturn: %s\n", 52, keyvalsReturn); + //wprintf(L" A8: %s(%i)", keyvalsReturn, *keyvalsReturn); + } + + g_free(keyvals); + g_free(maps); +} + +bool InsertKeyvalsFromKeymap(v_dw_3D &All_Vector,GdkKeymap * keymap){ + + // get the keyvals using GDK and copy into All_Vector + for(int i =0; i< (int) All_Vector[1].size();i++) { + // get key name US stored in [0][i][0] and copy to name in "other"-block[1][i][0] + All_Vector[1][i][0] = All_Vector[0][i][0]; + + // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] + All_Vector[1][i][0+1] = getKeyvalsFromKeymap(keymap,(All_Vector[1][i][0]),0); //shift state: unshifted:0 + All_Vector[1][i][1+1] = getKeyvalsFromKeymap(keymap,(All_Vector[1][i][0]),1); //shift state: shifted:1 + + //wprintf(L" Keycodes US dw : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); + //wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); + } +} + +// _S2 can go later +KMX_DWORD writeKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { + GdkKeymapKey *maps; + guint *keyvals; + gint count; + KMX_DWORD out; + for ( int ii =1; ii< 255;ii++) { + + KMX_DWORD out = getKeyvalsFromKeymap(keymap,ii,0); + KMX_DWORD out2= getKeyvalsFromKeymap(keymap,ii,1); + wprintf(L" ii = %i --> keymap = %i (%c)..%i(%c) \n",ii, out,out, out2,out2); + } +} + + +// _S2 not needed later +bool test(v_dw_3D &V) { + std::string extra = " "; + wprintf(L" +++++++ dimensions of whole Vector in test()\t\t\t\t\t\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); + wprintf(L"\n+++++++++ print some characters of US and Other +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + + for ( int k=0; k<(int)V[0].size(); k++) { + if(V[0][k][2] != V[1][k][2] ) + extra = " *** "; + else + extra = " "; + + if (V[0].size()>0) { + /*wprintf(L" row (US) ...... SC= %i .. %i (%c) .. %i (%c) .. --- ",V[0][k][0] , V[0][k][1] , V[0][k][1] , V[0][k][2] , V[0][k][2] ); + wprintf(L" \n"); + wprintf(L" row (Other)..... SC= %i .. %i (%c) .. %i (%c) .. %s \n", V[1][k][0] , V[1][k][1], V[1][k][1] , V[1][k][2], V[1][k][2] , extra.c_str()); + wprintf(L" \n");*/ + } + } + wprintf(L"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + return true; +} + +bool test_single(v_dw_3D &V) { + std::string extra = " "; + wprintf(L" +++++++ dimensions of single Vector in test_single()\t\t\t\t\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); + wprintf(L"\n +++++++++ print characters of SINGLE DW ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + + for ( int k=0; k<(int)V[0].size(); k++) { + if (V[0].size()>0) { + wprintf(L" row (US) ...... %i .. %i (%c) .. %i (%c) ........ \n", V[0][k][0] , V[0][k][1] ,V[0][k][1] , V[0][k][2], V[0][k][2] ); + } + } + wprintf(L" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + return true; +} + +// return the position of the VK in Other in All_Vector +/*KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector){ + // find correct row of char in US + for( int i=0; i< (int)All_Vector[0].size()-1;i++) { + if ( ( All_Vector[1][i][1] == VK_Other ) || ( All_Vector[1][i][2] == VK_Other )) { + return i; + } + } + return 0; //_S2 what do I return if not found?? +}*/ + + +// _S2 REMOVE +std::wstring PrintKeymapForCodeReturnKeySym(GdkKeymap *keymap, guint VK, v_dw_3D &All_Vector, ShiftState ss, int caps ){ +//GdkKeymap *keymap; + GdkModifierType consumed; + GdkKeymapKey *maps; + GdkEventKey* event; + guint *keyvals; + guint *keyvals_shift; + gint *n_entries; + gint count; + guint keycode; + + GdkKeymapKey* keys; + gint n_keys; + + + gdk_keymap_get_entries_for_keyval(keymap, VK,&keys,&n_keys); + + + int pos_1 =get_position_From_VirtualKey_Other(VK , All_Vector, 99); + // wprintf(L" get_position_From_VirtualKey_Other %i of VK%i (%c) \n", pos_1, VK,VK); + keycode = All_Vector[1][pos_1][0]; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return L"1"; + + + //unshifted + if (( ss == Base ) && ( caps == 0 )) { + GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); + std::wstring rV1= std::wstring(1, (int) *keyvals); + + gchar * gg1 = gdk_keyval_name (*keyvals); + guint lower; + guint upper; + gdk_keyval_convert_case (*gg1, &lower,&upper); + std::wstring rv2= std::wstring(1, (int) upper); + std::wstring rv1= std::wstring(1, (int) *keyvals); + + //return rv2; + return std::wstring(1, (int) *keyvals); + } + + //SHIFT+CAPS + else if ( ( ss == Shft ) && ( caps ==1 )) { + GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); + + std::wstring rV1= std::wstring(1, (int) *keyvals); + + gchar * gg1 = gdk_keyval_name (*keyvals); + guint lower; + guint upper; + gdk_keyval_convert_case (*gg1, &lower,&upper); + std::wstring rv2= std::wstring(1, (int) upper); + + std::wstring rv1= std::wstring(1, (int) *keyvals); + //return rv2; + return std::wstring(1, (int) *keyvals); + + } + + //Shift + else if (( ss == Shft ) && ( caps == 0 )) { + GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + std::wstring rV1= std::wstring(1, (int) *keyvals); + + +gchar * gg1 = gdk_keyval_name (*keyvals); +guint lower; +guint upper; +gdk_keyval_convert_case (*gg1, &lower,&upper); + + +//keyvals_shift = gg1; + std::wstring rv2= std::wstring(1, (int) upper); + + std::wstring rv1= std::wstring(1, (int) *keyvals); + return std::wstring(1, (int) *keyvals); + + } + + //caps + else if (( ss == Base ) && ( caps == 1 )) { + GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); + + std::wstring rV1= std::wstring(1, (int) *keyvals); + + gchar * gg1 = gdk_keyval_name (*keyvals); + guint lower; + guint upper; + gdk_keyval_convert_case (*gg1, &lower,&upper); + std::wstring rv2= std::wstring(1, (int) upper); + std::wstring rv1= std::wstring(1, (int) *keyvals); + + //return rv2; + return std::wstring(1, (int) *keyvals); + + } + /*//ALT-GR + else if { + GdkModifierType MOD_AltGr = (GdkModifierType) ( GDK_MOD5_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + return *keyvals; + }*/ + + else + return L"0"; +} + diff --git a/linux/mcompile/keymap/helpers.h b/linux/mcompile/keymap/helpers.h old mode 100644 new mode 100755 index b266631ff5..69b3f228b1 --- a/linux/mcompile/keymap/helpers.h +++ b/linux/mcompile/keymap/helpers.h @@ -8,13 +8,14 @@ #include "keymap.h" +//_S2 do not review - all this will be deleted later + // why again here? typedef std::vector v_str_1D; typedef std::vector v_dw_1D; typedef std::vector > v_dw_2D; typedef std::vector > > v_dw_3D; - int test_helpers(); // append characters using VectorFile (Data for Other Language on [1][ ][ ] ) @@ -26,7 +27,6 @@ bool InsertKeyvalsFromVectorFile(v_dw_3D &complete_Vector) ; // create a Vector with all entries of file int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector); - bool writeVectorToFile(v_dw_3D V) ; bool writeFileToVector(v_dw_3D& complete_Vector, const char* infile); bool CompareVector_To_VectorOfFile(v_dw_3D All_Vector,v_dw_3D File_Vector); @@ -35,5 +35,9 @@ bool test_In_Out(v_dw_3D All_Vector); // to check if content of Vector is ok bool write_RGKEY_FileToVector(v_dw_2D& shift_states, const char* infile) ; bool CompareVector_To_VectorOfFile_RGKEY(v_dw_2D Win_Vector,v_dw_2D Lin_Vector, v_dw_2D Map_Vector); +KMX_DWORD get_position_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector); +int replace_PosKey_with_Keycode(std::string in); + +//std::wstring get_VirtualKey_US_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &caps, v_dw_3D &All_Vector); #endif /* HELPERS_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/kmx_file.h b/linux/mcompile/keymap/kmx_file.h old mode 100644 new mode 100755 index 5187f09683..4ab43c38a8 --- a/linux/mcompile/keymap/kmx_file.h +++ b/linux/mcompile/keymap/kmx_file.h @@ -308,8 +308,8 @@ struct KMX_COMP_STORE { }; struct KMX_COMP_KEY { - KMX_WORD Key; - KMX_WORD _reserved; + KMX_WORD Key; + KMX_WORD _reserved; KMX_DWORD Line; KMX_DWORD ShiftFlags; KMX_DWORD dpOutput; @@ -360,8 +360,6 @@ struct KMX_COMP_KEYBOARD_KMXPLUSINFO { /** * Only valid if comp_keyboard.dwFlags&KF_KMXPLUS */ - - struct KMX_COMP_KEYBOARD_EX { KMX_COMP_KEYBOARD header; // 0000 see COMP_KEYBOARD KMX_COMP_KEYBOARD_KMXPLUSINFO kmxplus; // 0040 see COMP_KEYBOARD_EXTRA @@ -391,4 +389,4 @@ static_assert(sizeof(KMX_COMP_KEYBOARD) == KEYBOARDFILEHEADER_SIZE, "COMP_KEYBOA } // namespace kbp } // namespace km #endif -#endif /*KMX_FILE_H*/ \ No newline at end of file +#endif /*KMX_FILE_H*/ diff --git a/linux/mcompile/keymap/mc_savekeyboard.h b/linux/mcompile/keymap/mc_savekeyboard.h old mode 100644 new mode 100755 index 0907dcff5d..71f2e43749 --- a/linux/mcompile/keymap/mc_savekeyboard.h +++ b/linux/mcompile/keymap/mc_savekeyboard.h @@ -6,4 +6,4 @@ #define CERR_None 0x00000000 #define CERR_CannotAllocateMemory 0x00008004 #define CERR_UnableToWriteFully 0x00008007 -#define CERR_SomewhereIGotItWrong 0x00008009 \ No newline at end of file +#define CERR_SomewhereIGotItWrong 0x00008009 From bce124447ff2cb7393a0c2220bdb8261a742b8d6 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 7 Nov 2023 13:04:45 +0100 Subject: [PATCH 113/327] feat(linux): mcompile tidy up code --- linux/mcompile/keymap/keymap.cpp | 624 ++++++++++++---------- linux/mcompile/keymap/keymap.h | 223 ++------ linux/mcompile/keymap/km_types.h | 16 +- linux/mcompile/keymap/mc_import_rules.cpp | 252 ++++++--- linux/mcompile/keymap/mc_kmxfile.cpp | 23 +- linux/mcompile/keymap/mc_kmxfile.h | 11 +- linux/mcompile/keymap/mcompile.cpp | 165 ++---- linux/mcompile/keymap/mcompile.h | 5 +- 8 files changed, 645 insertions(+), 674 deletions(-) mode change 100644 => 100755 linux/mcompile/keymap/keymap.cpp mode change 100644 => 100755 linux/mcompile/keymap/keymap.h mode change 100644 => 100755 linux/mcompile/keymap/km_types.h mode change 100644 => 100755 linux/mcompile/keymap/mc_import_rules.cpp mode change 100644 => 100755 linux/mcompile/keymap/mc_kmxfile.cpp mode change 100644 => 100755 linux/mcompile/keymap/mc_kmxfile.h mode change 100644 => 100755 linux/mcompile/keymap/mcompile.cpp mode change 100644 => 100755 linux/mcompile/keymap/mcompile.h diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp old mode 100644 new mode 100755 index 4d674f9e4d..58deda5ece --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -1,25 +1,6 @@ #include "keymap.h" -/* -static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) -{ - GdkKeymapKey *maps; - guint *keyvals; - gint count; - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return; - - for (int i = 0; i < count; i++) { - if (maps[i].level > 0 || maps[i].group > 1) - continue; - printf(" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); - } - - g_free(keyvals); - g_free(maps); -} -*/ +#include int write_US_ToVector( v_dw_3D &vec,std::string language, const char* text) { @@ -45,7 +26,7 @@ int write_US_ToVector( v_dw_3D &vec,std::string language, const char* text) { return 1; } wprintf(L"\n ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - wprintf(L" +++++++ dimensions of Vector after split_US_To_3D_Vector (languages..characters..shiftstates)\t\t %li..%li..%li\n", vec.size(), vec[0].size(),vec[0][0].size()); + wprintf(L" +++++++ dimensions of Vector after split_US_To_3D_Vector (languages..characters..shiftstates)\t %li..%li..%li\n", vec.size(), vec[0].size(),vec[0][0].size()); fclose(fp); return 0; @@ -53,7 +34,7 @@ int write_US_ToVector( v_dw_3D &vec,std::string language, const char* text) { bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, std::string language) { // in the Configuration file we find the appopriate paragraph between "xkb_symbol " and the next xkb_symbol - // and then copy all rows starting with "key <" to a v1D-Vector + // and then copy all rows starting with "key <" to a 1D-Vector int buffer_size = 512; char buffer[buffer_size]; @@ -85,6 +66,8 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, } } } + complete_List.push_back(" key { [ space, space] };"); + //complete_List.push_back(" key { [ backslash, bar ] };"); if (complete_List.size() <1) { wprintf(L"ERROR: can't create row from US \n"); @@ -96,32 +79,43 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, KMX_DWORD convertNamesToValue(std::wstring tok_wstr){ std::map first; - //initializing first[L"exclam"] = 33; first[L"at"] = 64; first[L"numbersign"] = 35; first[L"dollar"] = 36; first[L"percent"] = 37; - first[L"dead_circumflex"] = 94; /* _S2 ??? */ + first[L"dead_circumflex"] = 94; first[L"ampersand"] = 38; first[L"asterisk"] = 42; first[L"parenleft"] = 40; first[L"parenright"] = 41; - first[L"equal"] = VK_EQUAL; /* BB = 187 */ - first[L"backslash"] = VK_BKSLASH; /* DC = 220 */ - first[L"bracketleft"] = VK_LBRKT; /* DB = 219 */ - first[L"bracketright"] = VK_RBRKT; /* DD = 221 */ - first[L"parenright"] = VK_COLON; /* BA = 186 */ - first[L"comma"] = VK_COMMA; /* BC = 188 */ - first[L"period"] = VK_PERIOD; /* BE = 190 */ - first[L"slash"] = VK_SLASH; /* BF = 191 */ - first[L"ssharp"] = VK_xDF; /* DF = 223 ß */ - first[L"minus"] = VK_HYPHEN; /* BD = 189 ? */ - first[L"dead_acute"] = VK_ACCENT; /* C0 = 192 ? */ - first[L"space"] = VK_SPACE; /* 20 = 32 ? */ + first[L"minus"] = 45; + first[L"underscore"] = 95; + first[L"equal"] = 61; + first[L"plus"] = 43; + first[L"bracketleft"] = 91; + first[L"braceleft"] = 123; + first[L"bracketright"] = 93; + first[L"braceright"] = 125; + first[L"semicolon"] = 59; + first[L"colon"] = 58; + first[L"apostrophe"] = 39; + first[L"quotedbl"] = 34; + first[L"backslash"] = 92; + first[L"bar"] = 124; + first[L"comma"] = 44; + first[L"less"] = 60; + first[L"period"] = 46; + first[L"greater"] = 62; + first[L"slash"] = 47; + first[L"question"] = 63; + first[L"space"] = 32; - // _S2 ?? VK_QUOTE, VK_OEM_102, + first[L"dead_acute"] = 180; + first[L"grave"] = 96; + first[L"ssharp"] = 223; + //first[L" ?? "] = VK_OEM_102; /* DE = 226 ' " ? VK_OEM_102 */ if ( tok_wstr.size() == 1) { return (KMX_DWORD) ( *tok_wstr.c_str() );; @@ -140,7 +134,7 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { // 1: take the whole line of the 1D-Vector and remove unwanted characters. // 2: seperate the name e.g. key from the shiftstates // 3: convert to KMX_DWORD - // 4: push Names/Shiftstates to shift_states and then shiftstates to All_US, our 3D-Vector holding all Elements + // 4: push Names/Shiftstates to shift_states and then shift_states to All_US, our 3D-Vector holding all Elements std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; char split_bracel = '{'; @@ -153,7 +147,7 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { std::wstring tok_wstr; // loop through the whole vector - for (int k = 0; k < (int)completeList.size() - 1; k++) { + for (int k = 0; k < (int)completeList.size() ; k++) { // remove all unwanted char for (int i = 0; i < (int) delim.size(); i++) { @@ -167,8 +161,8 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { std::istringstream split1(completeList[k]); for (std::string each; std::getline(split1, each, split_bracel); tokens.push_back(each)); - // replace keys names with Keycode ( with 29,...) - Keycde = replace_PosKey_with_Keycode(tokens[0]); + // replace keys names with Keycode ( with 21,...) + Keycde = replace_PosKey_with_Keycode_use_Lin(tokens[0]); tokens[0] = std::to_string(Keycde); // seperate rest of the vector to its elements and push to 'tokens' @@ -197,134 +191,78 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { } all_US.push_back(shift_states); - if ( all_US.size() ==0) { + if ( all_US.size() == 0) { wprintf(L"ERROR: Can't split US to 3D-Vector\n"); return 1; } return 0; } -int replace_PosKey_with_Keycode(std::string in) { +int replace_PosKey_with_Keycode_use_Lin(std::string in) { int out = returnIfCharInvalid; // _S2 these are the Scancode-Values we use in Keyman ( = like the windows scancodes) + // NAME IN SYMBOLS-FILE KEYCODE (LIN STYLE) (WIN STYLE) VK_US VK_DE + /*on US keyb;*/ + if ( in == "key") out = 49; /* VK_ */ // TOASK correct ??? + else if ( in == "key") out = 10; /* 0X02 VK_1 */ + else if ( in == "key") out = 11; /* 0X03 VK_2 */ + else if ( in == "key") out = 12; /* 0X04 VK_3 */ + else if ( in == "key") out = 13; /* 0X05 VK_4 */ + else if ( in == "key") out = 14; /* 0X06 VK_5 */ + else if ( in == "key") out = 15; /* 0X07 VK_6 */ + else if ( in == "key") out = 16; /* 0X08 VK_7 */ + else if ( in == "key") out = 17; /* 0X09 VK_8 */ + else if ( in == "key") out = 18; /* 0X0A VK_9 */ + else if ( in == "key") out = 19; /* 0X0B VK_0 */ + else if ( in == "key") out = 20; /*out = 61;*/ /* 0X0C VK_MINUS de ẞ*/ + else if ( in == "key") out = 21; /* 0X0D VK_EQUALS DE ' */ - if ( in == "key") out = 49; /* 0X VK_ */ // TOASK correct ??? - else if ( in == "key") out = 1; /* 0X02 VK_1 */ - else if ( in == "key") out = 2; /* 0X03 VK_2 */ - else if ( in == "key") out = 3; /* 0X04 VK_3 */ - else if ( in == "key") out = 4; /* 0X05 VK_4 */ - else if ( in == "key") out = 5; /* 0X06 VK_5 */ - else if ( in == "key") out = 6; /* 0X07 VK_6 */ - else if ( in == "key") out = 7; /* 0X08 VK_7 */ - else if ( in == "key") out = 8; /* 0X09 VK_8 */ - else if ( in == "key") out = 9; /* 0X0A VK_9 */ - else if ( in == "key") out = 10; /* 0X0B VK_0 */ - else if ( in == "key") out = 12; /* 0X0C VK_MINUS */ - else if ( in == "key") out = 13; /* 0X0D VK_EQUALS */ + else if ( in == "key") out = 24; /* 0X10 VK_Q */ + else if ( in == "key") out = 25; /* 0X11 VK_W */ + else if ( in == "key") out = 26; /* 0X12 VK_E */ + else if ( in == "key") out = 27; /* 0X13 VK_R */ + else if ( in == "key") out = 28; /* 0X14 VK_T */ + else if ( in == "key") out = 29; /*out = 52;*/ /* 0X15 VK_Y */ + else if ( in == "key") out = 30; /* 0X16 VK_U */ + else if ( in == "key") out = 31; /* 0X17 VK_I */ + else if ( in == "key") out = 32; /* 0X18 VK_O */ + else if ( in == "key") out = 33; /* 0X19 VK_P */ + else if ( in == "key") out = 34; /*out = 17;*/ /* 0X1A VK_LEFTBRACE DE Ü */ + else if ( in == "key") out = 35; /*out = 18;*/ /* 0X1B VK_RIGHTBRACE DE + */ - else if ( in == "key") out = 16; /* 0X10 VK_Q */ - else if ( in == "key") out = 17; /* 0X11 VK_W */ - else if ( in == "key") out = 18; /* 0X12 VK_E */ - else if ( in == "key") out = 19; /* 0X13 VK_R */ - else if ( in == "key") out = 20; /* 0X14 VK_T */ - else if ( in == "key") out = 21; /* 0X15 VK_Y */ - else if ( in == "key") out = 22; /* 0X16 VK_U */ - else if ( in == "key") out = 23; /* 0X17 VK_I */ - else if ( in == "key") out = 24; /* 0X18 VK_O */ - else if ( in == "key") out = 25; /* 0X19 VK_P */ - else if ( in == "key") out = 26; /* 0X1A VK_LEFTBRACE */ - else if ( in == "key") out = 27; /* 0X1B VK_RIGHTBRACE */ + else if ( in == "key") out = 38; /* 0X1E VK_A */ + else if ( in == "key") out = 39; /* 0X1F VK_S */ + else if ( in == "key") out = 40; /* 0X20 VK_D */ + else if ( in == "key") out = 41; /* 0X21 VK_F */ + else if ( in == "key") out = 42; /* 0X22 VK_G */ + else if ( in == "key") out = 43; /* 0X23 VK_H */ + else if ( in == "key") out = 44; /* 0X24 VK_J */ + else if ( in == "key") out = 45; /* 0X25 VK_K */ + else if ( in == "key") out = 46; /* 0X26 VK_L */ + else if ( in == "key") out = 47; /*out = 59;*/ /* 0X27 VK_SEMICOLON DE Ö*/ + else if ( in == "key") out = 48; /*out = 51;*/ /* 0X28 VK_APOSTROPHE DE Ä */ + //else if ( in == "key") out = 51; /*out = 20;*/ /* 0X29 VK_GRAVE DE # */ - else if ( in == "key") out = 30; /* 0X1E VK_A */ - else if ( in == "key") out = 31; /* 0X1F VK_S */ - else if ( in == "key") out = 32; /* 0X20 VK_D */ - else if ( in == "key") out = 33; /* 0X21 VK_F */ - else if ( in == "key") out = 34; /* 0X22 VK_G */ - else if ( in == "key") out = 35; /* 0X23 VK_H */ - else if ( in == "key") out = 36; /* 0X24 VK_J */ - else if ( in == "key") out = 37; /* 0X25 VK_K */ - else if ( in == "key") out = 38; /* 0X26 VK_L */ - else if ( in == "key") out = 39; /* 0X27 VK_SEMICOLON */ - else if ( in == "key") out = 40; /* 0X28 VK_APOSTROPHE */ - else if ( in == "key") out = 41; /* 0X29 VK_GRAVE */ - - else if ( in == "key") out = 44; /* 0X2C VK_Z */ - else if ( in == "key") out = 45; /* 0X2D VK_X */ - else if ( in == "key") out = 46; /* 0X2E VK_C */ - else if ( in == "key") out = 47; /* 0X2F VK_V */ - else if ( in == "key") out = 48; /* 0X30 VK_B */ - else if ( in == "key") out = 49; /* 0X31 VK_N */ - else if ( in == "key") out = 50; /* 0X32 VK_M */ - else if ( in == "key") out = 51; /* 0X33 VK_ COMMA */ - else if ( in == "key") out = 52; /* 0X34 VK_DOT */ - else if ( in == "key") out = 53; /* 0X35 VK_SLASH */ - else if ( in == "key") out = 54; /* 0X36 VK_RIGHTSHIFT */ - else if ( in == "key") out = 55; /* 0X37 VK_RIGHTSHIFT */ + else if ( in == "key") out = 52; /*out = 29;*/ /* 0X2C VK_Z */ + else if ( in == "key") out = 53; /* 0X2D VK_X */ + else if ( in == "key") out = 54; /* 0X2E VK_C */ + else if ( in == "key") out = 55; /* 0X2F VK_V */ + else if ( in == "key") out = 56; /* 0X30 VK_B */ + else if ( in == "key") out = 57; /* 0X31 VK_N */ + else if ( in == "key") out = 58; /* 0X32 VK_M */ + else if ( in == "key") out = 59; /* 0X33 VK_ COMMA */ + else if ( in == "key") out = 60; /* 0X34 VK_DOT */ + else if ( in == "key") out = 61; /*out = 16;*/ /* 0X35 VK_SLASH DE - */ + else if ( in == "key") out = 51; /* 0X29 VK_BKSLASH */ + else if ( in == "key") out = 63; /* 0X37 VK_RIGHTSHIFT */ + else if ( in == "key") out = 65; /* 0X20 ?? 39? VK_SPACE */ return out; } -/* -int replace_PosKey_with_Keycode_old(std::string in) { - int out = returnIfCharInvalid; - if ( in == "key") out = 49; // TOASK correct ??? - else if ( in == "key") out = 10; - else if ( in == "key") out = 11; - else if ( in == "key") out = 12; - else if ( in == "key") out = 13; - else if ( in == "key") out = 14; - else if ( in == "key") out = 15; - else if ( in == "key") out = 16; - else if ( in == "key") out = 17; - else if ( in == "key") out = 18; - else if ( in == "key") out = 19; - else if ( in == "key") out = 20; - else if ( in == "key") out = 21; - - else if ( in == "key") out = 24; - else if ( in == "key") out = 25; - else if ( in == "key") out = 26; - else if ( in == "key") out = 27; - else if ( in == "key") out = 28; - else if ( in == "key") out = 29; - else if ( in == "key") out = 30; - else if ( in == "key") out = 31; - else if ( in == "key") out = 32; - else if ( in == "key") out = 33; - else if ( in == "key") out = 34; - else if ( in == "key") out = 35; - - else if ( in == "key") out = 38; - else if ( in == "key") out = 39; - else if ( in == "key") out = 40; - else if ( in == "key") out = 41; - else if ( in == "key") out = 42; - else if ( in == "key") out = 43; - else if ( in == "key") out = 44; - else if ( in == "key") out = 45; - else if ( in == "key") out = 46; - else if ( in == "key") out = 47; - else if ( in == "key") out = 48; - else if ( in == "key") out = 49; - - else if ( in == "key") out = 52; - else if ( in == "key") out = 53; - else if ( in == "key") out = 54; - else if ( in == "key") out = 55; - else if ( in == "key") out = 56; - else if ( in == "key") out = 57; - else if ( in == "key") out = 58; - else if ( in == "key") out = 59; - else if ( in == "key") out = 60; - else if ( in == "key") out = 61; - else if ( in == "key") out = 51; - else if ( in == "key") out = 94; - - return out; -} -*/ v_dw_2D create_empty_2D( int dim_rows,int dim_shifts) { + v_dw_1D shifts; v_dw_2D Vector_2D; @@ -338,16 +276,15 @@ v_dw_2D create_empty_2D( int dim_rows,int dim_shifts) { return Vector_2D; } -#if USE_GDK - int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { - // create a 2D vector all filled with "--" and push to 3D-Vector +int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { + + // create a 2D vector all filled with " " and push to 3D-Vector v_dw_2D Other_Vector2D = create_empty_2D(All_Vector[0].size(),All_Vector[0][0].size()); - if (Other_Vector2D.size()==0) { + if (Other_Vector2D.size() == 0) { wprintf(L"ERROR: can't create empty 2D-Vector\n"); return 1; } - All_Vector.push_back(Other_Vector2D); wprintf(L" +++++++ dimensions of Vector after append_other_ToVector\t\t\t\t\t\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); wprintf(L" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n"); @@ -363,31 +300,16 @@ v_dw_2D create_empty_2D( int dim_rows,int dim_shifts) { All_Vector[1][i][0] = All_Vector[0][i][0]; // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] - All_Vector[1][i][0+1] = getKeyvalsFromKeymap(keymap,keycode_map[All_Vector[0][i][0]],0); //shift state: unshifted:0 - All_Vector[1][i][1+1] = getKeyvalsFromKeymap(keymap,keycode_map[All_Vector[0][i][0]],1); //shift state: shifted:1 - - wprintf(L" Keycodes US dw : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); - wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); - } - return 0; -} - - bool InsertKeyvalsFromKeymap(v_dw_3D &All_Vector,GdkKeymap * keymap){ - // get the keyvals using GDK and copy into All_Vector - for(int i =0; i< (int) All_Vector[1].size();i++) { - // get key name US stored in [0][i][0] and copy to name in "other"-block[1][i][0] - All_Vector[1][i][0] = All_Vector[0][i][0]; - - // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] - All_Vector[1][i][0+1] = getKeyvalsFromKeymap(keymap,(All_Vector[1][i][0]),0); //shift state: unshifted:0 - All_Vector[1][i][1+1] = getKeyvalsFromKeymap(keymap,(All_Vector[1][i][0]),1); //shift state: shifted:1 + All_Vector[1][i][0+1] = getKeyvalsFromKeymap(keymap,All_Vector[0][i][0],0); //shift state: unshifted:0 + All_Vector[1][i][1+1] = getKeyvalsFromKeymap(keymap,All_Vector[0][i][0],1); //shift state: shifted:1 //wprintf(L" Keycodes US dw : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); //wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); } + return 0; } - KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { +KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; guint *keyvals; gint count; @@ -396,150 +318,98 @@ v_dw_2D create_empty_2D( int dim_rows,int dim_shifts) { if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - // return 0; + // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html - if (!(shift_state_pos < count)) + if (!(shift_state_pos <= count)) return 0; out =(KMX_DWORD) keyvals[shift_state_pos]; - //wprintf(L" getKeyvalsFromKeymap: in %i -- out : %i \n", (int)keycode, out); - + // _S2 QUESTION + // _S2 what is 65104-65106, 65506, 21840 // _S2 if out of range of what ( ascii??) return 0 or other value ? - if (out > 255) - out = 0; + if (out > 255) { + wprintf(L"out of range: found value out( %i) for keycode = %i /shift_state_pos %i (49= TLDE 21= VK_EQUALS on US keyboard) \n", out,keycode,shift_state_pos); + out = 0; + } g_free(keyvals); g_free(maps); return out; } -#endif -// _S2 not needed later -bool test(v_dw_3D &V) { - std::string extra = " "; - wprintf(L" +++++++ dimensions of whole Vector in test()\t\t\t\t\t\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); - wprintf(L"\n+++++++++ print some characters of US and Other +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); +// _S2 TODO is this correct ?? +KMX_DWORD map_To_VK(KMX_DWORD SC ){ + // if there is a Keyman VK.. defined map to Keyman VKcode - for ( int k=0; k<(int)V[0].size(); k++) { - if(V[0][k][2] != V[1][k][2] ) - extra = " *** "; - else - extra = " "; + if ( SC == 49) return VK_BKSLASH; /* ; 220 = ` oder ^ */ + if ( SC == 20) return VK_LBRKT; /* ; 219 = - oder ß */ + if ( SC == 21) return VK_RBRKT; /* ; 221 = = oder ' */ - if (V[0].size()>0) { - /*wprintf(L" row (US) ...... SC= %i .. %i (%c) .. %i (%c) .. --- ",V[0][k][0] , V[0][k][1] , V[0][k][1] , V[0][k][2] , V[0][k][2] ); - wprintf(L" \n"); - wprintf(L" row (Other)..... SC= %i .. %i (%c) .. %i (%c) .. %s \n", V[1][k][0] , V[1][k][1], V[1][k][1] , V[1][k][2], V[1][k][2] , extra.c_str()); - wprintf(L" \n");*/ - } - } - wprintf(L"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - return true; + if ( SC == 34) return VK_COLON; /* ; 186 VK_OEM_4 = [ oder ü */ + if ( SC == 35) return VK_EQUAL; /* ; 187 = ] oder + */ + + if ( SC == 47) return VK_ACCENT; /* ; 192 VK_OEM_1 = : oder ö */ + if ( SC == 48) return VK_QUOTE; /* ' 222 VK_OEM_7 = " oder Ä */ + if ( SC == 51) return VK_SLASH; /* ; 191 = \ oder # */ + + if ( SC == 59) return VK_COMMA; /* ; 188 = , oder , */ + if ( SC == 60) return VK_PERIOD; /* ; 190 = . oder . */ + if ( SC == 61) return VK_HYPHEN; /* ; 189 = / oder - */ + + if ( SC == 65) return VK_SPACE; /* ; 32 VK_SPACE = oder */ + else + return SC; } -bool test_single(v_dw_3D &V) { - std::string extra = " "; - wprintf(L" +++++++ dimensions of single Vector in test_single()\t\t\t\t\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); - wprintf(L"\n +++++++++ print characters of SINGLE DW ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - - for ( int k=0; k<(int)V[0].size(); k++) { - if (V[0].size()>0) { - wprintf(L" row (US) ...... %i .. %i (%c) .. %i (%c) ........ \n", V[0][k][0] , V[0][k][1] ,V[0][k][1] , V[0][k][2], V[0][k][2] ); - } - } - wprintf(L" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - return true; -} - -// _S2 ToDo something does not work yet -// query All_Vector -// return RETURN NON SHIFTED CHAR [1] the VirtualKey of the Other Keyboard for given Scancode +// _S2 TODO Do I need to use All_Vector ?? KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ - // find correct row of char in US - for( int k=0; k< (int)All_Vector.size()-1;k++) { - for( int i=0; i< (int)All_Vector[1].size()-1;i++) { + for( int i=0; i< (int)All_Vector[0].size();i++) { + //number keys return unshifted value ( e.g. 1 not !) + if(SC <= 19) { + if ( All_Vector[0][i][0] == SC) + return All_Vector[1][i][1]; + } - // _S2 what if we use column 3(altgr) and 4 (shift+altgr) ?? + // other keys + if((SC > 19) ) { + if ( All_Vector[0][i][0] == SC) { - /*// unshifted values e.g. "q" (=113) are stored in column All_Vector[1][i][ 1 ] - if ( All_Vector[k][i][0] == (SC- All_Vector[0].size() )) { - wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); - return All_Vector[1][i][1] ; - }*/ + // normal capital characters return the value of capital char ( e.g. A) + if ((All_Vector[1][i][2] >= 65 ) && (All_Vector[1][i][2] < 91 )) + return All_Vector[1][i][2]; - if(( SC < 10) && (SC >= 0)){ - // values for numbers are stored in column All_Vector[1][i][ 1 ] - if ( All_Vector[k][i][0] == SC ) { - wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][2],All_Vector[1][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); - KMX_DWORD returnval= All_Vector[1][i][1]; - return All_Vector[1][i][1]; - } - } - - // shifted values e.g. "Q" (=81) are stored in column All_Vector[1][i][ 2 ] - if ( All_Vector[k][i][0] == SC ) { - wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][2],All_Vector[1][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); - KMX_DWORD returnval= All_Vector[1][i][2]; - - return All_Vector[1][i][2]; + // special characters return Keyman defined values (e.g. VK_ACCENT) + else + //return All_Vector[1][i][1]; + return map_To_VK(SC); } } } - return 0; //_S2 what do I return if not found?? +return 0; } - -/*// query All_Vector -// return RETURN NON SHIFTED CHAR [1] the VirtualKey of the Other Keyboard for given Scancode -KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ - // find correct row of char in US - for( int k=0; k< (int)All_Vector.size()-1;k++) { - for( int i=0; i< (int)All_Vector[1].size()-1;i++) { - - // _S2 what if we use column 3(altgr) and 4 (shift+altgr) ?? - - // unshifted values e.g. "q" (=113) are stored in column All_Vector[1][i][ 1 ] - if ( All_Vector[k][i][0] == (SC- All_Vector[0].size() )) { - wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); - return All_Vector[1][i][1] ; - } - - // shifted values e.g. "Q" (=81) are stored in column All_Vector[1][i][ 2 ] - if ( All_Vector[k][i][0] == SC ) { - wprintf(L" SC= %i .. i= %i .. %i:\t\t %i(%c) (%i (%c) : %i (%c) ) --- \n",SC , i, All_Vector[k][i][0] , All_Vector[k][i][1] ,All_Vector[1][i][2],All_Vector[1][i][2] ,All_Vector[k][i][1] , All_Vector[k][i][2] , All_Vector[k][i][2] ); - return All_Vector[1][i][2] ; - } - } - } - return 0; //_S2 what do I return if not found?? -}*/ - - +// _S2 not needed?, can go later? // return RETURN NON SHIFTED CHAR [1] the VirtualKey of the US Keyboard for given Scancode KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ // find correct row of char in US for( int i=0; i< (int)All_Vector[0].size()-1;i++) { if ( All_Vector[0][i][0] == SC ) { - wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- ",SC , i, All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2] ); - return All_Vector[0][i][1] ; // shouldn this be [0][i][2]? - //return All_Vector[0][i][2] ; // would be shifted version + return All_Vector[0][i][1] ; } } return 0; //_S2 what do I return if not found?? } - // return the Scancode of for given VirtualKey of Other Keyboard KMX_DWORD get_SC_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector){ // find correct row of char in US for( int i=0; i< (int)All_Vector[1].size()-1;i++) { if ( All_Vector[1][i][1] == VK_Other ) { - wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- ",VK_Other , i, All_Vector[1][i][0] , All_Vector[1][i][1] ,All_Vector[1][i][1] , All_Vector[1][i][2] , All_Vector[1][i][2] ); return All_Vector[1][i][0] ; } } @@ -551,22 +421,208 @@ KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ // find correct row of char in US for( int i=0; i< (int)All_Vector[0].size()-1;i++) { if ( All_Vector[0][i][2] == VK_US ) { - wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- \n",VK_US , i, All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2] ); return All_Vector[0][i][0] ; } } return 0; //_S2 what do I return if not found?? } - -// return the Scancode of for given VirtualKey of Other US -KMX_DWORD get_position_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ +// returns the position in All_Vector where VK_Other is found +KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector, int which_columns) { // find correct row of char in US - for( int i=0; i< (int)All_Vector[0].size()-1;i++) { - if ( All_Vector[0][i][2] == VK_US ) { - wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- \n",VK_US , i, All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2] ); - return i; + if((which_columns <1 ) ) + return 0; + + // search all columns + if(which_columns >(int)All_Vector[1][0].size()) { + for( int i=0; i< (int)All_Vector[1][0].size();i++) { + for( int j=0; j< (int)All_Vector[1].size()-1;j++) { + if ( ( All_Vector[1][j][i] == VK_Other ) ) + return j; + } } } + + else { + for( int j=0; j< (int)All_Vector[1].size()-1;j++) { + if ( ( All_Vector[1][j][which_columns] == VK_Other ) ) + return j; + } + } + return 0; //_S2 what do I return if not found?? + +} + +// _S2 TODO is this correct? +const int Lin_KM__map(int i, v_dw_3D &All_Vector) { + // MAP: + // VK KEYMAN-STYLE -> KEYCODE LINUX-STYLE + // e.g 188 -> 59 + //All_Vector_[ 1 ][ in which line of US did find the value 58 ][ take second or third column wherever I find 58 ]] + // finds 59th row (not value 59) + int dw=0; + //if (i == 32 ) return ; /* */5 + //if (i == 186 ) return 252; /* Ü */ + if (i == 187 ) {wprintf(L" swapped: i (%i) to 43 \n",dw,i); return 43; }/* + * */ + if (i == 188 ) {wprintf(L" swapped: i (%i) to 59 \n",dw,i); return 59; }/* COMMA */ + if (i == 189 ) {wprintf(L" swapped: i (%i) to 95 \n",dw,i); return 95; }/* - _ */ + if (i == 190 ) {wprintf(L" swapped: i (%i) to 58 \n",dw,i); return 58; }/* PERIOD */ + if (i == 191 ) {wprintf(L" swapped: i (%i) to 35 \n",dw,i); return 35; }/* # ' */ + //if (i == 191 ) {wprintf(L" swapped: i (%i) to 63 \n",dw,i); return 63; }/* */ + //if (i == 214 ) {wprintf(L" swapped: i (%i) to 192 \n",dw,i); return 192; }/* Ö */ + if (i == 219 ) {wprintf(L" swapped: i (%i) to 223 \n",dw,i); return 223; }/* Sharp-S+ ? */ + if (i == 220 ) {wprintf(L" swapped: i (%i) to 92 \n",dw,i); return 92; }/* ^ ° */ + //if (i == 221 ) {wprintf(L" swapped: i (%i) to 180 \n",dw,i); return 180; }/* ' ` */ + //if (i == 223 ) {wprintf(L" swapped: i (%i) to 59 \n",dw,i); return ; }/* */ + + if (i == 226 ) {wprintf(L" swapped: i (%i) to 60 \n",dw,i); return 60; }/* < > */ + if (i == 65105 ) {wprintf(L" swapped: i (%i) to 92 \n",dw,i); return 92; }/* */ + + // e.g. rgKey[192] contains character 214 + if (i == 192 ) {wprintf(L" swapped: i (%i) to 214 \n",dw,i); return 214; }/* Ö */ + if (i == 186 ) {wprintf(L" swapped: i (%i) to 220 \n",dw,i); return 220; }/* Ü */ + if (i == 222 ) {wprintf(L" swapped: i (%i) to 196 \n",dw,i); return 196; }/* Ä */ + + return i; +} + +// _S2 TODO +std::wstring getKeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint VK, v_dw_3D &All_Vector, ShiftState ss, int caps ){ + + GdkModifierType consumed; + GdkKeymapKey *maps; + GdkEventKey* event; + guint *keyvals; + guint *keyvals_shift; + gint *n_entries; + gint count; + guint keycode; + + GdkKeymapKey* keys; + gint n_keys; + + gdk_keymap_get_entries_for_keyval(keymap, VK,&keys,&n_keys); + + int pos_1 =get_position_From_VirtualKey_Other(VK , All_Vector, 99); + //wprintf(L" get_position_From_VirtualKey_Other %i of VK%i (%c) \n", pos_1, VK,VK); + keycode = All_Vector[1][pos_1][0]; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return L"1"; + + + //unshifted + if (( ss == Base ) && ( caps == 0 )) { + GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); + + return std::wstring(1, (int) *keyvals); + } + + //SHIFT+CAPS + else if ( ( ss == Shft ) && ( caps ==1 )) { + GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + + } + + //Shift + else if (( ss == Shft ) && ( caps == 0 )) { + GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + std::wstring rV1= std::wstring(1, (int) *keyvals); + + +/*const char * nme= gdk_keyval_name (keycode); +int aaa = (int)(*nme); +gint ggg = (gint)(*nme); +gchar * gg1 = gdk_keyval_name (GDK_KEY_4); +gchar * ff1 = gdk_keyval_name (GDK_KEY_a); +gchar * ee1 = gdk_keyval_name (GDK_KEY_A); +//gchar * gg1 = gdk_keyval_name (ggg); +guint lower; +guint upper; +gdk_keyval_convert_case (*ff1, &lower,&upper); +gdk_keyval_convert_case (*ee1, &lower,&upper); +gdk_keyval_convert_case (*gg1, &lower,&upper);*/ + + + gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count); + + for (int i = 0; i < count; i++) { + if (maps[i].level > 1 || maps[i].group > 1) + continue; + wprintf(L" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", + i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); + + int zz = keyvals[i]; + std::string str2 = std::string(1, zz); + const char * cc = str2.c_str(); + gchar * gg1 = gdk_keyval_name (zz); + + guint AAAAA_lowerx; + guint AAAAA_upperx; + if ( zz>0) + gdk_keyval_convert_case (*gg1, &AAAAA_lowerx,&AAAAA_upperx); + if ( AAAAA_lowerx == AAAAA_upperx ) { + wprintf(L" .................................AAAAA_lowerx == AAAAA_upperx %i (%c)\n", AAAAA_lowerx ,AAAAA_upperx); + std::wstring rv2= std::wstring(1, (int) AAAAA_upperx); + + return rv2;} + + int end=9; + } + + int zz1 = keyvals[0]; + //int zz1 = keycode; + std::string str21 = std::string(1, zz1); + const char * cc1 = str21.c_str(); + gchar * gg11 = gdk_keyval_name (zz1); + //convertNamesToValue(*gg11); + + guint AAAAA_lowerx1; + guint AAAAA_upperx1; + if ( zz1>0) + gdk_keyval_convert_case (*gg11, &AAAAA_lowerx1,&AAAAA_upperx1); + if ( AAAAA_lowerx1 == AAAAA_upperx1 ) + wprintf(L" ..........xxx.......................\n" ); + + + +/*guint keycode =38; +guint keyval = gdk_keymap_get_entries_for_keycode(keymap, keycode, NULL, NULL, NULL)[0].keyval; +guint keyval = gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps1, &keyvals1, NULL); +keyvals[i]*/ +const char * nme1= gdk_keyval_name (maps[0].keycode); + + + +//keyvals_shift = gg1; + std::wstring rv2= std::wstring(1, (int) AAAAA_upperx1); + + return rv2; + + return std::wstring(1, (int) *keyvals); + + } + + //caps + else if (( ss == Base ) && ( caps == 1 )) { + GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + + } + + /*//ALT-GR + else if { + GdkModifierType MOD_AltGr = (GdkModifierType) ( GDK_MOD5_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + return *keyvals; + }*/ + + else + return L"0"; } diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h old mode 100644 new mode 100755 index 8e782c36bd..839fe63f5d --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -27,167 +27,52 @@ typedef std::vector v_dw_1D; typedef std::vector > v_dw_2D; typedef std::vector > > v_dw_3D; + +enum ShiftState { + Base = 0, // 0 + Shft = 1, // 1 + Ctrl = 2, // 2 + ShftCtrl = Shft | Ctrl, // 3 + Menu = 4, // 4 -- NOT USED + ShftMenu = Shft | Menu, // 5 -- NOT USED + MenuCtrl = Menu | Ctrl, // 6 + ShftMenuCtrl = Shft | Menu | Ctrl, // 7 + Xxxx = 8, // 8 + ShftXxxx = Shft | Xxxx, // 9 +}; + // Map of all US English virtual key codes that we can translate -// const KMX_DWORD KMX_VKMap[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', //_S2 those might not work correctly yet*/ - /*VK_SPACE, - VK_ACCENT, VK_HYPHEN, VK_EQUAL, - VK_LBRKT, VK_RBRKT, VK_BKSLASH, - VK_COLON, VK_QUOTE, - VK_COMMA, VK_PERIOD, VK_SLASH, - VK_xDF, VK_OEM_102,*/ + + VK_ACCENT, /* 192 VK_OEM_3 */ + VK_HYPHEN, /* - 189 VK_OEM_MINUS */ + VK_EQUAL, /* = 187 VK_OEM_PLUS */ + + VK_LBRKT, /* [ 219 VK_OEM_4 */ + VK_RBRKT, /* ] 221 VK_OEM_6 */ + VK_BKSLASH, /* \ 220 VK_OEM_5 */ + + VK_COLON, /* ; 186 VK_OEM_1 or ö */ + VK_QUOTE, /* ' 222 VK_OEM_7 or Ä */ + + VK_COMMA, /* , 188 VK_OEM_COMMA */ + VK_PERIOD, /* . 190 VK_OEM_PERIOD */ + VK_SLASH, /* / 191 VK_OEM_2 */ + + VK_SPACE, /* 32 */ + + VK_xDF, /* ß (?) 223*/ + VK_OEM_102, /* < > | 226 */ + 0 }; -// mapping between Linux keycodes and keyman SC -const int keycode_map_old[67]={ - 0, /* */ - 0, /* */ - 0, /* */ - 0, /* */ - 0, /* */ - 0, /* */ - 0, /* */ - 0, /* */ - 0, /* */ - 0, /* */ - 2, /*10. 1 */ - 3, /*11. 2 */ - 4, /*12. 3 */ - 5, /*13. 4 */ - 6, /*14. 5 */ - 7, /*15. 6 */ - 8, /*16. 7 */ - 9, /*17. 8 */ - 10, /*18. 9 */ - 11, /*19. 0 */ - 12, /*20. MINUS */ - 13, /*21. EQUALS*/ - 14, /*22. BACKSPACE*/ - 15, /*23. TAB*/ - 16, /* 24. Q */ - 17, /* 25. W */ - 18, /* 26. E */ - 19, /* 27. R */ - 20, /* 28. T */ - 21, /* 29. Z */ - 22, /* 30. U */ - 23, /* 31. I*/ - 24, /* 32. O*/ - 25, /* 33. P*/ - 26, /*34. LEFTBRACE*/ - 27, /*35. RIGHTBRACE*/ - 28, /*36. ENTER*/ - 29, /*37. LEFTCTRL*/ - 30, /* 38. A */ - 31, /* 39. S */ - 32, /* 40. D */ - 33, /* 41. F */ - 34, /* 42. G */ - 35, /* 43. H */ - 36, /* 44. J */ - 37, /* 45. K */ - 38, /* 46. L */ - 39, /*47. SEMICOLON*/ - 40, /*48. APOSTROPHE*/ - 41, /*49. GRAVE*/ - 42, /*50. LEFTSHIFT*/ - 43, /*51. BACKSLASH*/ - 44, /*52. Z */ - 45, /*53. X */ - 46, /*54. C */ - 47, /*55. V */ - 48, /*56. B */ - 49, /*57. N */ - 50, /*58. M */ - 51, /*59. COMMA */ - 52, /*60. DOT */ - 53, /*61. SLASH */ - 54, /*62. R_SHIFT */ - 55, /*63. * */ - 56, /*64. LEFTALT*/ - 57, /*65. SPACE*/ - 58 /*66. CAPSLOCK*/ -}; - - -// mapping between Linux keycodes and keyman SC -const int keycode_map[67]={ - 0, /* */ - 10, /*10. 1 */ - 11, /*11. 2 */ - 12, /*12. 3 */ - 13, /*13. 4 */ - 14, /*14. 5 */ - 15, /*15. 6 */ - 16, /*16. 7 */ - 17, /*17. 8 */ - 18, /*18. 9 */ - 19, /*19. 0 */ - 20, /*20. MINUS */ - 21, /*21. EQUALS*/ - 22, /*22. BACKSPACE*/ - 23, /*23. TAB*/ - 0, /* */ - 24, /* 16.. Q */ - 25, /* 7. W */ - 26, /* 18. E */ - 27, /* 19. R */ - 28, /* 20. T */ - 29, /* 21. Z */ - 30, /* 22. U */ - 31, /* 23. I*/ - 32, /* 24. O*/ - 33, /* 25. P*/ - 34, /*26. LEFTBRACE*/ - 35, /*27. RIGHTBRACE*/ - 36, /*28. ENTER*/ - 37, /*29. LEFTCTRL*/ - 38, /* 30. A */ - 39, /* 31. S */ - 40, /* 32. D */ - 41, /* 33. F */ - 42, /* 34. G */ - 43, /* 35. H */ - 44, /* 36. J */ - 45, /* 37. K */ - 46, /* 38. L */ - 47, /*39. SEMICOLON*/ - 48, /*40. APOSTROPHE*/ - 49, /*41. GRAVE*/ - 50, /*42. LEFTSHIFT*/ - 51, /*43. BACKSLASH*/ - 52, /*44. Z */ - 53, /*45. X */ - 54, /*46. C */ - 55, /*47. V */ - 56, /*48. B */ - 57, /*49. N */ - 58, /*50. M */ - 59, /*51. COMMA */ - 60, /*52. DOT */ - 61, /*53. SLASH */ - 62, /*54. R_SHIFT */ - 63, /*55. * */ - 64, /*56. LEFTALT*/ - 65, /*57. SPACE*/ - 66 , /*58. CAPSLOCK*/ - 0, /* */ - 0, /* */ - 0, /* */ - 0, /* */ - 0, /* */ - 0, /* */ - 0, /* */ - 0 /* */ -}; - +//_S2 QUESTION Which character do we use in that case? 0 or FFFF or 32 or ?? // this is what we return when we find an invalid character -//_S2 Which character do we use in that case? 0 or FFFF or 32 or ?? static KMX_DWORD returnIfCharInvalid = 32; // takes a std::wstring (=contents of line symbols-file ) and returns the (int) value of the character @@ -205,16 +90,12 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE *fpp, const char *text, // 2nd step: write contents to 3D vector int split_US_To_3D_Vector(v_dw_3D &all_US, v_str_1D completeList); -// replace Name of Key (e.g. ) wih Keycode ( e.g. 15 ) -int replace_PosKey_with_Keycode(std::string in); - +// replace Name of Key (e.g. ) wih Keycode ( e.g. 0x15 ) +int replace_PosKey_with_Keycode_use_Lin(std::string in); // create an empty 2D vector containing "--" in all fields v_dw_2D create_empty_2D(int dim_rows, int dim_shifts); -// get Keyvals from VectorFile.txt and insert into All_Vector -bool InsertKeyvalsFromVectorFile(v_dw_3D &All_Vector); - // query All_Vector // return the VirtualKey of the Other Keyboard for given Scancode KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); @@ -222,12 +103,12 @@ KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); // return the Scancode of for given VirtualKey of Other Keyboard KMX_DWORD get_SC_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector); -// return the Scancode of for given VirtualKey of Other US +// return the Scancode of for given VirtualKey of US KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector); -// return the Scancode of for given VirtualKey of Other US -KMX_DWORD get_position_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector); - -#if USE_GDK +// return the Scancode of for given VirtualKey of Other +KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_US , v_dw_3D &All_Vector); +// return the Scancode of for given VirtualKey of Other in specific column. If column > available columns look in all columns; +KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector, int which_columns); // initialize GDK bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); @@ -238,24 +119,12 @@ int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap); // append characters using GDK to 3D-Vector (Data for Other Language on [1][ ][ ] ) int append_other_ToVector(v_dw_3D &All_Vector, GdkKeymap *keymap); -// get Keyvals from keymap and insert into All_Vector -bool InsertKeyvalsFromKeymap(v_dw_3D &All_Vector,GdkKeymap * keymap); - // find Keyvals to fill into 2D-Vector of Other Language KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos); -#endif +// mapping between Linux keycodes and keyman SC +const int Lin_KM__map(int i, v_dw_3D &All_Vector); -// testing of Vector contents ( first row of US and Other) -bool test(v_dw_3D &V); -bool test_single(v_dw_3D &V) ; - -// this is for using mcompile without gdk to be able to debug in VSCode: (can be deleted later) -// In mcompile using gdk: Read values of keyboard with help of GDK. -// in mcompile WITHOUT using GDK: use gdk once to read values-> store them in file Vectorfile.txt -// Vectorfile.txt will then be used to find & append Values of OtherKeyboard to Vector -bool writeVectorToFile(v_dw_3D V); -bool writeFileToVector(v_dw_3D& complete_Vector, const char* infile); -bool CompareVector_To_VectorOfFile(v_dw_3D All_Vector,v_dw_3D File_Vector); +std::wstring getKeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint VK, v_dw_3D &All_Vector, ShiftState ss, int caps ); # endif /*KEYMAP_H*/ diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h old mode 100644 new mode 100755 index d26b2bed8a..53f5485740 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -4,8 +4,6 @@ #include -#define X_test 0xFF1234 - /* #if defined(_WIN32) || defined(_WIN64) #define snprintf _snprintf @@ -47,7 +45,7 @@ typedef char16_t KMX_WCHAR; // _S2 typedef KMX_WCHAR* PKMX_WCHAR; // _S2 typedef wchar_t* PWSTR; // _S2 needs to be removed/ wchart-> char16 typedef PWSTR PKMX_WCHART; // _S2 needs to be removed/ wchart-> char16 -typedef const wchar_t* PCKMX_WCHART; // _S2 needs to be removed/? +//typedef const wchar_t* PCKMX_WCHART; // _S2 needs to be removed/? typedef char* LPSTR; // _S2 needs to be removed? typedef LPSTR LPKMX_STR; // _S2 needs to be removed? @@ -61,6 +59,7 @@ typedef uint8_t* PKMX_BYTE; // _S2 needs to be removed? typedef char KMX_CHAR; // _S2 needs to be removed/? typedef char* PKMX_STR; // _S2 needs to be removed/? +typedef unsigned int UINT; // _S2 needs to be removed/? typedef unsigned char BYTE; // _S2 needs to be removed? typedef unsigned long DWORD; // _S2 needs to be removed/? typedef unsigned short WORD; // _S2 needs to be removed/? @@ -68,7 +67,6 @@ typedef wchar_t* LPWSTR; // _S2 needs to be removed/? typedef WCHAR* PWCHAR; // _S2 needs to be removed/? typedef KMX_CHAR* PKMX_CHAR; // _S2 needs to be removed/? -typedef unsigned int UINT; // _S2 needs to be removed/? typedef int BOOL; // _S2 needs to be removed/? or is it int32_t?? @@ -133,7 +131,7 @@ typedef KMX_UCHAR* KMX_PUCHAR; #define VK_CANCEL 0x09 #define VK_DECIMAL 0x5B*/ - +// _S2 correct?? Do I need NUMPAD?? #define VK_NUMPAD0 96 #define VK_NUMPAD1 97 #define VK_NUMPAD2 98 @@ -148,4 +146,12 @@ typedef KMX_UCHAR* KMX_PUCHAR; #define VK_CANCEL 3 #define VK_DECIMAL 110 +#define VK_OEM_CLEAR 0xFE +#define VK_LSHIFT 0xA0 +#define VK_RSHIFT 0xA1 +#define VK_LCONTROL 0xA2 +#define VK_RCONTROL 0xA3 +#define VK_LMENU 0xA4 +#define VK_RMENU 0xA5 + #endif /*KM_TYPES*/ diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp old mode 100644 new mode 100755 index 41bd3938a4..8cd7a486dc --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -25,19 +25,7 @@ #include #include "km_types.h" #include "mc_kmxfile.h" - -enum ShiftState { - Base = 0, // 0 - Shft = 1, // 1 - Ctrl = 2, // 2 - ShftCtrl = Shft | Ctrl, // 3 - Menu = 4, // 4 -- NOT USED - ShftMenu = Shft | Menu, // 5 -- NOT USED - MenuCtrl = Menu | Ctrl, // 6 - ShftMenuCtrl = Shft | Menu | Ctrl, // 7 - Xxxx = 8, // 8 - ShftXxxx = Shft | Xxxx, // 9 -}; +#include "keymap.h" const int KMX_ShiftStateMap[] = { ISVIRTUALKEY, @@ -49,7 +37,8 @@ const int KMX_ShiftStateMap[] = { ISVIRTUALKEY | RALTFLAG, ISVIRTUALKEY | RALTFLAG | K_SHIFTFLAG, 0, - 0}; + 0 +}; class DeadKey { private: @@ -142,8 +131,6 @@ public: //right-hand keys, the left-hand scan code is returned. //If there is no translation, the function returns 0.*/ - - this->m_sc = get_SC_From_VirtualKey_Other(KMX_virtualKey, All_Vector); this->m_hkl = hkl; this->m_vk = KMX_virtualKey; @@ -158,10 +145,34 @@ public: // If there is no translation, the function returns 0. // SC -> VK this->m_vk = get_VirtualKey_Other_From_SC(scanCode, All_Vector); + // this->m_vk = get_VirtualKey_Other_From_SC_NEW(scanCode, All_Vector, keymap, scanCode,scanCode); + //this->m_vk = get_VirtualKey_Other_From_SC_GDK_dw( All_Vector, keymap, scanCode,scanCode); // use gdk to get vk`s + this->m_hkl = hkl; this->m_sc = scanCode; } + KMX_VirtualKey(UINT scanCode, KMX_HKL hkl, v_dw_3D All_Vector, GdkKeymap **keymap) { + // _S2 this->m_vk = MapVirtualKeyEx(scanCode, 1, hkl); // second para= 1: MAPVK_VSC_TO_VK =1 + // The first parameter is a scan code and is + // translated into a virtual-key code that does not + // distinguish between left- and right-hand keys. + // If there is no translation, the function returns 0. + // SC -> VK + this->m_vk = get_VirtualKey_Other_From_SC(scanCode, All_Vector); + + //this->m_vk = get_VirtualKey_Other_From_SC_NEW(scanCode, All_Vector, keymap, scanCode,scanCode); + this->m_hkl = hkl; + this->m_sc = scanCode ; + } + +void set_SC(UINT value){ + this->m_sc = value; +} +void set_VK(UINT value){ + this->m_vk = value; +} + UINT VK() { return this->m_vk; } @@ -179,7 +190,6 @@ public: this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; } - bool KMX_IsSGCAPS() { std::wstring stBase = this->KMX_GetShiftState(Base, false); std::wstring stShift = this->KMX_GetShiftState(Shft, false); @@ -286,7 +296,7 @@ public: return nkeys; } - bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion) { // I4552 + bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,v_dw_3D &All_Vector) { // I4552 // Get the CAPSLOCK value int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | @@ -305,12 +315,14 @@ public: if (st.size() == 0) { // No character assigned here - } else if (this->m_rgfDeadKey[(int)ss][caps]) { + } + // _S2 deadkeys don work yet + else if (this->m_rgfDeadKey[(int)ss][caps]) { // It's a dead key, append an @ sign. key->dpContext = new KMX_WCHAR[1]; *key->dpContext = 0; key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); - key->Key = KMX_VKUnderlyingLayoutToVKUS(this->VK()); + key->Key = KMX_VKUnderlyingLayoutToVKUS(All_Vector,this->VK()); key->Line = 0; if(bDeadkeyConversion) { // I4552 @@ -332,7 +344,7 @@ public: } if(isvalid) { - key->Key = KMX_VKUnderlyingLayoutToVKUS(this->VK()); + key->Key = KMX_VKUnderlyingLayoutToVKUS(All_Vector,this->VK()); key->Line = 0; key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); key->dpContext = new KMX_WCHAR; *key->dpContext = 0; @@ -485,7 +497,7 @@ public: // _S2 where to put this?? const int CODE__SIZE[] = { - -1, // undefined 0x00 + -1, // undefined 0x00 1, // CODE_ANY 0x01 2, // CODE_INDEX 0x02 0, // CODE_CONTEXT 0x03 @@ -494,14 +506,14 @@ const int CODE__SIZE[] = { 0, // CODE_RETURN 0x06 0, // CODE_BEEP 0x07 1, // CODE_DEADKEY 0x08 - -1, // unused 0x09 + -1, // unused 0x09 2, // CODE_EXTENDED 0x0A - -1, // CODE_EXTENDEDEND 0x0B (unused) + -1, // CODE_EXTENDEDEND 0x0B (unused) 1, // CODE_SWITCH 0x0C - -1, // CODE_KEY 0x0D (never used) + -1, // CODE_KEY 0x0D (never used) 0, // CODE_CLEARCONTEXT 0x0E 1, // CODE_CALL 0x0F - -1, // UC_SENTINEL_EXTENDEDEND 0x10 (not valid with UC_SENTINEL) + -1, // UC_SENTINEL_EXTENDEDEND 0x10 (not valid with UC_SENTINEL) 1, // CODE_CONTEXTEX 0x11 1, // CODE_NOTANY 0x12 2, // CODE_SETOPT 0x13 @@ -547,8 +559,6 @@ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p) { return p; } - - int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { int n = 0; while(p && *p) { @@ -563,8 +573,6 @@ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { return n; } - - // _S2 has to go !! bool write_rgKey_ToFile(std::vector rgKey ){ std::string RGKey_FileName="/Projects/keyman/keyman/linux/mcompile/keymap/rgKey_lin.txt"; @@ -581,31 +589,75 @@ bool write_rgKey_ToFile(std::vector rgKey ){ return true; } +bool is_Letter(int pos, v_dw_3D & All_Vector){ + if( ( All_Vector[1][pos][1] == All_Vector[1][pos][2] + 32) ) + return true; + return false; +} + +bool is_Number(int pos, v_dw_3D & All_Vector){ + if( (All_Vector[1][pos][1] >= 48) && (All_Vector[1][pos][1] <= 57) ) + return true; + return false; +} + +bool is_Special(int pos, v_dw_3D & All_Vector){ + if( !is_Number && !is_Letter) + return true; + return false; +} + +bool is_Edges(int pos, v_dw_3D & All_Vector){ + if( (All_Vector[1][pos][1] == 48)) + return true; + return false; +} + // _S2 where to put this?? -std::wstring get_VirtualKey_US_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &caps, v_dw_3D &All_Vector) { +std::wstring get_VirtualKey_Other_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &caps, v_dw_3D &All_Vector) { + // _S2 this will find the correct row in All_Vector + //( e.g. get_position_From_VirtualKey_Other(65 ,All_Vector ) returns 25 + // All_Vector[25] contains SC(38), unshifted A (97) shifted A (65) ) + KMX_DWORD pos = get_position_From_VirtualKey_Other(iKey, All_Vector,99); + /*KMX_DWORD pos0 = get_position_From_VirtualKey_Other(iKey, All_Vector,0); + KMX_DWORD pos1 = get_position_From_VirtualKey_Other(iKey, All_Vector,1); + KMX_DWORD pos2 = get_position_From_VirtualKey_Other(iKey, All_Vector,2); + KMX_DWORD pos3 = get_position_From_VirtualKey_Other(iKey, All_Vector,99);*/ int icaps; - KMX_DWORD pos = get_position_From_VirtualKey_US(iKey, All_Vector); - if (ss >9) return L""; - if( ss < All_Vector[0][pos].size()-1) { + if( ss < All_Vector[1][pos].size()-1) { - if ( ss % 2 == 0) - icaps = ss+2-caps; + // ss 0,2,4... + if ( ss % 2 == 0) { + // aAAa 4$$4 + if ( is_Letter(pos, All_Vector) || is_Number(pos, All_Vector)) + icaps = ss+2-caps; + // ..:: ##'' + else + icaps = ss+1; + } - if ( ss % 2 == 1) - icaps = ss+caps; + // ss 1,3,5... + if ( ss % 2 == 1) { + // aAAa 4$$4 + if ( is_Letter(pos, All_Vector) || is_Number(pos, All_Vector)) + icaps = ss+caps; + // ..:: ##'' + else + icaps = ss+1; + } - return std::wstring(1, (int) All_Vector[0][pos][icaps]); + return std::wstring(1, (int) All_Vector[1][pos][icaps]); } return L""; } -bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 - wprintf(L"\n ##### KMX_ImportRules of mc_import_rules started #####\n"); + +bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 KMX_Loader loader; const size_t BUF_sz= 256; @@ -626,10 +678,8 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std return false; } */ - KMX_HKL hkl = NULL; //_S2 added: but can I do this?? hkl is not needed in Linux?? - BYTE lpKeyState[256];// = new KeysEx[256]; std::vector rgKey; //= new VirtualKey[256]; std::vector alDead; @@ -640,21 +690,50 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std // Scroll through the Scan Code (SC) values and get the valid Virtual Key (VK) // values in it. Then, store the SC in each valid VK so it can act as both a // flag that the VK is valid, and it can store the SC value. + // _S2 this does not find exactly the same keys as the windows version does(windows finds more) + // but the ones we need for mcompile are there + //for(UINT sc = 0x01; sc <= 0x7f; sc++) { + +//should be 54 (= unshifted) +//KMX_VirtualKey *key1 = new KMX_VirtualKey(15, hkl, All_Vector, keymap); +//should be 65 (=shifted) +//KMX_VirtualKey *key2 = new KMX_VirtualKey(38, hkl, All_Vector, keymap); + +//------------------------------------ + +/*//for(UINT sc = 0x01; sc <= 0x7f; sc++) { + for(UINT sc = 0x0; sc <= 0x7f; sc++) { + KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector); // _S2 get this from my Vector + uint key_vk = key->VK() ; ++ wprintf(L" sc= %i --- VK = %i (%c)\n",sc,key_vk,key_vk); + if(key->VK() != 0) { + rgKey[key->VK()] = key; + } else {*/ + + + +//--------------------------- + + + for(UINT sc = 0x01; sc <= 0x7f; sc++) { - KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector); // _S2 get this from my Vector + // KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector); // _S2 get this from my Vector + KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector, keymap); // _S2 get this from my Vector uint key_vk = key->VK() ; - if(key->VK() != 0) { - rgKey[key->VK()] = key; + /*std::wstring s= getKeySyms_according_to_Shiftstate( *keymap, (guint) sc , All_Vector, Shft, 0 ); + if ( !s.empty() ); + UINT in1_dw = (UINT)(*s.c_str()); + + key->set_VK( in1_dw) ; + wprintf(L" sc= %i --- VK = %i (%c)\n",sc,key_vk,key_vk);*/ + if((key->VK() != 0) && (key->VK() <256)) { + rgKey[key->VK()] = key; } else { - delete key; + delete key; } + } - /* // where in rgkey do I store Numpad??? - // _S2 do we need NUMPAD now or later? If so we need to add Numpad values to All_Vector ( which has only values a-z) -// _S2 use KMX_VirtualKey !! - // _S2 do I need NUMPAD + SPECIAL_SHIFT for first draft ?? - // add the special keys that do not get added from the code above for(UINT ke = VK_NUMPAD0; ke <= VK_NUMPAD9; ke++) { rgKey[ke] = new KMX_VirtualKey(hkl, ke, All_Vector); } @@ -662,9 +741,9 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE, All_Vector); rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL, All_Vector); rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL, All_Vector); - */ -/* // _S2 do we need special shift state now or later? +/* + // _S2 do we need special shift state now or later? // See if there is a special shift state added for(UINT vk = 0; vk <= VK_OEM_CLEAR; vk++) { UINT sc = MapVirtualKeyEx(vk, 0, hkl); @@ -688,28 +767,59 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std } } */ + // _S2 test rgkey can go later + for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { + if(rgKey[iKey] != NULL) { + wprintf(L" Key Nr %i is available\n",iKey); + } + } // _S2 in this part we skip shiftstates 4, 5, 8, 9 for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { if(rgKey[iKey] != NULL) { WCHAR sbBuffer[256]; // Scratchpad we use many places + //UINT mapped_ikey = Lin_KM__map[iKey]; + UINT mapped_ikey = Lin_KM__map(iKey, All_Vector); + for(ShiftState ss = Base; ss <= loader.MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { if(ss == Menu || ss == ShftMenu) { // Alt and Shift+Alt don't work, so skip them continue; } +int Keypos = get_position_From_VirtualKey_Other(mapped_ikey , All_Vector, 2); +UINT pp = (UINT) All_Vector[1][Keypos][0]; + + + for(int caps = 0; caps <= 1; caps++) { + //wprintf(L"this was ss %i - ikey %i\n",ss ,iKey); //_S2 TODO //_S2 get char - do I need rc ?? ( was rc = ToUnicodeEx...) - std::wstring VK_US = get_VirtualKey_US_from_iKey(iKey, ss, caps, All_Vector); + std::wstring VK_Other = get_VirtualKey_Other_from_iKey(mapped_ikey, ss, caps, All_Vector); + //std::wstring VK_Other= PrintKeymapForCodeReturnKeySym( *keymap, mapped_ikey, All_Vector, ss, caps); + //std::wstring VK_Other= PrintKeymapForCodeReturnKeySym( *keymap, pp, All_Vector, ss, caps); + + + + + + + + /*if ( VK_Other_OLD != VK_Other) { + if(VK_Other_OLD!=L"" ) + wprintf(L"\nVK`s are different :-( %s <--> %s ",VK_Other_OLD.c_str() ,VK_Other.c_str()); + }*/ + + //std::wstring VK_Other = get_VirtualKey_Other_from_iKey(iKey, ss, caps, All_Vector); + //wprintf(L"ikey : %i (mapped to %i ) SS (%i) caps(%i) ----> returns %s (%i)\n", iKey, mapped_ikey , ss, caps, VK_Other.c_str(), (int) *( VK_Other.c_str())); //_S2 TODO //do I need that ?? //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { - if(VK_US == L"") { + if(VK_Other == L"") { rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); } @@ -723,7 +833,8 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std //_S2 TODO // fill m_rgss and m_rgfDeadkey ( m_rgfDeadkey will be done later) - rgKey[iKey]->KMX_SetShiftState(ss, VK_US, false, (caps == 0)); + //rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps == 0)); + rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps==0)); //} // from rc==1 // } // from rc > 0 @@ -737,6 +848,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std // } from rc<0 } } + wprintf(L" Values for SC: %i\t: VK: %i \n", rgKey[iKey]->SC(),rgKey[iKey]->VK() ); } } @@ -750,7 +862,14 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std write_RGKEY_FileToVector(V_map, "map.txt"); CompareVector_To_VectorOfFile_RGKEY( V_win, V_lin,V_map);*/ - + //std::vector< int > TestValues = {48,49,50,52,53,54,55,56,57,54,65,89,189,188}; + //std::vector< int > TestValues = {48,49,50,52,53,54,55,56}; + wprintf(L"-----------------\nNow the tests:\n"); + std::vector< int > TestValues = {65}; + for ( int i=0; i < TestValues.size();i++) { + wprintf(L"Results for %i\t: %s %s %s %s \n", TestValues[i], rgKey[TestValues[i]]->KMX_GetShiftState(Base,0).c_str(), rgKey[TestValues[i]]->KMX_GetShiftState(Base,1).c_str() , rgKey[TestValues[i]]->KMX_GetShiftState(Shft,0).c_str(), rgKey[TestValues[i]]->KMX_GetShiftState(Shft,1).c_str()); + } + wprintf(L"-----------------\n"); //------------------------------------------------------------- // Now that we've collected the key data, we need to @@ -758,7 +877,6 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std //------------------------------------------------------------- int nDeadkey = 0; - LPKMX_GROUP gp = new KMX_GROUP[kp->cxGroupArray+4]; // leave space for old memcpy(gp, kp->dpGroupArray, sizeof(KMX_GROUP) * kp->cxGroupArray); @@ -777,20 +895,15 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std //} LPKMX_KEY kkp = gp->dpKeyArray; -int STOP=0; for(UINT j = 0; j < gp->cxKeyArray; j++, kkp++) { nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpContext)); nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpOutput)); } } - kp->cxGroupArray++; gp = &kp->dpGroupArray[kp->cxGroupArray-1]; -int STOP2=0; - -// _S2 need to change mapping win-lin before i can get correct values here! UINT nKeys = 0; for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { @@ -811,11 +924,13 @@ int STOP2=0; // // Fill in the new rules // +int STOP; for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { + wprintf(L"********************************* I use Key Nr %i\n",iKey); // for each item, - if(rgKey[iKey]->KMX_LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion)) { // I4552 + if(rgKey[iKey]->KMX_LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector)) { // I4552 nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); } } @@ -835,7 +950,7 @@ int STOP2=0; *p++ = (KMX_WCHAR)(kp->cxGroupArray); *p = 0; - // + // _S2 TODO not sure if this works OK -> we need to use more shiftstates than base+Shift // I4550 - Each place we have a nomatch > use(baselayout) (this last group), we need to add all // the AltGr and ShiftAltGr combinations as rules to allow them to be matched as well. Yes, this // loop is not very efficient but it's not worthy of optimisation. @@ -863,7 +978,7 @@ int STOP2=0; } } - // + // _S2 TODO not sure if this works OK -> we need to use deadkeys... // If we have deadkeys, then add a new group to translate the deadkeys per the deadkey tables // We only do this if not in deadkey conversion mode // @@ -937,8 +1052,5 @@ int STOP2=0; kkp++; } } - - -wprintf(L"\n ##### KMX_ImportRules of mc_import_rules ended #####\n"); return true; } diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp old mode 100644 new mode 100755 index 5b6231f259..67e4c5f94a --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -3,15 +3,12 @@ #include "filesystem.h" // _S2 needed? #include -KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard); - KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz); LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, PKMX_WCHAR filename) { - wprintf(L"#### KMX_SaveKeyboard of mc_kmxfile started\n"); FILE *fp; fp = Open_File(filename, u"wb"); @@ -34,13 +31,11 @@ KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, PKMX_WCHAR filename) { return FALSE; } - wprintf(L"#### KMX_SaveKeyboard of mc_kmxfile ended\n"); return TRUE; } KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL FSaveDebug) { - wprintf(L" ##### KMX_WriteCompiledKeyboard of mc_kmxfile started\n"); LPKMX_GROUP fgp; LPKMX_STORE fsp; LPKMX_KEY fkp; @@ -76,7 +71,6 @@ KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL if( fgp->dpNoMatch ) size += u16len(fgp->dpNoMatch)*2 + 2; } - for(i = 0; i < fk->cxStoreArray; i++) { size += u16len(fk->dpStoreArray[i].dpString)*2 + 2; @@ -216,7 +210,6 @@ KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL delete[] buf; - wprintf(L" ##### KMX_WriteCompiledKeyboard of mc_kmxfile ended\n"); return CERR_None; } @@ -226,6 +219,7 @@ PKMX_WCHAR KMX_StringOffset(PKMX_BYTE base, KMX_DWORD offset) { } #ifdef KMX_64BIT + /** CopyKeyboard will copy the data read into bufp from x86-sized structures into x64-sized structures starting at `base` @@ -318,7 +312,7 @@ LPKMX_KEYBOARD KMX_CopyKeyboard(PKMX_BYTE bufp, PKMX_BYTE base) */ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize) { - wprintf(L" ##### KMX_FixupKeyboard of mcompile started\n"); + UNREFERENCED_PARAMETER(dwFileSize); KMX_DWORD i, j; @@ -358,13 +352,11 @@ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFil } } - wprintf(L" ##### KMX_FixupKeyboard of mcompile ended\n"); return kbp; } #endif KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { - wprintf(L"\n##### KMX_LoadKeyboard of mc_kmxfile started #####\n"); PKMX_BYTE buf; FILE* fp; @@ -418,7 +410,7 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { if (!buf) { fclose(fp); KMX_LogError(L"LogErr1: Not allocmem\n" ); - // _S2 delete [] buf; ???? + // _S2 QUESTION delete [] buf; ???? return FALSE; } @@ -431,7 +423,7 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { if (fread(filebase, 1, sz, fp) < (size_t)sz) { KMX_LogError(L"LogError1: Could not read file\n" ); fclose(fp); - // _S2 delete [] buf; ???? + // _S2 QUESTION delete [] buf; ???? return FALSE; } @@ -446,7 +438,7 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { if (!KMX_VerifyKeyboard(filebase, sz)) { KMX_LogError(L"LogError1: errVerifyKeyboard\n" ); - // _S2 delete [] buf; ???? + // _S2 QUESTION delete [] buf; ???? return FALSE; } @@ -459,7 +451,7 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { if (!kbp) { KMX_LogError(L"LogError1: errFixupKeyboard\n" ); - // _S2 delete [] buf; ???? + // _S2 QUESTION delete [] buf; ???? return FALSE; } @@ -470,9 +462,8 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { return FALSE; } *lpKeyboard = kbp; - // _S2 delete [] buf; ???? + // _S2 QUESTION delete [] buf; ???? - wprintf(L"##### KMX_LoadKeyboard of mc_kmxfile ended #####\n"); return TRUE; } diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h old mode 100644 new mode 100755 index e2e09c484f..2d347348a9 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -9,8 +9,6 @@ #include // _S2 can be removed later -//+++++++++++++++++++++++++++++++++++ - #ifndef _KMXFILE_H #define _KMXFILE_H @@ -31,7 +29,6 @@ typedef struct KMX_tagKEY { } KMX_KEY, *LPKMX_KEY; - typedef struct KMX_tagGROUP { KMX_WCHAR* dpName; LPKMX_KEY dpKeyArray; // [LPKEY] address of first item in key array @@ -42,7 +39,6 @@ typedef struct KMX_tagGROUP { } KMX_GROUP, *LPKMX_GROUP; - typedef struct KMX_tagKEYBOARD { KMX_DWORD dwIdentifier; // Keyman compiled keyboard id @@ -76,11 +72,14 @@ typedef struct KMX_tagKEYBOARD { //HBITMAP hBitmap; // handle to the bitmap in the file; } KMX_KEYBOARD, *LPKMX_KEYBOARD; -KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD *lpKeyboard); // _S2 LPKEYBOARD ok to leave as is?? + +KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD *lpKeyboard); KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, PKMX_WCHAR filename); + KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL FSaveDebug); -#endif + +#endif // _KMXFILE_H //---------------------old---------------------------------------- /* diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp old mode 100644 new mode 100755 index 5eadab21b4..3f3393e065 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -21,26 +21,8 @@ 31 Dec 2014 - mcdurdin - I4549 - V9.0 - Mnemonic layout recompiler does not translate Lctrl Ralt for deadkeys correctly 06 Feb 2015 - mcdurdin - I4552 - V9.0 - Add mnemonic recompile option to ignore deadkeys 08 Apr 2015 - mcdurdin - I4651 - V9.0 - Mnemonic layout recompiler maps AltGr+VK_BKSLASH rather than VK_OEM_102 - -This is a copy of win/src/eng/mcompile.cpp -there are 2 options to run mcompile - -u ( which will be done later) - -d ( which will be done here ) - -mcompile -d runs 4 important steps: - -LoadKeyboard(); -> started to exchange for being cross platform ( old version is to the right ) - -int out = run_DoConvert_Part1_getMap(argc,argv); -> there is a version for getting the mapping (keymap.cpp) but it uses string. At the end we will need to se char16_t - -run_DoConvert_Part2_TranslateKeyboard(); -> - -SaveKeyboard(); -> - */ - -// REMEMBER in this VM now debugs with meson compile AND with F5 !!! ( because launch.json has configuration: "Debug with Meson") -// To debug with VSC (F5): -// cd to: /Projects/keyman/keyman/linux/mcompile/keymap/build_mcompile -// run : meson compile ( executable is created - TODO after each change !) -// cursor in mcompile.cpp: F5 - +//_S2 // in /Projects/keyman/keyman/linux/mcompile/keymap/build_mcompile // run with: //./mcompile -d in.kmx bla.dll 0407 out.kmx @@ -56,7 +38,7 @@ mcompile -d runs 4 important steps: KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]); -bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 +bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 std::vector KMX_FDeadkeys; // I4353 @@ -90,26 +72,25 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ argv.push_back(cmdl_par); } - wprintf(L"##### started run\n"); - test_helpers(); + wprintf(L"##### started run\n"); - if(argc < 3 || (argc < 5 && u16cmp(argv[1], u"-u") != 0)) { // I4273// I4273 - wprintf( - L"Usage: mcompile -u infile.kmx outfile.kmx\n" - L" mcompile [-d] infile.kmx kbdfile.dll kbid outfile.kmx\n" - L" With -u parameter, converts keyboard from ANSI to Unicode\n" - L" Otherwise, mcompile converts a Keyman mnemonic layout to a\n" - L" positional one based on the Windows keyboard\n" - L" layout file given by kbdfile.dll\n\n" - L" kbid should be a hexadecimal number e.g. 409 for US English\n" - L" -d convert deadkeys to plain keys\n"); // I4552 + if(argc < 3 || (argc < 5 && u16cmp(argv[1], u"-u") != 0)) { // I4273// I4273 + wprintf( + L"Usage: mcompile -u infile.kmx outfile.kmx\n" + L" mcompile [-d] infile.kmx kbdfile.dll kbid outfile.kmx\n" + L" With -u parameter, converts keyboard from ANSI to Unicode\n" + L" Otherwise, mcompile converts a Keyman mnemonic layout to a\n" + L" positional one based on the Windows keyboard\n" + L" layout file given by kbdfile.dll\n\n" + L" kbid should be a hexadecimal number e.g. 409 for US English\n" + L" -d convert deadkeys to plain keys\n"); // I4552 - return 1; - } + return 1; + } -//-_S2 -------u option will be done later---------------------- + // _S2 QUESTION -------u option will be done later. Do we need it?? ---------------------- - /* if(wcscmp(argv[1], L"-u") == 0) { // I4273 + /* if(wcscmp(argv[1], L"-u") == 0) { // I4273 wchar_t *infile = argv[2], *outfile = argv[3]; LPKEYBOARD kmxfile; @@ -128,8 +109,8 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ delete[] kmxfile; return 0; // I4279 - }*/ -//----------------------------- + }*/ + //----------------------------- int bDeadkeyConversion = u16cmp(argv[1], u"-d") == 0; // I4552 int n = (bDeadkeyConversion ? 2 : 1); @@ -161,7 +142,6 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ // switch the shift state from the VIRTUALCHARKEY to VIRTUALKEY, without changing any // other properties of the key. // - // 3. Write the new keyman keyboard file @@ -179,7 +159,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ }*/ #else // LINUX -// _S2 do I need all parameters?-no +// _S2 ToDo :do I need all parameters?-no if(KMX_DoConvert( kmxfile, kbid, bDeadkeyConversion, argc, (gchar**) argv_ch)) { // I4552F KMX_SaveKeyboard(kmxfile, outfile); } @@ -191,7 +171,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ wprintf(L"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm end\n"); return 0 ; } - +// _S2 TODO which version of VKShiftStates do we use ? // comment from win-version // Map of all shift states that we will work with //const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; @@ -229,7 +209,6 @@ KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { KMX_DWORD KMX_VKUSToVKUnderlyingLayout(v_dw_3D &All_Vector,KMX_DWORD inUS) { // loop and find char in US; then return char of Other for( int i=0; i< (int)All_Vector[0].size();i++) { - // lists entries of all_vector for( int j=1; j< (int)All_Vector[0][0].size();j++) { if((inUS == All_Vector[0][i][j] )) { return All_Vector[1][i][2]; @@ -239,10 +218,17 @@ KMX_DWORD KMX_VKUSToVKUnderlyingLayout(v_dw_3D &All_Vector,KMX_DWORD inUS) { return inUS; } -// _S2 this will definitely give wrong results!!!! -KMX_WORD KMX_VKUnderlyingLayoutToVKUS(KMX_WORD VKey) { - // _S2 TODO adapt for mcompile linux - return VKey; +// takes capital letter of Other returns cpital character of US keyboard +KMX_WORD KMX_VKUnderlyingLayoutToVKUS(v_dw_3D &All_Vector,KMX_DWORD inOther) { + // loop and find char in Other; then return char of US + for( int i=0; i< (int)All_Vector[1].size();i++) { + for( int j=1; j< (int)All_Vector[1][0].size();j++) { + if((inOther == All_Vector[1][i][j] )) { + return All_Vector[0][i][2]; + } + } + } + return inOther; } @@ -250,10 +236,15 @@ KMX_WORD KMX_VKUnderlyingLayoutToVKUS(KMX_WORD VKey) { KMX_DWORD KMX_CharFromVK(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey){ KMX_UINT VKShiftState_lin; - if (VKShiftState == 0 ) VKShiftState_lin =0; - if (VKShiftState == 16) VKShiftState_lin =1; - if (VKShiftState == 9 ) VKShiftState_lin =2; - if (VKShiftState == 25) VKShiftState_lin =3; + + /* 0000 0000 */ + if (VKShiftState == 0 ) VKShiftState_lin = 0; + /* 0001 0000 */ + if (VKShiftState == 16) VKShiftState_lin = 1; + /* 0000 1001 */ + if (VKShiftState == 9 ) VKShiftState_lin = 2; + /* 0001 1001 */ + if (VKShiftState == 25) VKShiftState_lin = 3; // loop and find vkUnderlying in Other; then return char with correct shiftstate for( int i=0; i< (int)All_Vector[1].size();i++) { @@ -265,7 +256,6 @@ KMX_DWORD KMX_CharFromVK(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VK return vkUnderlying; } -#if USE_GDK bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]){ // get keymap of keyboard layout in use @@ -304,12 +294,10 @@ int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ } return 0; } -#endif KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]) { - wprintf(L"\n##### KMX_DoConvert of mcompile started #####\n"); KMX_WCHAR DeadKey; if(!KMX_SetKeyboardToPositional(kbd)) return FALSE; @@ -320,9 +308,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon // evident for the 102nd key on UK, for example, where \ can be generated with VK_OEM_102 or AltGr+VK_QUOTE. // For now, we get the least shifted version, which is hopefully adequate. -#if USE_GDK - wprintf(L"USE_GDK is 1 ****************************************** \n"); - // _S2 first version with GTK - change later to XklGetGroupNames und XklGetCurrentState as Eberhard suggested + // _S2 TODO first version with GTK - change later to XklGetGroupNames und XklGetCurrentState as Eberhard suggested //_ init gdk GdkKeymap *keymap; if(InitializeGDK(&keymap , argc, argv)) { @@ -336,29 +322,6 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon wprintf(L"ERROR: can't create one vector from both keyboards\n"); return FALSE; } -#else - wprintf(L"USE_GDK is 0 ****************************************** \n"); - - // create vector - v_dw_3D All_Vector; - if(createOneVectorFromBothKeyboards(All_Vector)){ - wprintf(L"ERROR: can't create one vector from both keyboards\n"); - return FALSE; - } -#endif -//-------------------------------------------------------------------------------- -/* - //_S2 this is to use a file and a vector instead of GDK-functions so debugging is easier...not needed later... - v_dw_3D complete_Vector; - //bool writeVec_OK = writeVectorToFile(All_Vector); - bool WriteFileOK = writeFileToVector( complete_Vector,"/Projects/keyman/keyman/linux/mcompile/keymap/VectorFile.txt" ); - bool isEqual= CompareVector_To_VectorOfFile( All_Vector, complete_Vector); - wprintf(L" vectors are equal: %i\n",isEqual); // this mmeans both file are equal and All_Vector contains correct data*/ -//test(All_Vector); - -//test_In_Out(All_Vector); - -//-------------------------------------------------------------------------------- const wchar_t* ERROR = L" "; @@ -368,18 +331,17 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon // Loop through each possible key on the keyboard for (int i = 0;KMX_VKMap[i]; i++) { // I4651 - // _S2 why were those 2 functions originally not done in 1 step ?? KMX_DWORD vkUnderlying = KMX_VKUSToVKUnderlyingLayout(All_Vector,(int) KMX_VKMap[i] ); KMX_WCHAR ch = KMX_CharFromVK(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey); - //_S2 marker in output if difference is not 32= (unshifted-shifted ) - can go later + //_S2 marker in wprintf if difference is not 32= (unshifted-shifted ) - can go later if (!( ((int) KMX_VKMap[i] == ch ) || ((int) KMX_VKMap[i] == (int) ch -32) ) ) ERROR = L" !!!"; else ERROR = L" "; - wprintf(L" DoConvert-read i: %i \t(KMX_VKMap): %i (%c) \t---> vkUnderlying: %i (%c) \tshiftstate[%i]: ( %i ) \t---- > ch: %i (%c) \t%ls \t%ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, j, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); + //wprintf(L" DoConvert-read i: %i \t(KMX_VKMap): %i (%c) \t---> vkUnderlying: %i (%c) \tshiftstate[%i]: ( %i ) \t---- > ch: %i (%c) \t%ls \t%ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, j, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); /* _S2 ToDo @@ -389,30 +351,23 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon } }*/ - //wprintf(L" switch with ch: %i (%c)......\n" , ch,ch); + //wprintf(L" switch with ch: %i (%c)......\n" , ch,ch); switch(ch) { case 0x0000: break; - // _S2 deadkeys will be done later + // _S2 TODO deadkeys will be done later //case 0xFFFF: ConvertDeadkey(kbd, VKMap[i], VKShiftState[j], DeadKey); break; default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); } } } -wprintf(L"\n##### KMX_ReportUnconvertedKeyboardRules of mcompile will start #####\n"); KMX_ReportUnconvertedKeyboardRules(kbd); -// _S2 convert mcompile Step1: use (wrong) Datatype WCHAR (=wchar_t) -// _S2 convert mcompile Step2: use (OK) Datatype KMX_WCHAR (=char16_t) - - if(!KMX_ImportRules(kbid, kbd, All_Vector, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 + if(!KMX_ImportRules(kbid, kbd, All_Vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 return FALSE; } -/**/ - - wprintf(L"\n##### KMX_DoConvert of mcompile ended #####\n"); return TRUE; } @@ -433,7 +388,6 @@ void KMX_LogError(const KMX_WCHART* m1,int m2, LPKMX_KEY key) { // void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { - //wprintf(L"\n ##### KMX_TranslateKey of mcompile started #### with vk: %i (%c) shift: %i ch: %i (%c)......" , vk,vk, shift, ch,ch); // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. @@ -446,8 +400,7 @@ void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) //LogError(L"Converted mnemonic rule on line %d, + '%c' TO + [%x K_%d]", key->Line, key->Key, shift, vk); key->ShiftFlags = ISVIRTUALKEY | shift; key->Key = vk; - -//wprintf(L"ISVIRTUALKEY: %i , shift: %i, key->ShiftFlags for mnemonic= %i\n", ISVIRTUALKEY,shift, key->ShiftFlags); + //wprintf(L"ISVIRTUALKEY: %i , shift: %i, key->ShiftFlags for mnemonic= %i\n", ISVIRTUALKEY,shift, key->ShiftFlags); //wprintf(L" 1 and changed, %i (%c) %i (%c) ", ch,ch, vk,vk); } else if(key->ShiftFlags & VIRTUALCHARKEY && key->Key == ch) { // Key is a virtual character key with a hard-coded shift state. @@ -458,65 +411,48 @@ void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) //LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, key->ShiftFlags & ~VIRTUALCHARKEY, vk); key->ShiftFlags &= ~VIRTUALCHARKEY; key->Key = vk; - -//wprintf(L"key->ShiftFlags for VIRTUALCHARKEY= %i", key->ShiftFlags); + //wprintf(L"key->ShiftFlags for VIRTUALCHARKEY= %i", key->ShiftFlags); //wprintf(L" 2 and changed, vk: %i (%c) ---> %i (%c) ", vk,vk, ch,ch); } - - //wprintf(L"\n ##### KMX_TranslateKey of mcompile ended ##### \n"); - //wprintf(L"key->ShiftFlags: %i, key->Key: %i\n", key->ShiftFlags,key->Key); } void KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { - - //wprintf(L"\n ##### KMX_TranslateGroup of mcompile started #####\n"); for(unsigned int i = 0; i < group->cxKeyArray; i++) { KMX_TranslateKey(&group->dpKeyArray[i], vk, shift, ch); } - - //wprintf(L" ##### KMX_TranslateGroup of mcompile ended #####\n"); } void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { - //wprintf(L"\n ##### KMX_TranslateKeyboard of mcompile started #####\n"); //if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)){ - //wprintf(L" ##### KMX_TranslateKeyboard of mcompile started #### with vk: %i (%c) shift: %i ch: %i (%c)......(shift & (LCTRLFLAG|RALTFLAG)) %i == (LCTRLFLAG|RALTFLAG)%i): %i \n" , vk,vk, shift, ch,ch, (shift & (LCTRLFLAG|RALTFLAG)) , (LCTRLFLAG|RALTFLAG), (shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)); for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { if(kbd->dpGroupArray[i].fUsingKeys) { KMX_TranslateGroup(&kbd->dpGroupArray[i], vk, shift, ch); } } - //wprintf(L" ##### KMX_TranslateKeyboard of mcompile ended #####\n"); } void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key) { if(key->ShiftFlags == 0) { //KMX_LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); - //wprintf(L" Sab Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); - //MX_LogError(L"Did not find a match for mnemonic rule on line %d,\n", key->Line); + //wprintf(L" SAB Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); } else if(key->ShiftFlags & VIRTUALCHARKEY) { //KMX_LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); //wprintf(L"SAB Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); - //KMX_LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, \n", key->Line); } } void KMX_ReportUnconvertedGroupRules(LPKMX_GROUP group) { - wprintf(L"\n ##### KMX_ReportUnconvertedGroupRules of mcompile started #####\n"); for(unsigned int i = 0; i < group->cxKeyArray; i++) { KMX_ReportUnconvertedKeyRule(&group->dpKeyArray[i]); } - wprintf(L"\n ##### KMX_ReportUnconvertedGroupRules of mcompile ended #####\n"); } void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { - wprintf(L"\n ##### KMX_ReportUnconvertedKeyboardRules of mcompile started #####\n"); for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { if(kbd->dpGroupArray[i].fUsingKeys) { KMX_ReportUnconvertedGroupRules(&kbd->dpGroupArray[i]); } } - wprintf(L"\n ##### KMX_ReportUnconvertedKeyboardRules of mcompile ended #####\n"); } @@ -526,7 +462,6 @@ void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { // ---- old copy code from here ---------------------------------------------------------- - /* BOOL ConvertKeyboardToUnicode(LPKEYBOARD kbd); // I4273 diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h old mode 100644 new mode 100755 index b4edd3c0bc..e7f4e8c8b7 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -28,7 +28,9 @@ #include "mc_kmxfile.h" int run(int argc, std::vector str_argv, char* argv[]); + void KMX_LogError(const KMX_WCHART* m1, int m2 = 0); + //void KMX_LogError(const KMX_WCHART* m1, int m2 = 0, LPKMX_KEY key =NULL); struct KMX_DeadkeyMapping { // I4353 @@ -40,7 +42,8 @@ struct KMX_DeadkeyMapping { // I4353 extern std::vector KMX_FDeadkeys; // I4353 // _S2 is this correct here??? -KMX_WORD KMX_VKUnderlyingLayoutToVKUS(KMX_WORD VKey) ; +KMX_WORD KMX_VKUnderlyingLayoutToVKUS(KMX_WORD VKey); +KMX_WORD KMX_VKUnderlyingLayoutToVKUS(v_dw_3D &All_Vector,KMX_DWORD inOther); //--------------------old /* From bab7d372efc53f85e3b7f9b4e094bcefa345fdc6 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 7 Nov 2023 13:19:15 +0100 Subject: [PATCH 114/327] feat(linux): mcompile more tidy up code --- linux/mcompile/keymap/helpers.cpp | 52 +++++++++++++++++++++++ linux/mcompile/keymap/keymap.cpp | 9 ++-- linux/mcompile/keymap/mc_import_rules.cpp | 25 +---------- linux/mcompile/keymap/mcompile.cpp | 24 ----------- 4 files changed, 58 insertions(+), 52 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index bee2d764f6..7036882627 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -782,3 +782,55 @@ gdk_keyval_convert_case (*gg1, &lower,&upper); return L"0"; } +/* +bool write_rgKey_ToFile(std::vector rgKey ){ + std::string RGKey_FileName="/Projects/keyman/keyman/linux/mcompile/keymap/rgKey_lin.txt"; + + std::wofstream TxTFile(RGKey_FileName); + for ( int i=0; i< rgKey.size();i++) { + if(rgKey[i] != NULL) { + TxTFile << rgKey[i]->VK() << "-" << rgKey[i]->SC()<< " -> ( " << rgKey[i]->KMX_GetShiftState(Base, 0) << "-" << rgKey[i]->KMX_GetShiftState(Base, 1) << " )" + << " *-* ( " << rgKey[i]->KMX_GetShiftState(Shft, 0) << "-" << rgKey[i]->KMX_GetShiftState(Shft, 1) << " )"; + TxTFile << "\n"; + } + } + TxTFile.close(); + return true; +} + + + + + // _S2 can go later: check if all correct + /*write_rgKey_ToFile(rgKey) ; + v_dw_2D V_lin,V_win,V_map; + write_RGKEY_FileToVector(V_lin, "rgKey_lin.txt"); + write_RGKEY_FileToVector(V_win, "rgKey_Win.txt"); + write_RGKEY_FileToVector(V_map, "map.txt"); + CompareVector_To_VectorOfFile_RGKEY( V_win, V_lin,V_map);*/ + + + + +/* // _S2 maybe not needed +bool get_US_Keysym_From_OtherKeysym(v_str_3D &All_Vector, int inOther, int &OutUS){ + + MyCoutW(L" #### get_US_Char_FromOther of keymap started", 1); + // loop and find char in Other; then find char of US + for( int i=0; i< All_Vector[1].size();i++) { + for( int j=1; j< (int)All_Vector[1][0].size();j++) { + + int KeysymUS = (int) *All_Vector[0][i][j].c_str(); + int KeysymOther = (int) *All_Vector[1][i][j].c_str(); + std::wstring KeysymUS_wstr = wstring_from_string(All_Vector[1][i][j]); + + if( inOther == KeysymOther ) { + OutUS = KeysymUS; + return true; + } + } + } + MyCoutW(L" #### get_US_Char_FromOther of keymap ended", 1); + return true; +}*/ + diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 58deda5ece..e1523b39f4 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -4,7 +4,6 @@ int write_US_ToVector( v_dw_3D &vec,std::string language, const char* text) { - // _S2 relative path !! std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; const char* path = FullPathName.c_str(); @@ -402,7 +401,7 @@ KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ return All_Vector[0][i][1] ; } } - return 0; //_S2 what do I return if not found?? + return 0; //_S2 TODO what do I return if not found?? } // return the Scancode of for given VirtualKey of Other Keyboard @@ -413,7 +412,7 @@ KMX_DWORD get_SC_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector) return All_Vector[1][i][0] ; } } - return 0; //_S2 what do I return if not found?? + return 0; //_S2 TODO what do I return if not found?? } // return the Scancode of for given VirtualKey of Other US @@ -424,7 +423,7 @@ KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ return All_Vector[0][i][0] ; } } - return 0; //_S2 what do I return if not found?? + return 0; //_S2 TODO what do I return if not found?? } // returns the position in All_Vector where VK_Other is found @@ -450,7 +449,7 @@ KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_V } } - return 0; //_S2 what do I return if not found?? + return 0; //_S2 TODO what do I return if not found?? } diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 8cd7a486dc..cce861c016 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -144,6 +144,8 @@ public: // distinguish between left- and right-hand keys. // If there is no translation, the function returns 0. // SC -> VK + //_S2 QUESTION I tried to use gdk_translate-function in get_VirtualKey_Other_From_SC_GDK_dw which was not possible so I use a setter afterwards + //_S2 QUESTION Wy did it give me an error? this->m_vk = get_VirtualKey_Other_From_SC(scanCode, All_Vector); // this->m_vk = get_VirtualKey_Other_From_SC_NEW(scanCode, All_Vector, keymap, scanCode,scanCode); //this->m_vk = get_VirtualKey_Other_From_SC_GDK_dw( All_Vector, keymap, scanCode,scanCode); // use gdk to get vk`s @@ -573,21 +575,7 @@ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { return n; } -// _S2 has to go !! -bool write_rgKey_ToFile(std::vector rgKey ){ - std::string RGKey_FileName="/Projects/keyman/keyman/linux/mcompile/keymap/rgKey_lin.txt"; - std::wofstream TxTFile(RGKey_FileName); - for ( int i=0; i< rgKey.size();i++) { - if(rgKey[i] != NULL) { - TxTFile << rgKey[i]->VK() << "-" << rgKey[i]->SC()<< " -> ( " << rgKey[i]->KMX_GetShiftState(Base, 0) << "-" << rgKey[i]->KMX_GetShiftState(Base, 1) << " )" - << " *-* ( " << rgKey[i]->KMX_GetShiftState(Shft, 0) << "-" << rgKey[i]->KMX_GetShiftState(Shft, 1) << " )"; - TxTFile << "\n"; - } - } - TxTFile.close(); - return true; -} bool is_Letter(int pos, v_dw_3D & All_Vector){ if( ( All_Vector[1][pos][1] == All_Vector[1][pos][2] + 32) ) @@ -853,15 +841,6 @@ UINT pp = (UINT) All_Vector[1][Keypos][0]; } - - // _S2 can go later: check if all correct - /*write_rgKey_ToFile(rgKey) ; - v_dw_2D V_lin,V_win,V_map; - write_RGKEY_FileToVector(V_lin, "rgKey_lin.txt"); - write_RGKEY_FileToVector(V_win, "rgKey_Win.txt"); - write_RGKEY_FileToVector(V_map, "map.txt"); - CompareVector_To_VectorOfFile_RGKEY( V_win, V_lin,V_map);*/ - //std::vector< int > TestValues = {48,49,50,52,53,54,55,56,57,54,65,89,189,188}; //std::vector< int > TestValues = {48,49,50,52,53,54,55,56}; wprintf(L"-----------------\nNow the tests:\n"); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 3f3393e065..1c750ed4ff 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -1410,27 +1410,3 @@ wprintf(L" in Us %i and KeysymsUS %i : \n", inUS ,KeysymUS ); } */ - - -/* // _S2 maybe not needed -bool get_US_Keysym_From_OtherKeysym(v_str_3D &All_Vector, int inOther, int &OutUS){ - - MyCoutW(L" #### get_US_Char_FromOther of keymap started", 1); - // loop and find char in Other; then find char of US - for( int i=0; i< All_Vector[1].size();i++) { - for( int j=1; j< (int)All_Vector[1][0].size();j++) { - - int KeysymUS = (int) *All_Vector[0][i][j].c_str(); - int KeysymOther = (int) *All_Vector[1][i][j].c_str(); - std::wstring KeysymUS_wstr = wstring_from_string(All_Vector[1][i][j]); - - if( inOther == KeysymOther ) { - OutUS = KeysymUS; - return true; - } - } - } - MyCoutW(L" #### get_US_Char_FromOther of keymap ended", 1); - return true; -}*/ - From 0a09e59aa6c23ada1f026352fa9b62f822a7876e Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 7 Nov 2023 22:55:40 +0100 Subject: [PATCH 115/327] feat(linux): mcompile tidy up and rgkeys for nr, chars for DE and FR --- linux/mcompile/keymap/keymap.cpp | 99 ++++------------------- linux/mcompile/keymap/mc_import_rules.cpp | 74 +++++------------ 2 files changed, 38 insertions(+), 135 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index e1523b39f4..0c5bfe072e 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -429,12 +429,12 @@ KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ // returns the position in All_Vector where VK_Other is found KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector, int which_columns) { // find correct row of char in US - if((which_columns <1 ) ) + if((which_columns <0 ) ) return 0; // search all columns if(which_columns >(int)All_Vector[1][0].size()) { - for( int i=0; i< (int)All_Vector[1][0].size();i++) { + for( int i=1; i< (int)All_Vector[1][0].size();i++) { for( int j=0; j< (int)All_Vector[1].size()-1;j++) { if ( ( All_Vector[1][j][i] == VK_Other ) ) return j; @@ -491,22 +491,18 @@ std::wstring getKeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint VK, v_ GdkModifierType consumed; GdkKeymapKey *maps; - GdkEventKey* event; guint *keyvals; - guint *keyvals_shift; - gint *n_entries; gint count; guint keycode; - GdkKeymapKey* keys; gint n_keys; + guint lowerCase; + guint upperCase; - gdk_keymap_get_entries_for_keyval(keymap, VK,&keys,&n_keys); - - int pos_1 =get_position_From_VirtualKey_Other(VK , All_Vector, 99); - //wprintf(L" get_position_From_VirtualKey_Other %i of VK%i (%c) \n", pos_1, VK,VK); + int pos_1 =get_position_From_VirtualKey_Other(VK , All_Vector, 0); keycode = All_Vector[1][pos_1][0]; + // _S2 TODO what to return if it fails? if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return L"1"; @@ -515,7 +511,6 @@ std::wstring getKeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint VK, v_ if (( ss == Base ) && ( caps == 0 )) { GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); } @@ -524,7 +519,6 @@ std::wstring getKeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint VK, v_ GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); return std::wstring(1, (int) *keyvals); - } //Shift @@ -533,78 +527,20 @@ std::wstring getKeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint VK, v_ gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); std::wstring rV1= std::wstring(1, (int) *keyvals); + for (int i = 0; i < count; i++) { + if (maps[i].level > 1 || maps[i].group > 1) + continue; -/*const char * nme= gdk_keyval_name (keycode); -int aaa = (int)(*nme); -gint ggg = (gint)(*nme); -gchar * gg1 = gdk_keyval_name (GDK_KEY_4); -gchar * ff1 = gdk_keyval_name (GDK_KEY_a); -gchar * ee1 = gdk_keyval_name (GDK_KEY_A); -//gchar * gg1 = gdk_keyval_name (ggg); -guint lower; -guint upper; -gdk_keyval_convert_case (*ff1, &lower,&upper); -gdk_keyval_convert_case (*ee1, &lower,&upper); -gdk_keyval_convert_case (*gg1, &lower,&upper);*/ + gchar * gch = gdk_keyval_name (keyvals[i]); + if ( keyvals[i]>0) + gdk_keyval_convert_case (*gch, &lowerCase, &upperCase); - gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count); - - for (int i = 0; i < count; i++) { - if (maps[i].level > 1 || maps[i].group > 1) - continue; - wprintf(L" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", - i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); - - int zz = keyvals[i]; - std::string str2 = std::string(1, zz); - const char * cc = str2.c_str(); - gchar * gg1 = gdk_keyval_name (zz); - - guint AAAAA_lowerx; - guint AAAAA_upperx; - if ( zz>0) - gdk_keyval_convert_case (*gg1, &AAAAA_lowerx,&AAAAA_upperx); - if ( AAAAA_lowerx == AAAAA_upperx ) { - wprintf(L" .................................AAAAA_lowerx == AAAAA_upperx %i (%c)\n", AAAAA_lowerx ,AAAAA_upperx); - std::wstring rv2= std::wstring(1, (int) AAAAA_upperx); - - return rv2;} - - int end=9; - } - - int zz1 = keyvals[0]; - //int zz1 = keycode; - std::string str21 = std::string(1, zz1); - const char * cc1 = str21.c_str(); - gchar * gg11 = gdk_keyval_name (zz1); - //convertNamesToValue(*gg11); - - guint AAAAA_lowerx1; - guint AAAAA_upperx1; - if ( zz1>0) - gdk_keyval_convert_case (*gg11, &AAAAA_lowerx1,&AAAAA_upperx1); - if ( AAAAA_lowerx1 == AAAAA_upperx1 ) - wprintf(L" ..........xxx.......................\n" ); - - - -/*guint keycode =38; -guint keyval = gdk_keymap_get_entries_for_keycode(keymap, keycode, NULL, NULL, NULL)[0].keyval; -guint keyval = gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps1, &keyvals1, NULL); -keyvals[i]*/ -const char * nme1= gdk_keyval_name (maps[0].keycode); - - - -//keyvals_shift = gg1; - std::wstring rv2= std::wstring(1, (int) AAAAA_upperx1); - - return rv2; - - return std::wstring(1, (int) *keyvals); - + // _S2 is ( lowerCase == upperCase ) true for all number keys for all keyboards? + if ( lowerCase == upperCase ) + return std::wstring(1, (int) upperCase); + } + return rV1; } //caps @@ -612,7 +548,6 @@ const char * nme1= gdk_keyval_name (maps[0].keycode); GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); return std::wstring(1, (int) *keyvals); - } /*//ALT-GR diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index cce861c016..72f189fcf8 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -609,10 +609,7 @@ std::wstring get_VirtualKey_Other_from_iKey(KMX_DWORD iKey, ShiftState &ss, int //( e.g. get_position_From_VirtualKey_Other(65 ,All_Vector ) returns 25 // All_Vector[25] contains SC(38), unshifted A (97) shifted A (65) ) KMX_DWORD pos = get_position_From_VirtualKey_Other(iKey, All_Vector,99); - /*KMX_DWORD pos0 = get_position_From_VirtualKey_Other(iKey, All_Vector,0); - KMX_DWORD pos1 = get_position_From_VirtualKey_Other(iKey, All_Vector,1); - KMX_DWORD pos2 = get_position_From_VirtualKey_Other(iKey, All_Vector,2); - KMX_DWORD pos3 = get_position_From_VirtualKey_Other(iKey, All_Vector,99);*/ + int icaps; if (ss >9) return L""; @@ -705,15 +702,14 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd for(UINT sc = 0x01; sc <= 0x7f; sc++) { - // KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector); // _S2 get this from my Vector - KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector, keymap); // _S2 get this from my Vector - uint key_vk = key->VK() ; - /*std::wstring s= getKeySyms_according_to_Shiftstate( *keymap, (guint) sc , All_Vector, Shft, 0 ); - if ( !s.empty() ); - UINT in1_dw = (UINT)(*s.c_str()); + KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector, keymap); + std::wstring str= getKeySyms_according_to_Shiftstate( *keymap, (guint) sc , All_Vector, Shft, 0 ); - key->set_VK( in1_dw) ; - wprintf(L" sc= %i --- VK = %i (%c)\n",sc,key_vk,key_vk);*/ + // use str to fill key->vk + if ( !str.empty() ); + key->set_VK( (UINT)(*str.c_str())) ; + + /*wprintf(L" sc= %i --- VK = %i (%c)\n",sc,key_vk,key_vk);*/ if((key->VK() != 0) && (key->VK() <256)) { rgKey[key->VK()] = key; } else { @@ -756,18 +752,19 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd } */ // _S2 test rgkey can go later - for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { + for(UINT iKey = 100; iKey < rgKey.size(); iKey++) { if(rgKey[iKey] != NULL) { wprintf(L" Key Nr %i is available\n",iKey); } } + // _S2 This part is not finished completely. It still needs some work.. + // _S2 in this part we skip shiftstates 4, 5, 8, 9 for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { if(rgKey[iKey] != NULL) { WCHAR sbBuffer[256]; // Scratchpad we use many places - //UINT mapped_ikey = Lin_KM__map[iKey]; UINT mapped_ikey = Lin_KM__map(iKey, All_Vector); for(ShiftState ss = Base; ss <= loader.MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { @@ -776,39 +773,15 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd continue; } -int Keypos = get_position_From_VirtualKey_Other(mapped_ikey , All_Vector, 2); -UINT pp = (UINT) All_Vector[1][Keypos][0]; - - - for(int caps = 0; caps <= 1; caps++) { - //wprintf(L"this was ss %i - ikey %i\n",ss ,iKey); - //_S2 TODO - //_S2 get char - do I need rc ?? ( was rc = ToUnicodeEx...) + //_S2 TODO get char - do I need rc ?? ( was rc = ToUnicodeEx...) std::wstring VK_Other = get_VirtualKey_Other_from_iKey(mapped_ikey, ss, caps, All_Vector); - //std::wstring VK_Other= PrintKeymapForCodeReturnKeySym( *keymap, mapped_ikey, All_Vector, ss, caps); - //std::wstring VK_Other= PrintKeymapForCodeReturnKeySym( *keymap, pp, All_Vector, ss, caps); - - - - - - - /*if ( VK_Other_OLD != VK_Other) { - if(VK_Other_OLD!=L"" ) - wprintf(L"\nVK`s are different :-( %s <--> %s ",VK_Other_OLD.c_str() ,VK_Other.c_str()); - }*/ - - //std::wstring VK_Other = get_VirtualKey_Other_from_iKey(iKey, ss, caps, All_Vector); - //wprintf(L"ikey : %i (mapped to %i ) SS (%i) caps(%i) ----> returns %s (%i)\n", iKey, mapped_ikey , ss, caps, VK_Other.c_str(), (int) *( VK_Other.c_str())); - - //_S2 TODO - //do I need that ?? + //_S2 TODO do I need that ?? //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { if(VK_Other == L"") { - rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); + rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); } //_S2 TODO @@ -816,15 +789,11 @@ UINT pp = (UINT) All_Vector[1][Keypos][0]; //It's dealing with control characters. If ToUnicodeEx gets VK_A with the Ctrl key pressed, //it will write 0x01 to sBuffer[0] , without Ctrl it's 0x41. The if detects this case. if( (ss == Ctrl || ss == ShftCtrl) /*&& CTRl +0x40 in the buffer ( which indicates a ctrl press) */) { - continue; + continue; } - //_S2 TODO - // fill m_rgss and m_rgfDeadkey ( m_rgfDeadkey will be done later) - //rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps == 0)); - rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps==0)); - //} // from rc==1 - // } // from rc > 0 + //_S2 TODO fill m_rgfDeadkey ( m_rgfDeadkey will be done later) + rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps==0)); //_S2 TODO @@ -836,15 +805,14 @@ UINT pp = (UINT) All_Vector[1][Keypos][0]; // } from rc<0 } } - wprintf(L" Values for SC: %i\t: VK: %i \n", rgKey[iKey]->SC(),rgKey[iKey]->VK() ); } } - + //_S2 this gan co later //std::vector< int > TestValues = {48,49,50,52,53,54,55,56,57,54,65,89,189,188}; - //std::vector< int > TestValues = {48,49,50,52,53,54,55,56}; - wprintf(L"-----------------\nNow the tests:\n"); - std::vector< int > TestValues = {65}; + std::vector< int > TestValues = {48,49,50,51,52,53,54,55,56,57,65,66,67,88,89,90}; + // std::vector< int > TestValues = {65}; + wprintf(L"-----------------\nNow some tests:\n"); for ( int i=0; i < TestValues.size();i++) { wprintf(L"Results for %i\t: %s %s %s %s \n", TestValues[i], rgKey[TestValues[i]]->KMX_GetShiftState(Base,0).c_str(), rgKey[TestValues[i]]->KMX_GetShiftState(Base,1).c_str() , rgKey[TestValues[i]]->KMX_GetShiftState(Shft,0).c_str(), rgKey[TestValues[i]]->KMX_GetShiftState(Shft,1).c_str()); } From 867dc565cdb34e959727ff4ffeb01cdaf6f4950f Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 8 Nov 2023 14:23:53 +0100 Subject: [PATCH 116/327] feat(linux): mcompile numbers + Char OK for DE,FR --- linux/mcompile/keymap/keymap.cpp | 120 +++++++++++++++++----- linux/mcompile/keymap/keymap.h | 2 +- linux/mcompile/keymap/mc_import_rules.cpp | 21 +++- 3 files changed, 115 insertions(+), 28 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index e756e8e714..deafa022a7 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -342,23 +342,23 @@ KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state KMX_DWORD map_To_VK(KMX_DWORD SC ){ // if there is a Keyman VK.. defined map to Keyman VKcode - if ( SC == 49) return VK_BKSLASH; /* ; 220 = ` oder ^ */ - if ( SC == 20) return VK_LBRKT; /* ; 219 = - oder ß */ - if ( SC == 21) return VK_RBRKT; /* ; 221 = = oder ' */ + // if ( SC == 49) return VK_BKSLASH; /* ; 220 = ` oder ^ */ + // if ( SC == 20) return VK_LBRKT; /* ; 219 = - oder ß */ + // if ( SC == 21) return VK_RBRKT; /* ; 221 = = oder ' */ - if ( SC == 34) return VK_COLON; /* ; 186 VK_OEM_4 = [ oder ü */ - if ( SC == 35) return VK_EQUAL; /* ; 187 = ] oder + */ + // if ( SC == 34) return VK_COLON; /* ; 186 VK_OEM_4 = [ oder ü */ + // if ( SC == 35) return VK_EQUAL; /* ; 187 = ] oder + */ - if ( SC == 47) return VK_ACCENT; /* ; 192 VK_OEM_1 = : oder ö */ - if ( SC == 48) return VK_QUOTE; /* ' 222 VK_OEM_7 = " oder Ä */ - if ( SC == 51) return VK_SLASH; /* ; 191 = \ oder # */ + // if ( SC == 47) return VK_ACCENT; /* ; 192 VK_OEM_1 = : oder ö */ + // if ( SC == 48) return VK_QUOTE; /* ' 222 VK_OEM_7 = " oder Ä */ + // if ( SC == 51) return VK_SLASH; /* ; 191 = \ oder # */ - if ( SC == 59) return VK_COMMA; /* ; 188 = , oder , */ - if ( SC == 60) return VK_PERIOD; /* ; 190 = . oder . */ - if ( SC == 61) return VK_HYPHEN; /* ; 189 = / oder - */ + // if ( SC == 59) return VK_COMMA; /* ; 188 = , oder , */ + // if ( SC == 60) return VK_PERIOD; /* ; 190 = . oder . */ + // if ( SC == 61) return VK_HYPHEN; /* ; 189 = / oder - */ - if ( SC == 65) return VK_SPACE; /* ; 32 VK_SPACE = oder */ - else + // if ( SC == 65) return VK_SPACE; /* ; 32 VK_SPACE = oder */ + // else return SC; } @@ -463,24 +463,25 @@ const int Lin_KM__map(int i, v_dw_3D &All_Vector) { int dw=0; //if (i == 32 ) return ; /* */5 //if (i == 186 ) return 252; /* Ü */ - if (i == 187 ) {wprintf(L" swapped: i (%i) to 43 \n",dw,i); return 43; }/* + * */ - if (i == 188 ) {wprintf(L" swapped: i (%i) to 59 \n",dw,i); return 59; }/* COMMA */ - if (i == 189 ) {wprintf(L" swapped: i (%i) to 95 \n",dw,i); return 95; }/* - _ */ - if (i == 190 ) {wprintf(L" swapped: i (%i) to 58 \n",dw,i); return 58; }/* PERIOD */ - if (i == 191 ) {wprintf(L" swapped: i (%i) to 35 \n",dw,i); return 35; }/* # ' */ + //if (i == 187 ) {wprintf(L" swapped: i (%i) to 43 \n",dw,i); return 43; }/* + * */ + //if (i == 188 ) {wprintf(L" swapped: i (%i) to 59 \n",dw,i); return 59; }/* COMMA */ + //if (i == 189 ) {wprintf(L" swapped: i (%i) to 95 \n",dw,i); return 95; }/* - _ */ + //if (i == 190 ) {wprintf(L" swapped: i (%i) to 58 \n",dw,i); return 58; }/* PERIOD */ + //if (i == 191 ) {wprintf(L" swapped: i (%i) to 35 \n",dw,i); return 35; }/* # ' */ //if (i == 191 ) {wprintf(L" swapped: i (%i) to 63 \n",dw,i); return 63; }/* */ //if (i == 214 ) {wprintf(L" swapped: i (%i) to 192 \n",dw,i); return 192; }/* Ö */ - if (i == 219 ) {wprintf(L" swapped: i (%i) to 223 \n",dw,i); return 223; }/* Sharp-S+ ? */ - if (i == 220 ) {wprintf(L" swapped: i (%i) to 92 \n",dw,i); return 92; }/* ^ ° */ + //if (i == 219 ) {wprintf(L" swapped: i (%i) to 223 \n",dw,i); return 223; }/* Sharp-S+ ? */ + //if (i == 220 ) {wprintf(L" swapped: i (%i) to 92 \n",dw,i); return 92; }/* ^ ° */ //if (i == 221 ) {wprintf(L" swapped: i (%i) to 180 \n",dw,i); return 180; }/* ' ` */ //if (i == 223 ) {wprintf(L" swapped: i (%i) to 59 \n",dw,i); return ; }/* */ - if (i == 226 ) {wprintf(L" swapped: i (%i) to 60 \n",dw,i); return 60; }/* < > */ - if (i == 65105 ) {wprintf(L" swapped: i (%i) to 92 \n",dw,i); return 92; }/* */ + //if (i == 226 ) {wprintf(L" swapped: i (%i) to 60 \n",dw,i); return 60; }/* < > */ + //if (i == 65105 ) {wprintf(L" swapped: i (%i) to 92 \n",dw,i); return 92; }/* */ // e.g. rgKey[192] contains character 214 - if (i == 192 ) {wprintf(L" swapped: i (%i) to 214 \n",dw,i); return 214; }/* Ö */ - if (i == 186 ) {wprintf(L" swapped: i (%i) to 220 \n",dw,i); return 220; }/* Ü */ + //if (i == 192 ) {wprintf(L" swapped: i (%i) to 214 \n",dw,i); return 214; }/* Ö */ + //if (i == 186 ) {wprintf(L" swapped: i (%i) to 220 \n",dw,i); return 220; }/* Ü */ + //if (i == 222 ) {wprintf(L" swapped: i (%i) to 196 \n",dw,i); return 196; }/* Ä */ if (i == 222 ) {wprintf(L" swapped: i (%i) to 196 \n",dw,i); return 196; }/* Ä */ return i; @@ -559,4 +560,73 @@ std::wstring getKeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint VK, v_ else return L"0"; -} \ No newline at end of file +} + + +std::wstring PrintKeymapForCodeReturnKeySym2(GdkKeymap *keymap, guint VK, v_dw_3D &All_Vector, ShiftState ss, int caps ){ + + GdkModifierType consumed; + GdkKeymapKey *maps; + GdkEventKey* event; + guint *keyvals; + guint *keyvals_shift; + gint *n_entries; + gint count; + guint keycode; + + GdkKeymapKey* keys; + gint n_keys; + + gdk_keymap_get_entries_for_keyval(keymap, VK,&keys,&n_keys); + + int pos_1 =get_position_From_VirtualKey_Other(VK , All_Vector, 0); + //wprintf(L" get_position_From_VirtualKey_Other %i of VK%i (%c) \n", pos_1, VK,VK); + keycode = All_Vector[1][pos_1][0]; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return L"1"; + + + //unshifted + if (( ss == Base ) && ( caps == 0 )) { + GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + } + + //SHIFT+CAPS + else if ( ( ss == Shft ) && ( caps ==1 )) { + GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + + } + + //Shift + else if (( ss == Shft ) && ( caps == 0 )) { + GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + std::wstring rV1= std::wstring(1, (int) *keyvals); + return std::wstring(1, (int) *keyvals); + + } + + //caps + else if (( ss == Base ) && ( caps == 1 )) { + GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + + } + + /*//ALT-GR + else if { + GdkModifierType MOD_AltGr = (GdkModifierType) ( GDK_MOD5_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + return *keyvals; + }*/ + + else + return L"0"; +} + diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index d9d7c56f3a..3b1c7a468c 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -126,5 +126,5 @@ KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state const int Lin_KM__map(int i, v_dw_3D &All_Vector); std::wstring getKeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint VK, v_dw_3D &All_Vector, ShiftState ss, int caps ); - +std::wstring PrintKeymapForCodeReturnKeySym2(GdkKeymap *keymap, guint VK, v_dw_3D &All_Vector, ShiftState ss, int caps ); # endif /*KEYMAP_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index accefd6f42..a30d73fecb 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -773,10 +773,26 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd continue; } +// _S2 TODO get Keyval from GDK +int Keypos = get_position_From_VirtualKey_Other(mapped_ikey , All_Vector, 99); +UINT VK_vec = (UINT) All_Vector[1][Keypos][0]; + for(int caps = 0; caps <= 1; caps++) { //_S2 TODO get char - do I need rc ?? ( was rc = ToUnicodeEx...) - std::wstring VK_Other = get_VirtualKey_Other_from_iKey(mapped_ikey, ss, caps, All_Vector); + std::wstring VK_Other_OLD = get_VirtualKey_Other_from_iKey(mapped_ikey, ss, caps, All_Vector); + // std::wstring VK_Other1= getKeySyms_according_to_Shiftstate( *keymap, VK_vec, All_Vector, ss, caps); + std::wstring VK_Other = PrintKeymapForCodeReturnKeySym2( *keymap, VK_vec, All_Vector, ss, caps ); + + + //std::wstring VK_Other1= PrintKeymapForCodeReturnKeySym( *keymap, pp, All_Vector, ss, caps); + + + + if ( VK_Other_OLD != VK_Other) { + if(VK_Other!=L"" ) + wprintf(L"\nVK`s are different :-( %s <--> %s ",VK_Other.c_str() ,VK_Other_OLD.c_str()); + } //_S2 TODO do I need that ?? //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { @@ -793,7 +809,8 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd } //_S2 TODO fill m_rgfDeadkey ( m_rgfDeadkey will be done later) - rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps==0)); + //rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps==0)); + rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps)); //_S2 TODO From e8fb6f8b607c87e372122ee866abc45d6940bf3b Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 8 Nov 2023 17:19:28 +0100 Subject: [PATCH 117/327] feat(linux): mcompile started OEM keys --- linux/mcompile/keymap/keymap.cpp | 58 +++++++++++++++-------- linux/mcompile/keymap/keymap.h | 6 ++- linux/mcompile/keymap/mc_import_rules.cpp | 31 ++++++------ 3 files changed, 61 insertions(+), 34 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index deafa022a7..ba6f549503 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -338,16 +338,15 @@ KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state return out; } -// _S2 TODO is this correct ?? -KMX_DWORD map_To_VK(KMX_DWORD SC ){ +KMX_DWORD mapVK_To_char(KMX_DWORD SC ){ // if there is a Keyman VK.. defined map to Keyman VKcode // if ( SC == 49) return VK_BKSLASH; /* ; 220 = ` oder ^ */ // if ( SC == 20) return VK_LBRKT; /* ; 219 = - oder ß */ // if ( SC == 21) return VK_RBRKT; /* ; 221 = = oder ' */ - // if ( SC == 34) return VK_COLON; /* ; 186 VK_OEM_4 = [ oder ü */ - // if ( SC == 35) return VK_EQUAL; /* ; 187 = ] oder + */ + if ( SC == 34) return VK_COLON; /* ; 186 VK_OEM_4 = [ oder ü */ + if ( SC == 35) return VK_EQUAL; /* ; 187 = ] oder + */ // if ( SC == 47) return VK_ACCENT; /* ; 192 VK_OEM_1 = : oder ö */ // if ( SC == 48) return VK_QUOTE; /* ' 222 VK_OEM_7 = " oder Ä */ @@ -361,6 +360,30 @@ KMX_DWORD map_To_VK(KMX_DWORD SC ){ // else return SC; } +// _S2 TODO is this correct ?? +KMX_DWORD mapChar_To_VK(KMX_DWORD chr ){ + // if there is a Keyman VK.. defined map to Keyman VKcode + + // if ( SC == 49) return VK_BKSLASH; /* ; 220 = ` oder ^ */ + // if ( SC == 20) return VK_LBRKT; /* ; 219 = - oder ß */ + // if ( SC == 21) return VK_RBRKT; /* ; 221 = = oder ' */ + + if ( chr == VK_COLON) return 220; /* ; 186 VK_OEM_4 = [ oder ü */ + if ( chr == 187) return 42; /* ; 186 VK_OEM_4 = [ oder ü */ + // if ( SC == 35) return VK_EQUAL; /* ; 187 = ] oder + */ + + // if ( SC == 47) return VK_ACCENT; /* ; 192 VK_OEM_1 = : oder ö */ + // if ( SC == 48) return VK_QUOTE; /* ' 222 VK_OEM_7 = " oder Ä */ + // if ( SC == 51) return VK_SLASH; /* ; 191 = \ oder # */ + + // if ( SC == 59) return VK_COMMA; /* ; 188 = , oder , */ + // if ( SC == 60) return VK_PERIOD; /* ; 190 = . oder . */ + // if ( SC == 61) return VK_HYPHEN; /* ; 189 = / oder - */ + + // if ( SC == 65) return VK_SPACE; /* ; 32 VK_SPACE = oder */ + // else + return chr; +} // _S2 TODO Do I need to use All_Vector ?? KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ @@ -383,7 +406,7 @@ KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ // special characters return Keyman defined values (e.g. VK_ACCENT) else //return All_Vector[1][i][1]; - return map_To_VK(SC); + return mapVK_To_char(SC); } } } @@ -453,7 +476,7 @@ KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_V } -// _S2 TODO is this correct? +// _S2 TODO How to do mapping between Linux keycodes and keyman SC const int Lin_KM__map(int i, v_dw_3D &All_Vector) { // MAP: // VK KEYMAN-STYLE -> KEYCODE LINUX-STYLE @@ -462,47 +485,44 @@ const int Lin_KM__map(int i, v_dw_3D &All_Vector) { // finds 59th row (not value 59) int dw=0; //if (i == 32 ) return ; /* */5 - //if (i == 186 ) return 252; /* Ü */ - //if (i == 187 ) {wprintf(L" swapped: i (%i) to 43 \n",dw,i); return 43; }/* + * */ + if (i == 186 ) return 220; /* Ü */ + if (i == 187 ) return 42; /* + * */ //if (i == 188 ) {wprintf(L" swapped: i (%i) to 59 \n",dw,i); return 59; }/* COMMA */ //if (i == 189 ) {wprintf(L" swapped: i (%i) to 95 \n",dw,i); return 95; }/* - _ */ //if (i == 190 ) {wprintf(L" swapped: i (%i) to 58 \n",dw,i); return 58; }/* PERIOD */ //if (i == 191 ) {wprintf(L" swapped: i (%i) to 35 \n",dw,i); return 35; }/* # ' */ - //if (i == 191 ) {wprintf(L" swapped: i (%i) to 63 \n",dw,i); return 63; }/* */ - //if (i == 214 ) {wprintf(L" swapped: i (%i) to 192 \n",dw,i); return 192; }/* Ö */ + //if (i == 191 ) {wprintf(L" swapped: i (%i) to 63 \n",dw,i); return 63; }/* */ + //if (i == 214 ) {wprintf(L" swapped: i (%i) to 192 \n",dw,i); return 192; }/* Ö */ //if (i == 219 ) {wprintf(L" swapped: i (%i) to 223 \n",dw,i); return 223; }/* Sharp-S+ ? */ //if (i == 220 ) {wprintf(L" swapped: i (%i) to 92 \n",dw,i); return 92; }/* ^ ° */ - //if (i == 221 ) {wprintf(L" swapped: i (%i) to 180 \n",dw,i); return 180; }/* ' ` */ - //if (i == 223 ) {wprintf(L" swapped: i (%i) to 59 \n",dw,i); return ; }/* */ + //if (i == 221 ) {wprintf(L" swapped: i (%i) to 180 \n",dw,i); return 180; }/* ' ` */ + //if (i == 223 ) {wprintf(L" swapped: i (%i) to 59 \n",dw,i); return ; }/* */ //if (i == 226 ) {wprintf(L" swapped: i (%i) to 60 \n",dw,i); return 60; }/* < > */ //if (i == 65105 ) {wprintf(L" swapped: i (%i) to 92 \n",dw,i); return 92; }/* */ - // e.g. rgKey[192] contains character 214 + // e.g. rgKey[192] contains character 214 //if (i == 192 ) {wprintf(L" swapped: i (%i) to 214 \n",dw,i); return 214; }/* Ö */ //if (i == 186 ) {wprintf(L" swapped: i (%i) to 220 \n",dw,i); return 220; }/* Ü */ //if (i == 222 ) {wprintf(L" swapped: i (%i) to 196 \n",dw,i); return 196; }/* Ä */ - if (i == 222 ) {wprintf(L" swapped: i (%i) to 196 \n",dw,i); return 196; }/* Ä */ + if (i == 220) {wprintf(L" swapped: i (%i) to 196 \n",dw,i); return 186; }/* Ä */ + if (i == 42) {wprintf(L" swapped: i (%i) to 196 \n",dw,i); return 187; }/* + */ return i; } // _S2 TODO -std::wstring getKeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint VK, v_dw_3D &All_Vector, ShiftState ss, int caps ){ +std::wstring getKeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint keycode, v_dw_3D &All_Vector, ShiftState ss, int caps ){ GdkModifierType consumed; GdkKeymapKey *maps; guint *keyvals; gint count; - guint keycode; GdkKeymapKey* keys; gint n_keys; guint lowerCase; guint upperCase; - int pos_1 =get_position_From_VirtualKey_Other(VK , All_Vector, 0); - keycode = All_Vector[1][pos_1][0]; - // _S2 TODO what to return if it fails? if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return L"1"; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 3b1c7a468c..f34a0d5419 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -122,9 +122,13 @@ int append_other_ToVector(v_dw_3D &All_Vector, GdkKeymap *keymap); // find Keyvals to fill into 2D-Vector of Other Language KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos); -// mapping between Linux keycodes and keyman SC +// _S2 TODO How to do mapping between Linux keycodes and keyman SC const int Lin_KM__map(int i, v_dw_3D &All_Vector); +KMX_DWORD map_To_VK(KMX_DWORD SC); +KMX_DWORD mapChar_To_VK(KMX_DWORD chr ); +KMX_DWORD mapVK_To_char(KMX_DWORD SC ); std::wstring getKeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint VK, v_dw_3D &All_Vector, ShiftState ss, int caps ); std::wstring PrintKeymapForCodeReturnKeySym2(GdkKeymap *keymap, guint VK, v_dw_3D &All_Vector, ShiftState ss, int caps ); + # endif /*KEYMAP_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index a30d73fecb..8bd236161d 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -144,11 +144,7 @@ public: // distinguish between left- and right-hand keys. // If there is no translation, the function returns 0. // SC -> VK - //_S2 QUESTION I tried to use gdk_translate-function in get_VirtualKey_Other_From_SC_GDK_dw which was not possible so I use a setter afterwards - //_S2 QUESTION Wy did it give me an error? - this->m_vk = get_VirtualKey_Other_From_SC(scanCode, All_Vector); - // this->m_vk = get_VirtualKey_Other_From_SC_NEW(scanCode, All_Vector, keymap, scanCode,scanCode); - //this->m_vk = get_VirtualKey_Other_From_SC_GDK_dw( All_Vector, keymap, scanCode,scanCode); // use gdk to get vk`s + this->m_vk = get_VirtualKey_Other_From_SC(scanCode, All_Vector); this->m_hkl = hkl; this->m_sc = scanCode; @@ -161,19 +157,22 @@ public: // distinguish between left- and right-hand keys. // If there is no translation, the function returns 0. // SC -> VK + //_S2 QUESTION I tried to use gdk_translate-function in get_VirtualKey_Other_From_SC_GDK_dw which was not possible so I use a setter afterwards + //_S2 QUESTION Wy did it give me an error? + // this->m_vk = get_VirtualKey_Other_From_SC_NEW(scanCode, All_Vector, keymap, scanCode,scanCode); + //this->m_vk = get_VirtualKey_Other_From_SC_GDK_dw( All_Vector, keymap, scanCode,scanCode); // use gdk to get vk`s this->m_vk = get_VirtualKey_Other_From_SC(scanCode, All_Vector); - - //this->m_vk = get_VirtualKey_Other_From_SC_NEW(scanCode, All_Vector, keymap, scanCode,scanCode); this->m_hkl = hkl; this->m_sc = scanCode ; } -void set_SC(UINT value){ - this->m_sc = value; -} -void set_VK(UINT value){ - this->m_vk = value; -} + void set_SC(UINT value){ + this->m_sc = value; + } + + void set_VK(UINT value){ + this->m_vk = value; + } UINT VK() { return this->m_vk; @@ -705,9 +704,11 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector, keymap); std::wstring str= getKeySyms_according_to_Shiftstate( *keymap, (guint) sc , All_Vector, Shft, 0 ); +int sedfzhjkl=99; // use str to fill key->vk if ( !str.empty() ); - key->set_VK( (UINT)(*str.c_str())) ; + //key->set_VK( (UINT)(*str.c_str())) ; + key->set_VK( (UINT)(mapVK_To_char(sc))) ; /*wprintf(L" sc= %i --- VK = %i (%c)\n",sc,key_vk,key_vk);*/ if((key->VK() != 0) && (key->VK() <256)) { @@ -785,6 +786,7 @@ UINT VK_vec = (UINT) All_Vector[1][Keypos][0]; std::wstring VK_Other = PrintKeymapForCodeReturnKeySym2( *keymap, VK_vec, All_Vector, ss, caps ); + //std::wstring VK_Other1= PrintKeymapForCodeReturnKeySym( *keymap, pp, All_Vector, ss, caps); @@ -810,6 +812,7 @@ UINT VK_vec = (UINT) All_Vector[1][Keypos][0]; //_S2 TODO fill m_rgfDeadkey ( m_rgfDeadkey will be done later) //rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps==0)); + //rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps)); rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps)); From e9cc54617bdba142dae0d1bbf4c91b9f60ab810f Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 9 Nov 2023 12:55:19 +0100 Subject: [PATCH 118/327] feat(linux): mcompile OEM keys --- linux/mcompile/keymap/keymap.cpp | 3 - linux/mcompile/keymap/mc_import_rules.cpp | 96 ++++++++++++----------- linux/mcompile/keymap/mcompile.cpp | 9 +-- 3 files changed, 53 insertions(+), 55 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index ba6f549503..aaea9f5122 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -619,7 +619,6 @@ std::wstring PrintKeymapForCodeReturnKeySym2(GdkKeymap *keymap, guint VK, v_dw_ GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); return std::wstring(1, (int) *keyvals); - } //Shift @@ -628,7 +627,6 @@ std::wstring PrintKeymapForCodeReturnKeySym2(GdkKeymap *keymap, guint VK, v_dw_ gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); std::wstring rV1= std::wstring(1, (int) *keyvals); return std::wstring(1, (int) *keyvals); - } //caps @@ -636,7 +634,6 @@ std::wstring PrintKeymapForCodeReturnKeySym2(GdkKeymap *keymap, guint VK, v_dw_ GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); return std::wstring(1, (int) *keyvals); - } /*//ALT-GR diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 8bd236161d..2e434fa5be 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -144,7 +144,9 @@ public: // distinguish between left- and right-hand keys. // If there is no translation, the function returns 0. // SC -> VK - this->m_vk = get_VirtualKey_Other_From_SC(scanCode, All_Vector); + //_S2 QUESTION I tried to use gdk_translate-function in get_VirtualKey_Other_From_SC_GDK_dw which was not possible so I use a setter afterwards + //_S2 QUESTION Wy did it give me an error? + this->m_vk = get_VirtualKey_Other_From_SC(scanCode, All_Vector); this->m_hkl = hkl; this->m_sc = scanCode; @@ -157,22 +159,21 @@ public: // distinguish between left- and right-hand keys. // If there is no translation, the function returns 0. // SC -> VK - //_S2 QUESTION I tried to use gdk_translate-function in get_VirtualKey_Other_From_SC_GDK_dw which was not possible so I use a setter afterwards - //_S2 QUESTION Wy did it give me an error? - // this->m_vk = get_VirtualKey_Other_From_SC_NEW(scanCode, All_Vector, keymap, scanCode,scanCode); - //this->m_vk = get_VirtualKey_Other_From_SC_GDK_dw( All_Vector, keymap, scanCode,scanCode); // use gdk to get vk`s this->m_vk = get_VirtualKey_Other_From_SC(scanCode, All_Vector); + // this->m_vk = get_VirtualKey_Other_From_SC_NEW(scanCode, All_Vector, keymap, scanCode,scanCode); + //this->m_vk = get_VirtualKey_Other_From_SC_GDK_dw( All_Vector, keymap, scanCode,scanCode); // use gdk to get vk`s + + //this->m_vk = get_VirtualKey_Other_From_SC_NEW(scanCode, All_Vector, keymap, scanCode,scanCode); this->m_hkl = hkl; this->m_sc = scanCode ; } - void set_SC(UINT value){ - this->m_sc = value; - } - - void set_VK(UINT value){ - this->m_vk = value; - } +void set_SC(UINT value){ + this->m_sc = value; +} +void set_VK(UINT value){ + this->m_vk = value; +} UINT VK() { return this->m_vk; @@ -263,6 +264,20 @@ public: int nkeys = 0; // Get the CAPSLOCK value + +bool b1= this->KMX_IsCapsEqualToShift(); +bool b2= this->KMX_IsSGCAPS(); +bool b3= this->KMX_IsAltGrCapsEqualToAltGrShift(); +bool b4= this->KMX_IsXxxxGrCapsEqualToXxxxShift() ; + +int i1 = this->KMX_IsCapsEqualToShift() ? 1 : 0; +int i2 = this->KMX_IsSGCAPS() ? 2 : 0; +int i3 = this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0; +int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; + + + + int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | (this->KMX_IsSGCAPS() ? 2 : 0) | @@ -676,39 +691,16 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd // flag that the VK is valid, and it can store the SC value. // _S2 this does not find exactly the same keys as the windows version does(windows finds more) // but the ones we need for mcompile are there - //for(UINT sc = 0x01; sc <= 0x7f; sc++) { - -//should be 54 (= unshifted) -//KMX_VirtualKey *key1 = new KMX_VirtualKey(15, hkl, All_Vector, keymap); -//should be 65 (=shifted) -//KMX_VirtualKey *key2 = new KMX_VirtualKey(38, hkl, All_Vector, keymap); - -//------------------------------------ - -/*//for(UINT sc = 0x01; sc <= 0x7f; sc++) { - for(UINT sc = 0x0; sc <= 0x7f; sc++) { - KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector); // _S2 get this from my Vector - uint key_vk = key->VK() ; -+ wprintf(L" sc= %i --- VK = %i (%c)\n",sc,key_vk,key_vk); - if(key->VK() != 0) { - rgKey[key->VK()] = key; - } else {*/ - - - -//--------------------------- - for(UINT sc = 0x01; sc <= 0x7f; sc++) { KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector, keymap); std::wstring str= getKeySyms_according_to_Shiftstate( *keymap, (guint) sc , All_Vector, Shft, 0 ); -int sedfzhjkl=99; - // use str to fill key->vk + // _S2 QUESTION How to use keymap to fill key->vk correctly + // use str to edit key->vk if ( !str.empty() ); - //key->set_VK( (UINT)(*str.c_str())) ; - key->set_VK( (UINT)(mapVK_To_char(sc))) ; + key->set_VK( (UINT)(*str.c_str())) ; /*wprintf(L" sc= %i --- VK = %i (%c)\n",sc,key_vk,key_vk);*/ if((key->VK() != 0) && (key->VK() <256)) { @@ -759,7 +751,21 @@ int sedfzhjkl=99; } } - // _S2 This part is not finished completely. It still needs some work.. + // _S2 QUIESTION !!! + // Different characters on Windows and Lunux for shift/Caps-states: + // Windows Linux + // none/caps/shift/caps+Shift <=> none/caps/shift/caps+Shift + // a A A a <=> a A A a + // ö Ö Ö ö <=> ö Ö Ö ö + // 1 ! ! 1 <=> 1 1 ! ! ( on US keyboard) + // & 1 1 & <=> & 1 1 & ( on FR keyboard) + // ù % % ù <=> ù Ù % % (!!!) + // ' # # ' <=> # # ' ' + // - - _ _ <=> - - _ _ + // + // in which order would we place them in rgKey[] ?? + // this affects counting of keys in functions KMX_GetKeyCount/KMX_IsCapsEqualToShift + // _S2 in this part we skip shiftstates 4, 5, 8, 9 for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { @@ -783,18 +789,14 @@ UINT VK_vec = (UINT) All_Vector[1][Keypos][0]; //_S2 TODO get char - do I need rc ?? ( was rc = ToUnicodeEx...) std::wstring VK_Other_OLD = get_VirtualKey_Other_from_iKey(mapped_ikey, ss, caps, All_Vector); // std::wstring VK_Other1= getKeySyms_according_to_Shiftstate( *keymap, VK_vec, All_Vector, ss, caps); - std::wstring VK_Other = PrintKeymapForCodeReturnKeySym2( *keymap, VK_vec, All_Vector, ss, caps ); - - - - //std::wstring VK_Other1= PrintKeymapForCodeReturnKeySym( *keymap, pp, All_Vector, ss, caps); - + std::wstring VK_Other = PrintKeymapForCodeReturnKeySym2( *keymap, VK_vec, All_Vector, ss, caps ); + /* _S2 can go later if ( VK_Other_OLD != VK_Other) { if(VK_Other!=L"" ) wprintf(L"\nVK`s are different :-( %s <--> %s ",VK_Other.c_str() ,VK_Other_OLD.c_str()); - } + }*/ //_S2 TODO do I need that ?? //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { @@ -812,7 +814,6 @@ UINT VK_vec = (UINT) All_Vector[1][Keypos][0]; //_S2 TODO fill m_rgfDeadkey ( m_rgfDeadkey will be done later) //rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps==0)); - //rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps)); rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps)); @@ -875,6 +876,7 @@ UINT VK_vec = (UINT) All_Vector[1][Keypos][0]; for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { nKeys+= rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); + wprintf(L" iKey = %i, Delta: %i \n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState())); } } diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 790b2bca91..478bd02ab1 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -335,17 +335,16 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon KMX_WCHAR ch = KMX_CharFromVK(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey); - //_S2 marker in wprintf if difference is not 32= (unshifted-shifted ) - can go later + /*//_S2 marker in wprintf if difference is not 32= (unshifted-shifted ) - can go later if (!( ((int) KMX_VKMap[i] == ch ) || ((int) KMX_VKMap[i] == (int) ch -32) ) ) ERROR = L" !!!"; else - ERROR = L" "; - + ERROR = L" ";*/ //wprintf(L" DoConvert-read i: %i \t(KMX_VKMap): %i (%c) \t---> vkUnderlying: %i (%c) \tshiftstate[%i]: ( %i ) \t---- > ch: %i (%c) \t%ls \t%ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, j, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); - /* _S2 ToDo - if(bDeadkeyConversion) { // I4552 + // _S2 ToDo + /*if(bDeadkeyConversion) { // I4552 if(ch == 0xFFFF) { ch = DeadKey; } From 3796ee35e0d30a1483eb215d833d31341b3c05c4 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 9 Nov 2023 16:58:08 +0100 Subject: [PATCH 119/327] feat(linux): mcompile new get_position_From_GDK --- linux/mcompile/keymap/helpers.cpp | 3 ++- linux/mcompile/keymap/helpers.h | 7 ++--- linux/mcompile/keymap/keymap.cpp | 16 ++++++++++++ linux/mcompile/keymap/keymap.h | 2 ++ linux/mcompile/keymap/mc_import_rules.cpp | 31 ++++++++++++++++------- linux/mcompile/keymap/mc_kmxfile.cpp | 1 - 6 files changed, 46 insertions(+), 14 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 26da6a78cf..69c0a92317 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -1,8 +1,9 @@ #include "helpers.h" +// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //_S2 do not review - all this will be deleted later - +// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! int append_other_ToVector(v_dw_3D &All_Vector) { InsertKeyvalsFromVectorFile(All_Vector); diff --git a/linux/mcompile/keymap/helpers.h b/linux/mcompile/keymap/helpers.h index 69b3f228b1..aefa2c3e3b 100755 --- a/linux/mcompile/keymap/helpers.h +++ b/linux/mcompile/keymap/helpers.h @@ -1,3 +1,7 @@ +// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +//_S2 do not review - all this will be deleted later +// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + #pragma once #ifndef HELPERS_H #define HELPERS_H @@ -7,9 +11,6 @@ #include "mc_kmxfile.h" #include "keymap.h" - -//_S2 do not review - all this will be deleted later - // why again here? typedef std::vector v_str_1D; typedef std::vector v_dw_1D; diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index aaea9f5122..03dc4e3dca 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -476,6 +476,22 @@ KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_V } +// returns Keyval which hold the Keysym (in unshifted, shifted) +KMX_DWORD get_position_From_GDK(GdkKeymap *keymap, UINT KeySym ) { + GdkKeymapKey *maps; + guint *keyvals; + gint count; + + for (int k=0; k<255 ; k++ ){ + if (gdk_keymap_get_entries_for_keycode (keymap, k, &maps, &keyvals, &count)) { + if ( (keyvals[0] == KeySym) || (keyvals[1] == KeySym) ) { + return (KMX_DWORD) maps[0].keycode; + } + } + } + return 0; //_S2 TODO what do I return if not found?? +} + // _S2 TODO How to do mapping between Linux keycodes and keyman SC const int Lin_KM__map(int i, v_dw_3D &All_Vector) { // MAP: diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index f34a0d5419..0a3ca2abcf 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -109,6 +109,8 @@ KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector); KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_US , v_dw_3D &All_Vector); // return the Scancode of for given VirtualKey of Other in specific column. If column > available columns look in all columns; KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector, int which_columns); +// return the Scancode of for given VirtualKey using GDK +KMX_DWORD get_position_From_GDK(GdkKeymap *keymap, UINT mapped_ikey); // initialize GDK bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 2e434fa5be..fff1450865 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -332,7 +332,7 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; if (st.size() == 0) { // No character assigned here } - // _S2 deadkeys don work yet + // _S2 deadkeys don't work yet else if (this->m_rgfDeadKey[(int)ss][caps]) { // It's a dead key, append an @ sign. key->dpContext = new KMX_WCHAR[1]; @@ -690,8 +690,6 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd // values in it. Then, store the SC in each valid VK so it can act as both a // flag that the VK is valid, and it can store the SC value. // _S2 this does not find exactly the same keys as the windows version does(windows finds more) - // but the ones we need for mcompile are there - for(UINT sc = 0x01; sc <= 0x7f; sc++) { KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector, keymap); @@ -780,16 +778,29 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd continue; } -// _S2 TODO get Keyval from GDK -int Keypos = get_position_From_VirtualKey_Other(mapped_ikey , All_Vector, 99); -UINT VK_vec = (UINT) All_Vector[1][Keypos][0]; + // _S2 TODO get Keyval from GDK get the keyval(nr of key )for e.g.52 -> 52 is printed out by key 13) + //int Keypos = get_position_From_VirtualKey_Other(mapped_ikey , All_Vector, 99); + //UINT VK_vec = (UINT) All_Vector[1][Keypos][0]; + + // _S2 get_position_From_GDK gives wrong values for 0,65,94,126 which are not processed correctly -> "what do I return if not found..." + KMX_DWORD keypos_GDK= get_position_From_GDK( *keymap, mapped_ikey ); + + //if ( VK_vec != keypos_GDK) + // wprintf(L" DIFFFFERERNT !!!!!!! , %i -- %i\n", VK_vec,keypos_GDK ); + + // _S2 TODO this needs to go !! it's temporary until we decide what to return if not found. At the moment we return 0 in this case which is a problem for gdk + // _S2 to avoid Gdk-CRITICAL **: 16:41:42.662: gdk_keymap_get_entries_for_keyval: assertion 'keyval != 0' failed we set keypos_GDK to a value + if (keypos_GDK ==0) + keypos_GDK = 49; + for(int caps = 0; caps <= 1; caps++) { //_S2 TODO get char - do I need rc ?? ( was rc = ToUnicodeEx...) std::wstring VK_Other_OLD = get_VirtualKey_Other_from_iKey(mapped_ikey, ss, caps, All_Vector); // std::wstring VK_Other1= getKeySyms_according_to_Shiftstate( *keymap, VK_vec, All_Vector, ss, caps); - std::wstring VK_Other = PrintKeymapForCodeReturnKeySym2( *keymap, VK_vec, All_Vector, ss, caps ); + //std::wstring VK_Other = PrintKeymapForCodeReturnKeySym2( *keymap, VK_vec, All_Vector, ss, caps ); + std::wstring VK_Other = PrintKeymapForCodeReturnKeySym2( *keymap, keypos_GDK, All_Vector, ss, caps ); /* _S2 can go later @@ -849,6 +860,7 @@ UINT VK_vec = (UINT) All_Vector[1][Keypos][0]; memcpy(gp, kp->dpGroupArray, sizeof(KMX_GROUP) * kp->cxGroupArray); // + // Find the current highest deadkey index // @@ -876,10 +888,11 @@ UINT VK_vec = (UINT) All_Vector[1][Keypos][0]; for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { nKeys+= rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); - wprintf(L" iKey = %i, Delta: %i \n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState())); + //wprintf(L" iKey = %i, Delta: %i \n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState())); } } + nDeadkey++; // ensure a 1-based index above the max deadkey value already in the keyboard gp->fUsingKeys = TRUE; @@ -897,7 +910,7 @@ int STOP; for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { - wprintf(L"********************************* I use Key Nr %i\n",iKey); + //wprintf(L"********************************* I use Key Nr %i\n",iKey); // for each item, if(rgKey[iKey]->KMX_LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector)) { // I4552 nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 67e4c5f94a..6188cda6c3 100755 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -1,6 +1,5 @@ #include "mc_kmxfile.h" #include "u16.h" -#include "filesystem.h" // _S2 needed? #include KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz); From 4a7901b640cf56ac4285d0e8cf97a2bb5fdb66d2 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 9 Nov 2023 17:06:20 +0100 Subject: [PATCH 120/327] feat(linux): mcompile tidy up --- linux/mcompile/keymap/helpers.cpp | 298 ++++++++++++++++++++++ linux/mcompile/keymap/mc_import_rules.cpp | 4 +- linux/mcompile/keymap/mcompile.cpp | 298 +--------------------- 3 files changed, 301 insertions(+), 299 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 69c0a92317..ac350e047c 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -834,3 +834,301 @@ bool get_US_Keysym_From_OtherKeysym(v_str_3D &All_Vector, int inOther, int &OutU MyCoutW(L" #### get_US_Char_FromOther of keymap ended", 1); return true; }*/ + + +// _S2 maybe I will need that later?? + +/* static xkb_keysym_t get_ascii(struct xkb_state *state, xkb_keycode_t keycode) { + struct xkb_keymap *keymap; + xkb_layout_index_t num_layouts; + xkb_layout_index_t layout; + xkb_level_index_t level; + const xkb_keysym_t *syms; + int num_syms; + + keymap = xkb_state_get_keymap(state); + num_layouts = xkb_keymap_num_layouts_for_key(keymap, keycode); + + for (layout = 0; layout < num_layouts; layout++) { + level = xkb_state_key_get_level(state, keycode, layout); + num_syms = xkb_keymap_key_get_syms_by_level(keymap, keycode, + layout, level, &syms); + if (num_syms != 1) + continue; + + if (syms[0] > 0 && xkb_keysym_to_utf32(syms[0]) < 128) + return syms[0]; + } + + return XKB_KEY_NoSymbol; +} +*/ + + + /*static xkb_keysym_t get_ascii_SAB(xkb_keycode_t keycode) { + + xkb_layout_index_t num_layouts; + xkb_layout_index_t layout; + xkb_level_index_t level; + const xkb_keysym_t *syms; + int num_syms; + + struct xkb_context *ctx; + + ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS); + if (!ctx) + MyCoutW(L" # Error in xkb_context_new", 1); + + + + +// get a keymap from a given name ( is) +struct xkb_keymap *keymap_is; + struct xkb_rule_names names = { + // Example RMLVO for Icelandic Dvorak. + .rules = NULL, + .model = "pc105", + .layout = "is", + .variant = "dvorak", + .options = "terminate:ctrl_alt_bksp" + }; + keymap_is = xkb_keymap_new_from_names(ctx, &names, XKB_KEYMAP_COMPILE_NO_FLAGS); + + if (!keymap_is) + MyCoutW(L" # Error in xkb_keymap_new_from_names", 1); + + // how many layouts are in keymap ( here is: 4) + num_layouts = xkb_keymap_num_layouts_for_key(keymap_is, keycode); + std::wcout << L" num_layouts: " << num_layouts << L"\n"; + + for (layout = 0; layout < num_layouts; layout++) { + + // how many levels do we have per key e.g. [a, A, ä, ascitilde ] + std::wcout << L" layout: Nr" << layout << L"\n"; + xkb_level_index_t level = xkb_keymap_num_levels_for_key ( keymap_is, keycode, layout ) ; + std::wcout << L" we have level nr of : " << level << L"\n"; + +for( int j=0; j< level;j++) +{ + std::wcout << L" j: " << j << L"\n"; + // get the keysym(characzter) in level level ( get a for level 1; A for level 2;) + num_syms = xkb_keymap_key_get_syms_by_level(keymap_is, keycode, layout, j, &syms); + std::wcout << L" num_syms(j): " << num_syms << L"\n"; + + // if no entry for this level + if (num_syms != 1) + continue; + + if (syms[0] > 0 && xkb_keysym_to_utf32(syms[0]) < 128) + return syms[0]; + + } + } + + return XKB_KEY_NoSymbol; +}*/ +// bak all tries for DoConvert here: +/* + +//#include "XKeyboard.h" +#include "/usr/include/libxklavier/xklavier.h" +#include "/usr/include/libxklavier/xkl_config_item.h" +#include "/usr/include/libxklavier/xkl_config_rec.h +#include "/usr/include/libxklavier/xkl_config_registry.h +#include "/usr/include/libxklavier/xkl_engine.h +#include "/usr/include/libxklavier/xkl_engine_marshal.h +#include "/usr/include/libxklavier/xkl-enum-types.h +#include "/usr/include/libxklavier/xklavier.h" +#include "/usr/include/libxklavier/xklavier.h" + + + + +std::wcout << L"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\n"; +std::string st = std::locale("").name() ; +std::wstring wstr = wstring_from_string(st); + +std::wcout << wstr; +std::wcout << L"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\n"; +xklgetg +//const char** ccc = XklGetGroupNames ( ) ; +//xkl_engine_get_groups_names +//const char** cccc = XkbGetNames ( ) ; +/* + Display *dpy = XOpenDisplay(NULL); + + if (dpy == NULL) { + fprintf(stderr, "Cannot open display\n"); + exit(1); + } + + XkbStateRec state; + XkbGetState(dpy, XkbUseCoreKbd, &state); + + XkbDescPtr desc = XkbGetKeyboard(dpy, XkbAllComponentsMask, XkbUseCoreKbd); + char*symbols = XGetAtomName(dpy, desc->names->symbols); + //char *group = XGetAtomName(dpy, desc->names->groups[state.group]); + //printf("Full name: %s\n", group); + +XKeyboard xkb; + +std::string cGrpName=xkb.currentGroupName(); //return somethings like "USA" +std::string cGrpSymb=xkb.currentGroupSymbol(); //return somethings like "us" + +xkb.setGroupByNum(0);//set keyboard layout to first layout in available ones + +//wprintf(L"Full name: %s\n", symbols); + +//std::wcout << L"qqqqqqqqqqqqqqqqqqqq: " << *symbols; + + + + + xkb_keysym_t in; + xkb_keysym_t out; + +std::vector < int > vi ={34,39,43,47,48,61,57}; +for( int i=0; i vi ={34,39,43,47,48,61,57}; +for( int i=0; i 0 && xkb_keysym_to_utf32(syms[0]) < 128) + return syms[0]; + + + } + + + //return XKB_KEY_NoSymbol; + + + MyCoutW(L" # XKB get syn OK", 1); + + // https://cpp.hotexamples.com/examples/-/-/xkb_state_get_keymap/cpp-xkb_state_get_keymap-function-examples.html + + int num; + lv = xkb_state_key_get_level(state, code + KBDXKB_SHIFT, lo); + num = xkb_keymap_key_get_syms_by_level(keymap, code + KBDXKB_SHIFT, lo, lv, &s); + + + +*/ + +/*int get_OtherKeysym_From_US_Keysym(v_str_3D &All_Vector,int inUS){ + int outOther; + MyCoutW(L" #### get_OtherKeysym_From_US_Keysym of keymap started", 1); + wprintf(L" in Us ##################### %i and KeysymsUS : \n", inUS ); + // loop and find char in US; then find char of Other + for( int i=0; i< (int)All_Vector[1].size();i++) { + for( int j=0; j< (int)All_Vector[1][0].size();j++) { + + int KeysymUS = (int) *All_Vector[0][i][j].c_str(); + int KeysymOther = (int) *All_Vector[1][i][j].c_str(); + std::wstring KeysymUS_wstr = wstring_from_string(All_Vector[0][i][j]); + //if ( inUS == 58) +wprintf(L" in Us %i and KeysymsUS %i : \n", inUS ,KeysymUS ); +//wprintf(L" ................................................................................... inxx: %s outxx: %s %s\n", All_Vector[0][25][2].c_str(),All_Vector[1][25][0].c_str(),All_Vector[1][25][2].c_str()); + if( inUS == KeysymUS ) { + //wprintf(L" FOUND Value in US !!!!! : %i out ########: %S \n", inUS,KeysymUS_wstr.c_str()); + //wprintf(L" FOUND Value in US !!!!! : %i out ########: %S \n", inUS,KeysymUS_wstr.c_str()); + // wprintf(L" FOUND Value in OTHER !!!!! : Other in: %i ( %s ) -- Keycode : %s -- US out ########: %i ( %s ) \n", KeysymUS,All_Vector[0][i][j].c_str(), All_Vector[1][i][0].c_str() , KeysymOther,All_Vector[1][i][j].c_str()); + wprintf(L" get_OtherKeysym_From_US_Keysym FOUND Value in US !!!!! : Other in: %i ( %s ) -- Keycode : %s -- US out ########: %i ( %s ) \n", + KeysymUS,All_Vector[0][i][j].c_str(), All_Vector[1][i][0].c_str() , KeysymOther,All_Vector[1][i][j].c_str()); + + + //wprintf(L" FOUND 2 Value in OTHER !!!!! : Other in: %i ( %s ) -- Keycode : %s -- US out ########: %i ( %s ) \n", KeysymOther,All_Vector[1][i][j].c_str(), All_Vector[1][i][0].c_str() , KeysymUS,All_Vector[0][i][j].c_str()); + + outOther = KeysymOther; + + MyCoutW(L" #### get_OtherKeysym_From_US_Keysym of keymap ended", 1); + + return outOther; + } + } + } + MyCoutW(L" #### get_US_Char_FromOther of keymap ended", 1); + return true; +} +*/ diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index fff1450865..04b52340d5 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -788,8 +788,8 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd //if ( VK_vec != keypos_GDK) // wprintf(L" DIFFFFERERNT !!!!!!! , %i -- %i\n", VK_vec,keypos_GDK ); - // _S2 TODO this needs to go !! it's temporary until we decide what to return if not found. At the moment we return 0 in this case which is a problem for gdk - // _S2 to avoid Gdk-CRITICAL **: 16:41:42.662: gdk_keymap_get_entries_for_keyval: assertion 'keyval != 0' failed we set keypos_GDK to a value + // _S2 TODO this needs to go !! it's TEMPORARY until we decide what to return if not found. At the moment we return 0 in this case which is a problem for gdk + // _S2 to avoid Gdk-CRITICAL **: 16:41:42.662: gdk_keymap_get_entries_for_keyval: assertion 'keyval != 0' failed: we set keypos_GDK to a value if (keypos_GDK ==0) keypos_GDK = 49; diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 478bd02ab1..12851fa6e5 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -370,6 +370,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon return TRUE; } +// _S2 TODO void KMX_LogError(const KMX_WCHART* m1,int m2) { wprintf((PWSTR)m1, m2); } @@ -1111,300 +1112,3 @@ void LogError(PWSTR fmt, ...) { _putws(fmtbuf); } */ - -// _S2 maybe I will need that later?? - -/* static xkb_keysym_t get_ascii(struct xkb_state *state, xkb_keycode_t keycode) { - struct xkb_keymap *keymap; - xkb_layout_index_t num_layouts; - xkb_layout_index_t layout; - xkb_level_index_t level; - const xkb_keysym_t *syms; - int num_syms; - - keymap = xkb_state_get_keymap(state); - num_layouts = xkb_keymap_num_layouts_for_key(keymap, keycode); - - for (layout = 0; layout < num_layouts; layout++) { - level = xkb_state_key_get_level(state, keycode, layout); - num_syms = xkb_keymap_key_get_syms_by_level(keymap, keycode, - layout, level, &syms); - if (num_syms != 1) - continue; - - if (syms[0] > 0 && xkb_keysym_to_utf32(syms[0]) < 128) - return syms[0]; - } - - return XKB_KEY_NoSymbol; -} -*/ - - - /*static xkb_keysym_t get_ascii_SAB(xkb_keycode_t keycode) { - - xkb_layout_index_t num_layouts; - xkb_layout_index_t layout; - xkb_level_index_t level; - const xkb_keysym_t *syms; - int num_syms; - - struct xkb_context *ctx; - - ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS); - if (!ctx) - MyCoutW(L" # Error in xkb_context_new", 1); - - - - -// get a keymap from a given name ( is) -struct xkb_keymap *keymap_is; - struct xkb_rule_names names = { - // Example RMLVO for Icelandic Dvorak. - .rules = NULL, - .model = "pc105", - .layout = "is", - .variant = "dvorak", - .options = "terminate:ctrl_alt_bksp" - }; - keymap_is = xkb_keymap_new_from_names(ctx, &names, XKB_KEYMAP_COMPILE_NO_FLAGS); - - if (!keymap_is) - MyCoutW(L" # Error in xkb_keymap_new_from_names", 1); - - // how many layouts are in keymap ( here is: 4) - num_layouts = xkb_keymap_num_layouts_for_key(keymap_is, keycode); - std::wcout << L" num_layouts: " << num_layouts << L"\n"; - - for (layout = 0; layout < num_layouts; layout++) { - - // how many levels do we have per key e.g. [a, A, ä, ascitilde ] - std::wcout << L" layout: Nr" << layout << L"\n"; - xkb_level_index_t level = xkb_keymap_num_levels_for_key ( keymap_is, keycode, layout ) ; - std::wcout << L" we have level nr of : " << level << L"\n"; - -for( int j=0; j< level;j++) -{ - std::wcout << L" j: " << j << L"\n"; - // get the keysym(characzter) in level level ( get a for level 1; A for level 2;) - num_syms = xkb_keymap_key_get_syms_by_level(keymap_is, keycode, layout, j, &syms); - std::wcout << L" num_syms(j): " << num_syms << L"\n"; - - // if no entry for this level - if (num_syms != 1) - continue; - - if (syms[0] > 0 && xkb_keysym_to_utf32(syms[0]) < 128) - return syms[0]; - - } - } - - return XKB_KEY_NoSymbol; -}*/ -// bak all tries for DoConvert here: -/* - -//#include "XKeyboard.h" -#include "/usr/include/libxklavier/xklavier.h" -#include "/usr/include/libxklavier/xkl_config_item.h" -#include "/usr/include/libxklavier/xkl_config_rec.h -#include "/usr/include/libxklavier/xkl_config_registry.h -#include "/usr/include/libxklavier/xkl_engine.h -#include "/usr/include/libxklavier/xkl_engine_marshal.h -#include "/usr/include/libxklavier/xkl-enum-types.h -#include "/usr/include/libxklavier/xklavier.h" -#include "/usr/include/libxklavier/xklavier.h" - - - - -std::wcout << L"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\n"; -std::string st = std::locale("").name() ; -std::wstring wstr = wstring_from_string(st); - -std::wcout << wstr; -std::wcout << L"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\n"; -xklgetg -//const char** ccc = XklGetGroupNames ( ) ; -//xkl_engine_get_groups_names -//const char** cccc = XkbGetNames ( ) ; -/* - Display *dpy = XOpenDisplay(NULL); - - if (dpy == NULL) { - fprintf(stderr, "Cannot open display\n"); - exit(1); - } - - XkbStateRec state; - XkbGetState(dpy, XkbUseCoreKbd, &state); - - XkbDescPtr desc = XkbGetKeyboard(dpy, XkbAllComponentsMask, XkbUseCoreKbd); - char*symbols = XGetAtomName(dpy, desc->names->symbols); - //char *group = XGetAtomName(dpy, desc->names->groups[state.group]); - //printf("Full name: %s\n", group); - -XKeyboard xkb; - -std::string cGrpName=xkb.currentGroupName(); //return somethings like "USA" -std::string cGrpSymb=xkb.currentGroupSymbol(); //return somethings like "us" - -xkb.setGroupByNum(0);//set keyboard layout to first layout in available ones - -//wprintf(L"Full name: %s\n", symbols); - -//std::wcout << L"qqqqqqqqqqqqqqqqqqqq: " << *symbols; - - - - - xkb_keysym_t in; - xkb_keysym_t out; - -std::vector < int > vi ={34,39,43,47,48,61,57}; -for( int i=0; i vi ={34,39,43,47,48,61,57}; -for( int i=0; i 0 && xkb_keysym_to_utf32(syms[0]) < 128) - return syms[0]; - - - } - - - //return XKB_KEY_NoSymbol; - - - MyCoutW(L" # XKB get syn OK", 1); - - // https://cpp.hotexamples.com/examples/-/-/xkb_state_get_keymap/cpp-xkb_state_get_keymap-function-examples.html - - int num; - lv = xkb_state_key_get_level(state, code + KBDXKB_SHIFT, lo); - num = xkb_keymap_key_get_syms_by_level(keymap, code + KBDXKB_SHIFT, lo, lv, &s); - - - -*/ - -/*int get_OtherKeysym_From_US_Keysym(v_str_3D &All_Vector,int inUS){ - int outOther; - MyCoutW(L" #### get_OtherKeysym_From_US_Keysym of keymap started", 1); - wprintf(L" in Us ##################### %i and KeysymsUS : \n", inUS ); - // loop and find char in US; then find char of Other - for( int i=0; i< (int)All_Vector[1].size();i++) { - for( int j=0; j< (int)All_Vector[1][0].size();j++) { - - int KeysymUS = (int) *All_Vector[0][i][j].c_str(); - int KeysymOther = (int) *All_Vector[1][i][j].c_str(); - std::wstring KeysymUS_wstr = wstring_from_string(All_Vector[0][i][j]); - //if ( inUS == 58) -wprintf(L" in Us %i and KeysymsUS %i : \n", inUS ,KeysymUS ); -//wprintf(L" ................................................................................... inxx: %s outxx: %s %s\n", All_Vector[0][25][2].c_str(),All_Vector[1][25][0].c_str(),All_Vector[1][25][2].c_str()); - if( inUS == KeysymUS ) { - //wprintf(L" FOUND Value in US !!!!! : %i out ########: %S \n", inUS,KeysymUS_wstr.c_str()); - //wprintf(L" FOUND Value in US !!!!! : %i out ########: %S \n", inUS,KeysymUS_wstr.c_str()); - // wprintf(L" FOUND Value in OTHER !!!!! : Other in: %i ( %s ) -- Keycode : %s -- US out ########: %i ( %s ) \n", KeysymUS,All_Vector[0][i][j].c_str(), All_Vector[1][i][0].c_str() , KeysymOther,All_Vector[1][i][j].c_str()); - wprintf(L" get_OtherKeysym_From_US_Keysym FOUND Value in US !!!!! : Other in: %i ( %s ) -- Keycode : %s -- US out ########: %i ( %s ) \n", - KeysymUS,All_Vector[0][i][j].c_str(), All_Vector[1][i][0].c_str() , KeysymOther,All_Vector[1][i][j].c_str()); - - - //wprintf(L" FOUND 2 Value in OTHER !!!!! : Other in: %i ( %s ) -- Keycode : %s -- US out ########: %i ( %s ) \n", KeysymOther,All_Vector[1][i][j].c_str(), All_Vector[1][i][0].c_str() , KeysymUS,All_Vector[0][i][j].c_str()); - - outOther = KeysymOther; - - MyCoutW(L" #### get_OtherKeysym_From_US_Keysym of keymap ended", 1); - - return outOther; - } - } - } - MyCoutW(L" #### get_US_Char_FromOther of keymap ended", 1); - return true; -} -*/ From 9e31156edcbe3243b95bb091f0bc500078998b84 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 10 Nov 2023 11:05:03 +0100 Subject: [PATCH 121/327] feat(linux): mcompile tidy up --- linux/mcompile/keymap/helpers.cpp | 25 ++++++++++ linux/mcompile/keymap/keymap.cpp | 61 ++++++++++++++--------- linux/mcompile/keymap/keymap.h | 5 +- linux/mcompile/keymap/mc_import_rules.cpp | 30 +++++------ linux/mcompile/keymap/mcompile.cpp | 8 +-- 5 files changed, 87 insertions(+), 42 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index ac350e047c..aafbc42548 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -304,7 +304,32 @@ bool write_RGKEY_FileToVector(v_dw_2D& shift_states, const char* infile) { fclose(fp); return(0); } +KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector) { + for( int i=0; i< (int)All_Vector[0].size();i++) { + //number keys return unshifted value ( e.g. 1, not !) + if(SC <= 19) { + if ( All_Vector[0][i][0] == SC) + return All_Vector[1][i][1]; + } + + // other keys + if((SC > 19) ) { + if ( All_Vector[0][i][0] == SC) { + + // normal capital characters return the value of capital char ( e.g. A) + if ((All_Vector[1][i][2] >= 65 ) && (All_Vector[1][i][2] < 91 )) + return All_Vector[1][i][2]; + + // special characters return Keyman defined values (e.g. VK_ACCENT) + else + //return All_Vector[1][i][1]; + return mapVK_To_char(SC); + } + } + } +return 0; +} bool test_In_Out(v_dw_3D All_Vector){ for ( int i=0; i<61;i++) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 03dc4e3dca..57d7c790af 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -329,7 +329,7 @@ KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state // _S2 if out of range of what ( ascii??) return 0 or other value ? if (out > 255) { wprintf(L"out of range: found value out( %i) for keycode = %i /shift_state_pos %i (49= TLDE 21= VK_EQUALS on US keyboard) \n", out,keycode,shift_state_pos); - out = 0; + //out = 0; } g_free(keyvals); @@ -385,11 +385,11 @@ KMX_DWORD mapChar_To_VK(KMX_DWORD chr ){ return chr; } -// _S2 TODO Do I need to use All_Vector ?? -KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ +// _S2 This can go later +/*KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector) { for( int i=0; i< (int)All_Vector[0].size();i++) { - //number keys return unshifted value ( e.g. 1 not !) + //number keys return unshifted value ( e.g. 1, not !) if(SC <= 19) { if ( All_Vector[0][i][0] == SC) return All_Vector[1][i][1]; @@ -412,8 +412,41 @@ KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ } return 0; } +*/ +KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { + GdkModifierType consumed; + GdkKeymapKey *maps; + guint *keyvals; + guint lowerCase; + guint upperCase; + gint count; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return 0; + + //Shift + //GdkModifierType MOD_Shift = (GdkModifierType) ( ~consumed & GDK_SHIFT_MASK ); + GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + + for (int i = 0; i < count; i++) { + if (maps[i].level > 1 || maps[i].group > 1) + continue; + + gchar * kv_name = gdk_keyval_name (keyvals[i]); + + if ( keyvals[i]>0) + gdk_keyval_convert_case (*kv_name, &lowerCase, &upperCase); + + // _S2 is ( lowerCase == upperCase ) true for all number keys for all keyboards? + if ( lowerCase == upperCase ) + return (KMX_DWORD) upperCase; + } + return (KMX_DWORD) *keyvals; +return 0; +} // _S2 not needed?, can go later? // return RETURN NON SHIFTED CHAR [1] the VirtualKey of the US Keyboard for given Scancode @@ -560,24 +593,7 @@ std::wstring getKeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint keycod //Shift else if (( ss == Shft ) && ( caps == 0 )) { - GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); - std::wstring rV1= std::wstring(1, (int) *keyvals); - - for (int i = 0; i < count; i++) { - if (maps[i].level > 1 || maps[i].group > 1) - continue; - - gchar * gch = gdk_keyval_name (keyvals[i]); - - if ( keyvals[i]>0) - gdk_keyval_convert_case (*gch, &lowerCase, &upperCase); - - // _S2 is ( lowerCase == upperCase ) true for all number keys for all keyboards? - if ( lowerCase == upperCase ) - return std::wstring(1, (int) upperCase); - } - return rV1; + return std::wstring(1, (int) get_VirtualKey_Other_GDK(keymap, keycode)); } //caps @@ -609,7 +625,6 @@ std::wstring PrintKeymapForCodeReturnKeySym2(GdkKeymap *keymap, guint VK, v_dw_ gint *n_entries; gint count; guint keycode; - GdkKeymapKey* keys; gint n_keys; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 0a3ca2abcf..a91e547b37 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -98,7 +98,7 @@ v_dw_2D create_empty_2D(int dim_rows, int dim_shifts); // query All_Vector // return the VirtualKey of the Other Keyboard for given Scancode -KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); +//KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); // return the VirtualKey of the US Keyboard for given Scancode KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); // return the Scancode of for given VirtualKey of Other Keyboard @@ -112,6 +112,9 @@ KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_V // return the Scancode of for given VirtualKey using GDK KMX_DWORD get_position_From_GDK(GdkKeymap *keymap, UINT mapped_ikey); +// return the VirtualKey of the Other Keyboard for given Scancode using GDK +KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD scanCode); + // initialize GDK bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 04b52340d5..01f7fe769d 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -109,18 +109,18 @@ private: public: // _S2 can be deleted later - KMX_VirtualKey(KMX_HKL hkl, UINT KMX_virtualKey) {/* + /* KMX_VirtualKey(KMX_HKL hkl, UINT KMX_virtualKey) { this->m_sc = MapVirtualKeyEx(virtualKey, 0, hkl); this->m_hkl = hkl; this->m_vk = KMX_virtualKey; - memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey));*/ - } + memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); + }*/ // _S2 can be deleted later - KMX_VirtualKey(UINT scanCode, KMX_HKL hkl) { + /*KMX_VirtualKey(UINT scanCode, KMX_HKL hkl) { // this->m_vk = MapVirtualKeyEx(scanCode, 1, hkl); this->m_hkl = hkl; this->m_sc = scanCode; - } + }*/ KMX_VirtualKey(KMX_HKL hkl, UINT KMX_virtualKey, v_dw_3D All_Vector) {/* @@ -137,20 +137,17 @@ public: memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); } - KMX_VirtualKey(UINT scanCode, KMX_HKL hkl, v_dw_3D All_Vector) { + /*KMX_VirtualKey(UINT scanCode, KMX_HKL hkl, v_dw_3D All_Vector) { // _S2 this->m_vk = MapVirtualKeyEx(scanCode, 1, hkl); // second para= 1: MAPVK_VSC_TO_VK =1 // The first parameter is a scan code and is // translated into a virtual-key code that does not // distinguish between left- and right-hand keys. // If there is no translation, the function returns 0. // SC -> VK - //_S2 QUESTION I tried to use gdk_translate-function in get_VirtualKey_Other_From_SC_GDK_dw which was not possible so I use a setter afterwards - //_S2 QUESTION Wy did it give me an error? this->m_vk = get_VirtualKey_Other_From_SC(scanCode, All_Vector); - this->m_hkl = hkl; this->m_sc = scanCode; - } + }*/ KMX_VirtualKey(UINT scanCode, KMX_HKL hkl, v_dw_3D All_Vector, GdkKeymap **keymap) { // _S2 this->m_vk = MapVirtualKeyEx(scanCode, 1, hkl); // second para= 1: MAPVK_VSC_TO_VK =1 @@ -159,11 +156,15 @@ public: // distinguish between left- and right-hand keys. // If there is no translation, the function returns 0. // SC -> VK - this->m_vk = get_VirtualKey_Other_From_SC(scanCode, All_Vector); - // this->m_vk = get_VirtualKey_Other_From_SC_NEW(scanCode, All_Vector, keymap, scanCode,scanCode); - //this->m_vk = get_VirtualKey_Other_From_SC_GDK_dw( All_Vector, keymap, scanCode,scanCode); // use gdk to get vk`s + //KMX_DWORD old = get_VirtualKey_Other_From_SC(scanCode, All_Vector); + this->m_vk = get_VirtualKey_Other_GDK(*keymap, scanCode); - //this->m_vk = get_VirtualKey_Other_From_SC_NEW(scanCode, All_Vector, keymap, scanCode,scanCode); +/* _S2 can go later + if( this->m_vk != old) + wprintf(L" not the same !!!!!!!!!!!!!!!!!!!!!!!!! scanCode%i: %i(%c) -- %i(%c)\n",scanCode, this->m_vk, this->m_vk, old,old); + else + wprintf(L" all good ................... scanCode%i: %i(%c) -- %i(%c)\n",scanCode, this->m_vk, this->m_vk, old,old); + */ this->m_hkl = hkl; this->m_sc = scanCode ; } @@ -842,6 +843,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd //_S2 this gan co later //std::vector< int > TestValues = {48,49,50,52,53,54,55,56,57,54,65,89,189,188}; + //std::vector< int > TestValues = {48,49,50,51,52,53,54,55,56,57,65,66,67,88,89,90, 176,177,196,214,220}; std::vector< int > TestValues = {48,49,50,51,52,53,54,55,56,57,65,66,67,88,89,90}; // std::vector< int > TestValues = {65}; wprintf(L"-----------------\nNow some tests:\n"); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 12851fa6e5..2bc79446f2 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -387,7 +387,7 @@ void KMX_LogError(const KMX_WCHART* m1,int m2, LPKMX_KEY key) { // correct shift state and key. Adjust the LCTRL+RALT -> RALT if necessary // void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { - + // _S2 ToDos here? // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. @@ -423,7 +423,7 @@ void KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, KMX_UINT shift, KMX_WCHA } void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { -//if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)){ +// _S2 if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)){ for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { if(kbd->dpGroupArray[i].fUsingKeys) { KMX_TranslateGroup(&kbd->dpGroupArray[i], vk, shift, ch); @@ -434,10 +434,10 @@ void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_ void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key) { if(key->ShiftFlags == 0) { //KMX_LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); - //wprintf(L" SAB Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); + //wprintf(L" _S2 Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); } else if(key->ShiftFlags & VIRTUALCHARKEY) { //KMX_LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); - //wprintf(L"SAB Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); + //wprintf(L"_S2 Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); } } From 42702d10eb9e6517b47f6cc2a74e4e2d473c5801 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 10 Nov 2023 14:33:59 +0100 Subject: [PATCH 122/327] feat(linux): mcompile more tidy up --- linux/mcompile/keymap/keymap.cpp | 22 +++------------------- linux/mcompile/keymap/keymap.h | 19 +++++++++---------- linux/mcompile/keymap/mc_import_rules.cpp | 13 +++++-------- 3 files changed, 17 insertions(+), 37 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 57d7c790af..ec8c41255d 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -448,7 +448,7 @@ KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { return 0; } -// _S2 not needed?, can go later? +// _S2 not needed, can go later // return RETURN NON SHIFTED CHAR [1] the VirtualKey of the US Keyboard for given Scancode KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ // find correct row of char in US @@ -506,7 +506,6 @@ KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_V } return 0; //_S2 TODO what do I return if not found?? - } // returns Keyval which hold the Keysym (in unshifted, shifted) @@ -561,14 +560,12 @@ const int Lin_KM__map(int i, v_dw_3D &All_Vector) { } // _S2 TODO -std::wstring getKeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint keycode, v_dw_3D &All_Vector, ShiftState ss, int caps ){ +std::wstring get_KeyVals_according_to_Shiftstate(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ GdkModifierType consumed; GdkKeymapKey *maps; guint *keyvals; gint count; - GdkKeymapKey* keys; - gint n_keys; guint lowerCase; guint upperCase; @@ -615,29 +612,16 @@ std::wstring getKeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint keycod } -std::wstring PrintKeymapForCodeReturnKeySym2(GdkKeymap *keymap, guint VK, v_dw_3D &All_Vector, ShiftState ss, int caps ){ +std::wstring get_KeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ GdkModifierType consumed; GdkKeymapKey *maps; - GdkEventKey* event; guint *keyvals; - guint *keyvals_shift; - gint *n_entries; gint count; - guint keycode; - GdkKeymapKey* keys; - gint n_keys; - - gdk_keymap_get_entries_for_keyval(keymap, VK,&keys,&n_keys); - - int pos_1 =get_position_From_VirtualKey_Other(VK , All_Vector, 0); - //wprintf(L" get_position_From_VirtualKey_Other %i of VK%i (%c) \n", pos_1, VK,VK); - keycode = All_Vector[1][pos_1][0]; if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return L"1"; - //unshifted if (( ss == Base ) && ( caps == 0 )) { GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index a91e547b37..2e5a4dc36b 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -3,9 +3,6 @@ #ifndef KEYMAP_H #define KEYMAP_H -// _S2 can go later; is for use of mcompile with GDK or with VectorFile -#define USE_GDK 1 - #include #include #include @@ -99,15 +96,15 @@ v_dw_2D create_empty_2D(int dim_rows, int dim_shifts); // query All_Vector // return the VirtualKey of the Other Keyboard for given Scancode //KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); -// return the VirtualKey of the US Keyboard for given Scancode +// _S2 can go later return the VirtualKey of the US Keyboard for given Scancode KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); // return the Scancode of for given VirtualKey of Other Keyboard KMX_DWORD get_SC_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector); -// return the Scancode of for given VirtualKey of US +// _S2 can go later return the Scancode of for given VirtualKey of US KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector); -// return the Scancode of for given VirtualKey of Other -KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_US , v_dw_3D &All_Vector); -// return the Scancode of for given VirtualKey of Other in specific column. If column > available columns look in all columns; +// _S2 can go later return the Scancode of for given VirtualKey of Other +//KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_US , v_dw_3D &All_Vector); +// _S2 can go later return the Scancode of for given VirtualKey of Other in specific column. If column > available columns look in all columns; KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector, int which_columns); // return the Scancode of for given VirtualKey using GDK KMX_DWORD get_position_From_GDK(GdkKeymap *keymap, UINT mapped_ikey); @@ -133,7 +130,9 @@ KMX_DWORD map_To_VK(KMX_DWORD SC); KMX_DWORD mapChar_To_VK(KMX_DWORD chr ); KMX_DWORD mapVK_To_char(KMX_DWORD SC ); -std::wstring getKeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint VK, v_dw_3D &All_Vector, ShiftState ss, int caps ); -std::wstring PrintKeymapForCodeReturnKeySym2(GdkKeymap *keymap, guint VK, v_dw_3D &All_Vector, ShiftState ss, int caps ); +// returns Keyvals fo ra given key (for unshifted: finds the Name of the Key e.g. A or 1 ) +std::wstring get_KeyVals_according_to_Shiftstate(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); +// returns KeySyms fo ra given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) +std::wstring get_KeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); # endif /*KEYMAP_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 01f7fe769d..5303ac864a 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -617,11 +617,11 @@ bool is_Edges(int pos, v_dw_3D & All_Vector){ } -// _S2 where to put this?? +// _S2 can go later std::wstring get_VirtualKey_Other_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &caps, v_dw_3D &All_Vector) { // _S2 this will find the correct row in All_Vector - //( e.g. get_position_From_VirtualKey_Other(65 ,All_Vector ) returns 25 + //( e.g. get_position_From_VirtualKey_Other(65 ,All_Vector.99 ) returns 25 // All_Vector[25] contains SC(38), unshifted A (97) shifted A (65) ) KMX_DWORD pos = get_position_From_VirtualKey_Other(iKey, All_Vector,99); @@ -694,7 +694,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd for(UINT sc = 0x01; sc <= 0x7f; sc++) { KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector, keymap); - std::wstring str= getKeySyms_according_to_Shiftstate( *keymap, (guint) sc , All_Vector, Shft, 0 ); + std::wstring str= get_KeyVals_according_to_Shiftstate( *keymap, (guint) sc , Shft, 0 ); // _S2 QUESTION How to use keymap to fill key->vk correctly // use str to edit key->vk @@ -779,7 +779,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd continue; } - // _S2 TODO get Keyval from GDK get the keyval(nr of key )for e.g.52 -> 52 is printed out by key 13) + // _S2 can go later //int Keypos = get_position_From_VirtualKey_Other(mapped_ikey , All_Vector, 99); //UINT VK_vec = (UINT) All_Vector[1][Keypos][0]; @@ -799,10 +799,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd //_S2 TODO get char - do I need rc ?? ( was rc = ToUnicodeEx...) std::wstring VK_Other_OLD = get_VirtualKey_Other_from_iKey(mapped_ikey, ss, caps, All_Vector); - // std::wstring VK_Other1= getKeySyms_according_to_Shiftstate( *keymap, VK_vec, All_Vector, ss, caps); - //std::wstring VK_Other = PrintKeymapForCodeReturnKeySym2( *keymap, VK_vec, All_Vector, ss, caps ); - std::wstring VK_Other = PrintKeymapForCodeReturnKeySym2( *keymap, keypos_GDK, All_Vector, ss, caps ); - + std::wstring VK_Other = get_KeySyms_according_to_Shiftstate( *keymap, keypos_GDK, ss, caps); /* _S2 can go later if ( VK_Other_OLD != VK_Other) { From 4a318cba4791a65099240df6481cc88bb7c959f4 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 10 Nov 2023 15:33:30 +0100 Subject: [PATCH 123/327] feat(linux): mcompile constructor KMX_VirtualKey to use with GDK --- linux/mcompile/keymap/keymap.cpp | 6 +-- linux/mcompile/keymap/mc_import_rules.cpp | 61 ++++++----------------- linux/mcompile/keymap/mcompile.cpp | 2 +- 3 files changed, 19 insertions(+), 50 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index ec8c41255d..5b6f7a9841 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -444,8 +444,8 @@ KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { if ( lowerCase == upperCase ) return (KMX_DWORD) upperCase; } - return (KMX_DWORD) *keyvals; -return 0; + return (KMX_DWORD) *keyvals; //_S2 what to return if >255 +return 0; //_S2 what to return if not found } // _S2 not needed, can go later @@ -566,8 +566,6 @@ std::wstring get_KeyVals_according_to_Shiftstate(GdkKeymap *keymap, guint keyco GdkKeymapKey *maps; guint *keyvals; gint count; - guint lowerCase; - guint upperCase; // _S2 TODO what to return if it fails? if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 5303ac864a..62283130b8 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -150,32 +150,11 @@ public: }*/ KMX_VirtualKey(UINT scanCode, KMX_HKL hkl, v_dw_3D All_Vector, GdkKeymap **keymap) { - // _S2 this->m_vk = MapVirtualKeyEx(scanCode, 1, hkl); // second para= 1: MAPVK_VSC_TO_VK =1 - // The first parameter is a scan code and is - // translated into a virtual-key code that does not - // distinguish between left- and right-hand keys. - // If there is no translation, the function returns 0. - // SC -> VK - //KMX_DWORD old = get_VirtualKey_Other_From_SC(scanCode, All_Vector); this->m_vk = get_VirtualKey_Other_GDK(*keymap, scanCode); - -/* _S2 can go later - if( this->m_vk != old) - wprintf(L" not the same !!!!!!!!!!!!!!!!!!!!!!!!! scanCode%i: %i(%c) -- %i(%c)\n",scanCode, this->m_vk, this->m_vk, old,old); - else - wprintf(L" all good ................... scanCode%i: %i(%c) -- %i(%c)\n",scanCode, this->m_vk, this->m_vk, old,old); - */ this->m_hkl = hkl; this->m_sc = scanCode ; } -void set_SC(UINT value){ - this->m_sc = value; -} -void set_VK(UINT value){ - this->m_vk = value; -} - UINT VK() { return this->m_vk; } @@ -661,23 +640,23 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd KMX_Loader loader; const size_t BUF_sz= 256; - // _S2 do I need that for Linux?? - KMX_WCHAR inputHKL[12]; - u16sprintf(inputHKL,BUF_sz ,L"%08.8x", (unsigned int) u16tol(kbid, NULL, 16)); // _S2 wsprintf(inputHKL, L"%08.8x", (unsigned int) wcstol(kbid, NULL, 16)); + // _S2 do I need that for Linux?? + KMX_WCHAR inputHKL[12]; + u16sprintf(inputHKL,BUF_sz ,L"%08.8x", (unsigned int) u16tol(kbid, NULL, 16)); // _S2 wsprintf(inputHKL, L"%08.8x", (unsigned int) wcstol(kbid, NULL, 16)); - /* - // _S2 do I need that for Linux?? - int cKeyboards = GetKeyboardLayoutList(0, NULL); - HKL *rghkl = new HKL[cKeyboards]; - GetKeyboardLayoutList(cKeyboards, rghkl); - HKL hkl = LoadKeyboardLayout(inputHKL, KLF_NOTELLSHELL); - if(hkl == NULL) { - puts("Sorry, that keyboard does not seem to be valid."); - delete[] rghkl; - return false; - } - */ + /* + // _S2 do I need that for Linux?? + int cKeyboards = GetKeyboardLayoutList(0, NULL); + HKL *rghkl = new HKL[cKeyboards]; + GetKeyboardLayoutList(cKeyboards, rghkl); + HKL hkl = LoadKeyboardLayout(inputHKL, KLF_NOTELLSHELL); + if(hkl == NULL) { + puts("Sorry, that keyboard does not seem to be valid."); + delete[] rghkl; + return false; + } + */ KMX_HKL hkl = NULL; //_S2 added: but can I do this?? hkl is not needed in Linux?? BYTE lpKeyState[256];// = new KeysEx[256]; @@ -694,20 +673,12 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd for(UINT sc = 0x01; sc <= 0x7f; sc++) { KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector, keymap); - std::wstring str= get_KeyVals_according_to_Shiftstate( *keymap, (guint) sc , Shft, 0 ); - - // _S2 QUESTION How to use keymap to fill key->vk correctly - // use str to edit key->vk - if ( !str.empty() ); - key->set_VK( (UINT)(*str.c_str())) ; - - /*wprintf(L" sc= %i --- VK = %i (%c)\n",sc,key_vk,key_vk);*/ + // _S2 is there a better solution than && (key->VK() <256) if((key->VK() != 0) && (key->VK() <256)) { rgKey[key->VK()] = key; } else { delete key; } - } for(UINT ke = VK_NUMPAD0; ke <= VK_NUMPAD9; ke++) { diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 2bc79446f2..f8181d2683 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -72,7 +72,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ argv.push_back(cmdl_par); } - wprintf(L"##### started run\n"); + if(argc < 3 || (argc < 5 && u16cmp(argv[1], u"-u") != 0)) { // I4273// I4273 wprintf( From 4398de7b4168b4ef70ab70d100350da7a57f0b9a Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 13 Nov 2023 17:53:14 +0100 Subject: [PATCH 124/327] feat(linux): mcompile tidy up --- linux/mcompile/keymap/keymap.cpp | 2 ++ linux/mcompile/keymap/keymap.h | 6 ++++-- linux/mcompile/keymap/mc_import_rules.cpp | 22 ++++++++++++++-------- linux/mcompile/keymap/mcompile.cpp | 6 +++--- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 5b6f7a9841..413df913f6 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -110,6 +110,8 @@ KMX_DWORD convertNamesToValue(std::wstring tok_wstr){ first[L"slash"] = 47; first[L"question"] = 63; first[L"space"] = 32; + first[L"asciitilde"] = 126; + first[L"asciicircum"] = 136; first[L"dead_acute"] = 180; first[L"grave"] = 96; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 2e5a4dc36b..a3e2576067 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -70,7 +70,8 @@ const KMX_DWORD KMX_VKMap[] = { //_S2 QUESTION Which character do we use in that case? 0 or FFFF or 32 or ?? // this is what we return when we find an invalid character -static KMX_DWORD returnIfCharInvalid = 32; +//static KMX_DWORD returnIfCharInvalid = 32; +static KMX_DWORD returnIfCharInvalid = 0; // takes a std::wstring (=contents of line symbols-file ) and returns the (int) value of the character KMX_DWORD convertNamesToValue(std::wstring tok_wstr); @@ -98,7 +99,7 @@ v_dw_2D create_empty_2D(int dim_rows, int dim_shifts); //KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); // _S2 can go later return the VirtualKey of the US Keyboard for given Scancode KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); -// return the Scancode of for given VirtualKey of Other Keyboard +// _S2 can go later return the Scancode of for given VirtualKey of Other Keyboard KMX_DWORD get_SC_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector); // _S2 can go later return the Scancode of for given VirtualKey of US KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector); @@ -106,6 +107,7 @@ KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector); //KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_US , v_dw_3D &All_Vector); // _S2 can go later return the Scancode of for given VirtualKey of Other in specific column. If column > available columns look in all columns; KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector, int which_columns); + // return the Scancode of for given VirtualKey using GDK KMX_DWORD get_position_From_GDK(GdkKeymap *keymap, UINT mapped_ikey); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 62283130b8..1a6958b576 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -123,19 +123,18 @@ public: }*/ - KMX_VirtualKey(KMX_HKL hkl, UINT KMX_virtualKey, v_dw_3D All_Vector) {/* + /*KMX_VirtualKey(KMX_HKL hkl, UINT KMX_virtualKey, v_dw_3D All_Vector) { this->m_sc = MapVirtualKeyEx(virtualKey, 0, hkl); // second para =0: MAPVK_VK_TO_VSC=1 //the uCode parameter is a virtual-key code and is //translated into a scan code. If it is a virtual-key //code that does not distinguish between left- and //right-hand keys, the left-hand scan code is returned. - //If there is no translation, the function returns 0.*/ - + //If there is no translation, the function returns 0. this->m_sc = get_SC_From_VirtualKey_Other(KMX_virtualKey, All_Vector); this->m_hkl = hkl; this->m_vk = KMX_virtualKey; memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); - } + }*/ /*KMX_VirtualKey(UINT scanCode, KMX_HKL hkl, v_dw_3D All_Vector) { // _S2 this->m_vk = MapVirtualKeyEx(scanCode, 1, hkl); // second para= 1: MAPVK_VSC_TO_VK =1 @@ -155,6 +154,13 @@ public: this->m_sc = scanCode ; } + KMX_VirtualKey(KMX_HKL hkl,UINT scanCode, v_dw_3D All_Vector, GdkKeymap **keymap) { + this->m_vk = get_VirtualKey_Other_GDK(*keymap, scanCode); + this->m_hkl = hkl; + this->m_sc = scanCode ; + // _S2 ?? memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); + } + UINT VK() { return this->m_vk; } @@ -682,12 +688,12 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd } for(UINT ke = VK_NUMPAD0; ke <= VK_NUMPAD9; ke++) { - rgKey[ke] = new KMX_VirtualKey(hkl, ke, All_Vector); + rgKey[ke] = new KMX_VirtualKey(hkl, ke, All_Vector, keymap); } - rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE, All_Vector); - rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL, All_Vector); - rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL, All_Vector); + rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE, All_Vector, keymap); + rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL, All_Vector, keymap); + rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL, All_Vector, keymap); /* // _S2 do we need special shift state now or later? diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index f8181d2683..8455c78feb 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -323,7 +323,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon return FALSE; } - const wchar_t* ERROR = L" "; + // const wchar_t* ERROR = L" "; for (int j = 0; VKShiftState[j] != 0xFFFF; j++) { // I4651 wprintf(L"\n"); @@ -344,11 +344,11 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); // _S2 ToDo - /*if(bDeadkeyConversion) { // I4552 + if(bDeadkeyConversion) { // I4552 if(ch == 0xFFFF) { ch = DeadKey; } - }*/ + } //wprintf(L" switch with ch: %i (%c)......\n" , ch,ch); switch(ch) { From 5577e4c6d3c4fa9c428be04f39400e38512bf91f Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 17 Nov 2023 09:56:27 +0100 Subject: [PATCH 125/327] feat(linux): mcompile use ScanCodeToUSVirtualKey/USVirtualKeyToScanCode --- linux/mcompile/keymap/helpers.cpp | 276 ++++++++++++++- linux/mcompile/keymap/keymap.cpp | 55 ++- linux/mcompile/keymap/keymap.h | 407 +++++++++++++++++++++- linux/mcompile/keymap/mc_import_rules.cpp | 51 ++- 4 files changed, 757 insertions(+), 32 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index aafbc42548..e60de721a8 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -692,10 +692,282 @@ bool test_single(v_dw_3D &V) { } } return 0; //_S2 what do I return if not found?? -}*/ +}*/// _S2 REMOVE + + +void Inspect_Key_S(GdkKeymap *keymap ) { + + guint KCode = 51; + guint Keyval_Base= 35; + guint Keyval_Shift = 39; + guint Keyval = Keyval_Base; + + gchar* KeyvalName_Base; + char* KeyvalName_ch_Base; + gchar* KeyvalName_Shift; + char* KeyvalName_ch_Shift; + + GdkKeymapKey* keys; + gint n_keys; + + GdkKeymapKey *maps; + guint *keyvals; + guint *keyvals_shift; + gint *n_entries; + gint count; + + GdkModifierType consumed; + // ___ ___ ___ ___ + // | A | | Ö | | & | | ' | + // Key |_a_| |_ö_| |_6_| |_#_| + // KCode 38 47 15 51 + // Keyval Base 97 246 54 35 + // Keyval Shift 65 214 38 39 + // KeyValname(Base) a odiaresis 6 apostrophe + // KeyValname(Shift) A Odiaresis ampersand numbersign + +//--------------------------------------- +gchar * gc= gdk_keyval_name (214); +gchar * gc0= gdk_keyval_name (65); +//--------------------------------------- +std::string sr = "odiaeresis"; +gchar * chr= (gchar*) sr.c_str(); ; +guint gi= gdk_keyval_from_name (chr); +//--------------------------------------- +Keyval= Keyval_Shift; + // finds ALL CHARACTERS ON KEY KCode for all levels and groups + // key 51 gr=0 (DE); lev=0 keyval 35(#) + // key 51 gr=0 (FR); lev=0 keyval 35(*) + // key 51 gr=0 (US); lev=0 keyval 35(\) + // key 51 gr=0 (ES); lev=0 keyval 35(\) + gdk_keymap_get_entries_for_keycode(keymap, KCode, &maps, &keyvals, &count); + wprintf(L"----------------------------\nprinting out the characters given by keypress of key SC/Keycode:%i\n",KCode); + for (int i = 0; i < count; i++) { + //if (maps[i].level > 0 || maps[i].group > 1) + // continue; + wprintf(L" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", + i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); + } + // finds all levels, groups WHERE KEYVAL IS LOCATED + // ' is on key 13, gr=0,lev=0 for swedish; + // ' is on key 51, gr=0,lev=1 for german; + // ' is on key 48, gr=2,lev=0 for english?; + // ' is on key 48, gr=3,lev=0 for spanish?; + //gdk_keymap_get_entries_for_keyval(keymap, Keyval,&keys,&n_keys); + gdk_keymap_get_entries_for_keyval(keymap, Keyval,&keys,&n_keys); + wprintf(L"----------------------------\nprinting out the characters given by keypress of Keyval :%i\n",Keyval); + for (int i = 0; i < n_keys; i++) { + //if (maps[i].level > 0 || maps[i].group > 1) + // continue; + wprintf(L" i=%d, Keyval=%d, (%c) keycode %i group %i level %i\n", + i, Keyval,Keyval, keys[i].keycode,keys[i].group,keys[i].level); + } +//--------------------------------------- + +gint Key_on_DE; +gint KeyVal_on_US; + Keyval = 214; + gdk_keymap_get_entries_for_keyval(keymap, Keyval,&keys,&n_keys); + wprintf(L"----------------------------\nprinting out the characters given by keypress of Keyval :%i\n",Keyval); + for (int i = 0; i < n_keys; i++) { + //if (maps[i].level > 0 || maps[i].group > 1) + // continue; + wprintf(L" i=%d, Keyval=%d, (%c) keycode %i group %i level %i\n", + i, Keyval,Keyval, keys[i].keycode,keys[i].group,keys[i].level); + } + for (int i = 0; i < n_keys; i++) { + if (keys[i].group ==0) + Key_on_DE = keys[i].keycode; + } + + gdk_keymap_get_entries_for_keycode(keymap, Key_on_DE, &maps, &keyvals, &count); + wprintf(L"----------------------------\nprinting out the characters given by keypress of key SC/Keycode:%i\n",Key_on_DE); + for (int i = 0; i < count; i++) { + //if (maps[i].level > 0 || maps[i].group > 1) + // continue; + wprintf(L" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", + i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); + } +for (int i = 0; i < count; i++) { + if ((maps[i].group ==2 )&& (maps[i].level ==0)) + KeyVal_on_US = maps[i].keycode; + } + +const UINT VK_US= ScanCodeToUSVirtualKey[KeyVal_on_US-8]; +const UINT VK_US2= USVirtualKeyToScanCode[KeyVal_on_US]; + +GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); +gdk_keymap_translate_keyboard_state (keymap, KCode, MOD_base , 0, keyvals, NULL, NULL, & consumed); +std::wstring rV1= std::wstring(1, (int) *keyvals); + + KeyvalName_Base = gdk_keyval_name (Keyval_Base); + KeyvalName_ch_Base = (char*) KeyvalName_Base; + std::string KeyvalName_str_Base(KeyvalName_ch_Base); + KeyvalName_Shift= gdk_keyval_name (Keyval_Shift); + KeyvalName_ch_Shift = (char*) KeyvalName_Shift; + std::string KeyvalName_str_Shift(KeyvalName_ch_Shift); + + + wprintf(L" keyval_Base %i has the name: %s ------ ", Keyval_Base, KeyvalName_str_Base.c_str()); + wprintf(L" keyval_Shift %i has the name: %s \n", Keyval_Shift, KeyvalName_str_Shift.c_str()); + //wprintf(L" keyval "); +int stop=99; + +} + + +void Try_GDK(GdkKeymap *keymap, guint k ) { + GdkKeymapKey *maps; + guint *keyvals; + gint count; + + // key 35(DE) = 187= OEM_PLUS; + +gdk_keymap_get_entries_for_keycode (keymap, k, &maps, &keyvals, &count); +wprintf(L"----------------------------\nprinting out the characters given by keypress of key SC/Keycode:%i\n",k); + for (int i = 0; i < count; i++) { + //if (maps[i].level > 0 || maps[i].group > 1) + // continue; + wprintf(L" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", + i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); + } + +wprintf(L"----------------------------\n"); +// finds a character on a key(KeyNr/SC) according to shiftstate/caps +// in: SC out: AsciiChar + + GdkModifierType consumed; + /* GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); + gdk_keymap_translate_keyboard_state (keymap, k, MOD_base , 0, keyvals, NULL, NULL, & consumed); + int kv= (int)*keyvals; + //std::wstring kv_ws= std::wstring(1, (int) *keyvals); + wprintf(L" gdk_keymap_translate_keyboard_state (keycode/SC %i) gives unshifted: %i (%c) -- ", k, kv,kv ); + + GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); + gdk_keymap_translate_keyboard_state (keymap, k, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + int kv1= (int)*keyvals; + //std::wstring kv_ws1= std::wstring(1, (int) *keyvals); + wprintf(L" and shifted %i (%c) \n", kv1,kv1 );*/ + +for ( int iii=1; iii< 66;iii++) +{ + GdkModifierType consumed; + GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); + gdk_keymap_translate_keyboard_state (keymap, iii, MOD_base , 0, keyvals, NULL, NULL, & consumed); + int kv= (int)*keyvals; + //std::wstring kv_ws= std::wstring(1, (int) *keyvals); + wprintf(L" gdk_keymap_translate_keyboard_state (keycode/SC %i) gives unshifted: %i (%c) -- \t", iii, kv,kv ); + + GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); + gdk_keymap_translate_keyboard_state (keymap, iii, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + int kv1= (int)*keyvals; + //std::wstring kv_ws1= std::wstring(1, (int) *keyvals); + wprintf(L" and shifted \t%i(%c) \n", kv1,kv1 ); + +} + + +wprintf(L"----------------------------\n"); +// finds a character on a key(KeyNr/SC) according to shiftstate/caps +// in: SC out: AsciiChar + gchar * gch; + char * ch; + + + + GdkModifierType consumedS; +for ( int iii=1; iii< 66;iii++) +{ /*gchar * gch1; + gch1 = gdk_keyval_name ((guint) iii); + std::string str_ch((char*)gch1);*/ + + gch = gdk_keyval_name ((guint) iii); + ch = (char*) gch; + std::string str_ch(ch); + //wprintf(L" key nr %i has the name: -- %s ", iii, str_ch.c_str()); + + + GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); + gdk_keymap_translate_keyboard_state (keymap, iii, MOD_base , 0, keyvals, NULL, NULL, & consumedS); + int kv= (int)*keyvals; + //std::wstring kv_ws= std::wstring(1, (int) *keyvals); + wprintf(L" (keycode/SC %i) has the name: %s \t\t---- gives unshifted: %i (%c) -- \t", iii, str_ch.c_str(),kv,kv ); + + GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); + gdk_keymap_translate_keyboard_state (keymap, iii, MOD_Shift , 0, keyvals, NULL, NULL, & consumedS); + int kv1= (int)*keyvals; + //std::wstring kv_ws1= std::wstring(1, (int) *keyvals); + wprintf(L" and shifted \t%i(%c) \n", kv1,kv1 ); + +} + +wprintf(L"----------------------------\n"); + /*GdkKeymapKey **keys1; + guint kval = 42; + gint *n_keys; + gboolean gboo = gdk_keymap_get_entries_for_keyval ( keymap, kval, keys1, n_keys); + wprintf(L" gdk_keymap_get_entries_for_keyval gives %i keys for this keyval( %i) :\n", *n_keys),(int) kval; + + //for (int i = 0; i < *n_keys; i++) { + for (int i = 0; i < 1; i++) { + wprintf(L" character 43 can be obtained by pressing %i keys:, keys1[%i]\n", + *n_keys, *keys1[i]); + int iii=99; + }*/ + +wprintf(L"----------------------------\n"); +// converts the Ascii-nr to the name specified in symbols-file( 35 -> numbersign( KEY_numbersign); 65 -> A( KEY_A) +// in: AsciiNr out: name in symbolfile + gchar * gch1; + char * ch1; + guint *keyvalsU; + guint *keyvalsS; + +for ( int ii=10; ii<65;ii++) { + gch1 = gdk_keyval_name ((guint) ii); + ch1 = (char*) gch; + std::string str_ch1(ch1); + wprintf(L" key nr %i has the name: -- %s \n ", ii, str_ch1.c_str()); + + //g_free(keyvalsU); + //g_free(maps); + + /*gdk_keymap_translate_keyboard_state (keymap, ii, MOD_Shift , 0, keyvalsS, NULL, NULL, & consumed); + int char_shifted = (int) *keyvalsS;*/ + + /* GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); + gdk_keymap_translate_keyboard_state (keymap, ii, MOD_base , 0, keyvalsS, NULL, NULL, & consumed); + int char_shifted = (int) *keyvalsS;*/ + + /* GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); + gdk_keymap_translate_keyboard_state (keymap, ii, MOD_base , 0, keyvalsU, NULL, NULL, & consumed); + int char_unshifted = (int) *keyvalsU;*/ + + //wprintf(L" key nr %i has the name: -- %ls \t\tand prints --> %c\t(%i)-\n ", ii, gch.c_str(), char_shifted,char_shifted); + + //wprintf(L", %c (%i) -- %c (%i) \n", ii,ii,char_shifted,char_shifted); +} +wprintf(L"----------------------------\n"); +// convert the content of a key which is more than 1 char long to the char ( plus -> +) +// in: name in symbolfile out: Ascii-Nr +std::string name = "plus"; +const char* name_ch = name.c_str(); + +guint name_int= gdk_keyval_from_name (name_ch); +wprintf(L" key with name '%s' has the (ASCII)value: :%i(%c)\n", name.c_str(), name_int,name_int); + +wprintf(L"----------------------------\n"); + +guint32 g32= gdk_keyval_to_unicode ('R'); +wprintf(L"----------------------------\n"); +guint g= gdk_unicode_to_keyval ('\u0052'); +wprintf(L"----------------------------\n"); + +} + + -// _S2 REMOVE std::wstring PrintKeymapForCodeReturnKeySym(GdkKeymap *keymap, guint VK, v_dw_3D &All_Vector, ShiftState ss, int caps ){ //GdkKeymap *keymap; GdkModifierType consumed; diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 413df913f6..f44642b7ab 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -347,8 +347,8 @@ KMX_DWORD mapVK_To_char(KMX_DWORD SC ){ // if ( SC == 20) return VK_LBRKT; /* ; 219 = - oder ß */ // if ( SC == 21) return VK_RBRKT; /* ; 221 = = oder ' */ - if ( SC == 34) return VK_COLON; /* ; 186 VK_OEM_4 = [ oder ü */ - if ( SC == 35) return VK_EQUAL; /* ; 187 = ] oder + */ + // if ( SC == 34) return VK_COLON; /* ; 186 VK_OEM_4 = [ oder ü */ + //if ( SC == 35) return VK_EQUAL; /* ; 187 = ] oder + */ // if ( SC == 47) return VK_ACCENT; /* ; 192 VK_OEM_1 = : oder ö */ // if ( SC == 48) return VK_QUOTE; /* ' 222 VK_OEM_7 = " oder Ä */ @@ -370,8 +370,8 @@ KMX_DWORD mapChar_To_VK(KMX_DWORD chr ){ // if ( SC == 20) return VK_LBRKT; /* ; 219 = - oder ß */ // if ( SC == 21) return VK_RBRKT; /* ; 221 = = oder ' */ - if ( chr == VK_COLON) return 220; /* ; 186 VK_OEM_4 = [ oder ü */ - if ( chr == 187) return 42; /* ; 186 VK_OEM_4 = [ oder ü */ + // if ( chr == VK_COLON) return 220; /* ; 186 VK_OEM_4 = [ oder ü */ +// if ( chr == 187) return 42; /* ; 186 VK_OEM_4 = [ oder ü */ // if ( SC == 35) return VK_EQUAL; /* ; 187 = ] oder + */ // if ( SC == 47) return VK_ACCENT; /* ; 192 VK_OEM_1 = : oder ö */ @@ -446,8 +446,14 @@ KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { if ( lowerCase == upperCase ) return (KMX_DWORD) upperCase; } - return (KMX_DWORD) *keyvals; //_S2 what to return if >255 -return 0; //_S2 what to return if not found + // _S2 ToDo tidy up + if ( keycode >7) { + UINT VK_for_rgKey2 = ScanCodeToUSVirtualKey[keycode-8]; + + // return (KMX_DWORD) *keyvals; //_S2 what to return if >255 + return (KMX_DWORD) VK_for_rgKey2 ; } + + return 0; //_S2 what to return if not found } // _S2 not needed, can go later @@ -510,7 +516,7 @@ KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_V return 0; //_S2 TODO what do I return if not found?? } -// returns Keyval which hold the Keysym (in unshifted, shifted) +// returns KeyCode which hold the Keysym (in unshifted, shifted) KMX_DWORD get_position_From_GDK(GdkKeymap *keymap, UINT KeySym ) { GdkKeymapKey *maps; guint *keyvals; @@ -525,6 +531,21 @@ KMX_DWORD get_position_From_GDK(GdkKeymap *keymap, UINT KeySym ) { } return 0; //_S2 TODO what do I return if not found?? } +// returns KeyCode which holds the Keysym (in unshifted, shifted) +/*KMX_DWORD get_SC_From_Keycode_GDK(GdkKeymap *keymap, UINT SC ) { + GdkKeymapKey *maps; + guint *keyvals; + gint count; + + for (int k=0; k<255 ; k++ ){ + if (gdk_keymap_get_entries_for_keycode (keymap, k, &maps, &keyvals, &count)) { + if ( (keyvals[0] == SC) || (keyvals[1] == SC) ) { + return (KMX_DWORD) maps[0].keycode; + } + } + } + return 0; //_S2 TODO what do I return if not found?? +}*/ // _S2 TODO How to do mapping between Linux keycodes and keyman SC const int Lin_KM__map(int i, v_dw_3D &All_Vector) { @@ -535,8 +556,8 @@ const int Lin_KM__map(int i, v_dw_3D &All_Vector) { // finds 59th row (not value 59) int dw=0; //if (i == 32 ) return ; /* */5 - if (i == 186 ) return 220; /* Ü */ - if (i == 187 ) return 42; /* + * */ + //if (i == 186 ) return 220; /* Ü */ + //if (i == 187 ) return 42; /* + * */ //if (i == 188 ) {wprintf(L" swapped: i (%i) to 59 \n",dw,i); return 59; }/* COMMA */ //if (i == 189 ) {wprintf(L" swapped: i (%i) to 95 \n",dw,i); return 95; }/* - _ */ //if (i == 190 ) {wprintf(L" swapped: i (%i) to 58 \n",dw,i); return 58; }/* PERIOD */ @@ -555,8 +576,8 @@ const int Lin_KM__map(int i, v_dw_3D &All_Vector) { //if (i == 192 ) {wprintf(L" swapped: i (%i) to 214 \n",dw,i); return 214; }/* Ö */ //if (i == 186 ) {wprintf(L" swapped: i (%i) to 220 \n",dw,i); return 220; }/* Ü */ //if (i == 222 ) {wprintf(L" swapped: i (%i) to 196 \n",dw,i); return 196; }/* Ä */ - if (i == 220) {wprintf(L" swapped: i (%i) to 196 \n",dw,i); return 186; }/* Ä */ - if (i == 42) {wprintf(L" swapped: i (%i) to 196 \n",dw,i); return 187; }/* + */ + //if (i == 220) {wprintf(L" swapped: i (%i) to 196 \n",dw,i); return 186; }/* Ä */ + //if (i == 42) {wprintf(L" swapped: i (%i) to 196 \n",dw,i); return 187; }/* + */ return i; } @@ -662,3 +683,15 @@ std::wstring get_KeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint keyco return L"0"; } +// _S2 maybe not needed +UINT find_SC_Other_fromVK_GDK(UINT vk_US,GdkKeymap *keymap) { + UINT SC__Other; + + for ( int i=0; i<255;i++) { + SC__Other= (UINT )get_position_From_GDK( keymap, i); + if(SC__Other==vk_US ) + return SC__Other; + } + return vk_US; +} + diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index a3e2576067..418b460990 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -38,6 +38,407 @@ enum ShiftState { ShftXxxx = Shft | Xxxx, // 9 }; +const UINT USVirtualKeyToScanCode[256] = +{ + 0x00, // L"K_?00", // &H0 + 0x00, // L"K_LBUTTON", // &H1 + 0x00, // L"K_RBUTTON", // &H2 + 0x46, // L"K_CANCEL", // &H3 + 0x00, // L"K_MBUTTON", // &H4 + 0x00, // L"K_?05", // &H5 + 0x00, // L"K_?06", // &H6 + 0x00, // L"K_?07", // &H7 + 0x0E, // L"K_BKSP", // &H8 + 0x0F, // L"K_TAB", // &H9 + 0x00, // L"K_?0A", // &HA + 0x00, // L"K_?0B", // &HB + 0x4C, // L"K_KP5", // &HC + 0x1C, // L"K_ENTER", // &HD + 0x00, // L"K_?0E", // &HE + 0x00, // L"K_?0F", // &HF + 0x2A, // L"K_SHIFT", // &H10 + 0x1D, // L"K_CONTRO0x00, // L", // &H11 + 0x38, // L"K_ALT", // &H12 + 0x00, // L"K_PAUSE", // &H13 + 0x3A, // L"K_CAPS", // &H14 + 0x00, // L"K_KANJI?15", // &H15 + 0x00, // L"K_KANJI?16", // &H16 + 0x00, // L"K_KANJI?17", // &H17 + 0x00, // L"K_KANJI?18", // &H18 + 0x00, // L"K_KANJI?19", // &H19 + 0x00, // L"K_?1A", // &H1A + 0x01, // L"K_ESC", // &H1B + 0x00, // L"K_KANJI?1C", // &H1C + 0x00, // L"K_KANJI?1D", // &H1D + 0x00, // L"K_KANJI?1E", // &H1E + 0x00, // L"K_KANJI?1F", // &H1F + 0x39, // L"K_SPACE", // &H20 + 0x49, // L"K_PGUP", // &H21 + 0x51, // L"K_PGDN", // &H22 + 0x4F, // L"K_END", // &H23 + 0x47, // L"K_HOME", // &H24 + 0x4B, // L"K_LEFT", // &H25 + 0x48, // L"K_UP", // &H26 + 0x4D, // L"K_RIGHT", // &H27 + 0x50, // L"K_DOWN", // &H28 + 0x00, // L"K_SEL", // &H29 + 0x00, // L"K_PRINT", // &H2A + 0x00, // L"K_EXEC", // &H2B + 0x54, // L"K_PRTSCN", // &H2C + 0x52, // L"K_INS", // &H2D + 0x53, // L"K_DEL", // &H2E + 0x63, // L"K_HELP", // &H2F + 0x0B, // L"K_0", // &H30 + 0x02, // L"K_1", // &H31 + 0x03, // L"K_2", // &H32 + 0x04, // L"K_3", // &H33 + 0x05, // L"K_4", // &H34 + 0x06, // L"K_5", // &H35 + 0x07, // L"K_6", // &H36 + 0x08, // L"K_7", // &H37 + 0x09, // L"K_8", // &H38 + 0x0A, // L"K_9", // &H39 + 0x00, // L"K_?3A", // &H3A + 0x00, // L"K_?3B", // &H3B + 0x00, // L"K_?3C", // &H3C + 0x00, // L"K_?3D", // &H3D + 0x00, // L"K_?3E", // &H3E + 0x00, // L"K_?3F", // &H3F + 0x00, // L"K_?40", // &H40 + 0x1E, // L"K_A", // &H41 + 0x30, // L"K_B", // &H42 + 0x2E, // L"K_C", // &H43 + 0x20, // L"K_D", // &H44 + 0x12, // L"K_E", // &H45 + 0x21, // L"K_F", // &H46 + 0x22, // L"K_G", // &H47 + 0x23, // L"K_H", // &H48 + 0x17, // L"K_I", // &H49 + 0x24, // L"K_J", // &H4A + 0x25, // L"K_K", // &H4B + 0x26, // L"K_L", // &H4C + 0x32, // L"K_M", // &H4D + 0x31, // L"K_N", // &H4E + 0x18, // L"K_O", // &H4F + 0x19, // L"K_P", // &H50 + 0x10, // L"K_Q", // &H51 + 0x13, // L"K_R", // &H52 + 0x1F, // L"K_S", // &H53 + 0x14, // L"K_T", // &H54 + 0x16, // L"K_U", // &H55 + 0x2F, // L"K_V", // &H56 + 0x11, // L"K_W", // &H57 + 0x2D, // L"K_X", // &H58 + 0x15, // L"K_Y", // &H59 + 0x2C, // L"K_Z", // &H5A + 0x5B, // L"K_?5B", // &H5B + 0x5C, // L"K_?5C", // &H5C + 0x5D, // L"K_?5D", // &H5D + 0x00, // L"K_?5E", // &H5E + 0x5F, // L"K_?5F", // &H5F + 0x52, // L"K_NP0", // &H60 + 0x4F, // L"K_NP1", // &H61 + 0x50, // L"K_NP2", // &H62 + 0x51, // L"K_NP3", // &H63 + 0x4B, // L"K_NP4", // &H64 + 0x4C, // L"K_NP5", // &H65 + 0x4D, // L"K_NP6", // &H66 + 0x47, // L"K_NP7", // &H67 + 0x48, // L"K_NP8", // &H68 + 0x49, // L"K_NP9", // &H69 + 0x37, // L"K_NPSTAR", // &H6A + 0x4E, // L"K_NPPLUS", // &H6B + 0x7E, // L"K_SEPARATOR", // &H6C // MCD 01-11-02: Brazilian Fix, 00 -> 7E + 0x4A, // L"K_NPMINUS", // &H6D + 0x53, // L"K_NPDOT", // &H6E + 0x135, // L"K_NPSLASH", // &H6F + 0x3B, // L"K_F1", // &H70 + 0x3C, // L"K_F2", // &H71 + 0x3D, // L"K_F3", // &H72 + 0x3E, // L"K_F4", // &H73 + 0x3F, // L"K_F5", // &H74 + 0x40, // L"K_F6", // &H75 + 0x41, // L"K_F7", // &H76 + 0x42, // L"K_F8", // &H77 + 0x43, // L"K_F9", // &H78 + 0x44, // L"K_F10", // &H79 + 0x57, // L"K_F11", // &H7A + 0x58, // L"K_F12", // &H7B + 0x64, // L"K_F13", // &H7C + 0x65, // L"K_F14", // &H7D + 0x66, // L"K_F15", // &H7E + 0x67, // L"K_F16", // &H7F + 0x68, // L"K_F17", // &H80 + 0x69, // L"K_F18", // &H81 + 0x6A, // L"K_F19", // &H82 + 0x6B, // L"K_F20", // &H83 + 0x6C, // L"K_F21", // &H84 + 0x6D, // L"K_F22", // &H85 + 0x6E, // L"K_F23", // &H86 + 0x76, // L"K_F24", // &H87 + + 0x00, // L"K_?88", // &H88 + 0x00, // L"K_?89", // &H89 + 0x00, // L"K_?8A", // &H8A + 0x00, // L"K_?8B", // &H8B + 0x00, // L"K_?8C", // &H8C + 0x00, // L"K_?8D", // &H8D + 0x00, // L"K_?8E", // &H8E + 0x00, // L"K_?8F", // &H8F + + 0x45, // L"K_NUMLOCK", // &H90 + 0x46, // L"K_SCROL0x00, // L", // &H91 + + 0x00, // L"K_?92", // &H92 + 0x00, // L"K_?93", // &H93 + 0x00, // L"K_?94", // &H94 + 0x00, // L"K_?95", // &H95 + 0x00, // L"K_?96", // &H96 + 0x00, // L"K_?97", // &H97 + 0x00, // L"K_?98", // &H98 + 0x00, // L"K_?99", // &H99 + 0x00, // L"K_?9A", // &H9A + 0x00, // L"K_?9B", // &H9B + 0x00, // L"K_?9C", // &H9C + 0x00, // L"K_?9D", // &H9D + 0x00, // L"K_?9E", // &H9E + 0x00, // L"K_?9F", // &H9F + 0x2A, // L"K_?A0", // &HA0 + 0x36, // L"K_?A1", // &HA1 + 0x1D, // L"K_?A2", // &HA2 + 0x1D, // L"K_?A3", // &HA3 + 0x38, // L"K_?A4", // &HA4 + 0x38, // L"K_?A5", // &HA5 + 0x6A, // L"K_?A6", // &HA6 + 0x69, // L"K_?A7", // &HA7 + 0x67, // L"K_?A8", // &HA8 + 0x68, // L"K_?A9", // &HA9 + 0x65, // L"K_?AA", // &HAA + 0x66, // L"K_?AB", // &HAB + 0x32, // L"K_?AC", // &HAC + 0x20, // L"K_?AD", // &HAD + 0x2E, // L"K_?AE", // &HAE + 0x30, // L"K_?AF", // &HAF + 0x19, // L"K_?B0", // &HB0 + 0x10, // L"K_?B1", // &HB1 + 0x24, // L"K_?B2", // &HB2 + 0x22, // L"K_?B3", // &HB3 + 0x6C, // L"K_?B4", // &HB4 + 0x6D, // L"K_?B5", // &HB5 + 0x6B, // L"K_?B6", // &HB6 + 0x21, // L"K_?B7", // &HB7 + 0x00, // L"K_?B8", // &HB8 + 0x00, // L"K_?B9", // &HB9 + 0x27, // L"K_COLON", // &HBA + 0x0D, // L"K_EQUA0x00, // L", // &HBB + 0x33, // L"K_COMMA", // &HBC + 0x0C, // L"K_HYPHEN", // &HBD + 0x34, // L"K_PERIOD", // &HBE + 0x35, // L"K_SLASH", // &HBF + 0x29, // L"K_BKQUOTE", // &HC0 + + 0x73, // L"K_?C1", // &HC1 + 0x7E, // L"K_?C2", // &HC2 + 0x00, // L"K_?C3", // &HC3 + 0x00, // L"K_?C4", // &HC4 + 0x00, // L"K_?C5", // &HC5 + 0x00, // L"K_?C6", // &HC6 + 0x00, // L"K_?C7", // &HC7 + 0x00, // L"K_?C8", // &HC8 + 0x00, // L"K_?C9", // &HC9 + 0x00, // L"K_?CA", // &HCA + 0x00, // L"K_?CB", // &HCB + 0x00, // L"K_?CC", // &HCC + 0x00, // L"K_?CD", // &HCD + 0x00, // L"K_?CE", // &HCE + 0x00, // L"K_?CF", // &HCF + 0x00, // L"K_?D0", // &HD0 + 0x00, // L"K_?D1", // &HD1 + 0x00, // L"K_?D2", // &HD2 + 0x00, // L"K_?D3", // &HD3 + 0x00, // L"K_?D4", // &HD4 + 0x00, // L"K_?D5", // &HD5 + 0x00, // L"K_?D6", // &HD6 + 0x00, // L"K_?D7", // &HD7 + 0x00, // L"K_?D8", // &HD8 + 0x00, // L"K_?D9", // &HD9 + 0x00, // L"K_?DA", // &HDA + 0x1A, // L"K_LBRKT", // &HDB + 0x2B, // L"K_BKSLASH", // &HDC + 0x1B, // L"K_RBRKT", // &HDD + 0x28, // L"K_QUOTE", // &HDE + 0x73, // L"K_oDF", // &HDF // MCD 01-11-02: Brazilian fix: 00 -> 73 + 0x00, // L"K_oE0", // &HE0 + 0x00, // L"K_oE1", // &HE1 + 0x56, // L"K_oE2", // &HE2 + 0x00, // L"K_oE3", // &HE3 + 0x00, // L"K_oE4", // &HE4 + + 0x00, // L"K_?E5", // &HE5 + + 0x00, // L"K_oE6", // &HE6 + + 0x00, // L"K_?E7", // &HE7 + 0x00, // L"K_?E8", // &HE8 + + 0x71, // L"K_oE9", // &HE9 + 0x5C, // L"K_oEA", // &HEA + 0x7B, // L"K_oEB", // &HEB + 0x00, // L"K_oEC", // &HEC + 0x6F, // L"K_oED", // &HED + 0x5A, // L"K_oEE", // &HEE + 0x00, // L"K_oEF", // &HEF + 0x00, // L"K_oF0", // &HF0 + 0x5B, // L"K_oF1", // &HF1 + 0x00, // L"K_oF2", // &HF2 + 0x5F, // L"K_oF3", // &HF3 + 0x00, // L"K_oF4", // &HF4 + 0x5E, // L"K_oF5", // &HF5 + + 0x00, // L"K_?F6", // &HF6 + 0x00, // L"K_?F7", // &HF7 + 0x00, // L"K_?F8", // &HF8 + 0x5D, // L"K_?F9", // &HF9 + 0x00, // L"K_?FA", // &HFA + 0x62, // L"K_?FB", // &HFB + 0x00, // L"K_?FC", // &HFC + 0x00, // L"K_?FD", // &HFD + 0x00, // L"K_?FE", // &HFE + 0x00 // L"K_?FF" // &HFF +}; + +const UINT ScanCodeToUSVirtualKey[128] = { + 0x01, // 0x00 => K_LBUTTON + 0x1b, // 0x01 => K_ESC + 0x31, // 0x02 => K_1 + 0x32, // 0x03 => K_2 + 0x33, // 0x04 => K_3 + 0x34, // 0x05 => K_4 + 0x35, // 0x06 => K_5 + 0x36, // 0x07 => K_6 + 0x37, // 0x08 => K_7 + 0x38, // 0x09 => K_8 + 0x39, // 0x0a => K_9 + 0x30, // 0x0b => K_0 + 0xbd, // 0x0c => K_HYPHEN + 0xbb, // 0x0d => K_EQUAL + 0x08, // 0x0e => K_BKSP + 0x09, // 0x0f => K_TAB + 0x51, // 0x10 => K_Q + 0x57, // 0x11 => K_W + 0x45, // 0x12 => K_E + 0x52, // 0x13 => K_R + 0x54, // 0x14 => K_T 20 + 0x59, // 0x15 => K_Y + 0x55, // 0x16 => K_U + 0x49, // 0x17 => K_I + 0x4f, // 0x18 => K_O + 0x50, // 0x19 => K_P + 0xdb, // 0x1a => K_LBRKT + 0xdd, // 0x1b => K_RBRKT + 0x0d, // 0x1c => K_ENTER + 0x11, // 0x1d => K_CONTROL + 0x41, // 0x1e => K_A + 0x53, // 0x1f => K_S + 0x44, // 0x20 => K_D + 0x46, // 0x21 => K_F + 0x47, // 0x22 => K_G + 0x48, // 0x23 => K_H + 0x4a, // 0x24 => K_J + 0x4b, // 0x25 => K_K + 0x4c, // 0x26 => K_L + 0xba, // 0x27 => K_COLON 39 + 0xde, // 0x28 => K_QUOTE + 0xc0, // 0x29 => K_BKQUOTE + 0x10, // 0x2a => K_SHIFT + 0xdc, // 0x2b => K_BKSLASH + 0x5a, // 0x2c => K_Z + 0x58, // 0x2d => K_X + 0x43, // 0x2e => K_C + 0x56, // 0x2f => K_V + 0x42, // 0x30 => K_B + 0x4e, // 0x31 => K_N + 0x4d, // 0x32 => K_M + 0xbc, // 0x33 => K_COMMA + 0xbe, // 0x34 => K_PERIOD + 0xbf, // 0x35 => K_SLASH + 0xa1, // 0x36 => K_?A1 + 0x6a, // 0x37 => K_NPSTAR + 0x12, // 0x38 => K_ALT + 0x20, // 0x39 => K_SPACE + 0x14, // 0x3a => K_CAPS + 0x70, // 0x3b => K_F1 59 + 0x71, // 0x3c => K_F2 + 0x72, // 0x3d => K_F3 + 0x73, // 0x3e => K_F4 + 0x74, // 0x3f => K_F5 + 0x75, // 0x40 => K_F6 + 0x76, // 0x41 => K_F7 + 0x77, // 0x42 => K_F8 + 0x78, // 0x43 => K_F9 + 0x79, // 0x44 => K_F10 + 0x90, // 0x45 => K_NUMLOCK + 0x03, // 0x46 => K_CANCEL + 0x24, // 0x47 => K_HOME + 0x26, // 0x48 => K_UP + 0x21, // 0x49 => K_PGUP + 0x6d, // 0x4a => K_NPMINUS + 0x25, // 0x4b => K_LEFT + 0x0c, // 0x4c => K_KP5 + 0x27, // 0x4d => K_RIGHT + 0x6b, // 0x4e => K_NPPLUS + 0x23, // 0x4f => K_END + 0x28, // 0x50 => K_DOWN + 0x22, // 0x51 => K_PGDN + 0x2d, // 0x52 => K_INS + 0x2e, // 0x53 => K_DEL + 0x2c, // 0x54 => K_PRTSCN + 0x00, // 0x55 => No match + 0xe2, // 0x56 => K_oE2 + 0x7a, // 0x57 => K_F11 + 0x7b, // 0x58 => K_F12 + 0x00, // 0x59 => No match + 0xee, // 0x5a => K_oEE + 0x5b, // 0x5b => K_?5B + 0x5c, // 0x5c => K_?5C + 0x5d, // 0x5d => K_?5D + 0xf5, // 0x5e => K_oF5 + 0x5f, // 0x5f => K_?5F + 0x00, // 0x60 => No match + 0x00, // 0x61 => No match + 0xfb, // 0x62 => K_?FB + 0x2f, // 0x63 => K_HELP + 0x7c, // 0x64 => K_F13 + 0x7d, // 0x65 => K_F14 + 0x7e, // 0x66 => K_F15 + 0x7f, // 0x67 => K_F16 + 0x80, // 0x68 => K_F17 + 0x81, // 0x69 => K_F18 + 0x82, // 0x6a => K_F19 + 0x83, // 0x6b => K_F20 + 0x84, // 0x6c => K_F21 + 0x85, // 0x6d => K_F22 + 0x86, // 0x6e => K_F23 + 0xed, // 0x6f => K_oED + 0x00, // 0x70 => No match + 0xe9, // 0x71 => K_oE9 + 0x00, // 0x72 => No match + 0xc1, // 0x73 => K_?C1 + 0x00, // 0x74 => No match + 0x00, // 0x75 => No match + 0x87, // 0x76 => K_F24 + 0x00, // 0x77 => No match + 0x00, // 0x78 => No match + 0x00, // 0x79 => No match + 0x00, // 0x7a => No match + 0xeb, // 0x7b => K_oEB + 0x00, // 0x7c => No match + 0x00, // 0x7d => No match + 0x6c, // 0x7e => K_SEPARATOR + 0x00 // 0x7f => No match +}; + + // Map of all US English virtual key codes that we can translate const KMX_DWORD KMX_VKMap[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', @@ -110,10 +511,12 @@ KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_V // return the Scancode of for given VirtualKey using GDK KMX_DWORD get_position_From_GDK(GdkKeymap *keymap, UINT mapped_ikey); - +// can go later +void Try_GDK(GdkKeymap *keymap, UINT KeySym ); +void Inspect_Key_S(GdkKeymap *keymap ) ; // return the VirtualKey of the Other Keyboard for given Scancode using GDK KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD scanCode); - +UINT find_SC_Other_fromVK_GDK(UINT vk_US_187,GdkKeymap *keymap); // initialize GDK bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 1a6958b576..90560e8c75 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -677,10 +677,16 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd // flag that the VK is valid, and it can store the SC value. // _S2 this does not find exactly the same keys as the windows version does(windows finds more) + int keycountS =0; for(UINT sc = 0x01; sc <= 0x7f; sc++) { + // fills m_vk with the VK of the US keyboard which is not right!! + // ( mcompile win uses MapVirtualKeyEx() to fill m_vk with the VK of the Other keyboard) + // Linux cant get a VK for the US Keyboard using USVirtualKeyToScanCode/ScanCodeToUSVirtualKey + // Linux cannot get a VK for Other Keyboard + // it could return SC if that helps KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector, keymap); - // _S2 is there a better solution than && (key->VK() <256) - if((key->VK() != 0) && (key->VK() <256)) { + if((key->VK() != 0) ) { + keycountS++; rgKey[key->VK()] = key; } else { delete key; @@ -727,6 +733,9 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd } } + //Try_GDK( *keymap, 35 ) ; // key 35(DE) = 187= OEM_PLUS + //Inspect_Key_S(*keymap); + // _S2 QUIESTION !!! // Different characters on Windows and Lunux for shift/Caps-states: // Windows Linux @@ -748,7 +757,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd if(rgKey[iKey] != NULL) { WCHAR sbBuffer[256]; // Scratchpad we use many places - UINT mapped_ikey = Lin_KM__map(iKey, All_Vector); + UINT SC_Other = Lin_KM__map(iKey, All_Vector); for(ShiftState ss = Base; ss <= loader.MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { if(ss == Menu || ss == ShftMenu) { @@ -757,14 +766,22 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd } // _S2 can go later - //int Keypos = get_position_From_VirtualKey_Other(mapped_ikey , All_Vector, 99); + //int Keypos = get_position_From_VirtualKey_Other(SC_Other , All_Vector, 99); //UINT VK_vec = (UINT) All_Vector[1][Keypos][0]; - // _S2 get_position_From_GDK gives wrong values for 0,65,94,126 which are not processed correctly -> "what do I return if not found..." - KMX_DWORD keypos_GDK= get_position_From_GDK( *keymap, mapped_ikey ); - //if ( VK_vec != keypos_GDK) - // wprintf(L" DIFFFFERERNT !!!!!!! , %i -- %i\n", VK_vec,keypos_GDK ); + + + // _S2 get_position_From_GDK gives wrong values for 0,65,94,126 which are not processed correctly -> "what do I return if not found..." + KMX_DWORD keypos_GDK= get_position_From_GDK( *keymap, SC_Other ); + KMX_DWORD SC_US; + if( SC_Other>7) + SC_US= (KMX_DWORD)(8+ USVirtualKeyToScanCode[ SC_Other ]); + else SC_US=0; + +//wprintf(L" for vk of %i we get Keycode US of %i SC_Other %i: ( on Key US (%i) we find char %i (%c) ) \n", SC_Other, 8+USVirtualKeyToScanCode[SC_Other], 8+USVirtualKeyToScanCode[SC_Other] , +//8+USVirtualKeyToScanCode[SC_Other],get_VirtualKey_Other_GDK(*keymap, 8+USVirtualKeyToScanCode[SC_Other]),get_VirtualKey_Other_GDK(*keymap, 8+USVirtualKeyToScanCode[SC_Other]) ); + // _S2 TODO this needs to go !! it's TEMPORARY until we decide what to return if not found. At the moment we return 0 in this case which is a problem for gdk // _S2 to avoid Gdk-CRITICAL **: 16:41:42.662: gdk_keymap_get_entries_for_keyval: assertion 'keyval != 0' failed: we set keypos_GDK to a value @@ -775,14 +792,15 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd for(int caps = 0; caps <= 1; caps++) { //_S2 TODO get char - do I need rc ?? ( was rc = ToUnicodeEx...) - std::wstring VK_Other_OLD = get_VirtualKey_Other_from_iKey(mapped_ikey, ss, caps, All_Vector); - std::wstring VK_Other = get_KeySyms_according_to_Shiftstate( *keymap, keypos_GDK, ss, caps); + std::wstring VK_Other_OLD = get_VirtualKey_Other_from_iKey(SC_Other, ss, caps, All_Vector); + //std::wstring VK_Other2 = get_KeySyms_according_to_Shiftstate( *keymap, keypos_GDK, ss, caps); + std::wstring VK_Other = get_KeySyms_according_to_Shiftstate( *keymap, SC_US, ss, caps); + std::wstring VK_Other3 = get_KeySyms_according_to_Shiftstate( *keymap, SC_Other, ss, caps); + std::wstring VK_Other31 = get_KeySyms_according_to_Shiftstate( *keymap, 187, ss, caps); + std::wstring VK_Other32 = get_KeySyms_according_to_Shiftstate( *keymap, 221, ss, caps); + std::wstring VK_Other33 = get_KeySyms_according_to_Shiftstate( *keymap, 186, ss, caps); + //std::wstring VK_Other77 = get_KeySyms_according_to_Shiftstate( *keymap, SC_US, ss, caps); - /* _S2 can go later - if ( VK_Other_OLD != VK_Other) { - if(VK_Other!=L"" ) - wprintf(L"\nVK`s are different :-( %s <--> %s ",VK_Other.c_str() ,VK_Other_OLD.c_str()); - }*/ //_S2 TODO do I need that ?? //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { @@ -821,7 +839,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd std::vector< int > TestValues = {48,49,50,51,52,53,54,55,56,57,65,66,67,88,89,90}; // std::vector< int > TestValues = {65}; wprintf(L"-----------------\nNow some tests:\n"); - for ( int i=0; i < TestValues.size();i++) { + for ( int i=0; i < (int) TestValues.size();i++) { wprintf(L"Results for %i\t: %s %s %s %s \n", TestValues[i], rgKey[TestValues[i]]->KMX_GetShiftState(Base,0).c_str(), rgKey[TestValues[i]]->KMX_GetShiftState(Base,1).c_str() , rgKey[TestValues[i]]->KMX_GetShiftState(Shft,0).c_str(), rgKey[TestValues[i]]->KMX_GetShiftState(Shft,1).c_str()); } wprintf(L"-----------------\n"); @@ -882,7 +900,6 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd // // Fill in the new rules // -int STOP; for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { From d731f4fbfe7e63cc522f9e468a49c8221e010bde Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 17 Nov 2023 10:25:35 +0100 Subject: [PATCH 126/327] feat(linux): mcompile tidy up rename functions --- linux/mcompile/keymap/keymap.cpp | 14 +++---- linux/mcompile/keymap/keymap.h | 4 +- linux/mcompile/keymap/mc_import_rules.cpp | 47 ++--------------------- 3 files changed, 13 insertions(+), 52 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index f44642b7ab..a992ee3b86 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -516,15 +516,15 @@ KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_V return 0; //_S2 TODO what do I return if not found?? } -// returns KeyCode which hold the Keysym (in unshifted, shifted) -KMX_DWORD get_position_From_GDK(GdkKeymap *keymap, UINT KeySym ) { +// returns KeyCode which hold the Keysym/Keyval (in unshifted, shifted) +KMX_DWORD get_KeyCode_From_KeyVal_GDK(GdkKeymap *keymap, UINT Keyval ) { GdkKeymapKey *maps; guint *keyvals; gint count; for (int k=0; k<255 ; k++ ){ if (gdk_keymap_get_entries_for_keycode (keymap, k, &maps, &keyvals, &count)) { - if ( (keyvals[0] == KeySym) || (keyvals[1] == KeySym) ) { + if ( (keyvals[0] == Keyval) || (keyvals[1] == Keyval) ) { return (KMX_DWORD) maps[0].keycode; } } @@ -684,14 +684,14 @@ std::wstring get_KeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint keyco } // _S2 maybe not needed -UINT find_SC_Other_fromVK_GDK(UINT vk_US,GdkKeymap *keymap) { +UINT find_SC_Other_from_SC_US_GDK(UINT SC_US,GdkKeymap *keymap) { UINT SC__Other; for ( int i=0; i<255;i++) { - SC__Other= (UINT )get_position_From_GDK( keymap, i); - if(SC__Other==vk_US ) + SC__Other= (UINT )get_KeyCode_From_KeyVal_GDK( keymap, i); + if(SC__Other==SC_US ) return SC__Other; } - return vk_US; + return SC_US; } diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 418b460990..6162a71437 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -510,13 +510,13 @@ KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector); KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector, int which_columns); // return the Scancode of for given VirtualKey using GDK -KMX_DWORD get_position_From_GDK(GdkKeymap *keymap, UINT mapped_ikey); +KMX_DWORD get_KeyCode_From_KeyVal_GDK(GdkKeymap *keymap, UINT mapped_ikey); // can go later void Try_GDK(GdkKeymap *keymap, UINT KeySym ); void Inspect_Key_S(GdkKeymap *keymap ) ; // return the VirtualKey of the Other Keyboard for given Scancode using GDK KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD scanCode); -UINT find_SC_Other_fromVK_GDK(UINT vk_US_187,GdkKeymap *keymap); +UINT find_SC_Other_from_SC_US_GDK(UINT vk_US_187,GdkKeymap *keymap); // initialize GDK bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 90560e8c75..7902d7b2e3 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -733,25 +733,6 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd } } - //Try_GDK( *keymap, 35 ) ; // key 35(DE) = 187= OEM_PLUS - //Inspect_Key_S(*keymap); - - // _S2 QUIESTION !!! - // Different characters on Windows and Lunux for shift/Caps-states: - // Windows Linux - // none/caps/shift/caps+Shift <=> none/caps/shift/caps+Shift - // a A A a <=> a A A a - // ö Ö Ö ö <=> ö Ö Ö ö - // 1 ! ! 1 <=> 1 1 ! ! ( on US keyboard) - // & 1 1 & <=> & 1 1 & ( on FR keyboard) - // ù % % ù <=> ù Ù % % (!!!) - // ' # # ' <=> # # ' ' - // - - _ _ <=> - - _ _ - // - // in which order would we place them in rgKey[] ?? - // this affects counting of keys in functions KMX_GetKeyCount/KMX_IsCapsEqualToShift - - // _S2 in this part we skip shiftstates 4, 5, 8, 9 for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { if(rgKey[iKey] != NULL) { @@ -765,41 +746,21 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd continue; } - // _S2 can go later - //int Keypos = get_position_From_VirtualKey_Other(SC_Other , All_Vector, 99); - //UINT VK_vec = (UINT) All_Vector[1][Keypos][0]; - - - - - // _S2 get_position_From_GDK gives wrong values for 0,65,94,126 which are not processed correctly -> "what do I return if not found..." - KMX_DWORD keypos_GDK= get_position_From_GDK( *keymap, SC_Other ); KMX_DWORD SC_US; if( SC_Other>7) - SC_US= (KMX_DWORD)(8+ USVirtualKeyToScanCode[ SC_Other ]); - else SC_US=0; + SC_US= (KMX_DWORD)(8+ USVirtualKeyToScanCode[ SC_Other ]); + else SC_US = 0; //wprintf(L" for vk of %i we get Keycode US of %i SC_Other %i: ( on Key US (%i) we find char %i (%c) ) \n", SC_Other, 8+USVirtualKeyToScanCode[SC_Other], 8+USVirtualKeyToScanCode[SC_Other] , //8+USVirtualKeyToScanCode[SC_Other],get_VirtualKey_Other_GDK(*keymap, 8+USVirtualKeyToScanCode[SC_Other]),get_VirtualKey_Other_GDK(*keymap, 8+USVirtualKeyToScanCode[SC_Other]) ); - // _S2 TODO this needs to go !! it's TEMPORARY until we decide what to return if not found. At the moment we return 0 in this case which is a problem for gdk - // _S2 to avoid Gdk-CRITICAL **: 16:41:42.662: gdk_keymap_get_entries_for_keyval: assertion 'keyval != 0' failed: we set keypos_GDK to a value - if (keypos_GDK ==0) - keypos_GDK = 49; - - for(int caps = 0; caps <= 1; caps++) { //_S2 TODO get char - do I need rc ?? ( was rc = ToUnicodeEx...) - std::wstring VK_Other_OLD = get_VirtualKey_Other_from_iKey(SC_Other, ss, caps, All_Vector); - //std::wstring VK_Other2 = get_KeySyms_according_to_Shiftstate( *keymap, keypos_GDK, ss, caps); + //std::wstring VK_Other_OLD = get_VirtualKey_Other_from_iKey(SC_Other, ss, caps, All_Vector); std::wstring VK_Other = get_KeySyms_according_to_Shiftstate( *keymap, SC_US, ss, caps); - std::wstring VK_Other3 = get_KeySyms_according_to_Shiftstate( *keymap, SC_Other, ss, caps); - std::wstring VK_Other31 = get_KeySyms_according_to_Shiftstate( *keymap, 187, ss, caps); - std::wstring VK_Other32 = get_KeySyms_according_to_Shiftstate( *keymap, 221, ss, caps); - std::wstring VK_Other33 = get_KeySyms_according_to_Shiftstate( *keymap, 186, ss, caps); - //std::wstring VK_Other77 = get_KeySyms_according_to_Shiftstate( *keymap, SC_US, ss, caps); + //std::wstring VK_Other3 = get_KeySyms_according_to_Shiftstate( *keymap, SC_Other, ss, caps); //_S2 TODO do I need that ?? From fa57aa7ae9b71029d33864e0b23b3031afedf7fc Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 20 Nov 2023 19:38:31 +0100 Subject: [PATCH 127/327] feat(linux): mcompile fill rgkey with AltGr+ AltGr/Caps --- linux/mcompile/keymap/helpers.cpp | 66 +++++++++++- linux/mcompile/keymap/keymap.cpp | 32 ++++-- linux/mcompile/keymap/mc_import_rules.cpp | 125 +++++++++++----------- 3 files changed, 148 insertions(+), 75 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index e60de721a8..9564706549 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -720,7 +720,7 @@ void Inspect_Key_S(GdkKeymap *keymap ) { // ___ ___ ___ ___ // | A | | Ö | | & | | ' | // Key |_a_| |_ö_| |_6_| |_#_| - // KCode 38 47 15 51 + // KeyCode 38 47 15 51 // Keyval Base 97 246 54 35 // Keyval Shift 65 214 38 39 // KeyValname(Base) a odiaresis 6 apostrophe @@ -1429,3 +1429,67 @@ wprintf(L" in Us %i and KeysymsUS %i : \n", inUS ,KeysymUS ); return true; } */ + + +bool is_Letter(int pos, v_dw_3D & All_Vector){ + if( ( All_Vector[1][pos][1] == All_Vector[1][pos][2] + 32) ) + return true; + return false; +} + +bool is_Number(int pos, v_dw_3D & All_Vector){ + if( (All_Vector[1][pos][1] >= 48) && (All_Vector[1][pos][1] <= 57) ) + return true; + return false; +} + +bool is_Special(int pos, v_dw_3D & All_Vector){ + if( !is_Number && !is_Letter) + return true; + return false; +} + +bool is_Edges(int pos, v_dw_3D & All_Vector){ + if( (All_Vector[1][pos][1] == 48)) + return true; + return false; +} +// _S2 can go later +std::wstring get_VirtualKey_Other_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &caps, v_dw_3D &All_Vector) { + + // _S2 this will find the correct row in All_Vector + //( e.g. get_position_From_VirtualKey_Other(65 ,All_Vector.99 ) returns 25 + // All_Vector[25] contains SC(38), unshifted A (97) shifted A (65) ) + KMX_DWORD pos = get_position_From_VirtualKey_Other(iKey, All_Vector,99); + + int icaps; + if (ss >9) + return L""; + + if( ss < All_Vector[1][pos].size()-1) { + + // ss 0,2,4... + if ( ss % 2 == 0) { + // aAAa 4$$4 + if ( is_Letter(pos, All_Vector) || is_Number(pos, All_Vector)) + icaps = ss+2-caps; + // ..:: ##'' + else + icaps = ss+1; + } + + // ss 1,3,5... + if ( ss % 2 == 1) { + // aAAa 4$$4 + if ( is_Letter(pos, All_Vector) || is_Number(pos, All_Vector)) + icaps = ss+caps; + // ..:: ##'' + else + icaps = ss+1; + } + + return std::wstring(1, (int) All_Vector[1][pos][icaps]); + } + return L""; +} + diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index a992ee3b86..c3370ca17e 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -446,11 +446,16 @@ KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { if ( lowerCase == upperCase ) return (KMX_DWORD) upperCase; } + + + // _S2 ToDo + // either it gives the correct rgkeys (all non-char filled with special char) or + // it gives not all rgkeys but nr, a-z are filled correctly // _S2 ToDo tidy up if ( keycode >7) { UINT VK_for_rgKey2 = ScanCodeToUSVirtualKey[keycode-8]; - // return (KMX_DWORD) *keyvals; //_S2 what to return if >255 + //return (KMX_DWORD) *keyvals;} //_S2 what to return if >255 return (KMX_DWORD) VK_for_rgKey2 ; } return 0; //_S2 what to return if not found @@ -594,7 +599,6 @@ std::wstring get_KeyVals_according_to_Shiftstate(GdkKeymap *keymap, guint keyco if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return L"1"; - //unshifted if (( ss == Base ) && ( caps == 0 )) { GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); @@ -641,7 +645,8 @@ std::wstring get_KeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint keyco gint count; if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return L"1"; + return L"\0"; + //return L"1"; //unshifted if (( ss == Base ) && ( caps == 0 )) { @@ -672,15 +677,24 @@ std::wstring get_KeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint keyco return std::wstring(1, (int) *keyvals); } - /*//ALT-GR - else if { - GdkModifierType MOD_AltGr = (GdkModifierType) ( GDK_MOD5_MASK ); + //ALT-GR + else if (( ss == MenuCtrl ) && ( caps == 0 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) ( 144 ); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - return *keyvals; - }*/ + return std::wstring(1, (int) *keyvals); + } + + + //ALT-GR + else if (( ss == MenuCtrl ) && ( caps == 1 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) ( 144 ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + } else - return L"0"; + return L"\0"; + //return L"0"; } // _S2 maybe not needed diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 7902d7b2e3..8645e03c99 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -300,6 +300,20 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,v_dw_3D &All_Vector) { // I4552 // Get the CAPSLOCK value + + +bool b1= this->KMX_IsCapsEqualToShift(); +bool b2= this->KMX_IsSGCAPS(); +bool b3= this->KMX_IsAltGrCapsEqualToAltGrShift(); +bool b4= this->KMX_IsXxxxGrCapsEqualToXxxxShift() ; + +int i1 = this->KMX_IsCapsEqualToShift() ? 1 : 0; +int i2 = this->KMX_IsSGCAPS() ? 2 : 0; +int i3 = this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0; +int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; + + + int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | (this->KMX_IsSGCAPS() ? 2 : 0) | @@ -324,6 +338,8 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; key->dpContext = new KMX_WCHAR[1]; *key->dpContext = 0; key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); + + // _S2 this fun returns the shifted Char it goes wrog for numbers, special here!! key->Key = KMX_VKUnderlyingLayoutToVKUS(All_Vector,this->VK()); key->Line = 0; @@ -346,6 +362,7 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; } if(isvalid) { + // _S2 this fun returns the shifted Char instead of keyname -> use gdk function!! key->Key = KMX_VKUnderlyingLayoutToVKUS(All_Vector,this->VK()); key->Line = 0; key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); @@ -575,70 +592,15 @@ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { return n; } +bool IsKeymanUsedKey_S2(std::wstring SC_Other) { +int SC_US = (int) (*SC_Other.c_str()); -bool is_Letter(int pos, v_dw_3D & All_Vector){ - if( ( All_Vector[1][pos][1] == All_Vector[1][pos][2] + 32) ) - return true; - return false; -} - -bool is_Number(int pos, v_dw_3D & All_Vector){ - if( (All_Vector[1][pos][1] >= 48) && (All_Vector[1][pos][1] <= 57) ) + if ((SC_US>= 0x20 && SC_US <= 0x7A) || (SC_US >= 0x88 && SC_US < 0xFF)) return true; - return false; -} + else + return false; -bool is_Special(int pos, v_dw_3D & All_Vector){ - if( !is_Number && !is_Letter) - return true; - return false; -} - -bool is_Edges(int pos, v_dw_3D & All_Vector){ - if( (All_Vector[1][pos][1] == 48)) - return true; - return false; -} - - -// _S2 can go later -std::wstring get_VirtualKey_Other_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &caps, v_dw_3D &All_Vector) { - - // _S2 this will find the correct row in All_Vector - //( e.g. get_position_From_VirtualKey_Other(65 ,All_Vector.99 ) returns 25 - // All_Vector[25] contains SC(38), unshifted A (97) shifted A (65) ) - KMX_DWORD pos = get_position_From_VirtualKey_Other(iKey, All_Vector,99); - - int icaps; - if (ss >9) - return L""; - - if( ss < All_Vector[1][pos].size()-1) { - - // ss 0,2,4... - if ( ss % 2 == 0) { - // aAAa 4$$4 - if ( is_Letter(pos, All_Vector) || is_Number(pos, All_Vector)) - icaps = ss+2-caps; - // ..:: ##'' - else - icaps = ss+1; - } - - // ss 1,3,5... - if ( ss % 2 == 1) { - // aAAa 4$$4 - if ( is_Letter(pos, All_Vector) || is_Number(pos, All_Vector)) - icaps = ss+caps; - // ..:: ##'' - else - icaps = ss+1; - } - - return std::wstring(1, (int) All_Vector[1][pos][icaps]); - } - return L""; } @@ -685,7 +647,12 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd // Linux cannot get a VK for Other Keyboard // it could return SC if that helps KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector, keymap); - if((key->VK() != 0) ) { + + // _S2 ToDo + // either it gives the correct rgkeys (all non-char filled with special char) or + // it gives not all rgkeys but nr, a-z are filled correctly + if((key->VK() != 0) && (key->VK()< 255)) { // if used without ScanCodeToUSVirtualKey[] + // if((key->VK() != 0) ) { keycountS++; rgKey[key->VK()] = key; } else { @@ -751,6 +718,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd SC_US= (KMX_DWORD)(8+ USVirtualKeyToScanCode[ SC_Other ]); else SC_US = 0; + //wprintf(L" for vk of %i we get Keycode US of %i SC_Other %i: ( on Key US (%i) we find char %i (%c) ) \n", SC_Other, 8+USVirtualKeyToScanCode[SC_Other], 8+USVirtualKeyToScanCode[SC_Other] , //8+USVirtualKeyToScanCode[SC_Other],get_VirtualKey_Other_GDK(*keymap, 8+USVirtualKeyToScanCode[SC_Other]),get_VirtualKey_Other_GDK(*keymap, 8+USVirtualKeyToScanCode[SC_Other]) ); @@ -763,10 +731,38 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd //std::wstring VK_Other3 = get_KeySyms_according_to_Shiftstate( *keymap, SC_Other, ss, caps); + //std::wstring VK_OtherTEST6 = get_KeySyms_according_to_Shiftstate( *keymap, 51, MenuCtrl, 0); + // std::wstring VK_OtherTEST16 = get_KeySyms_according_to_Shiftstate( *keymap, 51, MenuCtrl, 1); + + /*std::wstring VK_OtherTEST ; + std::wstring VK_OtherTEST0 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Base, 0); + std::wstring VK_OtherTEST1= get_KeySyms_according_to_Shiftstate( *keymap, 58, Shft, 0); + std::wstring VK_OtherTEST2 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Ctrl, 0); + std::wstring VK_OtherTEST3 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftCtrl, 0); + std::wstring VK_OtherTEST4 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Menu, 0); + std::wstring VK_OtherTEST5 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftMenu, 0); + std::wstring VK_OtherTEST7 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftMenuCtrl, 0); + std::wstring VK_OtherTEST8 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Xxxx, 0); + std::wstring VK_OtherTEST9 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftXxxx, 0); + std::wstring VK_OtherTEST10 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Base, 1); + std::wstring VK_OtherTEST11 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Shft, 1); + std::wstring VK_OtherTEST12 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Ctrl, 1); + std::wstring VK_OtherTEST13 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftCtrl, 1); + std::wstring VK_OtherTEST14 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Menu, 1); + std::wstring VK_OtherTEST15 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftMenu, 1); + std::wstring VK_OtherTEST17 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftMenuCtrl, 1); + std::wstring VK_OtherTEST18 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Xxxx, 1); + std::wstring VK_OtherTEST19 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftXxxx, 1); + */ + // _S2 needs to be changed - temporary to get the same keys as keyman does when using USVirtualKeyToScanCode + if (!IsKeymanUsedKey_S2(VK_Other)) + VK_Other =L"\0"; + //_S2 TODO do I need that ?? //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { if(VK_Other == L"") { - rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); + //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); + rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps)); } //_S2 TODO @@ -785,7 +781,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd //_S2 TODO // _S2 handle deadkeys later // if rc <0: it got a deadkey { - // fill m_rgss and m_rgfDeadkey + // fill m_rgss and m_rgfDeadkey and alDead //SET_SHIFTSTATES( deadkey) //sbuffer is value out of ToUnicodeEx / AllVector // do more stuff for deadkeys... // } from rc<0 @@ -838,12 +834,11 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd kp->cxGroupArray++; gp = &kp->dpGroupArray[kp->cxGroupArray-1]; - UINT nKeys = 0; for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { nKeys+= rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); - //wprintf(L" iKey = %i, Delta: %i \n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState())); + wprintf(L" iKey = %i, Delta: %i \n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState())); } } From e353f4e8d65e1d38f3aa77a272fdcb7b56d0754e Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 20 Nov 2023 21:28:44 +0100 Subject: [PATCH 128/327] feat(linux): mcompile remove -u option --- linux/mcompile/keymap/README.md | 1 + linux/mcompile/keymap/helpers.cpp | 30 +++++++++++++++++++++ linux/mcompile/keymap/keymap.cpp | 32 ----------------------- linux/mcompile/keymap/keymap.h | 2 -- linux/mcompile/keymap/mc_import_rules.cpp | 20 +++++++------- linux/mcompile/keymap/mcompile.cpp | 26 ++---------------- 6 files changed, 43 insertions(+), 68 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index 781f88de97..ac790701d3 100755 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -28,6 +28,7 @@ TODO where to store VK_CANCEL.... in km_types.h or elsewhere? ToDo check up to 8 shiftstates ( find symbols-file with 8) TODO get_position_From_VirtualKey_US: take care of the other shiftstates ToDo make this better!!! get_VirtualKey_Other_From_SC +ToDo use _free(keyvals); g_free(maps); TODO next: - change mapping (win-lin) for writing All_Vector diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 9564706549..3c66cf6309 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -1493,3 +1493,33 @@ std::wstring get_VirtualKey_Other_from_iKey(KMX_DWORD iKey, ShiftState &ss, int return L""; } + +// _S2 This can go later +/*KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector) { + + for( int i=0; i< (int)All_Vector[0].size();i++) { + //number keys return unshifted value ( e.g. 1, not !) + if(SC <= 19) { + if ( All_Vector[0][i][0] == SC) + return All_Vector[1][i][1]; + } + + // other keys + if((SC > 19) ) { + if ( All_Vector[0][i][0] == SC) { + + // normal capital characters return the value of capital char ( e.g. A) + if ((All_Vector[1][i][2] >= 65 ) && (All_Vector[1][i][2] < 91 )) + return All_Vector[1][i][2]; + + // special characters return Keyman defined values (e.g. VK_ACCENT) + else + //return All_Vector[1][i][1]; + return mapVK_To_char(SC); + } + } + } +return 0; +} +*/ + diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index c3370ca17e..dd9ba21fa7 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -326,8 +326,6 @@ KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state out =(KMX_DWORD) keyvals[shift_state_pos]; - // _S2 QUESTION - // _S2 what is 65104-65106, 65506, 21840 // _S2 if out of range of what ( ascii??) return 0 or other value ? if (out > 255) { wprintf(L"out of range: found value out( %i) for keycode = %i /shift_state_pos %i (49= TLDE 21= VK_EQUALS on US keyboard) \n", out,keycode,shift_state_pos); @@ -386,36 +384,6 @@ KMX_DWORD mapChar_To_VK(KMX_DWORD chr ){ // else return chr; } - -// _S2 This can go later -/*KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector) { - - for( int i=0; i< (int)All_Vector[0].size();i++) { - //number keys return unshifted value ( e.g. 1, not !) - if(SC <= 19) { - if ( All_Vector[0][i][0] == SC) - return All_Vector[1][i][1]; - } - - // other keys - if((SC > 19) ) { - if ( All_Vector[0][i][0] == SC) { - - // normal capital characters return the value of capital char ( e.g. A) - if ((All_Vector[1][i][2] >= 65 ) && (All_Vector[1][i][2] < 91 )) - return All_Vector[1][i][2]; - - // special characters return Keyman defined values (e.g. VK_ACCENT) - else - //return All_Vector[1][i][1]; - return mapVK_To_char(SC); - } - } - } -return 0; -} -*/ - KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { GdkModifierType consumed; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 6162a71437..59ab1314b3 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -496,8 +496,6 @@ int replace_PosKey_with_Keycode_use_Lin(std::string in); v_dw_2D create_empty_2D(int dim_rows, int dim_shifts); // query All_Vector -// return the VirtualKey of the Other Keyboard for given Scancode -//KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); // _S2 can go later return the VirtualKey of the US Keyboard for given Scancode KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); // _S2 can go later return the Scancode of for given VirtualKey of Other Keyboard diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 8645e03c99..4cf81d5716 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -594,12 +594,12 @@ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { bool IsKeymanUsedKey_S2(std::wstring SC_Other) { -int SC_US = (int) (*SC_Other.c_str()); + int SC_US = (int) (*SC_Other.c_str()); - if ((SC_US>= 0x20 && SC_US <= 0x7A) || (SC_US >= 0x88 && SC_US < 0xFF)) - return true; - else - return false; + if ((SC_US>= 0x20 && SC_US <= 0x7A) || (SC_US >= 0x88 && SC_US < 0xFF)) + return true; + else + return false; } @@ -743,18 +743,18 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd std::wstring VK_OtherTEST5 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftMenu, 0); std::wstring VK_OtherTEST7 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftMenuCtrl, 0); std::wstring VK_OtherTEST8 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Xxxx, 0); - std::wstring VK_OtherTEST9 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftXxxx, 0); + std::wstring VK_OtherTEST9 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftXxxx, 0); std::wstring VK_OtherTEST10 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Base, 1); std::wstring VK_OtherTEST11 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Shft, 1); std::wstring VK_OtherTEST12 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Ctrl, 1); - std::wstring VK_OtherTEST13 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftCtrl, 1); + std::wstring VK_OtherTEST13 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftCtrl, 1); std::wstring VK_OtherTEST14 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Menu, 1); std::wstring VK_OtherTEST15 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftMenu, 1); std::wstring VK_OtherTEST17 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftMenuCtrl, 1); - std::wstring VK_OtherTEST18 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Xxxx, 1); - std::wstring VK_OtherTEST19 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftXxxx, 1); + std::wstring VK_OtherTEST18 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Xxxx, 1); + std::wstring VK_OtherTEST19 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftXxxx, 1); */ - // _S2 needs to be changed - temporary to get the same keys as keyman does when using USVirtualKeyToScanCode + // _S2 needs to be changed - it's temporary to get the same keys as keyman does when using USVirtualKeyToScanCode if (!IsKeymanUsedKey_S2(VK_Other)) VK_Other =L"\0"; diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 8455c78feb..733f13f620 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -76,7 +76,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ if(argc < 3 || (argc < 5 && u16cmp(argv[1], u"-u") != 0)) { // I4273// I4273 wprintf( - L"Usage: mcompile -u infile.kmx outfile.kmx\n" + L"Usage: mcompile -u infile.kmx outfile.kmx\n (not available for Linux)" L" mcompile [-d] infile.kmx kbdfile.dll kbid outfile.kmx\n" L" With -u parameter, converts keyboard from ANSI to Unicode\n" L" Otherwise, mcompile converts a Keyman mnemonic layout to a\n" @@ -88,29 +88,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ return 1; } - // _S2 QUESTION -------u option will be done later. Do we need it?? ---------------------- - - /* if(wcscmp(argv[1], L"-u") == 0) { // I4273 - wchar_t *infile = argv[2], *outfile = argv[3]; - - LPKEYBOARD kmxfile; - - if(!LoadKeyboard(infile, &kmxfile)) { - LogError(L"Failed to load keyboard (%d)", GetLastError()); - // replaced by _S2 KMX_LogError(L"Failed to load keyboard (%d)\n", errno ); - return 3; - } - - if(ConvertKeyboardToUnicode(kmxfile)) { - SaveKeyboard(kmxfile, outfile); - } - - //DeleteReallocatedPointers(kmxfile); :TODO - delete[] kmxfile; - - return 0; // I4279 - }*/ - //----------------------------- + // -u option was removed for Linux int bDeadkeyConversion = u16cmp(argv[1], u"-d") == 0; // I4552 int n = (bDeadkeyConversion ? 2 : 1); From 621376525a0d0d05ef72f8bb922799e8ada13a8c Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 21 Nov 2023 15:58:07 +0100 Subject: [PATCH 129/327] feat(linux): mcompile use AltGr; tidy up --- linux/mcompile/keymap/helpers.cpp | 534 ++++++++++++++++------ linux/mcompile/keymap/helpers.h | 12 + linux/mcompile/keymap/keymap.cpp | 237 ++-------- linux/mcompile/keymap/keymap.h | 59 ++- linux/mcompile/keymap/mc_import_rules.cpp | 1 - 5 files changed, 484 insertions(+), 359 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 3c66cf6309..7503488343 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -304,6 +304,7 @@ bool write_RGKEY_FileToVector(v_dw_2D& shift_states, const char* infile) { fclose(fp); return(0); } + KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector) { for( int i=0; i< (int)All_Vector[0].size();i++) { @@ -330,6 +331,7 @@ KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector) { } return 0; } + bool test_In_Out(v_dw_3D All_Vector){ for ( int i=0; i<61;i++) @@ -399,8 +401,7 @@ KMX_DWORD get_position_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector) return 0; //_S2 what do I return if not found?? } -/* -// _S2 where to put this?? +/*// _S2 where to put this?? std::wstring get_VirtualKey_US_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &caps, v_dw_3D &All_Vector) { int icaps; @@ -425,7 +426,6 @@ std::wstring get_VirtualKey_US_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &c } */ - int replace_PosKey_with_Keycode(std::string in) { int out = returnIfCharInvalid; @@ -517,7 +517,6 @@ KMX_DWORD get_VirtualKey_Other_Layer2_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector // query All_Vector // return RETURN NON SHIFTED CHAR [1] the VirtualKey of the Other Keyboard for given Scancode - void GDK_Check(guint keyval){ gchar * gg = gdk_keyval_name (keyval); @@ -544,7 +543,6 @@ gdk_keyval_convert_case (GDK_KEY_4, lower,upper); gdk_keyval_convert_case (GDK_KEY_dollar, lower,upper);*/ } - static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) { GdkModifierType consumed; GdkKeymapKey *maps; @@ -645,7 +643,6 @@ KMX_DWORD writeKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_sta } } - // _S2 not needed later bool test(v_dw_3D &V) { std::string extra = " "; @@ -693,129 +690,6 @@ bool test_single(v_dw_3D &V) { } return 0; //_S2 what do I return if not found?? }*/// _S2 REMOVE - - -void Inspect_Key_S(GdkKeymap *keymap ) { - - guint KCode = 51; - guint Keyval_Base= 35; - guint Keyval_Shift = 39; - guint Keyval = Keyval_Base; - - gchar* KeyvalName_Base; - char* KeyvalName_ch_Base; - gchar* KeyvalName_Shift; - char* KeyvalName_ch_Shift; - - GdkKeymapKey* keys; - gint n_keys; - - GdkKeymapKey *maps; - guint *keyvals; - guint *keyvals_shift; - gint *n_entries; - gint count; - - GdkModifierType consumed; - // ___ ___ ___ ___ - // | A | | Ö | | & | | ' | - // Key |_a_| |_ö_| |_6_| |_#_| - // KeyCode 38 47 15 51 - // Keyval Base 97 246 54 35 - // Keyval Shift 65 214 38 39 - // KeyValname(Base) a odiaresis 6 apostrophe - // KeyValname(Shift) A Odiaresis ampersand numbersign - -//--------------------------------------- -gchar * gc= gdk_keyval_name (214); -gchar * gc0= gdk_keyval_name (65); -//--------------------------------------- -std::string sr = "odiaeresis"; -gchar * chr= (gchar*) sr.c_str(); ; -guint gi= gdk_keyval_from_name (chr); -//--------------------------------------- -Keyval= Keyval_Shift; - // finds ALL CHARACTERS ON KEY KCode for all levels and groups - // key 51 gr=0 (DE); lev=0 keyval 35(#) - // key 51 gr=0 (FR); lev=0 keyval 35(*) - // key 51 gr=0 (US); lev=0 keyval 35(\) - // key 51 gr=0 (ES); lev=0 keyval 35(\) - gdk_keymap_get_entries_for_keycode(keymap, KCode, &maps, &keyvals, &count); - wprintf(L"----------------------------\nprinting out the characters given by keypress of key SC/Keycode:%i\n",KCode); - for (int i = 0; i < count; i++) { - //if (maps[i].level > 0 || maps[i].group > 1) - // continue; - wprintf(L" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", - i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); - } - // finds all levels, groups WHERE KEYVAL IS LOCATED - // ' is on key 13, gr=0,lev=0 for swedish; - // ' is on key 51, gr=0,lev=1 for german; - // ' is on key 48, gr=2,lev=0 for english?; - // ' is on key 48, gr=3,lev=0 for spanish?; - //gdk_keymap_get_entries_for_keyval(keymap, Keyval,&keys,&n_keys); - gdk_keymap_get_entries_for_keyval(keymap, Keyval,&keys,&n_keys); - wprintf(L"----------------------------\nprinting out the characters given by keypress of Keyval :%i\n",Keyval); - for (int i = 0; i < n_keys; i++) { - //if (maps[i].level > 0 || maps[i].group > 1) - // continue; - wprintf(L" i=%d, Keyval=%d, (%c) keycode %i group %i level %i\n", - i, Keyval,Keyval, keys[i].keycode,keys[i].group,keys[i].level); - } -//--------------------------------------- - -gint Key_on_DE; -gint KeyVal_on_US; - Keyval = 214; - gdk_keymap_get_entries_for_keyval(keymap, Keyval,&keys,&n_keys); - wprintf(L"----------------------------\nprinting out the characters given by keypress of Keyval :%i\n",Keyval); - for (int i = 0; i < n_keys; i++) { - //if (maps[i].level > 0 || maps[i].group > 1) - // continue; - wprintf(L" i=%d, Keyval=%d, (%c) keycode %i group %i level %i\n", - i, Keyval,Keyval, keys[i].keycode,keys[i].group,keys[i].level); - } - for (int i = 0; i < n_keys; i++) { - if (keys[i].group ==0) - Key_on_DE = keys[i].keycode; - } - - gdk_keymap_get_entries_for_keycode(keymap, Key_on_DE, &maps, &keyvals, &count); - wprintf(L"----------------------------\nprinting out the characters given by keypress of key SC/Keycode:%i\n",Key_on_DE); - for (int i = 0; i < count; i++) { - //if (maps[i].level > 0 || maps[i].group > 1) - // continue; - wprintf(L" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", - i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); - } -for (int i = 0; i < count; i++) { - if ((maps[i].group ==2 )&& (maps[i].level ==0)) - KeyVal_on_US = maps[i].keycode; - } - -const UINT VK_US= ScanCodeToUSVirtualKey[KeyVal_on_US-8]; -const UINT VK_US2= USVirtualKeyToScanCode[KeyVal_on_US]; - -GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); -gdk_keymap_translate_keyboard_state (keymap, KCode, MOD_base , 0, keyvals, NULL, NULL, & consumed); -std::wstring rV1= std::wstring(1, (int) *keyvals); - - KeyvalName_Base = gdk_keyval_name (Keyval_Base); - KeyvalName_ch_Base = (char*) KeyvalName_Base; - std::string KeyvalName_str_Base(KeyvalName_ch_Base); - KeyvalName_Shift= gdk_keyval_name (Keyval_Shift); - KeyvalName_ch_Shift = (char*) KeyvalName_Shift; - std::string KeyvalName_str_Shift(KeyvalName_ch_Shift); - - - wprintf(L" keyval_Base %i has the name: %s ------ ", Keyval_Base, KeyvalName_str_Base.c_str()); - wprintf(L" keyval_Shift %i has the name: %s \n", Keyval_Shift, KeyvalName_str_Shift.c_str()); - //wprintf(L" keyval "); -int stop=99; - -} - - void Try_GDK(GdkKeymap *keymap, guint k ) { GdkKeymapKey *maps; guint *keyvals; @@ -965,9 +839,6 @@ wprintf(L"----------------------------\n"); } - - - std::wstring PrintKeymapForCodeReturnKeySym(GdkKeymap *keymap, guint VK, v_dw_3D &All_Vector, ShiftState ss, int caps ){ //GdkKeymap *keymap; GdkModifierType consumed; @@ -1107,9 +978,6 @@ bool write_rgKey_ToFile(std::vector rgKey ){ write_RGKEY_FileToVector(V_map, "map.txt"); CompareVector_To_VectorOfFile_RGKEY( V_win, V_lin,V_map);*/ - - - /* // _S2 maybe not needed bool get_US_Keysym_From_OtherKeysym(v_str_3D &All_Vector, int inOther, int &OutUS){ @@ -1132,7 +1000,6 @@ bool get_US_Keysym_From_OtherKeysym(v_str_3D &All_Vector, int inOther, int &OutU return true; }*/ - // _S2 maybe I will need that later?? /* static xkb_keysym_t get_ascii(struct xkb_state *state, xkb_keycode_t keycode) { @@ -1161,7 +1028,6 @@ bool get_US_Keysym_From_OtherKeysym(v_str_3D &All_Vector, int inOther, int &OutU } */ - /*static xkb_keysym_t get_ascii_SAB(xkb_keycode_t keycode) { xkb_layout_index_t num_layouts; @@ -1430,7 +1296,6 @@ wprintf(L" in Us %i and KeysymsUS %i : \n", inUS ,KeysymUS ); } */ - bool is_Letter(int pos, v_dw_3D & All_Vector){ if( ( All_Vector[1][pos][1] == All_Vector[1][pos][2] + 32) ) return true; @@ -1493,7 +1358,6 @@ std::wstring get_VirtualKey_Other_from_iKey(KMX_DWORD iKey, ShiftState &ss, int return L""; } - // _S2 This can go later /*KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector) { @@ -1522,4 +1386,396 @@ std::wstring get_VirtualKey_Other_from_iKey(KMX_DWORD iKey, ShiftState &ss, int return 0; } */ +// _S2 not needed, can go later +// return RETURN NON SHIFTED CHAR [1] the VirtualKey of the US Keyboard for given Scancode +KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ + // find correct row of char in US + for( int i=0; i< (int)All_Vector[0].size()-1;i++) { + if ( All_Vector[0][i][0] == SC ) { + return All_Vector[0][i][1] ; + } + } + return 0; //_S2 TODO what do I return if not found?? +} + +// return the Scancode of for given VirtualKey of Other Keyboard +KMX_DWORD get_SC_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector){ + // find correct row of char in US + for( int i=0; i< (int)All_Vector[1].size()-1;i++) { + if ( All_Vector[1][i][1] == VK_Other ) { + return All_Vector[1][i][0] ; + } + } + return 0; //_S2 TODO what do I return if not found?? +} + +// return the Scancode of for given VirtualKey of Other US +KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ + // find correct row of char in US + for( int i=0; i< (int)All_Vector[0].size()-1;i++) { + if ( All_Vector[0][i][2] == VK_US ) { + return All_Vector[0][i][0] ; + } + } + return 0; //_S2 TODO what do I return if not found?? +} + +// returns the position in All_Vector where VK_Other is found +KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector, int which_columns) { + // find correct row of char in US + if((which_columns <0 ) ) + return 0; + + // search all columns + if(which_columns >(int)All_Vector[1][0].size()) { + for( int i=1; i< (int)All_Vector[1][0].size();i++) { + for( int j=0; j< (int)All_Vector[1].size()-1;j++) { + if ( ( All_Vector[1][j][i] == VK_Other ) ) + return j; + } + } + } + + else { + for( int j=0; j< (int)All_Vector[1].size()-1;j++) { + if ( ( All_Vector[1][j][which_columns] == VK_Other ) ) + return j; + } + } + + return 0; //_S2 TODO what do I return if not found?? +} + +// returns KeyCode which hold the Keysym/Keyval (in unshifted, shifted) +KMX_DWORD get_KeyCode_From_KeyVal_GDK(GdkKeymap *keymap, UINT Keyval ) { + GdkKeymapKey *maps; + guint *keyvals; + gint count; + + for (int k=0; k<255 ; k++ ){ + if (gdk_keymap_get_entries_for_keycode (keymap, k, &maps, &keyvals, &count)) { + if ( (keyvals[0] == Keyval) || (keyvals[1] == Keyval) ) { + return (KMX_DWORD) maps[0].keycode; + } + } + } + + g_free(keyvals); + g_free(maps); + + return 0; //_S2 TODO what do I return if not found?? +} + +// returns KeyCode which holds the Keysym (in unshifted, shifted) +/*KMX_DWORD get_SC_From_Keycode_GDK(GdkKeymap *keymap, UINT SC ) { + GdkKeymapKey *maps; + guint *keyvals; + gint count; + + for (int k=0; k<255 ; k++ ){ + if (gdk_keymap_get_entries_for_keycode (keymap, k, &maps, &keyvals, &count)) { + if ( (keyvals[0] == SC) || (keyvals[1] == SC) ) { + return (KMX_DWORD) maps[0].keycode; + } + } + } + + g_free(keyvals); + g_free(maps); + return 0; //_S2 TODO what do I return if not found?? +}*/ + +KMX_DWORD mapVK_To_char(KMX_DWORD SC ){ + // if there is a Keyman VK.. defined map to Keyman VKcode + + // if ( SC == 49) return VK_BKSLASH; /* ; 220 = ` oder ^ */ + // if ( SC == 20) return VK_LBRKT; /* ; 219 = - oder ß */ + // if ( SC == 21) return VK_RBRKT; /* ; 221 = = oder ' */ + + // if ( SC == 34) return VK_COLON; /* ; 186 VK_OEM_4 = [ oder ü */ + //if ( SC == 35) return VK_EQUAL; /* ; 187 = ] oder + */ + + // if ( SC == 47) return VK_ACCENT; /* ; 192 VK_OEM_1 = : oder ö */ + // if ( SC == 48) return VK_QUOTE; /* ' 222 VK_OEM_7 = " oder Ä */ + // if ( SC == 51) return VK_SLASH; /* ; 191 = \ oder # */ + + // if ( SC == 59) return VK_COMMA; /* ; 188 = , oder , */ + // if ( SC == 60) return VK_PERIOD; /* ; 190 = . oder . */ + // if ( SC == 61) return VK_HYPHEN; /* ; 189 = / oder - */ + + // if ( SC == 65) return VK_SPACE; /* ; 32 VK_SPACE = oder */ + // else + return SC; +} +// _S2 TODO is this correct ?? +KMX_DWORD mapChar_To_VK(KMX_DWORD chr ){ + // if there is a Keyman VK.. defined map to Keyman VKcode + + // if ( SC == 49) return VK_BKSLASH; /* ; 220 = ` oder ^ */ + // if ( SC == 20) return VK_LBRKT; /* ; 219 = - oder ß */ + // if ( SC == 21) return VK_RBRKT; /* ; 221 = = oder ' */ + + // if ( chr == VK_COLON) return 220; /* ; 186 VK_OEM_4 = [ oder ü */ +// if ( chr == 187) return 42; /* ; 186 VK_OEM_4 = [ oder ü */ + // if ( SC == 35) return VK_EQUAL; /* ; 187 = ] oder + */ + + // if ( SC == 47) return VK_ACCENT; /* ; 192 VK_OEM_1 = : oder ö */ + // if ( SC == 48) return VK_QUOTE; /* ' 222 VK_OEM_7 = " oder Ä */ + // if ( SC == 51) return VK_SLASH; /* ; 191 = \ oder # */ + + // if ( SC == 59) return VK_COMMA; /* ; 188 = , oder , */ + // if ( SC == 60) return VK_PERIOD; /* ; 190 = . oder . */ + // if ( SC == 61) return VK_HYPHEN; /* ; 189 = / oder - */ + + // if ( SC == 65) return VK_SPACE; /* ; 32 VK_SPACE = oder */ + // else + return chr; +} + +void Inspect_Key_S2(GdkKeymap *keymap ) { + + guint KCode = 34; + guint Keyval_Base= 35; + guint Keyval_Shift = 39; + guint Keyval = Keyval_Base; + + gchar* KeyvalName_Base; + char* KeyvalName_ch_Base; + gchar* KeyvalName_Shift; + char* KeyvalName_ch_Shift; + + GdkKeymapKey* keys; + gint n_keys; + + GdkKeymapKey *maps; + guint *keyvals; + guint *keyvals_shift; + gint *n_entries; + gint count; + + GdkModifierType consumed; + // ___ ___ ___ ___ + // | A | | Ö | | & | | ' | + // Key |_a_| |_ö_| |_6_| |_#_| + // KeyCode 38 47 15 51 + // Keyval Base 97 246 54 35 + // Keyval Shift 65 214 38 39 + // KeyValname(Base) a odiaresis 6 apostrophe + // KeyValname(Shift) A Odiaresis ampersand numbersign + +//--------------------------------------- +gchar * gc= gdk_keyval_name (214); +gchar * gc0= gdk_keyval_name (65); +//--------------------------------------- +std::string sr = "odiaeresis"; +gchar * chr= (gchar*) sr.c_str(); ; +guint gi= gdk_keyval_from_name (chr); +//--------------------------------------- +Keyval= Keyval_Shift; + // finds ALL CHARACTERS ON KEY KCode for all levels and groups + // key 51 gr=0 (DE); lev=0 keyval 35(#) + // key 51 gr=0 (FR); lev=0 keyval 35(*) + // key 51 gr=0 (US); lev=0 keyval 35(\) + // key 51 gr=0 (ES); lev=0 keyval 35(\) + gdk_keymap_get_entries_for_keycode(keymap, KCode, &maps, &keyvals, &count); + wprintf(L"----------------------------\nprinting out the characters given by keypress of key SC/Keycode:%i\n",KCode); + for (int i = 0; i < count; i++) { + //if (maps[i].level > 0 || maps[i].group > 1) + // continue; + wprintf(L" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", + i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); + } + // finds all levels, groups WHERE KEYVAL IS LOCATED + // ' is on key 13, gr=0,lev=0 for swedish; + // ' is on key 51, gr=0,lev=1 for german; + // ' is on key 48, gr=2,lev=0 for english?; + // ' is on key 48, gr=3,lev=0 for spanish?; + //gdk_keymap_get_entries_for_keyval(keymap, Keyval,&keys,&n_keys); + gdk_keymap_get_entries_for_keyval(keymap, Keyval,&keys,&n_keys); + wprintf(L"----------------------------\nprinting out the characters given by keypress of Keyval :%i\n",Keyval); + for (int i = 0; i < n_keys; i++) { + //if (maps[i].level > 0 || maps[i].group > 1) + // continue; + wprintf(L" i=%d, Keyval=%d, (%c) keycode %i group %i level %i\n", + i, Keyval,Keyval, keys[i].keycode,keys[i].group,keys[i].level); + } +//--------------------------------------- + +gint Key_on_DE; +gint KeyVal_on_US; + Keyval = 214; + gdk_keymap_get_entries_for_keyval(keymap, Keyval,&keys,&n_keys); + wprintf(L"----------------------------\nprinting out the characters given by keypress of Keyval :%i\n",Keyval); + for (int i = 0; i < n_keys; i++) { + //if (maps[i].level > 0 || maps[i].group > 1) + // continue; + wprintf(L" i=%d, Keyval=%d, (%c) keycode %i group %i level %i\n", + i, Keyval,Keyval, keys[i].keycode,keys[i].group,keys[i].level); + } + for (int i = 0; i < n_keys; i++) { + if (keys[i].group ==0) + Key_on_DE = keys[i].keycode; + } + + g_free(keyvals); + g_free(maps); + + gdk_keymap_get_entries_for_keycode(keymap, Key_on_DE, &maps, &keyvals, &count); + wprintf(L"----------------------------\nprinting out the characters given by keypress of key SC/Keycode:%i\n",Key_on_DE); + for (int i = 0; i < count; i++) { + //if (maps[i].level > 0 || maps[i].group > 1) + // continue; + wprintf(L" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", + i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); + } +for (int i = 0; i < count; i++) { + if ((maps[i].group ==2 )&& (maps[i].level ==0)) + KeyVal_on_US = maps[i].keycode; + } + +const UINT VK_US= ScanCodeToUSVirtualKey[KeyVal_on_US-8]; +const UINT VK_US2= USVirtualKeyToScanCode[KeyVal_on_US]; + +GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); +gdk_keymap_translate_keyboard_state (keymap, KCode, MOD_base , 0, keyvals, NULL, NULL, & consumed); +std::wstring rV1= std::wstring(1, (int) *keyvals); + + KeyvalName_Base = gdk_keyval_name (Keyval_Base); + KeyvalName_ch_Base = (char*) KeyvalName_Base; + std::string KeyvalName_str_Base(KeyvalName_ch_Base); + KeyvalName_Shift= gdk_keyval_name (Keyval_Shift); + KeyvalName_ch_Shift = (char*) KeyvalName_Shift; + std::string KeyvalName_str_Shift(KeyvalName_ch_Shift); + + + wprintf(L" keyval_Base %i has the name: %s ------ ", Keyval_Base, KeyvalName_str_Base.c_str()); + wprintf(L" keyval_Shift %i has the name: %s \n", Keyval_Shift, KeyvalName_str_Shift.c_str()); + //wprintf(L" keyval "); +int stop=99; + + g_free(keyvals); + g_free(maps); + +} + +void Inspect_Key_S(GdkKeymap *keymap ) { + + guint KCode = 51; + guint Keyval_Base= 35; + guint Keyval_Shift = 39; + guint Keyval = Keyval_Base; + + gchar* KeyvalName_Base; + char* KeyvalName_ch_Base; + gchar* KeyvalName_Shift; + char* KeyvalName_ch_Shift; + + GdkKeymapKey* keys; + gint n_keys; + + GdkKeymapKey *maps; + guint *keyvals; + guint *keyvals_shift; + gint *n_entries; + gint count; + + GdkModifierType consumed; + // ___ ___ ___ ___ + // | A | | Ö | | & | | ' | + // Key |_a_| |_ö_| |_6_| |_#_| + // KeyCode 38 47 15 51 + // Keyval Base 97 246 54 35 + // Keyval Shift 65 214 38 39 + // KeyValname(Base) a odiaresis 6 apostrophe + // KeyValname(Shift) A Odiaresis ampersand numbersign + +//--------------------------------------- +gchar * gc= gdk_keyval_name (214); +gchar * gc0= gdk_keyval_name (65); +//--------------------------------------- +std::string sr = "odiaeresis"; +gchar * chr= (gchar*) sr.c_str(); ; +guint gi= gdk_keyval_from_name (chr); +//--------------------------------------- +Keyval= Keyval_Shift; + // finds ALL CHARACTERS ON KEY KCode for all levels and groups + // key 51 gr=0 (DE); lev=0 keyval 35(#) + // key 51 gr=0 (FR); lev=0 keyval 35(*) + // key 51 gr=0 (US); lev=0 keyval 35(\) + // key 51 gr=0 (ES); lev=0 keyval 35(\) + gdk_keymap_get_entries_for_keycode(keymap, KCode, &maps, &keyvals, &count); + wprintf(L"----------------------------\nprinting out the characters given by keypress of key SC/Keycode:%i\n",KCode); + for (int i = 0; i < count; i++) { + //if (maps[i].level > 0 || maps[i].group > 1) + // continue; + wprintf(L" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", + i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); + } + // finds all levels, groups WHERE KEYVAL IS LOCATED + // ' is on key 13, gr=0,lev=0 for swedish; + // ' is on key 51, gr=0,lev=1 for german; + // ' is on key 48, gr=2,lev=0 for english?; + // ' is on key 48, gr=3,lev=0 for spanish?; + //gdk_keymap_get_entries_for_keyval(keymap, Keyval,&keys,&n_keys); + gdk_keymap_get_entries_for_keyval(keymap, Keyval,&keys,&n_keys); + wprintf(L"----------------------------\nprinting out the characters given by keypress of Keyval :%i\n",Keyval); + for (int i = 0; i < n_keys; i++) { + //if (maps[i].level > 0 || maps[i].group > 1) + // continue; + wprintf(L" i=%d, Keyval=%d, (%c) keycode %i group %i level %i\n", + i, Keyval,Keyval, keys[i].keycode,keys[i].group,keys[i].level); + } +//--------------------------------------- + +gint Key_on_DE; +gint KeyVal_on_US; + Keyval = 214; + gdk_keymap_get_entries_for_keyval(keymap, Keyval,&keys,&n_keys); + wprintf(L"----------------------------\nprinting out the characters given by keypress of Keyval :%i\n",Keyval); + for (int i = 0; i < n_keys; i++) { + //if (maps[i].level > 0 || maps[i].group > 1) + // continue; + wprintf(L" i=%d, Keyval=%d, (%c) keycode %i group %i level %i\n", + i, Keyval,Keyval, keys[i].keycode,keys[i].group,keys[i].level); + } + for (int i = 0; i < n_keys; i++) { + if (keys[i].group ==0) + Key_on_DE = keys[i].keycode; + } + + gdk_keymap_get_entries_for_keycode(keymap, Key_on_DE, &maps, &keyvals, &count); + wprintf(L"----------------------------\nprinting out the characters given by keypress of key SC/Keycode:%i\n",Key_on_DE); + for (int i = 0; i < count; i++) { + //if (maps[i].level > 0 || maps[i].group > 1) + // continue; + wprintf(L" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", + i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); + } +for (int i = 0; i < count; i++) { + if ((maps[i].group ==2 )&& (maps[i].level ==0)) + KeyVal_on_US = maps[i].keycode; + } + +const UINT VK_US= ScanCodeToUSVirtualKey[KeyVal_on_US-8]; +const UINT VK_US2= USVirtualKeyToScanCode[KeyVal_on_US]; + +GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); +gdk_keymap_translate_keyboard_state (keymap, KCode, MOD_base , 0, keyvals, NULL, NULL, & consumed); +std::wstring rV1= std::wstring(1, (int) *keyvals); + + KeyvalName_Base = gdk_keyval_name (Keyval_Base); + KeyvalName_ch_Base = (char*) KeyvalName_Base; + std::string KeyvalName_str_Base(KeyvalName_ch_Base); + KeyvalName_Shift= gdk_keyval_name (Keyval_Shift); + KeyvalName_ch_Shift = (char*) KeyvalName_Shift; + std::string KeyvalName_str_Shift(KeyvalName_ch_Shift); + + + wprintf(L" keyval_Base %i has the name: %s ------ ", Keyval_Base, KeyvalName_str_Base.c_str()); + wprintf(L" keyval_Shift %i has the name: %s \n", Keyval_Shift, KeyvalName_str_Shift.c_str()); + //wprintf(L" keyval "); +int stop=99; + +} + diff --git a/linux/mcompile/keymap/helpers.h b/linux/mcompile/keymap/helpers.h index aefa2c3e3b..07a28ea05e 100755 --- a/linux/mcompile/keymap/helpers.h +++ b/linux/mcompile/keymap/helpers.h @@ -40,5 +40,17 @@ KMX_DWORD get_position_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector) int replace_PosKey_with_Keycode(std::string in); +// query All_Vector +// _S2 can go later return the VirtualKey of the US Keyboard for given Scancode +KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); +// _S2 can go later return the Scancode of for given VirtualKey of Other Keyboard +KMX_DWORD get_SC_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector); +// _S2 can go later return the Scancode of for given VirtualKey of US +KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector); +// _S2 can go later return the Scancode of for given VirtualKey of Other +KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_US , v_dw_3D &All_Vector); +// _S2 can go later return the Scancode of for given VirtualKey of Other in specific column. If column > available columns look in all columns; +KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector, int which_columns); + //std::wstring get_VirtualKey_US_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &caps, v_dw_3D &All_Vector); #endif /* HELPERS_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index dd9ba21fa7..2a38c472dc 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -338,52 +338,6 @@ KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state return out; } -KMX_DWORD mapVK_To_char(KMX_DWORD SC ){ - // if there is a Keyman VK.. defined map to Keyman VKcode - - // if ( SC == 49) return VK_BKSLASH; /* ; 220 = ` oder ^ */ - // if ( SC == 20) return VK_LBRKT; /* ; 219 = - oder ß */ - // if ( SC == 21) return VK_RBRKT; /* ; 221 = = oder ' */ - - // if ( SC == 34) return VK_COLON; /* ; 186 VK_OEM_4 = [ oder ü */ - //if ( SC == 35) return VK_EQUAL; /* ; 187 = ] oder + */ - - // if ( SC == 47) return VK_ACCENT; /* ; 192 VK_OEM_1 = : oder ö */ - // if ( SC == 48) return VK_QUOTE; /* ' 222 VK_OEM_7 = " oder Ä */ - // if ( SC == 51) return VK_SLASH; /* ; 191 = \ oder # */ - - // if ( SC == 59) return VK_COMMA; /* ; 188 = , oder , */ - // if ( SC == 60) return VK_PERIOD; /* ; 190 = . oder . */ - // if ( SC == 61) return VK_HYPHEN; /* ; 189 = / oder - */ - - // if ( SC == 65) return VK_SPACE; /* ; 32 VK_SPACE = oder */ - // else - return SC; -} -// _S2 TODO is this correct ?? -KMX_DWORD mapChar_To_VK(KMX_DWORD chr ){ - // if there is a Keyman VK.. defined map to Keyman VKcode - - // if ( SC == 49) return VK_BKSLASH; /* ; 220 = ` oder ^ */ - // if ( SC == 20) return VK_LBRKT; /* ; 219 = - oder ß */ - // if ( SC == 21) return VK_RBRKT; /* ; 221 = = oder ' */ - - // if ( chr == VK_COLON) return 220; /* ; 186 VK_OEM_4 = [ oder ü */ -// if ( chr == 187) return 42; /* ; 186 VK_OEM_4 = [ oder ü */ - // if ( SC == 35) return VK_EQUAL; /* ; 187 = ] oder + */ - - // if ( SC == 47) return VK_ACCENT; /* ; 192 VK_OEM_1 = : oder ö */ - // if ( SC == 48) return VK_QUOTE; /* ' 222 VK_OEM_7 = " oder Ä */ - // if ( SC == 51) return VK_SLASH; /* ; 191 = \ oder # */ - - // if ( SC == 59) return VK_COMMA; /* ; 188 = , oder , */ - // if ( SC == 60) return VK_PERIOD; /* ; 190 = . oder . */ - // if ( SC == 61) return VK_HYPHEN; /* ; 189 = / oder - */ - - // if ( SC == 65) return VK_SPACE; /* ; 32 VK_SPACE = oder */ - // else - return chr; -} KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { GdkModifierType consumed; @@ -429,97 +383,6 @@ KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { return 0; //_S2 what to return if not found } -// _S2 not needed, can go later -// return RETURN NON SHIFTED CHAR [1] the VirtualKey of the US Keyboard for given Scancode -KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ - // find correct row of char in US - for( int i=0; i< (int)All_Vector[0].size()-1;i++) { - if ( All_Vector[0][i][0] == SC ) { - return All_Vector[0][i][1] ; - } - } - return 0; //_S2 TODO what do I return if not found?? -} - -// return the Scancode of for given VirtualKey of Other Keyboard -KMX_DWORD get_SC_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector){ - // find correct row of char in US - for( int i=0; i< (int)All_Vector[1].size()-1;i++) { - if ( All_Vector[1][i][1] == VK_Other ) { - return All_Vector[1][i][0] ; - } - } - return 0; //_S2 TODO what do I return if not found?? -} - -// return the Scancode of for given VirtualKey of Other US -KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ - // find correct row of char in US - for( int i=0; i< (int)All_Vector[0].size()-1;i++) { - if ( All_Vector[0][i][2] == VK_US ) { - return All_Vector[0][i][0] ; - } - } - return 0; //_S2 TODO what do I return if not found?? -} - -// returns the position in All_Vector where VK_Other is found -KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector, int which_columns) { - // find correct row of char in US - if((which_columns <0 ) ) - return 0; - - // search all columns - if(which_columns >(int)All_Vector[1][0].size()) { - for( int i=1; i< (int)All_Vector[1][0].size();i++) { - for( int j=0; j< (int)All_Vector[1].size()-1;j++) { - if ( ( All_Vector[1][j][i] == VK_Other ) ) - return j; - } - } - } - - else { - for( int j=0; j< (int)All_Vector[1].size()-1;j++) { - if ( ( All_Vector[1][j][which_columns] == VK_Other ) ) - return j; - } - } - - return 0; //_S2 TODO what do I return if not found?? -} - -// returns KeyCode which hold the Keysym/Keyval (in unshifted, shifted) -KMX_DWORD get_KeyCode_From_KeyVal_GDK(GdkKeymap *keymap, UINT Keyval ) { - GdkKeymapKey *maps; - guint *keyvals; - gint count; - - for (int k=0; k<255 ; k++ ){ - if (gdk_keymap_get_entries_for_keycode (keymap, k, &maps, &keyvals, &count)) { - if ( (keyvals[0] == Keyval) || (keyvals[1] == Keyval) ) { - return (KMX_DWORD) maps[0].keycode; - } - } - } - return 0; //_S2 TODO what do I return if not found?? -} -// returns KeyCode which holds the Keysym (in unshifted, shifted) -/*KMX_DWORD get_SC_From_Keycode_GDK(GdkKeymap *keymap, UINT SC ) { - GdkKeymapKey *maps; - guint *keyvals; - gint count; - - for (int k=0; k<255 ; k++ ){ - if (gdk_keymap_get_entries_for_keycode (keymap, k, &maps, &keyvals, &count)) { - if ( (keyvals[0] == SC) || (keyvals[1] == SC) ) { - return (KMX_DWORD) maps[0].keycode; - } - } - } - return 0; //_S2 TODO what do I return if not found?? -}*/ - // _S2 TODO How to do mapping between Linux keycodes and keyman SC const int Lin_KM__map(int i, v_dw_3D &All_Vector) { // MAP: @@ -555,56 +418,6 @@ const int Lin_KM__map(int i, v_dw_3D &All_Vector) { return i; } -// _S2 TODO -std::wstring get_KeyVals_according_to_Shiftstate(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ - - GdkModifierType consumed; - GdkKeymapKey *maps; - guint *keyvals; - gint count; - - // _S2 TODO what to return if it fails? - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return L"1"; - - //unshifted - if (( ss == Base ) && ( caps == 0 )) { - GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); - } - - //SHIFT+CAPS - else if ( ( ss == Shft ) && ( caps ==1 )) { - GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); - } - - //Shift - else if (( ss == Shft ) && ( caps == 0 )) { - return std::wstring(1, (int) get_VirtualKey_Other_GDK(keymap, keycode)); - } - - //caps - else if (( ss == Base ) && ( caps == 1 )) { - GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); - } - - /*//ALT-GR - else if { - GdkModifierType MOD_AltGr = (GdkModifierType) ( GDK_MOD5_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - return *keyvals; - }*/ - - else - return L"0"; -} - - std::wstring get_KeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ GdkModifierType consumed; @@ -665,6 +478,56 @@ std::wstring get_KeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint keyco //return L"0"; } +// _S2 TODO +/*std::wstring get_KeyVals_according_to_Shiftstate(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ + + GdkModifierType consumed; + GdkKeymapKey *maps; + guint *keyvals; + gint count; + + // _S2 TODO what to return if it fails? + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return L"1"; + + //unshifted + if (( ss == Base ) && ( caps == 0 )) { + GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + } + + //SHIFT+CAPS + else if ( ( ss == Shft ) && ( caps ==1 )) { + GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + } + + //Shift + else if (( ss == Shft ) && ( caps == 0 )) { + return std::wstring(1, (int) get_VirtualKey_Other_GDK(keymap, keycode)); + } + + //caps + else if (( ss == Base ) && ( caps == 1 )) { + GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + } + + //ALT-GR + //else if { + // GdkModifierType MOD_AltGr = (GdkModifierType) ( GDK_MOD5_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + return *keyvals; + } + + else + return L"0"; +} +*/ + // _S2 maybe not needed UINT find_SC_Other_from_SC_US_GDK(UINT SC_US,GdkKeymap *keymap) { UINT SC__Other; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 59ab1314b3..1ecc627823 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -38,8 +38,7 @@ enum ShiftState { ShftXxxx = Shft | Xxxx, // 9 }; -const UINT USVirtualKeyToScanCode[256] = -{ +const UINT USVirtualKeyToScanCode[256] = { 0x00, // L"K_?00", // &H0 0x00, // L"K_LBUTTON", // &H1 0x00, // L"K_RBUTTON", // &H2 @@ -438,7 +437,6 @@ const UINT ScanCodeToUSVirtualKey[128] = { 0x00 // 0x7f => No match }; - // Map of all US English virtual key codes that we can translate const KMX_DWORD KMX_VKMap[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', @@ -477,9 +475,9 @@ static KMX_DWORD returnIfCharInvalid = 0; // takes a std::wstring (=contents of line symbols-file ) and returns the (int) value of the character KMX_DWORD convertNamesToValue(std::wstring tok_wstr); -// create a Vector with all entries of Vector+ keymap -int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector); +// create a Vector with all entries of Vector +int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector); // read configuration file, split and write to 3D-Vector (Data for US on [0][ ][ ] ) int write_US_ToVector(v_dw_3D &vec, std::string language, const char *text); @@ -495,47 +493,44 @@ int replace_PosKey_with_Keycode_use_Lin(std::string in); // create an empty 2D vector containing "--" in all fields v_dw_2D create_empty_2D(int dim_rows, int dim_shifts); -// query All_Vector -// _S2 can go later return the VirtualKey of the US Keyboard for given Scancode -KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); -// _S2 can go later return the Scancode of for given VirtualKey of Other Keyboard -KMX_DWORD get_SC_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector); -// _S2 can go later return the Scancode of for given VirtualKey of US -KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector); -// _S2 can go later return the Scancode of for given VirtualKey of Other -//KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_US , v_dw_3D &All_Vector); -// _S2 can go later return the Scancode of for given VirtualKey of Other in specific column. If column > available columns look in all columns; -KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector, int which_columns); - // return the Scancode of for given VirtualKey using GDK KMX_DWORD get_KeyCode_From_KeyVal_GDK(GdkKeymap *keymap, UINT mapped_ikey); -// can go later -void Try_GDK(GdkKeymap *keymap, UINT KeySym ); -void Inspect_Key_S(GdkKeymap *keymap ) ; + // return the VirtualKey of the Other Keyboard for given Scancode using GDK KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD scanCode); -UINT find_SC_Other_from_SC_US_GDK(UINT vk_US_187,GdkKeymap *keymap); + // initialize GDK bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); -// create a Vector with all entries of both keymaps -int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap); - +//_S2 needed? // append characters using GDK to 3D-Vector (Data for Other Language on [1][ ][ ] ) int append_other_ToVector(v_dw_3D &All_Vector, GdkKeymap *keymap); // find Keyvals to fill into 2D-Vector of Other Language KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos); -// _S2 TODO How to do mapping between Linux keycodes and keyman SC -const int Lin_KM__map(int i, v_dw_3D &All_Vector); -KMX_DWORD map_To_VK(KMX_DWORD SC); -KMX_DWORD mapChar_To_VK(KMX_DWORD chr ); -KMX_DWORD mapVK_To_char(KMX_DWORD SC ); - -// returns Keyvals fo ra given key (for unshifted: finds the Name of the Key e.g. A or 1 ) -std::wstring get_KeyVals_according_to_Shiftstate(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); // returns KeySyms fo ra given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) std::wstring get_KeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); + +// _S2 needed? +// can go later +void Try_GDK(GdkKeymap *keymap, UINT KeySym ); +void Inspect_Key_S(GdkKeymap *keymap ) ; +UINT find_SC_Other_from_SC_US_GDK(UINT vk_US_187,GdkKeymap *keymap); +// _S2 needed? +// create a Vector with all entries of both keymaps+ keymap +int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap); + +//needed? +// returns Keyvals fo ra given key (for unshifted: finds the Name of the Key e.g. A or 1 ) +std::wstring get_KeyVals_according_to_Shiftstate(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); + +// _S2 TODO How to do mapping between Linux keycodes and keyman SC +const int Lin_KM__map(int i, v_dw_3D &All_Vector); + +KMX_DWORD mapChar_To_VK(KMX_DWORD chr ); + +KMX_DWORD mapVK_To_char(KMX_DWORD SC ); + # endif /*KEYMAP_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 4cf81d5716..d12b3abb0a 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -603,7 +603,6 @@ bool IsKeymanUsedKey_S2(std::wstring SC_Other) { } - bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 KMX_Loader loader; const size_t BUF_sz= 256; From 80f7374fb1067edf0b59b0a4e4dfb39fd66486d3 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 21 Nov 2023 16:40:36 +0100 Subject: [PATCH 130/327] feat(linux): mcompile rename functions --- linux/mcompile/keymap/helpers.cpp | 59 +++++++++++++++-- linux/mcompile/keymap/helpers.h | 5 +- linux/mcompile/keymap/keymap.cpp | 80 ++++++----------------- linux/mcompile/keymap/keymap.h | 19 +++--- linux/mcompile/keymap/mc_import_rules.cpp | 48 +++++++------- 5 files changed, 113 insertions(+), 98 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 7503488343..0519147233 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -621,8 +621,8 @@ bool InsertKeyvalsFromKeymap(v_dw_3D &All_Vector,GdkKeymap * keymap){ All_Vector[1][i][0] = All_Vector[0][i][0]; // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] - All_Vector[1][i][0+1] = getKeyvalsFromKeymap(keymap,(All_Vector[1][i][0]),0); //shift state: unshifted:0 - All_Vector[1][i][1+1] = getKeyvalsFromKeymap(keymap,(All_Vector[1][i][0]),1); //shift state: shifted:1 + All_Vector[1][i][0+1] = getKeyvalsFromKeyCode(keymap,(All_Vector[1][i][0]),0); //shift state: unshifted:0 + All_Vector[1][i][1+1] = getKeyvalsFromKeyCode(keymap,(All_Vector[1][i][0]),1); //shift state: shifted:1 //wprintf(L" Keycodes US dw : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); //wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); @@ -637,8 +637,8 @@ KMX_DWORD writeKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_sta KMX_DWORD out; for ( int ii =1; ii< 255;ii++) { - KMX_DWORD out = getKeyvalsFromKeymap(keymap,ii,0); - KMX_DWORD out2= getKeyvalsFromKeymap(keymap,ii,1); + KMX_DWORD out = getKeyvalsFromKeyCode(keymap,ii,0); + KMX_DWORD out2= getKeyvalsFromKeyCode(keymap,ii,1); wprintf(L" ii = %i --> keymap = %i (%c)..%i(%c) \n",ii, out,out, out2,out2); } } @@ -1779,3 +1779,54 @@ int stop=99; } +// _S2 TODO +/*std::wstring get_KeyVals_according_to_Shiftstate(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ + + GdkModifierType consumed; + GdkKeymapKey *maps; + guint *keyvals; + gint count; + + // _S2 TODO what to return if it fails? + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return L"1"; + + //unshifted + if (( ss == Base ) && ( caps == 0 )) { + GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + } + + //SHIFT+CAPS + else if ( ( ss == Shft ) && ( caps ==1 )) { + GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + } + + //Shift + else if (( ss == Shft ) && ( caps == 0 )) { + return std::wstring(1, (int) get_VirtualKey_Other_GDK(keymap, keycode)); + } + + //caps + else if (( ss == Base ) && ( caps == 1 )) { + GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + } + + //ALT-GR + //else if { + // GdkModifierType MOD_AltGr = (GdkModifierType) ( GDK_MOD5_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + return *keyvals; + } + + else + return L"0"; +} +*/ + + diff --git a/linux/mcompile/keymap/helpers.h b/linux/mcompile/keymap/helpers.h index 07a28ea05e..25012176a1 100755 --- a/linux/mcompile/keymap/helpers.h +++ b/linux/mcompile/keymap/helpers.h @@ -51,6 +51,9 @@ KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector); KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_US , v_dw_3D &All_Vector); // _S2 can go later return the Scancode of for given VirtualKey of Other in specific column. If column > available columns look in all columns; KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector, int which_columns); - +/* +// returns Keyvals fo ra given key (for unshifted: finds the Name of the Key e.g. A or 1 ) +std::wstring get_KeyVals_according_to_Shiftstate(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); +*/ //std::wstring get_VirtualKey_US_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &caps, v_dw_3D &All_Vector); #endif /* HELPERS_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 2a38c472dc..fddb1d5dbc 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -75,7 +75,7 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, return 0; } -KMX_DWORD convertNamesToValue(std::wstring tok_wstr){ +KMX_DWORD convertNamesToASCIIValue(std::wstring tok_wstr){ std::map first; first[L"exclam"] = 33; @@ -163,7 +163,7 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { for (std::string each; std::getline(split1, each, split_bracel); tokens.push_back(each)); // replace keys names with Keycode ( with 21,...) - Keycde = replace_PosKey_with_Keycode_use_Lin(tokens[0]); + Keycde = replace_KeyName_with_Keycode(tokens[0]); tokens[0] = std::to_string(Keycde); // seperate rest of the vector to its elements and push to 'tokens' @@ -178,7 +178,7 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { for ( int i = 1; i< (int) tokens.size();i++) { // replace a name with a single character ( a -> a ; equal -> = ) - tokens_int = convertNamesToValue( wstring_from_string(tokens[i])); + tokens_int = convertNamesToASCIIValue( wstring_from_string(tokens[i])); tokens_dw.push_back(tokens_int); } @@ -199,7 +199,7 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { return 0; } -int replace_PosKey_with_Keycode_use_Lin(std::string in) { +int replace_KeyName_with_Keycode(std::string in) { int out = returnIfCharInvalid; // _S2 these are the Scancode-Values we use in Keyman ( = like the windows scancodes) @@ -262,7 +262,7 @@ int replace_PosKey_with_Keycode_use_Lin(std::string in) { return out; } -v_dw_2D create_empty_2D( int dim_rows,int dim_shifts) { +v_dw_2D create_empty_2D_Vector( int dim_rows,int dim_shifts) { v_dw_1D shifts; v_dw_2D Vector_2D; @@ -280,7 +280,7 @@ v_dw_2D create_empty_2D( int dim_rows,int dim_shifts) { int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { // create a 2D vector all filled with " " and push to 3D-Vector - v_dw_2D Other_Vector2D = create_empty_2D(All_Vector[0].size(),All_Vector[0][0].size()); + v_dw_2D Other_Vector2D = create_empty_2D_Vector(All_Vector[0].size(),All_Vector[0][0].size()); if (Other_Vector2D.size() == 0) { wprintf(L"ERROR: can't create empty 2D-Vector\n"); @@ -301,8 +301,8 @@ int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { All_Vector[1][i][0] = All_Vector[0][i][0]; // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] - All_Vector[1][i][0+1] = getKeyvalsFromKeymap(keymap,All_Vector[0][i][0],0); //shift state: unshifted:0 - All_Vector[1][i][1+1] = getKeyvalsFromKeymap(keymap,All_Vector[0][i][0],1); //shift state: shifted:1 + All_Vector[1][i][0+1] = getKeyvalsFromKeyCode(keymap,All_Vector[0][i][0],0); //shift state: unshifted:0 + All_Vector[1][i][1+1] = getKeyvalsFromKeyCode(keymap,All_Vector[0][i][0],1); //shift state: shifted:1 //wprintf(L" Keycodes US dw : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); //wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); @@ -310,7 +310,8 @@ int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { return 0; } -KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { +// _S2 can I use gdk_keymap_translate_keyboard_state instead? +KMX_DWORD getKeyvalsFromKeyCode(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; guint *keyvals; gint count; @@ -338,6 +339,7 @@ KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state return out; } +// _S2 do we need that? KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { GdkModifierType consumed; @@ -383,6 +385,14 @@ KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { return 0; //_S2 what to return if not found } +KMX_DWORD get_VirtualKey_US( KMX_DWORD keycode) { + + if ( keycode >7) + return (KMX_DWORD) ScanCodeToUSVirtualKey[keycode-8]; + + return 0; //_S2 what to return if not found +} + // _S2 TODO How to do mapping between Linux keycodes and keyman SC const int Lin_KM__map(int i, v_dw_3D &All_Vector) { // MAP: @@ -418,7 +428,7 @@ const int Lin_KM__map(int i, v_dw_3D &All_Vector) { return i; } -std::wstring get_KeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ +std::wstring get_KeyVals_according_to_keycode_and_Shiftstate(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ GdkModifierType consumed; GdkKeymapKey *maps; @@ -478,56 +488,6 @@ std::wstring get_KeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint keyco //return L"0"; } -// _S2 TODO -/*std::wstring get_KeyVals_according_to_Shiftstate(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ - - GdkModifierType consumed; - GdkKeymapKey *maps; - guint *keyvals; - gint count; - - // _S2 TODO what to return if it fails? - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return L"1"; - - //unshifted - if (( ss == Base ) && ( caps == 0 )) { - GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); - } - - //SHIFT+CAPS - else if ( ( ss == Shft ) && ( caps ==1 )) { - GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); - } - - //Shift - else if (( ss == Shft ) && ( caps == 0 )) { - return std::wstring(1, (int) get_VirtualKey_Other_GDK(keymap, keycode)); - } - - //caps - else if (( ss == Base ) && ( caps == 1 )) { - GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); - } - - //ALT-GR - //else if { - // GdkModifierType MOD_AltGr = (GdkModifierType) ( GDK_MOD5_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - return *keyvals; - } - - else - return L"0"; -} -*/ - // _S2 maybe not needed UINT find_SC_Other_from_SC_US_GDK(UINT SC_US,GdkKeymap *keymap) { UINT SC__Other; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 1ecc627823..962eef368f 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -473,11 +473,11 @@ const KMX_DWORD KMX_VKMap[] = { static KMX_DWORD returnIfCharInvalid = 0; // takes a std::wstring (=contents of line symbols-file ) and returns the (int) value of the character -KMX_DWORD convertNamesToValue(std::wstring tok_wstr); - +KMX_DWORD convertNamesToASCIIValue(std::wstring tok_wstr); // create a Vector with all entries of Vector int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector); + // read configuration file, split and write to 3D-Vector (Data for US on [0][ ][ ] ) int write_US_ToVector(v_dw_3D &vec, std::string language, const char *text); @@ -488,17 +488,19 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE *fpp, const char *text, int split_US_To_3D_Vector(v_dw_3D &all_US, v_str_1D completeList); // replace Name of Key (e.g. ) wih Keycode ( e.g. 0x15 ) -int replace_PosKey_with_Keycode_use_Lin(std::string in); +int replace_KeyName_with_Keycode(std::string in); // create an empty 2D vector containing "--" in all fields -v_dw_2D create_empty_2D(int dim_rows, int dim_shifts); +v_dw_2D create_empty_2D_Vector(int dim_rows, int dim_shifts); // return the Scancode of for given VirtualKey using GDK -KMX_DWORD get_KeyCode_From_KeyVal_GDK(GdkKeymap *keymap, UINT mapped_ikey); +KMX_DWORD get_KeyCode_From_KeyVal_GDK(GdkKeymap *keymap, UINT Keyval); // return the VirtualKey of the Other Keyboard for given Scancode using GDK KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD scanCode); +KMX_DWORD get_VirtualKey_US( KMX_DWORD keycode); + // initialize GDK bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); @@ -507,10 +509,10 @@ bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); int append_other_ToVector(v_dw_3D &All_Vector, GdkKeymap *keymap); // find Keyvals to fill into 2D-Vector of Other Language -KMX_DWORD getKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos); +KMX_DWORD getKeyvalsFromKeyCode(GdkKeymap *keymap, guint keycode, int shift_state_pos); // returns KeySyms fo ra given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) -std::wstring get_KeySyms_according_to_Shiftstate(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); +std::wstring get_KeyVals_according_to_keycode_and_Shiftstate(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); // _S2 needed? @@ -523,9 +525,6 @@ UINT find_SC_Other_from_SC_US_GDK(UINT vk_US_187,GdkKeymap *keymap); int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap); //needed? -// returns Keyvals fo ra given key (for unshifted: finds the Name of the Key e.g. A or 1 ) -std::wstring get_KeyVals_according_to_Shiftstate(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); - // _S2 TODO How to do mapping between Linux keycodes and keyman SC const int Lin_KM__map(int i, v_dw_3D &All_Vector); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index d12b3abb0a..5817c8e67c 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -150,12 +150,14 @@ public: KMX_VirtualKey(UINT scanCode, KMX_HKL hkl, v_dw_3D All_Vector, GdkKeymap **keymap) { this->m_vk = get_VirtualKey_Other_GDK(*keymap, scanCode); + // _s2 correct? this->m_vk = get_VirtualKey_US( scanCode) this->m_hkl = hkl; this->m_sc = scanCode ; } KMX_VirtualKey(KMX_HKL hkl,UINT scanCode, v_dw_3D All_Vector, GdkKeymap **keymap) { this->m_vk = get_VirtualKey_Other_GDK(*keymap, scanCode); + // _s2 correct? this->m_vk = get_VirtualKey_US( scanCode) this->m_hkl = hkl; this->m_sc = scanCode ; // _S2 ?? memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); @@ -723,35 +725,35 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd for(int caps = 0; caps <= 1; caps++) { - + // _S2 this is not VK_Other but keysym_other //_S2 TODO get char - do I need rc ?? ( was rc = ToUnicodeEx...) //std::wstring VK_Other_OLD = get_VirtualKey_Other_from_iKey(SC_Other, ss, caps, All_Vector); - std::wstring VK_Other = get_KeySyms_according_to_Shiftstate( *keymap, SC_US, ss, caps); - //std::wstring VK_Other3 = get_KeySyms_according_to_Shiftstate( *keymap, SC_Other, ss, caps); + std::wstring VK_Other = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, SC_US, ss, caps); + //std::wstring VK_Other3 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, SC_Other, ss, caps); - //std::wstring VK_OtherTEST6 = get_KeySyms_according_to_Shiftstate( *keymap, 51, MenuCtrl, 0); - // std::wstring VK_OtherTEST16 = get_KeySyms_according_to_Shiftstate( *keymap, 51, MenuCtrl, 1); + //std::wstring VK_OtherTEST6 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 51, MenuCtrl, 0); + // std::wstring VK_OtherTEST16 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 51, MenuCtrl, 1); /*std::wstring VK_OtherTEST ; - std::wstring VK_OtherTEST0 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Base, 0); - std::wstring VK_OtherTEST1= get_KeySyms_according_to_Shiftstate( *keymap, 58, Shft, 0); - std::wstring VK_OtherTEST2 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Ctrl, 0); - std::wstring VK_OtherTEST3 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftCtrl, 0); - std::wstring VK_OtherTEST4 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Menu, 0); - std::wstring VK_OtherTEST5 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftMenu, 0); - std::wstring VK_OtherTEST7 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftMenuCtrl, 0); - std::wstring VK_OtherTEST8 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Xxxx, 0); - std::wstring VK_OtherTEST9 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftXxxx, 0); - std::wstring VK_OtherTEST10 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Base, 1); - std::wstring VK_OtherTEST11 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Shft, 1); - std::wstring VK_OtherTEST12 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Ctrl, 1); - std::wstring VK_OtherTEST13 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftCtrl, 1); - std::wstring VK_OtherTEST14 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Menu, 1); - std::wstring VK_OtherTEST15 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftMenu, 1); - std::wstring VK_OtherTEST17 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftMenuCtrl, 1); - std::wstring VK_OtherTEST18 = get_KeySyms_according_to_Shiftstate( *keymap, 58, Xxxx, 1); - std::wstring VK_OtherTEST19 = get_KeySyms_according_to_Shiftstate( *keymap, 58, ShftXxxx, 1); + std::wstring VK_OtherTEST0 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, Base, 0); + std::wstring VK_OtherTEST1= get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, Shft, 0); + std::wstring VK_OtherTEST2 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, Ctrl, 0); + std::wstring VK_OtherTEST3 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, ShftCtrl, 0); + std::wstring VK_OtherTEST4 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, Menu, 0); + std::wstring VK_OtherTEST5 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, ShftMenu, 0); + std::wstring VK_OtherTEST7 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, ShftMenuCtrl, 0); + std::wstring VK_OtherTEST8 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, Xxxx, 0); + std::wstring VK_OtherTEST9 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, ShftXxxx, 0); + std::wstring VK_OtherTEST10 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, Base, 1); + std::wstring VK_OtherTEST11 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, Shft, 1); + std::wstring VK_OtherTEST12 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, Ctrl, 1); + std::wstring VK_OtherTEST13 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, ShftCtrl, 1); + std::wstring VK_OtherTEST14 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, Menu, 1); + std::wstring VK_OtherTEST15 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, ShftMenu, 1); + std::wstring VK_OtherTEST17 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, ShftMenuCtrl, 1); + std::wstring VK_OtherTEST18 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, Xxxx, 1); + std::wstring VK_OtherTEST19 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, ShftXxxx, 1); */ // _S2 needs to be changed - it's temporary to get the same keys as keyman does when using USVirtualKeyToScanCode if (!IsKeymanUsedKey_S2(VK_Other)) From 46acfd03072e7293396600735f8e2e494785011f Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 22 Nov 2023 13:31:17 +0100 Subject: [PATCH 131/327] feat(linux): mcompile find char using SC (KMX_VKUSToSCUnderlyingLayout) instead of VK --- linux/mcompile/keymap/keymap.cpp | 52 ++++++++------ linux/mcompile/keymap/keymap.h | 8 ++- linux/mcompile/keymap/mc_import_rules.cpp | 88 ++++++++++++----------- linux/mcompile/keymap/mcompile.cpp | 40 +++++++---- 4 files changed, 108 insertions(+), 80 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index fddb1d5dbc..83d39a85fa 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -148,7 +148,7 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { std::wstring tok_wstr; // loop through the whole vector - for (int k = 0; k < (int)completeList.size() ; k++) { + for (int k = 0; k < (int)completeList.size(); k++) { // remove all unwanted char for (int i = 0; i < (int) delim.size(); i++) { @@ -205,25 +205,25 @@ int replace_KeyName_with_Keycode(std::string in) { // _S2 these are the Scancode-Values we use in Keyman ( = like the windows scancodes) // NAME IN SYMBOLS-FILE KEYCODE (LIN STYLE) (WIN STYLE) VK_US VK_DE /*on US keyb;*/ - if ( in == "key") out = 49; /* VK_ */ // TOASK correct ??? - else if ( in == "key") out = 10; /* 0X02 VK_1 */ - else if ( in == "key") out = 11; /* 0X03 VK_2 */ - else if ( in == "key") out = 12; /* 0X04 VK_3 */ - else if ( in == "key") out = 13; /* 0X05 VK_4 */ - else if ( in == "key") out = 14; /* 0X06 VK_5 */ - else if ( in == "key") out = 15; /* 0X07 VK_6 */ - else if ( in == "key") out = 16; /* 0X08 VK_7 */ - else if ( in == "key") out = 17; /* 0X09 VK_8 */ - else if ( in == "key") out = 18; /* 0X0A VK_9 */ - else if ( in == "key") out = 19; /* 0X0B VK_0 */ + if ( in == "key") out = 49; /* VK_ */ // TOASK correct ??? + else if ( in == "key") out = 10; /* 0X02 VK_1 */ + else if ( in == "key") out = 11; /* 0X03 VK_2 */ + else if ( in == "key") out = 12; /* 0X04 VK_3 */ + else if ( in == "key") out = 13; /* 0X05 VK_4 */ + else if ( in == "key") out = 14; /* 0X06 VK_5 */ + else if ( in == "key") out = 15; /* 0X07 VK_6 */ + else if ( in == "key") out = 16; /* 0X08 VK_7 */ + else if ( in == "key") out = 17; /* 0X09 VK_8 */ + else if ( in == "key") out = 18; /* 0X0A VK_9 */ + else if ( in == "key") out = 19; /* 0X0B VK_0 */ else if ( in == "key") out = 20; /*out = 61;*/ /* 0X0C VK_MINUS de ẞ*/ - else if ( in == "key") out = 21; /* 0X0D VK_EQUALS DE ' */ + else if ( in == "key") out = 21; /* 0X0D VK_EQUALS DE ' */ - else if ( in == "key") out = 24; /* 0X10 VK_Q */ - else if ( in == "key") out = 25; /* 0X11 VK_W */ - else if ( in == "key") out = 26; /* 0X12 VK_E */ - else if ( in == "key") out = 27; /* 0X13 VK_R */ - else if ( in == "key") out = 28; /* 0X14 VK_T */ + else if ( in == "key") out = 24; /* 0X10 VK_Q */ + else if ( in == "key") out = 25; /* 0X11 VK_W */ + else if ( in == "key") out = 26; /* 0X12 VK_E */ + else if ( in == "key") out = 27; /* 0X13 VK_R */ + else if ( in == "key") out = 28; /* 0X14 VK_T */ else if ( in == "key") out = 29; /*out = 52;*/ /* 0X15 VK_Y */ else if ( in == "key") out = 30; /* 0X16 VK_U */ else if ( in == "key") out = 31; /* 0X17 VK_I */ @@ -380,7 +380,7 @@ KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { UINT VK_for_rgKey2 = ScanCodeToUSVirtualKey[keycode-8]; //return (KMX_DWORD) *keyvals;} //_S2 what to return if >255 - return (KMX_DWORD) VK_for_rgKey2 ; } + return (KMX_DWORD) VK_for_rgKey2; } return 0; //_S2 what to return if not found } @@ -470,7 +470,8 @@ std::wstring get_KeyVals_according_to_keycode_and_Shiftstate(GdkKeymap *keymap, //ALT-GR else if (( ss == MenuCtrl ) && ( caps == 0 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) ( 144 ); + //GdkModifierType MOD_AltGr = (GdkModifierType) ( 144 ); + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK) ); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); return std::wstring(1, (int) *keyvals); } @@ -478,7 +479,8 @@ std::wstring get_KeyVals_according_to_keycode_and_Shiftstate(GdkKeymap *keymap, //ALT-GR else if (( ss == MenuCtrl ) && ( caps == 1 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) ( 144 ); + //GdkModifierType MOD_AltGr = (GdkModifierType) ( 146 ); + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); return std::wstring(1, (int) *keyvals); } @@ -500,3 +502,11 @@ UINT find_SC_Other_from_SC_US_GDK(UINT SC_US,GdkKeymap *keymap) { return SC_US; } + +int map_VKShiftState_to_Lin(int VKShiftState) { + if (VKShiftState == 0 ) return 0; /* 0000 0000 */ + if (VKShiftState == 16) return 1; /* 0001 0000 */ + //if (VKShiftState == 9 ) return 2; /* 0000 1001 */ + //if (VKShiftState == 25) return 3; /* 0001 1001 */ + return VKShiftState; +} diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 962eef368f..b8b2648813 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -38,6 +38,8 @@ enum ShiftState { ShftXxxx = Shft | Xxxx, // 9 }; +int map_VKShiftState_to_Lin(int VKShiftState); + const UINT USVirtualKeyToScanCode[256] = { 0x00, // L"K_?00", // &H0 0x00, // L"K_LBUTTON", // &H1 @@ -444,6 +446,8 @@ const KMX_DWORD KMX_VKMap[] = { //_S2 those might not work correctly yet*/ + VK_SPACE, /* 32 */ + VK_ACCENT, /* 192 VK_OEM_3 */ VK_HYPHEN, /* - 189 VK_OEM_MINUS */ VK_EQUAL, /* = 187 VK_OEM_PLUS */ @@ -459,8 +463,6 @@ const KMX_DWORD KMX_VKMap[] = { VK_PERIOD, /* . 190 VK_OEM_PERIOD */ VK_SLASH, /* / 191 VK_OEM_2 */ - VK_SPACE, /* 32 */ - VK_xDF, /* ß (?) 223*/ VK_OEM_102, /* < > | 226 */ @@ -518,7 +520,7 @@ std::wstring get_KeyVals_according_to_keycode_and_Shiftstate(GdkKeymap *keymap, // _S2 needed? // can go later void Try_GDK(GdkKeymap *keymap, UINT KeySym ); -void Inspect_Key_S(GdkKeymap *keymap ) ; +void Inspect_Key_S(GdkKeymap *keymap ); UINT find_SC_Other_from_SC_US_GDK(UINT vk_US_187,GdkKeymap *keymap); // _S2 needed? // create a Vector with all entries of both keymaps+ keymap diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 5817c8e67c..2600b0d39a 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -152,14 +152,14 @@ public: this->m_vk = get_VirtualKey_Other_GDK(*keymap, scanCode); // _s2 correct? this->m_vk = get_VirtualKey_US( scanCode) this->m_hkl = hkl; - this->m_sc = scanCode ; + this->m_sc = scanCode; } KMX_VirtualKey(KMX_HKL hkl,UINT scanCode, v_dw_3D All_Vector, GdkKeymap **keymap) { this->m_vk = get_VirtualKey_Other_GDK(*keymap, scanCode); // _s2 correct? this->m_vk = get_VirtualKey_US( scanCode) this->m_hkl = hkl; - this->m_sc = scanCode ; + this->m_sc = scanCode; // _S2 ?? memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); } @@ -170,6 +170,10 @@ public: UINT SC() { return this->m_sc; } + // _S2 can go later + std::wstring get_m_rgss(int i,int j) { + return m_rgss[i][j]; + } std::wstring KMX_GetShiftState(ShiftState shiftState, bool capsLock) { return this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)]; @@ -256,7 +260,7 @@ public: bool b1= this->KMX_IsCapsEqualToShift(); bool b2= this->KMX_IsSGCAPS(); bool b3= this->KMX_IsAltGrCapsEqualToAltGrShift(); -bool b4= this->KMX_IsXxxxGrCapsEqualToXxxxShift() ; +bool b4= this->KMX_IsXxxxGrCapsEqualToXxxxShift(); int i1 = this->KMX_IsCapsEqualToShift() ? 1 : 0; int i2 = this->KMX_IsSGCAPS() ? 2 : 0; @@ -290,7 +294,6 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; for (size_t ich = 0; ich < st.size(); ich++) { if(st[ich] < 0x20 || st[ich] == 0x7F) { isvalid=false; break; } } - if(isvalid) { nkeys++; } @@ -307,7 +310,7 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; bool b1= this->KMX_IsCapsEqualToShift(); bool b2= this->KMX_IsSGCAPS(); bool b3= this->KMX_IsAltGrCapsEqualToAltGrShift(); -bool b4= this->KMX_IsXxxxGrCapsEqualToXxxxShift() ; +bool b4= this->KMX_IsXxxxGrCapsEqualToXxxxShift(); int i1 = this->KMX_IsCapsEqualToShift() ? 1 : 0; int i2 = this->KMX_IsSGCAPS() ? 2 : 0; @@ -340,7 +343,6 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; key->dpContext = new KMX_WCHAR[1]; *key->dpContext = 0; key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); - // _S2 this fun returns the shifted Char it goes wrog for numbers, special here!! key->Key = KMX_VKUnderlyingLayoutToVKUS(All_Vector,this->VK()); key->Line = 0; @@ -362,10 +364,11 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; for (size_t ich = 0; ich < st.size(); ich++) { if(st[ich] < 0x20 || st[ich] == 0x7F) { isvalid=false; break; } } - if(isvalid) { // _S2 this fun returns the shifted Char instead of keyname -> use gdk function!! key->Key = KMX_VKUnderlyingLayoutToVKUS(All_Vector,this->VK()); + std::wstring w1_S2 = get_m_rgss(ss,caps); + wprintf(L" --- %ls ",w1_S2.c_str()); key->Line = 0; key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); key->dpContext = new KMX_WCHAR; *key->dpContext = 0; @@ -596,9 +599,10 @@ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { bool IsKeymanUsedKey_S2(std::wstring SC_Other) { - int SC_US = (int) (*SC_Other.c_str()); + int SC_ = (int) (*SC_Other.c_str()); - if ((SC_US>= 0x20 && SC_US <= 0x7A) || (SC_US >= 0x88 && SC_US < 0xFF)) + // 32 122 136 256 + if ((SC_>= 0x20 && SC_ <= 0x7A) || (SC_ >= 0x88 && SC_ < 0xFF)) return true; else return false; @@ -725,43 +729,45 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd for(int caps = 0; caps <= 1; caps++) { - // _S2 this is not VK_Other but keysym_other //_S2 TODO get char - do I need rc ?? ( was rc = ToUnicodeEx...) - //std::wstring VK_Other_OLD = get_VirtualKey_Other_from_iKey(SC_Other, ss, caps, All_Vector); - std::wstring VK_Other = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, SC_US, ss, caps); - //std::wstring VK_Other3 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, SC_Other, ss, caps); + //std::wstring KeyVal_Other_OLD = get_VirtualKey_Other_from_iKey(SC_Other, ss, caps, All_Vector); + std::wstring KeyVal_Other = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, SC_US, ss, caps); + std::wstring KeyVal_Other3 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, SC_US, ss, caps); - //std::wstring VK_OtherTEST6 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 51, MenuCtrl, 0); - // std::wstring VK_OtherTEST16 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 51, MenuCtrl, 1); + //std::wstring KeyVal_OtherTEST6 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 51, MenuCtrl, 0); + // std::wstring KeyVal_OtherTEST16 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 51, MenuCtrl, 1); + +int testval= 38; + std::wstring KeyVal_OtherTEST; + std::wstring KeyVal_OtherTEST0 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, Base, 0); + std::wstring KeyVal_OtherTEST1= get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, Shft, 0); + std::wstring KeyVal_OtherTEST2 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, Ctrl, 0); + std::wstring KeyVal_OtherTEST3 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, ShftCtrl, 0); + std::wstring KeyVal_OtherTEST4 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, Menu, 0); + std::wstring KeyVal_OtherTEST5 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, ShftMenu, 0); + std::wstring KeyVal_OtherTEST7 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, ShftMenuCtrl, 0); + std::wstring KeyVal_OtherTEST8 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, Xxxx, 0); + std::wstring KeyVal_OtherTEST9 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, ShftXxxx, 0); + std::wstring KeyVal_OtherTEST10 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, Base, 1); + std::wstring KeyVal_OtherTEST11 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, Shft, 1); + std::wstring KeyVal_OtherTEST12 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, Ctrl, 1); + std::wstring KeyVal_OtherTEST13 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, ShftCtrl, 1); + std::wstring KeyVal_OtherTEST14 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, Menu, 1); + std::wstring KeyVal_OtherTEST15 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, ShftMenu, 1); + std::wstring KeyVal_OtherTEST17 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, ShftMenuCtrl, 1); + std::wstring KeyVal_OtherTEST18 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, Xxxx, 1); + std::wstring KeyVal_OtherTEST19 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, ShftXxxx, 1); + std::wstring KeyVal_OtherTEST20 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, MenuCtrl, 0); + std::wstring KeyVal_OtherTEST21 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, MenuCtrl, 1); - /*std::wstring VK_OtherTEST ; - std::wstring VK_OtherTEST0 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, Base, 0); - std::wstring VK_OtherTEST1= get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, Shft, 0); - std::wstring VK_OtherTEST2 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, Ctrl, 0); - std::wstring VK_OtherTEST3 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, ShftCtrl, 0); - std::wstring VK_OtherTEST4 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, Menu, 0); - std::wstring VK_OtherTEST5 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, ShftMenu, 0); - std::wstring VK_OtherTEST7 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, ShftMenuCtrl, 0); - std::wstring VK_OtherTEST8 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, Xxxx, 0); - std::wstring VK_OtherTEST9 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, ShftXxxx, 0); - std::wstring VK_OtherTEST10 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, Base, 1); - std::wstring VK_OtherTEST11 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, Shft, 1); - std::wstring VK_OtherTEST12 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, Ctrl, 1); - std::wstring VK_OtherTEST13 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, ShftCtrl, 1); - std::wstring VK_OtherTEST14 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, Menu, 1); - std::wstring VK_OtherTEST15 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, ShftMenu, 1); - std::wstring VK_OtherTEST17 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, ShftMenuCtrl, 1); - std::wstring VK_OtherTEST18 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, Xxxx, 1); - std::wstring VK_OtherTEST19 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 58, ShftXxxx, 1); - */ // _S2 needs to be changed - it's temporary to get the same keys as keyman does when using USVirtualKeyToScanCode - if (!IsKeymanUsedKey_S2(VK_Other)) - VK_Other =L"\0"; + if (!IsKeymanUsedKey_S2(KeyVal_Other)) + KeyVal_Other =L"\0"; //_S2 TODO do I need that ?? //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { - if(VK_Other == L"") { + if(KeyVal_Other == L"") { //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps)); } @@ -775,8 +781,8 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd } //_S2 TODO fill m_rgfDeadkey ( m_rgfDeadkey will be done later) - //rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps==0)); - rgKey[iKey]->KMX_SetShiftState(ss, VK_Other, false, (caps)); + //rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps==0)); + rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps)); //_S2 TODO @@ -839,7 +845,6 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { nKeys+= rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); - wprintf(L" iKey = %i, Delta: %i \n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState())); } } @@ -862,6 +867,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { //wprintf(L"********************************* I use Key Nr %i\n",iKey); // for each item, + wprintf(L" \n iKey = %i, nKeys %i + Delta:\t%i", iKey,nKeys, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState())); if(rgKey[iKey]->KMX_LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector)) { // I4552 nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); } diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 733f13f620..382dd7c63a 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -43,12 +43,12 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gdk std::vector KMX_FDeadkeys; // I4353 void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch); -void KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) ; -void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) ; +void KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch); +void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch); void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key); void KMX_ReportUnconvertedGroupRules(LPKMX_GROUP group); -void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) ; +void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd); #if defined(_WIN32) || defined(_WIN64) int wmain(int argc, wchar_t* argv[]) { @@ -147,7 +147,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ delete kmxfile; wprintf(L"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm end\n"); - return 0 ; + return 0; } // _S2 TODO which version of VKShiftStates do we use ? // comment from win-version @@ -183,6 +183,13 @@ KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { return FALSE; } +// takes SC of US keyboard and returns SC of OTHER keyboard +UINT KMX_VKUSToSCUnderlyingLayout(KMX_DWORD VirtualKeyUS) { + UINT SC_US = 8 + USVirtualKeyToScanCode[VirtualKeyUS]; + UINT SC_OTHER = SC_US; // not neccessary but to understand what we do + return SC_OTHER; +} + // takes capital letter of US returns cpital character of Other keyboard KMX_DWORD KMX_VKUSToVKUnderlyingLayout(v_dw_3D &All_Vector,KMX_DWORD inUS) { // loop and find char in US; then return char of Other @@ -208,9 +215,7 @@ KMX_WORD KMX_VKUnderlyingLayoutToVKUS(v_dw_3D &All_Vector,KMX_DWORD inOther) { } return inOther; } - - -// takes cpital character of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] +// takes VK of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] KMX_DWORD KMX_CharFromVK(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey){ KMX_UINT VKShiftState_lin; @@ -234,6 +239,13 @@ KMX_DWORD KMX_CharFromVK(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VK return vkUnderlying; } +// takes SC of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] +KMX_WCHAR KMX_CharFromSC(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey) { + int VKShiftState_lin = map_VKShiftState_to_Lin(VKShiftState); + KMX_DWORD KeyvalOther = getKeyvalsFromKeyCode(keymap,SC_OTHER, VKShiftState_lin); + return (KMX_WCHAR) KeyvalOther; +} + bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]){ // get keymap of keyboard layout in use @@ -273,7 +285,6 @@ int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ return 0; } - KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]) { KMX_WCHAR DeadKey; @@ -309,15 +320,13 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon // Loop through each possible key on the keyboard for (int i = 0;KMX_VKMap[i]; i++) { // I4651 - KMX_DWORD vkUnderlying = KMX_VKUSToVKUnderlyingLayout(All_Vector,(int) KMX_VKMap[i] ); + // win goes via VK, Lin goes vie SC + /*KMX_DWORD vkUnderlying = KMX_VKUSToVKUnderlyingLayout(All_Vector,(int) KMX_VKMap[i] ); + KMX_WCHAR ch = KMX_CharFromVK(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey);*/ - KMX_WCHAR ch = KMX_CharFromVK(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey); + UINT scUnderlying = KMX_VKUSToSCUnderlyingLayout(KMX_VKMap[i]); + KMX_WCHAR ch= KMX_CharFromSC(keymap, VKShiftState[j], scUnderlying, &DeadKey); - /*//_S2 marker in wprintf if difference is not 32= (unshifted-shifted ) - can go later - if (!( ((int) KMX_VKMap[i] == ch ) || ((int) KMX_VKMap[i] == (int) ch -32) ) ) - ERROR = L" !!!"; - else - ERROR = L" ";*/ //wprintf(L" DoConvert-read i: %i \t(KMX_VKMap): %i (%c) \t---> vkUnderlying: %i (%c) \tshiftstate[%i]: ( %i ) \t---- > ch: %i (%c) \t%ls \t%ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, j, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); @@ -388,6 +397,7 @@ void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) // But that is up to the designer. //LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, key->ShiftFlags & ~VIRTUALCHARKEY, vk); key->ShiftFlags &= ~VIRTUALCHARKEY; + //wprintf(L" i am processing vk%i (%c) char %i (%c) \n", vk,vk, ch,ch); key->Key = vk; //wprintf(L"key->ShiftFlags for VIRTUALCHARKEY= %i", key->ShiftFlags); //wprintf(L" 2 and changed, vk: %i (%c) ---> %i (%c) ", vk,vk, ch,ch); From ca831fcb0359794063e10321428ee58de98166d3 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 23 Nov 2023 15:16:35 +0100 Subject: [PATCH 132/327] feat(linux): mcompile function to manually fill rgkey[VK_DE] for testing reasons --- linux/mcompile/keymap/keymap.cpp | 51 ++++++++++++++++++++--- linux/mcompile/keymap/keymap.h | 6 ++- linux/mcompile/keymap/mc_import_rules.cpp | 38 ++++++++++------- linux/mcompile/keymap/mcompile.cpp | 7 ++-- 4 files changed, 77 insertions(+), 25 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 83d39a85fa..e027b01066 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -385,13 +385,56 @@ KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { return 0; //_S2 what to return if not found } -KMX_DWORD get_VirtualKey_US( KMX_DWORD keycode) { - +KMX_DWORD get_VKUS_fromKeyCode( KMX_DWORD keycode) { if ( keycode >7) return (KMX_DWORD) ScanCodeToUSVirtualKey[keycode-8]; - return 0; //_S2 what to return if not found } +KMX_DWORD get_KeyCode_fromVKUS( KMX_DWORD VK_US) { + if( VK_US > 7) + return (KMX_DWORD)(8+ USVirtualKeyToScanCode[ VK_US ]); + else + return 0; +} + +// _S2 this needs to go; only to check if mcompile gives the same end result. +// _S2 helps to force filling rgkey[VK_DE] +UINT map_Ikey_DE(UINT iKey) { + if (iKey == 186 ) return 219; + if (iKey == 187 ) return 221; + if (iKey == 188 ) return 188; + if (iKey == 189 ) return 191; + if (iKey == 190 ) return 190; + if (iKey == 191 ) return 220; + if (iKey == 192 ) return 186; + if (iKey == 219 ) return 189; + if (iKey == 220 ) return 192; + if (iKey == 221 ) return 187; + if (iKey == 222 ) return 222; + if (iKey == 226 ) return 226; + return iKey; +} + +// _S2 this needs to go; only to check if mcompile gives the same end result. +// _S2 helps to force filling rgkey[VK_FR] +UINT map_Ikey_FR(UINT iKey) { + if (iKey == 186 ) return 221; + if (iKey == 187 ) return 187; + if (iKey == 188 ) return 77; + if (iKey == 189 ) return 223; + if (iKey == 190 ) return 188; + if (iKey == 191 ) return 190; + if (iKey == 192 ) return 222; + if (iKey == 219 ) return 189; + if (iKey == 220 ) return 220; + if (iKey == 221 ) return 219; + if (iKey == 222 ) return 192; + if (iKey == 223 ) return 191; + if (iKey == 226 ) return 226; + if (iKey == 77 ) return 186; + return iKey; +} + // _S2 TODO How to do mapping between Linux keycodes and keyman SC const int Lin_KM__map(int i, v_dw_3D &All_Vector) { @@ -476,7 +519,6 @@ std::wstring get_KeyVals_according_to_keycode_and_Shiftstate(GdkKeymap *keymap, return std::wstring(1, (int) *keyvals); } - //ALT-GR else if (( ss == MenuCtrl ) && ( caps == 1 )){ //GdkModifierType MOD_AltGr = (GdkModifierType) ( 146 ); @@ -487,7 +529,6 @@ std::wstring get_KeyVals_according_to_keycode_and_Shiftstate(GdkKeymap *keymap, else return L"\0"; - //return L"0"; } // _S2 maybe not needed diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index b8b2648813..8a2e0ff680 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -501,7 +501,11 @@ KMX_DWORD get_KeyCode_From_KeyVal_GDK(GdkKeymap *keymap, UINT Keyval); // return the VirtualKey of the Other Keyboard for given Scancode using GDK KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD scanCode); -KMX_DWORD get_VirtualKey_US( KMX_DWORD keycode); +KMX_DWORD get_VKUS_fromKeyCode( KMX_DWORD keycode); +KMX_DWORD get_KeyCode_fromVKUS( KMX_DWORD VK_US); + +UINT map_Ikey_DE(UINT iKey); +UINT map_Ikey_FR(UINT iKey); // initialize GDK bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 2600b0d39a..86392a8653 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -597,12 +597,12 @@ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { return n; } -bool IsKeymanUsedKey_S2(std::wstring SC_Other) { +bool IsKeymanUsedKeyVal(std::wstring Keyval) { - int SC_ = (int) (*SC_Other.c_str()); + int KV = (int) (*Keyval.c_str()); - // 32 122 136 256 - if ((SC_>= 0x20 && SC_ <= 0x7A) || (SC_ >= 0x88 && SC_ < 0xFF)) + // 32 122 136 256 + if ((KV >= 0x20 && KV <= 0x7A) || (KV >= 0x88 && KV < 0xFF)) return true; else return false; @@ -665,6 +665,9 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd } } + // _S2 remove! only for testing helps to force filling rgkey[VK_DE] + rgKey[223] = new KMX_VirtualKey(hkl, 223, All_Vector, keymap); + for(UINT ke = VK_NUMPAD0; ke <= VK_NUMPAD9; ke++) { rgKey[ke] = new KMX_VirtualKey(hkl, ke, All_Vector, keymap); } @@ -710,7 +713,11 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd if(rgKey[iKey] != NULL) { WCHAR sbBuffer[256]; // Scratchpad we use many places - UINT SC_Other = Lin_KM__map(iKey, All_Vector); + UINT VK_Other = Lin_KM__map(iKey, All_Vector); + + // _S2 only for testing can go later helps to force filling rgkey[VK_DE] + UINT iKey_DE = map_Ikey_DE(iKey); + UINT iKey_FR = map_Ikey_FR(iKey); for(ShiftState ss = Base; ss <= loader.MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { if(ss == Menu || ss == ShftMenu) { @@ -718,19 +725,20 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd continue; } - KMX_DWORD SC_US; - if( SC_Other>7) - SC_US= (KMX_DWORD)(8+ USVirtualKeyToScanCode[ SC_Other ]); - else SC_US = 0; + + // KMX_DWORD SC_US = get_KeyCode_fromVKUS(iKey); // _S2 needs to be here late + KMX_DWORD SC_US = get_KeyCode_fromVKUS(iKey_DE); // _S2 only for testing can go later helps to force filling rgkey[VK_DE] + //KMX_DWORD SC_US = get_KeyCode_fromVKUS(iKey_FR); // _S2 only for testing can go later helps to force filling rgkey[VK_DE] -//wprintf(L" for vk of %i we get Keycode US of %i SC_Other %i: ( on Key US (%i) we find char %i (%c) ) \n", SC_Other, 8+USVirtualKeyToScanCode[SC_Other], 8+USVirtualKeyToScanCode[SC_Other] , -//8+USVirtualKeyToScanCode[SC_Other],get_VirtualKey_Other_GDK(*keymap, 8+USVirtualKeyToScanCode[SC_Other]),get_VirtualKey_Other_GDK(*keymap, 8+USVirtualKeyToScanCode[SC_Other]) ); +//wprintf(L" for vk of %i we get Keycode US of %i VK_Other %i: ( on Key US (%i) we find char %i (%c) ) \n", +// VK_Other, 8+USVirtualKeyToScanCode[VK_Other], 8+USVirtualKeyToScanCode[VK_Other] , +//8+USVirtualKeyToScanCode[VK_Other],get_VirtualKey_Other_GDK(*keymap, 8+USVirtualKeyToScanCode[VK_Other]),get_VirtualKey_Other_GDK(*keymap, 8+USVirtualKeyToScanCode[VK_Other]) ); for(int caps = 0; caps <= 1; caps++) { //_S2 TODO get char - do I need rc ?? ( was rc = ToUnicodeEx...) - //std::wstring KeyVal_Other_OLD = get_VirtualKey_Other_from_iKey(SC_Other, ss, caps, All_Vector); + //std::wstring KeyVal_Other_OLD = get_VirtualKey_Other_from_iKey(VK_Other, ss, caps, All_Vector); std::wstring KeyVal_Other = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, SC_US, ss, caps); std::wstring KeyVal_Other3 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, SC_US, ss, caps); @@ -761,9 +769,9 @@ int testval= 38; std::wstring KeyVal_OtherTEST20 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, MenuCtrl, 0); std::wstring KeyVal_OtherTEST21 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, MenuCtrl, 1); - // _S2 needs to be changed - it's temporary to get the same keys as keyman does when using USVirtualKeyToScanCode - if (!IsKeymanUsedKey_S2(KeyVal_Other)) - KeyVal_Other =L"\0"; + // _S2 needs to be changed - it's temporary to get the same keys as keyman does when using USVirtualKeyToScanCode prevents chars like ሴ + if (!IsKeymanUsedKeyVal(KeyVal_Other)) + KeyVal_Other = L"\0"; //_S2 TODO do I need that ?? //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 382dd7c63a..9198f65e91 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -325,7 +325,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon KMX_WCHAR ch = KMX_CharFromVK(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey);*/ UINT scUnderlying = KMX_VKUSToSCUnderlyingLayout(KMX_VKMap[i]); - KMX_WCHAR ch= KMX_CharFromSC(keymap, VKShiftState[j], scUnderlying, &DeadKey); + KMX_WCHAR ch = KMX_CharFromSC(keymap, VKShiftState[j], scUnderlying, &DeadKey); //wprintf(L" DoConvert-read i: %i \t(KMX_VKMap): %i (%c) \t---> vkUnderlying: %i (%c) \tshiftstate[%i]: ( %i ) \t---- > ch: %i (%c) \t%ls \t%ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, j, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); @@ -341,7 +341,6 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon switch(ch) { case 0x0000: break; - // _S2 TODO deadkeys will be done later //case 0xFFFF: ConvertDeadkey(kbd, VKMap[i], VKShiftState[j], DeadKey); break; default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); @@ -422,10 +421,10 @@ void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_ void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key) { if(key->ShiftFlags == 0) { //KMX_LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); - //wprintf(L" _S2 Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); + wprintf(L" _S2 Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); } else if(key->ShiftFlags & VIRTUALCHARKEY) { //KMX_LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); - //wprintf(L"_S2 Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); + wprintf(L"_S2 Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); } } From 2c3d5e8201ad27574a310ee38a73967cb75b68f6 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 24 Nov 2023 10:42:51 +0100 Subject: [PATCH 133/327] feat(linux): mcompile manually fill rgkey with the same values --- linux/mcompile/keymap/keymap.cpp | 8 ++++ linux/mcompile/keymap/mc_import_rules.cpp | 47 +++++++++++++++++------ linux/mcompile/keymap/mcompile.cpp | 6 +-- 3 files changed, 47 insertions(+), 14 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index e027b01066..b8cabc5a3b 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -481,6 +481,14 @@ std::wstring get_KeyVals_according_to_keycode_and_Shiftstate(GdkKeymap *keymap, if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return L"\0"; //return L"1"; +// _S2 remove! only for testing helps to force filling rgkey[VK_DE] +if((keycode == 49) && (ss == Base)) return L"^"; +if((keycode == 21) && (ss == Base)) return L"'"; +if((keycode == 21) && (ss == Shft)) return L"`"; +if((keycode == 21) && (ss == Base) && (caps == 1)) return L"'"; +if((keycode == 20) && (ss == Base) && (caps == 1)) return L"ß"; //L"ẞ"; +if((keycode == 20) && (ss == ShftMenuCtrl) && (caps == 0)) return L"ß"; //L"ẞ"; +if((keycode == 20) && (ss == ShftMenuCtrl) && (caps == 1)) return L"ß"; //L"ẞ"; //unshifted if (( ss == Base ) && ( caps == 0 )) { diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 86392a8653..4c26ecc3ad 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -599,12 +599,22 @@ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { bool IsKeymanUsedKeyVal(std::wstring Keyval) { + + int KV = (int) (*Keyval.c_str()); - // 32 122 136 256 - if ((KV >= 0x20 && KV <= 0x7A) || (KV >= 0x88 && KV < 0xFF)) + // 32 127 196 256 + if ((KV >= 0x20 && KV <= 0x7F) || (KV >= 0xC4 && KV < 198) || + (KV >= 199 && KV < 208) || (KV >= 209 && KV < 216) || (KV >= 217 && KV < 229) || + (KV >= 231 && KV < 240) || (KV >= 241 && KV < 248) || (KV >= 249 && KV < 0xFF) || + (KV == 128) || (KV == 178) || (KV == 167) || (KV == 179)|| (KV == 176)|| (KV == 181) ) + + + // 32 127 136 256 + //if ((KV >= 0x20 && KV <= 0x7F) || (KV == 214)|| (KV == 246)|| (KV ==196)|| (KV == 228) || (KV ==220)|| (KV == 252)|| (KV ==223)|| (KV == 186)) return true; else + return false; } @@ -702,11 +712,11 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd } */ // _S2 test rgkey can go later - for(UINT iKey = 100; iKey < rgKey.size(); iKey++) { + /*for(UINT iKey = 100; iKey < rgKey.size(); iKey++) { if(rgKey[iKey] != NULL) { wprintf(L" Key Nr %i is available\n",iKey); } - } + }*/ // _S2 in this part we skip shiftstates 4, 5, 8, 9 for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { @@ -806,16 +816,29 @@ int testval= 38; } //_S2 this gan co later - //std::vector< int > TestValues = {48,49,50,52,53,54,55,56,57,54,65,89,189,188}; - //std::vector< int > TestValues = {48,49,50,51,52,53,54,55,56,57,65,66,67,88,89,90, 176,177,196,214,220}; - std::vector< int > TestValues = {48,49,50,51,52,53,54,55,56,57,65,66,67,88,89,90}; - // std::vector< int > TestValues = {65}; + std::vector< int > TestValues = {48,49,50,51,52,53,54,55,56,57,65,66,67,88,89,90, 186,187,188,189,191,191,192,219,220,221,222,223,226}; wprintf(L"-----------------\nNow some tests:\n"); + wprintf(L" Base Caps Shift Shfit+Caps MenuCtrl MenuCtrl+Caps \n"); + for ( int i=0; i < (int) TestValues.size();i++) { - wprintf(L"Results for %i\t: %s %s %s %s \n", TestValues[i], rgKey[TestValues[i]]->KMX_GetShiftState(Base,0).c_str(), rgKey[TestValues[i]]->KMX_GetShiftState(Base,1).c_str() , rgKey[TestValues[i]]->KMX_GetShiftState(Shft,0).c_str(), rgKey[TestValues[i]]->KMX_GetShiftState(Shft,1).c_str()); + std::wstring wws = rgKey[TestValues[i]]->get_m_rgss(0,0); + wprintf(L"Results for %i\t: %ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \n", + TestValues[i], + rgKey[TestValues[i]]->get_m_rgss(0,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(0,0)[0], + rgKey[TestValues[i]]->get_m_rgss(0,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(0,1)[0], + rgKey[TestValues[i]]->get_m_rgss(1,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(1,0)[0], + rgKey[TestValues[i]]->get_m_rgss(1,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(1,1)[0], + rgKey[TestValues[i]]->get_m_rgss(6,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(6,0)[0], + rgKey[TestValues[i]]->get_m_rgss(6,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(6,1)[0], + rgKey[TestValues[i]]->get_m_rgss(7,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(7,0)[0], + rgKey[TestValues[i]]->get_m_rgss(7,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(7,1)[0] + ); } wprintf(L"-----------------\n"); + + + //------------------------------------------------------------- // Now that we've collected the key data, we need to // translate it to kmx and append to the existing keyboard @@ -850,10 +873,13 @@ int testval= 38; kp->cxGroupArray++; gp = &kp->dpGroupArray[kp->cxGroupArray-1]; UINT nKeys = 0; + int sab_nr = 0; for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { nKeys+= rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); - } + wprintf(L" iKey = %i, Delta: %i -> Sum %i\n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()), nKeys); + sab_nr ++; + } } @@ -866,7 +892,6 @@ int testval= 38; gp->cxKeyArray = nKeys; gp->dpKeyArray = new KMX_KEY[gp->cxKeyArray]; nKeys = 0; - // // Fill in the new rules // diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 9198f65e91..5646bd46e4 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -146,7 +146,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ //DeleteReallocatedPointers(kmxfile); :TODO // _S2 not my ToDo :-) delete kmxfile; - wprintf(L"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm end\n"); + wprintf(L"\nmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm end\n"); return 0; } // _S2 TODO which version of VKShiftStates do we use ? @@ -421,10 +421,10 @@ void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_ void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key) { if(key->ShiftFlags == 0) { //KMX_LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); - wprintf(L" _S2 Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); + //wprintf(L" _S2 Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); } else if(key->ShiftFlags & VIRTUALCHARKEY) { //KMX_LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); - wprintf(L"_S2 Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); + //wprintf(L"_S2 Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); } } From 58a315089d41e40550d8f5e9324df5d0ebca5ccc Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 24 Nov 2023 17:29:59 +0100 Subject: [PATCH 134/327] feat(linux): mcompile force filling rgkey[VK_DE] to be able to check lowest part of ImportRule --- linux/mcompile/keymap/keymap.cpp | 2 ++ linux/mcompile/keymap/mc_import_rules.cpp | 42 ++++++++++++++++++----- linux/mcompile/keymap/mcompile.cpp | 10 ++++++ linux/mcompile/keymap/mcompile.h | 2 +- 4 files changed, 47 insertions(+), 9 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index b8cabc5a3b..f3110f8035 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -400,6 +400,8 @@ KMX_DWORD get_KeyCode_fromVKUS( KMX_DWORD VK_US) { // _S2 this needs to go; only to check if mcompile gives the same end result. // _S2 helps to force filling rgkey[VK_DE] UINT map_Ikey_DE(UINT iKey) { + if (iKey == 89 ) return 90; + if (iKey == 90 ) return 89; if (iKey == 186 ) return 219; if (iKey == 187 ) return 221; if (iKey == 188 ) return 188; diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 4c26ecc3ad..374c1d0b6f 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -175,6 +175,11 @@ public: return m_rgss[i][j]; } + // _S2 can go later + void set_sc(int i) { + this->m_sc=i; + } + std::wstring KMX_GetShiftState(ShiftState shiftState, bool capsLock) { return this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)]; } @@ -303,7 +308,7 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; return nkeys; } - bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,v_dw_3D &All_Vector) { // I4552 + bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,v_dw_3D &All_Vector, GdkKeymap * keymap) { // I4552 // Get the CAPSLOCK value @@ -333,6 +338,7 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; for (int caps = 0; caps <= 1; caps++) { std::wstring st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); PKMX_WCHAR p; // was PWSTR p; + PKMX_WCHAR q; if (st.size() == 0) { // No character assigned here @@ -344,7 +350,8 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; *key->dpContext = 0; key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); // _S2 this fun returns the shifted Char it goes wrog for numbers, special here!! - key->Key = KMX_VKUnderlyingLayoutToVKUS(All_Vector,this->VK()); + //key->Key = KMX_VKUnderlyingLayoutToVKUS(All_Vector,this->VK()); + key->Key = KMX_VKUnderlyingLayoutToVKUS_GDK(keymap,this->VK()); key->Line = 0; if(bDeadkeyConversion) { // I4552 @@ -365,15 +372,18 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; if(st[ich] < 0x20 || st[ich] == 0x7F) { isvalid=false; break; } } if(isvalid) { - // _S2 this fun returns the shifted Char instead of keyname -> use gdk function!! - key->Key = KMX_VKUnderlyingLayoutToVKUS(All_Vector,this->VK()); + //key->Key = KMX_VKUnderlyingLayoutToVKUS(All_Vector,this->VK()); + key->Key = KMX_VKUnderlyingLayoutToVKUS_GDK(keymap,this->VK()); std::wstring w1_S2 = get_m_rgss(ss,caps); - wprintf(L" --- %ls ",w1_S2.c_str()); + wprintf(L"\n KMX_VKUnderlyingLayoutToVKUS_GD writes %ls %c",w1_S2.c_str(), key->Key ); key->Line = 0; + // _S2 _differences in sstateflag probably from here and KMX_IsCapsEqualToShift... key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); key->dpContext = new KMX_WCHAR; *key->dpContext = 0; p = key->dpOutput = new KMX_WCHAR[st.size() + 1]; - for(size_t ich = 0; ich < st.size(); ich++) *p++ = st[ich]; + for(size_t ich = 0; ich < st.size(); ich++) { + q=p; + *p++ = st[ich];} *p = 0; key++; } @@ -725,9 +735,25 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd UINT VK_Other = Lin_KM__map(iKey, All_Vector); - // _S2 only for testing can go later helps to force filling rgkey[VK_DE] + // _S2 only for testing can go later helps to force filling rgkey[VK_DE]---v---- UINT iKey_DE = map_Ikey_DE(iKey); UINT iKey_FR = map_Ikey_FR(iKey); + if ( rgKey[iKey]->VK() == 89 ) rgKey[iKey]->set_sc(52); + if ( rgKey[iKey]->VK() == 90 ) rgKey[iKey]->set_sc(29); + if ( rgKey[iKey]->VK() == 186 ) rgKey[iKey]->set_sc(34); + if ( rgKey[iKey]->VK() == 187 ) rgKey[iKey]->set_sc(35); + if ( rgKey[iKey]->VK() == 188 ) rgKey[iKey]->set_sc(59); + if ( rgKey[iKey]->VK() == 189 ) rgKey[iKey]->set_sc(61); + if ( rgKey[iKey]->VK() == 190 ) rgKey[iKey]->set_sc(60); + if ( rgKey[iKey]->VK() == 191 ) rgKey[iKey]->set_sc(51); + if ( rgKey[iKey]->VK() == 192 ) rgKey[iKey]->set_sc(47); + if ( rgKey[iKey]->VK() == 219 ) rgKey[iKey]->set_sc(20); + if ( rgKey[iKey]->VK() == 220 ) rgKey[iKey]->set_sc(49); + if ( rgKey[iKey]->VK() == 221 ) rgKey[iKey]->set_sc(21); + if ( rgKey[iKey]->VK() == 222 ) rgKey[iKey]->set_sc(48); + if ( rgKey[iKey]->VK() == 226 ) rgKey[iKey]->set_sc(94); + + // _S2 only for testing can go later helps to force filling rgkey[VK_DE]---^---- for(ShiftState ss = Base; ss <= loader.MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { if(ss == Menu || ss == ShftMenu) { @@ -901,7 +927,7 @@ int testval= 38; //wprintf(L"********************************* I use Key Nr %i\n",iKey); // for each item, wprintf(L" \n iKey = %i, nKeys %i + Delta:\t%i", iKey,nKeys, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState())); - if(rgKey[iKey]->KMX_LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector)) { // I4552 + if(rgKey[iKey]->KMX_LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); } } diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 5646bd46e4..9f11a247b1 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -215,6 +215,16 @@ KMX_WORD KMX_VKUnderlyingLayoutToVKUS(v_dw_3D &All_Vector,KMX_DWORD inOther) { } return inOther; } + +KMX_WCHART KMX_VKUnderlyingLayoutToVKUS_GDK(GdkKeymap* keymap,KMX_DWORD VK_US) { + + KMX_WORD VK_DE = ( KMX_WORD ) map_Ikey_DE(VK_US); + if(VK_DE!= VK_US) + return VK_DE; + else + return VK_US; +} + // takes VK of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] KMX_DWORD KMX_CharFromVK(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey){ diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index e7f4e8c8b7..f6f5179af6 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -44,7 +44,7 @@ extern std::vector KMX_FDeadkeys; // I4353 // _S2 is this correct here??? KMX_WORD KMX_VKUnderlyingLayoutToVKUS(KMX_WORD VKey); KMX_WORD KMX_VKUnderlyingLayoutToVKUS(v_dw_3D &All_Vector,KMX_DWORD inOther); - +KMX_WCHART KMX_VKUnderlyingLayoutToVKUS_GDK(GdkKeymap* keymap,KMX_DWORD inOther); //--------------------old /* #include From 0ce6b413b6197950cd63b6a1098f4c6b7d76ad60 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 27 Nov 2023 16:22:18 +0100 Subject: [PATCH 135/327] feat(linux): mcompile change LayoutRow to use Linux-Style shiftstates --- linux/mcompile/keymap/mc_import_rules.cpp | 139 ++++++++++++---------- 1 file changed, 77 insertions(+), 62 deletions(-) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 374c1d0b6f..0097b7573b 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -203,15 +203,16 @@ public: (stShift.compare(stShiftCaps) != 0))); } +// _S2 is character () bool KMX_IsCapsEqualToShift() { - std::wstring stBase = this->KMX_GetShiftState(Base, false); - std::wstring stShift = this->KMX_GetShiftState(Shft, false); - std::wstring stCaps = this->KMX_GetShiftState(Base, true); + std::wstring stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß + std::wstring stShift = this->KMX_GetShiftState(Shft, false); // 0,0 A $ ? + std::wstring stCaps = this->KMX_GetShiftState(Base, true); // 0,0 A 4 ẞ return ( - (stBase.size() > 0) && - (stShift.size() > 0) && - (stBase.compare(stShift) != 0) && - (stShift.compare(stCaps) == 0)); + (stBase.size() > 0) && // char inside + (stShift.size() > 0) && // char inside + (stBase.compare(stShift) != 0) && // stBase != stShft + (stShift.compare(stCaps) == 0)); // stShft == stCaps } bool KMX_IsAltGrCapsEqualToAltGrShift() { @@ -252,6 +253,8 @@ public: } UINT KMX_GetShiftStateValue(int capslock, int caps, ShiftState ss) { + wprintf(L"GetShiftStateValue takes capslock: %i, caps: %i, ss: %i and returns: %i\n", capslock, caps, ss, KMX_ShiftStateMap[(int)ss] | + (capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0)); return KMX_ShiftStateMap[(int)ss] | (capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0); @@ -261,25 +264,12 @@ public: int nkeys = 0; // Get the CAPSLOCK value - -bool b1= this->KMX_IsCapsEqualToShift(); -bool b2= this->KMX_IsSGCAPS(); -bool b3= this->KMX_IsAltGrCapsEqualToAltGrShift(); -bool b4= this->KMX_IsXxxxGrCapsEqualToXxxxShift(); - -int i1 = this->KMX_IsCapsEqualToShift() ? 1 : 0; -int i2 = this->KMX_IsSGCAPS() ? 2 : 0; -int i3 = this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0; -int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; - - - - - int capslock = + //_S2 not used + /*int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | (this->KMX_IsSGCAPS() ? 2 : 0) | (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0);*/ for (int ss = 0; ss <= MaxShiftState; ss++) { if (ss == Menu || ss == ShftMenu) { @@ -323,12 +313,59 @@ int i3 = this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0; int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; + // _S2 original: + /*int capslock = + (this->IsCapsEqualToShift() ? 1 : 0) | + (this->IsSGCAPS() ? 2 : 0) | + (this->IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | + (this->IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0);*/ - int capslock = + +// _S2 change! only for testing helps to force filling rgkey[VK_DE] +int capslock; + + // numbers: + if( (this->m_vk>=48) && (this->m_vk<=57) ) { + capslock = + (this->KMX_IsCapsEqualToShift() ? 0 : 1) | + (this->KMX_IsSGCAPS() ? 2 : 0) | + (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | + (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + } + // characters: + else if( (this->m_vk>=65) && (this->m_vk<=90) ) { + capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | (this->KMX_IsSGCAPS() ? 2 : 0) | (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + } + // ä,ö,ü: + else if( (this->m_vk==32) ||(this->m_vk==186) ||(this->m_vk==192)|| (this->m_vk==222) ) { + capslock = + (this->KMX_IsCapsEqualToShift() ? 1 : 0) | + (this->KMX_IsSGCAPS() ? 2 : 0) | + (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | + (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + } + // < and _: + else if( (this->m_vk==189) || (this->m_vk==220) || (this->m_vk==221) || (this->m_vk==226) ) { + capslock = + (this->KMX_IsCapsEqualToShift() ? 1 : 0) | + (this->KMX_IsSGCAPS() ? 2 : 0) | + (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | + (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + } + // punctuation Char: + else { + capslock = + (this->KMX_IsCapsEqualToShift() ? 0 : 1) | + (this->KMX_IsSGCAPS() ? 2 : 0) | + (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | + (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + } + + for (int ss = 0; ss <= MaxShiftState; ss++) { if (ss == Menu || ss == ShftMenu) { @@ -375,7 +412,9 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; //key->Key = KMX_VKUnderlyingLayoutToVKUS(All_Vector,this->VK()); key->Key = KMX_VKUnderlyingLayoutToVKUS_GDK(keymap,this->VK()); std::wstring w1_S2 = get_m_rgss(ss,caps); - wprintf(L"\n KMX_VKUnderlyingLayoutToVKUS_GD writes %ls %c",w1_S2.c_str(), key->Key ); + //wprintf(L"\n KMX_VKUnderlyingLayoutToVKUS_GD writes %ls %c",w1_S2.c_str(), key->Key ); + + wprintf(L" this->VK(): %i ", this->VK()); key->Line = 0; // _S2 _differences in sstateflag probably from here and KMX_IsCapsEqualToShift... key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); @@ -752,7 +791,6 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd if ( rgKey[iKey]->VK() == 221 ) rgKey[iKey]->set_sc(21); if ( rgKey[iKey]->VK() == 222 ) rgKey[iKey]->set_sc(48); if ( rgKey[iKey]->VK() == 226 ) rgKey[iKey]->set_sc(94); - // _S2 only for testing can go later helps to force filling rgkey[VK_DE]---^---- for(ShiftState ss = Base; ss <= loader.MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { @@ -776,35 +814,11 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd //_S2 TODO get char - do I need rc ?? ( was rc = ToUnicodeEx...) //std::wstring KeyVal_Other_OLD = get_VirtualKey_Other_from_iKey(VK_Other, ss, caps, All_Vector); std::wstring KeyVal_Other = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, SC_US, ss, caps); - std::wstring KeyVal_Other3 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, SC_US, ss, caps); //std::wstring KeyVal_OtherTEST6 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 51, MenuCtrl, 0); // std::wstring KeyVal_OtherTEST16 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 51, MenuCtrl, 1); -int testval= 38; - std::wstring KeyVal_OtherTEST; - std::wstring KeyVal_OtherTEST0 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, Base, 0); - std::wstring KeyVal_OtherTEST1= get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, Shft, 0); - std::wstring KeyVal_OtherTEST2 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, Ctrl, 0); - std::wstring KeyVal_OtherTEST3 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, ShftCtrl, 0); - std::wstring KeyVal_OtherTEST4 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, Menu, 0); - std::wstring KeyVal_OtherTEST5 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, ShftMenu, 0); - std::wstring KeyVal_OtherTEST7 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, ShftMenuCtrl, 0); - std::wstring KeyVal_OtherTEST8 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, Xxxx, 0); - std::wstring KeyVal_OtherTEST9 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, ShftXxxx, 0); - std::wstring KeyVal_OtherTEST10 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, Base, 1); - std::wstring KeyVal_OtherTEST11 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, Shft, 1); - std::wstring KeyVal_OtherTEST12 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, Ctrl, 1); - std::wstring KeyVal_OtherTEST13 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, ShftCtrl, 1); - std::wstring KeyVal_OtherTEST14 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, Menu, 1); - std::wstring KeyVal_OtherTEST15 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, ShftMenu, 1); - std::wstring KeyVal_OtherTEST17 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, ShftMenuCtrl, 1); - std::wstring KeyVal_OtherTEST18 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, Xxxx, 1); - std::wstring KeyVal_OtherTEST19 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, ShftXxxx, 1); - std::wstring KeyVal_OtherTEST20 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, MenuCtrl, 0); - std::wstring KeyVal_OtherTEST21 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, testval, MenuCtrl, 1); - // _S2 needs to be changed - it's temporary to get the same keys as keyman does when using USVirtualKeyToScanCode prevents chars like ሴ if (!IsKeymanUsedKeyVal(KeyVal_Other)) KeyVal_Other = L"\0"; @@ -848,16 +862,15 @@ int testval= 38; for ( int i=0; i < (int) TestValues.size();i++) { std::wstring wws = rgKey[TestValues[i]]->get_m_rgss(0,0); - wprintf(L"Results for %i\t: %ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \n", - TestValues[i], - rgKey[TestValues[i]]->get_m_rgss(0,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(0,0)[0], - rgKey[TestValues[i]]->get_m_rgss(0,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(0,1)[0], - rgKey[TestValues[i]]->get_m_rgss(1,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(1,0)[0], - rgKey[TestValues[i]]->get_m_rgss(1,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(1,1)[0], - rgKey[TestValues[i]]->get_m_rgss(6,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(6,0)[0], - rgKey[TestValues[i]]->get_m_rgss(6,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(6,1)[0], - rgKey[TestValues[i]]->get_m_rgss(7,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(7,0)[0], - rgKey[TestValues[i]]->get_m_rgss(7,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(7,1)[0] + wprintf(L"Results for %i\t: %ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \n", TestValues[i], + rgKey[TestValues[i]]->get_m_rgss(0,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(0,0)[0], + rgKey[TestValues[i]]->get_m_rgss(0,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(0,1)[0], + rgKey[TestValues[i]]->get_m_rgss(1,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(1,0)[0], + rgKey[TestValues[i]]->get_m_rgss(1,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(1,1)[0], + rgKey[TestValues[i]]->get_m_rgss(6,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(6,0)[0], + rgKey[TestValues[i]]->get_m_rgss(6,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(6,1)[0], + rgKey[TestValues[i]]->get_m_rgss(7,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(7,0)[0], + rgKey[TestValues[i]]->get_m_rgss(7,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(7,1)[0] ); } wprintf(L"-----------------\n"); @@ -921,12 +934,12 @@ int testval= 38; // // Fill in the new rules // - +int STOP=0; // _S2 LayoutRow: VKToUnderlying should work OK; GetSSValue not checked yet, but this is definitely different for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { //wprintf(L"********************************* I use Key Nr %i\n",iKey); // for each item, - wprintf(L" \n iKey = %i, nKeys %i + Delta:\t%i", iKey,nKeys, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState())); + //wprintf(L" \n iKey = %i, nKeys %i + Delta:\t%i", iKey,nKeys, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState())); if(rgKey[iKey]->KMX_LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); } @@ -942,6 +955,7 @@ int testval= 38; for(UINT i = 0; i < kp->cxGroupArray - 1; i++, gp2++) { if(gp2->fUsingKeys && gp2->dpNoMatch == NULL) { KMX_WCHAR *p = gp2->dpNoMatch = new KMX_WCHAR[4]; + KMX_WCHAR *q = p; *p++ = UC_SENTINEL; *p++ = CODE_USE; *p++ = (KMX_WCHAR)(kp->cxGroupArray); @@ -966,6 +980,7 @@ int testval= 38; kkp2->ShiftFlags = kkp->ShiftFlags; kkp2->Line = 0; KMX_WCHAR *p = kkp2->dpOutput = new KMX_WCHAR[4]; + KMX_WCHAR *q=p; *p++ = UC_SENTINEL; *p++ = CODE_USE; *p++ = (KMX_WCHAR)(kp->cxGroupArray); From 7cd43792ab1499756b9a3e7456b4b0c042a9d5d2 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 28 Nov 2023 20:43:33 +0100 Subject: [PATCH 136/327] feat(linux): mcompile start deadkeys, KMX_Lin_ImportRules_Lin --- linux/mcompile/keymap/mc_import_rules.cpp | 526 +++++++++++++++++++++- linux/mcompile/keymap/mcompile.cpp | 13 + 2 files changed, 537 insertions(+), 2 deletions(-) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 0097b7573b..5a58e6c2e6 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -414,6 +414,147 @@ int capslock; std::wstring w1_S2 = get_m_rgss(ss,caps); //wprintf(L"\n KMX_VKUnderlyingLayoutToVKUS_GD writes %ls %c",w1_S2.c_str(), key->Key ); + wprintf(L" this->VK(): %i ", this->VK()); + key->Line = 0; + // _S2 _differences in sstateflag probably from here and KMX_IsCapsEqualToShift... + key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); + key->dpContext = new KMX_WCHAR; *key->dpContext = 0; + p = key->dpOutput = new KMX_WCHAR[st.size() + 1]; + for(size_t ich = 0; ich < st.size(); ich++) { + q=p; + *p++ = st[ich];} + *p = 0; + key++; + } + } + } + } + return true; + } + + bool KMX_LayoutRow_Lin(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,v_dw_3D &All_Vector, GdkKeymap * keymap) { // I4552 + // Get the CAPSLOCK value + + +bool b1= this->KMX_IsCapsEqualToShift(); +bool b2= this->KMX_IsSGCAPS(); +bool b3= this->KMX_IsAltGrCapsEqualToAltGrShift(); +bool b4= this->KMX_IsXxxxGrCapsEqualToXxxxShift(); + +int i1 = this->KMX_IsCapsEqualToShift() ? 1 : 0; +int i2 = this->KMX_IsSGCAPS() ? 2 : 0; +int i3 = this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0; +int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; + + + // _S2 original: + /*int capslock = + (this->IsCapsEqualToShift() ? 1 : 0) | + (this->IsSGCAPS() ? 2 : 0) | + (this->IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | + (this->IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0);*/ + + +// _S2 change! only for testing helps to force filling rgkey[VK_DE] +int capslock; + + // numbers: + if( (this->m_vk>=48) && (this->m_vk<=57) ) { + capslock = + (this->KMX_IsCapsEqualToShift() ? 0 : 1) | + (this->KMX_IsSGCAPS() ? 2 : 0) | + (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | + (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + } + // characters: + else if( (this->m_vk>=65) && (this->m_vk<=90) ) { + capslock = + (this->KMX_IsCapsEqualToShift() ? 1 : 0) | + (this->KMX_IsSGCAPS() ? 2 : 0) | + (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | + (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + } + // ä,ö,ü: + else if( (this->m_vk==32) ||(this->m_vk==186) ||(this->m_vk==192)|| (this->m_vk==222) ) { + capslock = + (this->KMX_IsCapsEqualToShift() ? 1 : 0) | + (this->KMX_IsSGCAPS() ? 2 : 0) | + (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | + (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + } + // < and _: + else if( (this->m_vk==189) || (this->m_vk==220) || (this->m_vk==221) || (this->m_vk==226) ) { + capslock = + (this->KMX_IsCapsEqualToShift() ? 1 : 0) | + (this->KMX_IsSGCAPS() ? 2 : 0) | + (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | + (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + } + // punctuation Char: + else { + capslock = + (this->KMX_IsCapsEqualToShift() ? 0 : 1) | + (this->KMX_IsSGCAPS() ? 2 : 0) | + (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | + (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + } + + + + for (int ss = 0; ss <= MaxShiftState; ss++) { + if (ss == Menu || ss == ShftMenu) { + // Alt and Shift+Alt don't work, so skip them + continue; + } + for (int caps = 0; caps <= 1; caps++) { + std::wstring st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); + PKMX_WCHAR p; // was PWSTR p; + PKMX_WCHAR q; + + if (st.size() == 0) { + // No character assigned here + } + // _S2 deadkeys don't work yet + else if (this->m_rgfDeadKey[(int)ss][caps]) { + // It's a dead key, append an @ sign. + key->dpContext = new KMX_WCHAR[1]; + *key->dpContext = 0; + key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); + // _S2 this fun returns the shifted Char it goes wrog for numbers, special here!! + //key->Key = KMX_VKUnderlyingLayoutToVKUS(All_Vector,this->VK()); + key->Key = KMX_VKUnderlyingLayoutToVKUS_GDK(keymap,this->VK()); + key->Line = 0; + + if(bDeadkeyConversion) { // I4552 + p = key->dpOutput = new KMX_WCHAR[2]; + *p++ = st[0]; + *p = 0; + } else { + p = key->dpOutput = new KMX_WCHAR[4]; + *p++ = UC_SENTINEL; + *p++ = CODE_DEADKEY; + *p++ = KMX_DeadKeyMap(st[0], deadkeys, deadkeyBase, &KMX_FDeadkeys); // I4353 + *p = 0; + } + key++; + } else { + bool isvalid = true; + for (size_t ich = 0; ich < st.size(); ich++) { + if(st[ich] < 0x20 || st[ich] == 0x7F) { isvalid=false; break; } + } + if(isvalid) { + // wrong function!! + //key->Key = KMX_VKUnderlyingLayoutToVKUS(All_Vector,this->VK()); + key->Key = KMX_VKUnderlyingLayoutToVKUS_GDK(keymap,this->VK()); + std::wstring w1_S2 = get_m_rgss(ss,caps); + //wprintf(L"\n KMX_VKUnderlyingLayoutToVKUS_GD writes %ls %c ( from %i) \n",w1_S2.c_str(), key->Key , this->VK()); + + if(key->Key != this->VK()) +wprintf(L"\n key->Key AND this->VK() different %i ( from %i) \n", key->Key , this->VK()); + + + + wprintf(L" this->VK(): %i ", this->VK()); key->Line = 0; // _S2 _differences in sstateflag probably from here and KMX_IsCapsEqualToShift... @@ -668,10 +809,388 @@ bool IsKeymanUsedKeyVal(std::wstring Keyval) { } +void Inspect_kp(LPKMX_KEYBOARD kp) { + wprintf(L"-------\n"); + wprintf(L"-------\n"); + wprintf(L"-------\n"); + wprintf(L"kp has %i groups and %i keys\n",kp->cxGroupArray, kp->dpGroupArray->cxKeyArray); + wprintf(L"-------\n"); + +//for ( int i=0; i<150;i++) { +for ( int i=0; idpGroupArray->cxKeyArray;i++) { + wprintf(L"key nr :%i has key:%i(%c) Line:%i Shiftflags:%i Output %c (%d)\n",i,kp->dpGroupArray->dpKeyArray->Key,kp->dpGroupArray->dpKeyArray->Key, + kp->dpGroupArray->dpKeyArray->Line,kp->dpGroupArray->dpKeyArray->ShiftFlags ,kp->dpGroupArray->dpKeyArray->dpOutput,*kp->dpGroupArray->dpKeyArray->dpOutput ); + kp->dpGroupArray->dpKeyArray++; +} + wprintf(L"-------\n"); + wprintf(L"-------\n"); + wprintf(L"-------\n"); +} + + +bool KMX_Lin_ImportRules_Lin(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 + KMX_Loader loader; + const size_t BUF_sz= 256; + //Inspect_kp(kp); // _ _S2 only open for inspecting; if used when running the program it will crash :-( ) + KMX_HKL hkl = NULL; //_S2 added: but can I do this?? hkl is not needed in Linux?? + + BYTE lpKeyState[256];// = new KeysEx[256]; + std::vector rgKey; //= new VirtualKey[256]; + std::vector alDead; + + KMX_VirtualKey* rgKey_single = new KMX_VirtualKey(1, hkl, All_Vector, keymap); + UINT nkeys_single =0; + + rgKey.resize(256); + + // _S2 scroll through OTHER + // Scroll through the Scan Code (SC) values and get the valid Virtual Key (VK) + // values in it. Then, store the SC in each valid VK so it can act as both a + // flag that the VK is valid, and it can store the SC value. + for(UINT sc = 0x01; sc <= 0x7f; sc++) { + // fills m_vk with the VK of the US keyboard which is not right!! + // ( mcompile win uses MapVirtualKeyEx() to fill m_vk with the VK of the Other keyboard) + // Linux cant get a VK for the US Keyboard using USVirtualKeyToScanCode/ScanCodeToUSVirtualKey + // Linux cannot get a VK for Other Keyboard + // it could return SC if that helps + KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector, keymap); + if((key->VK() != 0) && (key->VK()< 255)) { // if used without ScanCodeToUSVirtualKey[] + rgKey[key->VK()] = key; + } else { + delete key; + } + } + + for(UINT ke = VK_NUMPAD0; ke <= VK_NUMPAD9; ke++) { + rgKey[ke] = new KMX_VirtualKey(hkl, ke, All_Vector, keymap); + } + + rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE, All_Vector, keymap); + rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL, All_Vector, keymap); + rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL, All_Vector, keymap); + +/* + // _S2 do we need special shift state now or later? + // See if there is a special shift state added + for(UINT vk = 0; vk <= VK_OEM_CLEAR; vk++) { + UINT sc = MapVirtualKeyEx(vk, 0, hkl); + UINT vkL = MapVirtualKeyEx(sc, 1, hkl); + UINT vkR = MapVirtualKeyEx(sc, 3, hkl); + if((vkL != vkR) && + (vk != vkL)) { + switch(vk) { + case VK_LCONTROL: + case VK_RCONTROL: + case VK_LSHIFT: + case VK_RSHIFT: + case VK_LMENU: + case VK_RMENU: + break; + + default: + loader.Set_XxxxVk(vk); + break; + } + } + } +*/ + + + // _S2 in this part we skip shiftstates 4, 5, 8, 9 + for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { + if(rgKey[iKey] != NULL) { + WCHAR sbBuffer[256]; // Scratchpad we use many places + + for(ShiftState ss = Base; ss <= loader.MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { + if(ss == Menu || ss == ShftMenu) { + continue; // Alt and Shift+Alt don't work, so skip them + } + + KMX_DWORD SC_US = get_KeyCode_fromVKUS(iKey); // _S2 only for testing can go later helps to force filling rgkey[VK_DE] + + for(int caps = 0; caps <= 1; caps++) { + //_S2 TODO get char - do I need rc ?? ( was rc = ToUnicodeEx...) + std::wstring KeyVal_Other = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, SC_US, ss, caps); + + if (!IsKeymanUsedKeyVal(KeyVal_Other)) + KeyVal_Other = L"\0"; + + //_S2 TODO do I need that ?? + //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { + if(KeyVal_Other == L"") { + //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); + rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps)); + rgKey_single->KMX_SetShiftState(ss, L"", false, (caps)); + } + + //_S2 TODO + //else // if rc ==1 : it got 1 char && +40 in Buffer CTRl pressed { + //It's dealing with control characters. If ToUnicodeEx gets VK_A with the Ctrl key pressed, + //it will write 0x01 to sBuffer[0] , without Ctrl it's 0x41. The if detects this case. + //&& CTRl +0x40 in the buffer ( which indicates a ctrl press) + if( (ss == Ctrl || ss == ShftCtrl) /*&& CTRl +0x40 in the buffer ( which indicates a ctrl press) */) { + continue; + } + + //_S2 TODO fill m_rgfDeadkey ( m_rgfDeadkey will be done later) + //rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps==0)); + rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps)); + rgKey_single->KMX_SetShiftState(ss, KeyVal_Other, false, (caps)); + //if( KeyVal_Other != L"") + if( IsKeymanUsedKeyVal(KeyVal_Other) ) + nkeys_single ++ ; + int ertzu=888; + + + //_S2 TODO + // _S2 handle deadkeys later + // if rc <0: it got a deadkey { + // fill m_rgss and m_rgfDeadkey and alDead + //SET_SHIFTSTATES( deadkey) //sbuffer is value out of ToUnicodeEx / AllVector + // do more stuff for deadkeys... + // } from rc<0 + } + } + } + } + + + //------------------------------------------------------------- + // Now that we've collected the key data, we need to + // translate it to kmx and append to the existing keyboard + //------------------------------------------------------------- + + int nDeadkey = 0; + LPKMX_GROUP gp = new KMX_GROUP[kp->cxGroupArray+4]; // leave space for old + memcpy(gp, kp->dpGroupArray, sizeof(KMX_GROUP) * kp->cxGroupArray); + + // + + // Find the current highest deadkey index + // + + kp->dpGroupArray = gp; + for(UINT i = 0; i < kp->cxGroupArray; i++, gp++) { + //if(gp->fUsingKeys && gp->dpNoMatch == NULL) { // I4550 + // WCHAR *p = gp->dpNoMatch = new WCHAR[4]; + // *p++ = UC_SENTINEL; + // *p++ = CODE_USE; + // *p++ = (WCHAR)(kp->cxGroupArray + 1); + // *p = 0; + //} + LPKMX_KEY kkp = gp->dpKeyArray; + + for(UINT j = 0; j < gp->cxKeyArray; j++, kkp++) { + nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpContext)); + nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpOutput)); + } + } + + // _S2 find nkeys + /*kp->cxGroupArray++; + gp = &kp->dpGroupArray[kp->cxGroupArray-1]; + UINT nKeys = 0; + for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { + if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { + nKeys+= rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); + wprintf(L" iKey = %i, Delta: %i -> Sum %i\n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()), nKeys); + } + }*/ + + nDeadkey++; // ensure a 1-based index above the max deadkey value already in the keyboard + + gp->fUsingKeys = TRUE; + gp->dpMatch = NULL; + gp->dpName = NULL; + gp->dpNoMatch = NULL; + //gp->cxKeyArray = nKeys; + gp->cxKeyArray = nkeys_single; + gp->dpKeyArray = new KMX_KEY[gp->cxKeyArray]; + UINT nKeys = 0; + + + // + // Fill in the new rules + // + for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { + if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { + if(rgKey[iKey]->KMX_LayoutRow_Lin(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 + //if(rgKey_single->KMX_LayoutRow_Lin(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 + + nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); + wprintf(L"nKeys sum: %i\n", nKeys); + } + } + } + + // --------------------------------------------------------------------------------------------- + + // A _S2 Look at the character in the key rule, + + // e.g. + 'y' > '... (so, key->Key == 'y' && key->ShiftFlags == 0) + KMX_WCHAR key_key; + KMX_DWORD key_shiftFlag; + // --------------------------------------------------------------------------------------------- + // B _S2 Find the key data by finding 'y' keyval in the target layout. (DE?) + // --------------------------------------------------------------------------------------------- + // C _S2 Look up the scan code (and modifiers) associated with that keyval. + // --------------------------------------------------------------------------------------------- + // D _S2 Use that scan code to get the US english vkey equivalent via ScanCodeToUSVirtualKey[] + // --------------------------------------------------------------------------------------------- + // E _S2 Rewrite the key rule to + [K_Z] > ... + // --------------------------------------------------------------------------------------------- + // F _S2 Nuance needed around modifier keys (so it may need to be + [SHIFT K_Z] for 'Y', for example). + // --------------------------------------------------------------------------------------------- + // Keyval(DE) -> SC_DE -> SC_US -> VK_US + // --------------------------------------------------------------------------------------------- + + + // _S2 no changes here after removing rgkey + gp->cxKeyArray = nKeys; + + // + // Add nomatch control to each terminating 'using keys' group // I4550 + // + LPKMX_GROUP gp2 = kp->dpGroupArray; + for(UINT i = 0; i < kp->cxGroupArray - 1; i++, gp2++) { + if(gp2->fUsingKeys && gp2->dpNoMatch == NULL) { + KMX_WCHAR *p = gp2->dpNoMatch = new KMX_WCHAR[4]; + KMX_WCHAR *q = p; + *p++ = UC_SENTINEL; + *p++ = CODE_USE; + *p++ = (KMX_WCHAR)(kp->cxGroupArray); + *p = 0; + + // _S2 TODO not sure if this works OK -> we need to use more shiftstates than base+Shift + // I4550 - Each place we have a nomatch > use(baselayout) (this last group), we need to add all + // the AltGr and ShiftAltGr combinations as rules to allow them to be matched as well. Yes, this + // loop is not very efficient but it's not worthy of optimisation. + // + UINT j; + LPKMX_KEY kkp; + for(j = 0, kkp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kkp++) { + wprintf(L"key: kkp->key%i(%c) and SFlag %i\n",kkp->Key,kkp->Key,kkp->ShiftFlags ); + //wprintf(L"key: gp ->key%i(%c) and SFlag %i\n",gp->dpKeyArray->Key,gp->dpKeyArray->Key,gp->dpKeyArray->ShiftFlags ); + //wprintf(L"key: gp2->key%i(%c) and SFlag %i\n",gp2->dpKeyArray->Key,gp2->dpKeyArray->Key,gp2->dpKeyArray->ShiftFlags ); + //wprintf(L"key: kp ->key%i(%c) and SFlag %i\n",kp->dpGroupArray->dpKeyArray->Key,kp->dpGroupArray->dpKeyArray->Key,kp->dpGroupArray->dpKeyArray->ShiftFlags ); + /*&& CTRl +0x40 in the buffer ( which indicates a ctrl press) */ + if((kkp->ShiftFlags & (K_CTRLFLAG|K_ALTFLAG|LCTRLFLAG|LALTFLAG|RCTRLFLAG|RALTFLAG)) != 0) { + gp2->cxKeyArray++; + LPKMX_KEY kkp2 = new KMX_KEY[gp2->cxKeyArray]; + memcpy(kkp2, gp2->dpKeyArray, sizeof(KMX_KEY)*(gp2->cxKeyArray-1)); + gp2->dpKeyArray = kkp2; + kkp2 = &kkp2[gp2->cxKeyArray-1]; + kkp2->dpContext = new KMX_WCHAR; *kkp2->dpContext = 0; + kkp2->Key = kkp->Key; + kkp2->ShiftFlags = kkp->ShiftFlags; + kkp2->Line = 0; + KMX_WCHAR *p = kkp2->dpOutput = new KMX_WCHAR[4]; + KMX_WCHAR *q=p; + *p++ = UC_SENTINEL; + *p++ = CODE_USE; + *p++ = (KMX_WCHAR)(kp->cxGroupArray); + *p = 0; + } + } + } + } + + if (alDead.size() > 0 && !bDeadkeyConversion) { // I4552 + kp->cxGroupArray++; + + KMX_WCHAR *p = gp->dpMatch = new KMX_WCHAR[4]; + *p++ = UC_SENTINEL; + *p++ = CODE_USE; + *p++ = (KMX_WCHAR) kp->cxGroupArray; + *p = 0; + + gp++; + + gp->fUsingKeys = FALSE; + gp->dpMatch = NULL; + gp->dpName = NULL; + gp->dpNoMatch = NULL; + gp->cxKeyArray = alDead.size(); + LPKMX_KEY kkp = gp->dpKeyArray = new KMX_KEY[alDead.size()]; + + LPKMX_STORE sp = new KMX_STORE[kp->cxStoreArray + alDead.size() * 2]; + memcpy(sp, kp->dpStoreArray, sizeof(KMX_STORE) * kp->cxStoreArray); + + kp->dpStoreArray = sp; + + sp = &sp[kp->cxStoreArray]; + int nStoreBase = kp->cxStoreArray; + kp->cxStoreArray += alDead.size() * 2; + + for(UINT i = 0; i < alDead.size(); i++) { + DeadKey *dk = alDead[i]; + + sp->dpName = NULL; + sp->dwSystemID = 0; + sp->dpString = new KMX_WCHAR[dk->KMX_Count() + 1]; + for(int j = 0; j < dk->KMX_Count(); j++) + sp->dpString[j] = dk->KMX_GetBaseCharacter(j); + sp->dpString[dk->KMX_Count()] = 0; + sp++; + + sp->dpName = NULL; + sp->dwSystemID = 0; + sp->dpString = new KMX_WCHAR[dk->KMX_Count() + 1]; + for(int j = 0; j < dk->KMX_Count(); j++) + sp->dpString[j] = dk->KMX_GetCombinedCharacter(j); + sp->dpString[dk->KMX_Count()] = 0; + sp++; + + kkp->Line = 0; + kkp->ShiftFlags = 0; + kkp->Key = 0; + KMX_WCHAR *p = kkp->dpContext = new KMX_WCHAR[8]; + *p++ = UC_SENTINEL; + *p++ = CODE_DEADKEY; + *p++ = KMX_DeadKeyMap(dk->KMX_DeadCharacter(), &alDead, nDeadkey, FDeadkeys); // I4353 + // *p++ = nDeadkey+i; + *p++ = UC_SENTINEL; + *p++ = CODE_ANY; + *p++ = nStoreBase + i*2 + 1; + *p = 0; + + p = kkp->dpOutput = new KMX_WCHAR[5]; + *p++ = UC_SENTINEL; + *p++ = CODE_INDEX; + *p++ = nStoreBase + i*2 + 2; + *p++ = 2; + *p = 0; + + kkp++; + } + } +return true; +} + + + + +void Inspect_gp(KMX_tagGROUP* gp) { + for (int i = 0; i < gp->cxKeyArray; i++) { + wprintf(L"key nr : has key:%i(%c) Line:%i Shiftflags:%i Output %c (%d)\n", gp->dpKeyArray->Key, gp->dpKeyArray->Key, + gp->dpKeyArray->Line, gp->dpKeyArray->ShiftFlags, gp->dpKeyArray->dpOutput, *gp->dpKeyArray->dpOutput); + // gp->cxKeyArray++; + } +} + +void Inspect_key(LPKMX_KEY key) { + //for (int i = 0; i < gp->cxKeyArray; i++) { + wprintf(L"key nr : has key:%i(%c) Line:%i Shiftflags:%i Output \n", key->Key, key->Key, + key->Line, key->ShiftFlags); + /*wprintf(L"key nr : has key:%i(%c) Line:%i Shiftflags:%i Output %c (%d)\n", key->Key, key->Key, + key->Line, key->ShiftFlags, key->dpOutput, *key->dpOutput);*/ + // gp->cxKeyArray++; + // } +} bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 KMX_Loader loader; const size_t BUF_sz= 256; - +//Inspect_kp(kp); // _S2 do I need that for Linux?? KMX_WCHAR inputHKL[12]; u16sprintf(inputHKL,BUF_sz ,L"%08.8x", (unsigned int) u16tol(kbid, NULL, 16)); // _S2 wsprintf(inputHKL, L"%08.8x", (unsigned int) wcstol(kbid, NULL, 16)); @@ -934,6 +1453,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd // // Fill in the new rules // + int STOP=0; // _S2 LayoutRow: VKToUnderlying should work OK; GetSSValue not checked yet, but this is definitely different for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { @@ -942,6 +1462,7 @@ int STOP=0; // _S2 LayoutRow: VKToUnderlying should work OK; GetSSValue not che //wprintf(L" \n iKey = %i, nKeys %i + Delta:\t%i", iKey,nKeys, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState())); if(rgKey[iKey]->KMX_LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); + //Inspect_key(&gp->dpKeyArray[nKeys]); } } } @@ -1064,5 +1585,6 @@ int STOP=0; // _S2 LayoutRow: VKToUnderlying should work OK; GetSSValue not che kkp++; } } + //Inspect_kp(kp); return true; -} \ No newline at end of file +} diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 9f11a247b1..b3853680c3 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -39,6 +39,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]); bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 +bool KMX_Lin_ImportRules_Lin(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 std::vector KMX_FDeadkeys; // I4353 @@ -251,8 +252,19 @@ KMX_DWORD KMX_CharFromVK(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VK // takes SC of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] KMX_WCHAR KMX_CharFromSC(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey) { + int VKShiftState_lin = map_VKShiftState_to_Lin(VKShiftState); KMX_DWORD KeyvalOther = getKeyvalsFromKeyCode(keymap,SC_OTHER, VKShiftState_lin); + + // _S2 which value?? + // _S2 what to return for deadkeys ? 65106? dead-acute? or what else? + if (KeyvalOther > 65000) { + std::string ws((const char*) gdk_keyval_name (KeyvalOther)); + std::u16string u16s = u16string_from_string(ws); + *DeadKey = *(KMX_WCHAR*) u16s.c_str(); + return 0xFFFF; + } + return (KMX_WCHAR) KeyvalOther; } @@ -360,6 +372,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon KMX_ReportUnconvertedKeyboardRules(kbd); + //if(!KMX_Lin_ImportRules_Lin(kbid, kbd, All_Vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 if(!KMX_ImportRules(kbid, kbd, All_Vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 return FALSE; } From df64c563c3d67082a6df215f16189e1953f92e5a Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 30 Nov 2023 11:08:21 +0100 Subject: [PATCH 137/327] feat(linux): mcompile deadkeys: open DoConvert- "if(bDeadkeyConversion) {// I4552..." --- linux/mcompile/keymap/helpers.cpp | 52 ++++++++++++++++-- linux/mcompile/keymap/keymap.cpp | 85 +++++++++++++++++------------- linux/mcompile/keymap/mcompile.cpp | 9 ++-- 3 files changed, 99 insertions(+), 47 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 0519147233..cb41587aa6 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -1571,6 +1571,12 @@ std::string sr = "odiaeresis"; gchar * chr= (gchar*) sr.c_str(); ; guint gi= gdk_keyval_from_name (chr); //--------------------------------------- +//guint32 gdk_keyval_to_unicode (guint keyval); +guint32 gg323 = gdk_keyval_to_unicode (65106); +//--------------------------------------- +//guint gdk_unicode_to_keyval (guint32 wc); +guint GGGIII= gdk_unicode_to_keyval (gg323); +//--------------------------------------- Keyval= Keyval_Shift; // finds ALL CHARACTERS ON KEY KCode for all levels and groups // key 51 gr=0 (DE); lev=0 keyval 35(#) @@ -1690,13 +1696,49 @@ void Inspect_Key_S(GdkKeymap *keymap ) { // KeyValname(Shift) A Odiaresis ampersand numbersign //--------------------------------------- -gchar * gc= gdk_keyval_name (214); -gchar * gc0= gdk_keyval_name (65); +gchar * gc= gdk_keyval_name (729); +gchar * gc0= gdk_keyval_name (94); //--------------------------------------- -std::string sr = "odiaeresis"; +std::string sr = "dead_acute"; gchar * chr= (gchar*) sr.c_str(); ; guint gi= gdk_keyval_from_name (chr); //--------------------------------------- +/*std::string sr4= "acute"; +gchar * chr4= (gchar*) sr4.c_str(); ; +guint gi4= gdk_keyval_from_name (chr4); +//--------------------------------------- +std::string sr1= "dead_grave"; +gchar * chr1= (gchar*) sr1.c_str(); ; +guint gi1= gdk_keyval_from_name (chr1); +//--------------------------------------- +std::string sr2 = "grave"; +gchar * chr2= (gchar*) sr2.c_str(); ; +guint gi2= gdk_keyval_from_name (chr2); +//--------------------------------------- +std::string sr21 = "dead_abovedot"; +gchar * chr21= (gchar*) sr21.c_str(); ; +guint gi21= gdk_keyval_from_name (chr21);*/ +//--------------------------------------- +//--------------------------------------- +//guint32 gdk_keyval_to_unicode (guint keyval); +/*guint32 gg323 = gdk_keyval_to_unicode (65106); +guint32 gz = gdk_keyval_to_unicode (65); +guint32 gz1 = gdk_keyval_to_unicode (220); +guint32 gz2 = gdk_keyval_to_unicode (7838); +//--------------------------------------- +//guint gdk_unicode_to_keyval (guint32 wc); +guint GGGIII= gdk_unicode_to_keyval (gg323); +guint GGGIII2= gdk_unicode_to_keyval (gz2); +guint GGGIII3= gdk_unicode_to_keyval (gz); +guint GGGIII4= gdk_unicode_to_keyval (gz1); +//guint GGGIII2 =gdk_unicode_to_keyval (L"\u1E9E"); +//gchar * gc2= gdk_keyval_name ((int) \u1E9E); +wchar_t w[] = L"\u1E9E"; +wchar_t ww[] = L"A"; +unsigned int Alef = (unsigned int) L'ẞ'; +guint GGII4= gdk_unicode_to_keyval (Alef); +guint GGI4= gdk_unicode_to_keyval ((unsigned int) L'ẞ');*/ +//--------------------------------------- Keyval= Keyval_Shift; // finds ALL CHARACTERS ON KEY KCode for all levels and groups // key 51 gr=0 (DE); lev=0 keyval 35(#) @@ -1729,7 +1771,7 @@ Keyval= Keyval_Shift; gint Key_on_DE; gint KeyVal_on_US; - Keyval = 214; + Keyval = 38; gdk_keymap_get_entries_for_keyval(keymap, Keyval,&keys,&n_keys); wprintf(L"----------------------------\nprinting out the characters given by keypress of Keyval :%i\n",Keyval); for (int i = 0; i < n_keys; i++) { @@ -1738,7 +1780,7 @@ gint KeyVal_on_US; wprintf(L" i=%d, Keyval=%d, (%c) keycode %i group %i level %i\n", i, Keyval,Keyval, keys[i].keycode,keys[i].group,keys[i].level); } - for (int i = 0; i < n_keys; i++) { + for (int i = 1; i < n_keys; i++) { if (keys[i].group ==0) Key_on_DE = keys[i].keycode; } diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index f3110f8035..344cc5fc42 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -78,44 +78,57 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, KMX_DWORD convertNamesToASCIIValue(std::wstring tok_wstr){ std::map first; - first[L"exclam"] = 33; - first[L"at"] = 64; - first[L"numbersign"] = 35; - first[L"dollar"] = 36; - first[L"percent"] = 37; - first[L"dead_circumflex"] = 94; - first[L"ampersand"] = 38; - first[L"asterisk"] = 42; - first[L"parenleft"] = 40; - first[L"parenright"] = 41; - first[L"minus"] = 45; - first[L"underscore"] = 95; - first[L"equal"] = 61; - first[L"plus"] = 43; - first[L"bracketleft"] = 91; - first[L"braceleft"] = 123; - first[L"bracketright"] = 93; - first[L"braceright"] = 125; - first[L"semicolon"] = 59; - first[L"colon"] = 58; - first[L"apostrophe"] = 39; - first[L"quotedbl"] = 34; - first[L"backslash"] = 92; - first[L"bar"] = 124; - first[L"comma"] = 44; - first[L"less"] = 60; - first[L"period"] = 46; - first[L"greater"] = 62; - first[L"slash"] = 47; - first[L"question"] = 63; - first[L"space"] = 32; - first[L"asciitilde"] = 126; - first[L"asciicircum"] = 136; + first[L"ampersand"] = 38; + first[L"apostrophe"] = 39; + first[L"asciicircum"] = 136; + first[L"asciitilde"] = 126; + first[L"asterisk"] = 42; + first[L"at"] = 64; + first[L"backslash"] = 92; + first[L"bar"] = 124; + first[L"braceleft"] = 123; + first[L"braceright"] = 125; + first[L"bracketleft"] = 91; + first[L"bracketright"] = 93; + first[L"colon"] = 58; + first[L"comma"] = 44; + first[L"dollar"] = 36; + first[L"equal"] = 61; + first[L"exclam"] = 33; + first[L"grave"] = 96; + first[L"greater"] = 62; + first[L"less"] = 60; + first[L"minus"] = 45; + first[L"numbersign"] = 35; + first[L"parenleft"] = 40; + first[L"parenright"] = 41; + first[L"percent"] = 37; + first[L"period"] = 46; + first[L"plus"] = 43; + first[L"question"] = 63; + first[L"quotedbl"] = 34; + first[L"semicolon"] = 59; + first[L"slash"] = 47; + first[L"space"] = 32; + first[L"ssharp"] = 223; + first[L"underscore"] = 95; + + // _S2 those deadkeys + space: + first[L"dead_abovedot"] = 729; + first[L"dead_abovering"] = 730; + first[L"dead_acute"] = 180; //39 180 ?? + first[L"dead_breve"] = 728; + first[L"dead_caron"] = 711; + first[L"dead_cedilla"] = 184; + first[L"dead_circumflex"] = 94; + first[L"dead_diaeresis"] = 168; + first[L"dead_doubleacute"] = 733; + first[L"dead_grave"] = 96; + first[L"dead_ogonek"] = 731; + first[L"dead_perispomeni"] = 126; + first[L"dead_tilde"] = 126; - first[L"dead_acute"] = 180; - first[L"grave"] = 96; - first[L"ssharp"] = 223; //first[L" ?? "] = VK_OEM_102; /* DE = 226 ' " ? VK_OEM_102 */ if ( tok_wstr.size() == 1) { diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index b3853680c3..801ed84586 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -256,12 +256,10 @@ KMX_WCHAR KMX_CharFromSC(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHE int VKShiftState_lin = map_VKShiftState_to_Lin(VKShiftState); KMX_DWORD KeyvalOther = getKeyvalsFromKeyCode(keymap,SC_OTHER, VKShiftState_lin); - // _S2 which value?? - // _S2 what to return for deadkeys ? 65106? dead-acute? or what else? - if (KeyvalOther > 65000) { + // _S2 how to detect deadkeys ? KeyvalOther > 255? KeyvalOther > 65100 ? or what else? + if (KeyvalOther > 255) { std::string ws((const char*) gdk_keyval_name (KeyvalOther)); - std::u16string u16s = u16string_from_string(ws); - *DeadKey = *(KMX_WCHAR*) u16s.c_str(); + *DeadKey = convertNamesToASCIIValue( wstring_from_string(ws)); return 0xFFFF; } @@ -352,7 +350,6 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon //wprintf(L" DoConvert-read i: %i \t(KMX_VKMap): %i (%c) \t---> vkUnderlying: %i (%c) \tshiftstate[%i]: ( %i ) \t---- > ch: %i (%c) \t%ls \t%ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, j, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); - // _S2 ToDo if(bDeadkeyConversion) { // I4552 if(ch == 0xFFFF) { ch = DeadKey; From aec220dfaaa25c02d28474c3484f79e7b623a9d7 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 30 Nov 2023 11:33:37 +0100 Subject: [PATCH 138/327] feat(linux): mcompile tidy up --- linux/mcompile/keymap/helpers.cpp | 376 ++++++++++++++++++++++ linux/mcompile/keymap/keymap.cpp | 35 +- linux/mcompile/keymap/keymap.h | 3 +- linux/mcompile/keymap/mc_import_rules.cpp | 345 +------------------- linux/mcompile/keymap/mcompile.cpp | 2 +- 5 files changed, 380 insertions(+), 381 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index cb41587aa6..e80ffc8d65 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -1872,3 +1872,379 @@ int stop=99; */ +// _S2 this needs to go; only to check if mcompile gives the same end result. +// _S2 helps to force filling rgkey[VK_FR] +UINT map_Ikey_FR(UINT iKey) { + if (iKey == 186 ) return 221; + if (iKey == 187 ) return 187; + if (iKey == 188 ) return 77; + if (iKey == 189 ) return 223; + if (iKey == 190 ) return 188; + if (iKey == 191 ) return 190; + if (iKey == 192 ) return 222; + if (iKey == 219 ) return 189; + if (iKey == 220 ) return 220; + if (iKey == 221 ) return 219; + if (iKey == 222 ) return 192; + if (iKey == 223 ) return 191; + if (iKey == 226 ) return 226; + if (iKey == 77 ) return 186; + return iKey; +} + + + +/*bool KMX_Lin_ImportRules_Lin(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 + KMX_Loader loader; + const size_t BUF_sz= 256; + //Inspect_kp(kp); // _ _S2 only open for inspecting; if used when running the program it will crash :-( ) + KMX_HKL hkl = NULL; //_S2 added: but can I do this?? hkl is not needed in Linux?? + + BYTE lpKeyState[256];// = new KeysEx[256]; + std::vector rgKey; //= new VirtualKey[256]; + std::vector alDead; + + KMX_VirtualKey* rgKey_single = new KMX_VirtualKey(1, hkl, All_Vector, keymap); + UINT nkeys_single =0; + + rgKey.resize(256); + + // _S2 scroll through OTHER + // Scroll through the Scan Code (SC) values and get the valid Virtual Key (VK) + // values in it. Then, store the SC in each valid VK so it can act as both a + // flag that the VK is valid, and it can store the SC value. + for(UINT sc = 0x01; sc <= 0x7f; sc++) { + // fills m_vk with the VK of the US keyboard which is not right!! + // ( mcompile win uses MapVirtualKeyEx() to fill m_vk with the VK of the Other keyboard) + // Linux cant get a VK for the US Keyboard using USVirtualKeyToScanCode/ScanCodeToUSVirtualKey + // Linux cannot get a VK for Other Keyboard + // it could return SC if that helps + KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector, keymap); + if((key->VK() != 0) && (key->VK()< 255)) { // if used without ScanCodeToUSVirtualKey[] + rgKey[key->VK()] = key; + } else { + delete key; + } + } + + for(UINT ke = VK_NUMPAD0; ke <= VK_NUMPAD9; ke++) { + rgKey[ke] = new KMX_VirtualKey(hkl, ke, All_Vector, keymap); + } + + rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE, All_Vector, keymap); + rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL, All_Vector, keymap); + rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL, All_Vector, keymap); + + +// // _S2 do we need special shift state now or later? +// // See if there is a special shift state added +// for(UINT vk = 0; vk <= VK_OEM_CLEAR; vk++) { +// UINT sc = MapVirtualKeyEx(vk, 0, hkl); +// UINT vkL = MapVirtualKeyEx(sc, 1, hkl); +// UINT vkR = MapVirtualKeyEx(sc, 3, hkl); +// if((vkL != vkR) && +// (vk != vkL)) { +// switch(vk) { +// case VK_LCONTROL: +// case VK_RCONTROL: +// case VK_LSHIFT: +// case VK_RSHIFT: +// case VK_LMENU: +// case VK_RMENU: +// break; +// +// default: +// loader.Set_XxxxVk(vk); +// break; +// } +// } +// } + + + + // _S2 in this part we skip shiftstates 4, 5, 8, 9 + for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { + if(rgKey[iKey] != NULL) { + WCHAR sbBuffer[256]; // Scratchpad we use many places + + for(ShiftState ss = Base; ss <= loader.MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { + if(ss == Menu || ss == ShftMenu) { + continue; // Alt and Shift+Alt don't work, so skip them + } + + KMX_DWORD SC_US = get_KeyCode_fromVKUS(iKey); // _S2 only for testing can go later helps to force filling rgkey[VK_DE] + + for(int caps = 0; caps <= 1; caps++) { + //_S2 TODO get char - do I need rc ?? ( was rc = ToUnicodeEx...) + std::wstring KeyVal_Other = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, SC_US, ss, caps); + + if (!IsKeymanUsedKeyVal(KeyVal_Other)) + KeyVal_Other = L"\0"; + + //_S2 TODO do I need that ?? + //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { + if(KeyVal_Other == L"") { + //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); + rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps)); + rgKey_single->KMX_SetShiftState(ss, L"", false, (caps)); + } + + //_S2 TODO + //else // if rc ==1 : it got 1 char && +40 in Buffer CTRl pressed { + //It's dealing with control characters. If ToUnicodeEx gets VK_A with the Ctrl key pressed, + //it will write 0x01 to sBuffer[0] , without Ctrl it's 0x41. The if detects this case. + //&& CTRl +0x40 in the buffer ( which indicates a ctrl press) + if( (ss == Ctrl || ss == ShftCtrl) //&& CTRl +0x40 in the buffer ( which indicates a ctrl press) //) { + continue; + } + + //_S2 TODO fill m_rgfDeadkey ( m_rgfDeadkey will be done later) + //rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps==0)); + rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps)); + rgKey_single->KMX_SetShiftState(ss, KeyVal_Other, false, (caps)); + //if( KeyVal_Other != L"") + if( IsKeymanUsedKeyVal(KeyVal_Other) ) + nkeys_single ++ ; + int ertzu=888; + + + //_S2 TODO + // _S2 handle deadkeys later + // if rc <0: it got a deadkey { + // fill m_rgss and m_rgfDeadkey and alDead + //SET_SHIFTSTATES( deadkey) //sbuffer is value out of ToUnicodeEx / AllVector + // do more stuff for deadkeys... + // } from rc<0 + } + } + } + } + + + //------------------------------------------------------------- + // Now that we've collected the key data, we need to + // translate it to kmx and append to the existing keyboard + //------------------------------------------------------------- + + int nDeadkey = 0; + LPKMX_GROUP gp = new KMX_GROUP[kp->cxGroupArray+4]; // leave space for old + memcpy(gp, kp->dpGroupArray, sizeof(KMX_GROUP) * kp->cxGroupArray); + + // + + // Find the current highest deadkey index + // + + kp->dpGroupArray = gp; + for(UINT i = 0; i < kp->cxGroupArray; i++, gp++) { + //if(gp->fUsingKeys && gp->dpNoMatch == NULL) { // I4550 + // WCHAR *p = gp->dpNoMatch = new WCHAR[4]; + // *p++ = UC_SENTINEL; + // *p++ = CODE_USE; + // *p++ = (WCHAR)(kp->cxGroupArray + 1); + // *p = 0; + //} + LPKMX_KEY kkp = gp->dpKeyArray; + + for(UINT j = 0; j < gp->cxKeyArray; j++, kkp++) { + nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpContext)); + nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpOutput)); + } + } + + // _S2 find nkeys + // kp->cxGroupArray++; + // gp = &kp->dpGroupArray[kp->cxGroupArray-1]; + // UINT nKeys = 0; + // for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { + // if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { + // nKeys+= rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); + // wprintf(L" iKey = %i, Delta: %i -> Sum %i\n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()), nKeys); + // } + // } + + nDeadkey++; // ensure a 1-based index above the max deadkey value already in the keyboard + + gp->fUsingKeys = TRUE; + gp->dpMatch = NULL; + gp->dpName = NULL; + gp->dpNoMatch = NULL; + //gp->cxKeyArray = nKeys; + gp->cxKeyArray = nkeys_single; + gp->dpKeyArray = new KMX_KEY[gp->cxKeyArray]; + UINT nKeys = 0; + + + // + // Fill in the new rules + // + for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { + if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { + if(rgKey[iKey]->KMX_LayoutRow_Lin(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 + //if(rgKey_single->KMX_LayoutRow_Lin(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 + + nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); + wprintf(L"nKeys sum: %i\n", nKeys); + } + } + } + + // --------------------------------------------------------------------------------------------- + + // A _S2 Look at the character in the key rule, + + // e.g. + 'y' > '... (so, key->Key == 'y' && key->ShiftFlags == 0) + KMX_WCHAR key_key; + KMX_DWORD key_shiftFlag; + // --------------------------------------------------------------------------------------------- + // B _S2 Find the key data by finding 'y' keyval in the target layout. (DE?) + // --------------------------------------------------------------------------------------------- + // C _S2 Look up the scan code (and modifiers) associated with that keyval. + // --------------------------------------------------------------------------------------------- + // D _S2 Use that scan code to get the US english vkey equivalent via ScanCodeToUSVirtualKey[] + // --------------------------------------------------------------------------------------------- + // E _S2 Rewrite the key rule to + [K_Z] > ... + // --------------------------------------------------------------------------------------------- + // F _S2 Nuance needed around modifier keys (so it may need to be + [SHIFT K_Z] for 'Y', for example). + // --------------------------------------------------------------------------------------------- + // Keyval(DE) -> SC_DE -> SC_US -> VK_US + // --------------------------------------------------------------------------------------------- + + + // _S2 no changes here after removing rgkey + gp->cxKeyArray = nKeys; + + // + // Add nomatch control to each terminating 'using keys' group // I4550 + // + LPKMX_GROUP gp2 = kp->dpGroupArray; + for(UINT i = 0; i < kp->cxGroupArray - 1; i++, gp2++) { + if(gp2->fUsingKeys && gp2->dpNoMatch == NULL) { + KMX_WCHAR *p = gp2->dpNoMatch = new KMX_WCHAR[4]; + KMX_WCHAR *q = p; + *p++ = UC_SENTINEL; + *p++ = CODE_USE; + *p++ = (KMX_WCHAR)(kp->cxGroupArray); + *p = 0; + + // _S2 TODO not sure if this works OK -> we need to use more shiftstates than base+Shift + // I4550 - Each place we have a nomatch > use(baselayout) (this last group), we need to add all + // the AltGr and ShiftAltGr combinations as rules to allow them to be matched as well. Yes, this + // loop is not very efficient but it's not worthy of optimisation. + // + UINT j; + LPKMX_KEY kkp; + for(j = 0, kkp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kkp++) { + wprintf(L"key: kkp->key%i(%c) and SFlag %i\n",kkp->Key,kkp->Key,kkp->ShiftFlags ); + //wprintf(L"key: gp ->key%i(%c) and SFlag %i\n",gp->dpKeyArray->Key,gp->dpKeyArray->Key,gp->dpKeyArray->ShiftFlags ); + //wprintf(L"key: gp2->key%i(%c) and SFlag %i\n",gp2->dpKeyArray->Key,gp2->dpKeyArray->Key,gp2->dpKeyArray->ShiftFlags ); + //wprintf(L"key: kp ->key%i(%c) and SFlag %i\n",kp->dpGroupArray->dpKeyArray->Key,kp->dpGroupArray->dpKeyArray->Key,kp->dpGroupArray->dpKeyArray->ShiftFlags ); + //&& CTRl +0x40 in the buffer ( which indicates a ctrl press) // + if((kkp->ShiftFlags & (K_CTRLFLAG|K_ALTFLAG|LCTRLFLAG|LALTFLAG|RCTRLFLAG|RALTFLAG)) != 0) { + gp2->cxKeyArray++; + LPKMX_KEY kkp2 = new KMX_KEY[gp2->cxKeyArray]; + memcpy(kkp2, gp2->dpKeyArray, sizeof(KMX_KEY)*(gp2->cxKeyArray-1)); + gp2->dpKeyArray = kkp2; + kkp2 = &kkp2[gp2->cxKeyArray-1]; + kkp2->dpContext = new KMX_WCHAR; *kkp2->dpContext = 0; + kkp2->Key = kkp->Key; + kkp2->ShiftFlags = kkp->ShiftFlags; + kkp2->Line = 0; + KMX_WCHAR *p = kkp2->dpOutput = new KMX_WCHAR[4]; + KMX_WCHAR *q=p; + *p++ = UC_SENTINEL; + *p++ = CODE_USE; + *p++ = (KMX_WCHAR)(kp->cxGroupArray); + *p = 0; + } + } + } + } + + if (alDead.size() > 0 && !bDeadkeyConversion) { // I4552 + kp->cxGroupArray++; + + KMX_WCHAR *p = gp->dpMatch = new KMX_WCHAR[4]; + *p++ = UC_SENTINEL; + *p++ = CODE_USE; + *p++ = (KMX_WCHAR) kp->cxGroupArray; + *p = 0; + + gp++; + + gp->fUsingKeys = FALSE; + gp->dpMatch = NULL; + gp->dpName = NULL; + gp->dpNoMatch = NULL; + gp->cxKeyArray = alDead.size(); + LPKMX_KEY kkp = gp->dpKeyArray = new KMX_KEY[alDead.size()]; + + LPKMX_STORE sp = new KMX_STORE[kp->cxStoreArray + alDead.size() * 2]; + memcpy(sp, kp->dpStoreArray, sizeof(KMX_STORE) * kp->cxStoreArray); + + kp->dpStoreArray = sp; + + sp = &sp[kp->cxStoreArray]; + int nStoreBase = kp->cxStoreArray; + kp->cxStoreArray += alDead.size() * 2; + + for(UINT i = 0; i < alDead.size(); i++) { + DeadKey *dk = alDead[i]; + + sp->dpName = NULL; + sp->dwSystemID = 0; + sp->dpString = new KMX_WCHAR[dk->KMX_Count() + 1]; + for(int j = 0; j < dk->KMX_Count(); j++) + sp->dpString[j] = dk->KMX_GetBaseCharacter(j); + sp->dpString[dk->KMX_Count()] = 0; + sp++; + + sp->dpName = NULL; + sp->dwSystemID = 0; + sp->dpString = new KMX_WCHAR[dk->KMX_Count() + 1]; + for(int j = 0; j < dk->KMX_Count(); j++) + sp->dpString[j] = dk->KMX_GetCombinedCharacter(j); + sp->dpString[dk->KMX_Count()] = 0; + sp++; + + kkp->Line = 0; + kkp->ShiftFlags = 0; + kkp->Key = 0; + KMX_WCHAR *p = kkp->dpContext = new KMX_WCHAR[8]; + *p++ = UC_SENTINEL; + *p++ = CODE_DEADKEY; + *p++ = KMX_DeadKeyMap(dk->KMX_DeadCharacter(), &alDead, nDeadkey, FDeadkeys); // I4353 + // *p++ = nDeadkey+i; + *p++ = UC_SENTINEL; + *p++ = CODE_ANY; + *p++ = nStoreBase + i*2 + 1; + *p = 0; + + p = kkp->dpOutput = new KMX_WCHAR[5]; + *p++ = UC_SENTINEL; + *p++ = CODE_INDEX; + *p++ = nStoreBase + i*2 + 2; + *p++ = 2; + *p = 0; + + kkp++; + } + } +return true; +}*/ + + + + + +// _S2 maybe not needed +UINT find_SC_Other_from_SC_US_GDK(UINT SC_US,GdkKeymap *keymap) { + UINT SC__Other; + + for ( int i=0; i<255;i++) { + SC__Other= (UINT )get_KeyCode_From_KeyVal_GDK( keymap, i); + if(SC__Other==SC_US ) + return SC__Other; + } + return SC_US; +} \ No newline at end of file diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 344cc5fc42..989790fc20 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -114,7 +114,6 @@ KMX_DWORD convertNamesToASCIIValue(std::wstring tok_wstr){ first[L"ssharp"] = 223; first[L"underscore"] = 95; - // _S2 those deadkeys + space: first[L"dead_abovedot"] = 729; first[L"dead_abovering"] = 730; first[L"dead_acute"] = 180; //39 180 ?? @@ -352,7 +351,7 @@ KMX_DWORD getKeyvalsFromKeyCode(GdkKeymap *keymap, guint keycode, int shift_stat return out; } -// _S2 do we need that? +// _S2 do we need that - it does the same as get_KeyCode_fromVKUS KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { GdkModifierType consumed; @@ -430,27 +429,6 @@ UINT map_Ikey_DE(UINT iKey) { return iKey; } -// _S2 this needs to go; only to check if mcompile gives the same end result. -// _S2 helps to force filling rgkey[VK_FR] -UINT map_Ikey_FR(UINT iKey) { - if (iKey == 186 ) return 221; - if (iKey == 187 ) return 187; - if (iKey == 188 ) return 77; - if (iKey == 189 ) return 223; - if (iKey == 190 ) return 188; - if (iKey == 191 ) return 190; - if (iKey == 192 ) return 222; - if (iKey == 219 ) return 189; - if (iKey == 220 ) return 220; - if (iKey == 221 ) return 219; - if (iKey == 222 ) return 192; - if (iKey == 223 ) return 191; - if (iKey == 226 ) return 226; - if (iKey == 77 ) return 186; - return iKey; -} - - // _S2 TODO How to do mapping between Linux keycodes and keyman SC const int Lin_KM__map(int i, v_dw_3D &All_Vector) { // MAP: @@ -554,17 +532,6 @@ if((keycode == 20) && (ss == ShftMenuCtrl) && (caps == 1)) return L"ß"; //L return L"\0"; } -// _S2 maybe not needed -UINT find_SC_Other_from_SC_US_GDK(UINT SC_US,GdkKeymap *keymap) { - UINT SC__Other; - - for ( int i=0; i<255;i++) { - SC__Other= (UINT )get_KeyCode_From_KeyVal_GDK( keymap, i); - if(SC__Other==SC_US ) - return SC__Other; - } - return SC_US; -} int map_VKShiftState_to_Lin(int VKShiftState) { diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 8a2e0ff680..aef708942a 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -505,7 +505,6 @@ KMX_DWORD get_VKUS_fromKeyCode( KMX_DWORD keycode); KMX_DWORD get_KeyCode_fromVKUS( KMX_DWORD VK_US); UINT map_Ikey_DE(UINT iKey); -UINT map_Ikey_FR(UINT iKey); // initialize GDK bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); @@ -525,7 +524,7 @@ std::wstring get_KeyVals_according_to_keycode_and_Shiftstate(GdkKeymap *keymap, // can go later void Try_GDK(GdkKeymap *keymap, UINT KeySym ); void Inspect_Key_S(GdkKeymap *keymap ); -UINT find_SC_Other_from_SC_US_GDK(UINT vk_US_187,GdkKeymap *keymap); +//UINT find_SC_Other_from_SC_US_GDK(UINT vk_US_187,GdkKeymap *keymap); // _S2 needed? // create a Vector with all entries of both keymaps+ keymap int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 5a58e6c2e6..1c91a42e77 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -828,348 +828,6 @@ for ( int i=0; idpGroupArray->cxKeyArray;i++) { } -bool KMX_Lin_ImportRules_Lin(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 - KMX_Loader loader; - const size_t BUF_sz= 256; - //Inspect_kp(kp); // _ _S2 only open for inspecting; if used when running the program it will crash :-( ) - KMX_HKL hkl = NULL; //_S2 added: but can I do this?? hkl is not needed in Linux?? - - BYTE lpKeyState[256];// = new KeysEx[256]; - std::vector rgKey; //= new VirtualKey[256]; - std::vector alDead; - - KMX_VirtualKey* rgKey_single = new KMX_VirtualKey(1, hkl, All_Vector, keymap); - UINT nkeys_single =0; - - rgKey.resize(256); - - // _S2 scroll through OTHER - // Scroll through the Scan Code (SC) values and get the valid Virtual Key (VK) - // values in it. Then, store the SC in each valid VK so it can act as both a - // flag that the VK is valid, and it can store the SC value. - for(UINT sc = 0x01; sc <= 0x7f; sc++) { - // fills m_vk with the VK of the US keyboard which is not right!! - // ( mcompile win uses MapVirtualKeyEx() to fill m_vk with the VK of the Other keyboard) - // Linux cant get a VK for the US Keyboard using USVirtualKeyToScanCode/ScanCodeToUSVirtualKey - // Linux cannot get a VK for Other Keyboard - // it could return SC if that helps - KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector, keymap); - if((key->VK() != 0) && (key->VK()< 255)) { // if used without ScanCodeToUSVirtualKey[] - rgKey[key->VK()] = key; - } else { - delete key; - } - } - - for(UINT ke = VK_NUMPAD0; ke <= VK_NUMPAD9; ke++) { - rgKey[ke] = new KMX_VirtualKey(hkl, ke, All_Vector, keymap); - } - - rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE, All_Vector, keymap); - rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL, All_Vector, keymap); - rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL, All_Vector, keymap); - -/* - // _S2 do we need special shift state now or later? - // See if there is a special shift state added - for(UINT vk = 0; vk <= VK_OEM_CLEAR; vk++) { - UINT sc = MapVirtualKeyEx(vk, 0, hkl); - UINT vkL = MapVirtualKeyEx(sc, 1, hkl); - UINT vkR = MapVirtualKeyEx(sc, 3, hkl); - if((vkL != vkR) && - (vk != vkL)) { - switch(vk) { - case VK_LCONTROL: - case VK_RCONTROL: - case VK_LSHIFT: - case VK_RSHIFT: - case VK_LMENU: - case VK_RMENU: - break; - - default: - loader.Set_XxxxVk(vk); - break; - } - } - } -*/ - - - // _S2 in this part we skip shiftstates 4, 5, 8, 9 - for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { - if(rgKey[iKey] != NULL) { - WCHAR sbBuffer[256]; // Scratchpad we use many places - - for(ShiftState ss = Base; ss <= loader.MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { - if(ss == Menu || ss == ShftMenu) { - continue; // Alt and Shift+Alt don't work, so skip them - } - - KMX_DWORD SC_US = get_KeyCode_fromVKUS(iKey); // _S2 only for testing can go later helps to force filling rgkey[VK_DE] - - for(int caps = 0; caps <= 1; caps++) { - //_S2 TODO get char - do I need rc ?? ( was rc = ToUnicodeEx...) - std::wstring KeyVal_Other = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, SC_US, ss, caps); - - if (!IsKeymanUsedKeyVal(KeyVal_Other)) - KeyVal_Other = L"\0"; - - //_S2 TODO do I need that ?? - //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { - if(KeyVal_Other == L"") { - //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); - rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps)); - rgKey_single->KMX_SetShiftState(ss, L"", false, (caps)); - } - - //_S2 TODO - //else // if rc ==1 : it got 1 char && +40 in Buffer CTRl pressed { - //It's dealing with control characters. If ToUnicodeEx gets VK_A with the Ctrl key pressed, - //it will write 0x01 to sBuffer[0] , without Ctrl it's 0x41. The if detects this case. - //&& CTRl +0x40 in the buffer ( which indicates a ctrl press) - if( (ss == Ctrl || ss == ShftCtrl) /*&& CTRl +0x40 in the buffer ( which indicates a ctrl press) */) { - continue; - } - - //_S2 TODO fill m_rgfDeadkey ( m_rgfDeadkey will be done later) - //rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps==0)); - rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps)); - rgKey_single->KMX_SetShiftState(ss, KeyVal_Other, false, (caps)); - //if( KeyVal_Other != L"") - if( IsKeymanUsedKeyVal(KeyVal_Other) ) - nkeys_single ++ ; - int ertzu=888; - - - //_S2 TODO - // _S2 handle deadkeys later - // if rc <0: it got a deadkey { - // fill m_rgss and m_rgfDeadkey and alDead - //SET_SHIFTSTATES( deadkey) //sbuffer is value out of ToUnicodeEx / AllVector - // do more stuff for deadkeys... - // } from rc<0 - } - } - } - } - - - //------------------------------------------------------------- - // Now that we've collected the key data, we need to - // translate it to kmx and append to the existing keyboard - //------------------------------------------------------------- - - int nDeadkey = 0; - LPKMX_GROUP gp = new KMX_GROUP[kp->cxGroupArray+4]; // leave space for old - memcpy(gp, kp->dpGroupArray, sizeof(KMX_GROUP) * kp->cxGroupArray); - - // - - // Find the current highest deadkey index - // - - kp->dpGroupArray = gp; - for(UINT i = 0; i < kp->cxGroupArray; i++, gp++) { - //if(gp->fUsingKeys && gp->dpNoMatch == NULL) { // I4550 - // WCHAR *p = gp->dpNoMatch = new WCHAR[4]; - // *p++ = UC_SENTINEL; - // *p++ = CODE_USE; - // *p++ = (WCHAR)(kp->cxGroupArray + 1); - // *p = 0; - //} - LPKMX_KEY kkp = gp->dpKeyArray; - - for(UINT j = 0; j < gp->cxKeyArray; j++, kkp++) { - nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpContext)); - nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpOutput)); - } - } - - // _S2 find nkeys - /*kp->cxGroupArray++; - gp = &kp->dpGroupArray[kp->cxGroupArray-1]; - UINT nKeys = 0; - for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { - if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { - nKeys+= rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); - wprintf(L" iKey = %i, Delta: %i -> Sum %i\n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()), nKeys); - } - }*/ - - nDeadkey++; // ensure a 1-based index above the max deadkey value already in the keyboard - - gp->fUsingKeys = TRUE; - gp->dpMatch = NULL; - gp->dpName = NULL; - gp->dpNoMatch = NULL; - //gp->cxKeyArray = nKeys; - gp->cxKeyArray = nkeys_single; - gp->dpKeyArray = new KMX_KEY[gp->cxKeyArray]; - UINT nKeys = 0; - - - // - // Fill in the new rules - // - for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { - if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { - if(rgKey[iKey]->KMX_LayoutRow_Lin(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 - //if(rgKey_single->KMX_LayoutRow_Lin(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 - - nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); - wprintf(L"nKeys sum: %i\n", nKeys); - } - } - } - - // --------------------------------------------------------------------------------------------- - - // A _S2 Look at the character in the key rule, - - // e.g. + 'y' > '... (so, key->Key == 'y' && key->ShiftFlags == 0) - KMX_WCHAR key_key; - KMX_DWORD key_shiftFlag; - // --------------------------------------------------------------------------------------------- - // B _S2 Find the key data by finding 'y' keyval in the target layout. (DE?) - // --------------------------------------------------------------------------------------------- - // C _S2 Look up the scan code (and modifiers) associated with that keyval. - // --------------------------------------------------------------------------------------------- - // D _S2 Use that scan code to get the US english vkey equivalent via ScanCodeToUSVirtualKey[] - // --------------------------------------------------------------------------------------------- - // E _S2 Rewrite the key rule to + [K_Z] > ... - // --------------------------------------------------------------------------------------------- - // F _S2 Nuance needed around modifier keys (so it may need to be + [SHIFT K_Z] for 'Y', for example). - // --------------------------------------------------------------------------------------------- - // Keyval(DE) -> SC_DE -> SC_US -> VK_US - // --------------------------------------------------------------------------------------------- - - - // _S2 no changes here after removing rgkey - gp->cxKeyArray = nKeys; - - // - // Add nomatch control to each terminating 'using keys' group // I4550 - // - LPKMX_GROUP gp2 = kp->dpGroupArray; - for(UINT i = 0; i < kp->cxGroupArray - 1; i++, gp2++) { - if(gp2->fUsingKeys && gp2->dpNoMatch == NULL) { - KMX_WCHAR *p = gp2->dpNoMatch = new KMX_WCHAR[4]; - KMX_WCHAR *q = p; - *p++ = UC_SENTINEL; - *p++ = CODE_USE; - *p++ = (KMX_WCHAR)(kp->cxGroupArray); - *p = 0; - - // _S2 TODO not sure if this works OK -> we need to use more shiftstates than base+Shift - // I4550 - Each place we have a nomatch > use(baselayout) (this last group), we need to add all - // the AltGr and ShiftAltGr combinations as rules to allow them to be matched as well. Yes, this - // loop is not very efficient but it's not worthy of optimisation. - // - UINT j; - LPKMX_KEY kkp; - for(j = 0, kkp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kkp++) { - wprintf(L"key: kkp->key%i(%c) and SFlag %i\n",kkp->Key,kkp->Key,kkp->ShiftFlags ); - //wprintf(L"key: gp ->key%i(%c) and SFlag %i\n",gp->dpKeyArray->Key,gp->dpKeyArray->Key,gp->dpKeyArray->ShiftFlags ); - //wprintf(L"key: gp2->key%i(%c) and SFlag %i\n",gp2->dpKeyArray->Key,gp2->dpKeyArray->Key,gp2->dpKeyArray->ShiftFlags ); - //wprintf(L"key: kp ->key%i(%c) and SFlag %i\n",kp->dpGroupArray->dpKeyArray->Key,kp->dpGroupArray->dpKeyArray->Key,kp->dpGroupArray->dpKeyArray->ShiftFlags ); - /*&& CTRl +0x40 in the buffer ( which indicates a ctrl press) */ - if((kkp->ShiftFlags & (K_CTRLFLAG|K_ALTFLAG|LCTRLFLAG|LALTFLAG|RCTRLFLAG|RALTFLAG)) != 0) { - gp2->cxKeyArray++; - LPKMX_KEY kkp2 = new KMX_KEY[gp2->cxKeyArray]; - memcpy(kkp2, gp2->dpKeyArray, sizeof(KMX_KEY)*(gp2->cxKeyArray-1)); - gp2->dpKeyArray = kkp2; - kkp2 = &kkp2[gp2->cxKeyArray-1]; - kkp2->dpContext = new KMX_WCHAR; *kkp2->dpContext = 0; - kkp2->Key = kkp->Key; - kkp2->ShiftFlags = kkp->ShiftFlags; - kkp2->Line = 0; - KMX_WCHAR *p = kkp2->dpOutput = new KMX_WCHAR[4]; - KMX_WCHAR *q=p; - *p++ = UC_SENTINEL; - *p++ = CODE_USE; - *p++ = (KMX_WCHAR)(kp->cxGroupArray); - *p = 0; - } - } - } - } - - if (alDead.size() > 0 && !bDeadkeyConversion) { // I4552 - kp->cxGroupArray++; - - KMX_WCHAR *p = gp->dpMatch = new KMX_WCHAR[4]; - *p++ = UC_SENTINEL; - *p++ = CODE_USE; - *p++ = (KMX_WCHAR) kp->cxGroupArray; - *p = 0; - - gp++; - - gp->fUsingKeys = FALSE; - gp->dpMatch = NULL; - gp->dpName = NULL; - gp->dpNoMatch = NULL; - gp->cxKeyArray = alDead.size(); - LPKMX_KEY kkp = gp->dpKeyArray = new KMX_KEY[alDead.size()]; - - LPKMX_STORE sp = new KMX_STORE[kp->cxStoreArray + alDead.size() * 2]; - memcpy(sp, kp->dpStoreArray, sizeof(KMX_STORE) * kp->cxStoreArray); - - kp->dpStoreArray = sp; - - sp = &sp[kp->cxStoreArray]; - int nStoreBase = kp->cxStoreArray; - kp->cxStoreArray += alDead.size() * 2; - - for(UINT i = 0; i < alDead.size(); i++) { - DeadKey *dk = alDead[i]; - - sp->dpName = NULL; - sp->dwSystemID = 0; - sp->dpString = new KMX_WCHAR[dk->KMX_Count() + 1]; - for(int j = 0; j < dk->KMX_Count(); j++) - sp->dpString[j] = dk->KMX_GetBaseCharacter(j); - sp->dpString[dk->KMX_Count()] = 0; - sp++; - - sp->dpName = NULL; - sp->dwSystemID = 0; - sp->dpString = new KMX_WCHAR[dk->KMX_Count() + 1]; - for(int j = 0; j < dk->KMX_Count(); j++) - sp->dpString[j] = dk->KMX_GetCombinedCharacter(j); - sp->dpString[dk->KMX_Count()] = 0; - sp++; - - kkp->Line = 0; - kkp->ShiftFlags = 0; - kkp->Key = 0; - KMX_WCHAR *p = kkp->dpContext = new KMX_WCHAR[8]; - *p++ = UC_SENTINEL; - *p++ = CODE_DEADKEY; - *p++ = KMX_DeadKeyMap(dk->KMX_DeadCharacter(), &alDead, nDeadkey, FDeadkeys); // I4353 - // *p++ = nDeadkey+i; - *p++ = UC_SENTINEL; - *p++ = CODE_ANY; - *p++ = nStoreBase + i*2 + 1; - *p = 0; - - p = kkp->dpOutput = new KMX_WCHAR[5]; - *p++ = UC_SENTINEL; - *p++ = CODE_INDEX; - *p++ = nStoreBase + i*2 + 2; - *p++ = 2; - *p = 0; - - kkp++; - } - } -return true; -} - - - - void Inspect_gp(KMX_tagGROUP* gp) { for (int i = 0; i < gp->cxKeyArray; i++) { wprintf(L"key nr : has key:%i(%c) Line:%i Shiftflags:%i Output %c (%d)\n", gp->dpKeyArray->Key, gp->dpKeyArray->Key, @@ -1187,6 +845,7 @@ void Inspect_key(LPKMX_KEY key) { // gp->cxKeyArray++; // } } + bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 KMX_Loader loader; const size_t BUF_sz= 256; @@ -1295,7 +954,6 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd // _S2 only for testing can go later helps to force filling rgkey[VK_DE]---v---- UINT iKey_DE = map_Ikey_DE(iKey); - UINT iKey_FR = map_Ikey_FR(iKey); if ( rgKey[iKey]->VK() == 89 ) rgKey[iKey]->set_sc(52); if ( rgKey[iKey]->VK() == 90 ) rgKey[iKey]->set_sc(29); if ( rgKey[iKey]->VK() == 186 ) rgKey[iKey]->set_sc(34); @@ -1321,7 +979,6 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd // KMX_DWORD SC_US = get_KeyCode_fromVKUS(iKey); // _S2 needs to be here late KMX_DWORD SC_US = get_KeyCode_fromVKUS(iKey_DE); // _S2 only for testing can go later helps to force filling rgkey[VK_DE] - //KMX_DWORD SC_US = get_KeyCode_fromVKUS(iKey_FR); // _S2 only for testing can go later helps to force filling rgkey[VK_DE] //wprintf(L" for vk of %i we get Keycode US of %i VK_Other %i: ( on Key US (%i) we find char %i (%c) ) \n", diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 801ed84586..cc7e0fbb41 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -39,7 +39,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]); bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 -bool KMX_Lin_ImportRules_Lin(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 +//bool KMX_Lin_ImportRules_Lin(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 std::vector KMX_FDeadkeys; // I4353 From 3d0980103b897b104d99f3cbe9f36cefce519230 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 30 Nov 2023 14:40:08 +0100 Subject: [PATCH 139/327] feat(linux): mcompile leave rgkey; use SC; sort by VK_US (instead of VK_DE) --- linux/mcompile/keymap/keymap.cpp | 68 ++++++++++++++++++- linux/mcompile/keymap/mc_import_rules.cpp | 80 ++--------------------- 2 files changed, 72 insertions(+), 76 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 989790fc20..29926a4778 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -403,8 +403,9 @@ KMX_DWORD get_VKUS_fromKeyCode( KMX_DWORD keycode) { return 0; //_S2 what to return if not found } KMX_DWORD get_KeyCode_fromVKUS( KMX_DWORD VK_US) { - if( VK_US > 7) - return (KMX_DWORD)(8+ USVirtualKeyToScanCode[ VK_US ]); + if( VK_US > 7) { + KMX_DWORD test = (KMX_DWORD)(8+ USVirtualKeyToScanCode[ VK_US ]); + return (KMX_DWORD)(8+ USVirtualKeyToScanCode[ VK_US ]);} else return 0; } @@ -464,7 +465,7 @@ const int Lin_KM__map(int i, v_dw_3D &All_Vector) { return i; } -std::wstring get_KeyVals_according_to_keycode_and_Shiftstate(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ +std::wstring get_KeyVals_according_to_keycode_and_Shiftstate_Lin(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ GdkModifierType consumed; GdkKeymapKey *maps; @@ -533,6 +534,67 @@ if((keycode == 20) && (ss == ShftMenuCtrl) && (caps == 1)) return L"ß"; //L } +std::wstring get_KeyVals_according_to_keycode_and_Shiftstate(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ + + GdkModifierType consumed; + GdkKeymapKey *maps; + guint *keyvals; + gint count; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return L"\0"; + //return L"1"; + + //unshifted + if (( ss == Base ) && ( caps == 0 )) { + GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + } + + //SHIFT+CAPS + else if ( ( ss == Shft ) && ( caps ==1 )) { + GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + } + + //Shift + else if (( ss == Shft ) && ( caps == 0 )) { + GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + std::wstring rV1= std::wstring(1, (int) *keyvals); + return std::wstring(1, (int) *keyvals); + } + + //caps + else if (( ss == Base ) && ( caps == 1 )) { + GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + } + + //ALT-GR + else if (( ss == MenuCtrl ) && ( caps == 0 )){ + //GdkModifierType MOD_AltGr = (GdkModifierType) ( 144 ); + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + } + + //ALT-GR + else if (( ss == MenuCtrl ) && ( caps == 1 )){ + //GdkModifierType MOD_AltGr = (GdkModifierType) ( 146 ); + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + } + + else + return L"\0"; +} + + int map_VKShiftState_to_Lin(int VKShiftState) { if (VKShiftState == 0 ) return 0; /* 0000 0000 */ diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 1c91a42e77..f9918a882e 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -252,7 +252,7 @@ public: return (this->m_vk >= 0x20 && this->m_vk <= 0x5F) || (this->m_vk >= 0x88); } - UINT KMX_GetShiftStateValue(int capslock, int caps, ShiftState ss) { +UINT KMX_GetShiftStateValue(int capslock, int caps, ShiftState ss) { wprintf(L"GetShiftStateValue takes capslock: %i, caps: %i, ss: %i and returns: %i\n", capslock, caps, ss, KMX_ShiftStateMap[(int)ss] | (capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0)); return @@ -314,56 +314,12 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; // _S2 original: - /*int capslock = - (this->IsCapsEqualToShift() ? 1 : 0) | - (this->IsSGCAPS() ? 2 : 0) | - (this->IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0);*/ - - -// _S2 change! only for testing helps to force filling rgkey[VK_DE] -int capslock; - - // numbers: - if( (this->m_vk>=48) && (this->m_vk<=57) ) { - capslock = - (this->KMX_IsCapsEqualToShift() ? 0 : 1) | - (this->KMX_IsSGCAPS() ? 2 : 0) | - (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); - } - // characters: - else if( (this->m_vk>=65) && (this->m_vk<=90) ) { - capslock = + int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | (this->KMX_IsSGCAPS() ? 2 : 0) | (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); - } - // ä,ö,ü: - else if( (this->m_vk==32) ||(this->m_vk==186) ||(this->m_vk==192)|| (this->m_vk==222) ) { - capslock = - (this->KMX_IsCapsEqualToShift() ? 1 : 0) | - (this->KMX_IsSGCAPS() ? 2 : 0) | - (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); - } - // < and _: - else if( (this->m_vk==189) || (this->m_vk==220) || (this->m_vk==221) || (this->m_vk==226) ) { - capslock = - (this->KMX_IsCapsEqualToShift() ? 1 : 0) | - (this->KMX_IsSGCAPS() ? 2 : 0) | - (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); - } - // punctuation Char: - else { - capslock = - (this->KMX_IsCapsEqualToShift() ? 0 : 1) | - (this->KMX_IsSGCAPS() ? 2 : 0) | - (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); - } + @@ -902,9 +858,6 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd } } - // _S2 remove! only for testing helps to force filling rgkey[VK_DE] - rgKey[223] = new KMX_VirtualKey(hkl, 223, All_Vector, keymap); - for(UINT ke = VK_NUMPAD0; ke <= VK_NUMPAD9; ke++) { rgKey[ke] = new KMX_VirtualKey(hkl, ke, All_Vector, keymap); } @@ -952,24 +905,6 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd UINT VK_Other = Lin_KM__map(iKey, All_Vector); - // _S2 only for testing can go later helps to force filling rgkey[VK_DE]---v---- - UINT iKey_DE = map_Ikey_DE(iKey); - if ( rgKey[iKey]->VK() == 89 ) rgKey[iKey]->set_sc(52); - if ( rgKey[iKey]->VK() == 90 ) rgKey[iKey]->set_sc(29); - if ( rgKey[iKey]->VK() == 186 ) rgKey[iKey]->set_sc(34); - if ( rgKey[iKey]->VK() == 187 ) rgKey[iKey]->set_sc(35); - if ( rgKey[iKey]->VK() == 188 ) rgKey[iKey]->set_sc(59); - if ( rgKey[iKey]->VK() == 189 ) rgKey[iKey]->set_sc(61); - if ( rgKey[iKey]->VK() == 190 ) rgKey[iKey]->set_sc(60); - if ( rgKey[iKey]->VK() == 191 ) rgKey[iKey]->set_sc(51); - if ( rgKey[iKey]->VK() == 192 ) rgKey[iKey]->set_sc(47); - if ( rgKey[iKey]->VK() == 219 ) rgKey[iKey]->set_sc(20); - if ( rgKey[iKey]->VK() == 220 ) rgKey[iKey]->set_sc(49); - if ( rgKey[iKey]->VK() == 221 ) rgKey[iKey]->set_sc(21); - if ( rgKey[iKey]->VK() == 222 ) rgKey[iKey]->set_sc(48); - if ( rgKey[iKey]->VK() == 226 ) rgKey[iKey]->set_sc(94); - // _S2 only for testing can go later helps to force filling rgkey[VK_DE]---^---- - for(ShiftState ss = Base; ss <= loader.MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { if(ss == Menu || ss == ShftMenu) { // Alt and Shift+Alt don't work, so skip them @@ -977,9 +912,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd } - // KMX_DWORD SC_US = get_KeyCode_fromVKUS(iKey); // _S2 needs to be here late - KMX_DWORD SC_US = get_KeyCode_fromVKUS(iKey_DE); // _S2 only for testing can go later helps to force filling rgkey[VK_DE] - + KMX_DWORD SC_US = get_KeyCode_fromVKUS(iKey); //wprintf(L" for vk of %i we get Keycode US of %i VK_Other %i: ( on Key US (%i) we find char %i (%c) ) \n", // VK_Other, 8+USVirtualKeyToScanCode[VK_Other], 8+USVirtualKeyToScanCode[VK_Other] , @@ -997,7 +930,8 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd // _S2 needs to be changed - it's temporary to get the same keys as keyman does when using USVirtualKeyToScanCode prevents chars like ሴ if (!IsKeymanUsedKeyVal(KeyVal_Other)) - KeyVal_Other = L"\0"; + KeyVal_Other = L"@"; + // KeyVal_Other = L"\0"; _S2 what to return if not found //_S2 TODO do I need that ?? //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { @@ -1032,7 +966,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd } //_S2 this gan co later - std::vector< int > TestValues = {48,49,50,51,52,53,54,55,56,57,65,66,67,88,89,90, 186,187,188,189,191,191,192,219,220,221,222,223,226}; + std::vector< int > TestValues = {48,49,50,51,52,53,54,55,56,57,65,66,67,88,89,90, 186,187,188,189,191,191,192,219,220,221}; wprintf(L"-----------------\nNow some tests:\n"); wprintf(L" Base Caps Shift Shfit+Caps MenuCtrl MenuCtrl+Caps \n"); From 5f857de3d88bff272f29c8f8f47e46647dae817c Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 30 Nov 2023 17:40:02 +0100 Subject: [PATCH 140/327] feat(linux): mcompile fill rgkey with deadkey --- linux/mcompile/keymap/helpers.cpp | 133 +++++++++++++++++++++- linux/mcompile/keymap/keymap.cpp | 91 +++------------ linux/mcompile/keymap/keymap.h | 6 +- linux/mcompile/keymap/mc_import_rules.cpp | 21 +--- linux/mcompile/keymap/mcompile.cpp | 3 +- 5 files changed, 158 insertions(+), 96 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index e80ffc8d65..630e6676a5 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -2247,4 +2247,135 @@ UINT find_SC_Other_from_SC_US_GDK(UINT SC_US,GdkKeymap *keymap) { return SC__Other; } return SC_US; -} \ No newline at end of file +} + +std::wstring get_KeyVals_according_to_keycode_and_Shiftstate_Lin(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ + + GdkModifierType consumed; + GdkKeymapKey *maps; + guint *keyvals; + gint count; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return L"\0"; + //return L"1"; +// _S2 remove! only for testing helps to force filling rgkey[VK_DE] +if((keycode == 49) && (ss == Base)) return L"^"; +if((keycode == 21) && (ss == Base)) return L"'"; +if((keycode == 21) && (ss == Shft)) return L"`"; +if((keycode == 21) && (ss == Base) && (caps == 1)) return L"'"; +if((keycode == 20) && (ss == Base) && (caps == 1)) return L"ß"; //L"ẞ"; +if((keycode == 20) && (ss == ShftMenuCtrl) && (caps == 0)) return L"ß"; //L"ẞ"; +if((keycode == 20) && (ss == ShftMenuCtrl) && (caps == 1)) return L"ß"; //L"ẞ"; + + //unshifted + if (( ss == Base ) && ( caps == 0 )) { + GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + } + + //SHIFT+CAPS + else if ( ( ss == Shft ) && ( caps ==1 )) { + GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + } + + //Shift + else if (( ss == Shft ) && ( caps == 0 )) { + GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + std::wstring rV1= std::wstring(1, (int) *keyvals); + return std::wstring(1, (int) *keyvals); + } + + //caps + else if (( ss == Base ) && ( caps == 1 )) { + GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + } + + //ALT-GR + else if (( ss == MenuCtrl ) && ( caps == 0 )){ + //GdkModifierType MOD_AltGr = (GdkModifierType) ( 144 ); + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + } + + //ALT-GR + else if (( ss == MenuCtrl ) && ( caps == 1 )){ + //GdkModifierType MOD_AltGr = (GdkModifierType) ( 146 ); + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + } + + else + return L"\0"; +} + + + +std::wstring get_KeyVals_according_to_keycode_and_Shiftstate(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ + + GdkModifierType consumed; + GdkKeymapKey *maps; + guint *keyvals; + gint count; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return L"\0"; + //return L"1"; + + //unshifted + if (( ss == Base ) && ( caps == 0 )) { + GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + } + + //SHIFT+CAPS + else if ( ( ss == Shft ) && ( caps ==1 )) { + GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + } + + //Shift + else if (( ss == Shft ) && ( caps == 0 )) { + GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + std::wstring rV1= std::wstring(1, (int) *keyvals); + return std::wstring(1, (int) *keyvals); + } + + //caps + else if (( ss == Base ) && ( caps == 1 )) { + GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + } + + //ALT-GR + else if (( ss == MenuCtrl ) && ( caps == 0 )){ + //GdkModifierType MOD_AltGr = (GdkModifierType) ( 144 ); + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + } + + //ALT-GR + else if (( ss == MenuCtrl ) && ( caps == 1 )){ + //GdkModifierType MOD_AltGr = (GdkModifierType) ( 146 ); + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + return std::wstring(1, (int) *keyvals); + } + + else + return L"\0"; +} + diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 29926a4778..82e6c9c6e7 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -465,82 +465,35 @@ const int Lin_KM__map(int i, v_dw_3D &All_Vector) { return i; } -std::wstring get_KeyVals_according_to_keycode_and_Shiftstate_Lin(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ +std::wstring convert_DeadkeyValues_ToChar(int in) { - GdkModifierType consumed; - GdkKeymapKey *maps; - guint *keyvals; - gint count; + KMX_DWORD lname; - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return L"\0"; - //return L"1"; -// _S2 remove! only for testing helps to force filling rgkey[VK_DE] -if((keycode == 49) && (ss == Base)) return L"^"; -if((keycode == 21) && (ss == Base)) return L"'"; -if((keycode == 21) && (ss == Shft)) return L"`"; -if((keycode == 21) && (ss == Base) && (caps == 1)) return L"'"; -if((keycode == 20) && (ss == Base) && (caps == 1)) return L"ß"; //L"ẞ"; -if((keycode == 20) && (ss == ShftMenuCtrl) && (caps == 0)) return L"ß"; //L"ẞ"; -if((keycode == 20) && (ss == ShftMenuCtrl) && (caps == 1)) return L"ß"; //L"ẞ"; + if (in < deadkeyThreshold) { + if (!IsKeymanUsedKeyVal(std::wstring(1, in))) + return L"\0"; + return std::wstring(1, in); + } else { + std::string long_name((const char*) gdk_keyval_name (in)); // 6510 => "dead_circumflex " + lname = convertNamesToASCIIValue( wstring_from_string(long_name)); // "dead_circumflex " => 94 - //unshifted - if (( ss == Base ) && ( caps == 0 )) { - GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); + if (lname != returnIfCharInvalid) { + std::wstring ss = std::wstring(1, lname ); + return std::wstring(1, lname ); // 94 => "^" + } else + return L"\0"; } - - //SHIFT+CAPS - else if ( ( ss == Shft ) && ( caps ==1 )) { - GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); - } - - //Shift - else if (( ss == Shft ) && ( caps == 0 )) { - GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); - std::wstring rV1= std::wstring(1, (int) *keyvals); - return std::wstring(1, (int) *keyvals); - } - - //caps - else if (( ss == Base ) && ( caps == 1 )) { - GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); - } - - //ALT-GR - else if (( ss == MenuCtrl ) && ( caps == 0 )){ - //GdkModifierType MOD_AltGr = (GdkModifierType) ( 144 ); - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); - } - - //ALT-GR - else if (( ss == MenuCtrl ) && ( caps == 1 )){ - //GdkModifierType MOD_AltGr = (GdkModifierType) ( 146 ); - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); - } - - else - return L"\0"; + return L"\0"; } - -std::wstring get_KeyVals_according_to_keycode_and_Shiftstate(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ +std::wstring get_KeyVals_according_to_keycode_and_Shiftstate_new(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ GdkModifierType consumed; GdkKeymapKey *maps; guint *keyvals; gint count; + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return L"\0"; //return L"1"; @@ -549,14 +502,12 @@ std::wstring get_KeyVals_according_to_keycode_and_Shiftstate(GdkKeymap *keymap, if (( ss == Base ) && ( caps == 0 )) { GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); } //SHIFT+CAPS else if ( ( ss == Shft ) && ( caps ==1 )) { GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); } //Shift @@ -564,14 +515,12 @@ std::wstring get_KeyVals_according_to_keycode_and_Shiftstate(GdkKeymap *keymap, GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); std::wstring rV1= std::wstring(1, (int) *keyvals); - return std::wstring(1, (int) *keyvals); } //caps else if (( ss == Base ) && ( caps == 1 )) { GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); } //ALT-GR @@ -579,7 +528,6 @@ std::wstring get_KeyVals_according_to_keycode_and_Shiftstate(GdkKeymap *keymap, //GdkModifierType MOD_AltGr = (GdkModifierType) ( 144 ); GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK) ); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); } //ALT-GR @@ -587,15 +535,12 @@ std::wstring get_KeyVals_according_to_keycode_and_Shiftstate(GdkKeymap *keymap, //GdkModifierType MOD_AltGr = (GdkModifierType) ( 146 ); GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); } - else - return L"\0"; + return convert_DeadkeyValues_ToChar((int) *keyvals);; } - int map_VKShiftState_to_Lin(int VKShiftState) { if (VKShiftState == 0 ) return 0; /* 0000 0000 */ if (VKShiftState == 16) return 1; /* 0001 0000 */ diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index aef708942a..0a34b804e5 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -474,6 +474,9 @@ const KMX_DWORD KMX_VKMap[] = { //static KMX_DWORD returnIfCharInvalid = 32; static KMX_DWORD returnIfCharInvalid = 0; +//_S2 QUESTION Which threshold ( from what int value onwards is a character considered deadkey? 65000 28000?, > 255? ?? +static KMX_DWORD deadkeyThreshold = 65000; + // takes a std::wstring (=contents of line symbols-file ) and returns the (int) value of the character KMX_DWORD convertNamesToASCIIValue(std::wstring tok_wstr); @@ -517,8 +520,9 @@ int append_other_ToVector(v_dw_3D &All_Vector, GdkKeymap *keymap); KMX_DWORD getKeyvalsFromKeyCode(GdkKeymap *keymap, guint keycode, int shift_state_pos); // returns KeySyms fo ra given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) -std::wstring get_KeyVals_according_to_keycode_and_Shiftstate(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); +std::wstring get_KeyVals_according_to_keycode_and_Shiftstate_new(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); +bool IsKeymanUsedKeyVal(std::wstring Keyval); // _S2 needed? // can go later diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index f9918a882e..e5732ec8d9 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -911,27 +911,11 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd continue; } - KMX_DWORD SC_US = get_KeyCode_fromVKUS(iKey); -//wprintf(L" for vk of %i we get Keycode US of %i VK_Other %i: ( on Key US (%i) we find char %i (%c) ) \n", -// VK_Other, 8+USVirtualKeyToScanCode[VK_Other], 8+USVirtualKeyToScanCode[VK_Other] , -//8+USVirtualKeyToScanCode[VK_Other],get_VirtualKey_Other_GDK(*keymap, 8+USVirtualKeyToScanCode[VK_Other]),get_VirtualKey_Other_GDK(*keymap, 8+USVirtualKeyToScanCode[VK_Other]) ); - - for(int caps = 0; caps <= 1; caps++) { //_S2 TODO get char - do I need rc ?? ( was rc = ToUnicodeEx...) - //std::wstring KeyVal_Other_OLD = get_VirtualKey_Other_from_iKey(VK_Other, ss, caps, All_Vector); - std::wstring KeyVal_Other = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, SC_US, ss, caps); - - - //std::wstring KeyVal_OtherTEST6 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 51, MenuCtrl, 0); - // std::wstring KeyVal_OtherTEST16 = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, 51, MenuCtrl, 1); - - // _S2 needs to be changed - it's temporary to get the same keys as keyman does when using USVirtualKeyToScanCode prevents chars like ሴ - if (!IsKeymanUsedKeyVal(KeyVal_Other)) - KeyVal_Other = L"@"; - // KeyVal_Other = L"\0"; _S2 what to return if not found + std::wstring KeyVal_Other = get_KeyVals_according_to_keycode_and_Shiftstate_new( *keymap, SC_US, ss, caps); //_S2 TODO do I need that ?? //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { @@ -985,9 +969,6 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd } wprintf(L"-----------------\n"); - - - //------------------------------------------------------------- // Now that we've collected the key data, we need to // translate it to kmx and append to the existing keyboard diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index cc7e0fbb41..2bb12e5b00 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -256,7 +256,8 @@ KMX_WCHAR KMX_CharFromSC(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHE int VKShiftState_lin = map_VKShiftState_to_Lin(VKShiftState); KMX_DWORD KeyvalOther = getKeyvalsFromKeyCode(keymap,SC_OTHER, VKShiftState_lin); - // _S2 how to detect deadkeys ? KeyvalOther > 255? KeyvalOther > 65100 ? or what else? + // _S2 how to detect deadkeys ? KeyvalOther >deadkeyThreshold KeyvalOther > 255? KeyvalOther > 65000 ? or what else? + //if (KeyvalOther > deadkeyThreshold) { if (KeyvalOther > 255) { std::string ws((const char*) gdk_keyval_name (KeyvalOther)); *DeadKey = convertNamesToASCIIValue( wstring_from_string(ws)); From 70efd21e0915f396377c741be37df64fae9d9ead Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 1 Dec 2023 12:28:00 +0100 Subject: [PATCH 141/327] feat(linux): mcompile open functions for deadkeys and start to exchange with KMX_ --- linux/mcompile/keymap/mc_import_rules.cpp | 6 +- linux/mcompile/keymap/mcompile.cpp | 331 +++++++++++++++------- 2 files changed, 229 insertions(+), 108 deletions(-) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index e5732ec8d9..f1045e4c5f 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -849,9 +849,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd // _S2 ToDo // either it gives the correct rgkeys (all non-char filled with special char) or // it gives not all rgkeys but nr, a-z are filled correctly - if((key->VK() != 0) && (key->VK()< 255)) { // if used without ScanCodeToUSVirtualKey[] - // if((key->VK() != 0) ) { - keycountS++; + if((key->VK() != 0) ) { rgKey[key->VK()] = key; } else { delete key; @@ -950,7 +948,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd } //_S2 this gan co later - std::vector< int > TestValues = {48,49,50,51,52,53,54,55,56,57,65,66,67,88,89,90, 186,187,188,189,191,191,192,219,220,221}; + std::vector< int > TestValues = {48,49,50,51,52,53,54,55,56,57,65,66,67,88,89,90, 186,187,188,189,191,191,192,219,220,221,222,226}; wprintf(L"-----------------\nNow some tests:\n"); wprintf(L" Base Caps Shift Shfit+Caps MenuCtrl MenuCtrl+Caps \n"); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 2bb12e5b00..d747bc2a08 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -51,6 +51,21 @@ void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key); void KMX_ReportUnconvertedGroupRules(LPKMX_GROUP group); void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd); +int KMX_GetDeadkeys(WORD DeadKey, WORD *OutputPairs) ; + + +int KMX_GetDeadkeys_NT(WORD DeadKey, WORD *OutputPairs); // returns array of [USVK, ch] pairs +int KMX_GetDeadkeys_NT_x64(WORD DeadKey, WORD *OutputPairs); // returns array of [USVK, ch] pairs +void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift); + +void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch); +void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group,KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch); +void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch); + + +KMX_WORD KMX_VKUSToVKUnderlyingLayout_S2(KMX_WORD VKey); +KMX_WORD KMX_VKUnderlyingLayoutToVKUS_S2(KMX_WORD VKey); + #if defined(_WIN32) || defined(_WIN64) int wmain(int argc, wchar_t* argv[]) { std::vector str_argv_16 = convert_argvW_to_Vector_u16str( argc, argv); @@ -306,6 +321,102 @@ int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ return 0; } +KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { + KMX_WCHAR noneS2; + /*LPGROUP gp; + LPKEY kp; + LPSTORE sp; + UINT i, j; + WCHAR dkid = 0; + static WCHAR s_next_dkid = 0; + static dkidmap *s_dkids = NULL; + static int s_ndkids = 0; + + if(!kbd) { + if(s_dkids) { + delete s_dkids; + } + s_dkids = NULL; + s_ndkids = 0; + s_next_dkid = 0; + return 0; + } + + for(int i = 0; i < s_ndkids; i++) { + if(s_dkids[i].src_deadkey == deadkey) { + return s_dkids[i].dst_deadkey; + } + } + + if(s_next_dkid != 0) { + s_dkids = (dkidmap*) realloc(s_dkids, sizeof(dkidmap) * (s_ndkids+1)); + s_dkids[s_ndkids].src_deadkey = deadkey; + return s_dkids[s_ndkids++].dst_deadkey = ++s_next_dkid; + } + + for(i = 0, gp = kbd->dpGroupArray; i < kbd->cxGroupArray; i++, gp++) { + for(j = 0, kp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kp++) { + dkid = max(dkid, ScanXStringForMaxDeadkeyID(kp->dpContext)); + dkid = max(dkid, ScanXStringForMaxDeadkeyID(kp->dpOutput)); + } + dkid = max(dkid, ScanXStringForMaxDeadkeyID(gp->dpMatch)); + dkid = max(dkid, ScanXStringForMaxDeadkeyID(gp->dpNoMatch)); + } + + for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { + dkid = max(dkid, ScanXStringForMaxDeadkeyID(sp->dpString)); + } + + s_dkids = (dkidmap*) realloc(s_dkids, sizeof(dkidmap) * (s_ndkids+1)); + s_dkids[s_ndkids].src_deadkey = deadkey; + return s_dkids[s_ndkids++].dst_deadkey = s_next_dkid = ++dkid;*/ + return noneS2; +} + +void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR deadkey) { + KMX_WORD deadkeys[512], *pdk; + + // Lookup the deadkey table for the deadkey in the physical keyboard + // Then for each character, go through and map it through + +KMX_WCHAR dkid = KMX_GetUniqueDeadkeyID(kbd, deadkey); + + // Add the deadkey to the mapping table for use in the import rules phase + KMX_DeadkeyMapping KMX_deadkeyMapping = { deadkey, dkid, shift, vk }; // I4353 + KMX_FDeadkeys.push_back(KMX_deadkeyMapping); //dkid, vk, shift); // I4353 + + KMX_AddDeadkeyRule(kbd, dkid, vk, shift); + + KMX_GetDeadkeys(deadkey, pdk = deadkeys); // returns array of [usvk, ch_out] pairs + while(*pdk) { + // Look up the ch + // _S2 the new function returns KMX_DWORD + UINT vkUnderlying = KMX_VKUnderlyingLayoutToVKUS_S2(*pdk); + KMX_TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); + pdk+=3; + } +} + +KMX_WORD KMX_VKUSToVKUnderlyingLayout_S2(KMX_WORD VKey) { + /*if(IsWow64()) { + return VKUSToVKUnderlyingLayout_NT_x64(VKey); + } else { + return VKUSToVKUnderlyingLayout_NT(VKey); + }*/ + KMX_WORD retu ; + return retu; +} + +KMX_WORD KMX_VKUnderlyingLayoutToVKUS_S2(KMX_WORD VKey) { + /* if(IsWow64()) { + return VKUnderlyingLayoutToVKUS_NT_x64(VKey); + } else { + return VKUnderlyingLayoutToVKUS_NT(VKey); + }*/ + KMX_WORD retu ; + return retu; +} + KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]) { KMX_WCHAR DeadKey; @@ -362,7 +473,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon case 0x0000: break; // _S2 TODO deadkeys will be done later - //case 0xFFFF: ConvertDeadkey(kbd, VKMap[i], VKShiftState[j], DeadKey); break; + case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey); break; default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); } } @@ -463,11 +574,125 @@ void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { } } +void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift) { + // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. + // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" + // to provide an alternate.. + /*if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4549 + shift &= ~LCTRLFLAG; + + // If the first group is not a matching-keys group, then we need to add into + // each subgroup, otherwise just the match group + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + LPKMX_KEY keys = new KEY[kbd->dpGroupArray[i].cxKeyArray + 1]; + memcpy(keys+1, kbd->dpGroupArray[i].dpKeyArray, kbd->dpGroupArray[i].cxKeyArray * sizeof(KEY)); + keys[0].dpContext = new WCHAR[1]; + keys[0].dpContext[0] = 0; + keys[0].dpOutput = new WCHAR[4]; // UC_SENTINEL, CODE_DEADKEY, deadkey_value, 0 + keys[0].dpOutput[0] = UC_SENTINEL; + keys[0].dpOutput[1] = CODE_DEADKEY; + keys[0].dpOutput[2] = deadkey; // TODO: translate to unique index + keys[0].dpOutput[3] = 0; + keys[0].Key = vk; + keys[0].Line = 0; + keys[0].ShiftFlags = shift | ISVIRTUALKEY; + kbd->dpGroupArray[i].dpKeyArray = keys; + kbd->dpGroupArray[i].cxKeyArray++; + //LogError("Add deadkey rule: + [%d K_%d] > dk(%d)", shift, vk, deadkey); + if(i == kbd->StartGroup[1]) break; // If this is the initial group, that's all we need to do. + } + }*/ +} +int KMX_GetDeadkeys(WORD DeadKey, WORD *OutputPairs) { + /*if(IsWow64()) { + return KMX_GetDeadkeys_NT_x64(DeadKey, OutputPairs); + } else { + return KMX_GetDeadkeys_NT(DeadKey, OutputPairs); + }*/ +} +int KMX_GetDeadkeys_NT_x64(WORD DeadKey, WORD *OutputPairs) { + /*WORD *p = OutputPairs, shift; + for(int i = 0; KbdTables_x64->pDeadKey[i].dwBoth; i++) { + if(HIWORD(KbdTables_x64->pDeadKey[i].dwBoth) == DeadKey) { + WORD vk = CharToUSVK_NT_x64(LOWORD(KbdTables_x64->pDeadKey[i].dwBoth), &shift); + if(vk != 0) { + *p++ = vk; + *p++ = shift; + *p++ = KbdTables_x64->pDeadKey[i].wchComposed; + } else { + LogError(L"Warning: complex deadkey not supported."); + } + } + } + *p = 0; + return (INT_PTR)(p-OutputPairs);*/ +} +int KMX_GetDeadkeys_NT(WORD DeadKey, WORD *OutputPairs) { + /*WORD *p = OutputPairs, shift; + for(int i = 0; KbdTables->pDeadKey[i].dwBoth; i++) { + if(HIWORD(KbdTables->pDeadKey[i].dwBoth) == DeadKey) { + WORD vk = CharToUSVK_NT(LOWORD(KbdTables->pDeadKey[i].dwBoth), &shift); + if(vk != 0) { + *p++ = vk; + *p++ = shift; + *p++ = KbdTables->pDeadKey[i].wchComposed; + } else { + LogError(L"Warning: complex deadkey not supported."); + } + } + } + *p = 0; + return (INT_PTR)(p-OutputPairs);*/ + return 999; +} +void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { + /*if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { + + // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. + // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" + // to provide an alternate.. + if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4327 + shift &= ~LCTRLFLAG; + + if(key->ShiftFlags == 0) { + //LogError("Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d]", key->Line, key->Key, deadkey, shift, vk); + key->ShiftFlags = ISVIRTUALKEY | shift; + } else { + //LogError("Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO dk(%d) + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, deadkey, key->ShiftFlags & ~VIRTUALCHARKEY, vk); + key->ShiftFlags &= ~VIRTUALCHARKEY; + } + + int len = wcslen(key->dpContext); + PWSTR context = new WCHAR[len + 4]; + memcpy(context, key->dpContext, len * sizeof(WCHAR)); + context[len] = UC_SENTINEL; + context[len+1] = CODE_DEADKEY; + context[len+2] = deadkey; + context[len+3] = 0; + key->dpContext = context; + key->Key = vk; + }*/ +} + +void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group,KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { + for(unsigned int i = 0; i < group->cxKeyArray; i++) { + KMX_TranslateDeadkeyKey(&group->dpKeyArray[i], deadkey, vk, shift, ch); + } +} + +void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + KMX_TranslateDeadkeyGroup(&kbd->dpGroupArray[i], deadkey, vk, shift, ch); + } + } +} // ---- old copy code from here ---------------------------------------------------------- /* @@ -547,36 +772,7 @@ void TranslateDeadkeyKeyboard(LPKEYBOARD kbd, WCHAR deadkey, WORD vk, UINT shift } } -void AddDeadkeyRule(LPKEYBOARD kbd, WCHAR deadkey, WORD vk, UINT shift) { - // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. - // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" - // to provide an alternate.. - if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4549 - shift &= ~LCTRLFLAG; - // If the first group is not a matching-keys group, then we need to add into - // each subgroup, otherwise just the match group - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { - LPKEY keys = new KEY[kbd->dpGroupArray[i].cxKeyArray + 1]; - memcpy(keys+1, kbd->dpGroupArray[i].dpKeyArray, kbd->dpGroupArray[i].cxKeyArray * sizeof(KEY)); - keys[0].dpContext = new WCHAR[1]; - keys[0].dpContext[0] = 0; - keys[0].dpOutput = new WCHAR[4]; // UC_SENTINEL, CODE_DEADKEY, deadkey_value, 0 - keys[0].dpOutput[0] = UC_SENTINEL; - keys[0].dpOutput[1] = CODE_DEADKEY; - keys[0].dpOutput[2] = deadkey; // TODO: translate to unique index - keys[0].dpOutput[3] = 0; - keys[0].Key = vk; - keys[0].Line = 0; - keys[0].ShiftFlags = shift | ISVIRTUALKEY; - kbd->dpGroupArray[i].dpKeyArray = keys; - kbd->dpGroupArray[i].cxKeyArray++; - //LogError("Add deadkey rule: + [%d K_%d] > dk(%d)", shift, vk, deadkey); - if(i == kbd->StartGroup[1]) break; // If this is the initial group, that's all we need to do. - } - } -} WCHAR ScanXStringForMaxDeadkeyID(LPWSTR str) { WCHAR dkid = 0; @@ -596,83 +792,10 @@ struct dkidmap { WCHAR src_deadkey, dst_deadkey; }; -WCHAR GetUniqueDeadkeyID(LPKEYBOARD kbd, WCHAR deadkey) { - LPGROUP gp; - LPKEY kp; - LPSTORE sp; - UINT i, j; - WCHAR dkid = 0; - static WCHAR s_next_dkid = 0; - static dkidmap *s_dkids = NULL; - static int s_ndkids = 0; - - if(!kbd) { - if(s_dkids) { - delete s_dkids; - } - s_dkids = NULL; - s_ndkids = 0; - s_next_dkid = 0; - return 0; - } - - for(int i = 0; i < s_ndkids; i++) { - if(s_dkids[i].src_deadkey == deadkey) { - return s_dkids[i].dst_deadkey; - } - } - - if(s_next_dkid != 0) { - s_dkids = (dkidmap*) realloc(s_dkids, sizeof(dkidmap) * (s_ndkids+1)); - s_dkids[s_ndkids].src_deadkey = deadkey; - return s_dkids[s_ndkids++].dst_deadkey = ++s_next_dkid; - } - - for(i = 0, gp = kbd->dpGroupArray; i < kbd->cxGroupArray; i++, gp++) { - for(j = 0, kp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kp++) { - dkid = max(dkid, ScanXStringForMaxDeadkeyID(kp->dpContext)); - dkid = max(dkid, ScanXStringForMaxDeadkeyID(kp->dpOutput)); - } - dkid = max(dkid, ScanXStringForMaxDeadkeyID(gp->dpMatch)); - dkid = max(dkid, ScanXStringForMaxDeadkeyID(gp->dpNoMatch)); - } - - for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { - dkid = max(dkid, ScanXStringForMaxDeadkeyID(sp->dpString)); - } - - s_dkids = (dkidmap*) realloc(s_dkids, sizeof(dkidmap) * (s_ndkids+1)); - s_dkids[s_ndkids].src_deadkey = deadkey; - return s_dkids[s_ndkids++].dst_deadkey = s_next_dkid = ++dkid; -} - - -void ConvertDeadkey(LPKEYBOARD kbd, WORD vk, UINT shift, WCHAR deadkey) { - WORD deadkeys[512], *pdk; - - // Lookup the deadkey table for the deadkey in the physical keyboard - // Then for each character, go through and map it through - - WCHAR dkid = GetUniqueDeadkeyID(kbd, deadkey); - - // Add the deadkey to the mapping table for use in the import rules phase - DeadkeyMapping deadkeyMapping = { deadkey, dkid, shift, vk }; // I4353 - FDeadkeys.push_back(deadkeyMapping); //dkid, vk, shift); // I4353 - - AddDeadkeyRule(kbd, dkid, vk, shift); - - GetDeadkeys(deadkey, pdk = deadkeys); // returns array of [usvk, ch_out] pairs - while(*pdk) { - // Look up the ch - UINT vkUnderlying = VKUnderlyingLayoutToVKUS(*pdk); - TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); - pdk+=3; - } -} - */ + //---------old- - original code------------------------------------------ /*#include "pch.h" #include From 0c5dab947ed8240ea6879bc8ec311ef850c864ae Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 1 Dec 2023 21:56:26 +0100 Subject: [PATCH 142/327] feat(linux): mcompile open more functions for deadkeys --- linux/mcompile/keymap/mcompile.cpp | 116 +++++++++++++++-------------- linux/mcompile/keymap/mcompile.h | 2 + 2 files changed, 63 insertions(+), 55 deletions(-) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index d747bc2a08..39688d98fc 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -206,6 +206,11 @@ UINT KMX_VKUSToSCUnderlyingLayout(KMX_DWORD VirtualKeyUS) { return SC_OTHER; } + +struct KMX_dkidmap { + KMX_WCHAR src_deadkey, dst_deadkey; +}; + // takes capital letter of US returns cpital character of Other keyboard KMX_DWORD KMX_VKUSToVKUnderlyingLayout(v_dw_3D &All_Vector,KMX_DWORD inUS) { // loop and find char in US; then return char of Other @@ -321,15 +326,36 @@ int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ return 0; } +// Note: max is not a standard c api function or macro +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif + +//LPWSTR +KMX_WCHAR KMX_ScanXStringForMaxDeadkeyID(PKMX_WCHAR str) { + KMX_WCHAR dkid = 0; + while(str && *str) { + if(*str == UC_SENTINEL) { + switch(*(str+1)) { + case CODE_DEADKEY: + dkid = max(dkid, *(str+2)); + } + } + str = KMX_incxstr(str); + } + return dkid; +} + + KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { KMX_WCHAR noneS2; - /*LPGROUP gp; - LPKEY kp; - LPSTORE sp; + LPKMX_GROUP gp; + LPKMX_KEY kp; + LPKMX_STORE sp; UINT i, j; - WCHAR dkid = 0; - static WCHAR s_next_dkid = 0; - static dkidmap *s_dkids = NULL; + KMX_WCHAR dkid = 0; + static KMX_WCHAR s_next_dkid = 0; + static KMX_dkidmap *s_dkids = NULL; static int s_ndkids = 0; if(!kbd) { @@ -349,28 +375,27 @@ KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { } if(s_next_dkid != 0) { - s_dkids = (dkidmap*) realloc(s_dkids, sizeof(dkidmap) * (s_ndkids+1)); + s_dkids = (KMX_dkidmap*) realloc(s_dkids, sizeof(KMX_dkidmap) * (s_ndkids+1)); s_dkids[s_ndkids].src_deadkey = deadkey; return s_dkids[s_ndkids++].dst_deadkey = ++s_next_dkid; } for(i = 0, gp = kbd->dpGroupArray; i < kbd->cxGroupArray; i++, gp++) { for(j = 0, kp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kp++) { - dkid = max(dkid, ScanXStringForMaxDeadkeyID(kp->dpContext)); - dkid = max(dkid, ScanXStringForMaxDeadkeyID(kp->dpOutput)); + dkid = max(dkid, KMX_ScanXStringForMaxDeadkeyID(kp->dpContext)); + dkid = max(dkid, KMX_ScanXStringForMaxDeadkeyID(kp->dpOutput)); } - dkid = max(dkid, ScanXStringForMaxDeadkeyID(gp->dpMatch)); - dkid = max(dkid, ScanXStringForMaxDeadkeyID(gp->dpNoMatch)); + dkid = max(dkid, KMX_ScanXStringForMaxDeadkeyID(gp->dpMatch)); + dkid = max(dkid, KMX_ScanXStringForMaxDeadkeyID(gp->dpNoMatch)); } for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { - dkid = max(dkid, ScanXStringForMaxDeadkeyID(sp->dpString)); + dkid = max(dkid, KMX_ScanXStringForMaxDeadkeyID(sp->dpString)); } - s_dkids = (dkidmap*) realloc(s_dkids, sizeof(dkidmap) * (s_ndkids+1)); + s_dkids = (KMX_dkidmap*) realloc(s_dkids, sizeof(KMX_dkidmap) * (s_ndkids+1)); s_dkids[s_ndkids].src_deadkey = deadkey; - return s_dkids[s_ndkids++].dst_deadkey = s_next_dkid = ++dkid;*/ - return noneS2; + return s_dkids[s_ndkids++].dst_deadkey = s_next_dkid = ++dkid; } void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR deadkey) { @@ -379,20 +404,20 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR d // Lookup the deadkey table for the deadkey in the physical keyboard // Then for each character, go through and map it through -KMX_WCHAR dkid = KMX_GetUniqueDeadkeyID(kbd, deadkey); + KMX_WCHAR dkid = KMX_GetUniqueDeadkeyID(kbd, deadkey); // _S2 OK Conversion easy - should work right away // Add the deadkey to the mapping table for use in the import rules phase KMX_DeadkeyMapping KMX_deadkeyMapping = { deadkey, dkid, shift, vk }; // I4353 KMX_FDeadkeys.push_back(KMX_deadkeyMapping); //dkid, vk, shift); // I4353 - KMX_AddDeadkeyRule(kbd, dkid, vk, shift); + KMX_AddDeadkeyRule(kbd, dkid, vk, shift); // _S2 OK Conversion easy - should work right away + KMX_GetDeadkeys(deadkey, pdk = deadkeys); // returns array of [usvk, ch_out] pairs // _S2 Conversion hard but similar to keys remove _NT86,... - KMX_GetDeadkeys(deadkey, pdk = deadkeys); // returns array of [usvk, ch_out] pairs while(*pdk) { // Look up the ch // _S2 the new function returns KMX_DWORD - UINT vkUnderlying = KMX_VKUnderlyingLayoutToVKUS_S2(*pdk); - KMX_TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); + UINT vkUnderlying = KMX_VKUnderlyingLayoutToVKUS_S2(*pdk); // _S2 Conversion medium use my gdk-funct + KMX_TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); // _S2 OK Conversion easy - should work right away pdk+=3; } } @@ -467,12 +492,10 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon ch = DeadKey; } } - +//_S2 convert deadkey KMX_ //wprintf(L" switch with ch: %i (%c)......\n" , ch,ch); switch(ch) { - case 0x0000: break; - // _S2 TODO deadkeys will be done later case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey); break; default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); } @@ -553,10 +576,10 @@ void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_ void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key) { if(key->ShiftFlags == 0) { //KMX_LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); - //wprintf(L" _S2 Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); + wprintf(L" _S2 Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); } else if(key->ShiftFlags & VIRTUALCHARKEY) { //KMX_LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); - //wprintf(L"_S2 Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); + wprintf(L"_S2 Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); } } @@ -578,18 +601,18 @@ void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. - /*if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4549 + if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4549 shift &= ~LCTRLFLAG; // If the first group is not a matching-keys group, then we need to add into // each subgroup, otherwise just the match group for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { if(kbd->dpGroupArray[i].fUsingKeys) { - LPKMX_KEY keys = new KEY[kbd->dpGroupArray[i].cxKeyArray + 1]; - memcpy(keys+1, kbd->dpGroupArray[i].dpKeyArray, kbd->dpGroupArray[i].cxKeyArray * sizeof(KEY)); - keys[0].dpContext = new WCHAR[1]; + LPKMX_KEY keys = new KMX_KEY[kbd->dpGroupArray[i].cxKeyArray + 1]; + memcpy(keys+1, kbd->dpGroupArray[i].dpKeyArray, kbd->dpGroupArray[i].cxKeyArray * sizeof(KMX_KEY)); + keys[0].dpContext = new KMX_WCHAR[1]; keys[0].dpContext[0] = 0; - keys[0].dpOutput = new WCHAR[4]; // UC_SENTINEL, CODE_DEADKEY, deadkey_value, 0 + keys[0].dpOutput = new KMX_WCHAR[4]; // UC_SENTINEL, CODE_DEADKEY, deadkey_value, 0 keys[0].dpOutput[0] = UC_SENTINEL; keys[0].dpOutput[1] = CODE_DEADKEY; keys[0].dpOutput[2] = deadkey; // TODO: translate to unique index @@ -602,7 +625,7 @@ void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT //LogError("Add deadkey rule: + [%d K_%d] > dk(%d)", shift, vk, deadkey); if(i == kbd->StartGroup[1]) break; // If this is the initial group, that's all we need to do. } - }*/ + } } @@ -652,7 +675,7 @@ int KMX_GetDeadkeys_NT(WORD DeadKey, WORD *OutputPairs) { } void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { - /*if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { + if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" @@ -668,16 +691,18 @@ void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT key->ShiftFlags &= ~VIRTUALCHARKEY; } - int len = wcslen(key->dpContext); - PWSTR context = new WCHAR[len + 4]; - memcpy(context, key->dpContext, len * sizeof(WCHAR)); + int len = u16len(key->dpContext); + + //PWSTR + PKMX_WCHAR context = new KMX_WCHAR[len + 4]; + memcpy(context, key->dpContext, len * sizeof(KMX_WCHAR)); context[len] = UC_SENTINEL; context[len+1] = CODE_DEADKEY; context[len+2] = deadkey; context[len+3] = 0; key->dpContext = context; key->Key = vk; - }*/ + } } void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group,KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { @@ -773,25 +798,6 @@ void TranslateDeadkeyKeyboard(LPKEYBOARD kbd, WCHAR deadkey, WORD vk, UINT shift } - -WCHAR ScanXStringForMaxDeadkeyID(LPWSTR str) { - WCHAR dkid = 0; - while(str && *str) { - if(*str == UC_SENTINEL) { - switch(*(str+1)) { - case CODE_DEADKEY: - dkid = max(dkid, *(str+2)); - } - } - str = incxstr(str); - } - return dkid; -} - -struct dkidmap { - WCHAR src_deadkey, dst_deadkey; -}; - */ diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index f6f5179af6..f5fd9f287d 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -45,6 +45,8 @@ extern std::vector KMX_FDeadkeys; // I4353 KMX_WORD KMX_VKUnderlyingLayoutToVKUS(KMX_WORD VKey); KMX_WORD KMX_VKUnderlyingLayoutToVKUS(v_dw_3D &All_Vector,KMX_DWORD inOther); KMX_WCHART KMX_VKUnderlyingLayoutToVKUS_GDK(GdkKeymap* keymap,KMX_DWORD inOther); + +PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); //--------------------old /* #include From 901429671748973600f8570159ee3a942d728309 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 1 Dec 2023 23:07:01 +0100 Subject: [PATCH 143/327] feat(linux): mcompile tidy up --- linux/mcompile/keymap/keymap.cpp | 291 +++++------ linux/mcompile/keymap/keymap.h | 57 +-- linux/mcompile/keymap/mc_import_rules.cpp | 259 +++++----- linux/mcompile/keymap/mc_kmxfile.h | 2 +- linux/mcompile/keymap/mcompile.cpp | 578 +++++++++++----------- linux/mcompile/keymap/mcompile.h | 6 +- 6 files changed, 585 insertions(+), 608 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 82e6c9c6e7..fa6143f06c 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -2,6 +2,83 @@ #include + +int map_VKShiftState_to_Lin(int VKShiftState) { + if (VKShiftState == 0 ) return 0; /* 0000 0000 */ + if (VKShiftState == 16) return 1; /* 0001 0000 */ + //if (VKShiftState == 9 ) return 2; /* 0000 1001 */ + //if (VKShiftState == 25) return 3; /* 0001 1001 */ + return VKShiftState; +} + +KMX_DWORD convertNamesToASCIIValue(std::wstring tok_wstr){ + std::map first; + + + first[L"ampersand"] = 38; + first[L"apostrophe"] = 39; + first[L"asciicircum"] = 136; + first[L"asciitilde"] = 126; + first[L"asterisk"] = 42; + first[L"at"] = 64; + first[L"backslash"] = 92; + first[L"bar"] = 124; + first[L"braceleft"] = 123; + first[L"braceright"] = 125; + first[L"bracketleft"] = 91; + first[L"bracketright"] = 93; + first[L"colon"] = 58; + first[L"comma"] = 44; + first[L"dollar"] = 36; + first[L"equal"] = 61; + first[L"exclam"] = 33; + first[L"grave"] = 96; + first[L"greater"] = 62; + first[L"less"] = 60; + first[L"minus"] = 45; + first[L"numbersign"] = 35; + first[L"parenleft"] = 40; + first[L"parenright"] = 41; + first[L"percent"] = 37; + first[L"period"] = 46; + first[L"plus"] = 43; + first[L"question"] = 63; + first[L"quotedbl"] = 34; + first[L"semicolon"] = 59; + first[L"slash"] = 47; + first[L"space"] = 32; + first[L"ssharp"] = 223; + first[L"underscore"] = 95; + + first[L"dead_abovedot"] = 729; + first[L"dead_abovering"] = 730; + first[L"dead_acute"] = 180; //39 180 ?? + first[L"dead_breve"] = 728; + first[L"dead_caron"] = 711; + first[L"dead_cedilla"] = 184; + first[L"dead_circumflex"] = 94; + first[L"dead_diaeresis"] = 168; + first[L"dead_doubleacute"] = 733; + first[L"dead_grave"] = 96; + first[L"dead_ogonek"] = 731; + first[L"dead_perispomeni"] = 126; + first[L"dead_tilde"] = 126; + + //first[L" ?? "] = VK_OEM_102; /* DE = 226 ' " ? VK_OEM_102 */ + + if ( tok_wstr.size() == 1) { + return (KMX_DWORD) ( *tok_wstr.c_str() );; + } + else { + std::map ::iterator it; + for (it = first.begin(); it != first.end(); ++it) { + if (it->first == tok_wstr) + return it->second; + } + } + return returnIfCharInvalid; +} + int write_US_ToVector( v_dw_3D &vec,std::string language, const char* text) { std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; @@ -75,142 +152,6 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, return 0; } -KMX_DWORD convertNamesToASCIIValue(std::wstring tok_wstr){ - std::map first; - - - first[L"ampersand"] = 38; - first[L"apostrophe"] = 39; - first[L"asciicircum"] = 136; - first[L"asciitilde"] = 126; - first[L"asterisk"] = 42; - first[L"at"] = 64; - first[L"backslash"] = 92; - first[L"bar"] = 124; - first[L"braceleft"] = 123; - first[L"braceright"] = 125; - first[L"bracketleft"] = 91; - first[L"bracketright"] = 93; - first[L"colon"] = 58; - first[L"comma"] = 44; - first[L"dollar"] = 36; - first[L"equal"] = 61; - first[L"exclam"] = 33; - first[L"grave"] = 96; - first[L"greater"] = 62; - first[L"less"] = 60; - first[L"minus"] = 45; - first[L"numbersign"] = 35; - first[L"parenleft"] = 40; - first[L"parenright"] = 41; - first[L"percent"] = 37; - first[L"period"] = 46; - first[L"plus"] = 43; - first[L"question"] = 63; - first[L"quotedbl"] = 34; - first[L"semicolon"] = 59; - first[L"slash"] = 47; - first[L"space"] = 32; - first[L"ssharp"] = 223; - first[L"underscore"] = 95; - - first[L"dead_abovedot"] = 729; - first[L"dead_abovering"] = 730; - first[L"dead_acute"] = 180; //39 180 ?? - first[L"dead_breve"] = 728; - first[L"dead_caron"] = 711; - first[L"dead_cedilla"] = 184; - first[L"dead_circumflex"] = 94; - first[L"dead_diaeresis"] = 168; - first[L"dead_doubleacute"] = 733; - first[L"dead_grave"] = 96; - first[L"dead_ogonek"] = 731; - first[L"dead_perispomeni"] = 126; - first[L"dead_tilde"] = 126; - - //first[L" ?? "] = VK_OEM_102; /* DE = 226 ' " ? VK_OEM_102 */ - - if ( tok_wstr.size() == 1) { - return (KMX_DWORD) ( *tok_wstr.c_str() );; - } - else { - std::map ::iterator it; - for (it = first.begin(); it != first.end(); ++it) { - if (it->first == tok_wstr) - return it->second; - } - } - return returnIfCharInvalid; -} - -int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { - // 1: take the whole line of the 1D-Vector and remove unwanted characters. - // 2: seperate the name e.g. key from the shiftstates - // 3: convert to KMX_DWORD - // 4: push Names/Shiftstates to shift_states and then shift_states to All_US, our 3D-Vector holding all Elements - - std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; - char split_bracel = '{'; - char split_char_komma = ','; - int Keycde; - v_str_1D tokens; - v_dw_1D tokens_dw; - v_dw_2D shift_states; - KMX_DWORD tokens_int; - std::wstring tok_wstr; - - // loop through the whole vector - for (int k = 0; k < (int)completeList.size(); k++) { - - // remove all unwanted char - for (int i = 0; i < (int) delim.size(); i++) { - completeList[k].erase(remove(completeList[k].begin(), completeList[k].end(), delim[i]), completeList[k].end()); - } - - // only lines with ("key<.. are of interest - if (completeList[k].find("key<") != std::string::npos) { - - //split off the key names - std::istringstream split1(completeList[k]); - for (std::string each; std::getline(split1, each, split_bracel); tokens.push_back(each)); - - // replace keys names with Keycode ( with 21,...) - Keycde = replace_KeyName_with_Keycode(tokens[0]); - tokens[0] = std::to_string(Keycde); - - // seperate rest of the vector to its elements and push to 'tokens' - std::istringstream split(tokens[1]); - tokens.pop_back(); - - for (std::string each; std::getline(split, each, split_char_komma); tokens.push_back(each)); - - // now convert all to KMX_DWORD and fill tokens - tokens_dw.push_back((KMX_DWORD) Keycde); - - for ( int i = 1; i< (int) tokens.size();i++) { - - // replace a name with a single character ( a -> a ; equal -> = ) - tokens_int = convertNamesToASCIIValue( wstring_from_string(tokens[i])); - tokens_dw.push_back(tokens_int); - } - - //wprintf(L" Keyval %i: %i (%c) --- %i (%c) \n", tokens_dw[0],tokens_dw[1],tokens_dw[1], tokens_dw[2], tokens_dw[2]); - - // now push result to shift_states - shift_states.push_back(tokens_dw); - tokens_dw.clear(); - tokens.clear(); - } - } - all_US.push_back(shift_states); - - if ( all_US.size() == 0) { - wprintf(L"ERROR: Can't split US to 3D-Vector\n"); - return 1; - } - return 0; -} - int replace_KeyName_with_Keycode(std::string in) { int out = returnIfCharInvalid; @@ -274,6 +215,74 @@ int replace_KeyName_with_Keycode(std::string in) { return out; } +int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { + // 1: take the whole line of the 1D-Vector and remove unwanted characters. + // 2: seperate the name e.g. key from the shiftstates + // 3: convert to KMX_DWORD + // 4: push Names/Shiftstates to shift_states and then shift_states to All_US, our 3D-Vector holding all Elements + + std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; + char split_bracel = '{'; + char split_char_komma = ','; + int Keycde; + v_str_1D tokens; + v_dw_1D tokens_dw; + v_dw_2D shift_states; + KMX_DWORD tokens_int; + std::wstring tok_wstr; + + // loop through the whole vector + for (int k = 0; k < (int)completeList.size(); k++) { + + // remove all unwanted char + for (int i = 0; i < (int) delim.size(); i++) { + completeList[k].erase(remove(completeList[k].begin(), completeList[k].end(), delim[i]), completeList[k].end()); + } + + // only lines with ("key<.. are of interest + if (completeList[k].find("key<") != std::string::npos) { + + //split off the key names + std::istringstream split1(completeList[k]); + for (std::string each; std::getline(split1, each, split_bracel); tokens.push_back(each)); + + // replace keys names with Keycode ( with 21,...) + Keycde = replace_KeyName_with_Keycode(tokens[0]); + tokens[0] = std::to_string(Keycde); + + // seperate rest of the vector to its elements and push to 'tokens' + std::istringstream split(tokens[1]); + tokens.pop_back(); + + for (std::string each; std::getline(split, each, split_char_komma); tokens.push_back(each)); + + // now convert all to KMX_DWORD and fill tokens + tokens_dw.push_back((KMX_DWORD) Keycde); + + for ( int i = 1; i< (int) tokens.size();i++) { + + // replace a name with a single character ( a -> a ; equal -> = ) + tokens_int = convertNamesToASCIIValue( wstring_from_string(tokens[i])); + tokens_dw.push_back(tokens_int); + } + + //wprintf(L" Keyval %i: %i (%c) --- %i (%c) \n", tokens_dw[0],tokens_dw[1],tokens_dw[1], tokens_dw[2], tokens_dw[2]); + + // now push result to shift_states + shift_states.push_back(tokens_dw); + tokens_dw.clear(); + tokens.clear(); + } + } + all_US.push_back(shift_states); + + if ( all_US.size() == 0) { + wprintf(L"ERROR: Can't split US to 3D-Vector\n"); + return 1; + } + return 0; +} + v_dw_2D create_empty_2D_Vector( int dim_rows,int dim_shifts) { v_dw_1D shifts; @@ -402,6 +411,7 @@ KMX_DWORD get_VKUS_fromKeyCode( KMX_DWORD keycode) { return (KMX_DWORD) ScanCodeToUSVirtualKey[keycode-8]; return 0; //_S2 what to return if not found } + KMX_DWORD get_KeyCode_fromVKUS( KMX_DWORD VK_US) { if( VK_US > 7) { KMX_DWORD test = (KMX_DWORD)(8+ USVirtualKeyToScanCode[ VK_US ]); @@ -539,12 +549,3 @@ std::wstring get_KeyVals_according_to_keycode_and_Shiftstate_new(GdkKeymap *key return convert_DeadkeyValues_ToChar((int) *keyvals);; } - - -int map_VKShiftState_to_Lin(int VKShiftState) { - if (VKShiftState == 0 ) return 0; /* 0000 0000 */ - if (VKShiftState == 16) return 1; /* 0001 0000 */ - //if (VKShiftState == 9 ) return 2; /* 0000 1001 */ - //if (VKShiftState == 25) return 3; /* 0001 1001 */ - return VKShiftState; -} diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 0a34b804e5..82472a91b9 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -24,6 +24,7 @@ typedef std::vector v_dw_1D; typedef std::vector > v_dw_2D; typedef std::vector > > v_dw_3D; +// _S2 sort declarations/definitions to mcompile or keymaap.. enum ShiftState { Base = 0, // 0 @@ -38,8 +39,6 @@ enum ShiftState { ShftXxxx = Shft | Xxxx, // 9 }; -int map_VKShiftState_to_Lin(int VKShiftState); - const UINT USVirtualKeyToScanCode[256] = { 0x00, // L"K_?00", // &H0 0x00, // L"K_LBUTTON", // &H1 @@ -444,8 +443,6 @@ const KMX_DWORD KMX_VKMap[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - //_S2 those might not work correctly yet*/ - VK_SPACE, /* 32 */ VK_ACCENT, /* 192 VK_OEM_3 */ @@ -477,11 +474,14 @@ static KMX_DWORD returnIfCharInvalid = 0; //_S2 QUESTION Which threshold ( from what int value onwards is a character considered deadkey? 65000 28000?, > 255? ?? static KMX_DWORD deadkeyThreshold = 65000; +int map_VKShiftState_to_Lin(int VKShiftState); + // takes a std::wstring (=contents of line symbols-file ) and returns the (int) value of the character KMX_DWORD convertNamesToASCIIValue(std::wstring tok_wstr); -// create a Vector with all entries of Vector -int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector); +// create a Vector with all entries of both keymaps+ keymap +int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap); +//int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector); // read configuration file, split and write to 3D-Vector (Data for US on [0][ ][ ] ) int write_US_ToVector(v_dw_3D &vec, std::string language, const char *text); @@ -489,32 +489,24 @@ int write_US_ToVector(v_dw_3D &vec, std::string language, const char *text); // 1. step: read complete Row of Configuration file US bool createCompleteRow_US(v_str_1D &complete_List, FILE *fpp, const char *text, std::string language); -// 2nd step: write contents to 3D vector -int split_US_To_3D_Vector(v_dw_3D &all_US, v_str_1D completeList); - // replace Name of Key (e.g. ) wih Keycode ( e.g. 0x15 ) int replace_KeyName_with_Keycode(std::string in); +// 2nd step: write contents to 3D vector +int split_US_To_3D_Vector(v_dw_3D &all_US, v_str_1D completeList); + // create an empty 2D vector containing "--" in all fields v_dw_2D create_empty_2D_Vector(int dim_rows, int dim_shifts); -// return the Scancode of for given VirtualKey using GDK -KMX_DWORD get_KeyCode_From_KeyVal_GDK(GdkKeymap *keymap, UINT Keyval); - -// return the VirtualKey of the Other Keyboard for given Scancode using GDK -KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD scanCode); - -KMX_DWORD get_VKUS_fromKeyCode( KMX_DWORD keycode); -KMX_DWORD get_KeyCode_fromVKUS( KMX_DWORD VK_US); - -UINT map_Ikey_DE(UINT iKey); +//_S2 needed? +// append characters using GDK to 3D-Vector (Data for Other Language on [1][ ][ ] ) +int append_other_ToVector(v_dw_3D &All_Vector, GdkKeymap *keymap); // initialize GDK bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); -//_S2 needed? -// append characters using GDK to 3D-Vector (Data for Other Language on [1][ ][ ] ) -int append_other_ToVector(v_dw_3D &All_Vector, GdkKeymap *keymap); +// return the Scancode of for given VirtualKey using GDK +KMX_DWORD get_KeyCode_From_KeyVal_GDK(GdkKeymap *keymap, UINT Keyval); // find Keyvals to fill into 2D-Vector of Other Language KMX_DWORD getKeyvalsFromKeyCode(GdkKeymap *keymap, guint keycode, int shift_state_pos); @@ -522,23 +514,26 @@ KMX_DWORD getKeyvalsFromKeyCode(GdkKeymap *keymap, guint keycode, int shift_stat // returns KeySyms fo ra given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) std::wstring get_KeyVals_according_to_keycode_and_Shiftstate_new(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); +// return the VirtualKey of the Other Keyboard for given Scancode using GDK +KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD scanCode); + +KMX_DWORD get_VKUS_fromKeyCode( KMX_DWORD keycode); + +KMX_DWORD get_KeyCode_fromVKUS( KMX_DWORD VK_US); + bool IsKeymanUsedKeyVal(std::wstring Keyval); + +//UINT find_SC_Other_from_SC_US_GDK(UINT vk_US_187,GdkKeymap *keymap); + +UINT map_Ikey_DE(UINT iKey); // _S2 needed? // can go later void Try_GDK(GdkKeymap *keymap, UINT KeySym ); -void Inspect_Key_S(GdkKeymap *keymap ); -//UINT find_SC_Other_from_SC_US_GDK(UINT vk_US_187,GdkKeymap *keymap); -// _S2 needed? -// create a Vector with all entries of both keymaps+ keymap -int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap); - -//needed? +void Inspect_Key_S(GdkKeymap *keymap );//needed? // _S2 TODO How to do mapping between Linux keycodes and keyman SC const int Lin_KM__map(int i, v_dw_3D &All_Vector); - KMX_DWORD mapChar_To_VK(KMX_DWORD chr ); - KMX_DWORD mapVK_To_char(KMX_DWORD SC ); # endif /*KEYMAP_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index f1045e4c5f..6f1d08cb50 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -665,70 +665,6 @@ public: }*/ }; -// _S2 where to put this?? -const int CODE__SIZE[] = { - -1, // undefined 0x00 - 1, // CODE_ANY 0x01 - 2, // CODE_INDEX 0x02 - 0, // CODE_CONTEXT 0x03 - 0, // CODE_NUL 0x04 - 1, // CODE_USE 0x05 - 0, // CODE_RETURN 0x06 - 0, // CODE_BEEP 0x07 - 1, // CODE_DEADKEY 0x08 - -1, // unused 0x09 - 2, // CODE_EXTENDED 0x0A - -1, // CODE_EXTENDEDEND 0x0B (unused) - 1, // CODE_SWITCH 0x0C - -1, // CODE_KEY 0x0D (never used) - 0, // CODE_CLEARCONTEXT 0x0E - 1, // CODE_CALL 0x0F - -1, // UC_SENTINEL_EXTENDEDEND 0x10 (not valid with UC_SENTINEL) - 1, // CODE_CONTEXTEX 0x11 - 1, // CODE_NOTANY 0x12 - 2, // CODE_SETOPT 0x13 - 3, // CODE_IFOPT 0x14 - 1, // CODE_SAVEOPT 0x15 - 1, // CODE_RESETOPT 0x16 - 3, // CODE_IFSYSTEMSTORE 0x17 - 2 // CODE_SETSYSTEMSTORE 0x18 -}; - -// _S2 where to put this?? -PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p) { - - if (*p == 0) - return p; - if (*p != UC_SENTINEL) { - if (*p >= 0xD800 && *p <= 0xDBFF && *(p + 1) >= 0xDC00 && *(p + 1) <= 0xDFFF) - return p + 2; - return p + 1; - } - // UC_SENTINEL(FFFF) with UC_SENTINEL_EXTENDEDEND(0x10) == variable length - if (*(p + 1) == CODE_EXTENDED) { - p += 2; - while (*p && *p != UC_SENTINEL_EXTENDEDEND) - p++; - - if (*p == 0) return p; - return p + 1; - } - - if (*(p + 1) > CODE_LASTCODE || CODE__SIZE[*(p + 1)] == -1) { - return p + 1; - } - - int deltaptr = 2 + CODE__SIZE[*(p + 1)]; - - // check for \0 between UC_SENTINEL(FFFF) and next printable character - for (int i = 0; i < deltaptr; i++) { - if (*p == 0) - return p; - p++; - } - return p; -} - int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { int n = 0; while(p && *p) { @@ -743,65 +679,6 @@ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { return n; } -bool IsKeymanUsedKeyVal(std::wstring Keyval) { - - - - int KV = (int) (*Keyval.c_str()); - - // 32 127 196 256 - if ((KV >= 0x20 && KV <= 0x7F) || (KV >= 0xC4 && KV < 198) || - (KV >= 199 && KV < 208) || (KV >= 209 && KV < 216) || (KV >= 217 && KV < 229) || - (KV >= 231 && KV < 240) || (KV >= 241 && KV < 248) || (KV >= 249 && KV < 0xFF) || - (KV == 128) || (KV == 178) || (KV == 167) || (KV == 179)|| (KV == 176)|| (KV == 181) ) - - - // 32 127 136 256 - //if ((KV >= 0x20 && KV <= 0x7F) || (KV == 214)|| (KV == 246)|| (KV ==196)|| (KV == 228) || (KV ==220)|| (KV == 252)|| (KV ==223)|| (KV == 186)) - return true; - else - - return false; - -} - -void Inspect_kp(LPKMX_KEYBOARD kp) { - wprintf(L"-------\n"); - wprintf(L"-------\n"); - wprintf(L"-------\n"); - wprintf(L"kp has %i groups and %i keys\n",kp->cxGroupArray, kp->dpGroupArray->cxKeyArray); - wprintf(L"-------\n"); - -//for ( int i=0; i<150;i++) { -for ( int i=0; idpGroupArray->cxKeyArray;i++) { - wprintf(L"key nr :%i has key:%i(%c) Line:%i Shiftflags:%i Output %c (%d)\n",i,kp->dpGroupArray->dpKeyArray->Key,kp->dpGroupArray->dpKeyArray->Key, - kp->dpGroupArray->dpKeyArray->Line,kp->dpGroupArray->dpKeyArray->ShiftFlags ,kp->dpGroupArray->dpKeyArray->dpOutput,*kp->dpGroupArray->dpKeyArray->dpOutput ); - kp->dpGroupArray->dpKeyArray++; -} - wprintf(L"-------\n"); - wprintf(L"-------\n"); - wprintf(L"-------\n"); -} - - -void Inspect_gp(KMX_tagGROUP* gp) { - for (int i = 0; i < gp->cxKeyArray; i++) { - wprintf(L"key nr : has key:%i(%c) Line:%i Shiftflags:%i Output %c (%d)\n", gp->dpKeyArray->Key, gp->dpKeyArray->Key, - gp->dpKeyArray->Line, gp->dpKeyArray->ShiftFlags, gp->dpKeyArray->dpOutput, *gp->dpKeyArray->dpOutput); - // gp->cxKeyArray++; - } -} - -void Inspect_key(LPKMX_KEY key) { - //for (int i = 0; i < gp->cxKeyArray; i++) { - wprintf(L"key nr : has key:%i(%c) Line:%i Shiftflags:%i Output \n", key->Key, key->Key, - key->Line, key->ShiftFlags); - /*wprintf(L"key nr : has key:%i(%c) Line:%i Shiftflags:%i Output %c (%d)\n", key->Key, key->Key, - key->Line, key->ShiftFlags, key->dpOutput, *key->dpOutput);*/ - // gp->cxKeyArray++; - // } -} - bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 KMX_Loader loader; const size_t BUF_sz= 256; @@ -810,19 +687,6 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd KMX_WCHAR inputHKL[12]; u16sprintf(inputHKL,BUF_sz ,L"%08.8x", (unsigned int) u16tol(kbid, NULL, 16)); // _S2 wsprintf(inputHKL, L"%08.8x", (unsigned int) wcstol(kbid, NULL, 16)); - - /* - // _S2 do I need that for Linux?? - int cKeyboards = GetKeyboardLayoutList(0, NULL); - HKL *rghkl = new HKL[cKeyboards]; - GetKeyboardLayoutList(cKeyboards, rghkl); - HKL hkl = LoadKeyboardLayout(inputHKL, KLF_NOTELLSHELL); - if(hkl == NULL) { - puts("Sorry, that keyboard does not seem to be valid."); - delete[] rghkl; - return false; - } - */ KMX_HKL hkl = NULL; //_S2 added: but can I do this?? hkl is not needed in Linux?? BYTE lpKeyState[256];// = new KeysEx[256]; @@ -1158,3 +1022,126 @@ int STOP=0; // _S2 LayoutRow: VKToUnderlying should work OK; GetSSValue not che //Inspect_kp(kp); return true; } + + +// _S2 where to put this?? +const int CODE__SIZE[] = { + -1, // undefined 0x00 + 1, // CODE_ANY 0x01 + 2, // CODE_INDEX 0x02 + 0, // CODE_CONTEXT 0x03 + 0, // CODE_NUL 0x04 + 1, // CODE_USE 0x05 + 0, // CODE_RETURN 0x06 + 0, // CODE_BEEP 0x07 + 1, // CODE_DEADKEY 0x08 + -1, // unused 0x09 + 2, // CODE_EXTENDED 0x0A + -1, // CODE_EXTENDEDEND 0x0B (unused) + 1, // CODE_SWITCH 0x0C + -1, // CODE_KEY 0x0D (never used) + 0, // CODE_CLEARCONTEXT 0x0E + 1, // CODE_CALL 0x0F + -1, // UC_SENTINEL_EXTENDEDEND 0x10 (not valid with UC_SENTINEL) + 1, // CODE_CONTEXTEX 0x11 + 1, // CODE_NOTANY 0x12 + 2, // CODE_SETOPT 0x13 + 3, // CODE_IFOPT 0x14 + 1, // CODE_SAVEOPT 0x15 + 1, // CODE_RESETOPT 0x16 + 3, // CODE_IFSYSTEMSTORE 0x17 + 2 // CODE_SETSYSTEMSTORE 0x18 +}; + +// _S2 where to put this?? +PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p) { + + if (*p == 0) + return p; + if (*p != UC_SENTINEL) { + if (*p >= 0xD800 && *p <= 0xDBFF && *(p + 1) >= 0xDC00 && *(p + 1) <= 0xDFFF) + return p + 2; + return p + 1; + } + // UC_SENTINEL(FFFF) with UC_SENTINEL_EXTENDEDEND(0x10) == variable length + if (*(p + 1) == CODE_EXTENDED) { + p += 2; + while (*p && *p != UC_SENTINEL_EXTENDEDEND) + p++; + + if (*p == 0) return p; + return p + 1; + } + + if (*(p + 1) > CODE_LASTCODE || CODE__SIZE[*(p + 1)] == -1) { + return p + 1; + } + + int deltaptr = 2 + CODE__SIZE[*(p + 1)]; + + // check for \0 between UC_SENTINEL(FFFF) and next printable character + for (int i = 0; i < deltaptr; i++) { + if (*p == 0) + return p; + p++; + } + return p; +} + +bool IsKeymanUsedKeyVal(std::wstring Keyval) { + + + + int KV = (int) (*Keyval.c_str()); + + // 32 127 196 256 + if ((KV >= 0x20 && KV <= 0x7F) || (KV >= 0xC4 && KV < 198) || + (KV >= 199 && KV < 208) || (KV >= 209 && KV < 216) || (KV >= 217 && KV < 229) || + (KV >= 231 && KV < 240) || (KV >= 241 && KV < 248) || (KV >= 249 && KV < 0xFF) || + (KV == 128) || (KV == 178) || (KV == 167) || (KV == 179)|| (KV == 176)|| (KV == 181) ) + + + // 32 127 136 256 + //if ((KV >= 0x20 && KV <= 0x7F) || (KV == 214)|| (KV == 246)|| (KV ==196)|| (KV == 228) || (KV ==220)|| (KV == 252)|| (KV ==223)|| (KV == 186)) + return true; + else + + return false; + +} + +void Inspect_kp(LPKMX_KEYBOARD kp) { + wprintf(L"-------\n"); + wprintf(L"-------\n"); + wprintf(L"-------\n"); + wprintf(L"kp has %i groups and %i keys\n",kp->cxGroupArray, kp->dpGroupArray->cxKeyArray); + wprintf(L"-------\n"); + +//for ( int i=0; i<150;i++) { +for ( int i=0; idpGroupArray->cxKeyArray;i++) { + wprintf(L"key nr :%i has key:%i(%c) Line:%i Shiftflags:%i Output %c (%d)\n",i,kp->dpGroupArray->dpKeyArray->Key,kp->dpGroupArray->dpKeyArray->Key, + kp->dpGroupArray->dpKeyArray->Line,kp->dpGroupArray->dpKeyArray->ShiftFlags ,kp->dpGroupArray->dpKeyArray->dpOutput,*kp->dpGroupArray->dpKeyArray->dpOutput ); + kp->dpGroupArray->dpKeyArray++; +} + wprintf(L"-------\n"); + wprintf(L"-------\n"); + wprintf(L"-------\n"); +} + +void Inspect_gp(KMX_tagGROUP* gp) { + for (int i = 0; i < gp->cxKeyArray; i++) { + wprintf(L"key nr : has key:%i(%c) Line:%i Shiftflags:%i Output %c (%d)\n", gp->dpKeyArray->Key, gp->dpKeyArray->Key, + gp->dpKeyArray->Line, gp->dpKeyArray->ShiftFlags, gp->dpKeyArray->dpOutput, *gp->dpKeyArray->dpOutput); + // gp->cxKeyArray++; + } +} + +void Inspect_key(LPKMX_KEY key) { + //for (int i = 0; i < gp->cxKeyArray; i++) { + wprintf(L"key nr : has key:%i(%c) Line:%i Shiftflags:%i Output \n", key->Key, key->Key, + key->Line, key->ShiftFlags); + /*wprintf(L"key nr : has key:%i(%c) Line:%i Shiftflags:%i Output %c (%d)\n", key->Key, key->Key, + key->Line, key->ShiftFlags, key->dpOutput, *key->dpOutput);*/ + // gp->cxKeyArray++; + // } +} diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 2d347348a9..78c6e36ff7 100755 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -34,7 +34,7 @@ typedef struct KMX_tagGROUP { LPKMX_KEY dpKeyArray; // [LPKEY] address of first item in key array PKMX_WCHAR dpMatch; PKMX_WCHAR dpNoMatch; - KMX_DWORD cxKeyArray; // in array entries // _S2 was DWORD + KMX_DWORD cxKeyArray; // in array entries int32_t fUsingKeys; // group(xx) [using keys] <-- specified or not } KMX_GROUP, *LPKMX_GROUP; diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 39688d98fc..8befc90857 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -51,20 +51,21 @@ void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key); void KMX_ReportUnconvertedGroupRules(LPKMX_GROUP group); void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd); -int KMX_GetDeadkeys(WORD DeadKey, WORD *OutputPairs) ; +void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch); +void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group,KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch); +void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch); +int KMX_GetDeadkeys(WORD DeadKey, WORD *OutputPairs) ; int KMX_GetDeadkeys_NT(WORD DeadKey, WORD *OutputPairs); // returns array of [USVK, ch] pairs int KMX_GetDeadkeys_NT_x64(WORD DeadKey, WORD *OutputPairs); // returns array of [USVK, ch] pairs void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift); -void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch); -void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group,KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch); -void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch); - KMX_WORD KMX_VKUSToVKUnderlyingLayout_S2(KMX_WORD VKey); KMX_WORD KMX_VKUnderlyingLayoutToVKUS_S2(KMX_WORD VKey); +KMX_UINT KMX_VKUSToSCUnderlyingLayout(KMX_DWORD VirtualKeyUS); +KMX_WCHAR KMX_CharFromSC(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey); #if defined(_WIN32) || defined(_WIN64) int wmain(int argc, wchar_t* argv[]) { @@ -177,153 +178,155 @@ const UINT VKShiftState[] = {0, K_SHIFTFLAG, 0xFFFF}; // we have assigned these to columns 1-4 ( column o holds the keycode) //const UINT VKShiftState[] = {0, 1, 2, 3, 0xFFFF}; -KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { - LPKMX_STORE sp; - KMX_UINT i; - for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { - if(sp->dwSystemID == TSS_MNEMONIC) { - if(!sp->dpString) { - KMX_LogError(L"Invalid &mnemoniclayout system store"); - return FALSE; - } - if(u16cmp((const KMX_WCHAR*)sp->dpString, u"1") != 0) { - KMX_LogError(L"Keyboard is not a mnemonic layout keyboard"); - return FALSE; - } - *sp->dpString = '0'; - return TRUE; +// +// TranslateKey +// +// For each key rule on the keyboard, remap its key to the +// correct shift state and key. Adjust the LCTRL+RALT -> RALT if necessary +// +void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { + // _S2 ToDos here? + // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. + // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" + // to provide an alternate.. + if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) + shift &= ~LCTRLFLAG; + + if(key->ShiftFlags == 0 && key->Key == ch) { + // Key is a mnemonic key with no shift state defined. + // Remap the key according to the character on the key cap. + //LogError(L"Converted mnemonic rule on line %d, + '%c' TO + [%x K_%d]", key->Line, key->Key, shift, vk); + key->ShiftFlags = ISVIRTUALKEY | shift; + key->Key = vk; + //wprintf(L"ISVIRTUALKEY: %i , shift: %i, key->ShiftFlags for mnemonic= %i\n", ISVIRTUALKEY,shift, key->ShiftFlags); + //wprintf(L" 1 and changed, %i (%c) %i (%c) ", ch,ch, vk,vk); + } else if(key->ShiftFlags & VIRTUALCHARKEY && key->Key == ch) { + // Key is a virtual character key with a hard-coded shift state. + // Do not remap the shift state, just move the key. + // This will not result in 100% wonderful mappings as there could + // be overlap, depending on how keys are arranged on the target layout. + // But that is up to the designer. + //LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, key->ShiftFlags & ~VIRTUALCHARKEY, vk); + key->ShiftFlags &= ~VIRTUALCHARKEY; + //wprintf(L" i am processing vk%i (%c) char %i (%c) \n", vk,vk, ch,ch); + key->Key = vk; + //wprintf(L"key->ShiftFlags for VIRTUALCHARKEY= %i", key->ShiftFlags); + //wprintf(L" 2 and changed, vk: %i (%c) ---> %i (%c) ", vk,vk, ch,ch); + } +} + +void KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { + for(unsigned int i = 0; i < group->cxKeyArray; i++) { + KMX_TranslateKey(&group->dpKeyArray[i], vk, shift, ch); + } +} + +void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + KMX_TranslateGroup(&kbd->dpGroupArray[i], vk, shift, ch); } } - - KMX_LogError(L"Keyboard is not a mnemonic layout keyboard"); - return FALSE; } -// takes SC of US keyboard and returns SC of OTHER keyboard -UINT KMX_VKUSToSCUnderlyingLayout(KMX_DWORD VirtualKeyUS) { - UINT SC_US = 8 + USVirtualKeyToScanCode[VirtualKeyUS]; - UINT SC_OTHER = SC_US; // not neccessary but to understand what we do - return SC_OTHER; +void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key) { + if(key->ShiftFlags == 0) { + //KMX_LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); + wprintf(L" _S2 Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); + } else if(key->ShiftFlags & VIRTUALCHARKEY) { + //KMX_LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); + wprintf(L"_S2 Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); + } } +void KMX_ReportUnconvertedGroupRules(LPKMX_GROUP group) { + for(unsigned int i = 0; i < group->cxKeyArray; i++) { + KMX_ReportUnconvertedKeyRule(&group->dpKeyArray[i]); + } +} -struct KMX_dkidmap { - KMX_WCHAR src_deadkey, dst_deadkey; -}; - -// takes capital letter of US returns cpital character of Other keyboard -KMX_DWORD KMX_VKUSToVKUnderlyingLayout(v_dw_3D &All_Vector,KMX_DWORD inUS) { - // loop and find char in US; then return char of Other - for( int i=0; i< (int)All_Vector[0].size();i++) { - for( int j=1; j< (int)All_Vector[0][0].size();j++) { - if((inUS == All_Vector[0][i][j] )) { - return All_Vector[1][i][2]; - } +void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + KMX_ReportUnconvertedGroupRules(&kbd->dpGroupArray[i]); } } - return inUS; } -// takes capital letter of Other returns cpital character of US keyboard -KMX_WORD KMX_VKUnderlyingLayoutToVKUS(v_dw_3D &All_Vector,KMX_DWORD inOther) { - // loop and find char in Other; then return char of US - for( int i=0; i< (int)All_Vector[1].size();i++) { - for( int j=1; j< (int)All_Vector[1][0].size();j++) { - if((inOther == All_Vector[1][i][j] )) { - return All_Vector[0][i][2]; - } +void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { + if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { + + // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. + // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" + // to provide an alternate.. + if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4327 + shift &= ~LCTRLFLAG; + + if(key->ShiftFlags == 0) { + //LogError("Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d]", key->Line, key->Key, deadkey, shift, vk); + key->ShiftFlags = ISVIRTUALKEY | shift; + } else { + //LogError("Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO dk(%d) + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, deadkey, key->ShiftFlags & ~VIRTUALCHARKEY, vk); + key->ShiftFlags &= ~VIRTUALCHARKEY; + } + + int len = u16len(key->dpContext); + + //PWSTR + PKMX_WCHAR context = new KMX_WCHAR[len + 4]; + memcpy(context, key->dpContext, len * sizeof(KMX_WCHAR)); + context[len] = UC_SENTINEL; + context[len+1] = CODE_DEADKEY; + context[len+2] = deadkey; + context[len+3] = 0; + key->dpContext = context; + key->Key = vk; + } +} + +void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group,KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { + for(unsigned int i = 0; i < group->cxKeyArray; i++) { + KMX_TranslateDeadkeyKey(&group->dpKeyArray[i], deadkey, vk, shift, ch); + } +} + +void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + KMX_TranslateDeadkeyGroup(&kbd->dpGroupArray[i], deadkey, vk, shift, ch); } } - return inOther; } -KMX_WCHART KMX_VKUnderlyingLayoutToVKUS_GDK(GdkKeymap* keymap,KMX_DWORD VK_US) { +void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift) { + // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. + // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" + // to provide an alternate.. + if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4549 + shift &= ~LCTRLFLAG; - KMX_WORD VK_DE = ( KMX_WORD ) map_Ikey_DE(VK_US); - if(VK_DE!= VK_US) - return VK_DE; - else - return VK_US; -} - -// takes VK of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] -KMX_DWORD KMX_CharFromVK(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey){ - - KMX_UINT VKShiftState_lin; - - /* 0000 0000 */ - if (VKShiftState == 0 ) VKShiftState_lin = 0; - /* 0001 0000 */ - if (VKShiftState == 16) VKShiftState_lin = 1; - /* 0000 1001 */ - if (VKShiftState == 9 ) VKShiftState_lin = 2; - /* 0001 1001 */ - if (VKShiftState == 25) VKShiftState_lin = 3; - - // loop and find vkUnderlying in Other; then return char with correct shiftstate - for( int i=0; i< (int)All_Vector[1].size();i++) { - KMX_DWORD CharOther = All_Vector[1][i][2]; - if( vkUnderlying == CharOther ) { - return All_Vector[1][i][VKShiftState_lin+1]; // [VKShiftState_lin+1] because we have the name of the key in All_Vector[1][i][0], so we need to get the one after this - } + // If the first group is not a matching-keys group, then we need to add into + // each subgroup, otherwise just the match group + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + LPKMX_KEY keys = new KMX_KEY[kbd->dpGroupArray[i].cxKeyArray + 1]; + memcpy(keys+1, kbd->dpGroupArray[i].dpKeyArray, kbd->dpGroupArray[i].cxKeyArray * sizeof(KMX_KEY)); + keys[0].dpContext = new KMX_WCHAR[1]; + keys[0].dpContext[0] = 0; + keys[0].dpOutput = new KMX_WCHAR[4]; // UC_SENTINEL, CODE_DEADKEY, deadkey_value, 0 + keys[0].dpOutput[0] = UC_SENTINEL; + keys[0].dpOutput[1] = CODE_DEADKEY; + keys[0].dpOutput[2] = deadkey; // TODO: translate to unique index + keys[0].dpOutput[3] = 0; + keys[0].Key = vk; + keys[0].Line = 0; + keys[0].ShiftFlags = shift | ISVIRTUALKEY; + kbd->dpGroupArray[i].dpKeyArray = keys; + kbd->dpGroupArray[i].cxKeyArray++; + //LogError("Add deadkey rule: + [%d K_%d] > dk(%d)", shift, vk, deadkey); + if(i == kbd->StartGroup[1]) break; // If this is the initial group, that's all we need to do. + } } - return vkUnderlying; -} - -// takes SC of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] -KMX_WCHAR KMX_CharFromSC(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey) { - - int VKShiftState_lin = map_VKShiftState_to_Lin(VKShiftState); - KMX_DWORD KeyvalOther = getKeyvalsFromKeyCode(keymap,SC_OTHER, VKShiftState_lin); - - // _S2 how to detect deadkeys ? KeyvalOther >deadkeyThreshold KeyvalOther > 255? KeyvalOther > 65000 ? or what else? - //if (KeyvalOther > deadkeyThreshold) { - if (KeyvalOther > 255) { - std::string ws((const char*) gdk_keyval_name (KeyvalOther)); - *DeadKey = convertNamesToASCIIValue( wstring_from_string(ws)); - return 0xFFFF; - } - - return (KMX_WCHAR) KeyvalOther; -} - -bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]){ -// get keymap of keyboard layout in use - - gdk_init(&argc, &argv); - GdkDisplay *display = gdk_display_get_default(); - if (!display) { - wprintf(L"ERROR: can't get display\n"); - return 1; - } - - *keymap = gdk_keymap_get_for_display(display); - if (!keymap) { - wprintf(L"ERROR: Can't get keymap\n"); - gdk_display_close(display); - return 2; - } - - return 0; -} - -int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ - - std::string US_language = "us"; - const char* text_us = "xkb_symbols \"basic\""; - //const char* text_us = "xkb_symbols \"intl\""; - - if(write_US_ToVector(All_Vector,US_language, text_us)) { - wprintf(L"ERROR: can't write US to Vector \n"); - return 1; - } - - // add contents of other keyboard to All_Vector - if( append_other_ToVector(All_Vector,keymap)) { - wprintf(L"ERROR: can't append Other ToVector \n"); - return 2; - } - return 0; } // Note: max is not a standard c api function or macro @@ -331,7 +334,6 @@ int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ #define max(a,b) (((a) > (b)) ? (a) : (b)) #endif -//LPWSTR KMX_WCHAR KMX_ScanXStringForMaxDeadkeyID(PKMX_WCHAR str) { KMX_WCHAR dkid = 0; while(str && *str) { @@ -346,6 +348,9 @@ KMX_WCHAR KMX_ScanXStringForMaxDeadkeyID(PKMX_WCHAR str) { return dkid; } +struct KMX_dkidmap { + KMX_WCHAR src_deadkey, dst_deadkey; +}; KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { KMX_WCHAR noneS2; @@ -422,24 +427,26 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR d } } -KMX_WORD KMX_VKUSToVKUnderlyingLayout_S2(KMX_WORD VKey) { - /*if(IsWow64()) { - return VKUSToVKUnderlyingLayout_NT_x64(VKey); - } else { - return VKUSToVKUnderlyingLayout_NT(VKey); - }*/ - KMX_WORD retu ; - return retu; -} +KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { + LPKMX_STORE sp; + KMX_UINT i; + for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { + if(sp->dwSystemID == TSS_MNEMONIC) { + if(!sp->dpString) { + KMX_LogError(L"Invalid &mnemoniclayout system store"); + return FALSE; + } + if(u16cmp((const KMX_WCHAR*)sp->dpString, u"1") != 0) { + KMX_LogError(L"Keyboard is not a mnemonic layout keyboard"); + return FALSE; + } + *sp->dpString = '0'; + return TRUE; + } + } -KMX_WORD KMX_VKUnderlyingLayoutToVKUS_S2(KMX_WORD VKey) { - /* if(IsWow64()) { - return VKUnderlyingLayoutToVKUS_NT_x64(VKey); - } else { - return VKUnderlyingLayoutToVKUS_NT(VKey); - }*/ - KMX_WORD retu ; - return retu; + KMX_LogError(L"Keyboard is not a mnemonic layout keyboard"); + return FALSE; } KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]) { @@ -492,7 +499,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon ch = DeadKey; } } -//_S2 convert deadkey KMX_ + //wprintf(L" switch with ch: %i (%c)......\n" , ch,ch); switch(ch) { case 0x0000: break; @@ -521,113 +528,143 @@ void KMX_LogError(const KMX_WCHART* m1,int m2, LPKMX_KEY key) { } */ -// -// TranslateKey -// -// For each key rule on the keyboard, remap its key to the -// correct shift state and key. Adjust the LCTRL+RALT -> RALT if necessary -// -void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { - // _S2 ToDos here? - // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. - // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" - // to provide an alternate.. - if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) - shift &= ~LCTRLFLAG; - - if(key->ShiftFlags == 0 && key->Key == ch) { - // Key is a mnemonic key with no shift state defined. - // Remap the key according to the character on the key cap. - //LogError(L"Converted mnemonic rule on line %d, + '%c' TO + [%x K_%d]", key->Line, key->Key, shift, vk); - key->ShiftFlags = ISVIRTUALKEY | shift; - key->Key = vk; - //wprintf(L"ISVIRTUALKEY: %i , shift: %i, key->ShiftFlags for mnemonic= %i\n", ISVIRTUALKEY,shift, key->ShiftFlags); - //wprintf(L" 1 and changed, %i (%c) %i (%c) ", ch,ch, vk,vk); - } else if(key->ShiftFlags & VIRTUALCHARKEY && key->Key == ch) { - // Key is a virtual character key with a hard-coded shift state. - // Do not remap the shift state, just move the key. - // This will not result in 100% wonderful mappings as there could - // be overlap, depending on how keys are arranged on the target layout. - // But that is up to the designer. - //LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, key->ShiftFlags & ~VIRTUALCHARKEY, vk); - key->ShiftFlags &= ~VIRTUALCHARKEY; - //wprintf(L" i am processing vk%i (%c) char %i (%c) \n", vk,vk, ch,ch); - key->Key = vk; - //wprintf(L"key->ShiftFlags for VIRTUALCHARKEY= %i", key->ShiftFlags); - //wprintf(L" 2 and changed, vk: %i (%c) ---> %i (%c) ", vk,vk, ch,ch); - } +// takes SC of US keyboard and returns SC of OTHER keyboard +UINT KMX_VKUSToSCUnderlyingLayout(KMX_DWORD VirtualKeyUS) { + UINT SC_US = 8 + USVirtualKeyToScanCode[VirtualKeyUS]; + UINT SC_OTHER = SC_US; // not neccessary but to understand what we do + return SC_OTHER; } - -void KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { - for(unsigned int i = 0; i < group->cxKeyArray; i++) { - KMX_TranslateKey(&group->dpKeyArray[i], vk, shift, ch); - } -} - -void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { -// _S2 if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)){ - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { - KMX_TranslateGroup(&kbd->dpGroupArray[i], vk, shift, ch); +// takes capital letter of US returns cpital character of Other keyboard +KMX_DWORD KMX_VKUSToVKUnderlyingLayout(v_dw_3D &All_Vector,KMX_DWORD inUS) { + // loop and find char in US; then return char of Other + for( int i=0; i< (int)All_Vector[0].size();i++) { + for( int j=1; j< (int)All_Vector[0][0].size();j++) { + if((inUS == All_Vector[0][i][j] )) { + return All_Vector[1][i][2]; + } } } + return inUS; } - -void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key) { - if(key->ShiftFlags == 0) { - //KMX_LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); - wprintf(L" _S2 Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); - } else if(key->ShiftFlags & VIRTUALCHARKEY) { - //KMX_LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); - wprintf(L"_S2 Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); - } -} - -void KMX_ReportUnconvertedGroupRules(LPKMX_GROUP group) { - for(unsigned int i = 0; i < group->cxKeyArray; i++) { - KMX_ReportUnconvertedKeyRule(&group->dpKeyArray[i]); - } -} - -void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { - KMX_ReportUnconvertedGroupRules(&kbd->dpGroupArray[i]); +// takes capital letter of Other returns cpital character of US keyboard +KMX_WORD KMX_VKUnderlyingLayoutToVKUS(v_dw_3D &All_Vector,KMX_DWORD inOther) { + // loop and find char in Other; then return char of US + for( int i=0; i< (int)All_Vector[1].size();i++) { + for( int j=1; j< (int)All_Vector[1][0].size();j++) { + if((inOther == All_Vector[1][i][j] )) { + return All_Vector[0][i][2]; + } } } + return inOther; } +// _S2 sure KMX_WCHART ??? not KMX_WCHAR ?? +KMX_WCHART KMX_VKUnderlyingLayoutToVKUS_GDK(GdkKeymap* keymap,KMX_DWORD VK_US) { -void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift) { - // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. - // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" - // to provide an alternate.. - if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4549 - shift &= ~LCTRLFLAG; + KMX_WORD VK_DE = ( KMX_WORD ) map_Ikey_DE(VK_US); + if(VK_DE!= VK_US) + return VK_DE; + else + return VK_US; +} +// takes VK of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] +KMX_DWORD KMX_CharFromVK(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey){ - // If the first group is not a matching-keys group, then we need to add into - // each subgroup, otherwise just the match group - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { - LPKMX_KEY keys = new KMX_KEY[kbd->dpGroupArray[i].cxKeyArray + 1]; - memcpy(keys+1, kbd->dpGroupArray[i].dpKeyArray, kbd->dpGroupArray[i].cxKeyArray * sizeof(KMX_KEY)); - keys[0].dpContext = new KMX_WCHAR[1]; - keys[0].dpContext[0] = 0; - keys[0].dpOutput = new KMX_WCHAR[4]; // UC_SENTINEL, CODE_DEADKEY, deadkey_value, 0 - keys[0].dpOutput[0] = UC_SENTINEL; - keys[0].dpOutput[1] = CODE_DEADKEY; - keys[0].dpOutput[2] = deadkey; // TODO: translate to unique index - keys[0].dpOutput[3] = 0; - keys[0].Key = vk; - keys[0].Line = 0; - keys[0].ShiftFlags = shift | ISVIRTUALKEY; - kbd->dpGroupArray[i].dpKeyArray = keys; - kbd->dpGroupArray[i].cxKeyArray++; - //LogError("Add deadkey rule: + [%d K_%d] > dk(%d)", shift, vk, deadkey); - if(i == kbd->StartGroup[1]) break; // If this is the initial group, that's all we need to do. - } + KMX_UINT VKShiftState_lin; + + /* 0000 0000 */ + if (VKShiftState == 0 ) VKShiftState_lin = 0; + /* 0001 0000 */ + if (VKShiftState == 16) VKShiftState_lin = 1; + /* 0000 1001 */ + if (VKShiftState == 9 ) VKShiftState_lin = 2; + /* 0001 1001 */ + if (VKShiftState == 25) VKShiftState_lin = 3; + + // loop and find vkUnderlying in Other; then return char with correct shiftstate + for( int i=0; i< (int)All_Vector[1].size();i++) { + KMX_DWORD CharOther = All_Vector[1][i][2]; + if( vkUnderlying == CharOther ) { + return All_Vector[1][i][VKShiftState_lin+1]; // [VKShiftState_lin+1] because we have the name of the key in All_Vector[1][i][0], so we need to get the one after this + } } + return vkUnderlying; +} +// takes SC of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] +KMX_WCHAR KMX_CharFromSC(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey) { + + int VKShiftState_lin = map_VKShiftState_to_Lin(VKShiftState); + KMX_DWORD KeyvalOther = getKeyvalsFromKeyCode(keymap,SC_OTHER, VKShiftState_lin); + + // _S2 how to detect deadkeys ? KeyvalOther >deadkeyThreshold KeyvalOther > 255? KeyvalOther > 65000 ? or what else? + //if (KeyvalOther > deadkeyThreshold) { + if (KeyvalOther > 255) { + std::string ws((const char*) gdk_keyval_name (KeyvalOther)); + *DeadKey = convertNamesToASCIIValue( wstring_from_string(ws)); + return 0xFFFF; + } + + return (KMX_WCHAR) KeyvalOther; } +bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]){ +// get keymap of keyboard layout in use + + gdk_init(&argc, &argv); + GdkDisplay *display = gdk_display_get_default(); + if (!display) { + wprintf(L"ERROR: can't get display\n"); + return 1; + } + + *keymap = gdk_keymap_get_for_display(display); + if (!keymap) { + wprintf(L"ERROR: Can't get keymap\n"); + gdk_display_close(display); + return 2; + } + + return 0; +} + +int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ + + std::string US_language = "us"; + const char* text_us = "xkb_symbols \"basic\""; + //const char* text_us = "xkb_symbols \"intl\""; + + if(write_US_ToVector(All_Vector,US_language, text_us)) { + wprintf(L"ERROR: can't write US to Vector \n"); + return 1; + } + + // add contents of other keyboard to All_Vector + if( append_other_ToVector(All_Vector,keymap)) { + wprintf(L"ERROR: can't append Other ToVector \n"); + return 2; + } + return 0; +} + +KMX_WORD KMX_VKUSToVKUnderlyingLayout_S2(KMX_WORD VKey) { + /*if(IsWow64()) { + return VKUSToVKUnderlyingLayout_NT_x64(VKey); + } else { + return VKUSToVKUnderlyingLayout_NT(VKey); + }*/ + KMX_WORD retu ; + return retu; +} + +KMX_WORD KMX_VKUnderlyingLayoutToVKUS_S2(KMX_WORD VKey) { + /* if(IsWow64()) { + return VKUnderlyingLayoutToVKUS_NT_x64(VKey); + } else { + return VKUnderlyingLayoutToVKUS_NT(VKey); + }*/ + KMX_WORD retu ; + return retu; +} int KMX_GetDeadkeys(WORD DeadKey, WORD *OutputPairs) { /*if(IsWow64()) { @@ -674,50 +711,7 @@ int KMX_GetDeadkeys_NT(WORD DeadKey, WORD *OutputPairs) { return 999; } -void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { - if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { - // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. - // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" - // to provide an alternate.. - if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4327 - shift &= ~LCTRLFLAG; - - if(key->ShiftFlags == 0) { - //LogError("Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d]", key->Line, key->Key, deadkey, shift, vk); - key->ShiftFlags = ISVIRTUALKEY | shift; - } else { - //LogError("Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO dk(%d) + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, deadkey, key->ShiftFlags & ~VIRTUALCHARKEY, vk); - key->ShiftFlags &= ~VIRTUALCHARKEY; - } - - int len = u16len(key->dpContext); - - //PWSTR - PKMX_WCHAR context = new KMX_WCHAR[len + 4]; - memcpy(context, key->dpContext, len * sizeof(KMX_WCHAR)); - context[len] = UC_SENTINEL; - context[len+1] = CODE_DEADKEY; - context[len+2] = deadkey; - context[len+3] = 0; - key->dpContext = context; - key->Key = vk; - } -} - -void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group,KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { - for(unsigned int i = 0; i < group->cxKeyArray; i++) { - KMX_TranslateDeadkeyKey(&group->dpKeyArray[i], deadkey, vk, shift, ch); - } -} - -void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { - KMX_TranslateDeadkeyGroup(&kbd->dpGroupArray[i], deadkey, vk, shift, ch); - } - } -} // ---- old copy code from here ---------------------------------------------------------- /* diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index f5fd9f287d..a1595a0fd4 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -27,10 +27,7 @@ #include "mc_kmxfile.h" -int run(int argc, std::vector str_argv, char* argv[]); - void KMX_LogError(const KMX_WCHART* m1, int m2 = 0); - //void KMX_LogError(const KMX_WCHART* m1, int m2 = 0, LPKMX_KEY key =NULL); struct KMX_DeadkeyMapping { // I4353 @@ -41,9 +38,12 @@ struct KMX_DeadkeyMapping { // I4353 extern std::vector KMX_FDeadkeys; // I4353 +int run(int argc, std::vector str_argv, char* argv[]); + // _S2 is this correct here??? KMX_WORD KMX_VKUnderlyingLayoutToVKUS(KMX_WORD VKey); KMX_WORD KMX_VKUnderlyingLayoutToVKUS(v_dw_3D &All_Vector,KMX_DWORD inOther); +// _S2 sure KMX_WCHART ??? not KMX_WCHAR ?? KMX_WCHART KMX_VKUnderlyingLayoutToVKUS_GDK(GdkKeymap* keymap,KMX_DWORD inOther); PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); From 4b84604eb4af062a33ddb220a8d7d6d77e0f0b45 Mon Sep 17 00:00:00 2001 From: Sabine Date: Sat, 2 Dec 2023 17:20:23 +0100 Subject: [PATCH 144/327] feat(linux): mcompile new file deadkey.h/.cpp and function createDK_ComposeTable --- linux/mcompile/keymap/deadkey.cpp | 5410 ++++++++++++++++++++++++++++ linux/mcompile/keymap/deadkey.h | 15 + linux/mcompile/keymap/keymap.cpp | 11 +- linux/mcompile/keymap/keymap.h | 3 +- linux/mcompile/keymap/mcompile.cpp | 24 +- linux/mcompile/keymap/mcompile.h | 2 + linux/mcompile/keymap/meson.build | 1 + 7 files changed, 5451 insertions(+), 15 deletions(-) create mode 100755 linux/mcompile/keymap/deadkey.cpp create mode 100755 linux/mcompile/keymap/deadkey.h diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp new file mode 100755 index 0000000000..720083b57c --- /dev/null +++ b/linux/mcompile/keymap/deadkey.cpp @@ -0,0 +1,5410 @@ +#include "keymap.h" +#include "deadkey.h" + +#include + +int createDK_ComposeTable(v_dw_2D & dk_ComposeTable){ + + // values taken from: https://help.ubuntu.com/community/GtkComposeTable + //dk_ComposeTable[i][0] : First + //dk_ComposeTable[i][1] : Second + //dk_ComposeTable[i][2] : Third + //dk_ComposeTable[i][3] : Character + //dk_ComposeTable[i][4] : Unicode-Value + + v_dw_1D line; + + // Diacritics and punctuation + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"acute accent")); + line.push_back(0x00B4); + dk_ComposeTable.push_back(line); + line.clear(); + + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"space")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Apostrophe")); + line.push_back(0x27); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"space")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Apostrophe")); + line.push_back(0x27); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"parenleft")); + line.push_back(convertNamesToIntegerValue(L"space")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Breve")); + line.push_back(0x02D8); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"space")); + line.push_back(convertNamesToIntegerValue(L"parenleft")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Breve")); + line.push_back(0x02D8); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"space")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Caron")); + line.push_back(0x02C7); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"space")); + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Caron")); + line.push_back(0x02C7); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Cedilla")); + line.push_back(0x00B8); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"space")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Circumflex accent")); + line.push_back(0x005E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"space")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Circumflex accent")); + line.push_back(0x005E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"space")); + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Circumflex accent")); + line.push_back(0x005E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"space")); + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Circumflex accent")); + line.push_back(0x005E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Diaeresis")); + line.push_back(0x00A8); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"grave")); + line.push_back(convertNamesToIntegerValue(L"space")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Grave accent")); + line.push_back(0x60); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"space")); + line.push_back(convertNamesToIntegerValue(L"grave")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Grave accent")); + line.push_back(0x60); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"em dash —")); + line.push_back(0x2014); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"en dash –")); + line.push_back(0x2013); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"exclam")); + line.push_back(convertNamesToIntegerValue(L"exclam")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"inverted exclamation mark")); + line.push_back(0x00A1); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"question")); + line.push_back(convertNamesToIntegerValue(L"question")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"inverted question mark")); + line.push_back(0x00BF); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"exclam")); + line.push_back(convertNamesToIntegerValue(L"question")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"interrobang")); + line.push_back(0x203D); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"parenleft")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"left Curly Bracket")); + line.push_back(0x007B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"parenleft")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"left Curly Bracket")); + line.push_back(0x007B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"left single Quotation Mark")); + line.push_back(0x2018); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"left single Quotation Mark")); + line.push_back(0x2018); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"parenleft")); + line.push_back(convertNamesToIntegerValue(L"parenleft")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"left Square Bracket")); + line.push_back(0x005B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"left pointing Double Angle Quotation Mark")); + line.push_back(0x00AB); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Macron")); + line.push_back(0x00AF); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Macron")); + line.push_back(0x00AF); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Macron")); + line.push_back(0x00AF); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Macron")); + line.push_back(0x00AF); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Macron")); + line.push_back(0x00AF); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"space")); + line.push_back(convertNamesToIntegerValue(L"space")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Non-breaking Space")); + line.push_back(0x00A0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"parenright")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"right Curly Bracket")); + line.push_back(0x007D); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"parenright")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"right Curly Bracket")); + line.push_back(0x007D); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"right single Quotation Mark")); + line.push_back(0x2019); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"right single Quotation Mark")); + line.push_back(0x2019); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"parenright")); + line.push_back(convertNamesToIntegerValue(L"parenright")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"right Square Bracket")); + line.push_back(0x005D); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"right pointing Double Angle Quotation Mark")); + line.push_back(0x00BB); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"space")); + line.push_back(convertNamesToIntegerValue(L"SoftHyphen (word break)")); + line.push_back(0x00AD); + dk_ComposeTable.push_back(line); + line.clear(); + + // Currency + line.push_back(convertNamesToIntegerValue(L"bar")); + line.push_back(convertNamesToIntegerValue(L"C")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Cent sign")); + line.push_back(0x00A2); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"bar")); + line.push_back(convertNamesToIntegerValue(L"c")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Cent sign")); + line.push_back(0x00A2); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"C")); + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Cent sign")); + line.push_back(0x00A2); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"c")); + line.push_back(convertNamesToIntegerValue(L"bar")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Cent sign")); + line.push_back(0x00A2); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"c")); + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Cent sign")); + line.push_back(0x00A2); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"C")); + line.push_back(convertNamesToIntegerValue(L"bar")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Cent sign")); + line.push_back(0x00A2); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"C")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Cent sign")); + line.push_back(0x00A2); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"c")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Cent sign")); + line.push_back(0x00A2); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"C")); + line.push_back(convertNamesToIntegerValue(L"equal")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Euro sign")); + line.push_back(0x20AC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"c")); + line.push_back(convertNamesToIntegerValue(L"equal")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Euro sign")); + line.push_back(0x20AC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"equal")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Euro sign")); + line.push_back(0x20AC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"equal")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Euro sign")); + line.push_back(0x20AC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"equal")); + line.push_back(convertNamesToIntegerValue(L"C")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Euro sign")); + line.push_back(0x20AC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"equal")); + line.push_back(convertNamesToIntegerValue(L"c")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Euro sign")); + line.push_back(0x20AC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"equal")); + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Euro sign")); + line.push_back(0x20AC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"equal")); + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Euro sign")); + line.push_back(0x20AC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"equal")); + line.push_back(convertNamesToIntegerValue(L"L")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Lira sign")); + line.push_back(0x00A3); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"L")); + line.push_back(convertNamesToIntegerValue(L"equal")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Lira sign")); + line.push_back(0x00A3); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"l")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Pound sign")); + line.push_back(0x00A3); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"L")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Pound sign")); + line.push_back(0x00A3); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"L")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Pound sign")); + line.push_back(0x00A3); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"l")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Pound sign")); + line.push_back(0x00A3); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"R")); + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Rupee sign")); + line.push_back(0x20a8); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"equal")); + line.push_back(convertNamesToIntegerValue(L"Y")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Yen sign")); + line.push_back(0x00A5); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"equal")); + line.push_back(convertNamesToIntegerValue(L"y")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Yen sign")); + line.push_back(0x00A5); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"Y")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Yen sign")); + line.push_back(0x00A5); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"y")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Yen sign")); + line.push_back(0x00A5); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Y")); + line.push_back(convertNamesToIntegerValue(L"equal")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Yen sign")); + line.push_back(0x00A5); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Y")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Yen sign")); + line.push_back(0x00A5); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"y")); + line.push_back(convertNamesToIntegerValue(L"equal")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Yen sign")); + line.push_back(0x00A5); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"y")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Yen sign")); + line.push_back(0x00A5); + dk_ComposeTable.push_back(line); + line.clear(); + + + // Vulgar Fractions + line.push_back(convertNamesToIntegerValue(L"1")); + line.push_back(convertNamesToIntegerValue(L"2")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"One-half")); + line.push_back(0x00BD); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"1")); + line.push_back(convertNamesToIntegerValue(L"3")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"One-third")); + line.push_back(0x2153); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"2")); + line.push_back(convertNamesToIntegerValue(L"3")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Two-thirds")); + line.push_back(0x2154); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"1")); + line.push_back(convertNamesToIntegerValue(L"4")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"One-quarter")); + line.push_back(0x00BC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"3")); + line.push_back(convertNamesToIntegerValue(L"4")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Three-quarters")); + line.push_back(0x00BE); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"1")); + line.push_back(convertNamesToIntegerValue(L"5")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"One-fifth")); + line.push_back(0x2155); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"2")); + line.push_back(convertNamesToIntegerValue(L"5")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Two-fifths")); + line.push_back(0x2156); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"3")); + line.push_back(convertNamesToIntegerValue(L"5")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Three-fifths")); + line.push_back(0x2157); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"4")); + line.push_back(convertNamesToIntegerValue(L"5")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Four-fifths")); + line.push_back(0x2158); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"1")); + line.push_back(convertNamesToIntegerValue(L"6")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"One-sixth")); + line.push_back(0x2159); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"1")); + line.push_back(convertNamesToIntegerValue(L"8")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"One-eighth")); + line.push_back(0x215B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"3")); + line.push_back(convertNamesToIntegerValue(L"8")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Three-eighths")); + line.push_back(0x215C); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"5")); + line.push_back(convertNamesToIntegerValue(L"8")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Five-eighths")); + line.push_back(0x215D); + dk_ComposeTable.push_back(line); + line.clear(); + + // Mathematical Symbols and Signs + line.push_back(convertNamesToIntegerValue(L"7")); + line.push_back(convertNamesToIntegerValue(L"8")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Seven-eighths")); + line.push_back(0x215E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"backslash")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Backslash bar")); + line.push_back(0x233f); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"backslash")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Backslash bar")); + line.push_back(0x233f); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"0")); + line.push_back(convertNamesToIntegerValue(L"C")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Copyright sign")); + line.push_back(0x00A9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"0")); + line.push_back(convertNamesToIntegerValue(L"c")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Copyright sign")); + line.push_back(0x00A9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"C")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Copyright sign")); + line.push_back(0x00A9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"c")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Copyright sign")); + line.push_back(0x00A9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"C")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Copyright sign")); + line.push_back(0x00A9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"c")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Copyright sign")); + line.push_back(0x00A9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"C")); + line.push_back(convertNamesToIntegerValue(L"0")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Copyright sign")); + line.push_back(0x00A9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"C")); + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Copyright sign")); + line.push_back(0x00A9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"C")); + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Copyright sign")); + line.push_back(0x00A9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"c")); + line.push_back(convertNamesToIntegerValue(L"0")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Copyright sign")); + line.push_back(0x00A9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"c")); + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Copyright sign")); + line.push_back(0x00A9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"c")); + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Copyright sign")); + line.push_back(0x00A9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"parenleft")); + line.push_back(convertNamesToIntegerValue(L"c")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Copyright sign")); + line.push_back(0x00A9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Degree sign")); + line.push_back(0x00B0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"0")); + line.push_back(convertNamesToIntegerValue(L"asterisk")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Degree sign")); + line.push_back(0x00B0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asterisk")); + line.push_back(convertNamesToIntegerValue(L"0")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Degree sign")); + line.push_back(0x00B0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Diamond operator")); + line.push_back(0x22c4); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Diamond operator")); + line.push_back(0x22c4); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"colon")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Division sign")); + line.push_back(0x00F7); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"colon")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Division sign")); + line.push_back(0x00F7); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"feminine ordinal indicator")); + line.push_back(0x00AA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"feminine ordinal indicator")); + line.push_back(0x00AA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"feminine ordinal indicator")); + line.push_back(0x00AA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"feminine ordinal indicator")); + line.push_back(0x00AA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"equal")); + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Identical to")); + line.push_back(0x2261); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"8")); + line.push_back(convertNamesToIntegerValue(L"8")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Infinity")); + line.push_back(0x221e); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"equal")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Less-than or equal to")); + line.push_back(0x2264); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"equal")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Greater-than or equal to")); + line.push_back(0x2265); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"masculine ordinal indicator")); + line.push_back(0x00BA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"masculine ordinal indicator")); + line.push_back(0x00BA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"masculine ordinal indicator")); + line.push_back(0x00BA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"masculine ordinal indicator")); + line.push_back(0x00BA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Micro sign")); + line.push_back(0x00B5); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Micro sign")); + line.push_back(0x00B5); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Micro sign")); + line.push_back(0x00B5); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Micro sign")); + line.push_back(0x00B5); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Middle·Dot")); + line.push_back(0x00B7); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Middle·Dot")); + line.push_back(0x00B7); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"x")); + line.push_back(convertNamesToIntegerValue(L"x")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Multiplication sign")); + line.push_back(0x00D7); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"equal")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Not equal to")); + line.push_back(0x2260); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"equal")); + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Not equal to")); + line.push_back(0x2260); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"equal")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Not equal to")); + line.push_back(0x2260); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Not sign")); + line.push_back(0x00AC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Not sign")); + line.push_back(0x00AC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"plus")); + line.push_back(convertNamesToIntegerValue(L"plus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Number sign (Octothorpe)")); + line.push_back(0x23); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"exclam")); + line.push_back(convertNamesToIntegerValue(L"P")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Pilcrow sign")); + line.push_back(0x00B6); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"exclam")); + line.push_back(convertNamesToIntegerValue(L"p")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Pilcrow sign")); + line.push_back(0x00B6); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"p")); + line.push_back(convertNamesToIntegerValue(L"exclam")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Pilcrow sign")); + line.push_back(0x00B6); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"P")); + line.push_back(convertNamesToIntegerValue(L"exclam")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Pilcrow sign")); + line.push_back(0x00B6); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"plus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"plusminus sign")); + line.push_back(0x00B1); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"plus")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"plusminus sign")); + line.push_back(0x00B1); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"R")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Registered sign")); + line.push_back(0x00AE); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"r")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Registered sign")); + line.push_back(0x00AE); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"R")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Registered sign")); + line.push_back(0x00AE); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"r")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Registered sign")); + line.push_back(0x00AE); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"parenleft")); + line.push_back(convertNamesToIntegerValue(L"r")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Registered sign")); + line.push_back(0x00AE); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Slash bar")); + line.push_back(0x233f); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Slash bar")); + line.push_back(0x233f); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"T")); + line.push_back(convertNamesToIntegerValue(L"M")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Trademark sign")); + line.push_back(0x2122); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"T")); + line.push_back(convertNamesToIntegerValue(L"m")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Trademark sign")); + line.push_back(0x2122); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"t")); + line.push_back(convertNamesToIntegerValue(L"M")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Trademark sign")); + line.push_back(0x2122); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"t")); + line.push_back(convertNamesToIntegerValue(L"m")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Trademark sign")); + line.push_back(0x2122); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"reverse Solidus")); + line.push_back(0x005C); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"reverse Solidus")); + line.push_back(0x005C); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"reverse Solidus")); + line.push_back(0x005C); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"0")); + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Section sign")); + line.push_back(0x00A7); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"0")); + line.push_back(convertNamesToIntegerValue(L"S")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Section sign")); + line.push_back(0x00A7); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"exclam")); + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Section sign")); + line.push_back(0x00A7); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"exclam")); + line.push_back(convertNamesToIntegerValue(L"S")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Section sign")); + line.push_back(0x00A7); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Section sign")); + line.push_back(0x00A7); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"S")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Section sign")); + line.push_back(0x00A7); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"S")); + line.push_back(convertNamesToIntegerValue(L"0")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Section sign")); + line.push_back(0x00A7); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"S")); + line.push_back(convertNamesToIntegerValue(L"exclam")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Section sign")); + line.push_back(0x00A7); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"0")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Section sign")); + line.push_back(0x00A7); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Section sign")); + line.push_back(0x00A7); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"S")); + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Section sign")); + line.push_back(0x00A7); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"exclam")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Section sign")); + line.push_back(0x00A7); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"v")); + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Square root")); + line.push_back(0x221a); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"v")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Square root")); + line.push_back(0x221a); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"bracketleft")); + line.push_back(convertNamesToIntegerValue(L"bracketright")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"squish quad")); + line.push_back(0x2337); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"0")); + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Superscript Zero")); + line.push_back(0x2070); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"0")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Superscript Zero")); + line.push_back(0x2070); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"1")); + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Superscript One")); + line.push_back(0x00B9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"1")); + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Superscript One")); + line.push_back(0x00B9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"1")); + line.push_back(convertNamesToIntegerValue(L"S")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Superscript One")); + line.push_back(0x00B9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"1")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Superscript One")); + line.push_back(0x00B9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"1")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Superscript One")); + line.push_back(0x00B9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"S")); + line.push_back(convertNamesToIntegerValue(L"1")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Superscript One")); + line.push_back(0x00B9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"2")); + line.push_back(convertNamesToIntegerValue(L"S")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Superscript Two")); + line.push_back(0x00B2); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"2")); + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Superscript Two")); + line.push_back(0x00B2); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"2")); + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Superscript Two")); + line.push_back(0x00B2); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"2")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Superscript Two")); + line.push_back(0x00B2); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"2")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Superscript Two")); + line.push_back(0x00B2); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"S")); + line.push_back(convertNamesToIntegerValue(L"2")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Superscript Two")); + line.push_back(0x00B2); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"3")); + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Superscript Three")); + line.push_back(0x00B3); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"3")); + line.push_back(convertNamesToIntegerValue(L"S")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Superscript Three")); + line.push_back(0x00B3); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"3")); + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Superscript Three")); + line.push_back(0x00B3); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"3")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Superscript Three")); + line.push_back(0x00B3); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"S")); + line.push_back(convertNamesToIntegerValue(L"3")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Superscript Three")); + line.push_back(0x00B3); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"3")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Superscript Three")); + line.push_back(0x00B3); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciiTilde (~)")); + line.push_back(convertNamesToIntegerValue(L"space")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Tilde")); + line.push_back(0x007E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"space")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Tilde")); + line.push_back(0x007E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"space")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Tilde")); + line.push_back(0x007E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"space")); + line.push_back(convertNamesToIntegerValue(L"asciiTilde")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"Tilde")); + line.push_back(0x007E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"vertical line")); + line.push_back(0x007C); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"l")); + line.push_back(convertNamesToIntegerValue(L"v")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"vertical line")); + line.push_back(0x007C); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"L")); + line.push_back(convertNamesToIntegerValue(L"V")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"vertical line")); + line.push_back(0x007C); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"vertical line")); + line.push_back(0x007C); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"v")); + line.push_back(convertNamesToIntegerValue(L"l")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"vertical line")); + line.push_back(0x007C); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"V")); + line.push_back(convertNamesToIntegerValue(L"L")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"vertical line")); + line.push_back(0x007C); + dk_ComposeTable.push_back(line); + line.clear(); + + // Latin majuscules + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"acute")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with acute")); + line.push_back(0x00C1); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with acute")); + line.push_back(0x00C1); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"acute")); + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with acute")); + line.push_back(0x00C1); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with acute")); + line.push_back(0x00C1); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"parenleft")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with breve")); + line.push_back(0x102); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"parenleft")); + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with breve")); + line.push_back(0x102); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with circumflex")); + line.push_back(0x00C2); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with circumflex")); + line.push_back(0x00C2); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with circumflex")); + line.push_back(0x00C2); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with circumflex")); + line.push_back(0x00C2); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with diaeresis")); + line.push_back(0x00C4); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"diaeresis")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with diaeresis")); + line.push_back(0x00C4); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"diaeresis")); + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with diaeresis")); + line.push_back(0x00C4); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with diaeresis")); + line.push_back(0x00C4); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"grave")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with grave")); + line.push_back(0x00C0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"grave")); + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with grave")); + line.push_back(0x00C0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with ogonek")); + line.push_back(0x104); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with ogonek")); + line.push_back(0x104); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with ring above")); + line.push_back(0x00C5); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"asterisk")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with ring above")); + line.push_back(0x00C5); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asterisk")); + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with ring above")); + line.push_back(0x00C5); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"asciiTilde")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with tilde")); + line.push_back(0x00C3); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with tilde")); + line.push_back(0x00C3); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciiTilde")); + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with tilde")); + line.push_back(0x00C3); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital A with tilde")); + line.push_back(0x00C3); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"A")); + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital AE ligature")); + line.push_back(0x00C6); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"B")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital B with dot above")); + line.push_back(0x100); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"B")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital B with dot above")); + line.push_back(0x100); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"C")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital C with acute")); + line.push_back(0x106); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"C")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital C with acute")); + line.push_back(0x106); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"C")); + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital C with caron")); + line.push_back(0x010C); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"C")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital C with caron")); + line.push_back(0x010C); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"C")); + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital C with cedilla")); + line.push_back(0x00C7); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"C")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital C with cedilla")); + line.push_back(0x00C7); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"C")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital C with dot above")); + line.push_back(0x010A); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"C")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital C with dot above")); + line.push_back(0x010A); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"D")); + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital D with caron")); + line.push_back(0x010E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"D")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital D with caron")); + line.push_back(0x010E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"D")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital D with dot above")); + line.push_back(0x1E0A); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"D")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital D with dot above")); + line.push_back(0x1E0A); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"D")); + line.push_back(convertNamesToIntegerValue(L"H")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Eth")); + line.push_back(0x00D0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"D")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital D with stroke")); + line.push_back(0x110); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"D")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital D with stroke")); + line.push_back(0x110); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"acute")); + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital E with acute")); + line.push_back(0x00C9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital E with acute")); + line.push_back(0x00C9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"acute")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital E with acute")); + line.push_back(0x00C9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital E with acute")); + line.push_back(0x00C9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital E with caron")); + line.push_back(0x011A); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital E with caron")); + line.push_back(0x011A); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital E with circumflex")); + line.push_back(0x00CA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital E with circumflex")); + line.push_back(0x00CA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital E with circumflex")); + line.push_back(0x00CA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital E with circumflex")); + line.push_back(0x00CA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"diaeresis")); + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital E with diaeresis")); + line.push_back(0x00CB); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital E with diaeresis")); + line.push_back(0x00CB); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"diaeresis")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital E with diaeresis")); + line.push_back(0x00CB); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital E with diaeresis")); + line.push_back(0x00CB); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital E with dot above")); + line.push_back(0x116); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital E with dot above")); + line.push_back(0x116); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"grave")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital E with grave")); + line.push_back(0x00C8); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"grave")); + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital E with grave")); + line.push_back(0x00C8); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital E with macron")); + line.push_back(0x112); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital E with macron")); + line.push_back(0x112); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital E with macron")); + line.push_back(0x112); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital E with macron")); + line.push_back(0x112); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital E with ogonek")); + line.push_back(0x118); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital E with ogonek")); + line.push_back(0x118); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"N")); + line.push_back(convertNamesToIntegerValue(L"G")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital ENG")); + line.push_back(0x014A); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"F")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital F with dot above")); + line.push_back(0x1E1E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"F")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital F with dot above")); + line.push_back(0x1E1E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"breve")); + line.push_back(convertNamesToIntegerValue(L"G")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital G with breve")); + line.push_back(0x011E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"G")); + line.push_back(convertNamesToIntegerValue(L"breve")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital G with breve")); + line.push_back(0x011E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"G")); + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital G with breve")); + line.push_back(0x011E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"G")); + line.push_back(convertNamesToIntegerValue(L"parenleft")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital G with breve")); + line.push_back(0x011E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"parenleft")); + line.push_back(convertNamesToIntegerValue(L"G")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital G with breve")); + line.push_back(0x011E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"G")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital G with cedilla")); + line.push_back(0x122); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"G")); + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital G with cedilla")); + line.push_back(0x122); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"G")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital G with dot above")); + line.push_back(0x120); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"G")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital G with dot above")); + line.push_back(0x120); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"acute")); + line.push_back(convertNamesToIntegerValue(L"I")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital I with acute")); + line.push_back(0x00CD); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"I")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital I with acute")); + line.push_back(0x00CD); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"I")); + line.push_back(convertNamesToIntegerValue(L"acute")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital I with acute")); + line.push_back(0x00CD); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"I")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital I with acute")); + line.push_back(0x00CD); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"I")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital I with circumflex")); + line.push_back(0x00CE); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"I")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital I with circumflex")); + line.push_back(0x00CE); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"I")); + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital I with circumflex")); + line.push_back(0x00CE); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"I")); + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital I with circumflex")); + line.push_back(0x00CE); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"diaeresis")); + line.push_back(convertNamesToIntegerValue(L"I")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital I with diaeresis")); + line.push_back(0x00CF); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"I")); + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital I with diaeresis")); + line.push_back(0x00CF); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"I")); + line.push_back(convertNamesToIntegerValue(L"diaeresis")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital I with diaeresis")); + line.push_back(0x00CF); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"I")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital I with diaeresis")); + line.push_back(0x00CF); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"I")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital I with dot above")); + line.push_back(0x130); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"I")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital I with dot above")); + line.push_back(0x130); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"grave")); + line.push_back(convertNamesToIntegerValue(L"I")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital I with grave")); + line.push_back(0x00CC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"I")); + line.push_back(convertNamesToIntegerValue(L"grave")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital I with grave")); + line.push_back(0x00CC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"I")); + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital I with macron")); + line.push_back(0x012A); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"I")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital I with macron")); + line.push_back(0x012A); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"I")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital I with macron")); + line.push_back(0x012A); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"I")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital I with macron")); + line.push_back(0x012A); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"I")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital I with ogonek")); + line.push_back(0x012E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"I")); + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital I with ogonek")); + line.push_back(0x012E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciiTilde")); + line.push_back(convertNamesToIntegerValue(L"I")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital I with tilde")); + line.push_back(0x128); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"I")); + line.push_back(convertNamesToIntegerValue(L"asciiTilde")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital I with tilde")); + line.push_back(0x128); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"K")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital K with cedilla")); + line.push_back(0x136); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"K")); + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital K with cedilla")); + line.push_back(0x136); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"L")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital L with acute")); + line.push_back(0x139); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"L")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital L with acute")); + line.push_back(0x139); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"L")); + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital L with caron")); + line.push_back(0x013D); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"L")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital L with caron")); + line.push_back(0x013D); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"L")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital L with cedilla")); + line.push_back(0x013B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"L")); + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital L with cedilla")); + line.push_back(0x013B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"L")); + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital L with stroke")); + line.push_back(0x141); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"L")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital L with stroke")); + line.push_back(0x141); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"M")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital M with dot above")); + line.push_back(0x1E40); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"M")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital M with dot above")); + line.push_back(0x1E40); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"N")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital N with acute")); + line.push_back(0x143); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"N")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital N with acute")); + line.push_back(0x143); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"N")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital N with caron")); + line.push_back(0x147); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"N")); + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital N with caron")); + line.push_back(0x147); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"N")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital N with cedilla")); + line.push_back(0x145); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"N")); + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital N with cedilla")); + line.push_back(0x145); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciiTilde")); + line.push_back(convertNamesToIntegerValue(L"N")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital N with tilde")); + line.push_back(0x00D1); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"N")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital N with tilde")); + line.push_back(0x00D1); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"N")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital N with tilde")); + line.push_back(0x00D1); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"N")); + line.push_back(convertNamesToIntegerValue(L"asciiTilde")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital N with tilde")); + line.push_back(0x00D1); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"E")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital ligature OE")); + line.push_back(0x152); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"acute")); + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital O with acute")); + line.push_back(0x00D3); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital O with acute")); + line.push_back(0x00D3); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"acute")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital O with acute")); + line.push_back(0x00D3); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital O with acute")); + line.push_back(0x00D3); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital O with circumflex")); + line.push_back(0x00D4); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital O with circumflex")); + line.push_back(0x00D4); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital O with circumflex")); + line.push_back(0x00D4); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital O with circumflex")); + line.push_back(0x00D4); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"diaeresis")); + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital O with diaeresis")); + line.push_back(0x00D6); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"diaeresis")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital O with diaeresis")); + line.push_back(0x00D6); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital O with diaeresis")); + line.push_back(0x00D6); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital O with diaeresis")); + line.push_back(0x00D6); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"grave")); + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital O with grave")); + line.push_back(0x00D2); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"grave")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital O with grave")); + line.push_back(0x00D2); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital O with stroke")); + line.push_back(0x00D8); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital O with stroke")); + line.push_back(0x00D8); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciiTilde")); + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital O with tilde")); + line.push_back(0x00D5); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital O with tilde")); + line.push_back(0x00D5); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital O with tilde")); + line.push_back(0x00D5); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"O")); + line.push_back(convertNamesToIntegerValue(L"asciiTilde")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital O with tilde")); + line.push_back(0x00D5); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"P")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital P with dot above")); + line.push_back(0x1E56); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"P")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital P with dot above")); + line.push_back(0x1E56); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"R")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital R with acute")); + line.push_back(0x154); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"R")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital R with acute")); + line.push_back(0x154); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"R")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital R with caron")); + line.push_back(0x158); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"R")); + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital R with caron")); + line.push_back(0x158); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"R")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital R with cedilla")); + line.push_back(0x156); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"R")); + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital R with cedilla")); + line.push_back(0x156); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"S")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital S with acute")); + line.push_back(0x015A); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"S")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital S with acute")); + line.push_back(0x015A); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"S")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital S with caron")); + line.push_back(0x160); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"S")); + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital S with caron")); + line.push_back(0x160); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"cedilla")); + line.push_back(convertNamesToIntegerValue(L"S")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital S with cedilla")); + line.push_back(0x015E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"S")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital S with cedilla")); + line.push_back(0x015E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"S")); + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital S with cedilla")); + line.push_back(0x015E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"S")); + line.push_back(convertNamesToIntegerValue(L"cedilla")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital S with cedilla")); + line.push_back(0x015E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"S")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital S with dot above")); + line.push_back(0x1E60); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"S")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital S with dot above")); + line.push_back(0x1E60); + dk_ComposeTable.push_back(line); + line.clear(); + + + + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"T")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital T with caron")); + line.push_back(0x164); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"T")); + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital T with caron")); + line.push_back(0x164); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"T")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital T with dot above")); + line.push_back(0x1E6A); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"T")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital T with dot above")); + line.push_back(0x1E6A); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"T")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital T with stroke")); + line.push_back(0x166); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"T")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital T with stroke")); + line.push_back(0x166); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"T")); + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital T with stroke")); + line.push_back(0x166); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"T")); + line.push_back(convertNamesToIntegerValue(L"H")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital THORN")); + line.push_back(0x00DE); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"acute")); + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital U with acute")); + line.push_back(0x00DA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital U with acute")); + line.push_back(0x00DA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"acute")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital U with acute")); + line.push_back(0x00DA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital U with acute")); + line.push_back(0x00DA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital U with circumflex")); + line.push_back(0x00DB); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital U with circumflex")); + line.push_back(0x00DB); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital U with circumflex")); + line.push_back(0x00DB); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital U with circumflex")); + line.push_back(0x00DB); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"diaeresis")); + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital U with diaeresis")); + line.push_back(0x00DC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital U with diaeresis")); + line.push_back(0x00DC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"diaeresis")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital U with diaeresis")); + line.push_back(0x00DC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital U with diaeresis")); + line.push_back(0x00DC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"grave")); + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital U with grave")); + line.push_back(0x00D9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"grave")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital U with grave")); + line.push_back(0x00D9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital U with macron")); + line.push_back(0x016A); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital U with macron")); + line.push_back(0x016B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital U with macron")); + line.push_back(0x016B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital U with macron")); + line.push_back(0x016A); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital U with ogonek")); + line.push_back(0x172); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital U with ogonek")); + line.push_back(0x172); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asterisk")); + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital U with ring above")); + line.push_back(0x016E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"asterisk")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital U with ring above")); + line.push_back(0x016E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciiTilde")); + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital U with tilde")); + line.push_back(0x168); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"asciiTilde")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital U with tilde")); + line.push_back(0x168); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"W")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital W with circumflex")); + line.push_back(0x174); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"W")); + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital W with circumflex")); + line.push_back(0x174); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"acute")); + line.push_back(convertNamesToIntegerValue(L"Y")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Y with acute")); + line.push_back(0x00DD); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"Y")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Y with acute")); + line.push_back(0x00DD); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Y")); + line.push_back(convertNamesToIntegerValue(L"acute")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Y with acute")); + line.push_back(0x00DD); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Y")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Y with acute")); + line.push_back(0x00DD); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"Y")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Y with circumflex")); + line.push_back(0x176); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Y")); + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Y with circumflex")); + line.push_back(0x176); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"diaeresis")); + line.push_back(convertNamesToIntegerValue(L"Y")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Y with diaeresis")); + line.push_back(0x178); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"Y")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Y with diaeresis")); + line.push_back(0x178); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Y")); + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Y with diaeresis")); + line.push_back(0x178); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Y")); + line.push_back(convertNamesToIntegerValue(L"diaeresis")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Y with diaeresis")); + line.push_back(0x178); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"Z")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Z with acute")); + line.push_back(0x179); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Z")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Z with acute")); + line.push_back(0x179); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"Z")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Z with caron")); + line.push_back(0x017D); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"v")); + line.push_back(convertNamesToIntegerValue(L"Z")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Z with caron")); + line.push_back(0x017D); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Z")); + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Z with caron")); + line.push_back(0x017D); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"Z")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Z with dot above")); + line.push_back(0x017B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Z")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Z with dot above")); + line.push_back(0x017B); + dk_ComposeTable.push_back(line); + line.clear(); + + // Latin minuscule + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with acute")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"acute")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with acute")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"acute")); + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with acute")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with acute")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"parenleft")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with breve")); + line.push_back(0x103); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"parenleft")); + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with breve")); + line.push_back(0x103); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with circumflex")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with circumflex")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with circumflex")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with circumflex")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"diaeresis")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with diaeresis")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with diaeresis")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"diaeresis")); + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with diaeresis")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with diaeresis")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"grave")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with grave")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"grave")); + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with grave")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with ogonek")); + line.push_back(0x105); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with ogonek")); + line.push_back(0x105); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"asterisk")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with ring above")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with ring above")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asterisk")); + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with ring above")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"asciiTilde")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with tilde")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with tilde")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciiTilde")); + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with tilde")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small A with tilde")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"a")); + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small AE ligature")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"b")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small B with dot above")); + line.push_back(0x1000); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"b")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small B with dot above")); + line.push_back(0x1000); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"c")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small C with acute")); + line.push_back(0x107); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"c")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small C with acute")); + line.push_back(0x107); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"c")); + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small C with caron")); + line.push_back(0x010D); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"c")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small C with caron")); + line.push_back(0x010D); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"c")); + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small C with cedilla")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"c")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small C with cedilla")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"c")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small C with dot above")); + line.push_back(0x010B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"c")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small C with dot above")); + line.push_back(0x010B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"d")); + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small D with caron")); + line.push_back(0x010F); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"d")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small D with caron")); + line.push_back(0x010F); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"d")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small D with dot above")); + line.push_back(0x1E0B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"d")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small D with dot above")); + line.push_back(0x1E0B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"d")); + line.push_back(convertNamesToIntegerValue(L"h")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Eth")); + line.push_back(0x00F0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"d")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small D with stroke")); + line.push_back(0x111); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"d")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small D with stroke")); + line.push_back(0x111); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"i")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small dotless I")); + line.push_back(0x131); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"i")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small dotless I")); + line.push_back(0x131); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"acute")); + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small E with acute")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small E with acute")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"acute")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small E with acute")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small E with acute")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small E with caron")); + line.push_back(0x011B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small E with caron")); + line.push_back(0x011B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small E with circumflex")); + line.push_back(0x00EA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small E with circumflex")); + line.push_back(0x00EA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small E with circumflex")); + line.push_back(0x00EA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small E with circumflex")); + line.push_back(0x00EA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"diaeresis")); + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small E with diaeresis")); + line.push_back(0x00EB); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"diaeresis")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small E with diaeresis")); + line.push_back(0x00EB); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small E with diaeresis")); + line.push_back(0x00EB); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small E with diaeresis")); + line.push_back(0x00EB); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small E with dot above")); + line.push_back(0x117); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small E with dot above")); + line.push_back(0x117); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"grave")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small E with grave")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"grave")); + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small E with grave")); + line.push_back(0x0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small E with macron")); + line.push_back(0x113); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small E with macron")); + line.push_back(0x113); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small E with macron")); + line.push_back(0x113); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small E with macron")); + line.push_back(0x113); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small E with ogonek")); + line.push_back(0x119); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small E with ogonek")); + line.push_back(0x119); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"n")); + line.push_back(convertNamesToIntegerValue(L"g")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small ENG")); + line.push_back(0x014B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"f")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small F with dot above")); + line.push_back(0x1E1F); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"f")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small F with dot above")); + line.push_back(0x1E1F); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"breve")); + line.push_back(convertNamesToIntegerValue(L"g")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small G with breve")); + line.push_back(0x011F); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"g")); + line.push_back(convertNamesToIntegerValue(L"breve")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small G with breve")); + line.push_back(0x011F); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"g")); + line.push_back(convertNamesToIntegerValue(L"parenleft")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small G with breve")); + line.push_back(0x011F); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"g")); + line.push_back(convertNamesToIntegerValue(L"U")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small G with breve")); + line.push_back(0x011F); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"parenleft")); + line.push_back(convertNamesToIntegerValue(L"g")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small G with breve")); + line.push_back(0x011F); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"g")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small G with cedilla")); + line.push_back(0x123); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"g")); + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small G with cedilla")); + line.push_back(0x123); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"g")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small G with dot above")); + line.push_back(0x121); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"g")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small G with dot above")); + line.push_back(0x121); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"acute")); + line.push_back(convertNamesToIntegerValue(L"i")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small I with acute")); + line.push_back(0x00ED); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"i")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small I with acute")); + line.push_back(0x00ED); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"i")); + line.push_back(convertNamesToIntegerValue(L"acute")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small I with acute")); + line.push_back(0x00ED); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"i")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small I with acute")); + line.push_back(0x00ED); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"i")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small I with circumflex")); + line.push_back(0x00EE); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"i")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small I with circumflex")); + line.push_back(0x00EE); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"i")); + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small I with circumflex")); + line.push_back(0x00EE); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"i")); + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small I with circumflex")); + line.push_back(0x00EE); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"diaeresis")); + line.push_back(convertNamesToIntegerValue(L"i")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small I with diaeresis")); + line.push_back(0x00EF); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"i")); + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small I with diaeresis")); + line.push_back(0x00EF); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"i")); + line.push_back(convertNamesToIntegerValue(L"diaeresis")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small I with diaeresis")); + line.push_back(0x00EF); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"i")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small I with diaeresis")); + line.push_back(0x00EF); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"grave")); + line.push_back(convertNamesToIntegerValue(L"i")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small I with grave")); + line.push_back(0x00EC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"i")); + line.push_back(convertNamesToIntegerValue(L"grave")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small I with grave")); + line.push_back(0x00EC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"i")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small I with macron")); + line.push_back(0x012B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"i")); + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small I with macron")); + line.push_back(0x012B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"i")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small I with macron")); + line.push_back(0x012B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"i")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small I with macron")); + line.push_back(0x012B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"i")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small I with ogonek")); + line.push_back(0x012F); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"i")); + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small I with ogonek")); + line.push_back(0x012F); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciiTilde")); + line.push_back(convertNamesToIntegerValue(L"i")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small I with tilde")); + line.push_back(0x129); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"i")); + line.push_back(convertNamesToIntegerValue(L"asciiTilde")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small I with tilde")); + line.push_back(0x129); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"k")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small K with cedilla")); + line.push_back(0x137); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"k")); + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small K with cedilla")); + line.push_back(0x137); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"k")); + line.push_back(convertNamesToIntegerValue(L"k")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small KRA")); + line.push_back(0x138); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"l")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small L with acute")); + line.push_back(0x013A); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"l")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small L with acute")); + line.push_back(0x013A); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"l")); + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small L with caron")); + line.push_back(0x013E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"l")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small L with caron")); + line.push_back(0x013E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"l")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small L with cedilla")); + line.push_back(0x013C); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"l")); + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small L with cedilla")); + line.push_back(0x013C); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"l")); + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small L with stroke")); + line.push_back(0x142); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"l")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small L with stroke")); + line.push_back(0x142); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"e")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small ligature OE")); + line.push_back(0x153); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"m")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small M with dot above")); + line.push_back(0x1E41); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"m")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small M with dot above")); + line.push_back(0x1E41); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"n")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small N with acute")); + line.push_back(0x144); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"n")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small N with acute")); + line.push_back(0x144); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"n")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small N with caron")); + line.push_back(0x148); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"n")); + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small N with caron")); + line.push_back(0x148); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"n")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small N with cedilla")); + line.push_back(0x146); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"n")); + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small N with cedilla")); + line.push_back(0x146); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciiTilde")); + line.push_back(convertNamesToIntegerValue(L"n")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small N with tilde")); + line.push_back(0x00F1); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"n")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small N with tilde")); + line.push_back(0x00F1); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"n")); + line.push_back(convertNamesToIntegerValue(L"asciiTilde")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small N with tilde")); + line.push_back(0x00F1); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"n")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small N with tilde")); + line.push_back(0x00F1); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"acute")); + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small O with acute")); + line.push_back(0x00F3); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small O with acute")); + line.push_back(0x00F3); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"acute")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small O with acute")); + line.push_back(0x00F3); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small O with acute")); + line.push_back(0x00F3); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small O with circumflex")); + line.push_back(0x00F4); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small O with circumflex")); + line.push_back(0x00F4); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small O with circumflex")); + line.push_back(0x00F4); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small O with circumflex")); + line.push_back(0x00F4); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"diaeresis")); + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small O with diaeresis")); + line.push_back(0x00F6); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"diaeresis")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small O with diaeresis")); + line.push_back(0x00F6); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small O with diaeresis")); + line.push_back(0x00F6); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small O with diaeresis")); + line.push_back(0x00F6); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"grave")); + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small O with grave")); + line.push_back(0x00F2); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"grave")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small O with grave")); + line.push_back(0x00F2); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small O with stroke")); + line.push_back(0x00F8); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small O with stroke")); + line.push_back(0x00F8); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciiTilde")); + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small O with tilde")); + line.push_back(0x00F5); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small O with tilde")); + line.push_back(0x00F5); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small O with tilde")); + line.push_back(0x00F5); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"o")); + line.push_back(convertNamesToIntegerValue(L"asciiTilde")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small O with tilde")); + line.push_back(0x00F5); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"p")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small P with dot above")); + line.push_back(0x1E57); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"p")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small P with dot above")); + line.push_back(0x1E57); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"r")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small R with acute")); + line.push_back(0x155); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"r")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small R with acute")); + line.push_back(0x155); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"r")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small R with caron")); + line.push_back(0x159); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"r")); + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small R with caron")); + line.push_back(0x159); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"r")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small R with cedilla")); + line.push_back(0x157); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"r")); + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small R with cedilla")); + line.push_back(0x157); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small S with acute")); + line.push_back(0x015B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small S with acute")); + line.push_back(0x015B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small S with caron")); + line.push_back(0x161); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small S with caron")); + line.push_back(0x161); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"cedilla")); + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small S with cedilla")); + line.push_back(0x015F); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small S with cedilla")); + line.push_back(0x015F); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small S with cedilla")); + line.push_back(0x015F); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"cedilla")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small S with cedilla")); + line.push_back(0x015F); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small S with dot above")); + line.push_back(0x1E61); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small S with dot above")); + line.push_back(0x1E61); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"s")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small SHARP S")); + line.push_back(0x00DF); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"t")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small T with caron")); + line.push_back(0x165); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"t")); + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small T with caron")); + line.push_back(0x165); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"t")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small T with dot above")); + line.push_back(0x1E6B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"t")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small T with dot above")); + line.push_back(0x1E6B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"t")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small T with stroke")); + line.push_back(0x167); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"t")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small T with stroke")); + line.push_back(0x167); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"t")); + line.push_back(convertNamesToIntegerValue(L"slash")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small T with stroke")); + line.push_back(0x167); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"t")); + line.push_back(convertNamesToIntegerValue(L"h")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small THORN")); + line.push_back(0x00FE); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"acute")); + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with acute")); + line.push_back(0x00FA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with acute")); + line.push_back(0x00FA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with acute")); + line.push_back(0x00FA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"acute")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with acute")); + line.push_back(0x00FA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with caron")); + line.push_back(0x01D4); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with circumflex")); + line.push_back(0x00FB); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with circumflex")); + line.push_back(0x00FB); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with circumflex")); + line.push_back(0x00FB); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"greater")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with circumflex")); + line.push_back(0x00FB); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"diaeresis")); + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with diaeresis")); + line.push_back(0x00FC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with diaeresis")); + line.push_back(0x00FC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"diaeresis")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with diaeresis")); + line.push_back(0x00FC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with diaeresis")); + line.push_back(0x00FC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"grave")); + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with grave")); + line.push_back(0x00F9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"grave")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with grave")); + line.push_back(0x00F9); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with macron")); + line.push_back(0x016B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"minus")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with macron")); + line.push_back(0x016B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with macron")); + line.push_back(0x016B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"underscore")); + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with macron")); + line.push_back(0x016B); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with ogonek")); + line.push_back(0x173); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"comma")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with ogonek")); + line.push_back(0x173); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asterisk")); + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with ring above")); + line.push_back(0x016F); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"asterisk")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with ring above")); + line.push_back(0x016F); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciiTilde")); + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with tilde")); + line.push_back(0x169); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"u")); + line.push_back(convertNamesToIntegerValue(L"asciiTilde")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small U with tilde")); + line.push_back(0x169); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"w")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small W with circumflex")); + line.push_back(0x175); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"w")); + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small W with circumflex")); + line.push_back(0x175); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"acute")); + line.push_back(convertNamesToIntegerValue(L"y")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Y with acute")); + line.push_back(0x00FD); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"y")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Y with acute")); + line.push_back(0x00FD); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"y")); + line.push_back(convertNamesToIntegerValue(L"acute")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Y with acute")); + line.push_back(0x00FD); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"y")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Y with acute")); + line.push_back(0x00FD); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"y")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Y with circumflex")); + line.push_back(0x177); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"y")); + line.push_back(convertNamesToIntegerValue(L"asciicircum")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Y with circumflex")); + line.push_back(0x177); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"diaeresis")); + line.push_back(convertNamesToIntegerValue(L"y")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Y with diaeresis")); + line.push_back(0x00FF); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"y")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Y with diaeresis")); + line.push_back(0x00FF); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"y")); + line.push_back(convertNamesToIntegerValue(L"diaeresis")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Y with diaeresis")); + line.push_back(0x00FF); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"y")); + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Y with diaeresis")); + line.push_back(0x00FF); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"z")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Z with acute")); + line.push_back(0x017A); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"z")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Z with acute")); + line.push_back(0x017A); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"z")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Z with caron")); + line.push_back(0x017E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"v")); + line.push_back(convertNamesToIntegerValue(L"z")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Z with caron")); + line.push_back(0x017E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"z")); + line.push_back(convertNamesToIntegerValue(L"less")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Z with caron")); + line.push_back(0x017E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"z")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Z with dot above")); + line.push_back(0x017C); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"z")); + line.push_back(convertNamesToIntegerValue(L"period")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Z with dot above")); + line.push_back(0x017C); + dk_ComposeTable.push_back(line); + line.clear(); + + // Greek + /*line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"space")); + line.push_back(convertNamesToIntegerValue(L"dialytika tonos")); + line.push_back(0x385); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"space")); + line.push_back(convertNamesToIntegerValue(L"dialytika tonos")); + line.push_back(0x385); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"Greek_Alpha")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Alpha with tonos")); + line.push_back(0x386); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Greek_Alpha")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Alpha with tonos")); + line.push_back(0x386); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"Greek_Epsilon")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Epsilon with tonos")); + line.push_back(0x388); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Greek_Epsilon")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Epsilon with tonos")); + line.push_back(0x388); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"Greek_Eta")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Eta with tonos")); + line.push_back(0x389); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Greek_Eta")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Eta with tonos")); + line.push_back(0x389); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Greek_Iota")); + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Iota with dialytika")); + line.push_back(0x03AA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"Greek_Iota")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Iota with dialytika")); + line.push_back(0x03AA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"Greek_Iota")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Iota with tonos")); + line.push_back(0x038A); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Greek_Iota")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Iota with tonos")); + line.push_back(0x038A); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"Greek_Omicron")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Omicron with tonos")); + line.push_back(0x038C); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Greek_Omicron")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Omicron with tonos")); + line.push_back(0x038C); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Greek_Upsilon")); + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Upsilon with dialytika")); + line.push_back(0x03AB); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"Greek_Upsilon")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Upsilon with dialytika")); + line.push_back(0x03AB); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"Greek_Upsilon")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Upsilon with tonos")); + line.push_back(0x038E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Greek_Upsilon")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Upsilon with tonos")); + line.push_back(0x038E); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"Greek_Omega")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Omega with tonos")); + line.push_back(0x038F); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Greek_Omega")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"capital Omega with tonos")); + line.push_back(0x038F); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"Greek_Alpha")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Alpha with tonos")); + line.push_back(0x03AC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Greek_Alpha")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Alpha with tonos")); + line.push_back(0x03AC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"Greek_Epsilon")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Epsilon with tonos")); + line.push_back(0x03AD); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Greek_Epsilon")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Epsilon with tonos")); + line.push_back(0x03AD); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"Greek_eta")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Eta with tonos")); + line.push_back(0x03AE); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Greek_eta")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Eta with tonos")); + line.push_back(0x03AE); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"Greek_iota")); + line.push_back(convertNamesToIntegerValue(L"small Iota with dialytika and tonos")); + line.push_back(0x390); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"Greek_iota")); + line.push_back(convertNamesToIntegerValue(L"small Iota with dialytika and tonos")); + line.push_back(0x390); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Greek_iota")); + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Iota with dialytika")); + line.push_back(0x03CA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"Greek_iota")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Iota with dialytika")); + line.push_back(0x03CA); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"Greek_iota")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Iota with tonos")); + line.push_back(0x03AF); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Greek_iota")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Iota with tonos")); + line.push_back(0x03AF); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"Greek_oMicron")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Omicron with tonos")); + line.push_back(0x03CC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Greek_Omicron")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Omicron with tonos")); + line.push_back(0x03CC); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"Greek_upsilon")); + line.push_back(convertNamesToIntegerValue(L"small Upsilon with dialytika and tonos")); + line.push_back(0x03B0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"Greek_upsilon")); + line.push_back(convertNamesToIntegerValue(L"small Upsilon with dialytika and tonos")); + line.push_back(0x03B0); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Greek_upsilon")); + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Upsilon with dialytika")); + line.push_back(0x03CB); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"quotedbl")); + line.push_back(convertNamesToIntegerValue(L"Greek_upsilon")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Upsilon with dialytika")); + line.push_back(0x03CB); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"Greek_upsilon")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Upsilon with tonos")); + line.push_back(0x03CD); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Greek_upsilon")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Upsilon with tonos")); + line.push_back(0x03CD); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"Greek_omega")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Omega with tonos")); + line.push_back(0x03CE); + dk_ComposeTable.push_back(line); + line.clear(); + + line.push_back(convertNamesToIntegerValue(L"Greek_omega")); + line.push_back(convertNamesToIntegerValue(L"apostrophe")); + line.push_back(convertNamesToIntegerValue(L"")); + line.push_back(convertNamesToIntegerValue(L"small Omega with tonos")); + line.push_back(0x03CE); + dk_ComposeTable.push_back(line); + line.clear();*/ + + return 0; +} + + +KMX_DWORD find_ComposedCharacter(v_dw_2D * p_dk_ComposeTable, KMX_DWORD first, KMX_DWORD second , KMX_DWORD third ) { + + v_dw_2D dk_ComposeTable = * p_dk_ComposeTable; + + for ( int i =0; i< (dk_ComposeTable).size()-1; i++) { + if (( (KMX_DWORD) dk_ComposeTable[i][0] == first) && ( (KMX_DWORD) dk_ComposeTable[i][1] == second) && ( (KMX_DWORD) dk_ComposeTable[i][2] == third) ) + return (KMX_DWORD) dk_ComposeTable[i][4]; + } + return 0; // _S2 what to return if not found? +} + diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h new file mode 100755 index 0000000000..7c6d2f034e --- /dev/null +++ b/linux/mcompile/keymap/deadkey.h @@ -0,0 +1,15 @@ +// In ths program we use a 3D-Vector Vector[language][Keys][Shiftstates] +#pragma once +#ifndef DEADKEY_H +#define DEADKEY_H + +#include +#include +#include +#include + +int createDK_ComposeTable(v_dw_2D & dk_ComposeTable); + +KMX_DWORD find_ComposedCharacter(v_dw_2D * dk_ComposeTable, KMX_DWORD first, KMX_DWORD second , KMX_DWORD third = 0 ); + +# endif /*DEADKEY_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index fa6143f06c..ec3d28461b 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -11,10 +11,9 @@ int map_VKShiftState_to_Lin(int VKShiftState) { return VKShiftState; } -KMX_DWORD convertNamesToASCIIValue(std::wstring tok_wstr){ +KMX_DWORD convertNamesToIntegerValue(std::wstring tok_wstr){ std::map first; - first[L"ampersand"] = 38; first[L"apostrophe"] = 39; first[L"asciicircum"] = 136; @@ -64,6 +63,9 @@ KMX_DWORD convertNamesToASCIIValue(std::wstring tok_wstr){ first[L"dead_perispomeni"] = 126; first[L"dead_tilde"] = 126; + + first[L"acute accent"] = 0xB4; + //first[L" ?? "] = VK_OEM_102; /* DE = 226 ' " ? VK_OEM_102 */ if ( tok_wstr.size() == 1) { @@ -262,7 +264,7 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { for ( int i = 1; i< (int) tokens.size();i++) { // replace a name with a single character ( a -> a ; equal -> = ) - tokens_int = convertNamesToASCIIValue( wstring_from_string(tokens[i])); + tokens_int = convertNamesToIntegerValue( wstring_from_string(tokens[i])); tokens_dw.push_back(tokens_int); } @@ -485,7 +487,7 @@ std::wstring convert_DeadkeyValues_ToChar(int in) { return std::wstring(1, in); } else { std::string long_name((const char*) gdk_keyval_name (in)); // 6510 => "dead_circumflex " - lname = convertNamesToASCIIValue( wstring_from_string(long_name)); // "dead_circumflex " => 94 + lname = convertNamesToIntegerValue( wstring_from_string(long_name)); // "dead_circumflex " => 94 if (lname != returnIfCharInvalid) { std::wstring ss = std::wstring(1, lname ); @@ -549,3 +551,4 @@ std::wstring get_KeyVals_according_to_keycode_and_Shiftstate_new(GdkKeymap *key return convert_DeadkeyValues_ToChar((int) *keyvals);; } + diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 82472a91b9..c7b1fbd0b2 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -477,7 +477,7 @@ static KMX_DWORD deadkeyThreshold = 65000; int map_VKShiftState_to_Lin(int VKShiftState); // takes a std::wstring (=contents of line symbols-file ) and returns the (int) value of the character -KMX_DWORD convertNamesToASCIIValue(std::wstring tok_wstr); +KMX_DWORD convertNamesToIntegerValue(std::wstring tok_wstr); // create a Vector with all entries of both keymaps+ keymap int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap); @@ -523,7 +523,6 @@ KMX_DWORD get_KeyCode_fromVKUS( KMX_DWORD VK_US); bool IsKeymanUsedKeyVal(std::wstring Keyval); - //UINT find_SC_Other_from_SC_US_GDK(UINT vk_US_187,GdkKeymap *keymap); UINT map_Ikey_DE(UINT iKey); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 8befc90857..08f2a3a6c7 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -55,10 +55,10 @@ void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WOR void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group,KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch); void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch); -int KMX_GetDeadkeys(WORD DeadKey, WORD *OutputPairs) ; +int KMX_GetDeadkeys(KMX_WORD DeadKey, KMX_WORD *OutputPairs) ; -int KMX_GetDeadkeys_NT(WORD DeadKey, WORD *OutputPairs); // returns array of [USVK, ch] pairs -int KMX_GetDeadkeys_NT_x64(WORD DeadKey, WORD *OutputPairs); // returns array of [USVK, ch] pairs +int KMX_GetDeadkeys_NT(KMX_WORD DeadKey, KMX_WORD *OutputPairs); // returns array of [USVK, ch] pairs +int KMX_GetDeadkeys_NT_x64(KMX_WORD DeadKey, KMX_WORD *OutputPairs); // returns array of [USVK, ch] pairs void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift); @@ -471,12 +471,17 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon // create vector v_dw_3D All_Vector; - if(createOneVectorFromBothKeyboards(All_Vector,keymap)){ + if(createOneVectorFromBothKeyboards(All_Vector, keymap)){ wprintf(L"ERROR: can't create one vector from both keyboards\n"); return FALSE; } - // const wchar_t* ERROR = L" "; + // create dk_createDK_ComposeTable + v_dw_2D dk_ComposeTable; + if(createDK_ComposeTable(dk_ComposeTable)){ + wprintf(L"ERROR: can't create dk_ComposeTable\n"); + return FALSE; + } for (int j = 0; VKShiftState[j] != 0xFFFF; j++) { // I4651 wprintf(L"\n"); @@ -600,7 +605,7 @@ KMX_WCHAR KMX_CharFromSC(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHE //if (KeyvalOther > deadkeyThreshold) { if (KeyvalOther > 255) { std::string ws((const char*) gdk_keyval_name (KeyvalOther)); - *DeadKey = convertNamesToASCIIValue( wstring_from_string(ws)); + *DeadKey = convertNamesToIntegerValue( wstring_from_string(ws)); return 0xFFFF; } @@ -666,7 +671,8 @@ KMX_WORD KMX_VKUnderlyingLayoutToVKUS_S2(KMX_WORD VKey) { return retu; } -int KMX_GetDeadkeys(WORD DeadKey, WORD *OutputPairs) { +int KMX_GetDeadkeys(KMX_WORD DeadKey, KMX_WORD *OutputPairs) { + int asdfghjk=0; /*if(IsWow64()) { return KMX_GetDeadkeys_NT_x64(DeadKey, OutputPairs); } else { @@ -674,7 +680,7 @@ int KMX_GetDeadkeys(WORD DeadKey, WORD *OutputPairs) { }*/ } -int KMX_GetDeadkeys_NT_x64(WORD DeadKey, WORD *OutputPairs) { +int KMX_GetDeadkeys_NT_x64(KMX_WORD DeadKey, KMX_WORD *OutputPairs) { /*WORD *p = OutputPairs, shift; for(int i = 0; KbdTables_x64->pDeadKey[i].dwBoth; i++) { if(HIWORD(KbdTables_x64->pDeadKey[i].dwBoth) == DeadKey) { @@ -692,7 +698,7 @@ int KMX_GetDeadkeys_NT_x64(WORD DeadKey, WORD *OutputPairs) { return (INT_PTR)(p-OutputPairs);*/ } -int KMX_GetDeadkeys_NT(WORD DeadKey, WORD *OutputPairs) { +int KMX_GetDeadkeys_NT(KMX_WORD DeadKey, KMX_WORD *OutputPairs) { /*WORD *p = OutputPairs, shift; for(int i = 0; KbdTables->pDeadKey[i].dwBoth; i++) { if(HIWORD(KbdTables->pDeadKey[i].dwBoth) == DeadKey) { diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index a1595a0fd4..e450d0336f 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -25,6 +25,8 @@ #include "keymap.h" #include "helpers.h" +#include "deadkey.h" + #include "mc_kmxfile.h" void KMX_LogError(const KMX_WCHART* m1, int m2 = 0); diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index 49f75b2885..60fb919de9 100755 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -13,6 +13,7 @@ deps = [gtk, x11, xkb,libxklavier] cpp_files = files( 'helpers.cpp', 'keymap.cpp', + 'deadkey.cpp', 'mcompile.cpp', 'filesystem.cpp', 'mc_kmxfile.cpp', From f29d6f1de18109f706eae56303dc8b5d283f5303 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 4 Dec 2023 16:10:34 +0100 Subject: [PATCH 145/327] feat(linux): mcompile open KMX_ConvertDeadkey --- linux/mcompile/keymap/deadkey.cpp | 5801 ++-------------------------- linux/mcompile/keymap/deadkey.h | 13 +- linux/mcompile/keymap/mcompile.cpp | 76 +- linux/mcompile/keymap/mcompile.h | 1 + 4 files changed, 440 insertions(+), 5451 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 720083b57c..20f2d8b375 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -1,5410 +1,413 @@ #include "keymap.h" #include "deadkey.h" -#include - -int createDK_ComposeTable(v_dw_2D & dk_ComposeTable){ - - // values taken from: https://help.ubuntu.com/community/GtkComposeTable - //dk_ComposeTable[i][0] : First - //dk_ComposeTable[i][1] : Second - //dk_ComposeTable[i][2] : Third - //dk_ComposeTable[i][3] : Character - //dk_ComposeTable[i][4] : Unicode-Value - - v_dw_1D line; - - // Diacritics and punctuation - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"acute accent")); - line.push_back(0x00B4); - dk_ComposeTable.push_back(line); - line.clear(); - - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"space")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Apostrophe")); - line.push_back(0x27); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"space")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Apostrophe")); - line.push_back(0x27); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"parenleft")); - line.push_back(convertNamesToIntegerValue(L"space")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Breve")); - line.push_back(0x02D8); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"space")); - line.push_back(convertNamesToIntegerValue(L"parenleft")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Breve")); - line.push_back(0x02D8); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"space")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Caron")); - line.push_back(0x02C7); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"space")); - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Caron")); - line.push_back(0x02C7); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Cedilla")); - line.push_back(0x00B8); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"space")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Circumflex accent")); - line.push_back(0x005E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"space")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Circumflex accent")); - line.push_back(0x005E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"space")); - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Circumflex accent")); - line.push_back(0x005E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"space")); - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Circumflex accent")); - line.push_back(0x005E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Diaeresis")); - line.push_back(0x00A8); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"grave")); - line.push_back(convertNamesToIntegerValue(L"space")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Grave accent")); - line.push_back(0x60); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"space")); - line.push_back(convertNamesToIntegerValue(L"grave")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Grave accent")); - line.push_back(0x60); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"em dash —")); - line.push_back(0x2014); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"en dash –")); - line.push_back(0x2013); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"exclam")); - line.push_back(convertNamesToIntegerValue(L"exclam")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"inverted exclamation mark")); - line.push_back(0x00A1); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"question")); - line.push_back(convertNamesToIntegerValue(L"question")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"inverted question mark")); - line.push_back(0x00BF); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"exclam")); - line.push_back(convertNamesToIntegerValue(L"question")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"interrobang")); - line.push_back(0x203D); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"parenleft")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"left Curly Bracket")); - line.push_back(0x007B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"parenleft")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"left Curly Bracket")); - line.push_back(0x007B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"left single Quotation Mark")); - line.push_back(0x2018); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"left single Quotation Mark")); - line.push_back(0x2018); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"parenleft")); - line.push_back(convertNamesToIntegerValue(L"parenleft")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"left Square Bracket")); - line.push_back(0x005B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"left pointing Double Angle Quotation Mark")); - line.push_back(0x00AB); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Macron")); - line.push_back(0x00AF); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Macron")); - line.push_back(0x00AF); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Macron")); - line.push_back(0x00AF); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Macron")); - line.push_back(0x00AF); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Macron")); - line.push_back(0x00AF); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"space")); - line.push_back(convertNamesToIntegerValue(L"space")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Non-breaking Space")); - line.push_back(0x00A0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"parenright")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"right Curly Bracket")); - line.push_back(0x007D); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"parenright")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"right Curly Bracket")); - line.push_back(0x007D); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"right single Quotation Mark")); - line.push_back(0x2019); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"right single Quotation Mark")); - line.push_back(0x2019); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"parenright")); - line.push_back(convertNamesToIntegerValue(L"parenright")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"right Square Bracket")); - line.push_back(0x005D); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"right pointing Double Angle Quotation Mark")); - line.push_back(0x00BB); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"space")); - line.push_back(convertNamesToIntegerValue(L"SoftHyphen (word break)")); - line.push_back(0x00AD); - dk_ComposeTable.push_back(line); - line.clear(); - - // Currency - line.push_back(convertNamesToIntegerValue(L"bar")); - line.push_back(convertNamesToIntegerValue(L"C")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Cent sign")); - line.push_back(0x00A2); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"bar")); - line.push_back(convertNamesToIntegerValue(L"c")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Cent sign")); - line.push_back(0x00A2); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"C")); - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Cent sign")); - line.push_back(0x00A2); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"c")); - line.push_back(convertNamesToIntegerValue(L"bar")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Cent sign")); - line.push_back(0x00A2); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"c")); - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Cent sign")); - line.push_back(0x00A2); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"C")); - line.push_back(convertNamesToIntegerValue(L"bar")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Cent sign")); - line.push_back(0x00A2); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"C")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Cent sign")); - line.push_back(0x00A2); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"c")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Cent sign")); - line.push_back(0x00A2); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"C")); - line.push_back(convertNamesToIntegerValue(L"equal")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Euro sign")); - line.push_back(0x20AC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"c")); - line.push_back(convertNamesToIntegerValue(L"equal")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Euro sign")); - line.push_back(0x20AC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"equal")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Euro sign")); - line.push_back(0x20AC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"equal")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Euro sign")); - line.push_back(0x20AC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"equal")); - line.push_back(convertNamesToIntegerValue(L"C")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Euro sign")); - line.push_back(0x20AC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"equal")); - line.push_back(convertNamesToIntegerValue(L"c")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Euro sign")); - line.push_back(0x20AC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"equal")); - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Euro sign")); - line.push_back(0x20AC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"equal")); - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Euro sign")); - line.push_back(0x20AC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"equal")); - line.push_back(convertNamesToIntegerValue(L"L")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Lira sign")); - line.push_back(0x00A3); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"L")); - line.push_back(convertNamesToIntegerValue(L"equal")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Lira sign")); - line.push_back(0x00A3); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"l")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Pound sign")); - line.push_back(0x00A3); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"L")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Pound sign")); - line.push_back(0x00A3); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"L")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Pound sign")); - line.push_back(0x00A3); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"l")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Pound sign")); - line.push_back(0x00A3); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"R")); - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Rupee sign")); - line.push_back(0x20a8); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"equal")); - line.push_back(convertNamesToIntegerValue(L"Y")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Yen sign")); - line.push_back(0x00A5); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"equal")); - line.push_back(convertNamesToIntegerValue(L"y")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Yen sign")); - line.push_back(0x00A5); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"Y")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Yen sign")); - line.push_back(0x00A5); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"y")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Yen sign")); - line.push_back(0x00A5); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Y")); - line.push_back(convertNamesToIntegerValue(L"equal")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Yen sign")); - line.push_back(0x00A5); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Y")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Yen sign")); - line.push_back(0x00A5); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"y")); - line.push_back(convertNamesToIntegerValue(L"equal")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Yen sign")); - line.push_back(0x00A5); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"y")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Yen sign")); - line.push_back(0x00A5); - dk_ComposeTable.push_back(line); - line.clear(); - - - // Vulgar Fractions - line.push_back(convertNamesToIntegerValue(L"1")); - line.push_back(convertNamesToIntegerValue(L"2")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"One-half")); - line.push_back(0x00BD); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"1")); - line.push_back(convertNamesToIntegerValue(L"3")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"One-third")); - line.push_back(0x2153); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"2")); - line.push_back(convertNamesToIntegerValue(L"3")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Two-thirds")); - line.push_back(0x2154); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"1")); - line.push_back(convertNamesToIntegerValue(L"4")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"One-quarter")); - line.push_back(0x00BC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"3")); - line.push_back(convertNamesToIntegerValue(L"4")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Three-quarters")); - line.push_back(0x00BE); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"1")); - line.push_back(convertNamesToIntegerValue(L"5")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"One-fifth")); - line.push_back(0x2155); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"2")); - line.push_back(convertNamesToIntegerValue(L"5")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Two-fifths")); - line.push_back(0x2156); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"3")); - line.push_back(convertNamesToIntegerValue(L"5")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Three-fifths")); - line.push_back(0x2157); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"4")); - line.push_back(convertNamesToIntegerValue(L"5")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Four-fifths")); - line.push_back(0x2158); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"1")); - line.push_back(convertNamesToIntegerValue(L"6")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"One-sixth")); - line.push_back(0x2159); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"1")); - line.push_back(convertNamesToIntegerValue(L"8")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"One-eighth")); - line.push_back(0x215B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"3")); - line.push_back(convertNamesToIntegerValue(L"8")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Three-eighths")); - line.push_back(0x215C); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"5")); - line.push_back(convertNamesToIntegerValue(L"8")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Five-eighths")); - line.push_back(0x215D); - dk_ComposeTable.push_back(line); - line.clear(); - - // Mathematical Symbols and Signs - line.push_back(convertNamesToIntegerValue(L"7")); - line.push_back(convertNamesToIntegerValue(L"8")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Seven-eighths")); - line.push_back(0x215E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"backslash")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Backslash bar")); - line.push_back(0x233f); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"backslash")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Backslash bar")); - line.push_back(0x233f); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"0")); - line.push_back(convertNamesToIntegerValue(L"C")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Copyright sign")); - line.push_back(0x00A9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"0")); - line.push_back(convertNamesToIntegerValue(L"c")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Copyright sign")); - line.push_back(0x00A9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"C")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Copyright sign")); - line.push_back(0x00A9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"c")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Copyright sign")); - line.push_back(0x00A9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"C")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Copyright sign")); - line.push_back(0x00A9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"c")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Copyright sign")); - line.push_back(0x00A9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"C")); - line.push_back(convertNamesToIntegerValue(L"0")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Copyright sign")); - line.push_back(0x00A9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"C")); - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Copyright sign")); - line.push_back(0x00A9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"C")); - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Copyright sign")); - line.push_back(0x00A9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"c")); - line.push_back(convertNamesToIntegerValue(L"0")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Copyright sign")); - line.push_back(0x00A9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"c")); - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Copyright sign")); - line.push_back(0x00A9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"c")); - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Copyright sign")); - line.push_back(0x00A9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"parenleft")); - line.push_back(convertNamesToIntegerValue(L"c")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Copyright sign")); - line.push_back(0x00A9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Degree sign")); - line.push_back(0x00B0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"0")); - line.push_back(convertNamesToIntegerValue(L"asterisk")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Degree sign")); - line.push_back(0x00B0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asterisk")); - line.push_back(convertNamesToIntegerValue(L"0")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Degree sign")); - line.push_back(0x00B0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Diamond operator")); - line.push_back(0x22c4); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Diamond operator")); - line.push_back(0x22c4); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"colon")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Division sign")); - line.push_back(0x00F7); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"colon")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Division sign")); - line.push_back(0x00F7); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"feminine ordinal indicator")); - line.push_back(0x00AA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"feminine ordinal indicator")); - line.push_back(0x00AA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"feminine ordinal indicator")); - line.push_back(0x00AA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"feminine ordinal indicator")); - line.push_back(0x00AA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"equal")); - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Identical to")); - line.push_back(0x2261); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"8")); - line.push_back(convertNamesToIntegerValue(L"8")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Infinity")); - line.push_back(0x221e); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"equal")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Less-than or equal to")); - line.push_back(0x2264); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"equal")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Greater-than or equal to")); - line.push_back(0x2265); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"masculine ordinal indicator")); - line.push_back(0x00BA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"masculine ordinal indicator")); - line.push_back(0x00BA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"masculine ordinal indicator")); - line.push_back(0x00BA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"masculine ordinal indicator")); - line.push_back(0x00BA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Micro sign")); - line.push_back(0x00B5); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Micro sign")); - line.push_back(0x00B5); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Micro sign")); - line.push_back(0x00B5); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Micro sign")); - line.push_back(0x00B5); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Middle·Dot")); - line.push_back(0x00B7); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Middle·Dot")); - line.push_back(0x00B7); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"x")); - line.push_back(convertNamesToIntegerValue(L"x")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Multiplication sign")); - line.push_back(0x00D7); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"equal")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Not equal to")); - line.push_back(0x2260); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"equal")); - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Not equal to")); - line.push_back(0x2260); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"equal")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Not equal to")); - line.push_back(0x2260); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Not sign")); - line.push_back(0x00AC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Not sign")); - line.push_back(0x00AC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"plus")); - line.push_back(convertNamesToIntegerValue(L"plus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Number sign (Octothorpe)")); - line.push_back(0x23); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"exclam")); - line.push_back(convertNamesToIntegerValue(L"P")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Pilcrow sign")); - line.push_back(0x00B6); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"exclam")); - line.push_back(convertNamesToIntegerValue(L"p")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Pilcrow sign")); - line.push_back(0x00B6); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"p")); - line.push_back(convertNamesToIntegerValue(L"exclam")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Pilcrow sign")); - line.push_back(0x00B6); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"P")); - line.push_back(convertNamesToIntegerValue(L"exclam")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Pilcrow sign")); - line.push_back(0x00B6); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"plus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"plusminus sign")); - line.push_back(0x00B1); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"plus")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"plusminus sign")); - line.push_back(0x00B1); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"R")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Registered sign")); - line.push_back(0x00AE); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"r")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Registered sign")); - line.push_back(0x00AE); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"R")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Registered sign")); - line.push_back(0x00AE); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"r")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Registered sign")); - line.push_back(0x00AE); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"parenleft")); - line.push_back(convertNamesToIntegerValue(L"r")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Registered sign")); - line.push_back(0x00AE); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Slash bar")); - line.push_back(0x233f); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Slash bar")); - line.push_back(0x233f); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"T")); - line.push_back(convertNamesToIntegerValue(L"M")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Trademark sign")); - line.push_back(0x2122); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"T")); - line.push_back(convertNamesToIntegerValue(L"m")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Trademark sign")); - line.push_back(0x2122); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"t")); - line.push_back(convertNamesToIntegerValue(L"M")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Trademark sign")); - line.push_back(0x2122); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"t")); - line.push_back(convertNamesToIntegerValue(L"m")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Trademark sign")); - line.push_back(0x2122); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"reverse Solidus")); - line.push_back(0x005C); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"reverse Solidus")); - line.push_back(0x005C); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"reverse Solidus")); - line.push_back(0x005C); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"0")); - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Section sign")); - line.push_back(0x00A7); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"0")); - line.push_back(convertNamesToIntegerValue(L"S")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Section sign")); - line.push_back(0x00A7); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"exclam")); - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Section sign")); - line.push_back(0x00A7); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"exclam")); - line.push_back(convertNamesToIntegerValue(L"S")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Section sign")); - line.push_back(0x00A7); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Section sign")); - line.push_back(0x00A7); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"S")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Section sign")); - line.push_back(0x00A7); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"S")); - line.push_back(convertNamesToIntegerValue(L"0")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Section sign")); - line.push_back(0x00A7); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"S")); - line.push_back(convertNamesToIntegerValue(L"exclam")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Section sign")); - line.push_back(0x00A7); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"0")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Section sign")); - line.push_back(0x00A7); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Section sign")); - line.push_back(0x00A7); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"S")); - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Section sign")); - line.push_back(0x00A7); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"exclam")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Section sign")); - line.push_back(0x00A7); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"v")); - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Square root")); - line.push_back(0x221a); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"v")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Square root")); - line.push_back(0x221a); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"bracketleft")); - line.push_back(convertNamesToIntegerValue(L"bracketright")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"squish quad")); - line.push_back(0x2337); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"0")); - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Superscript Zero")); - line.push_back(0x2070); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"0")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Superscript Zero")); - line.push_back(0x2070); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"1")); - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Superscript One")); - line.push_back(0x00B9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"1")); - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Superscript One")); - line.push_back(0x00B9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"1")); - line.push_back(convertNamesToIntegerValue(L"S")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Superscript One")); - line.push_back(0x00B9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"1")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Superscript One")); - line.push_back(0x00B9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"1")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Superscript One")); - line.push_back(0x00B9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"S")); - line.push_back(convertNamesToIntegerValue(L"1")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Superscript One")); - line.push_back(0x00B9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"2")); - line.push_back(convertNamesToIntegerValue(L"S")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Superscript Two")); - line.push_back(0x00B2); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"2")); - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Superscript Two")); - line.push_back(0x00B2); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"2")); - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Superscript Two")); - line.push_back(0x00B2); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"2")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Superscript Two")); - line.push_back(0x00B2); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"2")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Superscript Two")); - line.push_back(0x00B2); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"S")); - line.push_back(convertNamesToIntegerValue(L"2")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Superscript Two")); - line.push_back(0x00B2); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"3")); - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Superscript Three")); - line.push_back(0x00B3); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"3")); - line.push_back(convertNamesToIntegerValue(L"S")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Superscript Three")); - line.push_back(0x00B3); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"3")); - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Superscript Three")); - line.push_back(0x00B3); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"3")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Superscript Three")); - line.push_back(0x00B3); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"S")); - line.push_back(convertNamesToIntegerValue(L"3")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Superscript Three")); - line.push_back(0x00B3); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"3")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Superscript Three")); - line.push_back(0x00B3); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciiTilde (~)")); - line.push_back(convertNamesToIntegerValue(L"space")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Tilde")); - line.push_back(0x007E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"space")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Tilde")); - line.push_back(0x007E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"space")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Tilde")); - line.push_back(0x007E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"space")); - line.push_back(convertNamesToIntegerValue(L"asciiTilde")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"Tilde")); - line.push_back(0x007E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"vertical line")); - line.push_back(0x007C); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"l")); - line.push_back(convertNamesToIntegerValue(L"v")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"vertical line")); - line.push_back(0x007C); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"L")); - line.push_back(convertNamesToIntegerValue(L"V")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"vertical line")); - line.push_back(0x007C); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"vertical line")); - line.push_back(0x007C); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"v")); - line.push_back(convertNamesToIntegerValue(L"l")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"vertical line")); - line.push_back(0x007C); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"V")); - line.push_back(convertNamesToIntegerValue(L"L")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"vertical line")); - line.push_back(0x007C); - dk_ComposeTable.push_back(line); - line.clear(); - - // Latin majuscules - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"acute")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with acute")); - line.push_back(0x00C1); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with acute")); - line.push_back(0x00C1); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"acute")); - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with acute")); - line.push_back(0x00C1); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with acute")); - line.push_back(0x00C1); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"parenleft")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with breve")); - line.push_back(0x102); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"parenleft")); - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with breve")); - line.push_back(0x102); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with circumflex")); - line.push_back(0x00C2); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with circumflex")); - line.push_back(0x00C2); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with circumflex")); - line.push_back(0x00C2); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with circumflex")); - line.push_back(0x00C2); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with diaeresis")); - line.push_back(0x00C4); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"diaeresis")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with diaeresis")); - line.push_back(0x00C4); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"diaeresis")); - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with diaeresis")); - line.push_back(0x00C4); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with diaeresis")); - line.push_back(0x00C4); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"grave")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with grave")); - line.push_back(0x00C0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"grave")); - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with grave")); - line.push_back(0x00C0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with ogonek")); - line.push_back(0x104); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with ogonek")); - line.push_back(0x104); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with ring above")); - line.push_back(0x00C5); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"asterisk")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with ring above")); - line.push_back(0x00C5); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asterisk")); - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with ring above")); - line.push_back(0x00C5); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"asciiTilde")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with tilde")); - line.push_back(0x00C3); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with tilde")); - line.push_back(0x00C3); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciiTilde")); - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with tilde")); - line.push_back(0x00C3); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital A with tilde")); - line.push_back(0x00C3); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"A")); - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital AE ligature")); - line.push_back(0x00C6); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"B")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital B with dot above")); - line.push_back(0x100); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"B")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital B with dot above")); - line.push_back(0x100); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"C")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital C with acute")); - line.push_back(0x106); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"C")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital C with acute")); - line.push_back(0x106); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"C")); - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital C with caron")); - line.push_back(0x010C); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"C")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital C with caron")); - line.push_back(0x010C); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"C")); - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital C with cedilla")); - line.push_back(0x00C7); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"C")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital C with cedilla")); - line.push_back(0x00C7); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"C")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital C with dot above")); - line.push_back(0x010A); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"C")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital C with dot above")); - line.push_back(0x010A); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"D")); - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital D with caron")); - line.push_back(0x010E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"D")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital D with caron")); - line.push_back(0x010E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"D")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital D with dot above")); - line.push_back(0x1E0A); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"D")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital D with dot above")); - line.push_back(0x1E0A); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"D")); - line.push_back(convertNamesToIntegerValue(L"H")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Eth")); - line.push_back(0x00D0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"D")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital D with stroke")); - line.push_back(0x110); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"D")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital D with stroke")); - line.push_back(0x110); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"acute")); - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital E with acute")); - line.push_back(0x00C9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital E with acute")); - line.push_back(0x00C9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"acute")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital E with acute")); - line.push_back(0x00C9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital E with acute")); - line.push_back(0x00C9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital E with caron")); - line.push_back(0x011A); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital E with caron")); - line.push_back(0x011A); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital E with circumflex")); - line.push_back(0x00CA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital E with circumflex")); - line.push_back(0x00CA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital E with circumflex")); - line.push_back(0x00CA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital E with circumflex")); - line.push_back(0x00CA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"diaeresis")); - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital E with diaeresis")); - line.push_back(0x00CB); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital E with diaeresis")); - line.push_back(0x00CB); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"diaeresis")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital E with diaeresis")); - line.push_back(0x00CB); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital E with diaeresis")); - line.push_back(0x00CB); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital E with dot above")); - line.push_back(0x116); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital E with dot above")); - line.push_back(0x116); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"grave")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital E with grave")); - line.push_back(0x00C8); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"grave")); - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital E with grave")); - line.push_back(0x00C8); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital E with macron")); - line.push_back(0x112); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital E with macron")); - line.push_back(0x112); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital E with macron")); - line.push_back(0x112); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital E with macron")); - line.push_back(0x112); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital E with ogonek")); - line.push_back(0x118); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital E with ogonek")); - line.push_back(0x118); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"N")); - line.push_back(convertNamesToIntegerValue(L"G")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital ENG")); - line.push_back(0x014A); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"F")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital F with dot above")); - line.push_back(0x1E1E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"F")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital F with dot above")); - line.push_back(0x1E1E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"breve")); - line.push_back(convertNamesToIntegerValue(L"G")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital G with breve")); - line.push_back(0x011E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"G")); - line.push_back(convertNamesToIntegerValue(L"breve")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital G with breve")); - line.push_back(0x011E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"G")); - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital G with breve")); - line.push_back(0x011E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"G")); - line.push_back(convertNamesToIntegerValue(L"parenleft")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital G with breve")); - line.push_back(0x011E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"parenleft")); - line.push_back(convertNamesToIntegerValue(L"G")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital G with breve")); - line.push_back(0x011E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"G")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital G with cedilla")); - line.push_back(0x122); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"G")); - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital G with cedilla")); - line.push_back(0x122); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"G")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital G with dot above")); - line.push_back(0x120); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"G")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital G with dot above")); - line.push_back(0x120); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"acute")); - line.push_back(convertNamesToIntegerValue(L"I")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital I with acute")); - line.push_back(0x00CD); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"I")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital I with acute")); - line.push_back(0x00CD); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"I")); - line.push_back(convertNamesToIntegerValue(L"acute")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital I with acute")); - line.push_back(0x00CD); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"I")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital I with acute")); - line.push_back(0x00CD); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"I")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital I with circumflex")); - line.push_back(0x00CE); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"I")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital I with circumflex")); - line.push_back(0x00CE); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"I")); - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital I with circumflex")); - line.push_back(0x00CE); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"I")); - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital I with circumflex")); - line.push_back(0x00CE); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"diaeresis")); - line.push_back(convertNamesToIntegerValue(L"I")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital I with diaeresis")); - line.push_back(0x00CF); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"I")); - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital I with diaeresis")); - line.push_back(0x00CF); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"I")); - line.push_back(convertNamesToIntegerValue(L"diaeresis")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital I with diaeresis")); - line.push_back(0x00CF); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"I")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital I with diaeresis")); - line.push_back(0x00CF); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"I")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital I with dot above")); - line.push_back(0x130); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"I")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital I with dot above")); - line.push_back(0x130); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"grave")); - line.push_back(convertNamesToIntegerValue(L"I")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital I with grave")); - line.push_back(0x00CC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"I")); - line.push_back(convertNamesToIntegerValue(L"grave")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital I with grave")); - line.push_back(0x00CC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"I")); - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital I with macron")); - line.push_back(0x012A); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"I")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital I with macron")); - line.push_back(0x012A); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"I")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital I with macron")); - line.push_back(0x012A); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"I")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital I with macron")); - line.push_back(0x012A); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"I")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital I with ogonek")); - line.push_back(0x012E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"I")); - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital I with ogonek")); - line.push_back(0x012E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciiTilde")); - line.push_back(convertNamesToIntegerValue(L"I")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital I with tilde")); - line.push_back(0x128); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"I")); - line.push_back(convertNamesToIntegerValue(L"asciiTilde")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital I with tilde")); - line.push_back(0x128); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"K")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital K with cedilla")); - line.push_back(0x136); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"K")); - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital K with cedilla")); - line.push_back(0x136); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"L")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital L with acute")); - line.push_back(0x139); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"L")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital L with acute")); - line.push_back(0x139); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"L")); - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital L with caron")); - line.push_back(0x013D); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"L")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital L with caron")); - line.push_back(0x013D); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"L")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital L with cedilla")); - line.push_back(0x013B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"L")); - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital L with cedilla")); - line.push_back(0x013B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"L")); - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital L with stroke")); - line.push_back(0x141); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"L")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital L with stroke")); - line.push_back(0x141); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"M")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital M with dot above")); - line.push_back(0x1E40); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"M")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital M with dot above")); - line.push_back(0x1E40); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"N")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital N with acute")); - line.push_back(0x143); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"N")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital N with acute")); - line.push_back(0x143); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"N")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital N with caron")); - line.push_back(0x147); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"N")); - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital N with caron")); - line.push_back(0x147); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"N")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital N with cedilla")); - line.push_back(0x145); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"N")); - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital N with cedilla")); - line.push_back(0x145); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciiTilde")); - line.push_back(convertNamesToIntegerValue(L"N")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital N with tilde")); - line.push_back(0x00D1); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"N")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital N with tilde")); - line.push_back(0x00D1); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"N")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital N with tilde")); - line.push_back(0x00D1); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"N")); - line.push_back(convertNamesToIntegerValue(L"asciiTilde")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital N with tilde")); - line.push_back(0x00D1); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"E")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital ligature OE")); - line.push_back(0x152); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"acute")); - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital O with acute")); - line.push_back(0x00D3); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital O with acute")); - line.push_back(0x00D3); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"acute")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital O with acute")); - line.push_back(0x00D3); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital O with acute")); - line.push_back(0x00D3); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital O with circumflex")); - line.push_back(0x00D4); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital O with circumflex")); - line.push_back(0x00D4); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital O with circumflex")); - line.push_back(0x00D4); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital O with circumflex")); - line.push_back(0x00D4); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"diaeresis")); - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital O with diaeresis")); - line.push_back(0x00D6); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"diaeresis")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital O with diaeresis")); - line.push_back(0x00D6); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital O with diaeresis")); - line.push_back(0x00D6); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital O with diaeresis")); - line.push_back(0x00D6); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"grave")); - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital O with grave")); - line.push_back(0x00D2); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"grave")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital O with grave")); - line.push_back(0x00D2); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital O with stroke")); - line.push_back(0x00D8); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital O with stroke")); - line.push_back(0x00D8); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciiTilde")); - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital O with tilde")); - line.push_back(0x00D5); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital O with tilde")); - line.push_back(0x00D5); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital O with tilde")); - line.push_back(0x00D5); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"O")); - line.push_back(convertNamesToIntegerValue(L"asciiTilde")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital O with tilde")); - line.push_back(0x00D5); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"P")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital P with dot above")); - line.push_back(0x1E56); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"P")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital P with dot above")); - line.push_back(0x1E56); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"R")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital R with acute")); - line.push_back(0x154); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"R")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital R with acute")); - line.push_back(0x154); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"R")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital R with caron")); - line.push_back(0x158); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"R")); - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital R with caron")); - line.push_back(0x158); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"R")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital R with cedilla")); - line.push_back(0x156); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"R")); - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital R with cedilla")); - line.push_back(0x156); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"S")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital S with acute")); - line.push_back(0x015A); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"S")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital S with acute")); - line.push_back(0x015A); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"S")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital S with caron")); - line.push_back(0x160); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"S")); - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital S with caron")); - line.push_back(0x160); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"cedilla")); - line.push_back(convertNamesToIntegerValue(L"S")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital S with cedilla")); - line.push_back(0x015E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"S")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital S with cedilla")); - line.push_back(0x015E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"S")); - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital S with cedilla")); - line.push_back(0x015E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"S")); - line.push_back(convertNamesToIntegerValue(L"cedilla")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital S with cedilla")); - line.push_back(0x015E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"S")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital S with dot above")); - line.push_back(0x1E60); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"S")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital S with dot above")); - line.push_back(0x1E60); - dk_ComposeTable.push_back(line); - line.clear(); - - - - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"T")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital T with caron")); - line.push_back(0x164); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"T")); - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital T with caron")); - line.push_back(0x164); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"T")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital T with dot above")); - line.push_back(0x1E6A); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"T")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital T with dot above")); - line.push_back(0x1E6A); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"T")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital T with stroke")); - line.push_back(0x166); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"T")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital T with stroke")); - line.push_back(0x166); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"T")); - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital T with stroke")); - line.push_back(0x166); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"T")); - line.push_back(convertNamesToIntegerValue(L"H")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital THORN")); - line.push_back(0x00DE); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"acute")); - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital U with acute")); - line.push_back(0x00DA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital U with acute")); - line.push_back(0x00DA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"acute")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital U with acute")); - line.push_back(0x00DA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital U with acute")); - line.push_back(0x00DA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital U with circumflex")); - line.push_back(0x00DB); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital U with circumflex")); - line.push_back(0x00DB); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital U with circumflex")); - line.push_back(0x00DB); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital U with circumflex")); - line.push_back(0x00DB); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"diaeresis")); - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital U with diaeresis")); - line.push_back(0x00DC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital U with diaeresis")); - line.push_back(0x00DC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"diaeresis")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital U with diaeresis")); - line.push_back(0x00DC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital U with diaeresis")); - line.push_back(0x00DC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"grave")); - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital U with grave")); - line.push_back(0x00D9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"grave")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital U with grave")); - line.push_back(0x00D9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital U with macron")); - line.push_back(0x016A); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital U with macron")); - line.push_back(0x016B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital U with macron")); - line.push_back(0x016B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital U with macron")); - line.push_back(0x016A); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital U with ogonek")); - line.push_back(0x172); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital U with ogonek")); - line.push_back(0x172); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asterisk")); - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital U with ring above")); - line.push_back(0x016E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"asterisk")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital U with ring above")); - line.push_back(0x016E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciiTilde")); - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital U with tilde")); - line.push_back(0x168); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"asciiTilde")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital U with tilde")); - line.push_back(0x168); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"W")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital W with circumflex")); - line.push_back(0x174); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"W")); - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital W with circumflex")); - line.push_back(0x174); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"acute")); - line.push_back(convertNamesToIntegerValue(L"Y")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Y with acute")); - line.push_back(0x00DD); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"Y")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Y with acute")); - line.push_back(0x00DD); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Y")); - line.push_back(convertNamesToIntegerValue(L"acute")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Y with acute")); - line.push_back(0x00DD); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Y")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Y with acute")); - line.push_back(0x00DD); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"Y")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Y with circumflex")); - line.push_back(0x176); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Y")); - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Y with circumflex")); - line.push_back(0x176); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"diaeresis")); - line.push_back(convertNamesToIntegerValue(L"Y")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Y with diaeresis")); - line.push_back(0x178); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"Y")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Y with diaeresis")); - line.push_back(0x178); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Y")); - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Y with diaeresis")); - line.push_back(0x178); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Y")); - line.push_back(convertNamesToIntegerValue(L"diaeresis")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Y with diaeresis")); - line.push_back(0x178); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"Z")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Z with acute")); - line.push_back(0x179); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Z")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Z with acute")); - line.push_back(0x179); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"Z")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Z with caron")); - line.push_back(0x017D); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"v")); - line.push_back(convertNamesToIntegerValue(L"Z")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Z with caron")); - line.push_back(0x017D); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Z")); - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Z with caron")); - line.push_back(0x017D); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"Z")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Z with dot above")); - line.push_back(0x017B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Z")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Z with dot above")); - line.push_back(0x017B); - dk_ComposeTable.push_back(line); - line.clear(); - - // Latin minuscule - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with acute")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"acute")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with acute")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"acute")); - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with acute")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with acute")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"parenleft")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with breve")); - line.push_back(0x103); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"parenleft")); - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with breve")); - line.push_back(0x103); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with circumflex")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with circumflex")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with circumflex")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with circumflex")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"diaeresis")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with diaeresis")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with diaeresis")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"diaeresis")); - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with diaeresis")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with diaeresis")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"grave")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with grave")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"grave")); - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with grave")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with ogonek")); - line.push_back(0x105); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with ogonek")); - line.push_back(0x105); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"asterisk")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with ring above")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with ring above")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asterisk")); - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with ring above")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"asciiTilde")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with tilde")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with tilde")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciiTilde")); - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with tilde")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small A with tilde")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"a")); - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small AE ligature")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"b")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small B with dot above")); - line.push_back(0x1000); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"b")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small B with dot above")); - line.push_back(0x1000); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"c")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small C with acute")); - line.push_back(0x107); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"c")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small C with acute")); - line.push_back(0x107); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"c")); - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small C with caron")); - line.push_back(0x010D); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"c")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small C with caron")); - line.push_back(0x010D); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"c")); - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small C with cedilla")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"c")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small C with cedilla")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"c")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small C with dot above")); - line.push_back(0x010B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"c")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small C with dot above")); - line.push_back(0x010B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"d")); - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small D with caron")); - line.push_back(0x010F); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"d")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small D with caron")); - line.push_back(0x010F); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"d")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small D with dot above")); - line.push_back(0x1E0B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"d")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small D with dot above")); - line.push_back(0x1E0B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"d")); - line.push_back(convertNamesToIntegerValue(L"h")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Eth")); - line.push_back(0x00F0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"d")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small D with stroke")); - line.push_back(0x111); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"d")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small D with stroke")); - line.push_back(0x111); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"i")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small dotless I")); - line.push_back(0x131); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"i")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small dotless I")); - line.push_back(0x131); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"acute")); - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small E with acute")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small E with acute")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"acute")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small E with acute")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small E with acute")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small E with caron")); - line.push_back(0x011B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small E with caron")); - line.push_back(0x011B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small E with circumflex")); - line.push_back(0x00EA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small E with circumflex")); - line.push_back(0x00EA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small E with circumflex")); - line.push_back(0x00EA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small E with circumflex")); - line.push_back(0x00EA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"diaeresis")); - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small E with diaeresis")); - line.push_back(0x00EB); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"diaeresis")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small E with diaeresis")); - line.push_back(0x00EB); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small E with diaeresis")); - line.push_back(0x00EB); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small E with diaeresis")); - line.push_back(0x00EB); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small E with dot above")); - line.push_back(0x117); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small E with dot above")); - line.push_back(0x117); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"grave")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small E with grave")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"grave")); - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small E with grave")); - line.push_back(0x0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small E with macron")); - line.push_back(0x113); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small E with macron")); - line.push_back(0x113); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small E with macron")); - line.push_back(0x113); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small E with macron")); - line.push_back(0x113); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small E with ogonek")); - line.push_back(0x119); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small E with ogonek")); - line.push_back(0x119); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"n")); - line.push_back(convertNamesToIntegerValue(L"g")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small ENG")); - line.push_back(0x014B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"f")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small F with dot above")); - line.push_back(0x1E1F); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"f")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small F with dot above")); - line.push_back(0x1E1F); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"breve")); - line.push_back(convertNamesToIntegerValue(L"g")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small G with breve")); - line.push_back(0x011F); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"g")); - line.push_back(convertNamesToIntegerValue(L"breve")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small G with breve")); - line.push_back(0x011F); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"g")); - line.push_back(convertNamesToIntegerValue(L"parenleft")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small G with breve")); - line.push_back(0x011F); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"g")); - line.push_back(convertNamesToIntegerValue(L"U")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small G with breve")); - line.push_back(0x011F); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"parenleft")); - line.push_back(convertNamesToIntegerValue(L"g")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small G with breve")); - line.push_back(0x011F); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"g")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small G with cedilla")); - line.push_back(0x123); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"g")); - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small G with cedilla")); - line.push_back(0x123); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"g")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small G with dot above")); - line.push_back(0x121); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"g")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small G with dot above")); - line.push_back(0x121); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"acute")); - line.push_back(convertNamesToIntegerValue(L"i")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small I with acute")); - line.push_back(0x00ED); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"i")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small I with acute")); - line.push_back(0x00ED); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"i")); - line.push_back(convertNamesToIntegerValue(L"acute")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small I with acute")); - line.push_back(0x00ED); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"i")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small I with acute")); - line.push_back(0x00ED); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"i")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small I with circumflex")); - line.push_back(0x00EE); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"i")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small I with circumflex")); - line.push_back(0x00EE); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"i")); - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small I with circumflex")); - line.push_back(0x00EE); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"i")); - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small I with circumflex")); - line.push_back(0x00EE); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"diaeresis")); - line.push_back(convertNamesToIntegerValue(L"i")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small I with diaeresis")); - line.push_back(0x00EF); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"i")); - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small I with diaeresis")); - line.push_back(0x00EF); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"i")); - line.push_back(convertNamesToIntegerValue(L"diaeresis")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small I with diaeresis")); - line.push_back(0x00EF); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"i")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small I with diaeresis")); - line.push_back(0x00EF); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"grave")); - line.push_back(convertNamesToIntegerValue(L"i")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small I with grave")); - line.push_back(0x00EC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"i")); - line.push_back(convertNamesToIntegerValue(L"grave")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small I with grave")); - line.push_back(0x00EC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"i")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small I with macron")); - line.push_back(0x012B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"i")); - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small I with macron")); - line.push_back(0x012B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"i")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small I with macron")); - line.push_back(0x012B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"i")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small I with macron")); - line.push_back(0x012B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"i")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small I with ogonek")); - line.push_back(0x012F); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"i")); - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small I with ogonek")); - line.push_back(0x012F); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciiTilde")); - line.push_back(convertNamesToIntegerValue(L"i")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small I with tilde")); - line.push_back(0x129); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"i")); - line.push_back(convertNamesToIntegerValue(L"asciiTilde")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small I with tilde")); - line.push_back(0x129); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"k")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small K with cedilla")); - line.push_back(0x137); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"k")); - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small K with cedilla")); - line.push_back(0x137); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"k")); - line.push_back(convertNamesToIntegerValue(L"k")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small KRA")); - line.push_back(0x138); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"l")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small L with acute")); - line.push_back(0x013A); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"l")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small L with acute")); - line.push_back(0x013A); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"l")); - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small L with caron")); - line.push_back(0x013E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"l")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small L with caron")); - line.push_back(0x013E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"l")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small L with cedilla")); - line.push_back(0x013C); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"l")); - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small L with cedilla")); - line.push_back(0x013C); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"l")); - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small L with stroke")); - line.push_back(0x142); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"l")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small L with stroke")); - line.push_back(0x142); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"e")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small ligature OE")); - line.push_back(0x153); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"m")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small M with dot above")); - line.push_back(0x1E41); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"m")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small M with dot above")); - line.push_back(0x1E41); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"n")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small N with acute")); - line.push_back(0x144); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"n")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small N with acute")); - line.push_back(0x144); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"n")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small N with caron")); - line.push_back(0x148); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"n")); - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small N with caron")); - line.push_back(0x148); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"n")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small N with cedilla")); - line.push_back(0x146); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"n")); - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small N with cedilla")); - line.push_back(0x146); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciiTilde")); - line.push_back(convertNamesToIntegerValue(L"n")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small N with tilde")); - line.push_back(0x00F1); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"n")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small N with tilde")); - line.push_back(0x00F1); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"n")); - line.push_back(convertNamesToIntegerValue(L"asciiTilde")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small N with tilde")); - line.push_back(0x00F1); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"n")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small N with tilde")); - line.push_back(0x00F1); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"acute")); - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small O with acute")); - line.push_back(0x00F3); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small O with acute")); - line.push_back(0x00F3); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"acute")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small O with acute")); - line.push_back(0x00F3); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small O with acute")); - line.push_back(0x00F3); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small O with circumflex")); - line.push_back(0x00F4); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small O with circumflex")); - line.push_back(0x00F4); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small O with circumflex")); - line.push_back(0x00F4); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small O with circumflex")); - line.push_back(0x00F4); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"diaeresis")); - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small O with diaeresis")); - line.push_back(0x00F6); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"diaeresis")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small O with diaeresis")); - line.push_back(0x00F6); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small O with diaeresis")); - line.push_back(0x00F6); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small O with diaeresis")); - line.push_back(0x00F6); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"grave")); - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small O with grave")); - line.push_back(0x00F2); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"grave")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small O with grave")); - line.push_back(0x00F2); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small O with stroke")); - line.push_back(0x00F8); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small O with stroke")); - line.push_back(0x00F8); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciiTilde")); - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small O with tilde")); - line.push_back(0x00F5); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small O with tilde")); - line.push_back(0x00F5); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small O with tilde")); - line.push_back(0x00F5); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"o")); - line.push_back(convertNamesToIntegerValue(L"asciiTilde")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small O with tilde")); - line.push_back(0x00F5); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"p")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small P with dot above")); - line.push_back(0x1E57); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"p")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small P with dot above")); - line.push_back(0x1E57); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"r")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small R with acute")); - line.push_back(0x155); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"r")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small R with acute")); - line.push_back(0x155); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"r")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small R with caron")); - line.push_back(0x159); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"r")); - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small R with caron")); - line.push_back(0x159); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"r")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small R with cedilla")); - line.push_back(0x157); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"r")); - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small R with cedilla")); - line.push_back(0x157); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small S with acute")); - line.push_back(0x015B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small S with acute")); - line.push_back(0x015B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small S with caron")); - line.push_back(0x161); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small S with caron")); - line.push_back(0x161); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"cedilla")); - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small S with cedilla")); - line.push_back(0x015F); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small S with cedilla")); - line.push_back(0x015F); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small S with cedilla")); - line.push_back(0x015F); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"cedilla")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small S with cedilla")); - line.push_back(0x015F); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small S with dot above")); - line.push_back(0x1E61); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small S with dot above")); - line.push_back(0x1E61); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"s")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small SHARP S")); - line.push_back(0x00DF); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"t")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small T with caron")); - line.push_back(0x165); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"t")); - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small T with caron")); - line.push_back(0x165); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"t")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small T with dot above")); - line.push_back(0x1E6B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"t")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small T with dot above")); - line.push_back(0x1E6B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"t")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small T with stroke")); - line.push_back(0x167); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"t")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small T with stroke")); - line.push_back(0x167); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"t")); - line.push_back(convertNamesToIntegerValue(L"slash")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small T with stroke")); - line.push_back(0x167); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"t")); - line.push_back(convertNamesToIntegerValue(L"h")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small THORN")); - line.push_back(0x00FE); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"acute")); - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with acute")); - line.push_back(0x00FA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with acute")); - line.push_back(0x00FA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with acute")); - line.push_back(0x00FA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"acute")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with acute")); - line.push_back(0x00FA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with caron")); - line.push_back(0x01D4); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with circumflex")); - line.push_back(0x00FB); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with circumflex")); - line.push_back(0x00FB); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with circumflex")); - line.push_back(0x00FB); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"greater")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with circumflex")); - line.push_back(0x00FB); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"diaeresis")); - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with diaeresis")); - line.push_back(0x00FC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with diaeresis")); - line.push_back(0x00FC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"diaeresis")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with diaeresis")); - line.push_back(0x00FC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with diaeresis")); - line.push_back(0x00FC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"grave")); - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with grave")); - line.push_back(0x00F9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"grave")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with grave")); - line.push_back(0x00F9); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with macron")); - line.push_back(0x016B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"minus")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with macron")); - line.push_back(0x016B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with macron")); - line.push_back(0x016B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"underscore")); - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with macron")); - line.push_back(0x016B); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with ogonek")); - line.push_back(0x173); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"comma")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with ogonek")); - line.push_back(0x173); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asterisk")); - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with ring above")); - line.push_back(0x016F); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"asterisk")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with ring above")); - line.push_back(0x016F); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciiTilde")); - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with tilde")); - line.push_back(0x169); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"u")); - line.push_back(convertNamesToIntegerValue(L"asciiTilde")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small U with tilde")); - line.push_back(0x169); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"w")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small W with circumflex")); - line.push_back(0x175); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"w")); - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small W with circumflex")); - line.push_back(0x175); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"acute")); - line.push_back(convertNamesToIntegerValue(L"y")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Y with acute")); - line.push_back(0x00FD); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"y")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Y with acute")); - line.push_back(0x00FD); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"y")); - line.push_back(convertNamesToIntegerValue(L"acute")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Y with acute")); - line.push_back(0x00FD); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"y")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Y with acute")); - line.push_back(0x00FD); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"y")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Y with circumflex")); - line.push_back(0x177); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"y")); - line.push_back(convertNamesToIntegerValue(L"asciicircum")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Y with circumflex")); - line.push_back(0x177); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"diaeresis")); - line.push_back(convertNamesToIntegerValue(L"y")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Y with diaeresis")); - line.push_back(0x00FF); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"y")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Y with diaeresis")); - line.push_back(0x00FF); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"y")); - line.push_back(convertNamesToIntegerValue(L"diaeresis")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Y with diaeresis")); - line.push_back(0x00FF); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"y")); - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Y with diaeresis")); - line.push_back(0x00FF); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"z")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Z with acute")); - line.push_back(0x017A); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"z")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Z with acute")); - line.push_back(0x017A); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"z")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Z with caron")); - line.push_back(0x017E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"v")); - line.push_back(convertNamesToIntegerValue(L"z")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Z with caron")); - line.push_back(0x017E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"z")); - line.push_back(convertNamesToIntegerValue(L"less")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Z with caron")); - line.push_back(0x017E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"z")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Z with dot above")); - line.push_back(0x017C); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"z")); - line.push_back(convertNamesToIntegerValue(L"period")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Z with dot above")); - line.push_back(0x017C); - dk_ComposeTable.push_back(line); - line.clear(); - - // Greek - /*line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"space")); - line.push_back(convertNamesToIntegerValue(L"dialytika tonos")); - line.push_back(0x385); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"space")); - line.push_back(convertNamesToIntegerValue(L"dialytika tonos")); - line.push_back(0x385); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"Greek_Alpha")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Alpha with tonos")); - line.push_back(0x386); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Greek_Alpha")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Alpha with tonos")); - line.push_back(0x386); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"Greek_Epsilon")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Epsilon with tonos")); - line.push_back(0x388); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Greek_Epsilon")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Epsilon with tonos")); - line.push_back(0x388); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"Greek_Eta")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Eta with tonos")); - line.push_back(0x389); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Greek_Eta")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Eta with tonos")); - line.push_back(0x389); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Greek_Iota")); - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Iota with dialytika")); - line.push_back(0x03AA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"Greek_Iota")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Iota with dialytika")); - line.push_back(0x03AA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"Greek_Iota")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Iota with tonos")); - line.push_back(0x038A); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Greek_Iota")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Iota with tonos")); - line.push_back(0x038A); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"Greek_Omicron")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Omicron with tonos")); - line.push_back(0x038C); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Greek_Omicron")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Omicron with tonos")); - line.push_back(0x038C); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Greek_Upsilon")); - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Upsilon with dialytika")); - line.push_back(0x03AB); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"Greek_Upsilon")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Upsilon with dialytika")); - line.push_back(0x03AB); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"Greek_Upsilon")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Upsilon with tonos")); - line.push_back(0x038E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Greek_Upsilon")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Upsilon with tonos")); - line.push_back(0x038E); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"Greek_Omega")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Omega with tonos")); - line.push_back(0x038F); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Greek_Omega")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"capital Omega with tonos")); - line.push_back(0x038F); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"Greek_Alpha")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Alpha with tonos")); - line.push_back(0x03AC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Greek_Alpha")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Alpha with tonos")); - line.push_back(0x03AC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"Greek_Epsilon")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Epsilon with tonos")); - line.push_back(0x03AD); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Greek_Epsilon")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Epsilon with tonos")); - line.push_back(0x03AD); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"Greek_eta")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Eta with tonos")); - line.push_back(0x03AE); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Greek_eta")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Eta with tonos")); - line.push_back(0x03AE); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"Greek_iota")); - line.push_back(convertNamesToIntegerValue(L"small Iota with dialytika and tonos")); - line.push_back(0x390); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"Greek_iota")); - line.push_back(convertNamesToIntegerValue(L"small Iota with dialytika and tonos")); - line.push_back(0x390); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Greek_iota")); - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Iota with dialytika")); - line.push_back(0x03CA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"Greek_iota")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Iota with dialytika")); - line.push_back(0x03CA); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"Greek_iota")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Iota with tonos")); - line.push_back(0x03AF); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Greek_iota")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Iota with tonos")); - line.push_back(0x03AF); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"Greek_oMicron")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Omicron with tonos")); - line.push_back(0x03CC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Greek_Omicron")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Omicron with tonos")); - line.push_back(0x03CC); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"Greek_upsilon")); - line.push_back(convertNamesToIntegerValue(L"small Upsilon with dialytika and tonos")); - line.push_back(0x03B0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"Greek_upsilon")); - line.push_back(convertNamesToIntegerValue(L"small Upsilon with dialytika and tonos")); - line.push_back(0x03B0); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Greek_upsilon")); - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Upsilon with dialytika")); - line.push_back(0x03CB); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"quotedbl")); - line.push_back(convertNamesToIntegerValue(L"Greek_upsilon")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Upsilon with dialytika")); - line.push_back(0x03CB); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"Greek_upsilon")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Upsilon with tonos")); - line.push_back(0x03CD); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Greek_upsilon")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Upsilon with tonos")); - line.push_back(0x03CD); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"Greek_omega")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Omega with tonos")); - line.push_back(0x03CE); - dk_ComposeTable.push_back(line); - line.clear(); - - line.push_back(convertNamesToIntegerValue(L"Greek_omega")); - line.push_back(convertNamesToIntegerValue(L"apostrophe")); - line.push_back(convertNamesToIntegerValue(L"")); - line.push_back(convertNamesToIntegerValue(L"small Omega with tonos")); - line.push_back(0x03CE); - dk_ComposeTable.push_back(line); - line.clear();*/ - - return 0; +// _S2 do I need the names somewhere??? +v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult) { + v_dw_1D line; + line.push_back(convertNamesToIntegerValue(first)); + line.push_back(convertNamesToIntegerValue(second)); + //line.push_back(convertNamesToIntegerValue(nameresult)); + line.push_back(number); + return line; } - -KMX_DWORD find_ComposedCharacter(v_dw_2D * p_dk_ComposeTable, KMX_DWORD first, KMX_DWORD second , KMX_DWORD third ) { - +KMX_DWORD find_dk_Character(v_dw_2D * p_dk_ComposeTable, KMX_DWORD first, KMX_DWORD second ) { v_dw_2D dk_ComposeTable = * p_dk_ComposeTable; - for ( int i =0; i< (dk_ComposeTable).size()-1; i++) { - if (( (KMX_DWORD) dk_ComposeTable[i][0] == first) && ( (KMX_DWORD) dk_ComposeTable[i][1] == second) && ( (KMX_DWORD) dk_ComposeTable[i][2] == third) ) - return (KMX_DWORD) dk_ComposeTable[i][4]; + if (( (KMX_DWORD) dk_ComposeTable[i][0] == first) && ( (KMX_DWORD) dk_ComposeTable[i][1] == second) ) + return (KMX_DWORD) dk_ComposeTable[i][3]; } return 0; // _S2 what to return if not found? } +void find_all_dk_combinations(v_dw_2D * p_dk_ComposeTable, v_dw_2D &dk_CombinationTable, KMX_DWORD dk) { + v_dw_2D dk_ComposeTable = * p_dk_ComposeTable; + v_dw_1D line; + for ( int i =0; i< (dk_ComposeTable).size()-1; i++) { + if ( dk_ComposeTable[i][0] == dk) { + line.push_back(dk_ComposeTable[i][0]); + line.push_back(dk_ComposeTable[i][1]); + line.push_back(dk_ComposeTable[i][2]); + dk_CombinationTable.push_back(line); + line.clear(); + } + } +} + +// _S2 quick&dirty needs to be changed !! +KMX_DWORD getKeyname(KMX_DWORD in, KMX_DWORD &shift) { + if ( (in >=65) && (in <= 90)) { + shift=1; + return in; + } + else { + shift=0; + return (in-32); + } +} + +KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable){ + + // values taken from: https://help.ubuntu.com/community/GtkDeadKeyTable#Latin + //dk_ComposeTable[i][0] : First + //dk_ComposeTable[i][1] : Second + //dk_ComposeTable[i][3] : Unicode-Value + //dk_ComposeTable[i][4] : Character + + v_dw_1D line; + + line = createLine(L"dead_grave", L"A", 0x00C0, L"capital A with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_grave", L"E", 0x00C8, L"capital E with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_grave", L"I", 0x00CC, L"capital I with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_grave", L"O", 0x00D2, L"capital O with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_grave", L"U", 0x00D9, L"capital U with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_grave", L"a", 0x00E0, L"small A with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_grave", L"e", 0x00E8, L"small E with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_grave", L"i", 0x00EC, L"small I with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_grave", L"o", 0x00F2, L"small O with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_grave", L"u", 0x00F9, L"small U with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"A", 0x00C1, L"capital A with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"C", 0x0106, L"capital C with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"E", 0x00C9, L"capital E with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"I", 0x00CD, L"capital I with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"L", 0x0139, L"capital L with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"N", 0x0143, L"capital N with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"O", 0x00D3, L"capital O with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"R", 0x0154, L"capital R with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"S", 0x015A, L"capital S with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"U", 0x00DA, L"capital U with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"Y", 0x00DD, L"capital Y with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"Z", 0x0179, L"capital Z with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"a", 0x00E1, L"small A with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"c", 0x0107, L"small C with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"e", 0x00E9, L"small E with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"i", 0x00ED, L"small I with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"l", 0x013A, L"small L with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"n", 0x0144, L"small N with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"o", 0x00F3, L"small O with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"r", 0x0155, L"small R with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"s", 0x015B, L"small S with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"u", 0x00FA, L"small U with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"y", 0x00FD, L"small Y with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"z", 0x017A, L"small Z with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_circumflex", L"A", 0x00C2, L"capital A with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_circumflex", L"E", 0x00CA, L"capital E with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_circumflex", L"I", 0x00CE, L"capital I with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_circumflex", L"O", 0x00D4, L"capital O with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_circumflex", L"U", 0x00DB, L"capital U with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_circumflex", L"a", 0x00E2, L"small A with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_circumflex", L"e", 0x00EA, L"small E with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_circumflex", L"i", 0x00EE, L"small I with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_circumflex", L"o", 0x00F4, L"small O with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_circumflex", L"u", 0x00FB, L"small U with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_tilde", L"A", 0x00C3, L"capital A with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_tilde", L"I", 0x0128, L"capital I with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_tilde", L"N", 0x00D1, L"capital N with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_tilde", L"O", 0x00D5, L"capital O with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_tilde", L"U", 0x0168, L"capital U with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_tilde", L"a", 0x00E3, L"small A with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_tilde", L"i", 0x0129, L"small I with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_tilde", L"n", 0x00F1, L"small N with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_tilde", L"o", 0x00F5, L"small O with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_tilde", L"u", 0x0169, L"small U with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_macron", L"A", 0x0100, L"capital A with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_macron", L"E", 0x0112, L"capital E with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_macron", L"I", 0x012A, L"capital I with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_macron", L"O", 0x014C, L"capital O with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_macron", L"U", 0x016A, L"capital U with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_macron", L"a", 0x0101, L"small A with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_macron", L"e", 0x0113, L"small E with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_macron", L"i", 0x012B, L"small I with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_macron", L"o", 0x014D, L"small O with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_macron", L"u", 0x016B, L"small U with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_breve", L"A", 0x0102, L"capital A with breve"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_breve", L"G", 0x011E, L"capital G with breve"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_breve", L"a", 0x0103, L"small A with breve"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_breve", L"g", 0x011F, L"small G with breve"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_abovedot", L"E", 0x0116, L"capital E with dot above"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_abovedot", L"I", 0x0130, L"capital I with dot above"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_abovedot", L"Z", 0x017B, L"capital Z with dot above"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_abovedot", L"e", 0x0117, L"small E with dot above"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_abovedot", L"i", 0x0131, L"small DOTLESS_I"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_abovedot", L"z", 0x017C, L"small Z with dot above"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_diaeresis", L"A", 0x00C4, L"capital A with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_diaeresis", L"E", 0x00CB, L"capital E with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_diaeresis", L"I", 0x00CF, L"capital I with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_diaeresis", L"O", 0x00D6, L"capital O with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_diaeresis", L"U", 0x00DC, L"capital U with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_diaeresis", L"Y", 0x0178, L"capital Y with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_diaeresis", L"a", 0x00E4, L"small A with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_diaeresis", L"e", 0x00EB, L"small E with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_diaeresis", L"i", 0x00EF, L"small I with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_diaeresis", L"o", 0x00F6, L"small O with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_diaeresis", L"u", 0x00FC, L"small U with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_diaeresis", L"y", 0x00FF, L"small Y with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_abovering", L"A", 0x00C5, L"capital A with ring above"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_abovering", L"U", 0x016E, L"capital U with ring above"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_abovering", L"a", 0x00E5, L"small A with ring above"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_abovering", L"u", 0x016F, L"small U with ring above"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_doubleacute", L"O", 0x0150, L"capital O with double acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_doubleacute", L"U", 0x0170, L"capital U with double acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_doubleacute", L"o", 0x0151, L"small O with double acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_doubleacute", L"u", 0x0171, L"small U with double acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"C", 0x010C, L"capital C with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"D", 0x010E, L"capital D with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"E", 0x011A, L"capital E with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"L", 0x013D, L"capital L with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"N", 0x0147, L"capital N with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"R", 0x0158, L"capital R with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"S", 0x0160, L"capital S with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"T", 0x0164, L"capital T with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"Z", 0x017D, L"capital Z with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"c", 0x010D, L"small C with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"d", 0x010F, L"small D with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"e", 0x011B, L"small E with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"l", 0x013E, L"small L with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"n", 0x0148, L"small N with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"r", 0x0159, L"small R with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"s", 0x0161, L"small S with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"t", 0x0165, L"small T with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"z", 0x017E, L"small Z with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"C", 0x00C7, L"capital C with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"G", 0x0122, L"capital G with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"K", 0x0136, L"capital K with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"L", 0x013B, L"capital L with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"N", 0x0145, L"capital N with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"R", 0x0156, L"capital R with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"S", 0x015E, L"capital S with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"c", 0x00E7, L"small C with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"g", 0x0123, L"small G with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"k", 0x0137, L"small K with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"l", 0x013C, L"small L with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"n", 0x0146, L"small N with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"r", 0x0157, L"small R with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"s", 0x015F, L"small S with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_ogonek", L"A", 0x0104, L"capital A with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_ogonek", L"E", 0x0118, L"capital E with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_ogonek", L"I", 0x012E, L"capital I with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_ogonek", L"U", 0x0172, L"capital U with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_ogonek", L"a", 0x0105, L"small A with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_ogonek", L"e", 0x0119, L"small E with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_ogonek", L"i", 0x012F, L"small I with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_ogonek", L"u", 0x0173, L"small U with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + + + + line = createLine(L"dead_breve", L"space", 0x02D8, L"BREVE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_breve", L"dead_breve", 0x02D8, L"BREVE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_abovedot", L"space", 0x02D9, L"DOT_ABOVE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_abovedot", L"abovedot", 0x02D9, L"DOT_ABOVE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_abovedot", L"dead_abovedot", 0x02D9, L"DOT_ABOVE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_abovering", L"dead_abovering", 0x02DA, L"RING_ABOVE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_abovering", L"space", 0x02DA, L"RING_ABOVE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"space", 0x0027, L"APOSTROPHE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"apostrophe", 0x00B4, L"ACUTE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"acute", 0x00B4, L"ACUTE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"dead_acute", 0x00B4, L"ACUTE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_doubleacute", L"space", 0x02DD, L"DOUBLE_ACUTE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_doubleacute", L"dead_doubleacute", 0x02DD, L"DOUBLE_ACUTE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"space", 0x02C7, L"CARON"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"caron", 0x02C7, L"CARON"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"dead_caron", 0x02C7, L"CARON"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"space", 0x00B8, L"CEDILLA"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"comma", 0x00B8, L"CEDILLA"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"cedilla", 0x00B8, L"CEDILLA"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"dead_cedilla", 0x00B8, L"CEDILLA"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_circumflex", L"space", 0x005E, L"CIRCUMFLEX_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_circumflex", L"minus", 0x00AF, L"MACRON"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_circumflex", L"asciicircum", 0x005E, L"CIRCUMFLEX_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_circumflex", L"underscore", 0x00AF, L"MACRON"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_circumflex", L"dead_circumflex", 0x005E, L"CIRCUMFLEX_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_diaeresis", L"quotedbl", 0x00A8, L"DIAERESIS"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_diaeresis", L"diaeresis", 0x00A8, L"DIAERESIS"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_diaeresis", L"dead_diaeresis", 0x00A8, L"DIAERESIS"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_grave", L"space", 0x0060, L"GRAVE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_grave", L"grave", 0x0060, L"GRAVE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_grave", L"dead_grave", 0x0060, L"GRAVE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_macron", L"macron", 0x00AF, L"MACRON"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_macron", L"dead_macron", 0x00AF, L"MACRON"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_ogonek", L"space", 0x02DB, L"OGONEK"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_ogonek", L"ogonek", 0x02DB, L"OGONEK"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_ogonek", L"dead_ogonek", 0x02DB, L"OGONEK"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_tilde", L"space", 0x007E, L"TILDE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_tilde", L"asciitilde", 0x007E, L"TILDE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_tilde", L"dead_tilde", 0x007E, L"TILDE"); + dk_ComposeTable.push_back(line); line.clear(); + + return 0; +} + + + diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index 7c6d2f034e..cf27e7ed70 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -1,15 +1,16 @@ -// In ths program we use a 3D-Vector Vector[language][Keys][Shiftstates] + #pragma once #ifndef DEADKEY_H #define DEADKEY_H -#include -#include -#include #include -int createDK_ComposeTable(v_dw_2D & dk_ComposeTable); +v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult); +KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable); -KMX_DWORD find_ComposedCharacter(v_dw_2D * dk_ComposeTable, KMX_DWORD first, KMX_DWORD second , KMX_DWORD third = 0 ); +KMX_DWORD find_dkCharacter(v_dw_2D * dk_ComposeTable, KMX_DWORD first, KMX_DWORD second ); + +void find_all_dk_combinations(v_dw_2D * dk_ComposeTable, v_dw_2D & dk_CombinationTable, KMX_DWORD dk); +KMX_DWORD getKeyname(KMX_DWORD in, KMX_DWORD &shift) ; # endif /*DEADKEY_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 08f2a3a6c7..ba20d76e1a 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -57,8 +57,6 @@ void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT int KMX_GetDeadkeys(KMX_WORD DeadKey, KMX_WORD *OutputPairs) ; -int KMX_GetDeadkeys_NT(KMX_WORD DeadKey, KMX_WORD *OutputPairs); // returns array of [USVK, ch] pairs -int KMX_GetDeadkeys_NT_x64(KMX_WORD DeadKey, KMX_WORD *OutputPairs); // returns array of [USVK, ch] pairs void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift); @@ -403,7 +401,7 @@ KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { return s_dkids[s_ndkids++].dst_deadkey = s_next_dkid = ++dkid; } -void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR deadkey) { +void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR deadkey, GdkKeymap * keymap) { KMX_WORD deadkeys[512], *pdk; // Lookup the deadkey table for the deadkey in the physical keyboard @@ -421,7 +419,7 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR d while(*pdk) { // Look up the ch // _S2 the new function returns KMX_DWORD - UINT vkUnderlying = KMX_VKUnderlyingLayoutToVKUS_S2(*pdk); // _S2 Conversion medium use my gdk-funct + UINT vkUnderlying = KMX_VKUnderlyingLayoutToVKUS_GDK(keymap, *pdk); // _S2 Conversion medium use my gdk-funct KMX_TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); // _S2 OK Conversion easy - should work right away pdk+=3; } @@ -478,7 +476,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon // create dk_createDK_ComposeTable v_dw_2D dk_ComposeTable; - if(createDK_ComposeTable(dk_ComposeTable)){ + if(create_DKTable(dk_ComposeTable)){ wprintf(L"ERROR: can't create dk_ComposeTable\n"); return FALSE; } @@ -508,7 +506,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon //wprintf(L" switch with ch: %i (%c)......\n" , ch,ch); switch(ch) { case 0x0000: break; - case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey); break; + case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, keymap); break; default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); } } @@ -571,6 +569,11 @@ KMX_WCHART KMX_VKUnderlyingLayoutToVKUS_GDK(GdkKeymap* keymap,KMX_DWORD VK_US) { return VK_DE; else return VK_US; +}// _S2 sure KMX_WCHART ??? not KMX_WCHAR ?? + +KMX_WCHAR KMX_VKUnderlyingLayoutToVKUS_GDK2(GdkKeymap* keymap,KMX_DWORD VK_Other) { + + return VK_Other; } // takes VK of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] KMX_DWORD KMX_CharFromVK(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey){ @@ -672,49 +675,30 @@ KMX_WORD KMX_VKUnderlyingLayoutToVKUS_S2(KMX_WORD VKey) { } int KMX_GetDeadkeys(KMX_WORD DeadKey, KMX_WORD *OutputPairs) { - int asdfghjk=0; - /*if(IsWow64()) { - return KMX_GetDeadkeys_NT_x64(DeadKey, OutputPairs); - } else { - return KMX_GetDeadkeys_NT(DeadKey, OutputPairs); - }*/ -} + KMX_WORD *p = OutputPairs, shift; + KMX_DWORD shift_S2; -int KMX_GetDeadkeys_NT_x64(KMX_WORD DeadKey, KMX_WORD *OutputPairs) { - /*WORD *p = OutputPairs, shift; - for(int i = 0; KbdTables_x64->pDeadKey[i].dwBoth; i++) { - if(HIWORD(KbdTables_x64->pDeadKey[i].dwBoth) == DeadKey) { - WORD vk = CharToUSVK_NT_x64(LOWORD(KbdTables_x64->pDeadKey[i].dwBoth), &shift); - if(vk != 0) { - *p++ = vk; - *p++ = shift; - *p++ = KbdTables_x64->pDeadKey[i].wchComposed; - } else { - LogError(L"Warning: complex deadkey not supported."); - } - } - } - *p = 0; - return (INT_PTR)(p-OutputPairs);*/ -} + //_S2 make static! + // create dk_createDK_ComposeTable + v_dw_2D dk_ComposeTable; + create_DKTable(dk_ComposeTable); -int KMX_GetDeadkeys_NT(KMX_WORD DeadKey, KMX_WORD *OutputPairs) { - /*WORD *p = OutputPairs, shift; - for(int i = 0; KbdTables->pDeadKey[i].dwBoth; i++) { - if(HIWORD(KbdTables->pDeadKey[i].dwBoth) == DeadKey) { - WORD vk = CharToUSVK_NT(LOWORD(KbdTables->pDeadKey[i].dwBoth), &shift); - if(vk != 0) { - *p++ = vk; - *p++ = shift; - *p++ = KbdTables->pDeadKey[i].wchComposed; - } else { - LogError(L"Warning: complex deadkey not supported."); - } - } - } + v_dw_2D dk_CombinationTable; + find_all_dk_combinations(&dk_ComposeTable, dk_CombinationTable, DeadKey); + + for ( int i=0; i< dk_CombinationTable.size()-1;i++) { + KMX_WORD vk = getKeyname(dk_CombinationTable[i][1], shift_S2); + if(vk != 0) { + *p++ = vk; + *p++ = shift_S2; + *p++ = dk_CombinationTable[i][2]; + } + //else { + // LogError(L"Warning: complex deadkey not supported."); + // } + } *p = 0; - return (INT_PTR)(p-OutputPairs);*/ - return 999; + return (p-OutputPairs); } diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index e450d0336f..2cb827c9a3 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -47,6 +47,7 @@ KMX_WORD KMX_VKUnderlyingLayoutToVKUS(KMX_WORD VKey); KMX_WORD KMX_VKUnderlyingLayoutToVKUS(v_dw_3D &All_Vector,KMX_DWORD inOther); // _S2 sure KMX_WCHART ??? not KMX_WCHAR ?? KMX_WCHART KMX_VKUnderlyingLayoutToVKUS_GDK(GdkKeymap* keymap,KMX_DWORD inOther); +KMX_WCHAR KMX_VKUnderlyingLayoutToVKUS_GDK2(GdkKeymap* keymap,KMX_DWORD inOther); PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); //--------------------old From 01c7a110e0b6ce8812585428bd35ec2bae8ec50a Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 4 Dec 2023 16:48:30 +0100 Subject: [PATCH 146/327] feat(linux): mcompile open KMX_ConvertDeadkey/KMX_GetDeadkeys --- linux/mcompile/keymap/mcompile.cpp | 32 ++++++++---------------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index ba20d76e1a..ff137a5f42 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -55,8 +55,7 @@ void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WOR void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group,KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch); void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch); -int KMX_GetDeadkeys(KMX_WORD DeadKey, KMX_WORD *OutputPairs) ; - +int KMX_GetDeadkeys(v_dw_2D & dk_ComposeTable, KMX_WORD DeadKey, KMX_WORD *OutputPairs); void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift); @@ -351,7 +350,6 @@ struct KMX_dkidmap { }; KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { - KMX_WCHAR noneS2; LPKMX_GROUP gp; LPKMX_KEY kp; LPKMX_STORE sp; @@ -404,9 +402,12 @@ KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR deadkey, GdkKeymap * keymap) { KMX_WORD deadkeys[512], *pdk; + // create dk_createDK_ComposeTable + v_dw_2D dk_Table; + create_DKTable(dk_Table); + // Lookup the deadkey table for the deadkey in the physical keyboard // Then for each character, go through and map it through - KMX_WCHAR dkid = KMX_GetUniqueDeadkeyID(kbd, deadkey); // _S2 OK Conversion easy - should work right away // Add the deadkey to the mapping table for use in the import rules phase @@ -414,7 +415,7 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR d KMX_FDeadkeys.push_back(KMX_deadkeyMapping); //dkid, vk, shift); // I4353 KMX_AddDeadkeyRule(kbd, dkid, vk, shift); // _S2 OK Conversion easy - should work right away - KMX_GetDeadkeys(deadkey, pdk = deadkeys); // returns array of [usvk, ch_out] pairs // _S2 Conversion hard but similar to keys remove _NT86,... + KMX_GetDeadkeys(dk_Table, deadkey, pdk = deadkeys); // returns array of [usvk, ch_out] pairs // _S2 Conversion hard but similar to keys remove _NT86,... while(*pdk) { // Look up the ch @@ -474,13 +475,6 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon return FALSE; } - // create dk_createDK_ComposeTable - v_dw_2D dk_ComposeTable; - if(create_DKTable(dk_ComposeTable)){ - wprintf(L"ERROR: can't create dk_ComposeTable\n"); - return FALSE; - } - for (int j = 0; VKShiftState[j] != 0xFFFF; j++) { // I4651 wprintf(L"\n"); @@ -665,26 +659,16 @@ KMX_WORD KMX_VKUSToVKUnderlyingLayout_S2(KMX_WORD VKey) { } KMX_WORD KMX_VKUnderlyingLayoutToVKUS_S2(KMX_WORD VKey) { - /* if(IsWow64()) { - return VKUnderlyingLayoutToVKUS_NT_x64(VKey); - } else { - return VKUnderlyingLayoutToVKUS_NT(VKey); - }*/ KMX_WORD retu ; return retu; } -int KMX_GetDeadkeys(KMX_WORD DeadKey, KMX_WORD *OutputPairs) { +int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs) { KMX_WORD *p = OutputPairs, shift; KMX_DWORD shift_S2; - //_S2 make static! - // create dk_createDK_ComposeTable - v_dw_2D dk_ComposeTable; - create_DKTable(dk_ComposeTable); - v_dw_2D dk_CombinationTable; - find_all_dk_combinations(&dk_ComposeTable, dk_CombinationTable, DeadKey); + find_all_dk_combinations(&dk_Table, dk_CombinationTable, DeadKey); for ( int i=0; i< dk_CombinationTable.size()-1;i++) { KMX_WORD vk = getKeyname(dk_CombinationTable[i][1], shift_S2); From 5a5fd432eb434ccc75d3cae3f96277bdbbe2b815 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 5 Dec 2023 16:50:06 +0100 Subject: [PATCH 147/327] feat(linux): mcompile KMX_ConvertDeadkey finished --- linux/mcompile/keymap/mcompile.cpp | 82 +++++++++++++++++++++--------- linux/mcompile/keymap/mcompile.h | 9 ++-- 2 files changed, 63 insertions(+), 28 deletions(-) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index ff137a5f42..3e471f0fcd 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -56,11 +56,11 @@ void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group,KMX_WCHAR deadkey, KMX_WORD vk, void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch); int KMX_GetDeadkeys(v_dw_2D & dk_ComposeTable, KMX_WORD DeadKey, KMX_WORD *OutputPairs); +int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, KMX_WORD sc); void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift); KMX_WORD KMX_VKUSToVKUnderlyingLayout_S2(KMX_WORD VKey); -KMX_WORD KMX_VKUnderlyingLayoutToVKUS_S2(KMX_WORD VKey); KMX_UINT KMX_VKUSToSCUnderlyingLayout(KMX_DWORD VirtualKeyUS); KMX_WCHAR KMX_CharFromSC(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey); @@ -300,6 +300,7 @@ void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4549 + shift &= ~LCTRLFLAG; // If the first group is not a matching-keys group, then we need to add into @@ -399,7 +400,7 @@ KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { return s_dkids[s_ndkids++].dst_deadkey = s_next_dkid = ++dkid; } -void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR deadkey, GdkKeymap * keymap) { +void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR deadkey, v_dw_3D &All_Vector) { KMX_WORD deadkeys[512], *pdk; // create dk_createDK_ComposeTable @@ -408,20 +409,19 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR d // Lookup the deadkey table for the deadkey in the physical keyboard // Then for each character, go through and map it through - KMX_WCHAR dkid = KMX_GetUniqueDeadkeyID(kbd, deadkey); // _S2 OK Conversion easy - should work right away + KMX_WCHAR dkid = KMX_GetUniqueDeadkeyID(kbd, deadkey); // Add the deadkey to the mapping table for use in the import rules phase - KMX_DeadkeyMapping KMX_deadkeyMapping = { deadkey, dkid, shift, vk }; // I4353 + KMX_DeadkeyMapping KMX_deadkeyMapping = { deadkey, dkid, shift, vk}; // I4353 KMX_FDeadkeys.push_back(KMX_deadkeyMapping); //dkid, vk, shift); // I4353 - KMX_AddDeadkeyRule(kbd, dkid, vk, shift); // _S2 OK Conversion easy - should work right away - KMX_GetDeadkeys(dk_Table, deadkey, pdk = deadkeys); // returns array of [usvk, ch_out] pairs // _S2 Conversion hard but similar to keys remove _NT86,... + KMX_AddDeadkeyRule(kbd, dkid, vk, shift); + KMX_GetDeadkeys(dk_Table, deadkey, pdk = deadkeys); // returns array of [usvk, ch_out] pairs while(*pdk) { // Look up the ch - // _S2 the new function returns KMX_DWORD - UINT vkUnderlying = KMX_VKUnderlyingLayoutToVKUS_GDK(keymap, *pdk); // _S2 Conversion medium use my gdk-funct - KMX_TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); // _S2 OK Conversion easy - should work right away + UINT vkUnderlying = KMX_VKUnderlyingLayoutToVKUS(All_Vector, *pdk); + KMX_TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); pdk+=3; } } @@ -500,7 +500,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon //wprintf(L" switch with ch: %i (%c)......\n" , ch,ch); switch(ch) { case 0x0000: break; - case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, keymap); break; + case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector); break; default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); } } @@ -531,6 +531,7 @@ UINT KMX_VKUSToSCUnderlyingLayout(KMX_DWORD VirtualKeyUS) { UINT SC_OTHER = SC_US; // not neccessary but to understand what we do return SC_OTHER; } + // takes capital letter of US returns cpital character of Other keyboard KMX_DWORD KMX_VKUSToVKUnderlyingLayout(v_dw_3D &All_Vector,KMX_DWORD inUS) { // loop and find char in US; then return char of Other @@ -544,7 +545,7 @@ KMX_DWORD KMX_VKUSToVKUnderlyingLayout(v_dw_3D &All_Vector,KMX_DWORD inUS) { return inUS; } // takes capital letter of Other returns cpital character of US keyboard -KMX_WORD KMX_VKUnderlyingLayoutToVKUS(v_dw_3D &All_Vector,KMX_DWORD inOther) { +KMX_WORD VKUS(v_dw_3D &All_Vector,KMX_DWORD inOther) { // loop and find char in Other; then return char of US for( int i=0; i< (int)All_Vector[1].size();i++) { for( int j=1; j< (int)All_Vector[1][0].size();j++) { @@ -555,6 +556,25 @@ KMX_WORD KMX_VKUnderlyingLayoutToVKUS(v_dw_3D &All_Vector,KMX_DWORD inOther) { } return inOther; } + + + +KMX_WCHAR KMX_VKUnderlyingLayoutToVKUS(v_dw_3D All_Vector, KMX_DWORD VK_US) { + + KMX_DWORD VK_Other; + + for( int i=0; i< (int)All_Vector[0].size()-1 ;i++) { + for( int j=1; j< (int)All_Vector[0][0].size();j++) { + if ( ( All_Vector[0][i][j] == VK_US ) ) { + VK_Other = All_Vector[1][i][j];; + return VK_Other; + } + } + } + return VK_US; +} + + // _S2 sure KMX_WCHART ??? not KMX_WCHAR ?? KMX_WCHART KMX_VKUnderlyingLayoutToVKUS_GDK(GdkKeymap* keymap,KMX_DWORD VK_US) { @@ -565,9 +585,9 @@ KMX_WCHART KMX_VKUnderlyingLayoutToVKUS_GDK(GdkKeymap* keymap,KMX_DWORD VK_US) { return VK_US; }// _S2 sure KMX_WCHART ??? not KMX_WCHAR ?? -KMX_WCHAR KMX_VKUnderlyingLayoutToVKUS_GDK2(GdkKeymap* keymap,KMX_DWORD VK_Other) { +KMX_WCHAR KMX_SCKUnderlyingLayoutToVKUS_GDK2(GdkKeymap* keymap,KMX_DWORD SC_Other) { - return VK_Other; + return SC_Other; } // takes VK of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] KMX_DWORD KMX_CharFromVK(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey){ @@ -648,20 +668,32 @@ int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ return 0; } -KMX_WORD KMX_VKUSToVKUnderlyingLayout_S2(KMX_WORD VKey) { - /*if(IsWow64()) { - return VKUSToVKUnderlyingLayout_NT_x64(VKey); - } else { - return VKUSToVKUnderlyingLayout_NT(VKey); - }*/ - KMX_WORD retu ; - return retu; + + +int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, KMX_WORD sc) { + KMX_WORD *p = OutputPairs, shift; + KMX_DWORD shift_S2; + + v_dw_2D dk_CombinationTable; + find_all_dk_combinations(&dk_Table, dk_CombinationTable, DeadKey); + + for ( int i=0; i< dk_CombinationTable.size()-1;i++) { + KMX_WORD vk = getKeyname(dk_CombinationTable[i][1], shift_S2); + if(vk != 0) { + *p++ = vk; + *p++ = shift_S2; + *p++ = dk_CombinationTable[i][2]; + int sdfghj0ç = 88; + } + //else { + // LogError(L"Warning: complex deadkey not supported."); + // } + } + *p = 0; + return (p-OutputPairs); } -KMX_WORD KMX_VKUnderlyingLayoutToVKUS_S2(KMX_WORD VKey) { - KMX_WORD retu ; - return retu; -} + int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs) { KMX_WORD *p = OutputPairs, shift; diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 2cb827c9a3..858901412a 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -36,18 +36,21 @@ struct KMX_DeadkeyMapping { // I4353 KMX_WCHAR deadkey, dkid; KMX_UINT shift; KMX_WORD vk; + KMX_WORD sc; }; extern std::vector KMX_FDeadkeys; // I4353 int run(int argc, std::vector str_argv, char* argv[]); -// _S2 is this correct here??? -KMX_WORD KMX_VKUnderlyingLayoutToVKUS(KMX_WORD VKey); -KMX_WORD KMX_VKUnderlyingLayoutToVKUS(v_dw_3D &All_Vector,KMX_DWORD inOther); // _S2 sure KMX_WCHART ??? not KMX_WCHAR ?? KMX_WCHART KMX_VKUnderlyingLayoutToVKUS_GDK(GdkKeymap* keymap,KMX_DWORD inOther); + KMX_WCHAR KMX_VKUnderlyingLayoutToVKUS_GDK2(GdkKeymap* keymap,KMX_DWORD inOther); +KMX_WCHAR KMX_VKUnderlyingLayoutToVKUS(v_dw_3D All_Vector,KMX_DWORD SC_US); + + +KMX_WCHAR KMX_SCUnderlyingLayoutToVKUS_GDK(GdkKeymap* keymap,KMX_DWORD inOther); PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); //--------------------old From 3d7175455b42ffc40e8821c69a5d96786e25d613 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 6 Dec 2023 16:24:16 +0100 Subject: [PATCH 148/327] feat(linux): mcompile changes in KMX_ConvertDeadkey --- linux/mcompile/keymap/deadkey.cpp | 27 +++++++++----- linux/mcompile/keymap/deadkey.h | 2 +- linux/mcompile/keymap/helpers.cpp | 7 ++-- linux/mcompile/keymap/keymap.cpp | 4 ++ linux/mcompile/keymap/mc_import_rules.cpp | 10 ++--- linux/mcompile/keymap/mcompile.cpp | 45 +++++------------------ 6 files changed, 40 insertions(+), 55 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 20f2d8b375..802b9079df 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -34,18 +34,27 @@ void find_all_dk_combinations(v_dw_2D * p_dk_ComposeTable, v_dw_2D &dk_Combinat } } -// _S2 quick&dirty needs to be changed !! -KMX_DWORD getKeyname(KMX_DWORD in, KMX_DWORD &shift) { - if ( (in >=65) && (in <= 90)) { - shift=1; - return in; - } - else { - shift=0; - return (in-32); +KMX_DWORD KMX_getKeyname(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap) { + + guint Keyval = (guint) KVal; + GdkKeymapKey* keys; + gint n_keys; + + // _S2 QUESTION can I assume that the win keyname is always the uppercase(level1) value?? + KMX_DWORD Name = (KMX_DWORD) gdk_keyval_to_upper (KVal); + if( Keyval !=0) { + gdk_keymap_get_entries_for_keyval(keymap, Keyval, &keys, &n_keys); + for (int i = 0; i < n_keys; i++) { + if (keys[i].group == 0) { + shift = keys[i].level; + return Name; + } } + } + return Name; } +// _S2 QUESTION is this the right place to get dk from? if not wher are they stored? KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable){ // values taken from: https://help.ubuntu.com/community/GtkDeadKeyTable#Latin diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index cf27e7ed70..140b3a4d62 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -11,6 +11,6 @@ KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable); KMX_DWORD find_dkCharacter(v_dw_2D * dk_ComposeTable, KMX_DWORD first, KMX_DWORD second ); void find_all_dk_combinations(v_dw_2D * dk_ComposeTable, v_dw_2D & dk_CombinationTable, KMX_DWORD dk); -KMX_DWORD getKeyname(KMX_DWORD in, KMX_DWORD &shift) ; +KMX_DWORD KMX_getKeyname(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap) ; # endif /*DEADKEY_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 630e6676a5..7936d6af29 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -776,7 +776,7 @@ for ( int iii=1; iii< 66;iii++) } wprintf(L"----------------------------\n"); - /*GdkKeymapKey **keys1; + GdkKeymapKey **keys1; guint kval = 42; gint *n_keys; gboolean gboo = gdk_keymap_get_entries_for_keyval ( keymap, kval, keys1, n_keys); @@ -787,7 +787,7 @@ wprintf(L"----------------------------\n"); wprintf(L" character 43 can be obtained by pressing %i keys:, keys1[%i]\n", *n_keys, *keys1[i]); int iii=99; - }*/ + } wprintf(L"----------------------------\n"); // converts the Ascii-nr to the name specified in symbols-file( 35 -> numbersign( KEY_numbersign); 65 -> A( KEY_A) @@ -1699,7 +1699,7 @@ void Inspect_Key_S(GdkKeymap *keymap ) { gchar * gc= gdk_keyval_name (729); gchar * gc0= gdk_keyval_name (94); //--------------------------------------- -std::string sr = "dead_acute"; +std::string sr = "dead_macron"; gchar * chr= (gchar*) sr.c_str(); ; guint gi= gdk_keyval_from_name (chr); //--------------------------------------- @@ -1821,6 +1821,7 @@ int stop=99; } + // _S2 TODO /*std::wstring get_KeyVals_according_to_Shiftstate(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index ec3d28461b..033a9ac1f5 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -28,6 +28,7 @@ KMX_DWORD convertNamesToIntegerValue(std::wstring tok_wstr){ first[L"bracketright"] = 93; first[L"colon"] = 58; first[L"comma"] = 44; + first[L"diaeresis"] = 168; first[L"dollar"] = 36; first[L"equal"] = 61; first[L"exclam"] = 33; @@ -348,6 +349,9 @@ KMX_DWORD getKeyvalsFromKeyCode(GdkKeymap *keymap, guint keycode, int shift_stat if (!(shift_state_pos <= count)) return 0; + if (!(keycode <= 64)) + return 0; + out =(KMX_DWORD) keyvals[shift_state_pos]; // _S2 if out of range of what ( ascii??) return 0 or other value ? diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 6f1d08cb50..30936a49e2 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -253,8 +253,8 @@ public: } UINT KMX_GetShiftStateValue(int capslock, int caps, ShiftState ss) { - wprintf(L"GetShiftStateValue takes capslock: %i, caps: %i, ss: %i and returns: %i\n", capslock, caps, ss, KMX_ShiftStateMap[(int)ss] | - (capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0)); + //wprintf(L"GetShiftStateValue takes capslock: %i, caps: %i, ss: %i and returns: %i\n", capslock, caps, ss, KMX_ShiftStateMap[(int)ss] | + //(capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0)); return KMX_ShiftStateMap[(int)ss] | (capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0); @@ -321,8 +321,6 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); - - for (int ss = 0; ss <= MaxShiftState; ss++) { if (ss == Menu || ss == ShftMenu) { // Alt and Shift+Alt don't work, so skip them @@ -370,7 +368,7 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; std::wstring w1_S2 = get_m_rgss(ss,caps); //wprintf(L"\n KMX_VKUnderlyingLayoutToVKUS_GD writes %ls %c",w1_S2.c_str(), key->Key ); - wprintf(L" this->VK(): %i ", this->VK()); + //wprintf(L" this->VK(): %i ", this->VK()); key->Line = 0; // _S2 _differences in sstateflag probably from here and KMX_IsCapsEqualToShift... key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); @@ -869,7 +867,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { nKeys+= rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); - wprintf(L" iKey = %i, Delta: %i -> Sum %i\n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()), nKeys); + //wprintf(L" iKey = %i, Delta: %i -> Sum %i\n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()), nKeys); sab_nr ++; } } diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 3e471f0fcd..9ddaec6eaf 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -55,7 +55,7 @@ void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WOR void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group,KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch); void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch); -int KMX_GetDeadkeys(v_dw_2D & dk_ComposeTable, KMX_WORD DeadKey, KMX_WORD *OutputPairs); +int KMX_GetDeadkeys(v_dw_2D & dk_ComposeTable, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap); int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, KMX_WORD sc); void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift); @@ -229,10 +229,10 @@ void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_ void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key) { if(key->ShiftFlags == 0) { //KMX_LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); - wprintf(L" _S2 Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); + //wprintf(L" _S2 Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); } else if(key->ShiftFlags & VIRTUALCHARKEY) { //KMX_LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); - wprintf(L"_S2 Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); + //wprintf(L"_S2 Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); } } @@ -400,7 +400,7 @@ KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { return s_dkids[s_ndkids++].dst_deadkey = s_next_dkid = ++dkid; } -void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR deadkey, v_dw_3D &All_Vector) { +void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR deadkey, v_dw_3D &All_Vector, GdkKeymap* keymap) { KMX_WORD deadkeys[512], *pdk; // create dk_createDK_ComposeTable @@ -416,7 +416,7 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR d KMX_FDeadkeys.push_back(KMX_deadkeyMapping); //dkid, vk, shift); // I4353 KMX_AddDeadkeyRule(kbd, dkid, vk, shift); - KMX_GetDeadkeys(dk_Table, deadkey, pdk = deadkeys); // returns array of [usvk, ch_out] pairs + KMX_GetDeadkeys(dk_Table, deadkey, pdk = deadkeys, keymap); // returns array of [usvk, ch_out] pairs while(*pdk) { // Look up the ch @@ -486,7 +486,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon KMX_WCHAR ch = KMX_CharFromVK(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey);*/ UINT scUnderlying = KMX_VKUSToSCUnderlyingLayout(KMX_VKMap[i]); - KMX_WCHAR ch = KMX_CharFromSC(keymap, VKShiftState[j], scUnderlying, &DeadKey); + KMX_WCHAR ch = KMX_CharFromSC(keymap, VKShiftState[j], scUnderlying, &DeadKey); // _S2 ch is of Other KB //wprintf(L" DoConvert-read i: %i \t(KMX_VKMap): %i (%c) \t---> vkUnderlying: %i (%c) \tshiftstate[%i]: ( %i ) \t---- > ch: %i (%c) \t%ls \t%ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, j, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); @@ -500,7 +500,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon //wprintf(L" switch with ch: %i (%c)......\n" , ch,ch); switch(ch) { case 0x0000: break; - case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector); break; + case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap); break; default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); } } @@ -650,7 +650,6 @@ bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]){ } int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ - std::string US_language = "us"; const char* text_us = "xkb_symbols \"basic\""; //const char* text_us = "xkb_symbols \"intl\""; @@ -668,9 +667,8 @@ int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ return 0; } +int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap) { - -int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, KMX_WORD sc) { KMX_WORD *p = OutputPairs, shift; KMX_DWORD shift_S2; @@ -678,32 +676,7 @@ int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, find_all_dk_combinations(&dk_Table, dk_CombinationTable, DeadKey); for ( int i=0; i< dk_CombinationTable.size()-1;i++) { - KMX_WORD vk = getKeyname(dk_CombinationTable[i][1], shift_S2); - if(vk != 0) { - *p++ = vk; - *p++ = shift_S2; - *p++ = dk_CombinationTable[i][2]; - int sdfghj0ç = 88; - } - //else { - // LogError(L"Warning: complex deadkey not supported."); - // } - } - *p = 0; - return (p-OutputPairs); -} - - - -int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs) { - KMX_WORD *p = OutputPairs, shift; - KMX_DWORD shift_S2; - - v_dw_2D dk_CombinationTable; - find_all_dk_combinations(&dk_Table, dk_CombinationTable, DeadKey); - - for ( int i=0; i< dk_CombinationTable.size()-1;i++) { - KMX_WORD vk = getKeyname(dk_CombinationTable[i][1], shift_S2); + KMX_WORD vk = KMX_getKeyname(dk_CombinationTable[i][1], shift_S2, keymap); if(vk != 0) { *p++ = vk; *p++ = shift_S2; From 9122080c1e361dadea14e480bff2c3d857e7010d Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 7 Dec 2023 12:51:08 +0100 Subject: [PATCH 149/327] feat(linux): mcompile allow keycode 94 in getKeyvalsFromKeyCode --- linux/mcompile/keymap/helpers.cpp | 6 +++--- linux/mcompile/keymap/keymap.cpp | 2 +- linux/mcompile/keymap/mc_import_rules.cpp | 13 ++++++++++++- linux/mcompile/keymap/mcompile.cpp | 11 ++++------- linux/mcompile/keymap/mcompile.h | 1 - 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 7936d6af29..fa7a3487b4 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -1668,7 +1668,7 @@ void Inspect_Key_S(GdkKeymap *keymap ) { guint KCode = 51; guint Keyval_Base= 35; - guint Keyval_Shift = 39; + guint Keyval_Shift = 60; guint Keyval = Keyval_Base; gchar* KeyvalName_Base; @@ -1696,10 +1696,10 @@ void Inspect_Key_S(GdkKeymap *keymap ) { // KeyValname(Shift) A Odiaresis ampersand numbersign //--------------------------------------- -gchar * gc= gdk_keyval_name (729); +gchar * gc= gdk_keyval_name (60); gchar * gc0= gdk_keyval_name (94); //--------------------------------------- -std::string sr = "dead_macron"; +std::string sr = "less"; gchar * chr= (gchar*) sr.c_str(); ; guint gi= gdk_keyval_from_name (chr); //--------------------------------------- diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 033a9ac1f5..77090e9b76 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -349,7 +349,7 @@ KMX_DWORD getKeyvalsFromKeyCode(GdkKeymap *keymap, guint keycode, int shift_stat if (!(shift_state_pos <= count)) return 0; - if (!(keycode <= 64)) + if (!(keycode <= 94)) return 0; out =(KMX_DWORD) keyvals[shift_state_pos]; diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 30936a49e2..12788b211d 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -777,6 +777,17 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd //_S2 TODO get char - do I need rc ?? ( was rc = ToUnicodeEx...) std::wstring KeyVal_Other = get_KeyVals_according_to_keycode_and_Shiftstate_new( *keymap, SC_US, ss, caps); + + + + + + + + + +// _S2 brackets nor the same in if/else/else if blocks !!!! + //_S2 TODO do I need that ?? //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { if(KeyVal_Other == L"") { @@ -792,12 +803,12 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd continue; } - //_S2 TODO fill m_rgfDeadkey ( m_rgfDeadkey will be done later) //rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps==0)); rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps)); //_S2 TODO + // dk > 65000??? // _S2 handle deadkeys later // if rc <0: it got a deadkey { // fill m_rgss and m_rgfDeadkey and alDead diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 9ddaec6eaf..882cb0b81f 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -229,10 +229,10 @@ void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_ void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key) { if(key->ShiftFlags == 0) { //KMX_LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); - //wprintf(L" _S2 Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); + wprintf(L" _S2 Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); } else if(key->ShiftFlags & VIRTUALCHARKEY) { //KMX_LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); - //wprintf(L"_S2 Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); + wprintf(L"_S2 Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); } } @@ -500,7 +500,8 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon //wprintf(L" switch with ch: %i (%c)......\n" , ch,ch); switch(ch) { case 0x0000: break; - case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap); break; + case 0xFFFF: + KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap); break; default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); } } @@ -557,12 +558,9 @@ KMX_WORD VKUS(v_dw_3D &All_Vector,KMX_DWORD inOther) { return inOther; } - - KMX_WCHAR KMX_VKUnderlyingLayoutToVKUS(v_dw_3D All_Vector, KMX_DWORD VK_US) { KMX_DWORD VK_Other; - for( int i=0; i< (int)All_Vector[0].size()-1 ;i++) { for( int j=1; j< (int)All_Vector[0][0].size();j++) { if ( ( All_Vector[0][i][j] == VK_US ) ) { @@ -574,7 +572,6 @@ KMX_WCHAR KMX_VKUnderlyingLayoutToVKUS(v_dw_3D All_Vector, KMX_DWORD VK_US) { return VK_US; } - // _S2 sure KMX_WCHART ??? not KMX_WCHAR ?? KMX_WCHART KMX_VKUnderlyingLayoutToVKUS_GDK(GdkKeymap* keymap,KMX_DWORD VK_US) { diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 858901412a..e81c2807e2 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -36,7 +36,6 @@ struct KMX_DeadkeyMapping { // I4353 KMX_WCHAR deadkey, dkid; KMX_UINT shift; KMX_WORD vk; - KMX_WORD sc; }; extern std::vector KMX_FDeadkeys; // I4353 From aad0191a5b7f378aea243ca89fe04b3280931762 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 7 Dec 2023 13:58:43 +0100 Subject: [PATCH 150/327] feat(linux): mcompile sort converting functions I --- linux/mcompile/keymap/helpers.cpp | 14 ++++++++++++++ linux/mcompile/keymap/keymap.h | 3 --- linux/mcompile/keymap/mcompile.cpp | 26 +++++++------------------- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index fa7a3487b4..41ceb0b496 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -2380,3 +2380,17 @@ std::wstring get_KeyVals_according_to_keycode_and_Shiftstate(GdkKeymap *keymap, return L"\0"; } +// takes capital letter of Other returns cpital character of US keyboard +/*KMX_WORD VKUS(v_dw_3D &All_Vector,KMX_DWORD inOther) { + // loop and find char in Other; then return char of US + for( int i=0; i< (int)All_Vector[1].size();i++) { + for( int j=1; j< (int)All_Vector[1][0].size();j++) { + if((inOther == All_Vector[1][i][j] )) { + return All_Vector[0][i][2]; + } + } + } + return inOther; +}*/ + + diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index c7b1fbd0b2..0adf47618d 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -505,9 +505,6 @@ int append_other_ToVector(v_dw_3D &All_Vector, GdkKeymap *keymap); // initialize GDK bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); -// return the Scancode of for given VirtualKey using GDK -KMX_DWORD get_KeyCode_From_KeyVal_GDK(GdkKeymap *keymap, UINT Keyval); - // find Keyvals to fill into 2D-Vector of Other Language KMX_DWORD getKeyvalsFromKeyCode(GdkKeymap *keymap, guint keycode, int shift_state_pos); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 882cb0b81f..59dd991407 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -545,34 +545,22 @@ KMX_DWORD KMX_VKUSToVKUnderlyingLayout(v_dw_3D &All_Vector,KMX_DWORD inUS) { } return inUS; } -// takes capital letter of Other returns cpital character of US keyboard -KMX_WORD VKUS(v_dw_3D &All_Vector,KMX_DWORD inOther) { - // loop and find char in Other; then return char of US - for( int i=0; i< (int)All_Vector[1].size();i++) { - for( int j=1; j< (int)All_Vector[1][0].size();j++) { - if((inOther == All_Vector[1][i][j] )) { - return All_Vector[0][i][2]; - } - } - } - return inOther; -} -KMX_WCHAR KMX_VKUnderlyingLayoutToVKUS(v_dw_3D All_Vector, KMX_DWORD VK_US) { +KMX_WCHAR KMX_VKUnderlyingLayoutToVKUS(v_dw_3D All_Vector, KMX_DWORD VK_OTHER) { - KMX_DWORD VK_Other; + KMX_DWORD VK_US; for( int i=0; i< (int)All_Vector[0].size()-1 ;i++) { for( int j=1; j< (int)All_Vector[0][0].size();j++) { - if ( ( All_Vector[0][i][j] == VK_US ) ) { - VK_Other = All_Vector[1][i][j];; - return VK_Other; + if ( ( All_Vector[0][i][j] == VK_OTHER ) ) { + VK_US = All_Vector[1][i][j];; + return VK_US; } } } - return VK_US; + return VK_OTHER; } -// _S2 sure KMX_WCHART ??? not KMX_WCHAR ?? +// _S2 sure KMX_WCHART ??? not KMX_WCHAR ?? not usable!! KMX_WCHART KMX_VKUnderlyingLayoutToVKUS_GDK(GdkKeymap* keymap,KMX_DWORD VK_US) { KMX_WORD VK_DE = ( KMX_WORD ) map_Ikey_DE(VK_US); From e1f2972230a0c5f3db869ef2dce46fee535a8b77 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 7 Dec 2023 14:08:54 +0100 Subject: [PATCH 151/327] feat(linux): mcompile sort converting functions II --- linux/mcompile/keymap/deadkey.cpp | 2 +- linux/mcompile/keymap/deadkey.h | 2 +- linux/mcompile/keymap/helpers.cpp | 8 ++++---- linux/mcompile/keymap/keymap.cpp | 6 +++--- linux/mcompile/keymap/keymap.h | 2 +- linux/mcompile/keymap/mcompile.cpp | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 802b9079df..e41aa6233e 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -34,7 +34,7 @@ void find_all_dk_combinations(v_dw_2D * p_dk_ComposeTable, v_dw_2D &dk_Combinat } } -KMX_DWORD KMX_getKeyname(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap) { +KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap) { guint Keyval = (guint) KVal; GdkKeymapKey* keys; diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index 140b3a4d62..b718164139 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -11,6 +11,6 @@ KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable); KMX_DWORD find_dkCharacter(v_dw_2D * dk_ComposeTable, KMX_DWORD first, KMX_DWORD second ); void find_all_dk_combinations(v_dw_2D * dk_ComposeTable, v_dw_2D & dk_CombinationTable, KMX_DWORD dk); -KMX_DWORD KMX_getKeyname(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap) ; +KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap) ; # endif /*DEADKEY_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 41ceb0b496..93ea3745a5 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -621,8 +621,8 @@ bool InsertKeyvalsFromKeymap(v_dw_3D &All_Vector,GdkKeymap * keymap){ All_Vector[1][i][0] = All_Vector[0][i][0]; // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] - All_Vector[1][i][0+1] = getKeyvalsFromKeyCode(keymap,(All_Vector[1][i][0]),0); //shift state: unshifted:0 - All_Vector[1][i][1+1] = getKeyvalsFromKeyCode(keymap,(All_Vector[1][i][0]),1); //shift state: shifted:1 + All_Vector[1][i][0+1] = getKeyvalsOtherFromKeyCode(keymap,(All_Vector[1][i][0]),0); //shift state: unshifted:0 + All_Vector[1][i][1+1] = getKeyvalsOtherFromKeyCode(keymap,(All_Vector[1][i][0]),1); //shift state: shifted:1 //wprintf(L" Keycodes US dw : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); //wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); @@ -637,8 +637,8 @@ KMX_DWORD writeKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_sta KMX_DWORD out; for ( int ii =1; ii< 255;ii++) { - KMX_DWORD out = getKeyvalsFromKeyCode(keymap,ii,0); - KMX_DWORD out2= getKeyvalsFromKeyCode(keymap,ii,1); + KMX_DWORD out = getKeyvalsOtherFromKeyCode(keymap,ii,0); + KMX_DWORD out2= getKeyvalsOtherFromKeyCode(keymap,ii,1); wprintf(L" ii = %i --> keymap = %i (%c)..%i(%c) \n",ii, out,out, out2,out2); } } diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 77090e9b76..192a95f529 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -325,8 +325,8 @@ int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { All_Vector[1][i][0] = All_Vector[0][i][0]; // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] - All_Vector[1][i][0+1] = getKeyvalsFromKeyCode(keymap,All_Vector[0][i][0],0); //shift state: unshifted:0 - All_Vector[1][i][1+1] = getKeyvalsFromKeyCode(keymap,All_Vector[0][i][0],1); //shift state: shifted:1 + All_Vector[1][i][0+1] = getKeyvalsOtherFromKeyCode(keymap,All_Vector[0][i][0],0); //shift state: unshifted:0 + All_Vector[1][i][1+1] = getKeyvalsOtherFromKeyCode(keymap,All_Vector[0][i][0],1); //shift state: shifted:1 //wprintf(L" Keycodes US dw : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); //wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); @@ -335,7 +335,7 @@ int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { } // _S2 can I use gdk_keymap_translate_keyboard_state instead? -KMX_DWORD getKeyvalsFromKeyCode(GdkKeymap *keymap, guint keycode, int shift_state_pos) { +KMX_DWORD getKeyvalsOtherFromKeyCode(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; guint *keyvals; gint count; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 0adf47618d..a3125098ac 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -506,7 +506,7 @@ int append_other_ToVector(v_dw_3D &All_Vector, GdkKeymap *keymap); bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); // find Keyvals to fill into 2D-Vector of Other Language -KMX_DWORD getKeyvalsFromKeyCode(GdkKeymap *keymap, guint keycode, int shift_state_pos); +KMX_DWORD getKeyvalsOtherFromKeyCode(GdkKeymap *keymap, guint keycode, int shift_state_pos); // returns KeySyms fo ra given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) std::wstring get_KeyVals_according_to_keycode_and_Shiftstate_new(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 59dd991407..a9ce834382 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -601,7 +601,7 @@ KMX_DWORD KMX_CharFromVK(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VK KMX_WCHAR KMX_CharFromSC(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey) { int VKShiftState_lin = map_VKShiftState_to_Lin(VKShiftState); - KMX_DWORD KeyvalOther = getKeyvalsFromKeyCode(keymap,SC_OTHER, VKShiftState_lin); + KMX_DWORD KeyvalOther = getKeyvalsOtherFromKeyCode(keymap,SC_OTHER, VKShiftState_lin); // _S2 how to detect deadkeys ? KeyvalOther >deadkeyThreshold KeyvalOther > 255? KeyvalOther > 65000 ? or what else? //if (KeyvalOther > deadkeyThreshold) { @@ -661,7 +661,7 @@ int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, find_all_dk_combinations(&dk_Table, dk_CombinationTable, DeadKey); for ( int i=0; i< dk_CombinationTable.size()-1;i++) { - KMX_WORD vk = KMX_getKeyname(dk_CombinationTable[i][1], shift_S2, keymap); + KMX_WORD vk = KMX_changeKeynameToCapital(dk_CombinationTable[i][1], shift_S2, keymap); if(vk != 0) { *p++ = vk; *p++ = shift_S2; From f2d22ebc3f95e01fd656d6fb6cccb29f2be57017 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 7 Dec 2023 14:28:26 +0100 Subject: [PATCH 152/327] feat(linux): mcompile sort converting functions III --- linux/mcompile/keymap/helpers.cpp | 8 ++++---- linux/mcompile/keymap/keymap.cpp | 6 +++--- linux/mcompile/keymap/keymap.h | 2 +- linux/mcompile/keymap/mcompile.cpp | 9 ++++----- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 93ea3745a5..41ceb0b496 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -621,8 +621,8 @@ bool InsertKeyvalsFromKeymap(v_dw_3D &All_Vector,GdkKeymap * keymap){ All_Vector[1][i][0] = All_Vector[0][i][0]; // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] - All_Vector[1][i][0+1] = getKeyvalsOtherFromKeyCode(keymap,(All_Vector[1][i][0]),0); //shift state: unshifted:0 - All_Vector[1][i][1+1] = getKeyvalsOtherFromKeyCode(keymap,(All_Vector[1][i][0]),1); //shift state: shifted:1 + All_Vector[1][i][0+1] = getKeyvalsFromKeyCode(keymap,(All_Vector[1][i][0]),0); //shift state: unshifted:0 + All_Vector[1][i][1+1] = getKeyvalsFromKeyCode(keymap,(All_Vector[1][i][0]),1); //shift state: shifted:1 //wprintf(L" Keycodes US dw : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); //wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); @@ -637,8 +637,8 @@ KMX_DWORD writeKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_sta KMX_DWORD out; for ( int ii =1; ii< 255;ii++) { - KMX_DWORD out = getKeyvalsOtherFromKeyCode(keymap,ii,0); - KMX_DWORD out2= getKeyvalsOtherFromKeyCode(keymap,ii,1); + KMX_DWORD out = getKeyvalsFromKeyCode(keymap,ii,0); + KMX_DWORD out2= getKeyvalsFromKeyCode(keymap,ii,1); wprintf(L" ii = %i --> keymap = %i (%c)..%i(%c) \n",ii, out,out, out2,out2); } } diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 192a95f529..77090e9b76 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -325,8 +325,8 @@ int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { All_Vector[1][i][0] = All_Vector[0][i][0]; // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] - All_Vector[1][i][0+1] = getKeyvalsOtherFromKeyCode(keymap,All_Vector[0][i][0],0); //shift state: unshifted:0 - All_Vector[1][i][1+1] = getKeyvalsOtherFromKeyCode(keymap,All_Vector[0][i][0],1); //shift state: shifted:1 + All_Vector[1][i][0+1] = getKeyvalsFromKeyCode(keymap,All_Vector[0][i][0],0); //shift state: unshifted:0 + All_Vector[1][i][1+1] = getKeyvalsFromKeyCode(keymap,All_Vector[0][i][0],1); //shift state: shifted:1 //wprintf(L" Keycodes US dw : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); //wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); @@ -335,7 +335,7 @@ int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { } // _S2 can I use gdk_keymap_translate_keyboard_state instead? -KMX_DWORD getKeyvalsOtherFromKeyCode(GdkKeymap *keymap, guint keycode, int shift_state_pos) { +KMX_DWORD getKeyvalsFromKeyCode(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; guint *keyvals; gint count; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index a3125098ac..0adf47618d 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -506,7 +506,7 @@ int append_other_ToVector(v_dw_3D &All_Vector, GdkKeymap *keymap); bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); // find Keyvals to fill into 2D-Vector of Other Language -KMX_DWORD getKeyvalsOtherFromKeyCode(GdkKeymap *keymap, guint keycode, int shift_state_pos); +KMX_DWORD getKeyvalsFromKeyCode(GdkKeymap *keymap, guint keycode, int shift_state_pos); // returns KeySyms fo ra given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) std::wstring get_KeyVals_according_to_keycode_and_Shiftstate_new(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index a9ce834382..34d14173c9 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -56,11 +56,10 @@ void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group,KMX_WCHAR deadkey, KMX_WORD vk, void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch); int KMX_GetDeadkeys(v_dw_2D & dk_ComposeTable, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap); -int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, KMX_WORD sc); +//int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, KMX_WORD sc); void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift); -KMX_WORD KMX_VKUSToVKUnderlyingLayout_S2(KMX_WORD VKey); KMX_UINT KMX_VKUSToSCUnderlyingLayout(KMX_DWORD VirtualKeyUS); KMX_WCHAR KMX_CharFromSC(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey); @@ -420,6 +419,7 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR d while(*pdk) { // Look up the ch + // go via SC UINT vkUnderlying = KMX_VKUnderlyingLayoutToVKUS(All_Vector, *pdk); KMX_TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); pdk+=3; @@ -481,7 +481,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon // Loop through each possible key on the keyboard for (int i = 0;KMX_VKMap[i]; i++) { // I4651 - // win goes via VK, Lin goes vie SC + // win goes via VK, Lin goes via SC /*KMX_DWORD vkUnderlying = KMX_VKUSToVKUnderlyingLayout(All_Vector,(int) KMX_VKMap[i] ); KMX_WCHAR ch = KMX_CharFromVK(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey);*/ @@ -601,7 +601,7 @@ KMX_DWORD KMX_CharFromVK(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VK KMX_WCHAR KMX_CharFromSC(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey) { int VKShiftState_lin = map_VKShiftState_to_Lin(VKShiftState); - KMX_DWORD KeyvalOther = getKeyvalsOtherFromKeyCode(keymap,SC_OTHER, VKShiftState_lin); + KMX_DWORD KeyvalOther = getKeyvalsFromKeyCode(keymap,SC_OTHER, VKShiftState_lin); // _S2 how to detect deadkeys ? KeyvalOther >deadkeyThreshold KeyvalOther > 255? KeyvalOther > 65000 ? or what else? //if (KeyvalOther > deadkeyThreshold) { @@ -610,7 +610,6 @@ KMX_WCHAR KMX_CharFromSC(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHE *DeadKey = convertNamesToIntegerValue( wstring_from_string(ws)); return 0xFFFF; } - return (KMX_WCHAR) KeyvalOther; } From 25957c535081082602f1db7a1382fbf725450e51 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 7 Dec 2023 14:51:47 +0100 Subject: [PATCH 153/327] feat(linux): mcompile sort converting functions IV --- linux/mcompile/keymap/helpers.cpp | 7 +++---- linux/mcompile/keymap/keymap.cpp | 6 +++--- linux/mcompile/keymap/keymap.h | 3 +++ linux/mcompile/keymap/mcompile.h | 8 ++++++++ 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 41ceb0b496..8e5482d78d 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -1719,9 +1719,9 @@ std::string sr21 = "dead_abovedot"; gchar * chr21= (gchar*) sr21.c_str(); ; guint gi21= gdk_keyval_from_name (chr21);*/ //--------------------------------------- -//--------------------------------------- +//---------------------------------------*/ //guint32 gdk_keyval_to_unicode (guint keyval); -/*guint32 gg323 = gdk_keyval_to_unicode (65106); +guint32 gg323 = gdk_keyval_to_unicode (65106); guint32 gz = gdk_keyval_to_unicode (65); guint32 gz1 = gdk_keyval_to_unicode (220); guint32 gz2 = gdk_keyval_to_unicode (7838); @@ -1733,7 +1733,7 @@ guint GGGIII3= gdk_unicode_to_keyval (gz); guint GGGIII4= gdk_unicode_to_keyval (gz1); //guint GGGIII2 =gdk_unicode_to_keyval (L"\u1E9E"); //gchar * gc2= gdk_keyval_name ((int) \u1E9E); -wchar_t w[] = L"\u1E9E"; +/*wchar_t w[] = L"\u1E9E"; wchar_t ww[] = L"A"; unsigned int Alef = (unsigned int) L'ẞ'; guint GGII4= gdk_unicode_to_keyval (Alef); @@ -2393,4 +2393,3 @@ std::wstring get_KeyVals_according_to_keycode_and_Shiftstate(GdkKeymap *keymap, return inOther; }*/ - diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 77090e9b76..6e14e78b9a 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -490,12 +490,12 @@ std::wstring convert_DeadkeyValues_ToChar(int in) { return L"\0"; return std::wstring(1, in); } else { - std::string long_name((const char*) gdk_keyval_name (in)); // 6510 => "dead_circumflex " - lname = convertNamesToIntegerValue( wstring_from_string(long_name)); // "dead_circumflex " => 94 + std::string long_name((const char*) gdk_keyval_name (in)); // 65106 => "dead_circumflex " + lname = convertNamesToIntegerValue( wstring_from_string(long_name)); // "dead_circumflex " => 94 if (lname != returnIfCharInvalid) { std::wstring ss = std::wstring(1, lname ); - return std::wstring(1, lname ); // 94 => "^" + return std::wstring(1, lname ); // 94 => "^" } else return L"\0"; } diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 0adf47618d..e50e764593 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -508,6 +508,9 @@ bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); // find Keyvals to fill into 2D-Vector of Other Language KMX_DWORD getKeyvalsFromKeyCode(GdkKeymap *keymap, guint keycode, int shift_state_pos); +// take deadkey-value (e.g.65106) and return character (e.g. '^' ) +std::wstring convert_DeadkeyValues_ToChar(int in); + // returns KeySyms fo ra given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) std::wstring get_KeyVals_according_to_keycode_and_Shiftstate_new(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index e81c2807e2..2cac50c6e6 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -52,6 +52,14 @@ KMX_WCHAR KMX_VKUnderlyingLayoutToVKUS(v_dw_3D All_Vector,KMX_DWORD SC_US); KMX_WCHAR KMX_SCUnderlyingLayoutToVKUS_GDK(GdkKeymap* keymap,KMX_DWORD inOther); PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); + +UINT KMX_VKUSToSCUnderlyingLayout(KMX_DWORD VirtualKeyUS); +KMX_DWORD KMX_VKUSToVKUnderlyingLayout(v_dw_3D &All_Vector,KMX_DWORD inUS); +KMX_DWORD KMX_CharFromVK(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey); +KMX_WCHAR KMX_CharFromSC(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey); +int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap); + + //--------------------old /* #include From 60534b1c79e3587b6aae6f12150e82c37dabd468 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 7 Dec 2023 16:17:31 +0100 Subject: [PATCH 154/327] feat(linux): mcompile start ImportRule deadkey(therefore created ImportRule_bak) --- linux/mcompile/keymap/mc_import_rules.cpp | 399 +++++++++++++++++++++- linux/mcompile/keymap/mcompile.cpp | 6 +- 2 files changed, 388 insertions(+), 17 deletions(-) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 12788b211d..103c031d78 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -695,11 +695,10 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd // _S2 scroll through OTHER // Scroll through the Scan Code (SC) values and get the valid Virtual Key (VK) - // values in it. Then, store the SC in each valid VK so it can act as both a + // values in it. Then, store the SC in each valid VK so it can act as both a // flag that the VK is valid, and it can store the SC value. // _S2 this does not find exactly the same keys as the windows version does(windows finds more) - int keycountS =0; for(UINT sc = 0x01; sc <= 0x7f; sc++) { // fills m_vk with the VK of the US keyboard which is not right!! // ( mcompile win uses MapVirtualKeyEx() to fill m_vk with the VK of the Other keyboard) @@ -733,7 +732,387 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd UINT sc = MapVirtualKeyEx(vk, 0, hkl); UINT vkL = MapVirtualKeyEx(sc, 1, hkl); UINT vkR = MapVirtualKeyEx(sc, 3, hkl); - if((vkL != vkR) && + if((vkL != vkR) && + (vk != vkL)) { + switch(vk) { + case VK_LCONTROL: + case VK_RCONTROL: + case VK_LSHIFT: + case VK_RSHIFT: + case VK_LMENU: + case VK_RMENU: + break; + + default: + loader.Set_XxxxVk(vk); + break; + } + } + } +*/ + // _S2 test rgkey can go later + /*for(UINT iKey = 100; iKey < rgKey.size(); iKey++) { + if(rgKey[iKey] != NULL) { + wprintf(L" Key Nr %i is available\n",iKey); + } + }*/ + + // _S2 in this part we skip shiftstates 4, 5, 8, 9 + for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { + if(rgKey[iKey] != NULL) { + WCHAR sbBuffer[256]; // Scratchpad we use many places + + UINT VK_Other = Lin_KM__map(iKey, All_Vector); + + for(ShiftState ss = Base; ss <= loader.MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { + if(ss == Menu || ss == ShftMenu) { + // Alt and Shift+Alt don't work, so skip them + continue; + } + + KMX_DWORD SC_US = get_KeyCode_fromVKUS(iKey); + + for(int caps = 0; caps <= 1; caps++) { + //_S2 TODO get char - do I need rc ?? ( was rc = ToUnicodeEx...) + std::wstring KeyVal_Other = get_KeyVals_according_to_keycode_and_Shiftstate_new( *keymap, SC_US, ss, caps); + +//----------------------------------------------- +int rc = 11; + if (rc == 0) { + int trurzttz = 57; + } + if(rc > 0) { + if(*sbBuffer == 0) { + //_S2 TODO do I need that ?? + //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { + if(KeyVal_Other == L"") { + //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); + rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps)); + } + } + else { + /*if((rc == 1) && (ss == Ctrl || ss == ShftCtrl) && (rgKey[iKey]->VK() == ((UINT)sbBuffer[0] + 0x40))) { + // ToUnicodeEx has an internal knowledge about those + // VK_A ~ VK_Z keys to produce the control characters, + // when the conversion rule is not provided in keyboard + // layout files + continue; + }*/ + // if rc ==1 : it got 1 char && +40 in Buffer CTRl pressed { + //It's dealing with control characters. If ToUnicodeEx gets VK_A with5 the Ctrl key pressed, + //it will write 0x01 to sBuffer[0] , without Ctrl it's 0x41. The if detects this case. + /* if( (ss == Ctrl || ss == ShftCtrl) ) { + //&& CTRl +0x40 in the buffer ( which indicates a ctrl press) + continue; + }*/ + sbBuffer[rc] = 0; + //rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps==0)); + rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps)); //_S2 + } + } + else if(rc < 0) { + /* //_S2 TODO + // dk > 65000??? + // _S2 handle deadkeys later + // if rc <0: it got a deadkey { + // fill m_rgss and m_rgfDeadkey and alDead + //SET_SHIFTSTATES( deadkey) //sbuffer is value out of ToUnicodeEx / AllVector + // do more stuff for deadkeys... + + sbBuffer[2] = 0; + rgKey[iKey]->SetShiftState(ss, sbBuffer, true, (caps == 0));*/ + + // It's a dead key; let's flush out whats stored in the keyboard state. + /*loader.ClearKeyboardBuffer(VK_DECIMAL, rgKey[VK_DECIMAL]->SC(), hkl); + DeadKey *dk = NULL; + for(UINT iDead = 0; iDead < alDead.size(); iDead++) { + dk = alDead[iDead]; + WCHAR dktest1 = dk->DeadCharacter(); + WCHAR dktest2 = rgKey[iKey]->GetShiftState(ss, caps == 0)[0]; + if(dk->DeadCharacter() == rgKey[iKey]->GetShiftState(ss, caps == 0)[0]) { + break; + } + dk = NULL; + } + if(dk == NULL) { + alDead.push_back(loader.ProcessDeadKey(iKey, ss, lpKeyState, rgKey, caps == 0, hkl)); + }*/ + } + } + } + } + } + + //_S2 this gan co later + std::vector< int > TestValues = {48,49,50,51,52,53,54,55,56,57,65,66,67,88,89,90, 186,187,188,189,191,191,192,219,220,221,222,226}; + wprintf(L"-----------------\nNow some tests:\n"); + wprintf(L" Base Caps Shift Shfit+Caps MenuCtrl MenuCtrl+Caps \n"); + + for ( int i=0; i < (int) TestValues.size();i++) { + std::wstring wws = rgKey[TestValues[i]]->get_m_rgss(0,0); + wprintf(L"Results for %i\t: %ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \n", TestValues[i], + rgKey[TestValues[i]]->get_m_rgss(0,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(0,0)[0], + rgKey[TestValues[i]]->get_m_rgss(0,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(0,1)[0], + rgKey[TestValues[i]]->get_m_rgss(1,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(1,0)[0], + rgKey[TestValues[i]]->get_m_rgss(1,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(1,1)[0], + rgKey[TestValues[i]]->get_m_rgss(6,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(6,0)[0], + rgKey[TestValues[i]]->get_m_rgss(6,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(6,1)[0], + rgKey[TestValues[i]]->get_m_rgss(7,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(7,0)[0], + rgKey[TestValues[i]]->get_m_rgss(7,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(7,1)[0] + ); + } + wprintf(L"-----------------\n"); + + //------------------------------------------------------------- + // Now that we've collected the key data, we need to + // translate it to kmx and append to the existing keyboard + //------------------------------------------------------------- + + int nDeadkey = 0; + LPKMX_GROUP gp = new KMX_GROUP[kp->cxGroupArray+4]; // leave space for old + memcpy(gp, kp->dpGroupArray, sizeof(KMX_GROUP) * kp->cxGroupArray); + + // + + // Find the current highest deadkey index + // + + kp->dpGroupArray = gp; + for(UINT i = 0; i < kp->cxGroupArray; i++, gp++) { + //if(gp->fUsingKeys && gp->dpNoMatch == NULL) { // I4550 + // WCHAR *p = gp->dpNoMatch = new WCHAR[4]; + // *p++ = UC_SENTINEL; + // *p++ = CODE_USE; + // *p++ = (WCHAR)(kp->cxGroupArray + 1); + // *p = 0; + //} + LPKMX_KEY kkp = gp->dpKeyArray; + + for(UINT j = 0; j < gp->cxKeyArray; j++, kkp++) { + nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpContext)); + nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpOutput)); + } + } + + kp->cxGroupArray++; + gp = &kp->dpGroupArray[kp->cxGroupArray-1]; + UINT nKeys = 0; + int sab_nr = 0; + for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { + if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { + nKeys+= rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); + //wprintf(L" iKey = %i, Delta: %i -> Sum %i\n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()), nKeys); + sab_nr ++; + } + } + + + nDeadkey++; // ensure a 1-based index above the max deadkey value already in the keyboard + + gp->fUsingKeys = TRUE; + gp->dpMatch = NULL; + gp->dpName = NULL; + gp->dpNoMatch = NULL; + gp->cxKeyArray = nKeys; + gp->dpKeyArray = new KMX_KEY[gp->cxKeyArray]; + nKeys = 0; + // + // Fill in the new rules + // + +int STOP=0; // _S2 LayoutRow: VKToUnderlying should work OK; GetSSValue not checked yet, but this is definitely different + for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { + if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { + //wprintf(L"********************************* I use Key Nr %i\n",iKey); + // for each item, + //wprintf(L" \n iKey = %i, nKeys %i + Delta:\t%i", iKey,nKeys, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState())); + if(rgKey[iKey]->KMX_LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 + nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); + //Inspect_key(&gp->dpKeyArray[nKeys]); + } + } + } + + gp->cxKeyArray = nKeys; + + // + // Add nomatch control to each terminating 'using keys' group // I4550 + // + LPKMX_GROUP gp2 = kp->dpGroupArray; + for(UINT i = 0; i < kp->cxGroupArray - 1; i++, gp2++) { + if(gp2->fUsingKeys && gp2->dpNoMatch == NULL) { + KMX_WCHAR *p = gp2->dpNoMatch = new KMX_WCHAR[4]; + KMX_WCHAR *q = p; + *p++ = UC_SENTINEL; + *p++ = CODE_USE; + *p++ = (KMX_WCHAR)(kp->cxGroupArray); + *p = 0; + + // _S2 TODO not sure if this works OK -> we need to use more shiftstates than base+Shift + // I4550 - Each place we have a nomatch > use(baselayout) (this last group), we need to add all + // the AltGr and ShiftAltGr combinations as rules to allow them to be matched as well. Yes, this + // loop is not very efficient but it's not worthy of optimisation. + // + UINT j; + LPKMX_KEY kkp; + for(j = 0, kkp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kkp++) { + if((kkp->ShiftFlags & (K_CTRLFLAG|K_ALTFLAG|LCTRLFLAG|LALTFLAG|RCTRLFLAG|RALTFLAG)) != 0) { + gp2->cxKeyArray++; + LPKMX_KEY kkp2 = new KMX_KEY[gp2->cxKeyArray]; + memcpy(kkp2, gp2->dpKeyArray, sizeof(KMX_KEY)*(gp2->cxKeyArray-1)); + gp2->dpKeyArray = kkp2; + kkp2 = &kkp2[gp2->cxKeyArray-1]; + kkp2->dpContext = new KMX_WCHAR; *kkp2->dpContext = 0; + kkp2->Key = kkp->Key; + kkp2->ShiftFlags = kkp->ShiftFlags; + kkp2->Line = 0; + KMX_WCHAR *p = kkp2->dpOutput = new KMX_WCHAR[4]; + KMX_WCHAR *q=p; + *p++ = UC_SENTINEL; + *p++ = CODE_USE; + *p++ = (KMX_WCHAR)(kp->cxGroupArray); + *p = 0; + } + } + } + } + + // _S2 TODO not sure if this works OK -> we need to use deadkeys... + // If we have deadkeys, then add a new group to translate the deadkeys per the deadkey tables + // We only do this if not in deadkey conversion mode + // + + if (alDead.size() > 0 && !bDeadkeyConversion) { // I4552 + kp->cxGroupArray++; + + KMX_WCHAR *p = gp->dpMatch = new KMX_WCHAR[4]; + *p++ = UC_SENTINEL; + *p++ = CODE_USE; + *p++ = (KMX_WCHAR) kp->cxGroupArray; + *p = 0; + + gp++; + + gp->fUsingKeys = FALSE; + gp->dpMatch = NULL; + gp->dpName = NULL; + gp->dpNoMatch = NULL; + gp->cxKeyArray = alDead.size(); + LPKMX_KEY kkp = gp->dpKeyArray = new KMX_KEY[alDead.size()]; + + LPKMX_STORE sp = new KMX_STORE[kp->cxStoreArray + alDead.size() * 2]; + memcpy(sp, kp->dpStoreArray, sizeof(KMX_STORE) * kp->cxStoreArray); + + kp->dpStoreArray = sp; + + sp = &sp[kp->cxStoreArray]; + int nStoreBase = kp->cxStoreArray; + kp->cxStoreArray += alDead.size() * 2; + + for(UINT i = 0; i < alDead.size(); i++) { + DeadKey *dk = alDead[i]; + + sp->dpName = NULL; + sp->dwSystemID = 0; + sp->dpString = new KMX_WCHAR[dk->KMX_Count() + 1]; + for(int j = 0; j < dk->KMX_Count(); j++) + sp->dpString[j] = dk->KMX_GetBaseCharacter(j); + sp->dpString[dk->KMX_Count()] = 0; + sp++; + + sp->dpName = NULL; + sp->dwSystemID = 0; + sp->dpString = new KMX_WCHAR[dk->KMX_Count() + 1]; + for(int j = 0; j < dk->KMX_Count(); j++) + sp->dpString[j] = dk->KMX_GetCombinedCharacter(j); + sp->dpString[dk->KMX_Count()] = 0; + sp++; + + kkp->Line = 0; + kkp->ShiftFlags = 0; + kkp->Key = 0; + KMX_WCHAR *p = kkp->dpContext = new KMX_WCHAR[8]; + *p++ = UC_SENTINEL; + *p++ = CODE_DEADKEY; + *p++ = KMX_DeadKeyMap(dk->KMX_DeadCharacter(), &alDead, nDeadkey, FDeadkeys); // I4353 + // *p++ = nDeadkey+i; + *p++ = UC_SENTINEL; + *p++ = CODE_ANY; + *p++ = nStoreBase + i*2 + 1; + *p = 0; + + p = kkp->dpOutput = new KMX_WCHAR[5]; + *p++ = UC_SENTINEL; + *p++ = CODE_INDEX; + *p++ = nStoreBase + i*2 + 2; + *p++ = 2; + *p = 0; + + kkp++; + } + } + //Inspect_kp(kp); +return true; +} + + + +bool KMX_ImportRules_bak(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 + KMX_Loader loader; + const size_t BUF_sz= 256; +//Inspect_kp(kp); + // _S2 do I need that for Linux?? + KMX_WCHAR inputHKL[12]; + u16sprintf(inputHKL,BUF_sz ,L"%08.8x", (unsigned int) u16tol(kbid, NULL, 16)); // _S2 wsprintf(inputHKL, L"%08.8x", (unsigned int) wcstol(kbid, NULL, 16)); + + KMX_HKL hkl = NULL; //_S2 added: but can I do this?? hkl is not needed in Linux?? + + BYTE lpKeyState[256];// = new KeysEx[256]; + std::vector rgKey; //= new VirtualKey[256]; + std::vector alDead; + + rgKey.resize(256); + + // _S2 scroll through OTHER + // Scroll through the Scan Code (SC) values and get the valid Virtual Key (VK) + // values in it. Then, store the SC in each valid VK so it can act as both a + // flag that the VK is valid, and it can store the SC value. + // _S2 this does not find exactly the same keys as the windows version does(windows finds more) + + for(UINT sc = 0x01; sc <= 0x7f; sc++) { + // fills m_vk with the VK of the US keyboard which is not right!! + // ( mcompile win uses MapVirtualKeyEx() to fill m_vk with the VK of the Other keyboard) + // Linux cant get a VK for the US Keyboard using USVirtualKeyToScanCode/ScanCodeToUSVirtualKey + // Linux cannot get a VK for Other Keyboard + // it could return SC if that helps + KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector, keymap); + + // _S2 ToDo + // either it gives the correct rgkeys (all non-char filled with special char) or + // it gives not all rgkeys but nr, a-z are filled correctly + if((key->VK() != 0) ) { + rgKey[key->VK()] = key; + } else { + delete key; + } + } + + for(UINT ke = VK_NUMPAD0; ke <= VK_NUMPAD9; ke++) { + rgKey[ke] = new KMX_VirtualKey(hkl, ke, All_Vector, keymap); + } + + rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE, All_Vector, keymap); + rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL, All_Vector, keymap); + rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL, All_Vector, keymap); + +/* + // _S2 do we need special shift state now or later? + // See if there is a special shift state added + for(UINT vk = 0; vk <= VK_OEM_CLEAR; vk++) { + UINT sc = MapVirtualKeyEx(vk, 0, hkl); + UINT vkL = MapVirtualKeyEx(sc, 1, hkl); + UINT vkR = MapVirtualKeyEx(sc, 3, hkl); + if((vkL != vkR) && (vk != vkL)) { switch(vk) { case VK_LCONTROL: @@ -778,15 +1157,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd std::wstring KeyVal_Other = get_KeyVals_according_to_keycode_and_Shiftstate_new( *keymap, SC_US, ss, caps); - - - - - - - - -// _S2 brackets nor the same in if/else/else if blocks !!!! +// _S2 brackets not the same in if/else/else if blocks !!!! //_S2 TODO do I need that ?? //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { @@ -901,7 +1272,7 @@ int STOP=0; // _S2 LayoutRow: VKToUnderlying should work OK; GetSSValue not che for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { //wprintf(L"********************************* I use Key Nr %i\n",iKey); - // for each item, + // for each item, //wprintf(L" \n iKey = %i, nKeys %i + Delta:\t%i", iKey,nKeys, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState())); if(rgKey[iKey]->KMX_LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); @@ -926,7 +1297,7 @@ int STOP=0; // _S2 LayoutRow: VKToUnderlying should work OK; GetSSValue not che *p = 0; // _S2 TODO not sure if this works OK -> we need to use more shiftstates than base+Shift - // I4550 - Each place we have a nomatch > use(baselayout) (this last group), we need to add all + // I4550 - Each place we have a nomatch > use(baselayout) (this last group), we need to add all // the AltGr and ShiftAltGr combinations as rules to allow them to be matched as well. Yes, this // loop is not very efficient but it's not worthy of optimisation. // diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 34d14173c9..c931dde16f 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -39,6 +39,8 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]); bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 + +bool KMX_ImportRules_bak(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 //bool KMX_Lin_ImportRules_Lin(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 std::vector KMX_FDeadkeys; // I4353 @@ -500,8 +502,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon //wprintf(L" switch with ch: %i (%c)......\n" , ch,ch); switch(ch) { case 0x0000: break; - case 0xFFFF: - KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap); break; + case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap); break; default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); } } @@ -509,7 +510,6 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon KMX_ReportUnconvertedKeyboardRules(kbd); - //if(!KMX_Lin_ImportRules_Lin(kbid, kbd, All_Vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 if(!KMX_ImportRules(kbid, kbd, All_Vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 return FALSE; } From e932ba5c2962664c8553d2a53b1fde1b3dc9ac08 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 11 Dec 2023 19:14:46 +0100 Subject: [PATCH 155/327] feat(linux): mcompile new KMX_ToUnicodeEx --- linux/mcompile/keymap/helpers.cpp | 531 ++++++++++++++++++++ linux/mcompile/keymap/keymap.cpp | 92 +++- linux/mcompile/keymap/keymap.h | 5 + linux/mcompile/keymap/mc_import_rules.cpp | 584 ++-------------------- linux/mcompile/keymap/mcompile.cpp | 4 +- 5 files changed, 658 insertions(+), 558 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 8e5482d78d..74fab133b9 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -1820,6 +1820,500 @@ int stop=99; } +/* +bool KMX_LayoutRow_Lin(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,v_dw_3D &All_Vector, GdkKeymap * keymap) { // I4552 + // Get the CAPSLOCK value + + +bool b1= this->KMX_IsCapsEqualToShift(); +bool b2= this->KMX_IsSGCAPS(); +bool b3= this->KMX_IsAltGrCapsEqualToAltGrShift(); +bool b4= this->KMX_IsXxxxGrCapsEqualToXxxxShift(); + +int i1 = this->KMX_IsCapsEqualToShift() ? 1 : 0; +int i2 = this->KMX_IsSGCAPS() ? 2 : 0; +int i3 = this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0; +int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; + + + // _S2 original: + /int capslock = + (this->IsCapsEqualToShift() ? 1 : 0) | + (this->IsSGCAPS() ? 2 : 0) | + (this->IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | + (this->IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0);/ + + +// _S2 change! only for testing helps to force filling rgkey[VK_DE] +int capslock; + + // numbers: + if( (this->m_vk>=48) && (this->m_vk<=57) ) { + capslock = + (this->KMX_IsCapsEqualToShift() ? 0 : 1) | + (this->KMX_IsSGCAPS() ? 2 : 0) | + (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | + (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + } + // characters: + else if( (this->m_vk>=65) && (this->m_vk<=90) ) { + capslock = + (this->KMX_IsCapsEqualToShift() ? 1 : 0) | + (this->KMX_IsSGCAPS() ? 2 : 0) | + (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | + (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + } + // ä,ö,ü: + else if( (this->m_vk==32) ||(this->m_vk==186) ||(this->m_vk==192)|| (this->m_vk==222) ) { + capslock = + (this->KMX_IsCapsEqualToShift() ? 1 : 0) | + (this->KMX_IsSGCAPS() ? 2 : 0) | + (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | + (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + } + // < and _: + else if( (this->m_vk==189) || (this->m_vk==220) || (this->m_vk==221) || (this->m_vk==226) ) { + capslock = + (this->KMX_IsCapsEqualToShift() ? 1 : 0) | + (this->KMX_IsSGCAPS() ? 2 : 0) | + (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | + (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + } + // punctuation Char: + else { + capslock = + (this->KMX_IsCapsEqualToShift() ? 0 : 1) | + (this->KMX_IsSGCAPS() ? 2 : 0) | + (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | + (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + } + + + + for (int ss = 0; ss <= MaxShiftState; ss++) { + if (ss == Menu || ss == ShftMenu) { + // Alt and Shift+Alt don't work, so skip them + continue; + } + for (int caps = 0; caps <= 1; caps++) { + std::wstring st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); + PKMX_WCHAR p; // was PWSTR p; + PKMX_WCHAR q; + + if (st.size() == 0) { + // No character assigned here + } + // _S2 deadkeys don't work yet + else if (this->m_rgfDeadKey[(int)ss][caps]) { + // It's a dead key, append an @ sign. + key->dpContext = new KMX_WCHAR[1]; + *key->dpContext = 0; + key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); + // _S2 this fun returns the shifted Char it goes wrog for numbers, special here!! + //key->Key = KMX_VKUnderlyingLayoutToVKUS(All_Vector,this->VK()); + key->Key = KMX_VKUnderlyingLayoutToVKUS_GDK(keymap,this->VK()); + key->Line = 0; + + if(bDeadkeyConversion) { // I4552 + p = key->dpOutput = new KMX_WCHAR[2]; + *p++ = st[0]; + *p = 0; + } else { + p = key->dpOutput = new KMX_WCHAR[4]; + *p++ = UC_SENTINEL; + *p++ = CODE_DEADKEY; + *p++ = KMX_DeadKeyMap(st[0], deadkeys, deadkeyBase, &KMX_FDeadkeys); // I4353 + *p = 0; + } + key++; + } else { + bool isvalid = true; + for (size_t ich = 0; ich < st.size(); ich++) { + if(st[ich] < 0x20 || st[ich] == 0x7F) { isvalid=false; break; } + } + if(isvalid) { + // wrong function!! + //key->Key = KMX_VKUnderlyingLayoutToVKUS(All_Vector,this->VK()); + key->Key = KMX_VKUnderlyingLayoutToVKUS_GDK(keymap,this->VK()); + std::wstring w1_S2 = get_m_rgss(ss,caps); + //wprintf(L"\n KMX_VKUnderlyingLayoutToVKUS_GD writes %ls %c ( from %i) \n",w1_S2.c_str(), key->Key , this->VK()); + + if(key->Key != this->VK()) +wprintf(L"\n key->Key AND this->VK() different %i ( from %i) \n", key->Key , this->VK()); + + + + + wprintf(L" this->VK(): %i ", this->VK()); + key->Line = 0; + // _S2 _differences in sstateflag probably from here and KMX_IsCapsEqualToShift... + key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); + key->dpContext = new KMX_WCHAR; *key->dpContext = 0; + p = key->dpOutput = new KMX_WCHAR[st.size() + 1]; + for(size_t ich = 0; ich < st.size(); ich++) { + q=p; + *p++ = st[ich];} + *p = 0; + key++; + } + } + } + } + return true; + } +*/ + + + +/*bool KMX_ImportRules_bak(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 + KMX_Loader loader; + const size_t BUF_sz= 256; +//Inspect_kp(kp); + // _S2 do I need that for Linux?? + KMX_WCHAR inputHKL[12]; + u16sprintf(inputHKL,BUF_sz ,L"%08.8x", (unsigned int) u16tol(kbid, NULL, 16)); // _S2 wsprintf(inputHKL, L"%08.8x", (unsigned int) wcstol(kbid, NULL, 16)); + + KMX_HKL hkl = NULL; //_S2 added: but can I do this?? hkl is not needed in Linux?? + + BYTE lpKeyState[256];// = new KeysEx[256]; + std::vector rgKey; //= new VirtualKey[256]; + std::vector alDead; + + rgKey.resize(256); + + // _S2 scroll through OTHER + // Scroll through the Scan Code (SC) values and get the valid Virtual Key (VK) + // values in it. Then, store the SC in each valid VK so it can act as both a + // flag that the VK is valid, and it can store the SC value. + // _S2 this does not find exactly the same keys as the windows version does(windows finds more) + + for(UINT sc = 0x01; sc <= 0x7f; sc++) { + // fills m_vk with the VK of the US keyboard which is not right!! + // ( mcompile win uses MapVirtualKeyEx() to fill m_vk with the VK of the Other keyboard) + // Linux cant get a VK for the US Keyboard using USVirtualKeyToScanCode/ScanCodeToUSVirtualKey + // Linux cannot get a VK for Other Keyboard + // it could return SC if that helps + KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector, keymap); + + // _S2 ToDo + // either it gives the correct rgkeys (all non-char filled with special char) or + // it gives not all rgkeys but nr, a-z are filled correctly + if((key->VK() != 0) ) { + rgKey[key->VK()] = key; + } else { + delete key; + } + } + + for(UINT ke = VK_NUMPAD0; ke <= VK_NUMPAD9; ke++) { + rgKey[ke] = new KMX_VirtualKey(hkl, ke, All_Vector, keymap); + } + + rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE, All_Vector, keymap); + rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL, All_Vector, keymap); + rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL, All_Vector, keymap); + + + // _S2 do we need special shift state now or later? + // See if there is a special shift state added + for(UINT vk = 0; vk <= VK_OEM_CLEAR; vk++) { + UINT sc = MapVirtualKeyEx(vk, 0, hkl); + UINT vkL = MapVirtualKeyEx(sc, 1, hkl); + UINT vkR = MapVirtualKeyEx(sc, 3, hkl); + if((vkL != vkR) && + (vk != vkL)) { + switch(vk) { + case VK_LCONTROL: + case VK_RCONTROL: + case VK_LSHIFT: + case VK_RSHIFT: + case VK_LMENU: + case VK_RMENU: + break; + + default: + loader.Set_XxxxVk(vk); + break; + } + } + } + + // _S2 test rgkey can go later + for(UINT iKey = 100; iKey < rgKey.size(); iKey++) { + if(rgKey[iKey] != NULL) { + wprintf(L" Key Nr %i is available\n",iKey); + } + } + + // _S2 in this part we skip shiftstates 4, 5, 8, 9 + for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { + if(rgKey[iKey] != NULL) { + WCHAR sbBuffer[256]; // Scratchpad we use many places + + UINT VK_Other = Lin_KM__map(iKey, All_Vector); + + for(ShiftState ss = Base; ss <= loader.MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { + if(ss == Menu || ss == ShftMenu) { + // Alt and Shift+Alt don't work, so skip them + continue; + } + + KMX_DWORD SC_US = get_KeyCode_fromVKUS(iKey); + + for(int caps = 0; caps <= 1; caps++) { + //_S2 TODO get char - do I need rc ?? ( was rc = ToUnicodeEx...) + std::wstring KeyVal_Other = get_KeyVals_according_to_keycode_and_Shiftstate_new( *keymap, SC_US, ss, caps); + + +// _S2 brackets not the same in if/else/else if blocks !!!! + + //_S2 TODO do I need that ?? + //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { + if(KeyVal_Other == L"") { + //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); + rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps)); + } + + //_S2 TODO + //else // if rc ==1 : it got 1 char && +40 in Buffer CTRl pressed { + //It's dealing with control characters. If ToUnicodeEx gets VK_A with the Ctrl key pressed, + //it will write 0x01 to sBuffer[0] , without Ctrl it's 0x41. The if detects this case. + if( (ss == Ctrl || ss == ShftCtrl) /*&& CTRl +0x40 in the buffer ( which indicates a ctrl press) ) { + continue; + } + + //rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps==0)); + rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps)); + + + //_S2 TODO + // dk > 65000??? + // _S2 handle deadkeys later + // if rc <0: it got a deadkey { + // fill m_rgss and m_rgfDeadkey and alDead + //SET_SHIFTSTATES( deadkey) //sbuffer is value out of ToUnicodeEx / AllVector + // do more stuff for deadkeys... + // } from rc<0 + } + } + } + } + + //_S2 this gan co later + std::vector< int > TestValues = {48,49,50,51,52,53,54,55,56,57,65,66,67,88,89,90, 186,187,188,189,191,191,192,219,220,221,222,226}; + wprintf(L"-----------------\nNow some tests:\n"); + wprintf(L" Base Caps Shift Shfit+Caps MenuCtrl MenuCtrl+Caps \n"); + + for ( int i=0; i < (int) TestValues.size();i++) { + std::wstring wws = rgKey[TestValues[i]]->get_m_rgss(0,0); + wprintf(L"Results for %i\t: %ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \n", TestValues[i], + rgKey[TestValues[i]]->get_m_rgss(0,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(0,0)[0], + rgKey[TestValues[i]]->get_m_rgss(0,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(0,1)[0], + rgKey[TestValues[i]]->get_m_rgss(1,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(1,0)[0], + rgKey[TestValues[i]]->get_m_rgss(1,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(1,1)[0], + rgKey[TestValues[i]]->get_m_rgss(6,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(6,0)[0], + rgKey[TestValues[i]]->get_m_rgss(6,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(6,1)[0], + rgKey[TestValues[i]]->get_m_rgss(7,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(7,0)[0], + rgKey[TestValues[i]]->get_m_rgss(7,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(7,1)[0] + ); + } + wprintf(L"-----------------\n"); + + //------------------------------------------------------------- + // Now that we've collected the key data, we need to + // translate it to kmx and append to the existing keyboard + //------------------------------------------------------------- + + int nDeadkey = 0; + LPKMX_GROUP gp = new KMX_GROUP[kp->cxGroupArray+4]; // leave space for old + memcpy(gp, kp->dpGroupArray, sizeof(KMX_GROUP) * kp->cxGroupArray); + + // + + // Find the current highest deadkey index + // + + kp->dpGroupArray = gp; + for(UINT i = 0; i < kp->cxGroupArray; i++, gp++) { + //if(gp->fUsingKeys && gp->dpNoMatch == NULL) { // I4550 + // WCHAR *p = gp->dpNoMatch = new WCHAR[4]; + // *p++ = UC_SENTINEL; + // *p++ = CODE_USE; + // *p++ = (WCHAR)(kp->cxGroupArray + 1); + // *p = 0; + //} + LPKMX_KEY kkp = gp->dpKeyArray; + + for(UINT j = 0; j < gp->cxKeyArray; j++, kkp++) { + nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpContext)); + nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpOutput)); + } + } + + kp->cxGroupArray++; + gp = &kp->dpGroupArray[kp->cxGroupArray-1]; + UINT nKeys = 0; + int sab_nr = 0; + for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { + if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { + nKeys+= rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); + //wprintf(L" iKey = %i, Delta: %i -> Sum %i\n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()), nKeys); + sab_nr ++; + } + } + + + nDeadkey++; // ensure a 1-based index above the max deadkey value already in the keyboard + + gp->fUsingKeys = TRUE; + gp->dpMatch = NULL; + gp->dpName = NULL; + gp->dpNoMatch = NULL; + gp->cxKeyArray = nKeys; + gp->dpKeyArray = new KMX_KEY[gp->cxKeyArray]; + nKeys = 0; + // + // Fill in the new rules + // + +int STOP=0; // _S2 LayoutRow: VKToUnderlying should work OK; GetSSValue not checked yet, but this is definitely different + for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { + if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { + //wprintf(L"********************************* I use Key Nr %i\n",iKey); + // for each item, + //wprintf(L" \n iKey = %i, nKeys %i + Delta:\t%i", iKey,nKeys, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState())); + if(rgKey[iKey]->KMX_LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 + nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); + //Inspect_key(&gp->dpKeyArray[nKeys]); + } + } + } + + gp->cxKeyArray = nKeys; + + // + // Add nomatch control to each terminating 'using keys' group // I4550 + // + LPKMX_GROUP gp2 = kp->dpGroupArray; + for(UINT i = 0; i < kp->cxGroupArray - 1; i++, gp2++) { + if(gp2->fUsingKeys && gp2->dpNoMatch == NULL) { + KMX_WCHAR *p = gp2->dpNoMatch = new KMX_WCHAR[4]; + KMX_WCHAR *q = p; + *p++ = UC_SENTINEL; + *p++ = CODE_USE; + *p++ = (KMX_WCHAR)(kp->cxGroupArray); + *p = 0; + + // _S2 TODO not sure if this works OK -> we need to use more shiftstates than base+Shift + // I4550 - Each place we have a nomatch > use(baselayout) (this last group), we need to add all + // the AltGr and ShiftAltGr combinations as rules to allow them to be matched as well. Yes, this + // loop is not very efficient but it's not worthy of optimisation. + // + UINT j; + LPKMX_KEY kkp; + for(j = 0, kkp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kkp++) { + if((kkp->ShiftFlags & (K_CTRLFLAG|K_ALTFLAG|LCTRLFLAG|LALTFLAG|RCTRLFLAG|RALTFLAG)) != 0) { + gp2->cxKeyArray++; + LPKMX_KEY kkp2 = new KMX_KEY[gp2->cxKeyArray]; + memcpy(kkp2, gp2->dpKeyArray, sizeof(KMX_KEY)*(gp2->cxKeyArray-1)); + gp2->dpKeyArray = kkp2; + kkp2 = &kkp2[gp2->cxKeyArray-1]; + kkp2->dpContext = new KMX_WCHAR; *kkp2->dpContext = 0; + kkp2->Key = kkp->Key; + kkp2->ShiftFlags = kkp->ShiftFlags; + kkp2->Line = 0; + KMX_WCHAR *p = kkp2->dpOutput = new KMX_WCHAR[4]; + KMX_WCHAR *q=p; + *p++ = UC_SENTINEL; + *p++ = CODE_USE; + *p++ = (KMX_WCHAR)(kp->cxGroupArray); + *p = 0; + } + } + } + } + + // _S2 TODO not sure if this works OK -> we need to use deadkeys... + // If we have deadkeys, then add a new group to translate the deadkeys per the deadkey tables + // We only do this if not in deadkey conversion mode + // + + if (alDead.size() > 0 && !bDeadkeyConversion) { // I4552 + kp->cxGroupArray++; + + KMX_WCHAR *p = gp->dpMatch = new KMX_WCHAR[4]; + *p++ = UC_SENTINEL; + *p++ = CODE_USE; + *p++ = (KMX_WCHAR) kp->cxGroupArray; + *p = 0; + + gp++; + + gp->fUsingKeys = FALSE; + gp->dpMatch = NULL; + gp->dpName = NULL; + gp->dpNoMatch = NULL; + gp->cxKeyArray = alDead.size(); + LPKMX_KEY kkp = gp->dpKeyArray = new KMX_KEY[alDead.size()]; + + LPKMX_STORE sp = new KMX_STORE[kp->cxStoreArray + alDead.size() * 2]; + memcpy(sp, kp->dpStoreArray, sizeof(KMX_STORE) * kp->cxStoreArray); + + kp->dpStoreArray = sp; + + sp = &sp[kp->cxStoreArray]; + int nStoreBase = kp->cxStoreArray; + kp->cxStoreArray += alDead.size() * 2; + + for(UINT i = 0; i < alDead.size(); i++) { + DeadKey *dk = alDead[i]; + + sp->dpName = NULL; + sp->dwSystemID = 0; + sp->dpString = new KMX_WCHAR[dk->KMX_Count() + 1]; + for(int j = 0; j < dk->KMX_Count(); j++) + sp->dpString[j] = dk->KMX_GetBaseCharacter(j); + sp->dpString[dk->KMX_Count()] = 0; + sp++; + + sp->dpName = NULL; + sp->dwSystemID = 0; + sp->dpString = new KMX_WCHAR[dk->KMX_Count() + 1]; + for(int j = 0; j < dk->KMX_Count(); j++) + sp->dpString[j] = dk->KMX_GetCombinedCharacter(j); + sp->dpString[dk->KMX_Count()] = 0; + sp++; + + kkp->Line = 0; + kkp->ShiftFlags = 0; + kkp->Key = 0; + KMX_WCHAR *p = kkp->dpContext = new KMX_WCHAR[8]; + *p++ = UC_SENTINEL; + *p++ = CODE_DEADKEY; + *p++ = KMX_DeadKeyMap(dk->KMX_DeadCharacter(), &alDead, nDeadkey, FDeadkeys); // I4353 + // *p++ = nDeadkey+i; + *p++ = UC_SENTINEL; + *p++ = CODE_ANY; + *p++ = nStoreBase + i*2 + 1; + *p = 0; + + p = kkp->dpOutput = new KMX_WCHAR[5]; + *p++ = UC_SENTINEL; + *p++ = CODE_INDEX; + *p++ = nStoreBase + i*2 + 2; + *p++ = 2; + *p = 0; + + kkp++; + } + } + //Inspect_kp(kp); +return true; +}*/ + + + + // _S2 TODO @@ -2393,3 +2887,40 @@ std::wstring get_KeyVals_according_to_keycode_and_Shiftstate(GdkKeymap *keymap, return inOther; }*/ + +/*int KMX_ToUnicodeEx(GdkKeymap *keymap, guint ScanCode, const BYTE *lpKeyState, PWCHAR pwszBuff, int cchBuff, int shift_state, int caps) { + +int IIII = ShiftState(shift_state); + KMX_DWORD kvl= getKeyvalsFromKeyCode(keymap, ScanCode, shift_state); + + std::wstring KeyVal_Other = get_KeyVals_according_to_keycode_and_Shiftstate_new( keymap, ScanCode, ShiftState(shift_state), caps); + + WCHAR kv_wchar = (WCHAR) kvl; + PWCHAR kp_v_wchar = &kv_wchar; + pwszBuff= kp_v_wchar; + + //std::wstring wws= std::wstring(1, kvl); + KMX_WCHAR DeadKey; + //std::wstring wws= + KMX_WCHAR val= KMX_CharFromSC(keymap, shift_state, ScanCode, &DeadKey); +KMX_DWORD dw= getKeyvalsFromKeyCode(keymap, ScanCode, ShiftState(shift_state)); + +//std::wstring abc= get_KeyVals_according_to_keycode_and_Shiftstate_new(keymap, ScanCode, ShiftState(shift_state), 0); +WCHAR wchr= (WCHAR) dw; +PWCHAR pwchr = &wchr; +//PWCHAR pwcp2= (PWCHAR) abc.c_str(); + PWCHAR wwch= (PWCHAR) wws.c_str(); +PWCHAR KeyVal_Otherpwcp2= (PWCHAR) KeyVal_Other.c_str(); + //pwszBuff[0]= *pwchr; + pwszBuff[0]= *KeyVal_Otherpwcp2; + + int rc; + + if((kvl >= 0xfe50) && (kvl <= 0xfe93) ) + rc = -1; + else rc = 1; + + return rc; + +}*/ + diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 6e14e78b9a..7f5ffb60e5 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -355,8 +355,9 @@ KMX_DWORD getKeyvalsFromKeyCode(GdkKeymap *keymap, guint keycode, int shift_stat out =(KMX_DWORD) keyvals[shift_state_pos]; // _S2 if out of range of what ( ascii??) return 0 or other value ? - if (out > 255) { - wprintf(L"out of range: found value out( %i) for keycode = %i /shift_state_pos %i (49= TLDE 21= VK_EQUALS on US keyboard) \n", out,keycode,shift_state_pos); + //if (out > 255) { + if ( (out >= deadkey_min) && (out <= deadkey_max) ) { + wprintf(L"out of range: found deadkey value out( %i) for keycode = %i /shift_state_pos %i (49= TLDE 21= VK_EQUALS on US keyboard) \n", out,keycode,shift_state_pos); //out = 0; } @@ -485,23 +486,47 @@ std::wstring convert_DeadkeyValues_ToChar(int in) { KMX_DWORD lname; - if (in < deadkeyThreshold) { + if (in < deadkeyThreshold) { // no deadkey; no Unicode if (!IsKeymanUsedKeyVal(std::wstring(1, in))) return L"\0"; return std::wstring(1, in); - } else { - std::string long_name((const char*) gdk_keyval_name (in)); // 65106 => "dead_circumflex " - lname = convertNamesToIntegerValue( wstring_from_string(long_name)); // "dead_circumflex " => 94 + } + else { + std::string long_name((const char*) gdk_keyval_name (in)); + + if ( long_name.substr (0,2) == "U+" ) // U+... Unicode value + return CodePointToWString(in-0x1000000); + + lname = convertNamesToIntegerValue( wstring_from_string(long_name)); // 65106 => "dead_circumflex " => 94 => "^" if (lname != returnIfCharInvalid) { - std::wstring ss = std::wstring(1, lname ); - return std::wstring(1, lname ); // 94 => "^" - } else + return std::wstring(1, lname ); + } + else return L"\0"; } return L"\0"; } +std::wstring CodePointToWString(unsigned int codepoint) { + std::wstring str; + + if constexpr (sizeof(wchar_t) > 2) { + str = static_cast(codepoint); + } + else if (codepoint <= 0xFFFF) { + str = static_cast(codepoint); + } + else { + codepoint -= 0x10000; + str.resize(2); + str[0] = static_cast(0xD800 + ((codepoint >> 10) & 0x3FF)); + str[1] = static_cast(0xDC00 + (codepoint & 0x3FF)); + } + + return str; +} + std::wstring get_KeyVals_according_to_keycode_and_Shiftstate_new(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ GdkModifierType consumed; @@ -509,50 +534,65 @@ std::wstring get_KeyVals_according_to_keycode_and_Shiftstate_new(GdkKeymap *key guint *keyvals; gint count; - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return L"\0"; - //return L"1"; - //unshifted + //unshifted (shiftstate: 0) if (( ss == Base ) && ( caps == 0 )) { GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); } - //SHIFT+CAPS - else if ( ( ss == Shft ) && ( caps ==1 )) { - GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); + //caps (shiftstate: 0) + else if (( ss == Base ) && ( caps == 1 )) { + GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); } - //Shift + //Shift (shiftstate: 1) else if (( ss == Shft ) && ( caps == 0 )) { GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); std::wstring rV1= std::wstring(1, (int) *keyvals); } - //caps - else if (( ss == Base ) && ( caps == 1 )) { - GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); + //SHIFT+CAPS (shiftstate: 1) + else if ( ( ss == Shft ) && ( caps ==1 )) { + GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); } - //ALT-GR + // Ctrl (shiftstate: 2) + // SHIFT+Ctrl (shiftstate: 2) + + //ALT-GR (shiftstate: 6) else if (( ss == MenuCtrl ) && ( caps == 0 )){ - //GdkModifierType MOD_AltGr = (GdkModifierType) ( 144 ); GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK) ); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); } - //ALT-GR + //ALT-GR +CAPS (shiftstate: 6) else if (( ss == MenuCtrl ) && ( caps == 1 )){ - //GdkModifierType MOD_AltGr = (GdkModifierType) ( 146 ); GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); } - return convert_DeadkeyValues_ToChar((int) *keyvals);; + //ALT-GR (shiftstate: 7) + else if (( ss == ShftMenuCtrl ) && ( caps == 0 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR +CAPS (shiftstate: 7) + else if (( ss == ShftMenuCtrl ) && ( caps == 1 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + else + return L"\0"; + + return std::wstring(1, (int) *keyvals); + //return convert_DeadkeyValues_ToChar((int) *keyvals); } diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index e50e764593..cbae5a5959 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -473,6 +473,8 @@ static KMX_DWORD returnIfCharInvalid = 0; //_S2 QUESTION Which threshold ( from what int value onwards is a character considered deadkey? 65000 28000?, > 255? ?? static KMX_DWORD deadkeyThreshold = 65000; +static KMX_DWORD deadkey_min = 0xfe50; +static KMX_DWORD deadkey_max = 0xfe93; int map_VKShiftState_to_Lin(int VKShiftState); @@ -523,6 +525,8 @@ KMX_DWORD get_KeyCode_fromVKUS( KMX_DWORD VK_US); bool IsKeymanUsedKeyVal(std::wstring Keyval); +std::wstring CodePointToWString(unsigned int codepoint); + //UINT find_SC_Other_from_SC_US_GDK(UINT vk_US_187,GdkKeymap *keymap); UINT map_Ikey_DE(UINT iKey); @@ -535,4 +539,5 @@ const int Lin_KM__map(int i, v_dw_3D &All_Vector); KMX_DWORD mapChar_To_VK(KMX_DWORD chr ); KMX_DWORD mapVK_To_char(KMX_DWORD SC ); + # endif /*KEYMAP_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 103c031d78..0afa2be717 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -190,40 +190,40 @@ public: } bool KMX_IsSGCAPS() { - std::wstring stBase = this->KMX_GetShiftState(Base, false); - std::wstring stShift = this->KMX_GetShiftState(Shft, false); - std::wstring stCaps = this->KMX_GetShiftState(Base, true); - std::wstring stShiftCaps = this->KMX_GetShiftState(Shft, true); + std::wstring stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß + std::wstring stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? + std::wstring stCaps = this->KMX_GetShiftState(Base, true); // 0,1 A 4 ẞ + std::wstring stShiftCaps = this->KMX_GetShiftState(Shft, true); // 1,1 a $ ? return ( ((stCaps.size() > 0) && - (stBase.compare(stCaps) != 0) && - (stShift.compare(stCaps) != 0)) || + (stBase.compare(stCaps) != 0) && // stBase != stCaps + (stShift.compare(stCaps) != 0)) || // stShift!= stCaps ((stShiftCaps.size() > 0) && - (stBase.compare(stShiftCaps) != 0) && - (stShift.compare(stShiftCaps) != 0))); + (stBase.compare(stShiftCaps) != 0) && // stBase != stShiftCaps + (stShift.compare(stShiftCaps) != 0))); // stShift!= stShiftCaps } // _S2 is character () bool KMX_IsCapsEqualToShift() { std::wstring stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß - std::wstring stShift = this->KMX_GetShiftState(Shft, false); // 0,0 A $ ? - std::wstring stCaps = this->KMX_GetShiftState(Base, true); // 0,0 A 4 ẞ + std::wstring stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? + std::wstring stCaps = this->KMX_GetShiftState(Base, true); // 0,1 A 4 ẞ return ( - (stBase.size() > 0) && // char inside - (stShift.size() > 0) && // char inside + (stBase.size() > 0) && // unshifted char inside + (stShift.size() > 0) && // shifted char inside (stBase.compare(stShift) != 0) && // stBase != stShft (stShift.compare(stCaps) == 0)); // stShft == stCaps } bool KMX_IsAltGrCapsEqualToAltGrShift() { - std::wstring stBase = this->KMX_GetShiftState(MenuCtrl, false); - std::wstring stShift = this->KMX_GetShiftState(ShftMenuCtrl, false); - std::wstring stCaps = this->KMX_GetShiftState(MenuCtrl, true); + std::wstring stBase = this->KMX_GetShiftState(MenuCtrl, false); // 0,0 + std::wstring stShift = this->KMX_GetShiftState(ShftMenuCtrl, false); // 1,0 + std::wstring stCaps = this->KMX_GetShiftState(MenuCtrl, true); // 0,1 return ( - (stBase.size() > 0) && - (stShift.size() > 0) && - (stBase.compare(stShift) != 0) && - (stShift.compare(stCaps) == 0)); + (stBase.size() > 0) && // unshifted MenuCtrl/AltGr char inside + (stShift.size() > 0) && // shifted MenuCtrl/AltGr char inside + (stBase.compare(stShift) != 0) && // stBase != stShft + (stShift.compare(stCaps) == 0)); // stShft == stCaps } bool KMX_IsXxxxGrCapsEqualToXxxxShift() { @@ -301,8 +301,8 @@ UINT KMX_GetShiftStateValue(int capslock, int caps, ShiftState ss) { bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,v_dw_3D &All_Vector, GdkKeymap * keymap) { // I4552 // Get the CAPSLOCK value - -bool b1= this->KMX_IsCapsEqualToShift(); +// _S2 needs to go later // this should be true for char, number, special +bool b1= this->KMX_IsCapsEqualToShift(); // but is false for numbers and special bool b2= this->KMX_IsSGCAPS(); bool b3= this->KMX_IsAltGrCapsEqualToAltGrShift(); bool b4= this->KMX_IsXxxxGrCapsEqualToXxxxShift(); @@ -312,8 +312,7 @@ int i2 = this->KMX_IsSGCAPS() ? 2 : 0; int i3 = this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0; int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; - - // _S2 original: + // _S2 TODO capslock is not calculated corectly for linux. therefore key->ShiftFlags will be wrong for numbers, special characters int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | (this->KMX_IsSGCAPS() ? 2 : 0) | @@ -334,7 +333,7 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; if (st.size() == 0) { // No character assigned here } - // _S2 deadkeys don't work yet + // _S2 TODO deadkeys don't work yet/ if true is in m_rgfDeadKey else if (this->m_rgfDeadKey[(int)ss][caps]) { // It's a dead key, append an @ sign. key->dpContext = new KMX_WCHAR[1]; @@ -385,147 +384,6 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; } return true; } - - bool KMX_LayoutRow_Lin(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,v_dw_3D &All_Vector, GdkKeymap * keymap) { // I4552 - // Get the CAPSLOCK value - - -bool b1= this->KMX_IsCapsEqualToShift(); -bool b2= this->KMX_IsSGCAPS(); -bool b3= this->KMX_IsAltGrCapsEqualToAltGrShift(); -bool b4= this->KMX_IsXxxxGrCapsEqualToXxxxShift(); - -int i1 = this->KMX_IsCapsEqualToShift() ? 1 : 0; -int i2 = this->KMX_IsSGCAPS() ? 2 : 0; -int i3 = this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0; -int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; - - - // _S2 original: - /*int capslock = - (this->IsCapsEqualToShift() ? 1 : 0) | - (this->IsSGCAPS() ? 2 : 0) | - (this->IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0);*/ - - -// _S2 change! only for testing helps to force filling rgkey[VK_DE] -int capslock; - - // numbers: - if( (this->m_vk>=48) && (this->m_vk<=57) ) { - capslock = - (this->KMX_IsCapsEqualToShift() ? 0 : 1) | - (this->KMX_IsSGCAPS() ? 2 : 0) | - (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); - } - // characters: - else if( (this->m_vk>=65) && (this->m_vk<=90) ) { - capslock = - (this->KMX_IsCapsEqualToShift() ? 1 : 0) | - (this->KMX_IsSGCAPS() ? 2 : 0) | - (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); - } - // ä,ö,ü: - else if( (this->m_vk==32) ||(this->m_vk==186) ||(this->m_vk==192)|| (this->m_vk==222) ) { - capslock = - (this->KMX_IsCapsEqualToShift() ? 1 : 0) | - (this->KMX_IsSGCAPS() ? 2 : 0) | - (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); - } - // < and _: - else if( (this->m_vk==189) || (this->m_vk==220) || (this->m_vk==221) || (this->m_vk==226) ) { - capslock = - (this->KMX_IsCapsEqualToShift() ? 1 : 0) | - (this->KMX_IsSGCAPS() ? 2 : 0) | - (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); - } - // punctuation Char: - else { - capslock = - (this->KMX_IsCapsEqualToShift() ? 0 : 1) | - (this->KMX_IsSGCAPS() ? 2 : 0) | - (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); - } - - - - for (int ss = 0; ss <= MaxShiftState; ss++) { - if (ss == Menu || ss == ShftMenu) { - // Alt and Shift+Alt don't work, so skip them - continue; - } - for (int caps = 0; caps <= 1; caps++) { - std::wstring st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); - PKMX_WCHAR p; // was PWSTR p; - PKMX_WCHAR q; - - if (st.size() == 0) { - // No character assigned here - } - // _S2 deadkeys don't work yet - else if (this->m_rgfDeadKey[(int)ss][caps]) { - // It's a dead key, append an @ sign. - key->dpContext = new KMX_WCHAR[1]; - *key->dpContext = 0; - key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); - // _S2 this fun returns the shifted Char it goes wrog for numbers, special here!! - //key->Key = KMX_VKUnderlyingLayoutToVKUS(All_Vector,this->VK()); - key->Key = KMX_VKUnderlyingLayoutToVKUS_GDK(keymap,this->VK()); - key->Line = 0; - - if(bDeadkeyConversion) { // I4552 - p = key->dpOutput = new KMX_WCHAR[2]; - *p++ = st[0]; - *p = 0; - } else { - p = key->dpOutput = new KMX_WCHAR[4]; - *p++ = UC_SENTINEL; - *p++ = CODE_DEADKEY; - *p++ = KMX_DeadKeyMap(st[0], deadkeys, deadkeyBase, &KMX_FDeadkeys); // I4353 - *p = 0; - } - key++; - } else { - bool isvalid = true; - for (size_t ich = 0; ich < st.size(); ich++) { - if(st[ich] < 0x20 || st[ich] == 0x7F) { isvalid=false; break; } - } - if(isvalid) { - // wrong function!! - //key->Key = KMX_VKUnderlyingLayoutToVKUS(All_Vector,this->VK()); - key->Key = KMX_VKUnderlyingLayoutToVKUS_GDK(keymap,this->VK()); - std::wstring w1_S2 = get_m_rgss(ss,caps); - //wprintf(L"\n KMX_VKUnderlyingLayoutToVKUS_GD writes %ls %c ( from %i) \n",w1_S2.c_str(), key->Key , this->VK()); - - if(key->Key != this->VK()) -wprintf(L"\n key->Key AND this->VK() different %i ( from %i) \n", key->Key , this->VK()); - - - - - wprintf(L" this->VK(): %i ", this->VK()); - key->Line = 0; - // _S2 _differences in sstateflag probably from here and KMX_IsCapsEqualToShift... - key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); - key->dpContext = new KMX_WCHAR; *key->dpContext = 0; - p = key->dpOutput = new KMX_WCHAR[st.size() + 1]; - for(size_t ich = 0; ich < st.size(); ich++) { - q=p; - *p++ = st[ich];} - *p = 0; - key++; - } - } - } - } - return true; - } }; class KMX_Loader { @@ -565,7 +423,6 @@ public: bool IsControlChar(wchar_t ch) { return (ch < 0x0020) || (ch >= 0x007F && ch <= 0x009F); } - DeadKey *ProcessDeadKey( UINT iKeyDead, // The index into the VirtualKey of the dead key ShiftState shiftStateDead, // The shiftstate that contains the dead key @@ -677,6 +534,19 @@ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { return n; } +int KMX_ToUnicodeEx(GdkKeymap *keymap, guint ScanCode, const BYTE *lpKeyState, PWCHAR pwszBuff, int cchBuff, int shift_state, int caps) { + + KMX_DWORD kvl= getKeyvalsFromKeyCode(keymap, ScanCode, shift_state); + + std::wstring character = get_KeyVals_according_to_keycode_and_Shiftstate_new( keymap, ScanCode, ShiftState(shift_state), caps); + pwszBuff[0]= * (PWCHAR) character.c_str(); + + if((kvl >= 0xfe50) && (kvl <= 0xfe93)) + return -1; + else + return 1; +} + bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 KMX_Loader loader; const size_t BUF_sz= 256; @@ -707,9 +577,6 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd // it could return SC if that helps KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector, keymap); - // _S2 ToDo - // either it gives the correct rgkeys (all non-char filled with special char) or - // it gives not all rgkeys but nr, a-z are filled correctly if((key->VK() != 0) ) { rgKey[key->VK()] = key; } else { @@ -774,13 +641,17 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd for(int caps = 0; caps <= 1; caps++) { //_S2 TODO get char - do I need rc ?? ( was rc = ToUnicodeEx...) - std::wstring KeyVal_Other = get_KeyVals_according_to_keycode_and_Shiftstate_new( *keymap, SC_US, ss, caps); + /* + loader.ClearKeyboardBuffer(VK_DECIMAL, rgKey[VK_DECIMAL]->SC(), hkl); + loader.FillKeyState(lpKeyState, ss, (caps == 0)); + int rc = ToUnicodeEx(rgKey[iKey]->VK(), rgKey[iKey]->SC(), lpKeyState, sbBuffer, _countof(sbBuffer), 0, hkl); + */ + + + + std::wstring KeyVal_Other = get_KeyVals_according_to_keycode_and_Shiftstate_new( *keymap, SC_US, ss, caps); + int rc = KMX_ToUnicodeEx(*keymap, SC_US, lpKeyState, sbBuffer, sizeof(sbBuffer)/sizeof(WCHAR), ss, caps) ; -//----------------------------------------------- -int rc = 11; - if (rc == 0) { - int trurzttz = 57; - } if(rc > 0) { if(*sbBuffer == 0) { //_S2 TODO do I need that ?? @@ -799,20 +670,20 @@ int rc = 11; continue; }*/ // if rc ==1 : it got 1 char && +40 in Buffer CTRl pressed { - //It's dealing with control characters. If ToUnicodeEx gets VK_A with5 the Ctrl key pressed, + //It's dealing with control characters. If ToUnicodeEx gets VK_A with the Ctrl key pressed, //it will write 0x01 to sBuffer[0] , without Ctrl it's 0x41. The if detects this case. - /* if( (ss == Ctrl || ss == ShftCtrl) ) { + if( (ss == Ctrl || ss == ShftCtrl) ) { //&& CTRl +0x40 in the buffer ( which indicates a ctrl press) continue; - }*/ + } sbBuffer[rc] = 0; //rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps==0)); rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps)); //_S2 + int SDFGHJK=99; } } - else if(rc < 0) { - /* //_S2 TODO - // dk > 65000??? + else if(rc < 0) { + //_S2 TODO // _S2 handle deadkeys later // if rc <0: it got a deadkey { // fill m_rgss and m_rgfDeadkey and alDead @@ -820,7 +691,8 @@ int rc = 11; // do more stuff for deadkeys... sbBuffer[2] = 0; - rgKey[iKey]->SetShiftState(ss, sbBuffer, true, (caps == 0));*/ + //rgKey[iKey]->SetShiftState(ss, sbBuffer, true, (caps == 0)); + rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, true, (caps )); // It's a dead key; let's flush out whats stored in the keyboard state. /*loader.ClearKeyboardBuffer(VK_DECIMAL, rgKey[VK_DECIMAL]->SC(), hkl); @@ -1056,354 +928,6 @@ return true; } - -bool KMX_ImportRules_bak(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 - KMX_Loader loader; - const size_t BUF_sz= 256; -//Inspect_kp(kp); - // _S2 do I need that for Linux?? - KMX_WCHAR inputHKL[12]; - u16sprintf(inputHKL,BUF_sz ,L"%08.8x", (unsigned int) u16tol(kbid, NULL, 16)); // _S2 wsprintf(inputHKL, L"%08.8x", (unsigned int) wcstol(kbid, NULL, 16)); - - KMX_HKL hkl = NULL; //_S2 added: but can I do this?? hkl is not needed in Linux?? - - BYTE lpKeyState[256];// = new KeysEx[256]; - std::vector rgKey; //= new VirtualKey[256]; - std::vector alDead; - - rgKey.resize(256); - - // _S2 scroll through OTHER - // Scroll through the Scan Code (SC) values and get the valid Virtual Key (VK) - // values in it. Then, store the SC in each valid VK so it can act as both a - // flag that the VK is valid, and it can store the SC value. - // _S2 this does not find exactly the same keys as the windows version does(windows finds more) - - for(UINT sc = 0x01; sc <= 0x7f; sc++) { - // fills m_vk with the VK of the US keyboard which is not right!! - // ( mcompile win uses MapVirtualKeyEx() to fill m_vk with the VK of the Other keyboard) - // Linux cant get a VK for the US Keyboard using USVirtualKeyToScanCode/ScanCodeToUSVirtualKey - // Linux cannot get a VK for Other Keyboard - // it could return SC if that helps - KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector, keymap); - - // _S2 ToDo - // either it gives the correct rgkeys (all non-char filled with special char) or - // it gives not all rgkeys but nr, a-z are filled correctly - if((key->VK() != 0) ) { - rgKey[key->VK()] = key; - } else { - delete key; - } - } - - for(UINT ke = VK_NUMPAD0; ke <= VK_NUMPAD9; ke++) { - rgKey[ke] = new KMX_VirtualKey(hkl, ke, All_Vector, keymap); - } - - rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE, All_Vector, keymap); - rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL, All_Vector, keymap); - rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL, All_Vector, keymap); - -/* - // _S2 do we need special shift state now or later? - // See if there is a special shift state added - for(UINT vk = 0; vk <= VK_OEM_CLEAR; vk++) { - UINT sc = MapVirtualKeyEx(vk, 0, hkl); - UINT vkL = MapVirtualKeyEx(sc, 1, hkl); - UINT vkR = MapVirtualKeyEx(sc, 3, hkl); - if((vkL != vkR) && - (vk != vkL)) { - switch(vk) { - case VK_LCONTROL: - case VK_RCONTROL: - case VK_LSHIFT: - case VK_RSHIFT: - case VK_LMENU: - case VK_RMENU: - break; - - default: - loader.Set_XxxxVk(vk); - break; - } - } - } -*/ - // _S2 test rgkey can go later - /*for(UINT iKey = 100; iKey < rgKey.size(); iKey++) { - if(rgKey[iKey] != NULL) { - wprintf(L" Key Nr %i is available\n",iKey); - } - }*/ - - // _S2 in this part we skip shiftstates 4, 5, 8, 9 - for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { - if(rgKey[iKey] != NULL) { - WCHAR sbBuffer[256]; // Scratchpad we use many places - - UINT VK_Other = Lin_KM__map(iKey, All_Vector); - - for(ShiftState ss = Base; ss <= loader.MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { - if(ss == Menu || ss == ShftMenu) { - // Alt and Shift+Alt don't work, so skip them - continue; - } - - KMX_DWORD SC_US = get_KeyCode_fromVKUS(iKey); - - for(int caps = 0; caps <= 1; caps++) { - //_S2 TODO get char - do I need rc ?? ( was rc = ToUnicodeEx...) - std::wstring KeyVal_Other = get_KeyVals_according_to_keycode_and_Shiftstate_new( *keymap, SC_US, ss, caps); - - -// _S2 brackets not the same in if/else/else if blocks !!!! - - //_S2 TODO do I need that ?? - //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { - if(KeyVal_Other == L"") { - //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); - rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps)); - } - - //_S2 TODO - //else // if rc ==1 : it got 1 char && +40 in Buffer CTRl pressed { - //It's dealing with control characters. If ToUnicodeEx gets VK_A with the Ctrl key pressed, - //it will write 0x01 to sBuffer[0] , without Ctrl it's 0x41. The if detects this case. - if( (ss == Ctrl || ss == ShftCtrl) /*&& CTRl +0x40 in the buffer ( which indicates a ctrl press) */) { - continue; - } - - //rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps==0)); - rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps)); - - - //_S2 TODO - // dk > 65000??? - // _S2 handle deadkeys later - // if rc <0: it got a deadkey { - // fill m_rgss and m_rgfDeadkey and alDead - //SET_SHIFTSTATES( deadkey) //sbuffer is value out of ToUnicodeEx / AllVector - // do more stuff for deadkeys... - // } from rc<0 - } - } - } - } - - //_S2 this gan co later - std::vector< int > TestValues = {48,49,50,51,52,53,54,55,56,57,65,66,67,88,89,90, 186,187,188,189,191,191,192,219,220,221,222,226}; - wprintf(L"-----------------\nNow some tests:\n"); - wprintf(L" Base Caps Shift Shfit+Caps MenuCtrl MenuCtrl+Caps \n"); - - for ( int i=0; i < (int) TestValues.size();i++) { - std::wstring wws = rgKey[TestValues[i]]->get_m_rgss(0,0); - wprintf(L"Results for %i\t: %ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \n", TestValues[i], - rgKey[TestValues[i]]->get_m_rgss(0,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(0,0)[0], - rgKey[TestValues[i]]->get_m_rgss(0,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(0,1)[0], - rgKey[TestValues[i]]->get_m_rgss(1,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(1,0)[0], - rgKey[TestValues[i]]->get_m_rgss(1,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(1,1)[0], - rgKey[TestValues[i]]->get_m_rgss(6,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(6,0)[0], - rgKey[TestValues[i]]->get_m_rgss(6,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(6,1)[0], - rgKey[TestValues[i]]->get_m_rgss(7,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(7,0)[0], - rgKey[TestValues[i]]->get_m_rgss(7,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(7,1)[0] - ); - } - wprintf(L"-----------------\n"); - - //------------------------------------------------------------- - // Now that we've collected the key data, we need to - // translate it to kmx and append to the existing keyboard - //------------------------------------------------------------- - - int nDeadkey = 0; - LPKMX_GROUP gp = new KMX_GROUP[kp->cxGroupArray+4]; // leave space for old - memcpy(gp, kp->dpGroupArray, sizeof(KMX_GROUP) * kp->cxGroupArray); - - // - - // Find the current highest deadkey index - // - - kp->dpGroupArray = gp; - for(UINT i = 0; i < kp->cxGroupArray; i++, gp++) { - //if(gp->fUsingKeys && gp->dpNoMatch == NULL) { // I4550 - // WCHAR *p = gp->dpNoMatch = new WCHAR[4]; - // *p++ = UC_SENTINEL; - // *p++ = CODE_USE; - // *p++ = (WCHAR)(kp->cxGroupArray + 1); - // *p = 0; - //} - LPKMX_KEY kkp = gp->dpKeyArray; - - for(UINT j = 0; j < gp->cxKeyArray; j++, kkp++) { - nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpContext)); - nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpOutput)); - } - } - - kp->cxGroupArray++; - gp = &kp->dpGroupArray[kp->cxGroupArray-1]; - UINT nKeys = 0; - int sab_nr = 0; - for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { - if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { - nKeys+= rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); - //wprintf(L" iKey = %i, Delta: %i -> Sum %i\n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()), nKeys); - sab_nr ++; - } - } - - - nDeadkey++; // ensure a 1-based index above the max deadkey value already in the keyboard - - gp->fUsingKeys = TRUE; - gp->dpMatch = NULL; - gp->dpName = NULL; - gp->dpNoMatch = NULL; - gp->cxKeyArray = nKeys; - gp->dpKeyArray = new KMX_KEY[gp->cxKeyArray]; - nKeys = 0; - // - // Fill in the new rules - // - -int STOP=0; // _S2 LayoutRow: VKToUnderlying should work OK; GetSSValue not checked yet, but this is definitely different - for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { - if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { - //wprintf(L"********************************* I use Key Nr %i\n",iKey); - // for each item, - //wprintf(L" \n iKey = %i, nKeys %i + Delta:\t%i", iKey,nKeys, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState())); - if(rgKey[iKey]->KMX_LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 - nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); - //Inspect_key(&gp->dpKeyArray[nKeys]); - } - } - } - - gp->cxKeyArray = nKeys; - - // - // Add nomatch control to each terminating 'using keys' group // I4550 - // - LPKMX_GROUP gp2 = kp->dpGroupArray; - for(UINT i = 0; i < kp->cxGroupArray - 1; i++, gp2++) { - if(gp2->fUsingKeys && gp2->dpNoMatch == NULL) { - KMX_WCHAR *p = gp2->dpNoMatch = new KMX_WCHAR[4]; - KMX_WCHAR *q = p; - *p++ = UC_SENTINEL; - *p++ = CODE_USE; - *p++ = (KMX_WCHAR)(kp->cxGroupArray); - *p = 0; - - // _S2 TODO not sure if this works OK -> we need to use more shiftstates than base+Shift - // I4550 - Each place we have a nomatch > use(baselayout) (this last group), we need to add all - // the AltGr and ShiftAltGr combinations as rules to allow them to be matched as well. Yes, this - // loop is not very efficient but it's not worthy of optimisation. - // - UINT j; - LPKMX_KEY kkp; - for(j = 0, kkp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kkp++) { - if((kkp->ShiftFlags & (K_CTRLFLAG|K_ALTFLAG|LCTRLFLAG|LALTFLAG|RCTRLFLAG|RALTFLAG)) != 0) { - gp2->cxKeyArray++; - LPKMX_KEY kkp2 = new KMX_KEY[gp2->cxKeyArray]; - memcpy(kkp2, gp2->dpKeyArray, sizeof(KMX_KEY)*(gp2->cxKeyArray-1)); - gp2->dpKeyArray = kkp2; - kkp2 = &kkp2[gp2->cxKeyArray-1]; - kkp2->dpContext = new KMX_WCHAR; *kkp2->dpContext = 0; - kkp2->Key = kkp->Key; - kkp2->ShiftFlags = kkp->ShiftFlags; - kkp2->Line = 0; - KMX_WCHAR *p = kkp2->dpOutput = new KMX_WCHAR[4]; - KMX_WCHAR *q=p; - *p++ = UC_SENTINEL; - *p++ = CODE_USE; - *p++ = (KMX_WCHAR)(kp->cxGroupArray); - *p = 0; - } - } - } - } - - // _S2 TODO not sure if this works OK -> we need to use deadkeys... - // If we have deadkeys, then add a new group to translate the deadkeys per the deadkey tables - // We only do this if not in deadkey conversion mode - // - - if (alDead.size() > 0 && !bDeadkeyConversion) { // I4552 - kp->cxGroupArray++; - - KMX_WCHAR *p = gp->dpMatch = new KMX_WCHAR[4]; - *p++ = UC_SENTINEL; - *p++ = CODE_USE; - *p++ = (KMX_WCHAR) kp->cxGroupArray; - *p = 0; - - gp++; - - gp->fUsingKeys = FALSE; - gp->dpMatch = NULL; - gp->dpName = NULL; - gp->dpNoMatch = NULL; - gp->cxKeyArray = alDead.size(); - LPKMX_KEY kkp = gp->dpKeyArray = new KMX_KEY[alDead.size()]; - - LPKMX_STORE sp = new KMX_STORE[kp->cxStoreArray + alDead.size() * 2]; - memcpy(sp, kp->dpStoreArray, sizeof(KMX_STORE) * kp->cxStoreArray); - - kp->dpStoreArray = sp; - - sp = &sp[kp->cxStoreArray]; - int nStoreBase = kp->cxStoreArray; - kp->cxStoreArray += alDead.size() * 2; - - for(UINT i = 0; i < alDead.size(); i++) { - DeadKey *dk = alDead[i]; - - sp->dpName = NULL; - sp->dwSystemID = 0; - sp->dpString = new KMX_WCHAR[dk->KMX_Count() + 1]; - for(int j = 0; j < dk->KMX_Count(); j++) - sp->dpString[j] = dk->KMX_GetBaseCharacter(j); - sp->dpString[dk->KMX_Count()] = 0; - sp++; - - sp->dpName = NULL; - sp->dwSystemID = 0; - sp->dpString = new KMX_WCHAR[dk->KMX_Count() + 1]; - for(int j = 0; j < dk->KMX_Count(); j++) - sp->dpString[j] = dk->KMX_GetCombinedCharacter(j); - sp->dpString[dk->KMX_Count()] = 0; - sp++; - - kkp->Line = 0; - kkp->ShiftFlags = 0; - kkp->Key = 0; - KMX_WCHAR *p = kkp->dpContext = new KMX_WCHAR[8]; - *p++ = UC_SENTINEL; - *p++ = CODE_DEADKEY; - *p++ = KMX_DeadKeyMap(dk->KMX_DeadCharacter(), &alDead, nDeadkey, FDeadkeys); // I4353 - // *p++ = nDeadkey+i; - *p++ = UC_SENTINEL; - *p++ = CODE_ANY; - *p++ = nStoreBase + i*2 + 1; - *p = 0; - - p = kkp->dpOutput = new KMX_WCHAR[5]; - *p++ = UC_SENTINEL; - *p++ = CODE_INDEX; - *p++ = nStoreBase + i*2 + 2; - *p++ = 2; - *p = 0; - - kkp++; - } - } - //Inspect_kp(kp); -return true; -} - - // _S2 where to put this?? const int CODE__SIZE[] = { -1, // undefined 0x00 diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index c931dde16f..4d3c54e6cf 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -230,10 +230,10 @@ void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_ void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key) { if(key->ShiftFlags == 0) { //KMX_LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); - wprintf(L" _S2 Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); + //wprintf(L" _S2 Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); } else if(key->ShiftFlags & VIRTUALCHARKEY) { //KMX_LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); - wprintf(L"_S2 Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); + //wprintf(L"_S2 Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); } } From 6ace426d845e514a5eb6b919a36d11a832f72b2f Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 11 Dec 2023 23:07:19 +0100 Subject: [PATCH 156/327] feat(linux): mcompile cleanup --- linux/mcompile/keymap/deadkey.cpp | 2 +- linux/mcompile/keymap/helpers.cpp | 92 ++++++++ linux/mcompile/keymap/keymap.cpp | 66 +----- linux/mcompile/keymap/km_types.h | 12 +- linux/mcompile/keymap/mc_import_rules.cpp | 258 ++++++++++------------ linux/mcompile/keymap/mc_kmxfile.cpp | 7 - linux/mcompile/keymap/mc_kmxfile.h | 2 - linux/mcompile/keymap/mcompile.cpp | 8 +- 8 files changed, 226 insertions(+), 221 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index e41aa6233e..5152e5e601 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -1,7 +1,7 @@ #include "keymap.h" #include "deadkey.h" -// _S2 do I need the names somewhere??? +// _S2 do I need nameresult somewhere??? v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult) { v_dw_1D line; line.push_back(convertNamesToIntegerValue(first)); diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 74fab133b9..922eb0b9a4 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -5,6 +5,98 @@ //_S2 do not review - all this will be deleted later // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +// _S2 can go later +void Inspect_kp(LPKMX_KEYBOARD kp) { + wprintf(L"-------\n"); + wprintf(L"-------\n"); + wprintf(L"-------\n"); + wprintf(L"kp has %i groups and %i keys\n",kp->cxGroupArray, kp->dpGroupArray->cxKeyArray); + wprintf(L"-------\n"); + +//for ( int i=0; i<150;i++) { +for ( int i=0; idpGroupArray->cxKeyArray;i++) { + wprintf(L"key nr :%i has key:%i(%c) Line:%i Shiftflags:%i Output %c (%d)\n",i,kp->dpGroupArray->dpKeyArray->Key,kp->dpGroupArray->dpKeyArray->Key, + kp->dpGroupArray->dpKeyArray->Line,kp->dpGroupArray->dpKeyArray->ShiftFlags ,kp->dpGroupArray->dpKeyArray->dpOutput,*kp->dpGroupArray->dpKeyArray->dpOutput ); + kp->dpGroupArray->dpKeyArray++; +} + wprintf(L"-------\n"); + wprintf(L"-------\n"); + wprintf(L"-------\n"); +} + +void Inspect_gp(KMX_tagGROUP* gp) { + for (int i = 0; i < gp->cxKeyArray; i++) { + wprintf(L"key nr : has key:%i(%c) Line:%i Shiftflags:%i Output %c (%d)\n", gp->dpKeyArray->Key, gp->dpKeyArray->Key, + gp->dpKeyArray->Line, gp->dpKeyArray->ShiftFlags, gp->dpKeyArray->dpOutput, *gp->dpKeyArray->dpOutput); + // gp->cxKeyArray++; + } +} + +void Inspect_key(LPKMX_KEY key) { + //for (int i = 0; i < gp->cxKeyArray; i++) { + wprintf(L"key nr : has key:%i(%c) Line:%i Shiftflags:%i Output \n", key->Key, key->Key, + key->Line, key->ShiftFlags); + /*wprintf(L"key nr : has key:%i(%c) Line:%i Shiftflags:%i Output %c (%d)\n", key->Key, key->Key, + key->Line, key->ShiftFlags, key->dpOutput, *key->dpOutput);*/ + // gp->cxKeyArray++; + // } +} + +// _S2 this needs to go; only to check if mcompile gives the same end result. +// _S2 helps to force filling rgkey[VK_DE] +UINT map_Ikey_DE(UINT iKey) { + if (iKey == 89 ) return 90; + if (iKey == 90 ) return 89; + if (iKey == 186 ) return 219; + if (iKey == 187 ) return 221; + if (iKey == 188 ) return 188; + if (iKey == 189 ) return 191; + if (iKey == 190 ) return 190; + if (iKey == 191 ) return 220; + if (iKey == 192 ) return 186; + if (iKey == 219 ) return 189; + if (iKey == 220 ) return 192; + if (iKey == 221 ) return 187; + if (iKey == 222 ) return 222; + if (iKey == 226 ) return 226; + return iKey; +} + +// _S2 TODO How to do mapping between Linux keycodes and keyman SC +const int Lin_KM__map(int i, v_dw_3D &All_Vector) { + // MAP: + // VK KEYMAN-STYLE -> KEYCODE LINUX-STYLE + // e.g 188 -> 59 + //All_Vector_[ 1 ][ in which line of US did find the value 58 ][ take second or third column wherever I find 58 ]] + // finds 59th row (not value 59) + int dw=0; + //if (i == 32 ) return ; /* */5 + //if (i == 186 ) return 220; /* Ü */ + //if (i == 187 ) return 42; /* + * */ + //if (i == 188 ) {wprintf(L" swapped: i (%i) to 59 \n",dw,i); return 59; }/* COMMA */ + //if (i == 189 ) {wprintf(L" swapped: i (%i) to 95 \n",dw,i); return 95; }/* - _ */ + //if (i == 190 ) {wprintf(L" swapped: i (%i) to 58 \n",dw,i); return 58; }/* PERIOD */ + //if (i == 191 ) {wprintf(L" swapped: i (%i) to 35 \n",dw,i); return 35; }/* # ' */ + //if (i == 191 ) {wprintf(L" swapped: i (%i) to 63 \n",dw,i); return 63; }/* */ + //if (i == 214 ) {wprintf(L" swapped: i (%i) to 192 \n",dw,i); return 192; }/* Ö */ + //if (i == 219 ) {wprintf(L" swapped: i (%i) to 223 \n",dw,i); return 223; }/* Sharp-S+ ? */ + //if (i == 220 ) {wprintf(L" swapped: i (%i) to 92 \n",dw,i); return 92; }/* ^ ° */ + //if (i == 221 ) {wprintf(L" swapped: i (%i) to 180 \n",dw,i); return 180; }/* ' ` */ + //if (i == 223 ) {wprintf(L" swapped: i (%i) to 59 \n",dw,i); return ; }/* */ + + //if (i == 226 ) {wprintf(L" swapped: i (%i) to 60 \n",dw,i); return 60; }/* < > */ + //if (i == 65105 ) {wprintf(L" swapped: i (%i) to 92 \n",dw,i); return 92; }/* */ + + // e.g. rgKey[192] contains character 214 + //if (i == 192 ) {wprintf(L" swapped: i (%i) to 214 \n",dw,i); return 214; }/* Ö */ + //if (i == 186 ) {wprintf(L" swapped: i (%i) to 220 \n",dw,i); return 220; }/* Ü */ + //if (i == 222 ) {wprintf(L" swapped: i (%i) to 196 \n",dw,i); return 196; }/* Ä */ + //if (i == 220) {wprintf(L" swapped: i (%i) to 196 \n",dw,i); return 186; }/* Ä */ + //if (i == 42) {wprintf(L" swapped: i (%i) to 196 \n",dw,i); return 187; }/* + */ + + return i; +} + int append_other_ToVector(v_dw_3D &All_Vector) { InsertKeyvalsFromVectorFile(All_Vector); return 0; diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 7f5ffb60e5..baa89427b4 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -158,7 +158,7 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, int replace_KeyName_with_Keycode(std::string in) { int out = returnIfCharInvalid; -// _S2 these are the Scancode-Values we use in Keyman ( = like the windows scancodes) +// _S2 these are the Scancode-Values we use in Keyman ( = the windows scancodes+8 ) // NAME IN SYMBOLS-FILE KEYCODE (LIN STYLE) (WIN STYLE) VK_US VK_DE /*on US keyb;*/ if ( in == "key") out = 49; /* VK_ */ // TOASK correct ??? @@ -400,9 +400,6 @@ KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { } - // _S2 ToDo - // either it gives the correct rgkeys (all non-char filled with special char) or - // it gives not all rgkeys but nr, a-z are filled correctly // _S2 ToDo tidy up if ( keycode >7) { UINT VK_for_rgKey2 = ScanCodeToUSVirtualKey[keycode-8]; @@ -427,61 +424,6 @@ KMX_DWORD get_KeyCode_fromVKUS( KMX_DWORD VK_US) { return 0; } -// _S2 this needs to go; only to check if mcompile gives the same end result. -// _S2 helps to force filling rgkey[VK_DE] -UINT map_Ikey_DE(UINT iKey) { - if (iKey == 89 ) return 90; - if (iKey == 90 ) return 89; - if (iKey == 186 ) return 219; - if (iKey == 187 ) return 221; - if (iKey == 188 ) return 188; - if (iKey == 189 ) return 191; - if (iKey == 190 ) return 190; - if (iKey == 191 ) return 220; - if (iKey == 192 ) return 186; - if (iKey == 219 ) return 189; - if (iKey == 220 ) return 192; - if (iKey == 221 ) return 187; - if (iKey == 222 ) return 222; - if (iKey == 226 ) return 226; - return iKey; -} - -// _S2 TODO How to do mapping between Linux keycodes and keyman SC -const int Lin_KM__map(int i, v_dw_3D &All_Vector) { - // MAP: - // VK KEYMAN-STYLE -> KEYCODE LINUX-STYLE - // e.g 188 -> 59 - //All_Vector_[ 1 ][ in which line of US did find the value 58 ][ take second or third column wherever I find 58 ]] - // finds 59th row (not value 59) - int dw=0; - //if (i == 32 ) return ; /* */5 - //if (i == 186 ) return 220; /* Ü */ - //if (i == 187 ) return 42; /* + * */ - //if (i == 188 ) {wprintf(L" swapped: i (%i) to 59 \n",dw,i); return 59; }/* COMMA */ - //if (i == 189 ) {wprintf(L" swapped: i (%i) to 95 \n",dw,i); return 95; }/* - _ */ - //if (i == 190 ) {wprintf(L" swapped: i (%i) to 58 \n",dw,i); return 58; }/* PERIOD */ - //if (i == 191 ) {wprintf(L" swapped: i (%i) to 35 \n",dw,i); return 35; }/* # ' */ - //if (i == 191 ) {wprintf(L" swapped: i (%i) to 63 \n",dw,i); return 63; }/* */ - //if (i == 214 ) {wprintf(L" swapped: i (%i) to 192 \n",dw,i); return 192; }/* Ö */ - //if (i == 219 ) {wprintf(L" swapped: i (%i) to 223 \n",dw,i); return 223; }/* Sharp-S+ ? */ - //if (i == 220 ) {wprintf(L" swapped: i (%i) to 92 \n",dw,i); return 92; }/* ^ ° */ - //if (i == 221 ) {wprintf(L" swapped: i (%i) to 180 \n",dw,i); return 180; }/* ' ` */ - //if (i == 223 ) {wprintf(L" swapped: i (%i) to 59 \n",dw,i); return ; }/* */ - - //if (i == 226 ) {wprintf(L" swapped: i (%i) to 60 \n",dw,i); return 60; }/* < > */ - //if (i == 65105 ) {wprintf(L" swapped: i (%i) to 92 \n",dw,i); return 92; }/* */ - - // e.g. rgKey[192] contains character 214 - //if (i == 192 ) {wprintf(L" swapped: i (%i) to 214 \n",dw,i); return 214; }/* Ö */ - //if (i == 186 ) {wprintf(L" swapped: i (%i) to 220 \n",dw,i); return 220; }/* Ü */ - //if (i == 222 ) {wprintf(L" swapped: i (%i) to 196 \n",dw,i); return 196; }/* Ä */ - //if (i == 220) {wprintf(L" swapped: i (%i) to 196 \n",dw,i); return 186; }/* Ä */ - //if (i == 42) {wprintf(L" swapped: i (%i) to 196 \n",dw,i); return 187; }/* + */ - - return i; -} - std::wstring convert_DeadkeyValues_ToChar(int in) { KMX_DWORD lname; @@ -592,7 +534,9 @@ std::wstring get_KeyVals_according_to_keycode_and_Shiftstate_new(GdkKeymap *key else return L"\0"; - return std::wstring(1, (int) *keyvals); - //return convert_DeadkeyValues_ToChar((int) *keyvals); + if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max) ) + return convert_DeadkeyValues_ToChar((int) *keyvals); + else + return std::wstring(1, (int) *keyvals); } diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index 53f5485740..0c04550432 100755 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -44,11 +44,11 @@ typedef WCHAR KMX_WCHART; // _S2 needs to be removed/ wchart-> cha typedef char16_t KMX_WCHAR; // _S2 typedef KMX_WCHAR* PKMX_WCHAR; // _S2 typedef wchar_t* PWSTR; // _S2 needs to be removed/ wchart-> char16 -typedef PWSTR PKMX_WCHART; // _S2 needs to be removed/ wchart-> char16 +//typedef PWSTR PKMX_WCHART; // _S2 needs to be removed/ wchart-> char16 //typedef const wchar_t* PCKMX_WCHART; // _S2 needs to be removed/? typedef char* LPSTR; // _S2 needs to be removed? -typedef LPSTR LPKMX_STR; // _S2 needs to be removed? +//typedef LPSTR LPKMX_STR; // _S2 needs to be removed? typedef uint8_t* LPBYTE; // _S2 needs to be removed/? typedef uint8_t* LPKMX_BYTE; // _S2 needs to be removed? @@ -57,7 +57,7 @@ typedef uint8_t* PBYTE; // _S2 needs to be removed/? typedef uint8_t* PKMX_BYTE; // _S2 needs to be removed? typedef char KMX_CHAR; // _S2 needs to be removed/? -typedef char* PKMX_STR; // _S2 needs to be removed/? +//typedef char* PKMX_STR; // _S2 needs to be removed/? typedef unsigned int UINT; // _S2 needs to be removed/? typedef unsigned char BYTE; // _S2 needs to be removed? @@ -154,4 +154,10 @@ typedef KMX_UCHAR* KMX_PUCHAR; #define VK_LMENU 0xA4 #define VK_RMENU 0xA5 +#define VK_SHIFT 0x10 +#define VK_CONTROL 0x11 +#define VK_MENU 0x12 +#define VK_PAUSE 0x13 +#define VK_CAPITAL 0x14 + #endif /*KM_TYPES*/ diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 0afa2be717..0602a9ca5a 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -27,6 +27,8 @@ #include "mc_kmxfile.h" #include "keymap.h" +int KMX_ToUnicodeEx(guint ScanCode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, int cchBuff, int shift_state, int caps, GdkKeymap *keymap =NULL); + const int KMX_ShiftStateMap[] = { ISVIRTUALKEY, ISVIRTUALKEY | K_SHIFTFLAG, @@ -189,6 +191,12 @@ public: this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; } + void KMX_SetShiftState(ShiftState shiftState, std::u16string value16, bool isDeadKey, bool capsLock) { + std::wstring value = wstring_from_u16string(value16); + this->m_rgfDeadKey[(UINT)shiftState][(capsLock ? 1 : 0)] = isDeadKey; + this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; + } + bool KMX_IsSGCAPS() { std::wstring stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß std::wstring stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? @@ -408,8 +416,8 @@ public: ShiftState MaxShiftState() { return (Get_XxxxVk() == 0 ? ShftMenuCtrl : ShftXxxx); } -/* - void FillKeyState(BYTE *lpKeyState, ShiftState ss, bool fCapsLock) { + + void KMX_FillKeyState(KMX_BYTE *lpKeyState, ShiftState ss, bool fCapsLock) { lpKeyState[VK_SHIFT] = (((ss & Shft) != 0) ? 0x80 : 0x00); lpKeyState[VK_CONTROL] = (((ss & Ctrl) != 0) ? 0x80 : 0x00); lpKeyState[VK_MENU] = (((ss & Menu) != 0) ? 0x80 : 0x00); @@ -419,7 +427,7 @@ public: } lpKeyState[VK_CAPITAL] = (fCapsLock ? 0x01 : 0x00); } - +/* bool IsControlChar(wchar_t ch) { return (ch < 0x0020) || (ch >= 0x007F && ch <= 0x009F); } @@ -510,14 +518,15 @@ public: } return deadKey; } +*/ - void KMX_ClearKeyboardBuffer(UINT vk, UINT sc, HKL hkl) { - WCHAR sb[16]; + void KMX_ClearKeyboardBuffer() { + KMX_WCHAR sb[16]; int rc = 0; - do { - rc = ::ToUnicodeEx(vk, sc, lpKeyStateNull, sb, _countof(sb), 0, hkl); - } while(rc != 1 && rc != 0); - }*/ + for( int i=0; i<16; i++) { + sb[i] = L'\0'; + } + } }; int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { @@ -534,11 +543,12 @@ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { return n; } -int KMX_ToUnicodeEx(GdkKeymap *keymap, guint ScanCode, const BYTE *lpKeyState, PWCHAR pwszBuff, int cchBuff, int shift_state, int caps) { +// _S2 cchBuff remove? +int KMX_ToUnicodeEx( guint ScanCode, const BYTE *lpKeyStccate, PWCHAR pwszBuff, int cchBuff, int shift_state, int caps,GdkKeymap *keymap) { KMX_DWORD kvl= getKeyvalsFromKeyCode(keymap, ScanCode, shift_state); - std::wstring character = get_KeyVals_according_to_keycode_and_Shiftstate_new( keymap, ScanCode, ShiftState(shift_state), caps); + std::wstring character = get_KeyVals_according_to_keycode_and_Shiftstate_new(keymap, ScanCode, ShiftState(shift_state), caps); pwszBuff[0]= * (PWCHAR) character.c_str(); if((kvl >= 0xfe50) && (kvl <= 0xfe93)) @@ -547,6 +557,20 @@ int KMX_ToUnicodeEx(GdkKeymap *keymap, guint ScanCode, const BYTE *lpKeyState, P return 1; } +// _S2 cchBuff remove? +int KMX_ToUnicodeEx(guint ScanCode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, int cchBuff, int shift_state, int caps,GdkKeymap *keymap) { + + KMX_DWORD kvl= getKeyvalsFromKeyCode(keymap, ScanCode, shift_state); + + std::wstring character = get_KeyVals_according_to_keycode_and_Shiftstate_new(keymap, ScanCode, ShiftState(shift_state), caps); + pwszBuff[0]= * (PWCHAR) character.c_str(); + + if((kvl >= 0xfe50) && (kvl <= 0xfe93) ) + return -1; + else + return 1; +} + bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 KMX_Loader loader; const size_t BUF_sz= 256; @@ -592,123 +616,109 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL, All_Vector, keymap); rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL, All_Vector, keymap); -/* - // _S2 do we need special shift state now or later? - // See if there is a special shift state added - for(UINT vk = 0; vk <= VK_OEM_CLEAR; vk++) { - UINT sc = MapVirtualKeyEx(vk, 0, hkl); - UINT vkL = MapVirtualKeyEx(sc, 1, hkl); - UINT vkR = MapVirtualKeyEx(sc, 3, hkl); - if((vkL != vkR) && - (vk != vkL)) { - switch(vk) { - case VK_LCONTROL: - case VK_RCONTROL: - case VK_LSHIFT: - case VK_RSHIFT: - case VK_LMENU: - case VK_RMENU: - break; + /* + // _S2 do we need special shift state now or later? + // See if there is a special shift state added + for(UINT vk = 0; vk <= VK_OEM_CLEAR; vk++) { + UINT sc = MapVirtualKeyEx(vk, 0, hkl); + UINT vkL = MapVirtualKeyEx(sc, 1, hkl); + UINT vkR = MapVirtualKeyEx(sc, 3, hkl); + if((vkL != vkR) && + (vk != vkL)) { + switch(vk) { + case VK_LCONTROL: + case VK_RCONTROL: + case VK_LSHIFT: + case VK_RSHIFT: + case VK_LMENU: + case VK_RMENU: + break; - default: - loader.Set_XxxxVk(vk); - break; - } - } - } -*/ - // _S2 test rgkey can go later - /*for(UINT iKey = 100; iKey < rgKey.size(); iKey++) { - if(rgKey[iKey] != NULL) { - wprintf(L" Key Nr %i is available\n",iKey); - } - }*/ - - // _S2 in this part we skip shiftstates 4, 5, 8, 9 - for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { - if(rgKey[iKey] != NULL) { - WCHAR sbBuffer[256]; // Scratchpad we use many places - - UINT VK_Other = Lin_KM__map(iKey, All_Vector); - - for(ShiftState ss = Base; ss <= loader.MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { - if(ss == Menu || ss == ShftMenu) { - // Alt and Shift+Alt don't work, so skip them - continue; + default: + loader.Set_XxxxVk(vk); + break; + } } + } + */ + // _S2 test rgkey can go later + /*for(UINT iKey = 100; iKey < rgKey.size(); iKey++) { + if(rgKey[iKey] != NULL) { + wprintf(L" Key Nr %i is available\n",iKey); + } + }*/ - KMX_DWORD SC_US = get_KeyCode_fromVKUS(iKey); + // in this part we skip shiftstates 4, 5, 8, 9 + for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { + if(rgKey[iKey] != NULL) { + KMX_WCHAR sbBuffer[256]; // Scratchpad we use many places - for(int caps = 0; caps <= 1; caps++) { - //_S2 TODO get char - do I need rc ?? ( was rc = ToUnicodeEx...) - /* - loader.ClearKeyboardBuffer(VK_DECIMAL, rgKey[VK_DECIMAL]->SC(), hkl); - loader.FillKeyState(lpKeyState, ss, (caps == 0)); - int rc = ToUnicodeEx(rgKey[iKey]->VK(), rgKey[iKey]->SC(), lpKeyState, sbBuffer, _countof(sbBuffer), 0, hkl); - */ + for(ShiftState ss = Base; ss <= loader.MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { + if(ss == Menu || ss == ShftMenu) { + // Alt and Shift+Alt don't work, so skip them + continue; + } + KMX_DWORD SC_US = get_KeyCode_fromVKUS(iKey); + for(int caps = 0; caps <= 1; caps++) { + // _S2 is THIS correct ??? Do we need lpKeyState or is it just used in ToUnicodeEx?? + loader.KMX_ClearKeyboardBuffer(); + loader.KMX_FillKeyState(lpKeyState, ss, (caps == 0)); + int rc = KMX_ToUnicodeEx(SC_US, lpKeyState, sbBuffer, sizeof(sbBuffer)/sizeof(WCHAR), ss, caps, *keymap) ; - std::wstring KeyVal_Other = get_KeyVals_according_to_keycode_and_Shiftstate_new( *keymap, SC_US, ss, caps); - int rc = KMX_ToUnicodeEx(*keymap, SC_US, lpKeyState, sbBuffer, sizeof(sbBuffer)/sizeof(WCHAR), ss, caps) ; - - if(rc > 0) { - if(*sbBuffer == 0) { - //_S2 TODO do I need that ?? - //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { - if(KeyVal_Other == L"") { + if(rc > 0) { + if(*sbBuffer == 0) { //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps)); } - } - else { - /*if((rc == 1) && (ss == Ctrl || ss == ShftCtrl) && (rgKey[iKey]->VK() == ((UINT)sbBuffer[0] + 0x40))) { - // ToUnicodeEx has an internal knowledge about those - // VK_A ~ VK_Z keys to produce the control characters, - // when the conversion rule is not provided in keyboard - // layout files - continue; - }*/ - // if rc ==1 : it got 1 char && +40 in Buffer CTRl pressed { - //It's dealing with control characters. If ToUnicodeEx gets VK_A with the Ctrl key pressed, - //it will write 0x01 to sBuffer[0] , without Ctrl it's 0x41. The if detects this case. - if( (ss == Ctrl || ss == ShftCtrl) ) { - //&& CTRl +0x40 in the buffer ( which indicates a ctrl press) - continue; - } - sbBuffer[rc] = 0; - //rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps==0)); - rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps)); //_S2 - int SDFGHJK=99; + else { + if((rc == 1) && + (ss == Ctrl || ss == ShftCtrl) && + (rgKey[iKey]->VK() == ((UINT)sbBuffer[0] + 0x40))) { + // _S2 TODO is this the same behavior on Linux? + // if rc ==1 : it got 1 char && +40 in Buffer CTRl pressed + // It's dealing with control characters. If ToUnicodeEx gets + // VK_A with the Ctrl key pressed, it will write 0x01 to sBuffer[0], + // without Ctrl it's 0x41. The if detects this case. + // && CTRl +0x40 in the buffer ( which indicates a ctrl press) + + // ToUnicodeEx has an internal knowledge about those + // VK_A ~ VK_Z keys to produce the control characters, + // when the conversion rule is not provided in keyboard + // layout files + continue; + } + if( (ss == Ctrl || ss == ShftCtrl) ) { + continue; + } + sbBuffer[rc] = 0; + //rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps==0)); + rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps)); //_S2 } } - else if(rc < 0) { - //_S2 TODO - // _S2 handle deadkeys later - // if rc <0: it got a deadkey { - // fill m_rgss and m_rgfDeadkey and alDead - //SET_SHIFTSTATES( deadkey) //sbuffer is value out of ToUnicodeEx / AllVector - // do more stuff for deadkeys... - + else if(rc < 0) { + //_S2 TODO sbBuffer[2] = 0; //rgKey[iKey]->SetShiftState(ss, sbBuffer, true, (caps == 0)); - rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, true, (caps )); + rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); // It's a dead key; let's flush out whats stored in the keyboard state. - /*loader.ClearKeyboardBuffer(VK_DECIMAL, rgKey[VK_DECIMAL]->SC(), hkl); + loader.KMX_ClearKeyboardBuffer(); DeadKey *dk = NULL; for(UINT iDead = 0; iDead < alDead.size(); iDead++) { dk = alDead[iDead]; - WCHAR dktest1 = dk->DeadCharacter(); - WCHAR dktest2 = rgKey[iKey]->GetShiftState(ss, caps == 0)[0]; - if(dk->DeadCharacter() == rgKey[iKey]->GetShiftState(ss, caps == 0)[0]) { + WCHAR dktest1 = dk->KMX_DeadCharacter(); + WCHAR dktest2 = rgKey[iKey]->KMX_GetShiftState(ss, caps == 0)[0]; + if(dk->KMX_DeadCharacter() == rgKey[iKey]->KMX_GetShiftState(ss, caps == 0)[0]) { break; } dk = NULL; } if(dk == NULL) { - alDead.push_back(loader.ProcessDeadKey(iKey, ss, lpKeyState, rgKey, caps == 0, hkl)); - }*/ + //_S2 TODO + //alDead.push_back(loader.KMX_ProcessDeadKey(iKey, ss, lpKeyState, rgKey, caps == 0, hkl)); + } } } } @@ -722,7 +732,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd for ( int i=0; i < (int) TestValues.size();i++) { std::wstring wws = rgKey[TestValues[i]]->get_m_rgss(0,0); - wprintf(L"Results for %i\t: %ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \n", TestValues[i], + wprintf(L"Results for %i / SC %i\t : %ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \n", TestValues[i], rgKey[TestValues[i]]->SC(), rgKey[TestValues[i]]->get_m_rgss(0,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(0,0)[0], rgKey[TestValues[i]]->get_m_rgss(0,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(0,1)[0], rgKey[TestValues[i]]->get_m_rgss(1,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(1,0)[0], @@ -923,11 +933,9 @@ int STOP=0; // _S2 LayoutRow: VKToUnderlying should work OK; GetSSValue not che kkp++; } } - //Inspect_kp(kp); return true; } - // _S2 where to put this?? const int CODE__SIZE[] = { -1, // undefined 0x00 @@ -1013,39 +1021,3 @@ bool IsKeymanUsedKeyVal(std::wstring Keyval) { return false; } - -void Inspect_kp(LPKMX_KEYBOARD kp) { - wprintf(L"-------\n"); - wprintf(L"-------\n"); - wprintf(L"-------\n"); - wprintf(L"kp has %i groups and %i keys\n",kp->cxGroupArray, kp->dpGroupArray->cxKeyArray); - wprintf(L"-------\n"); - -//for ( int i=0; i<150;i++) { -for ( int i=0; idpGroupArray->cxKeyArray;i++) { - wprintf(L"key nr :%i has key:%i(%c) Line:%i Shiftflags:%i Output %c (%d)\n",i,kp->dpGroupArray->dpKeyArray->Key,kp->dpGroupArray->dpKeyArray->Key, - kp->dpGroupArray->dpKeyArray->Line,kp->dpGroupArray->dpKeyArray->ShiftFlags ,kp->dpGroupArray->dpKeyArray->dpOutput,*kp->dpGroupArray->dpKeyArray->dpOutput ); - kp->dpGroupArray->dpKeyArray++; -} - wprintf(L"-------\n"); - wprintf(L"-------\n"); - wprintf(L"-------\n"); -} - -void Inspect_gp(KMX_tagGROUP* gp) { - for (int i = 0; i < gp->cxKeyArray; i++) { - wprintf(L"key nr : has key:%i(%c) Line:%i Shiftflags:%i Output %c (%d)\n", gp->dpKeyArray->Key, gp->dpKeyArray->Key, - gp->dpKeyArray->Line, gp->dpKeyArray->ShiftFlags, gp->dpKeyArray->dpOutput, *gp->dpKeyArray->dpOutput); - // gp->cxKeyArray++; - } -} - -void Inspect_key(LPKMX_KEY key) { - //for (int i = 0; i < gp->cxKeyArray; i++) { - wprintf(L"key nr : has key:%i(%c) Line:%i Shiftflags:%i Output \n", key->Key, key->Key, - key->Line, key->ShiftFlags); - /*wprintf(L"key nr : has key:%i(%c) Line:%i Shiftflags:%i Output %c (%d)\n", key->Key, key->Key, - key->Line, key->ShiftFlags, key->dpOutput, *key->dpOutput);*/ - // gp->cxKeyArray++; - // } -} diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 6188cda6c3..3098357885 100755 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -409,7 +409,6 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { if (!buf) { fclose(fp); KMX_LogError(L"LogErr1: Not allocmem\n" ); - // _S2 QUESTION delete [] buf; ???? return FALSE; } @@ -422,7 +421,6 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { if (fread(filebase, 1, sz, fp) < (size_t)sz) { KMX_LogError(L"LogError1: Could not read file\n" ); fclose(fp); - // _S2 QUESTION delete [] buf; ???? return FALSE; } @@ -437,7 +435,6 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { if (!KMX_VerifyKeyboard(filebase, sz)) { KMX_LogError(L"LogError1: errVerifyKeyboard\n" ); - // _S2 QUESTION delete [] buf; ???? return FALSE; } @@ -450,8 +447,6 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { if (!kbp) { KMX_LogError(L"LogError1: errFixupKeyboard\n" ); - // _S2 QUESTION delete [] buf; ???? - return FALSE; } @@ -461,8 +456,6 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { return FALSE; } *lpKeyboard = kbp; - // _S2 QUESTION delete [] buf; ???? - return TRUE; } diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 78c6e36ff7..aa45af117e 100755 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -7,8 +7,6 @@ #include "filesystem.h" #include "mcompile.h" -#include // _S2 can be removed later - #ifndef _KMXFILE_H #define _KMXFILE_H diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 4d3c54e6cf..5d58a44c74 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -183,7 +183,6 @@ const UINT VKShiftState[] = {0, K_SHIFTFLAG, 0xFFFF}; // correct shift state and key. Adjust the LCTRL+RALT -> RALT if necessary // void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { - // _S2 ToDos here? // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. @@ -654,18 +653,19 @@ int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap) { KMX_WORD *p = OutputPairs, shift; - KMX_DWORD shift_S2; + KMX_DWORD shift2; v_dw_2D dk_CombinationTable; find_all_dk_combinations(&dk_Table, dk_CombinationTable, DeadKey); for ( int i=0; i< dk_CombinationTable.size()-1;i++) { - KMX_WORD vk = KMX_changeKeynameToCapital(dk_CombinationTable[i][1], shift_S2, keymap); + KMX_WORD vk = KMX_changeKeynameToCapital(dk_CombinationTable[i][1], shift2, keymap); if(vk != 0) { *p++ = vk; - *p++ = shift_S2; + *p++ = shift2; *p++ = dk_CombinationTable[i][2]; } + // _S2 TODO //else { // LogError(L"Warning: complex deadkey not supported."); // } From 349fe17770c27d2504df8bc252753221864b4fa8 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 12 Dec 2023 09:48:33 +0100 Subject: [PATCH 157/327] feat(linux): mcompile renaming func --- linux/mcompile/keymap/deadkey.cpp | 1 + linux/mcompile/keymap/helpers.cpp | 2 +- linux/mcompile/keymap/helpers.h | 4 ++++ linux/mcompile/keymap/mc_import_rules.cpp | 18 +++++----------- linux/mcompile/keymap/mcompile.cpp | 26 +++++++++++------------ linux/mcompile/keymap/mcompile.h | 23 +++++++++----------- 6 files changed, 34 insertions(+), 40 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 5152e5e601..757624bcda 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -11,6 +11,7 @@ v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, return line; } +// _S2 used? KMX_DWORD find_dk_Character(v_dw_2D * p_dk_ComposeTable, KMX_DWORD first, KMX_DWORD second ) { v_dw_2D dk_ComposeTable = * p_dk_ComposeTable; for ( int i =0; i< (dk_ComposeTable).size()-1; i++) { diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 922eb0b9a4..e12cfd3e0c 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -2994,7 +2994,7 @@ int IIII = ShiftState(shift_state); //std::wstring wws= std::wstring(1, kvl); KMX_WCHAR DeadKey; //std::wstring wws= - KMX_WCHAR val= KMX_CharFromSC(keymap, shift_state, ScanCode, &DeadKey); + KMX_WCHAR val= KMX_CharFromSC_underlying(keymap, shift_state, ScanCode, &DeadKey); KMX_DWORD dw= getKeyvalsFromKeyCode(keymap, ScanCode, ShiftState(shift_state)); //std::wstring abc= get_KeyVals_according_to_keycode_and_Shiftstate_new(keymap, ScanCode, ShiftState(shift_state), 0); diff --git a/linux/mcompile/keymap/helpers.h b/linux/mcompile/keymap/helpers.h index 25012176a1..5c7a2f24ac 100755 --- a/linux/mcompile/keymap/helpers.h +++ b/linux/mcompile/keymap/helpers.h @@ -56,4 +56,8 @@ KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_V std::wstring get_KeyVals_according_to_Shiftstate(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); */ //std::wstring get_VirtualKey_US_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &caps, v_dw_3D &All_Vector); + +//bool KMX_ImportRules_bak(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 +//bool KMX_Lin_ImportRules_Lin(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 + #endif /* HELPERS_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 0602a9ca5a..feb5f8611a 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -1002,22 +1002,14 @@ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p) { bool IsKeymanUsedKeyVal(std::wstring Keyval) { - - int KV = (int) (*Keyval.c_str()); // 32 127 196 256 - if ((KV >= 0x20 && KV <= 0x7F) || (KV >= 0xC4 && KV < 198) || - (KV >= 199 && KV < 208) || (KV >= 209 && KV < 216) || (KV >= 217 && KV < 229) || - (KV >= 231 && KV < 240) || (KV >= 241 && KV < 248) || (KV >= 249 && KV < 0xFF) || - (KV == 128) || (KV == 178) || (KV == 167) || (KV == 179)|| (KV == 176)|| (KV == 181) ) - - - // 32 127 136 256 - //if ((KV >= 0x20 && KV <= 0x7F) || (KV == 214)|| (KV == 246)|| (KV ==196)|| (KV == 228) || (KV ==220)|| (KV == 252)|| (KV ==223)|| (KV == 186)) - return true; + if ((KV >= 0x20 && KV <= 0x7F) || (KV >= 0xC4 && KV < 198) || + (KV >= 199 && KV < 208) || (KV >= 209 && KV < 216) || (KV >= 217 && KV < 229) || + (KV >= 231 && KV < 240) || (KV >= 241 && KV < 248) || (KV >= 249 && KV < 0xFF) || + (KV == 128) || (KV == 178) || (KV == 167) || (KV == 179) || (KV == 176)|| (KV == 181) ) + return true; else - return false; - } diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 5d58a44c74..94b9f82664 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -40,9 +40,6 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 -bool KMX_ImportRules_bak(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 -//bool KMX_Lin_ImportRules_Lin(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 - std::vector KMX_FDeadkeys; // I4353 void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch); @@ -62,8 +59,8 @@ int KMX_GetDeadkeys(v_dw_2D & dk_ComposeTable, KMX_WORD DeadKey, KMX_WORD *Outpu void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift); -KMX_UINT KMX_VKUSToSCUnderlyingLayout(KMX_DWORD VirtualKeyUS); -KMX_WCHAR KMX_CharFromSC(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey); +KMX_UINT KMX_VKUSToSCUnderlying(KMX_DWORD VirtualKeyUS); +KMX_WCHAR KMX_CharFromSC_underlying(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey); #if defined(_WIN32) || defined(_WIN64) int wmain(int argc, wchar_t* argv[]) { @@ -164,6 +161,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ wprintf(L"\nmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm end\n"); return 0; } + // _S2 TODO which version of VKShiftStates do we use ? // comment from win-version // Map of all shift states that we will work with @@ -483,11 +481,11 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon for (int i = 0;KMX_VKMap[i]; i++) { // I4651 // win goes via VK, Lin goes via SC - /*KMX_DWORD vkUnderlying = KMX_VKUSToVKUnderlyingLayout(All_Vector,(int) KMX_VKMap[i] ); - KMX_WCHAR ch = KMX_CharFromVK(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey);*/ + /*KMX_DWORD vkUnderlying = KMX_VKUSToCharUnderlying(All_Vector,(int) KMX_VKMap[i] ); + KMX_WCHAR ch = KMX_CharFromVK_underlying(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey);*/ - UINT scUnderlying = KMX_VKUSToSCUnderlyingLayout(KMX_VKMap[i]); - KMX_WCHAR ch = KMX_CharFromSC(keymap, VKShiftState[j], scUnderlying, &DeadKey); // _S2 ch is of Other KB + UINT scUnderlying = KMX_VKUSToSCUnderlying(KMX_VKMap[i]); + KMX_WCHAR ch = KMX_CharFromSC_underlying(keymap, VKShiftState[j], scUnderlying, &DeadKey); // _S2 ch is of Other KB //wprintf(L" DoConvert-read i: %i \t(KMX_VKMap): %i (%c) \t---> vkUnderlying: %i (%c) \tshiftstate[%i]: ( %i ) \t---- > ch: %i (%c) \t%ls \t%ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, j, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); @@ -526,14 +524,14 @@ void KMX_LogError(const KMX_WCHART* m1,int m2, LPKMX_KEY key) { */ // takes SC of US keyboard and returns SC of OTHER keyboard -UINT KMX_VKUSToSCUnderlyingLayout(KMX_DWORD VirtualKeyUS) { +UINT KMX_VKUSToSCUnderlying(KMX_DWORD VirtualKeyUS) { UINT SC_US = 8 + USVirtualKeyToScanCode[VirtualKeyUS]; UINT SC_OTHER = SC_US; // not neccessary but to understand what we do return SC_OTHER; } // takes capital letter of US returns cpital character of Other keyboard -KMX_DWORD KMX_VKUSToVKUnderlyingLayout(v_dw_3D &All_Vector,KMX_DWORD inUS) { +KMX_DWORD KMX_VKUSToCharUnderlying(v_dw_3D &All_Vector,KMX_DWORD inUS) { // loop and find char in US; then return char of Other for( int i=0; i< (int)All_Vector[0].size();i++) { for( int j=1; j< (int)All_Vector[0][0].size();j++) { @@ -573,8 +571,9 @@ KMX_WCHAR KMX_SCKUnderlyingLayoutToVKUS_GDK2(GdkKeymap* keymap,KMX_DWORD SC_Othe return SC_Other; } + // takes VK of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] -KMX_DWORD KMX_CharFromVK(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey){ +KMX_DWORD KMX_CharFromVK_underlying(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey){ KMX_UINT VKShiftState_lin; @@ -596,8 +595,9 @@ KMX_DWORD KMX_CharFromVK(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VK } return vkUnderlying; } + // takes SC of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] -KMX_WCHAR KMX_CharFromSC(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey) { +KMX_WCHAR KMX_CharFromSC_underlying(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey) { int VKShiftState_lin = map_VKShiftState_to_Lin(VKShiftState); KMX_DWORD KeyvalOther = getKeyvalsFromKeyCode(keymap,SC_OTHER, VKShiftState_lin); diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 2cac50c6e6..c23df35506 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -42,21 +42,18 @@ extern std::vector KMX_FDeadkeys; // I4353 int run(int argc, std::vector str_argv, char* argv[]); -// _S2 sure KMX_WCHART ??? not KMX_WCHAR ?? -KMX_WCHART KMX_VKUnderlyingLayoutToVKUS_GDK(GdkKeymap* keymap,KMX_DWORD inOther); - -KMX_WCHAR KMX_VKUnderlyingLayoutToVKUS_GDK2(GdkKeymap* keymap,KMX_DWORD inOther); -KMX_WCHAR KMX_VKUnderlyingLayoutToVKUS(v_dw_3D All_Vector,KMX_DWORD SC_US); - - -KMX_WCHAR KMX_SCUnderlyingLayoutToVKUS_GDK(GdkKeymap* keymap,KMX_DWORD inOther); - PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); -UINT KMX_VKUSToSCUnderlyingLayout(KMX_DWORD VirtualKeyUS); -KMX_DWORD KMX_VKUSToVKUnderlyingLayout(v_dw_3D &All_Vector,KMX_DWORD inUS); -KMX_DWORD KMX_CharFromVK(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey); -KMX_WCHAR KMX_CharFromSC(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey); +// _S2 sure KMX_WCHART ??? not KMX_WCHAR ?? +KMX_WCHART KMX_VKUnderlyingLayoutToVKUS_GDK(GdkKeymap* keymap,KMX_DWORD inOther); +KMX_WCHAR KMX_VKUnderlyingLayoutToVKUS_GDK2(GdkKeymap* keymap,KMX_DWORD inOther); +KMX_WCHAR KMX_VKUnderlyingLayoutToVKUS(v_dw_3D All_Vector,KMX_DWORD SC_US); +//KMX_WCHAR KMX_SCUnderlyingLayoutToVKUS_GDK(GdkKeymap* keymap,KMX_DWORD inOther); +UINT KMX_VKUSToSCUnderlying(KMX_DWORD VirtualKeyUS); +KMX_DWORD KMX_VKUSToCharUnderlying(v_dw_3D &All_Vector,KMX_DWORD inUS); +KMX_DWORD KMX_CharFromVK_underlying(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey); +KMX_WCHAR KMX_CharFromSC_underlying(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey); + int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap); From 65ff317e104a3e1a36ddb806882b731f2400a2c9 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 12 Dec 2023 13:26:13 +0100 Subject: [PATCH 158/327] feat(linux): mcompile renaming converting functions --- linux/mcompile/keymap/helpers.cpp | 8 +- linux/mcompile/keymap/keymap.cpp | 28 ++-- linux/mcompile/keymap/keymap.h | 154 +++++++++++----------- linux/mcompile/keymap/mc_import_rules.cpp | 34 +++-- linux/mcompile/keymap/mcompile.cpp | 45 +++---- linux/mcompile/keymap/mcompile.h | 15 +-- 6 files changed, 144 insertions(+), 140 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index e12cfd3e0c..db068caeb0 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -713,8 +713,8 @@ bool InsertKeyvalsFromKeymap(v_dw_3D &All_Vector,GdkKeymap * keymap){ All_Vector[1][i][0] = All_Vector[0][i][0]; // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] - All_Vector[1][i][0+1] = getKeyvalsFromKeyCode(keymap,(All_Vector[1][i][0]),0); //shift state: unshifted:0 - All_Vector[1][i][1+1] = getKeyvalsFromKeyCode(keymap,(All_Vector[1][i][0]),1); //shift state: shifted:1 + All_Vector[1][i][0+1] = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,(All_Vector[1][i][0]),0); //shift state: unshifted:0 + All_Vector[1][i][1+1] = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,(All_Vector[1][i][0]),1); //shift state: shifted:1 //wprintf(L" Keycodes US dw : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); //wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); @@ -729,8 +729,8 @@ KMX_DWORD writeKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_sta KMX_DWORD out; for ( int ii =1; ii< 255;ii++) { - KMX_DWORD out = getKeyvalsFromKeyCode(keymap,ii,0); - KMX_DWORD out2= getKeyvalsFromKeyCode(keymap,ii,1); + KMX_DWORD out = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,ii,0); + KMX_DWORD out2= KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,ii,1); wprintf(L" ii = %i --> keymap = %i (%c)..%i(%c) \n",ii, out,out, out2,out2); } } diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index baa89427b4..1b4b203d84 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -325,8 +325,8 @@ int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { All_Vector[1][i][0] = All_Vector[0][i][0]; // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] - All_Vector[1][i][0+1] = getKeyvalsFromKeyCode(keymap,All_Vector[0][i][0],0); //shift state: unshifted:0 - All_Vector[1][i][1+1] = getKeyvalsFromKeyCode(keymap,All_Vector[0][i][0],1); //shift state: shifted:1 + All_Vector[1][i][0+1] = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,All_Vector[0][i][0],0); //shift state: unshifted:0 + All_Vector[1][i][1+1] = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,All_Vector[0][i][0],1); //shift state: shifted:1 //wprintf(L" Keycodes US dw : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); //wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); @@ -334,8 +334,8 @@ int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { return 0; } -// _S2 can I use gdk_keymap_translate_keyboard_state instead? -KMX_DWORD getKeyvalsFromKeyCode(GdkKeymap *keymap, guint keycode, int shift_state_pos) { +// _S2 can I use gdk_keymap_translate_keyboard_state instead? return s shifted + unshifted only- no altgr,... +KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; guint *keyvals; gint count; @@ -346,6 +346,8 @@ KMX_DWORD getKeyvalsFromKeyCode(GdkKeymap *keymap, guint keycode, int shift_stat //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html +// _S2 this will return 223 instaed of 7838 for UNICODE cher on DE keycode 20 ß ẞ ? ? + if (!(shift_state_pos <= count)) return 0; @@ -367,8 +369,8 @@ KMX_DWORD getKeyvalsFromKeyCode(GdkKeymap *keymap, guint keycode, int shift_stat return out; } -// _S2 do we need that - it does the same as get_KeyCode_fromVKUS -KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { +// _S2 do we need that - it does the same as KMX_get_KeyCodeUnderlying_From_VKUS +KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { GdkModifierType consumed; GdkKeymapKey *maps; @@ -410,13 +412,13 @@ KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { return 0; //_S2 what to return if not found } -KMX_DWORD get_VKUS_fromKeyCode( KMX_DWORD keycode) { +/*KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying( KMX_DWORD keycode) { if ( keycode >7) return (KMX_DWORD) ScanCodeToUSVirtualKey[keycode-8]; return 0; //_S2 what to return if not found -} +}*/ -KMX_DWORD get_KeyCode_fromVKUS( KMX_DWORD VK_US) { +KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS( KMX_DWORD VK_US) { if( VK_US > 7) { KMX_DWORD test = (KMX_DWORD)(8+ USVirtualKeyToScanCode[ VK_US ]); return (KMX_DWORD)(8+ USVirtualKeyToScanCode[ VK_US ]);} @@ -450,6 +452,7 @@ std::wstring convert_DeadkeyValues_ToChar(int in) { return L"\0"; } + std::wstring CodePointToWString(unsigned int codepoint) { std::wstring str; @@ -469,7 +472,7 @@ std::wstring CodePointToWString(unsigned int codepoint) { return str; } -std::wstring get_KeyVals_according_to_keycode_and_Shiftstate_new(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ +std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ GdkModifierType consumed; GdkKeymapKey *maps; @@ -534,9 +537,10 @@ std::wstring get_KeyVals_according_to_keycode_and_Shiftstate_new(GdkKeymap *key else return L"\0"; - if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max) ) + //if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max) ) + if((*keyvals >= deadkey_min) ) return convert_DeadkeyValues_ToChar((int) *keyvals); else - return std::wstring(1, (int) *keyvals); + return std::wstring(1, (int) *keyvals); } diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index cbae5a5959..87b1e2569c 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -39,6 +39,77 @@ enum ShiftState { ShftXxxx = Shft | Xxxx, // 9 }; +// Map of all US English virtual key codes that we can translate +const KMX_DWORD KMX_VKMap[] = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + + VK_SPACE, /* 32 */ + + VK_ACCENT, /* 192 VK_OEM_3 */ + VK_HYPHEN, /* - 189 VK_OEM_MINUS */ + VK_EQUAL, /* = 187 VK_OEM_PLUS */ + + VK_LBRKT, /* [ 219 VK_OEM_4 */ + VK_RBRKT, /* ] 221 VK_OEM_6 */ + VK_BKSLASH, /* \ 220 VK_OEM_5 */ + + VK_COLON, /* ; 186 VK_OEM_1 or ö */ + VK_QUOTE, /* ' 222 VK_OEM_7 or Ä */ + + VK_COMMA, /* , 188 VK_OEM_COMMA */ + VK_PERIOD, /* . 190 VK_OEM_PERIOD */ + VK_SLASH, /* / 191 VK_OEM_2 */ + + VK_xDF, /* ß (?) 223*/ + VK_OEM_102, /* < > | 226 */ + + 0 +}; + +//_S2 QUESTION Which character do we use in that case? 0 or FFFF or 32 or ?? +// this is what we return when we find an invalid character +//static KMX_DWORD returnIfCharInvalid = 32; +static KMX_DWORD returnIfCharInvalid = 0; + +//_S2 QUESTION Which threshold ( from what int value onwards is a character considered deadkey? 65000 28000?, > 255? ?? +static KMX_DWORD deadkeyThreshold = 65000; +static KMX_DWORD deadkey_min = 0xfe50; +static KMX_DWORD deadkey_max = 0xfe93; + +int map_VKShiftState_to_Lin(int VKShiftState); + +// takes a std::wstring (=contents of line symbols-file ) and returns the (int) value of the character +KMX_DWORD convertNamesToIntegerValue(std::wstring tok_wstr); + +// create a Vector with all entries of both keymaps+ keymap +int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap); +//int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector); + +// read configuration file, split and write to 3D-Vector (Data for US on [0][ ][ ] ) +int write_US_ToVector(v_dw_3D &vec, std::string language, const char *text); + +// 1. step: read complete Row of Configuration file US +bool createCompleteRow_US(v_str_1D &complete_List, FILE *fpp, const char *text, std::string language); + +// replace Name of Key (e.g. ) wih Keycode ( e.g. 0x15 ) +int replace_KeyName_with_Keycode(std::string in); + +// 2nd step: write contents to 3D vector +int split_US_To_3D_Vector(v_dw_3D &all_US, v_str_1D completeList); + +// create an empty 2D vector containing "--" in all fields +v_dw_2D create_empty_2D_Vector(int dim_rows, int dim_shifts); + +//_S2 needed? +// append characters using GDK to 3D-Vector (Data for Other Language on [1][ ][ ] ) +int append_other_ToVector(v_dw_3D &All_Vector, GdkKeymap *keymap); + +// initialize GDK +bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); + +//------------------------------ + const UINT USVirtualKeyToScanCode[256] = { 0x00, // L"K_?00", // &H0 0x00, // L"K_LBUTTON", // &H1 @@ -438,90 +509,21 @@ const UINT ScanCodeToUSVirtualKey[128] = { 0x00 // 0x7f => No match }; -// Map of all US English virtual key codes that we can translate -const KMX_DWORD KMX_VKMap[] = { - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - - VK_SPACE, /* 32 */ - - VK_ACCENT, /* 192 VK_OEM_3 */ - VK_HYPHEN, /* - 189 VK_OEM_MINUS */ - VK_EQUAL, /* = 187 VK_OEM_PLUS */ - - VK_LBRKT, /* [ 219 VK_OEM_4 */ - VK_RBRKT, /* ] 221 VK_OEM_6 */ - VK_BKSLASH, /* \ 220 VK_OEM_5 */ - - VK_COLON, /* ; 186 VK_OEM_1 or ö */ - VK_QUOTE, /* ' 222 VK_OEM_7 or Ä */ - - VK_COMMA, /* , 188 VK_OEM_COMMA */ - VK_PERIOD, /* . 190 VK_OEM_PERIOD */ - VK_SLASH, /* / 191 VK_OEM_2 */ - - VK_xDF, /* ß (?) 223*/ - VK_OEM_102, /* < > | 226 */ - - 0 -}; - -//_S2 QUESTION Which character do we use in that case? 0 or FFFF or 32 or ?? -// this is what we return when we find an invalid character -//static KMX_DWORD returnIfCharInvalid = 32; -static KMX_DWORD returnIfCharInvalid = 0; - -//_S2 QUESTION Which threshold ( from what int value onwards is a character considered deadkey? 65000 28000?, > 255? ?? -static KMX_DWORD deadkeyThreshold = 65000; -static KMX_DWORD deadkey_min = 0xfe50; -static KMX_DWORD deadkey_max = 0xfe93; - -int map_VKShiftState_to_Lin(int VKShiftState); - -// takes a std::wstring (=contents of line symbols-file ) and returns the (int) value of the character -KMX_DWORD convertNamesToIntegerValue(std::wstring tok_wstr); - -// create a Vector with all entries of both keymaps+ keymap -int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap); -//int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector); - -// read configuration file, split and write to 3D-Vector (Data for US on [0][ ][ ] ) -int write_US_ToVector(v_dw_3D &vec, std::string language, const char *text); - -// 1. step: read complete Row of Configuration file US -bool createCompleteRow_US(v_str_1D &complete_List, FILE *fpp, const char *text, std::string language); - -// replace Name of Key (e.g. ) wih Keycode ( e.g. 0x15 ) -int replace_KeyName_with_Keycode(std::string in); - -// 2nd step: write contents to 3D vector -int split_US_To_3D_Vector(v_dw_3D &all_US, v_str_1D completeList); - -// create an empty 2D vector containing "--" in all fields -v_dw_2D create_empty_2D_Vector(int dim_rows, int dim_shifts); - -//_S2 needed? -// append characters using GDK to 3D-Vector (Data for Other Language on [1][ ][ ] ) -int append_other_ToVector(v_dw_3D &All_Vector, GdkKeymap *keymap); - -// initialize GDK -bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); - -// find Keyvals to fill into 2D-Vector of Other Language -KMX_DWORD getKeyvalsFromKeyCode(GdkKeymap *keymap, guint keycode, int shift_state_pos); - // take deadkey-value (e.g.65106) and return character (e.g. '^' ) std::wstring convert_DeadkeyValues_ToChar(int in); +// find Keyvals to fill into 2D-Vector of Other Language +KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos); + // returns KeySyms fo ra given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) -std::wstring get_KeyVals_according_to_keycode_and_Shiftstate_new(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); +std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); // return the VirtualKey of the Other Keyboard for given Scancode using GDK -KMX_DWORD get_VirtualKey_Other_GDK( GdkKeymap *keymap, KMX_DWORD scanCode); +KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD scanCode); -KMX_DWORD get_VKUS_fromKeyCode( KMX_DWORD keycode); +//KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying( KMX_DWORD keycode); -KMX_DWORD get_KeyCode_fromVKUS( KMX_DWORD VK_US); +KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS( KMX_DWORD VK_US); bool IsKeymanUsedKeyVal(std::wstring Keyval); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index feb5f8611a..dd9678813e 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -151,14 +151,14 @@ public: }*/ KMX_VirtualKey(UINT scanCode, KMX_HKL hkl, v_dw_3D All_Vector, GdkKeymap **keymap) { - this->m_vk = get_VirtualKey_Other_GDK(*keymap, scanCode); + this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying_GDK(*keymap, scanCode); // _s2 correct? this->m_vk = get_VirtualKey_US( scanCode) this->m_hkl = hkl; this->m_sc = scanCode; } KMX_VirtualKey(KMX_HKL hkl,UINT scanCode, v_dw_3D All_Vector, GdkKeymap **keymap) { - this->m_vk = get_VirtualKey_Other_GDK(*keymap, scanCode); + this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying_GDK(*keymap, scanCode); // _s2 correct? this->m_vk = get_VirtualKey_US( scanCode) this->m_hkl = hkl; this->m_sc = scanCode; @@ -348,8 +348,8 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; *key->dpContext = 0; key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); // _S2 this fun returns the shifted Char it goes wrog for numbers, special here!! - //key->Key = KMX_VKUnderlyingLayoutToVKUS(All_Vector,this->VK()); - key->Key = KMX_VKUnderlyingLayoutToVKUS_GDK(keymap,this->VK()); + //key->Key = KMX_get_KVUS_From_KVUnderlying_VEC(All_Vector,this->VK()); + key->Key = KMX_get_VKUnderlying_From_VKUS_GDK(keymap,this->VK()); key->Line = 0; if(bDeadkeyConversion) { // I4552 @@ -370,10 +370,10 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; if(st[ich] < 0x20 || st[ich] == 0x7F) { isvalid=false; break; } } if(isvalid) { - //key->Key = KMX_VKUnderlyingLayoutToVKUS(All_Vector,this->VK()); - key->Key = KMX_VKUnderlyingLayoutToVKUS_GDK(keymap,this->VK()); + //key->Key = KMX_get_KVUS_From_KVUnderlying_VEC(All_Vector,this->VK()); + key->Key = KMX_get_VKUnderlying_From_VKUS_GDK(keymap,this->VK()); std::wstring w1_S2 = get_m_rgss(ss,caps); - //wprintf(L"\n KMX_VKUnderlyingLayoutToVKUS_GD writes %ls %c",w1_S2.c_str(), key->Key ); + //wprintf(L"\n KMX_get_KVUS_From_KVUnderlying_GD writes %ls %c",w1_S2.c_str(), key->Key ); //wprintf(L" this->VK(): %i ", this->VK()); key->Line = 0; @@ -546,12 +546,12 @@ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { // _S2 cchBuff remove? int KMX_ToUnicodeEx( guint ScanCode, const BYTE *lpKeyStccate, PWCHAR pwszBuff, int cchBuff, int shift_state, int caps,GdkKeymap *keymap) { - KMX_DWORD kvl= getKeyvalsFromKeyCode(keymap, ScanCode, shift_state); + KMX_DWORD kvl= KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap, ScanCode, shift_state); - std::wstring character = get_KeyVals_according_to_keycode_and_Shiftstate_new(keymap, ScanCode, ShiftState(shift_state), caps); + std::wstring character = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, ScanCode, ShiftState(shift_state), caps); pwszBuff[0]= * (PWCHAR) character.c_str(); - if((kvl >= 0xfe50) && (kvl <= 0xfe93)) + if((kvl >= deadkey_min) && (kvl <= deadkey_max)) return -1; else return 1; @@ -560,14 +560,12 @@ int KMX_ToUnicodeEx( guint ScanCode, const BYTE *lpKeyStccate, PWCHAR pwszBuff, // _S2 cchBuff remove? int KMX_ToUnicodeEx(guint ScanCode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, int cchBuff, int shift_state, int caps,GdkKeymap *keymap) { - KMX_DWORD kvl= getKeyvalsFromKeyCode(keymap, ScanCode, shift_state); - - std::wstring character = get_KeyVals_according_to_keycode_and_Shiftstate_new(keymap, ScanCode, ShiftState(shift_state), caps); - pwszBuff[0]= * (PWCHAR) character.c_str(); - - if((kvl >= 0xfe50) && (kvl <= 0xfe93) ) + KMX_DWORD kvl= KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap, ScanCode, shift_state); + if((kvl >= deadkey_min) && (kvl <= deadkey_max)) return -1; - else + + std::wstring character = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, ScanCode, ShiftState(shift_state), caps); + pwszBuff[0]= * (PWCHAR) character.c_str(); return 1; } @@ -659,7 +657,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd continue; } - KMX_DWORD SC_US = get_KeyCode_fromVKUS(iKey); + KMX_DWORD SC_US = KMX_get_KeyCodeUnderlying_From_VKUS(iKey); for(int caps = 0; caps <= 1; caps++) { // _S2 is THIS correct ??? Do we need lpKeyState or is it just used in ToUnicodeEx?? diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 94b9f82664..81c09e2f47 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -59,8 +59,8 @@ int KMX_GetDeadkeys(v_dw_2D & dk_ComposeTable, KMX_WORD DeadKey, KMX_WORD *Outpu void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift); -KMX_UINT KMX_VKUSToSCUnderlying(KMX_DWORD VirtualKeyUS); -KMX_WCHAR KMX_CharFromSC_underlying(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey); +KMX_UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); +KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey); #if defined(_WIN32) || defined(_WIN64) int wmain(int argc, wchar_t* argv[]) { @@ -419,7 +419,7 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR d while(*pdk) { // Look up the ch // go via SC - UINT vkUnderlying = KMX_VKUnderlyingLayoutToVKUS(All_Vector, *pdk); + UINT vkUnderlying = KMX_get_KVUS_From_KVUnderlying_VEC(All_Vector, *pdk); KMX_TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); pdk+=3; } @@ -481,11 +481,11 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon for (int i = 0;KMX_VKMap[i]; i++) { // I4651 // win goes via VK, Lin goes via SC - /*KMX_DWORD vkUnderlying = KMX_VKUSToCharUnderlying(All_Vector,(int) KMX_VKMap[i] ); - KMX_WCHAR ch = KMX_CharFromVK_underlying(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey);*/ + /*KMX_DWORD vkUnderlying = KMX_get_KVUnderlying_From_KVUS_VEC(All_Vector,(int) KMX_VKMap[i] ); + KMX_WCHAR ch = KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_VEC(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey);*/ - UINT scUnderlying = KMX_VKUSToSCUnderlying(KMX_VKMap[i]); - KMX_WCHAR ch = KMX_CharFromSC_underlying(keymap, VKShiftState[j], scUnderlying, &DeadKey); // _S2 ch is of Other KB + UINT scUnderlying = KMX_get_SCUnderlying_From_VKUS(KMX_VKMap[i]); + KMX_WCHAR ch = KMX_get_CharUnderlying_From_SCUnderlying_GDK(keymap, VKShiftState[j], scUnderlying, &DeadKey); // _S2 ch is of Other KB //wprintf(L" DoConvert-read i: %i \t(KMX_VKMap): %i (%c) \t---> vkUnderlying: %i (%c) \tshiftstate[%i]: ( %i ) \t---- > ch: %i (%c) \t%ls \t%ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, j, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); @@ -524,14 +524,14 @@ void KMX_LogError(const KMX_WCHART* m1,int m2, LPKMX_KEY key) { */ // takes SC of US keyboard and returns SC of OTHER keyboard -UINT KMX_VKUSToSCUnderlying(KMX_DWORD VirtualKeyUS) { +UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS) { UINT SC_US = 8 + USVirtualKeyToScanCode[VirtualKeyUS]; UINT SC_OTHER = SC_US; // not neccessary but to understand what we do return SC_OTHER; } // takes capital letter of US returns cpital character of Other keyboard -KMX_DWORD KMX_VKUSToCharUnderlying(v_dw_3D &All_Vector,KMX_DWORD inUS) { +KMX_DWORD KMX_get_KVUnderlying_From_KVUS_VEC(v_dw_3D &All_Vector,KMX_DWORD inUS) { // loop and find char in US; then return char of Other for( int i=0; i< (int)All_Vector[0].size();i++) { for( int j=1; j< (int)All_Vector[0][0].size();j++) { @@ -543,7 +543,7 @@ KMX_DWORD KMX_VKUSToCharUnderlying(v_dw_3D &All_Vector,KMX_DWORD inUS) { return inUS; } -KMX_WCHAR KMX_VKUnderlyingLayoutToVKUS(v_dw_3D All_Vector, KMX_DWORD VK_OTHER) { +KMX_WCHAR KMX_get_KVUS_From_KVUnderlying_VEC(v_dw_3D All_Vector, KMX_DWORD VK_OTHER) { KMX_DWORD VK_US; for( int i=0; i< (int)All_Vector[0].size()-1 ;i++) { @@ -558,7 +558,7 @@ KMX_WCHAR KMX_VKUnderlyingLayoutToVKUS(v_dw_3D All_Vector, KMX_DWORD VK_OTHER) { } // _S2 sure KMX_WCHART ??? not KMX_WCHAR ?? not usable!! -KMX_WCHART KMX_VKUnderlyingLayoutToVKUS_GDK(GdkKeymap* keymap,KMX_DWORD VK_US) { +KMX_WCHART KMX_get_VKUnderlying_From_VKUS_GDK(GdkKeymap* keymap,KMX_DWORD VK_US) { KMX_WORD VK_DE = ( KMX_WORD ) map_Ikey_DE(VK_US); if(VK_DE!= VK_US) @@ -572,35 +572,36 @@ KMX_WCHAR KMX_SCKUnderlyingLayoutToVKUS_GDK2(GdkKeymap* keymap,KMX_DWORD SC_Othe return SC_Other; } -// takes VK of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] -KMX_DWORD KMX_CharFromVK_underlying(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey){ +/* takes KV of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] +KMX_DWORD KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_VEC(v_dw_3D &All_Vector,KMX_DWORD KVUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey){ KMX_UINT VKShiftState_lin; - /* 0000 0000 */ + // 0000 0000 if (VKShiftState == 0 ) VKShiftState_lin = 0; - /* 0001 0000 */ + // 0001 0000 if (VKShiftState == 16) VKShiftState_lin = 1; - /* 0000 1001 */ + // 0000 1001 if (VKShiftState == 9 ) VKShiftState_lin = 2; - /* 0001 1001 */ + // 0001 1001 if (VKShiftState == 25) VKShiftState_lin = 3; - // loop and find vkUnderlying in Other; then return char with correct shiftstate + // loop and find KVUnderlying in Other; then return char with correct shiftstate for( int i=0; i< (int)All_Vector[1].size();i++) { KMX_DWORD CharOther = All_Vector[1][i][2]; - if( vkUnderlying == CharOther ) { + if( KVUnderlying == CharOther ) { return All_Vector[1][i][VKShiftState_lin+1]; // [VKShiftState_lin+1] because we have the name of the key in All_Vector[1][i][0], so we need to get the one after this } } - return vkUnderlying; + return KVUnderlying; } +*/ // takes SC of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] -KMX_WCHAR KMX_CharFromSC_underlying(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey) { +KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey) { int VKShiftState_lin = map_VKShiftState_to_Lin(VKShiftState); - KMX_DWORD KeyvalOther = getKeyvalsFromKeyCode(keymap,SC_OTHER, VKShiftState_lin); + KMX_DWORD KeyvalOther = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,SC_OTHER, VKShiftState_lin); // _S2 how to detect deadkeys ? KeyvalOther >deadkeyThreshold KeyvalOther > 255? KeyvalOther > 65000 ? or what else? //if (KeyvalOther > deadkeyThreshold) { diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index c23df35506..7fa71f6c52 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -45,14 +45,13 @@ int run(int argc, std::vector str_argv, char* argv[]); PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); // _S2 sure KMX_WCHART ??? not KMX_WCHAR ?? -KMX_WCHART KMX_VKUnderlyingLayoutToVKUS_GDK(GdkKeymap* keymap,KMX_DWORD inOther); -KMX_WCHAR KMX_VKUnderlyingLayoutToVKUS_GDK2(GdkKeymap* keymap,KMX_DWORD inOther); -KMX_WCHAR KMX_VKUnderlyingLayoutToVKUS(v_dw_3D All_Vector,KMX_DWORD SC_US); -//KMX_WCHAR KMX_SCUnderlyingLayoutToVKUS_GDK(GdkKeymap* keymap,KMX_DWORD inOther); -UINT KMX_VKUSToSCUnderlying(KMX_DWORD VirtualKeyUS); -KMX_DWORD KMX_VKUSToCharUnderlying(v_dw_3D &All_Vector,KMX_DWORD inUS); -KMX_DWORD KMX_CharFromVK_underlying(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey); -KMX_WCHAR KMX_CharFromSC_underlying(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey); +KMX_WCHART KMX_get_VKUnderlying_From_VKUS_GDK(GdkKeymap* keymap,KMX_DWORD inOther); +//KMX_WCHAR KMX_get_KVUS_From_KVUnderlying_GDK2(GdkKeymap* keymap,KMX_DWORD inOther); +KMX_WCHAR KMX_get_KVUS_From_KVUnderlying_VEC(v_dw_3D All_Vector,KMX_DWORD SC_US); +UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); +KMX_DWORD KMX_get_KVUnderlying_From_KVUS_VEC(v_dw_3D &All_Vector,KMX_DWORD inUS); +//KMX_DWORD KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_VEC(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey); +KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey); int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap); From bc478f7254cf5d411c1eb4a8802f598a4b94471f Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 12 Dec 2023 23:05:33 +0100 Subject: [PATCH 159/327] feat(linux): mcompile LayoutRow started --- linux/mcompile/keymap/mc_import_rules.cpp | 9 ++++---- linux/mcompile/keymap/mcompile.cpp | 27 +++++++++++++++++++++-- linux/mcompile/keymap/mcompile.h | 2 ++ 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index dd9678813e..93e9624e51 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -327,6 +327,8 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + capslock=1; // _S2 + for (int ss = 0; ss <= MaxShiftState; ss++) { if (ss == Menu || ss == ShftMenu) { @@ -370,12 +372,9 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; if(st[ich] < 0x20 || st[ich] == 0x7F) { isvalid=false; break; } } if(isvalid) { - //key->Key = KMX_get_KVUS_From_KVUnderlying_VEC(All_Vector,this->VK()); - key->Key = KMX_get_VKUnderlying_From_VKUS_GDK(keymap,this->VK()); - std::wstring w1_S2 = get_m_rgss(ss,caps); - //wprintf(L"\n KMX_get_KVUS_From_KVUnderlying_GD writes %ls %c",w1_S2.c_str(), key->Key ); + KMX_DWORD SC_Underlying = KMX_get_KeyCodeUnderlying_From_KeycodeUS_VEC(All_Vector,this->SC(), ss); + key->Key = KMX_get_VKUS_From_KeyCodeUnderlying_GDK( keymap, SC_Underlying); - //wprintf(L" this->VK(): %i ", this->VK()); key->Line = 0; // _S2 _differences in sstateflag probably from here and KMX_IsCapsEqualToShift... key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 81c09e2f47..c2ec204fa4 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -560,11 +560,11 @@ KMX_WCHAR KMX_get_KVUS_From_KVUnderlying_VEC(v_dw_3D All_Vector, KMX_DWORD VK_OT // _S2 sure KMX_WCHART ??? not KMX_WCHAR ?? not usable!! KMX_WCHART KMX_get_VKUnderlying_From_VKUS_GDK(GdkKeymap* keymap,KMX_DWORD VK_US) { - KMX_WORD VK_DE = ( KMX_WORD ) map_Ikey_DE(VK_US); + /*KMX_WORD VK_DE = ( KMX_WORD ) map_Ikey_DE(VK_US); if(VK_DE!= VK_US) return VK_DE; else - return VK_US; + return VK_US;*/ }// _S2 sure KMX_WCHART ??? not KMX_WCHAR ?? KMX_WCHAR KMX_SCKUnderlyingLayoutToVKUS_GDK2(GdkKeymap* keymap,KMX_DWORD SC_Other) { @@ -597,6 +597,29 @@ KMX_DWORD KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_VEC(v_dw_3D } */ +KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_VEC(v_dw_3D &All_Vector, KMX_DWORD KC_US, int Shiftstate) { + + KMX_DWORD Character = 0; + // find character with that scancode + for( int i=0; i< (int)All_Vector[0].size()-1 ;i++) { + if ( ( All_Vector[0][i][0] == KC_US ) ) { + if ( Shiftstate+1 < All_Vector[0][i].size()-1) + Character = All_Vector[0][i][Shiftstate+1]; + break; + } + } + + //Find underlying SC of character + for( int i=0; i< (int)All_Vector[1].size()-1 ;i++) { + for( int j=1; j< (int)All_Vector[01][0].size();j++) { + if ( ( All_Vector[1][i][j] == Character ) ) { + KC_US = All_Vector[1][i][j]; + return All_Vector[1][i][0]; + } + } + } + return KC_US; +} // takes SC of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey) { diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 7fa71f6c52..6fc43a5b65 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -53,6 +53,8 @@ KMX_DWORD KMX_get_KVUnderlying_From_KVUS_VEC(v_dw_3D &All_Vector,KMX_DWORD inUS) //KMX_DWORD KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_VEC(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey); KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey); +KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_VEC(v_dw_3D &All_Vector, KMX_DWORD VK_US, int Shiftstate); + int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap); From 60c3d89bb0daa2640363c315eab4ebb5b8a36f5c Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 13 Dec 2023 14:40:28 +0100 Subject: [PATCH 160/327] feat(linux): mcompile LayoutRow --- linux/mcompile/keymap/keymap.cpp | 23 +++++++++++++++++++++-- linux/mcompile/keymap/keymap.h | 4 +++- linux/mcompile/keymap/mc_import_rules.cpp | 19 ++++++++++++++----- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 1b4b203d84..8b49d612c4 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -412,11 +412,11 @@ KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD return 0; //_S2 what to return if not found } -/*KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying( KMX_DWORD keycode) { +KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying( KMX_DWORD keycode) { if ( keycode >7) return (KMX_DWORD) ScanCodeToUSVirtualKey[keycode-8]; return 0; //_S2 what to return if not found -}*/ +} KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS( KMX_DWORD VK_US) { if( VK_US > 7) { @@ -544,3 +544,22 @@ std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(Gd return std::wstring(1, (int) *keyvals); } + + +KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector,KMX_DWORD KC_US, ShiftState ss, int caps) { + + KMX_DWORD Character; + std::wstring ws = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, KC_US, ss, caps); + Character = *ws.c_str(); + + //Find underlying SC of character + for( int i=0; i< (int)All_Vector[1].size()-1 ;i++) { + for( int j=1; j< (int)All_Vector[01][0].size();j++) { + if ( ( All_Vector[1][i][j] == Character ) ) { + KC_US = All_Vector[1][i][j]; + return All_Vector[1][i][0]; + } + } + } + return KC_US; +} diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 87b1e2569c..66bd9967c0 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -521,10 +521,12 @@ std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(Gdk // return the VirtualKey of the Other Keyboard for given Scancode using GDK KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD scanCode); -//KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying( KMX_DWORD keycode); +KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying( KMX_DWORD keycode); KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS( KMX_DWORD VK_US); +KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector,KMX_DWORD KC_US, ShiftState ss, int caps); + bool IsKeymanUsedKeyVal(std::wstring Keyval); std::wstring CodePointToWString(unsigned int codepoint); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 93e9624e51..7f24aaa71f 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -327,8 +327,8 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); - capslock=1; // _S2 - + // _S2 DESIGN NEEDED on how to replace capslock + capslock=1; // _S2 for (int ss = 0; ss <= MaxShiftState; ss++) { if (ss == Menu || ss == ShftMenu) { @@ -372,11 +372,19 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; if(st[ich] < 0x20 || st[ich] == 0x7F) { isvalid=false; break; } } if(isvalid) { - KMX_DWORD SC_Underlying = KMX_get_KeyCodeUnderlying_From_KeycodeUS_VEC(All_Vector,this->SC(), ss); - key->Key = KMX_get_VKUS_From_KeyCodeUnderlying_GDK( keymap, SC_Underlying); + // this is different to mcompile windows !!!! + // this->m_sc stores SC-US = SCUnderlying + // this->m_vk stores VK-US + // key->Key stores VK-US + // key->dpOutput stores character Underlying + + // _S2 confusing: since we sort rgkey by VKUS: is SC_Underlying the right SC or SC_Underlying_gdk?? it will be clear when we look at kmx/kmn-file + //KMX_DWORD SC_Underlying = KMX_get_KeyCodeUnderlying_From_KeycodeUS_VEC(All_Vector,this->SC(), ss); + + KMX_DWORD SC_Underlying_gdk = KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(keymap, All_Vector,this->SC(), (ShiftState) ss, caps); + key->Key = KMX_get_VKUS_From_KeyCodeUnderlying_GDK( keymap, SC_Underlying_gdk); key->Line = 0; - // _S2 _differences in sstateflag probably from here and KMX_IsCapsEqualToShift... key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); key->dpContext = new KMX_WCHAR; *key->dpContext = 0; p = key->dpOutput = new KMX_WCHAR[st.size() + 1]; @@ -658,6 +666,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd KMX_DWORD SC_US = KMX_get_KeyCodeUnderlying_From_VKUS(iKey); + // _S2 deadkey not finished; Ctrl, Shft +40 not tested for(int caps = 0; caps <= 1; caps++) { // _S2 is THIS correct ??? Do we need lpKeyState or is it just used in ToUnicodeEx?? loader.KMX_ClearKeyboardBuffer(); From 0d00533153b66cb1ffca0516f2c8e4a1edd8fa34 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 13 Dec 2023 16:13:14 +0100 Subject: [PATCH 161/327] feat(linux): mcompile lots of cleanup --- linux/mcompile/keymap/deadkey.cpp | 3 +- linux/mcompile/keymap/helpers.cpp | 33 ++++++++- linux/mcompile/keymap/keymap.cpp | 8 +- linux/mcompile/keymap/keymap.h | 17 ----- linux/mcompile/keymap/mc_import_rules.cpp | 90 +++++------------------ linux/mcompile/keymap/mcompile.cpp | 44 +---------- linux/mcompile/keymap/mcompile.h | 13 +--- 7 files changed, 56 insertions(+), 152 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 757624bcda..062d8eb2fb 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -1,7 +1,6 @@ #include "keymap.h" #include "deadkey.h" -// _S2 do I need nameresult somewhere??? v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult) { v_dw_1D line; line.push_back(convertNamesToIntegerValue(first)); @@ -55,7 +54,7 @@ KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap return Name; } -// _S2 QUESTION is this the right place to get dk from? if not wher are they stored? +// _S2 DESIGN NEEDED is this the right place to get dk from? if not wher are they stored? KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable){ // values taken from: https://help.ubuntu.com/community/GtkDeadKeyTable#Latin diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index db068caeb0..b872c24782 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -62,6 +62,31 @@ UINT map_Ikey_DE(UINT iKey) { return iKey; } +/* takes KV of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] +KMX_DWORD KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_VEC(v_dw_3D &All_Vector,KMX_DWORD KVUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey){ + + KMX_UINT VKShiftState_lin; + + // 0000 0000 + if (VKShiftState == 0 ) VKShiftState_lin = 0; + // 0001 0000 + if (VKShiftState == 16) VKShiftState_lin = 1; + // 0000 1001 + if (VKShiftState == 9 ) VKShiftState_lin = 2; + // 0001 1001 + if (VKShiftState == 25) VKShiftState_lin = 3; + + // loop and find KVUnderlying in Other; then return char with correct shiftstate + for( int i=0; i< (int)All_Vector[1].size();i++) { + KMX_DWORD CharOther = All_Vector[1][i][2]; + if( KVUnderlying == CharOther ) { + return All_Vector[1][i][VKShiftState_lin+1]; // [VKShiftState_lin+1] because we have the name of the key in All_Vector[1][i][0], so we need to get the one after this + } + } + return KVUnderlying; +} +*/ + // _S2 TODO How to do mapping between Linux keycodes and keyman SC const int Lin_KM__map(int i, v_dw_3D &All_Vector) { // MAP: @@ -397,7 +422,7 @@ bool write_RGKEY_FileToVector(v_dw_2D& shift_states, const char* infile) { return(0); } -KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector) { +/*KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector) { for( int i=0; i< (int)All_Vector[0].size();i++) { //number keys return unshifted value ( e.g. 1, not !) @@ -422,8 +447,8 @@ KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector) { } } return 0; -} - +}*/ +/* bool test_In_Out(v_dw_3D All_Vector){ for ( int i=0; i<61;i++) @@ -476,7 +501,7 @@ bool test_In_Out(v_dw_3D All_Vector){ } } } - +*/ // ToDo write 2 func for return pos of Key_US and Pos of Key_Other // return the Scancode of for given VirtualKey of Other US KMX_DWORD get_position_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 8b49d612c4..f49bc0116c 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -158,7 +158,7 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, int replace_KeyName_with_Keycode(std::string in) { int out = returnIfCharInvalid; -// _S2 these are the Scancode-Values we use in Keyman ( = the windows scancodes+8 ) + // _S2 these are the Scancode-Values we use in Keyman ( = the windows scancodes+8 ) // NAME IN SYMBOLS-FILE KEYCODE (LIN STYLE) (WIN STYLE) VK_US VK_DE /*on US keyb;*/ if ( in == "key") out = 49; /* VK_ */ // TOASK correct ??? @@ -356,20 +356,16 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap out =(KMX_DWORD) keyvals[shift_state_pos]; - // _S2 if out of range of what ( ascii??) return 0 or other value ? - //if (out > 255) { if ( (out >= deadkey_min) && (out <= deadkey_max) ) { wprintf(L"out of range: found deadkey value out( %i) for keycode = %i /shift_state_pos %i (49= TLDE 21= VK_EQUALS on US keyboard) \n", out,keycode,shift_state_pos); - //out = 0; } - + // _S2 g_free used everywhere? g_free(keyvals); g_free(maps); return out; } -// _S2 do we need that - it does the same as KMX_get_KeyCodeUnderlying_From_VKUS KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { GdkModifierType consumed; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 66bd9967c0..03b1bd4dd9 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -67,9 +67,6 @@ const KMX_DWORD KMX_VKMap[] = { 0 }; -//_S2 QUESTION Which character do we use in that case? 0 or FFFF or 32 or ?? -// this is what we return when we find an invalid character -//static KMX_DWORD returnIfCharInvalid = 32; static KMX_DWORD returnIfCharInvalid = 0; //_S2 QUESTION Which threshold ( from what int value onwards is a character considered deadkey? 65000 28000?, > 255? ?? @@ -101,7 +98,6 @@ int split_US_To_3D_Vector(v_dw_3D &all_US, v_str_1D completeList); // create an empty 2D vector containing "--" in all fields v_dw_2D create_empty_2D_Vector(int dim_rows, int dim_shifts); -//_S2 needed? // append characters using GDK to 3D-Vector (Data for Other Language on [1][ ][ ] ) int append_other_ToVector(v_dw_3D &All_Vector, GdkKeymap *keymap); @@ -531,17 +527,4 @@ bool IsKeymanUsedKeyVal(std::wstring Keyval); std::wstring CodePointToWString(unsigned int codepoint); -//UINT find_SC_Other_from_SC_US_GDK(UINT vk_US_187,GdkKeymap *keymap); - -UINT map_Ikey_DE(UINT iKey); -// _S2 needed? -// can go later -void Try_GDK(GdkKeymap *keymap, UINT KeySym ); -void Inspect_Key_S(GdkKeymap *keymap );//needed? -// _S2 TODO How to do mapping between Linux keycodes and keyman SC -const int Lin_KM__map(int i, v_dw_3D &All_Vector); -KMX_DWORD mapChar_To_VK(KMX_DWORD chr ); -KMX_DWORD mapVK_To_char(KMX_DWORD SC ); - - # endif /*KEYMAP_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 7f24aaa71f..59b2f0f4cc 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -27,8 +27,8 @@ #include "mc_kmxfile.h" #include "keymap.h" -int KMX_ToUnicodeEx(guint ScanCode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, int cchBuff, int shift_state, int caps, GdkKeymap *keymap =NULL); - +int KMX_ToUnicodeEx(guint ScanCode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, int shift_state, int caps, GdkKeymap *keymap =NULL); +int KMX_ToUnicodeEx(guint ScanCode, const BYTE *lpKeyState, PWCHAR pwszBuff, int shift_state, int caps,GdkKeymap *keymap); const int KMX_ShiftStateMap[] = { ISVIRTUALKEY, ISVIRTUALKEY | K_SHIFTFLAG, @@ -110,56 +110,15 @@ private: std::wstring m_rgss[10][2]; public: -// _S2 can be deleted later - /* KMX_VirtualKey(KMX_HKL hkl, UINT KMX_virtualKey) { - this->m_sc = MapVirtualKeyEx(virtualKey, 0, hkl); - this->m_hkl = hkl; - this->m_vk = KMX_virtualKey; - memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); - }*/ - // _S2 can be deleted later - /*KMX_VirtualKey(UINT scanCode, KMX_HKL hkl) { - // this->m_vk = MapVirtualKeyEx(scanCode, 1, hkl); - this->m_hkl = hkl; - this->m_sc = scanCode; - }*/ - - - /*KMX_VirtualKey(KMX_HKL hkl, UINT KMX_virtualKey, v_dw_3D All_Vector) { - this->m_sc = MapVirtualKeyEx(virtualKey, 0, hkl); // second para =0: MAPVK_VK_TO_VSC=1 - //the uCode parameter is a virtual-key code and is - //translated into a scan code. If it is a virtual-key - //code that does not distinguish between left- and - //right-hand keys, the left-hand scan code is returned. - //If there is no translation, the function returns 0. - this->m_sc = get_SC_From_VirtualKey_Other(KMX_virtualKey, All_Vector); - this->m_hkl = hkl; - this->m_vk = KMX_virtualKey; - memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); - }*/ - - /*KMX_VirtualKey(UINT scanCode, KMX_HKL hkl, v_dw_3D All_Vector) { - // _S2 this->m_vk = MapVirtualKeyEx(scanCode, 1, hkl); // second para= 1: MAPVK_VSC_TO_VK =1 - // The first parameter is a scan code and is - // translated into a virtual-key code that does not - // distinguish between left- and right-hand keys. - // If there is no translation, the function returns 0. - // SC -> VK - this->m_vk = get_VirtualKey_Other_From_SC(scanCode, All_Vector); - this->m_hkl = hkl; - this->m_sc = scanCode; - }*/ KMX_VirtualKey(UINT scanCode, KMX_HKL hkl, v_dw_3D All_Vector, GdkKeymap **keymap) { this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying_GDK(*keymap, scanCode); - // _s2 correct? this->m_vk = get_VirtualKey_US( scanCode) this->m_hkl = hkl; this->m_sc = scanCode; } KMX_VirtualKey(KMX_HKL hkl,UINT scanCode, v_dw_3D All_Vector, GdkKeymap **keymap) { this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying_GDK(*keymap, scanCode); - // _s2 correct? this->m_vk = get_VirtualKey_US( scanCode) this->m_hkl = hkl; this->m_sc = scanCode; // _S2 ?? memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); @@ -211,7 +170,6 @@ public: (stShift.compare(stShiftCaps) != 0))); // stShift!= stShiftCaps } -// _S2 is character () bool KMX_IsCapsEqualToShift() { std::wstring stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß std::wstring stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? @@ -320,7 +278,6 @@ int i2 = this->KMX_IsSGCAPS() ? 2 : 0; int i3 = this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0; int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; - // _S2 TODO capslock is not calculated corectly for linux. therefore key->ShiftFlags will be wrong for numbers, special characters int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | (this->KMX_IsSGCAPS() ? 2 : 0) | @@ -329,6 +286,7 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; // _S2 DESIGN NEEDED on how to replace capslock capslock=1; // _S2 + // _S2 TODO capslock is not calculated corectly for linux. therefore key->ShiftFlags will be wrong for numbers, special characters for (int ss = 0; ss <= MaxShiftState; ss++) { if (ss == Menu || ss == ShftMenu) { @@ -349,9 +307,8 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; key->dpContext = new KMX_WCHAR[1]; *key->dpContext = 0; key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); - // _S2 this fun returns the shifted Char it goes wrog for numbers, special here!! //key->Key = KMX_get_KVUS_From_KVUnderlying_VEC(All_Vector,this->VK()); - key->Key = KMX_get_VKUnderlying_From_VKUS_GDK(keymap,this->VK()); + // key->Key = KMX_get_VKUnderlying_From_VKUS_GDK(keymap,this->VK()); key->Line = 0; if(bDeadkeyConversion) { // I4552 @@ -379,7 +336,7 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; // key->dpOutput stores character Underlying // _S2 confusing: since we sort rgkey by VKUS: is SC_Underlying the right SC or SC_Underlying_gdk?? it will be clear when we look at kmx/kmn-file - //KMX_DWORD SC_Underlying = KMX_get_KeyCodeUnderlying_From_KeycodeUS_VEC(All_Vector,this->SC(), ss); + //KMX_DWORD SC_Underlying = KMX_get_SCUnderlying_From_SCUS_VEC(All_Vector,this->SC(), ss); KMX_DWORD SC_Underlying_gdk = KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(keymap, All_Vector,this->SC(), (ShiftState) ss, caps); key->Key = KMX_get_VKUS_From_KeyCodeUnderlying_GDK( keymap, SC_Underlying_gdk); @@ -390,7 +347,8 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; p = key->dpOutput = new KMX_WCHAR[st.size() + 1]; for(size_t ich = 0; ich < st.size(); ich++) { q=p; - *p++ = st[ich];} + *p++ = st[ich]; + } *p = 0; key++; } @@ -550,8 +508,7 @@ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { return n; } -// _S2 cchBuff remove? -int KMX_ToUnicodeEx( guint ScanCode, const BYTE *lpKeyStccate, PWCHAR pwszBuff, int cchBuff, int shift_state, int caps,GdkKeymap *keymap) { +int KMX_ToUnicodeEx( guint ScanCode, const BYTE *lpKeyStccate, PWCHAR pwszBuff, int shift_state, int caps,GdkKeymap *keymap) { KMX_DWORD kvl= KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap, ScanCode, shift_state); @@ -564,8 +521,7 @@ int KMX_ToUnicodeEx( guint ScanCode, const BYTE *lpKeyStccate, PWCHAR pwszBuff, return 1; } -// _S2 cchBuff remove? -int KMX_ToUnicodeEx(guint ScanCode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, int cchBuff, int shift_state, int caps,GdkKeymap *keymap) { +int KMX_ToUnicodeEx(guint ScanCode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, int shift_state, int caps,GdkKeymap *keymap) { KMX_DWORD kvl= KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap, ScanCode, shift_state); if((kvl >= deadkey_min) && (kvl <= deadkey_max)) @@ -579,10 +535,6 @@ int KMX_ToUnicodeEx(guint ScanCode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 KMX_Loader loader; const size_t BUF_sz= 256; -//Inspect_kp(kp); - // _S2 do I need that for Linux?? - KMX_WCHAR inputHKL[12]; - u16sprintf(inputHKL,BUF_sz ,L"%08.8x", (unsigned int) u16tol(kbid, NULL, 16)); // _S2 wsprintf(inputHKL, L"%08.8x", (unsigned int) wcstol(kbid, NULL, 16)); KMX_HKL hkl = NULL; //_S2 added: but can I do this?? hkl is not needed in Linux?? @@ -592,18 +544,16 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd rgKey.resize(256); - // _S2 scroll through OTHER // Scroll through the Scan Code (SC) values and get the valid Virtual Key (VK) // values in it. Then, store the SC in each valid VK so it can act as both a // flag that the VK is valid, and it can store the SC value. - // _S2 this does not find exactly the same keys as the windows version does(windows finds more) for(UINT sc = 0x01; sc <= 0x7f; sc++) { - // fills m_vk with the VK of the US keyboard which is not right!! - // ( mcompile win uses MapVirtualKeyEx() to fill m_vk with the VK of the Other keyboard) + // fills m_vk with the VK of the US keyboard + // ( mcompile win uses MapVirtualKeyEx() to fill m_vk with the VK of the Underlying keyboard) // Linux cant get a VK for the US Keyboard using USVirtualKeyToScanCode/ScanCodeToUSVirtualKey - // Linux cannot get a VK for Other Keyboard - // it could return SC if that helps + // Linux cannot get a VK for the underling Keyboard + // this "connection" is possible only while using All_Vector KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector, keymap); if((key->VK() != 0) ) { @@ -671,7 +621,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd // _S2 is THIS correct ??? Do we need lpKeyState or is it just used in ToUnicodeEx?? loader.KMX_ClearKeyboardBuffer(); loader.KMX_FillKeyState(lpKeyState, ss, (caps == 0)); - int rc = KMX_ToUnicodeEx(SC_US, lpKeyState, sbBuffer, sizeof(sbBuffer)/sizeof(WCHAR), ss, caps, *keymap) ; + int rc = KMX_ToUnicodeEx(SC_US, lpKeyState, sbBuffer, ss, caps, *keymap) ; if(rc > 0) { if(*sbBuffer == 0) { @@ -804,19 +754,15 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd gp->cxKeyArray = nKeys; gp->dpKeyArray = new KMX_KEY[gp->cxKeyArray]; nKeys = 0; + + // // Fill in the new rules // - -int STOP=0; // _S2 LayoutRow: VKToUnderlying should work OK; GetSSValue not checked yet, but this is definitely different for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { - //wprintf(L"********************************* I use Key Nr %i\n",iKey); - // for each item, - //wprintf(L" \n iKey = %i, nKeys %i + Delta:\t%i", iKey,nKeys, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState())); if(rgKey[iKey]->KMX_LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); - //Inspect_key(&gp->dpKeyArray[nKeys]); } } } @@ -942,7 +888,7 @@ int STOP=0; // _S2 LayoutRow: VKToUnderlying should work OK; GetSSValue not che return true; } -// _S2 where to put this?? +// _S2 where is nthe best place to put this?? const int CODE__SIZE[] = { -1, // undefined 0x00 1, // CODE_ANY 0x01 @@ -971,7 +917,7 @@ const int CODE__SIZE[] = { 2 // CODE_SETSYSTEMSTORE 0x18 }; -// _S2 where to put this?? +// _S2 where is nthe best place to put this?? PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p) { if (*p == 0) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index c2ec204fa4..46715eff23 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -227,10 +227,10 @@ void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_ void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key) { if(key->ShiftFlags == 0) { //KMX_LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); - //wprintf(L" _S2 Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); + wprintf(L" _S2 Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); } else if(key->ShiftFlags & VIRTUALCHARKEY) { //KMX_LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); - //wprintf(L"_S2 Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); + wprintf(L"_S2 Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); } } @@ -485,9 +485,8 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon KMX_WCHAR ch = KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_VEC(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey);*/ UINT scUnderlying = KMX_get_SCUnderlying_From_VKUS(KMX_VKMap[i]); - KMX_WCHAR ch = KMX_get_CharUnderlying_From_SCUnderlying_GDK(keymap, VKShiftState[j], scUnderlying, &DeadKey); // _S2 ch is of Other KB + KMX_WCHAR ch = KMX_get_CharUnderlying_From_SCUnderlying_GDK(keymap, VKShiftState[j], scUnderlying, &DeadKey); - //wprintf(L" DoConvert-read i: %i \t(KMX_VKMap): %i (%c) \t---> vkUnderlying: %i (%c) \tshiftstate[%i]: ( %i ) \t---- > ch: %i (%c) \t%ls \t%ls\n" , i,(int) KMX_VKMap[i],(int)KMX_VKMap[i], vkUnderlying,vkUnderlying, j, VKShiftState[j] , ch ,ch , ((int) vkUnderlying != (int) KMX_VKMap[i] ) ? L" *** ": L"", ERROR); //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); if(bDeadkeyConversion) { // I4552 @@ -496,7 +495,6 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon } } - //wprintf(L" switch with ch: %i (%c)......\n" , ch,ch); switch(ch) { case 0x0000: break; case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap); break; @@ -557,47 +555,13 @@ KMX_WCHAR KMX_get_KVUS_From_KVUnderlying_VEC(v_dw_3D All_Vector, KMX_DWORD VK_OT return VK_OTHER; } -// _S2 sure KMX_WCHART ??? not KMX_WCHAR ?? not usable!! -KMX_WCHART KMX_get_VKUnderlying_From_VKUS_GDK(GdkKeymap* keymap,KMX_DWORD VK_US) { - - /*KMX_WORD VK_DE = ( KMX_WORD ) map_Ikey_DE(VK_US); - if(VK_DE!= VK_US) - return VK_DE; - else - return VK_US;*/ -}// _S2 sure KMX_WCHART ??? not KMX_WCHAR ?? KMX_WCHAR KMX_SCKUnderlyingLayoutToVKUS_GDK2(GdkKeymap* keymap,KMX_DWORD SC_Other) { return SC_Other; } -/* takes KV of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] -KMX_DWORD KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_VEC(v_dw_3D &All_Vector,KMX_DWORD KVUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey){ - - KMX_UINT VKShiftState_lin; - - // 0000 0000 - if (VKShiftState == 0 ) VKShiftState_lin = 0; - // 0001 0000 - if (VKShiftState == 16) VKShiftState_lin = 1; - // 0000 1001 - if (VKShiftState == 9 ) VKShiftState_lin = 2; - // 0001 1001 - if (VKShiftState == 25) VKShiftState_lin = 3; - - // loop and find KVUnderlying in Other; then return char with correct shiftstate - for( int i=0; i< (int)All_Vector[1].size();i++) { - KMX_DWORD CharOther = All_Vector[1][i][2]; - if( KVUnderlying == CharOther ) { - return All_Vector[1][i][VKShiftState_lin+1]; // [VKShiftState_lin+1] because we have the name of the key in All_Vector[1][i][0], so we need to get the one after this - } - } - return KVUnderlying; -} -*/ - -KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_VEC(v_dw_3D &All_Vector, KMX_DWORD KC_US, int Shiftstate) { +KMX_DWORD KMX_get_SCUnderlying_From_SCUS_VEC(v_dw_3D &All_Vector, KMX_DWORD KC_US, int Shiftstate) { KMX_DWORD Character = 0; // find character with that scancode diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 6fc43a5b65..db31bd9c07 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -17,16 +17,12 @@ */ - - #ifndef MCOMPILE_H #define MCOMPILE_H #include #include "keymap.h" #include "helpers.h" - #include "deadkey.h" - #include "mc_kmxfile.h" void KMX_LogError(const KMX_WCHART* m1, int m2 = 0); @@ -44,17 +40,12 @@ int run(int argc, std::vector str_argv, char* argv[]); PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); -// _S2 sure KMX_WCHART ??? not KMX_WCHAR ?? -KMX_WCHART KMX_get_VKUnderlying_From_VKUS_GDK(GdkKeymap* keymap,KMX_DWORD inOther); -//KMX_WCHAR KMX_get_KVUS_From_KVUnderlying_GDK2(GdkKeymap* keymap,KMX_DWORD inOther); +UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); +KMX_DWORD KMX_get_SCUnderlying_From_SCUS_VEC(v_dw_3D &All_Vector, KMX_DWORD VK_US, int Shiftstate); KMX_WCHAR KMX_get_KVUS_From_KVUnderlying_VEC(v_dw_3D All_Vector,KMX_DWORD SC_US); -UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); KMX_DWORD KMX_get_KVUnderlying_From_KVUS_VEC(v_dw_3D &All_Vector,KMX_DWORD inUS); -//KMX_DWORD KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_VEC(v_dw_3D &All_Vector,KMX_DWORD vkUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey); KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey); -KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_VEC(v_dw_3D &All_Vector, KMX_DWORD VK_US, int Shiftstate); - int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap); From 0f124814d4f528b8f09b5eede5bf0dca3d6f9840 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 13 Dec 2023 17:47:15 +0100 Subject: [PATCH 162/327] feat(linux): mcompile minor changes --- linux/mcompile/keymap/keymap.cpp | 2 +- linux/mcompile/keymap/mc_import_rules.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index f49bc0116c..e1aacb1167 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -426,7 +426,7 @@ std::wstring convert_DeadkeyValues_ToChar(int in) { KMX_DWORD lname; - if (in < deadkeyThreshold) { // no deadkey; no Unicode + if (in <= deadkey_min) { // no deadkey; no Unicode if (!IsKeymanUsedKeyVal(std::wstring(1, in))) return L"\0"; return std::wstring(1, in); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 59b2f0f4cc..3e056cd725 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -682,7 +682,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd } //_S2 this gan co later - std::vector< int > TestValues = {48,49,50,51,52,53,54,55,56,57,65,66,67,88,89,90, 186,187,188,189,191,191,192,219,220,221,222,226}; + std::vector< int > TestValues = {40,44,48,49,50,51,52,53,54,55,56,57,65,66,67,88,89,90, 186,187,188,189,191,191,192,219,220,221,222,226}; wprintf(L"-----------------\nNow some tests:\n"); wprintf(L" Base Caps Shift Shfit+Caps MenuCtrl MenuCtrl+Caps \n"); @@ -763,6 +763,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { if(rgKey[iKey]->KMX_LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); + wprintf(L" iKey = %i, Delta: %i -> Sum %i\n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()), nKeys); } } } @@ -957,7 +958,7 @@ bool IsKeymanUsedKeyVal(std::wstring Keyval) { int KV = (int) (*Keyval.c_str()); // 32 127 196 256 - if ((KV >= 0x20 && KV <= 0x7F) || (KV >= 0xC4 && KV < 198) || + if ((KV >= 0x20 && KV <= 0x7F) || (KV >= 0x20 && KV <= 0x7F) || (KV >= 0xC4 && KV < 198) || (KV >= 199 && KV < 208) || (KV >= 209 && KV < 216) || (KV >= 217 && KV < 229) || (KV >= 231 && KV < 240) || (KV >= 241 && KV < 248) || (KV >= 249 && KV < 0xFF) || (KV == 128) || (KV == 178) || (KV == 167) || (KV == 179) || (KV == 176)|| (KV == 181) ) From 7cc51bfe7eab523c7962a7790652e72ebcc0f6c6 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 13 Dec 2023 20:04:35 +0100 Subject: [PATCH 163/327] feat(linux): mcompile minor changes2 --- linux/mcompile/keymap/README.md | 10 ++-------- linux/mcompile/keymap/deadkey.cpp | 1 - linux/mcompile/keymap/keymap.cpp | 6 +++--- linux/mcompile/keymap/kmx_file.h | 1 - linux/mcompile/keymap/mc_import_rules.cpp | 2 -- linux/mcompile/keymap/mcompile.cpp | 4 ++-- 6 files changed, 7 insertions(+), 17 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index ac790701d3..0988640f52 100755 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -11,9 +11,6 @@ TODO deadkeys don't work yet TODO path for xkb/symbols as compile time option in meson TODO check how many/which shift states we use ( at the moment we read all shiftstate-columns of US but then use only 2 colums (non-shift + shift) then use as many colums for Other ) TODO define folder to store File_US.txt" in and find better name -TODO get rid of GTK functions that are deprecated and use X11 instead -TODO retrieve name of Other keyboard and use appropriate name instead of "Other" -TODO mcompile.cpp: open mcompile -u - option - do we need that? TODO check if I can use files from some other keyman path instead of a copy in keymap ( e.g. filesystem.h exists elsewhere) TODO remove kbdid and kbd for Linux TODO shiftstate-count @@ -21,25 +18,22 @@ TODO keymap SplitToV.cpp exchange 4 with genaerated shiftcount TODO shift-statevector TODO Do I need HKL for Linux / can I just use a void* or remove HKL ?? TODO typeddef of KMX_HKL - can I delete all m_hkl from classes? -TODO define what to return when SC/VK is not found in get_VirtualKey_Other_From_SC,... TODO check if passed All_Vectpor as ptr/ref not as value e.g. in KMX_CharFromVK, KMX_VKUSToVKUnderlyingLayout, KMX_ImportRules ToDo in get_VirtualKey_Other_From_SC: what if we use column 3(altgr) and 4 (shift+altgr) ?? TODO where to store VK_CANCEL.... in km_types.h or elsewhere? ToDo check up to 8 shiftstates ( find symbols-file with 8) TODO get_position_From_VirtualKey_US: take care of the other shiftstates -ToDo make this better!!! get_VirtualKey_Other_From_SC ToDo use _free(keyvals); g_free(maps); TODO next: - - change mapping (win-lin) for writing All_Vector - - compare entries in rgKey ( are the same rgKey[]filled? it is OK from rgKey[65]-rgkey[90] but for other values??? ) - mc_import-rules (from ~ l. 790) see if everything gives the same result on win-Lin - check if I use char16_t everywhere instead of wchar_t or char - replace GDK - see in which files I can put some functions (e.g. incxstr) that were duplicated or even #include their original location - - remove testing functions - remove USE_GDK - what is wrong with kp->dpBitmapOffset/BitmapSize ? + - Check/find use of wchar_t/wstring and replace with char16_t/u16string + - check call by reference/value TODO ... diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 062d8eb2fb..ce4cea8297 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -10,7 +10,6 @@ v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, return line; } -// _S2 used? KMX_DWORD find_dk_Character(v_dw_2D * p_dk_ComposeTable, KMX_DWORD first, KMX_DWORD second ) { v_dw_2D dk_ComposeTable = * p_dk_ComposeTable; for ( int i =0; i< (dk_ComposeTable).size()-1; i++) { diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index e1aacb1167..d450de354f 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -158,9 +158,9 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, int replace_KeyName_with_Keycode(std::string in) { int out = returnIfCharInvalid; - // _S2 these are the Scancode-Values we use in Keyman ( = the windows scancodes+8 ) + // these are the Scancode-Values we use in Keyman ( = the windows scancodes+8 ) // NAME IN SYMBOLS-FILE KEYCODE (LIN STYLE) (WIN STYLE) VK_US VK_DE - /*on US keyb;*/ + /*on US keyb;*/ if ( in == "key") out = 49; /* VK_ */ // TOASK correct ??? else if ( in == "key") out = 10; /* 0X02 VK_1 */ else if ( in == "key") out = 11; /* 0X03 VK_2 */ @@ -334,7 +334,7 @@ int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { return 0; } -// _S2 can I use gdk_keymap_translate_keyboard_state instead? return s shifted + unshifted only- no altgr,... +// _S2 use gdk_keymap_translate_keyboard_state instead return s shifted + unshifted only- no altgr,... KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; guint *keyvals; diff --git a/linux/mcompile/keymap/kmx_file.h b/linux/mcompile/keymap/kmx_file.h index 4ab43c38a8..1cf49c61b5 100755 --- a/linux/mcompile/keymap/kmx_file.h +++ b/linux/mcompile/keymap/kmx_file.h @@ -9,7 +9,6 @@ #include -//_S2 what is this and do we need it??? #define UNREFERENCED_PARAMETER(P) (P) #define TRUNCATE ((size_t)-1) #ifdef KMN_KBP diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 3e056cd725..786eba91a2 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -783,7 +783,6 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd *p++ = (KMX_WCHAR)(kp->cxGroupArray); *p = 0; - // _S2 TODO not sure if this works OK -> we need to use more shiftstates than base+Shift // I4550 - Each place we have a nomatch > use(baselayout) (this last group), we need to add all // the AltGr and ShiftAltGr combinations as rules to allow them to be matched as well. Yes, this // loop is not very efficient but it's not worthy of optimisation. @@ -812,7 +811,6 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd } } - // _S2 TODO not sure if this works OK -> we need to use deadkeys... // If we have deadkeys, then add a new group to translate the deadkeys per the deadkey tables // We only do this if not in deadkey conversion mode // diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 46715eff23..eee0b46616 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -591,8 +591,8 @@ KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_U KMX_DWORD KeyvalOther = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,SC_OTHER, VKShiftState_lin); // _S2 how to detect deadkeys ? KeyvalOther >deadkeyThreshold KeyvalOther > 255? KeyvalOther > 65000 ? or what else? - //if (KeyvalOther > deadkeyThreshold) { - if (KeyvalOther > 255) { + if (KeyvalOther > deadkeyThreshold) { + //if (KeyvalOther > 255) { std::string ws((const char*) gdk_keyval_name (KeyvalOther)); *DeadKey = convertNamesToIntegerValue( wstring_from_string(ws)); return 0xFFFF; From a17ed9f16f8653f652630cc27013ba682ba87a9a Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 9 Jan 2024 16:22:38 +0100 Subject: [PATCH 164/327] feat(linux): mcompile check deadkeys.cpp/h --- linux/mcompile/keymap/deadkey.cpp | 10 ++++++---- linux/mcompile/keymap/deadkey.h | 11 ++++++++--- linux/mcompile/keymap/keymap.cpp | 4 ++-- linux/mcompile/keymap/mc_import_rules.cpp | 6 ++++++ linux/mcompile/keymap/mcompile.cpp | 23 +++++++++++------------ 5 files changed, 33 insertions(+), 21 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index ce4cea8297..a32d67c5ae 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -10,16 +10,17 @@ v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, return line; } -KMX_DWORD find_dk_Character(v_dw_2D * p_dk_ComposeTable, KMX_DWORD first, KMX_DWORD second ) { +/*KMX_DWORD find_dk_Character(v_dw_2D * p_dk_ComposeTable, KMX_DWORD first, KMX_DWORD second ) { v_dw_2D dk_ComposeTable = * p_dk_ComposeTable; for ( int i =0; i< (dk_ComposeTable).size()-1; i++) { if (( (KMX_DWORD) dk_ComposeTable[i][0] == first) && ( (KMX_DWORD) dk_ComposeTable[i][1] == second) ) return (KMX_DWORD) dk_ComposeTable[i][3]; } return 0; // _S2 what to return if not found? -} +}*/ -void find_all_dk_combinations(v_dw_2D * p_dk_ComposeTable, v_dw_2D &dk_CombinationTable, KMX_DWORD dk) { +void find_dk_combinations_for_single_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &dk_SingleTable, KMX_DWORD dk) { + // _S2 use return value to check if >0 lines in table v_dw_2D dk_ComposeTable = * p_dk_ComposeTable; v_dw_1D line; for ( int i =0; i< (dk_ComposeTable).size()-1; i++) { @@ -27,12 +28,13 @@ void find_all_dk_combinations(v_dw_2D * p_dk_ComposeTable, v_dw_2D &dk_Combinat line.push_back(dk_ComposeTable[i][0]); line.push_back(dk_ComposeTable[i][1]); line.push_back(dk_ComposeTable[i][2]); - dk_CombinationTable.push_back(line); + dk_SingleTable.push_back(line); line.clear(); } } } +// _S2 is this correct?? KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap) { guint Keyval = (guint) KVal; diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index b718164139..ddfb3e1c98 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -4,13 +4,18 @@ #define DEADKEY_H #include - +// creates a vector for a dk combination ( ` + a -> à ) v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult); + +// creates a 2D-vector of all dk combinations ( ` + a -> à ; ^ + a -> â ; `+ e -> è; ...) KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable); -KMX_DWORD find_dkCharacter(v_dw_2D * dk_ComposeTable, KMX_DWORD first, KMX_DWORD second ); +//KMX_DWORD find_dkCharacter(v_dw_2D * dk_ComposeTable, KMX_DWORD first, KMX_DWORD second ); -void find_all_dk_combinations(v_dw_2D * dk_ComposeTable, v_dw_2D & dk_CombinationTable, KMX_DWORD dk); +// finds all combination for a specific deadkey(dk) +void find_dk_combinations_for_single_dk(v_dw_2D * dk_ComposeTable, v_dw_2D & dk_SingleTable, KMX_DWORD dk); + +// gets the shifted character of a key KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap) ; # endif /*DEADKEY_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index d450de354f..ff28aeb412 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -6,8 +6,8 @@ int map_VKShiftState_to_Lin(int VKShiftState) { if (VKShiftState == 0 ) return 0; /* 0000 0000 */ if (VKShiftState == 16) return 1; /* 0001 0000 */ - //if (VKShiftState == 9 ) return 2; /* 0000 1001 */ - //if (VKShiftState == 25) return 3; /* 0001 1001 */ + if (VKShiftState == 9 ) return 2; /* 0000 1001 */ + if (VKShiftState == 25) return 3; /* 0001 1001 */ return VKShiftState; } diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 786eba91a2..df6a4dd33d 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -614,6 +614,12 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd continue; } + //_S2 to compare win-lin kmn-files skip ss6+7; MUST BE restored/removed later!!!! + if(ss == MenuCtrl|| ss == ShftMenuCtrl) { + // Alt and Shift+Alt don't work, so skip them + continue; + } + KMX_DWORD SC_US = KMX_get_KeyCodeUnderlying_From_VKUS(iKey); // _S2 deadkey not finished; Ctrl, Shft +40 not tested diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index eee0b46616..088251f033 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -165,8 +165,8 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ // _S2 TODO which version of VKShiftStates do we use ? // comment from win-version // Map of all shift states that we will work with -//const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; -const UINT VKShiftState[] = {0, K_SHIFTFLAG, 0xFFFF}; +const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; +//const UINT VKShiftState[] = {0, K_SHIFTFLAG, 0xFFFF}; // my comment for Lin version // Ubuntu: Each of the 4 columns specifies a different modifier: unmodified, shift, right alt (altgr), shift+right alt(altgr) @@ -555,7 +555,6 @@ KMX_WCHAR KMX_get_KVUS_From_KVUnderlying_VEC(v_dw_3D All_Vector, KMX_DWORD VK_OT return VK_OTHER; } - KMX_WCHAR KMX_SCKUnderlyingLayoutToVKUS_GDK2(GdkKeymap* keymap,KMX_DWORD SC_Other) { return SC_Other; @@ -640,18 +639,18 @@ int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap) { - KMX_WORD *p = OutputPairs, shift; - KMX_DWORD shift2; + KMX_WORD *p = OutputPairs; + KMX_DWORD shift; - v_dw_2D dk_CombinationTable; - find_all_dk_combinations(&dk_Table, dk_CombinationTable, DeadKey); - - for ( int i=0; i< dk_CombinationTable.size()-1;i++) { - KMX_WORD vk = KMX_changeKeynameToCapital(dk_CombinationTable[i][1], shift2, keymap); + v_dw_2D dk_SingleTable; + find_dk_combinations_for_single_dk(&dk_Table, dk_SingleTable, DeadKey); +// _S2 CAPS <-> NCAPS problem from here? + for ( int i=0; i< dk_SingleTable.size()-1;i++) { + KMX_WORD vk = KMX_changeKeynameToCapital(dk_SingleTable[i][1], shift, keymap); if(vk != 0) { *p++ = vk; - *p++ = shift2; - *p++ = dk_CombinationTable[i][2]; + *p++ = shift; + *p++ = dk_SingleTable[i][2]; } // _S2 TODO //else { From 1ac467bff5ae2dc896464e11e7472c38903da621 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 10 Jan 2024 13:32:15 +0100 Subject: [PATCH 165/327] feat(linux): mcompile check files --- linux/mcompile/keymap/helpers.cpp | 72 +++++ linux/mcompile/keymap/keymap.cpp | 355 ++++++++++++---------- linux/mcompile/keymap/keymap.h | 12 +- linux/mcompile/keymap/mc_import_rules.cpp | 47 ++- linux/mcompile/keymap/mcompile.cpp | 20 -- 5 files changed, 298 insertions(+), 208 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index b872c24782..6676f826d3 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -604,6 +604,78 @@ int replace_PosKey_with_Keycode(std::string in) { return out; } + + +int replace_KeyName_with_Keycode2(std::string in) { + int out = returnIfCharInvalid; + + // these are the Scancode-Values we use in Keyman ( = the windows scancodes+8 ) + // NAME IN SYMBOLS-FILE KEYCODE (LIN STYLE) (WIN STYLE) VK_US VK_DE + /*on US keyb;*/ + if ( in == "key") out = 49; /* VK_ */ // TOASK correct ??? + else if ( in == "key") out = 10; /* 0X02 VK_1 */ + else if ( in == "key") out = 11; /* 0X03 VK_2 */ + else if ( in == "key") out = 12; /* 0X04 VK_3 */ + else if ( in == "key") out = 13; /* 0X05 VK_4 */ + else if ( in == "key") out = 14; /* 0X06 VK_5 */ + else if ( in == "key") out = 15; /* 0X07 VK_6 */ + else if ( in == "key") out = 16; /* 0X08 VK_7 */ + else if ( in == "key") out = 17; /* 0X09 VK_8 */ + else if ( in == "key") out = 18; /* 0X0A VK_9 */ + else if ( in == "key") out = 19; /* 0X0B VK_0 */ + else if ( in == "key") out = 20; /*out = 61;*/ /* 0X0C VK_MINUS de ẞ*/ + else if ( in == "key") out = 21; /* 0X0D VK_EQUALS DE ' */ + + else if ( in == "key") out = 24; /* 0X10 VK_Q */ + else if ( in == "key") out = 25; /* 0X11 VK_W */ + else if ( in == "key") out = 26; /* 0X12 VK_E */ + else if ( in == "key") out = 27; /* 0X13 VK_R */ + else if ( in == "key") out = 28; /* 0X14 VK_T */ + else if ( in == "key") out = 29; /*out = 52;*/ /* 0X15 VK_Y */ + else if ( in == "key") out = 30; /* 0X16 VK_U */ + else if ( in == "key") out = 31; /* 0X17 VK_I */ + else if ( in == "key") out = 32; /* 0X18 VK_O */ + else if ( in == "key") out = 33; /* 0X19 VK_P */ + else if ( in == "key") out = 34; /*out = 17;*/ /* 0X1A VK_LEFTBRACE DE Ü */ + else if ( in == "key") out = 35; /*out = 18;*/ /* 0X1B VK_RIGHTBRACE DE + */ + + else if ( in == "key") out = 38; /* 0X1E VK_A */ + else if ( in == "key") out = 39; /* 0X1F VK_S */ + else if ( in == "key") out = 40; /* 0X20 VK_D */ + else if ( in == "key") out = 41; /* 0X21 VK_F */ + else if ( in == "key") out = 42; /* 0X22 VK_G */ + else if ( in == "key") out = 43; /* 0X23 VK_H */ + else if ( in == "key") out = 44; /* 0X24 VK_J */ + else if ( in == "key") out = 45; /* 0X25 VK_K */ + else if ( in == "key") out = 46; /* 0X26 VK_L */ + else if ( in == "key") out = 47; /*out = 59;*/ /* 0X27 VK_SEMICOLON DE Ö*/ + else if ( in == "key") out = 48; /*out = 51;*/ /* 0X28 VK_APOSTROPHE DE Ä */ + + else if ( in == "key") out = 52; /*out = 29;*/ /* 0X2C VK_Z */ + else if ( in == "key") out = 53; /* 0X2D VK_X */ + else if ( in == "key") out = 54; /* 0X2E VK_C */ + else if ( in == "key") out = 55; /* 0X2F VK_V */ + else if ( in == "key") out = 56; /* 0X30 VK_B */ + else if ( in == "key") out = 57; /* 0X31 VK_N */ + else if ( in == "key") out = 58; /* 0X32 VK_M */ + else if ( in == "key") out = 59; /* 0X33 VK_ COMMA */ + else if ( in == "key") out = 60; /* 0X34 VK_DOT */ + else if ( in == "key") out = 61; /*out = 16;*/ /* 0X35 VK_SLASH DE - */ + else if ( in == "key") out = 51; /* 0X29 VK_BKSLASH */ + else if ( in == "key") out = 63; /* 0X37 VK_RIGHTSHIFT */ + else if ( in == "key") out = 65; /* 0X20 ?? 39? VK_SPACE */ + + return out; +} + + +/* +KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying( KMX_DWORD keycode) { + if ( keycode >7) + return (KMX_DWORD) ScanCodeToUSVirtualKey[keycode-8]; + return 0; //_S2 what to return if not found +}*/ + // return RETURN NON SHIFTED CHAR [1] the VirtualKey of the US Keyboard for given Scancode KMX_DWORD get_VirtualKey_Other_Layer1_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ // find correct row of char in US diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index ff28aeb412..57f656359f 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -4,11 +4,11 @@ int map_VKShiftState_to_Lin(int VKShiftState) { - if (VKShiftState == 0 ) return 0; /* 0000 0000 */ - if (VKShiftState == 16) return 1; /* 0001 0000 */ - if (VKShiftState == 9 ) return 2; /* 0000 1001 */ - if (VKShiftState == 25) return 3; /* 0001 1001 */ - return VKShiftState; + if (VKShiftState == 0 ) return 0; /* 0000 0000 */ + else if (VKShiftState == 16) return 1; /* 0001 0000 */ + else if (VKShiftState == 9 ) return 2; /* 0000 1001 */ + else if (VKShiftState == 25) return 3; /* 0001 1001 */ + else return VKShiftState; } KMX_DWORD convertNamesToIntegerValue(std::wstring tok_wstr){ @@ -111,7 +111,7 @@ int write_US_ToVector( v_dw_3D &vec,std::string language, const char* text) { return 0; } -bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, std::string language) { +bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, std::string language) { // in the Configuration file we find the appopriate paragraph between "xkb_symbol " and the next xkb_symbol // and then copy all rows starting with "key <" to a 1D-Vector @@ -146,7 +146,6 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, } } complete_List.push_back(" key { [ space, space] };"); - //complete_List.push_back(" key { [ backslash, bar ] };"); if (complete_List.size() <1) { wprintf(L"ERROR: can't create row from US \n"); @@ -158,62 +157,59 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, int replace_KeyName_with_Keycode(std::string in) { int out = returnIfCharInvalid; - // these are the Scancode-Values we use in Keyman ( = the windows scancodes+8 ) - // NAME IN SYMBOLS-FILE KEYCODE (LIN STYLE) (WIN STYLE) VK_US VK_DE - /*on US keyb;*/ - if ( in == "key") out = 49; /* VK_ */ // TOASK correct ??? - else if ( in == "key") out = 10; /* 0X02 VK_1 */ - else if ( in == "key") out = 11; /* 0X03 VK_2 */ - else if ( in == "key") out = 12; /* 0X04 VK_3 */ - else if ( in == "key") out = 13; /* 0X05 VK_4 */ - else if ( in == "key") out = 14; /* 0X06 VK_5 */ - else if ( in == "key") out = 15; /* 0X07 VK_6 */ - else if ( in == "key") out = 16; /* 0X08 VK_7 */ - else if ( in == "key") out = 17; /* 0X09 VK_8 */ - else if ( in == "key") out = 18; /* 0X0A VK_9 */ - else if ( in == "key") out = 19; /* 0X0B VK_0 */ - else if ( in == "key") out = 20; /*out = 61;*/ /* 0X0C VK_MINUS de ẞ*/ - else if ( in == "key") out = 21; /* 0X0D VK_EQUALS DE ' */ + // these are the Scancode-Values we use in Keyman (= windows scancodes+8 ) + if ( in == "key") out = 49; /* VK_ */ + else if ( in == "key") out = 10; /* VK_1 */ + else if ( in == "key") out = 11; /* VK_2 */ + else if ( in == "key") out = 12; /* VK_3 */ + else if ( in == "key") out = 13; /* VK_4 */ + else if ( in == "key") out = 14; /* VK_5 */ + else if ( in == "key") out = 15; /* VK_6 */ + else if ( in == "key") out = 16; /* VK_7 */ + else if ( in == "key") out = 17; /* VK_8 */ + else if ( in == "key") out = 18; /* VK_9 */ + else if ( in == "key") out = 19; /* VK_0 */ + else if ( in == "key") out = 20; /* VK_MINUS de ẞ */ + else if ( in == "key") out = 21; /* VK_EQUALS DE ' */ - else if ( in == "key") out = 24; /* 0X10 VK_Q */ - else if ( in == "key") out = 25; /* 0X11 VK_W */ - else if ( in == "key") out = 26; /* 0X12 VK_E */ - else if ( in == "key") out = 27; /* 0X13 VK_R */ - else if ( in == "key") out = 28; /* 0X14 VK_T */ - else if ( in == "key") out = 29; /*out = 52;*/ /* 0X15 VK_Y */ - else if ( in == "key") out = 30; /* 0X16 VK_U */ - else if ( in == "key") out = 31; /* 0X17 VK_I */ - else if ( in == "key") out = 32; /* 0X18 VK_O */ - else if ( in == "key") out = 33; /* 0X19 VK_P */ - else if ( in == "key") out = 34; /*out = 17;*/ /* 0X1A VK_LEFTBRACE DE Ü */ - else if ( in == "key") out = 35; /*out = 18;*/ /* 0X1B VK_RIGHTBRACE DE + */ + else if ( in == "key") out = 24; /* VK_Q */ + else if ( in == "key") out = 25; /* VK_W */ + else if ( in == "key") out = 26; /* VK_E */ + else if ( in == "key") out = 27; /* VK_R */ + else if ( in == "key") out = 28; /* VK_T */ + else if ( in == "key") out = 29; /* VK_Y */ + else if ( in == "key") out = 30; /* VK_U */ + else if ( in == "key") out = 31; /* VK_I */ + else if ( in == "key") out = 32; /* VK_O */ + else if ( in == "key") out = 33; /* VK_P */ + else if ( in == "key") out = 34; /* VK_LEFTBRACE DE Ü */ + else if ( in == "key") out = 35; /* VK_RIGHTBRACE DE + */ - else if ( in == "key") out = 38; /* 0X1E VK_A */ - else if ( in == "key") out = 39; /* 0X1F VK_S */ - else if ( in == "key") out = 40; /* 0X20 VK_D */ - else if ( in == "key") out = 41; /* 0X21 VK_F */ - else if ( in == "key") out = 42; /* 0X22 VK_G */ - else if ( in == "key") out = 43; /* 0X23 VK_H */ - else if ( in == "key") out = 44; /* 0X24 VK_J */ - else if ( in == "key") out = 45; /* 0X25 VK_K */ - else if ( in == "key") out = 46; /* 0X26 VK_L */ - else if ( in == "key") out = 47; /*out = 59;*/ /* 0X27 VK_SEMICOLON DE Ö*/ - else if ( in == "key") out = 48; /*out = 51;*/ /* 0X28 VK_APOSTROPHE DE Ä */ - //else if ( in == "key") out = 51; /*out = 20;*/ /* 0X29 VK_GRAVE DE # */ + else if ( in == "key") out = 38; /* VK_A */ + else if ( in == "key") out = 39; /* VK_S */ + else if ( in == "key") out = 40; /* VK_D */ + else if ( in == "key") out = 41; /* VK_F */ + else if ( in == "key") out = 42; /* VK_G */ + else if ( in == "key") out = 43; /* VK_H */ + else if ( in == "key") out = 44; /* VK_J */ + else if ( in == "key") out = 45; /* VK_K */ + else if ( in == "key") out = 46; /* VK_L */ + else if ( in == "key") out = 47; /* VK_SEMICOLON DE Ö */ + else if ( in == "key") out = 48; /* VK_APOSTROPHE DE Ä */ - else if ( in == "key") out = 52; /*out = 29;*/ /* 0X2C VK_Z */ - else if ( in == "key") out = 53; /* 0X2D VK_X */ - else if ( in == "key") out = 54; /* 0X2E VK_C */ - else if ( in == "key") out = 55; /* 0X2F VK_V */ - else if ( in == "key") out = 56; /* 0X30 VK_B */ - else if ( in == "key") out = 57; /* 0X31 VK_N */ - else if ( in == "key") out = 58; /* 0X32 VK_M */ - else if ( in == "key") out = 59; /* 0X33 VK_ COMMA */ - else if ( in == "key") out = 60; /* 0X34 VK_DOT */ - else if ( in == "key") out = 61; /*out = 16;*/ /* 0X35 VK_SLASH DE - */ - else if ( in == "key") out = 51; /* 0X29 VK_BKSLASH */ - else if ( in == "key") out = 63; /* 0X37 VK_RIGHTSHIFT */ - else if ( in == "key") out = 65; /* 0X20 ?? 39? VK_SPACE */ + else if ( in == "key") out = 52; /* VK_Z */ + else if ( in == "key") out = 53; /* VK_X */ + else if ( in == "key") out = 54; /* VK_C */ + else if ( in == "key") out = 55; /* VK_V */ + else if ( in == "key") out = 56; /* VK_B */ + else if ( in == "key") out = 57; /* VK_N */ + else if ( in == "key") out = 58; /* VK_M */ + else if ( in == "key") out = 59; /* VK_ COMMA */ + else if ( in == "key") out = 60; /* VK_DOT */ + else if ( in == "key") out = 61; /* VK_SLASH DE - */ + else if ( in == "key") out = 51; /* VK_BKSLASH */ + else if ( in == "key") out = 63; /* VK_RIGHTSHIFT */ + else if ( in == "key") out = 65; /* VK_SPACE */ return out; } @@ -232,7 +228,6 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { v_dw_1D tokens_dw; v_dw_2D shift_states; KMX_DWORD tokens_int; - std::wstring tok_wstr; // loop through the whole vector for (int k = 0; k < (int)completeList.size(); k++) { @@ -286,13 +281,13 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { return 0; } -v_dw_2D create_empty_2D_Vector( int dim_rows,int dim_shifts) { +v_dw_2D create_empty_2D_Vector( int dim_rows,int dim_ss) { v_dw_1D shifts; v_dw_2D Vector_2D; for ( int i=0; i< dim_rows;i++) { - for ( int j=0; j< dim_shifts;j++) { + for ( int j=0; j< dim_ss;j++) { shifts.push_back(returnIfCharInvalid); } Vector_2D.push_back(shifts); @@ -334,94 +329,43 @@ int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { return 0; } -// _S2 use gdk_keymap_translate_keyboard_state instead return s shifted + unshifted only- no altgr,... -KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos) { - GdkKeymapKey *maps; - guint *keyvals; - gint count; - KMX_DWORD out; +bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]){ +// get keymap of keyboard layout in use - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return 0; - //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html - -// _S2 this will return 223 instaed of 7838 for UNICODE cher on DE keycode 20 ß ẞ ? ? - - if (!(shift_state_pos <= count)) - return 0; - - if (!(keycode <= 94)) - return 0; - - out =(KMX_DWORD) keyvals[shift_state_pos]; - - if ( (out >= deadkey_min) && (out <= deadkey_max) ) { - wprintf(L"out of range: found deadkey value out( %i) for keycode = %i /shift_state_pos %i (49= TLDE 21= VK_EQUALS on US keyboard) \n", out,keycode,shift_state_pos); + gdk_init(&argc, &argv); + GdkDisplay *display = gdk_display_get_default(); + if (!display) { + wprintf(L"ERROR: can't get display\n"); + return 1; } - // _S2 g_free used everywhere? - g_free(keyvals); - g_free(maps); - return out; + *keymap = gdk_keymap_get_for_display(display); + if (!keymap) { + wprintf(L"ERROR: Can't get keymap\n"); + gdk_display_close(display); + return 2; + } + + return 0; } -KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { +//------------------------------ +// _S2 ToDo deadkeys. Do we need this ? +bool IsKeymanUsedKeyVal(std::wstring Keyval) { - GdkModifierType consumed; - GdkKeymapKey *maps; - guint *keyvals; - guint lowerCase; - guint upperCase; - gint count; + int KV = (int) (*Keyval.c_str()); - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return 0; - - //Shift - //GdkModifierType MOD_Shift = (GdkModifierType) ( ~consumed & GDK_SHIFT_MASK ); - GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); - - for (int i = 0; i < count; i++) { - if (maps[i].level > 1 || maps[i].group > 1) - continue; - - gchar * kv_name = gdk_keyval_name (keyvals[i]); - - if ( keyvals[i]>0) - gdk_keyval_convert_case (*kv_name, &lowerCase, &upperCase); - - // _S2 is ( lowerCase == upperCase ) true for all number keys for all keyboards? - if ( lowerCase == upperCase ) - return (KMX_DWORD) upperCase; - } - - - // _S2 ToDo tidy up - if ( keycode >7) { - UINT VK_for_rgKey2 = ScanCodeToUSVirtualKey[keycode-8]; - - //return (KMX_DWORD) *keyvals;} //_S2 what to return if >255 - return (KMX_DWORD) VK_for_rgKey2; } - - return 0; //_S2 what to return if not found -} - -KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying( KMX_DWORD keycode) { - if ( keycode >7) - return (KMX_DWORD) ScanCodeToUSVirtualKey[keycode-8]; - return 0; //_S2 what to return if not found -} - -KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS( KMX_DWORD VK_US) { - if( VK_US > 7) { - KMX_DWORD test = (KMX_DWORD)(8+ USVirtualKeyToScanCode[ VK_US ]); - return (KMX_DWORD)(8+ USVirtualKeyToScanCode[ VK_US ]);} + // 32 127 196 256 + if ((KV >= 0x20 && KV <= 0x7F) || (KV >= 0x20 && KV <= 0x7F) || (KV >= 0xC4 && KV < 198) || + (KV >= 199 && KV < 208) || (KV >= 209 && KV < 216) || (KV >= 217 && KV < 229) || + (KV >= 231 && KV < 240) || (KV >= 241 && KV < 248) || (KV >= 249 && KV < 0xFF) || + (KV == 128) || (KV == 178) || (KV == 167) || (KV == 179) || (KV == 176)|| (KV == 181) ) + return true; else - return 0; + return false; } +// _S2 ToDo deadkeys. std::wstring convert_DeadkeyValues_ToChar(int in) { KMX_DWORD lname; @@ -448,24 +392,36 @@ std::wstring convert_DeadkeyValues_ToChar(int in) { return L"\0"; } +// _S2 use gdk_keymap_translate_keyboard_state instead return s shifted + unshifted only- no altgr,... +KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos) { + GdkKeymapKey *maps; + guint *keyvals; + gint count; + KMX_DWORD out; -std::wstring CodePointToWString(unsigned int codepoint) { - std::wstring str; + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return 0; + //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html - if constexpr (sizeof(wchar_t) > 2) { - str = static_cast(codepoint); - } - else if (codepoint <= 0xFFFF) { - str = static_cast(codepoint); - } - else { - codepoint -= 0x10000; - str.resize(2); - str[0] = static_cast(0xD800 + ((codepoint >> 10) & 0x3FF)); - str[1] = static_cast(0xDC00 + (codepoint & 0x3FF)); - } +// _S2 this will return 223 instaed of 7838 for UNICODE char on DE keycode 20 ß ẞ ? ? - return str; + if (!(shift_state_pos <= count)) + return 0; + + if (!(keycode <= 94)) + return 0; + + out =(KMX_DWORD) keyvals[shift_state_pos]; + + if ( (out >= deadkey_min) && (out <= deadkey_max) ) { + wprintf(L"out of range: found deadkey value out( %i) for keycode = %i /shift_state_pos %i (49= TLDE 21= VK_EQUALS on US keyboard) \n", out,keycode,shift_state_pos); + } + // _S2 g_free used everywhere? + g_free(keyvals); + g_free(maps); + + return out; } std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ @@ -540,7 +496,55 @@ std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(Gd return std::wstring(1, (int) *keyvals); } +KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { + GdkModifierType consumed; + GdkKeymapKey *maps; + guint *keyvals; + guint lowerCase; + guint upperCase; + gint count; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return 0; + + //Shift + //GdkModifierType MOD_Shift = (GdkModifierType) ( ~consumed & GDK_SHIFT_MASK ); + GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + + for (int i = 0; i < count; i++) { + if (maps[i].level > 1 || maps[i].group > 1) + continue; + + gchar * kv_name = gdk_keyval_name (keyvals[i]); + + if ( keyvals[i]>0) + gdk_keyval_convert_case (*kv_name, &lowerCase, &upperCase); + + // _S2 is ( lowerCase == upperCase ) true for all number keys for all keyboards? + if ( lowerCase == upperCase ) + return (KMX_DWORD) upperCase; + } + + + // _S2 ToDo tidy up + if ( keycode >7) { + UINT VK_for_rgKey2 = ScanCodeToUSVirtualKey[keycode-8]; + + //return (KMX_DWORD) *keyvals;} //_S2 what to return if >255 + return (KMX_DWORD) VK_for_rgKey2; } + + return 0; //_S2 what to return if not found +} + +KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS( KMX_DWORD VK_US) { + + if( VK_US > 7) { + return (KMX_DWORD)(8+ USVirtualKeyToScanCode[ VK_US ]);} + else + return 0; +} KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector,KMX_DWORD KC_US, ShiftState ss, int caps) { @@ -559,3 +563,42 @@ KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3 } return KC_US; } + +std::wstring CodePointToWString(unsigned int codepoint) { + std::wstring str; + + if constexpr (sizeof(wchar_t) > 2) { + str = static_cast(codepoint); + } + else if (codepoint <= 0xFFFF) { + str = static_cast(codepoint); + } + else { + codepoint -= 0x10000; + str.resize(2); + str[0] = static_cast(0xD800 + ((codepoint >> 10) & 0x3FF)); + str[1] = static_cast(0xDC00 + (codepoint & 0x3FF)); + } + + return str; +} + +// _S2 check if this works +/*std::u16string CodePointToU16String(unsigned int codepoint) { + std::u16string str; + + if constexpr (sizeof(wchar_t) > 2) { + str = static_cast(codepoint); + } + else if (codepoint <= 0xFFFF) { + str = static_cast(codepoint); + } + else { + codepoint -= 0x10000; + str.resize(2); + str[0] = static_cast(0xD800 + ((codepoint >> 10) & 0x3FF)); + str[1] = static_cast(0xDC00 + (codepoint & 0x3FF)); + } + + return str; +}*/ diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 03b1bd4dd9..3b59f117c0 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -505,6 +505,8 @@ const UINT ScanCodeToUSVirtualKey[128] = { 0x00 // 0x7f => No match }; +bool IsKeymanUsedKeyVal(std::wstring Keyval); + // take deadkey-value (e.g.65106) and return character (e.g. '^' ) std::wstring convert_DeadkeyValues_ToChar(int in); @@ -517,14 +519,16 @@ std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(Gdk // return the VirtualKey of the Other Keyboard for given Scancode using GDK KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD scanCode); -KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying( KMX_DWORD keycode); - +// return the Keycode of the Other Keyboard for given VK_US KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS( KMX_DWORD VK_US); +// return the Keycode of the Other Keyboard for given VK_US using GDK KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector,KMX_DWORD KC_US, ShiftState ss, int caps); -bool IsKeymanUsedKeyVal(std::wstring Keyval); - +// converts codePoint to wstring std::wstring CodePointToWString(unsigned int codepoint); +// converts codePoint to u16string ( _S2 ToDo is this cvorrect?) +//std::u16string CodePointToU16String(unsigned int codepoint); + # endif /*KEYMAP_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index df6a4dd33d..fce7ac20c4 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -27,8 +27,9 @@ #include "mc_kmxfile.h" #include "keymap.h" -int KMX_ToUnicodeEx(guint ScanCode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, int shift_state, int caps, GdkKeymap *keymap =NULL); + int KMX_ToUnicodeEx(guint ScanCode, const BYTE *lpKeyState, PWCHAR pwszBuff, int shift_state, int caps,GdkKeymap *keymap); + const int KMX_ShiftStateMap[] = { ISVIRTUALKEY, ISVIRTUALKEY | K_SHIFTFLAG, @@ -42,6 +43,7 @@ const int KMX_ShiftStateMap[] = { 0 }; +// _S2 ToDo open deadkey functions class DeadKey { private: KMX_WCHAR m_deadchar; @@ -121,7 +123,8 @@ public: this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying_GDK(*keymap, scanCode); this->m_hkl = hkl; this->m_sc = scanCode; - // _S2 ?? memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); + // _S2 ToDo deadkey + // memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); } UINT VK() { @@ -136,10 +139,10 @@ public: return m_rgss[i][j]; } - // _S2 can go later + /*// _S2 can go later void set_sc(int i) { this->m_sc=i; - } + }*/ std::wstring KMX_GetShiftState(ShiftState shiftState, bool capsLock) { return this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)]; @@ -156,6 +159,7 @@ public: this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; } +// _S2 DESIGN NEEDED how to change those? bool KMX_IsSGCAPS() { std::wstring stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß std::wstring stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? @@ -218,7 +222,7 @@ public: return (this->m_vk >= 0x20 && this->m_vk <= 0x5F) || (this->m_vk >= 0x88); } -UINT KMX_GetShiftStateValue(int capslock, int caps, ShiftState ss) { + UINT KMX_GetShiftStateValue(int capslock, int caps, ShiftState ss) { //wprintf(L"GetShiftStateValue takes capslock: %i, caps: %i, ss: %i and returns: %i\n", capslock, caps, ss, KMX_ShiftStateMap[(int)ss] | //(capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0)); return @@ -226,11 +230,12 @@ UINT KMX_GetShiftStateValue(int capslock, int caps, ShiftState ss) { (capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0); } + // _S2 should count OK for char AND deadkeys int KMX_GetKeyCount(int MaxShiftState) { int nkeys = 0; // Get the CAPSLOCK value - //_S2 not used + //_S2 not used in original code; can be deleted /*int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | (this->KMX_IsSGCAPS() ? 2 : 0) | @@ -296,7 +301,7 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; for (int caps = 0; caps <= 1; caps++) { std::wstring st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); PKMX_WCHAR p; // was PWSTR p; - PKMX_WCHAR q; + PKMX_WCHAR q; // _S2 q has to go: it`s just for debugging if (st.size() == 0) { // No character assigned here @@ -331,13 +336,10 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; if(isvalid) { // this is different to mcompile windows !!!! // this->m_sc stores SC-US = SCUnderlying - // this->m_vk stores VK-US - // key->Key stores VK-US + // this->m_vk stores VK-US ( not underlying !!) + // key->Key stores VK-US ( not underlying !!) // key->dpOutput stores character Underlying - // _S2 confusing: since we sort rgkey by VKUS: is SC_Underlying the right SC or SC_Underlying_gdk?? it will be clear when we look at kmx/kmn-file - //KMX_DWORD SC_Underlying = KMX_get_SCUnderlying_From_SCUS_VEC(All_Vector,this->SC(), ss); - KMX_DWORD SC_Underlying_gdk = KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(keymap, All_Vector,this->SC(), (ShiftState) ss, caps); key->Key = KMX_get_VKUS_From_KeyCodeUnderlying_GDK( keymap, SC_Underlying_gdk); @@ -528,8 +530,11 @@ int KMX_ToUnicodeEx(guint ScanCode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, return -1; std::wstring character = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, ScanCode, ShiftState(shift_state), caps); - pwszBuff[0]= * (PWCHAR) character.c_str(); - return 1; + std::string ch_str = string_from_wstring(character); + std::u16string ch_16 = u16string_from_string(ch_str); + pwszBuff[0]= * (PKMX_WCHAR) ch_16.c_str(); + + return 1; } bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 @@ -956,17 +961,3 @@ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p) { } return p; } - -bool IsKeymanUsedKeyVal(std::wstring Keyval) { - - int KV = (int) (*Keyval.c_str()); - - // 32 127 196 256 - if ((KV >= 0x20 && KV <= 0x7F) || (KV >= 0x20 && KV <= 0x7F) || (KV >= 0xC4 && KV < 198) || - (KV >= 199 && KV < 208) || (KV >= 209 && KV < 216) || (KV >= 217 && KV < 229) || - (KV >= 231 && KV < 240) || (KV >= 241 && KV < 248) || (KV >= 249 && KV < 0xFF) || - (KV == 128) || (KV == 178) || (KV == 167) || (KV == 179) || (KV == 176)|| (KV == 181) ) - return true; - else - return false; -} diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 088251f033..c595e1a02f 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -599,26 +599,6 @@ KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_U return (KMX_WCHAR) KeyvalOther; } -bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]){ -// get keymap of keyboard layout in use - - gdk_init(&argc, &argv); - GdkDisplay *display = gdk_display_get_default(); - if (!display) { - wprintf(L"ERROR: can't get display\n"); - return 1; - } - - *keymap = gdk_keymap_get_for_display(display); - if (!keymap) { - wprintf(L"ERROR: Can't get keymap\n"); - gdk_display_close(display); - return 2; - } - - return 0; -} - int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ std::string US_language = "us"; const char* text_us = "xkb_symbols \"basic\""; From 4132d5f43b596ea3c4c805d38e433ab2598b7b1d Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 11 Jan 2024 11:13:02 +0100 Subject: [PATCH 166/327] feat(linux): mcompile work on _S2 comments --- linux/mcompile/keymap/README.md | 11 +- linux/mcompile/keymap/deadkey.cpp | 3 +- linux/mcompile/keymap/helpers.cpp | 26 ++++ linux/mcompile/keymap/keymap.cpp | 140 ++++++++++++++++++---- linux/mcompile/keymap/keymap.h | 15 ++- linux/mcompile/keymap/km_types.h | 26 ++-- linux/mcompile/keymap/mc_import_rules.cpp | 68 ++--------- linux/mcompile/keymap/mc_kmxfile.cpp | 34 ++++++ linux/mcompile/keymap/mcompile.cpp | 69 ++--------- linux/mcompile/keymap/mcompile.h | 10 +- 10 files changed, 225 insertions(+), 177 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index 0988640f52..f695fa0fd8 100755 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -9,10 +9,8 @@ Sample program that reads US basic keyboard and compares to key value group TODO check if US basic is the right Keyboard to compare with TODO deadkeys don't work yet TODO path for xkb/symbols as compile time option in meson -TODO check how many/which shift states we use ( at the moment we read all shiftstate-columns of US but then use only 2 colums (non-shift + shift) then use as many colums for Other ) TODO define folder to store File_US.txt" in and find better name TODO check if I can use files from some other keyman path instead of a copy in keymap ( e.g. filesystem.h exists elsewhere) -TODO remove kbdid and kbd for Linux TODO shiftstate-count TODO keymap SplitToV.cpp exchange 4 with genaerated shiftcount TODO shift-statevector @@ -22,17 +20,14 @@ TODO check if passed All_Vectpor as ptr/ref not as value e.g. in KMX_CharFromVK, ToDo in get_VirtualKey_Other_From_SC: what if we use column 3(altgr) and 4 (shift+altgr) ?? TODO where to store VK_CANCEL.... in km_types.h or elsewhere? ToDo check up to 8 shiftstates ( find symbols-file with 8) -TODO get_position_From_VirtualKey_US: take care of the other shiftstates ToDo use _free(keyvals); g_free(maps); +ToDo use u16string OR wstring-functions only and remove the other TODO next: - - mc_import-rules (from ~ l. 790) see if everything gives the same result on win-Lin - check if I use char16_t everywhere instead of wchar_t or char - - replace GDK - - see in which files I can put some functions (e.g. incxstr) that were duplicated or even #include their original location - - remove USE_GDK - - what is wrong with kp->dpBitmapOffset/BitmapSize ? - Check/find use of wchar_t/wstring and replace with char16_t/u16string + - replace GDK + - what is wrong with kp->dpBitmapOffset/BitmapSize ? - check call by reference/value TODO ... diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index a32d67c5ae..c22a537a5e 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -34,9 +34,8 @@ void find_dk_combinations_for_single_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &d } } -// _S2 is this correct?? +// _S2 might be used when deadkeys are implemented . is it correct?? KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap) { - guint Keyval = (guint) KVal; GdkKeymapKey* keys; gint n_keys; diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 6676f826d3..7be581b5cf 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -668,6 +668,32 @@ int replace_KeyName_with_Keycode2(std::string in) { return out; } +/*int KMX_ToUnicodeEx( guint ScanCode, const BYTE *lpKeyStccate, PWCHAR pwszBuff, int shift_state, int caps,GdkKeymap *keymap) { + + KMX_DWORD kvl= KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap, ScanCode, shift_state); + + std::wstring character = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, ScanCode, ShiftState(shift_state), caps); + pwszBuff[0]= * (PWCHAR) character.c_str(); + + if((kvl >= deadkey_min) && (kvl <= deadkey_max)) + return -1; + else + return 1; +}*/ + + +// takes capital letter of US returns cpital character of Other keyboard +/*KMX_DWORD KMX_get_KVUnderlying_From_KVUS_VEC(v_dw_3D &All_Vector,KMX_DWORD inUS) { + // loop and find char in US; then return char of Other + for( int i=0; i< (int)All_Vector[0].size();i++) { + for( int j=1; j< (int)All_Vector[0][0].size();j++) { + if((inUS == All_Vector[0][i][j] )) { + return All_Vector[1][i][2]; + } + } + } + return inUS; +}*/ /* KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying( KMX_DWORD keycode) { diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 57f656359f..14234db71e 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -370,7 +370,7 @@ std::wstring convert_DeadkeyValues_ToChar(int in) { KMX_DWORD lname; - if (in <= deadkey_min) { // no deadkey; no Unicode + if (in <= (int) deadkey_min) { // no deadkey; no Unicode if (!IsKeymanUsedKeyVal(std::wstring(1, in))) return L"\0"; return std::wstring(1, in); @@ -392,6 +392,32 @@ std::wstring convert_DeadkeyValues_ToChar(int in) { return L"\0"; } +std::u16string convert_DeadkeyValues_ToChar_16(int in) { + + KMX_DWORD lname; + + if (in <= (int) deadkey_min) { // no deadkey; no Unicode + if (!IsKeymanUsedKeyVal(std::wstring(1, in))) + return u"\0"; + return std::u16string(1, in); + } + else { + std::string long_name((const char*) gdk_keyval_name (in)); + + if ( long_name.substr (0,2) == "U+" ) // U+... Unicode value + return CodePointToString_16(in-0x1000000); + + lname = convertNamesToIntegerValue( wstring_from_string(long_name)); // 65106 => "dead_circumflex " => 94 => "^" + + if (lname != returnIfCharInvalid) { + return std::u16string(1, lname ); + } + else + return u"\0"; + } + return u"\0"; +} + // _S2 use gdk_keymap_translate_keyboard_state instead return s shifted + unshifted only- no altgr,... KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; @@ -424,7 +450,7 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap return out; } -std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ +std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ GdkModifierType consumed; GdkKeymapKey *maps; @@ -496,6 +522,77 @@ std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(Gd return std::wstring(1, (int) *keyvals); } +std::u16string KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_16(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ + + GdkModifierType consumed; + GdkKeymapKey *maps; + guint *keyvals; + gint count; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return u"\0"; + + //unshifted (shiftstate: 0) + if (( ss == Base ) && ( caps == 0 )) { + GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); + } + + //caps (shiftstate: 0) + else if (( ss == Base ) && ( caps == 1 )) { + GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); + } + + //Shift (shiftstate: 1) + else if (( ss == Shft ) && ( caps == 0 )) { + GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + } + + //SHIFT+CAPS (shiftstate: 1) + else if ( ( ss == Shft ) && ( caps ==1 )) { + GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); + } + + // Ctrl (shiftstate: 2) + // SHIFT+Ctrl (shiftstate: 2) + + //ALT-GR (shiftstate: 6) + else if (( ss == MenuCtrl ) && ( caps == 0 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR +CAPS (shiftstate: 6) + else if (( ss == MenuCtrl ) && ( caps == 1 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR (shiftstate: 7) + else if (( ss == ShftMenuCtrl ) && ( caps == 0 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR +CAPS (shiftstate: 7) + else if (( ss == ShftMenuCtrl ) && ( caps == 1 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + else + return u"\0"; + + //if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max) ) + if((*keyvals >= deadkey_min) ) + return convert_DeadkeyValues_ToChar_16((int) *keyvals); + else + return std::u16string(1, (int) *keyvals); +} + KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { GdkModifierType consumed; @@ -509,31 +606,25 @@ KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD return 0; //Shift - //GdkModifierType MOD_Shift = (GdkModifierType) ( ~consumed & GDK_SHIFT_MASK ); - GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); - for (int i = 0; i < count; i++) { - if (maps[i].level > 1 || maps[i].group > 1) - continue; + for (int i = 0; i < count; i++) { + if (maps[i].level > 1 || maps[i].group > 1) + continue; - gchar * kv_name = gdk_keyval_name (keyvals[i]); + gchar * kv_name = gdk_keyval_name (keyvals[i]); - if ( keyvals[i]>0) - gdk_keyval_convert_case (*kv_name, &lowerCase, &upperCase); + if ( keyvals[i]>0) + gdk_keyval_convert_case (*kv_name, &lowerCase, &upperCase); - // _S2 is ( lowerCase == upperCase ) true for all number keys for all keyboards? - if ( lowerCase == upperCase ) - return (KMX_DWORD) upperCase; - } + // _S2 is ( lowerCase == upperCase ) true for all number keys for all keyboards? + if ( lowerCase == upperCase ) + return (KMX_DWORD) upperCase; + } - - // _S2 ToDo tidy up - if ( keycode >7) { - UINT VK_for_rgKey2 = ScanCodeToUSVirtualKey[keycode-8]; - - //return (KMX_DWORD) *keyvals;} //_S2 what to return if >255 - return (KMX_DWORD) VK_for_rgKey2; } + if ( keycode >7) + return (KMX_DWORD) ScanCodeToUSVirtualKey[keycode-8]; return 0; //_S2 what to return if not found } @@ -583,8 +674,7 @@ std::wstring CodePointToWString(unsigned int codepoint) { return str; } -// _S2 check if this works -/*std::u16string CodePointToU16String(unsigned int codepoint) { +std::u16string CodePointToString_16(unsigned int codepoint) { std::u16string str; if constexpr (sizeof(wchar_t) > 2) { @@ -601,4 +691,4 @@ std::wstring CodePointToWString(unsigned int codepoint) { } return str; -}*/ +} diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 3b59f117c0..803b2689d3 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -24,8 +24,6 @@ typedef std::vector v_dw_1D; typedef std::vector > v_dw_2D; typedef std::vector > > v_dw_3D; -// _S2 sort declarations/definitions to mcompile or keymaap.. - enum ShiftState { Base = 0, // 0 Shft = 1, // 1 @@ -69,8 +67,6 @@ const KMX_DWORD KMX_VKMap[] = { static KMX_DWORD returnIfCharInvalid = 0; -//_S2 QUESTION Which threshold ( from what int value onwards is a character considered deadkey? 65000 28000?, > 255? ?? -static KMX_DWORD deadkeyThreshold = 65000; static KMX_DWORD deadkey_min = 0xfe50; static KMX_DWORD deadkey_max = 0xfe93; @@ -507,14 +503,18 @@ const UINT ScanCodeToUSVirtualKey[128] = { bool IsKeymanUsedKeyVal(std::wstring Keyval); -// take deadkey-value (e.g.65106) and return character (e.g. '^' ) +// take deadkey-value (e.g.65106) and return wstring (e.g. '^' ) std::wstring convert_DeadkeyValues_ToChar(int in); +// take deadkey-value (e.g.65106) and return u16string (e.g. '^' ) +std::u16string convert_DeadkeyValues_ToChar_16(int in); // find Keyvals to fill into 2D-Vector of Other Language KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos); // returns KeySyms fo ra given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); +// returns KeySyms fo ra given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) +std::u16string KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_16(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); // return the VirtualKey of the Other Keyboard for given Scancode using GDK KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD scanCode); @@ -527,8 +527,7 @@ KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3 // converts codePoint to wstring std::wstring CodePointToWString(unsigned int codepoint); - -// converts codePoint to u16string ( _S2 ToDo is this cvorrect?) -//std::u16string CodePointToU16String(unsigned int codepoint); +// converts codePoint to u16string +std::u16string CodePointToString_16(unsigned int codepoint); # endif /*KEYMAP_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index 0c04550432..dc9cbca442 100755 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -44,11 +44,8 @@ typedef WCHAR KMX_WCHART; // _S2 needs to be removed/ wchart-> cha typedef char16_t KMX_WCHAR; // _S2 typedef KMX_WCHAR* PKMX_WCHAR; // _S2 typedef wchar_t* PWSTR; // _S2 needs to be removed/ wchart-> char16 -//typedef PWSTR PKMX_WCHART; // _S2 needs to be removed/ wchart-> char16 -//typedef const wchar_t* PCKMX_WCHART; // _S2 needs to be removed/? typedef char* LPSTR; // _S2 needs to be removed? -//typedef LPSTR LPKMX_STR; // _S2 needs to be removed? typedef uint8_t* LPBYTE; // _S2 needs to be removed/? typedef uint8_t* LPKMX_BYTE; // _S2 needs to be removed? @@ -57,7 +54,6 @@ typedef uint8_t* PBYTE; // _S2 needs to be removed/? typedef uint8_t* PKMX_BYTE; // _S2 needs to be removed? typedef char KMX_CHAR; // _S2 needs to be removed/? -//typedef char* PKMX_STR; // _S2 needs to be removed/? typedef unsigned int UINT; // _S2 needs to be removed/? typedef unsigned char BYTE; // _S2 needs to be removed? @@ -103,18 +99,18 @@ typedef wchar_t KMX_UCHAR; typedef KMX_UCHAR* KMX_PUCHAR; #define VK_SPACE 0x20 -#define VK_COLON 0xBA -#define VK_EQUAL 0xBB -#define VK_COMMA 0xBC -#define VK_HYPHEN 0xBD -#define VK_PERIOD 0xBE -#define VK_SLASH 0xBF -#define VK_ACCENT 0xC0 -#define VK_LBRKT 0xDB +#define VK_COLON 0xBA +#define VK_EQUAL 0xBB +#define VK_COMMA 0xBC +#define VK_HYPHEN 0xBD +#define VK_PERIOD 0xBE +#define VK_SLASH 0xBF +#define VK_ACCENT 0xC0 +#define VK_LBRKT 0xDB #define VK_BKSLASH 0xDC -#define VK_RBRKT 0xDD -#define VK_QUOTE 0xDE -#define VK_xDF 0xDF +#define VK_RBRKT 0xDD +#define VK_QUOTE 0xDE +#define VK_xDF 0xDF #define VK_OEM_102 0xE2 // "<>" or "\|" on RT 102-key kbd. /*#define VK_NUMPAD0 0x5A diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index fce7ac20c4..6d50c72742 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -510,19 +510,6 @@ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { return n; } -int KMX_ToUnicodeEx( guint ScanCode, const BYTE *lpKeyStccate, PWCHAR pwszBuff, int shift_state, int caps,GdkKeymap *keymap) { - - KMX_DWORD kvl= KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap, ScanCode, shift_state); - - std::wstring character = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, ScanCode, ShiftState(shift_state), caps); - pwszBuff[0]= * (PWCHAR) character.c_str(); - - if((kvl >= deadkey_min) && (kvl <= deadkey_max)) - return -1; - else - return 1; -} - int KMX_ToUnicodeEx(guint ScanCode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, int shift_state, int caps,GdkKeymap *keymap) { KMX_DWORD kvl= KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap, ScanCode, shift_state); @@ -530,14 +517,11 @@ int KMX_ToUnicodeEx(guint ScanCode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, return -1; std::wstring character = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, ScanCode, ShiftState(shift_state), caps); - std::string ch_str = string_from_wstring(character); - std::u16string ch_16 = u16string_from_string(ch_str); - pwszBuff[0]= * (PKMX_WCHAR) ch_16.c_str(); - + pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(character).c_str(); return 1; } -bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 +bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 KMX_Loader loader; const size_t BUF_sz= 256; @@ -577,7 +561,8 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL, All_Vector, keymap); /* - // _S2 do we need special shift state now or later? + // _S2 RALT <-> SHIFT CTRL Problem from here?? + // _S2 DESIGN NEEDED do we need special shift state now or later? // See if there is a special shift state added for(UINT vk = 0; vk <= VK_OEM_CLEAR; vk++) { UINT sc = MapVirtualKeyEx(vk, 0, hkl); @@ -643,6 +628,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd if((rc == 1) && (ss == Ctrl || ss == ShftCtrl) && (rgKey[iKey]->VK() == ((UINT)sbBuffer[0] + 0x40))) { + // _S2 RALT<-> SHIFT CTR problem from here?? // _S2 TODO is this the same behavior on Linux? // if rc ==1 : it got 1 char && +40 in Buffer CTRl pressed // It's dealing with control characters. If ToUnicodeEx gets @@ -675,8 +661,8 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd DeadKey *dk = NULL; for(UINT iDead = 0; iDead < alDead.size(); iDead++) { dk = alDead[iDead]; - WCHAR dktest1 = dk->KMX_DeadCharacter(); - WCHAR dktest2 = rgKey[iKey]->KMX_GetShiftState(ss, caps == 0)[0]; + WCHAR dktest1 = dk->KMX_DeadCharacter(); // _S2 can go later ; just for testing + WCHAR dktest2 = rgKey[iKey]->KMX_GetShiftState(ss, caps == 0)[0]; // _S2 can go later ; just for testing if(dk->KMX_DeadCharacter() == rgKey[iKey]->KMX_GetShiftState(ss, caps == 0)[0]) { break; } @@ -746,12 +732,10 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd kp->cxGroupArray++; gp = &kp->dpGroupArray[kp->cxGroupArray-1]; UINT nKeys = 0; - int sab_nr = 0; for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { nKeys+= rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); //wprintf(L" iKey = %i, Delta: %i -> Sum %i\n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()), nKeys); - sab_nr ++; } } @@ -770,6 +754,8 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd // // Fill in the new rules // + + // _S2 [CTRL NCAPS K_?00] > use(group3) c line(0) from here ? for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { if(rgKey[iKey]->KMX_LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 @@ -784,6 +770,7 @@ bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, Gd // // Add nomatch control to each terminating 'using keys' group // I4550 // + // _S2 [CTRL NCAPS K_?00] > use(group3) c line(0) from here ? LPKMX_GROUP gp2 = kp->dpGroupArray; for(UINT i = 0; i < kp->cxGroupArray - 1; i++, gp2++) { if(gp2->fUsingKeys && gp2->dpNoMatch == NULL) { @@ -926,38 +913,3 @@ const int CODE__SIZE[] = { 3, // CODE_IFSYSTEMSTORE 0x17 2 // CODE_SETSYSTEMSTORE 0x18 }; - -// _S2 where is nthe best place to put this?? -PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p) { - - if (*p == 0) - return p; - if (*p != UC_SENTINEL) { - if (*p >= 0xD800 && *p <= 0xDBFF && *(p + 1) >= 0xDC00 && *(p + 1) <= 0xDFFF) - return p + 2; - return p + 1; - } - // UC_SENTINEL(FFFF) with UC_SENTINEL_EXTENDEDEND(0x10) == variable length - if (*(p + 1) == CODE_EXTENDED) { - p += 2; - while (*p && *p != UC_SENTINEL_EXTENDEDEND) - p++; - - if (*p == 0) return p; - return p + 1; - } - - if (*(p + 1) > CODE_LASTCODE || CODE__SIZE[*(p + 1)] == -1) { - return p + 1; - } - - int deltaptr = 2 + CODE__SIZE[*(p + 1)]; - - // check for \0 between UC_SENTINEL(FFFF) and next printable character - for (int i = 0; i < deltaptr; i++) { - if (*p == 0) - return p; - p++; - } - return p; -} diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 3098357885..991bfc2dae 100755 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -484,6 +484,40 @@ KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz){ return TRUE; } +PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p) { + + if (*p == 0) + return p; + if (*p != UC_SENTINEL) { + if (*p >= 0xD800 && *p <= 0xDBFF && *(p + 1) >= 0xDC00 && *(p + 1) <= 0xDFFF) + return p + 2; + return p + 1; + } + // UC_SENTINEL(FFFF) with UC_SENTINEL_EXTENDEDEND(0x10) == variable length + if (*(p + 1) == CODE_EXTENDED) { + p += 2; + while (*p && *p != UC_SENTINEL_EXTENDEDEND) + p++; + + if (*p == 0) return p; + return p + 1; + } + + if (*(p + 1) > CODE_LASTCODE || CODE__SIZE[*(p + 1)] == -1) { + return p + 1; + } + + int deltaptr = 2 + CODE__SIZE[*(p + 1)]; + + // check for \0 between UC_SENTINEL(FFFF) and next printable character + for (int i = 0; i < deltaptr; i++) { + if (*p == 0) + return p; + p++; + } + return p; +} + //---------------------old---------------------------------------- diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index c595e1a02f..cf54039c58 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -32,35 +32,19 @@ #include "mcompile.h" -//------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------ -KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]); +KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]); -bool KMX_ImportRules(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 +bool KMX_ImportRules( LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 std::vector KMX_FDeadkeys; // I4353 -void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch); -void KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch); -void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch); - -void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key); -void KMX_ReportUnconvertedGroupRules(LPKMX_GROUP group); -void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd); - -void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch); -void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group,KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch); -void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch); - -int KMX_GetDeadkeys(v_dw_2D & dk_ComposeTable, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap); -//int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, KMX_WORD sc); -void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift); - - -KMX_UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); -KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey); +// Note: max is not a standard c api function or macro +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif #if defined(_WIN32) || defined(_WIN64) int wmain(int argc, wchar_t* argv[]) { @@ -84,8 +68,6 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ argv.push_back(cmdl_par); } - - if(argc < 3 || (argc < 5 && u16cmp(argv[1], u"-u") != 0)) { // I4273// I4273 wprintf( L"Usage: mcompile -u infile.kmx outfile.kmx\n (not available for Linux)" @@ -149,8 +131,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ }*/ #else // LINUX -// _S2 ToDo :do I need all parameters?-no - if(KMX_DoConvert( kmxfile, kbid, bDeadkeyConversion, argc, (gchar**) argv_ch)) { // I4552F + if(KMX_DoConvert( kmxfile, bDeadkeyConversion, argc, (gchar**) argv_ch)) { // I4552F KMX_SaveKeyboard(kmxfile, outfile); } #endif @@ -162,11 +143,8 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ return 0; } -// _S2 TODO which version of VKShiftStates do we use ? -// comment from win-version // Map of all shift states that we will work with const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; -//const UINT VKShiftState[] = {0, K_SHIFTFLAG, 0xFFFF}; // my comment for Lin version // Ubuntu: Each of the 4 columns specifies a different modifier: unmodified, shift, right alt (altgr), shift+right alt(altgr) @@ -325,11 +303,6 @@ void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT } } -// Note: max is not a standard c api function or macro -#ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif - KMX_WCHAR KMX_ScanXStringForMaxDeadkeyID(PKMX_WCHAR str) { KMX_WCHAR dkid = 0; while(str && *str) { @@ -447,7 +420,7 @@ KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { return FALSE; } -KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]) { +KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]) { KMX_WCHAR DeadKey; @@ -481,9 +454,6 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon for (int i = 0;KMX_VKMap[i]; i++) { // I4651 // win goes via VK, Lin goes via SC - /*KMX_DWORD vkUnderlying = KMX_get_KVUnderlying_From_KVUS_VEC(All_Vector,(int) KMX_VKMap[i] ); - KMX_WCHAR ch = KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_VEC(All_Vector,vkUnderlying, VKShiftState[j], &DeadKey);*/ - UINT scUnderlying = KMX_get_SCUnderlying_From_VKUS(KMX_VKMap[i]); KMX_WCHAR ch = KMX_get_CharUnderlying_From_SCUnderlying_GDK(keymap, VKShiftState[j], scUnderlying, &DeadKey); @@ -505,7 +475,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, PKMX_WCHAR kbid, KMX_BOOL bDeadkeyCon KMX_ReportUnconvertedKeyboardRules(kbd); - if(!KMX_ImportRules(kbid, kbd, All_Vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 + if(!KMX_ImportRules(kbd, All_Vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 return FALSE; } return TRUE; @@ -528,19 +498,6 @@ UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS) { return SC_OTHER; } -// takes capital letter of US returns cpital character of Other keyboard -KMX_DWORD KMX_get_KVUnderlying_From_KVUS_VEC(v_dw_3D &All_Vector,KMX_DWORD inUS) { - // loop and find char in US; then return char of Other - for( int i=0; i< (int)All_Vector[0].size();i++) { - for( int j=1; j< (int)All_Vector[0][0].size();j++) { - if((inUS == All_Vector[0][i][j] )) { - return All_Vector[1][i][2]; - } - } - } - return inUS; -} - KMX_WCHAR KMX_get_KVUS_From_KVUnderlying_VEC(v_dw_3D All_Vector, KMX_DWORD VK_OTHER) { KMX_DWORD VK_US; @@ -566,7 +523,7 @@ KMX_DWORD KMX_get_SCUnderlying_From_SCUS_VEC(v_dw_3D &All_Vector, KMX_DWORD KC_U // find character with that scancode for( int i=0; i< (int)All_Vector[0].size()-1 ;i++) { if ( ( All_Vector[0][i][0] == KC_US ) ) { - if ( Shiftstate+1 < All_Vector[0][i].size()-1) + if ( Shiftstate+1 < (int) All_Vector[0][i].size()-1) Character = All_Vector[0][i][Shiftstate+1]; break; } @@ -589,9 +546,7 @@ KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_U int VKShiftState_lin = map_VKShiftState_to_Lin(VKShiftState); KMX_DWORD KeyvalOther = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,SC_OTHER, VKShiftState_lin); - // _S2 how to detect deadkeys ? KeyvalOther >deadkeyThreshold KeyvalOther > 255? KeyvalOther > 65000 ? or what else? - if (KeyvalOther > deadkeyThreshold) { - //if (KeyvalOther > 255) { + if (KeyvalOther >= deadkey_min) { std::string ws((const char*) gdk_keyval_name (KeyvalOther)); *DeadKey = convertNamesToIntegerValue( wstring_from_string(ws)); return 0xFFFF; @@ -625,7 +580,7 @@ int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, v_dw_2D dk_SingleTable; find_dk_combinations_for_single_dk(&dk_Table, dk_SingleTable, DeadKey); // _S2 CAPS <-> NCAPS problem from here? - for ( int i=0; i< dk_SingleTable.size()-1;i++) { + for ( int i=0; i< (int) dk_SingleTable.size()-1;i++) { KMX_WORD vk = KMX_changeKeynameToCapital(dk_SingleTable[i][1], shift, keymap); if(vk != 0) { *p++ = vk; diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index db31bd9c07..a846e85ff1 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -40,12 +40,14 @@ int run(int argc, std::vector str_argv, char* argv[]); PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); -UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); -KMX_DWORD KMX_get_SCUnderlying_From_SCUS_VEC(v_dw_3D &All_Vector, KMX_DWORD VK_US, int Shiftstate); -KMX_WCHAR KMX_get_KVUS_From_KVUnderlying_VEC(v_dw_3D All_Vector,KMX_DWORD SC_US); -KMX_DWORD KMX_get_KVUnderlying_From_KVUS_VEC(v_dw_3D &All_Vector,KMX_DWORD inUS); +UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); + KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey); +// _S2 this is used in code for deadkeys and should be removed later +KMX_WCHAR KMX_get_KVUS_From_KVUnderlying_VEC(v_dw_3D All_Vector,KMX_DWORD SC_US); + + int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap); From 474d5d6518e05dc0037ccb869bfc0d35b89d89fb Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 11 Jan 2024 17:46:45 +0100 Subject: [PATCH 167/327] feat(linux): mcompile KMX_VirtualKey KMX_VirtualKey(KMX_HKL hkl,UINT virtualKey, GdkKeymap **keymap) --- linux/mcompile/keymap/deadkey.cpp | 2 +- linux/mcompile/keymap/km_types.h | 41 ++++++++++++++++------- linux/mcompile/keymap/mc_import_rules.cpp | 39 +++++++++++---------- linux/mcompile/keymap/mcompile.cpp | 3 +- linux/mcompile/keymap/mcompile.h | 2 -- 5 files changed, 51 insertions(+), 36 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index c22a537a5e..51e1e8238e 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -23,7 +23,7 @@ void find_dk_combinations_for_single_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &d // _S2 use return value to check if >0 lines in table v_dw_2D dk_ComposeTable = * p_dk_ComposeTable; v_dw_1D line; - for ( int i =0; i< (dk_ComposeTable).size()-1; i++) { + for ( int i =0; i< (int) dk_ComposeTable.size()-1; i++) { if ( dk_ComposeTable[i][0] == dk) { line.push_back(dk_ComposeTable[i][0]); line.push_back(dk_ComposeTable[i][1]); diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index dc9cbca442..6473950cdf 100755 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -127,20 +127,35 @@ typedef KMX_UCHAR* KMX_PUCHAR; #define VK_CANCEL 0x09 #define VK_DECIMAL 0x5B*/ -// _S2 correct?? Do I need NUMPAD?? -#define VK_NUMPAD0 96 -#define VK_NUMPAD1 97 -#define VK_NUMPAD2 98 -#define VK_NUMPAD3 99 -#define VK_NUMPAD4 100 -#define VK_NUMPAD5 101 -#define VK_NUMPAD6 102 -#define VK_NUMPAD7 103 -#define VK_NUMPAD8 104 -#define VK_NUMPAD9 105 -#define VK_DIVIDE 111 +// _S2 correct?? ?? + +#define VK_NUMPAD0 0x60 +#define VK_NUMPAD1 0x61 +#define VK_NUMPAD2 0x62 +#define VK_NUMPAD3 0x63 +#define VK_NUMPAD4 0x64 +#define VK_NUMPAD5 0x65 +#define VK_NUMPAD6 0x66 +#define VK_NUMPAD7 0x67 +#define VK_NUMPAD8 0x68 +#define VK_NUMPAD9 0x69 + + +// _S2 correct?? ?? +/*#define VK_NUMPAD0 0x2D +#define VK_NUMPAD1 0x23 +#define VK_NUMPAD2 0x28 +#define VK_NUMPAD3 0x22 +#define VK_NUMPAD4 0x25 +#define VK_NUMPAD5 0x0C +#define VK_NUMPAD6 0x27 +#define VK_NUMPAD7 0x24 +#define VK_NUMPAD8 0x26 +#define VK_NUMPAD9 0x21*/ + +#define VK_DIVIDE 0x6F #define VK_CANCEL 3 -#define VK_DECIMAL 110 +#define VK_DECIMAL 0x2E #define VK_OEM_CLEAR 0xFE #define VK_LSHIFT 0xA0 diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 6d50c72742..e3b914cbe0 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -113,20 +113,20 @@ private: public: - KMX_VirtualKey(UINT scanCode, KMX_HKL hkl, v_dw_3D All_Vector, GdkKeymap **keymap) { - this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying_GDK(*keymap, scanCode); + KMX_VirtualKey(KMX_HKL hkl,UINT virtualKey, GdkKeymap **keymap) { + this->m_sc=KMX_get_SCUnderlying_From_VKUS(virtualKey); this->m_hkl = hkl; - this->m_sc = scanCode; - } - - KMX_VirtualKey(KMX_HKL hkl,UINT scanCode, v_dw_3D All_Vector, GdkKeymap **keymap) { - this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying_GDK(*keymap, scanCode); - this->m_hkl = hkl; - this->m_sc = scanCode; + this->m_vk = virtualKey; // _S2 ToDo deadkey // memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); } + KMX_VirtualKey(UINT scanCode, KMX_HKL hkl, GdkKeymap **keymap) { + this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying_GDK(*keymap, scanCode); + this->m_hkl = hkl; + this->m_sc = scanCode; + } + UINT VK() { return this->m_vk; } @@ -301,7 +301,6 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; for (int caps = 0; caps <= 1; caps++) { std::wstring st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); PKMX_WCHAR p; // was PWSTR p; - PKMX_WCHAR q; // _S2 q has to go: it`s just for debugging if (st.size() == 0) { // No character assigned here @@ -348,7 +347,6 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; key->dpContext = new KMX_WCHAR; *key->dpContext = 0; p = key->dpOutput = new KMX_WCHAR[st.size() + 1]; for(size_t ich = 0; ich < st.size(); ich++) { - q=p; *p++ = st[ich]; } *p = 0; @@ -489,7 +487,6 @@ public: void KMX_ClearKeyboardBuffer() { KMX_WCHAR sb[16]; - int rc = 0; for( int i=0; i<16; i++) { sb[i] = L'\0'; } @@ -523,7 +520,7 @@ int KMX_ToUnicodeEx(guint ScanCode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 KMX_Loader loader; - const size_t BUF_sz= 256; + KMX_HKL hkl = NULL; //_S2 added: but can I do this?? hkl is not needed in Linux?? @@ -543,7 +540,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // Linux cant get a VK for the US Keyboard using USVirtualKeyToScanCode/ScanCodeToUSVirtualKey // Linux cannot get a VK for the underling Keyboard // this "connection" is possible only while using All_Vector - KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector, keymap); + KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, keymap); if((key->VK() != 0) ) { rgKey[key->VK()] = key; @@ -553,12 +550,18 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, } for(UINT ke = VK_NUMPAD0; ke <= VK_NUMPAD9; ke++) { - rgKey[ke] = new KMX_VirtualKey(hkl, ke, All_Vector, keymap); + rgKey[ke] = new KMX_VirtualKey(hkl, ke, keymap); } - rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE, All_Vector, keymap); - rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL, All_Vector, keymap); - rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL, All_Vector, keymap); + /*UINT Val_VK_NUMPAD0[] = {45,35,40,34,37,12,39,36,38,33, 0xFFFF}; + for (int i = 0; Val_VK_NUMPAD0[i] != 0xFFFF; i++) { + rgKey[Val_VK_NUMPAD0[i] ] = new KMX_VirtualKey(hkl, Val_VK_NUMPAD0[i] , keymap); + }*/ + + // _S2 ???? which numbers for VK_DIVIDE, VK_CANCEL, VK_DECIMAL ? + rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE, keymap); + rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL, keymap); + rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL, keymap); /* // _S2 RALT <-> SHIFT CTRL Problem from here?? diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index cf54039c58..7d4bc51a12 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -491,7 +491,7 @@ void KMX_LogError(const KMX_WCHART* m1,int m2, LPKMX_KEY key) { } */ -// takes SC of US keyboard and returns SC of OTHER keyboard +// takes VK of US keyboard and returns SC of OTHER keyboard UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS) { UINT SC_US = 8 + USVirtualKeyToScanCode[VirtualKeyUS]; UINT SC_OTHER = SC_US; // not neccessary but to understand what we do @@ -596,7 +596,6 @@ int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, return (p-OutputPairs); } - // ---- old copy code from here ---------------------------------------------------------- /* diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index a846e85ff1..bba96c4041 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -47,10 +47,8 @@ KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_UI // _S2 this is used in code for deadkeys and should be removed later KMX_WCHAR KMX_get_KVUS_From_KVUnderlying_VEC(v_dw_3D All_Vector,KMX_DWORD SC_US); - int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap); - //--------------------old /* #include From 6a310276f5fc675a74720d17e0fd6bc447921906 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 12 Jan 2024 15:37:47 +0100 Subject: [PATCH 168/327] feat(linux): mcompile opened some deadkey-functions --- linux/mcompile/keymap/deadkey.cpp | 1 + linux/mcompile/keymap/mc_import_rules.cpp | 72 ++++++++++++++++------- 2 files changed, 51 insertions(+), 22 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 51e1e8238e..6a08ea80c3 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -42,6 +42,7 @@ KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap // _S2 QUESTION can I assume that the win keyname is always the uppercase(level1) value?? KMX_DWORD Name = (KMX_DWORD) gdk_keyval_to_upper (KVal); + //KMX_DWORD Name = (KMX_DWORD) gdk_keyval_to_lower (KVal); if( Keyval !=0) { gdk_keymap_get_entries_for_keyval(keymap, Keyval, &keys, &n_keys); for (int i = 0; i < n_keys; i++) { diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index e3b914cbe0..2da2186632 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -51,19 +51,19 @@ private: std::vector m_rgcombchar; public: -/* DeadKey(WCHAR deadCharacter) { + DeadKey(KMX_WCHAR deadCharacter) { this->m_deadchar = deadCharacter; } -*/ + KMX_WCHAR KMX_DeadCharacter() { return this->m_deadchar; } -/* - void AddDeadKeyRow(WCHAR baseCharacter, WCHAR combinedCharacter) { + + void KMX_AddDeadKeyRow(KMX_WCHAR baseCharacter, KMX_WCHAR combinedCharacter) { this->m_rgbasechar.push_back(baseCharacter); this->m_rgcombchar.push_back(combinedCharacter); } -*/ + int KMX_Count() { return this->m_rgbasechar.size(); } @@ -85,6 +85,17 @@ public: } return false; }*/ + + + bool KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter) { + std::vector::iterator it; + for(it=this->m_rgbasechar.begin(); it= 0x007F && ch <= 0x009F); } - DeadKey *ProcessDeadKey( + bool KMX_IsControlChar(char16_t ch) { + return (ch < 0x0020) || (ch >= 0x007F && ch <= 0x009F); + } + + // _S2 ToDo ToUnicodeEx needs to be replaced here + DeadKey *KMX_ProcessDeadKey( UINT iKeyDead, // The index into the VirtualKey of the dead key ShiftState shiftStateDead, // The shiftstate that contains the dead key BYTE *lpKeyStateDead, // The key state for the dead key - std::vector rgKey, // Our array of dead keys + std::vector rgKey, // Our array of dead keys bool fCapsLock, // Was the caps lock key pressed? - HKL hkl) { // The keyboard layout + KMX_HKL KMX_hkl) { // The keyboard layout BYTE lpKeyState[256]; - DeadKey *deadKey = new DeadKey(rgKey[iKeyDead]->GetShiftState(shiftStateDead, fCapsLock)[0]); + DeadKey *deadKey = new DeadKey(rgKey[iKeyDead]->KMX_GetShiftState(shiftStateDead, fCapsLock)[0]); for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if (rgKey[iKey] != NULL) { @@ -427,31 +443,38 @@ public: // messed up so we run again and again to clear it up. // Risk is technically an infinite loop but per Hiroyama // that should be impossible here. - rc = ToUnicodeEx(rgKey[iKeyDead]->VK(), rgKey[iKeyDead]->SC(), lpKeyStateDead, sbBuffer, _countof(sbBuffer), 0, hkl); + + // _S2 needs replacement + // rc = ToUnicodeEx(rgKey[iKeyDead]->VK(), rgKey[iKeyDead]->SC(), lpKeyStateDead, sbBuffer, _countof(sbBuffer), 0, hkl); + rc=-1; //_S2 } // Now fill the key state for the potential base character - FillKeyState(lpKeyState, ss, (caps != 0)); + KMX_FillKeyState(lpKeyState, ss, (caps != 0)); - rc = ToUnicodeEx(rgKey[iKey]->VK(), rgKey[iKey]->SC(), lpKeyState, sbBuffer, _countof(sbBuffer), 0, hkl); + // _S2 needs replacement + //rc = ToUnicodeEx(rgKey[iKey]->VK(), rgKey[iKey]->SC(), lpKeyState, sbBuffer, _countof(sbBuffer), 0, hkl); if (rc == 1) { // That was indeed a base character for our dead key. // And we now have a composite character. Let's run // through one more time to get the actual base // character that made it all possible? WCHAR combchar = sbBuffer[0]; - rc = ToUnicodeEx(rgKey[iKey]->VK(), rgKey[iKey]->SC(), lpKeyState, sbBuffer, _countof(sbBuffer), 0, hkl); + + // _S2 needs replacement + //rc = ToUnicodeEx(rgKey[iKey]->VK(), rgKey[iKey]->SC(), lpKeyState, sbBuffer, _countof(sbBuffer), 0, hkl); WCHAR basechar = sbBuffer[0]; - if (deadKey->DeadCharacter() == combchar) { + if (deadKey->KMX_DeadCharacter() == combchar) { // Since the combined character is the same as the dead key, // we must clear out the keyboard buffer. - ClearKeyboardBuffer(VK_DECIMAL, rgKey[VK_DECIMAL]->SC(), hkl); + //KMX_ClearKeyboardBuffer(VK_DECIMAL, rgKey[VK_DECIMAL]->SC(), KMX_hkl); + KMX_ClearKeyboardBuffer(); } if ((((ss == Ctrl) || (ss == ShftCtrl)) && - (IsControlChar(basechar))) || + (KMX_IsControlChar(basechar))) || (basechar == combchar)) { // ToUnicodeEx has an internal knowledge about those // VK_A ~ VK_Z keys to produce the control characters, @@ -468,14 +491,15 @@ public: continue; } - if (!deadKey->ContainsBaseCharacter(basechar)) { - deadKey->AddDeadKeyRow(basechar, combchar); + if (!deadKey->KMX_ContainsBaseCharacter(basechar)) { + deadKey->KMX_AddDeadKeyRow(basechar, combchar); } } else if (rc > 1) { // Not a valid dead key combination, sorry! We just ignore it. } else if (rc < 0) { // It's another dead key, so we ignore it (other than to flush it from the state) - ClearKeyboardBuffer(VK_DECIMAL, rgKey[VK_DECIMAL]->SC(), hkl); + //ClearKeyboardBuffer(VK_DECIMAL, rgKey[VK_DECIMAL]->SC(), KMX_hkl); + KMX_ClearKeyboardBuffer(); } } } @@ -483,7 +507,7 @@ public: } return deadKey; } -*/ + void KMX_ClearKeyboardBuffer() { KMX_WCHAR sb[16]; @@ -662,6 +686,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // It's a dead key; let's flush out whats stored in the keyboard state. loader.KMX_ClearKeyboardBuffer(); DeadKey *dk = NULL; + int testI= alDead.size(); for(UINT iDead = 0; iDead < alDead.size(); iDead++) { dk = alDead[iDead]; WCHAR dktest1 = dk->KMX_DeadCharacter(); // _S2 can go later ; just for testing @@ -759,6 +784,9 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // // _S2 [CTRL NCAPS K_?00] > use(group3) c line(0) from here ? + //if this is missing: group(group3) using keys + // + [NCAPS K_SPACE] > " " c line(0) + for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { if(rgKey[iKey]->KMX_LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 From 417c9bb6aaa030fefcd234bfff84b141634afc05 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 12 Jan 2024 16:23:48 +0100 Subject: [PATCH 169/327] feat(linux): mcompile review code --- linux/mcompile/keymap/deadkey.cpp | 12 ++--- linux/mcompile/keymap/helpers.cpp | 8 +++ linux/mcompile/keymap/keymap.cpp | 6 ++- linux/mcompile/keymap/km_types.h | 60 +++++++++++------------ linux/mcompile/keymap/mc_import_rules.cpp | 29 ++--------- linux/mcompile/keymap/mcompile.cpp | 5 +- linux/mcompile/keymap/mcompile.h | 8 --- 7 files changed, 50 insertions(+), 78 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 6a08ea80c3..69899d06ce 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -10,15 +10,7 @@ v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, return line; } -/*KMX_DWORD find_dk_Character(v_dw_2D * p_dk_ComposeTable, KMX_DWORD first, KMX_DWORD second ) { - v_dw_2D dk_ComposeTable = * p_dk_ComposeTable; - for ( int i =0; i< (dk_ComposeTable).size()-1; i++) { - if (( (KMX_DWORD) dk_ComposeTable[i][0] == first) && ( (KMX_DWORD) dk_ComposeTable[i][1] == second) ) - return (KMX_DWORD) dk_ComposeTable[i][3]; - } - return 0; // _S2 what to return if not found? -}*/ - +// _S2 DEADKEY STUFF - DO NOT REVIEW YET void find_dk_combinations_for_single_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &dk_SingleTable, KMX_DWORD dk) { // _S2 use return value to check if >0 lines in table v_dw_2D dk_ComposeTable = * p_dk_ComposeTable; @@ -34,6 +26,7 @@ void find_dk_combinations_for_single_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &d } } +// _S2 DEADKEY STUFF - DO NOT REVIEW YET // _S2 might be used when deadkeys are implemented . is it correct?? KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap) { guint Keyval = (guint) KVal; @@ -55,6 +48,7 @@ KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap return Name; } +// _S2 DEADKEY STUFF - DO NOT REVIEW YET // _S2 DESIGN NEEDED is this the right place to get dk from? if not wher are they stored? KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable){ diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 7be581b5cf..87ae67348d 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -605,6 +605,14 @@ int replace_PosKey_with_Keycode(std::string in) { return out; } +/*KMX_DWORD find_dk_Character(v_dw_2D * p_dk_ComposeTable, KMX_DWORD first, KMX_DWORD second ) { + v_dw_2D dk_ComposeTable = * p_dk_ComposeTable; + for ( int i =0; i< (dk_ComposeTable).size()-1; i++) { + if (( (KMX_DWORD) dk_ComposeTable[i][0] == first) && ( (KMX_DWORD) dk_ComposeTable[i][1] == second) ) + return (KMX_DWORD) dk_ComposeTable[i][3]; + } + return 0; // _S2 what to return if not found? +}*/ int replace_KeyName_with_Keycode2(std::string in) { int out = returnIfCharInvalid; diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 14234db71e..132ae4804d 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -350,6 +350,7 @@ bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]){ } //------------------------------ +// _S2 DEADKEY STUFF - DO NOT REVIEW YET // _S2 ToDo deadkeys. Do we need this ? bool IsKeymanUsedKeyVal(std::wstring Keyval) { @@ -365,7 +366,7 @@ bool IsKeymanUsedKeyVal(std::wstring Keyval) { return false; } -// _S2 ToDo deadkeys. +// _S2 DEADKEY STUFF - DO NOT REVIEW YET std::wstring convert_DeadkeyValues_ToChar(int in) { KMX_DWORD lname; @@ -392,6 +393,7 @@ std::wstring convert_DeadkeyValues_ToChar(int in) { return L"\0"; } +// _S2 DEADKEY STUFF - DO NOT REVIEW YET std::u16string convert_DeadkeyValues_ToChar_16(int in) { KMX_DWORD lname; @@ -430,7 +432,7 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html -// _S2 this will return 223 instaed of 7838 for UNICODE char on DE keycode 20 ß ẞ ? ? + // this will return 223 instaed of 7838 for UNICODE char on DE keycode 20 ß ẞ ? ? if (!(shift_state_pos <= count)) return 0; diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index 6473950cdf..5953b67b27 100755 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -36,47 +36,44 @@ typedef uint16_t km_kbp_cp; // code point typedef uint32_t km_kbp_usv; // Unicode Scalar Value #endif -typedef km_kbp_cp KMX_WCHAR; // wc, 16-bit UNICODE character +// _S2 which can be removed later? +typedef unsigned int UINT; +typedef unsigned long DWORD; -typedef wchar_t WCHAR; // _S2 needs to be removed/ wchart-> char16 -typedef WCHAR KMX_WCHART; // _S2 needs to be removed/ wchart-> char16 +typedef unsigned char BYTE; +typedef char KMX_CHAR; -typedef char16_t KMX_WCHAR; // _S2 -typedef KMX_WCHAR* PKMX_WCHAR; // _S2 -typedef wchar_t* PWSTR; // _S2 needs to be removed/ wchart-> char16 +typedef char16_t KMX_WCHAR; +typedef KMX_WCHAR* PKMX_WCHAR; -typedef char* LPSTR; // _S2 needs to be removed? +typedef wchar_t WCHAR; +typedef WCHAR KMX_WCHART; +typedef wchar_t* PWSTR; +typedef WCHAR* PWCHAR; -typedef uint8_t* LPBYTE; // _S2 needs to be removed/? -typedef uint8_t* LPKMX_BYTE; // _S2 needs to be removed? +typedef uint8_t* LPKMX_BYTE; +typedef uint8_t* PKMX_BYTE; -typedef uint8_t* PBYTE; // _S2 needs to be removed/? -typedef uint8_t* PKMX_BYTE; // _S2 needs to be removed? +typedef uint32_t KMX_UINT; -typedef char KMX_CHAR; // _S2 needs to be removed/? +typedef KMX_BYTE* PKMX_BYTE; +typedef KMX_DWORD* PKMX_DWORD; +typedef int BOOL; -typedef unsigned int UINT; // _S2 needs to be removed/? -typedef unsigned char BYTE; // _S2 needs to be removed? -typedef unsigned long DWORD; // _S2 needs to be removed/? -typedef unsigned short WORD; // _S2 needs to be removed/? -typedef wchar_t* LPWSTR; // _S2 needs to be removed/? -typedef WCHAR* PWCHAR; // _S2 needs to be removed/? +//typedef uint8_t* PBYTE; +//typedef unsigned short WORD; +//typedef wchar_t* LPWSTR; +//typedef KMX_CHAR* PKMX_CHAR; +//typedef char* LPSTR; +//typedef uint8_t* LPBYTE; +//typedef KMX_WORD* PKMX_WORD; -typedef KMX_CHAR* PKMX_CHAR; // _S2 needs to be removed/? - -typedef int BOOL; // _S2 needs to be removed/? or is it int32_t?? - - // in WIN: - // PVOID A pointer to any type. - // typedef PVOID HANDLE; - // typedef HANDLE HKL; +// in WIN: +// PVOID A pointer to any type. +// typedef PVOID HANDLE; +// typedef HANDLE HKL; typedef void* KMX_HKL; // _S2 what is the equivalent to HKL and do I need it?? I assume a void* -typedef uint32_t KMX_UINT; - -typedef KMX_BYTE* PKMX_BYTE; -typedef KMX_WORD* PKMX_WORD; -typedef KMX_DWORD* PKMX_DWORD; #ifndef FALSE #define FALSE 0 @@ -128,7 +125,6 @@ typedef KMX_UCHAR* KMX_PUCHAR; #define VK_DECIMAL 0x5B*/ // _S2 correct?? ?? - #define VK_NUMPAD0 0x60 #define VK_NUMPAD1 0x61 #define VK_NUMPAD2 0x62 diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 2da2186632..69a99e81ba 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -43,6 +43,7 @@ const int KMX_ShiftStateMap[] = { 0 }; +// _S2 DEADKEY STUFF - DO NOT REVIEW YET // _S2 ToDo open deadkey functions class DeadKey { private: @@ -116,7 +117,7 @@ int KMX_DeadKeyMap(int index, std::vector *deadkeys, int deadkeyBase, class KMX_VirtualKey { private: - KMX_HKL m_hkl; // _S2 do I need this and is void* OK to assume? + KMX_HKL m_hkl; // _S2 do I need this and is void* OK to assume? If I remove this, will there be changes in Data-Vectors? UINT m_vk; UINT m_sc; bool m_rgfDeadKey[10][2]; @@ -150,11 +151,6 @@ public: return m_rgss[i][j]; } - /*// _S2 can go later - void set_sc(int i) { - this->m_sc=i; - }*/ - std::wstring KMX_GetShiftState(ShiftState shiftState, bool capsLock) { return this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)]; } @@ -241,7 +237,6 @@ public: (capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0); } - // _S2 should count OK for char AND deadkeys int KMX_GetKeyCount(int MaxShiftState) { int nkeys = 0; @@ -302,7 +297,7 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; // _S2 DESIGN NEEDED on how to replace capslock capslock=1; // _S2 - // _S2 TODO capslock is not calculated corectly for linux. therefore key->ShiftFlags will be wrong for numbers, special characters + // _S2 TODO capslock is not calculated correctly for linux. therefore key->ShiftFlags will be wrong for numbers, special characters for (int ss = 0; ss <= MaxShiftState; ss++) { if (ss == Menu || ss == ShftMenu) { @@ -411,6 +406,7 @@ public: return (ch < 0x0020) || (ch >= 0x007F && ch <= 0x009F); } +// _S2 DEADKEY STUFF - DO NOT REVIEW YET // _S2 ToDo ToUnicodeEx needs to be replaced here DeadKey *KMX_ProcessDeadKey( UINT iKeyDead, // The index into the VirtualKey of the dead key @@ -546,7 +542,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, KMX_Loader loader; - KMX_HKL hkl = NULL; //_S2 added: but can I do this?? hkl is not needed in Linux?? + KMX_HKL hkl = NULL; BYTE lpKeyState[256];// = new KeysEx[256]; std::vector rgKey; //= new VirtualKey[256]; @@ -588,7 +584,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL, keymap); /* - // _S2 RALT <-> SHIFT CTRL Problem from here?? // _S2 DESIGN NEEDED do we need special shift state now or later? // See if there is a special shift state added for(UINT vk = 0; vk <= VK_OEM_CLEAR; vk++) { @@ -613,12 +608,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, } } */ - // _S2 test rgkey can go later - /*for(UINT iKey = 100; iKey < rgKey.size(); iKey++) { - if(rgKey[iKey] != NULL) { - wprintf(L" Key Nr %i is available\n",iKey); - } - }*/ // in this part we skip shiftstates 4, 5, 8, 9 for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { @@ -655,7 +644,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, if((rc == 1) && (ss == Ctrl || ss == ShftCtrl) && (rgKey[iKey]->VK() == ((UINT)sbBuffer[0] + 0x40))) { - // _S2 RALT<-> SHIFT CTR problem from here?? // _S2 TODO is this the same behavior on Linux? // if rc ==1 : it got 1 char && +40 in Buffer CTRl pressed // It's dealing with control characters. If ToUnicodeEx gets @@ -782,11 +770,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // // Fill in the new rules // - - // _S2 [CTRL NCAPS K_?00] > use(group3) c line(0) from here ? - //if this is missing: group(group3) using keys - // + [NCAPS K_SPACE] > " " c line(0) - for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { if(rgKey[iKey]->KMX_LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 @@ -801,7 +784,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // // Add nomatch control to each terminating 'using keys' group // I4550 // - // _S2 [CTRL NCAPS K_?00] > use(group3) c line(0) from here ? LPKMX_GROUP gp2 = kp->dpGroupArray; for(UINT i = 0; i < kp->cxGroupArray - 1; i++, gp2++) { if(gp2->fUsingKeys && gp2->dpNoMatch == NULL) { @@ -916,7 +898,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, return true; } -// _S2 where is nthe best place to put this?? const int CODE__SIZE[] = { -1, // undefined 0x00 1, // CODE_ANY 0x01 diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 7d4bc51a12..fc11db76e8 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -432,7 +432,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg // evident for the 102nd key on UK, for example, where \ can be generated with VK_OEM_102 or AltGr+VK_QUOTE. // For now, we get the least shifted version, which is hopefully adequate. - // _S2 TODO first version with GTK - change later to XklGetGroupNames und XklGetCurrentState as Eberhard suggested + // _S2 TODO first version with GTK - maybe change later to XklGetGroupNames und XklGetCurrentState as Eberhard suggested //_ init gdk GdkKeymap *keymap; if(InitializeGDK(&keymap , argc, argv)) { @@ -467,7 +467,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg switch(ch) { case 0x0000: break; - case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap); break; + //case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap); break; default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); } } @@ -579,7 +579,6 @@ int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, v_dw_2D dk_SingleTable; find_dk_combinations_for_single_dk(&dk_Table, dk_SingleTable, DeadKey); -// _S2 CAPS <-> NCAPS problem from here? for ( int i=0; i< (int) dk_SingleTable.size()-1;i++) { KMX_WORD vk = KMX_changeKeynameToCapital(dk_SingleTable[i][1], shift, keymap); if(vk != 0) { diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index bba96c4041..3d6d1e08d3 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -51,18 +51,10 @@ int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, //--------------------old /* -#include void LogError(PWSTR message, ...); -struct DeadkeyMapping { // I4353 - WCHAR deadkey, dkid; - UINT shift; - WORD vk; -}; - -extern std::vector FDeadkeys; // I4353 */ #endif /*MCOMPILE_H*/ From c4d723e9fcc5abe05029f78dcbcd41ff66192ed3 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 12 Jan 2024 16:30:37 +0100 Subject: [PATCH 170/327] feat(linux): mcompile review comments --- linux/mcompile/keymap/mc_import_rules.cpp | 3 +-- linux/mcompile/keymap/mcompile.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 69a99e81ba..02da7969a0 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -406,7 +406,7 @@ public: return (ch < 0x0020) || (ch >= 0x007F && ch <= 0x009F); } -// _S2 DEADKEY STUFF - DO NOT REVIEW YET + // _S2 DEADKEY STUFF - DO NOT REVIEW YET // _S2 ToDo ToUnicodeEx needs to be replaced here DeadKey *KMX_ProcessDeadKey( UINT iKeyDead, // The index into the VirtualKey of the dead key @@ -622,7 +622,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, //_S2 to compare win-lin kmn-files skip ss6+7; MUST BE restored/removed later!!!! if(ss == MenuCtrl|| ss == ShftMenuCtrl) { - // Alt and Shift+Alt don't work, so skip them continue; } diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 3d6d1e08d3..a2fe8cfa13 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -44,7 +44,6 @@ UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey); -// _S2 this is used in code for deadkeys and should be removed later KMX_WCHAR KMX_get_KVUS_From_KVUnderlying_VEC(v_dw_3D All_Vector,KMX_DWORD SC_US); int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap); From f43ca566a69e39cb4211168cd95ff263c18c3dfa Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 12 Jan 2024 16:30:37 +0100 Subject: [PATCH 171/327] feat(linux): mcompile disable comments --- linux/mcompile/keymap/keymap.cpp | 15 ++++-------- linux/mcompile/keymap/mc_import_rules.cpp | 6 ++--- linux/mcompile/keymap/mc_kmxfile.cpp | 2 -- linux/mcompile/keymap/mcompile.cpp | 29 +++++++++++------------ 4 files changed, 22 insertions(+), 30 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 132ae4804d..f6ccc580ee 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -104,8 +104,8 @@ int write_US_ToVector( v_dw_3D &vec,std::string language, const char* text) { if( split_US_To_3D_Vector( vec,Vector_completeUS)) { return 1; } - wprintf(L"\n ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - wprintf(L" +++++++ dimensions of Vector after split_US_To_3D_Vector (languages..characters..shiftstates)\t %li..%li..%li\n", vec.size(), vec[0].size(),vec[0][0].size()); + //wprintf(L"\n ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + //wprintf(L" +++++++ dimensions of Vector after split_US_To_3D_Vector (languages..characters..shiftstates)\t %li..%li..%li\n", vec.size(), vec[0].size(),vec[0][0].size()); fclose(fp); return 0; @@ -121,10 +121,6 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, s const char* key = "key <"; std::string str_txt(text); std::string xbk_mark = "xkb_symbol"; - // _S2 TODO define folder to store File in - std::ofstream KeyboardFile("File_" + language + ".txt"); - - KeyboardFile << "Keyboard" << text << "\n"; if (fp) { while (fgets(buffer, buffer_size, fp) != NULL) { @@ -141,7 +137,6 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, s // as long as we are in the same xkb_symbol layout block and find "key <" we push the whole line into a 1D-vector if ((print_OK) && (std::string(str_buf).find(key) != std::string::npos)) { complete_List.push_back(buffer); - KeyboardFile << buffer; } } } @@ -306,8 +301,8 @@ int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { return 1; } All_Vector.push_back(Other_Vector2D); - wprintf(L" +++++++ dimensions of Vector after append_other_ToVector\t\t\t\t\t\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); - wprintf(L" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n"); + //wprintf(L" +++++++ dimensions of Vector after append_other_ToVector\t\t\t\t\t\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); + //wprintf(L" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n"); if (All_Vector.size() < 2) { wprintf(L"ERROR: creation of 3D-Vector failed\n"); @@ -443,7 +438,7 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap out =(KMX_DWORD) keyvals[shift_state_pos]; if ( (out >= deadkey_min) && (out <= deadkey_max) ) { - wprintf(L"out of range: found deadkey value out( %i) for keycode = %i /shift_state_pos %i (49= TLDE 21= VK_EQUALS on US keyboard) \n", out,keycode,shift_state_pos); + //wprintf(L"out of range: found deadkey value out( %i) for keycode = %i /shift_state_pos %i (49= TLDE 21= VK_EQUALS on US keyboard) \n", out,keycode,shift_state_pos); } // _S2 g_free used everywhere? g_free(keyvals); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 02da7969a0..4533baba9f 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -694,7 +694,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, } //_S2 this gan co later - std::vector< int > TestValues = {40,44,48,49,50,51,52,53,54,55,56,57,65,66,67,88,89,90, 186,187,188,189,191,191,192,219,220,221,222,226}; + /*std::vector< int > TestValues = {40,44,48,49,50,51,52,53,54,55,56,57,65,66,67,88,89,90, 186,187,188,189,191,191,192,219,220,221,222,226}; wprintf(L"-----------------\nNow some tests:\n"); wprintf(L" Base Caps Shift Shfit+Caps MenuCtrl MenuCtrl+Caps \n"); @@ -711,7 +711,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, rgKey[TestValues[i]]->get_m_rgss(7,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(7,1)[0] ); } - wprintf(L"-----------------\n"); + wprintf(L"-----------------\n");*/ //------------------------------------------------------------- // Now that we've collected the key data, we need to @@ -773,7 +773,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { if(rgKey[iKey]->KMX_LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); - wprintf(L" iKey = %i, Delta: %i -> Sum %i\n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()), nKeys); + // wprintf(L" iKey = %i, Delta: %i -> Sum %i\n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()), nKeys); } } } diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 991bfc2dae..499cb4089e 100755 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -362,8 +362,6 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { LPKMX_KEYBOARD kbp; PKMX_BYTE filebase; - wprintf(L" Loading file '%ls'\n", u16fmt((const char16_t*) fileName).c_str()); - if(!fileName || !lpKeyboard) { KMX_LogError(L"LogError1: Bad Filename\n" ); return FALSE; diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index fc11db76e8..8a95b1c576 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -68,28 +68,27 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ argv.push_back(cmdl_par); } - if(argc < 3 || (argc < 5 && u16cmp(argv[1], u"-u") != 0)) { // I4273// I4273 + if(argc < 3 || (argc > 4)) { // I4273// I4273 wprintf( - L"Usage: mcompile -u infile.kmx outfile.kmx\n (not available for Linux)" - L" mcompile [-d] infile.kmx kbdfile.dll kbid outfile.kmx\n" - L" With -u parameter, converts keyboard from ANSI to Unicode\n" - L" Otherwise, mcompile converts a Keyman mnemonic layout to a\n" - L" positional one based on the Windows keyboard\n" - L" layout file given by kbdfile.dll\n\n" - L" kbid should be a hexadecimal number e.g. 409 for US English\n" - L" -d convert deadkeys to plain keys\n"); // I4552 + L"Usage: mcompile [-d] infile.kmx outfile.kmx\n" + L" mmcompile -u ... (not available for Linux)\n " + L" mcompile converts a Keyman mnemonic layout to a\n" + L" positional one based on the Linux keyboard\n" + L" layout on top position\n" + L" (-d convert deadkeys to plain keys) not available yet \n\n" + + ); // I4552 return 1; } - // -u option was removed for Linux int bDeadkeyConversion = u16cmp(argv[1], u"-d") == 0; // I4552 int n = (bDeadkeyConversion ? 2 : 1); - char16_t* infile = (char16_t*) argv[n], *indll = (char16_t*) argv[n+1], *kbid = (char16_t*) argv[n+2], *outfile = (char16_t*) argv[n+3]; + char16_t* infile = (char16_t*) argv[n], *outfile = (char16_t*) argv[n+1]; - wprintf(L"mcompile%ls \"%ls\" \"%ls\" \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d" : L"", u16fmt((const char16_t*) infile).c_str(), u16fmt((const char16_t*) indll).c_str(), u16fmt((const char16_t*) kbid).c_str(), u16fmt((const char16_t*) outfile).c_str() ); // I4174 + wprintf(L"mcompile%ls \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d" : L"", u16fmt((const char16_t*) infile).c_str(), u16fmt((const char16_t*) outfile).c_str() ); // I4174 // 1. Load the keyman keyboard file @@ -139,7 +138,8 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ //DeleteReallocatedPointers(kmxfile); :TODO // _S2 not my ToDo :-) delete kmxfile; - wprintf(L"\nmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm end\n"); + //wprintf(L"\nmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm end\n"); + wprintf(L"\n"); return 0; } @@ -448,7 +448,6 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg } for (int j = 0; VKShiftState[j] != 0xFFFF; j++) { // I4651 - wprintf(L"\n"); // Loop through each possible key on the keyboard for (int i = 0;KMX_VKMap[i]; i++) { // I4651 @@ -467,7 +466,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg switch(ch) { case 0x0000: break; - //case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap); break; + case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap); break; default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); } } From 3f2109b3405183e6e8fc77c50becbfc9bd75b653 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 12 Jan 2024 16:30:37 +0100 Subject: [PATCH 172/327] feat(linux): mcompile disable comments --- linux/.gitignore | 6 ------ 1 file changed, 6 deletions(-) diff --git a/linux/.gitignore b/linux/.gitignore index 4d72bb16f4..82efe998cf 100644 --- a/linux/.gitignore +++ b/linux/.gitignore @@ -39,9 +39,3 @@ help/reference/ # Debian watch file - we generate it from watch.in watch -#sabine -*.kmn -*.kmx -*.kvk -*.bak -*.txt From f589087dff88f532d0d529fec8f214aeda244300 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 16 Jan 2024 11:05:20 +0100 Subject: [PATCH 173/327] feat(linux): mcompile-deadkeys start --- linux/mcompile/keymap/keymap.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index f6ccc580ee..79cd47c7b7 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -318,6 +318,7 @@ int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { All_Vector[1][i][0+1] = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,All_Vector[0][i][0],0); //shift state: unshifted:0 All_Vector[1][i][1+1] = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,All_Vector[0][i][0],1); //shift state: shifted:1 + //wprintf(L" Keycodes US dw : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); //wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); } From 5769bf04f8aa425739d1e6abc26b6f1dbd763ad3 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 18 Jan 2024 12:01:30 +0100 Subject: [PATCH 174/327] feat(linux): mcompile-deadkeys KMX_get_CharUnderlying_From_SCUnderlying_GDK/if(bDeadkeyConversion) --- .gitignore | 4 + linux/mcompile/keymap/helpers.cpp | 17 +++ linux/mcompile/keymap/keymap.cpp | 172 +++++++++++++++++++--- linux/mcompile/keymap/keymap.h | 10 +- linux/mcompile/keymap/mc_import_rules.cpp | 4 +- linux/mcompile/keymap/mcompile.cpp | 17 ++- linux/mcompile/keymap/mcompile.h | 2 +- 7 files changed, 192 insertions(+), 34 deletions(-) diff --git a/.gitignore b/.gitignore index 66f87cce1a..6b9eb20370 100644 --- a/.gitignore +++ b/.gitignore @@ -200,3 +200,7 @@ lcov.info # /developer/src/test/auto/kmcomp/*.txt /linux/mcompile/keymap/X_bak /linux/mcompile/keymap/anii.* + +/linux/mcompile/keymap/*.kmx + + diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 87ae67348d..0eba0c6542 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -299,6 +299,23 @@ bool CompareVector_To_VectorOfFile(v_dw_3D All_Vector,v_dw_3D File_Vector){ return true; } +/*// takes SC of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] +KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, PKMX_WCHAR DeadKey) { + + PKMX_WCHAR dky; + int VKShiftState_lin = map_VKShiftState_to_Lin(VKShiftState); + KMX_DWORD KeyvalOther = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,SC_OTHER, VKShiftState_lin, dky); + + if (KeyvalOther >= deadkey_min) { + /// std::string ws((const char*) gdk_keyval_name (KeyvalOther)); + // *DeadKey = convertNamesToIntegerValue( wstring_from_string(ws)); + +*DeadKey=*dky; +return 0xFFFF; + } + return (KMX_WCHAR) KeyvalOther; +}*/ + bool CompareVector_To_VectorOfFile_RGKEY(v_dw_2D Win_Vector,v_dw_2D Lin_Vector, v_dw_2D Map_Vector){ wprintf(L" #### CompareVector_To_VectorOfFile started: "); wprintf(L" #### dimensions: %i %i -- %i %i \n", Win_Vector.size() ,Win_Vector[0].size(), Lin_Vector.size() ,Lin_Vector[0].size()); diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 79cd47c7b7..380727eb8b 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -64,13 +64,12 @@ KMX_DWORD convertNamesToIntegerValue(std::wstring tok_wstr){ first[L"dead_perispomeni"] = 126; first[L"dead_tilde"] = 126; - first[L"acute accent"] = 0xB4; //first[L" ?? "] = VK_OEM_102; /* DE = 226 ' " ? VK_OEM_102 */ if ( tok_wstr.size() == 1) { - return (KMX_DWORD) ( *tok_wstr.c_str() );; + return (KMX_DWORD) ( *tok_wstr.c_str() ); } else { std::map ::iterator it; @@ -357,7 +356,21 @@ bool IsKeymanUsedKeyVal(std::wstring Keyval) { (KV >= 199 && KV < 208) || (KV >= 209 && KV < 216) || (KV >= 217 && KV < 229) || (KV >= 231 && KV < 240) || (KV >= 241 && KV < 248) || (KV >= 249 && KV < 0xFF) || (KV == 128) || (KV == 178) || (KV == 167) || (KV == 179) || (KV == 176)|| (KV == 181) ) - return true; + return true; + else + return false; +} + +bool IsKeymanUsedKeyVal(std::u16string Keyval) { + + int KV = (int) (*Keyval.c_str()); + + // 32 127 196 256 + if ((KV >= 0x20 && KV <= 0x7F) || (KV >= 0x20 && KV <= 0x7F) || (KV >= 0xC4 && KV < 198) || + (KV >= 199 && KV < 208) || (KV >= 209 && KV < 216) || (KV >= 217 && KV < 229) || + (KV >= 231 && KV < 240) || (KV >= 241 && KV < 248) || (KV >= 249 && KV < 0xFF) || + (KV == 128) || (KV == 178) || (KV == 167) || (KV == 179) || (KV == 176)|| (KV == 181) ) + return true; else return false; } @@ -389,23 +402,25 @@ std::wstring convert_DeadkeyValues_ToChar(int in) { return L"\0"; } -// _S2 DEADKEY STUFF - DO NOT REVIEW YET -std::u16string convert_DeadkeyValues_ToChar_16(int in) { +std::u16string convert_DeadkeyValues_To_U16str(int in) { KMX_DWORD lname; - if (in <= (int) deadkey_min) { // no deadkey; no Unicode - if (!IsKeymanUsedKeyVal(std::wstring(1, in))) + // it`s not a deadkey + if (in <= (int) deadkey_min) { // no deadkey; no Unicode 97 => a + if (!IsKeymanUsedKeyVal(std::u16string(1, in))) return u"\0"; return std::u16string(1, in); } else { std::string long_name((const char*) gdk_keyval_name (in)); - if ( long_name.substr (0,2) == "U+" ) // U+... Unicode value + // it's Unicode + if ( long_name.substr (0,2) == "U+" ) // U+... Unicode value U+1E9E => ẞ return CodePointToString_16(in-0x1000000); - lname = convertNamesToIntegerValue( wstring_from_string(long_name)); // 65106 => "dead_circumflex " => 94 => "^" + // it's a descriptive name like "dead_circumflex" + lname = convertNamesToIntegerValue( wstring_from_string(long_name)); // "dead_circumflex" => 94 => "^" if (lname != returnIfCharInvalid) { return std::u16string(1, lname ); @@ -428,19 +443,15 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html - // this will return 223 instaed of 7838 for UNICODE char on DE keycode 20 ß ẞ ? ? - if (!(shift_state_pos <= count)) + return 0; + + if (!(keycode <= 94)) return 0; - if (!(keycode <= 94)) - return 0; + KMX_DWORD deadkey =(KMX_DWORD) keyvals[shift_state_pos]; + out = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); - out =(KMX_DWORD) keyvals[shift_state_pos]; - - if ( (out >= deadkey_min) && (out <= deadkey_max) ) { - //wprintf(L"out of range: found deadkey value out( %i) for keycode = %i /shift_state_pos %i (49= TLDE 21= VK_EQUALS on US keyboard) \n", out,keycode,shift_state_pos); - } // _S2 g_free used everywhere? g_free(keyvals); g_free(maps); @@ -448,6 +459,103 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap return out; } +// _S2 use gdk_keymap_translate_keyboard_state instead return s shifted + unshifted only- no altgr,... +KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky) { + GdkKeymapKey *maps; + guint *keyvals; + gint count; + KMX_DWORD out; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return 0; + //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html + + if (!(shift_state_pos <= count)) + return 0; + + if (!(keycode <= 94)) + return 0; + + KMX_DWORD deadkey = (KMX_DWORD) keyvals[shift_state_pos]; + dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str(); + out = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); + + // _S2 g_free used everywhere? + g_free(keyvals); + g_free(maps); + + return out; +} + +// _S2 ToDo use only one of those +KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ + + GdkModifierType consumed; + GdkKeymapKey *maps; + guint *keyvals; + gint count; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return 0; + + //BASE (shiftstate: 0) + if (( ss == Base ) && ( caps == 0 )) { + GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); + } + + //BASE + CAPS (shiftstate: 0) + else if (( ss == Base ) && ( caps == 1 )) { + GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); + } + + //SHIFT (shiftstate: 1) + else if (( ss == Shft ) && ( caps == 0 )) { + GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + std::wstring rV1= std::wstring(1, (int) *keyvals); + } + + //SHIFT+CAPS (shiftstate: 1) + else if ( ( ss == Shft ) && ( caps ==1 )) { + GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR (shiftstate: 6) + else if (( ss == MenuCtrl ) && ( caps == 0 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR +CAPS (shiftstate: 6) + else if (( ss == MenuCtrl ) && ( caps == 1 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR (shiftstate: 7) + else if (( ss == ShftMenuCtrl ) && ( caps == 0 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR +CAPS (shiftstate: 7) + else if (( ss == ShftMenuCtrl ) && ( caps == 1 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + else + return 0; + + if((*keyvals >= deadkey_min)) + return 0xFFFF; + else + return (KMX_DWORD) *keyvals; +} + std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ GdkModifierType consumed; @@ -483,8 +591,20 @@ std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(Gdk gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); } + /* // Ctrl (shiftstate: 2) - // SHIFT+Ctrl (shiftstate: 2) + else if (( ss == Ctrl ) && ( caps == 0 )){ + GdkModifierType MOD_Ctrl = (GdkModifierType) ( GDK_MOD2_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl , 0, keyvals, NULL, NULL, & consumed); + } + + // Ctrl (shiftstate: 2) + else if (( ss == Ctrl ) && ( caps == 1 )){ + GdkModifierType MOD_CtrlCaps = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_LOCK_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps , 0, keyvals, NULL, NULL, & consumed); + } + // SHIFT+Ctrl (shiftstate: 3) + */ //ALT-GR (shiftstate: 6) else if (( ss == MenuCtrl ) && ( caps == 0 )){ @@ -554,8 +674,18 @@ std::u16string KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_1 gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); } + /*// Ctrl (shiftstate: 2) + else if (( ss == Ctrl ) && ( caps == 0 )){ + GdkModifierType MOD_Ctrl = (GdkModifierType) ( GDK_MOD2_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl , 0, keyvals, NULL, NULL, & consumed); + } + // Ctrl (shiftstate: 2) - // SHIFT+Ctrl (shiftstate: 2) + else if (( ss == Ctrl ) && ( caps == 1 )){ + GdkModifierType MOD_CtrlCaps = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_LOCK_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps , 0, keyvals, NULL, NULL, & consumed); + } + // SHIFT+Ctrl (shiftstate: 3)*/ //ALT-GR (shiftstate: 6) else if (( ss == MenuCtrl ) && ( caps == 0 )){ @@ -586,7 +716,7 @@ std::u16string KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_1 //if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max) ) if((*keyvals >= deadkey_min) ) - return convert_DeadkeyValues_ToChar_16((int) *keyvals); + return convert_DeadkeyValues_To_U16str((int) *keyvals); else return std::u16string(1, (int) *keyvals); } diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 803b2689d3..55c4a130bf 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -502,19 +502,23 @@ const UINT ScanCodeToUSVirtualKey[128] = { }; bool IsKeymanUsedKeyVal(std::wstring Keyval); +bool IsKeymanUsedKeyVal(std::u16string Keyval); // take deadkey-value (e.g.65106) and return wstring (e.g. '^' ) std::wstring convert_DeadkeyValues_ToChar(int in); // take deadkey-value (e.g.65106) and return u16string (e.g. '^' ) -std::u16string convert_DeadkeyValues_ToChar_16(int in); +std::u16string convert_DeadkeyValues_To_U16str(int in); // find Keyvals to fill into 2D-Vector of Other Language KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos); +KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky); -// returns KeySyms fo ra given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) +// returns KeySyms for a given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); -// returns KeySyms fo ra given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) +// returns KeySyms for a given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) std::u16string KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_16(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); +// returns KeySyms for a given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) +KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); // return the VirtualKey of the Other Keyboard for given Scancode using GDK KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD scanCode); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 4533baba9f..c6faa51c42 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -619,11 +619,11 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // Alt and Shift+Alt don't work, so skip them continue; } - +/* //_S2 to compare win-lin kmn-files skip ss6+7; MUST BE restored/removed later!!!! if(ss == MenuCtrl|| ss == ShftMenuCtrl) { continue; - } + }*/ KMX_DWORD SC_US = KMX_get_KeyCodeUnderlying_From_VKUS(iKey); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 8a95b1c576..ea43bf5f59 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -205,10 +205,10 @@ void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_ void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key) { if(key->ShiftFlags == 0) { //KMX_LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); - wprintf(L" _S2 Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); + //wprintf(L" _S2 Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); } else if(key->ShiftFlags & VIRTUALCHARKEY) { //KMX_LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); - wprintf(L"_S2 Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); + //wprintf(L"_S2 Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); } } @@ -464,6 +464,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg } } +wprintf(L" scunderlying: SS: %i Nr: %i VKMap[i] %i ch:%i (%c) \n", VKShiftState[j],i, KMX_VKMap[i],ch,ch ); switch(ch) { case 0x0000: break; case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap); break; @@ -539,17 +540,19 @@ KMX_DWORD KMX_get_SCUnderlying_From_SCUS_VEC(v_dw_3D &All_Vector, KMX_DWORD KC_U } return KC_US; } -// takes SC of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] -KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey) { +// takes SC of underlying keyboard and returns character of underlying keyboard with shiftstate VKShiftState[j] or deadkey +KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, PKMX_WCHAR DeadKey) { + + PKMX_WCHAR dky; int VKShiftState_lin = map_VKShiftState_to_Lin(VKShiftState); - KMX_DWORD KeyvalOther = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,SC_OTHER, VKShiftState_lin); + KMX_DWORD KeyvalOther = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,SC_OTHER, VKShiftState_lin, dky); if (KeyvalOther >= deadkey_min) { - std::string ws((const char*) gdk_keyval_name (KeyvalOther)); - *DeadKey = convertNamesToIntegerValue( wstring_from_string(ws)); + *DeadKey = *dky; return 0xFFFF; } + return (KMX_WCHAR) KeyvalOther; } diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index a2fe8cfa13..bfdbbc5488 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -42,7 +42,7 @@ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); -KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, KMX_WCHAR* DeadKey); +KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, PKMX_WCHAR DeadKey); KMX_WCHAR KMX_get_KVUS_From_KVUnderlying_VEC(v_dw_3D All_Vector,KMX_DWORD SC_US); From 33c63fb72afa992a23d7e2ef356b00a0791e06b9 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 19 Jan 2024 19:29:50 +0100 Subject: [PATCH 175/327] feat(linux): mcompile-loader.KMX_ProcessDeadKey --- linux/mcompile/keymap/keymap.cpp | 53 ++++++--- linux/mcompile/keymap/mc_import_rules.cpp | 128 ++++++++++++++++------ linux/mcompile/keymap/mcompile.cpp | 111 +++++++++++++++++-- linux/mcompile/keymap/mcompile.h | 3 +- 4 files changed, 235 insertions(+), 60 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 380727eb8b..53f6ceac8b 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -369,7 +369,8 @@ bool IsKeymanUsedKeyVal(std::u16string Keyval) { if ((KV >= 0x20 && KV <= 0x7F) || (KV >= 0x20 && KV <= 0x7F) || (KV >= 0xC4 && KV < 198) || (KV >= 199 && KV < 208) || (KV >= 209 && KV < 216) || (KV >= 217 && KV < 229) || (KV >= 231 && KV < 240) || (KV >= 241 && KV < 248) || (KV >= 249 && KV < 0xFF) || - (KV == 128) || (KV == 178) || (KV == 167) || (KV == 179) || (KV == 176)|| (KV == 181) ) + (KV == 128) || (KV == 178) || (KV == 167) || (KV == 179) || (KV == 176)|| (KV == 181)|| + (KV >= deadkey_min && KV < deadkey_max+1) ) return true; else return false; @@ -407,9 +408,9 @@ std::u16string convert_DeadkeyValues_To_U16str(int in) { KMX_DWORD lname; // it`s not a deadkey - if (in <= (int) deadkey_min) { // no deadkey; no Unicode 97 => a - if (!IsKeymanUsedKeyVal(std::u16string(1, in))) - return u"\0"; + if (in < (int) deadkey_min) { // no deadkey; no Unicode 97 => a + /*if (!IsKeymanUsedKeyVal(std::u16string(1, in))) + return u"\0";*/ return std::u16string(1, in); } else { @@ -449,7 +450,7 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap if (!(keycode <= 94)) return 0; - KMX_DWORD deadkey =(KMX_DWORD) keyvals[shift_state_pos]; + KMX_DWORD deadkey =(KMX_DWORD) keyvals[shift_state_pos]; //_S2 do I need this? no out = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); // _S2 g_free used everywhere? @@ -478,6 +479,8 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap return 0; KMX_DWORD deadkey = (KMX_DWORD) keyvals[shift_state_pos]; + //wprintf(L" keyvals[shift_state_pos]: %i %i %i %i----", keyvals[0],keyvals[1],keyvals[2],keyvals[3]); + dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str(); out = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); @@ -515,7 +518,6 @@ KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(Gdk else if (( ss == Shft ) && ( caps == 0 )) { GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); - std::wstring rV1= std::wstring(1, (int) *keyvals); } //SHIFT+CAPS (shiftstate: 1) @@ -524,15 +526,40 @@ KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(Gdk gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); } + // Ctrl (shiftstate: 2) + else if (( ss == Ctrl ) && ( caps == 0 )){ + GdkModifierType MOD_Ctrl = (GdkModifierType) ( GDK_MOD5_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl , 0, keyvals, NULL, NULL, & consumed); + } + + // Ctrl (shiftstate: 2) + else if (( ss == Ctrl ) && ( caps == 1 )){ + GdkModifierType MOD_CtrlCaps = (GdkModifierType) (GDK_MOD5_MASK | GDK_LOCK_MASK); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps , 0, keyvals, NULL, NULL, & consumed); + } + + + // SHIFT+Ctrl (shiftstate: 3) + else if (( ss == ShftCtrl ) && ( caps == 0 )){ + GdkModifierType MOD_Ctrl = (GdkModifierType) (GDK_SHIFT_MASK | GDK_MOD5_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl , 0, keyvals, NULL, NULL, & consumed); + } + + // SHIFT+Ctrl (shiftstate: 3) + else if (( ss == ShftCtrl ) && ( caps == 1 )){ + GdkModifierType MOD_CtrlCaps = (GdkModifierType) ( GDK_SHIFT_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps , 0, keyvals, NULL, NULL, & consumed); + } + //ALT-GR (shiftstate: 6) else if (( ss == MenuCtrl ) && ( caps == 0 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK) ); + GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); } //ALT-GR +CAPS (shiftstate: 6) else if (( ss == MenuCtrl ) && ( caps == 1 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); + GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); } @@ -550,7 +577,7 @@ KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(Gdk else return 0; - if((*keyvals >= deadkey_min)) + if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max)) return 0xFFFF; else return (KMX_DWORD) *keyvals; @@ -608,13 +635,13 @@ std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(Gdk //ALT-GR (shiftstate: 6) else if (( ss == MenuCtrl ) && ( caps == 0 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK) ); + GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); } //ALT-GR +CAPS (shiftstate: 6) else if (( ss == MenuCtrl ) && ( caps == 1 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); + GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); } @@ -689,13 +716,13 @@ std::u16string KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_1 //ALT-GR (shiftstate: 6) else if (( ss == MenuCtrl ) && ( caps == 0 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK) ); + GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); } //ALT-GR +CAPS (shiftstate: 6) else if (( ss == MenuCtrl ) && ( caps == 1 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); + GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); } diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index c6faa51c42..2f20fc41ce 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -28,8 +28,6 @@ #include "keymap.h" -int KMX_ToUnicodeEx(guint ScanCode, const BYTE *lpKeyState, PWCHAR pwszBuff, int shift_state, int caps,GdkKeymap *keymap); - const int KMX_ShiftStateMap[] = { ISVIRTUALKEY, ISVIRTUALKEY | K_SHIFTFLAG, @@ -99,6 +97,20 @@ public: } }; +int KMX_ToUnicodeEx(guint ScanCode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, int shift_state, int caps,GdkKeymap *keymap) { + + KMX_DWORD kvl= KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap, ScanCode, shift_state); + //if((kvl >= deadkey_min) && (kvl <= deadkey_max)) + + + std::wstring character = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, ScanCode, ShiftState(shift_state), caps); + std::u16string uuu16= u16string_from_wstring(character).c_str(); + pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(character).c_str(); + + if((kvl == 0xFFFF)) + return -1; + return 1; +} int KMX_DeadKeyMap(int index, std::vector *deadkeys, int deadkeyBase, std::vector *deadkeyMappings) { // I4327 // I4353 for(size_t i = 0; i < deadkeyMappings->size(); i++) { @@ -317,7 +329,7 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; key->dpContext = new KMX_WCHAR[1]; *key->dpContext = 0; key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); - //key->Key = KMX_get_KVUS_From_KVUnderlying_VEC(All_Vector,this->VK()); + //key->Key = KMX_get_VKUS_From_VKUnderlying_VEC(All_Vector,this->VK()); // key->Key = KMX_get_VKUnderlying_From_VKUS_GDK(keymap,this->VK()); key->Line = 0; @@ -384,7 +396,7 @@ public: m_XxxxVk = value; } - ShiftState MaxShiftState() { + ShiftState KMX_MaxShiftState() { return (Get_XxxxVk() == 0 ? ShftMenuCtrl : ShftXxxx); } @@ -411,19 +423,41 @@ public: DeadKey *KMX_ProcessDeadKey( UINT iKeyDead, // The index into the VirtualKey of the dead key ShiftState shiftStateDead, // The shiftstate that contains the dead key - BYTE *lpKeyStateDead, // The key state for the dead key + KMX_BYTE *lpKeyStateDead, // The key state for the dead key std::vector rgKey, // Our array of dead keys bool fCapsLock, // Was the caps lock key pressed? - KMX_HKL KMX_hkl) { // The keyboard layout + KMX_HKL KMX_hkl, // The keyboard layout + GdkKeymap *keymap) { // _S2 keymap, The keyboard layout - BYTE lpKeyState[256]; + + KMX_BYTE lpKeyState[256]; DeadKey *deadKey = new DeadKey(rgKey[iKeyDead]->KMX_GetShiftState(shiftStateDead, fCapsLock)[0]); +KMX_WCHAR sbBuffer1[16]; + KMX_WCHAR sbBuffer2[16]; + KMX_WCHAR sbBuffer3[16]; + KMX_WCHAR sbBuffer4[16]; + KMX_WCHAR sbBuffer5[16]; + int rc1 = KMX_ToUnicodeEx(49, lpKeyState, sbBuffer1, 0, 0, keymap) ; + int rc4 = KMX_ToUnicodeEx(21, lpKeyState, sbBuffer4, 0, 0, keymap) ; + int rc3 = KMX_ToUnicodeEx( 3, lpKeyState, sbBuffer3, 0, 0, keymap) ; + /*int rc2 = KMX_ToUnicodeEx( 49, lpKeyState, sbBuffer2, 0, 0, keymap) ; + int rc5 = KMX_ToUnicodeEx( 65, lpKeyState, sbBuffer5, 0, 0, keymap) ;*/ + + /*int rc1 = KMX_ToUnicodeEx(192, lpKeyState, sbBuffer1, 0, 0, keymap) ; + int rc4 = KMX_ToUnicodeEx(220, lpKeyState, sbBuffer4, 0, 0, keymap) ; + int rc3 = KMX_ToUnicodeEx( 3, lpKeyState, sbBuffer3, 0, 0, keymap) ; + int rc2 = KMX_ToUnicodeEx( 49, lpKeyState, sbBuffer2, 0, 0, keymap) ; + int rc5 = KMX_ToUnicodeEx( 65, lpKeyState, sbBuffer5, 0, 0, keymap) ;*/ + + + + for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if (rgKey[iKey] != NULL) { - WCHAR sbBuffer[16]; + KMX_WCHAR sbBuffer[16]; - for (ShiftState ss = Base; ss <= MaxShiftState(); ss = (ShiftState)((int)ss+1)) { + for (ShiftState ss = Base; ss <= KMX_MaxShiftState(); ss = (ShiftState)((int)ss+1)) { int rc = 0; if (ss == Menu || ss == ShftMenu) { // Alt and Shift+Alt don't work, so skip them @@ -431,6 +465,10 @@ public: } for (int caps = 0; caps <= 1; caps++) { + + //------_S2 To find a deadkey in a possibly messed up key ------------------------ + // _S2 My fun does not loop to shorten keys :-(( + // First the dead key while (rc >= 0) { // We know that this is a dead key coming up, otherwise @@ -442,25 +480,44 @@ public: // _S2 needs replacement // rc = ToUnicodeEx(rgKey[iKeyDead]->VK(), rgKey[iKeyDead]->SC(), lpKeyStateDead, sbBuffer, _countof(sbBuffer), 0, hkl); - rc=-1; //_S2 + //rc = KMX_ToUnicodeEx(rgKey[iKeyDead]->VK(), rgKey[iKeyDead]->SC(), lpKeyStateDead, sbBuffer, _countof(sbBuffer), 0, hkl); + + rc = KMX_ToUnicodeEx(rgKey[iKeyDead]->SC(), lpKeyState, sbBuffer, ss, caps, keymap); + //wprintf(L"ikey: %i rc = %i\n",iKey,rc); + rc=-1; //_S2 } + //---------------------------------------------------------------------------------- + // Now fill the key state for the potential base character KMX_FillKeyState(lpKeyState, ss, (caps != 0)); + //---------------------------------------------------------------------------------- + // _S2 needs replacement //rc = ToUnicodeEx(rgKey[iKey]->VK(), rgKey[iKey]->SC(), lpKeyState, sbBuffer, _countof(sbBuffer), 0, hkl); + rc = KMX_ToUnicodeEx( rgKey[iKey]->SC(), lpKeyState, sbBuffer, ss, caps, keymap) ; + + + //--------- ONE character found = combined char (e.g. â ) -------------------------- + // ***** E.G: ToUnicodeEx FOUND  ***** // + if (rc == 1) { - // That was indeed a base character for our dead key. + /*  */ // That was indeed a base character for our dead key. // And we now have a composite character. Let's run // through one more time to get the actual base + // character that made it all possible? - WCHAR combchar = sbBuffer[0]; - // _S2 needs replacement - //rc = ToUnicodeEx(rgKey[iKey]->VK(), rgKey[iKey]->SC(), lpKeyState, sbBuffer, _countof(sbBuffer), 0, hkl); + // _s2 store combined char + // ***** E.G: combchar =  ***** // + KMX_WCHAR combchar = sbBuffer[0]; - WCHAR basechar = sbBuffer[0]; + // _S2 again split to get base char ( e.g. a) + // ***** E.G: ToUnicodeEx FOUND A ***** // + /* A */ rc = KMX_ToUnicodeEx(rgKey[iKey]->SC(), lpKeyState, sbBuffer, ss, caps, keymap) ; + + KMX_WCHAR basechar = sbBuffer[0]; if (deadKey->KMX_DeadCharacter() == combchar) { // Since the combined character is the same as the dead key, @@ -490,9 +547,16 @@ public: if (!deadKey->KMX_ContainsBaseCharacter(basechar)) { deadKey->KMX_AddDeadKeyRow(basechar, combchar); } - } else if (rc > 1) { + } + + //---------no valid key combi -> IGNORE --------------------------------------------- + + else if (rc > 1) { // Not a valid dead key combination, sorry! We just ignore it. - } else if (rc < 0) { + } + + //---------another dead key-> IGNORE ----------------------------------------------- + else if (rc < 0) { // It's another dead key, so we ignore it (other than to flush it from the state) //ClearKeyboardBuffer(VK_DECIMAL, rgKey[VK_DECIMAL]->SC(), KMX_hkl); KMX_ClearKeyboardBuffer(); @@ -527,17 +591,6 @@ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { return n; } -int KMX_ToUnicodeEx(guint ScanCode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, int shift_state, int caps,GdkKeymap *keymap) { - - KMX_DWORD kvl= KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap, ScanCode, shift_state); - if((kvl >= deadkey_min) && (kvl <= deadkey_max)) - return -1; - - std::wstring character = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, ScanCode, ShiftState(shift_state), caps); - pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(character).c_str(); - return 1; -} - bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 KMX_Loader loader; @@ -614,7 +667,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, if(rgKey[iKey] != NULL) { KMX_WCHAR sbBuffer[256]; // Scratchpad we use many places - for(ShiftState ss = Base; ss <= loader.MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { + for(ShiftState ss = Base; ss <= loader.KMX_MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { if(ss == Menu || ss == ShftMenu) { // Alt and Shift+Alt don't work, so skip them continue; @@ -632,7 +685,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // _S2 is THIS correct ??? Do we need lpKeyState or is it just used in ToUnicodeEx?? loader.KMX_ClearKeyboardBuffer(); loader.KMX_FillKeyState(lpKeyState, ss, (caps == 0)); - int rc = KMX_ToUnicodeEx(SC_US, lpKeyState, sbBuffer, ss, caps, *keymap) ; + int rc = KMX_ToUnicodeEx(SC_US, lpKeyState, sbBuffer, ss, caps, *keymap); if(rc > 0) { if(*sbBuffer == 0) { @@ -669,6 +722,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, sbBuffer[2] = 0; //rgKey[iKey]->SetShiftState(ss, sbBuffer, true, (caps == 0)); rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); + wprintf(L"rc<0 for iKey nr. %i (%c) \n",iKey,iKey ); // It's a dead key; let's flush out whats stored in the keyboard state. loader.KMX_ClearKeyboardBuffer(); @@ -685,7 +739,13 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, } if(dk == NULL) { //_S2 TODO - //alDead.push_back(loader.KMX_ProcessDeadKey(iKey, ss, lpKeyState, rgKey, caps == 0, hkl)); + alDead.push_back(loader.KMX_ProcessDeadKey(iKey, ss, lpKeyState, rgKey, caps == 0, hkl, *keymap)); + //alDead.push_back(loader.KMX_ProcessDeadKey(192, ss, lpKeyState, rgKey, caps == 0, hkl, *keymap)); + + //_S2 for each dk (^ ' ` push_back all combinations ^,â,ê,î,ô,û ',á,é,í,ó,ú `,à,è,ì,ò,ù into alDead->m_rgcombchar) + //_S2 for each dk (^ ' ` push_back all base char : _,a,e,i,o,u into alDead->m_rgbasechar) + // S2 do nothing for other keys + int wertzui=9; } } } @@ -749,7 +809,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, UINT nKeys = 0; for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { - nKeys+= rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); + nKeys+= rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()); //wprintf(L" iKey = %i, Delta: %i -> Sum %i\n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()), nKeys); } } @@ -771,8 +831,8 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { - if(rgKey[iKey]->KMX_LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 - nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); + if(rgKey[iKey]->KMX_LayoutRow(loader.KMX_MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 + nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()); // wprintf(L" iKey = %i, Delta: %i -> Sum %i\n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()), nKeys); } } diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index ea43bf5f59..bd91bdc92c 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -35,6 +35,14 @@ //------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------ +// _S2 can go later +void test_keyboard_S2(LPKMX_KEYBOARD kmxfile); + +void TestKey_S2(LPKMX_KEY key) ; +void TestGroup_S2(LPKMX_GROUP group) ; +void TestKeyboard_S2(LPKMX_KEYBOARD kbd) ; + + KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]); bool KMX_ImportRules( LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 @@ -123,6 +131,9 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ return 3; } + + +//test_keyboard_S2(kmxfile); -> THE SAME #if defined(_WIN32) || defined(_WIN64) // _S2 DoConvert for windows needs to be done later ( can it be copied from engine/mcompile ?) /*if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552F @@ -131,14 +142,15 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ #else // LINUX if(KMX_DoConvert( kmxfile, bDeadkeyConversion, argc, (gchar**) argv_ch)) { // I4552F - KMX_SaveKeyboard(kmxfile, outfile); + KMX_SaveKeyboard(kmxfile, outfile); //test_keyboard_S2(kmxfile); -> THE SAME without DoConvert } +//test_keyboard_S2(kmxfile); // -> DIFFERENT #endif //DeleteReallocatedPointers(kmxfile); :TODO // _S2 not my ToDo :-) delete kmxfile; - //wprintf(L"\nmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm end\n"); + wprintf(L"\nmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm end\n"); wprintf(L"\n"); return 0; } @@ -228,6 +240,9 @@ void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { +//vk==192 && ch==94 && key->Key==94 && Line == 1572 +//vk==192 && ch==94 && key->Key==94 && Line == 1567 +//vk==192 && ch==94 && key->Key==94 && Line == 1568 // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" @@ -243,9 +258,10 @@ void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT key->ShiftFlags &= ~VIRTUALCHARKEY; } - int len = u16len(key->dpContext); + int len = u16len(key->dpContext); //PWSTR + // _S2 breakpoint key->Key==94 PKMX_WCHAR context = new KMX_WCHAR[len + 4]; memcpy(context, key->dpContext, len * sizeof(KMX_WCHAR)); context[len] = UC_SENTINEL; @@ -253,16 +269,18 @@ void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT context[len+2] = deadkey; context[len+3] = 0; key->dpContext = context; - key->Key = vk; + key->Key = vk; // _S2 fill with vk_US? } } void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group,KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { for(unsigned int i = 0; i < group->cxKeyArray; i++) { + //wprintf(L" i= %i \n",i); KMX_TranslateDeadkeyKey(&group->dpKeyArray[i], deadkey, vk, shift, ch); } } - +// is 223 0 175 +// should 45 0 175 --> need other VK !! void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { if(kbd->dpGroupArray[i].fUsingKeys) { @@ -271,16 +289,18 @@ void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WOR } } +// _S2 this does not work OK void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4549 - shift &= ~LCTRLFLAG; + // _s2 idee spanish keyboard has dk on altgr !! // If the first group is not a matching-keys group, then we need to add into // each subgroup, otherwise just the match group + int zaehler=0; for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { if(kbd->dpGroupArray[i].fUsingKeys) { LPKMX_KEY keys = new KMX_KEY[kbd->dpGroupArray[i].cxKeyArray + 1]; @@ -298,6 +318,9 @@ void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT kbd->dpGroupArray[i].dpKeyArray = keys; kbd->dpGroupArray[i].cxKeyArray++; //LogError("Add deadkey rule: + [%d K_%d] > dk(%d)", shift, vk, deadkey); + zaehler++; + //wprintf(L"Add deadkey rule: + [%d K_%d] > dk(%d) %i\n", shift, vk, deadkey,zaehler); + //test_keyboard_S2(kbd); if(i == kbd->StartGroup[1]) break; // If this is the initial group, that's all we need to do. } } @@ -391,8 +414,21 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR d while(*pdk) { // Look up the ch + // go via SC - UINT vkUnderlying = KMX_get_KVUS_From_KVUnderlying_VEC(All_Vector, *pdk); +// hier ist das problem: ich muss über sc hehen; nicht über VK_underlying, dens nicht gibt!! + //-S2 this is wrong!! + //UINT vkUnderlying = KMX_get_VKUS_From_VKUnderlying_VEC(All_Vector, *pdk); + UINT vkUnderlying = vk; + + //if(vkUnderlying != *pdk) + //wprintf(L" vkUnderlying_X %i *pdk %i \n", vkUnderlying, *pdk); + + //UINT vkUnderlying = VKUnderlyingLayoutToVKUS(*pdk); + // UINT scUnderlyingtest = KMX_get_SCUnderlying_From_VKUS(KMX_VKMap[i]); + + // _s (pdk+1) = UINT shift, *(pdk+2)=WORD ch + //wprintf(L" *(pdk+1): %i (%c) *(pdk+2) : \n", *(pdk+1), *(pdk+1) ); KMX_TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); pdk+=3; } @@ -457,22 +493,24 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg KMX_WCHAR ch = KMX_get_CharUnderlying_From_SCUnderlying_GDK(keymap, VKShiftState[j], scUnderlying, &DeadKey); //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); + //wprintf(L"--- VK_%d -> SC_%d [%c] dk=%d ( ss %i) \n", KMX_VKMap[i], KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]), ch == 0 ? 32 : ch, DeadKey,VKShiftState[j]); if(bDeadkeyConversion) { // I4552 if(ch == 0xFFFF) { ch = DeadKey; } } - -wprintf(L" scunderlying: SS: %i Nr: %i VKMap[i] %i ch:%i (%c) \n", VKShiftState[j],i, KMX_VKMap[i],ch,ch ); +// _S2 GOOD TIL HERE +wprintf(L" scunderlying: SS: %i Nr: %i VKMap[i] %i ch:%i (%c)\n", VKShiftState[j],i, KMX_VKMap[i],ch,ch ); switch(ch) { case 0x0000: break; - case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap); break; + case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap); break; //test_keyboard_S2(kbd); //-> mit Convert DK FALSCH; Ohne ConvertDK the same default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); } } } + //test_keyboard_S2(kbd); //-> HIER SCHON FALSCH KMX_ReportUnconvertedKeyboardRules(kbd); if(!KMX_ImportRules(kbd, All_Vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 @@ -498,7 +536,7 @@ UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS) { return SC_OTHER; } -KMX_WCHAR KMX_get_KVUS_From_KVUnderlying_VEC(v_dw_3D All_Vector, KMX_DWORD VK_OTHER) { +KMX_WCHAR KMX_get_VKUS_From_VKUnderlying_VEC(v_dw_3D All_Vector, KMX_DWORD VK_OTHER) { KMX_DWORD VK_US; for( int i=0; i< (int)All_Vector[0].size()-1 ;i++) { @@ -548,7 +586,7 @@ KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_U int VKShiftState_lin = map_VKShiftState_to_Lin(VKShiftState); KMX_DWORD KeyvalOther = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,SC_OTHER, VKShiftState_lin, dky); - if (KeyvalOther >= deadkey_min) { + if ((KeyvalOther >= deadkey_min) && (KeyvalOther >= deadkey_max)){ *DeadKey = *dky; return 0xFFFF; } @@ -597,6 +635,55 @@ int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, return (p-OutputPairs); } + +// _S2 can go later +void test_keyboard_S2(LPKMX_KEYBOARD kmxfile){ + + TestKeyboard_S2(kmxfile); +} + +void TestKey_S2(LPKMX_KEY key) { + //wprintf(L"key->dpOutput %i %i %i %i \n ",*key->dpOutput,*(key->dpOutput+1),*(key->dpOutput+2),*(key->dpOutput+3),*(key->dpOutput+4) ); + + wprintf(L" %i ",*key->dpOutput); + for (int i=1; i<8;i++) { + if( *(key->dpOutput+i) != 0) + wprintf(L" %i\t", *(key->dpOutput+i) ); + else + break; +} +wprintf(L" _\n"); + + + /*//wprintf(L" stopped at len for %i %i (%c) %c \n", key->Key, vk, vk, ch); + PWSTR context = new WCHAR[len + 4]; + memcpy(context, key->dpContext, len * sizeof(WCHAR)); + context[len] = UC_SENTINEL; + context[len+1] = CODE_DEADKEY; + context[len+2] = deadkey; + context[len+3] = 0; + key->dpContext = context; + key->Key = vk; + }*/ +} + +void TestGroup_S2(LPKMX_GROUP group) { + for(unsigned int i = 0; i < group->cxKeyArray; i++) { + wprintf(L" dpKeyArray[i] %i ",i ); + TestKey_S2(&group->dpKeyArray[i]); + } +} + +void TestKeyboard_S2(LPKMX_KEYBOARD kbd) { + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + wprintf(L"kbd->dpGroupArray[i] %i \n",i); + TestGroup_S2(&kbd->dpGroupArray[i]); + } + } +} + + // ---- old copy code from here ---------------------------------------------------------- /* diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index bfdbbc5488..06f47a6d86 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -44,10 +44,11 @@ UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, PKMX_WCHAR DeadKey); -KMX_WCHAR KMX_get_KVUS_From_KVUnderlying_VEC(v_dw_3D All_Vector,KMX_DWORD SC_US); +KMX_WCHAR KMX_get_VKUS_From_VKUnderlying_VEC(v_dw_3D All_Vector,KMX_DWORD SC_US); int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap); + //--------------------old /* From bbf3b39201f56f636d58e9decd3a7ede5b3f21e6 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 24 Jan 2024 10:30:08 +0100 Subject: [PATCH 176/327] feat(linux): mcompile newFunc create_alDead, class Deadkey to .h --- linux/mcompile/keymap/deadkey.cpp | 44 ++++++++++- linux/mcompile/keymap/deadkey.h | 6 ++ linux/mcompile/keymap/mc_import_rules.cpp | 94 +++++++++++++++-------- linux/mcompile/keymap/mc_import_rules.h | 90 ++++++++++++++++++++++ linux/mcompile/keymap/mcompile.cpp | 4 +- 5 files changed, 206 insertions(+), 32 deletions(-) create mode 100644 linux/mcompile/keymap/mc_import_rules.h diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 69899d06ce..d63c253154 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -26,6 +26,48 @@ void find_dk_combinations_for_single_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &d } } +//_S2 REVIEW +std::vector create_alDead() { + + std::vector alDead; + + v_dw_2D dk_ComposeTable; + KMX_DWORD dw= create_DKTable(dk_ComposeTable); + + for( int i=0; i< dk_ComposeTable.size()-1; i++) { + DeadKey *dk2= new DeadKey(dk_ComposeTable[i][0]); + for ( int j=0; j< dk_ComposeTable.size();j++) { + // check for right dk + if( dk_ComposeTable[i][0]==dk_ComposeTable[j][0]) + dk2->KMX_AddDeadKeyRow(dk_ComposeTable[j][1],dk_ComposeTable[j][2]); + } + alDead.push_back(dk2); + } + + return alDead; +} + +//_S2 REVIEW +std::vector reduce_alDead(std::vector dk_big) { + std::vector dk_small; + bool foundInSmall=false; + + for ( int i=1; iKMX_DeadCharacter()==94 || dk_big[i]->KMX_DeadCharacter()==96 || dk_big[i]->KMX_DeadCharacter()==180)) { + for( int k=0; k< dk_small.size();k++) { + if(dk_big[i]->KMX_DeadCharacter() == dk_small[k]->KMX_DeadCharacter()) + foundInSmall=true; + } + + if(!foundInSmall) + dk_small.push_back(dk_big[i]); + + foundInSmall=false; + } + } + return dk_small; +} + // _S2 DEADKEY STUFF - DO NOT REVIEW YET // _S2 might be used when deadkeys are implemented . is it correct?? KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap) { @@ -50,7 +92,7 @@ KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap // _S2 DEADKEY STUFF - DO NOT REVIEW YET // _S2 DESIGN NEEDED is this the right place to get dk from? if not wher are they stored? -KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable){ +KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable) { // values taken from: https://help.ubuntu.com/community/GtkDeadKeyTable#Latin //dk_ComposeTable[i][0] : First diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index ddfb3e1c98..a36990ad1f 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -4,6 +4,8 @@ #define DEADKEY_H #include +#include "mc_import_rules.h" + // creates a vector for a dk combination ( ` + a -> à ) v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult); @@ -12,6 +14,10 @@ KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable); //KMX_DWORD find_dkCharacter(v_dw_2D * dk_ComposeTable, KMX_DWORD first, KMX_DWORD second ); +//_S2 REVIEW +std::vector create_alDead(); +std::vector reduce_alDead(std::vector dk_big) ; + // finds all combination for a specific deadkey(dk) void find_dk_combinations_for_single_dk(v_dw_2D * dk_ComposeTable, v_dw_2D & dk_SingleTable, KMX_DWORD dk); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 2f20fc41ce..5b17227084 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -43,39 +43,22 @@ const int KMX_ShiftStateMap[] = { // _S2 DEADKEY STUFF - DO NOT REVIEW YET // _S2 ToDo open deadkey functions -class DeadKey { -private: - KMX_WCHAR m_deadchar; - std::vector m_rgbasechar; - std::vector m_rgcombchar; -public: - DeadKey(KMX_WCHAR deadCharacter) { + DeadKey::DeadKey(KMX_WCHAR deadCharacter) { this->m_deadchar = deadCharacter; } - KMX_WCHAR KMX_DeadCharacter() { + KMX_WCHAR DeadKey::KMX_DeadCharacter() { return this->m_deadchar; } - void KMX_AddDeadKeyRow(KMX_WCHAR baseCharacter, KMX_WCHAR combinedCharacter) { + void DeadKey::KMX_AddDeadKeyRow(KMX_WCHAR baseCharacter, KMX_WCHAR combinedCharacter) { this->m_rgbasechar.push_back(baseCharacter); this->m_rgcombchar.push_back(combinedCharacter); } - int KMX_Count() { - return this->m_rgbasechar.size(); - } - - KMX_WCHAR KMX_GetBaseCharacter(int index) { - return this->m_rgbasechar[index]; - } - - KMX_WCHAR KMX_GetCombinedCharacter(int index) { - return this->m_rgcombchar[index]; - } /* - bool ContainsBaseCharacter(WCHAR baseCharacter) { + bool DeadKey::ContainsBaseCharacter(WCHAR baseCharacter) { std::vector::iterator it; for(it=this->m_rgbasechar.begin(); it::iterator it; for(it=this->m_rgbasechar.begin(); itKMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; for (int caps = 0; caps <= 1; caps++) { std::wstring st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); PKMX_WCHAR p; // was PWSTR p; + PKMX_WCHAR p_S2; // was PWSTR p; if (st.size() == 0) { // No character assigned here @@ -338,11 +321,14 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; *p++ = st[0]; *p = 0; } else { + p = key->dpOutput = new KMX_WCHAR[4]; + p_S2 =p; *p++ = UC_SENTINEL; *p++ = CODE_DEADKEY; *p++ = KMX_DeadKeyMap(st[0], deadkeys, deadkeyBase, &KMX_FDeadkeys); // I4353 *p = 0; + int wertzu=57; } key++; } else { @@ -364,6 +350,8 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); key->dpContext = new KMX_WCHAR; *key->dpContext = 0; p = key->dpOutput = new KMX_WCHAR[st.size() + 1]; + + p_S2 = p; for(size_t ich = 0; ich < st.size(); ich++) { *p++ = st[ich]; } @@ -577,19 +565,52 @@ KMX_WCHAR sbBuffer1[16]; } }; -int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { +//_S2 REVIEW + +/* +int GetMaxDeadkeyIndex(WCHAR *p) { int n = 0; while(p && *p) { if(*p == UC_SENTINEL && *(p+1) == CODE_DEADKEY) + n = max(n, *(p+2)); + p = incxstr(p); + } + return n; +} +*/ + + +int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { + int n = 0; int pp = 0; + while(p && *p) { + if(*p == UC_SENTINEL && *(p+1) == CODE_DEADKEY) { + //pp = (int) *(p+2); + n = std::max(n, (int) *(p+2)); + } + p = KMX_incxstr(p); + } + return n; +} + + + +/*int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { + int n = 0; + int nn = 0; + int pp = 0; + while(p && *p) { + if(*p == UC_SENTINEL && *(p+1) == CODE_DEADKEY) + pp = (int) *(p+2); + //nn = std::max(n, *(p+2)); + nn = std::max(n, pp); - // n = max(n, *(p+2)); if( !(n > (*p+2))) // _S2 p+4 ?? n= (*p+2); p = KMX_incxstr(p); } return n; -} +}*/ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 KMX_Loader loader; @@ -601,6 +622,10 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector rgKey; //= new VirtualKey[256]; std::vector alDead; +//_S2 REVIEW + std::vector alDead2 ; + //std::vector alDead_small; + rgKey.resize(256); // Scroll through the Scan Code (SC) values and get the valid Virtual Key (VK) @@ -722,7 +747,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, sbBuffer[2] = 0; //rgKey[iKey]->SetShiftState(ss, sbBuffer, true, (caps == 0)); rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); - wprintf(L"rc<0 for iKey nr. %i (%c) \n",iKey,iKey ); + //wprintf(L"rc<0 for iKey nr. %i (%c) \n",iKey,iKey ); // It's a dead key; let's flush out whats stored in the keyboard state. loader.KMX_ClearKeyboardBuffer(); @@ -739,7 +764,13 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, } if(dk == NULL) { //_S2 TODO - alDead.push_back(loader.KMX_ProcessDeadKey(iKey, ss, lpKeyState, rgKey, caps == 0, hkl, *keymap)); + //alDead.push_back(loader.KMX_ProcessDeadKey(iKey, ss, lpKeyState, rgKey, caps == 0, hkl, *keymap)); + + //_S2 REVIEW + alDead2 = create_alDead(); + //_S2 REVIEW + alDead = reduce_alDead(alDead2); + //alDead.push_back(loader.KMX_ProcessDeadKey(192, ss, lpKeyState, rgKey, caps == 0, hkl, *keymap)); //_S2 for each dk (^ ' ` push_back all combinations ^,â,ê,î,ô,û ',á,é,í,ó,ú `,à,è,ì,ò,ù into alDead->m_rgcombchar) @@ -783,7 +814,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, memcpy(gp, kp->dpGroupArray, sizeof(KMX_GROUP) * kp->cxGroupArray); // - // Find the current highest deadkey index // @@ -803,7 +833,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpOutput)); } } - +//nDeadkey=3; //_S2 kp->cxGroupArray++; gp = &kp->dpGroupArray[kp->cxGroupArray-1]; UINT nKeys = 0; @@ -889,6 +919,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, kp->cxGroupArray++; KMX_WCHAR *p = gp->dpMatch = new KMX_WCHAR[4]; + KMX_WCHAR *qq_S2 = p; *p++ = UC_SENTINEL; *p++ = CODE_USE; *p++ = (KMX_WCHAR) kp->cxGroupArray; @@ -912,6 +943,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, int nStoreBase = kp->cxStoreArray; kp->cxStoreArray += alDead.size() * 2; +//_S2 here get ÂâÊêÎî... for(UINT i = 0; i < alDead.size(); i++) { DeadKey *dk = alDead[i]; @@ -935,6 +967,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, kkp->ShiftFlags = 0; kkp->Key = 0; KMX_WCHAR *p = kkp->dpContext = new KMX_WCHAR[8]; + KMX_WCHAR* qQQ_S2= p; *p++ = UC_SENTINEL; *p++ = CODE_DEADKEY; *p++ = KMX_DeadKeyMap(dk->KMX_DeadCharacter(), &alDead, nDeadkey, FDeadkeys); // I4353 @@ -945,6 +978,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, *p = 0; p = kkp->dpOutput = new KMX_WCHAR[5]; + KMX_WCHAR* QT_S2= p; *p++ = UC_SENTINEL; *p++ = CODE_INDEX; *p++ = nStoreBase + i*2 + 2; diff --git a/linux/mcompile/keymap/mc_import_rules.h b/linux/mcompile/keymap/mc_import_rules.h new file mode 100644 index 0000000000..f8c1f7b418 --- /dev/null +++ b/linux/mcompile/keymap/mc_import_rules.h @@ -0,0 +1,90 @@ + +#pragma once +#ifndef MC_IMPORT_RULES_H +#define MC_IMPORT_RULES_H +// _S2 ToDo open deadkey functions +class DeadKey { +private: + KMX_WCHAR m_deadchar; + std::vector m_rgbasechar; + std::vector m_rgcombchar; + +public: + DeadKey(KMX_WCHAR deadCharacter) ; + KMX_WCHAR KMX_DeadCharacter() ; + + void KMX_AddDeadKeyRow(KMX_WCHAR baseCharacter, KMX_WCHAR combinedCharacter) ; + int KMX_Count() { + return this->m_rgbasechar.size(); + } + + KMX_WCHAR KMX_GetBaseCharacter(int index) { + return this->m_rgbasechar[index]; + } + + KMX_WCHAR KMX_GetCombinedCharacter(int index) { + return this->m_rgcombchar[index]; + } + + bool ContainsBaseCharacter(WCHAR baseCharacter); + + + bool KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter) ; +}; + +class DeadKey1 { +private: + KMX_WCHAR m_deadchar; + std::vector m_rgbasechar; + std::vector m_rgcombchar; + +public: + DeadKey1(KMX_WCHAR deadCharacter) { + this->m_deadchar = deadCharacter; + } + + KMX_WCHAR KMX_DeadCharacter() { + return this->m_deadchar; + } + + void KMX_AddDeadKeyRow(KMX_WCHAR baseCharacter, KMX_WCHAR combinedCharacter) { + this->m_rgbasechar.push_back(baseCharacter); + this->m_rgcombchar.push_back(combinedCharacter); + } + + int KMX_Count() { + return this->m_rgbasechar.size(); + } + + KMX_WCHAR KMX_GetBaseCharacter(int index) { + return this->m_rgbasechar[index]; + } + + KMX_WCHAR KMX_GetCombinedCharacter(int index) { + return this->m_rgcombchar[index]; + } +/* + bool ContainsBaseCharacter(WCHAR baseCharacter) { + std::vector::iterator it; + for(it=this->m_rgbasechar.begin(); it::iterator it; + for(it=this->m_rgbasechar.begin(); itShiftFlags == 0) { //LogError("Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d]", key->Line, key->Key, deadkey, shift, vk); + //wprintf(L"Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d]\n", key->Line, key->Key, deadkey, shift, vk); key->ShiftFlags = ISVIRTUALKEY | shift; } else { //LogError("Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO dk(%d) + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, deadkey, key->ShiftFlags & ~VIRTUALCHARKEY, vk); + //wprintf(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO dk(%d) + [%x K_%d]\n", key->Line, key->ShiftFlags, key->Key, deadkey, key->ShiftFlags & ~VIRTUALCHARKEY, vk); key->ShiftFlags &= ~VIRTUALCHARKEY; } @@ -501,7 +503,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg } } // _S2 GOOD TIL HERE -wprintf(L" scunderlying: SS: %i Nr: %i VKMap[i] %i ch:%i (%c)\n", VKShiftState[j],i, KMX_VKMap[i],ch,ch ); +//wprintf(L" scunderlying: SS: %i Nr: %i VKMap[i] %i ch:%i (%c)\n", VKShiftState[j],i, KMX_VKMap[i],ch,ch ); switch(ch) { case 0x0000: break; case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap); break; //test_keyboard_S2(kbd); //-> mit Convert DK FALSCH; Ohne ConvertDK the same From 5a816ec3c538f53ffd3a041a8bb69f307be8ec04 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 24 Jan 2024 15:46:19 +0100 Subject: [PATCH 177/327] feat(linux): mcompile-dk KMX_TranslateDeadkeyKey --- linux/mcompile/keymap/deadkey.cpp | 20 +++++++++++-------- linux/mcompile/keymap/deadkey.h | 2 +- linux/mcompile/keymap/keymap.cpp | 16 ++++++++++++--- linux/mcompile/keymap/keymap.h | 1 + linux/mcompile/keymap/mcompile.cpp | 31 ++++++++++++++---------------- 5 files changed, 41 insertions(+), 29 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index d63c253154..9704022ef1 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -11,19 +11,23 @@ v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, } // _S2 DEADKEY STUFF - DO NOT REVIEW YET -void find_dk_combinations_for_single_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &dk_SingleTable, KMX_DWORD dk) { - // _S2 use return value to check if >0 lines in table - v_dw_2D dk_ComposeTable = * p_dk_ComposeTable; +bool find_dk_combinations_for_single_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &dk_SingleTable, KMX_DWORD dk) { + v_dw_1D line; - for ( int i =0; i< (int) dk_ComposeTable.size()-1; i++) { - if ( dk_ComposeTable[i][0] == dk) { - line.push_back(dk_ComposeTable[i][0]); - line.push_back(dk_ComposeTable[i][1]); - line.push_back(dk_ComposeTable[i][2]); + for ( int i =0; i< (int) (*p_dk_ComposeTable).size()-1; i++) { + // _S2 is there a better way to find a-z,A-Z? + if (((*p_dk_ComposeTable)[i][0] == dk) && (IsKeymanUsedChar((*p_dk_ComposeTable)[i][1]))) { + line.push_back((*p_dk_ComposeTable)[i][0]); + line.push_back((*p_dk_ComposeTable)[i][1]); + line.push_back((*p_dk_ComposeTable)[i][2]); dk_SingleTable.push_back(line); line.clear(); } } + if( dk_SingleTable.size()>0) + return true; + else + return false; } //_S2 REVIEW diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index a36990ad1f..4cdedc822b 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -19,7 +19,7 @@ std::vector create_alDead(); std::vector reduce_alDead(std::vector dk_big) ; // finds all combination for a specific deadkey(dk) -void find_dk_combinations_for_single_dk(v_dw_2D * dk_ComposeTable, v_dw_2D & dk_SingleTable, KMX_DWORD dk); +bool find_dk_combinations_for_single_dk(v_dw_2D * dk_ComposeTable, v_dw_2D & dk_SingleTable, KMX_DWORD dk); // gets the shifted character of a key KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap) ; diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 53f6ceac8b..692aa1f507 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -2,12 +2,13 @@ #include - +// _S2 is return 2 + 3 correct??? prob not int map_VKShiftState_to_Lin(int VKShiftState) { if (VKShiftState == 0 ) return 0; /* 0000 0000 */ else if (VKShiftState == 16) return 1; /* 0001 0000 */ - else if (VKShiftState == 9 ) return 2; /* 0000 1001 */ - else if (VKShiftState == 25) return 3; /* 0001 1001 */ + // _S2 if commented out only 3 DK will be processed ^ ' ` + //else if (VKShiftState == 9 ) return 2; /* 0000 1001 */ + //else if (VKShiftState == 25) return 3; /* 0001 1001 */ else return VKShiftState; } @@ -376,6 +377,15 @@ bool IsKeymanUsedKeyVal(std::u16string Keyval) { return false; } + +bool IsKeymanUsedChar(int KV) { + // 32 A-Z a-z + if ((KV == 0x20 ) || (KV >= 65 && KV <= 90) || (KV >= 97 && KV <= 122) ) + return true; + else + return false; +} + // _S2 DEADKEY STUFF - DO NOT REVIEW YET std::wstring convert_DeadkeyValues_ToChar(int in) { diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 55c4a130bf..b07927789a 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -503,6 +503,7 @@ const UINT ScanCodeToUSVirtualKey[128] = { bool IsKeymanUsedKeyVal(std::wstring Keyval); bool IsKeymanUsedKeyVal(std::u16string Keyval); +bool IsKeymanUsedChar(int KV); // take deadkey-value (e.g.65106) and return wstring (e.g. '^' ) std::wstring convert_DeadkeyValues_ToChar(int in); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index a3aeea37ac..ce87ef6780 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -239,6 +239,8 @@ void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { } void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { + //if(ch==94) + //wprintf(L" input with: key->Key: %i (%c) -- key->ShiftFlags %i -- key->Line %i -- shift %i --ch %i(%c) \n", key->Key,key->Key, key->ShiftFlags,key->Line, shift,ch,ch ); if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { //vk==192 && ch==94 && key->Key==94 && Line == 1572 //vk==192 && ch==94 && key->Key==94 && Line == 1567 @@ -252,11 +254,11 @@ void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT if(key->ShiftFlags == 0) { //LogError("Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d]", key->Line, key->Key, deadkey, shift, vk); - //wprintf(L"Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d]\n", key->Line, key->Key, deadkey, shift, vk); + wprintf(L"DK Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d], %i(%c)\n", key->Line, key->Key, deadkey, shift, vk, ch, ch); key->ShiftFlags = ISVIRTUALKEY | shift; } else { //LogError("Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO dk(%d) + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, deadkey, key->ShiftFlags & ~VIRTUALCHARKEY, vk); - //wprintf(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO dk(%d) + [%x K_%d]\n", key->Line, key->ShiftFlags, key->Key, deadkey, key->ShiftFlags & ~VIRTUALCHARKEY, vk); + wprintf(L"DK Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO dk(%d) + [%x K_%d], %i(%c)\n", key->Line, key->ShiftFlags, key->Key, deadkey, key->ShiftFlags & ~VIRTUALCHARKEY, vk, ch, ch); key->ShiftFlags &= ~VIRTUALCHARKEY; } @@ -321,7 +323,7 @@ void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT kbd->dpGroupArray[i].cxKeyArray++; //LogError("Add deadkey rule: + [%d K_%d] > dk(%d)", shift, vk, deadkey); zaehler++; - //wprintf(L"Add deadkey rule: + [%d K_%d] > dk(%d) %i\n", shift, vk, deadkey,zaehler); + wprintf(L"Add deadkey rule: + [%d K_%d] > dk(%d) %i\n", shift, vk, deadkey,zaehler); //test_keyboard_S2(kbd); if(i == kbd->StartGroup[1]) break; // If this is the initial group, that's all we need to do. } @@ -415,23 +417,18 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR d KMX_GetDeadkeys(dk_Table, deadkey, pdk = deadkeys, keymap); // returns array of [usvk, ch_out] pairs while(*pdk) { + // Look up the ch + UINT vkUnderlying = KMX_get_VKUS_From_VKUnderlying_VEC(All_Vector, *pdk); - // go via SC -// hier ist das problem: ich muss über sc hehen; nicht über VK_underlying, dens nicht gibt!! - //-S2 this is wrong!! - //UINT vkUnderlying = KMX_get_VKUS_From_VKUnderlying_VEC(All_Vector, *pdk); - UINT vkUnderlying = vk; + wprintf(L" vkUnderlying %i *pdk %i ", vkUnderlying, *pdk); - //if(vkUnderlying != *pdk) - //wprintf(L" vkUnderlying_X %i *pdk %i \n", vkUnderlying, *pdk); - - //UINT vkUnderlying = VKUnderlyingLayoutToVKUS(*pdk); - // UINT scUnderlyingtest = KMX_get_SCUnderlying_From_VKUS(KMX_VKMap[i]); - - // _s (pdk+1) = UINT shift, *(pdk+2)=WORD ch - //wprintf(L" *(pdk+1): %i (%c) *(pdk+2) : \n", *(pdk+1), *(pdk+1) ); - KMX_TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); + if(vkUnderlying != (UINT) *pdk) { + wprintf(L" TRANSLATED \n"); + KMX_TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); + } + else + wprintf(L" \n"); pdk+=3; } } From 53d6f021e2ae6c35e1c08e59d00369f108643c91 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 24 Jan 2024 16:08:04 +0100 Subject: [PATCH 178/327] feat(linux): mcompile-dk more KMX_TranslateDeadkeyKey --- linux/mcompile/keymap/mcompile.cpp | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index ce87ef6780..d5748e49b1 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -239,13 +239,7 @@ void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { } void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { - //if(ch==94) - //wprintf(L" input with: key->Key: %i (%c) -- key->ShiftFlags %i -- key->Line %i -- shift %i --ch %i(%c) \n", key->Key,key->Key, key->ShiftFlags,key->Line, shift,ch,ch ); - if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { -//vk==192 && ch==94 && key->Key==94 && Line == 1572 -//vk==192 && ch==94 && key->Key==94 && Line == 1567 -//vk==192 && ch==94 && key->Key==94 && Line == 1568 - + if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. @@ -262,10 +256,8 @@ void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT key->ShiftFlags &= ~VIRTUALCHARKEY; } - int len = u16len(key->dpContext); + int len = u16len(key->dpContext); - //PWSTR - // _S2 breakpoint key->Key==94 PKMX_WCHAR context = new KMX_WCHAR[len + 4]; memcpy(context, key->dpContext, len * sizeof(KMX_WCHAR)); context[len] = UC_SENTINEL; @@ -273,18 +265,16 @@ void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT context[len+2] = deadkey; context[len+3] = 0; key->dpContext = context; - key->Key = vk; // _S2 fill with vk_US? + key->Key = vk; } } void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group,KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { for(unsigned int i = 0; i < group->cxKeyArray; i++) { - //wprintf(L" i= %i \n",i); KMX_TranslateDeadkeyKey(&group->dpKeyArray[i], deadkey, vk, shift, ch); } } -// is 223 0 175 -// should 45 0 175 --> need other VK !! + void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { if(kbd->dpGroupArray[i].fUsingKeys) { @@ -618,7 +608,7 @@ int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, v_dw_2D dk_SingleTable; find_dk_combinations_for_single_dk(&dk_Table, dk_SingleTable, DeadKey); - for ( int i=0; i< (int) dk_SingleTable.size()-1;i++) { + for ( int i=0; i< (int) dk_SingleTable.size();i++) { KMX_WORD vk = KMX_changeKeynameToCapital(dk_SingleTable[i][1], shift, keymap); if(vk != 0) { *p++ = vk; From 0e20c3e34ec25fb7973527a80e7c6ab0c6feb55f Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 24 Jan 2024 19:12:07 +0100 Subject: [PATCH 179/327] feat(linux): mcompile-dk shrink contents of alDead --- linux/mcompile/keymap/deadkey.cpp | 5 ++++- linux/mcompile/keymap/keymap.cpp | 6 +++--- linux/mcompile/keymap/mc_import_rules.cpp | 4 ++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 9704022ef1..0ac91cd302 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -16,6 +16,7 @@ bool find_dk_combinations_for_single_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &d v_dw_1D line; for ( int i =0; i< (int) (*p_dk_ComposeTable).size()-1; i++) { // _S2 is there a better way to find a-z,A-Z? + //if (((*p_dk_ComposeTable)[i][0] == dk) ) { if (((*p_dk_ComposeTable)[i][0] == dk) && (IsKeymanUsedChar((*p_dk_ComposeTable)[i][1]))) { line.push_back((*p_dk_ComposeTable)[i][0]); line.push_back((*p_dk_ComposeTable)[i][1]); @@ -42,7 +43,8 @@ std::vector create_alDead() { DeadKey *dk2= new DeadKey(dk_ComposeTable[i][0]); for ( int j=0; j< dk_ComposeTable.size();j++) { // check for right dk - if( dk_ComposeTable[i][0]==dk_ComposeTable[j][0]) + // _S2 do I need to trim here?? + if(( dk_ComposeTable[i][0]==dk_ComposeTable[j][0]) && (IsKeymanUsedChar(dk_ComposeTable[j][1]))) dk2->KMX_AddDeadKeyRow(dk_ComposeTable[j][1],dk_ComposeTable[j][2]); } alDead.push_back(dk2); @@ -57,6 +59,7 @@ std::vector reduce_alDead(std::vector dk_big) { bool foundInSmall=false; for ( int i=1; iKMX_DeadCharacter()==94 || dk_big[i]->KMX_DeadCharacter()==96 || dk_big[i]->KMX_DeadCharacter()==180)) { for( int k=0; k< dk_small.size();k++) { if(dk_big[i]->KMX_DeadCharacter() == dk_small[k]->KMX_DeadCharacter()) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 692aa1f507..7375d7e1c4 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -2,13 +2,13 @@ #include -// _S2 is return 2 + 3 correct??? prob not +// _S2 is return 2 + 3 correct??? YES, it talking about the column-nr in symbols-file int map_VKShiftState_to_Lin(int VKShiftState) { if (VKShiftState == 0 ) return 0; /* 0000 0000 */ else if (VKShiftState == 16) return 1; /* 0001 0000 */ // _S2 if commented out only 3 DK will be processed ^ ' ` - //else if (VKShiftState == 9 ) return 2; /* 0000 1001 */ - //else if (VKShiftState == 25) return 3; /* 0001 1001 */ + else if (VKShiftState == 9 ) return 2; /* 0000 1001 */ + else if (VKShiftState == 25) return 3; /* 0001 1001 */ else return VKShiftState; } diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 5b17227084..bdac85d397 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -976,6 +976,8 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, *p++ = CODE_ANY; *p++ = nStoreBase + i*2 + 1; *p = 0; + wprintf(L" contents of kkp->dpContext: %i \\ %i \\ %i \\ %i \\ %i \\ %i \\ %i \\ %i ----", + *qQQ_S2,*(qQQ_S2+1),*(qQQ_S2+2),*(qQQ_S2+3),*(qQQ_S2+4),*(qQQ_S2+5),*(qQQ_S2+6),*(qQQ_S2+7),*(qQQ_S2+8)); p = kkp->dpOutput = new KMX_WCHAR[5]; KMX_WCHAR* QT_S2= p; @@ -985,6 +987,8 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, *p++ = 2; *p = 0; + wprintf(L" contents of kkp->dpOutput: %i \\ %i \\ %i \\ %i \\ %i \\ %i \\ %i \\ %i\n", + *QT_S2,*(QT_S2+1),*(QT_S2+2),*(QT_S2+3),*(QT_S2+4),*(QT_S2+5),*(QT_S2+6),*(QT_S2+7),*(QT_S2+8)); kkp++; } } From 0e849653b2be971c83f40c66a347d2f087e0146b Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 26 Jan 2024 12:44:42 +0100 Subject: [PATCH 180/327] feat(linux): mcompile-dk remove difference in kmn-file (deadkey(3) + [CTRL K_SPACE] <==> [CTRL "`"] --- linux/mcompile/keymap/deadkey.cpp | 239 +++++++++++++++-------------- linux/mcompile/keymap/mcompile.cpp | 22 ++- 2 files changed, 143 insertions(+), 118 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 0ac91cd302..a46072dedc 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -14,7 +14,8 @@ v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, bool find_dk_combinations_for_single_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &dk_SingleTable, KMX_DWORD dk) { v_dw_1D line; - for ( int i =0; i< (int) (*p_dk_ComposeTable).size()-1; i++) { + //for ( int i =0; i< (int) (*p_dk_ComposeTable).size()-1; i++) { + for ( int i =0; i< (int) (*p_dk_ComposeTable).size(); i++) { // _S2 is there a better way to find a-z,A-Z? //if (((*p_dk_ComposeTable)[i][0] == dk) ) { if (((*p_dk_ComposeTable)[i][0] == dk) && (IsKeymanUsedChar((*p_dk_ComposeTable)[i][1]))) { @@ -109,25 +110,50 @@ KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable) { v_dw_1D line; - line = createLine(L"dead_grave", L"A", 0x00C0, L"capital A with grave"); + line = createLine(L"dead_circumflex", L"a", 0x00E2, L"small A with circumflex"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"E", 0x00C8, L"capital E with grave"); + line = createLine(L"dead_circumflex", L"e", 0x00EA, L"small E with circumflex"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"I", 0x00CC, L"capital I with grave"); + line = createLine(L"dead_circumflex", L"i", 0x00EE, L"small I with circumflex"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"O", 0x00D2, L"capital O with grave"); + line = createLine(L"dead_circumflex", L"o", 0x00F4, L"small O with circumflex"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"U", 0x00D9, L"capital U with grave"); + line = createLine(L"dead_circumflex", L"u", 0x00FB, L"small U with circumflex"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"a", 0x00E0, L"small A with grave"); + line = createLine(L"dead_circumflex", L"A", 0x00C2, L"capital A with circumflex"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"e", 0x00E8, L"small E with grave"); + line = createLine(L"dead_circumflex", L"E", 0x00CA, L"capital E with circumflex"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"i", 0x00EC, L"small I with grave"); + line = createLine(L"dead_circumflex", L"I", 0x00CE, L"capital I with circumflex"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"o", 0x00F2, L"small O with grave"); + line = createLine(L"dead_circumflex", L"O", 0x00D4, L"capital O with circumflex"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"u", 0x00F9, L"small U with grave"); + line = createLine(L"dead_circumflex", L"U", 0x00DB, L"capital U with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine(L"dead_acute", L"a", 0x00E1, L"small A with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"c", 0x0107, L"small C with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"e", 0x00E9, L"small E with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"i", 0x00ED, L"small I with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"l", 0x013A, L"small L with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"n", 0x0144, L"small N with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"o", 0x00F3, L"small O with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"r", 0x0155, L"small R with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"s", 0x015B, L"small S with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"u", 0x00FA, L"small U with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"y", 0x00FD, L"small Y with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"z", 0x017A, L"small Z with acute"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_acute", L"A", 0x00C1, L"capital A with acute"); dk_ComposeTable.push_back(line); line.clear(); @@ -153,49 +179,37 @@ KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable) { dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_acute", L"Z", 0x0179, L"capital Z with acute"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"a", 0x00E1, L"small A with acute"); + + line = createLine(L"dead_grave", L"a", 0x00E0, L"small A with grave"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"c", 0x0107, L"small C with acute"); + line = createLine(L"dead_grave", L"e", 0x00E8, L"small E with grave"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"e", 0x00E9, L"small E with acute"); + line = createLine(L"dead_grave", L"i", 0x00EC, L"small I with grave"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"i", 0x00ED, L"small I with acute"); + line = createLine(L"dead_grave", L"o", 0x00F2, L"small O with grave"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"l", 0x013A, L"small L with acute"); + line = createLine(L"dead_grave", L"u", 0x00F9, L"small U with grave"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"n", 0x0144, L"small N with acute"); + line = createLine(L"dead_grave", L"A", 0x00C0, L"capital A with grave"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"o", 0x00F3, L"small O with acute"); + line = createLine(L"dead_grave", L"E", 0x00C8, L"capital E with grave"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"r", 0x0155, L"small R with acute"); + line = createLine(L"dead_grave", L"I", 0x00CC, L"capital I with grave"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"s", 0x015B, L"small S with acute"); + line = createLine(L"dead_grave", L"O", 0x00D2, L"capital O with grave"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"u", 0x00FA, L"small U with acute"); + line = createLine(L"dead_grave", L"U", 0x00D9, L"capital U with grave"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine(L"dead_tilde", L"a", 0x00E3, L"small A with tilde"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"y", 0x00FD, L"small Y with acute"); + line = createLine(L"dead_tilde", L"i", 0x0129, L"small I with tilde"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"z", 0x017A, L"small Z with acute"); + line = createLine(L"dead_tilde", L"n", 0x00F1, L"small N with tilde"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"A", 0x00C2, L"capital A with circumflex"); + line = createLine(L"dead_tilde", L"o", 0x00F5, L"small O with tilde"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"E", 0x00CA, L"capital E with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"I", 0x00CE, L"capital I with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"O", 0x00D4, L"capital O with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"U", 0x00DB, L"capital U with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"a", 0x00E2, L"small A with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"e", 0x00EA, L"small E with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"i", 0x00EE, L"small I with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"o", 0x00F4, L"small O with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"u", 0x00FB, L"small U with circumflex"); + line = createLine(L"dead_tilde", L"u", 0x0169, L"small U with tilde"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_tilde", L"A", 0x00C3, L"capital A with tilde"); dk_ComposeTable.push_back(line); line.clear(); @@ -207,15 +221,16 @@ KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable) { dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_tilde", L"U", 0x0168, L"capital U with tilde"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_tilde", L"a", 0x00E3, L"small A with tilde"); + + line = createLine(L"dead_macron", L"a", 0x0101, L"small A with macron"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_tilde", L"i", 0x0129, L"small I with tilde"); + line = createLine(L"dead_macron", L"e", 0x0113, L"small E with macron"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_tilde", L"n", 0x00F1, L"small N with tilde"); + line = createLine(L"dead_macron", L"i", 0x012B, L"small I with macron"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_tilde", L"o", 0x00F5, L"small O with tilde"); + line = createLine(L"dead_macron", L"o", 0x014D, L"small O with macron"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_tilde", L"u", 0x0169, L"small U with tilde"); + line = createLine(L"dead_macron", L"u", 0x016B, L"small U with macron"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_macron", L"A", 0x0100, L"capital A with macron"); dk_ComposeTable.push_back(line); line.clear(); @@ -227,23 +242,21 @@ KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable) { dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_macron", L"U", 0x016A, L"capital U with macron"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_macron", L"a", 0x0101, L"small A with macron"); + + line = createLine(L"dead_breve", L"a", 0x0103, L"small A with breve"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_macron", L"e", 0x0113, L"small E with macron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_macron", L"i", 0x012B, L"small I with macron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_macron", L"o", 0x014D, L"small O with macron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_macron", L"u", 0x016B, L"small U with macron"); + line = createLine(L"dead_breve", L"g", 0x011F, L"small G with breve"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_breve", L"A", 0x0102, L"capital A with breve"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_breve", L"G", 0x011E, L"capital G with breve"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_breve", L"a", 0x0103, L"small A with breve"); + + line = createLine(L"dead_abovedot", L"e", 0x0117, L"small E with dot above"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_breve", L"g", 0x011F, L"small G with breve"); + line = createLine(L"dead_abovedot", L"i", 0x0131, L"small DOTLESS_I"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_abovedot", L"z", 0x017C, L"small Z with dot above"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_abovedot", L"E", 0x0116, L"capital E with dot above"); dk_ComposeTable.push_back(line); line.clear(); @@ -251,11 +264,18 @@ KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable) { dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_abovedot", L"Z", 0x017B, L"capital Z with dot above"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_abovedot", L"e", 0x0117, L"small E with dot above"); + + line = createLine(L"dead_diaeresis", L"a", 0x00E4, L"small A with diaeresis"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_abovedot", L"i", 0x0131, L"small DOTLESS_I"); + line = createLine(L"dead_diaeresis", L"e", 0x00EB, L"small E with diaeresis"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_abovedot", L"z", 0x017C, L"small Z with dot above"); + line = createLine(L"dead_diaeresis", L"i", 0x00EF, L"small I with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_diaeresis", L"o", 0x00F6, L"small O with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_diaeresis", L"u", 0x00FC, L"small U with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_diaeresis", L"y", 0x00FF, L"small Y with diaeresis"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_diaeresis", L"A", 0x00C4, L"capital A with diaeresis"); dk_ComposeTable.push_back(line); line.clear(); @@ -269,33 +289,42 @@ KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable) { dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_diaeresis", L"Y", 0x0178, L"capital Y with diaeresis"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"a", 0x00E4, L"small A with diaeresis"); + + line = createLine(L"dead_abovering", L"a", 0x00E5, L"small A with ring above"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"e", 0x00EB, L"small E with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"i", 0x00EF, L"small I with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"o", 0x00F6, L"small O with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"u", 0x00FC, L"small U with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"y", 0x00FF, L"small Y with diaeresis"); + line = createLine(L"dead_abovering", L"u", 0x016F, L"small U with ring above"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_abovering", L"A", 0x00C5, L"capital A with ring above"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_abovering", L"U", 0x016E, L"capital U with ring above"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_abovering", L"a", 0x00E5, L"small A with ring above"); + + line = createLine(L"dead_doubleacute", L"o", 0x0151, L"small O with double acute"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_abovering", L"u", 0x016F, L"small U with ring above"); + line = createLine(L"dead_doubleacute", L"u", 0x0171, L"small U with double acute"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_doubleacute", L"O", 0x0150, L"capital O with double acute"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_doubleacute", L"U", 0x0170, L"capital U with double acute"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_doubleacute", L"o", 0x0151, L"small O with double acute"); + + line = createLine(L"dead_caron", L"c", 0x010D, L"small C with caron"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_doubleacute", L"u", 0x0171, L"small U with double acute"); + line = createLine(L"dead_caron", L"d", 0x010F, L"small D with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"e", 0x011B, L"small E with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"l", 0x013E, L"small L with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"n", 0x0148, L"small N with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"r", 0x0159, L"small R with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"s", 0x0161, L"small S with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"t", 0x0165, L"small T with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"z", 0x017E, L"small Z with caron"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_caron", L"C", 0x010C, L"capital C with caron"); dk_ComposeTable.push_back(line); line.clear(); @@ -315,23 +344,20 @@ KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable) { dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_caron", L"Z", 0x017D, L"capital Z with caron"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"c", 0x010D, L"small C with caron"); + + line = createLine(L"dead_cedilla", L"c", 0x00E7, L"small C with cedilla"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"d", 0x010F, L"small D with caron"); + line = createLine(L"dead_cedilla", L"g", 0x0123, L"small G with cedilla"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"e", 0x011B, L"small E with caron"); + line = createLine(L"dead_cedilla", L"k", 0x0137, L"small K with cedilla"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"l", 0x013E, L"small L with caron"); + line = createLine(L"dead_cedilla", L"l", 0x013C, L"small L with cedilla"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"n", 0x0148, L"small N with caron"); + line = createLine(L"dead_cedilla", L"n", 0x0146, L"small N with cedilla"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"r", 0x0159, L"small R with caron"); + line = createLine(L"dead_cedilla", L"r", 0x0157, L"small R with cedilla"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"s", 0x0161, L"small S with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"t", 0x0165, L"small T with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"z", 0x017E, L"small Z with caron"); + line = createLine(L"dead_cedilla", L"s", 0x015F, L"small S with cedilla"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_cedilla", L"C", 0x00C7, L"capital C with cedilla"); dk_ComposeTable.push_back(line); line.clear(); @@ -347,28 +373,6 @@ KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable) { dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_cedilla", L"S", 0x015E, L"capital S with cedilla"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"c", 0x00E7, L"small C with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"g", 0x0123, L"small G with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"k", 0x0137, L"small K with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"l", 0x013C, L"small L with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"n", 0x0146, L"small N with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"r", 0x0157, L"small R with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"s", 0x015F, L"small S with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_ogonek", L"A", 0x0104, L"capital A with ogonek"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_ogonek", L"E", 0x0118, L"capital E with ogonek"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_ogonek", L"I", 0x012E, L"capital I with ogonek"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_ogonek", L"U", 0x0172, L"capital U with ogonek"); - dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_ogonek", L"a", 0x0105, L"small A with ogonek"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_ogonek", L"e", 0x0119, L"small E with ogonek"); @@ -378,8 +382,21 @@ KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable) { line = createLine(L"dead_ogonek", L"u", 0x0173, L"small U with ogonek"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_ogonek", L"A", 0x0104, L"capital A with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_ogonek", L"E", 0x0118, L"capital E with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_ogonek", L"I", 0x012E, L"capital I with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_ogonek", L"U", 0x0172, L"capital U with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); - + line = createLine(L"dead_circumflex", L"space", 0x005E, L"CIRCUMFLEX_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"space", 0x0027, L"APOSTROPHE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_grave", L"space", 0x0060, L"GRAVE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_breve", L"space", 0x02D8, L"BREVE"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_breve", L"dead_breve", 0x02D8, L"BREVE"); @@ -394,8 +411,6 @@ KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable) { dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_abovering", L"space", 0x02DA, L"RING_ABOVE"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"space", 0x0027, L"APOSTROPHE"); - dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_acute", L"apostrophe", 0x00B4, L"ACUTE_ACCENT"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_acute", L"acute", 0x00B4, L"ACUTE_ACCENT"); @@ -420,8 +435,6 @@ KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable) { dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_cedilla", L"dead_cedilla", 0x00B8, L"CEDILLA"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"space", 0x005E, L"CIRCUMFLEX_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_circumflex", L"minus", 0x00AF, L"MACRON"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_circumflex", L"asciicircum", 0x005E, L"CIRCUMFLEX_ACCENT"); @@ -436,8 +449,6 @@ KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable) { dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_diaeresis", L"dead_diaeresis", 0x00A8, L"DIAERESIS"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"space", 0x0060, L"GRAVE_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_grave", L"grave", 0x0060, L"GRAVE_ACCENT"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_grave", L"dead_grave", 0x0060, L"GRAVE_ACCENT"); @@ -462,5 +473,3 @@ KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable) { return 0; } - - diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index d5748e49b1..94f1ed0657 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -239,6 +239,9 @@ void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { } void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { + + //if (key->Key == 94) + // wprintf(L"key->ShiftFlags: %i isEqual: %i %i(%c) %i(%c) ---> %i \n", key->ShiftFlags, key->ShiftFlags & VIRTUALCHARKEY , key->Key , key->Key, ch,ch , ((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch)); if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" @@ -391,6 +394,7 @@ KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR deadkey, v_dw_3D &All_Vector, GdkKeymap* keymap) { KMX_WORD deadkeys[512], *pdk; + // _S2 create dkTable once only and use as static/ define before func // create dk_createDK_ComposeTable v_dw_2D dk_Table; create_DKTable(dk_Table); @@ -401,9 +405,21 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR d // Add the deadkey to the mapping table for use in the import rules phase KMX_DeadkeyMapping KMX_deadkeyMapping = { deadkey, dkid, shift, vk}; // I4353 - KMX_FDeadkeys.push_back(KMX_deadkeyMapping); //dkid, vk, shift); // I4353 - KMX_AddDeadkeyRule(kbd, dkid, vk, shift); + //__S2 NEEDS to be here later + /*KMX_FDeadkeys.push_back(KMX_deadkeyMapping); //dkid, vk, shift); // I4353 + KMX_AddDeadkeyRule(kbd, dkid, vk, shift);*/ + + // _S2 NEEDS to go! -------- + // _S2 is only for testing &to compare 3 dk of windows + if(KMX_FDeadkeys.size()<3 ) + KMX_FDeadkeys.push_back(KMX_deadkeyMapping); //dkid, vk, shift); // I4353 + if(shift== 0 || shift== 16 ) + KMX_AddDeadkeyRule(kbd, dkid, vk, shift); + else + return;; + // _S2 ----------------------------- + KMX_GetDeadkeys(dk_Table, deadkey, pdk = deadkeys, keymap); // returns array of [usvk, ch_out] pairs while(*pdk) { @@ -411,7 +427,7 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR d // Look up the ch UINT vkUnderlying = KMX_get_VKUS_From_VKUnderlying_VEC(All_Vector, *pdk); - wprintf(L" vkUnderlying %i *pdk %i ", vkUnderlying, *pdk); + wprintf(L" vkUnderlying %i *pdk %i %i %ixxx", vkUnderlying, *pdk, *(pdk+1), *(pdk+2)); if(vkUnderlying != (UINT) *pdk) { wprintf(L" TRANSLATED \n"); From 783dc4b6b4f123fefb2644d3734e1b25d095483d Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 31 Jan 2024 12:42:10 +0100 Subject: [PATCH 181/327] feat(linux): mcompile-dk :use deadkey(dkmax) , contents of alDead sorted; KMX_ToUnicodeEx returns 0 as well --- linux/mcompile/keymap/deadkey.cpp | 250 +++++++++++----------- linux/mcompile/keymap/keymap.cpp | 15 +- linux/mcompile/keymap/keymap.h | 3 +- linux/mcompile/keymap/mc_import_rules.cpp | 67 +++++- linux/mcompile/keymap/mcompile.cpp | 87 ++++---- 5 files changed, 239 insertions(+), 183 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index a46072dedc..940f673499 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -44,8 +44,9 @@ std::vector create_alDead() { DeadKey *dk2= new DeadKey(dk_ComposeTable[i][0]); for ( int j=0; j< dk_ComposeTable.size();j++) { // check for right dk - // _S2 do I need to trim here?? + // _S2 do I need to trim here?? Yes, to prevent "aAeEiIoOuU -ˆ_^" if(( dk_ComposeTable[i][0]==dk_ComposeTable[j][0]) && (IsKeymanUsedChar(dk_ComposeTable[j][1]))) + //if(( dk_ComposeTable[i][0]==dk_ComposeTable[j][0]) ) dk2->KMX_AddDeadKeyRow(dk_ComposeTable[j][1],dk_ComposeTable[j][2]); } alDead.push_back(dk2); @@ -112,282 +113,282 @@ KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable) { line = createLine(L"dead_circumflex", L"a", 0x00E2, L"small A with circumflex"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"e", 0x00EA, L"small E with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"i", 0x00EE, L"small I with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"o", 0x00F4, L"small O with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"u", 0x00FB, L"small U with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_circumflex", L"A", 0x00C2, L"capital A with circumflex"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_circumflex", L"e", 0x00EA, L"small E with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_circumflex", L"E", 0x00CA, L"capital E with circumflex"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_circumflex", L"i", 0x00EE, L"small I with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_circumflex", L"I", 0x00CE, L"capital I with circumflex"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_circumflex", L"o", 0x00F4, L"small O with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_circumflex", L"O", 0x00D4, L"capital O with circumflex"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_circumflex", L"u", 0x00FB, L"small U with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_circumflex", L"U", 0x00DB, L"capital U with circumflex"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_acute", L"a", 0x00E1, L"small A with acute"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"c", 0x0107, L"small C with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"e", 0x00E9, L"small E with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"i", 0x00ED, L"small I with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"l", 0x013A, L"small L with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"n", 0x0144, L"small N with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"o", 0x00F3, L"small O with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"r", 0x0155, L"small R with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"s", 0x015B, L"small S with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"u", 0x00FA, L"small U with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"y", 0x00FD, L"small Y with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"z", 0x017A, L"small Z with acute"); - dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_acute", L"A", 0x00C1, L"capital A with acute"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"c", 0x0107, L"small C with acute"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_acute", L"C", 0x0106, L"capital C with acute"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"e", 0x00E9, L"small E with acute"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_acute", L"E", 0x00C9, L"capital E with acute"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"i", 0x00ED, L"small I with acute"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_acute", L"I", 0x00CD, L"capital I with acute"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"l", 0x013A, L"small L with acute"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_acute", L"L", 0x0139, L"capital L with acute"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"n", 0x0144, L"small N with acute"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_acute", L"N", 0x0143, L"capital N with acute"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"o", 0x00F3, L"small O with acute"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_acute", L"O", 0x00D3, L"capital O with acute"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"r", 0x0155, L"small R with acute"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_acute", L"R", 0x0154, L"capital R with acute"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"s", 0x015B, L"small S with acute"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_acute", L"S", 0x015A, L"capital S with acute"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"u", 0x00FA, L"small U with acute"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_acute", L"U", 0x00DA, L"capital U with acute"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"y", 0x00FD, L"small Y with acute"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_acute", L"Y", 0x00DD, L"capital Y with acute"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"z", 0x017A, L"small Z with acute"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_acute", L"Z", 0x0179, L"capital Z with acute"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_grave", L"a", 0x00E0, L"small A with grave"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"e", 0x00E8, L"small E with grave"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"i", 0x00EC, L"small I with grave"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"o", 0x00F2, L"small O with grave"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"u", 0x00F9, L"small U with grave"); - dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_grave", L"A", 0x00C0, L"capital A with grave"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_grave", L"e", 0x00E8, L"small E with grave"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_grave", L"E", 0x00C8, L"capital E with grave"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_grave", L"i", 0x00EC, L"small I with grave"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_grave", L"I", 0x00CC, L"capital I with grave"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_grave", L"o", 0x00F2, L"small O with grave"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_grave", L"O", 0x00D2, L"capital O with grave"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_grave", L"u", 0x00F9, L"small U with grave"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_grave", L"U", 0x00D9, L"capital U with grave"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_tilde", L"a", 0x00E3, L"small A with tilde"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_tilde", L"i", 0x0129, L"small I with tilde"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_tilde", L"n", 0x00F1, L"small N with tilde"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_tilde", L"o", 0x00F5, L"small O with tilde"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_tilde", L"u", 0x0169, L"small U with tilde"); - dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_tilde", L"A", 0x00C3, L"capital A with tilde"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_tilde", L"i", 0x0129, L"small I with tilde"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_tilde", L"I", 0x0128, L"capital I with tilde"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_tilde", L"n", 0x00F1, L"small N with tilde"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_tilde", L"N", 0x00D1, L"capital N with tilde"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_tilde", L"o", 0x00F5, L"small O with tilde"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_tilde", L"O", 0x00D5, L"capital O with tilde"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_tilde", L"u", 0x0169, L"small U with tilde"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_tilde", L"U", 0x0168, L"capital U with tilde"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_macron", L"a", 0x0101, L"small A with macron"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_macron", L"e", 0x0113, L"small E with macron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_macron", L"i", 0x012B, L"small I with macron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_macron", L"o", 0x014D, L"small O with macron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_macron", L"u", 0x016B, L"small U with macron"); - dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_macron", L"A", 0x0100, L"capital A with macron"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_macron", L"e", 0x0113, L"small E with macron"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_macron", L"E", 0x0112, L"capital E with macron"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_macron", L"i", 0x012B, L"small I with macron"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_macron", L"I", 0x012A, L"capital I with macron"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_macron", L"o", 0x014D, L"small O with macron"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_macron", L"O", 0x014C, L"capital O with macron"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_macron", L"u", 0x016B, L"small U with macron"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_macron", L"U", 0x016A, L"capital U with macron"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_breve", L"a", 0x0103, L"small A with breve"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_breve", L"g", 0x011F, L"small G with breve"); - dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_breve", L"A", 0x0102, L"capital A with breve"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_breve", L"g", 0x011F, L"small G with breve"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_breve", L"G", 0x011E, L"capital G with breve"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_abovedot", L"e", 0x0117, L"small E with dot above"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_abovedot", L"i", 0x0131, L"small DOTLESS_I"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_abovedot", L"z", 0x017C, L"small Z with dot above"); - dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_abovedot", L"E", 0x0116, L"capital E with dot above"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_abovedot", L"i", 0x0131, L"small DOTLESS_I"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_abovedot", L"I", 0x0130, L"capital I with dot above"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_abovedot", L"z", 0x017C, L"small Z with dot above"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_abovedot", L"Z", 0x017B, L"capital Z with dot above"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_diaeresis", L"a", 0x00E4, L"small A with diaeresis"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"e", 0x00EB, L"small E with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"i", 0x00EF, L"small I with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"o", 0x00F6, L"small O with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"u", 0x00FC, L"small U with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"y", 0x00FF, L"small Y with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_diaeresis", L"A", 0x00C4, L"capital A with diaeresis"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_diaeresis", L"e", 0x00EB, L"small E with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_diaeresis", L"E", 0x00CB, L"capital E with diaeresis"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_diaeresis", L"i", 0x00EF, L"small I with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_diaeresis", L"I", 0x00CF, L"capital I with diaeresis"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_diaeresis", L"o", 0x00F6, L"small O with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_diaeresis", L"O", 0x00D6, L"capital O with diaeresis"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_diaeresis", L"u", 0x00FC, L"small U with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_diaeresis", L"U", 0x00DC, L"capital U with diaeresis"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_diaeresis", L"y", 0x00FF, L"small Y with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_diaeresis", L"Y", 0x0178, L"capital Y with diaeresis"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_abovering", L"a", 0x00E5, L"small A with ring above"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_abovering", L"u", 0x016F, L"small U with ring above"); - dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_abovering", L"A", 0x00C5, L"capital A with ring above"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_abovering", L"u", 0x016F, L"small U with ring above"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_abovering", L"U", 0x016E, L"capital U with ring above"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_doubleacute", L"o", 0x0151, L"small O with double acute"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_doubleacute", L"u", 0x0171, L"small U with double acute"); - dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_doubleacute", L"O", 0x0150, L"capital O with double acute"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_doubleacute", L"u", 0x0171, L"small U with double acute"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_doubleacute", L"U", 0x0170, L"capital U with double acute"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_caron", L"c", 0x010D, L"small C with caron"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"d", 0x010F, L"small D with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"e", 0x011B, L"small E with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"l", 0x013E, L"small L with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"n", 0x0148, L"small N with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"r", 0x0159, L"small R with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"s", 0x0161, L"small S with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"t", 0x0165, L"small T with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"z", 0x017E, L"small Z with caron"); - dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_caron", L"C", 0x010C, L"capital C with caron"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"d", 0x010F, L"small D with caron"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_caron", L"D", 0x010E, L"capital D with caron"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"e", 0x011B, L"small E with caron"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_caron", L"E", 0x011A, L"capital E with caron"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"l", 0x013E, L"small L with caron"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_caron", L"L", 0x013D, L"capital L with caron"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"n", 0x0148, L"small N with caron"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_caron", L"N", 0x0147, L"capital N with caron"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"r", 0x0159, L"small R with caron"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_caron", L"R", 0x0158, L"capital R with caron"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"s", 0x0161, L"small S with caron"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_caron", L"S", 0x0160, L"capital S with caron"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"t", 0x0165, L"small T with caron"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_caron", L"T", 0x0164, L"capital T with caron"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"z", 0x017E, L"small Z with caron"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_caron", L"Z", 0x017D, L"capital Z with caron"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_cedilla", L"c", 0x00E7, L"small C with cedilla"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"g", 0x0123, L"small G with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"k", 0x0137, L"small K with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"l", 0x013C, L"small L with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"n", 0x0146, L"small N with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"r", 0x0157, L"small R with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"s", 0x015F, L"small S with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_cedilla", L"C", 0x00C7, L"capital C with cedilla"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"g", 0x0123, L"small G with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_cedilla", L"G", 0x0122, L"capital G with cedilla"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"k", 0x0137, L"small K with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_cedilla", L"K", 0x0136, L"capital K with cedilla"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"l", 0x013C, L"small L with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_cedilla", L"L", 0x013B, L"capital L with cedilla"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"n", 0x0146, L"small N with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_cedilla", L"N", 0x0145, L"capital N with cedilla"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"r", 0x0157, L"small R with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_cedilla", L"R", 0x0156, L"capital R with cedilla"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"s", 0x015F, L"small S with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_cedilla", L"S", 0x015E, L"capital S with cedilla"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_ogonek", L"a", 0x0105, L"small A with ogonek"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_ogonek", L"A", 0x0104, L"capital A with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_ogonek", L"e", 0x0119, L"small E with ogonek"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_ogonek", L"i", 0x012F, L"small I with ogonek"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_ogonek", L"u", 0x0173, L"small U with ogonek"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine(L"dead_ogonek", L"A", 0x0104, L"capital A with ogonek"); - dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_ogonek", L"E", 0x0118, L"capital E with ogonek"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_ogonek", L"i", 0x012F, L"small I with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_ogonek", L"I", 0x012E, L"capital I with ogonek"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_ogonek", L"u", 0x0173, L"small U with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_ogonek", L"U", 0x0172, L"capital U with ogonek"); dk_ComposeTable.push_back(line); line.clear(); @@ -399,36 +400,41 @@ KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable) { dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_breve", L"space", 0x02D8, L"BREVE"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_breve", L"dead_breve", 0x02D8, L"BREVE"); - dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_abovedot", L"space", 0x02D9, L"DOT_ABOVE"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_abovering", L"space", 0x02DA, L"RING_ABOVE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_doubleacute", L"space", 0x02DD, L"DOUBLE_ACUTE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_caron", L"space", 0x02C7, L"CARON"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_cedilla", L"space", 0x00B8, L"CEDILLA"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_ogonek", L"space", 0x02DB, L"OGONEK"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_tilde", L"space", 0x007E, L"TILDE"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine(L"dead_breve", L"dead_breve", 0x02D8, L"BREVE"); + dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_abovedot", L"abovedot", 0x02D9, L"DOT_ABOVE"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_abovedot", L"dead_abovedot", 0x02D9, L"DOT_ABOVE"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_abovering", L"dead_abovering", 0x02DA, L"RING_ABOVE"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_abovering", L"space", 0x02DA, L"RING_ABOVE"); - dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_acute", L"apostrophe", 0x00B4, L"ACUTE_ACCENT"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_acute", L"acute", 0x00B4, L"ACUTE_ACCENT"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_acute", L"dead_acute", 0x00B4, L"ACUTE_ACCENT"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_doubleacute", L"space", 0x02DD, L"DOUBLE_ACUTE_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_doubleacute", L"dead_doubleacute", 0x02DD, L"DOUBLE_ACUTE_ACCENT"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"space", 0x02C7, L"CARON"); - dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_caron", L"caron", 0x02C7, L"CARON"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_caron", L"dead_caron", 0x02C7, L"CARON"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"space", 0x00B8, L"CEDILLA"); - dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_cedilla", L"comma", 0x00B8, L"CEDILLA"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_cedilla", L"cedilla", 0x00B8, L"CEDILLA"); @@ -457,14 +463,10 @@ KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable) { dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_macron", L"dead_macron", 0x00AF, L"MACRON"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_ogonek", L"space", 0x02DB, L"OGONEK"); - dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_ogonek", L"ogonek", 0x02DB, L"OGONEK"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_ogonek", L"dead_ogonek", 0x02DB, L"OGONEK"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_tilde", L"space", 0x007E, L"TILDE"); - dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_tilde", L"asciitilde", 0x007E, L"TILDE"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_tilde", L"dead_tilde", 0x007E, L"TILDE"); diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 7375d7e1c4..aee3777d12 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -153,7 +153,7 @@ int replace_KeyName_with_Keycode(std::string in) { int out = returnIfCharInvalid; // these are the Scancode-Values we use in Keyman (= windows scancodes+8 ) - if ( in == "key") out = 49; /* VK_ */ + if ( in == "key") out = 49; /* VK_ BKQUOTE */ else if ( in == "key") out = 10; /* VK_1 */ else if ( in == "key") out = 11; /* VK_2 */ else if ( in == "key") out = 12; /* VK_3 */ @@ -164,8 +164,8 @@ int replace_KeyName_with_Keycode(std::string in) { else if ( in == "key") out = 17; /* VK_8 */ else if ( in == "key") out = 18; /* VK_9 */ else if ( in == "key") out = 19; /* VK_0 */ - else if ( in == "key") out = 20; /* VK_MINUS de ẞ */ - else if ( in == "key") out = 21; /* VK_EQUALS DE ' */ + else if ( in == "key") out = 20; /* VK_MINUS K_HYPHEN de ẞ */ + else if ( in == "key") out = 21; /* VK_EQUAL DE ' */ else if ( in == "key") out = 24; /* VK_Q */ else if ( in == "key") out = 25; /* VK_W */ @@ -391,7 +391,7 @@ std::wstring convert_DeadkeyValues_ToChar(int in) { KMX_DWORD lname; - if (in <= (int) deadkey_min) { // no deadkey; no Unicode + if (in < (int) deadkey_min) { // no deadkey; no Unicode if (!IsKeymanUsedKeyVal(std::wstring(1, in))) return L"\0"; return std::wstring(1, in); @@ -586,9 +586,11 @@ KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(Gdk } else return 0; - +//hier wird fffe returned ist das OK? if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max)) return 0xFFFF; + if((*keyvals > deadkey_max) || ((*keyvals < deadkey_min) && ( *keyvals > 0xFF))) + return 0xFFFE; else return (KMX_DWORD) *keyvals; } @@ -788,6 +790,7 @@ KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD return (KMX_DWORD) upperCase; } + KMX_DWORD testvar_S2 = ScanCodeToUSVirtualKey[keycode-8]; if ( keycode >7) return (KMX_DWORD) ScanCodeToUSVirtualKey[keycode-8]; @@ -795,7 +798,7 @@ KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD } KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS( KMX_DWORD VK_US) { - +KMX_DWORD test_S2 = (8+ USVirtualKeyToScanCode[ VK_US ]); if( VK_US > 7) { return (KMX_DWORD)(8+ USVirtualKeyToScanCode[ VK_US ]);} else diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index b07927789a..0eb64a9568 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -44,7 +44,7 @@ const KMX_DWORD KMX_VKMap[] = { VK_SPACE, /* 32 */ - VK_ACCENT, /* 192 VK_OEM_3 */ + VK_ACCENT, /* 192 VK_OEM_3 K_BKQUOTE */ VK_HYPHEN, /* - 189 VK_OEM_MINUS */ VK_EQUAL, /* = 187 VK_OEM_PLUS */ @@ -61,7 +61,6 @@ const KMX_DWORD KMX_VKMap[] = { VK_xDF, /* ß (?) 223*/ VK_OEM_102, /* < > | 226 */ - 0 }; diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index bdac85d397..479559e864 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -28,6 +28,43 @@ #include "keymap.h" + +void TestKey_S21(LPKMX_KEY key, int iii, int gr) { + + KMX_WCHAR* PP= key->dpOutput; + int z=0; + + if( *(key->dpOutput+1) != 0) { + wprintf(L"\n group[%i] dpKeyArray[%i] (key->key: %i) ",gr, iii, key->Key); + int tzuiop=0; + do { + wprintf(L"%i\t", *(PP+z )); + z++; + } while (*(PP+z) !=0); + } + //if ((*(PP+z) !=0)) wprintf(L" _\n"); +} + +void TestGroup_S21(LPKMX_GROUP group ,int gr) { + for(unsigned int i = 0; i < group->cxKeyArray; i++) { + TestKey_S21(&group->dpKeyArray[i],i,gr); + } +} + +void TestKeyboard_S21(LPKMX_KEYBOARD kbd) { + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + wprintf(L"\nkbd->dpGroupArray[%i] \n",i); + TestGroup_S21(&kbd->dpGroupArray[i], i); + } + } +} + +// _S2 can go later +void test_keyboard_S21(LPKMX_KEYBOARD kmxfile){ + //TestKeyboard_S21(kmxfile); +} + const int KMX_ShiftStateMap[] = { ISVIRTUALKEY, ISVIRTUALKEY | K_SHIFTFLAG, @@ -89,7 +126,9 @@ int KMX_ToUnicodeEx(guint ScanCode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, std::u16string uuu16= u16string_from_wstring(character).c_str(); pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(character).c_str(); - if((kvl == 0xFFFF)) + if((kvl == 0xFFFE)) + return 0; + if((kvl == 0xFFFF)) return -1; return 1; } @@ -224,8 +263,8 @@ public: } UINT KMX_GetShiftStateValue(int capslock, int caps, ShiftState ss) { - //wprintf(L"GetShiftStateValue takes capslock: %i, caps: %i, ss: %i and returns: %i\n", capslock, caps, ss, KMX_ShiftStateMap[(int)ss] | - //(capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0)); + //wprintf(L"GetShiftStateValue takes capslock: %i, caps: %i, ss: %i and returns: %i \n", + //capslock, caps, ss, (KMX_ShiftStateMap[(int)ss] | (capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0))); return KMX_ShiftStateMap[(int)ss] | (capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0); @@ -288,7 +327,7 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; (this->KMX_IsSGCAPS() ? 2 : 0) | (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); - +//wprintf(L"capslock is: %i\n",capslock); // _S2 DESIGN NEEDED on how to replace capslock capslock=1; // _S2 // _S2 TODO capslock is not calculated correctly for linux. therefore key->ShiftFlags will be wrong for numbers, special characters @@ -306,12 +345,16 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; if (st.size() == 0) { // No character assigned here } + // _S2 kommt er hier immer hin???? // _S2 TODO deadkeys don't work yet/ if true is in m_rgfDeadKey else if (this->m_rgfDeadKey[(int)ss][caps]) { // It's a dead key, append an @ sign. key->dpContext = new KMX_WCHAR[1]; *key->dpContext = 0; + + wprintf(L"st %i ", st[0]); key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); + //key->ShiftFlags = this->KMX_GetShiftStateValue(1, caps, (ShiftState) ss); //key->Key = KMX_get_VKUS_From_VKUnderlying_VEC(All_Vector,this->VK()); // key->Key = KMX_get_VKUnderlying_From_VKUS_GDK(keymap,this->VK()); key->Line = 0; @@ -697,11 +740,11 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // Alt and Shift+Alt don't work, so skip them continue; } -/* + //_S2 to compare win-lin kmn-files skip ss6+7; MUST BE restored/removed later!!!! if(ss == MenuCtrl|| ss == ShftMenuCtrl) { continue; - }*/ + } KMX_DWORD SC_US = KMX_get_KeyCodeUnderlying_From_VKUS(iKey); @@ -840,7 +883,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { nKeys+= rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()); - //wprintf(L" iKey = %i, Delta: %i -> Sum %i\n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()), nKeys); + //wprintf(L" iKey = %i, Delta: %i -> Sum %i\n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()), nKeys); } } @@ -890,6 +933,12 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, UINT j; LPKMX_KEY kkp; for(j = 0, kkp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kkp++) { + // _S2 missing 26 lines from here: since capalock is not correct this loop will never be done + //wprintf(L"will add Rule for group %i and key %i - shiftflag %i \n", i, kkp->Key, kkp->ShiftFlags); + KMX_DWORD S_S2 = kkp->ShiftFlags; + bool eins= (K_CTRLFLAG|K_ALTFLAG|LCTRLFLAG|LALTFLAG|RCTRLFLAG|RALTFLAG); + bool test_S_S2 = ((kkp->ShiftFlags & (K_CTRLFLAG|K_ALTFLAG|LCTRLFLAG|LALTFLAG|RCTRLFLAG|RALTFLAG)) != 0); + if((kkp->ShiftFlags & (K_CTRLFLAG|K_ALTFLAG|LCTRLFLAG|LALTFLAG|RCTRLFLAG|RALTFLAG)) != 0) { gp2->cxKeyArray++; LPKMX_KEY kkp2 = new KMX_KEY[gp2->cxKeyArray]; @@ -899,15 +948,19 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, kkp2->dpContext = new KMX_WCHAR; *kkp2->dpContext = 0; kkp2->Key = kkp->Key; kkp2->ShiftFlags = kkp->ShiftFlags; + //kkp2->ShiftFlags = 16384; kkp2->Line = 0; KMX_WCHAR *p = kkp2->dpOutput = new KMX_WCHAR[4]; KMX_WCHAR *q=p; *p++ = UC_SENTINEL; *p++ = CODE_USE; *p++ = (KMX_WCHAR)(kp->cxGroupArray); + //wprintf(L" --------------------------------did Rule for group %i and key %i - shiftflag %i \n", i, kkp->Key, kkp->ShiftFlags); *p = 0; } } + //test_keyboard_S21(kp); + int sdfghjk=0; } } diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 94f1ed0657..11b81d3706 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -238,10 +238,17 @@ void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { } } -void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { - +void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch, int abcd) { +PKMX_WCHAR PP = key->dpOutput; //if (key->Key == 94) // wprintf(L"key->ShiftFlags: %i isEqual: %i %i(%c) %i(%c) ---> %i \n", key->ShiftFlags, key->ShiftFlags & VIRTUALCHARKEY , key->Key , key->Key, ch,ch , ((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch)); + +/*if(abcd >1 && abcd < 815 ) { + +wprintf(L"key->Key %i\tkey->dpContext: %i %i %i %i %i %i %i %i %i \tkey->dpoutput: %i %i %i %i %i %i\n", key->Key, +*key->dpContext, *(key->dpContext+1),*(key->dpContext+2),*(key->dpContext+3),*(key->dpContext+4),*(key->dpContext+5),*(key->dpContext+6),*(key->dpContext+7),*(key->dpContext+8), +*key->dpOutput, *(key->dpOutput+1),*(key->dpOutput+2),*(key->dpOutput+3),*(key->dpOutput+4),*(key->dpOutput+5) ); +}*/ if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" @@ -251,11 +258,11 @@ void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT if(key->ShiftFlags == 0) { //LogError("Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d]", key->Line, key->Key, deadkey, shift, vk); - wprintf(L"DK Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d], %i(%c)\n", key->Line, key->Key, deadkey, shift, vk, ch, ch); + //wprintf(L"DK Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d], %i(%c)\n", key->Line, key->Key, deadkey, shift, vk, ch, ch); key->ShiftFlags = ISVIRTUALKEY | shift; } else { //LogError("Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO dk(%d) + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, deadkey, key->ShiftFlags & ~VIRTUALCHARKEY, vk); - wprintf(L"DK Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO dk(%d) + [%x K_%d], %i(%c)\n", key->Line, key->ShiftFlags, key->Key, deadkey, key->ShiftFlags & ~VIRTUALCHARKEY, vk, ch, ch); + //wprintf(L"DK Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO dk(%d) + [%x K_%d], %i(%c)\n", key->Line, key->ShiftFlags, key->Key, deadkey, key->ShiftFlags & ~VIRTUALCHARKEY, vk, ch, ch); key->ShiftFlags &= ~VIRTUALCHARKEY; } @@ -270,17 +277,21 @@ void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT key->dpContext = context; key->Key = vk; } + int sdfgh=0; } void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group,KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { for(unsigned int i = 0; i < group->cxKeyArray; i++) { - KMX_TranslateDeadkeyKey(&group->dpKeyArray[i], deadkey, vk, shift, ch); + //wprintf(L" key: %i\n",i ); + KMX_TranslateDeadkeyKey(&group->dpKeyArray[i], deadkey, vk, shift, ch, i); } } void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { if(kbd->dpGroupArray[i].fUsingKeys) { + + wprintf(L" group: %i\n",i ); KMX_TranslateDeadkeyGroup(&kbd->dpGroupArray[i], deadkey, vk, shift, ch); } } @@ -407,34 +418,34 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR d KMX_DeadkeyMapping KMX_deadkeyMapping = { deadkey, dkid, shift, vk}; // I4353 //__S2 NEEDS to be here later - /*KMX_FDeadkeys.push_back(KMX_deadkeyMapping); //dkid, vk, shift); // I4353 - KMX_AddDeadkeyRule(kbd, dkid, vk, shift);*/ + KMX_FDeadkeys.push_back(KMX_deadkeyMapping); //dkid, vk, shift); // I4353 + KMX_AddDeadkeyRule(kbd, dkid, vk, shift); // _S2 NEEDS to go! -------- - // _S2 is only for testing &to compare 3 dk of windows + /*// _S2 is only for testing &to compare 3 dk of windows if(KMX_FDeadkeys.size()<3 ) KMX_FDeadkeys.push_back(KMX_deadkeyMapping); //dkid, vk, shift); // I4353 if(shift== 0 || shift== 16 ) KMX_AddDeadkeyRule(kbd, dkid, vk, shift); else - return;; + return;;*/ // _S2 ----------------------------- KMX_GetDeadkeys(dk_Table, deadkey, pdk = deadkeys, keymap); // returns array of [usvk, ch_out] pairs - +//test_keyboard_S2(kbd); while(*pdk) { // Look up the ch UINT vkUnderlying = KMX_get_VKUS_From_VKUnderlying_VEC(All_Vector, *pdk); - wprintf(L" vkUnderlying %i *pdk %i %i %ixxx", vkUnderlying, *pdk, *(pdk+1), *(pdk+2)); + //wprintf(L" vkUnderlying %i *pdk %i %i %ixxx", vkUnderlying, *pdk, *(pdk+1), *(pdk+2)); + KMX_TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); if(vkUnderlying != (UINT) *pdk) { - wprintf(L" TRANSLATED \n"); - KMX_TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); + //wprintf(L" TRANSLATED \n"); } - else - wprintf(L" \n"); + //else + //wprintf(L" \n"); pdk+=3; } } @@ -515,9 +526,8 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg } } - //test_keyboard_S2(kbd); //-> HIER SCHON FALSCH + //test_keyboard_S2(kbd); KMX_ReportUnconvertedKeyboardRules(kbd); - if(!KMX_ImportRules(kbd, All_Vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 return FALSE; } @@ -643,47 +653,36 @@ int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, // _S2 can go later void test_keyboard_S2(LPKMX_KEYBOARD kmxfile){ - TestKeyboard_S2(kmxfile); } -void TestKey_S2(LPKMX_KEY key) { - //wprintf(L"key->dpOutput %i %i %i %i \n ",*key->dpOutput,*(key->dpOutput+1),*(key->dpOutput+2),*(key->dpOutput+3),*(key->dpOutput+4) ); +void TestKey_S2(LPKMX_KEY key, int iii, int gr) { - wprintf(L" %i ",*key->dpOutput); - for (int i=1; i<8;i++) { - if( *(key->dpOutput+i) != 0) - wprintf(L" %i\t", *(key->dpOutput+i) ); - else - break; -} -wprintf(L" _\n"); + KMX_WCHAR* PP= key->dpOutput; + int z=0; - - /*//wprintf(L" stopped at len for %i %i (%c) %c \n", key->Key, vk, vk, ch); - PWSTR context = new WCHAR[len + 4]; - memcpy(context, key->dpContext, len * sizeof(WCHAR)); - context[len] = UC_SENTINEL; - context[len+1] = CODE_DEADKEY; - context[len+2] = deadkey; - context[len+3] = 0; - key->dpContext = context; - key->Key = vk; - }*/ + if( *(key->dpOutput+1) != 0) { + wprintf(L"\n group[%i] dpKeyArray[%i] ",gr, iii); + int tzuiop=0; + do { + wprintf(L"%i\t", *(PP+z )); + z++; + } while (*(PP+z) !=0); + } + //if ((*(PP+z) !=0)) wprintf(L" _\n"); } -void TestGroup_S2(LPKMX_GROUP group) { +void TestGroup_S2(LPKMX_GROUP group ,int gr) { for(unsigned int i = 0; i < group->cxKeyArray; i++) { - wprintf(L" dpKeyArray[i] %i ",i ); - TestKey_S2(&group->dpKeyArray[i]); + TestKey_S2(&group->dpKeyArray[i],i,gr); } } void TestKeyboard_S2(LPKMX_KEYBOARD kbd) { for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { if(kbd->dpGroupArray[i].fUsingKeys) { - wprintf(L"kbd->dpGroupArray[i] %i \n",i); - TestGroup_S2(&kbd->dpGroupArray[i]); + wprintf(L"\nkbd->dpGroupArray[%i] \n",i); + TestGroup_S2(&kbd->dpGroupArray[i], i); } } } From 6af536a174e4c9180585001e5128e2f85aded272 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 1 Feb 2024 16:16:16 +0100 Subject: [PATCH 182/327] feat(linux): mcompile-dk more shiftstates in KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK --- linux/mcompile/keymap/keymap.cpp | 21 ++++++-- linux/mcompile/keymap/mc_import_rules.cpp | 60 ++++++++++++++++++++--- linux/mcompile/keymap/mcompile.cpp | 6 +-- 3 files changed, 72 insertions(+), 15 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index aee3777d12..5d798cf035 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -2,6 +2,7 @@ #include + // _S2 is return 2 + 3 correct??? YES, it talking about the column-nr in symbols-file int map_VKShiftState_to_Lin(int VKShiftState) { if (VKShiftState == 0 ) return 0; /* 0000 0000 */ @@ -13,6 +14,7 @@ int map_VKShiftState_to_Lin(int VKShiftState) { } KMX_DWORD convertNamesToIntegerValue(std::wstring tok_wstr){ + // more on https://manpages.ubuntu.com/manpages/jammy/man3/keysyms.3tk.html std::map first; first[L"ampersand"] = 38; @@ -22,6 +24,7 @@ KMX_DWORD convertNamesToIntegerValue(std::wstring tok_wstr){ first[L"asterisk"] = 42; first[L"at"] = 64; first[L"backslash"] = 92; + first[L"BackSpace"] = 65288; first[L"bar"] = 124; first[L"braceleft"] = 123; first[L"braceright"] = 125; @@ -630,8 +633,8 @@ std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(Gdk gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); } - /* - // Ctrl (shiftstate: 2) + // _S2 if I include this we get deadkey(65535) instead of deadkey(3) + /*// Ctrl (shiftstate: 2) else if (( ss == Ctrl ) && ( caps == 0 )){ GdkModifierType MOD_Ctrl = (GdkModifierType) ( GDK_MOD2_MASK ); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl , 0, keyvals, NULL, NULL, & consumed); @@ -641,9 +644,19 @@ std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(Gdk else if (( ss == Ctrl ) && ( caps == 1 )){ GdkModifierType MOD_CtrlCaps = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_LOCK_MASK) ); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps , 0, keyvals, NULL, NULL, & consumed); + }*/ + + /*// SHIFT+Ctrl (shiftstate: 3) + else if (( ss == ShftCtrl ) && ( caps == 0 )){ + GdkModifierType MOD_Ctrl = (GdkModifierType) (GDK_SHIFT_MASK | GDK_MOD2_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl , 0, keyvals, NULL, NULL, & consumed); } - // SHIFT+Ctrl (shiftstate: 3) - */ + + // SHIFT+Ctrl (shiftstate: 3) + else if (( ss == ShftCtrl ) && ( caps == 1 )){ + GdkModifierType MOD_CtrlCaps = (GdkModifierType) (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_LOCK_MASK); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps , 0, keyvals, NULL, NULL, & consumed); + }*/ //ALT-GR (shiftstate: 6) else if (( ss == MenuCtrl ) && ( caps == 0 )){ diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 479559e864..b60d233033 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -27,8 +27,6 @@ #include "mc_kmxfile.h" #include "keymap.h" - - void TestKey_S21(LPKMX_KEY key, int iii, int gr) { KMX_WCHAR* PP= key->dpOutput; @@ -170,6 +168,7 @@ public: this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying_GDK(*keymap, scanCode); this->m_hkl = hkl; this->m_sc = scanCode; + //KMX_InitializeDeadkeys(); // _S2 to get all 0 in rgfDeadkey[ ][ ]- why were there numbers??? } UINT VK() { @@ -183,6 +182,19 @@ public: std::wstring get_m_rgss(int i,int j) { return m_rgss[i][j]; } + // _S2 can go later + bool get_m_rgfDeadkey(int i,int j) { + return m_rgfDeadKey[i][j]; + } + + // _S2 do we need this?? + void KMX_InitializeDeadkeys() { + for ( int i=0; i<10;i++) { + for ( int j=0; j<2;j++) { + this->m_rgfDeadKey[i][j] = 0; + } + } + } std::wstring KMX_GetShiftState(ShiftState shiftState, bool capsLock) { return this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)]; @@ -193,6 +205,7 @@ public: this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; } +// _S2 why are there sometimes numbers in m_rgfDeadKey??? void KMX_SetShiftState(ShiftState shiftState, std::u16string value16, bool isDeadKey, bool capsLock) { std::wstring value = wstring_from_u16string(value16); this->m_rgfDeadKey[(UINT)shiftState][(capsLock ? 1 : 0)] = isDeadKey; @@ -352,7 +365,7 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; key->dpContext = new KMX_WCHAR[1]; *key->dpContext = 0; - wprintf(L"st %i ", st[0]); + wprintf(L"st %i \n", st[0]); key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); //key->ShiftFlags = this->KMX_GetShiftStateValue(1, caps, (ShiftState) ss); //key->Key = KMX_get_VKUS_From_VKUnderlying_VEC(All_Vector,this->VK()); @@ -391,10 +404,16 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; key->Line = 0; key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); - key->dpContext = new KMX_WCHAR; *key->dpContext = 0; + + //_S2 needs to go later + /*if(this->m_vk==192) + key->ShiftFlags=16400;*/ + + key->dpContext = new KMX_WCHAR; + *key->dpContext = 0; p = key->dpOutput = new KMX_WCHAR[st.size() + 1]; - p_S2 = p; + p_S2 = key->dpContext; for(size_t ich = 0; ich < st.size(); ich++) { *p++ = st[ich]; } @@ -404,6 +423,8 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; } } } + //wprintf(L"key->Key: %i %c\n",(key--)->Key,(key--)->Key); + int keyvalis= (key--)->Key; return true; } }; @@ -655,6 +676,21 @@ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { return n; }*/ +void check_rgkey_S2( std::vector rgKey, int i) { + + wprintf(L" rgfDeadkey[%i]: \t%i %i %i %i %i %i %i %i %i %i\n", i, + rgKey[i]->get_m_rgfDeadkey(0,0), rgKey[i]->get_m_rgfDeadkey(0,1), + rgKey[i]->get_m_rgfDeadkey(1,0), rgKey[i]->get_m_rgfDeadkey(1,1), + rgKey[i]->get_m_rgfDeadkey(2,0), rgKey[i]->get_m_rgfDeadkey(2,1), + rgKey[i]->get_m_rgfDeadkey(3,0), rgKey[i]->get_m_rgfDeadkey(3,1), + rgKey[i]->get_m_rgfDeadkey(4,0), rgKey[i]->get_m_rgfDeadkey(4,1), + rgKey[i]->get_m_rgfDeadkey(5,0), rgKey[i]->get_m_rgfDeadkey(5,1), + rgKey[i]->get_m_rgfDeadkey(6,0), rgKey[i]->get_m_rgfDeadkey(6,1), + rgKey[i]->get_m_rgfDeadkey(7,0), rgKey[i]->get_m_rgfDeadkey(7,1), + rgKey[i]->get_m_rgfDeadkey(8,0), rgKey[i]->get_m_rgfDeadkey(8,1), + rgKey[i]->get_m_rgfDeadkey(9,0), rgKey[i]->get_m_rgfDeadkey(9,1)); +} + bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 KMX_Loader loader; @@ -683,6 +719,9 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // this "connection" is possible only while using All_Vector KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, keymap); + // if(rgKey[sc] != NULL) + // check_rgkey_S2(rgKey, sc); + if((key->VK() != 0) ) { rgKey[key->VK()] = key; } else { @@ -690,6 +729,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, } } + for(UINT ke = VK_NUMPAD0; ke <= VK_NUMPAD9; ke++) { rgKey[ke] = new KMX_VirtualKey(hkl, ke, keymap); } @@ -730,9 +770,12 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, } */ + // in this part we skip shiftstates 4, 5, 8, 9 for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { + if(rgKey[iKey] != NULL) { +//check_rgkey_S2(rgKey, iKey); KMX_WCHAR sbBuffer[256]; // Scratchpad we use many places for(ShiftState ss = Base; ss <= loader.KMX_MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { @@ -745,7 +788,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, if(ss == MenuCtrl|| ss == ShftMenuCtrl) { continue; } - +//check_rgkey_S2(rgKey, iKey); KMX_DWORD SC_US = KMX_get_KeyCodeUnderlying_From_VKUS(iKey); // _S2 deadkey not finished; Ctrl, Shft +40 not tested @@ -834,7 +877,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, for ( int i=0; i < (int) TestValues.size();i++) { std::wstring wws = rgKey[TestValues[i]]->get_m_rgss(0,0); - wprintf(L"Results for %i / SC %i\t : %ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \n", TestValues[i], rgKey[TestValues[i]]->SC(), + wprintf(L"Results for %i / SC %i\t : %ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \n", TestValues[i), rgKey[TestValues[i]]->SC(), rgKey[TestValues[i]]->get_m_rgss(0,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(0,0)[0], rgKey[TestValues[i]]->get_m_rgss(0,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(0,1)[0], rgKey[TestValues[i]]->get_m_rgss(1,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(1,0)[0], @@ -945,7 +988,8 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, memcpy(kkp2, gp2->dpKeyArray, sizeof(KMX_KEY)*(gp2->cxKeyArray-1)); gp2->dpKeyArray = kkp2; kkp2 = &kkp2[gp2->cxKeyArray-1]; - kkp2->dpContext = new KMX_WCHAR; *kkp2->dpContext = 0; + kkp2->dpContext = new KMX_WCHAR; + *kkp2->dpContext = 0; kkp2->Key = kkp->Key; kkp2->ShiftFlags = kkp->ShiftFlags; //kkp2->ShiftFlags = 16384; diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 11b81d3706..20796ba355 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -242,7 +242,7 @@ void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT PKMX_WCHAR PP = key->dpOutput; //if (key->Key == 94) // wprintf(L"key->ShiftFlags: %i isEqual: %i %i(%c) %i(%c) ---> %i \n", key->ShiftFlags, key->ShiftFlags & VIRTUALCHARKEY , key->Key , key->Key, ch,ch , ((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch)); - +//wprintf(L"key->Key %i\n",key->Key); /*if(abcd >1 && abcd < 815 ) { wprintf(L"key->Key %i\tkey->dpContext: %i %i %i %i %i %i %i %i %i \tkey->dpoutput: %i %i %i %i %i %i\n", key->Key, @@ -291,7 +291,7 @@ void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WOR for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { if(kbd->dpGroupArray[i].fUsingKeys) { - wprintf(L" group: %i\n",i ); + //wprintf(L" group: %i\n",i ); KMX_TranslateDeadkeyGroup(&kbd->dpGroupArray[i], deadkey, vk, shift, ch); } } @@ -327,7 +327,7 @@ void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT kbd->dpGroupArray[i].cxKeyArray++; //LogError("Add deadkey rule: + [%d K_%d] > dk(%d)", shift, vk, deadkey); zaehler++; - wprintf(L"Add deadkey rule: + [%d K_%d] > dk(%d) %i\n", shift, vk, deadkey,zaehler); + //wprintf(L"Add deadkey rule: + [%d K_%d] > dk(%d) %i\n", shift, vk, deadkey,zaehler); //test_keyboard_S2(kbd); if(i == kbd->StartGroup[1]) break; // If this is the initial group, that's all we need to do. } From 463fe2fe883d361310ef7a7caf8891ecf5eba091 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 1 Feb 2024 18:15:44 +0100 Subject: [PATCH 183/327] feat(linux): mcompile-dk tidy up --- linux/mcompile/keymap/deadkey.cpp | 2 +- linux/mcompile/keymap/helpers.cpp | 33 +++++++++ linux/mcompile/keymap/keymap.cpp | 8 +- linux/mcompile/keymap/mc_import_rules.cpp | 89 +++-------------------- linux/mcompile/keymap/mc_import_rules.h | 60 +-------------- linux/mcompile/keymap/mc_kmxfile.cpp | 1 + linux/mcompile/keymap/mcompile.cpp | 44 ++--------- 7 files changed, 56 insertions(+), 181 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 940f673499..b9f91f056a 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -55,7 +55,7 @@ std::vector create_alDead() { return alDead; } -//_S2 REVIEW +//_S2 REVIEW this is for testing only and needs to go later std::vector reduce_alDead(std::vector dk_big) { std::vector dk_small; bool foundInSmall=false; diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 0eba0c6542..4020f60711 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -5,6 +5,39 @@ //_S2 do not review - all this will be deleted later // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +/* + +KMX_DWORD KMX_get_SCUnderlying_From_SCUS_VEC(v_dw_3D &All_Vector, KMX_DWORD KC_US, int Shiftstate) { + + KMX_DWORD Character = 0; + // find character with that scancode + for( int i=0; i< (int)All_Vector[0].size()-1 ;i++) { + if ( ( All_Vector[0][i][0] == KC_US ) ) { + if ( Shiftstate+1 < (int) All_Vector[0][i].size()-1) + Character = All_Vector[0][i][Shiftstate+1]; + break; + } + } + + //Find underlying SC of character + for( int i=0; i< (int)All_Vector[1].size()-1 ;i++) { + for( int j=1; j< (int)All_Vector[01][0].size();j++) { + if ( ( All_Vector[1][i][j] == Character ) ) { + KC_US = All_Vector[1][i][j]; + return All_Vector[1][i][0]; + } + } + } + return KC_US; +} + + + + +KMX_WCHAR KMX_SCKUnderlyingLayoutToVKUS_GDK2(GdkKeymap* keymap,KMX_DWORD SC_Other) { + + return SC_Other; +}*/ // _S2 can go later void Inspect_kp(LPKMX_KEYBOARD kp) { wprintf(L"-------\n"); diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 5d798cf035..00971a6aab 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -7,7 +7,7 @@ int map_VKShiftState_to_Lin(int VKShiftState) { if (VKShiftState == 0 ) return 0; /* 0000 0000 */ else if (VKShiftState == 16) return 1; /* 0001 0000 */ - // _S2 if commented out only 3 DK will be processed ^ ' ` + // _S2 if commented out only DK on base+shift will be processed ^ ' ` else if (VKShiftState == 9 ) return 2; /* 0000 1001 */ else if (VKShiftState == 25) return 3; /* 0001 1001 */ else return VKShiftState; @@ -352,7 +352,6 @@ bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]){ // _S2 DEADKEY STUFF - DO NOT REVIEW YET // _S2 ToDo deadkeys. Do we need this ? bool IsKeymanUsedKeyVal(std::wstring Keyval) { - int KV = (int) (*Keyval.c_str()); // 32 127 196 256 @@ -380,7 +379,6 @@ bool IsKeymanUsedKeyVal(std::u16string Keyval) { return false; } - bool IsKeymanUsedChar(int KV) { // 32 A-Z a-z if ((KV == 0x20 ) || (KV >= 65 && KV <= 90) || (KV >= 97 && KV <= 122) ) @@ -445,7 +443,7 @@ std::u16string convert_DeadkeyValues_To_U16str(int in) { return u"\0"; } -// _S2 use gdk_keymap_translate_keyboard_state instead return s shifted + unshifted only- no altgr,... +// _S2 use gdk_keymap_translate_keyboard_state instead returns shifted + unshifted only- no altgr,... KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; guint *keyvals; @@ -463,7 +461,7 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap if (!(keycode <= 94)) return 0; - KMX_DWORD deadkey =(KMX_DWORD) keyvals[shift_state_pos]; //_S2 do I need this? no + //KMX_DWORD deadkey =(KMX_DWORD) keyvals[shift_state_pos]; //_S2 do I need this? no out = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); // _S2 g_free used everywhere? diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index b60d233033..6fc72835b1 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -57,12 +57,12 @@ void TestKeyboard_S21(LPKMX_KEYBOARD kbd) { } } } - // _S2 can go later void test_keyboard_S21(LPKMX_KEYBOARD kmxfile){ //TestKeyboard_S21(kmxfile); } + const int KMX_ShiftStateMap[] = { ISVIRTUALKEY, ISVIRTUALKEY | K_SHIFTFLAG, @@ -77,7 +77,6 @@ const int KMX_ShiftStateMap[] = { }; // _S2 DEADKEY STUFF - DO NOT REVIEW YET -// _S2 ToDo open deadkey functions DeadKey::DeadKey(KMX_WCHAR deadCharacter) { this->m_deadchar = deadCharacter; @@ -92,18 +91,6 @@ const int KMX_ShiftStateMap[] = { this->m_rgcombchar.push_back(combinedCharacter); } -/* - bool DeadKey::ContainsBaseCharacter(WCHAR baseCharacter) { - std::vector::iterator it; - for(it=this->m_rgbasechar.begin(); it::iterator it; for(it=this->m_rgbasechar.begin(); itKMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; key->Line = 0; key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); - //_S2 needs to go later - /*if(this->m_vk==192) - key->ShiftFlags=16400;*/ - key->dpContext = new KMX_WCHAR; *key->dpContext = 0; p = key->dpOutput = new KMX_WCHAR[st.size() + 1]; @@ -470,7 +454,7 @@ public: return (ch < 0x0020) || (ch >= 0x007F && ch <= 0x009F); } - // _S2 DEADKEY STUFF - DO NOT REVIEW YET + // _S2 DEADKEY STUFF - DO NOT REVIEW YET --- Do we need this at all? // _S2 ToDo ToUnicodeEx needs to be replaced here DeadKey *KMX_ProcessDeadKey( UINT iKeyDead, // The index into the VirtualKey of the dead key @@ -530,10 +514,6 @@ KMX_WCHAR sbBuffer1[16]; // Risk is technically an infinite loop but per Hiroyama // that should be impossible here. - // _S2 needs replacement - // rc = ToUnicodeEx(rgKey[iKeyDead]->VK(), rgKey[iKeyDead]->SC(), lpKeyStateDead, sbBuffer, _countof(sbBuffer), 0, hkl); - //rc = KMX_ToUnicodeEx(rgKey[iKeyDead]->VK(), rgKey[iKeyDead]->SC(), lpKeyStateDead, sbBuffer, _countof(sbBuffer), 0, hkl); - rc = KMX_ToUnicodeEx(rgKey[iKeyDead]->SC(), lpKeyState, sbBuffer, ss, caps, keymap); //wprintf(L"ikey: %i rc = %i\n",iKey,rc); rc=-1; //_S2 @@ -546,11 +526,8 @@ KMX_WCHAR sbBuffer1[16]; //---------------------------------------------------------------------------------- - // _S2 needs replacement - //rc = ToUnicodeEx(rgKey[iKey]->VK(), rgKey[iKey]->SC(), lpKeyState, sbBuffer, _countof(sbBuffer), 0, hkl); rc = KMX_ToUnicodeEx( rgKey[iKey]->SC(), lpKeyState, sbBuffer, ss, caps, keymap) ; - //--------- ONE character found = combined char (e.g. â ) -------------------------- // ***** E.G: ToUnicodeEx FOUND  ***** // @@ -629,53 +606,18 @@ KMX_WCHAR sbBuffer1[16]; } }; -//_S2 REVIEW - -/* -int GetMaxDeadkeyIndex(WCHAR *p) { - int n = 0; - while(p && *p) { - if(*p == UC_SENTINEL && *(p+1) == CODE_DEADKEY) - n = max(n, *(p+2)); - p = incxstr(p); - } - return n; -} -*/ - int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { - int n = 0; int pp = 0; + int n = 0; while(p && *p) { - if(*p == UC_SENTINEL && *(p+1) == CODE_DEADKEY) { - //pp = (int) *(p+2); + if(*p == UC_SENTINEL && *(p+1) == CODE_DEADKEY) n = std::max(n, (int) *(p+2)); - } p = KMX_incxstr(p); } return n; } - -/*int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { - int n = 0; - int nn = 0; - int pp = 0; - while(p && *p) { - if(*p == UC_SENTINEL && *(p+1) == CODE_DEADKEY) - pp = (int) *(p+2); - //nn = std::max(n, *(p+2)); - nn = std::max(n, pp); - - if( !(n > (*p+2))) // _S2 p+4 ?? - n= (*p+2); - - p = KMX_incxstr(p); - } - return n; -}*/ - void check_rgkey_S2( std::vector rgKey, int i) { wprintf(L" rgfDeadkey[%i]: \t%i %i %i %i %i %i %i %i %i %i\n", i, @@ -694,16 +636,14 @@ void check_rgkey_S2( std::vector rgKey, int i) { bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 KMX_Loader loader; - KMX_HKL hkl = NULL; BYTE lpKeyState[256];// = new KeysEx[256]; std::vector rgKey; //= new VirtualKey[256]; std::vector alDead; -//_S2 REVIEW - std::vector alDead2 ; - //std::vector alDead_small; + //_S2 REVIEW + std::vector alDead2 ; rgKey.resize(256); @@ -719,9 +659,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // this "connection" is possible only while using All_Vector KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, keymap); - // if(rgKey[sc] != NULL) - // check_rgkey_S2(rgKey, sc); - if((key->VK() != 0) ) { rgKey[key->VK()] = key; } else { @@ -775,7 +712,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { if(rgKey[iKey] != NULL) { -//check_rgkey_S2(rgKey, iKey); KMX_WCHAR sbBuffer[256]; // Scratchpad we use many places for(ShiftState ss = Base; ss <= loader.KMX_MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { @@ -788,7 +724,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, if(ss == MenuCtrl|| ss == ShftMenuCtrl) { continue; } -//check_rgkey_S2(rgKey, iKey); KMX_DWORD SC_US = KMX_get_KeyCodeUnderlying_From_VKUS(iKey); // _S2 deadkey not finished; Ctrl, Shft +40 not tested @@ -851,14 +786,9 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, if(dk == NULL) { //_S2 TODO //alDead.push_back(loader.KMX_ProcessDeadKey(iKey, ss, lpKeyState, rgKey, caps == 0, hkl, *keymap)); - - //_S2 REVIEW alDead2 = create_alDead(); - //_S2 REVIEW alDead = reduce_alDead(alDead2); - //alDead.push_back(loader.KMX_ProcessDeadKey(192, ss, lpKeyState, rgKey, caps == 0, hkl, *keymap)); - //_S2 for each dk (^ ' ` push_back all combinations ^,â,ê,î,ô,û ',á,é,í,ó,ú `,à,è,ì,ò,ù into alDead->m_rgcombchar) //_S2 for each dk (^ ' ` push_back all base char : _,a,e,i,o,u into alDead->m_rgbasechar) // S2 do nothing for other keys @@ -919,7 +849,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpOutput)); } } -//nDeadkey=3; //_S2 + kp->cxGroupArray++; gp = &kp->dpGroupArray[kp->cxGroupArray-1]; UINT nKeys = 0; @@ -976,7 +906,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, UINT j; LPKMX_KEY kkp; for(j = 0, kkp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kkp++) { - // _S2 missing 26 lines from here: since capalock is not correct this loop will never be done + // _S2 AHA! missing 26 lines from here: since capalock is not correct this loop will never be done //wprintf(L"will add Rule for group %i and key %i - shiftflag %i \n", i, kkp->Key, kkp->ShiftFlags); KMX_DWORD S_S2 = kkp->ShiftFlags; bool eins= (K_CTRLFLAG|K_ALTFLAG|LCTRLFLAG|LALTFLAG|RCTRLFLAG|RALTFLAG); @@ -1003,7 +933,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, *p = 0; } } - //test_keyboard_S21(kp); int sdfghjk=0; } } diff --git a/linux/mcompile/keymap/mc_import_rules.h b/linux/mcompile/keymap/mc_import_rules.h index f8c1f7b418..3fad7e61ce 100644 --- a/linux/mcompile/keymap/mc_import_rules.h +++ b/linux/mcompile/keymap/mc_import_rules.h @@ -2,7 +2,7 @@ #pragma once #ifndef MC_IMPORT_RULES_H #define MC_IMPORT_RULES_H -// _S2 ToDo open deadkey functions + class DeadKey { private: KMX_WCHAR m_deadchar; @@ -14,6 +14,7 @@ public: KMX_WCHAR KMX_DeadCharacter() ; void KMX_AddDeadKeyRow(KMX_WCHAR baseCharacter, KMX_WCHAR combinedCharacter) ; + int KMX_Count() { return this->m_rgbasechar.size(); } @@ -26,65 +27,10 @@ public: return this->m_rgcombchar[index]; } + // _S2 only use one bool ContainsBaseCharacter(WCHAR baseCharacter); - bool KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter) ; }; -class DeadKey1 { -private: - KMX_WCHAR m_deadchar; - std::vector m_rgbasechar; - std::vector m_rgcombchar; - -public: - DeadKey1(KMX_WCHAR deadCharacter) { - this->m_deadchar = deadCharacter; - } - - KMX_WCHAR KMX_DeadCharacter() { - return this->m_deadchar; - } - - void KMX_AddDeadKeyRow(KMX_WCHAR baseCharacter, KMX_WCHAR combinedCharacter) { - this->m_rgbasechar.push_back(baseCharacter); - this->m_rgcombchar.push_back(combinedCharacter); - } - - int KMX_Count() { - return this->m_rgbasechar.size(); - } - - KMX_WCHAR KMX_GetBaseCharacter(int index) { - return this->m_rgbasechar[index]; - } - - KMX_WCHAR KMX_GetCombinedCharacter(int index) { - return this->m_rgcombchar[index]; - } -/* - bool ContainsBaseCharacter(WCHAR baseCharacter) { - std::vector::iterator it; - for(it=this->m_rgbasechar.begin(); it::iterator it; - for(it=this->m_rgbasechar.begin(); it str_argv, char* argv_ch[] = NULL){ } - -//test_keyboard_S2(kmxfile); -> THE SAME #if defined(_WIN32) || defined(_WIN64) // _S2 DoConvert for windows needs to be done later ( can it be copied from engine/mcompile ?) /*if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552F @@ -142,9 +139,9 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ #else // LINUX if(KMX_DoConvert( kmxfile, bDeadkeyConversion, argc, (gchar**) argv_ch)) { // I4552F - KMX_SaveKeyboard(kmxfile, outfile); //test_keyboard_S2(kmxfile); -> THE SAME without DoConvert + KMX_SaveKeyboard(kmxfile, outfile); } -//test_keyboard_S2(kmxfile); // -> DIFFERENT + #endif //DeleteReallocatedPointers(kmxfile); :TODO // _S2 not my ToDo :-) @@ -328,7 +325,7 @@ void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT //LogError("Add deadkey rule: + [%d K_%d] > dk(%d)", shift, vk, deadkey); zaehler++; //wprintf(L"Add deadkey rule: + [%d K_%d] > dk(%d) %i\n", shift, vk, deadkey,zaehler); - //test_keyboard_S2(kbd); + if(i == kbd->StartGroup[1]) break; // If this is the initial group, that's all we need to do. } } @@ -432,7 +429,7 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR d // _S2 ----------------------------- KMX_GetDeadkeys(dk_Table, deadkey, pdk = deadkeys, keymap); // returns array of [usvk, ch_out] pairs -//test_keyboard_S2(kbd); + while(*pdk) { // Look up the ch @@ -516,7 +513,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg ch = DeadKey; } } -// _S2 GOOD TIL HERE + //wprintf(L" scunderlying: SS: %i Nr: %i VKMap[i] %i ch:%i (%c)\n", VKShiftState[j],i, KMX_VKMap[i],ch,ch ); switch(ch) { case 0x0000: break; @@ -526,7 +523,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg } } - //test_keyboard_S2(kbd); + KMX_ReportUnconvertedKeyboardRules(kbd); if(!KMX_ImportRules(kbd, All_Vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 return FALSE; @@ -565,35 +562,6 @@ KMX_WCHAR KMX_get_VKUS_From_VKUnderlying_VEC(v_dw_3D All_Vector, KMX_DWORD VK_OT return VK_OTHER; } -KMX_WCHAR KMX_SCKUnderlyingLayoutToVKUS_GDK2(GdkKeymap* keymap,KMX_DWORD SC_Other) { - - return SC_Other; -} - -KMX_DWORD KMX_get_SCUnderlying_From_SCUS_VEC(v_dw_3D &All_Vector, KMX_DWORD KC_US, int Shiftstate) { - - KMX_DWORD Character = 0; - // find character with that scancode - for( int i=0; i< (int)All_Vector[0].size()-1 ;i++) { - if ( ( All_Vector[0][i][0] == KC_US ) ) { - if ( Shiftstate+1 < (int) All_Vector[0][i].size()-1) - Character = All_Vector[0][i][Shiftstate+1]; - break; - } - } - - //Find underlying SC of character - for( int i=0; i< (int)All_Vector[1].size()-1 ;i++) { - for( int j=1; j< (int)All_Vector[01][0].size();j++) { - if ( ( All_Vector[1][i][j] == Character ) ) { - KC_US = All_Vector[1][i][j]; - return All_Vector[1][i][0]; - } - } - } - return KC_US; -} - // takes SC of underlying keyboard and returns character of underlying keyboard with shiftstate VKShiftState[j] or deadkey KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, PKMX_WCHAR DeadKey) { From 78e736722abc83a97d1905fd4e0a2673021444c9 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 2 Feb 2024 16:36:49 +0100 Subject: [PATCH 184/327] feat(linux): mcompile-dk doublicate functions --- linux/mcompile/keymap/helpers.cpp | 100 ++++++++++++++++++++++ linux/mcompile/keymap/keymap.cpp | 16 ++-- linux/mcompile/keymap/keymap.h | 6 ++ linux/mcompile/keymap/mc_import_rules.cpp | 2 +- 4 files changed, 116 insertions(+), 8 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 4020f60711..ab7db5f4a5 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -5,8 +5,108 @@ //_S2 do not review - all this will be deleted later // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + /* +KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw_OLD(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ + + GdkModifierType consumed; + GdkKeymapKey *maps; + guint *keyvals; + gint count; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return 0; + + //BASE (shiftstate: 0) + if (( ss == Base ) && ( caps == 0 )) { + GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); + } + + //BASE + CAPS (shiftstate: 0) + else if (( ss == Base ) && ( caps == 1 )) { + GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); + } + + //SHIFT (shiftstate: 1) + else if (( ss == Shft ) && ( caps == 0 )) { + GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + } + + //SHIFT+CAPS (shiftstate: 1) + else if ( ( ss == Shft ) && ( caps ==1 )) { + GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); + } + + // Ctrl (shiftstate: 2) + else if (( ss == Ctrl ) && ( caps == 0 )){ + GdkModifierType MOD_Ctrl = (GdkModifierType) ( GDK_MOD5_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl , 0, keyvals, NULL, NULL, & consumed); + } + + // Ctrl (shiftstate: 2) + else if (( ss == Ctrl ) && ( caps == 1 )){ + GdkModifierType MOD_CtrlCaps = (GdkModifierType) (GDK_MOD5_MASK | GDK_LOCK_MASK); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps , 0, keyvals, NULL, NULL, & consumed); + } + + + // SHIFT+Ctrl (shiftstate: 3) + else if (( ss == ShftCtrl ) && ( caps == 0 )){ + GdkModifierType MOD_Ctrl = (GdkModifierType) (GDK_SHIFT_MASK | GDK_MOD5_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl , 0, keyvals, NULL, NULL, & consumed); + } + + // SHIFT+Ctrl (shiftstate: 3) + else if (( ss == ShftCtrl ) && ( caps == 1 )){ + GdkModifierType MOD_CtrlCaps = (GdkModifierType) ( GDK_SHIFT_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR (shiftstate: 6) + else if (( ss == MenuCtrl ) && ( caps == 0 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR +CAPS (shiftstate: 6) + else if (( ss == MenuCtrl ) && ( caps == 1 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR (shiftstate: 7) + else if (( ss == ShftMenuCtrl ) && ( caps == 0 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR +CAPS (shiftstate: 7) + else if (( ss == ShftMenuCtrl ) && ( caps == 1 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + else + return 0; +//_S2 hier wird fffe returned ist das OK? + if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max)) + return 0xFFFF; + if((*keyvals > deadkey_max) || ((*keyvals < deadkey_min) && ( *keyvals > 0xFF))) + return 0xFFFE; + else + return (KMX_DWORD) *keyvals; +} + + + + + + + KMX_DWORD KMX_get_SCUnderlying_From_SCUS_VEC(v_dw_3D &All_Vector, KMX_DWORD KC_US, int Shiftstate) { KMX_DWORD Character = 0; diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 00971a6aab..4effe4351b 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -462,7 +462,7 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap return 0; //KMX_DWORD deadkey =(KMX_DWORD) keyvals[shift_state_pos]; //_S2 do I need this? no - out = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); + out = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw_OLD(keymap, keycode, (ShiftState) shift_state_pos, 0); // _S2 g_free used everywhere? g_free(keyvals); @@ -493,7 +493,7 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap //wprintf(L" keyvals[shift_state_pos]: %i %i %i %i----", keyvals[0],keyvals[1],keyvals[2],keyvals[3]); dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str(); - out = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); + out = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw_OLD(keymap, keycode, (ShiftState) shift_state_pos, 0); // _S2 g_free used everywhere? g_free(keyvals); @@ -503,7 +503,7 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap } // _S2 ToDo use only one of those -KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ +KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw_OLD(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ GdkModifierType consumed; GdkKeymapKey *maps; @@ -587,7 +587,7 @@ KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(Gdk } else return 0; -//hier wird fffe returned ist das OK? +//_S2 hier wird fffe returned ist das OK? if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max)) return 0xFFFF; if((*keyvals > deadkey_max) || ((*keyvals < deadkey_min) && ( *keyvals > 0xFF))) @@ -596,7 +596,7 @@ KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(Gdk return (KMX_DWORD) *keyvals; } -std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ +std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_OLD(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ GdkModifierType consumed; GdkKeymapKey *maps; @@ -690,7 +690,7 @@ std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(Gdk return std::wstring(1, (int) *keyvals); } -std::u16string KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_16(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ +std::u16string KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_16_OLD(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ GdkModifierType consumed; GdkKeymapKey *maps; @@ -819,7 +819,9 @@ KMX_DWORD test_S2 = (8+ USVirtualKeyToScanCode[ VK_US ]); KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector,KMX_DWORD KC_US, ShiftState ss, int caps) { KMX_DWORD Character; - std::wstring ws = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, KC_US, ss, caps); + std::wstring ws = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_OLD(keymap, KC_US, ss, caps); + //std::wstring ws = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, KC_US, ss, caps); + Character = *ws.c_str(); //Find underlying SC of character diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 0eb64a9568..6c8c725e94 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -513,11 +513,17 @@ std::u16string convert_DeadkeyValues_To_U16str(int in); KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos); KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky); +int KMX_get_KeyvalsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); + + // returns KeySyms for a given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) +std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_OLD(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); // returns KeySyms for a given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) +std::u16string KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_16_OLD(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); std::u16string KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_16(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); // returns KeySyms for a given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) +KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw_OLD(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); // return the VirtualKey of the Other Keyboard for given Scancode using GDK diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 6fc72835b1..4830dcbab2 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -108,7 +108,7 @@ int KMX_ToUnicodeEx(guint ScanCode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, //if((kvl >= deadkey_min) && (kvl <= deadkey_max)) - std::wstring character = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, ScanCode, ShiftState(shift_state), caps); + std::wstring character = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_OLD(keymap, ScanCode, ShiftState(shift_state), caps); std::u16string uuu16= u16string_from_wstring(character).c_str(); pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(character).c_str(); From dcf49b9f0890a4753e0f98fa1cfc65da0761325d Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 2 Feb 2024 17:55:07 +0100 Subject: [PATCH 185/327] feat(linux): mcompile-dk tidy up --- linux/mcompile/keymap/helpers.cpp | 82 +++++++++++++++++++++++++++ linux/mcompile/keymap/keymap.cpp | 90 ++---------------------------- linux/mcompile/keymap/keymap.h | 4 +- linux/mcompile/keymap/mcompile.cpp | 1 + 4 files changed, 89 insertions(+), 88 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index ab7db5f4a5..0d0f5cbd50 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -6,6 +6,88 @@ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +std::u16string KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_16_OLD(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ + + GdkModifierType consumed; + GdkKeymapKey *maps; + guint *keyvals; + gint count; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return u"\0"; + + //unshifted (shiftstate: 0) + if (( ss == Base ) && ( caps == 0 )) { + GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); + } + + //caps (shiftstate: 0) + else if (( ss == Base ) && ( caps == 1 )) { + GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); + } + + //Shift (shiftstate: 1) + else if (( ss == Shft ) && ( caps == 0 )) { + GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + } + + //SHIFT+CAPS (shiftstate: 1) + else if ( ( ss == Shft ) && ( caps ==1 )) { + GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); + } + + /*// Ctrl (shiftstate: 2) + else if (( ss == Ctrl ) && ( caps == 0 )){ + GdkModifierType MOD_Ctrl = (GdkModifierType) ( GDK_MOD2_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl , 0, keyvals, NULL, NULL, & consumed); + } + + // Ctrl (shiftstate: 2) + else if (( ss == Ctrl ) && ( caps == 1 )){ + GdkModifierType MOD_CtrlCaps = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_LOCK_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps , 0, keyvals, NULL, NULL, & consumed); + } + // SHIFT+Ctrl (shiftstate: 3)*/ + + //ALT-GR (shiftstate: 6) + else if (( ss == MenuCtrl ) && ( caps == 0 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR +CAPS (shiftstate: 6) + else if (( ss == MenuCtrl ) && ( caps == 1 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR (shiftstate: 7) + else if (( ss == ShftMenuCtrl ) && ( caps == 0 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR +CAPS (shiftstate: 7) + else if (( ss == ShftMenuCtrl ) && ( caps == 1 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + else + return u"\0"; + + //if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max) ) + if((*keyvals >= deadkey_min) ) + return convert_DeadkeyValues_To_U16str((int) *keyvals); + else + return std::u16string(1, (int) *keyvals); +} + + /* KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw_OLD(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 4effe4351b..f2ce49dbbe 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -549,7 +549,6 @@ KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw_OLD gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps , 0, keyvals, NULL, NULL, & consumed); } - // SHIFT+Ctrl (shiftstate: 3) else if (( ss == ShftCtrl ) && ( caps == 0 )){ GdkModifierType MOD_Ctrl = (GdkModifierType) (GDK_SHIFT_MASK | GDK_MOD5_MASK ); @@ -587,12 +586,12 @@ KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw_OLD } else return 0; -//_S2 hier wird fffe returned ist das OK? - if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max)) + + if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max)) // deadkeys return 0xFFFF; - if((*keyvals > deadkey_max) || ((*keyvals < deadkey_min) && ( *keyvals > 0xFF))) + if((*keyvals > deadkey_max) || ((*keyvals < deadkey_min) && ( *keyvals > 0xFF))) // out of range return 0xFFFE; - else + else // usable char return (KMX_DWORD) *keyvals; } @@ -690,87 +689,6 @@ std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_OLD return std::wstring(1, (int) *keyvals); } -std::u16string KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_16_OLD(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ - - GdkModifierType consumed; - GdkKeymapKey *maps; - guint *keyvals; - gint count; - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return u"\0"; - - //unshifted (shiftstate: 0) - if (( ss == Base ) && ( caps == 0 )) { - GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); - } - - //caps (shiftstate: 0) - else if (( ss == Base ) && ( caps == 1 )) { - GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); - } - - //Shift (shiftstate: 1) - else if (( ss == Shft ) && ( caps == 0 )) { - GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); - } - - //SHIFT+CAPS (shiftstate: 1) - else if ( ( ss == Shft ) && ( caps ==1 )) { - GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); - } - - /*// Ctrl (shiftstate: 2) - else if (( ss == Ctrl ) && ( caps == 0 )){ - GdkModifierType MOD_Ctrl = (GdkModifierType) ( GDK_MOD2_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl , 0, keyvals, NULL, NULL, & consumed); - } - - // Ctrl (shiftstate: 2) - else if (( ss == Ctrl ) && ( caps == 1 )){ - GdkModifierType MOD_CtrlCaps = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_LOCK_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps , 0, keyvals, NULL, NULL, & consumed); - } - // SHIFT+Ctrl (shiftstate: 3)*/ - - //ALT-GR (shiftstate: 6) - else if (( ss == MenuCtrl ) && ( caps == 0 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - //ALT-GR +CAPS (shiftstate: 6) - else if (( ss == MenuCtrl ) && ( caps == 1 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - //ALT-GR (shiftstate: 7) - else if (( ss == ShftMenuCtrl ) && ( caps == 0 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - //ALT-GR +CAPS (shiftstate: 7) - else if (( ss == ShftMenuCtrl ) && ( caps == 1 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - else - return u"\0"; - - //if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max) ) - if((*keyvals >= deadkey_min) ) - return convert_DeadkeyValues_To_U16str((int) *keyvals); - else - return std::u16string(1, (int) *keyvals); -} - KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { GdkModifierType consumed; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 6c8c725e94..24a3ac8490 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -520,8 +520,8 @@ int KMX_get_KeyvalsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeym std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_OLD(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); // returns KeySyms for a given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) -std::u16string KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_16_OLD(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); -std::u16string KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_16(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); +//std::u16string KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_16_OLD(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); +//std::u16string KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_16(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); // returns KeySyms for a given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw_OLD(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index f25ebb6c3a..f2a34b5227 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -587,6 +587,7 @@ int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ return 1; } + // _S2 is it OK to have 65535 instead of 94, 96 and 180 as a value for deadkeys in Vector // add contents of other keyboard to All_Vector if( append_other_ToVector(All_Vector,keymap)) { wprintf(L"ERROR: can't append Other ToVector \n"); From 5ab1dcd727f6a6b0a7d11fdb8d2fcffbdf1e41c8 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 5 Feb 2024 14:40:16 +0100 Subject: [PATCH 186/327] feat(linux): mcompile-dk reduce nr of functions using gdk_keymap_translate_keyboard_state --- linux/mcompile/keymap/helpers.cpp | 24 +- linux/mcompile/keymap/keymap.cpp | 601 +++++++++++++++------- linux/mcompile/keymap/keymap.h | 21 +- linux/mcompile/keymap/mc_import_rules.cpp | 14 +- 4 files changed, 446 insertions(+), 214 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 0d0f5cbd50..179a07ea68 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -519,7 +519,7 @@ KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_U PKMX_WCHAR dky; int VKShiftState_lin = map_VKShiftState_to_Lin(VKShiftState); - KMX_DWORD KeyvalOther = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,SC_OTHER, VKShiftState_lin, dky); + KMX_DWORD KeyvalOther = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK_OLD(keymap,SC_OTHER, VKShiftState_lin, dky); if (KeyvalOther >= deadkey_min) { /// std::string ws((const char*) gdk_keyval_name (KeyvalOther)); @@ -910,7 +910,7 @@ int replace_KeyName_with_Keycode2(std::string in) { /*int KMX_ToUnicodeEx( guint ScanCode, const BYTE *lpKeyStccate, PWCHAR pwszBuff, int shift_state, int caps,GdkKeymap *keymap) { - KMX_DWORD kvl= KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap, ScanCode, shift_state); + KMX_DWORD kvl= KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK_OLD(keymap, ScanCode, shift_state); std::wstring character = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, ScanCode, ShiftState(shift_state), caps); pwszBuff[0]= * (PWCHAR) character.c_str(); @@ -998,7 +998,7 @@ gdk_keyval_convert_case (GDK_KEY_4, lower,upper); gdk_keyval_convert_case (GDK_KEY_dollar, lower,upper);*/ } -static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) { +/*static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) { GdkModifierType consumed; GdkKeymapKey *maps; GdkEventKey* event; @@ -1066,9 +1066,9 @@ static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) { g_free(keyvals); g_free(maps); -} +}*/ -bool InsertKeyvalsFromKeymap(v_dw_3D &All_Vector,GdkKeymap * keymap){ +/*bool InsertKeyvalsFromKeymap(v_dw_3D &All_Vector,GdkKeymap * keymap){ // get the keyvals using GDK and copy into All_Vector for(int i =0; i< (int) All_Vector[1].size();i++) { @@ -1076,27 +1076,27 @@ bool InsertKeyvalsFromKeymap(v_dw_3D &All_Vector,GdkKeymap * keymap){ All_Vector[1][i][0] = All_Vector[0][i][0]; // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] - All_Vector[1][i][0+1] = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,(All_Vector[1][i][0]),0); //shift state: unshifted:0 - All_Vector[1][i][1+1] = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,(All_Vector[1][i][0]),1); //shift state: shifted:1 + All_Vector[1][i][0+1] = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK_OLD(keymap,(All_Vector[1][i][0]),0); //shift state: unshifted:0 + All_Vector[1][i][1+1] = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK_OLD(keymap,(All_Vector[1][i][0]),1); //shift state: shifted:1 //wprintf(L" Keycodes US dw : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); //wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); } -} +}*/ // _S2 can go later -KMX_DWORD writeKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { +/*KMX_DWORD writeKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; guint *keyvals; gint count; KMX_DWORD out; for ( int ii =1; ii< 255;ii++) { - KMX_DWORD out = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,ii,0); - KMX_DWORD out2= KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,ii,1); + KMX_DWORD out = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK_OLD(keymap,ii,0); + KMX_DWORD out2= KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK_OLD(keymap,ii,1); wprintf(L" ii = %i --> keymap = %i (%c)..%i(%c) \n",ii, out,out, out2,out2); } -} +}*/ // _S2 not needed later bool test(v_dw_3D &V) { diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index f2ce49dbbe..12b17fc1b1 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -320,11 +320,8 @@ int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] All_Vector[1][i][0+1] = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,All_Vector[0][i][0],0); //shift state: unshifted:0 All_Vector[1][i][1+1] = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,All_Vector[0][i][0],1); //shift state: shifted:1 - - - //wprintf(L" Keycodes US dw : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); - //wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); } + return 0; } @@ -443,67 +440,8 @@ std::u16string convert_DeadkeyValues_To_U16str(int in) { return u"\0"; } -// _S2 use gdk_keymap_translate_keyboard_state instead returns shifted + unshifted only- no altgr,... -KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos) { - GdkKeymapKey *maps; - guint *keyvals; - gint count; - KMX_DWORD out; - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return 0; - //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html - - if (!(shift_state_pos <= count)) - return 0; - - if (!(keycode <= 94)) - return 0; - - //KMX_DWORD deadkey =(KMX_DWORD) keyvals[shift_state_pos]; //_S2 do I need this? no - out = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw_OLD(keymap, keycode, (ShiftState) shift_state_pos, 0); - - // _S2 g_free used everywhere? - g_free(keyvals); - g_free(maps); - - return out; -} - -// _S2 use gdk_keymap_translate_keyboard_state instead return s shifted + unshifted only- no altgr,... -KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky) { - GdkKeymapKey *maps; - guint *keyvals; - gint count; - KMX_DWORD out; - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return 0; - //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html - - if (!(shift_state_pos <= count)) - return 0; - - if (!(keycode <= 94)) - return 0; - - KMX_DWORD deadkey = (KMX_DWORD) keyvals[shift_state_pos]; - //wprintf(L" keyvals[shift_state_pos]: %i %i %i %i----", keyvals[0],keyvals[1],keyvals[2],keyvals[3]); - - dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str(); - out = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw_OLD(keymap, keycode, (ShiftState) shift_state_pos, 0); - - // _S2 g_free used everywhere? - g_free(keyvals); - g_free(maps); - - return out; -} - -// _S2 ToDo use only one of those -KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw_OLD(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ +//_S2 change Name +int NEW_KMX_get_Keyval_all_7(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps) { GdkModifierType consumed; GdkKeymapKey *maps; @@ -586,160 +524,453 @@ KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw_OLD } else return 0; - - if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max)) // deadkeys - return 0xFFFF; - if((*keyvals > deadkey_max) || ((*keyvals < deadkey_min) && ( *keyvals > 0xFF))) // out of range - return 0xFFFE; - else // usable char - return (KMX_DWORD) *keyvals; + return (int) *keyvals; } -std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_OLD(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ - GdkModifierType consumed; + + + // _S2 use gdk_keymap_translate_keyboard_state instead return s shifted + unshifted only- no altgr,... + KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky) { + GdkKeymapKey *maps; + guint *keyvals; + gint count; + KMX_DWORD out; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return 0; + //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html + + if (!(shift_state_pos <= count)) + return 0; + + if (!(keycode <= 94)) + return 0; + + KMX_DWORD deadkey = (KMX_DWORD) keyvals[shift_state_pos]; + //wprintf(L" keyvals[shift_state_pos]: %i %i %i %i----", keyvals[0],keyvals[1],keyvals[2],keyvals[3]); + + dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str(); + out = KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); + + // _S2 g_free used everywhere? + g_free(keyvals); + g_free(maps); + + return out; + } + + +// _S2 use gdk_keymap_translate_keyboard_state instead return s shifted + unshifted only- no altgr,... +KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; guint *keyvals; gint count; + KMX_DWORD out; if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return L"\0"; + return 0; + //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html - //unshifted (shiftstate: 0) - if (( ss == Base ) && ( caps == 0 )) { - GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); - } + if (!(shift_state_pos <= count)) + return 0; - //caps (shiftstate: 0) - else if (( ss == Base ) && ( caps == 1 )) { - GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); - } + if (!(keycode <= 94)) + return 0; - //Shift (shiftstate: 1) - else if (( ss == Shft ) && ( caps == 0 )) { - GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); - std::wstring rV1= std::wstring(1, (int) *keyvals); - } + // _S2 can I opt this out whne i do nou use dky?? + // KMX_DWORD deadkey = (KMX_DWORD) keyvals[shift_state_pos]; + // //wprintf(L" keyvals[shift_state_pos]: %i %i %i %i----", keyvals[0],keyvals[1],keyvals[2],keyvals[3]); + // dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str(); - //SHIFT+CAPS (shiftstate: 1) - else if ( ( ss == Shft ) && ( caps ==1 )) { - GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); - } + //out = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw_OLD(keymap, keycode, (ShiftState) shift_state_pos, 0); + //out = KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos,0); + out = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos,0); - // _S2 if I include this we get deadkey(65535) instead of deadkey(3) - /*// Ctrl (shiftstate: 2) - else if (( ss == Ctrl ) && ( caps == 0 )){ - GdkModifierType MOD_Ctrl = (GdkModifierType) ( GDK_MOD2_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl , 0, keyvals, NULL, NULL, & consumed); - } + // _S2 g_free used everywhere? + g_free(keyvals); + g_free(maps); - // Ctrl (shiftstate: 2) - else if (( ss == Ctrl ) && ( caps == 1 )){ - GdkModifierType MOD_CtrlCaps = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_LOCK_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps , 0, keyvals, NULL, NULL, & consumed); - }*/ - - /*// SHIFT+Ctrl (shiftstate: 3) - else if (( ss == ShftCtrl ) && ( caps == 0 )){ - GdkModifierType MOD_Ctrl = (GdkModifierType) (GDK_SHIFT_MASK | GDK_MOD2_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl , 0, keyvals, NULL, NULL, & consumed); - } - - // SHIFT+Ctrl (shiftstate: 3) - else if (( ss == ShftCtrl ) && ( caps == 1 )){ - GdkModifierType MOD_CtrlCaps = (GdkModifierType) (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_LOCK_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps , 0, keyvals, NULL, NULL, & consumed); - }*/ - - //ALT-GR (shiftstate: 6) - else if (( ss == MenuCtrl ) && ( caps == 0 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - //ALT-GR +CAPS (shiftstate: 6) - else if (( ss == MenuCtrl ) && ( caps == 1 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - //ALT-GR (shiftstate: 7) - else if (( ss == ShftMenuCtrl ) && ( caps == 0 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - //ALT-GR +CAPS (shiftstate: 7) - else if (( ss == ShftMenuCtrl ) && ( caps == 1 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - else - return L"\0"; - - //if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max) ) - if((*keyvals >= deadkey_min) ) - return convert_DeadkeyValues_ToChar((int) *keyvals); - else - return std::wstring(1, (int) *keyvals); + return out; } -KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { - - GdkModifierType consumed; +// _S2 use gdk_keymap_translate_keyboard_state instead return s shifted + unshifted only- no altgr,... +KMX_DWORD KMX_get_rc_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; guint *keyvals; - guint lowerCase; - guint upperCase; gint count; + KMX_DWORD out; if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; + //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html - //Shift - GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + if (!(shift_state_pos <= count)) + return 0; - for (int i = 0; i < count; i++) { - if (maps[i].level > 1 || maps[i].group > 1) - continue; + if (!(keycode <= 94)) + return 0; - gchar * kv_name = gdk_keyval_name (keyvals[i]); + // _S2 can I opt this out whne i do nou use dky?? + // KMX_DWORD deadkey = (KMX_DWORD) keyvals[shift_state_pos]; + // //wprintf(L" keyvals[shift_state_pos]: %i %i %i %i----", keyvals[0],keyvals[1],keyvals[2],keyvals[3]); + // dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str(); - if ( keyvals[i]>0) - gdk_keyval_convert_case (*kv_name, &lowerCase, &upperCase); + //out = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw_OLD(keymap, keycode, (ShiftState) shift_state_pos, 0); + out = KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos,0); + //out = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos,0); - // _S2 is ( lowerCase == upperCase ) true for all number keys for all keyboards? - if ( lowerCase == upperCase ) - return (KMX_DWORD) upperCase; + // _S2 g_free used everywhere? + g_free(keyvals); + g_free(maps); + + return out; +} + + // _S2 ToDo use only one of those + KMX_DWORD KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ + + GdkModifierType consumed; + GdkKeymapKey *maps; + guint *keyvals; + gint count; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return 0; + + KMX_DWORD keyvals_dw= (KMX_DWORD) NEW_KMX_get_Keyval_all_7(keymap, keycode, ss, caps) ; + + if((keyvals_dw >= deadkey_min) && (keyvals_dw <= deadkey_max)) // deadkeys + return 0xFFFF; + if((keyvals_dw > deadkey_max) || ((keyvals_dw < deadkey_min) && ( keyvals_dw > 0xFF))) // out of range + return 0xFFFE; + else // usable char + return keyvals_dw; } - KMX_DWORD testvar_S2 = ScanCodeToUSVirtualKey[keycode-8]; - if ( keycode >7) - return (KMX_DWORD) ScanCodeToUSVirtualKey[keycode-8]; - return 0; //_S2 what to return if not found -} -KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS( KMX_DWORD VK_US) { -KMX_DWORD test_S2 = (8+ USVirtualKeyToScanCode[ VK_US ]); - if( VK_US > 7) { - return (KMX_DWORD)(8+ USVirtualKeyToScanCode[ VK_US ]);} - else - return 0; -} -KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector,KMX_DWORD KC_US, ShiftState ss, int caps) { + // _S2 ToDo use only one of those + KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ + + GdkModifierType consumed; + GdkKeymapKey *maps; + guint *keyvals; + gint count; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return 0; + + KMX_DWORD keyvals_dw= (KMX_DWORD) NEW_KMX_get_Keyval_all_7(keymap, keycode, ss, caps) ; + return keyvals_dw; + } + // _S2 ToDo use only one of those + KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw_OLD(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ + + GdkModifierType consumed; + GdkKeymapKey *maps; + guint *keyvals; + gint count; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return 0; + + //BASE (shiftstate: 0) + if (( ss == Base ) && ( caps == 0 )) { + GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); + } + + //BASE + CAPS (shiftstate: 0) + else if (( ss == Base ) && ( caps == 1 )) { + GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); + } + + //SHIFT (shiftstate: 1) + else if (( ss == Shft ) && ( caps == 0 )) { + GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + } + + //SHIFT+CAPS (shiftstate: 1) + else if ( ( ss == Shft ) && ( caps ==1 )) { + GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); + } + + // Ctrl (shiftstate: 2) + else if (( ss == Ctrl ) && ( caps == 0 )){ + GdkModifierType MOD_Ctrl = (GdkModifierType) ( GDK_MOD5_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl , 0, keyvals, NULL, NULL, & consumed); + } + + // Ctrl (shiftstate: 2) + else if (( ss == Ctrl ) && ( caps == 1 )){ + GdkModifierType MOD_CtrlCaps = (GdkModifierType) (GDK_MOD5_MASK | GDK_LOCK_MASK); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps , 0, keyvals, NULL, NULL, & consumed); + } + + // SHIFT+Ctrl (shiftstate: 3) + else if (( ss == ShftCtrl ) && ( caps == 0 )){ + GdkModifierType MOD_Ctrl = (GdkModifierType) (GDK_SHIFT_MASK | GDK_MOD5_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl , 0, keyvals, NULL, NULL, & consumed); + } + + // SHIFT+Ctrl (shiftstate: 3) + else if (( ss == ShftCtrl ) && ( caps == 1 )){ + GdkModifierType MOD_CtrlCaps = (GdkModifierType) ( GDK_SHIFT_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR (shiftstate: 6) + else if (( ss == MenuCtrl ) && ( caps == 0 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR +CAPS (shiftstate: 6) + else if (( ss == MenuCtrl ) && ( caps == 1 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR (shiftstate: 7) + else if (( ss == ShftMenuCtrl ) && ( caps == 0 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR +CAPS (shiftstate: 7) + else if (( ss == ShftMenuCtrl ) && ( caps == 1 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + else + return 0; + + if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max)) // deadkeys + return 0xFFFF; + if((*keyvals > deadkey_max) || ((*keyvals < deadkey_min) && ( *keyvals > 0xFF))) // out of range + return 0xFFFE; + else // usable char + return (KMX_DWORD) *keyvals; + } + + +/* + std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_OLD(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ + + GdkModifierType consumed; + GdkKeymapKey *maps; + guint *keyvals; + gint count; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return L"\0"; + + //unshifted (shiftstate: 0) + if (( ss == Base ) && ( caps == 0 )) { + GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); + } + + //caps (shiftstate: 0) + else if (( ss == Base ) && ( caps == 1 )) { + GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); + } + + //Shift (shiftstate: 1) + else if (( ss == Shft ) && ( caps == 0 )) { + GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + std::wstring rV1= std::wstring(1, (int) *keyvals); + } + + //SHIFT+CAPS (shiftstate: 1) + else if ( ( ss == Shft ) && ( caps ==1 )) { + GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR (shiftstate: 6) + else if (( ss == MenuCtrl ) && ( caps == 0 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR +CAPS (shiftstate: 6) + else if (( ss == MenuCtrl ) && ( caps == 1 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR (shiftstate: 7) + else if (( ss == ShftMenuCtrl ) && ( caps == 0 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR +CAPS (shiftstate: 7) + else if (( ss == ShftMenuCtrl ) && ( caps == 1 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + else + return L"\0"; + + //if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max) ) + if((*keyvals >= deadkey_min) ) + return convert_DeadkeyValues_ToChar((int) *keyvals); + else + return std::wstring(1, (int) *keyvals); + } + +*/ + + + std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ + + GdkModifierType consumed; + GdkKeymapKey *maps; + guint *keyvals; + gint count; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return L"\0"; + + /* //unshifted (shiftstate: 0) + if (( ss == Base ) && ( caps == 0 )) { + GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); + } + + //caps (shiftstate: 0) + else if (( ss == Base ) && ( caps == 1 )) { + GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); + } + + //Shift (shiftstate: 1) + else if (( ss == Shft ) && ( caps == 0 )) { + GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + std::wstring rV1= std::wstring(1, (int) *keyvals); + } + + //SHIFT+CAPS (shiftstate: 1) + else if ( ( ss == Shft ) && ( caps ==1 )) { + GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); + } + + + //ALT-GR (shiftstate: 6) + else if (( ss == MenuCtrl ) && ( caps == 0 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR +CAPS (shiftstate: 6) + else if (( ss == MenuCtrl ) && ( caps == 1 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR (shiftstate: 7) + else if (( ss == ShftMenuCtrl ) && ( caps == 0 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + + //ALT-GR +CAPS (shiftstate: 7) + else if (( ss == ShftMenuCtrl ) && ( caps == 1 )){ + GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + } + else + return L"\0";*/ + + + + if( (ss ==2 ) ||(ss ==3 )) + return L"\0"; + + + int keyvals_int= NEW_KMX_get_Keyval_all_7(keymap, keycode, ss, caps); + + + + //if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max) ) + if((keyvals_int >= deadkey_min) ) + return convert_DeadkeyValues_ToChar(keyvals_int); + else + return std::wstring(1, keyvals_int); + } + + + + + + + + + KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { + + GdkModifierType consumed; + GdkKeymapKey *maps; + guint *keyvals; + guint lowerCase; + guint upperCase; + gint count; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return 0; + + //Shift + GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + + for (int i = 0; i < count; i++) { + if (maps[i].level > 1 || maps[i].group > 1) + continue; + + gchar * kv_name = gdk_keyval_name (keyvals[i]); + + if ( keyvals[i]>0) + gdk_keyval_convert_case (*kv_name, &lowerCase, &upperCase); + + // _S2 is ( lowerCase == upperCase ) true for all number keys for all keyboards? + if ( lowerCase == upperCase ) + return (KMX_DWORD) upperCase; + } + + KMX_DWORD testvar_S2 = ScanCodeToUSVirtualKey[keycode-8]; + if ( keycode >7) + return (KMX_DWORD) ScanCodeToUSVirtualKey[keycode-8]; + + return 0; //_S2 what to return if not found + } + + KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS( KMX_DWORD VK_US) { + KMX_DWORD test_S2 = (8+ USVirtualKeyToScanCode[ VK_US ]); + if( VK_US > 7) { + return (KMX_DWORD)(8+ USVirtualKeyToScanCode[ VK_US ]);} + else + return 0; + } + + KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector,KMX_DWORD KC_US, ShiftState ss, int caps) { KMX_DWORD Character; - std::wstring ws = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_OLD(keymap, KC_US, ss, caps); - //std::wstring ws = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, KC_US, ss, caps); - + ///std::wstring ws = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_OLD(keymap, KC_US, ss, caps); + std::wstring ws = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, KC_US, ss, caps); Character = *ws.c_str(); //Find underlying SC of character diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 24a3ac8490..4228ebafdc 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -509,23 +509,26 @@ std::wstring convert_DeadkeyValues_ToChar(int in); // take deadkey-value (e.g.65106) and return u16string (e.g. '^' ) std::u16string convert_DeadkeyValues_To_U16str(int in); -// find Keyvals to fill into 2D-Vector of Other Language -KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos); -KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky); + +int NEW_KMX_get_Keyval_all_7(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); int KMX_get_KeyvalsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); +// find Keyvals to fill into 2D-Vector of Other Language +KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos); +KMX_DWORD KMX_get_rc_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos); +KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky); + // returns KeySyms for a given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) -std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_OLD(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); -// returns KeySyms for a given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) -//std::u16string KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_16_OLD(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); -//std::u16string KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_16(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); -// returns KeySyms for a given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) -KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw_OLD(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); +KMX_DWORD KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); + + + + // return the VirtualKey of the Other Keyboard for given Scancode using GDK KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD scanCode); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 4830dcbab2..c08e7beec1 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -104,19 +104,17 @@ const int KMX_ShiftStateMap[] = { // _S2 naming?? int KMX_ToUnicodeEx(guint ScanCode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, int shift_state, int caps,GdkKeymap *keymap) { - KMX_DWORD kvl= KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap, ScanCode, shift_state); - //if((kvl >= deadkey_min) && (kvl <= deadkey_max)) + KMX_DWORD rc = KMX_get_rc_From_KeyCodeUnderlying_GDK(keymap,ScanCode, shift_state); - - std::wstring character = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_OLD(keymap, ScanCode, ShiftState(shift_state), caps); - std::u16string uuu16= u16string_from_wstring(character).c_str(); + std::wstring character= KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, ScanCode, ShiftState(shift_state), caps); pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(character).c_str(); - if((kvl == 0xFFFE)) + if(rc == 0xFFFE) return 0; - if((kvl == 0xFFFF)) + else if(rc == 0xFFFF) return -1; - return 1; + else + return 1; } int KMX_DeadKeyMap(int index, std::vector *deadkeys, int deadkeyBase, std::vector *deadkeyMappings) { // I4327 // I4353 From 38ce7ab87b583221bef67fb271d05ecca852f37b Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 6 Feb 2024 18:24:59 +0100 Subject: [PATCH 187/327] feat(linux): mcompile-dk new KMX_toUnicodeEx --- linux/mcompile/keymap/helpers.cpp | 21 + linux/mcompile/keymap/keymap.cpp | 461 +++++----------------- linux/mcompile/keymap/keymap.h | 12 +- linux/mcompile/keymap/mc_import_rules.cpp | 41 +- 4 files changed, 147 insertions(+), 388 deletions(-) diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 179a07ea68..6be364ccfb 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -1084,6 +1084,27 @@ gdk_keyval_convert_case (GDK_KEY_dollar, lower,upper);*/ } }*/ + + +// _S2 naming?? the original +/*int KMX_ToUnicodeEx_OLD(guint ScanCode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, int shift_state, int caps,GdkKeymap *keymap) { + + KMX_DWORD rc = KMX_get_rc_From_KeyCodeUnderlying_GDK(keymap,ScanCode, shift_state); + + std::wstring character= KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, ScanCode, ShiftState(shift_state), caps); + pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(character).c_str(); + + if((rc == 0)) + return -0; + else if((rc == 0xFFFE)) + return 0; + else if((rc == 0xFFFF)) + return -1; + else + return 1; +}*/ + + // _S2 can go later /*KMX_DWORD writeKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 12b17fc1b1..e00b23674e 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -440,8 +440,7 @@ std::u16string convert_DeadkeyValues_To_U16str(int in) { return u"\0"; } -//_S2 change Name -int NEW_KMX_get_Keyval_all_7(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps) { +int KMX_get_keyvals_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps) { GdkModifierType consumed; GdkKeymapKey *maps; @@ -527,42 +526,41 @@ int NEW_KMX_get_Keyval_all_7(GdkKeymap *keymap, guint keycode, ShiftState ss, in return (int) *keyvals; } +KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky) { + GdkKeymapKey *maps; + guint *keyvals; + gint count; + KMX_DWORD out; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return 0; + //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html + + if (!(shift_state_pos <= count)) + return 0; + + if (!(keycode <= 94)) + return 0; + + // _S2 can I use that????? + KMX_DWORD deadkey = (KMX_DWORD) keyvals[shift_state_pos]; + //KMX_DWORD deadkey2= (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ShiftState ss, int caps) + //wprintf(L" keyvals[shift_state_pos]: %i %i %i %i----", keyvals[0],keyvals[1],keyvals[2],keyvals[3]); - // _S2 use gdk_keymap_translate_keyboard_state instead return s shifted + unshifted only- no altgr,... - KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky) { - GdkKeymapKey *maps; - guint *keyvals; - gint count; - KMX_DWORD out; + dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str(); + out = KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); + wprintf(L" out is :.....................................%i\n", out); - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return 0; - //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html + // _S2 g_free used everywhere? + g_free(keyvals); + g_free(maps); - if (!(shift_state_pos <= count)) - return 0; + return out; +} - if (!(keycode <= 94)) - return 0; - - KMX_DWORD deadkey = (KMX_DWORD) keyvals[shift_state_pos]; - //wprintf(L" keyvals[shift_state_pos]: %i %i %i %i----", keyvals[0],keyvals[1],keyvals[2],keyvals[3]); - - dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str(); - out = KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); - - // _S2 g_free used everywhere? - g_free(keyvals); - g_free(maps); - - return out; - } - - -// _S2 use gdk_keymap_translate_keyboard_state instead return s shifted + unshifted only- no altgr,... KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; guint *keyvals; @@ -580,13 +578,6 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap if (!(keycode <= 94)) return 0; - // _S2 can I opt this out whne i do nou use dky?? - // KMX_DWORD deadkey = (KMX_DWORD) keyvals[shift_state_pos]; - // //wprintf(L" keyvals[shift_state_pos]: %i %i %i %i----", keyvals[0],keyvals[1],keyvals[2],keyvals[3]); - // dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str(); - - //out = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw_OLD(keymap, keycode, (ShiftState) shift_state_pos, 0); - //out = KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos,0); out = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos,0); // _S2 g_free used everywhere? @@ -595,8 +586,7 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap return out; } - -// _S2 use gdk_keymap_translate_keyboard_state instead return s shifted + unshifted only- no altgr,... +/* KMX_DWORD KMX_get_rc_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; guint *keyvals; @@ -614,14 +604,7 @@ KMX_DWORD KMX_get_rc_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode if (!(keycode <= 94)) return 0; - // _S2 can I opt this out whne i do nou use dky?? - // KMX_DWORD deadkey = (KMX_DWORD) keyvals[shift_state_pos]; - // //wprintf(L" keyvals[shift_state_pos]: %i %i %i %i----", keyvals[0],keyvals[1],keyvals[2],keyvals[3]); - // dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str(); - - //out = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw_OLD(keymap, keycode, (ShiftState) shift_state_pos, 0); out = KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos,0); - //out = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos,0); // _S2 g_free used everywhere? g_free(keyvals); @@ -629,347 +612,89 @@ KMX_DWORD KMX_get_rc_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode return out; } - - // _S2 ToDo use only one of those - KMX_DWORD KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ - - GdkModifierType consumed; - GdkKeymapKey *maps; - guint *keyvals; - gint count; - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return 0; - - KMX_DWORD keyvals_dw= (KMX_DWORD) NEW_KMX_get_Keyval_all_7(keymap, keycode, ss, caps) ; - - if((keyvals_dw >= deadkey_min) && (keyvals_dw <= deadkey_max)) // deadkeys - return 0xFFFF; - if((keyvals_dw > deadkey_max) || ((keyvals_dw < deadkey_min) && ( keyvals_dw > 0xFF))) // out of range - return 0xFFFE; - else // usable char - return keyvals_dw; - } - - - - - // _S2 ToDo use only one of those - KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ - - GdkModifierType consumed; - GdkKeymapKey *maps; - guint *keyvals; - gint count; - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return 0; - - KMX_DWORD keyvals_dw= (KMX_DWORD) NEW_KMX_get_Keyval_all_7(keymap, keycode, ss, caps) ; - return keyvals_dw; - } - // _S2 ToDo use only one of those - KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw_OLD(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ - - GdkModifierType consumed; - GdkKeymapKey *maps; - guint *keyvals; - gint count; - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return 0; - - //BASE (shiftstate: 0) - if (( ss == Base ) && ( caps == 0 )) { - GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); - } - - //BASE + CAPS (shiftstate: 0) - else if (( ss == Base ) && ( caps == 1 )) { - GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); - } - - //SHIFT (shiftstate: 1) - else if (( ss == Shft ) && ( caps == 0 )) { - GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); - } - - //SHIFT+CAPS (shiftstate: 1) - else if ( ( ss == Shft ) && ( caps ==1 )) { - GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); - } - - // Ctrl (shiftstate: 2) - else if (( ss == Ctrl ) && ( caps == 0 )){ - GdkModifierType MOD_Ctrl = (GdkModifierType) ( GDK_MOD5_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl , 0, keyvals, NULL, NULL, & consumed); - } - - // Ctrl (shiftstate: 2) - else if (( ss == Ctrl ) && ( caps == 1 )){ - GdkModifierType MOD_CtrlCaps = (GdkModifierType) (GDK_MOD5_MASK | GDK_LOCK_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps , 0, keyvals, NULL, NULL, & consumed); - } - - // SHIFT+Ctrl (shiftstate: 3) - else if (( ss == ShftCtrl ) && ( caps == 0 )){ - GdkModifierType MOD_Ctrl = (GdkModifierType) (GDK_SHIFT_MASK | GDK_MOD5_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl , 0, keyvals, NULL, NULL, & consumed); - } - - // SHIFT+Ctrl (shiftstate: 3) - else if (( ss == ShftCtrl ) && ( caps == 1 )){ - GdkModifierType MOD_CtrlCaps = (GdkModifierType) ( GDK_SHIFT_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps , 0, keyvals, NULL, NULL, & consumed); - } - - //ALT-GR (shiftstate: 6) - else if (( ss == MenuCtrl ) && ( caps == 0 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - //ALT-GR +CAPS (shiftstate: 6) - else if (( ss == MenuCtrl ) && ( caps == 1 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - //ALT-GR (shiftstate: 7) - else if (( ss == ShftMenuCtrl ) && ( caps == 0 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - //ALT-GR +CAPS (shiftstate: 7) - else if (( ss == ShftMenuCtrl ) && ( caps == 1 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - else - return 0; - - if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max)) // deadkeys - return 0xFFFF; - if((*keyvals > deadkey_max) || ((*keyvals < deadkey_min) && ( *keyvals > 0xFF))) // out of range - return 0xFFFE; - else // usable char - return (KMX_DWORD) *keyvals; - } - - -/* - std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_OLD(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ - - GdkModifierType consumed; - GdkKeymapKey *maps; - guint *keyvals; - gint count; - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return L"\0"; - - //unshifted (shiftstate: 0) - if (( ss == Base ) && ( caps == 0 )) { - GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); - } - - //caps (shiftstate: 0) - else if (( ss == Base ) && ( caps == 1 )) { - GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); - } - - //Shift (shiftstate: 1) - else if (( ss == Shft ) && ( caps == 0 )) { - GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); - std::wstring rV1= std::wstring(1, (int) *keyvals); - } - - //SHIFT+CAPS (shiftstate: 1) - else if ( ( ss == Shft ) && ( caps ==1 )) { - GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); - } - - //ALT-GR (shiftstate: 6) - else if (( ss == MenuCtrl ) && ( caps == 0 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - //ALT-GR +CAPS (shiftstate: 6) - else if (( ss == MenuCtrl ) && ( caps == 1 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - //ALT-GR (shiftstate: 7) - else if (( ss == ShftMenuCtrl ) && ( caps == 0 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - //ALT-GR +CAPS (shiftstate: 7) - else if (( ss == ShftMenuCtrl ) && ( caps == 1 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - else - return L"\0"; - - //if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max) ) - if((*keyvals >= deadkey_min) ) - return convert_DeadkeyValues_ToChar((int) *keyvals); - else - return std::wstring(1, (int) *keyvals); - } - */ +KMX_DWORD KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ + KMX_DWORD keyvals_dw= (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ss, caps) ; - std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ + if((keyvals_dw >= deadkey_min) && (keyvals_dw <= deadkey_max)) // deadkeys + return 0xFFFF; + else if((keyvals_dw > deadkey_max) || ((keyvals_dw < deadkey_min) && ( keyvals_dw > 0xFF))) // out of range + return 0xFFFE; + else // usable char + return keyvals_dw; +} - GdkModifierType consumed; - GdkKeymapKey *maps; - guint *keyvals; - gint count; - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return L"\0"; - - /* //unshifted (shiftstate: 0) - if (( ss == Base ) && ( caps == 0 )) { - GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); - } - - //caps (shiftstate: 0) - else if (( ss == Base ) && ( caps == 1 )) { - GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); - } - - //Shift (shiftstate: 1) - else if (( ss == Shft ) && ( caps == 0 )) { - GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); - std::wstring rV1= std::wstring(1, (int) *keyvals); - } - - //SHIFT+CAPS (shiftstate: 1) - else if ( ( ss == Shft ) && ( caps ==1 )) { - GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); - } - - - //ALT-GR (shiftstate: 6) - else if (( ss == MenuCtrl ) && ( caps == 0 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - //ALT-GR +CAPS (shiftstate: 6) - else if (( ss == MenuCtrl ) && ( caps == 1 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - //ALT-GR (shiftstate: 7) - else if (( ss == ShftMenuCtrl ) && ( caps == 0 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - //ALT-GR +CAPS (shiftstate: 7) - else if (( ss == ShftMenuCtrl ) && ( caps == 1 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - else - return L"\0";*/ +KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ + return (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ss, caps); +} +std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ + // _S2 skip ss 2+3 if( (ss ==2 ) ||(ss ==3 )) return L"\0"; + int keyvals_int= KMX_get_keyvals_From_Keycode(keymap, keycode, ss, caps); - int keyvals_int= NEW_KMX_get_Keyval_all_7(keymap, keycode, ss, caps); + //if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max) ) + if((keyvals_int >= deadkey_min) ) + return convert_DeadkeyValues_ToChar(keyvals_int); + else + return std::wstring(1, keyvals_int); +} +// _use gdk_keymap_translate_keyboard_state of other function +KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { - //if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max) ) - if((keyvals_int >= deadkey_min) ) - return convert_DeadkeyValues_ToChar(keyvals_int); - else - return std::wstring(1, keyvals_int); + GdkModifierType consumed; + GdkKeymapKey *maps; + guint *keyvals; + guint lowerCase; + guint upperCase; + gint count; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return 0; + + //Shift + GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + + for (int i = 0; i < count; i++) { + if (maps[i].level > 1 || maps[i].group > 1) + continue; + + gchar * kv_name = gdk_keyval_name (keyvals[i]); + + if ( keyvals[i]>0) + gdk_keyval_convert_case (*kv_name, &lowerCase, &upperCase); + + // _S2 is ( lowerCase == upperCase ) true for all number keys for all keyboards? + if ( lowerCase == upperCase ) + return (KMX_DWORD) upperCase; } +KMX_DWORD testvar_S2 = ScanCodeToUSVirtualKey[keycode-8]; + if ( keycode >7) + return (KMX_DWORD) ScanCodeToUSVirtualKey[keycode-8]; + return 0; //_S2 what to return if not found +} +KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS( KMX_DWORD VK_US) { +KMX_DWORD test_S2 = (8+ USVirtualKeyToScanCode[ VK_US ]); + if( VK_US > 7) { + return (KMX_DWORD)(8+ USVirtualKeyToScanCode[ VK_US ]);} + else + return 0; +} - - - - - KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { - - GdkModifierType consumed; - GdkKeymapKey *maps; - guint *keyvals; - guint lowerCase; - guint upperCase; - gint count; - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return 0; - - //Shift - GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); - - for (int i = 0; i < count; i++) { - if (maps[i].level > 1 || maps[i].group > 1) - continue; - - gchar * kv_name = gdk_keyval_name (keyvals[i]); - - if ( keyvals[i]>0) - gdk_keyval_convert_case (*kv_name, &lowerCase, &upperCase); - - // _S2 is ( lowerCase == upperCase ) true for all number keys for all keyboards? - if ( lowerCase == upperCase ) - return (KMX_DWORD) upperCase; - } - - KMX_DWORD testvar_S2 = ScanCodeToUSVirtualKey[keycode-8]; - if ( keycode >7) - return (KMX_DWORD) ScanCodeToUSVirtualKey[keycode-8]; - - return 0; //_S2 what to return if not found - } - - KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS( KMX_DWORD VK_US) { - KMX_DWORD test_S2 = (8+ USVirtualKeyToScanCode[ VK_US ]); - if( VK_US > 7) { - return (KMX_DWORD)(8+ USVirtualKeyToScanCode[ VK_US ]);} - else - return 0; - } - - KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector,KMX_DWORD KC_US, ShiftState ss, int caps) { +KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector,KMX_DWORD KC_US, ShiftState ss, int caps) { KMX_DWORD Character; - ///std::wstring ws = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_OLD(keymap, KC_US, ss, caps); std::wstring ws = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, KC_US, ss, caps); Character = *ws.c_str(); diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 4228ebafdc..f21a0688f6 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -506,19 +506,12 @@ bool IsKeymanUsedChar(int KV); // take deadkey-value (e.g.65106) and return wstring (e.g. '^' ) std::wstring convert_DeadkeyValues_ToChar(int in); -// take deadkey-value (e.g.65106) and return u16string (e.g. '^' ) std::u16string convert_DeadkeyValues_To_U16str(int in); +int KMX_get_keyvals_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); - -int NEW_KMX_get_Keyval_all_7(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); -int KMX_get_KeyvalsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); - - -// find Keyvals to fill into 2D-Vector of Other Language -KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos); -KMX_DWORD KMX_get_rc_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos); KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky); +KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos); // returns KeySyms for a given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); @@ -540,7 +533,6 @@ KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3 // converts codePoint to wstring std::wstring CodePointToWString(unsigned int codepoint); -// converts codePoint to u16string std::u16string CodePointToString_16(unsigned int codepoint); # endif /*KEYMAP_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index c08e7beec1..eb30c27c01 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -101,22 +101,44 @@ const int KMX_ShiftStateMap[] = { return false; } -// _S2 naming?? -int KMX_ToUnicodeEx(guint ScanCode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, int shift_state, int caps,GdkKeymap *keymap) { +int KMX_ToUnicodeEx(guint keycode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, int shift_state_pos, int caps,GdkKeymap *keymap) { - KMX_DWORD rc = KMX_get_rc_From_KeyCodeUnderlying_GDK(keymap,ScanCode, shift_state); +GdkKeymapKey *maps; + guint *keyvals; + gint count; + KMX_DWORD out; - std::wstring character= KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, ScanCode, ShiftState(shift_state), caps); + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return 0; + + //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html + + if (!(shift_state_pos <= count)) + return 0; + + if (!(keycode <= 94)) + return 0; + + + std::wstring character= KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, keycode, ShiftState(shift_state_pos), caps); pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(character).c_str(); - if(rc == 0xFFFE) - return 0; - else if(rc == 0xFFFF) + KMX_DWORD keyvals_dw= (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), caps) ; + + // _S2 g_free used everywhere? + g_free(keyvals); + g_free(maps); + + if((keyvals_dw >= deadkey_min) && (keyvals_dw <= deadkey_max)) // deadkeys return -1; - else - return 1; + else if(gdk_keyval_to_unicode(keyvals_dw) == 0) // NO UNICODE + return 0; + else // usable char + return 1; } + int KMX_DeadKeyMap(int index, std::vector *deadkeys, int deadkeyBase, std::vector *deadkeyMappings) { // I4327 // I4353 for(size_t i = 0; i < deadkeyMappings->size(); i++) { if((*deadkeyMappings)[i].deadkey == index) { @@ -726,7 +748,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // _S2 deadkey not finished; Ctrl, Shft +40 not tested for(int caps = 0; caps <= 1; caps++) { - // _S2 is THIS correct ??? Do we need lpKeyState or is it just used in ToUnicodeEx?? loader.KMX_ClearKeyboardBuffer(); loader.KMX_FillKeyState(lpKeyState, ss, (caps == 0)); int rc = KMX_ToUnicodeEx(SC_US, lpKeyState, sbBuffer, ss, caps, *keymap); From b345e6cda6916e1645c99cd5379686da512c08f0 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 6 Feb 2024 20:07:33 +0100 Subject: [PATCH 188/327] feat(linux): mcompile-dk tidy up --- linux/mcompile/keymap/deadkey.cpp | 11 +-- linux/mcompile/keymap/deadkey.h | 4 +- linux/mcompile/keymap/helpers.cpp | 26 ++++++ linux/mcompile/keymap/keymap.cpp | 98 +++++++++-------------- linux/mcompile/keymap/keymap.h | 4 + linux/mcompile/keymap/mc_import_rules.cpp | 22 +---- linux/mcompile/keymap/mc_kmxfile.cpp | 9 +-- linux/mcompile/keymap/mcompile.cpp | 31 +------ 8 files changed, 82 insertions(+), 123 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index b9f91f056a..51e8128c30 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -1,7 +1,7 @@ #include "keymap.h" #include "deadkey.h" -v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult) { +v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult) { v_dw_1D line; line.push_back(convertNamesToIntegerValue(first)); line.push_back(convertNamesToIntegerValue(second)); @@ -12,9 +12,7 @@ v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, // _S2 DEADKEY STUFF - DO NOT REVIEW YET bool find_dk_combinations_for_single_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &dk_SingleTable, KMX_DWORD dk) { - v_dw_1D line; - //for ( int i =0; i< (int) (*p_dk_ComposeTable).size()-1; i++) { for ( int i =0; i< (int) (*p_dk_ComposeTable).size(); i++) { // _S2 is there a better way to find a-z,A-Z? //if (((*p_dk_ComposeTable)[i][0] == dk) ) { @@ -34,11 +32,9 @@ bool find_dk_combinations_for_single_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &d //_S2 REVIEW std::vector create_alDead() { - std::vector alDead; - v_dw_2D dk_ComposeTable; - KMX_DWORD dw= create_DKTable(dk_ComposeTable); + KMX_DWORD dw = create_DKTable(dk_ComposeTable); for( int i=0; i< dk_ComposeTable.size()-1; i++) { DeadKey *dk2= new DeadKey(dk_ComposeTable[i][0]); @@ -51,7 +47,6 @@ std::vector create_alDead() { } alDead.push_back(dk2); } - return alDead; } @@ -67,10 +62,8 @@ std::vector reduce_alDead(std::vector dk_big) { if(dk_big[i]->KMX_DeadCharacter() == dk_small[k]->KMX_DeadCharacter()) foundInSmall=true; } - if(!foundInSmall) dk_small.push_back(dk_big[i]); - foundInSmall=false; } } diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index 4cdedc822b..ea88446197 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -7,13 +7,11 @@ #include "mc_import_rules.h" // creates a vector for a dk combination ( ` + a -> à ) -v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult); +v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult); // creates a 2D-vector of all dk combinations ( ` + a -> à ; ^ + a -> â ; `+ e -> è; ...) KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable); -//KMX_DWORD find_dkCharacter(v_dw_2D * dk_ComposeTable, KMX_DWORD first, KMX_DWORD second ); - //_S2 REVIEW std::vector create_alDead(); std::vector reduce_alDead(std::vector dk_big) ; diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 6be364ccfb..4c9efd6dca 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -1084,7 +1084,33 @@ gdk_keyval_convert_case (GDK_KEY_dollar, lower,upper);*/ } }*/ +/* +KMX_DWORD KMX_get_rc_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos) { + GdkKeymapKey *maps; + guint *keyvals; + gint count; + KMX_DWORD out; + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return 0; + //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html + + if (!(shift_state_pos <= count)) + return 0; + + if (!(keycode <= 94)) + return 0; + + out = KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos,0); + + // _S2 g_free used everywhere? + g_free(keyvals); + g_free(maps); + + return out; +} +*/ // _S2 naming?? the original /*int KMX_ToUnicodeEx_OLD(guint ScanCode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, int shift_state, int caps,GdkKeymap *keymap) { diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index e00b23674e..12f60b6cc7 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -2,18 +2,16 @@ #include - -// _S2 is return 2 + 3 correct??? YES, it talking about the column-nr in symbols-file int map_VKShiftState_to_Lin(int VKShiftState) { if (VKShiftState == 0 ) return 0; /* 0000 0000 */ else if (VKShiftState == 16) return 1; /* 0001 0000 */ // _S2 if commented out only DK on base+shift will be processed ^ ' ` else if (VKShiftState == 9 ) return 2; /* 0000 1001 */ else if (VKShiftState == 25) return 3; /* 0001 1001 */ - else return VKShiftState; + else return VKShiftState; } -KMX_DWORD convertNamesToIntegerValue(std::wstring tok_wstr){ +KMX_DWORD convertNamesToIntegerValue(std::wstring tok_wstr) { // more on https://manpages.ubuntu.com/manpages/jammy/man3/keysyms.3tk.html std::map first; @@ -85,6 +83,24 @@ KMX_DWORD convertNamesToIntegerValue(std::wstring tok_wstr){ return returnIfCharInvalid; } +int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap) { + std::string US_language = "us"; + const char* text_us = "xkb_symbols \"basic\""; + //const char* text_us = "xkb_symbols \"intl\""; + + if(write_US_ToVector(All_Vector,US_language, text_us)) { + wprintf(L"ERROR: can't write US to Vector \n"); + return 1; + } + + // add contents of other keyboard to All_Vector + if( append_other_ToVector(All_Vector,keymap)) { + wprintf(L"ERROR: can't append Other ToVector \n"); + return 2; + } + return 0; +} + int write_US_ToVector( v_dw_3D &vec,std::string language, const char* text) { std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; @@ -134,11 +150,11 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, s print_OK = false; // start when finding the mark xkb_symbol + correct layout - if ((std::string(str_buf).find(str_txt) != std::string::npos)) + if (std::string(str_buf).find(str_txt) != std::string::npos) print_OK = true; // as long as we are in the same xkb_symbol layout block and find "key <" we push the whole line into a 1D-vector - if ((print_OK) && (std::string(str_buf).find(key) != std::string::npos)) { + if (print_OK && (std::string(str_buf).find(key) != std::string::npos)) { complete_List.push_back(buffer); } } @@ -262,9 +278,6 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { tokens_dw.push_back(tokens_int); } - //wprintf(L" Keyval %i: %i (%c) --- %i (%c) \n", tokens_dw[0],tokens_dw[1],tokens_dw[1], tokens_dw[2], tokens_dw[2]); - - // now push result to shift_states shift_states.push_back(tokens_dw); tokens_dw.clear(); tokens.clear(); @@ -325,7 +338,7 @@ int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { return 0; } -bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]){ +bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]) { // get keymap of keyboard layout in use gdk_init(&argc, &argv); @@ -341,7 +354,6 @@ bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]){ gdk_display_close(display); return 2; } - return 0; } @@ -468,7 +480,7 @@ int KMX_get_keyvals_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); } - //SHIFT+CAPS (shiftstate: 1) + //SHIFT + CAPS (shiftstate: 1) else if ( ( ss == Shft ) && ( caps ==1 )) { GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); @@ -480,7 +492,7 @@ int KMX_get_keyvals_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl , 0, keyvals, NULL, NULL, & consumed); } - // Ctrl (shiftstate: 2) + // Ctrl + CAPS (shiftstate: 2) else if (( ss == Ctrl ) && ( caps == 1 )){ GdkModifierType MOD_CtrlCaps = (GdkModifierType) (GDK_MOD5_MASK | GDK_LOCK_MASK); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps , 0, keyvals, NULL, NULL, & consumed); @@ -492,7 +504,7 @@ int KMX_get_keyvals_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl , 0, keyvals, NULL, NULL, & consumed); } - // SHIFT+Ctrl (shiftstate: 3) + // SHIFT+Ctrl + CAPS (shiftstate: 3) else if (( ss == ShftCtrl ) && ( caps == 1 )){ GdkModifierType MOD_CtrlCaps = (GdkModifierType) ( GDK_SHIFT_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps , 0, keyvals, NULL, NULL, & consumed); @@ -504,7 +516,7 @@ int KMX_get_keyvals_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); } - //ALT-GR +CAPS (shiftstate: 6) + //ALT-GR + CAPS (shiftstate: 6) else if (( ss == MenuCtrl ) && ( caps == 1 )){ GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); @@ -526,6 +538,7 @@ int KMX_get_keyvals_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss return (int) *keyvals; } +// _S2 TODO KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky) { GdkKeymapKey *maps; guint *keyvals; @@ -545,14 +558,11 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap // _S2 can I use that????? KMX_DWORD deadkey = (KMX_DWORD) keyvals[shift_state_pos]; - //KMX_DWORD deadkey2= (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ShiftState ss, int caps) - - //wprintf(L" keyvals[shift_state_pos]: %i %i %i %i----", keyvals[0],keyvals[1],keyvals[2],keyvals[3]); dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str(); - out = KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); - wprintf(L" out is :.....................................%i\n", out); + out = KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); + //wprintf(L" out is :.....................................%i\n", out); // _S2 g_free used everywhere? g_free(keyvals); @@ -569,8 +579,6 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html if (!(shift_state_pos <= count)) return 0; @@ -578,7 +586,7 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap if (!(keycode <= 94)) return 0; - out = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos,0); + out = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); // _S2 g_free used everywhere? g_free(keyvals); @@ -586,36 +594,11 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap return out; } -/* -KMX_DWORD KMX_get_rc_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos) { - GdkKeymapKey *maps; - guint *keyvals; - gint count; - KMX_DWORD out; - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return 0; - //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html - - if (!(shift_state_pos <= count)) - return 0; - - if (!(keycode <= 94)) - return 0; - - out = KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos,0); - - // _S2 g_free used everywhere? - g_free(keyvals); - g_free(maps); - - return out; -} -*/ +// _S2 ToDo KMX_DWORD KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ - KMX_DWORD keyvals_dw= (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ss, caps) ; + KMX_DWORD keyvals_dw= (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ss, caps) ; if((keyvals_dw >= deadkey_min) && (keyvals_dw <= deadkey_max)) // deadkeys return 0xFFFF; @@ -627,26 +610,25 @@ KMX_DWORD KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(Gdk KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ - return (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ss, caps); + return (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ss, caps); } std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ // _S2 skip ss 2+3 if( (ss ==2 ) ||(ss ==3 )) - return L"\0"; + return L"\0"; - int keyvals_int= KMX_get_keyvals_From_Keycode(keymap, keycode, ss, caps); + int keyvals_int= KMX_get_keyvals_From_Keycode(keymap, keycode, ss, caps); //if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max) ) - if((keyvals_int >= deadkey_min) ) + if((keyvals_int >= deadkey_min)) return convert_DeadkeyValues_ToChar(keyvals_int); else return std::wstring(1, keyvals_int); } - -// _use gdk_keymap_translate_keyboard_state of other function +// _S2 ToDo // _use gdk_keymap_translate_keyboard_state of other function KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { GdkModifierType consumed; @@ -685,7 +667,7 @@ KMX_DWORD testvar_S2 = ScanCodeToUSVirtualKey[keycode-8]; } KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS( KMX_DWORD VK_US) { -KMX_DWORD test_S2 = (8+ USVirtualKeyToScanCode[ VK_US ]); + KMX_DWORD test_S2 = (8+ USVirtualKeyToScanCode[ VK_US ]); if( VK_US > 7) { return (KMX_DWORD)(8+ USVirtualKeyToScanCode[ VK_US ]);} else @@ -695,7 +677,7 @@ KMX_DWORD test_S2 = (8+ USVirtualKeyToScanCode[ VK_US ]); KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector,KMX_DWORD KC_US, ShiftState ss, int caps) { KMX_DWORD Character; - std::wstring ws = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, KC_US, ss, caps); + std::wstring ws = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, KC_US, ss, caps); Character = *ws.c_str(); //Find underlying SC of character diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index f21a0688f6..f06d1b2cc3 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -508,6 +508,9 @@ bool IsKeymanUsedChar(int KV); std::wstring convert_DeadkeyValues_ToChar(int in); std::u16string convert_DeadkeyValues_To_U16str(int in); + + +// uses gdk_keymap_translate_keyboard_state to get keyval int KMX_get_keyvals_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky); @@ -517,6 +520,7 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); +// _S2 returns char or FFFF / FFFE ???? KMX_DWORD KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index eb30c27c01..4427852a9c 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -36,7 +36,7 @@ void TestKey_S21(LPKMX_KEY key, int iii, int gr) { wprintf(L"\n group[%i] dpKeyArray[%i] (key->key: %i) ",gr, iii, key->Key); int tzuiop=0; do { - wprintf(L"%i\t", *(PP+z )); + wprintf(L"%i\t", *(PP+z )); z++; } while (*(PP+z) !=0); } @@ -102,8 +102,7 @@ const int KMX_ShiftStateMap[] = { } int KMX_ToUnicodeEx(guint keycode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, int shift_state_pos, int caps,GdkKeymap *keymap) { - -GdkKeymapKey *maps; + GdkKeymapKey *maps; guint *keyvals; gint count; KMX_DWORD out; @@ -111,20 +110,16 @@ GdkKeymapKey *maps; if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html - if (!(shift_state_pos <= count)) return 0; if (!(keycode <= 94)) return 0; - std::wstring character= KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, keycode, ShiftState(shift_state_pos), caps); pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(character).c_str(); - KMX_DWORD keyvals_dw= (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), caps) ; + KMX_DWORD keyvals_dw= (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), caps) ; // _S2 g_free used everywhere? g_free(keyvals); @@ -138,7 +133,6 @@ GdkKeymapKey *maps; return 1; } - int KMX_DeadKeyMap(int index, std::vector *deadkeys, int deadkeyBase, std::vector *deadkeyMappings) { // I4327 // I4353 for(size_t i = 0; i < deadkeyMappings->size(); i++) { if((*deadkeyMappings)[i].deadkey == index) { @@ -407,7 +401,7 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; // key->Key stores VK-US ( not underlying !!) // key->dpOutput stores character Underlying - KMX_DWORD SC_Underlying_gdk = KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(keymap, All_Vector,this->SC(), (ShiftState) ss, caps); + KMX_DWORD SC_Underlying_gdk = KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(keymap, All_Vector,this->SC(), (ShiftState) ss, caps); key->Key = KMX_get_VKUS_From_KeyCodeUnderlying_GDK( keymap, SC_Underlying_gdk); key->Line = 0; @@ -626,7 +620,6 @@ KMX_WCHAR sbBuffer1[16]; } }; - int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { int n = 0; while(p && *p) { @@ -637,7 +630,6 @@ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { return n; } - void check_rgkey_S2( std::vector rgKey, int i) { wprintf(L" rgfDeadkey[%i]: \t%i %i %i %i %i %i %i %i %i %i\n", i, @@ -686,16 +678,10 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, } } - for(UINT ke = VK_NUMPAD0; ke <= VK_NUMPAD9; ke++) { rgKey[ke] = new KMX_VirtualKey(hkl, ke, keymap); } - /*UINT Val_VK_NUMPAD0[] = {45,35,40,34,37,12,39,36,38,33, 0xFFFF}; - for (int i = 0; Val_VK_NUMPAD0[i] != 0xFFFF; i++) { - rgKey[Val_VK_NUMPAD0[i] ] = new KMX_VirtualKey(hkl, Val_VK_NUMPAD0[i] , keymap); - }*/ - // _S2 ???? which numbers for VK_DIVIDE, VK_CANCEL, VK_DECIMAL ? rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE, keymap); rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL, keymap); diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 6550ecbfcc..6a879bbcf4 100755 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -338,14 +338,7 @@ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFil if(cgp->dpMatch != NULL) gp->dpMatch = (PKMX_WCHAR) (base + cgp->dpMatch); if(cgp->dpNoMatch != NULL) gp->dpNoMatch = (PKMX_WCHAR) (base + cgp->dpNoMatch); - // _S2 Version of kmx_file v - /*gp->dpName = StringOffset(base, cgp->dpName); - gp->dpKeyArray = cgp->cxKeyArray > 0 ? (LPKEY) (base + cgp->dpKeyArray) : NULL; - gp->dpMatch = StringOffset(base, cgp->dpMatch); - gp->dpNoMatch = StringOffset(base, cgp->dpNoMatch);*/ - // _S2 Version of kmx_file ^ - - for(kp = gp->dpKeyArray, ckp = (PKMX_COMP_KEY) kp, j = 0; j < gp->cxKeyArray; j++, kp++, ckp++) { + for(kp = gp->dpKeyArray, ckp = (PKMX_COMP_KEY) kp, j = 0; j < gp->cxKeyArray; j++, kp++, ckp++) { kp->dpOutput = (PKMX_WCHAR) (base + ckp->dpOutput); kp->dpContext = (PKMX_WCHAR) (base + ckp->dpContext); } diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index f2a34b5227..849a7ca857 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -95,7 +95,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ char16_t* infile = (char16_t*) argv[n], *outfile = (char16_t*) argv[n+1]; - wprintf(L"mcompile%ls \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d" : L"", u16fmt((const char16_t*) infile).c_str(), u16fmt((const char16_t*) outfile).c_str() ); // I4174 + wprintf(L"mcompile%ls \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d" : L"", u16fmt((const char16_t*) infile).c_str(), u16fmt((const char16_t*) outfile).c_str() ); // I4174 // 1. Load the keyman keyboard file @@ -155,7 +155,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ // Map of all shift states that we will work with const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; -// my comment for Lin version +// _S2 my comment for Lin version // Ubuntu: Each of the 4 columns specifies a different modifier: unmodified, shift, right alt (altgr), shift+right alt(altgr) // some hold up to 8 what are those ??? // we have assigned these to columns 1-4 ( column o holds the keycode) @@ -464,7 +464,6 @@ KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { return TRUE; } } - KMX_LogError(L"Keyboard is not a mnemonic layout keyboard"); return FALSE; } @@ -484,7 +483,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg // _S2 TODO first version with GTK - maybe change later to XklGetGroupNames und XklGetCurrentState as Eberhard suggested //_ init gdk GdkKeymap *keymap; - if(InitializeGDK(&keymap , argc, argv)) { + if(InitializeGDK(&keymap , argc, argv)) { wprintf(L"ERROR: can't Initialize GDK\n"); return FALSE; } @@ -523,7 +522,6 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg } } - KMX_ReportUnconvertedKeyboardRules(kbd); if(!KMX_ImportRules(kbd, All_Vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 return FALSE; @@ -549,7 +547,6 @@ UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS) { } KMX_WCHAR KMX_get_VKUS_From_VKUnderlying_VEC(v_dw_3D All_Vector, KMX_DWORD VK_OTHER) { - KMX_DWORD VK_US; for( int i=0; i< (int)All_Vector[0].size()-1 ;i++) { for( int j=1; j< (int)All_Vector[0][0].size();j++) { @@ -573,29 +570,9 @@ KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_U *DeadKey = *dky; return 0xFFFF; } - return (KMX_WCHAR) KeyvalOther; } -int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap){ - std::string US_language = "us"; - const char* text_us = "xkb_symbols \"basic\""; - //const char* text_us = "xkb_symbols \"intl\""; - - if(write_US_ToVector(All_Vector,US_language, text_us)) { - wprintf(L"ERROR: can't write US to Vector \n"); - return 1; - } - - // _S2 is it OK to have 65535 instead of 94, 96 and 180 as a value for deadkeys in Vector - // add contents of other keyboard to All_Vector - if( append_other_ToVector(All_Vector,keymap)) { - wprintf(L"ERROR: can't append Other ToVector \n"); - return 2; - } - return 0; -} - int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap) { KMX_WORD *p = OutputPairs; @@ -634,7 +611,7 @@ void TestKey_S2(LPKMX_KEY key, int iii, int gr) { wprintf(L"\n group[%i] dpKeyArray[%i] ",gr, iii); int tzuiop=0; do { - wprintf(L"%i\t", *(PP+z )); + wprintf(L"%i\t", *(PP+z )); z++; } while (*(PP+z) !=0); } From 9c83fd02646ce68304ff43610e31a74c88b837ee Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 7 Feb 2024 10:29:44 +0100 Subject: [PATCH 189/327] feat(linux): mcompile-dk [K_?00] resolved --- linux/mcompile/keymap/keymap.cpp | 38 ++++++++++++++++++----- linux/mcompile/keymap/mc_import_rules.cpp | 6 ++-- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 12f60b6cc7..a2e6f5300f 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -397,7 +397,7 @@ bool IsKeymanUsedChar(int KV) { } // _S2 DEADKEY STUFF - DO NOT REVIEW YET -std::wstring convert_DeadkeyValues_ToChar(int in) { +std::wstring convert_DeadkeyValues_ToChar_old(int in) { KMX_DWORD lname; @@ -423,6 +423,35 @@ std::wstring convert_DeadkeyValues_ToChar(int in) { return L"\0"; } + +// _S2 DEADKEY STUFF - DO NOT REVIEW YET +std::wstring convert_DeadkeyValues_ToChar(int in) { + + KMX_DWORD lname; + + if (in == 0 ) + return L"\0"; + + std::string long_name((const char*) gdk_keyval_name (in)); + + if ( long_name.substr (0,2) == "U+" ) // U+... Unicode value + return CodePointToWString(in-0x1000000); + + if (in < (int) deadkey_min) { // no deadkey; no Unicode + /*if (!IsKeymanUsedKeyVal(std::wstring(1, in))) + return L"\0";*/ + return std::wstring(1, in); + } + + lname = convertNamesToIntegerValue( wstring_from_string(long_name)); // 65106 => "dead_circumflex " => 94 => "^" + + if (lname != returnIfCharInvalid) { + return std::wstring(1, lname ); + } + else + return L"\0"; +} + std::u16string convert_DeadkeyValues_To_U16str(int in) { KMX_DWORD lname; @@ -615,17 +644,12 @@ KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(Gdk std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ - // _S2 skip ss 2+3 + // _S2 skip ss 2+3 remove?? if( (ss ==2 ) ||(ss ==3 )) return L"\0"; int keyvals_int= KMX_get_keyvals_From_Keycode(keymap, keycode, ss, caps); - - //if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max) ) - if((keyvals_int >= deadkey_min)) return convert_DeadkeyValues_ToChar(keyvals_int); - else - return std::wstring(1, keyvals_int); } // _S2 ToDo // _use gdk_keymap_translate_keyboard_state of other function diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 4427852a9c..8c5446f246 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -369,9 +369,8 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; wprintf(L"st %i \n", st[0]); key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); - //key->ShiftFlags = this->KMX_GetShiftStateValue(1, caps, (ShiftState) ss); - //key->Key = KMX_get_VKUS_From_VKUnderlying_VEC(All_Vector,this->VK()); - // key->Key = KMX_get_VKUnderlying_From_VKUS_GDK(keymap,this->VK()); + // _S2 we already use VK_US so no need to convert it + key->Key = this->VK(); key->Line = 0; if(bDeadkeyConversion) { // I4552 @@ -730,6 +729,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, if(ss == MenuCtrl|| ss == ShftMenuCtrl) { continue; } + KMX_DWORD SC_US = KMX_get_KeyCodeUnderlying_From_VKUS(iKey); // _S2 deadkey not finished; Ctrl, Shft +40 not tested From fb47917974890b1452eb439fa04bcf56090776e9 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 9 Feb 2024 10:32:43 +0100 Subject: [PATCH 190/327] feat(linux): mcompile-dk alDead sorted & in right order as win version --- linux/mcompile/keymap/deadkey.cpp | 76 +++++++++++++++++++++-- linux/mcompile/keymap/deadkey.h | 6 +- linux/mcompile/keymap/helpers.cpp | 70 +++++++++++++++++++++ linux/mcompile/keymap/keymap.cpp | 13 +++- linux/mcompile/keymap/mc_import_rules.cpp | 16 +++-- linux/mcompile/keymap/mc_import_rules.h | 4 ++ linux/mcompile/keymap/mcompile.cpp | 9 ++- 7 files changed, 175 insertions(+), 19 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 51e8128c30..a97f24d323 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -39,10 +39,8 @@ std::vector create_alDead() { for( int i=0; i< dk_ComposeTable.size()-1; i++) { DeadKey *dk2= new DeadKey(dk_ComposeTable[i][0]); for ( int j=0; j< dk_ComposeTable.size();j++) { - // check for right dk - // _S2 do I need to trim here?? Yes, to prevent "aAeEiIoOuU -ˆ_^" + // _S2 check for right basechar, to prevent "aAeEiIoOuU -ˆ_^" if(( dk_ComposeTable[i][0]==dk_ComposeTable[j][0]) && (IsKeymanUsedChar(dk_ComposeTable[j][1]))) - //if(( dk_ComposeTable[i][0]==dk_ComposeTable[j][0]) ) dk2->KMX_AddDeadKeyRow(dk_ComposeTable[j][1],dk_ComposeTable[j][2]); } alDead.push_back(dk2); @@ -50,14 +48,80 @@ std::vector create_alDead() { return alDead; } -//_S2 REVIEW this is for testing only and needs to go later +bool found_dk_inVector(KMX_WCHAR dk, std::vector &dkVec) { + + int i=0; + if( dkVec.size()>0) { + do { + if( dk == dkVec[i]->KMX_GetDeadCharacter()) + return true; + i++; + } while (i < dkVec.size()); + } + return false; +} + +void Create_alDead(KMX_WCHAR dk, std::vector &dkVec, std::vector *p_All_Vec) { + std::vector dkVec_unsorted; + + if( dk == 0) + return; + + for (int j=0; j< (*p_All_Vec).size()-1;j++) { + if( dk == (*p_All_Vec)[j]->KMX_GetDeadCharacter()) { + if(! found_dk_inVector(dk, dkVec)) { + dkVec.push_back((*p_All_Vec)[j]); + return; + } + else return; + } + } + + for (int j=0; j< (*p_All_Vec).size()-1;j++) { + if( dk == (*p_All_Vec)[j]->KMX_GetDeadCharacter()) { + if(! found_dk_inVector(dk, dkVec_unsorted)) { + dkVec_unsorted.push_back((*p_All_Vec)[j]); + return; + } + else return; + } + } +} + +void sort_alDead(std::vector &small_Vec, std::vector *p_All_Vec) { + + std::vector small_sorted; + int Vsmall_size; + + int i=0; + + do { + int j=0; + Vsmall_size= small_Vec.size(); + + do { + if( (*p_All_Vec)[i]->KMX_DeadCharacter() == small_Vec[j]->KMX_DeadCharacter()) { + small_sorted.push_back(small_Vec[j]); + small_Vec.erase(std::next(small_Vec.begin()+j-1)); + Vsmall_size--; + } + j++; + } while (j< Vsmall_size); + + i++; + } while ((i< (*p_All_Vec).size()) && (Vsmall_size>0)); + + small_Vec = small_sorted; +} + +/* _S2 probably not needed //_S2 REVIEW this is for testing only and needs to go later std::vector reduce_alDead(std::vector dk_big) { std::vector dk_small; bool foundInSmall=false; for ( int i=1; iKMX_DeadCharacter()==94 || dk_big[i]->KMX_DeadCharacter()==96 || dk_big[i]->KMX_DeadCharacter()==180)) { + if( (dk_big[i]->KMX_DeadCharacter()==94 || dk_big[i]->KMX_DeadCharacter()==96 || dk_big[i]->KMX_DeadCharacter()==180|| dk_big[i]->KMX_DeadCharacter()==126|| dk_big[i]->KMX_DeadCharacter()==168)) { for( int k=0; k< dk_small.size();k++) { if(dk_big[i]->KMX_DeadCharacter() == dk_small[k]->KMX_DeadCharacter()) foundInSmall=true; @@ -69,7 +133,7 @@ std::vector reduce_alDead(std::vector dk_big) { } return dk_small; } - +*/ // _S2 DEADKEY STUFF - DO NOT REVIEW YET // _S2 might be used when deadkeys are implemented . is it correct?? KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap) { diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index ea88446197..4566756ee1 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -14,7 +14,11 @@ KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable); //_S2 REVIEW std::vector create_alDead(); -std::vector reduce_alDead(std::vector dk_big) ; +std::vector reduce_alDead(std::vector dk_big); + +void Create_alDead(KMX_WCHAR dk, std::vector &myVec, std::vector *p_All_Vec); +void sort_alDead(std::vector &myVec, std::vector *p_All_Vec); +bool found_dk_inVector(KMX_WCHAR dk, std::vector &myVec); // finds all combination for a specific deadkey(dk) bool find_dk_combinations_for_single_dk(v_dw_2D * dk_ComposeTable, v_dw_2D & dk_SingleTable, KMX_DWORD dk); diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 4c9efd6dca..d977ff4960 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -1084,6 +1084,76 @@ gdk_keyval_convert_case (GDK_KEY_dollar, lower,upper);*/ } }*/ +//_S2 REVIEW this is for testing only and needs to go later +/*std::vector reduce_alDead(GdkKeymap*keymap,std::vector dk_big) {/ + + + std::vector dk_underlying; + + + + std::vector dk_small; + bool foundInSmall=false; + + for ( int i=1; iKMX_DeadCharacter()==94 || dk_big[i]->KMX_DeadCharacter()==96 || dk_big[i]->KMX_DeadCharacter()==180|| dk_big[i]->KMX_DeadCharacter()==126|| dk_big[i]->KMX_DeadCharacter()==168)) { + for( int k=0; k< dk_small.size();k++) { + if(dk_big[i]->KMX_DeadCharacter() == dk_small[k]->KMX_DeadCharacter()) + foundInSmall=true; + } + if(!foundInSmall) + dk_small.push_back(dk_big[i]); + foundInSmall=false; + } + } + return dk_small; +}*/ + + + +/*// _S2 TODO +KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK_old(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky) { + GdkKeymapKey *maps; + guint *keyvals; + gint count; + KMX_DWORD out; + + +//in: keycode, shift_state_pos,keymap +//(out): dky-code if it is a deadkey; if not keep last +//out: keyval for char; FFFF for dk + + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return 0; + //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html + + if (!(shift_state_pos <= count)) + return 0; + + if (!(keycode <= 94)) + return 0; + + // _S2 can I use that????? + KMX_DWORD deadkey = (KMX_DWORD) keyvals[shift_state_pos]; + //wprintf(L" keyvals[shift_state_pos]: %i %i %i %i----", keyvals[0],keyvals[1],keyvals[2],keyvals[3]); + + dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str(); + out = KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); + //wprintf(L" out is :.....................................%i\n", out); + + // _S2 g_free used everywhere? + g_free(keyvals); + g_free(maps); + + return out; +} +*/ + + + /* KMX_DWORD KMX_get_rc_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index a2e6f5300f..150d8c95bd 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -54,7 +54,7 @@ KMX_DWORD convertNamesToIntegerValue(std::wstring tok_wstr) { first[L"dead_abovedot"] = 729; first[L"dead_abovering"] = 730; - first[L"dead_acute"] = 180; //39 180 ?? + first[L"dead_acute"] = 180; first[L"dead_breve"] = 728; first[L"dead_caron"] = 711; first[L"dead_cedilla"] = 184; @@ -573,6 +573,7 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap guint *keyvals; gint count; KMX_DWORD out; + KMX_DWORD deadkey; if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; @@ -585,8 +586,14 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap if (!(keycode <= 94)) return 0; - // _S2 can I use that????? - KMX_DWORD deadkey = (KMX_DWORD) keyvals[shift_state_pos]; + // _S2 take caps to this function + // here I get all kvals: normal char , my Deadkeys, allothr DK + KMX_DWORD All_Keyvals = KMX_get_keyvals_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), 0) ; + //wprintf(L"All_Keyvals: %i----\n", All_Keyvals); + + if(( (All_Keyvals >= deadkey_min) && (All_Keyvals <= deadkey_max))) + deadkey = All_Keyvals; + //wprintf(L" keyvals[shift_state_pos]: %i %i %i %i----", keyvals[0],keyvals[1],keyvals[2],keyvals[3]); dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str(); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 8c5446f246..ce1924131f 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -360,7 +360,6 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; if (st.size() == 0) { // No character assigned here } - // _S2 kommt er hier immer hin???? // _S2 TODO deadkeys don't work yet/ if true is in m_rgfDeadKey else if (this->m_rgfDeadKey[(int)ss][caps]) { // It's a dead key, append an @ sign. @@ -655,6 +654,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, //_S2 REVIEW std::vector alDead2 ; + std::vector alDead_cpl = create_alDead(); // _S2 finds all possible dk combinations that exist - will be refined to those used in the underlying keyboard rgKey.resize(256); @@ -769,6 +769,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, } } else if(rc < 0) { + wprintf(L"iKey: %i- ss: %i, caps: %i - bsBuffer[0] = %i\n", iKey, ss, caps,sbBuffer[0]); //_S2 TODO sbBuffer[2] = 0; //rgKey[iKey]->SetShiftState(ss, sbBuffer, true, (caps == 0)); @@ -778,11 +779,13 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // It's a dead key; let's flush out whats stored in the keyboard state. loader.KMX_ClearKeyboardBuffer(); DeadKey *dk = NULL; + Create_alDead(sbBuffer[0], alDead, &alDead_cpl); int testI= alDead.size(); - for(UINT iDead = 0; iDead < alDead.size(); iDead++) { + + /* for(UINT iDead = 0; iDead < alDead.size(); iDead++) { dk = alDead[iDead]; - WCHAR dktest1 = dk->KMX_DeadCharacter(); // _S2 can go later ; just for testing - WCHAR dktest2 = rgKey[iKey]->KMX_GetShiftState(ss, caps == 0)[0]; // _S2 can go later ; just for testing + KMX_WCHAR dktest1 = dk->KMX_DeadCharacter(); // _S2 can go later ; just for testing + KMX_WCHAR dktest2 = rgKey[iKey]->KMX_GetShiftState(ss, caps == 0)[0]; // _S2 can go later ; just for testing if(dk->KMX_DeadCharacter() == rgKey[iKey]->KMX_GetShiftState(ss, caps == 0)[0]) { break; } @@ -797,13 +800,14 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, //_S2 for each dk (^ ' ` push_back all combinations ^,â,ê,î,ô,û ',á,é,í,ó,ú `,à,è,ì,ò,ù into alDead->m_rgcombchar) //_S2 for each dk (^ ' ` push_back all base char : _,a,e,i,o,u into alDead->m_rgbasechar) // S2 do nothing for other keys - int wertzui=9; - } + }*/ } } } } } + // _S2 do we need to sort ?? + sort_alDead(alDead, &alDead_cpl) ; //_S2 this gan co later /*std::vector< int > TestValues = {40,44,48,49,50,51,52,53,54,55,56,57,65,66,67,88,89,90, 186,187,188,189,191,191,192,219,220,221,222,226}; diff --git a/linux/mcompile/keymap/mc_import_rules.h b/linux/mcompile/keymap/mc_import_rules.h index 3fad7e61ce..b80b4466a8 100644 --- a/linux/mcompile/keymap/mc_import_rules.h +++ b/linux/mcompile/keymap/mc_import_rules.h @@ -19,6 +19,10 @@ public: return this->m_rgbasechar.size(); } + KMX_WCHAR KMX_GetDeadCharacter() { + return this->m_deadchar; + } + KMX_WCHAR KMX_GetBaseCharacter(int index) { return this->m_rgbasechar[index]; } diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 849a7ca857..a7c24a4168 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -236,7 +236,7 @@ void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { } void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch, int abcd) { -PKMX_WCHAR PP = key->dpOutput; + //if (key->Key == 94) // wprintf(L"key->ShiftFlags: %i isEqual: %i %i(%c) %i(%c) ---> %i \n", key->ShiftFlags, key->ShiftFlags & VIRTUALCHARKEY , key->Key , key->Key, ch,ch , ((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch)); //wprintf(L"key->Key %i\n",key->Key); @@ -267,6 +267,7 @@ wprintf(L"key->Key %i\tkey->dpContext: %i %i %i %i %i %i %i %i %i \tkey->dpo PKMX_WCHAR context = new KMX_WCHAR[len + 4]; memcpy(context, key->dpContext, len * sizeof(KMX_WCHAR)); + PKMX_WCHAR PP = context; context[len] = UC_SENTINEL; context[len+1] = CODE_DEADKEY; context[len+2] = deadkey; @@ -505,7 +506,9 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg KMX_WCHAR ch = KMX_get_CharUnderlying_From_SCUnderlying_GDK(keymap, VKShiftState[j], scUnderlying, &DeadKey); //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); - //wprintf(L"--- VK_%d -> SC_%d [%c] dk=%d ( ss %i) \n", KMX_VKMap[i], KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]), ch == 0 ? 32 : ch, DeadKey,VKShiftState[j]); + wprintf(L"--- VK_%d -> SC_%d [%c] dk=%d ( ss %i) \n", KMX_VKMap[i], KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]), ch == 0 ? 32 : ch, DeadKey,VKShiftState[j]); + + //wprintf(L"--- VK_%d -> SC_ [%c] dk=%d ( ss %i) \n", VKMap[i], ch == 0 ? 32 : ch, DeadKey, VKShiftState[j]); if(bDeadkeyConversion) { // I4552 if(ch == 0xFFFF) { @@ -513,7 +516,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg } } -//wprintf(L" scunderlying: SS: %i Nr: %i VKMap[i] %i ch:%i (%c)\n", VKShiftState[j],i, KMX_VKMap[i],ch,ch ); +//wprintf(L" scunderlying: SS: %i Nr: %i VKMap[i] %i ch:%i (%c)\n", VKShiftState[j],i, KMX_VKMap[i],ch,ch );` switch(ch) { case 0x0000: break; case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap); break; //test_keyboard_S2(kbd); //-> mit Convert DK FALSCH; Ohne ConvertDK the same From f19ec9dca1d00dedbc9506e170d990250ede160b Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 9 Feb 2024 22:10:47 +0100 Subject: [PATCH 191/327] feat(linux): mcompile-dk found problem for deadkey(2) --- linux/mcompile/keymap/keymap.cpp | 8 ++++++-- linux/mcompile/keymap/mc_import_rules.cpp | 10 +++++---- linux/mcompile/keymap/mcompile.cpp | 25 ++++++++++++++++++----- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 150d8c95bd..a9ac90102c 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -575,6 +575,7 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap KMX_DWORD out; KMX_DWORD deadkey; + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) @@ -635,8 +636,11 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap KMX_DWORD KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ KMX_DWORD keyvals_dw= (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ss, caps) ; - - if((keyvals_dw >= deadkey_min) && (keyvals_dw <= deadkey_max)) // deadkeys + + // _S2 AHA output for dk4-12 at the top after dk... from here + // _S2 only for testing + if((keyvals_dw >= deadkey_min) && (keyvals_dw <= deadkey_max)) + //if((keyvals_dw >= 65104) && (keyvals_dw <= 65106)) // deadkeys return 0xFFFF; else if((keyvals_dw > deadkey_max) || ((keyvals_dw < deadkey_min) && ( keyvals_dw > 0xFF))) // out of range return 0xFFFE; diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index ce1924131f..ee61456b3b 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -383,11 +383,13 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; *p++ = UC_SENTINEL; *p++ = CODE_DEADKEY; *p++ = KMX_DeadKeyMap(st[0], deadkeys, deadkeyBase, &KMX_FDeadkeys); // I4353 + wprintf(L"KMX_DeadKeyMap(st[0], deadkeys, deadkeyBase, &KMX_FDeadkeys): %i\n",KMX_DeadKeyMap(st[0], deadkeys, deadkeyBase, &KMX_FDeadkeys)); *p = 0; int wertzu=57; } key++; - } else { + } + else { bool isvalid = true; for (size_t ich = 0; ich < st.size(); ich++) { if(st[ich] < 0x20 || st[ich] == 0x7F) { isvalid=false; break; } @@ -769,7 +771,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, } } else if(rc < 0) { - wprintf(L"iKey: %i- ss: %i, caps: %i - bsBuffer[0] = %i\n", iKey, ss, caps,sbBuffer[0]); + //wprintf(L"iKey: %i- ss: %i, caps: %i - bsBuffer[0] = %i\n", iKey, ss, caps,sbBuffer[0]); //_S2 TODO sbBuffer[2] = 0; //rgKey[iKey]->SetShiftState(ss, sbBuffer, true, (caps == 0)); @@ -806,7 +808,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, } } } - // _S2 do we need to sort ?? + // _S2 do we need to sort alDead?? sort_alDead(alDead, &alDead_cpl) ; //_S2 this gan co later @@ -949,7 +951,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // If we have deadkeys, then add a new group to translate the deadkeys per the deadkey tables // We only do this if not in deadkey conversion mode // - + // DK_PART if (alDead.size() > 0 && !bDeadkeyConversion) { // I4552 kp->cxGroupArray++; diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index a7c24a4168..2ecaa9de59 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -237,6 +237,9 @@ void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch, int abcd) { +// deadkey2 should not run this routine !!! but it does _S2 FEHLER HIER !!!!! + + //if (key->Key == 94) // wprintf(L"key->ShiftFlags: %i isEqual: %i %i(%c) %i(%c) ---> %i \n", key->ShiftFlags, key->ShiftFlags & VIRTUALCHARKEY , key->Key , key->Key, ch,ch , ((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch)); //wprintf(L"key->Key %i\n",key->Key); @@ -246,7 +249,16 @@ wprintf(L"key->Key %i\tkey->dpContext: %i %i %i %i %i %i %i %i %i \tkey->dpo *key->dpContext, *(key->dpContext+1),*(key->dpContext+2),*(key->dpContext+3),*(key->dpContext+4),*(key->dpContext+5),*(key->dpContext+6),*(key->dpContext+7),*(key->dpContext+8), *key->dpOutput, *(key->dpOutput+1),*(key->dpOutput+2),*(key->dpOutput+3),*(key->dpOutput+4),*(key->dpOutput+5) ); }*/ + + + if (deadkey == 2) { + wprintf(L"\ndeadkey %i, key->ShiftFlags:%i key->ShiftFlags & VIRTUALCHARKEY %i key->Key == ch %i",deadkey, key->ShiftFlags, key->ShiftFlags & VIRTUALCHARKEY, key->Key == ch); + } +Hier ist das Problem : für dk==2 springt er hier rein, was er nicht darf... if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { + //if(((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) && (!(deadkey==2 && shift==0))) { + + wprintf(L"TRUE!!!!!!!!!"); // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. @@ -325,7 +337,7 @@ void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT kbd->dpGroupArray[i].cxKeyArray++; //LogError("Add deadkey rule: + [%d K_%d] > dk(%d)", shift, vk, deadkey); zaehler++; - //wprintf(L"Add deadkey rule: + [%d K_%d] > dk(%d) %i\n", shift, vk, deadkey,zaehler); + wprintf(L"Add deadkey rule: + [%d K_%d] > dk(%d) %i\n", shift, vk, deadkey,zaehler); if(i == kbd->StartGroup[1]) break; // If this is the initial group, that's all we need to do. } @@ -402,7 +414,7 @@ KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR deadkey, v_dw_3D &All_Vector, GdkKeymap* keymap) { KMX_WORD deadkeys[512], *pdk; - +//wprintf(L" ***************************************** key: %i %i %i \n",vk,shift, deadkey); // _S2 create dkTable once only and use as static/ define before func // create dk_createDK_ComposeTable v_dw_2D dk_Table; @@ -506,10 +518,11 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg KMX_WCHAR ch = KMX_get_CharUnderlying_From_SCUnderlying_GDK(keymap, VKShiftState[j], scUnderlying, &DeadKey); //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); - wprintf(L"--- VK_%d -> SC_%d [%c] dk=%d ( ss %i) \n", KMX_VKMap[i], KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]), ch == 0 ? 32 : ch, DeadKey,VKShiftState[j]); + //wprintf(L"--- VK_%d -> SC_%d [%c] dk=%d ( ss %i) \n", KMX_VKMap[i], KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]), ch == 0 ? 32 : ch, DeadKey,VKShiftState[j]); +//wprintf(L"^^^^^^^^^^^^^^^^^^^^^^^, VKShiftState[j] ----> ch %i (%c)\n", (int)VKShiftState[j],ch,ch); //wprintf(L"--- VK_%d -> SC_ [%c] dk=%d ( ss %i) \n", VKMap[i], ch == 0 ? 32 : ch, DeadKey, VKShiftState[j]); - +int sdfghjkl=0; if(bDeadkeyConversion) { // I4552 if(ch == 0xFFFF) { ch = DeadKey; @@ -519,7 +532,8 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg //wprintf(L" scunderlying: SS: %i Nr: %i VKMap[i] %i ch:%i (%c)\n", VKShiftState[j],i, KMX_VKMap[i],ch,ch );` switch(ch) { case 0x0000: break; - case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap); break; //test_keyboard_S2(kbd); //-> mit Convert DK FALSCH; Ohne ConvertDK the same + case 0xFFFF: + KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap); break; //test_keyboard_S2(kbd); //-> mit Convert DK FALSCH; Ohne ConvertDK the same default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); } } @@ -563,6 +577,7 @@ KMX_WCHAR KMX_get_VKUS_From_VKUnderlying_VEC(v_dw_3D All_Vector, KMX_DWORD VK_OT } // takes SC of underlying keyboard and returns character of underlying keyboard with shiftstate VKShiftState[j] or deadkey +// _S2 KMX_UINT ??? KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, PKMX_WCHAR DeadKey) { PKMX_WCHAR dky; From d2cee893f29e7d10d4168151f2ba57b11672933f Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 12 Feb 2024 15:30:20 +0100 Subject: [PATCH 192/327] feat(linux): mcompile-dk resolved problem for deadkey(2) --- linux/mcompile/keymap/deadkey.cpp | 38 +---- linux/mcompile/keymap/deadkey.h | 9 +- linux/mcompile/keymap/helpers.cpp | 194 ++++++++++++++++++++++ linux/mcompile/keymap/keymap.cpp | 49 +----- linux/mcompile/keymap/keymap.h | 2 +- linux/mcompile/keymap/km_types.h | 2 +- linux/mcompile/keymap/mc_import_rules.cpp | 172 ++----------------- linux/mcompile/keymap/mc_import_rules.h | 2 +- linux/mcompile/keymap/mc_kmxfile.cpp | 2 +- linux/mcompile/keymap/mcompile.cpp | 74 ++++----- 10 files changed, 265 insertions(+), 279 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index a97f24d323..512dce12fe 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -10,11 +10,10 @@ v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, s return line; } -// _S2 DEADKEY STUFF - DO NOT REVIEW YET bool find_dk_combinations_for_single_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &dk_SingleTable, KMX_DWORD dk) { v_dw_1D line; for ( int i =0; i< (int) (*p_dk_ComposeTable).size(); i++) { - // _S2 is there a better way to find a-z,A-Z? + // _S2 QUESTION is there a better way to find a-z,A-Z? //if (((*p_dk_ComposeTable)[i][0] == dk) ) { if (((*p_dk_ComposeTable)[i][0] == dk) && (IsKeymanUsedChar((*p_dk_ComposeTable)[i][1]))) { line.push_back((*p_dk_ComposeTable)[i][0]); @@ -61,7 +60,7 @@ bool found_dk_inVector(KMX_WCHAR dk, std::vector &dkVec) { return false; } -void Create_alDead(KMX_WCHAR dk, std::vector &dkVec, std::vector *p_All_Vec) { +void refine_alDead(KMX_WCHAR dk, std::vector &dkVec, std::vector *p_All_Vec) { std::vector dkVec_unsorted; if( dk == 0) @@ -114,28 +113,7 @@ void sort_alDead(std::vector &small_Vec, std::vector *p_All_ small_Vec = small_sorted; } -/* _S2 probably not needed //_S2 REVIEW this is for testing only and needs to go later -std::vector reduce_alDead(std::vector dk_big) { - std::vector dk_small; - bool foundInSmall=false; - - for ( int i=1; iKMX_DeadCharacter()==94 || dk_big[i]->KMX_DeadCharacter()==96 || dk_big[i]->KMX_DeadCharacter()==180|| dk_big[i]->KMX_DeadCharacter()==126|| dk_big[i]->KMX_DeadCharacter()==168)) { - for( int k=0; k< dk_small.size();k++) { - if(dk_big[i]->KMX_DeadCharacter() == dk_small[k]->KMX_DeadCharacter()) - foundInSmall=true; - } - if(!foundInSmall) - dk_small.push_back(dk_big[i]); - foundInSmall=false; - } - } - return dk_small; -} -*/ -// _S2 DEADKEY STUFF - DO NOT REVIEW YET -// _S2 might be used when deadkeys are implemented . is it correct?? +// _S2 TODO might be used when deadkeys are implemented . is it correct?? KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap) { guint Keyval = (guint) KVal; GdkKeymapKey* keys; @@ -156,16 +134,14 @@ KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap return Name; } -// _S2 DEADKEY STUFF - DO NOT REVIEW YET // _S2 DESIGN NEEDED is this the right place to get dk from? if not wher are they stored? KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable) { // values taken from: https://help.ubuntu.com/community/GtkDeadKeyTable#Latin - //dk_ComposeTable[i][0] : First - //dk_ComposeTable[i][1] : Second - //dk_ComposeTable[i][3] : Unicode-Value - //dk_ComposeTable[i][4] : Character - + //dk_ComposeTable[i][0] : First (e.g. dead_circumflex) + //dk_ComposeTable[i][1] : Second (e.g. a) + //dk_ComposeTable[i][3] : Unicode-Value (e.g. 0x00E2) + //dk_ComposeTable[i][4] : Character (e.g. small A with circumflex) v_dw_1D line; line = createLine(L"dead_circumflex", L"a", 0x00E2, L"small A with circumflex"); diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index 4566756ee1..aa4ea2e21d 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -12,11 +12,16 @@ v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, s // creates a 2D-vector of all dk combinations ( ` + a -> à ; ^ + a -> â ; `+ e -> è; ...) KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable); -//_S2 REVIEW +//_S2 TODO REVIEW +//_S2 finds all possible dk combinations that exist std::vector create_alDead(); +//_S2 refines dk to those used in the underlying keyboard +void refine_alDead(KMX_WCHAR dk, std::vector &myVec, std::vector *p_All_Vec); + +// _S2 TODO maybe not used std::vector reduce_alDead(std::vector dk_big); -void Create_alDead(KMX_WCHAR dk, std::vector &myVec, std::vector *p_All_Vec); + void sort_alDead(std::vector &myVec, std::vector *p_All_Vec); bool found_dk_inVector(KMX_WCHAR dk, std::vector &myVec); diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index d977ff4960..6b2c4201b3 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -1152,6 +1152,200 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK_old(GdkKeymap *ke } */ +/* _S2 probably not needed //_S2 REVIEW this is for testing only and needs to go later +std::vector reduce_alDead(std::vector dk_big) { + std::vector dk_small; + bool foundInSmall=false; + + for ( int i=1; iKMX_DeadCharacter()==94 || dk_big[i]->KMX_DeadCharacter()==96 || dk_big[i]->KMX_DeadCharacter()==180|| dk_big[i]->KMX_DeadCharacter()==126|| dk_big[i]->KMX_DeadCharacter()==168)) { + for( int k=0; k< dk_small.size();k++) { + if(dk_big[i]->KMX_DeadCharacter() == dk_small[k]->KMX_DeadCharacter()) + foundInSmall=true; + } + if(!foundInSmall) + dk_small.push_back(dk_big[i]); + foundInSmall=false; + } + } + return dk_small; +} +*/ + + +// _S2 DEADKEY STUFF - DO NOT REVIEW YET +/*std::wstring convert_DeadkeyValues_ToChar_old(int in) { + + KMX_DWORD lname; + + if (in < (int) deadkey_min) { // no deadkey; no Unicode + if (!IsKeymanUsedKeyVal(std::wstring(1, in))) + return L"\0"; + return std::wstring(1, in); + } + else { + std::string long_name((const char*) gdk_keyval_name (in)); + + if ( long_name.substr (0,2) == "U+" ) // U+... Unicode value + return CodePointToWString(in-0x1000000); + + lname = convertNamesToIntegerValue( wstring_from_string(long_name)); // 65106 => "dead_circumflex " => 94 => "^" + + if (lname != returnIfCharInvalid) { + return std::wstring(1, lname ); + } + else + return L"\0"; + } + return L"\0"; +}*/ + + + // _S2 DEADKEY STUFF - DO NOT REVIEW YET --- Do we need this at all? + // _S2 ToDo ToUnicodeEx needs to be replaced here + /* DeadKey *KMX_ProcessDeadKey( + UINT iKeyDead, // The index into the VirtualKey of the dead key + ShiftState shiftStateDead, // The shiftstate that contains the dead key + KMX_BYTE *lpKeyStateDead, // The key state for the dead key + std::vector rgKey, // Our array of dead keys + bool fCapsLock, // Was the caps lock key pressed? + KMX_HKL KMX_hkl, // The keyboard layout + GdkKeymap *keymap) { // _S2 keymap, The keyboard layout + + + KMX_BYTE lpKeyState[256]; + DeadKey *deadKey = new DeadKey(rgKey[iKeyDead]->KMX_GetShiftState(shiftStateDead, fCapsLock)[0]); + +KMX_WCHAR sbBuffer1[16]; + KMX_WCHAR sbBuffer2[16]; + KMX_WCHAR sbBuffer3[16]; + KMX_WCHAR sbBuffer4[16]; + KMX_WCHAR sbBuffer5[16]; + int rc1 = KMX_ToUnicodeEx(49, lpKeyState, sbBuffer1, 0, 0, keymap) ; + int rc4 = KMX_ToUnicodeEx(21, lpKeyState, sbBuffer4, 0, 0, keymap) ; + int rc3 = KMX_ToUnicodeEx( 3, lpKeyState, sbBuffer3, 0, 0, keymap) ; + /*int rc2 = KMX_ToUnicodeEx( 49, lpKeyState, sbBuffer2, 0, 0, keymap) ; + int rc5 = KMX_ToUnicodeEx( 65, lpKeyState, sbBuffer5, 0, 0, keymap) ;*/ + + /*int rc1 = KMX_ToUnicodeEx(192, lpKeyState, sbBuffer1, 0, 0, keymap) ; + int rc4 = KMX_ToUnicodeEx(220, lpKeyState, sbBuffer4, 0, 0, keymap) ; + int rc3 = KMX_ToUnicodeEx( 3, lpKeyState, sbBuffer3, 0, 0, keymap) ; + int rc2 = KMX_ToUnicodeEx( 49, lpKeyState, sbBuffer2, 0, 0, keymap) ; + int rc5 = KMX_ToUnicodeEx( 65, lpKeyState, sbBuffer5, 0, 0, keymap) ;*/ + + + +/* + for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { + if (rgKey[iKey] != NULL) { + KMX_WCHAR sbBuffer[16]; + + for (ShiftState ss = Base; ss <= KMX_MaxShiftState(); ss = (ShiftState)((int)ss+1)) { + int rc = 0; + if (ss == Menu || ss == ShftMenu) { + // Alt and Shift+Alt don't work, so skip them + continue; + } + + for (int caps = 0; caps <= 1; caps++) { + + //------_S2 To find a deadkey in a possibly messed up key ------------------------ + // _S2 My fun does not loop to shorten keys :-(( + + // First the dead key + while (rc >= 0) { + // We know that this is a dead key coming up, otherwise + // this function would never have been called. If we do + // *not* get a dead key then that means the state is + // messed up so we run again and again to clear it up. + // Risk is technically an infinite loop but per Hiroyama + // that should be impossible here. + + rc = KMX_ToUnicodeEx(rgKey[iKeyDead]->SC(), lpKeyState, sbBuffer, ss, caps, keymap); + //wprintf(L"ikey: %i rc = %i\n",iKey,rc); + rc=-1; //_S2 + } + + //---------------------------------------------------------------------------------- + + // Now fill the key state for the potential base character + KMX_FillKeyState(lpKeyState, ss, (caps != 0)); + + //---------------------------------------------------------------------------------- + + rc = KMX_ToUnicodeEx( rgKey[iKey]->SC(), lpKeyState, sbBuffer, ss, caps, keymap) ; + + //--------- ONE character found = combined char (e.g. â ) -------------------------- + // ***** E.G: ToUnicodeEx FOUND  ***** // + + if (rc == 1) { +  */ // That was indeed a base character for our dead key. + // And we now have a composite character. Let's run + // through one more time to get the actual base + + // character that made it all possible? + + // _s2 store combined char + // ***** E.G: combchar =  ***** // + /*KMX_WCHAR combchar = sbBuffer[0]; + + // _S2 again split to get base char ( e.g. a) + // ***** E.G: ToUnicodeEx FOUND A ***** // + rc = KMX_ToUnicodeEx(rgKey[iKey]->SC(), lpKeyState, sbBuffer, ss, caps, keymap) ; + + KMX_WCHAR basechar = sbBuffer[0]; + + if (deadKey->KMX_DeadCharacter() == combchar) { + // Since the combined character is the same as the dead key, + // we must clear out the keyboard buffer. + //KMX_ClearKeyboardBuffer(VK_DECIMAL, rgKey[VK_DECIMAL]->SC(), KMX_hkl); + KMX_ClearKeyboardBuffer(); + } + + if ((((ss == Ctrl) || (ss == ShftCtrl)) && + (KMX_IsControlChar(basechar))) || + (basechar == combchar)) { + // ToUnicodeEx has an internal knowledge about those + // VK_A ~ VK_Z keys to produce the control characters, + // when the conversion rule is not provided in keyboard + // layout files + + // Additionally, dead key state is lost for some of these + // character combinations, for unknown reasons. + + // Therefore, if the base character and combining are equal, + // and its a CTRL or CTRL+SHIFT state, and a control character + // is returned, then we do not add this "dead key" (which + // is not really a dead key). + continue; + } + + if (!deadKey->KMX_ContainsBaseCharacter(basechar)) { + deadKey->KMX_AddDeadKeyRow(basechar, combchar); + } + } + + //---------no valid key combi -> IGNORE --------------------------------------------- + + else if (rc > 1) { + // Not a valid dead key combination, sorry! We just ignore it. + } + + //---------another dead key-> IGNORE ----------------------------------------------- + else if (rc < 0) { + // It's another dead key, so we ignore it (other than to flush it from the state) + //ClearKeyboardBuffer(VK_DECIMAL, rgKey[VK_DECIMAL]->SC(), KMX_hkl); + KMX_ClearKeyboardBuffer(); + } + } + } + } + } + return deadKey; + }*/ + + /* diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index a9ac90102c..908b947a3c 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -358,8 +358,7 @@ bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]) { } //------------------------------ -// _S2 DEADKEY STUFF - DO NOT REVIEW YET -// _S2 ToDo deadkeys. Do we need this ? +// _S2 TODO deadkeys. Do we need this ? bool IsKeymanUsedKeyVal(std::wstring Keyval) { int KV = (int) (*Keyval.c_str()); @@ -396,35 +395,7 @@ bool IsKeymanUsedChar(int KV) { return false; } -// _S2 DEADKEY STUFF - DO NOT REVIEW YET -std::wstring convert_DeadkeyValues_ToChar_old(int in) { - KMX_DWORD lname; - - if (in < (int) deadkey_min) { // no deadkey; no Unicode - if (!IsKeymanUsedKeyVal(std::wstring(1, in))) - return L"\0"; - return std::wstring(1, in); - } - else { - std::string long_name((const char*) gdk_keyval_name (in)); - - if ( long_name.substr (0,2) == "U+" ) // U+... Unicode value - return CodePointToWString(in-0x1000000); - - lname = convertNamesToIntegerValue( wstring_from_string(long_name)); // 65106 => "dead_circumflex " => 94 => "^" - - if (lname != returnIfCharInvalid) { - return std::wstring(1, lname ); - } - else - return L"\0"; - } - return L"\0"; -} - - -// _S2 DEADKEY STUFF - DO NOT REVIEW YET std::wstring convert_DeadkeyValues_ToChar(int in) { KMX_DWORD lname; @@ -451,7 +422,7 @@ std::wstring convert_DeadkeyValues_ToChar(int in) { else return L"\0"; } - +//_S2 REview and change?? std::u16string convert_DeadkeyValues_To_U16str(int in) { KMX_DWORD lname; @@ -587,7 +558,7 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap if (!(keycode <= 94)) return 0; - // _S2 take caps to this function + // _S2 TODO take caps to this function // here I get all kvals: normal char , my Deadkeys, allothr DK KMX_DWORD All_Keyvals = KMX_get_keyvals_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), 0) ; //wprintf(L"All_Keyvals: %i----\n", All_Keyvals); @@ -601,7 +572,7 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap out = KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); //wprintf(L" out is :.....................................%i\n", out); - // _S2 g_free used everywhere? + // _S2 TODO g_free used everywhere? g_free(keyvals); g_free(maps); @@ -625,7 +596,7 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap out = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); - // _S2 g_free used everywhere? + // _S2 TODO g_free used everywhere? g_free(keyvals); g_free(maps); @@ -638,9 +609,7 @@ KMX_DWORD KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(Gdk KMX_DWORD keyvals_dw= (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ss, caps) ; // _S2 AHA output for dk4-12 at the top after dk... from here - // _S2 only for testing - if((keyvals_dw >= deadkey_min) && (keyvals_dw <= deadkey_max)) - //if((keyvals_dw >= 65104) && (keyvals_dw <= 65106)) // deadkeys + if((keyvals_dw >= deadkey_min) && (keyvals_dw <= deadkey_max)) // deadkeys return 0xFFFF; else if((keyvals_dw > deadkey_max) || ((keyvals_dw < deadkey_min) && ( keyvals_dw > 0xFF))) // out of range return 0xFFFE; @@ -655,7 +624,7 @@ KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(Gdk std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ - // _S2 skip ss 2+3 remove?? + // _S2 QUESTION skip ss 2+3 remove?? if( (ss ==2 ) ||(ss ==3 )) return L"\0"; @@ -689,7 +658,7 @@ KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD if ( keyvals[i]>0) gdk_keyval_convert_case (*kv_name, &lowerCase, &upperCase); - // _S2 is ( lowerCase == upperCase ) true for all number keys for all keyboards? + // _S2 QUESTION is ( lowerCase == upperCase ) true for all number keys for all keyboards? if ( lowerCase == upperCase ) return (KMX_DWORD) upperCase; } @@ -698,7 +667,7 @@ KMX_DWORD testvar_S2 = ScanCodeToUSVirtualKey[keycode-8]; if ( keycode >7) return (KMX_DWORD) ScanCodeToUSVirtualKey[keycode-8]; - return 0; //_S2 what to return if not found + return 0; } KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS( KMX_DWORD VK_US) { diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index f06d1b2cc3..c3428cd1bb 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -520,7 +520,7 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); -// _S2 returns char or FFFF / FFFE ???? +// _S2 TODO returns char or FFFF / FFFE ???? KMX_DWORD KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index 5953b67b27..addadd7666 100755 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -72,7 +72,7 @@ typedef int BOOL; // PVOID A pointer to any type. // typedef PVOID HANDLE; // typedef HANDLE HKL; -typedef void* KMX_HKL; // _S2 what is the equivalent to HKL and do I need it?? I assume a void* +typedef void* KMX_HKL; // _S2 QUESTION what is the equivalent to HKL and do I need it?? I assume a void* #ifndef FALSE diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index ee61456b3b..3b26c5ec2f 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -76,8 +76,6 @@ const int KMX_ShiftStateMap[] = { 0 }; -// _S2 DEADKEY STUFF - DO NOT REVIEW YET - DeadKey::DeadKey(KMX_WCHAR deadCharacter) { this->m_deadchar = deadCharacter; } @@ -121,7 +119,7 @@ int KMX_ToUnicodeEx(guint keycode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, KMX_DWORD keyvals_dw= (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), caps) ; - // _S2 g_free used everywhere? + // _S2 TODO g_free used everywhere? g_free(keyvals); g_free(maps); @@ -150,7 +148,7 @@ int KMX_DeadKeyMap(int index, std::vector *deadkeys, int deadkeyBase, class KMX_VirtualKey { private: - KMX_HKL m_hkl; // _S2 do I need this and is void* OK to assume? If I remove this, will there be changes in Data-Vectors? + KMX_HKL m_hkl; // _S2 QUESTION do I need this and is void* OK to assume? If I remove this, will there be changes in Data-Vectors? UINT m_vk; UINT m_sc; bool m_rgfDeadKey[10][2]; @@ -162,7 +160,7 @@ public: this->m_sc=KMX_get_SCUnderlying_From_VKUS(virtualKey); this->m_hkl = hkl; this->m_vk = virtualKey; - // _S2 ToDo deadkey + // _S2 TODO deadkey // memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); } @@ -207,7 +205,7 @@ public: this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; } -// _S2 why are there sometimes numbers in m_rgfDeadKey??? +// _S2 QUESTION why are there sometimes numbers in m_rgfDeadKey??? void KMX_SetShiftState(ShiftState shiftState, std::u16string value16, bool isDeadKey, bool capsLock) { std::wstring value = wstring_from_u16string(value16); this->m_rgfDeadKey[(UINT)shiftState][(capsLock ? 1 : 0)] = isDeadKey; @@ -276,7 +274,7 @@ public: bool KMX_IsKeymanUsedKey() { return (this->m_vk >= 0x20 && this->m_vk <= 0x5F) || (this->m_vk >= 0x88); } - + UINT KMX_GetShiftStateValue(int capslock, int caps, ShiftState ss) { //wprintf(L"GetShiftStateValue takes capslock: %i, caps: %i, ss: %i and returns: %i \n", //capslock, caps, ss, (KMX_ShiftStateMap[(int)ss] | (capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0))); @@ -468,150 +466,6 @@ public: return (ch < 0x0020) || (ch >= 0x007F && ch <= 0x009F); } - // _S2 DEADKEY STUFF - DO NOT REVIEW YET --- Do we need this at all? - // _S2 ToDo ToUnicodeEx needs to be replaced here - DeadKey *KMX_ProcessDeadKey( - UINT iKeyDead, // The index into the VirtualKey of the dead key - ShiftState shiftStateDead, // The shiftstate that contains the dead key - KMX_BYTE *lpKeyStateDead, // The key state for the dead key - std::vector rgKey, // Our array of dead keys - bool fCapsLock, // Was the caps lock key pressed? - KMX_HKL KMX_hkl, // The keyboard layout - GdkKeymap *keymap) { // _S2 keymap, The keyboard layout - - - KMX_BYTE lpKeyState[256]; - DeadKey *deadKey = new DeadKey(rgKey[iKeyDead]->KMX_GetShiftState(shiftStateDead, fCapsLock)[0]); - -KMX_WCHAR sbBuffer1[16]; - KMX_WCHAR sbBuffer2[16]; - KMX_WCHAR sbBuffer3[16]; - KMX_WCHAR sbBuffer4[16]; - KMX_WCHAR sbBuffer5[16]; - int rc1 = KMX_ToUnicodeEx(49, lpKeyState, sbBuffer1, 0, 0, keymap) ; - int rc4 = KMX_ToUnicodeEx(21, lpKeyState, sbBuffer4, 0, 0, keymap) ; - int rc3 = KMX_ToUnicodeEx( 3, lpKeyState, sbBuffer3, 0, 0, keymap) ; - /*int rc2 = KMX_ToUnicodeEx( 49, lpKeyState, sbBuffer2, 0, 0, keymap) ; - int rc5 = KMX_ToUnicodeEx( 65, lpKeyState, sbBuffer5, 0, 0, keymap) ;*/ - - /*int rc1 = KMX_ToUnicodeEx(192, lpKeyState, sbBuffer1, 0, 0, keymap) ; - int rc4 = KMX_ToUnicodeEx(220, lpKeyState, sbBuffer4, 0, 0, keymap) ; - int rc3 = KMX_ToUnicodeEx( 3, lpKeyState, sbBuffer3, 0, 0, keymap) ; - int rc2 = KMX_ToUnicodeEx( 49, lpKeyState, sbBuffer2, 0, 0, keymap) ; - int rc5 = KMX_ToUnicodeEx( 65, lpKeyState, sbBuffer5, 0, 0, keymap) ;*/ - - - - - for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { - if (rgKey[iKey] != NULL) { - KMX_WCHAR sbBuffer[16]; - - for (ShiftState ss = Base; ss <= KMX_MaxShiftState(); ss = (ShiftState)((int)ss+1)) { - int rc = 0; - if (ss == Menu || ss == ShftMenu) { - // Alt and Shift+Alt don't work, so skip them - continue; - } - - for (int caps = 0; caps <= 1; caps++) { - - //------_S2 To find a deadkey in a possibly messed up key ------------------------ - // _S2 My fun does not loop to shorten keys :-(( - - // First the dead key - while (rc >= 0) { - // We know that this is a dead key coming up, otherwise - // this function would never have been called. If we do - // *not* get a dead key then that means the state is - // messed up so we run again and again to clear it up. - // Risk is technically an infinite loop but per Hiroyama - // that should be impossible here. - - rc = KMX_ToUnicodeEx(rgKey[iKeyDead]->SC(), lpKeyState, sbBuffer, ss, caps, keymap); - //wprintf(L"ikey: %i rc = %i\n",iKey,rc); - rc=-1; //_S2 - } - - //---------------------------------------------------------------------------------- - - // Now fill the key state for the potential base character - KMX_FillKeyState(lpKeyState, ss, (caps != 0)); - - //---------------------------------------------------------------------------------- - - rc = KMX_ToUnicodeEx( rgKey[iKey]->SC(), lpKeyState, sbBuffer, ss, caps, keymap) ; - - //--------- ONE character found = combined char (e.g. â ) -------------------------- - // ***** E.G: ToUnicodeEx FOUND  ***** // - - if (rc == 1) { - /*  */ // That was indeed a base character for our dead key. - // And we now have a composite character. Let's run - // through one more time to get the actual base - - // character that made it all possible? - - // _s2 store combined char - // ***** E.G: combchar =  ***** // - KMX_WCHAR combchar = sbBuffer[0]; - - // _S2 again split to get base char ( e.g. a) - // ***** E.G: ToUnicodeEx FOUND A ***** // - /* A */ rc = KMX_ToUnicodeEx(rgKey[iKey]->SC(), lpKeyState, sbBuffer, ss, caps, keymap) ; - - KMX_WCHAR basechar = sbBuffer[0]; - - if (deadKey->KMX_DeadCharacter() == combchar) { - // Since the combined character is the same as the dead key, - // we must clear out the keyboard buffer. - //KMX_ClearKeyboardBuffer(VK_DECIMAL, rgKey[VK_DECIMAL]->SC(), KMX_hkl); - KMX_ClearKeyboardBuffer(); - } - - if ((((ss == Ctrl) || (ss == ShftCtrl)) && - (KMX_IsControlChar(basechar))) || - (basechar == combchar)) { - // ToUnicodeEx has an internal knowledge about those - // VK_A ~ VK_Z keys to produce the control characters, - // when the conversion rule is not provided in keyboard - // layout files - - // Additionally, dead key state is lost for some of these - // character combinations, for unknown reasons. - - // Therefore, if the base character and combining are equal, - // and its a CTRL or CTRL+SHIFT state, and a control character - // is returned, then we do not add this "dead key" (which - // is not really a dead key). - continue; - } - - if (!deadKey->KMX_ContainsBaseCharacter(basechar)) { - deadKey->KMX_AddDeadKeyRow(basechar, combchar); - } - } - - //---------no valid key combi -> IGNORE --------------------------------------------- - - else if (rc > 1) { - // Not a valid dead key combination, sorry! We just ignore it. - } - - //---------another dead key-> IGNORE ----------------------------------------------- - else if (rc < 0) { - // It's another dead key, so we ignore it (other than to flush it from the state) - //ClearKeyboardBuffer(VK_DECIMAL, rgKey[VK_DECIMAL]->SC(), KMX_hkl); - KMX_ClearKeyboardBuffer(); - } - } - } - } - } - return deadKey; - } - - void KMX_ClearKeyboardBuffer() { KMX_WCHAR sb[16]; for( int i=0; i<16; i++) { @@ -656,7 +510,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, //_S2 REVIEW std::vector alDead2 ; - std::vector alDead_cpl = create_alDead(); // _S2 finds all possible dk combinations that exist - will be refined to those used in the underlying keyboard + std::vector alDead_cpl = create_alDead(); rgKey.resize(256); @@ -734,7 +588,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, KMX_DWORD SC_US = KMX_get_KeyCodeUnderlying_From_VKUS(iKey); - // _S2 deadkey not finished; Ctrl, Shft +40 not tested + // _S2 TODO deadkey not finished; Ctrl, Shft +40 not tested for(int caps = 0; caps <= 1; caps++) { loader.KMX_ClearKeyboardBuffer(); loader.KMX_FillKeyState(lpKeyState, ss, (caps == 0)); @@ -771,30 +625,24 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, } } else if(rc < 0) { - //wprintf(L"iKey: %i- ss: %i, caps: %i - bsBuffer[0] = %i\n", iKey, ss, caps,sbBuffer[0]); - //_S2 TODO sbBuffer[2] = 0; //rgKey[iKey]->SetShiftState(ss, sbBuffer, true, (caps == 0)); - rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); - //wprintf(L"rc<0 for iKey nr. %i (%c) \n",iKey,iKey ); + rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); //_S2 // It's a dead key; let's flush out whats stored in the keyboard state. loader.KMX_ClearKeyboardBuffer(); DeadKey *dk = NULL; - Create_alDead(sbBuffer[0], alDead, &alDead_cpl); + refine_alDead(sbBuffer[0], alDead, &alDead_cpl); int testI= alDead.size(); /* for(UINT iDead = 0; iDead < alDead.size(); iDead++) { dk = alDead[iDead]; - KMX_WCHAR dktest1 = dk->KMX_DeadCharacter(); // _S2 can go later ; just for testing - KMX_WCHAR dktest2 = rgKey[iKey]->KMX_GetShiftState(ss, caps == 0)[0]; // _S2 can go later ; just for testing if(dk->KMX_DeadCharacter() == rgKey[iKey]->KMX_GetShiftState(ss, caps == 0)[0]) { break; } dk = NULL; } if(dk == NULL) { - //_S2 TODO //alDead.push_back(loader.KMX_ProcessDeadKey(iKey, ss, lpKeyState, rgKey, caps == 0, hkl, *keymap)); alDead2 = create_alDead(); alDead = reduce_alDead(alDead2); @@ -808,7 +656,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, } } } - // _S2 do we need to sort alDead?? + // do we need to sort alDead?? sort_alDead(alDead, &alDead_cpl) ; //_S2 this gan co later diff --git a/linux/mcompile/keymap/mc_import_rules.h b/linux/mcompile/keymap/mc_import_rules.h index b80b4466a8..83e667f597 100644 --- a/linux/mcompile/keymap/mc_import_rules.h +++ b/linux/mcompile/keymap/mc_import_rules.h @@ -31,7 +31,7 @@ public: return this->m_rgcombchar[index]; } - // _S2 only use one + // _S2 TODO only use one bool ContainsBaseCharacter(WCHAR baseCharacter); bool KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter) ; diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 6a879bbcf4..ed2be90363 100755 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -475,7 +475,7 @@ KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz){ return TRUE; } -// __S2 use incxstr from elsewhere +// __S2 TODO use incxstr from elsewhere PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p) { if (*p == 0) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 2ecaa9de59..d52e3cedd9 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -132,7 +132,6 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ #if defined(_WIN32) || defined(_WIN64) - // _S2 DoConvert for windows needs to be done later ( can it be copied from engine/mcompile ?) /*if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552F KMX_SaveKeyboard(kmxfile, outfile); }*/ @@ -144,7 +143,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ #endif - //DeleteReallocatedPointers(kmxfile); :TODO // _S2 not my ToDo :-) + //DeleteReallocatedPointers(kmxfile); :TODO // not my ToDo :-) delete kmxfile; wprintf(L"\nmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm end\n"); @@ -157,15 +156,15 @@ const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCT // _S2 my comment for Lin version // Ubuntu: Each of the 4 columns specifies a different modifier: unmodified, shift, right alt (altgr), shift+right alt(altgr) -// some hold up to 8 what are those ??? // we have assigned these to columns 1-4 ( column o holds the keycode) -//const UINT VKShiftState[] = {0, 1, 2, 3, 0xFFFF}; +// const UINT VKShiftState[] = {0, 1, 2, 3, 0xFFFF}; // // TranslateKey // // For each key rule on the keyboard, remap its key to the // correct shift state and key. Adjust the LCTRL+RALT -> RALT if necessary +// _S2 exchange key->Key with the new value ( use vk instead of ch) // void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. @@ -237,28 +236,28 @@ void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch, int abcd) { -// deadkey2 should not run this routine !!! but it does _S2 FEHLER HIER !!!!! + //_S2 AHA Hier ist das Problem : für dk==2 springt er hier rein, was er nicht darf... + // this is because SHIFTFLAG has the wrong value + // which is because KMX_GetShiftStateValue gets the wrong value + // which is because capslock is not set correctlyS + // which is because WIN<->Lin shiftstares are different 4 $ $ 4 <-> 4 4 $ $ etc. - - //if (key->Key == 94) - // wprintf(L"key->ShiftFlags: %i isEqual: %i %i(%c) %i(%c) ---> %i \n", key->ShiftFlags, key->ShiftFlags & VIRTUALCHARKEY , key->Key , key->Key, ch,ch , ((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch)); -//wprintf(L"key->Key %i\n",key->Key); -/*if(abcd >1 && abcd < 815 ) { - -wprintf(L"key->Key %i\tkey->dpContext: %i %i %i %i %i %i %i %i %i \tkey->dpoutput: %i %i %i %i %i %i\n", key->Key, -*key->dpContext, *(key->dpContext+1),*(key->dpContext+2),*(key->dpContext+3),*(key->dpContext+4),*(key->dpContext+5),*(key->dpContext+6),*(key->dpContext+7),*(key->dpContext+8), -*key->dpOutput, *(key->dpOutput+1),*(key->dpOutput+2),*(key->dpOutput+3),*(key->dpOutput+4),*(key->dpOutput+5) ); -}*/ - - - if (deadkey == 2) { - wprintf(L"\ndeadkey %i, key->ShiftFlags:%i key->ShiftFlags & VIRTUALCHARKEY %i key->Key == ch %i",deadkey, key->ShiftFlags, key->ShiftFlags & VIRTUALCHARKEY, key->Key == ch); - } -Hier ist das Problem : für dk==2 springt er hier rein, was er nicht darf... +int wertzu=688; +// _S2 why is key->Key == ch -> false ???? if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { //if(((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) && (!(deadkey==2 && shift==0))) { + if(((deadkey==2 ))) { + //wprintf(L"\nXXdeadkey %i, vk: %i\tkey->ShiftFlags:%i \tkey->ShiftFlags & VIRTUALCHARKEY %i\tkey->Key == ch %i key->Key: %i ch: %i",deadkey, vk, key->ShiftFlags, key->ShiftFlags & VIRTUALCHARKEY, key->Key == ch, key->Key, ch); - wprintf(L"TRUE!!!!!!!!!"); + wprintf(L"\nXXdeadkey %i, vk: %i\tkey->Key: %i ch: %i",deadkey, vk, key->Key, ch); + + + wprintf(L" TRUE!!!!!!!!!"); + } + //wprintf(L"\ndeadkey %i, key->ShiftFlags:%i key->ShiftFlags & VIRTUALCHARKEY %i key->Key == ch %i",deadkey, key->ShiftFlags, key->ShiftFlags & VIRTUALCHARKEY, key->Key == ch); + + + //wprintf(L" TRUE!!!!!!!!!"); // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. @@ -414,6 +413,8 @@ KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR deadkey, v_dw_3D &All_Vector, GdkKeymap* keymap) { KMX_WORD deadkeys[512], *pdk; + KMX_WORD* pd_S2; + KMX_DWORD* pdd_S2; //wprintf(L" ***************************************** key: %i %i %i \n",vk,shift, deadkey); // _S2 create dkTable once only and use as static/ define before func // create dk_createDK_ComposeTable @@ -427,28 +428,17 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR d // Add the deadkey to the mapping table for use in the import rules phase KMX_DeadkeyMapping KMX_deadkeyMapping = { deadkey, dkid, shift, vk}; // I4353 - //__S2 NEEDS to be here later KMX_FDeadkeys.push_back(KMX_deadkeyMapping); //dkid, vk, shift); // I4353 KMX_AddDeadkeyRule(kbd, dkid, vk, shift); - // _S2 NEEDS to go! -------- - /*// _S2 is only for testing &to compare 3 dk of windows - if(KMX_FDeadkeys.size()<3 ) - KMX_FDeadkeys.push_back(KMX_deadkeyMapping); //dkid, vk, shift); // I4353 - if(shift== 0 || shift== 16 ) - KMX_AddDeadkeyRule(kbd, dkid, vk, shift); - else - return;;*/ - // _S2 ----------------------------- - KMX_GetDeadkeys(dk_Table, deadkey, pdk = deadkeys, keymap); // returns array of [usvk, ch_out] pairs - while(*pdk) { - +pd_S2=pdk; +//pdd_S2=pdk; // Look up the ch UINT vkUnderlying = KMX_get_VKUS_From_VKUnderlying_VEC(All_Vector, *pdk); - //wprintf(L" vkUnderlying %i *pdk %i %i %ixxx", vkUnderlying, *pdk, *(pdk+1), *(pdk+2)); + wprintf(L" vkUnderlying %i *pdk %i %i %ixxx \n", vkUnderlying, *pd_S2, *(pd_S2+1), *(pd_S2+2)); KMX_TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); if(vkUnderlying != (UINT) *pdk) { @@ -457,6 +447,7 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR d //else //wprintf(L" \n"); pdk+=3; + pd_S2+=3; } } @@ -532,14 +523,17 @@ int sdfghjkl=0; //wprintf(L" scunderlying: SS: %i Nr: %i VKMap[i] %i ch:%i (%c)\n", VKShiftState[j],i, KMX_VKMap[i],ch,ch );` switch(ch) { case 0x0000: break; - case 0xFFFF: - KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap); break; //test_keyboard_S2(kbd); //-> mit Convert DK FALSCH; Ohne ConvertDK the same - default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); + case 0xFFFF: // _S2 in kbd (=loaded from kmx-file): replace LCTRL+RALT -> Ctrl+Alt + write deadkey-> FFFF + CODE_DEADKEY + deadkey into context + KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap); break; + default: // _S2 in kbd (=loaded from kmx-file): replace LCTRL+RALT -> Ctrl+Alt + switch keyvalues e.g. y<->z + KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); } } } KMX_ReportUnconvertedKeyboardRules(kbd); + + // _S2 use translated kbd and write data to rgkey[] then add things to rgkey[] to enable to write to kmx-format if(!KMX_ImportRules(kbd, All_Vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 return FALSE; } @@ -577,7 +571,7 @@ KMX_WCHAR KMX_get_VKUS_From_VKUnderlying_VEC(v_dw_3D All_Vector, KMX_DWORD VK_OT } // takes SC of underlying keyboard and returns character of underlying keyboard with shiftstate VKShiftState[j] or deadkey -// _S2 KMX_UINT ??? +// _S2 QUESTION KMX_UINT ??? KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, PKMX_WCHAR DeadKey) { PKMX_WCHAR dky; From 3c9ccc0e5737f7467f6501e66234a29bb05f6a04 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 12 Feb 2024 15:30:20 +0100 Subject: [PATCH 193/327] feat(linux): mcompile-dk createAlDead out of loop --- linux/mcompile/keymap/deadkey.cpp | 31 ++---- linux/mcompile/keymap/deadkey.h | 24 ++--- linux/mcompile/keymap/helpers.cpp | 96 +++++++++++++++++ linux/mcompile/keymap/keymap.cpp | 28 ++--- linux/mcompile/keymap/mc_import_rules.cpp | 126 +++------------------- linux/mcompile/keymap/mcompile.cpp | 116 +++----------------- 6 files changed, 154 insertions(+), 267 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 512dce12fe..0164919a4a 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -10,9 +10,10 @@ v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, s return line; } -bool find_dk_combinations_for_single_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &dk_SingleTable, KMX_DWORD dk) { +bool find_dk_combinations_for_specific_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &dk_SingleTable, KMX_DWORD dk) { v_dw_1D line; for ( int i =0; i< (int) (*p_dk_ComposeTable).size(); i++) { + // _S2 QUESTION is there a better way to find a-z,A-Z? // _S2 QUESTION is there a better way to find a-z,A-Z? //if (((*p_dk_ComposeTable)[i][0] == dk) ) { if (((*p_dk_ComposeTable)[i][0] == dk) && (IsKeymanUsedChar((*p_dk_ComposeTable)[i][1]))) { @@ -29,11 +30,10 @@ bool find_dk_combinations_for_single_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &d return false; } -//_S2 REVIEW std::vector create_alDead() { std::vector alDead; v_dw_2D dk_ComposeTable; - KMX_DWORD dw = create_DKTable(dk_ComposeTable); + create_DKTable(dk_ComposeTable); for( int i=0; i< dk_ComposeTable.size()-1; i++) { DeadKey *dk2= new DeadKey(dk_ComposeTable[i][0]); @@ -61,8 +61,6 @@ bool found_dk_inVector(KMX_WCHAR dk, std::vector &dkVec) { } void refine_alDead(KMX_WCHAR dk, std::vector &dkVec, std::vector *p_All_Vec) { - std::vector dkVec_unsorted; - if( dk == 0) return; @@ -75,23 +73,12 @@ void refine_alDead(KMX_WCHAR dk, std::vector &dkVec, std::vectorKMX_GetDeadCharacter()) { - if(! found_dk_inVector(dk, dkVec_unsorted)) { - dkVec_unsorted.push_back((*p_All_Vec)[j]); - return; - } - else return; - } - } } void sort_alDead(std::vector &small_Vec, std::vector *p_All_Vec) { std::vector small_sorted; int Vsmall_size; - int i=0; do { @@ -99,20 +86,19 @@ void sort_alDead(std::vector &small_Vec, std::vector *p_All_ Vsmall_size= small_Vec.size(); do { - if( (*p_All_Vec)[i]->KMX_DeadCharacter() == small_Vec[j]->KMX_DeadCharacter()) { + if((*p_All_Vec)[i]->KMX_DeadCharacter() == small_Vec[j]->KMX_DeadCharacter()) { small_sorted.push_back(small_Vec[j]); small_Vec.erase(std::next(small_Vec.begin()+j-1)); Vsmall_size--; } j++; } while (j< Vsmall_size); - i++; } while ((i< (*p_All_Vec).size()) && (Vsmall_size>0)); - small_Vec = small_sorted; } +// _S2 TODO might be used when deadkeys are implemented . is it correct?? // _S2 TODO might be used when deadkeys are implemented . is it correct?? KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap) { guint Keyval = (guint) KVal; @@ -135,13 +121,14 @@ KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap } // _S2 DESIGN NEEDED is this the right place to get dk from? if not wher are they stored? -KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable) { +void create_DKTable(v_dw_2D & dk_ComposeTable) { - // values taken from: https://help.ubuntu.com/community/GtkDeadKeyTable#Latin + //values taken from: https://help.ubuntu.com/community/GtkDeadKeyTable#Latin //dk_ComposeTable[i][0] : First (e.g. dead_circumflex) //dk_ComposeTable[i][1] : Second (e.g. a) //dk_ComposeTable[i][3] : Unicode-Value (e.g. 0x00E2) //dk_ComposeTable[i][4] : Character (e.g. small A with circumflex) + v_dw_1D line; line = createLine(L"dead_circumflex", L"a", 0x00E2, L"small A with circumflex"); @@ -504,7 +491,5 @@ KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable) { dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_tilde", L"dead_tilde", 0x007E, L"TILDE"); dk_ComposeTable.push_back(line); line.clear(); - - return 0; } diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index aa4ea2e21d..65cc74129b 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -10,25 +10,23 @@ v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult); // creates a 2D-vector of all dk combinations ( ` + a -> à ; ^ + a -> â ; `+ e -> è; ...) -KMX_DWORD create_DKTable(v_dw_2D & dk_ComposeTable); +void create_DKTable(v_dw_2D & dk_ComposeTable); -//_S2 TODO REVIEW -//_S2 finds all possible dk combinations that exist +// find all possible dk combinations that exist std::vector create_alDead(); -//_S2 refines dk to those used in the underlying keyboard +// refine dk to those used in the underlying keyboard void refine_alDead(KMX_WCHAR dk, std::vector &myVec, std::vector *p_All_Vec); - -// _S2 TODO maybe not used -std::vector reduce_alDead(std::vector dk_big); - - -void sort_alDead(std::vector &myVec, std::vector *p_All_Vec); bool found_dk_inVector(KMX_WCHAR dk, std::vector &myVec); -// finds all combination for a specific deadkey(dk) -bool find_dk_combinations_for_single_dk(v_dw_2D * dk_ComposeTable, v_dw_2D & dk_SingleTable, KMX_DWORD dk); +// finds all combination for a specific deadkey(dk) ^-> â,ê,î,ô,û,... +bool find_dk_combinations_for_specific_dk(v_dw_2D * dk_ComposeTable, v_dw_2D & dk_SingleTable, KMX_DWORD dk); // gets the shifted character of a key -KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap) ; +KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap); + +// _S2 probably not used +std::vector reduce_alDead(std::vector dk_big); +// _S2 probably not used +void sort_alDead(std::vector &myVec, std::vector *p_All_Vec); # endif /*DEADKEY_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp index 6b2c4201b3..3770f18dcf 100755 --- a/linux/mcompile/keymap/helpers.cpp +++ b/linux/mcompile/keymap/helpers.cpp @@ -1346,6 +1346,102 @@ KMX_WCHAR sbBuffer1[16]; }*/ +// _S2 can go later +/*void test_keyboard_S2(LPKMX_KEYBOARD kmxfile); +void TestKey_S2(LPKMX_KEY key) ; +void TestGroup_S2(LPKMX_GROUP group) ; +void TestKeyboard_S2(LPKMX_KEYBOARD kbd) ;*/ + + +// _S2 can go later +/*void test_keyboard_S2(LPKMX_KEYBOARD kmxfile){ + TestKeyboard_S2(kmxfile); +} + +void TestKey_S2(LPKMX_KEY key, int iii, int gr) { + + KMX_WCHAR* PP= key->dpOutput; + int z=0; + + if( *(key->dpOutput+1) != 0) { + wprintf(L"\n group[%i] dpKeyArray[%i] ",gr, iii); + int tzuiop=0; + do { + wprintf(L"%i\t", *(PP+z )); + z++; + } while (*(PP+z) !=0); + } + //if ((*(PP+z) !=0)) wprintf(L" _\n"); +} + +void TestGroup_S2(LPKMX_GROUP group ,int gr) { + for(unsigned int i = 0; i < group->cxKeyArray; i++) { + TestKey_S2(&group->dpKeyArray[i],i,gr); + } +} + +void TestKeyboard_S2(LPKMX_KEYBOARD kbd) { + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + wprintf(L"\nkbd->dpGroupArray[%i] \n",i); + TestGroup_S2(&kbd->dpGroupArray[i], i); + } + } +}*/ + +/*void check_rgkey_S2( std::vector rgKey, int i) { + + wprintf(L" rgfDeadkey[%i]: \t%i %i %i %i %i %i %i %i %i %i\n", i, + rgKey[i]->get_m_rgfDeadkey(0,0), rgKey[i]->get_m_rgfDeadkey(0,1), + rgKey[i]->get_m_rgfDeadkey(1,0), rgKey[i]->get_m_rgfDeadkey(1,1), + rgKey[i]->get_m_rgfDeadkey(2,0), rgKey[i]->get_m_rgfDeadkey(2,1), + rgKey[i]->get_m_rgfDeadkey(3,0), rgKey[i]->get_m_rgfDeadkey(3,1), + rgKey[i]->get_m_rgfDeadkey(4,0), rgKey[i]->get_m_rgfDeadkey(4,1), + rgKey[i]->get_m_rgfDeadkey(5,0), rgKey[i]->get_m_rgfDeadkey(5,1), + rgKey[i]->get_m_rgfDeadkey(6,0), rgKey[i]->get_m_rgfDeadkey(6,1), + rgKey[i]->get_m_rgfDeadkey(7,0), rgKey[i]->get_m_rgfDeadkey(7,1), + rgKey[i]->get_m_rgfDeadkey(8,0), rgKey[i]->get_m_rgfDeadkey(8,1), + rgKey[i]->get_m_rgfDeadkey(9,0), rgKey[i]->get_m_rgfDeadkey(9,1)); +} + +*/ + +/*void TestKey_S21(LPKMX_KEY key, int iii, int gr) { + + KMX_WCHAR* PP= key->dpOutput; + int z=0; + + if( *(key->dpOutput+1) != 0) { + wprintf(L"\n group[%i] dpKeyArray[%i] (key->key: %i) ",gr, iii, key->Key); + int tzuiop=0; + do { + wprintf(L"%i\t", *(PP+z )); + z++; + } while (*(PP+z) !=0); + } + //if ((*(PP+z) !=0)) wprintf(L" _\n"); +} + +void TestGroup_S21(LPKMX_GROUP group ,int gr) { + for(unsigned int i = 0; i < group->cxKeyArray; i++) { + TestKey_S21(&group->dpKeyArray[i],i,gr); + } +} + +void TestKeyboard_S21(LPKMX_KEYBOARD kbd) { + for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if(kbd->dpGroupArray[i].fUsingKeys) { + wprintf(L"\nkbd->dpGroupArray[%i] \n",i); + TestGroup_S21(&kbd->dpGroupArray[i], i); + } + } +} +// _S2 can go later +void test_keyboard_S21(LPKMX_KEYBOARD kmxfile){ + //TestKeyboard_S21(kmxfile); +}*/ + + /* diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 908b947a3c..b424e04ae1 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -5,7 +5,6 @@ int map_VKShiftState_to_Lin(int VKShiftState) { if (VKShiftState == 0 ) return 0; /* 0000 0000 */ else if (VKShiftState == 16) return 1; /* 0001 0000 */ - // _S2 if commented out only DK on base+shift will be processed ^ ' ` else if (VKShiftState == 9 ) return 2; /* 0000 1001 */ else if (VKShiftState == 25) return 3; /* 0001 1001 */ else return VKShiftState; @@ -123,8 +122,6 @@ int write_US_ToVector( v_dw_3D &vec,std::string language, const char* text) { if( split_US_To_3D_Vector( vec,Vector_completeUS)) { return 1; } - //wprintf(L"\n ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - //wprintf(L" +++++++ dimensions of Vector after split_US_To_3D_Vector (languages..characters..shiftstates)\t %li..%li..%li\n", vec.size(), vec[0].size(),vec[0][0].size()); fclose(fp); return 0; @@ -317,8 +314,6 @@ int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { return 1; } All_Vector.push_back(Other_Vector2D); - //wprintf(L" +++++++ dimensions of Vector after append_other_ToVector\t\t\t\t\t\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); - //wprintf(L" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n"); if (All_Vector.size() < 2) { wprintf(L"ERROR: creation of 3D-Vector failed\n"); @@ -359,6 +354,7 @@ bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]) { //------------------------------ // _S2 TODO deadkeys. Do we need this ? +// _S2 TODO deadkeys. Do we need this ? bool IsKeymanUsedKeyVal(std::wstring Keyval) { int KV = (int) (*Keyval.c_str()); @@ -396,6 +392,7 @@ bool IsKeymanUsedChar(int KV) { } + std::wstring convert_DeadkeyValues_ToChar(int in) { KMX_DWORD lname; @@ -423,6 +420,7 @@ std::wstring convert_DeadkeyValues_ToChar(int in) { return L"\0"; } //_S2 REview and change?? +//_S2 REview and change?? std::u16string convert_DeadkeyValues_To_U16str(int in) { KMX_DWORD lname; @@ -535,6 +533,7 @@ int KMX_get_keyvals_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss } else return 0; + return (int) *keyvals; } @@ -558,21 +557,16 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap if (!(keycode <= 94)) return 0; + // _S2 TODO take caps to this function // _S2 TODO take caps to this function // here I get all kvals: normal char , my Deadkeys, allothr DK - KMX_DWORD All_Keyvals = KMX_get_keyvals_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), 0) ; - //wprintf(L"All_Keyvals: %i----\n", All_Keyvals); - + KMX_DWORD All_Keyvals = KMX_get_keyvals_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), 0); if(( (All_Keyvals >= deadkey_min) && (All_Keyvals <= deadkey_max))) deadkey = All_Keyvals; - //wprintf(L" keyvals[shift_state_pos]: %i %i %i %i----", keyvals[0],keyvals[1],keyvals[2],keyvals[3]); - dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str(); out = KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); - //wprintf(L" out is :.....................................%i\n", out); - // _S2 TODO g_free used everywhere? g_free(keyvals); g_free(maps); @@ -596,7 +590,6 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap out = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); - // _S2 TODO g_free used everywhere? g_free(keyvals); g_free(maps); @@ -606,9 +599,10 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap // _S2 ToDo KMX_DWORD KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ - KMX_DWORD keyvals_dw= (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ss, caps) ; + KMX_DWORD keyvals_dw= (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ss, caps); // _S2 AHA output for dk4-12 at the top after dk... from here + if((keyvals_dw >= deadkey_min) && (keyvals_dw <= deadkey_max)) // deadkeys if((keyvals_dw >= deadkey_min) && (keyvals_dw <= deadkey_max)) // deadkeys return 0xFFFF; else if((keyvals_dw > deadkey_max) || ((keyvals_dw < deadkey_min) && ( keyvals_dw > 0xFF))) // out of range @@ -624,6 +618,7 @@ KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(Gdk std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ + // _S2 QUESTION skip ss 2+3 remove?? // _S2 QUESTION skip ss 2+3 remove?? if( (ss ==2 ) ||(ss ==3 )) return L"\0"; @@ -658,12 +653,12 @@ KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD if ( keyvals[i]>0) gdk_keyval_convert_case (*kv_name, &lowerCase, &upperCase); + // _S2 QUESTION is ( lowerCase == upperCase ) true for all number keys for all keyboards? // _S2 QUESTION is ( lowerCase == upperCase ) true for all number keys for all keyboards? if ( lowerCase == upperCase ) return (KMX_DWORD) upperCase; - } +} -KMX_DWORD testvar_S2 = ScanCodeToUSVirtualKey[keycode-8]; if ( keycode >7) return (KMX_DWORD) ScanCodeToUSVirtualKey[keycode-8]; @@ -671,7 +666,6 @@ KMX_DWORD testvar_S2 = ScanCodeToUSVirtualKey[keycode-8]; } KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS( KMX_DWORD VK_US) { - KMX_DWORD test_S2 = (8+ USVirtualKeyToScanCode[ VK_US ]); if( VK_US > 7) { return (KMX_DWORD)(8+ USVirtualKeyToScanCode[ VK_US ]);} else diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 3b26c5ec2f..63f0f8c947 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -27,42 +27,6 @@ #include "mc_kmxfile.h" #include "keymap.h" -void TestKey_S21(LPKMX_KEY key, int iii, int gr) { - - KMX_WCHAR* PP= key->dpOutput; - int z=0; - - if( *(key->dpOutput+1) != 0) { - wprintf(L"\n group[%i] dpKeyArray[%i] (key->key: %i) ",gr, iii, key->Key); - int tzuiop=0; - do { - wprintf(L"%i\t", *(PP+z )); - z++; - } while (*(PP+z) !=0); - } - //if ((*(PP+z) !=0)) wprintf(L" _\n"); -} - -void TestGroup_S21(LPKMX_GROUP group ,int gr) { - for(unsigned int i = 0; i < group->cxKeyArray; i++) { - TestKey_S21(&group->dpKeyArray[i],i,gr); - } -} - -void TestKeyboard_S21(LPKMX_KEYBOARD kbd) { - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { - wprintf(L"\nkbd->dpGroupArray[%i] \n",i); - TestGroup_S21(&kbd->dpGroupArray[i], i); - } - } -} -// _S2 can go later -void test_keyboard_S21(LPKMX_KEYBOARD kmxfile){ - //TestKeyboard_S21(kmxfile); -} - - const int KMX_ShiftStateMap[] = { ISVIRTUALKEY, ISVIRTUALKEY | K_SHIFTFLAG, @@ -117,9 +81,8 @@ int KMX_ToUnicodeEx(guint keycode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, std::wstring character= KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, keycode, ShiftState(shift_state_pos), caps); pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(character).c_str(); - KMX_DWORD keyvals_dw= (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), caps) ; + KMX_DWORD keyvals_dw= (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), caps); - // _S2 TODO g_free used everywhere? g_free(keyvals); g_free(maps); @@ -148,6 +111,7 @@ int KMX_DeadKeyMap(int index, std::vector *deadkeys, int deadkeyBase, class KMX_VirtualKey { private: + KMX_HKL m_hkl; // _S2 QUESTION do I need this and is void* OK to assume? If I remove this, will there be changes in Data-Vectors? KMX_HKL m_hkl; // _S2 QUESTION do I need this and is void* OK to assume? If I remove this, will there be changes in Data-Vectors? UINT m_vk; UINT m_sc; @@ -161,6 +125,7 @@ public: this->m_hkl = hkl; this->m_vk = virtualKey; // _S2 TODO deadkey + // _S2 TODO deadkey // memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); } @@ -205,6 +170,7 @@ public: this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; } +// _S2 QUESTION why are there sometimes numbers in m_rgfDeadKey??? // _S2 QUESTION why are there sometimes numbers in m_rgfDeadKey??? void KMX_SetShiftState(ShiftState shiftState, std::u16string value16, bool isDeadKey, bool capsLock) { std::wstring value = wstring_from_u16string(value16); @@ -276,11 +242,7 @@ public: } UINT KMX_GetShiftStateValue(int capslock, int caps, ShiftState ss) { - //wprintf(L"GetShiftStateValue takes capslock: %i, caps: %i, ss: %i and returns: %i \n", - //capslock, caps, ss, (KMX_ShiftStateMap[(int)ss] | (capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0))); - return - KMX_ShiftStateMap[(int)ss] | - (capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0); + return KMX_ShiftStateMap[(int)ss] | (capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0); } int KMX_GetKeyCount(int MaxShiftState) { @@ -340,7 +302,7 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; (this->KMX_IsSGCAPS() ? 2 : 0) | (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); -//wprintf(L"capslock is: %i\n",capslock); + // _S2 DESIGN NEEDED on how to replace capslock capslock=1; // _S2 // _S2 TODO capslock is not calculated correctly for linux. therefore key->ShiftFlags will be wrong for numbers, special characters @@ -352,8 +314,7 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; } for (int caps = 0; caps <= 1; caps++) { std::wstring st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); - PKMX_WCHAR p; // was PWSTR p; - PKMX_WCHAR p_S2; // was PWSTR p; + PKMX_WCHAR p; if (st.size() == 0) { // No character assigned here @@ -364,7 +325,6 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; key->dpContext = new KMX_WCHAR[1]; *key->dpContext = 0; - wprintf(L"st %i \n", st[0]); key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); // _S2 we already use VK_US so no need to convert it key->Key = this->VK(); @@ -377,13 +337,10 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; } else { p = key->dpOutput = new KMX_WCHAR[4]; - p_S2 =p; *p++ = UC_SENTINEL; *p++ = CODE_DEADKEY; *p++ = KMX_DeadKeyMap(st[0], deadkeys, deadkeyBase, &KMX_FDeadkeys); // I4353 - wprintf(L"KMX_DeadKeyMap(st[0], deadkeys, deadkeyBase, &KMX_FDeadkeys): %i\n",KMX_DeadKeyMap(st[0], deadkeys, deadkeyBase, &KMX_FDeadkeys)); *p = 0; - int wertzu=57; } key++; } @@ -409,7 +366,6 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; *key->dpContext = 0; p = key->dpOutput = new KMX_WCHAR[st.size() + 1]; - p_S2 = key->dpContext; for(size_t ich = 0; ich < st.size(); ich++) { *p++ = st[ich]; } @@ -419,8 +375,6 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; } } } - //wprintf(L"key->Key: %i %c\n",(key--)->Key,(key--)->Key); - int keyvalis= (key--)->Key; return true; } }; @@ -484,21 +438,6 @@ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { return n; } -void check_rgkey_S2( std::vector rgKey, int i) { - - wprintf(L" rgfDeadkey[%i]: \t%i %i %i %i %i %i %i %i %i %i\n", i, - rgKey[i]->get_m_rgfDeadkey(0,0), rgKey[i]->get_m_rgfDeadkey(0,1), - rgKey[i]->get_m_rgfDeadkey(1,0), rgKey[i]->get_m_rgfDeadkey(1,1), - rgKey[i]->get_m_rgfDeadkey(2,0), rgKey[i]->get_m_rgfDeadkey(2,1), - rgKey[i]->get_m_rgfDeadkey(3,0), rgKey[i]->get_m_rgfDeadkey(3,1), - rgKey[i]->get_m_rgfDeadkey(4,0), rgKey[i]->get_m_rgfDeadkey(4,1), - rgKey[i]->get_m_rgfDeadkey(5,0), rgKey[i]->get_m_rgfDeadkey(5,1), - rgKey[i]->get_m_rgfDeadkey(6,0), rgKey[i]->get_m_rgfDeadkey(6,1), - rgKey[i]->get_m_rgfDeadkey(7,0), rgKey[i]->get_m_rgfDeadkey(7,1), - rgKey[i]->get_m_rgfDeadkey(8,0), rgKey[i]->get_m_rgfDeadkey(8,1), - rgKey[i]->get_m_rgfDeadkey(9,0), rgKey[i]->get_m_rgfDeadkey(9,1)); -} - bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 KMX_Loader loader; @@ -511,6 +450,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, //_S2 REVIEW std::vector alDead2 ; std::vector alDead_cpl = create_alDead(); + std::vector alDead_cpl = create_alDead(); rgKey.resize(256); @@ -588,6 +528,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, KMX_DWORD SC_US = KMX_get_KeyCodeUnderlying_From_VKUS(iKey); + // _S2 TODO deadkey not finished; Ctrl, Shft +40 not tested // _S2 TODO deadkey not finished; Ctrl, Shft +40 not tested for(int caps = 0; caps <= 1; caps++) { loader.KMX_ClearKeyboardBuffer(); @@ -628,12 +569,12 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, sbBuffer[2] = 0; //rgKey[iKey]->SetShiftState(ss, sbBuffer, true, (caps == 0)); rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); //_S2 + rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); //_S2 // It's a dead key; let's flush out whats stored in the keyboard state. loader.KMX_ClearKeyboardBuffer(); DeadKey *dk = NULL; refine_alDead(sbBuffer[0], alDead, &alDead_cpl); - int testI= alDead.size(); /* for(UINT iDead = 0; iDead < alDead.size(); iDead++) { dk = alDead[iDead]; @@ -646,10 +587,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, //alDead.push_back(loader.KMX_ProcessDeadKey(iKey, ss, lpKeyState, rgKey, caps == 0, hkl, *keymap)); alDead2 = create_alDead(); alDead = reduce_alDead(alDead2); - - //_S2 for each dk (^ ' ` push_back all combinations ^,â,ê,î,ô,û ',á,é,í,ó,ú `,à,è,ì,ò,ù into alDead->m_rgcombchar) - //_S2 for each dk (^ ' ` push_back all base char : _,a,e,i,o,u into alDead->m_rgbasechar) - // S2 do nothing for other keys }*/ } } @@ -657,27 +594,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, } } // do we need to sort alDead?? - sort_alDead(alDead, &alDead_cpl) ; - - //_S2 this gan co later - /*std::vector< int > TestValues = {40,44,48,49,50,51,52,53,54,55,56,57,65,66,67,88,89,90, 186,187,188,189,191,191,192,219,220,221,222,226}; - wprintf(L"-----------------\nNow some tests:\n"); - wprintf(L" Base Caps Shift Shfit+Caps MenuCtrl MenuCtrl+Caps \n"); - - for ( int i=0; i < (int) TestValues.size();i++) { - std::wstring wws = rgKey[TestValues[i]]->get_m_rgss(0,0); - wprintf(L"Results for %i / SC %i\t : %ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \n", TestValues[i), rgKey[TestValues[i]]->SC(), - rgKey[TestValues[i]]->get_m_rgss(0,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(0,0)[0], - rgKey[TestValues[i]]->get_m_rgss(0,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(0,1)[0], - rgKey[TestValues[i]]->get_m_rgss(1,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(1,0)[0], - rgKey[TestValues[i]]->get_m_rgss(1,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(1,1)[0], - rgKey[TestValues[i]]->get_m_rgss(6,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(6,0)[0], - rgKey[TestValues[i]]->get_m_rgss(6,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(6,1)[0], - rgKey[TestValues[i]]->get_m_rgss(7,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(7,0)[0], - rgKey[TestValues[i]]->get_m_rgss(7,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(7,1)[0] - ); - } - wprintf(L"-----------------\n");*/ + sort_alDead(alDead, &alDead_cpl); //------------------------------------------------------------- // Now that we've collected the key data, we need to @@ -715,8 +632,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { nKeys+= rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()); - //wprintf(L" iKey = %i, Delta: %i -> Sum %i\n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()), nKeys); - } + } } @@ -738,7 +654,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { if(rgKey[iKey]->KMX_LayoutRow(loader.KMX_MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()); - // wprintf(L" iKey = %i, Delta: %i -> Sum %i\n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()), nKeys); } } } @@ -766,11 +681,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, LPKMX_KEY kkp; for(j = 0, kkp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kkp++) { // _S2 AHA! missing 26 lines from here: since capalock is not correct this loop will never be done - //wprintf(L"will add Rule for group %i and key %i - shiftflag %i \n", i, kkp->Key, kkp->ShiftFlags); - KMX_DWORD S_S2 = kkp->ShiftFlags; - bool eins= (K_CTRLFLAG|K_ALTFLAG|LCTRLFLAG|LALTFLAG|RCTRLFLAG|RALTFLAG); - bool test_S_S2 = ((kkp->ShiftFlags & (K_CTRLFLAG|K_ALTFLAG|LCTRLFLAG|LALTFLAG|RCTRLFLAG|RALTFLAG)) != 0); - if((kkp->ShiftFlags & (K_CTRLFLAG|K_ALTFLAG|LCTRLFLAG|LALTFLAG|RCTRLFLAG|RALTFLAG)) != 0) { gp2->cxKeyArray++; LPKMX_KEY kkp2 = new KMX_KEY[gp2->cxKeyArray]; @@ -781,18 +691,15 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, *kkp2->dpContext = 0; kkp2->Key = kkp->Key; kkp2->ShiftFlags = kkp->ShiftFlags; - //kkp2->ShiftFlags = 16384; kkp2->Line = 0; KMX_WCHAR *p = kkp2->dpOutput = new KMX_WCHAR[4]; KMX_WCHAR *q=p; *p++ = UC_SENTINEL; *p++ = CODE_USE; *p++ = (KMX_WCHAR)(kp->cxGroupArray); - //wprintf(L" --------------------------------did Rule for group %i and key %i - shiftflag %i \n", i, kkp->Key, kkp->ShiftFlags); *p = 0; } } - int sdfghjk=0; } } @@ -804,7 +711,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, kp->cxGroupArray++; KMX_WCHAR *p = gp->dpMatch = new KMX_WCHAR[4]; - KMX_WCHAR *qq_S2 = p; *p++ = UC_SENTINEL; *p++ = CODE_USE; *p++ = (KMX_WCHAR) kp->cxGroupArray; @@ -828,7 +734,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, int nStoreBase = kp->cxStoreArray; kp->cxStoreArray += alDead.size() * 2; -//_S2 here get ÂâÊêÎî... for(UINT i = 0; i < alDead.size(); i++) { DeadKey *dk = alDead[i]; @@ -852,7 +757,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, kkp->ShiftFlags = 0; kkp->Key = 0; KMX_WCHAR *p = kkp->dpContext = new KMX_WCHAR[8]; - KMX_WCHAR* qQQ_S2= p; *p++ = UC_SENTINEL; *p++ = CODE_DEADKEY; *p++ = KMX_DeadKeyMap(dk->KMX_DeadCharacter(), &alDead, nDeadkey, FDeadkeys); // I4353 @@ -861,19 +765,13 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, *p++ = CODE_ANY; *p++ = nStoreBase + i*2 + 1; *p = 0; - wprintf(L" contents of kkp->dpContext: %i \\ %i \\ %i \\ %i \\ %i \\ %i \\ %i \\ %i ----", - *qQQ_S2,*(qQQ_S2+1),*(qQQ_S2+2),*(qQQ_S2+3),*(qQQ_S2+4),*(qQQ_S2+5),*(qQQ_S2+6),*(qQQ_S2+7),*(qQQ_S2+8)); p = kkp->dpOutput = new KMX_WCHAR[5]; - KMX_WCHAR* QT_S2= p; *p++ = UC_SENTINEL; *p++ = CODE_INDEX; *p++ = nStoreBase + i*2 + 2; *p++ = 2; *p = 0; - - wprintf(L" contents of kkp->dpOutput: %i \\ %i \\ %i \\ %i \\ %i \\ %i \\ %i \\ %i\n", - *QT_S2,*(QT_S2+1),*(QT_S2+2),*(QT_S2+3),*(QT_S2+4),*(QT_S2+5),*(QT_S2+6),*(QT_S2+7),*(QT_S2+8)); kkp++; } } diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index d52e3cedd9..0d55bb0768 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -35,12 +35,6 @@ //------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------ -// _S2 can go later -void test_keyboard_S2(LPKMX_KEYBOARD kmxfile); -void TestKey_S2(LPKMX_KEY key) ; -void TestGroup_S2(LPKMX_GROUP group) ; -void TestKeyboard_S2(LPKMX_KEYBOARD kbd) ; - KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]); @@ -143,6 +137,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ #endif + //DeleteReallocatedPointers(kmxfile); :TODO // not my ToDo :-) //DeleteReallocatedPointers(kmxfile); :TODO // not my ToDo :-) delete kmxfile; @@ -158,6 +153,7 @@ const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCT // Ubuntu: Each of the 4 columns specifies a different modifier: unmodified, shift, right alt (altgr), shift+right alt(altgr) // we have assigned these to columns 1-4 ( column o holds the keycode) // const UINT VKShiftState[] = {0, 1, 2, 3, 0xFFFF}; +// const UINT VKShiftState[] = {0, 1, 2, 3, 0xFFFF}; // // TranslateKey @@ -165,6 +161,7 @@ const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCT // For each key rule on the keyboard, remap its key to the // correct shift state and key. Adjust the LCTRL+RALT -> RALT if necessary // _S2 exchange key->Key with the new value ( use vk instead of ch) +// _S2 exchange key->Key with the new value ( use vk instead of ch) // void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. @@ -179,8 +176,6 @@ void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) //LogError(L"Converted mnemonic rule on line %d, + '%c' TO + [%x K_%d]", key->Line, key->Key, shift, vk); key->ShiftFlags = ISVIRTUALKEY | shift; key->Key = vk; - //wprintf(L"ISVIRTUALKEY: %i , shift: %i, key->ShiftFlags for mnemonic= %i\n", ISVIRTUALKEY,shift, key->ShiftFlags); - //wprintf(L" 1 and changed, %i (%c) %i (%c) ", ch,ch, vk,vk); } else if(key->ShiftFlags & VIRTUALCHARKEY && key->Key == ch) { // Key is a virtual character key with a hard-coded shift state. // Do not remap the shift state, just move the key. @@ -189,10 +184,7 @@ void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) // But that is up to the designer. //LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, key->ShiftFlags & ~VIRTUALCHARKEY, vk); key->ShiftFlags &= ~VIRTUALCHARKEY; - //wprintf(L" i am processing vk%i (%c) char %i (%c) \n", vk,vk, ch,ch); key->Key = vk; - //wprintf(L"key->ShiftFlags for VIRTUALCHARKEY= %i", key->ShiftFlags); - //wprintf(L" 2 and changed, vk: %i (%c) ---> %i (%c) ", vk,vk, ch,ch); } } @@ -235,29 +227,10 @@ void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { } void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch, int abcd) { +// _S2 this produces a different output due to different layouts for Lin<-> win ( foe the same languarǵe!!) - //_S2 AHA Hier ist das Problem : für dk==2 springt er hier rein, was er nicht darf... - // this is because SHIFTFLAG has the wrong value - // which is because KMX_GetShiftStateValue gets the wrong value - // which is because capslock is not set correctlyS - // which is because WIN<->Lin shiftstares are different 4 $ $ 4 <-> 4 4 $ $ etc. - -int wertzu=688; -// _S2 why is key->Key == ch -> false ???? if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { - //if(((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) && (!(deadkey==2 && shift==0))) { - if(((deadkey==2 ))) { - //wprintf(L"\nXXdeadkey %i, vk: %i\tkey->ShiftFlags:%i \tkey->ShiftFlags & VIRTUALCHARKEY %i\tkey->Key == ch %i key->Key: %i ch: %i",deadkey, vk, key->ShiftFlags, key->ShiftFlags & VIRTUALCHARKEY, key->Key == ch, key->Key, ch); - wprintf(L"\nXXdeadkey %i, vk: %i\tkey->Key: %i ch: %i",deadkey, vk, key->Key, ch); - - - wprintf(L" TRUE!!!!!!!!!"); - } - //wprintf(L"\ndeadkey %i, key->ShiftFlags:%i key->ShiftFlags & VIRTUALCHARKEY %i key->Key == ch %i",deadkey, key->ShiftFlags, key->ShiftFlags & VIRTUALCHARKEY, key->Key == ch); - - - //wprintf(L" TRUE!!!!!!!!!"); // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. @@ -286,12 +259,10 @@ int wertzu=688; key->dpContext = context; key->Key = vk; } - int sdfgh=0; } void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group,KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { for(unsigned int i = 0; i < group->cxKeyArray; i++) { - //wprintf(L" key: %i\n",i ); KMX_TranslateDeadkeyKey(&group->dpKeyArray[i], deadkey, vk, shift, ch, i); } } @@ -299,8 +270,6 @@ void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group,KMX_WCHAR deadkey, KMX_WORD vk, void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { if(kbd->dpGroupArray[i].fUsingKeys) { - - //wprintf(L" group: %i\n",i ); KMX_TranslateDeadkeyGroup(&kbd->dpGroupArray[i], deadkey, vk, shift, ch); } } @@ -317,7 +286,6 @@ void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT // If the first group is not a matching-keys group, then we need to add into // each subgroup, otherwise just the match group - int zaehler=0; for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { if(kbd->dpGroupArray[i].fUsingKeys) { LPKMX_KEY keys = new KMX_KEY[kbd->dpGroupArray[i].cxKeyArray + 1]; @@ -335,8 +303,7 @@ void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT kbd->dpGroupArray[i].dpKeyArray = keys; kbd->dpGroupArray[i].cxKeyArray++; //LogError("Add deadkey rule: + [%d K_%d] > dk(%d)", shift, vk, deadkey); - zaehler++; - wprintf(L"Add deadkey rule: + [%d K_%d] > dk(%d) %i\n", shift, vk, deadkey,zaehler); + wprintf(L"Add deadkey rule: + [%d K_%d] > dk(%d) \n", shift, vk, deadkey); if(i == kbd->StartGroup[1]) break; // If this is the initial group, that's all we need to do. } @@ -411,15 +378,8 @@ KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { return s_dkids[s_ndkids++].dst_deadkey = s_next_dkid = ++dkid; } -void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR deadkey, v_dw_3D &All_Vector, GdkKeymap* keymap) { +void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR deadkey, v_dw_3D &All_Vector, GdkKeymap* keymap,v_dw_2D dk_Table) { KMX_WORD deadkeys[512], *pdk; - KMX_WORD* pd_S2; - KMX_DWORD* pdd_S2; -//wprintf(L" ***************************************** key: %i %i %i \n",vk,shift, deadkey); - // _S2 create dkTable once only and use as static/ define before func - // create dk_createDK_ComposeTable - v_dw_2D dk_Table; - create_DKTable(dk_Table); // Lookup the deadkey table for the deadkey in the physical keyboard // Then for each character, go through and map it through @@ -438,14 +398,7 @@ pd_S2=pdk; // Look up the ch UINT vkUnderlying = KMX_get_VKUS_From_VKUnderlying_VEC(All_Vector, *pdk); - wprintf(L" vkUnderlying %i *pdk %i %i %ixxx \n", vkUnderlying, *pd_S2, *(pd_S2+1), *(pd_S2+2)); - KMX_TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); - - if(vkUnderlying != (UINT) *pdk) { - //wprintf(L" TRANSLATED \n"); - } - //else - //wprintf(L" \n"); + KMX_TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); pdk+=3; pd_S2+=3; } @@ -499,6 +452,9 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg return FALSE; } + v_dw_2D dk_Table; + create_DKTable(dk_Table); + for (int j = 0; VKShiftState[j] != 0xFFFF; j++) { // I4651 // Loop through each possible key on the keyboard @@ -508,23 +464,18 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg UINT scUnderlying = KMX_get_SCUnderlying_From_VKUS(KMX_VKMap[i]); KMX_WCHAR ch = KMX_get_CharUnderlying_From_SCUnderlying_GDK(keymap, VKShiftState[j], scUnderlying, &DeadKey); - //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); - //wprintf(L"--- VK_%d -> SC_%d [%c] dk=%d ( ss %i) \n", KMX_VKMap[i], KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]), ch == 0 ? 32 : ch, DeadKey,VKShiftState[j]); -//wprintf(L"^^^^^^^^^^^^^^^^^^^^^^^, VKShiftState[j] ----> ch %i (%c)\n", (int)VKShiftState[j],ch,ch); - //wprintf(L"--- VK_%d -> SC_ [%c] dk=%d ( ss %i) \n", VKMap[i], ch == 0 ? 32 : ch, DeadKey, VKShiftState[j]); -int sdfghjkl=0; + if(bDeadkeyConversion) { // I4552 if(ch == 0xFFFF) { ch = DeadKey; } } -//wprintf(L" scunderlying: SS: %i Nr: %i VKMap[i] %i ch:%i (%c)\n", VKShiftState[j],i, KMX_VKMap[i],ch,ch );` switch(ch) { case 0x0000: break; case 0xFFFF: // _S2 in kbd (=loaded from kmx-file): replace LCTRL+RALT -> Ctrl+Alt + write deadkey-> FFFF + CODE_DEADKEY + deadkey into context - KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap); break; + KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap , dk_Table); break; default: // _S2 in kbd (=loaded from kmx-file): replace LCTRL+RALT -> Ctrl+Alt + switch keyvalues e.g. y<->z KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); } @@ -533,6 +484,8 @@ int sdfghjkl=0; KMX_ReportUnconvertedKeyboardRules(kbd); + // _S2 use translated kbd and write data to rgkey[] then add things to rgkey[] to enable to write to kmx-format + // _S2 use translated kbd and write data to rgkey[] then add things to rgkey[] to enable to write to kmx-format if(!KMX_ImportRules(kbd, All_Vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 return FALSE; @@ -572,6 +525,7 @@ KMX_WCHAR KMX_get_VKUS_From_VKUnderlying_VEC(v_dw_3D All_Vector, KMX_DWORD VK_OT // takes SC of underlying keyboard and returns character of underlying keyboard with shiftstate VKShiftState[j] or deadkey // _S2 QUESTION KMX_UINT ??? +// _S2 QUESTION KMX_UINT ??? KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, PKMX_WCHAR DeadKey) { PKMX_WCHAR dky; @@ -591,7 +545,7 @@ int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, KMX_DWORD shift; v_dw_2D dk_SingleTable; - find_dk_combinations_for_single_dk(&dk_Table, dk_SingleTable, DeadKey); + find_dk_combinations_for_specific_dk(&dk_Table, dk_SingleTable, DeadKey); for ( int i=0; i< (int) dk_SingleTable.size();i++) { KMX_WORD vk = KMX_changeKeynameToCapital(dk_SingleTable[i][1], shift, keymap); if(vk != 0) { @@ -608,44 +562,6 @@ int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, return (p-OutputPairs); } - -// _S2 can go later -void test_keyboard_S2(LPKMX_KEYBOARD kmxfile){ - TestKeyboard_S2(kmxfile); -} - -void TestKey_S2(LPKMX_KEY key, int iii, int gr) { - - KMX_WCHAR* PP= key->dpOutput; - int z=0; - - if( *(key->dpOutput+1) != 0) { - wprintf(L"\n group[%i] dpKeyArray[%i] ",gr, iii); - int tzuiop=0; - do { - wprintf(L"%i\t", *(PP+z )); - z++; - } while (*(PP+z) !=0); - } - //if ((*(PP+z) !=0)) wprintf(L" _\n"); -} - -void TestGroup_S2(LPKMX_GROUP group ,int gr) { - for(unsigned int i = 0; i < group->cxKeyArray; i++) { - TestKey_S2(&group->dpKeyArray[i],i,gr); - } -} - -void TestKeyboard_S2(LPKMX_KEYBOARD kbd) { - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { - wprintf(L"\nkbd->dpGroupArray[%i] \n",i); - TestGroup_S2(&kbd->dpGroupArray[i], i); - } - } -} - - // ---- old copy code from here ---------------------------------------------------------- /* From b49f28f3ef09fe503fef1c9793152ecb84ac17b2 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 12 Feb 2024 20:03:50 +0100 Subject: [PATCH 194/327] feat(linux): resolve conflicts mcompile-dk remove unused functions, consolidate Datatypes --- linux/mcompile/keymap/keymap.cpp | 35 +---------------------- linux/mcompile/keymap/keymap.h | 2 -- linux/mcompile/keymap/km_types.h | 2 -- linux/mcompile/keymap/mc_import_rules.cpp | 12 ++++---- linux/mcompile/keymap/mc_import_rules.h | 3 -- linux/mcompile/keymap/mcompile.cpp | 19 ++++++------ linux/mcompile/keymap/mcompile.h | 4 +-- 7 files changed, 17 insertions(+), 60 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index b424e04ae1..729f4b3405 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -352,36 +352,6 @@ bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]) { return 0; } -//------------------------------ -// _S2 TODO deadkeys. Do we need this ? -// _S2 TODO deadkeys. Do we need this ? -bool IsKeymanUsedKeyVal(std::wstring Keyval) { - int KV = (int) (*Keyval.c_str()); - - // 32 127 196 256 - if ((KV >= 0x20 && KV <= 0x7F) || (KV >= 0x20 && KV <= 0x7F) || (KV >= 0xC4 && KV < 198) || - (KV >= 199 && KV < 208) || (KV >= 209 && KV < 216) || (KV >= 217 && KV < 229) || - (KV >= 231 && KV < 240) || (KV >= 241 && KV < 248) || (KV >= 249 && KV < 0xFF) || - (KV == 128) || (KV == 178) || (KV == 167) || (KV == 179) || (KV == 176)|| (KV == 181) ) - return true; - else - return false; -} - -bool IsKeymanUsedKeyVal(std::u16string Keyval) { - - int KV = (int) (*Keyval.c_str()); - - // 32 127 196 256 - if ((KV >= 0x20 && KV <= 0x7F) || (KV >= 0x20 && KV <= 0x7F) || (KV >= 0xC4 && KV < 198) || - (KV >= 199 && KV < 208) || (KV >= 209 && KV < 216) || (KV >= 217 && KV < 229) || - (KV >= 231 && KV < 240) || (KV >= 241 && KV < 248) || (KV >= 249 && KV < 0xFF) || - (KV == 128) || (KV == 178) || (KV == 167) || (KV == 179) || (KV == 176)|| (KV == 181)|| - (KV >= deadkey_min && KV < deadkey_max+1) ) - return true; - else - return false; -} bool IsKeymanUsedChar(int KV) { // 32 A-Z a-z @@ -619,10 +589,7 @@ KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(Gdk std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ // _S2 QUESTION skip ss 2+3 remove?? - // _S2 QUESTION skip ss 2+3 remove?? - if( (ss ==2 ) ||(ss ==3 )) - return L"\0"; - + int keyvals_int= KMX_get_keyvals_From_Keycode(keymap, keycode, ss, caps); return convert_DeadkeyValues_ToChar(keyvals_int); } diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index c3428cd1bb..de36bd70b1 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -500,8 +500,6 @@ const UINT ScanCodeToUSVirtualKey[128] = { 0x00 // 0x7f => No match }; -bool IsKeymanUsedKeyVal(std::wstring Keyval); -bool IsKeymanUsedKeyVal(std::u16string Keyval); bool IsKeymanUsedChar(int KV); // take deadkey-value (e.g.65106) and return wstring (e.g. '^' ) diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index addadd7666..bde3618209 100755 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -54,8 +54,6 @@ typedef WCHAR* PWCHAR; typedef uint8_t* LPKMX_BYTE; typedef uint8_t* PKMX_BYTE; -typedef uint32_t KMX_UINT; - typedef KMX_BYTE* PKMX_BYTE; typedef KMX_DWORD* PKMX_DWORD; typedef int BOOL; diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 63f0f8c947..c122f4ff75 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -128,12 +128,14 @@ public: // _S2 TODO deadkey // memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); } +//_S2 keymap* or keymap** KMX_VirtualKey(UINT scanCode, KMX_HKL hkl, GdkKeymap **keymap) { this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying_GDK(*keymap, scanCode); this->m_hkl = hkl; this->m_sc = scanCode; //KMX_InitializeDeadkeys(); // _S2 to get all 0 in rgfDeadkey[ ][ ]- why were there numbers??? + // _S2 originally initioalized with memse ( see above=) } UINT VK() { @@ -178,7 +180,7 @@ public: this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; } -// _S2 DESIGN NEEDED how to change those? +// _S2 DESIGN NEEDED how to change those? Do we need to change? bool KMX_IsSGCAPS() { std::wstring stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß std::wstring stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? @@ -319,14 +321,13 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; if (st.size() == 0) { // No character assigned here } - // _S2 TODO deadkeys don't work yet/ if true is in m_rgfDeadKey else if (this->m_rgfDeadKey[(int)ss][caps]) { // It's a dead key, append an @ sign. key->dpContext = new KMX_WCHAR[1]; *key->dpContext = 0; key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); - // _S2 we already use VK_US so no need to convert it + // we already use VK_US so no need to convert it key->Key = this->VK(); key->Line = 0; @@ -382,7 +383,7 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; class KMX_Loader { private: KMX_BYTE lpKeyStateNull[256]; - KMX_UINT m_XxxxVk; + UINT m_XxxxVk; public: KMX_Loader() { @@ -447,7 +448,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector rgKey; //= new VirtualKey[256]; std::vector alDead; - //_S2 REVIEW + //_S2 remove alDead2 std::vector alDead2 ; std::vector alDead_cpl = create_alDead(); std::vector alDead_cpl = create_alDead(); @@ -477,7 +478,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, rgKey[ke] = new KMX_VirtualKey(hkl, ke, keymap); } - // _S2 ???? which numbers for VK_DIVIDE, VK_CANCEL, VK_DECIMAL ? rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE, keymap); rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL, keymap); rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL, keymap); diff --git a/linux/mcompile/keymap/mc_import_rules.h b/linux/mcompile/keymap/mc_import_rules.h index 83e667f597..2725b4860f 100644 --- a/linux/mcompile/keymap/mc_import_rules.h +++ b/linux/mcompile/keymap/mc_import_rules.h @@ -31,9 +31,6 @@ public: return this->m_rgcombchar[index]; } - // _S2 TODO only use one - bool ContainsBaseCharacter(WCHAR baseCharacter); - bool KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter) ; }; diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 0d55bb0768..579b6575dd 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -163,7 +163,7 @@ const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCT // _S2 exchange key->Key with the new value ( use vk instead of ch) // _S2 exchange key->Key with the new value ( use vk instead of ch) // -void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { +void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. @@ -188,13 +188,13 @@ void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) } } -void KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { +void KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { for(unsigned int i = 0; i < group->cxKeyArray; i++) { KMX_TranslateKey(&group->dpKeyArray[i], vk, shift, ch); } } -void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_UINT shift, KMX_WCHAR ch) { +void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { if(kbd->dpGroupArray[i].fUsingKeys) { KMX_TranslateGroup(&kbd->dpGroupArray[i], vk, shift, ch); @@ -226,8 +226,8 @@ void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { } } -void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch, int abcd) { -// _S2 this produces a different output due to different layouts for Lin<-> win ( foe the same languarǵe!!) +void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { +// _S2 this produces a different output due to different layouts for Lin<-> win ( foe the same language!!) if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { @@ -263,7 +263,7 @@ void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group,KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { for(unsigned int i = 0; i < group->cxKeyArray; i++) { - KMX_TranslateDeadkeyKey(&group->dpKeyArray[i], deadkey, vk, shift, ch, i); + KMX_TranslateDeadkeyKey(&group->dpKeyArray[i], deadkey, vk, shift, ch); } } @@ -275,7 +275,6 @@ void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WOR } } -// _S2 this does not work OK void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" @@ -406,7 +405,7 @@ pd_S2=pdk; KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { LPKMX_STORE sp; - KMX_UINT i; + UINT i; for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { if(sp->dwSystemID == TSS_MNEMONIC) { if(!sp->dpString) { @@ -524,9 +523,7 @@ KMX_WCHAR KMX_get_VKUS_From_VKUnderlying_VEC(v_dw_3D All_Vector, KMX_DWORD VK_OT } // takes SC of underlying keyboard and returns character of underlying keyboard with shiftstate VKShiftState[j] or deadkey -// _S2 QUESTION KMX_UINT ??? -// _S2 QUESTION KMX_UINT ??? -KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, PKMX_WCHAR DeadKey) { +KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, UINT VKShiftState, UINT SC_OTHER, PKMX_WCHAR DeadKey) { PKMX_WCHAR dky; int VKShiftState_lin = map_VKShiftState_to_Lin(VKShiftState); diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 06f47a6d86..946faacf5c 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -30,7 +30,7 @@ void KMX_LogError(const KMX_WCHART* m1, int m2 = 0); struct KMX_DeadkeyMapping { // I4353 KMX_WCHAR deadkey, dkid; - KMX_UINT shift; + UINT shift; KMX_WORD vk; }; @@ -42,7 +42,7 @@ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); -KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, PKMX_WCHAR DeadKey); +KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, UINT VKShiftState, UINT SC_OTHER, PKMX_WCHAR DeadKey); KMX_WCHAR KMX_get_VKUS_From_VKUnderlying_VEC(v_dw_3D All_Vector,KMX_DWORD SC_US); From 80e044e106e527725ce80cf8a140f726a3689d23 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 13 Feb 2024 11:56:04 +0100 Subject: [PATCH 195/327] feat(linux): again resolce conflict mcompile-dk remove KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw --- linux/mcompile/keymap/keymap.cpp | 90 ++++++++++++++++++++++- linux/mcompile/keymap/keymap.h | 2 +- linux/mcompile/keymap/km_types.h | 2 +- linux/mcompile/keymap/mc_import_rules.cpp | 15 ++-- linux/mcompile/keymap/mcompile.cpp | 29 +++++--- linux/mcompile/keymap/mcompile.h | 1 + 6 files changed, 116 insertions(+), 23 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 729f4b3405..8689682efe 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -513,7 +513,7 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap guint *keyvals; gint count; KMX_DWORD out; - KMX_DWORD deadkey; + KMX_DWORD deadkey=0; if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) @@ -523,7 +523,7 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap if (!(shift_state_pos <= count)) return 0; - +// _S2 94 as variable/const if (!(keycode <= 94)) return 0; @@ -543,6 +543,70 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap return out; } +// _S2 TODO +KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK_New(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky) { + GdkKeymapKey *maps; + guint *keyvals; + gint count; + KMX_DWORD out; + KMX_DWORD deadkey=0; + + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return 0; + //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html + + if (!(shift_state_pos <= count)) + return 0; +// _S2 94 as variable/const + if (!(keycode <= 94)) + return 0; + + // _S2 TODO take caps to this function + // here I get all kvals: normal char , my Deadkeys, allothr DK + KMX_DWORD All_Keyvals = KMX_get_keyvals_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), 0); + if(( (All_Keyvals >= deadkey_min) && (All_Keyvals <= deadkey_max))) + deadkey = All_Keyvals; + // _S2 check if naming is correct: does get_char... return a char or a string or a DWORD;...? + dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str(); +/* +// _S2 ToDo +KMX_DWORD KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ + + KMX_DWORD keyvals_dw= (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ss, caps); + + // _S2 AHA output for dk4-12 at the top after dk... from here + if((keyvals_dw >= deadkey_min) && (keyvals_dw <= deadkey_max)) // deadkeys + return 0xFFFF; + else if((keyvals_dw > deadkey_max) || ((keyvals_dw < deadkey_min) && ( keyvals_dw > 0xFF))) // out of range + return 0xFFFE; + else // usable char + return keyvals_dw; +} +*/ + + g_free(keyvals); + g_free(maps); + + // _S2 AHA output for dk4-12 at the top after dk... from here + if((All_Keyvals >= deadkey_min) && (All_Keyvals <= deadkey_max)) // deadkeys + return 0xFFFF; + else if((All_Keyvals > deadkey_max) || ((All_Keyvals < deadkey_min) && ( All_Keyvals > 0xFF))) // out of range + return 0xFFFE; + else // usable char + return All_Keyvals; + + + + + + + //out = KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); + + +} + KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; guint *keyvals; @@ -580,6 +644,28 @@ KMX_DWORD KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(Gdk else // usable char return keyvals_dw; } +// _S2 remove term _other and use underlying instead +KMX_DWORD KMX_get_CharUnderlying_From_SCUnderlying_GDK_NEW(GdkKeymap *keymap, UINT VKShiftState, UINT SC_OTHER, PKMX_WCHAR DeadKey) { + //takes keymap, shift, scanCode + //fills ref deadkey + //returns character(KMX_DWORD) +PKMX_WCHAR dd; + KMX_DWORD keyvals_dw = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK_New(keymap, SC_OTHER, map_VKShiftState_to_Lin(VKShiftState), dd); + + + + +// _S2 rename dd + if((keyvals_dw >= deadkey_min) && (keyvals_dw >= deadkey_max)) { + *DeadKey = *dd; + return 0xFFFF; + } + else if((keyvals_dw > deadkey_max) || ((keyvals_dw < deadkey_min) && ( keyvals_dw > 0xFF))) // out of range + return 0xFFFE; + else // usable char + return keyvals_dw; + +} KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index de36bd70b1..50455c0ddc 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -520,7 +520,7 @@ KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(Gdk // _S2 TODO returns char or FFFF / FFFE ???? KMX_DWORD KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); - +KMX_DWORD KMX_get_CharUnderlying_From_SCUnderlying_GDK_NEW(GdkKeymap *keymap, UINT VKShiftState, UINT SC_OTHER, PKMX_WCHAR DeadKey); diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index bde3618209..686d68c5f3 100755 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -36,7 +36,7 @@ typedef uint16_t km_kbp_cp; // code point typedef uint32_t km_kbp_usv; // Unicode Scalar Value #endif -// _S2 which can be removed later? +// _S2 TODO which can be removed later? typedef unsigned int UINT; typedef unsigned long DWORD; diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index c122f4ff75..6c588f0def 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -128,7 +128,7 @@ public: // _S2 TODO deadkey // memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); } -//_S2 keymap* or keymap** +//_S2 ToDo keymap* or keymap** KMX_VirtualKey(UINT scanCode, KMX_HKL hkl, GdkKeymap **keymap) { this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying_GDK(*keymap, scanCode); @@ -251,7 +251,7 @@ public: int nkeys = 0; // Get the CAPSLOCK value - //_S2 not used in original code; can be deleted + //_S2 INFO not used in original code; can be deleted /*int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | (this->KMX_IsSGCAPS() ? 2 : 0) | @@ -448,7 +448,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector rgKey; //= new VirtualKey[256]; std::vector alDead; - //_S2 remove alDead2 + //_S2 TODO remove alDead2 std::vector alDead2 ; std::vector alDead_cpl = create_alDead(); std::vector alDead_cpl = create_alDead(); @@ -522,9 +522,9 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, } //_S2 to compare win-lin kmn-files skip ss6+7; MUST BE restored/removed later!!!! - if(ss == MenuCtrl|| ss == ShftMenuCtrl) { + /*if(ss == MenuCtrl|| ss == ShftMenuCtrl) { continue; - } + }*/ KMX_DWORD SC_US = KMX_get_KeyCodeUnderlying_From_VKUS(iKey); @@ -562,14 +562,13 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, } sbBuffer[rc] = 0; //rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps==0)); - rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps)); //_S2 + rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps)); //_S2 INFO } } else if(rc < 0) { sbBuffer[2] = 0; //rgKey[iKey]->SetShiftState(ss, sbBuffer, true, (caps == 0)); - rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); //_S2 - rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); //_S2 + rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); //_S2 INFO // It's a dead key; let's flush out whats stored in the keyboard state. loader.KMX_ClearKeyboardBuffer(); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 579b6575dd..c3ea5678b2 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -22,7 +22,7 @@ 06 Feb 2015 - mcdurdin - I4552 - V9.0 - Add mnemonic recompile option to ignore deadkeys 08 Apr 2015 - mcdurdin - I4651 - V9.0 - Mnemonic layout recompiler maps AltGr+VK_BKSLASH rather than VK_OEM_102 */ -//_S2 +//_S2 INFO // in /Projects/keyman/keyman/linux/mcompile/keymap/build_mcompile // run with: //./mcompile -d in.kmx bla.dll 0407 out.kmx @@ -149,7 +149,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ // Map of all shift states that we will work with const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; -// _S2 my comment for Lin version +// _S2 INFO my comment for Lin version // Ubuntu: Each of the 4 columns specifies a different modifier: unmodified, shift, right alt (altgr), shift+right alt(altgr) // we have assigned these to columns 1-4 ( column o holds the keycode) // const UINT VKShiftState[] = {0, 1, 2, 3, 0xFFFF}; @@ -160,8 +160,7 @@ const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCT // // For each key rule on the keyboard, remap its key to the // correct shift state and key. Adjust the LCTRL+RALT -> RALT if necessary -// _S2 exchange key->Key with the new value ( use vk instead of ch) -// _S2 exchange key->Key with the new value ( use vk instead of ch) +// _S2 INFO exchange key->Key with the new value ( use vk instead of ch) // void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. @@ -227,7 +226,7 @@ void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { } void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { -// _S2 this produces a different output due to different layouts for Lin<-> win ( foe the same language!!) +// _S2 INFO this produces a different output due to different layouts for Lin<-> win ( foe the same language!!) if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { @@ -281,7 +280,7 @@ void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT // to provide an alternate.. if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4549 shift &= ~LCTRLFLAG; - // _s2 idee spanish keyboard has dk on altgr !! + // _s2 INFO idee spanish keyboard has dk on altgr !! // If the first group is not a matching-keys group, then we need to add into // each subgroup, otherwise just the match group @@ -460,8 +459,17 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg for (int i = 0;KMX_VKMap[i]; i++) { // I4651 // win goes via VK, Lin goes via SC + + KMX_WCHAR DeadKey1=0; + DeadKey=0; UINT scUnderlying = KMX_get_SCUnderlying_From_VKUS(KMX_VKMap[i]); KMX_WCHAR ch = KMX_get_CharUnderlying_From_SCUnderlying_GDK(keymap, VKShiftState[j], scUnderlying, &DeadKey); + KMX_WCHAR ch1 = KMX_get_CharUnderlying_From_SCUnderlying_GDK_NEW(keymap, VKShiftState[j], scUnderlying, &DeadKey1); + + if( ch!=ch1) + wprintf(L"IS DIFFERENT!!!! %i <--> %i\n", ch,ch1); + if( DeadKey!=DeadKey1) + wprintf(L"DDDDKKKK IS DIFFERENT!!!! %i <--> %i\n", DeadKey,DeadKey1); //wprintf(L"--- VK_%d -> SC_ [%c] dk=%d ( ss %i) \n", VKMap[i], ch == 0 ? 32 : ch, DeadKey, VKShiftState[j]); @@ -473,9 +481,9 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg switch(ch) { case 0x0000: break; - case 0xFFFF: // _S2 in kbd (=loaded from kmx-file): replace LCTRL+RALT -> Ctrl+Alt + write deadkey-> FFFF + CODE_DEADKEY + deadkey into context + case 0xFFFF: // _S2 INFO in kbd (=loaded from kmx-file): replace LCTRL+RALT -> Ctrl+Alt + write deadkey-> FFFF + CODE_DEADKEY + deadkey into context KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap , dk_Table); break; - default: // _S2 in kbd (=loaded from kmx-file): replace LCTRL+RALT -> Ctrl+Alt + switch keyvalues e.g. y<->z + default: // _S2 INFO in kbd (=loaded from kmx-file): replace LCTRL+RALT -> Ctrl+Alt + switch keyvalues e.g. y<->z KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); } } @@ -483,9 +491,8 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg KMX_ReportUnconvertedKeyboardRules(kbd); - // _S2 use translated kbd and write data to rgkey[] then add things to rgkey[] to enable to write to kmx-format - // _S2 use translated kbd and write data to rgkey[] then add things to rgkey[] to enable to write to kmx-format + // _S2 INFO use translated kbd and write data to rgkey[] then add things to rgkey[] to enable to write to kmx-format if(!KMX_ImportRules(kbd, All_Vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 return FALSE; } @@ -528,7 +535,7 @@ KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, UINT PKMX_WCHAR dky; int VKShiftState_lin = map_VKShiftState_to_Lin(VKShiftState); KMX_DWORD KeyvalOther = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,SC_OTHER, VKShiftState_lin, dky); - +// _S2 < or > if ((KeyvalOther >= deadkey_min) && (KeyvalOther >= deadkey_max)){ *DeadKey = *dky; return 0xFFFF; diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 946faacf5c..9da0aa92a4 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -42,6 +42,7 @@ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); +// _S2 why is this function not in keymap.cpp/h KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, UINT VKShiftState, UINT SC_OTHER, PKMX_WCHAR DeadKey); KMX_WCHAR KMX_get_VKUS_From_VKUnderlying_VEC(v_dw_3D All_Vector,KMX_DWORD SC_US); From cdeeec9e63f6ccc8d70267c7269080ce8522e57c Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 13 Feb 2024 12:55:18 +0100 Subject: [PATCH 196/327] feat(linux): res. conf mcompile-dk rename more functions --- linux/mcompile/keymap/deadkey.cpp | 10 +- linux/mcompile/keymap/keymap.cpp | 147 +++++----------------- linux/mcompile/keymap/keymap.h | 30 ++--- linux/mcompile/keymap/mc_import_rules.cpp | 8 +- linux/mcompile/keymap/mcompile.cpp | 41 ++---- linux/mcompile/keymap/mcompile.h | 5 +- 6 files changed, 67 insertions(+), 174 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 0164919a4a..3fd95103ff 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -3,9 +3,9 @@ v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult) { v_dw_1D line; - line.push_back(convertNamesToIntegerValue(first)); - line.push_back(convertNamesToIntegerValue(second)); - //line.push_back(convertNamesToIntegerValue(nameresult)); + line.push_back(convertNamesToDWORDValue(first)); + line.push_back(convertNamesToDWORDValue(second)); + //line.push_back(convertNamesToDWORDValue(nameresult)); line.push_back(number); return line; } @@ -414,8 +414,12 @@ void create_DKTable(v_dw_2D & dk_ComposeTable) { line = createLine(L"dead_circumflex", L"space", 0x005E, L"CIRCUMFLEX_ACCENT"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine(L"dead_acute", L"space", 0x0027, L"APOSTROPHE"); dk_ComposeTable.push_back(line); line.clear(); + /*line = createLine(L"dead_acute", L"space", 0x00B4, L"ACUTE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear();*/ + line = createLine(L"dead_grave", L"space", 0x0060, L"GRAVE_ACCENT"); dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_breve", L"space", 0x02D8, L"BREVE"); diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 8689682efe..88d1f0ec67 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -1,16 +1,17 @@ #include "keymap.h" #include +// unmodified, shift, RALT, shift+RALT -int map_VKShiftState_to_Lin(int VKShiftState) { +int map_VKShiftState_to_LinModifier(int VKShiftState) { if (VKShiftState == 0 ) return 0; /* 0000 0000 */ else if (VKShiftState == 16) return 1; /* 0001 0000 */ else if (VKShiftState == 9 ) return 2; /* 0000 1001 */ else if (VKShiftState == 25) return 3; /* 0001 1001 */ - else return VKShiftState; + else return VKShiftState; } -KMX_DWORD convertNamesToIntegerValue(std::wstring tok_wstr) { +KMX_DWORD convertNamesToDWORDValue(std::wstring tok_wstr) { // more on https://manpages.ubuntu.com/manpages/jammy/man3/keysyms.3tk.html std::map first; @@ -93,8 +94,8 @@ int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap) { } // add contents of other keyboard to All_Vector - if( append_other_ToVector(All_Vector,keymap)) { - wprintf(L"ERROR: can't append Other ToVector \n"); + if( append_underlying_ToVector(All_Vector,keymap)) { + wprintf(L"ERROR: can't append underlying ToVector \n"); return 2; } return 0; @@ -271,7 +272,7 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { for ( int i = 1; i< (int) tokens.size();i++) { // replace a name with a single character ( a -> a ; equal -> = ) - tokens_int = convertNamesToIntegerValue( wstring_from_string(tokens[i])); + tokens_int = convertNamesToDWORDValue( wstring_from_string(tokens[i])); tokens_dw.push_back(tokens_int); } @@ -304,16 +305,16 @@ v_dw_2D create_empty_2D_Vector( int dim_rows,int dim_ss) { return Vector_2D; } -int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { +int append_underlying_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { // create a 2D vector all filled with " " and push to 3D-Vector - v_dw_2D Other_Vector2D = create_empty_2D_Vector(All_Vector[0].size(),All_Vector[0][0].size()); + v_dw_2D underlying_Vector2D = create_empty_2D_Vector(All_Vector[0].size(),All_Vector[0][0].size()); - if (Other_Vector2D.size() == 0) { + if (underlying_Vector2D.size() == 0) { wprintf(L"ERROR: can't create empty 2D-Vector\n"); return 1; } - All_Vector.push_back(Other_Vector2D); + All_Vector.push_back(underlying_Vector2D); if (All_Vector.size() < 2) { wprintf(L"ERROR: creation of 3D-Vector failed\n"); @@ -322,10 +323,10 @@ int append_other_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { for(int i =0; i< (int) All_Vector[1].size();i++) { - // get key name US stored in [0][i][0] and copy to name in "other"-block[1][i][0] + // get key name US stored in [0][i][0] and copy to name in "underlying"-block[1][i][0] All_Vector[1][i][0] = All_Vector[0][i][0]; - // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] + // get Keyvals of this key and copy to unshifted/shifted in "underlying"-block[1][i][1] / block[1][i][2] All_Vector[1][i][0+1] = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,All_Vector[0][i][0],0); //shift state: unshifted:0 All_Vector[1][i][1+1] = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,All_Vector[0][i][0],1); //shift state: shifted:1 } @@ -362,8 +363,7 @@ bool IsKeymanUsedChar(int KV) { } - -std::wstring convert_DeadkeyValues_ToChar(int in) { +std::wstring convert_DeadkeyValues_ToWstr(int in) { KMX_DWORD lname; @@ -381,7 +381,7 @@ std::wstring convert_DeadkeyValues_ToChar(int in) { return std::wstring(1, in); } - lname = convertNamesToIntegerValue( wstring_from_string(long_name)); // 65106 => "dead_circumflex " => 94 => "^" + lname = convertNamesToDWORDValue( wstring_from_string(long_name)); // 65106 => "dead_circumflex " => 94 => "^" if (lname != returnIfCharInvalid) { return std::wstring(1, lname ); @@ -389,8 +389,7 @@ std::wstring convert_DeadkeyValues_ToChar(int in) { else return L"\0"; } -//_S2 REview and change?? -//_S2 REview and change?? +//_S2 ToDo REview and change?? std::u16string convert_DeadkeyValues_To_U16str(int in) { KMX_DWORD lname; @@ -409,7 +408,7 @@ std::u16string convert_DeadkeyValues_To_U16str(int in) { return CodePointToString_16(in-0x1000000); // it's a descriptive name like "dead_circumflex" - lname = convertNamesToIntegerValue( wstring_from_string(long_name)); // "dead_circumflex" => 94 => "^" + lname = convertNamesToDWORDValue( wstring_from_string(long_name)); // "dead_circumflex" => 94 => "^" if (lname != returnIfCharInvalid) { return std::u16string(1, lname ); @@ -420,6 +419,7 @@ std::u16string convert_DeadkeyValues_To_U16str(int in) { return u"\0"; } +// base function to get keyvals int KMX_get_keyvals_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps) { GdkModifierType consumed; @@ -507,7 +507,6 @@ int KMX_get_keyvals_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss return (int) *keyvals; } -// _S2 TODO KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky) { GdkKeymapKey *maps; guint *keyvals; @@ -523,44 +522,8 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap if (!(shift_state_pos <= count)) return 0; -// _S2 94 as variable/const - if (!(keycode <= 94)) - return 0; - // _S2 TODO take caps to this function - // _S2 TODO take caps to this function - // here I get all kvals: normal char , my Deadkeys, allothr DK - KMX_DWORD All_Keyvals = KMX_get_keyvals_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), 0); - if(( (All_Keyvals >= deadkey_min) && (All_Keyvals <= deadkey_max))) - deadkey = All_Keyvals; - - dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str(); - out = KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); - - g_free(keyvals); - g_free(maps); - - return out; -} - -// _S2 TODO -KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK_New(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky) { - GdkKeymapKey *maps; - guint *keyvals; - gint count; - KMX_DWORD out; - KMX_DWORD deadkey=0; - - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return 0; - //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html - - if (!(shift_state_pos <= count)) - return 0; -// _S2 94 as variable/const - if (!(keycode <= 94)) + if (!(keycode <= keycode_max)) return 0; // _S2 TODO take caps to this function @@ -568,23 +531,8 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK_New(GdkKeymap *ke KMX_DWORD All_Keyvals = KMX_get_keyvals_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), 0); if(( (All_Keyvals >= deadkey_min) && (All_Keyvals <= deadkey_max))) deadkey = All_Keyvals; - // _S2 check if naming is correct: does get_char... return a char or a string or a DWORD;...? + // _S2 TODO check if naming is correct: does get_char... return a char or a string or a DWORD;...? dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str(); -/* -// _S2 ToDo -KMX_DWORD KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ - - KMX_DWORD keyvals_dw= (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ss, caps); - - // _S2 AHA output for dk4-12 at the top after dk... from here - if((keyvals_dw >= deadkey_min) && (keyvals_dw <= deadkey_max)) // deadkeys - return 0xFFFF; - else if((keyvals_dw > deadkey_max) || ((keyvals_dw < deadkey_min) && ( keyvals_dw > 0xFF))) // out of range - return 0xFFFE; - else // usable char - return keyvals_dw; -} -*/ g_free(keyvals); g_free(maps); @@ -596,15 +544,6 @@ KMX_DWORD KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(Gdk return 0xFFFE; else // usable char return All_Keyvals; - - - - - - - //out = KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); - - } KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos) { @@ -619,10 +558,10 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap if (!(shift_state_pos <= count)) return 0; - if (!(keycode <= 94)) + if (!(keycode <= keycode_max)) return 0; - out = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); + out = KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); g_free(keyvals); g_free(maps); @@ -630,54 +569,34 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap return out; } -// _S2 ToDo -KMX_DWORD KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ - - KMX_DWORD keyvals_dw= (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ss, caps); +// _S2 same as KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK ?? +KMX_DWORD KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, UINT VKShiftState, UINT SC_underlying, PKMX_WCHAR DeadKey) { - // _S2 AHA output for dk4-12 at the top after dk... from here - if((keyvals_dw >= deadkey_min) && (keyvals_dw <= deadkey_max)) // deadkeys - if((keyvals_dw >= deadkey_min) && (keyvals_dw <= deadkey_max)) // deadkeys - return 0xFFFF; - else if((keyvals_dw > deadkey_max) || ((keyvals_dw < deadkey_min) && ( keyvals_dw > 0xFF))) // out of range - return 0xFFFE; - else // usable char - return keyvals_dw; -} -// _S2 remove term _other and use underlying instead -KMX_DWORD KMX_get_CharUnderlying_From_SCUnderlying_GDK_NEW(GdkKeymap *keymap, UINT VKShiftState, UINT SC_OTHER, PKMX_WCHAR DeadKey) { - //takes keymap, shift, scanCode - //fills ref deadkey - //returns character(KMX_DWORD) -PKMX_WCHAR dd; - KMX_DWORD keyvals_dw = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK_New(keymap, SC_OTHER, map_VKShiftState_to_Lin(VKShiftState), dd); + PKMX_WCHAR dky; + KMX_DWORD keyvals_dw = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap, SC_underlying, map_VKShiftState_to_LinModifier(VKShiftState), dky); - - - -// _S2 rename dd - if((keyvals_dw >= deadkey_min) && (keyvals_dw >= deadkey_max)) { - *DeadKey = *dd; + if(keyvals_dw >= deadkey_min) { + *DeadKey = *dky; return 0xFFFF; } else if((keyvals_dw > deadkey_max) || ((keyvals_dw < deadkey_min) && ( keyvals_dw > 0xFF))) // out of range return 0xFFFE; else // usable char return keyvals_dw; - } -KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ +// _S2 why dio I need this function after all?? +KMX_DWORD KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ return (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ss, caps); } -std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ +std::wstring KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ // _S2 QUESTION skip ss 2+3 remove?? int keyvals_int= KMX_get_keyvals_From_Keycode(keymap, keycode, ss, caps); - return convert_DeadkeyValues_ToChar(keyvals_int); + return convert_DeadkeyValues_ToWstr(keyvals_int); } // _S2 ToDo // _use gdk_keymap_translate_keyboard_state of other function @@ -728,7 +647,7 @@ KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS( KMX_DWORD VK_US) { KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector,KMX_DWORD KC_US, ShiftState ss, int caps) { KMX_DWORD Character; - std::wstring ws = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, KC_US, ss, caps); + std::wstring ws = KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, KC_US, ss, caps); Character = *ws.c_str(); //Find underlying SC of character diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 50455c0ddc..0a2c12f976 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -65,14 +65,15 @@ const KMX_DWORD KMX_VKMap[] = { }; static KMX_DWORD returnIfCharInvalid = 0; +static KMX_DWORD keycode_max =94; static KMX_DWORD deadkey_min = 0xfe50; static KMX_DWORD deadkey_max = 0xfe93; -int map_VKShiftState_to_Lin(int VKShiftState); +int map_VKShiftState_to_LinModifier(int VKShiftState); // takes a std::wstring (=contents of line symbols-file ) and returns the (int) value of the character -KMX_DWORD convertNamesToIntegerValue(std::wstring tok_wstr); +KMX_DWORD convertNamesToDWORDValue(std::wstring tok_wstr); // create a Vector with all entries of both keymaps+ keymap int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap); @@ -93,8 +94,8 @@ int split_US_To_3D_Vector(v_dw_3D &all_US, v_str_1D completeList); // create an empty 2D vector containing "--" in all fields v_dw_2D create_empty_2D_Vector(int dim_rows, int dim_shifts); -// append characters using GDK to 3D-Vector (Data for Other Language on [1][ ][ ] ) -int append_other_ToVector(v_dw_3D &All_Vector, GdkKeymap *keymap); +// append characters using GDK to 3D-Vector (Data for underlying Language on [1][ ][ ] ) +int append_underlying_ToVector(v_dw_3D &All_Vector, GdkKeymap *keymap); // initialize GDK bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); @@ -503,34 +504,27 @@ const UINT ScanCodeToUSVirtualKey[128] = { bool IsKeymanUsedChar(int KV); // take deadkey-value (e.g.65106) and return wstring (e.g. '^' ) -std::wstring convert_DeadkeyValues_ToChar(int in); +std::wstring convert_DeadkeyValues_ToWstr(int in); std::u16string convert_DeadkeyValues_To_U16str(int in); - - // uses gdk_keymap_translate_keyboard_state to get keyval int KMX_get_keyvals_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); -KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky); KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos); // returns KeySyms for a given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) -std::wstring KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); -KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); +std::wstring KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); +KMX_DWORD KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); -// _S2 TODO returns char or FFFF / FFFE ???? -KMX_DWORD KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); -KMX_DWORD KMX_get_CharUnderlying_From_SCUnderlying_GDK_NEW(GdkKeymap *keymap, UINT VKShiftState, UINT SC_OTHER, PKMX_WCHAR DeadKey); +KMX_DWORD KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, UINT VKShiftState, UINT SC_underlying, PKMX_WCHAR DeadKey); - - -// return the VirtualKey of the Other Keyboard for given Scancode using GDK +// return the VirtualKey of the underlying Keyboard for given Scancode using GDK KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD scanCode); -// return the Keycode of the Other Keyboard for given VK_US +// return the Keycode of the underlying Keyboard for given VK_US KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS( KMX_DWORD VK_US); -// return the Keycode of the Other Keyboard for given VK_US using GDK +// return the Keycode of the underlying Keyboard for given VK_US using GDK KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector,KMX_DWORD KC_US, ShiftState ss, int caps); // converts codePoint to wstring diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 6c588f0def..f0675ff31e 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -75,11 +75,11 @@ int KMX_ToUnicodeEx(guint keycode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, if (!(shift_state_pos <= count)) return 0; - if (!(keycode <= 94)) + if (!(keycode <= keycode_max)) return 0; - std::wstring character= KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, keycode, ShiftState(shift_state_pos), caps); - pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(character).c_str(); + std::wstring str= KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, keycode, ShiftState(shift_state_pos), caps); + pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(str).c_str(); KMX_DWORD keyvals_dw= (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), caps); @@ -561,7 +561,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, continue; } sbBuffer[rc] = 0; - //rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps==0)); + //rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps==0)); rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps)); //_S2 INFO } } diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index c3ea5678b2..a4b36557bd 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -226,7 +226,7 @@ void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { } void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { -// _S2 INFO this produces a different output due to different layouts for Lin<-> win ( foe the same language!!) +// _S2 INFO this produces a different output due to different layouts for Lin<-> win ( for the same language!!) if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { @@ -394,7 +394,7 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR d pd_S2=pdk; //pdd_S2=pdk; // Look up the ch - UINT vkUnderlying = KMX_get_VKUS_From_VKUnderlying_VEC(All_Vector, *pdk); + UINT vkUnderlying = KMX_get_CharUS_From_VKUnderlying_VEC(All_Vector, *pdk); KMX_TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); pdk+=3; @@ -425,7 +425,7 @@ KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]) { - KMX_WCHAR DeadKey; + KMX_WCHAR DeadKey=0; if(!KMX_SetKeyboardToPositional(kbd)) return FALSE; @@ -460,16 +460,8 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg // win goes via VK, Lin goes via SC - KMX_WCHAR DeadKey1=0; - DeadKey=0; UINT scUnderlying = KMX_get_SCUnderlying_From_VKUS(KMX_VKMap[i]); KMX_WCHAR ch = KMX_get_CharUnderlying_From_SCUnderlying_GDK(keymap, VKShiftState[j], scUnderlying, &DeadKey); - KMX_WCHAR ch1 = KMX_get_CharUnderlying_From_SCUnderlying_GDK_NEW(keymap, VKShiftState[j], scUnderlying, &DeadKey1); - - if( ch!=ch1) - wprintf(L"IS DIFFERENT!!!! %i <--> %i\n", ch,ch1); - if( DeadKey!=DeadKey1) - wprintf(L"DDDDKKKK IS DIFFERENT!!!! %i <--> %i\n", DeadKey,DeadKey1); //wprintf(L"--- VK_%d -> SC_ [%c] dk=%d ( ss %i) \n", VKMap[i], ch == 0 ? 32 : ch, DeadKey, VKShiftState[j]); @@ -509,38 +501,25 @@ void KMX_LogError(const KMX_WCHART* m1,int m2, LPKMX_KEY key) { } */ -// takes VK of US keyboard and returns SC of OTHER keyboard +// _S2 why are those not in keymap.cpp/h +// takes VK of US keyboard and returns SC of underlying keyboard UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS) { UINT SC_US = 8 + USVirtualKeyToScanCode[VirtualKeyUS]; - UINT SC_OTHER = SC_US; // not neccessary but to understand what we do - return SC_OTHER; + UINT SC_underlying = SC_US; // not neccessary but to understand what we do + return SC_underlying; } -KMX_WCHAR KMX_get_VKUS_From_VKUnderlying_VEC(v_dw_3D All_Vector, KMX_DWORD VK_OTHER) { +KMX_WCHAR KMX_get_CharUS_From_VKUnderlying_VEC(v_dw_3D All_Vector, KMX_DWORD VK_underlying) { KMX_DWORD VK_US; for( int i=0; i< (int)All_Vector[0].size()-1 ;i++) { for( int j=1; j< (int)All_Vector[0][0].size();j++) { - if ( ( All_Vector[0][i][j] == VK_OTHER ) ) { + if ( ( All_Vector[0][i][j] == VK_underlying ) ) { VK_US = All_Vector[1][i][j];; return VK_US; } } } - return VK_OTHER; -} - -// takes SC of underlying keyboard and returns character of underlying keyboard with shiftstate VKShiftState[j] or deadkey -KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, UINT VKShiftState, UINT SC_OTHER, PKMX_WCHAR DeadKey) { - - PKMX_WCHAR dky; - int VKShiftState_lin = map_VKShiftState_to_Lin(VKShiftState); - KMX_DWORD KeyvalOther = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,SC_OTHER, VKShiftState_lin, dky); -// _S2 < or > - if ((KeyvalOther >= deadkey_min) && (KeyvalOther >= deadkey_max)){ - *DeadKey = *dky; - return 0xFFFF; - } - return (KMX_WCHAR) KeyvalOther; + return VK_underlying; } int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap) { diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 9da0aa92a4..f7b631993b 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -42,10 +42,7 @@ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); -// _S2 why is this function not in keymap.cpp/h -KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, UINT VKShiftState, UINT SC_OTHER, PKMX_WCHAR DeadKey); - -KMX_WCHAR KMX_get_VKUS_From_VKUnderlying_VEC(v_dw_3D All_Vector,KMX_DWORD SC_US); +KMX_WCHAR KMX_get_CharUS_From_VKUnderlying_VEC(v_dw_3D All_Vector,KMX_DWORD SC_US); int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap); From 4aec162e495794b71824b69efd7c739621a774c0 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 13 Feb 2024 13:58:37 +0100 Subject: [PATCH 197/327] feat(linux): again resolve mcompile-dk rename even more functions --- linux/mcompile/keymap/keymap.cpp | 60 ++++++++++++++--------- linux/mcompile/keymap/keymap.h | 19 ++++--- linux/mcompile/keymap/mc_import_rules.cpp | 4 +- linux/mcompile/keymap/mcompile.cpp | 24 +-------- linux/mcompile/keymap/mcompile.h | 2 - 5 files changed, 51 insertions(+), 58 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 88d1f0ec67..a83cc3cfab 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -169,7 +169,7 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, s int replace_KeyName_with_Keycode(std::string in) { int out = returnIfCharInvalid; - // these are the Scancode-Values we use in Keyman (= windows scancodes+8 ) + // these are the keycode-Values we use in Keyman (= windows scancodes+8 ) if ( in == "key") out = 49; /* VK_ BKQUOTE */ else if ( in == "key") out = 10; /* VK_1 */ else if ( in == "key") out = 11; /* VK_2 */ @@ -327,8 +327,8 @@ int append_underlying_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { All_Vector[1][i][0] = All_Vector[0][i][0]; // get Keyvals of this key and copy to unshifted/shifted in "underlying"-block[1][i][1] / block[1][i][2] - All_Vector[1][i][0+1] = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,All_Vector[0][i][0],0); //shift state: unshifted:0 - All_Vector[1][i][1+1] = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,All_Vector[0][i][0],1); //shift state: shifted:1 + All_Vector[1][i][0+1] = KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(keymap,All_Vector[0][i][0],0); //shift state: unshifted:0 + All_Vector[1][i][1+1] = KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(keymap,All_Vector[0][i][0],1); //shift state: shifted:1 } return 0; @@ -419,8 +419,7 @@ std::u16string convert_DeadkeyValues_To_U16str(int in) { return u"\0"; } -// base function to get keyvals -int KMX_get_keyvals_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps) { +int KMX_get_keyval_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps) { GdkModifierType consumed; GdkKeymapKey *maps; @@ -507,7 +506,7 @@ int KMX_get_keyvals_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss return (int) *keyvals; } -KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky) { +KMX_DWORD KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky) { GdkKeymapKey *maps; guint *keyvals; gint count; @@ -528,10 +527,9 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap // _S2 TODO take caps to this function // here I get all kvals: normal char , my Deadkeys, allothr DK - KMX_DWORD All_Keyvals = KMX_get_keyvals_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), 0); + KMX_DWORD All_Keyvals = KMX_get_keyval_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), 0); if(( (All_Keyvals >= deadkey_min) && (All_Keyvals <= deadkey_max))) deadkey = All_Keyvals; - // _S2 TODO check if naming is correct: does get_char... return a char or a string or a DWORD;...? dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str(); g_free(keyvals); @@ -546,7 +544,7 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap return All_Keyvals; } -KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos) { +KMX_DWORD KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; guint *keyvals; gint count; @@ -561,7 +559,7 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap if (!(keycode <= keycode_max)) return 0; - out = KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); + out = (KMX_DWORD) KMX_get_keyval_From_Keycode(keymap, keycode, (ShiftState) shift_state_pos, 0); g_free(keyvals); g_free(maps); @@ -569,11 +567,11 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap return out; } -// _S2 same as KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK ?? +// _S2 same as KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK ?? KMX_DWORD KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, UINT VKShiftState, UINT SC_underlying, PKMX_WCHAR DeadKey) { PKMX_WCHAR dky; - KMX_DWORD keyvals_dw = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap, SC_underlying, map_VKShiftState_to_LinModifier(VKShiftState), dky); + KMX_DWORD keyvals_dw = KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(keymap, SC_underlying, map_VKShiftState_to_LinModifier(VKShiftState), dky); if(keyvals_dw >= deadkey_min) { *DeadKey = *dky; @@ -585,17 +583,13 @@ KMX_DWORD KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, UINT V return keyvals_dw; } -// _S2 why dio I need this function after all?? -KMX_DWORD KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ - - return (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ss, caps); -} - -std::wstring KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ +std::wstring KMX_get_WStrUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ // _S2 QUESTION skip ss 2+3 remove?? - - int keyvals_int= KMX_get_keyvals_From_Keycode(keymap, keycode, ss, caps); + /*if( (ss ==2 ) ||(ss ==3 )) + return L"\0";*/ + + int keyvals_int= KMX_get_keyval_From_Keycode(keymap, keycode, ss, caps); return convert_DeadkeyValues_ToWstr(keyvals_int); } @@ -647,10 +641,10 @@ KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS( KMX_DWORD VK_US) { KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector,KMX_DWORD KC_US, ShiftState ss, int caps) { KMX_DWORD Character; - std::wstring ws = KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, KC_US, ss, caps); + std::wstring ws = KMX_get_WStrUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, KC_US, ss, caps); Character = *ws.c_str(); - //Find underlying SC of character + //Find underlying KC of character for( int i=0; i< (int)All_Vector[1].size()-1 ;i++) { for( int j=1; j< (int)All_Vector[01][0].size();j++) { if ( ( All_Vector[1][i][j] == Character ) ) { @@ -662,6 +656,26 @@ KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3 return KC_US; } +UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS) { + UINT SC_US = 8 + USVirtualKeyToScanCode[VirtualKeyUS]; + UINT SC_underlying = SC_US; // not neccessary but to understand what we do + return SC_underlying; +} + +KMX_WCHAR KMX_get_CharUS_From_VKUnderlying_VEC(v_dw_3D All_Vector, KMX_DWORD VK_underlying) { + KMX_DWORD VK_US; + for( int i=0; i< (int)All_Vector[0].size()-1 ;i++) { + for( int j=1; j< (int)All_Vector[0][0].size();j++) { + if ( ( All_Vector[0][i][j] == VK_underlying ) ) { + VK_US = All_Vector[1][i][j];; + return VK_US; + } + } + } + return VK_underlying; +} + + std::wstring CodePointToWString(unsigned int codepoint) { std::wstring str; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 0a2c12f976..8f273f9c70 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -507,19 +507,18 @@ bool IsKeymanUsedChar(int KV); std::wstring convert_DeadkeyValues_ToWstr(int in); std::u16string convert_DeadkeyValues_To_U16str(int in); -// uses gdk_keymap_translate_keyboard_state to get keyval -int KMX_get_keyvals_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); +// use gdk_keymap_translate_keyboard_state to get keyval - base function to get keyvals +int KMX_get_keyval_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); -KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos); +KMX_DWORD KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos); -// returns KeySyms for a given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) -std::wstring KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); -KMX_DWORD KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); +// return KeySyms for a given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) +std::wstring KMX_get_WStrUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); KMX_DWORD KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, UINT VKShiftState, UINT SC_underlying, PKMX_WCHAR DeadKey); -// return the VirtualKey of the underlying Keyboard for given Scancode using GDK -KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD scanCode); +// return the VirtualKey of the underlying Keyboard for given Keyode using GDK +KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD keycode); // return the Keycode of the underlying Keyboard for given VK_US KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS( KMX_DWORD VK_US); @@ -527,6 +526,10 @@ KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS( KMX_DWORD VK_US); // return the Keycode of the underlying Keyboard for given VK_US using GDK KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector,KMX_DWORD KC_US, ShiftState ss, int caps); +UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); + +KMX_WCHAR KMX_get_CharUS_From_VKUnderlying_VEC(v_dw_3D All_Vector,KMX_DWORD SC_US); + // converts codePoint to wstring std::wstring CodePointToWString(unsigned int codepoint); std::u16string CodePointToString_16(unsigned int codepoint); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index f0675ff31e..5f153fcc08 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -78,10 +78,10 @@ int KMX_ToUnicodeEx(guint keycode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, if (!(keycode <= keycode_max)) return 0; - std::wstring str= KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, keycode, ShiftState(shift_state_pos), caps); + std::wstring str= KMX_get_WStrUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, keycode, ShiftState(shift_state_pos), caps); pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(str).c_str(); - KMX_DWORD keyvals_dw= (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), caps); + KMX_DWORD keyvals_dw= (KMX_DWORD) KMX_get_keyval_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), caps); g_free(keyvals); g_free(maps); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index a4b36557bd..246a96c230 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -458,7 +458,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg // Loop through each possible key on the keyboard for (int i = 0;KMX_VKMap[i]; i++) { // I4651 - // win goes via VK, Lin goes via SC + // win goes via VK, Lin goes via SC/Keycode UINT scUnderlying = KMX_get_SCUnderlying_From_VKUS(KMX_VKMap[i]); KMX_WCHAR ch = KMX_get_CharUnderlying_From_SCUnderlying_GDK(keymap, VKShiftState[j], scUnderlying, &DeadKey); @@ -500,28 +500,6 @@ void KMX_LogError(const KMX_WCHART* m1,int m2, LPKMX_KEY key) { wprintf((PWSTR)m1, m2); } */ - -// _S2 why are those not in keymap.cpp/h -// takes VK of US keyboard and returns SC of underlying keyboard -UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS) { - UINT SC_US = 8 + USVirtualKeyToScanCode[VirtualKeyUS]; - UINT SC_underlying = SC_US; // not neccessary but to understand what we do - return SC_underlying; -} - -KMX_WCHAR KMX_get_CharUS_From_VKUnderlying_VEC(v_dw_3D All_Vector, KMX_DWORD VK_underlying) { - KMX_DWORD VK_US; - for( int i=0; i< (int)All_Vector[0].size()-1 ;i++) { - for( int j=1; j< (int)All_Vector[0][0].size();j++) { - if ( ( All_Vector[0][i][j] == VK_underlying ) ) { - VK_US = All_Vector[1][i][j];; - return VK_US; - } - } - } - return VK_underlying; -} - int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap) { KMX_WORD *p = OutputPairs; diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index f7b631993b..7ae5a0d7b1 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -42,8 +42,6 @@ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); -KMX_WCHAR KMX_get_CharUS_From_VKUnderlying_VEC(v_dw_3D All_Vector,KMX_DWORD SC_US); - int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap); From 8e0f7ffbbbd6020c65643f7eaa460b8436f14110 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 13 Feb 2024 18:25:55 +0100 Subject: [PATCH 198/327] feat(linux): mcompile-dk more replacing,renaming solved con --- linux/mcompile/keymap/deadkey.cpp | 22 ++-- linux/mcompile/keymap/deadkey.h | 2 - linux/mcompile/keymap/keymap.cpp | 125 +++++++--------------- linux/mcompile/keymap/keymap.h | 23 ++-- linux/mcompile/keymap/mc_import_rules.cpp | 65 ++++------- linux/mcompile/keymap/mcompile.cpp | 12 +-- linux/mcompile/keymap/mcompile.h | 2 - 7 files changed, 78 insertions(+), 173 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 3fd95103ff..b0c29da0be 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -3,19 +3,17 @@ v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult) { v_dw_1D line; - line.push_back(convertNamesToDWORDValue(first)); - line.push_back(convertNamesToDWORDValue(second)); - //line.push_back(convertNamesToDWORDValue(nameresult)); + line.push_back(convertNamesTo_DWORD_Value(first)); + line.push_back(convertNamesTo_DWORD_Value(second)); + //line.push_back(convertNamesTo_DWORD_Value(nameresult)); line.push_back(number); return line; } bool find_dk_combinations_for_specific_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &dk_SingleTable, KMX_DWORD dk) { v_dw_1D line; + for ( int i =0; i< (int) (*p_dk_ComposeTable).size(); i++) { - // _S2 QUESTION is there a better way to find a-z,A-Z? - // _S2 QUESTION is there a better way to find a-z,A-Z? - //if (((*p_dk_ComposeTable)[i][0] == dk) ) { if (((*p_dk_ComposeTable)[i][0] == dk) && (IsKeymanUsedChar((*p_dk_ComposeTable)[i][1]))) { line.push_back((*p_dk_ComposeTable)[i][0]); line.push_back((*p_dk_ComposeTable)[i][1]); @@ -24,6 +22,7 @@ bool find_dk_combinations_for_specific_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D line.clear(); } } + if( dk_SingleTable.size()>0) return true; else @@ -38,7 +37,6 @@ std::vector create_alDead() { for( int i=0; i< dk_ComposeTable.size()-1; i++) { DeadKey *dk2= new DeadKey(dk_ComposeTable[i][0]); for ( int j=0; j< dk_ComposeTable.size();j++) { - // _S2 check for right basechar, to prevent "aAeEiIoOuU -ˆ_^" if(( dk_ComposeTable[i][0]==dk_ComposeTable[j][0]) && (IsKeymanUsedChar(dk_ComposeTable[j][1]))) dk2->KMX_AddDeadKeyRow(dk_ComposeTable[j][1],dk_ComposeTable[j][2]); } @@ -98,26 +96,22 @@ void sort_alDead(std::vector &small_Vec, std::vector *p_All_ small_Vec = small_sorted; } -// _S2 TODO might be used when deadkeys are implemented . is it correct?? -// _S2 TODO might be used when deadkeys are implemented . is it correct?? KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap) { guint Keyval = (guint) KVal; GdkKeymapKey* keys; gint n_keys; - // _S2 QUESTION can I assume that the win keyname is always the uppercase(level1) value?? - KMX_DWORD Name = (KMX_DWORD) gdk_keyval_to_upper (KVal); - //KMX_DWORD Name = (KMX_DWORD) gdk_keyval_to_lower (KVal); + KMX_DWORD Cap = (KMX_DWORD) gdk_keyval_to_upper (KVal); if( Keyval !=0) { gdk_keymap_get_entries_for_keyval(keymap, Keyval, &keys, &n_keys); for (int i = 0; i < n_keys; i++) { if (keys[i].group == 0) { shift = keys[i].level; - return Name; + return Cap; } } } - return Name; + return Cap; } // _S2 DESIGN NEEDED is this the right place to get dk from? if not wher are they stored? diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index 65cc74129b..f2ea3f81de 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -24,8 +24,6 @@ bool find_dk_combinations_for_specific_dk(v_dw_2D * dk_ComposeTable, v_dw_2D & d // gets the shifted character of a key KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap); -// _S2 probably not used -std::vector reduce_alDead(std::vector dk_big); // _S2 probably not used void sort_alDead(std::vector &myVec, std::vector *p_All_Vec); diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index a83cc3cfab..a86a4f722a 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -11,7 +11,7 @@ int map_VKShiftState_to_LinModifier(int VKShiftState) { else return VKShiftState; } -KMX_DWORD convertNamesToDWORDValue(std::wstring tok_wstr) { +KMX_DWORD convertNamesTo_DWORD_Value(std::wstring tok_wstr) { // more on https://manpages.ubuntu.com/manpages/jammy/man3/keysyms.3tk.html std::map first; @@ -272,7 +272,7 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { for ( int i = 1; i< (int) tokens.size();i++) { // replace a name with a single character ( a -> a ; equal -> = ) - tokens_int = convertNamesToDWORDValue( wstring_from_string(tokens[i])); + tokens_int = convertNamesTo_DWORD_Value( wstring_from_string(tokens[i])); tokens_dw.push_back(tokens_int); } @@ -305,7 +305,7 @@ v_dw_2D create_empty_2D_Vector( int dim_rows,int dim_ss) { return Vector_2D; } -int append_underlying_ToVector(v_dw_3D &All_Vector,GdkKeymap * keymap) { +int append_underlying_ToVector(v_dw_3D &All_Vector,GdkKeymap *keymap) { // create a 2D vector all filled with " " and push to 3D-Vector v_dw_2D underlying_Vector2D = create_empty_2D_Vector(All_Vector[0].size(),All_Vector[0][0].size()); @@ -353,7 +353,6 @@ bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]) { return 0; } - bool IsKeymanUsedChar(int KV) { // 32 A-Z a-z if ((KV == 0x20 ) || (KV >= 65 && KV <= 90) || (KV >= 97 && KV <= 122) ) @@ -362,61 +361,50 @@ bool IsKeymanUsedChar(int KV) { return false; } - std::wstring convert_DeadkeyValues_ToWstr(int in) { - KMX_DWORD lname; - if (in == 0 ) return L"\0"; - std::string long_name((const char*) gdk_keyval_name (in)); + std::string long_name((const char*) gdk_keyval_name (in)); // e.g. "dead_circumflex" , "U+017F" , "t" - if ( long_name.substr (0,2) == "U+" ) // U+... Unicode value + if ( long_name.substr (0,2) == "U+" ) // U+... Unicode value return CodePointToWString(in-0x1000000); - if (in < (int) deadkey_min) { // no deadkey; no Unicode - /*if (!IsKeymanUsedKeyVal(std::wstring(1, in))) - return L"\0";*/ + if (in < (int) deadkey_min) { // no deadkey; no Unicode return std::wstring(1, in); } - lname = convertNamesToDWORDValue( wstring_from_string(long_name)); // 65106 => "dead_circumflex " => 94 => "^" + KMX_DWORD lname = convertNamesTo_DWORD_Value( wstring_from_string(long_name)); // 65106 => "dead_circumflex" => 94 => "^" - if (lname != returnIfCharInvalid) { - return std::wstring(1, lname ); - } - else - return L"\0"; + if (lname != returnIfCharInvalid) { + return std::wstring(1, lname ); + } + else + return L"\0"; } -//_S2 ToDo REview and change?? + std::u16string convert_DeadkeyValues_To_U16str(int in) { - KMX_DWORD lname; + if (in == 0 ) + return u"\0"; - // it`s not a deadkey - if (in < (int) deadkey_min) { // no deadkey; no Unicode 97 => a - /*if (!IsKeymanUsedKeyVal(std::u16string(1, in))) - return u"\0";*/ + std::string long_name((const char*) gdk_keyval_name (in)); // e.g. "dead_circumflex" , "U+017F" , "t" + + if ( long_name.substr (0,2) == "U+" ) // U+... Unicode value + return CodePointToString_16(in-0x1000000); + + if (in < (int) deadkey_min) { // no deadkey; no Unicode return std::u16string(1, in); } - else { - std::string long_name((const char*) gdk_keyval_name (in)); - // it's Unicode - if ( long_name.substr (0,2) == "U+" ) // U+... Unicode value U+1E9E => ẞ - return CodePointToString_16(in-0x1000000); + KMX_DWORD lname = convertNamesTo_DWORD_Value( wstring_from_string(long_name)); // 65106 => "dead_circumflex" => 94 => "^" - // it's a descriptive name like "dead_circumflex" - lname = convertNamesToDWORDValue( wstring_from_string(long_name)); // "dead_circumflex" => 94 => "^" - - if (lname != returnIfCharInvalid) { - return std::u16string(1, lname ); - } - else - return u"\0"; + if (lname != returnIfCharInvalid) { + return std::u16string(1, lname ); } - return u"\0"; + else + return u"\0"; } int KMX_get_keyval_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps) { @@ -516,6 +504,7 @@ KMX_DWORD KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; + // _S2 INFO maybe later use something like //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html @@ -525,8 +514,6 @@ KMX_DWORD KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, if (!(keycode <= keycode_max)) return 0; - // _S2 TODO take caps to this function - // here I get all kvals: normal char , my Deadkeys, allothr DK KMX_DWORD All_Keyvals = KMX_get_keyval_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), 0); if(( (All_Keyvals >= deadkey_min) && (All_Keyvals <= deadkey_max))) deadkey = All_Keyvals; @@ -567,13 +554,12 @@ KMX_DWORD KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, return out; } -// _S2 same as KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK ?? -KMX_DWORD KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, UINT VKShiftState, UINT SC_underlying, PKMX_WCHAR DeadKey) { +KMX_DWORD KMX_get_CharUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, UINT VKShiftState, UINT KC_underlying, PKMX_WCHAR DeadKey) { PKMX_WCHAR dky; - KMX_DWORD keyvals_dw = KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(keymap, SC_underlying, map_VKShiftState_to_LinModifier(VKShiftState), dky); + KMX_DWORD keyvals_dw = KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(keymap, KC_underlying, map_VKShiftState_to_LinModifier(VKShiftState), dky); - if(keyvals_dw >= deadkey_min) { + if(keyvals_dw >= deadkey_min) { // deadkey *DeadKey = *dky; return 0xFFFF; } @@ -583,65 +569,29 @@ KMX_DWORD KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, UINT V return keyvals_dw; } -std::wstring KMX_get_WStrUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ - - // _S2 QUESTION skip ss 2+3 remove?? - /*if( (ss ==2 ) ||(ss ==3 )) - return L"\0";*/ - +std::wstring KMX_get_WStrUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ int keyvals_int= KMX_get_keyval_From_Keycode(keymap, keycode, ss, caps); - return convert_DeadkeyValues_ToWstr(keyvals_int); + return convert_DeadkeyValues_ToWstr(keyvals_int); } -// _S2 ToDo // _use gdk_keymap_translate_keyboard_state of other function KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { - - GdkModifierType consumed; GdkKeymapKey *maps; guint *keyvals; - guint lowerCase; - guint upperCase; gint count; if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - //Shift - GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); - - for (int i = 0; i < count; i++) { - if (maps[i].level > 1 || maps[i].group > 1) - continue; - - gchar * kv_name = gdk_keyval_name (keyvals[i]); - - if ( keyvals[i]>0) - gdk_keyval_convert_case (*kv_name, &lowerCase, &upperCase); - - // _S2 QUESTION is ( lowerCase == upperCase ) true for all number keys for all keyboards? - // _S2 QUESTION is ( lowerCase == upperCase ) true for all number keys for all keyboards? - if ( lowerCase == upperCase ) - return (KMX_DWORD) upperCase; -} - if ( keycode >7) return (KMX_DWORD) ScanCodeToUSVirtualKey[keycode-8]; return 0; } -KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS( KMX_DWORD VK_US) { - if( VK_US > 7) { - return (KMX_DWORD)(8+ USVirtualKeyToScanCode[ VK_US ]);} - else - return 0; -} - -KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector,KMX_DWORD KC_US, ShiftState ss, int caps) { +KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector, KMX_DWORD KC_US, ShiftState ss, int caps) { KMX_DWORD Character; - std::wstring ws = KMX_get_WStrUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, KC_US, ss, caps); + std::wstring ws = KMX_get_WStrUnderlying_From_KeyCodeUnderlying_GDK(keymap, KC_US, ss, caps); Character = *ws.c_str(); //Find underlying KC of character @@ -656,10 +606,8 @@ KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3 return KC_US; } -UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS) { - UINT SC_US = 8 + USVirtualKeyToScanCode[VirtualKeyUS]; - UINT SC_underlying = SC_US; // not neccessary but to understand what we do - return SC_underlying; +UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS) { + return (8 + USVirtualKeyToScanCode[VirtualKeyUS]); } KMX_WCHAR KMX_get_CharUS_From_VKUnderlying_VEC(v_dw_3D All_Vector, KMX_DWORD VK_underlying) { @@ -675,7 +623,6 @@ KMX_WCHAR KMX_get_CharUS_From_VKUnderlying_VEC(v_dw_3D All_Vector, KMX_DWORD VK_ return VK_underlying; } - std::wstring CodePointToWString(unsigned int codepoint) { std::wstring str; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 8f273f9c70..e2736d3b54 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -66,18 +66,16 @@ const KMX_DWORD KMX_VKMap[] = { static KMX_DWORD returnIfCharInvalid = 0; static KMX_DWORD keycode_max =94; - static KMX_DWORD deadkey_min = 0xfe50; static KMX_DWORD deadkey_max = 0xfe93; int map_VKShiftState_to_LinModifier(int VKShiftState); // takes a std::wstring (=contents of line symbols-file ) and returns the (int) value of the character -KMX_DWORD convertNamesToDWORDValue(std::wstring tok_wstr); +KMX_DWORD convertNamesTo_DWORD_Value(std::wstring tok_wstr); // create a Vector with all entries of both keymaps+ keymap int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap); -//int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector); // read configuration file, split and write to 3D-Vector (Data for US on [0][ ][ ] ) int write_US_ToVector(v_dw_3D &vec, std::string language, const char *text); @@ -502,6 +500,7 @@ const UINT ScanCodeToUSVirtualKey[128] = { }; bool IsKeymanUsedChar(int KV); +//------------------------------ // take deadkey-value (e.g.65106) and return wstring (e.g. '^' ) std::wstring convert_DeadkeyValues_ToWstr(int in); @@ -510,25 +509,25 @@ std::u16string convert_DeadkeyValues_To_U16str(int in); // use gdk_keymap_translate_keyboard_state to get keyval - base function to get keyvals int KMX_get_keyval_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); +KMX_DWORD KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky); + KMX_DWORD KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos); +KMX_DWORD KMX_get_CharUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, UINT VKShiftState, UINT KC_underlying, PKMX_WCHAR DeadKey); + // return KeySyms for a given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) -std::wstring KMX_get_WStrUnderlying_according_to_keycode_and_Shiftstate_GDK(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); +std::wstring KMX_get_WStrUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); -KMX_DWORD KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, UINT VKShiftState, UINT SC_underlying, PKMX_WCHAR DeadKey); - -// return the VirtualKey of the underlying Keyboard for given Keyode using GDK +// return the VirtualKey of the underlying Keyboard for a given Keyode using GDK KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD keycode); -// return the Keycode of the underlying Keyboard for given VK_US -KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS( KMX_DWORD VK_US); - // return the Keycode of the underlying Keyboard for given VK_US using GDK KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector,KMX_DWORD KC_US, ShiftState ss, int caps); -UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); +// return the Keycode of the underlying Keyboard for given VK_US +UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); -KMX_WCHAR KMX_get_CharUS_From_VKUnderlying_VEC(v_dw_3D All_Vector,KMX_DWORD SC_US); +KMX_WCHAR KMX_get_CharUS_From_VKUnderlying_VEC(v_dw_3D All_Vector,KMX_DWORD VK_underlying); // converts codePoint to wstring std::wstring CodePointToWString(unsigned int codepoint); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 5f153fcc08..f508c5591c 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -78,7 +78,7 @@ int KMX_ToUnicodeEx(guint keycode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, if (!(keycode <= keycode_max)) return 0; - std::wstring str= KMX_get_WStrUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, keycode, ShiftState(shift_state_pos), caps); + std::wstring str= KMX_get_WStrUnderlying_From_KeyCodeUnderlying_GDK(keymap, keycode, ShiftState(shift_state_pos), caps); pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(str).c_str(); KMX_DWORD keyvals_dw= (KMX_DWORD) KMX_get_keyval_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), caps); @@ -121,12 +121,10 @@ private: public: KMX_VirtualKey(KMX_HKL hkl,UINT virtualKey, GdkKeymap **keymap) { - this->m_sc=KMX_get_SCUnderlying_From_VKUS(virtualKey); + this->m_sc = KMX_get_KeyCodeUnderlying_From_VKUS(virtualKey); this->m_hkl = hkl; this->m_vk = virtualKey; - // _S2 TODO deadkey - // _S2 TODO deadkey - // memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); + memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); } //_S2 ToDo keymap* or keymap** @@ -134,8 +132,7 @@ public: this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying_GDK(*keymap, scanCode); this->m_hkl = hkl; this->m_sc = scanCode; - //KMX_InitializeDeadkeys(); // _S2 to get all 0 in rgfDeadkey[ ][ ]- why were there numbers??? - // _S2 originally initioalized with memse ( see above=) + memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); } UINT VK() { @@ -145,6 +142,7 @@ public: UINT SC() { return this->m_sc; } + // _S2 can go later std::wstring get_m_rgss(int i,int j) { return m_rgss[i][j]; @@ -154,15 +152,6 @@ public: return m_rgfDeadKey[i][j]; } - // _S2 do we need this?? - void KMX_InitializeDeadkeys() { - for ( int i=0; i<10;i++) { - for ( int j=0; j<2;j++) { - this->m_rgfDeadKey[i][j] = 0; - } - } - } - std::wstring KMX_GetShiftState(ShiftState shiftState, bool capsLock) { return this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)]; } @@ -172,8 +161,6 @@ public: this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; } -// _S2 QUESTION why are there sometimes numbers in m_rgfDeadKey??? -// _S2 QUESTION why are there sometimes numbers in m_rgfDeadKey??? void KMX_SetShiftState(ShiftState shiftState, std::u16string value16, bool isDeadKey, bool capsLock) { std::wstring value = wstring_from_u16string(value16); this->m_rgfDeadKey[(UINT)shiftState][(capsLock ? 1 : 0)] = isDeadKey; @@ -285,11 +272,11 @@ public: return nkeys; } - bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,v_dw_3D &All_Vector, GdkKeymap * keymap) { // I4552 + bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,v_dw_3D &All_Vector, GdkKeymap *keymap) { // I4552 // Get the CAPSLOCK value // _S2 needs to go later // this should be true for char, number, special -bool b1= this->KMX_IsCapsEqualToShift(); // but is false for numbers and special +/*bool b1= this->KMX_IsCapsEqualToShift(); // but is false for numbers and special bool b2= this->KMX_IsSGCAPS(); bool b3= this->KMX_IsAltGrCapsEqualToAltGrShift(); bool b4= this->KMX_IsXxxxGrCapsEqualToXxxxShift(); @@ -297,7 +284,7 @@ bool b4= this->KMX_IsXxxxGrCapsEqualToXxxxShift(); int i1 = this->KMX_IsCapsEqualToShift() ? 1 : 0; int i2 = this->KMX_IsSGCAPS() ? 2 : 0; int i3 = this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0; -int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; +int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0;*/ int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | @@ -306,8 +293,9 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); // _S2 DESIGN NEEDED on how to replace capslock - capslock=1; // _S2 - // _S2 TODO capslock is not calculated correctly for linux. therefore key->ShiftFlags will be wrong for numbers, special characters + // capslock has different values for linux. Therefore key->ShiftFlags will be different for numbers, special characters + // for now set capslock=1 + capslock=1; for (int ss = 0; ss <= MaxShiftState; ss++) { if (ss == Menu || ss == ShftMenu) { @@ -357,8 +345,8 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; // key->Key stores VK-US ( not underlying !!) // key->dpOutput stores character Underlying - KMX_DWORD SC_Underlying_gdk = KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(keymap, All_Vector,this->SC(), (ShiftState) ss, caps); - key->Key = KMX_get_VKUS_From_KeyCodeUnderlying_GDK( keymap, SC_Underlying_gdk); + KMX_DWORD SC_Underlying = KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(keymap, All_Vector, this->SC(), (ShiftState) ss, caps); + key->Key = KMX_get_VKUS_From_KeyCodeUnderlying_GDK( keymap, SC_Underlying); key->Line = 0; key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); @@ -448,9 +436,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector rgKey; //= new VirtualKey[256]; std::vector alDead; - //_S2 TODO remove alDead2 - std::vector alDead2 ; - std::vector alDead_cpl = create_alDead(); + std::vector alDead_cpl = create_alDead(); rgKey.resize(256); @@ -521,19 +507,20 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, continue; } - //_S2 to compare win-lin kmn-files skip ss6+7; MUST BE restored/removed later!!!! + //_S2 to compare win-lin kmn-files skip ss6+7; MUST BE removed later!!!! /*if(ss == MenuCtrl|| ss == ShftMenuCtrl) { continue; }*/ - KMX_DWORD SC_US = KMX_get_KeyCodeUnderlying_From_VKUS(iKey); + KMX_DWORD KC_US = (KMX_DWORD) KMX_get_KeyCodeUnderlying_From_VKUS(iKey); + // _S2 TODO deadkey not finished; Ctrl, Shft +40 not tested // _S2 TODO deadkey not finished; Ctrl, Shft +40 not tested for(int caps = 0; caps <= 1; caps++) { loader.KMX_ClearKeyboardBuffer(); loader.KMX_FillKeyState(lpKeyState, ss, (caps == 0)); - int rc = KMX_ToUnicodeEx(SC_US, lpKeyState, sbBuffer, ss, caps, *keymap); + int rc = KMX_ToUnicodeEx(KC_US, lpKeyState, sbBuffer, ss, caps, *keymap); if(rc > 0) { if(*sbBuffer == 0) { @@ -573,26 +560,14 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // It's a dead key; let's flush out whats stored in the keyboard state. loader.KMX_ClearKeyboardBuffer(); DeadKey *dk = NULL; - refine_alDead(sbBuffer[0], alDead, &alDead_cpl); - /* for(UINT iDead = 0; iDead < alDead.size(); iDead++) { - dk = alDead[iDead]; - if(dk->KMX_DeadCharacter() == rgKey[iKey]->KMX_GetShiftState(ss, caps == 0)[0]) { - break; - } - dk = NULL; - } - if(dk == NULL) { - //alDead.push_back(loader.KMX_ProcessDeadKey(iKey, ss, lpKeyState, rgKey, caps == 0, hkl, *keymap)); - alDead2 = create_alDead(); - alDead = reduce_alDead(alDead2); - }*/ + refine_alDead(sbBuffer[0], alDead, &alDead_cpl); } } } } } - // do we need to sort alDead?? + // _S2 DESIGN NEEDED do we need to sort alDead? And if so how? sort_alDead(alDead, &alDead_cpl); //------------------------------------------------------------- diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 246a96c230..da42e17a46 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -149,12 +149,6 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ // Map of all shift states that we will work with const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; -// _S2 INFO my comment for Lin version -// Ubuntu: Each of the 4 columns specifies a different modifier: unmodified, shift, right alt (altgr), shift+right alt(altgr) -// we have assigned these to columns 1-4 ( column o holds the keycode) -// const UINT VKShiftState[] = {0, 1, 2, 3, 0xFFFF}; -// const UINT VKShiftState[] = {0, 1, 2, 3, 0xFFFF}; - // // TranslateKey // @@ -435,7 +429,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg // evident for the 102nd key on UK, for example, where \ can be generated with VK_OEM_102 or AltGr+VK_QUOTE. // For now, we get the least shifted version, which is hopefully adequate. - // _S2 TODO first version with GTK - maybe change later to XklGetGroupNames und XklGetCurrentState as Eberhard suggested + // _S2 INFO first version with GTK - maybe change later to XklGetGroupNames und XklGetCurrentState as Eberhard suggested //_ init gdk GdkKeymap *keymap; if(InitializeGDK(&keymap , argc, argv)) { @@ -460,8 +454,8 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg // win goes via VK, Lin goes via SC/Keycode - UINT scUnderlying = KMX_get_SCUnderlying_From_VKUS(KMX_VKMap[i]); - KMX_WCHAR ch = KMX_get_CharUnderlying_From_SCUnderlying_GDK(keymap, VKShiftState[j], scUnderlying, &DeadKey); + UINT scUnderlying = KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]); + KMX_WCHAR ch = KMX_get_CharUnderlying_From_KeyCodeUnderlying_GDK(keymap, VKShiftState[j], scUnderlying, &DeadKey); //wprintf(L"--- VK_%d -> SC_ [%c] dk=%d ( ss %i) \n", VKMap[i], ch == 0 ? 32 : ch, DeadKey, VKShiftState[j]); diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 7ae5a0d7b1..88fa129d0f 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -40,8 +40,6 @@ int run(int argc, std::vector str_argv, char* argv[]); PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); -UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); - int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap); From beaa25047e8c2437b37bf3ee307a61bb5850eaa8 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 14 Feb 2024 12:25:58 +0100 Subject: [PATCH 199/327] feat(linux): mcompile-dk remove dublicate lines after rebasing --- linux/mcompile/keymap/mc_import_rules.cpp | 1 - linux/mcompile/keymap/mcompile.cpp | 3 --- 2 files changed, 4 deletions(-) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index f508c5591c..c3153f55c9 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -111,7 +111,6 @@ int KMX_DeadKeyMap(int index, std::vector *deadkeys, int deadkeyBase, class KMX_VirtualKey { private: - KMX_HKL m_hkl; // _S2 QUESTION do I need this and is void* OK to assume? If I remove this, will there be changes in Data-Vectors? KMX_HKL m_hkl; // _S2 QUESTION do I need this and is void* OK to assume? If I remove this, will there be changes in Data-Vectors? UINT m_vk; UINT m_sc; diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index da42e17a46..6c6a997a1f 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -385,14 +385,11 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR d KMX_GetDeadkeys(dk_Table, deadkey, pdk = deadkeys, keymap); // returns array of [usvk, ch_out] pairs while(*pdk) { -pd_S2=pdk; -//pdd_S2=pdk; // Look up the ch UINT vkUnderlying = KMX_get_CharUS_From_VKUnderlying_VEC(All_Vector, *pdk); KMX_TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); pdk+=3; - pd_S2+=3; } } From 3662839708f643d15159cbd8eb76832080e20964 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 14 Feb 2024 12:45:55 +0100 Subject: [PATCH 200/327] feat(linux): mcompile-dk check warnings --- linux/mcompile/keymap/deadkey.cpp | 16 ++++++++-------- linux/mcompile/keymap/deadkey.h | 1 + linux/mcompile/keymap/keymap.cpp | 5 ++--- linux/mcompile/keymap/mc_import_rules.cpp | 8 +------- linux/mcompile/keymap/mcompile.cpp | 8 -------- 5 files changed, 12 insertions(+), 26 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index b0c29da0be..14e453aab5 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -34,9 +34,9 @@ std::vector create_alDead() { v_dw_2D dk_ComposeTable; create_DKTable(dk_ComposeTable); - for( int i=0; i< dk_ComposeTable.size()-1; i++) { + for( int i=0; i< (int) dk_ComposeTable.size()-1; i++) { DeadKey *dk2= new DeadKey(dk_ComposeTable[i][0]); - for ( int j=0; j< dk_ComposeTable.size();j++) { + for ( int j=0; j< (int) dk_ComposeTable.size();j++) { if(( dk_ComposeTable[i][0]==dk_ComposeTable[j][0]) && (IsKeymanUsedChar(dk_ComposeTable[j][1]))) dk2->KMX_AddDeadKeyRow(dk_ComposeTable[j][1],dk_ComposeTable[j][2]); } @@ -53,7 +53,7 @@ bool found_dk_inVector(KMX_WCHAR dk, std::vector &dkVec) { if( dk == dkVec[i]->KMX_GetDeadCharacter()) return true; i++; - } while (i < dkVec.size()); + } while (i < (int) dkVec.size()); } return false; } @@ -62,7 +62,7 @@ void refine_alDead(KMX_WCHAR dk, std::vector &dkVec, std::vectorKMX_GetDeadCharacter()) { if(! found_dk_inVector(dk, dkVec)) { dkVec.push_back((*p_All_Vec)[j]); @@ -77,10 +77,10 @@ void sort_alDead(std::vector &small_Vec, std::vector *p_All_ std::vector small_sorted; int Vsmall_size; - int i=0; + int i = 0; do { - int j=0; + int j = 0; Vsmall_size= small_Vec.size(); do { @@ -90,9 +90,9 @@ void sort_alDead(std::vector &small_Vec, std::vector *p_All_ Vsmall_size--; } j++; - } while (j< Vsmall_size); + } while (j < Vsmall_size); i++; - } while ((i< (*p_All_Vec).size()) && (Vsmall_size>0)); + } while ((i < (int) (*p_All_Vec).size()) && (Vsmall_size>0)); small_Vec = small_sorted; } diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index f2ea3f81de..adf26b404e 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -6,6 +6,7 @@ #include #include "mc_import_rules.h" + // creates a vector for a dk combination ( ` + a -> à ) v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult); diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index a86a4f722a..21a17f2dc6 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -1,8 +1,8 @@ #include "keymap.h" #include -// unmodified, shift, RALT, shift+RALT +// unmodified, shift, RALT, shift+RALT int map_VKShiftState_to_LinModifier(int VKShiftState) { if (VKShiftState == 0 ) return 0; /* 0000 0000 */ else if (VKShiftState == 16) return 1; /* 0001 0000 */ @@ -498,7 +498,6 @@ KMX_DWORD KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, GdkKeymapKey *maps; guint *keyvals; gint count; - KMX_DWORD out; KMX_DWORD deadkey=0; @@ -541,7 +540,7 @@ KMX_DWORD KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, return 0; if (!(shift_state_pos <= count)) - return 0; + return 0; if (!(keycode <= keycode_max)) return 0; diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index c3153f55c9..c3fdbd31e7 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -19,7 +19,6 @@ 06 Feb 2015 - mcdurdin - I4552 - V9.0 - Add mnemonic recompile option to ignore deadkeys */ - #include #include #include @@ -67,7 +66,6 @@ int KMX_ToUnicodeEx(guint keycode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, GdkKeymapKey *maps; guint *keyvals; gint count; - KMX_DWORD out; if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; @@ -75,7 +73,7 @@ int KMX_ToUnicodeEx(guint keycode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, if (!(shift_state_pos <= count)) return 0; - if (!(keycode <= keycode_max)) + if (!(keycode <= keycode_max)) return 0; std::wstring str= KMX_get_WStrUnderlying_From_KeyCodeUnderlying_GDK(keymap, keycode, ShiftState(shift_state_pos), caps); @@ -558,8 +556,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // It's a dead key; let's flush out whats stored in the keyboard state. loader.KMX_ClearKeyboardBuffer(); - DeadKey *dk = NULL; - refine_alDead(sbBuffer[0], alDead, &alDead_cpl); } } @@ -640,7 +636,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, for(UINT i = 0; i < kp->cxGroupArray - 1; i++, gp2++) { if(gp2->fUsingKeys && gp2->dpNoMatch == NULL) { KMX_WCHAR *p = gp2->dpNoMatch = new KMX_WCHAR[4]; - KMX_WCHAR *q = p; *p++ = UC_SENTINEL; *p++ = CODE_USE; *p++ = (KMX_WCHAR)(kp->cxGroupArray); @@ -666,7 +661,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, kkp2->ShiftFlags = kkp->ShiftFlags; kkp2->Line = 0; KMX_WCHAR *p = kkp2->dpOutput = new KMX_WCHAR[4]; - KMX_WCHAR *q=p; *p++ = UC_SENTINEL; *p++ = CODE_USE; *p++ = (KMX_WCHAR)(kp->cxGroupArray); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 6c6a997a1f..90aab8126b 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -22,13 +22,6 @@ 06 Feb 2015 - mcdurdin - I4552 - V9.0 - Add mnemonic recompile option to ignore deadkeys 08 Apr 2015 - mcdurdin - I4651 - V9.0 - Mnemonic layout recompiler maps AltGr+VK_BKSLASH rather than VK_OEM_102 */ -//_S2 INFO -// in /Projects/keyman/keyman/linux/mcompile/keymap/build_mcompile -// run with: -//./mcompile -d in.kmx bla.dll 0407 out.kmx -//./mcompile -d /Projects/keyman/keyman/linux/mcompile/keymap/anii.kmx bla.dll 0407 /Projects/keyman/keyman/linux/mcompile/keymap/anii_out.kmx -//./mcompile -d /Projects/keyman/keyman/linux/mcompile/keymap/sil_ipa_o.kmx bla.dll 0407 /Projects/keyman/keyman/linux/mcompile/keymap/sil_ipa_o_out2.kmx -//./mcompile -d /Projects/keyman/keyman/linux/mcompile/keymap/mcompile_test.kmx bla.dll 0407 /Projects/keyman/keyman/linux/mcompile/keymap/mcompile_test_out.kmx #include "mcompile.h" @@ -244,7 +237,6 @@ void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT PKMX_WCHAR context = new KMX_WCHAR[len + 4]; memcpy(context, key->dpContext, len * sizeof(KMX_WCHAR)); - PKMX_WCHAR PP = context; context[len] = UC_SENTINEL; context[len+1] = CODE_DEADKEY; context[len+2] = deadkey; From 3211a0c31af5de779f928a4668369778ea477d0a Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 14 Feb 2024 14:33:44 +0100 Subject: [PATCH 201/327] feat(linux): mcompile-dk gerneral tidy up --- linux/mcompile/keymap/README.md | 33 ++++++---------------- linux/mcompile/keymap/deadkey.h | 2 +- linux/mcompile/keymap/keymap.cpp | 4 +-- linux/mcompile/keymap/keymap.h | 2 +- linux/mcompile/keymap/km_types.h | 5 ++-- linux/mcompile/keymap/mc_import_rules.cpp | 34 ++++++++++++++--------- linux/mcompile/keymap/mc_kmxfile.cpp | 2 +- linux/mcompile/keymap/mcompile.cpp | 3 ++ 8 files changed, 40 insertions(+), 45 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index f695fa0fd8..9f2a624f67 100755 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -6,30 +6,15 @@ Sample program that reads US basic keyboard and compares to key value group # Keymap -TODO check if US basic is the right Keyboard to compare with -TODO deadkeys don't work yet -TODO path for xkb/symbols as compile time option in meson -TODO define folder to store File_US.txt" in and find better name -TODO check if I can use files from some other keyman path instead of a copy in keymap ( e.g. filesystem.h exists elsewhere) -TODO shiftstate-count -TODO keymap SplitToV.cpp exchange 4 with genaerated shiftcount -TODO shift-statevector -TODO Do I need HKL for Linux / can I just use a void* or remove HKL ?? -TODO typeddef of KMX_HKL - can I delete all m_hkl from classes? -TODO check if passed All_Vectpor as ptr/ref not as value e.g. in KMX_CharFromVK, KMX_VKUSToVKUnderlyingLayout, KMX_ImportRules -ToDo in get_VirtualKey_Other_From_SC: what if we use column 3(altgr) and 4 (shift+altgr) ?? -TODO where to store VK_CANCEL.... in km_types.h or elsewhere? -ToDo check up to 8 shiftstates ( find symbols-file with 8) -ToDo use _free(keyvals); g_free(maps); -ToDo use u16string OR wstring-functions only and remove the other - -TODO next: - - check if I use char16_t everywhere instead of wchar_t or char - - Check/find use of wchar_t/wstring and replace with char16_t/u16string - - replace GDK - - what is wrong with kp->dpBitmapOffset/BitmapSize ? - - check call by reference/value -TODO ... +_S2 TODO QUESTION check if US basic is the right Keyboard to compare with +_S2 TODO check if I can use files from some other keyman path instead of a copy here ( e.g. filesystem.h exists elsewhere); where can I use incxstr from +_S2 TODO Do I need HKL for Linux / can I just use a void* or remove HKL ??, typeddef of KMX_HKL - can I delete all m_hkl from classes? +_S2 TODO Check/find use of wchar_t/wstring and replace with char16_t/u16string +_S2 TODO TODO keymap* or keymap** everywhere? +_S2 TODO check call by reference/value +_S2 TODO replace GDK +_S2 TODO what is wrong with kp->dpBitmapOffset/BitmapSize ? +_S2 ... ./mcompile -d /Projects/keyman/keyman/linux/mcompile/keymap/mcompile_test.kmx bla.dll 0407 /Projects/keyman/keyman/linux/mcompile/keymap/mcompile_test_out.kmx diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index adf26b404e..303f1b56b3 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -25,7 +25,7 @@ bool find_dk_combinations_for_specific_dk(v_dw_2D * dk_ComposeTable, v_dw_2D & d // gets the shifted character of a key KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap); -// _S2 probably not used +// _S2 TODO probably not used void sort_alDead(std::vector &myVec, std::vector *p_All_Vec); # endif /*DEADKEY_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 21a17f2dc6..bacd8ca35d 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -567,7 +567,7 @@ KMX_DWORD KMX_get_CharUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, U else // usable char return keyvals_dw; } - +// _S2 do we need this func std::wstring KMX_get_WStrUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ int keyvals_int= KMX_get_keyval_From_Keycode(keymap, keycode, ss, caps); return convert_DeadkeyValues_ToWstr(keyvals_int); @@ -609,7 +609,7 @@ UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS) { return (8 + USVirtualKeyToScanCode[VirtualKeyUS]); } -KMX_WCHAR KMX_get_CharUS_From_VKUnderlying_VEC(v_dw_3D All_Vector, KMX_DWORD VK_underlying) { +KMX_WCHAR KMX_get_CharUS_From_VKUnderlying_VEC(v_dw_3D & All_Vector, KMX_DWORD VK_underlying) { KMX_DWORD VK_US; for( int i=0; i< (int)All_Vector[0].size()-1 ;i++) { for( int j=1; j< (int)All_Vector[0][0].size();j++) { diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index e2736d3b54..64fde3331b 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -527,7 +527,7 @@ KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3 // return the Keycode of the underlying Keyboard for given VK_US UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); -KMX_WCHAR KMX_get_CharUS_From_VKUnderlying_VEC(v_dw_3D All_Vector,KMX_DWORD VK_underlying); +KMX_WCHAR KMX_get_CharUS_From_VKUnderlying_VEC(v_dw_3D &All_Vector,KMX_DWORD VK_underlying); // converts codePoint to wstring std::wstring CodePointToWString(unsigned int codepoint); diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index 686d68c5f3..9ea50d381e 100755 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -36,7 +36,6 @@ typedef uint16_t km_kbp_cp; // code point typedef uint32_t km_kbp_usv; // Unicode Scalar Value #endif -// _S2 TODO which can be removed later? typedef unsigned int UINT; typedef unsigned long DWORD; @@ -122,7 +121,7 @@ typedef KMX_UCHAR* KMX_PUCHAR; #define VK_CANCEL 0x09 #define VK_DECIMAL 0x5B*/ -// _S2 correct?? ?? +// _S2 TODO correct?? ?? #define VK_NUMPAD0 0x60 #define VK_NUMPAD1 0x61 #define VK_NUMPAD2 0x62 @@ -135,7 +134,7 @@ typedef KMX_UCHAR* KMX_PUCHAR; #define VK_NUMPAD9 0x69 -// _S2 correct?? ?? +// _S2 TODO correct?? ?? /*#define VK_NUMPAD0 0x2D #define VK_NUMPAD1 0x23 #define VK_NUMPAD2 0x28 diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index c3fdbd31e7..a9ebb0aaed 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -123,7 +123,6 @@ public: this->m_vk = virtualKey; memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); } -//_S2 ToDo keymap* or keymap** KMX_VirtualKey(UINT scanCode, KMX_HKL hkl, GdkKeymap **keymap) { this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying_GDK(*keymap, scanCode); @@ -140,11 +139,11 @@ public: return this->m_sc; } - // _S2 can go later + // _S2 TODO can go later std::wstring get_m_rgss(int i,int j) { return m_rgss[i][j]; } - // _S2 can go later + // _S2 TODO can go later bool get_m_rgfDeadkey(int i,int j) { return m_rgfDeadKey[i][j]; } @@ -272,7 +271,7 @@ public: bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,v_dw_3D &All_Vector, GdkKeymap *keymap) { // I4552 // Get the CAPSLOCK value -// _S2 needs to go later // this should be true for char, number, special +// _S2 TODO needs to go later // this should be true for char, number, special /*bool b1= this->KMX_IsCapsEqualToShift(); // but is false for numbers and special bool b2= this->KMX_IsSGCAPS(); bool b3= this->KMX_IsAltGrCapsEqualToAltGrShift(); @@ -289,6 +288,8 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0;*/ (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + + // _S2 DIFFERENCE TO MCOMPILE WINDOWS // _S2 DESIGN NEEDED on how to replace capslock // capslock has different values for linux. Therefore key->ShiftFlags will be different for numbers, special characters // for now set capslock=1 @@ -406,6 +407,7 @@ public: return (ch < 0x0020) || (ch >= 0x007F && ch <= 0x009F); } + // _S2 TODO Do we need this? void KMX_ClearKeyboardBuffer() { KMX_WCHAR sb[16]; for( int i=0; i<16; i++) { @@ -434,7 +436,8 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector alDead; - std::vector alDead_cpl = create_alDead(); + // _S2 DIFFERENCE TO MCOMPILE WINDOWS + std::vector alDead_cpl = create_alDead(); rgKey.resize(256); @@ -504,7 +507,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, continue; } - //_S2 to compare win-lin kmn-files skip ss6+7; MUST BE removed later!!!! + //_S2 TODO to compare win-lin kmn-files skip ss6+7; MUST BE removed later!!!! /*if(ss == MenuCtrl|| ss == ShftMenuCtrl) { continue; }*/ @@ -512,28 +515,30 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, KMX_DWORD KC_US = (KMX_DWORD) KMX_get_KeyCodeUnderlying_From_VKUS(iKey); - // _S2 TODO deadkey not finished; Ctrl, Shft +40 not tested - // _S2 TODO deadkey not finished; Ctrl, Shft +40 not tested + // _S2 TODO not finished; Ctrl, Shft +40 not tested for(int caps = 0; caps <= 1; caps++) { - loader.KMX_ClearKeyboardBuffer(); + + // _S2 TODO Do we need this? + //loader.KMX_ClearKeyboardBuffer(); loader.KMX_FillKeyState(lpKeyState, ss, (caps == 0)); int rc = KMX_ToUnicodeEx(KC_US, lpKeyState, sbBuffer, ss, caps, *keymap); if(rc > 0) { if(*sbBuffer == 0) { - //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); + //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); // _S2 rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps)); } else { if((rc == 1) && (ss == Ctrl || ss == ShftCtrl) && (rgKey[iKey]->VK() == ((UINT)sbBuffer[0] + 0x40))) { - // _S2 TODO is this the same behavior on Linux? + // is this the same behavior on Linux? // if rc ==1 : it got 1 char && +40 in Buffer CTRl pressed + // && CTRl +0x40 in the buffer ( which indicates a ctrl press) + // It's dealing with control characters. If ToUnicodeEx gets // VK_A with the Ctrl key pressed, it will write 0x01 to sBuffer[0], // without Ctrl it's 0x41. The if detects this case. - // && CTRl +0x40 in the buffer ( which indicates a ctrl press) // ToUnicodeEx has an internal knowledge about those // VK_A ~ VK_Z keys to produce the control characters, @@ -555,7 +560,10 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); //_S2 INFO // It's a dead key; let's flush out whats stored in the keyboard state. - loader.KMX_ClearKeyboardBuffer(); + // _S2 TODO Do we need this? + //loader.KMX_ClearKeyboardBuffer(); + + // _S2 DIFFERENCE TO MCOMPILE WINDOWS refine_alDead(sbBuffer[0], alDead, &alDead_cpl); } } diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index ed2be90363..2d8a87f25f 100755 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -475,7 +475,7 @@ KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz){ return TRUE; } -// __S2 TODO use incxstr from elsewhere +// _S2 TODO use incxstr from elsewhere PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p) { if (*p == 0) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 90aab8126b..8174f47f99 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -426,6 +426,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg return FALSE; } + // _S2 DIFFERENCE TO MCOMPILE WINDOWS // create vector v_dw_3D All_Vector; if(createOneVectorFromBothKeyboards(All_Vector, keymap)){ @@ -441,6 +442,8 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg // Loop through each possible key on the keyboard for (int i = 0;KMX_VKMap[i]; i++) { // I4651 + + // _S2 DIFFERENCE TO MCOMPILE WINDOWS // win goes via VK, Lin goes via SC/Keycode UINT scUnderlying = KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]); From 8704c7ee804332f841d6a932f649d1feb38f47be Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 14 Feb 2024 14:48:15 +0100 Subject: [PATCH 202/327] feat(linux): mcompile-dk remove a function --- linux/mcompile/keymap/keymap.cpp | 4 ++-- linux/mcompile/keymap/mc_import_rules.cpp | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index bacd8ca35d..5772d8aec8 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -572,7 +572,6 @@ std::wstring KMX_get_WStrUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap int keyvals_int= KMX_get_keyval_From_Keycode(keymap, keycode, ss, caps); return convert_DeadkeyValues_ToWstr(keyvals_int); } - KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { GdkKeymapKey *maps; guint *keyvals; @@ -590,7 +589,8 @@ KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector, KMX_DWORD KC_US, ShiftState ss, int caps) { KMX_DWORD Character; - std::wstring ws = KMX_get_WStrUnderlying_From_KeyCodeUnderlying_GDK(keymap, KC_US, ss, caps); + //std::wstring ws = KMX_get_WStrUnderlying_From_KeyCodeUnderlying_GDK(keymap, KC_US, ss, caps); + std::wstring ws = convert_DeadkeyValues_ToWstr(KMX_get_keyval_From_Keycode(keymap, KC_US, ss, caps)); Character = *ws.c_str(); //Find underlying KC of character diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index a9ebb0aaed..bcf392c717 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -76,7 +76,9 @@ int KMX_ToUnicodeEx(guint keycode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, if (!(keycode <= keycode_max)) return 0; - std::wstring str= KMX_get_WStrUnderlying_From_KeyCodeUnderlying_GDK(keymap, keycode, ShiftState(shift_state_pos), caps); + //std::wstring str= KMX_get_WStrUnderlying_From_KeyCodeUnderlying_GDK(keymap, keycode, ShiftState(shift_state_pos), caps); + std::wstring str = convert_DeadkeyValues_ToWstr(KMX_get_keyval_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), caps)); + pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(str).c_str(); KMX_DWORD keyvals_dw= (KMX_DWORD) KMX_get_keyval_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), caps); From 07b1d5d1e3284f0e98282fe95f6ae061defb174e Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 14 Feb 2024 14:50:03 +0100 Subject: [PATCH 203/327] feat(linux): mcompile-dk remove func 2 --- linux/mcompile/keymap/keymap.cpp | 4 ++-- linux/mcompile/keymap/keymap.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 5772d8aec8..1ce507fbe0 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -567,11 +567,11 @@ KMX_DWORD KMX_get_CharUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, U else // usable char return keyvals_dw; } -// _S2 do we need this func +/*/ _S2 do we need this func std::wstring KMX_get_WStrUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ int keyvals_int= KMX_get_keyval_From_Keycode(keymap, keycode, ss, caps); return convert_DeadkeyValues_ToWstr(keyvals_int); -} +}*/ KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { GdkKeymapKey *maps; guint *keyvals; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 64fde3331b..35d3e74d38 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -516,7 +516,7 @@ KMX_DWORD KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, KMX_DWORD KMX_get_CharUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, UINT VKShiftState, UINT KC_underlying, PKMX_WCHAR DeadKey); // return KeySyms for a given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) -std::wstring KMX_get_WStrUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); +//std::wstring KMX_get_WStrUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); // return the VirtualKey of the underlying Keyboard for a given Keyode using GDK KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD keycode); From 0675a5df9cf53d3a98aa040721afa7c7dabf69ca Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 14 Feb 2024 15:29:33 +0100 Subject: [PATCH 204/327] feat(linux): mcompile-dk remove unneccessary function --- linux/mcompile/keymap/keymap.cpp | 7 +------ linux/mcompile/keymap/keymap.h | 3 --- linux/mcompile/keymap/mc_import_rules.cpp | 1 - linux/mcompile/keymap/mcompile.cpp | 4 ++-- 4 files changed, 3 insertions(+), 12 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 1ce507fbe0..807850a877 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -567,11 +567,7 @@ KMX_DWORD KMX_get_CharUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, U else // usable char return keyvals_dw; } -/*/ _S2 do we need this func -std::wstring KMX_get_WStrUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ - int keyvals_int= KMX_get_keyval_From_Keycode(keymap, keycode, ss, caps); - return convert_DeadkeyValues_ToWstr(keyvals_int); -}*/ + KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { GdkKeymapKey *maps; guint *keyvals; @@ -589,7 +585,6 @@ KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector, KMX_DWORD KC_US, ShiftState ss, int caps) { KMX_DWORD Character; - //std::wstring ws = KMX_get_WStrUnderlying_From_KeyCodeUnderlying_GDK(keymap, KC_US, ss, caps); std::wstring ws = convert_DeadkeyValues_ToWstr(KMX_get_keyval_From_Keycode(keymap, KC_US, ss, caps)); Character = *ws.c_str(); diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 35d3e74d38..6fb44329e1 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -515,9 +515,6 @@ KMX_DWORD KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, KMX_DWORD KMX_get_CharUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, UINT VKShiftState, UINT KC_underlying, PKMX_WCHAR DeadKey); -// return KeySyms for a given key (for unshifted: finds the Keysym according to Shiftstate e.g. a;A or 1;! ) -//std::wstring KMX_get_WStrUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); - // return the VirtualKey of the underlying Keyboard for a given Keyode using GDK KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD keycode); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index bcf392c717..e3eb9a3bd8 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -76,7 +76,6 @@ int KMX_ToUnicodeEx(guint keycode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, if (!(keycode <= keycode_max)) return 0; - //std::wstring str= KMX_get_WStrUnderlying_From_KeyCodeUnderlying_GDK(keymap, keycode, ShiftState(shift_state_pos), caps); std::wstring str = convert_DeadkeyValues_ToWstr(KMX_get_keyval_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), caps)); pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(str).c_str(); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 8174f47f99..5a836574e9 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -426,7 +426,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg return FALSE; } - // _S2 DIFFERENCE TO MCOMPILE WINDOWS + // _S2 DIFFERENT TO MCOMPILE WINDOWS // create vector v_dw_3D All_Vector; if(createOneVectorFromBothKeyboards(All_Vector, keymap)){ @@ -443,7 +443,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg for (int i = 0;KMX_VKMap[i]; i++) { // I4651 - // _S2 DIFFERENCE TO MCOMPILE WINDOWS + // _S2 DIFFERENT TO MCOMPILE WINDOWS // win goes via VK, Lin goes via SC/Keycode UINT scUnderlying = KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]); From 41e48038691d7a1d583eb4f653f352a6f9905bc3 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 14 Feb 2024 15:55:21 +0100 Subject: [PATCH 205/327] feat(linux): mcompile-dk rename function --- linux/mcompile/keymap/keymap.cpp | 84 ++++++++++++++++---------------- linux/mcompile/keymap/keymap.h | 10 ++-- 2 files changed, 48 insertions(+), 46 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 807850a877..4111e317cb 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -494,42 +494,6 @@ int KMX_get_keyval_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss, return (int) *keyvals; } -KMX_DWORD KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky) { - GdkKeymapKey *maps; - guint *keyvals; - gint count; - KMX_DWORD deadkey=0; - - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return 0; - // _S2 INFO maybe later use something like - //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html - - if (!(shift_state_pos <= count)) - return 0; - - if (!(keycode <= keycode_max)) - return 0; - - KMX_DWORD All_Keyvals = KMX_get_keyval_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), 0); - if(( (All_Keyvals >= deadkey_min) && (All_Keyvals <= deadkey_max))) - deadkey = All_Keyvals; - dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str(); - - g_free(keyvals); - g_free(maps); - - // _S2 AHA output for dk4-12 at the top after dk... from here - if((All_Keyvals >= deadkey_min) && (All_Keyvals <= deadkey_max)) // deadkeys - return 0xFFFF; - else if((All_Keyvals > deadkey_max) || ((All_Keyvals < deadkey_min) && ( All_Keyvals > 0xFF))) // out of range - return 0xFFFE; - else // usable char - return All_Keyvals; -} - KMX_DWORD KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; guint *keyvals; @@ -553,10 +517,48 @@ KMX_DWORD KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, return out; } +KMX_DWORD KMX_get_KeyvalUnderlying_DK_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky) { + GdkKeymapKey *maps; + guint *keyvals; + gint count; + KMX_DWORD deadkey=0; + + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return 0; + // _S2 INFO maybe later use something like + //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html + + if (!(shift_state_pos <= count)) + return 0; + + if (!(keycode <= keycode_max)) + return 0; + + KMX_DWORD All_Keyvals = KMX_get_keyval_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), 0); + + if(( (All_Keyvals >= deadkey_min) && (All_Keyvals <= deadkey_max))) + deadkey = All_Keyvals; + + dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str(); + + g_free(keyvals); + g_free(maps); + + // _S2 AHA output for dk4-12 at the top after dk... from here + if((All_Keyvals >= deadkey_min) && (All_Keyvals <= deadkey_max)) // deadkeys + return 0xFFFF; + else if((All_Keyvals > deadkey_max) || ((All_Keyvals < deadkey_min) && ( All_Keyvals > 0xFF))) // out of range + return 0xFFFE; + else // usable char + return All_Keyvals; +} + KMX_DWORD KMX_get_CharUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, UINT VKShiftState, UINT KC_underlying, PKMX_WCHAR DeadKey) { PKMX_WCHAR dky; - KMX_DWORD keyvals_dw = KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(keymap, KC_underlying, map_VKShiftState_to_LinModifier(VKShiftState), dky); + KMX_DWORD keyvals_dw = KMX_get_KeyvalUnderlying_DK_From_KeyCodeUnderlying_GDK(keymap, KC_underlying, map_VKShiftState_to_LinModifier(VKShiftState), dky); if(keyvals_dw >= deadkey_min) { // deadkey *DeadKey = *dky; @@ -600,10 +602,6 @@ KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3 return KC_US; } -UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS) { - return (8 + USVirtualKeyToScanCode[VirtualKeyUS]); -} - KMX_WCHAR KMX_get_CharUS_From_VKUnderlying_VEC(v_dw_3D & All_Vector, KMX_DWORD VK_underlying) { KMX_DWORD VK_US; for( int i=0; i< (int)All_Vector[0].size()-1 ;i++) { @@ -617,6 +615,10 @@ KMX_WCHAR KMX_get_CharUS_From_VKUnderlying_VEC(v_dw_3D & All_Vector, KMX_DWORD V return VK_underlying; } +UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS) { + return (8 + USVirtualKeyToScanCode[VirtualKeyUS]); +} + std::wstring CodePointToWString(unsigned int codepoint) { std::wstring str; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 6fb44329e1..58ec2fec55 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -509,10 +509,10 @@ std::u16string convert_DeadkeyValues_To_U16str(int in); // use gdk_keymap_translate_keyboard_state to get keyval - base function to get keyvals int KMX_get_keyval_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); -KMX_DWORD KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky); - KMX_DWORD KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos); +KMX_DWORD KMX_get_KeyvalUnderlying_DK_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky); + KMX_DWORD KMX_get_CharUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, UINT VKShiftState, UINT KC_underlying, PKMX_WCHAR DeadKey); // return the VirtualKey of the underlying Keyboard for a given Keyode using GDK @@ -521,12 +521,12 @@ KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD // return the Keycode of the underlying Keyboard for given VK_US using GDK KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector,KMX_DWORD KC_US, ShiftState ss, int caps); +KMX_WCHAR KMX_get_CharUS_From_VKUnderlying_VEC(v_dw_3D &All_Vector,KMX_DWORD VK_underlying); + // return the Keycode of the underlying Keyboard for given VK_US UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); -KMX_WCHAR KMX_get_CharUS_From_VKUnderlying_VEC(v_dw_3D &All_Vector,KMX_DWORD VK_underlying); - -// converts codePoint to wstring +// convert codePoint to wstring std::wstring CodePointToWString(unsigned int codepoint); std::u16string CodePointToString_16(unsigned int codepoint); From ed603820ca70c658628be5f1c11d190bafb59be7 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 14 Feb 2024 19:05:18 +0100 Subject: [PATCH 206/327] feat(linux): mcompile-dk replace KMX_LogError --- linux/mcompile/keymap/mc_kmxfile.cpp | 24 ++++++++-------- linux/mcompile/keymap/mcompile.cpp | 41 ++++++++++++++++++---------- linux/mcompile/keymap/mcompile.h | 3 +- 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 2d8a87f25f..59461607ac 100755 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -356,20 +356,20 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { PKMX_BYTE filebase; if(!fileName || !lpKeyboard) { - KMX_LogError(L"LogError1: Bad Filename\n" ); + KMX_LogError(L"Bad Filename\n" ); return FALSE; } fp = Open_File((const KMX_WCHAR*)fileName, u"rb"); if(fp == NULL) { - KMX_LogError(L"LogError1: Could not open file\n" ); + KMX_LogError(L"Could not open file\n" ); return FALSE; } if (fseek(fp, 0, SEEK_END) != 0) { fclose(fp); - KMX_LogError(L"LogError1: Could not fseek file\n" ); + KMX_LogError(L"Could not fseek file\n" ); return FALSE; } @@ -381,7 +381,7 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { if (fseek(fp, 0, SEEK_SET) != 0) { fclose(fp); - KMX_LogError(L"LogErr1: Could not fseek(set) file\n" ); + KMX_LogError(L"Could not fseek(set) file\n" ); return FALSE; } @@ -399,7 +399,7 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { if (!buf) { fclose(fp); - KMX_LogError(L"LogErr1: Not allocmem\n" ); + KMX_LogError(L"Not allocmem\n" ); return FALSE; } @@ -410,7 +410,7 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { #endif if (fread(filebase, 1, sz, fp) < (size_t)sz) { - KMX_LogError(L"LogError1: Could not read file\n" ); + KMX_LogError(L"Could not read file\n" ); fclose(fp); return FALSE; } @@ -425,7 +425,7 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { } if (!KMX_VerifyKeyboard(filebase, sz)) { - KMX_LogError(L"LogError1: errVerifyKeyboard\n" ); + KMX_LogError(L"errVerifyKeyboard\n" ); return FALSE; } @@ -437,13 +437,13 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { if (!kbp) { - KMX_LogError(L"LogError1: errFixupKeyboard\n" ); + KMX_LogError(L"errFixupKeyboard\n" ); return FALSE; } if (kbp->dwIdentifier != FILEID_COMPILED) { delete[] buf; - KMX_LogError(L"LogError1: errNotFileID\n" ); + KMX_LogError(L"errNotFileID\n" ); return FALSE; } *lpKeyboard = kbp; @@ -462,14 +462,14 @@ KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz){ for (csp = (PKMX_COMP_STORE)(filebase + ckbp->dpStoreArray), i = 0; i < ckbp->cxStoreArray; i++, csp++) { if (csp->dwSystemID == TSS_COMPILEDVERSION) { if (csp->dpString == 0) { - KMX_LogError(L"LogErr1: errWrongFileVersion:NULL"); + KMX_LogError(L"errWrongFileVersion:NULL"); } else { - wprintf(L"LogErr1: errWrongFileVersion:%10.10ls",(const PKMX_WCHAR) KMX_StringOffset((PKMX_BYTE)filebase, csp->dpString)); + KMX_LogError(L"errWrongFileVersion:%10.10ls",(const PKMX_WCHAR) KMX_StringOffset((PKMX_BYTE)filebase, csp->dpString)); } return FALSE; } } - KMX_LogError(L"LogErr1: errWrongFileVersion"); + KMX_LogError(L"errWrongFileVersion"); return FALSE; } return TRUE; diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 5a836574e9..706421d1be 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -40,6 +40,8 @@ std::vector KMX_FDeadkeys; // I4353 #define max(a,b) (((a) > (b)) ? (a) : (b)) #endif +#define _countof(a) (sizeof(a)/sizeof(*(a))) + #if defined(_WIN32) || defined(_WIN64) int wmain(int argc, wchar_t* argv[]) { std::vector str_argv_16 = convert_argvW_to_Vector_u16str( argc, argv); @@ -129,9 +131,8 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ } #endif + //DeleteReallocatedPointers(kmxfile); :TODO // not my ToDo :-) - //DeleteReallocatedPointers(kmxfile); :TODO // not my ToDo :-) - //DeleteReallocatedPointers(kmxfile); :TODO // not my ToDo :-) delete kmxfile; wprintf(L"\nmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm end\n"); @@ -190,11 +191,9 @@ void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHA void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key) { if(key->ShiftFlags == 0) { - //KMX_LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); - //wprintf(L" _S2 Did not find a match for mnemonic rule on line %d, + '%c' > ...\n", key->Line, key->Key); + KMX_LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); } else if(key->ShiftFlags & VIRTUALCHARKEY) { - //KMX_LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); - //wprintf(L"_S2 Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...\n", key->Line, key->ShiftFlags, key->Key); + KMX_LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); } } @@ -477,15 +476,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg return TRUE; } -// _S2 TODO -void KMX_LogError(const KMX_WCHART* m1,int m2) { - wprintf((PWSTR)m1, m2); -} -/* -void KMX_LogError(const KMX_WCHART* m1,int m2, LPKMX_KEY key) { - wprintf((PWSTR)m1, m2); -} -*/ + int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap) { KMX_WORD *p = OutputPairs; @@ -509,6 +500,26 @@ int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, return (p-OutputPairs); } + +void KMX_LogError(PWCHAR fmt, ...) { + WCHAR fmtbuf[256]; + wchar_t *end = L"\0"; + wchar_t *nl = L"\n"; + va_list vars; + int j=0; + + va_start(vars, fmt); + vswprintf (fmtbuf,_countof(fmtbuf), fmt, vars ); + fmtbuf[255] = 0; + + do { + putwchar(fmtbuf[j]); + j++; + } + while(fmtbuf[j] != *end); + putwchar(*nl); +} + // ---- old copy code from here ---------------------------------------------------------- /* diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 88fa129d0f..8aea942a61 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -25,8 +25,7 @@ #include "deadkey.h" #include "mc_kmxfile.h" -void KMX_LogError(const KMX_WCHART* m1, int m2 = 0); -//void KMX_LogError(const KMX_WCHART* m1, int m2 = 0, LPKMX_KEY key =NULL); +void KMX_LogError(PWCHAR fmt, ...) ; struct KMX_DeadkeyMapping { // I4353 KMX_WCHAR deadkey, dkid; From da4ea69fdeaa994fdc1eceb67acf38ea5c2342e6 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 15 Feb 2024 12:09:47 +0100 Subject: [PATCH 207/327] feat(linux): mcompile-dk remove helpers.cpp/h --- linux/mcompile/keymap/deadkey.cpp | 10 +- linux/mcompile/keymap/deadkey.h | 1 + linux/mcompile/keymap/helpers.cpp | 3788 ----------------------------- linux/mcompile/keymap/helpers.h | 63 - linux/mcompile/keymap/keymap.h | 15 +- linux/mcompile/keymap/km_types.h | 12 - linux/mcompile/keymap/mcompile.h | 1 - linux/mcompile/keymap/meson.build | 1 - 8 files changed, 13 insertions(+), 3878 deletions(-) delete mode 100755 linux/mcompile/keymap/helpers.cpp delete mode 100755 linux/mcompile/keymap/helpers.h diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 14e453aab5..60f181e15d 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -34,10 +34,10 @@ std::vector create_alDead() { v_dw_2D dk_ComposeTable; create_DKTable(dk_ComposeTable); - for( int i=0; i< (int) dk_ComposeTable.size()-1; i++) { - DeadKey *dk2= new DeadKey(dk_ComposeTable[i][0]); + for( int i=0; i < (int) dk_ComposeTable.size()-1; i++) { + DeadKey *dk2 = new DeadKey(dk_ComposeTable[i][0]); for ( int j=0; j< (int) dk_ComposeTable.size();j++) { - if(( dk_ComposeTable[i][0]==dk_ComposeTable[j][0]) && (IsKeymanUsedChar(dk_ComposeTable[j][1]))) + if(( dk_ComposeTable[i][0] == dk_ComposeTable[j][0]) && (IsKeymanUsedChar(dk_ComposeTable[j][1]))) dk2->KMX_AddDeadKeyRow(dk_ComposeTable[j][1],dk_ComposeTable[j][2]); } alDead.push_back(dk2); @@ -46,9 +46,8 @@ std::vector create_alDead() { } bool found_dk_inVector(KMX_WCHAR dk, std::vector &dkVec) { - int i=0; - if( dkVec.size()>0) { + if( dkVec.size() > 0) { do { if( dk == dkVec[i]->KMX_GetDeadCharacter()) return true; @@ -74,7 +73,6 @@ void refine_alDead(KMX_WCHAR dk, std::vector &dkVec, std::vector &small_Vec, std::vector *p_All_Vec) { - std::vector small_sorted; int Vsmall_size; int i = 0; diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index 303f1b56b3..b4c6de7aeb 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -15,6 +15,7 @@ void create_DKTable(v_dw_2D & dk_ComposeTable); // find all possible dk combinations that exist std::vector create_alDead(); + // refine dk to those used in the underlying keyboard void refine_alDead(KMX_WCHAR dk, std::vector &myVec, std::vector *p_All_Vec); bool found_dk_inVector(KMX_WCHAR dk, std::vector &myVec); diff --git a/linux/mcompile/keymap/helpers.cpp b/linux/mcompile/keymap/helpers.cpp deleted file mode 100755 index 3770f18dcf..0000000000 --- a/linux/mcompile/keymap/helpers.cpp +++ /dev/null @@ -1,3788 +0,0 @@ - -#include "helpers.h" - -// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -//_S2 do not review - all this will be deleted later -// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - -std::u16string KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_16_OLD(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ - - GdkModifierType consumed; - GdkKeymapKey *maps; - guint *keyvals; - gint count; - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return u"\0"; - - //unshifted (shiftstate: 0) - if (( ss == Base ) && ( caps == 0 )) { - GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); - } - - //caps (shiftstate: 0) - else if (( ss == Base ) && ( caps == 1 )) { - GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); - } - - //Shift (shiftstate: 1) - else if (( ss == Shft ) && ( caps == 0 )) { - GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); - } - - //SHIFT+CAPS (shiftstate: 1) - else if ( ( ss == Shft ) && ( caps ==1 )) { - GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); - } - - /*// Ctrl (shiftstate: 2) - else if (( ss == Ctrl ) && ( caps == 0 )){ - GdkModifierType MOD_Ctrl = (GdkModifierType) ( GDK_MOD2_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl , 0, keyvals, NULL, NULL, & consumed); - } - - // Ctrl (shiftstate: 2) - else if (( ss == Ctrl ) && ( caps == 1 )){ - GdkModifierType MOD_CtrlCaps = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_LOCK_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps , 0, keyvals, NULL, NULL, & consumed); - } - // SHIFT+Ctrl (shiftstate: 3)*/ - - //ALT-GR (shiftstate: 6) - else if (( ss == MenuCtrl ) && ( caps == 0 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - //ALT-GR +CAPS (shiftstate: 6) - else if (( ss == MenuCtrl ) && ( caps == 1 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - //ALT-GR (shiftstate: 7) - else if (( ss == ShftMenuCtrl ) && ( caps == 0 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - //ALT-GR +CAPS (shiftstate: 7) - else if (( ss == ShftMenuCtrl ) && ( caps == 1 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - else - return u"\0"; - - //if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max) ) - if((*keyvals >= deadkey_min) ) - return convert_DeadkeyValues_To_U16str((int) *keyvals); - else - return std::u16string(1, (int) *keyvals); -} - - -/* - -KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw_OLD(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){ - - GdkModifierType consumed; - GdkKeymapKey *maps; - guint *keyvals; - gint count; - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return 0; - - //BASE (shiftstate: 0) - if (( ss == Base ) && ( caps == 0 )) { - GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); - } - - //BASE + CAPS (shiftstate: 0) - else if (( ss == Base ) && ( caps == 1 )) { - GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); - } - - //SHIFT (shiftstate: 1) - else if (( ss == Shft ) && ( caps == 0 )) { - GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); - } - - //SHIFT+CAPS (shiftstate: 1) - else if ( ( ss == Shft ) && ( caps ==1 )) { - GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); - } - - // Ctrl (shiftstate: 2) - else if (( ss == Ctrl ) && ( caps == 0 )){ - GdkModifierType MOD_Ctrl = (GdkModifierType) ( GDK_MOD5_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl , 0, keyvals, NULL, NULL, & consumed); - } - - // Ctrl (shiftstate: 2) - else if (( ss == Ctrl ) && ( caps == 1 )){ - GdkModifierType MOD_CtrlCaps = (GdkModifierType) (GDK_MOD5_MASK | GDK_LOCK_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps , 0, keyvals, NULL, NULL, & consumed); - } - - - // SHIFT+Ctrl (shiftstate: 3) - else if (( ss == ShftCtrl ) && ( caps == 0 )){ - GdkModifierType MOD_Ctrl = (GdkModifierType) (GDK_SHIFT_MASK | GDK_MOD5_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl , 0, keyvals, NULL, NULL, & consumed); - } - - // SHIFT+Ctrl (shiftstate: 3) - else if (( ss == ShftCtrl ) && ( caps == 1 )){ - GdkModifierType MOD_CtrlCaps = (GdkModifierType) ( GDK_SHIFT_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps , 0, keyvals, NULL, NULL, & consumed); - } - - //ALT-GR (shiftstate: 6) - else if (( ss == MenuCtrl ) && ( caps == 0 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - //ALT-GR +CAPS (shiftstate: 6) - else if (( ss == MenuCtrl ) && ( caps == 1 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - //ALT-GR (shiftstate: 7) - else if (( ss == ShftMenuCtrl ) && ( caps == 0 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - - //ALT-GR +CAPS (shiftstate: 7) - else if (( ss == ShftMenuCtrl ) && ( caps == 1 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - } - else - return 0; -//_S2 hier wird fffe returned ist das OK? - if((*keyvals >= deadkey_min) && (*keyvals <= deadkey_max)) - return 0xFFFF; - if((*keyvals > deadkey_max) || ((*keyvals < deadkey_min) && ( *keyvals > 0xFF))) - return 0xFFFE; - else - return (KMX_DWORD) *keyvals; -} - - - - - - - -KMX_DWORD KMX_get_SCUnderlying_From_SCUS_VEC(v_dw_3D &All_Vector, KMX_DWORD KC_US, int Shiftstate) { - - KMX_DWORD Character = 0; - // find character with that scancode - for( int i=0; i< (int)All_Vector[0].size()-1 ;i++) { - if ( ( All_Vector[0][i][0] == KC_US ) ) { - if ( Shiftstate+1 < (int) All_Vector[0][i].size()-1) - Character = All_Vector[0][i][Shiftstate+1]; - break; - } - } - - //Find underlying SC of character - for( int i=0; i< (int)All_Vector[1].size()-1 ;i++) { - for( int j=1; j< (int)All_Vector[01][0].size();j++) { - if ( ( All_Vector[1][i][j] == Character ) ) { - KC_US = All_Vector[1][i][j]; - return All_Vector[1][i][0]; - } - } - } - return KC_US; -} - - - - -KMX_WCHAR KMX_SCKUnderlyingLayoutToVKUS_GDK2(GdkKeymap* keymap,KMX_DWORD SC_Other) { - - return SC_Other; -}*/ -// _S2 can go later -void Inspect_kp(LPKMX_KEYBOARD kp) { - wprintf(L"-------\n"); - wprintf(L"-------\n"); - wprintf(L"-------\n"); - wprintf(L"kp has %i groups and %i keys\n",kp->cxGroupArray, kp->dpGroupArray->cxKeyArray); - wprintf(L"-------\n"); - -//for ( int i=0; i<150;i++) { -for ( int i=0; idpGroupArray->cxKeyArray;i++) { - wprintf(L"key nr :%i has key:%i(%c) Line:%i Shiftflags:%i Output %c (%d)\n",i,kp->dpGroupArray->dpKeyArray->Key,kp->dpGroupArray->dpKeyArray->Key, - kp->dpGroupArray->dpKeyArray->Line,kp->dpGroupArray->dpKeyArray->ShiftFlags ,kp->dpGroupArray->dpKeyArray->dpOutput,*kp->dpGroupArray->dpKeyArray->dpOutput ); - kp->dpGroupArray->dpKeyArray++; -} - wprintf(L"-------\n"); - wprintf(L"-------\n"); - wprintf(L"-------\n"); -} - -void Inspect_gp(KMX_tagGROUP* gp) { - for (int i = 0; i < gp->cxKeyArray; i++) { - wprintf(L"key nr : has key:%i(%c) Line:%i Shiftflags:%i Output %c (%d)\n", gp->dpKeyArray->Key, gp->dpKeyArray->Key, - gp->dpKeyArray->Line, gp->dpKeyArray->ShiftFlags, gp->dpKeyArray->dpOutput, *gp->dpKeyArray->dpOutput); - // gp->cxKeyArray++; - } -} - -void Inspect_key(LPKMX_KEY key) { - //for (int i = 0; i < gp->cxKeyArray; i++) { - wprintf(L"key nr : has key:%i(%c) Line:%i Shiftflags:%i Output \n", key->Key, key->Key, - key->Line, key->ShiftFlags); - /*wprintf(L"key nr : has key:%i(%c) Line:%i Shiftflags:%i Output %c (%d)\n", key->Key, key->Key, - key->Line, key->ShiftFlags, key->dpOutput, *key->dpOutput);*/ - // gp->cxKeyArray++; - // } -} - -// _S2 this needs to go; only to check if mcompile gives the same end result. -// _S2 helps to force filling rgkey[VK_DE] -UINT map_Ikey_DE(UINT iKey) { - if (iKey == 89 ) return 90; - if (iKey == 90 ) return 89; - if (iKey == 186 ) return 219; - if (iKey == 187 ) return 221; - if (iKey == 188 ) return 188; - if (iKey == 189 ) return 191; - if (iKey == 190 ) return 190; - if (iKey == 191 ) return 220; - if (iKey == 192 ) return 186; - if (iKey == 219 ) return 189; - if (iKey == 220 ) return 192; - if (iKey == 221 ) return 187; - if (iKey == 222 ) return 222; - if (iKey == 226 ) return 226; - return iKey; -} - -/* takes KV of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] -KMX_DWORD KMX_get_CharUnderlying_according_to_keycode_and_Shiftstate_VEC(v_dw_3D &All_Vector,KMX_DWORD KVUnderlying, KMX_UINT VKShiftState, KMX_WCHAR* DeadKey){ - - KMX_UINT VKShiftState_lin; - - // 0000 0000 - if (VKShiftState == 0 ) VKShiftState_lin = 0; - // 0001 0000 - if (VKShiftState == 16) VKShiftState_lin = 1; - // 0000 1001 - if (VKShiftState == 9 ) VKShiftState_lin = 2; - // 0001 1001 - if (VKShiftState == 25) VKShiftState_lin = 3; - - // loop and find KVUnderlying in Other; then return char with correct shiftstate - for( int i=0; i< (int)All_Vector[1].size();i++) { - KMX_DWORD CharOther = All_Vector[1][i][2]; - if( KVUnderlying == CharOther ) { - return All_Vector[1][i][VKShiftState_lin+1]; // [VKShiftState_lin+1] because we have the name of the key in All_Vector[1][i][0], so we need to get the one after this - } - } - return KVUnderlying; -} -*/ - -// _S2 TODO How to do mapping between Linux keycodes and keyman SC -const int Lin_KM__map(int i, v_dw_3D &All_Vector) { - // MAP: - // VK KEYMAN-STYLE -> KEYCODE LINUX-STYLE - // e.g 188 -> 59 - //All_Vector_[ 1 ][ in which line of US did find the value 58 ][ take second or third column wherever I find 58 ]] - // finds 59th row (not value 59) - int dw=0; - //if (i == 32 ) return ; /* */5 - //if (i == 186 ) return 220; /* Ü */ - //if (i == 187 ) return 42; /* + * */ - //if (i == 188 ) {wprintf(L" swapped: i (%i) to 59 \n",dw,i); return 59; }/* COMMA */ - //if (i == 189 ) {wprintf(L" swapped: i (%i) to 95 \n",dw,i); return 95; }/* - _ */ - //if (i == 190 ) {wprintf(L" swapped: i (%i) to 58 \n",dw,i); return 58; }/* PERIOD */ - //if (i == 191 ) {wprintf(L" swapped: i (%i) to 35 \n",dw,i); return 35; }/* # ' */ - //if (i == 191 ) {wprintf(L" swapped: i (%i) to 63 \n",dw,i); return 63; }/* */ - //if (i == 214 ) {wprintf(L" swapped: i (%i) to 192 \n",dw,i); return 192; }/* Ö */ - //if (i == 219 ) {wprintf(L" swapped: i (%i) to 223 \n",dw,i); return 223; }/* Sharp-S+ ? */ - //if (i == 220 ) {wprintf(L" swapped: i (%i) to 92 \n",dw,i); return 92; }/* ^ ° */ - //if (i == 221 ) {wprintf(L" swapped: i (%i) to 180 \n",dw,i); return 180; }/* ' ` */ - //if (i == 223 ) {wprintf(L" swapped: i (%i) to 59 \n",dw,i); return ; }/* */ - - //if (i == 226 ) {wprintf(L" swapped: i (%i) to 60 \n",dw,i); return 60; }/* < > */ - //if (i == 65105 ) {wprintf(L" swapped: i (%i) to 92 \n",dw,i); return 92; }/* */ - - // e.g. rgKey[192] contains character 214 - //if (i == 192 ) {wprintf(L" swapped: i (%i) to 214 \n",dw,i); return 214; }/* Ö */ - //if (i == 186 ) {wprintf(L" swapped: i (%i) to 220 \n",dw,i); return 220; }/* Ü */ - //if (i == 222 ) {wprintf(L" swapped: i (%i) to 196 \n",dw,i); return 196; }/* Ä */ - //if (i == 220) {wprintf(L" swapped: i (%i) to 196 \n",dw,i); return 186; }/* Ä */ - //if (i == 42) {wprintf(L" swapped: i (%i) to 196 \n",dw,i); return 187; }/* + */ - - return i; -} - -int append_other_ToVector(v_dw_3D &All_Vector) { - InsertKeyvalsFromVectorFile(All_Vector); - return 0; -} - -bool InsertKeyvalsFromVectorFile(v_dw_3D &complete_Vector) { - std::string TxtFileName = "/Projects/keyman/keyman/linux/mcompile/keymap/VectorFile.txt" ; - - //wprintf(L" +++++++ dimensions of Vector at beginning of writeFileToVector (languages..characters..shiftstates)\t\t %li..%li..%li\n", complete_Vector.size(), complete_Vector.size(),complete_Vector.size()); - //wprintf(L" #### InsertKeyvalsFromVectorFile started: \n"); - - FILE *fp; - char str[600]; - std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; - v_str_1D complete_List; - v_dw_1D tokens_dw; - v_dw_2D shift_states; - int k = -1; - - /* opening file for reading */ - fp = fopen(TxtFileName.c_str() , "r"); - if(fp == NULL) { - perror("Error opening file"); - return(-1); - } - - while (fgets(str, 600, fp) != NULL) { - k++; - //puts(str); - complete_List.push_back(str); - if (strcmp(str, "Language 2\n") ==0){ - complete_Vector.push_back(shift_states); - shift_states.clear(); - continue; - } - - // remove all unwanted char - for (int i = 0; i < (int)delim.size(); i++) { - complete_List[k].erase(remove(complete_List[k].begin(), complete_List[k].end(), delim[i]), complete_List[k].end()); - } - - // split into numbers ( delimiter -) - std::stringstream ss(complete_List[k]); - int end = complete_List[k].find("-"); - while (end != -1) { // Loop until no delimiter is left in the string. - tokens_dw.push_back((DWORD)stoi(complete_List[k].substr(0, end))); - complete_List[k].erase(complete_List[k].begin(), complete_List[k].begin() + end + 1); - end = complete_List[k].find("-"); - } - shift_states.push_back(tokens_dw); - tokens_dw.clear(); - } - complete_Vector.push_back(shift_states); - shift_states.clear(); - - fclose(fp); - //wprintf(L" #### InsertKeyvalsFromVectorFile ended: \n"); - //wprintf(L" +++++++ dimensions of Vector at END of writeFileToVector (languages..characters..shiftstates)\t\t %li..%li..%li\n", complete_Vector.size(), complete_Vector[0].size(),complete_Vector[0][0].size()); -} - -int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector){ - // here we copy all contents of the FILE ( US and other already available in the file) to All_Vector - //wprintf(L" +++++++ dimensions of Vector in createOneVectorFromBothKeyboards 2 \t\t\t\t\t\t %li..%li..%li\n", All_Vector.size(), All_Vector.size(),All_Vector.size()); - - // add contents of file to All_Vector - if( append_other_ToVector(All_Vector)) { - wprintf(L"ERROR: can't append Other ToVector \n"); - return 2; - } - //wprintf(L" +++++++ dimensions of Vector in createOneVectorFromBothKeyboards 3 \t\t\t\t\t\t %li..%li..%li\n", All_Vector.size(), All_Vector[0].size(),All_Vector[0][0].size()); - return 0; -} - -bool writeVectorToFile(v_dw_3D V) { - std::string TxtFileName = "/Projects/keyman/keyman/linux/mcompile/keymap/VectorFile2.txt" ; - WCHAR DeadKey; - std::ofstream TxTFile(TxtFileName); - //TxTFile << "\n kbid << VKShiftState[j] << US VKMap[i] < delim{' ', '[', ']', '}', ';', '\t', '\n'}; - v_str_1D complete_List; - v_dw_1D tokens_dw; - v_dw_2D shift_states; - int k = -1; - - /* opening file for reading */ - fp = fopen("/Projects/keyman/keyman/linux/mcompile/keymap/VectorFile.txt" , "r"); - if(fp == NULL) { - perror("Error opening file"); - return(-1); - } - - while (fgets(str, 600, fp) != NULL) { - k++; - //puts(str); - complete_List.push_back(str); - if (strcmp(str, "Language 2\n") ==0){ - complete_Vector.push_back(shift_states); - shift_states.clear(); - continue; - } - - // remove all unwanted char - for (int i = 0; i < (int)delim.size(); i++) { - complete_List[k].erase(remove(complete_List[k].begin(), complete_List[k].end(), delim[i]), complete_List[k].end()); - } - - // split into numbers ( delimiter -) - std::stringstream ss(complete_List[k]); - int end = complete_List[k].find("-"); - while (end != -1) { // Loop until no delimiter is left in the string. - tokens_dw.push_back((DWORD)stoi(complete_List[k].substr(0, end))); - complete_List[k].erase(complete_List[k].begin(), complete_List[k].begin() + end + 1); - end = complete_List[k].find("-"); - } - shift_states.push_back(tokens_dw); - tokens_dw.clear(); - } - complete_Vector.push_back(shift_states); - shift_states.clear(); - - wprintf(L" #### writeFileToVector ended: \n"); - fclose(fp); - wprintf(L" +++++++ dimensions of Vector at END of writeFileToVector (languages..characters..shiftstates)\t\t %li..%li..%li\n", complete_Vector.size(), complete_Vector[0].size(),complete_Vector[0][0].size()); - - return(0); -} - -bool CompareVector_To_VectorOfFile(v_dw_3D All_Vector,v_dw_3D File_Vector){ - wprintf(L" #### CompareVector_To_VectorOfFile started: "); - wprintf(L" #### dimensions: %i %i %i -- %i %i %i \n", All_Vector.size() ,All_Vector[0].size(), All_Vector[0][0].size(),File_Vector.size() ,File_Vector[0].size(), File_Vector[0][0].size()); - - if (!(All_Vector.size() == File_Vector.size()) )return false; - if (!(All_Vector[0].size() == File_Vector[0].size())) return false; - if (!(All_Vector[0][0].size() == File_Vector[0][0].size())) return false; - - wprintf(L" #### CompareVector_To_VectorOfFile dimensions OK \n"); - for ( int i=0; i< All_Vector.size();i++) { - for ( int j=0; j< All_Vector[i].size();j++) { - for ( int k=0; k< All_Vector[i][j].size();k++){ - if(( All_Vector[i][j][k] != File_Vector[i][j][k])) { - wprintf(L" All_Vector[%i][%i][%i]: %i %i File_Vector[i][j][k]\n", i,j,k, All_Vector[i][j][k], File_Vector[i][j][k]); - wprintf(L" DIFFERENT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); - return false; - } - } - } - } - - return true; -} - -/*// takes SC of Other keyboard and returns character of Other keyboard with shiftstate VKShiftState[j] -KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, KMX_UINT VKShiftState, UINT SC_OTHER, PKMX_WCHAR DeadKey) { - - PKMX_WCHAR dky; - int VKShiftState_lin = map_VKShiftState_to_Lin(VKShiftState); - KMX_DWORD KeyvalOther = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK_OLD(keymap,SC_OTHER, VKShiftState_lin, dky); - - if (KeyvalOther >= deadkey_min) { - /// std::string ws((const char*) gdk_keyval_name (KeyvalOther)); - // *DeadKey = convertNamesToIntegerValue( wstring_from_string(ws)); - -*DeadKey=*dky; -return 0xFFFF; - } - return (KMX_WCHAR) KeyvalOther; -}*/ - -bool CompareVector_To_VectorOfFile_RGKEY(v_dw_2D Win_Vector,v_dw_2D Lin_Vector, v_dw_2D Map_Vector){ - wprintf(L" #### CompareVector_To_VectorOfFile started: "); - wprintf(L" #### dimensions: %i %i -- %i %i \n", Win_Vector.size() ,Win_Vector[0].size(), Lin_Vector.size() ,Lin_Vector[0].size()); - KMX_DWORD SC_Win, SC_Lin; - if (!(Win_Vector.size() == Lin_Vector.size()) )return false; - if (!(Win_Vector[0].size() == Lin_Vector[0].size())) return false; - - // loop through both vectors and compare VK ( " e.g. do both vectors contain character "Q" ? ( that is VK = 81)) - for ( int i=0; i< Lin_Vector.size();i++) { - - // for capital letters A-Z - if ( (i >64) && (i<91)) { - if( Lin_Vector[i][1] == (Win_Vector[i][1] +8 )) { - //wprintf(L" GOOD entry for Win/Lin_Vector[%i][0]: Win_Vector[%i][1] (%i/ %c) <--> Lin_Vector[%i][1] (%i/ %c)\n", i, i,Win_Vector[i][0] ,Win_Vector[i][0], i,Lin_Vector[i][0],Lin_Vector[i][0]); - continue; - } - else - wprintf(L" WRONG entry for Win/Lin_Vector[%i][0]: Win_Vector[%i][1] (%i/ %c) <--> Lin_Vector[%i][1] (%i/ %c)\n", i, i,Win_Vector[i][0] ,Win_Vector[i][0], i,Lin_Vector[i][0],Lin_Vector[i][0]); - return false; - } - - /* - // for unshifted letters a-z - else if ( (i >96) && (i<123)) { - } - - // for all other characters - else { - } - */ - } - wprintf(L" No Difference found in A-Z :-) SC have an offset of 8 "); - - return true; - } - -/*bool CompareVector_To_VectorOfFile_RGKEY(v_dw_2D Win_Vector,v_dw_2D Lin_Vector, v_dw_2D Map_Vector){ - wprintf(L" #### CompareVector_To_VectorOfFile started: "); - wprintf(L" #### dimensions: %i %i -- %i %i \n", Win_Vector.size() ,Win_Vector[0].size(), Lin_Vector.size() ,Lin_Vector[0].size()); - KMX_DWORD SC_Win, SC_Lin; - if (!(Win_Vector.size() == Lin_Vector.size()) )return false; - if (!(Win_Vector[0].size() == Lin_Vector[0].size())) return false; - - -// loop through both vectors and compare VK ( " e.g. do both vectors contain character "Q" ? ( that is VK = 81)) -for ( int i=0; i< Lin_Vector.size();i++) { - KMX_DWORD ValueOfVLin = Lin_Vector[i][0]; - if ( ValueOfVLin == 999) - continue; - - for ( int j=0; j< Win_Vector.size();j++) { - KMX_DWORD ValueOfVWin = Win_Vector[j][0]; - if (ValueOfVWin ==ValueOfVLin) { - wprintf(L" same value found: %i; (Lin): %i-%i %i--%i (Win) \n", ValueOfVLin,Lin_Vector[i][0],Lin_Vector[i][1],Win_Vector[i][1],Win_Vector[i][0] ); - - - // do I find these 2 SC as a pair (in a line) in map.txt - SC_Win = Win_Vector[j][0]; - SC_Lin = Lin_Vector[i][0]; - for( int k=0; k< Map_Vector.size(); k++) { - if((SC_Win == Map_Vector[k][1]) && ( SC_Lin== Map_Vector[k][1])) - wprintf(L" ....same value found: %i; (Lin): %i-%i %i--%i (Win) \n", ValueOfVLin,Lin_Vector[i][0],Lin_Vector[i][1],Win_Vector[i][1],Win_Vector[i][0] ); - - //wprintf(L" ... That EXISTS in map \n"); - //else - //wprintf(L" ... That DOES NOT EXIST in map \n"); - } - continue; - } - //else - wprintf(L" same value NOT found: %i\n", ValueOfVLin);// - } -} - return true; -}*/ - -bool write_RGKEY_FileToVector(v_dw_2D& shift_states, const char* infile) { - FILE *fp; - char str[600]; - std::vector delim{' ', '[', ']', '}','*', ')','(','>', '\t', '\n'}; - v_str_1D complete_List; - v_dw_1D tokens_dw; - int k = -1; - - for ( int i =0; i< 266;i++) { - tokens_dw.push_back(999); - tokens_dw.push_back(999); - shift_states.push_back(tokens_dw); - tokens_dw.clear(); - } - - fp = fopen(infile , "r"); - - if(fp == NULL) { - perror("Error opening file"); - return(-1); - } - - while (fgets(str, 600, fp) != NULL) { - k++; - complete_List.push_back(str); - - // remove all unwanted char - for (int i = 0; i < (int)delim.size(); i++) { - complete_List[k].erase(remove(complete_List[k].begin(), complete_List[k].end(), delim[i]), complete_List[k].end()); - } - - std::stringstream ss(complete_List[k]); - int dash = complete_List[k].find("-"); - int len2 =( (complete_List[k].size())-dash-2); - int size_l= sizeof(complete_List[k]); - - tokens_dw.push_back((DWORD)stoi(complete_List[k].substr(0, dash))); - tokens_dw.push_back((DWORD)stoi(complete_List[k].substr(dash+1, (len2)))); - int posInVec = tokens_dw[0]; - - shift_states[posInVec]=tokens_dw; - tokens_dw.clear(); - } - fclose(fp); - return(0); -} - -/*KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector) { - - for( int i=0; i< (int)All_Vector[0].size();i++) { - //number keys return unshifted value ( e.g. 1, not !) - if(SC <= 19) { - if ( All_Vector[0][i][0] == SC) - return All_Vector[1][i][1]; - } - - // other keys - if((SC > 19) ) { - if ( All_Vector[0][i][0] == SC) { - - // normal capital characters return the value of capital char ( e.g. A) - if ((All_Vector[1][i][2] >= 65 ) && (All_Vector[1][i][2] < 91 )) - return All_Vector[1][i][2]; - - // special characters return Keyman defined values (e.g. VK_ACCENT) - else - //return All_Vector[1][i][1]; - return mapVK_To_char(SC); - } - } - } -return 0; -}*/ -/* -bool test_In_Out(v_dw_3D All_Vector){ - - for ( int i=0; i<61;i++) - { - KMX_DWORD out_Other= get_VirtualKey_Other_From_SC(i,All_Vector); - KMX_DWORD out_US= get_VirtualKey_US_From_SC(i,All_Vector); - - if (out_Other==out_US) { - const wchar_t* ADD = L" "; - - wprintf(L" out = %i --- %i (%c) ", out_Other, out_US, *ADD); } - else { - const wchar_t* ADD = L"*" ; - wprintf(L" out = %i --- %i (%c) ", out_Other, out_US, *ADD); } - - wprintf(L"\n"); - } - - wprintf(L"-------------**\n"); - for ( int i=0; i<61;i++) - { - KMX_DWORD VK_Other= get_VirtualKey_Other_From_SC(i,All_Vector); - KMX_DWORD SC_Other= get_SC_From_VirtualKey_Other(VK_Other,All_Vector); - - if (i==SC_Other) { - const wchar_t* ADD = L" "; - wprintf(L"in %i ---> %i(%c) ---> %i (%c) \n", i, VK_Other,VK_Other, SC_Other ,*ADD); - } - - else { - const wchar_t* ADD = L"!"; - wprintf(L"in %i ---> %i(%c) ---> %i (%c) \n", i, VK_Other,VK_Other, SC_Other ,*ADD); - } - } - - wprintf(L" 3 -------------**\n"); - for ( int i=0; i<61;i++) - { - KMX_DWORD VK_Other= get_VirtualKey_US_From_SC(i,All_Vector); - KMX_DWORD SC_Other= get_SC_From_VirtualKey_US(VK_Other,All_Vector); - - if (i==SC_Other) { - const wchar_t* ADD = L" "; - wprintf(L"IN %i ---> %i(%c) ---> %i (%c) \n", i, VK_Other,VK_Other, SC_Other ,*ADD); - } - - else { - const wchar_t* ADD = L"!"; - wprintf(L"IN %i ---> %i(%c) ---> %i (%c) \n", i, VK_Other,VK_Other, SC_Other ,*ADD); - } - } -} -*/ -// ToDo write 2 func for return pos of Key_US and Pos of Key_Other -// return the Scancode of for given VirtualKey of Other US -KMX_DWORD get_position_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ - // find correct row of char in US - for( int i=0; i< (int)All_Vector[0].size()-1;i++) { - if ( ( All_Vector[0][i][1] == VK_US ) || ( All_Vector[0][i][2] == VK_US )) { - //if ( ( All_Vector[0][i][1] == VK_US ) ) { - //wprintf(L" VK_US= %i .. i= %i .. %i\t\t %i (%c) : %i (%c) +++ %i\t\t %i (%c) : %i (%c) \n",VK_US , i, - // All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2], - //All_Vector[1][i][0] , All_Vector[1][i][1] ,All_Vector[1][i][1] , All_Vector[1][i][2] , All_Vector[1][i][2] ); - return i; - } - } - return 0; //_S2 what do I return if not found?? -} - -/*// _S2 where to put this?? -std::wstring get_VirtualKey_US_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &caps, v_dw_3D &All_Vector) { - - int icaps; - KMX_DWORD pos = get_position_From_VirtualKey_US(iKey, All_Vector); - - if (ss >9) - return L""; - - if( ss < All_Vector[0][pos].size()-1) { - //if( ss < All_Vector[1][pos].size()-1) { // _S2 numbers need this - - if ( ss % 2 == 0) - icaps = ss+2-caps; - - if ( ss % 2 == 1) - icaps = ss+caps; - - return std::wstring(1, (int) All_Vector[0][pos][icaps]); - //return std::wstring(1, (int) All_Vector[1][pos][icaps]); - } - return L""; -} -*/ - -int replace_PosKey_with_Keycode(std::string in) { - int out = returnIfCharInvalid; - -// _S2 these are the Scancode-Values we use in Keyman ( = like the windows scancodes) - - if ( in == "key") out = 49; /* 0X VK_ */ // TOASK correct ??? - else if ( in == "key") out = 1; /* 0X02 VK_1 */ - else if ( in == "key") out = 2; /* 0X03 VK_2 */ - else if ( in == "key") out = 3; /* 0X04 VK_3 */ - else if ( in == "key") out = 4; /* 0X05 VK_4 */ - else if ( in == "key") out = 5; /* 0X06 VK_5 */ - else if ( in == "key") out = 6; /* 0X07 VK_6 */ - else if ( in == "key") out = 7; /* 0X08 VK_7 */ - else if ( in == "key") out = 8; /* 0X09 VK_8 */ - else if ( in == "key") out = 9; /* 0X0A VK_9 */ - else if ( in == "key") out = 10; /* 0X0B VK_0 */ - else if ( in == "key") out = 12; /* 0X0C VK_MINUS */ - else if ( in == "key") out = 13; /* 0X0D VK_EQUALS */ - - else if ( in == "key") out = 16; /* 0X10 VK_Q */ - else if ( in == "key") out = 17; /* 0X11 VK_W */ - else if ( in == "key") out = 18; /* 0X12 VK_E */ - else if ( in == "key") out = 19; /* 0X13 VK_R */ - else if ( in == "key") out = 20; /* 0X14 VK_T */ - else if ( in == "key") out = 21; /* 0X15 VK_Y */ - else if ( in == "key") out = 22; /* 0X16 VK_U */ - else if ( in == "key") out = 23; /* 0X17 VK_I */ - else if ( in == "key") out = 24; /* 0X18 VK_O */ - else if ( in == "key") out = 25; /* 0X19 VK_P */ - else if ( in == "key") out = 26; /* 0X1A VK_LEFTBRACE */ - else if ( in == "key") out = 27; /* 0X1B VK_RIGHTBRACE */ - - else if ( in == "key") out = 30; /* 0X1E VK_A */ - else if ( in == "key") out = 31; /* 0X1F VK_S */ - else if ( in == "key") out = 32; /* 0X20 VK_D */ - else if ( in == "key") out = 33; /* 0X21 VK_F */ - else if ( in == "key") out = 34; /* 0X22 VK_G */ - else if ( in == "key") out = 35; /* 0X23 VK_H */ - else if ( in == "key") out = 36; /* 0X24 VK_J */ - else if ( in == "key") out = 37; /* 0X25 VK_K */ - else if ( in == "key") out = 38; /* 0X26 VK_L */ - else if ( in == "key") out = 39; /* 0X27 VK_SEMICOLON */ - else if ( in == "key") out = 40; /* 0X28 VK_APOSTROPHE */ - else if ( in == "key") out = 41; /* 0X29 VK_GRAVE */ - - else if ( in == "key") out = 44; /* 0X2C VK_Z */ - else if ( in == "key") out = 45; /* 0X2D VK_X */ - else if ( in == "key") out = 46; /* 0X2E VK_C */ - else if ( in == "key") out = 47; /* 0X2F VK_V */ - else if ( in == "key") out = 48; /* 0X30 VK_B */ - else if ( in == "key") out = 49; /* 0X31 VK_N */ - else if ( in == "key") out = 50; /* 0X32 VK_M */ - else if ( in == "key") out = 51; /* 0X33 VK_ COMMA */ - else if ( in == "key") out = 52; /* 0X34 VK_DOT */ - else if ( in == "key") out = 53; /* 0X35 VK_SLASH */ - else if ( in == "key") out = 54; /* 0X36 VK_RIGHTSHIFT */ - else if ( in == "key") out = 55; /* 0X37 VK_RIGHTSHIFT */ - else if ( in == "key") out = 65; /* 0X20 VK_SPACE */ - - return out; -} - -/*KMX_DWORD find_dk_Character(v_dw_2D * p_dk_ComposeTable, KMX_DWORD first, KMX_DWORD second ) { - v_dw_2D dk_ComposeTable = * p_dk_ComposeTable; - for ( int i =0; i< (dk_ComposeTable).size()-1; i++) { - if (( (KMX_DWORD) dk_ComposeTable[i][0] == first) && ( (KMX_DWORD) dk_ComposeTable[i][1] == second) ) - return (KMX_DWORD) dk_ComposeTable[i][3]; - } - return 0; // _S2 what to return if not found? -}*/ - -int replace_KeyName_with_Keycode2(std::string in) { - int out = returnIfCharInvalid; - - // these are the Scancode-Values we use in Keyman ( = the windows scancodes+8 ) - // NAME IN SYMBOLS-FILE KEYCODE (LIN STYLE) (WIN STYLE) VK_US VK_DE - /*on US keyb;*/ - if ( in == "key") out = 49; /* VK_ */ // TOASK correct ??? - else if ( in == "key") out = 10; /* 0X02 VK_1 */ - else if ( in == "key") out = 11; /* 0X03 VK_2 */ - else if ( in == "key") out = 12; /* 0X04 VK_3 */ - else if ( in == "key") out = 13; /* 0X05 VK_4 */ - else if ( in == "key") out = 14; /* 0X06 VK_5 */ - else if ( in == "key") out = 15; /* 0X07 VK_6 */ - else if ( in == "key") out = 16; /* 0X08 VK_7 */ - else if ( in == "key") out = 17; /* 0X09 VK_8 */ - else if ( in == "key") out = 18; /* 0X0A VK_9 */ - else if ( in == "key") out = 19; /* 0X0B VK_0 */ - else if ( in == "key") out = 20; /*out = 61;*/ /* 0X0C VK_MINUS de ẞ*/ - else if ( in == "key") out = 21; /* 0X0D VK_EQUALS DE ' */ - - else if ( in == "key") out = 24; /* 0X10 VK_Q */ - else if ( in == "key") out = 25; /* 0X11 VK_W */ - else if ( in == "key") out = 26; /* 0X12 VK_E */ - else if ( in == "key") out = 27; /* 0X13 VK_R */ - else if ( in == "key") out = 28; /* 0X14 VK_T */ - else if ( in == "key") out = 29; /*out = 52;*/ /* 0X15 VK_Y */ - else if ( in == "key") out = 30; /* 0X16 VK_U */ - else if ( in == "key") out = 31; /* 0X17 VK_I */ - else if ( in == "key") out = 32; /* 0X18 VK_O */ - else if ( in == "key") out = 33; /* 0X19 VK_P */ - else if ( in == "key") out = 34; /*out = 17;*/ /* 0X1A VK_LEFTBRACE DE Ü */ - else if ( in == "key") out = 35; /*out = 18;*/ /* 0X1B VK_RIGHTBRACE DE + */ - - else if ( in == "key") out = 38; /* 0X1E VK_A */ - else if ( in == "key") out = 39; /* 0X1F VK_S */ - else if ( in == "key") out = 40; /* 0X20 VK_D */ - else if ( in == "key") out = 41; /* 0X21 VK_F */ - else if ( in == "key") out = 42; /* 0X22 VK_G */ - else if ( in == "key") out = 43; /* 0X23 VK_H */ - else if ( in == "key") out = 44; /* 0X24 VK_J */ - else if ( in == "key") out = 45; /* 0X25 VK_K */ - else if ( in == "key") out = 46; /* 0X26 VK_L */ - else if ( in == "key") out = 47; /*out = 59;*/ /* 0X27 VK_SEMICOLON DE Ö*/ - else if ( in == "key") out = 48; /*out = 51;*/ /* 0X28 VK_APOSTROPHE DE Ä */ - - else if ( in == "key") out = 52; /*out = 29;*/ /* 0X2C VK_Z */ - else if ( in == "key") out = 53; /* 0X2D VK_X */ - else if ( in == "key") out = 54; /* 0X2E VK_C */ - else if ( in == "key") out = 55; /* 0X2F VK_V */ - else if ( in == "key") out = 56; /* 0X30 VK_B */ - else if ( in == "key") out = 57; /* 0X31 VK_N */ - else if ( in == "key") out = 58; /* 0X32 VK_M */ - else if ( in == "key") out = 59; /* 0X33 VK_ COMMA */ - else if ( in == "key") out = 60; /* 0X34 VK_DOT */ - else if ( in == "key") out = 61; /*out = 16;*/ /* 0X35 VK_SLASH DE - */ - else if ( in == "key") out = 51; /* 0X29 VK_BKSLASH */ - else if ( in == "key") out = 63; /* 0X37 VK_RIGHTSHIFT */ - else if ( in == "key") out = 65; /* 0X20 ?? 39? VK_SPACE */ - - return out; -} - -/*int KMX_ToUnicodeEx( guint ScanCode, const BYTE *lpKeyStccate, PWCHAR pwszBuff, int shift_state, int caps,GdkKeymap *keymap) { - - KMX_DWORD kvl= KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK_OLD(keymap, ScanCode, shift_state); - - std::wstring character = KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, ScanCode, ShiftState(shift_state), caps); - pwszBuff[0]= * (PWCHAR) character.c_str(); - - if((kvl >= deadkey_min) && (kvl <= deadkey_max)) - return -1; - else - return 1; -}*/ - - -// takes capital letter of US returns cpital character of Other keyboard -/*KMX_DWORD KMX_get_KVUnderlying_From_KVUS_VEC(v_dw_3D &All_Vector,KMX_DWORD inUS) { - // loop and find char in US; then return char of Other - for( int i=0; i< (int)All_Vector[0].size();i++) { - for( int j=1; j< (int)All_Vector[0][0].size();j++) { - if((inUS == All_Vector[0][i][j] )) { - return All_Vector[1][i][2]; - } - } - } - return inUS; -}*/ - -/* -KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying( KMX_DWORD keycode) { - if ( keycode >7) - return (KMX_DWORD) ScanCodeToUSVirtualKey[keycode-8]; - return 0; //_S2 what to return if not found -}*/ - -// return RETURN NON SHIFTED CHAR [1] the VirtualKey of the US Keyboard for given Scancode -KMX_DWORD get_VirtualKey_Other_Layer1_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ - // find correct row of char in US - for( int i=0; i< (int)All_Vector[0].size()-1;i++) { - if ( All_Vector[0][i][0] == SC ) { - //wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- ",SC , i, All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2] ); - return All_Vector[1][i][1] ; - } - } - return 0; //_S2 what do I return if not found?? -} -// return RETURN NON SHIFTED CHAR [1] the VirtualKey of the US Keyboard for given Scancode -KMX_DWORD get_VirtualKey_Other_Layer2_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ - // find correct row of char in US - for( int i=0; i< (int)All_Vector[0].size()-1;i++) { - if ( All_Vector[0][i][0] == SC ) { - //wprintf(L" SC= %i .. i= %i .. %i:\t\t %i (%c) : %i (%c) --- ",SC , i, All_Vector[0][i][0] , All_Vector[0][i][1] ,All_Vector[0][i][1] , All_Vector[0][i][2] , All_Vector[0][i][2] ); - return All_Vector[1][i][2] ; - } - int ertzu=99; - } - - int ertzwrtu=99; - return 0; //_S2 what do I return if not found?? - - int eerurziurtzu=99; -} -// query All_Vector -// return RETURN NON SHIFTED CHAR [1] the VirtualKey of the Other Keyboard for given Scancode - -void GDK_Check(guint keyval){ - -gchar * gg = gdk_keyval_name (keyval); -guint to_up = gdk_keyval_to_upper ( keyval); - -guint to_low =gdk_keyval_to_lower ( keyval); -gboolean is_up= gdk_keyval_is_upper ( keyval); -gboolean is_low=gdk_keyval_is_lower ( keyval); -guint kv__frrom= gdk_keyval_from_name ((const gchar *) gg); -guint32 uni= gdk_keyval_to_unicode ( keyval); - -gchar * gg1 = gdk_keyval_name (keyval); -guint lower; -guint upper; -gdk_keyval_convert_case (*gg1, &lower,&upper); -gdk_keyval_convert_case (GDK_KEY_A, &lower,&upper); -gdk_keyval_convert_case (66, &lower,&upper); - - -/*guint *lower; guint *upper; -gdk_keyval_convert_case (GDK_KEY_A, lower,upper); -gdk_keyval_convert_case (GDK_KEY_a, lower,upper); -gdk_keyval_convert_case (GDK_KEY_4, lower,upper); -gdk_keyval_convert_case (GDK_KEY_dollar, lower,upper);*/ -} - -/*static void PrintKeymapForCode(GdkKeymap *keymap, guint keycode) { - GdkModifierType consumed; - GdkKeymapKey *maps; - GdkEventKey* event; - guint *keyvals; - guint *keyvalsReturn; - gint *n_entries; - gint count; - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return; - - for (int i = 0; i < count; i++) { - //if (maps[i].level > 0 || maps[i].group > 1) - // continue; - wprintf(L" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", - i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); - } - - for( int ii=10; ii<63; ii++) { - - //unshifted - GdkModifierType A1 = (GdkModifierType) (event->state & GDK_MODIFIER_MASK); - gdk_keymap_translate_keyboard_state (keymap, ii, (A1 ) , 0,keyvalsReturn, NULL, NULL, & consumed); - wprintf(L"\n ngdk_keymap_translate_keyboard_state: \t keycodeS=%u , n_entries %i\tUNSH: %s(%i)\t", ii, *n_entries, keyvalsReturn, *keyvalsReturn); - - //caps - gdk_keymap_translate_keyboard_state (keymap, ii, GDK_LOCK_MASK , 0,keyvalsReturn, NULL, NULL, & consumed); - wprintf(L" CAPS: %s(%i)\t", keyvalsReturn, *keyvalsReturn); - - //Shift - gdk_keymap_translate_keyboard_state (keymap, ii, GDK_SHIFT_MASK , 0,keyvalsReturn, NULL, NULL, & consumed); - wprintf(L" SH: %s(%i)\t", keyvalsReturn, *keyvalsReturn); - - //SHIFT+CAPS - GdkModifierType A4 = (GdkModifierType) (event->state | (GDK_SHIFT_MASK | GDK_LOCK_MASK)); - gdk_keymap_translate_keyboard_state (keymap, ii, A4 , 0,keyvalsReturn, NULL, NULL, & consumed); - wprintf(L" SH+CAPS: %s(%i) \t", keyvalsReturn, *keyvalsReturn); - - //ALT-GR - gdk_keymap_translate_keyboard_state (keymap, ii, GDK_MOD5_MASK , 0,keyvalsReturn, NULL, NULL, & consumed); - //wprintf(L"\n NEU1 ngdk_keymap_translate_keyboard_state: \t hardware_keycodeS=%u, keyvalsReturn: %s\n", 52, keyvalsReturn); - wprintf(L" ALTGR: %s(%i)", keyvalsReturn, *keyvalsReturn); - - //?? - gdk_keymap_translate_keyboard_state (keymap, ii, GDK_MOD1_MASK , 0,keyvalsReturn, NULL, NULL, & consumed); - // wprintf(L" NEU1 ngdk_keymap_translate_keyboard_state: \t hardware_keycodeS=%u, keyvalsReturn: %s\n", 52, keyvalsReturn); - //wprintf(L" A5: %s(%i)", keyvalsReturn, *keyvalsReturn); - - //?? - gdk_keymap_translate_keyboard_state (keymap, ii, GDK_MOD2_MASK , 0,keyvalsReturn, NULL, NULL, & consumed); - //wprintf(L" NEU1 ngdk_keymap_translate_keyboard_state: \t hardware_keycodeS=%u, keyvalsReturn: %s\n", 52, keyvalsReturn); - //wprintf(L" A6: %s(%i)", keyvalsReturn, *keyvalsReturn); - - //?? - gdk_keymap_translate_keyboard_state (keymap, ii, GDK_MOD3_MASK , 0,keyvalsReturn, NULL, NULL, & consumed); - // wprintf(L" NEU1 ngdk_keymap_translate_keyboard_state: \t hardware_keycodeS=%u, keyvalsReturn: %s\n", 52, keyvalsReturn); - // wprintf(L" A7: %s(%i)", keyvalsReturn, *keyvalsReturn); - - //?? - GdkModifierType A8 = (GdkModifierType) (event->state & ~consumed & GDK_MODIFIER_MASK); - gdk_keymap_translate_keyboard_state (keymap, ii, GDK_MOD4_MASK , 0,keyvalsReturn, NULL, NULL, & consumed); - //wprintf(L" NEU1 ngdk_keymap_translate_keyboard_state: \t hardware_keycodeS=%u, keyvalsReturn: %s\n", 52, keyvalsReturn); - //wprintf(L" A8: %s(%i)", keyvalsReturn, *keyvalsReturn); - } - - g_free(keyvals); - g_free(maps); -}*/ - -/*bool InsertKeyvalsFromKeymap(v_dw_3D &All_Vector,GdkKeymap * keymap){ - - // get the keyvals using GDK and copy into All_Vector - for(int i =0; i< (int) All_Vector[1].size();i++) { - // get key name US stored in [0][i][0] and copy to name in "other"-block[1][i][0] - All_Vector[1][i][0] = All_Vector[0][i][0]; - - // get Keyvals of this key and copy to unshifted/shifted in "other"-block[1][i][1] / block[1][i][2] - All_Vector[1][i][0+1] = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK_OLD(keymap,(All_Vector[1][i][0]),0); //shift state: unshifted:0 - All_Vector[1][i][1+1] = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK_OLD(keymap,(All_Vector[1][i][0]),1); //shift state: shifted:1 - - //wprintf(L" Keycodes US dw : %d (US): -- %i (%c) -- %i (%c) ---- (other): %i (%c) -- %i(%c) \n",(All_Vector[1][i][0]),All_Vector[0][i][1],All_Vector[0][i][1],All_Vector[0][i][2],All_Vector[0][i][2],All_Vector[1][i][1] ,All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); - //wprintf(L" Keycodes ->Other dw:-: %d (US): -- %i (%c) -- %i (%c) \n\n",(All_Vector[1][i][0]),All_Vector[1][i][1],All_Vector[1][i][1],All_Vector[1][i][2],All_Vector[1][i][2]); - } -}*/ - -//_S2 REVIEW this is for testing only and needs to go later -/*std::vector reduce_alDead(GdkKeymap*keymap,std::vector dk_big) {/ - - - std::vector dk_underlying; - - - - std::vector dk_small; - bool foundInSmall=false; - - for ( int i=1; iKMX_DeadCharacter()==94 || dk_big[i]->KMX_DeadCharacter()==96 || dk_big[i]->KMX_DeadCharacter()==180|| dk_big[i]->KMX_DeadCharacter()==126|| dk_big[i]->KMX_DeadCharacter()==168)) { - for( int k=0; k< dk_small.size();k++) { - if(dk_big[i]->KMX_DeadCharacter() == dk_small[k]->KMX_DeadCharacter()) - foundInSmall=true; - } - if(!foundInSmall) - dk_small.push_back(dk_big[i]); - foundInSmall=false; - } - } - return dk_small; -}*/ - - - -/*// _S2 TODO -KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK_old(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky) { - GdkKeymapKey *maps; - guint *keyvals; - gint count; - KMX_DWORD out; - - -//in: keycode, shift_state_pos,keymap -//(out): dky-code if it is a deadkey; if not keep last -//out: keyval for char; FFFF for dk - - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return 0; - //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html - - if (!(shift_state_pos <= count)) - return 0; - - if (!(keycode <= 94)) - return 0; - - // _S2 can I use that????? - KMX_DWORD deadkey = (KMX_DWORD) keyvals[shift_state_pos]; - //wprintf(L" keyvals[shift_state_pos]: %i %i %i %i----", keyvals[0],keyvals[1],keyvals[2],keyvals[3]); - - dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str(); - out = KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0); - //wprintf(L" out is :.....................................%i\n", out); - - // _S2 g_free used everywhere? - g_free(keyvals); - g_free(maps); - - return out; -} -*/ - -/* _S2 probably not needed //_S2 REVIEW this is for testing only and needs to go later -std::vector reduce_alDead(std::vector dk_big) { - std::vector dk_small; - bool foundInSmall=false; - - for ( int i=1; iKMX_DeadCharacter()==94 || dk_big[i]->KMX_DeadCharacter()==96 || dk_big[i]->KMX_DeadCharacter()==180|| dk_big[i]->KMX_DeadCharacter()==126|| dk_big[i]->KMX_DeadCharacter()==168)) { - for( int k=0; k< dk_small.size();k++) { - if(dk_big[i]->KMX_DeadCharacter() == dk_small[k]->KMX_DeadCharacter()) - foundInSmall=true; - } - if(!foundInSmall) - dk_small.push_back(dk_big[i]); - foundInSmall=false; - } - } - return dk_small; -} -*/ - - -// _S2 DEADKEY STUFF - DO NOT REVIEW YET -/*std::wstring convert_DeadkeyValues_ToChar_old(int in) { - - KMX_DWORD lname; - - if (in < (int) deadkey_min) { // no deadkey; no Unicode - if (!IsKeymanUsedKeyVal(std::wstring(1, in))) - return L"\0"; - return std::wstring(1, in); - } - else { - std::string long_name((const char*) gdk_keyval_name (in)); - - if ( long_name.substr (0,2) == "U+" ) // U+... Unicode value - return CodePointToWString(in-0x1000000); - - lname = convertNamesToIntegerValue( wstring_from_string(long_name)); // 65106 => "dead_circumflex " => 94 => "^" - - if (lname != returnIfCharInvalid) { - return std::wstring(1, lname ); - } - else - return L"\0"; - } - return L"\0"; -}*/ - - - // _S2 DEADKEY STUFF - DO NOT REVIEW YET --- Do we need this at all? - // _S2 ToDo ToUnicodeEx needs to be replaced here - /* DeadKey *KMX_ProcessDeadKey( - UINT iKeyDead, // The index into the VirtualKey of the dead key - ShiftState shiftStateDead, // The shiftstate that contains the dead key - KMX_BYTE *lpKeyStateDead, // The key state for the dead key - std::vector rgKey, // Our array of dead keys - bool fCapsLock, // Was the caps lock key pressed? - KMX_HKL KMX_hkl, // The keyboard layout - GdkKeymap *keymap) { // _S2 keymap, The keyboard layout - - - KMX_BYTE lpKeyState[256]; - DeadKey *deadKey = new DeadKey(rgKey[iKeyDead]->KMX_GetShiftState(shiftStateDead, fCapsLock)[0]); - -KMX_WCHAR sbBuffer1[16]; - KMX_WCHAR sbBuffer2[16]; - KMX_WCHAR sbBuffer3[16]; - KMX_WCHAR sbBuffer4[16]; - KMX_WCHAR sbBuffer5[16]; - int rc1 = KMX_ToUnicodeEx(49, lpKeyState, sbBuffer1, 0, 0, keymap) ; - int rc4 = KMX_ToUnicodeEx(21, lpKeyState, sbBuffer4, 0, 0, keymap) ; - int rc3 = KMX_ToUnicodeEx( 3, lpKeyState, sbBuffer3, 0, 0, keymap) ; - /*int rc2 = KMX_ToUnicodeEx( 49, lpKeyState, sbBuffer2, 0, 0, keymap) ; - int rc5 = KMX_ToUnicodeEx( 65, lpKeyState, sbBuffer5, 0, 0, keymap) ;*/ - - /*int rc1 = KMX_ToUnicodeEx(192, lpKeyState, sbBuffer1, 0, 0, keymap) ; - int rc4 = KMX_ToUnicodeEx(220, lpKeyState, sbBuffer4, 0, 0, keymap) ; - int rc3 = KMX_ToUnicodeEx( 3, lpKeyState, sbBuffer3, 0, 0, keymap) ; - int rc2 = KMX_ToUnicodeEx( 49, lpKeyState, sbBuffer2, 0, 0, keymap) ; - int rc5 = KMX_ToUnicodeEx( 65, lpKeyState, sbBuffer5, 0, 0, keymap) ;*/ - - - -/* - for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { - if (rgKey[iKey] != NULL) { - KMX_WCHAR sbBuffer[16]; - - for (ShiftState ss = Base; ss <= KMX_MaxShiftState(); ss = (ShiftState)((int)ss+1)) { - int rc = 0; - if (ss == Menu || ss == ShftMenu) { - // Alt and Shift+Alt don't work, so skip them - continue; - } - - for (int caps = 0; caps <= 1; caps++) { - - //------_S2 To find a deadkey in a possibly messed up key ------------------------ - // _S2 My fun does not loop to shorten keys :-(( - - // First the dead key - while (rc >= 0) { - // We know that this is a dead key coming up, otherwise - // this function would never have been called. If we do - // *not* get a dead key then that means the state is - // messed up so we run again and again to clear it up. - // Risk is technically an infinite loop but per Hiroyama - // that should be impossible here. - - rc = KMX_ToUnicodeEx(rgKey[iKeyDead]->SC(), lpKeyState, sbBuffer, ss, caps, keymap); - //wprintf(L"ikey: %i rc = %i\n",iKey,rc); - rc=-1; //_S2 - } - - //---------------------------------------------------------------------------------- - - // Now fill the key state for the potential base character - KMX_FillKeyState(lpKeyState, ss, (caps != 0)); - - //---------------------------------------------------------------------------------- - - rc = KMX_ToUnicodeEx( rgKey[iKey]->SC(), lpKeyState, sbBuffer, ss, caps, keymap) ; - - //--------- ONE character found = combined char (e.g. â ) -------------------------- - // ***** E.G: ToUnicodeEx FOUND Â ***** // - - if (rc == 1) { - Â */ // That was indeed a base character for our dead key. - // And we now have a composite character. Let's run - // through one more time to get the actual base - - // character that made it all possible? - - // _s2 store combined char - // ***** E.G: combchar = Â ***** // - /*KMX_WCHAR combchar = sbBuffer[0]; - - // _S2 again split to get base char ( e.g. a) - // ***** E.G: ToUnicodeEx FOUND A ***** // - rc = KMX_ToUnicodeEx(rgKey[iKey]->SC(), lpKeyState, sbBuffer, ss, caps, keymap) ; - - KMX_WCHAR basechar = sbBuffer[0]; - - if (deadKey->KMX_DeadCharacter() == combchar) { - // Since the combined character is the same as the dead key, - // we must clear out the keyboard buffer. - //KMX_ClearKeyboardBuffer(VK_DECIMAL, rgKey[VK_DECIMAL]->SC(), KMX_hkl); - KMX_ClearKeyboardBuffer(); - } - - if ((((ss == Ctrl) || (ss == ShftCtrl)) && - (KMX_IsControlChar(basechar))) || - (basechar == combchar)) { - // ToUnicodeEx has an internal knowledge about those - // VK_A ~ VK_Z keys to produce the control characters, - // when the conversion rule is not provided in keyboard - // layout files - - // Additionally, dead key state is lost for some of these - // character combinations, for unknown reasons. - - // Therefore, if the base character and combining are equal, - // and its a CTRL or CTRL+SHIFT state, and a control character - // is returned, then we do not add this "dead key" (which - // is not really a dead key). - continue; - } - - if (!deadKey->KMX_ContainsBaseCharacter(basechar)) { - deadKey->KMX_AddDeadKeyRow(basechar, combchar); - } - } - - //---------no valid key combi -> IGNORE --------------------------------------------- - - else if (rc > 1) { - // Not a valid dead key combination, sorry! We just ignore it. - } - - //---------another dead key-> IGNORE ----------------------------------------------- - else if (rc < 0) { - // It's another dead key, so we ignore it (other than to flush it from the state) - //ClearKeyboardBuffer(VK_DECIMAL, rgKey[VK_DECIMAL]->SC(), KMX_hkl); - KMX_ClearKeyboardBuffer(); - } - } - } - } - } - return deadKey; - }*/ - - -// _S2 can go later -/*void test_keyboard_S2(LPKMX_KEYBOARD kmxfile); -void TestKey_S2(LPKMX_KEY key) ; -void TestGroup_S2(LPKMX_GROUP group) ; -void TestKeyboard_S2(LPKMX_KEYBOARD kbd) ;*/ - - -// _S2 can go later -/*void test_keyboard_S2(LPKMX_KEYBOARD kmxfile){ - TestKeyboard_S2(kmxfile); -} - -void TestKey_S2(LPKMX_KEY key, int iii, int gr) { - - KMX_WCHAR* PP= key->dpOutput; - int z=0; - - if( *(key->dpOutput+1) != 0) { - wprintf(L"\n group[%i] dpKeyArray[%i] ",gr, iii); - int tzuiop=0; - do { - wprintf(L"%i\t", *(PP+z )); - z++; - } while (*(PP+z) !=0); - } - //if ((*(PP+z) !=0)) wprintf(L" _\n"); -} - -void TestGroup_S2(LPKMX_GROUP group ,int gr) { - for(unsigned int i = 0; i < group->cxKeyArray; i++) { - TestKey_S2(&group->dpKeyArray[i],i,gr); - } -} - -void TestKeyboard_S2(LPKMX_KEYBOARD kbd) { - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { - wprintf(L"\nkbd->dpGroupArray[%i] \n",i); - TestGroup_S2(&kbd->dpGroupArray[i], i); - } - } -}*/ - -/*void check_rgkey_S2( std::vector rgKey, int i) { - - wprintf(L" rgfDeadkey[%i]: \t%i %i %i %i %i %i %i %i %i %i\n", i, - rgKey[i]->get_m_rgfDeadkey(0,0), rgKey[i]->get_m_rgfDeadkey(0,1), - rgKey[i]->get_m_rgfDeadkey(1,0), rgKey[i]->get_m_rgfDeadkey(1,1), - rgKey[i]->get_m_rgfDeadkey(2,0), rgKey[i]->get_m_rgfDeadkey(2,1), - rgKey[i]->get_m_rgfDeadkey(3,0), rgKey[i]->get_m_rgfDeadkey(3,1), - rgKey[i]->get_m_rgfDeadkey(4,0), rgKey[i]->get_m_rgfDeadkey(4,1), - rgKey[i]->get_m_rgfDeadkey(5,0), rgKey[i]->get_m_rgfDeadkey(5,1), - rgKey[i]->get_m_rgfDeadkey(6,0), rgKey[i]->get_m_rgfDeadkey(6,1), - rgKey[i]->get_m_rgfDeadkey(7,0), rgKey[i]->get_m_rgfDeadkey(7,1), - rgKey[i]->get_m_rgfDeadkey(8,0), rgKey[i]->get_m_rgfDeadkey(8,1), - rgKey[i]->get_m_rgfDeadkey(9,0), rgKey[i]->get_m_rgfDeadkey(9,1)); -} - -*/ - -/*void TestKey_S21(LPKMX_KEY key, int iii, int gr) { - - KMX_WCHAR* PP= key->dpOutput; - int z=0; - - if( *(key->dpOutput+1) != 0) { - wprintf(L"\n group[%i] dpKeyArray[%i] (key->key: %i) ",gr, iii, key->Key); - int tzuiop=0; - do { - wprintf(L"%i\t", *(PP+z )); - z++; - } while (*(PP+z) !=0); - } - //if ((*(PP+z) !=0)) wprintf(L" _\n"); -} - -void TestGroup_S21(LPKMX_GROUP group ,int gr) { - for(unsigned int i = 0; i < group->cxKeyArray; i++) { - TestKey_S21(&group->dpKeyArray[i],i,gr); - } -} - -void TestKeyboard_S21(LPKMX_KEYBOARD kbd) { - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { - wprintf(L"\nkbd->dpGroupArray[%i] \n",i); - TestGroup_S21(&kbd->dpGroupArray[i], i); - } - } -} -// _S2 can go later -void test_keyboard_S21(LPKMX_KEYBOARD kmxfile){ - //TestKeyboard_S21(kmxfile); -}*/ - - - - -/* -KMX_DWORD KMX_get_rc_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos) { - GdkKeymapKey *maps; - guint *keyvals; - gint count; - KMX_DWORD out; - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return 0; - //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html - - if (!(shift_state_pos <= count)) - return 0; - - if (!(keycode <= 94)) - return 0; - - out = KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos,0); - - // _S2 g_free used everywhere? - g_free(keyvals); - g_free(maps); - - return out; -} -*/ - -// _S2 naming?? the original -/*int KMX_ToUnicodeEx_OLD(guint ScanCode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, int shift_state, int caps,GdkKeymap *keymap) { - - KMX_DWORD rc = KMX_get_rc_From_KeyCodeUnderlying_GDK(keymap,ScanCode, shift_state); - - std::wstring character= KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK(keymap, ScanCode, ShiftState(shift_state), caps); - pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(character).c_str(); - - if((rc == 0)) - return -0; - else if((rc == 0xFFFE)) - return 0; - else if((rc == 0xFFFF)) - return -1; - else - return 1; -}*/ - - -// _S2 can go later -/*KMX_DWORD writeKeyvalsFromKeymap(GdkKeymap *keymap, guint keycode, int shift_state_pos) { - GdkKeymapKey *maps; - guint *keyvals; - gint count; - KMX_DWORD out; - for ( int ii =1; ii< 255;ii++) { - - KMX_DWORD out = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK_OLD(keymap,ii,0); - KMX_DWORD out2= KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK_OLD(keymap,ii,1); - wprintf(L" ii = %i --> keymap = %i (%c)..%i(%c) \n",ii, out,out, out2,out2); - } -}*/ - -// _S2 not needed later -bool test(v_dw_3D &V) { - std::string extra = " "; - wprintf(L" +++++++ dimensions of whole Vector in test()\t\t\t\t\t\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); - wprintf(L"\n+++++++++ print some characters of US and Other +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - - for ( int k=0; k<(int)V[0].size(); k++) { - if(V[0][k][2] != V[1][k][2] ) - extra = " *** "; - else - extra = " "; - - if (V[0].size()>0) { - /*wprintf(L" row (US) ...... SC= %i .. %i (%c) .. %i (%c) .. --- ",V[0][k][0] , V[0][k][1] , V[0][k][1] , V[0][k][2] , V[0][k][2] ); - wprintf(L" \n"); - wprintf(L" row (Other)..... SC= %i .. %i (%c) .. %i (%c) .. %s \n", V[1][k][0] , V[1][k][1], V[1][k][1] , V[1][k][2], V[1][k][2] , extra.c_str()); - wprintf(L" \n");*/ - } - } - wprintf(L"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - return true; -} - -bool test_single(v_dw_3D &V) { - std::string extra = " "; - wprintf(L" +++++++ dimensions of single Vector in test_single()\t\t\t\t\t\t %li..%li..%li\n", V.size(), V[0].size(),V[0][0].size()); - wprintf(L"\n +++++++++ print characters of SINGLE DW ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - - for ( int k=0; k<(int)V[0].size(); k++) { - if (V[0].size()>0) { - wprintf(L" row (US) ...... %i .. %i (%c) .. %i (%c) ........ \n", V[0][k][0] , V[0][k][1] ,V[0][k][1] , V[0][k][2], V[0][k][2] ); - } - } - wprintf(L" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - return true; -} - -// return the position of the VK in Other in All_Vector -/*KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector){ - // find correct row of char in US - for( int i=0; i< (int)All_Vector[0].size()-1;i++) { - if ( ( All_Vector[1][i][1] == VK_Other ) || ( All_Vector[1][i][2] == VK_Other )) { - return i; - } - } - return 0; //_S2 what do I return if not found?? -}*/// _S2 REMOVE -void Try_GDK(GdkKeymap *keymap, guint k ) { - GdkKeymapKey *maps; - guint *keyvals; - gint count; - - // key 35(DE) = 187= OEM_PLUS; - -gdk_keymap_get_entries_for_keycode (keymap, k, &maps, &keyvals, &count); -wprintf(L"----------------------------\nprinting out the characters given by keypress of key SC/Keycode:%i\n",k); - for (int i = 0; i < count; i++) { - //if (maps[i].level > 0 || maps[i].group > 1) - // continue; - wprintf(L" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", - i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); - } - -wprintf(L"----------------------------\n"); -// finds a character on a key(KeyNr/SC) according to shiftstate/caps -// in: SC out: AsciiChar - - GdkModifierType consumed; - /* GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); - gdk_keymap_translate_keyboard_state (keymap, k, MOD_base , 0, keyvals, NULL, NULL, & consumed); - int kv= (int)*keyvals; - //std::wstring kv_ws= std::wstring(1, (int) *keyvals); - wprintf(L" gdk_keymap_translate_keyboard_state (keycode/SC %i) gives unshifted: %i (%c) -- ", k, kv,kv ); - - GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); - gdk_keymap_translate_keyboard_state (keymap, k, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); - int kv1= (int)*keyvals; - //std::wstring kv_ws1= std::wstring(1, (int) *keyvals); - wprintf(L" and shifted %i (%c) \n", kv1,kv1 );*/ - -for ( int iii=1; iii< 66;iii++) -{ - GdkModifierType consumed; - GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); - gdk_keymap_translate_keyboard_state (keymap, iii, MOD_base , 0, keyvals, NULL, NULL, & consumed); - int kv= (int)*keyvals; - //std::wstring kv_ws= std::wstring(1, (int) *keyvals); - wprintf(L" gdk_keymap_translate_keyboard_state (keycode/SC %i) gives unshifted: %i (%c) -- \t", iii, kv,kv ); - - GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); - gdk_keymap_translate_keyboard_state (keymap, iii, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); - int kv1= (int)*keyvals; - //std::wstring kv_ws1= std::wstring(1, (int) *keyvals); - wprintf(L" and shifted \t%i(%c) \n", kv1,kv1 ); - -} - - -wprintf(L"----------------------------\n"); -// finds a character on a key(KeyNr/SC) according to shiftstate/caps -// in: SC out: AsciiChar - gchar * gch; - char * ch; - - - - GdkModifierType consumedS; -for ( int iii=1; iii< 66;iii++) -{ /*gchar * gch1; - gch1 = gdk_keyval_name ((guint) iii); - std::string str_ch((char*)gch1);*/ - - gch = gdk_keyval_name ((guint) iii); - ch = (char*) gch; - std::string str_ch(ch); - //wprintf(L" key nr %i has the name: -- %s ", iii, str_ch.c_str()); - - - GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); - gdk_keymap_translate_keyboard_state (keymap, iii, MOD_base , 0, keyvals, NULL, NULL, & consumedS); - int kv= (int)*keyvals; - //std::wstring kv_ws= std::wstring(1, (int) *keyvals); - wprintf(L" (keycode/SC %i) has the name: %s \t\t---- gives unshifted: %i (%c) -- \t", iii, str_ch.c_str(),kv,kv ); - - GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); - gdk_keymap_translate_keyboard_state (keymap, iii, MOD_Shift , 0, keyvals, NULL, NULL, & consumedS); - int kv1= (int)*keyvals; - //std::wstring kv_ws1= std::wstring(1, (int) *keyvals); - wprintf(L" and shifted \t%i(%c) \n", kv1,kv1 ); - -} - -wprintf(L"----------------------------\n"); - GdkKeymapKey **keys1; - guint kval = 42; - gint *n_keys; - gboolean gboo = gdk_keymap_get_entries_for_keyval ( keymap, kval, keys1, n_keys); - wprintf(L" gdk_keymap_get_entries_for_keyval gives %i keys for this keyval( %i) :\n", *n_keys),(int) kval; - - //for (int i = 0; i < *n_keys; i++) { - for (int i = 0; i < 1; i++) { - wprintf(L" character 43 can be obtained by pressing %i keys:, keys1[%i]\n", - *n_keys, *keys1[i]); - int iii=99; - } - -wprintf(L"----------------------------\n"); -// converts the Ascii-nr to the name specified in symbols-file( 35 -> numbersign( KEY_numbersign); 65 -> A( KEY_A) -// in: AsciiNr out: name in symbolfile - gchar * gch1; - char * ch1; - guint *keyvalsU; - guint *keyvalsS; - -for ( int ii=10; ii<65;ii++) { - gch1 = gdk_keyval_name ((guint) ii); - ch1 = (char*) gch; - std::string str_ch1(ch1); - wprintf(L" key nr %i has the name: -- %s \n ", ii, str_ch1.c_str()); - - //g_free(keyvalsU); - //g_free(maps); - - /*gdk_keymap_translate_keyboard_state (keymap, ii, MOD_Shift , 0, keyvalsS, NULL, NULL, & consumed); - int char_shifted = (int) *keyvalsS;*/ - - /* GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); - gdk_keymap_translate_keyboard_state (keymap, ii, MOD_base , 0, keyvalsS, NULL, NULL, & consumed); - int char_shifted = (int) *keyvalsS;*/ - - /* GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); - gdk_keymap_translate_keyboard_state (keymap, ii, MOD_base , 0, keyvalsU, NULL, NULL, & consumed); - int char_unshifted = (int) *keyvalsU;*/ - - //wprintf(L" key nr %i has the name: -- %ls \t\tand prints --> %c\t(%i)-\n ", ii, gch.c_str(), char_shifted,char_shifted); - - //wprintf(L", %c (%i) -- %c (%i) \n", ii,ii,char_shifted,char_shifted); -} -wprintf(L"----------------------------\n"); -// convert the content of a key which is more than 1 char long to the char ( plus -> +) -// in: name in symbolfile out: Ascii-Nr -std::string name = "plus"; -const char* name_ch = name.c_str(); - -guint name_int= gdk_keyval_from_name (name_ch); -wprintf(L" key with name '%s' has the (ASCII)value: :%i(%c)\n", name.c_str(), name_int,name_int); - -wprintf(L"----------------------------\n"); - -guint32 g32= gdk_keyval_to_unicode ('R'); -wprintf(L"----------------------------\n"); -guint g= gdk_unicode_to_keyval ('\u0052'); -wprintf(L"----------------------------\n"); - -} - -std::wstring PrintKeymapForCodeReturnKeySym(GdkKeymap *keymap, guint VK, v_dw_3D &All_Vector, ShiftState ss, int caps ){ -//GdkKeymap *keymap; - GdkModifierType consumed; - GdkKeymapKey *maps; - GdkEventKey* event; - guint *keyvals; - guint *keyvals_shift; - gint *n_entries; - gint count; - guint keycode; - - GdkKeymapKey* keys; - gint n_keys; - - - gdk_keymap_get_entries_for_keyval(keymap, VK,&keys,&n_keys); - - - int pos_1 =get_position_From_VirtualKey_Other(VK , All_Vector, 99); - // wprintf(L" get_position_From_VirtualKey_Other %i of VK%i (%c) \n", pos_1, VK,VK); - keycode = All_Vector[1][pos_1][0]; - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return L"1"; - - - //unshifted - if (( ss == Base ) && ( caps == 0 )) { - GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); - std::wstring rV1= std::wstring(1, (int) *keyvals); - - gchar * gg1 = gdk_keyval_name (*keyvals); - guint lower; - guint upper; - gdk_keyval_convert_case (*gg1, &lower,&upper); - std::wstring rv2= std::wstring(1, (int) upper); - std::wstring rv1= std::wstring(1, (int) *keyvals); - - //return rv2; - return std::wstring(1, (int) *keyvals); - } - - //SHIFT+CAPS - else if ( ( ss == Shft ) && ( caps ==1 )) { - GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); - - std::wstring rV1= std::wstring(1, (int) *keyvals); - - gchar * gg1 = gdk_keyval_name (*keyvals); - guint lower; - guint upper; - gdk_keyval_convert_case (*gg1, &lower,&upper); - std::wstring rv2= std::wstring(1, (int) upper); - - std::wstring rv1= std::wstring(1, (int) *keyvals); - //return rv2; - return std::wstring(1, (int) *keyvals); - - } - - //Shift - else if (( ss == Shft ) && ( caps == 0 )) { - GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); - std::wstring rV1= std::wstring(1, (int) *keyvals); - - -gchar * gg1 = gdk_keyval_name (*keyvals); -guint lower; -guint upper; -gdk_keyval_convert_case (*gg1, &lower,&upper); - - -//keyvals_shift = gg1; - std::wstring rv2= std::wstring(1, (int) upper); - - std::wstring rv1= std::wstring(1, (int) *keyvals); - return std::wstring(1, (int) *keyvals); - - } - - //caps - else if (( ss == Base ) && ( caps == 1 )) { - GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); - - std::wstring rV1= std::wstring(1, (int) *keyvals); - - gchar * gg1 = gdk_keyval_name (*keyvals); - guint lower; - guint upper; - gdk_keyval_convert_case (*gg1, &lower,&upper); - std::wstring rv2= std::wstring(1, (int) upper); - std::wstring rv1= std::wstring(1, (int) *keyvals); - - //return rv2; - return std::wstring(1, (int) *keyvals); - - } - /*//ALT-GR - else if { - GdkModifierType MOD_AltGr = (GdkModifierType) ( GDK_MOD5_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - return *keyvals; - }*/ - - else - return L"0"; -} - -/* -bool write_rgKey_ToFile(std::vector rgKey ){ - std::string RGKey_FileName="/Projects/keyman/keyman/linux/mcompile/keymap/rgKey_lin.txt"; - - std::wofstream TxTFile(RGKey_FileName); - for ( int i=0; i< rgKey.size();i++) { - if(rgKey[i] != NULL) { - TxTFile << rgKey[i]->VK() << "-" << rgKey[i]->SC()<< " -> ( " << rgKey[i]->KMX_GetShiftState(Base, 0) << "-" << rgKey[i]->KMX_GetShiftState(Base, 1) << " )" - << " *-* ( " << rgKey[i]->KMX_GetShiftState(Shft, 0) << "-" << rgKey[i]->KMX_GetShiftState(Shft, 1) << " )"; - TxTFile << "\n"; - } - } - TxTFile.close(); - return true; -} - - - - - // _S2 can go later: check if all correct - /*write_rgKey_ToFile(rgKey) ; - v_dw_2D V_lin,V_win,V_map; - write_RGKEY_FileToVector(V_lin, "rgKey_lin.txt"); - write_RGKEY_FileToVector(V_win, "rgKey_Win.txt"); - write_RGKEY_FileToVector(V_map, "map.txt"); - CompareVector_To_VectorOfFile_RGKEY( V_win, V_lin,V_map);*/ - -/* // _S2 maybe not needed -bool get_US_Keysym_From_OtherKeysym(v_str_3D &All_Vector, int inOther, int &OutUS){ - - MyCoutW(L" #### get_US_Char_FromOther of keymap started", 1); - // loop and find char in Other; then find char of US - for( int i=0; i< All_Vector[1].size();i++) { - for( int j=1; j< (int)All_Vector[1][0].size();j++) { - - int KeysymUS = (int) *All_Vector[0][i][j].c_str(); - int KeysymOther = (int) *All_Vector[1][i][j].c_str(); - std::wstring KeysymUS_wstr = wstring_from_string(All_Vector[1][i][j]); - - if( inOther == KeysymOther ) { - OutUS = KeysymUS; - return true; - } - } - } - MyCoutW(L" #### get_US_Char_FromOther of keymap ended", 1); - return true; -}*/ - -// _S2 maybe I will need that later?? - -/* static xkb_keysym_t get_ascii(struct xkb_state *state, xkb_keycode_t keycode) { - struct xkb_keymap *keymap; - xkb_layout_index_t num_layouts; - xkb_layout_index_t layout; - xkb_level_index_t level; - const xkb_keysym_t *syms; - int num_syms; - - keymap = xkb_state_get_keymap(state); - num_layouts = xkb_keymap_num_layouts_for_key(keymap, keycode); - - for (layout = 0; layout < num_layouts; layout++) { - level = xkb_state_key_get_level(state, keycode, layout); - num_syms = xkb_keymap_key_get_syms_by_level(keymap, keycode, - layout, level, &syms); - if (num_syms != 1) - continue; - - if (syms[0] > 0 && xkb_keysym_to_utf32(syms[0]) < 128) - return syms[0]; - } - - return XKB_KEY_NoSymbol; -} -*/ - - /*static xkb_keysym_t get_ascii_SAB(xkb_keycode_t keycode) { - - xkb_layout_index_t num_layouts; - xkb_layout_index_t layout; - xkb_level_index_t level; - const xkb_keysym_t *syms; - int num_syms; - - struct xkb_context *ctx; - - ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS); - if (!ctx) - MyCoutW(L" # Error in xkb_context_new", 1); - - - - -// get a keymap from a given name ( is) -struct xkb_keymap *keymap_is; - struct xkb_rule_names names = { - // Example RMLVO for Icelandic Dvorak. - .rules = NULL, - .model = "pc105", - .layout = "is", - .variant = "dvorak", - .options = "terminate:ctrl_alt_bksp" - }; - keymap_is = xkb_keymap_new_from_names(ctx, &names, XKB_KEYMAP_COMPILE_NO_FLAGS); - - if (!keymap_is) - MyCoutW(L" # Error in xkb_keymap_new_from_names", 1); - - // how many layouts are in keymap ( here is: 4) - num_layouts = xkb_keymap_num_layouts_for_key(keymap_is, keycode); - std::wcout << L" num_layouts: " << num_layouts << L"\n"; - - for (layout = 0; layout < num_layouts; layout++) { - - // how many levels do we have per key e.g. [a, A, ä, ascitilde ] - std::wcout << L" layout: Nr" << layout << L"\n"; - xkb_level_index_t level = xkb_keymap_num_levels_for_key ( keymap_is, keycode, layout ) ; - std::wcout << L" we have level nr of : " << level << L"\n"; - -for( int j=0; j< level;j++) -{ - std::wcout << L" j: " << j << L"\n"; - // get the keysym(characzter) in level level ( get a for level 1; A for level 2;) - num_syms = xkb_keymap_key_get_syms_by_level(keymap_is, keycode, layout, j, &syms); - std::wcout << L" num_syms(j): " << num_syms << L"\n"; - - // if no entry for this level - if (num_syms != 1) - continue; - - if (syms[0] > 0 && xkb_keysym_to_utf32(syms[0]) < 128) - return syms[0]; - - } - } - - return XKB_KEY_NoSymbol; -}*/ -// bak all tries for DoConvert here: -/* - -//#include "XKeyboard.h" -#include "/usr/include/libxklavier/xklavier.h" -#include "/usr/include/libxklavier/xkl_config_item.h" -#include "/usr/include/libxklavier/xkl_config_rec.h -#include "/usr/include/libxklavier/xkl_config_registry.h -#include "/usr/include/libxklavier/xkl_engine.h -#include "/usr/include/libxklavier/xkl_engine_marshal.h -#include "/usr/include/libxklavier/xkl-enum-types.h -#include "/usr/include/libxklavier/xklavier.h" -#include "/usr/include/libxklavier/xklavier.h" - - - - -std::wcout << L"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\n"; -std::string st = std::locale("").name() ; -std::wstring wstr = wstring_from_string(st); - -std::wcout << wstr; -std::wcout << L"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\n"; -xklgetg -//const char** ccc = XklGetGroupNames ( ) ; -//xkl_engine_get_groups_names -//const char** cccc = XkbGetNames ( ) ; -/* - Display *dpy = XOpenDisplay(NULL); - - if (dpy == NULL) { - fprintf(stderr, "Cannot open display\n"); - exit(1); - } - - XkbStateRec state; - XkbGetState(dpy, XkbUseCoreKbd, &state); - - XkbDescPtr desc = XkbGetKeyboard(dpy, XkbAllComponentsMask, XkbUseCoreKbd); - char*symbols = XGetAtomName(dpy, desc->names->symbols); - //char *group = XGetAtomName(dpy, desc->names->groups[state.group]); - //printf("Full name: %s\n", group); - -XKeyboard xkb; - -std::string cGrpName=xkb.currentGroupName(); //return somethings like "USA" -std::string cGrpSymb=xkb.currentGroupSymbol(); //return somethings like "us" - -xkb.setGroupByNum(0);//set keyboard layout to first layout in available ones - -//wprintf(L"Full name: %s\n", symbols); - -//std::wcout << L"qqqqqqqqqqqqqqqqqqqq: " << *symbols; - - - - - xkb_keysym_t in; - xkb_keysym_t out; - -std::vector < int > vi ={34,39,43,47,48,61,57}; -for( int i=0; i vi ={34,39,43,47,48,61,57}; -for( int i=0; i 0 && xkb_keysym_to_utf32(syms[0]) < 128) - return syms[0]; - - - } - - - //return XKB_KEY_NoSymbol; - - - MyCoutW(L" # XKB get syn OK", 1); - - // https://cpp.hotexamples.com/examples/-/-/xkb_state_get_keymap/cpp-xkb_state_get_keymap-function-examples.html - - int num; - lv = xkb_state_key_get_level(state, code + KBDXKB_SHIFT, lo); - num = xkb_keymap_key_get_syms_by_level(keymap, code + KBDXKB_SHIFT, lo, lv, &s); - - - -*/ - -/*int get_OtherKeysym_From_US_Keysym(v_str_3D &All_Vector,int inUS){ - int outOther; - MyCoutW(L" #### get_OtherKeysym_From_US_Keysym of keymap started", 1); - wprintf(L" in Us ##################### %i and KeysymsUS : \n", inUS ); - // loop and find char in US; then find char of Other - for( int i=0; i< (int)All_Vector[1].size();i++) { - for( int j=0; j< (int)All_Vector[1][0].size();j++) { - - int KeysymUS = (int) *All_Vector[0][i][j].c_str(); - int KeysymOther = (int) *All_Vector[1][i][j].c_str(); - std::wstring KeysymUS_wstr = wstring_from_string(All_Vector[0][i][j]); - //if ( inUS == 58) -wprintf(L" in Us %i and KeysymsUS %i : \n", inUS ,KeysymUS ); -//wprintf(L" ................................................................................... inxx: %s outxx: %s %s\n", All_Vector[0][25][2].c_str(),All_Vector[1][25][0].c_str(),All_Vector[1][25][2].c_str()); - if( inUS == KeysymUS ) { - //wprintf(L" FOUND Value in US !!!!! : %i out ########: %S \n", inUS,KeysymUS_wstr.c_str()); - //wprintf(L" FOUND Value in US !!!!! : %i out ########: %S \n", inUS,KeysymUS_wstr.c_str()); - // wprintf(L" FOUND Value in OTHER !!!!! : Other in: %i ( %s ) -- Keycode : %s -- US out ########: %i ( %s ) \n", KeysymUS,All_Vector[0][i][j].c_str(), All_Vector[1][i][0].c_str() , KeysymOther,All_Vector[1][i][j].c_str()); - wprintf(L" get_OtherKeysym_From_US_Keysym FOUND Value in US !!!!! : Other in: %i ( %s ) -- Keycode : %s -- US out ########: %i ( %s ) \n", - KeysymUS,All_Vector[0][i][j].c_str(), All_Vector[1][i][0].c_str() , KeysymOther,All_Vector[1][i][j].c_str()); - - - //wprintf(L" FOUND 2 Value in OTHER !!!!! : Other in: %i ( %s ) -- Keycode : %s -- US out ########: %i ( %s ) \n", KeysymOther,All_Vector[1][i][j].c_str(), All_Vector[1][i][0].c_str() , KeysymUS,All_Vector[0][i][j].c_str()); - - outOther = KeysymOther; - - MyCoutW(L" #### get_OtherKeysym_From_US_Keysym of keymap ended", 1); - - return outOther; - } - } - } - MyCoutW(L" #### get_US_Char_FromOther of keymap ended", 1); - return true; -} -*/ - -bool is_Letter(int pos, v_dw_3D & All_Vector){ - if( ( All_Vector[1][pos][1] == All_Vector[1][pos][2] + 32) ) - return true; - return false; -} - -bool is_Number(int pos, v_dw_3D & All_Vector){ - if( (All_Vector[1][pos][1] >= 48) && (All_Vector[1][pos][1] <= 57) ) - return true; - return false; -} - -bool is_Special(int pos, v_dw_3D & All_Vector){ - if( !is_Number && !is_Letter) - return true; - return false; -} - -bool is_Edges(int pos, v_dw_3D & All_Vector){ - if( (All_Vector[1][pos][1] == 48)) - return true; - return false; -} -// _S2 can go later -std::wstring get_VirtualKey_Other_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &caps, v_dw_3D &All_Vector) { - - // _S2 this will find the correct row in All_Vector - //( e.g. get_position_From_VirtualKey_Other(65 ,All_Vector.99 ) returns 25 - // All_Vector[25] contains SC(38), unshifted A (97) shifted A (65) ) - KMX_DWORD pos = get_position_From_VirtualKey_Other(iKey, All_Vector,99); - - int icaps; - if (ss >9) - return L""; - - if( ss < All_Vector[1][pos].size()-1) { - - // ss 0,2,4... - if ( ss % 2 == 0) { - // aAAa 4$$4 - if ( is_Letter(pos, All_Vector) || is_Number(pos, All_Vector)) - icaps = ss+2-caps; - // ..:: ##'' - else - icaps = ss+1; - } - - // ss 1,3,5... - if ( ss % 2 == 1) { - // aAAa 4$$4 - if ( is_Letter(pos, All_Vector) || is_Number(pos, All_Vector)) - icaps = ss+caps; - // ..:: ##'' - else - icaps = ss+1; - } - - return std::wstring(1, (int) All_Vector[1][pos][icaps]); - } - return L""; -} - -// _S2 This can go later -/*KMX_DWORD get_VirtualKey_Other_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector) { - - for( int i=0; i< (int)All_Vector[0].size();i++) { - //number keys return unshifted value ( e.g. 1, not !) - if(SC <= 19) { - if ( All_Vector[0][i][0] == SC) - return All_Vector[1][i][1]; - } - - // other keys - if((SC > 19) ) { - if ( All_Vector[0][i][0] == SC) { - - // normal capital characters return the value of capital char ( e.g. A) - if ((All_Vector[1][i][2] >= 65 ) && (All_Vector[1][i][2] < 91 )) - return All_Vector[1][i][2]; - - // special characters return Keyman defined values (e.g. VK_ACCENT) - else - //return All_Vector[1][i][1]; - return mapVK_To_char(SC); - } - } - } -return 0; -} -*/ -// _S2 not needed, can go later -// return RETURN NON SHIFTED CHAR [1] the VirtualKey of the US Keyboard for given Scancode -KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector){ - // find correct row of char in US - for( int i=0; i< (int)All_Vector[0].size()-1;i++) { - if ( All_Vector[0][i][0] == SC ) { - return All_Vector[0][i][1] ; - } - } - return 0; //_S2 TODO what do I return if not found?? -} - -// return the Scancode of for given VirtualKey of Other Keyboard -KMX_DWORD get_SC_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector){ - // find correct row of char in US - for( int i=0; i< (int)All_Vector[1].size()-1;i++) { - if ( All_Vector[1][i][1] == VK_Other ) { - return All_Vector[1][i][0] ; - } - } - return 0; //_S2 TODO what do I return if not found?? -} - -// return the Scancode of for given VirtualKey of Other US -KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector){ - // find correct row of char in US - for( int i=0; i< (int)All_Vector[0].size()-1;i++) { - if ( All_Vector[0][i][2] == VK_US ) { - return All_Vector[0][i][0] ; - } - } - return 0; //_S2 TODO what do I return if not found?? -} - -// returns the position in All_Vector where VK_Other is found -KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector, int which_columns) { - // find correct row of char in US - if((which_columns <0 ) ) - return 0; - - // search all columns - if(which_columns >(int)All_Vector[1][0].size()) { - for( int i=1; i< (int)All_Vector[1][0].size();i++) { - for( int j=0; j< (int)All_Vector[1].size()-1;j++) { - if ( ( All_Vector[1][j][i] == VK_Other ) ) - return j; - } - } - } - - else { - for( int j=0; j< (int)All_Vector[1].size()-1;j++) { - if ( ( All_Vector[1][j][which_columns] == VK_Other ) ) - return j; - } - } - - return 0; //_S2 TODO what do I return if not found?? -} - -// returns KeyCode which hold the Keysym/Keyval (in unshifted, shifted) -KMX_DWORD get_KeyCode_From_KeyVal_GDK(GdkKeymap *keymap, UINT Keyval ) { - GdkKeymapKey *maps; - guint *keyvals; - gint count; - - for (int k=0; k<255 ; k++ ){ - if (gdk_keymap_get_entries_for_keycode (keymap, k, &maps, &keyvals, &count)) { - if ( (keyvals[0] == Keyval) || (keyvals[1] == Keyval) ) { - return (KMX_DWORD) maps[0].keycode; - } - } - } - - g_free(keyvals); - g_free(maps); - - return 0; //_S2 TODO what do I return if not found?? -} - -// returns KeyCode which holds the Keysym (in unshifted, shifted) -/*KMX_DWORD get_SC_From_Keycode_GDK(GdkKeymap *keymap, UINT SC ) { - GdkKeymapKey *maps; - guint *keyvals; - gint count; - - for (int k=0; k<255 ; k++ ){ - if (gdk_keymap_get_entries_for_keycode (keymap, k, &maps, &keyvals, &count)) { - if ( (keyvals[0] == SC) || (keyvals[1] == SC) ) { - return (KMX_DWORD) maps[0].keycode; - } - } - } - - g_free(keyvals); - g_free(maps); - return 0; //_S2 TODO what do I return if not found?? -}*/ - -KMX_DWORD mapVK_To_char(KMX_DWORD SC ){ - // if there is a Keyman VK.. defined map to Keyman VKcode - - // if ( SC == 49) return VK_BKSLASH; /* ; 220 = ` oder ^ */ - // if ( SC == 20) return VK_LBRKT; /* ; 219 = - oder ß */ - // if ( SC == 21) return VK_RBRKT; /* ; 221 = = oder ' */ - - // if ( SC == 34) return VK_COLON; /* ; 186 VK_OEM_4 = [ oder ü */ - //if ( SC == 35) return VK_EQUAL; /* ; 187 = ] oder + */ - - // if ( SC == 47) return VK_ACCENT; /* ; 192 VK_OEM_1 = : oder ö */ - // if ( SC == 48) return VK_QUOTE; /* ' 222 VK_OEM_7 = " oder Ä */ - // if ( SC == 51) return VK_SLASH; /* ; 191 = \ oder # */ - - // if ( SC == 59) return VK_COMMA; /* ; 188 = , oder , */ - // if ( SC == 60) return VK_PERIOD; /* ; 190 = . oder . */ - // if ( SC == 61) return VK_HYPHEN; /* ; 189 = / oder - */ - - // if ( SC == 65) return VK_SPACE; /* ; 32 VK_SPACE = oder */ - // else - return SC; -} -// _S2 TODO is this correct ?? -KMX_DWORD mapChar_To_VK(KMX_DWORD chr ){ - // if there is a Keyman VK.. defined map to Keyman VKcode - - // if ( SC == 49) return VK_BKSLASH; /* ; 220 = ` oder ^ */ - // if ( SC == 20) return VK_LBRKT; /* ; 219 = - oder ß */ - // if ( SC == 21) return VK_RBRKT; /* ; 221 = = oder ' */ - - // if ( chr == VK_COLON) return 220; /* ; 186 VK_OEM_4 = [ oder ü */ -// if ( chr == 187) return 42; /* ; 186 VK_OEM_4 = [ oder ü */ - // if ( SC == 35) return VK_EQUAL; /* ; 187 = ] oder + */ - - // if ( SC == 47) return VK_ACCENT; /* ; 192 VK_OEM_1 = : oder ö */ - // if ( SC == 48) return VK_QUOTE; /* ' 222 VK_OEM_7 = " oder Ä */ - // if ( SC == 51) return VK_SLASH; /* ; 191 = \ oder # */ - - // if ( SC == 59) return VK_COMMA; /* ; 188 = , oder , */ - // if ( SC == 60) return VK_PERIOD; /* ; 190 = . oder . */ - // if ( SC == 61) return VK_HYPHEN; /* ; 189 = / oder - */ - - // if ( SC == 65) return VK_SPACE; /* ; 32 VK_SPACE = oder */ - // else - return chr; -} - -void Inspect_Key_S2(GdkKeymap *keymap ) { - - guint KCode = 34; - guint Keyval_Base= 35; - guint Keyval_Shift = 39; - guint Keyval = Keyval_Base; - - gchar* KeyvalName_Base; - char* KeyvalName_ch_Base; - gchar* KeyvalName_Shift; - char* KeyvalName_ch_Shift; - - GdkKeymapKey* keys; - gint n_keys; - - GdkKeymapKey *maps; - guint *keyvals; - guint *keyvals_shift; - gint *n_entries; - gint count; - - GdkModifierType consumed; - // ___ ___ ___ ___ - // | A | | Ö | | & | | ' | - // Key |_a_| |_ö_| |_6_| |_#_| - // KeyCode 38 47 15 51 - // Keyval Base 97 246 54 35 - // Keyval Shift 65 214 38 39 - // KeyValname(Base) a odiaresis 6 apostrophe - // KeyValname(Shift) A Odiaresis ampersand numbersign - -//--------------------------------------- -gchar * gc= gdk_keyval_name (214); -gchar * gc0= gdk_keyval_name (65); -//--------------------------------------- -std::string sr = "odiaeresis"; -gchar * chr= (gchar*) sr.c_str(); ; -guint gi= gdk_keyval_from_name (chr); -//--------------------------------------- -//guint32 gdk_keyval_to_unicode (guint keyval); -guint32 gg323 = gdk_keyval_to_unicode (65106); -//--------------------------------------- -//guint gdk_unicode_to_keyval (guint32 wc); -guint GGGIII= gdk_unicode_to_keyval (gg323); -//--------------------------------------- -Keyval= Keyval_Shift; - // finds ALL CHARACTERS ON KEY KCode for all levels and groups - // key 51 gr=0 (DE); lev=0 keyval 35(#) - // key 51 gr=0 (FR); lev=0 keyval 35(*) - // key 51 gr=0 (US); lev=0 keyval 35(\) - // key 51 gr=0 (ES); lev=0 keyval 35(\) - gdk_keymap_get_entries_for_keycode(keymap, KCode, &maps, &keyvals, &count); - wprintf(L"----------------------------\nprinting out the characters given by keypress of key SC/Keycode:%i\n",KCode); - for (int i = 0; i < count; i++) { - //if (maps[i].level > 0 || maps[i].group > 1) - // continue; - wprintf(L" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", - i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); - } - // finds all levels, groups WHERE KEYVAL IS LOCATED - // ' is on key 13, gr=0,lev=0 for swedish; - // ' is on key 51, gr=0,lev=1 for german; - // ' is on key 48, gr=2,lev=0 for english?; - // ' is on key 48, gr=3,lev=0 for spanish?; - //gdk_keymap_get_entries_for_keyval(keymap, Keyval,&keys,&n_keys); - gdk_keymap_get_entries_for_keyval(keymap, Keyval,&keys,&n_keys); - wprintf(L"----------------------------\nprinting out the characters given by keypress of Keyval :%i\n",Keyval); - for (int i = 0; i < n_keys; i++) { - //if (maps[i].level > 0 || maps[i].group > 1) - // continue; - wprintf(L" i=%d, Keyval=%d, (%c) keycode %i group %i level %i\n", - i, Keyval,Keyval, keys[i].keycode,keys[i].group,keys[i].level); - } -//--------------------------------------- - -gint Key_on_DE; -gint KeyVal_on_US; - Keyval = 214; - gdk_keymap_get_entries_for_keyval(keymap, Keyval,&keys,&n_keys); - wprintf(L"----------------------------\nprinting out the characters given by keypress of Keyval :%i\n",Keyval); - for (int i = 0; i < n_keys; i++) { - //if (maps[i].level > 0 || maps[i].group > 1) - // continue; - wprintf(L" i=%d, Keyval=%d, (%c) keycode %i group %i level %i\n", - i, Keyval,Keyval, keys[i].keycode,keys[i].group,keys[i].level); - } - for (int i = 0; i < n_keys; i++) { - if (keys[i].group ==0) - Key_on_DE = keys[i].keycode; - } - - g_free(keyvals); - g_free(maps); - - gdk_keymap_get_entries_for_keycode(keymap, Key_on_DE, &maps, &keyvals, &count); - wprintf(L"----------------------------\nprinting out the characters given by keypress of key SC/Keycode:%i\n",Key_on_DE); - for (int i = 0; i < count; i++) { - //if (maps[i].level > 0 || maps[i].group > 1) - // continue; - wprintf(L" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", - i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); - } -for (int i = 0; i < count; i++) { - if ((maps[i].group ==2 )&& (maps[i].level ==0)) - KeyVal_on_US = maps[i].keycode; - } - -const UINT VK_US= ScanCodeToUSVirtualKey[KeyVal_on_US-8]; -const UINT VK_US2= USVirtualKeyToScanCode[KeyVal_on_US]; - -GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); -gdk_keymap_translate_keyboard_state (keymap, KCode, MOD_base , 0, keyvals, NULL, NULL, & consumed); -std::wstring rV1= std::wstring(1, (int) *keyvals); - - KeyvalName_Base = gdk_keyval_name (Keyval_Base); - KeyvalName_ch_Base = (char*) KeyvalName_Base; - std::string KeyvalName_str_Base(KeyvalName_ch_Base); - KeyvalName_Shift= gdk_keyval_name (Keyval_Shift); - KeyvalName_ch_Shift = (char*) KeyvalName_Shift; - std::string KeyvalName_str_Shift(KeyvalName_ch_Shift); - - - wprintf(L" keyval_Base %i has the name: %s ------ ", Keyval_Base, KeyvalName_str_Base.c_str()); - wprintf(L" keyval_Shift %i has the name: %s \n", Keyval_Shift, KeyvalName_str_Shift.c_str()); - //wprintf(L" keyval "); -int stop=99; - - g_free(keyvals); - g_free(maps); - -} - -void Inspect_Key_S(GdkKeymap *keymap ) { - - guint KCode = 51; - guint Keyval_Base= 35; - guint Keyval_Shift = 60; - guint Keyval = Keyval_Base; - - gchar* KeyvalName_Base; - char* KeyvalName_ch_Base; - gchar* KeyvalName_Shift; - char* KeyvalName_ch_Shift; - - GdkKeymapKey* keys; - gint n_keys; - - GdkKeymapKey *maps; - guint *keyvals; - guint *keyvals_shift; - gint *n_entries; - gint count; - - GdkModifierType consumed; - // ___ ___ ___ ___ - // | A | | Ö | | & | | ' | - // Key |_a_| |_ö_| |_6_| |_#_| - // KeyCode 38 47 15 51 - // Keyval Base 97 246 54 35 - // Keyval Shift 65 214 38 39 - // KeyValname(Base) a odiaresis 6 apostrophe - // KeyValname(Shift) A Odiaresis ampersand numbersign - -//--------------------------------------- -gchar * gc= gdk_keyval_name (60); -gchar * gc0= gdk_keyval_name (94); -//--------------------------------------- -std::string sr = "less"; -gchar * chr= (gchar*) sr.c_str(); ; -guint gi= gdk_keyval_from_name (chr); -//--------------------------------------- -/*std::string sr4= "acute"; -gchar * chr4= (gchar*) sr4.c_str(); ; -guint gi4= gdk_keyval_from_name (chr4); -//--------------------------------------- -std::string sr1= "dead_grave"; -gchar * chr1= (gchar*) sr1.c_str(); ; -guint gi1= gdk_keyval_from_name (chr1); -//--------------------------------------- -std::string sr2 = "grave"; -gchar * chr2= (gchar*) sr2.c_str(); ; -guint gi2= gdk_keyval_from_name (chr2); -//--------------------------------------- -std::string sr21 = "dead_abovedot"; -gchar * chr21= (gchar*) sr21.c_str(); ; -guint gi21= gdk_keyval_from_name (chr21);*/ -//--------------------------------------- -//---------------------------------------*/ -//guint32 gdk_keyval_to_unicode (guint keyval); -guint32 gg323 = gdk_keyval_to_unicode (65106); -guint32 gz = gdk_keyval_to_unicode (65); -guint32 gz1 = gdk_keyval_to_unicode (220); -guint32 gz2 = gdk_keyval_to_unicode (7838); -//--------------------------------------- -//guint gdk_unicode_to_keyval (guint32 wc); -guint GGGIII= gdk_unicode_to_keyval (gg323); -guint GGGIII2= gdk_unicode_to_keyval (gz2); -guint GGGIII3= gdk_unicode_to_keyval (gz); -guint GGGIII4= gdk_unicode_to_keyval (gz1); -//guint GGGIII2 =gdk_unicode_to_keyval (L"\u1E9E"); -//gchar * gc2= gdk_keyval_name ((int) \u1E9E); -/*wchar_t w[] = L"\u1E9E"; -wchar_t ww[] = L"A"; -unsigned int Alef = (unsigned int) L'ẞ'; -guint GGII4= gdk_unicode_to_keyval (Alef); -guint GGI4= gdk_unicode_to_keyval ((unsigned int) L'ẞ');*/ -//--------------------------------------- -Keyval= Keyval_Shift; - // finds ALL CHARACTERS ON KEY KCode for all levels and groups - // key 51 gr=0 (DE); lev=0 keyval 35(#) - // key 51 gr=0 (FR); lev=0 keyval 35(*) - // key 51 gr=0 (US); lev=0 keyval 35(\) - // key 51 gr=0 (ES); lev=0 keyval 35(\) - gdk_keymap_get_entries_for_keycode(keymap, KCode, &maps, &keyvals, &count); - wprintf(L"----------------------------\nprinting out the characters given by keypress of key SC/Keycode:%i\n",KCode); - for (int i = 0; i < count; i++) { - //if (maps[i].level > 0 || maps[i].group > 1) - // continue; - wprintf(L" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", - i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); - } - // finds all levels, groups WHERE KEYVAL IS LOCATED - // ' is on key 13, gr=0,lev=0 for swedish; - // ' is on key 51, gr=0,lev=1 for german; - // ' is on key 48, gr=2,lev=0 for english?; - // ' is on key 48, gr=3,lev=0 for spanish?; - //gdk_keymap_get_entries_for_keyval(keymap, Keyval,&keys,&n_keys); - gdk_keymap_get_entries_for_keyval(keymap, Keyval,&keys,&n_keys); - wprintf(L"----------------------------\nprinting out the characters given by keypress of Keyval :%i\n",Keyval); - for (int i = 0; i < n_keys; i++) { - //if (maps[i].level > 0 || maps[i].group > 1) - // continue; - wprintf(L" i=%d, Keyval=%d, (%c) keycode %i group %i level %i\n", - i, Keyval,Keyval, keys[i].keycode,keys[i].group,keys[i].level); - } -//--------------------------------------- - -gint Key_on_DE; -gint KeyVal_on_US; - Keyval = 38; - gdk_keymap_get_entries_for_keyval(keymap, Keyval,&keys,&n_keys); - wprintf(L"----------------------------\nprinting out the characters given by keypress of Keyval :%i\n",Keyval); - for (int i = 0; i < n_keys; i++) { - //if (maps[i].level > 0 || maps[i].group > 1) - // continue; - wprintf(L" i=%d, Keyval=%d, (%c) keycode %i group %i level %i\n", - i, Keyval,Keyval, keys[i].keycode,keys[i].group,keys[i].level); - } - for (int i = 1; i < n_keys; i++) { - if (keys[i].group ==0) - Key_on_DE = keys[i].keycode; - } - - gdk_keymap_get_entries_for_keycode(keymap, Key_on_DE, &maps, &keyvals, &count); - wprintf(L"----------------------------\nprinting out the characters given by keypress of key SC/Keycode:%i\n",Key_on_DE); - for (int i = 0; i < count; i++) { - //if (maps[i].level > 0 || maps[i].group > 1) - // continue; - wprintf(L" i=%d, keycode=%d, keyval=%d (%c), level=%d, group=%d\n", - i, maps[i].keycode, keyvals[i], keyvals[i], maps[i].level, maps[i].group); - } -for (int i = 0; i < count; i++) { - if ((maps[i].group ==2 )&& (maps[i].level ==0)) - KeyVal_on_US = maps[i].keycode; - } - -const UINT VK_US= ScanCodeToUSVirtualKey[KeyVal_on_US-8]; -const UINT VK_US2= USVirtualKeyToScanCode[KeyVal_on_US]; - -GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); -gdk_keymap_translate_keyboard_state (keymap, KCode, MOD_base , 0, keyvals, NULL, NULL, & consumed); -std::wstring rV1= std::wstring(1, (int) *keyvals); - - KeyvalName_Base = gdk_keyval_name (Keyval_Base); - KeyvalName_ch_Base = (char*) KeyvalName_Base; - std::string KeyvalName_str_Base(KeyvalName_ch_Base); - KeyvalName_Shift= gdk_keyval_name (Keyval_Shift); - KeyvalName_ch_Shift = (char*) KeyvalName_Shift; - std::string KeyvalName_str_Shift(KeyvalName_ch_Shift); - - - wprintf(L" keyval_Base %i has the name: %s ------ ", Keyval_Base, KeyvalName_str_Base.c_str()); - wprintf(L" keyval_Shift %i has the name: %s \n", Keyval_Shift, KeyvalName_str_Shift.c_str()); - //wprintf(L" keyval "); -int stop=99; - -} - -/* -bool KMX_LayoutRow_Lin(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,v_dw_3D &All_Vector, GdkKeymap * keymap) { // I4552 - // Get the CAPSLOCK value - - -bool b1= this->KMX_IsCapsEqualToShift(); -bool b2= this->KMX_IsSGCAPS(); -bool b3= this->KMX_IsAltGrCapsEqualToAltGrShift(); -bool b4= this->KMX_IsXxxxGrCapsEqualToXxxxShift(); - -int i1 = this->KMX_IsCapsEqualToShift() ? 1 : 0; -int i2 = this->KMX_IsSGCAPS() ? 2 : 0; -int i3 = this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0; -int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0; - - - // _S2 original: - /int capslock = - (this->IsCapsEqualToShift() ? 1 : 0) | - (this->IsSGCAPS() ? 2 : 0) | - (this->IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0);/ - - -// _S2 change! only for testing helps to force filling rgkey[VK_DE] -int capslock; - - // numbers: - if( (this->m_vk>=48) && (this->m_vk<=57) ) { - capslock = - (this->KMX_IsCapsEqualToShift() ? 0 : 1) | - (this->KMX_IsSGCAPS() ? 2 : 0) | - (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); - } - // characters: - else if( (this->m_vk>=65) && (this->m_vk<=90) ) { - capslock = - (this->KMX_IsCapsEqualToShift() ? 1 : 0) | - (this->KMX_IsSGCAPS() ? 2 : 0) | - (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); - } - // ä,ö,ü: - else if( (this->m_vk==32) ||(this->m_vk==186) ||(this->m_vk==192)|| (this->m_vk==222) ) { - capslock = - (this->KMX_IsCapsEqualToShift() ? 1 : 0) | - (this->KMX_IsSGCAPS() ? 2 : 0) | - (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); - } - // < and _: - else if( (this->m_vk==189) || (this->m_vk==220) || (this->m_vk==221) || (this->m_vk==226) ) { - capslock = - (this->KMX_IsCapsEqualToShift() ? 1 : 0) | - (this->KMX_IsSGCAPS() ? 2 : 0) | - (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); - } - // punctuation Char: - else { - capslock = - (this->KMX_IsCapsEqualToShift() ? 0 : 1) | - (this->KMX_IsSGCAPS() ? 2 : 0) | - (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); - } - - - - for (int ss = 0; ss <= MaxShiftState; ss++) { - if (ss == Menu || ss == ShftMenu) { - // Alt and Shift+Alt don't work, so skip them - continue; - } - for (int caps = 0; caps <= 1; caps++) { - std::wstring st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); - PKMX_WCHAR p; // was PWSTR p; - PKMX_WCHAR q; - - if (st.size() == 0) { - // No character assigned here - } - // _S2 deadkeys don't work yet - else if (this->m_rgfDeadKey[(int)ss][caps]) { - // It's a dead key, append an @ sign. - key->dpContext = new KMX_WCHAR[1]; - *key->dpContext = 0; - key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); - // _S2 this fun returns the shifted Char it goes wrog for numbers, special here!! - //key->Key = KMX_VKUnderlyingLayoutToVKUS(All_Vector,this->VK()); - key->Key = KMX_VKUnderlyingLayoutToVKUS_GDK(keymap,this->VK()); - key->Line = 0; - - if(bDeadkeyConversion) { // I4552 - p = key->dpOutput = new KMX_WCHAR[2]; - *p++ = st[0]; - *p = 0; - } else { - p = key->dpOutput = new KMX_WCHAR[4]; - *p++ = UC_SENTINEL; - *p++ = CODE_DEADKEY; - *p++ = KMX_DeadKeyMap(st[0], deadkeys, deadkeyBase, &KMX_FDeadkeys); // I4353 - *p = 0; - } - key++; - } else { - bool isvalid = true; - for (size_t ich = 0; ich < st.size(); ich++) { - if(st[ich] < 0x20 || st[ich] == 0x7F) { isvalid=false; break; } - } - if(isvalid) { - // wrong function!! - //key->Key = KMX_VKUnderlyingLayoutToVKUS(All_Vector,this->VK()); - key->Key = KMX_VKUnderlyingLayoutToVKUS_GDK(keymap,this->VK()); - std::wstring w1_S2 = get_m_rgss(ss,caps); - //wprintf(L"\n KMX_VKUnderlyingLayoutToVKUS_GD writes %ls %c ( from %i) \n",w1_S2.c_str(), key->Key , this->VK()); - - if(key->Key != this->VK()) -wprintf(L"\n key->Key AND this->VK() different %i ( from %i) \n", key->Key , this->VK()); - - - - - wprintf(L" this->VK(): %i ", this->VK()); - key->Line = 0; - // _S2 _differences in sstateflag probably from here and KMX_IsCapsEqualToShift... - key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); - key->dpContext = new KMX_WCHAR; *key->dpContext = 0; - p = key->dpOutput = new KMX_WCHAR[st.size() + 1]; - for(size_t ich = 0; ich < st.size(); ich++) { - q=p; - *p++ = st[ich];} - *p = 0; - key++; - } - } - } - } - return true; - } -*/ - - - -/*bool KMX_ImportRules_bak(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 - KMX_Loader loader; - const size_t BUF_sz= 256; -//Inspect_kp(kp); - // _S2 do I need that for Linux?? - KMX_WCHAR inputHKL[12]; - u16sprintf(inputHKL,BUF_sz ,L"%08.8x", (unsigned int) u16tol(kbid, NULL, 16)); // _S2 wsprintf(inputHKL, L"%08.8x", (unsigned int) wcstol(kbid, NULL, 16)); - - KMX_HKL hkl = NULL; //_S2 added: but can I do this?? hkl is not needed in Linux?? - - BYTE lpKeyState[256];// = new KeysEx[256]; - std::vector rgKey; //= new VirtualKey[256]; - std::vector alDead; - - rgKey.resize(256); - - // _S2 scroll through OTHER - // Scroll through the Scan Code (SC) values and get the valid Virtual Key (VK) - // values in it. Then, store the SC in each valid VK so it can act as both a - // flag that the VK is valid, and it can store the SC value. - // _S2 this does not find exactly the same keys as the windows version does(windows finds more) - - for(UINT sc = 0x01; sc <= 0x7f; sc++) { - // fills m_vk with the VK of the US keyboard which is not right!! - // ( mcompile win uses MapVirtualKeyEx() to fill m_vk with the VK of the Other keyboard) - // Linux cant get a VK for the US Keyboard using USVirtualKeyToScanCode/ScanCodeToUSVirtualKey - // Linux cannot get a VK for Other Keyboard - // it could return SC if that helps - KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector, keymap); - - // _S2 ToDo - // either it gives the correct rgkeys (all non-char filled with special char) or - // it gives not all rgkeys but nr, a-z are filled correctly - if((key->VK() != 0) ) { - rgKey[key->VK()] = key; - } else { - delete key; - } - } - - for(UINT ke = VK_NUMPAD0; ke <= VK_NUMPAD9; ke++) { - rgKey[ke] = new KMX_VirtualKey(hkl, ke, All_Vector, keymap); - } - - rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE, All_Vector, keymap); - rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL, All_Vector, keymap); - rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL, All_Vector, keymap); - - - // _S2 do we need special shift state now or later? - // See if there is a special shift state added - for(UINT vk = 0; vk <= VK_OEM_CLEAR; vk++) { - UINT sc = MapVirtualKeyEx(vk, 0, hkl); - UINT vkL = MapVirtualKeyEx(sc, 1, hkl); - UINT vkR = MapVirtualKeyEx(sc, 3, hkl); - if((vkL != vkR) && - (vk != vkL)) { - switch(vk) { - case VK_LCONTROL: - case VK_RCONTROL: - case VK_LSHIFT: - case VK_RSHIFT: - case VK_LMENU: - case VK_RMENU: - break; - - default: - loader.Set_XxxxVk(vk); - break; - } - } - } - - // _S2 test rgkey can go later - for(UINT iKey = 100; iKey < rgKey.size(); iKey++) { - if(rgKey[iKey] != NULL) { - wprintf(L" Key Nr %i is available\n",iKey); - } - } - - // _S2 in this part we skip shiftstates 4, 5, 8, 9 - for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { - if(rgKey[iKey] != NULL) { - WCHAR sbBuffer[256]; // Scratchpad we use many places - - UINT VK_Other = Lin_KM__map(iKey, All_Vector); - - for(ShiftState ss = Base; ss <= loader.MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { - if(ss == Menu || ss == ShftMenu) { - // Alt and Shift+Alt don't work, so skip them - continue; - } - - KMX_DWORD SC_US = get_KeyCode_fromVKUS(iKey); - - for(int caps = 0; caps <= 1; caps++) { - //_S2 TODO get char - do I need rc ?? ( was rc = ToUnicodeEx...) - std::wstring KeyVal_Other = get_KeyVals_according_to_keycode_and_Shiftstate_new( *keymap, SC_US, ss, caps); - - -// _S2 brackets not the same in if/else/else if blocks !!!! - - //_S2 TODO do I need that ?? - //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { - if(KeyVal_Other == L"") { - //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); - rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps)); - } - - //_S2 TODO - //else // if rc ==1 : it got 1 char && +40 in Buffer CTRl pressed { - //It's dealing with control characters. If ToUnicodeEx gets VK_A with the Ctrl key pressed, - //it will write 0x01 to sBuffer[0] , without Ctrl it's 0x41. The if detects this case. - if( (ss == Ctrl || ss == ShftCtrl) /*&& CTRl +0x40 in the buffer ( which indicates a ctrl press) ) { - continue; - } - - //rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps==0)); - rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps)); - - - //_S2 TODO - // dk > 65000??? - // _S2 handle deadkeys later - // if rc <0: it got a deadkey { - // fill m_rgss and m_rgfDeadkey and alDead - //SET_SHIFTSTATES( deadkey) //sbuffer is value out of ToUnicodeEx / AllVector - // do more stuff for deadkeys... - // } from rc<0 - } - } - } - } - - //_S2 this gan co later - std::vector< int > TestValues = {48,49,50,51,52,53,54,55,56,57,65,66,67,88,89,90, 186,187,188,189,191,191,192,219,220,221,222,226}; - wprintf(L"-----------------\nNow some tests:\n"); - wprintf(L" Base Caps Shift Shfit+Caps MenuCtrl MenuCtrl+Caps \n"); - - for ( int i=0; i < (int) TestValues.size();i++) { - std::wstring wws = rgKey[TestValues[i]]->get_m_rgss(0,0); - wprintf(L"Results for %i\t: %ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \t%ls (%i) \n", TestValues[i], - rgKey[TestValues[i]]->get_m_rgss(0,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(0,0)[0], - rgKey[TestValues[i]]->get_m_rgss(0,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(0,1)[0], - rgKey[TestValues[i]]->get_m_rgss(1,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(1,0)[0], - rgKey[TestValues[i]]->get_m_rgss(1,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(1,1)[0], - rgKey[TestValues[i]]->get_m_rgss(6,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(6,0)[0], - rgKey[TestValues[i]]->get_m_rgss(6,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(6,1)[0], - rgKey[TestValues[i]]->get_m_rgss(7,0).c_str(), rgKey[TestValues[i]]->get_m_rgss(7,0)[0], - rgKey[TestValues[i]]->get_m_rgss(7,1).c_str(), rgKey[TestValues[i]]->get_m_rgss(7,1)[0] - ); - } - wprintf(L"-----------------\n"); - - //------------------------------------------------------------- - // Now that we've collected the key data, we need to - // translate it to kmx and append to the existing keyboard - //------------------------------------------------------------- - - int nDeadkey = 0; - LPKMX_GROUP gp = new KMX_GROUP[kp->cxGroupArray+4]; // leave space for old - memcpy(gp, kp->dpGroupArray, sizeof(KMX_GROUP) * kp->cxGroupArray); - - // - - // Find the current highest deadkey index - // - - kp->dpGroupArray = gp; - for(UINT i = 0; i < kp->cxGroupArray; i++, gp++) { - //if(gp->fUsingKeys && gp->dpNoMatch == NULL) { // I4550 - // WCHAR *p = gp->dpNoMatch = new WCHAR[4]; - // *p++ = UC_SENTINEL; - // *p++ = CODE_USE; - // *p++ = (WCHAR)(kp->cxGroupArray + 1); - // *p = 0; - //} - LPKMX_KEY kkp = gp->dpKeyArray; - - for(UINT j = 0; j < gp->cxKeyArray; j++, kkp++) { - nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpContext)); - nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpOutput)); - } - } - - kp->cxGroupArray++; - gp = &kp->dpGroupArray[kp->cxGroupArray-1]; - UINT nKeys = 0; - int sab_nr = 0; - for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { - if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { - nKeys+= rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); - //wprintf(L" iKey = %i, Delta: %i -> Sum %i\n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()), nKeys); - sab_nr ++; - } - } - - - nDeadkey++; // ensure a 1-based index above the max deadkey value already in the keyboard - - gp->fUsingKeys = TRUE; - gp->dpMatch = NULL; - gp->dpName = NULL; - gp->dpNoMatch = NULL; - gp->cxKeyArray = nKeys; - gp->dpKeyArray = new KMX_KEY[gp->cxKeyArray]; - nKeys = 0; - // - // Fill in the new rules - // - -int STOP=0; // _S2 LayoutRow: VKToUnderlying should work OK; GetSSValue not checked yet, but this is definitely different - for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { - if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { - //wprintf(L"********************************* I use Key Nr %i\n",iKey); - // for each item, - //wprintf(L" \n iKey = %i, nKeys %i + Delta:\t%i", iKey,nKeys, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState())); - if(rgKey[iKey]->KMX_LayoutRow(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 - nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); - //Inspect_key(&gp->dpKeyArray[nKeys]); - } - } - } - - gp->cxKeyArray = nKeys; - - // - // Add nomatch control to each terminating 'using keys' group // I4550 - // - LPKMX_GROUP gp2 = kp->dpGroupArray; - for(UINT i = 0; i < kp->cxGroupArray - 1; i++, gp2++) { - if(gp2->fUsingKeys && gp2->dpNoMatch == NULL) { - KMX_WCHAR *p = gp2->dpNoMatch = new KMX_WCHAR[4]; - KMX_WCHAR *q = p; - *p++ = UC_SENTINEL; - *p++ = CODE_USE; - *p++ = (KMX_WCHAR)(kp->cxGroupArray); - *p = 0; - - // _S2 TODO not sure if this works OK -> we need to use more shiftstates than base+Shift - // I4550 - Each place we have a nomatch > use(baselayout) (this last group), we need to add all - // the AltGr and ShiftAltGr combinations as rules to allow them to be matched as well. Yes, this - // loop is not very efficient but it's not worthy of optimisation. - // - UINT j; - LPKMX_KEY kkp; - for(j = 0, kkp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kkp++) { - if((kkp->ShiftFlags & (K_CTRLFLAG|K_ALTFLAG|LCTRLFLAG|LALTFLAG|RCTRLFLAG|RALTFLAG)) != 0) { - gp2->cxKeyArray++; - LPKMX_KEY kkp2 = new KMX_KEY[gp2->cxKeyArray]; - memcpy(kkp2, gp2->dpKeyArray, sizeof(KMX_KEY)*(gp2->cxKeyArray-1)); - gp2->dpKeyArray = kkp2; - kkp2 = &kkp2[gp2->cxKeyArray-1]; - kkp2->dpContext = new KMX_WCHAR; *kkp2->dpContext = 0; - kkp2->Key = kkp->Key; - kkp2->ShiftFlags = kkp->ShiftFlags; - kkp2->Line = 0; - KMX_WCHAR *p = kkp2->dpOutput = new KMX_WCHAR[4]; - KMX_WCHAR *q=p; - *p++ = UC_SENTINEL; - *p++ = CODE_USE; - *p++ = (KMX_WCHAR)(kp->cxGroupArray); - *p = 0; - } - } - } - } - - // _S2 TODO not sure if this works OK -> we need to use deadkeys... - // If we have deadkeys, then add a new group to translate the deadkeys per the deadkey tables - // We only do this if not in deadkey conversion mode - // - - if (alDead.size() > 0 && !bDeadkeyConversion) { // I4552 - kp->cxGroupArray++; - - KMX_WCHAR *p = gp->dpMatch = new KMX_WCHAR[4]; - *p++ = UC_SENTINEL; - *p++ = CODE_USE; - *p++ = (KMX_WCHAR) kp->cxGroupArray; - *p = 0; - - gp++; - - gp->fUsingKeys = FALSE; - gp->dpMatch = NULL; - gp->dpName = NULL; - gp->dpNoMatch = NULL; - gp->cxKeyArray = alDead.size(); - LPKMX_KEY kkp = gp->dpKeyArray = new KMX_KEY[alDead.size()]; - - LPKMX_STORE sp = new KMX_STORE[kp->cxStoreArray + alDead.size() * 2]; - memcpy(sp, kp->dpStoreArray, sizeof(KMX_STORE) * kp->cxStoreArray); - - kp->dpStoreArray = sp; - - sp = &sp[kp->cxStoreArray]; - int nStoreBase = kp->cxStoreArray; - kp->cxStoreArray += alDead.size() * 2; - - for(UINT i = 0; i < alDead.size(); i++) { - DeadKey *dk = alDead[i]; - - sp->dpName = NULL; - sp->dwSystemID = 0; - sp->dpString = new KMX_WCHAR[dk->KMX_Count() + 1]; - for(int j = 0; j < dk->KMX_Count(); j++) - sp->dpString[j] = dk->KMX_GetBaseCharacter(j); - sp->dpString[dk->KMX_Count()] = 0; - sp++; - - sp->dpName = NULL; - sp->dwSystemID = 0; - sp->dpString = new KMX_WCHAR[dk->KMX_Count() + 1]; - for(int j = 0; j < dk->KMX_Count(); j++) - sp->dpString[j] = dk->KMX_GetCombinedCharacter(j); - sp->dpString[dk->KMX_Count()] = 0; - sp++; - - kkp->Line = 0; - kkp->ShiftFlags = 0; - kkp->Key = 0; - KMX_WCHAR *p = kkp->dpContext = new KMX_WCHAR[8]; - *p++ = UC_SENTINEL; - *p++ = CODE_DEADKEY; - *p++ = KMX_DeadKeyMap(dk->KMX_DeadCharacter(), &alDead, nDeadkey, FDeadkeys); // I4353 - // *p++ = nDeadkey+i; - *p++ = UC_SENTINEL; - *p++ = CODE_ANY; - *p++ = nStoreBase + i*2 + 1; - *p = 0; - - p = kkp->dpOutput = new KMX_WCHAR[5]; - *p++ = UC_SENTINEL; - *p++ = CODE_INDEX; - *p++ = nStoreBase + i*2 + 2; - *p++ = 2; - *p = 0; - - kkp++; - } - } - //Inspect_kp(kp); -return true; -}*/ - - - - - - -// _S2 TODO -/*std::wstring get_KeyVals_according_to_Shiftstate(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ - - GdkModifierType consumed; - GdkKeymapKey *maps; - guint *keyvals; - gint count; - - // _S2 TODO what to return if it fails? - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return L"1"; - - //unshifted - if (( ss == Base ) && ( caps == 0 )) { - GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); - } - - //SHIFT+CAPS - else if ( ( ss == Shft ) && ( caps ==1 )) { - GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); - } - - //Shift - else if (( ss == Shft ) && ( caps == 0 )) { - return std::wstring(1, (int) get_VirtualKey_Other_GDK(keymap, keycode)); - } - - //caps - else if (( ss == Base ) && ( caps == 1 )) { - GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); - } - - //ALT-GR - //else if { - // GdkModifierType MOD_AltGr = (GdkModifierType) ( GDK_MOD5_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - return *keyvals; - } - - else - return L"0"; -} -*/ - - -// _S2 this needs to go; only to check if mcompile gives the same end result. -// _S2 helps to force filling rgkey[VK_FR] -UINT map_Ikey_FR(UINT iKey) { - if (iKey == 186 ) return 221; - if (iKey == 187 ) return 187; - if (iKey == 188 ) return 77; - if (iKey == 189 ) return 223; - if (iKey == 190 ) return 188; - if (iKey == 191 ) return 190; - if (iKey == 192 ) return 222; - if (iKey == 219 ) return 189; - if (iKey == 220 ) return 220; - if (iKey == 221 ) return 219; - if (iKey == 222 ) return 192; - if (iKey == 223 ) return 191; - if (iKey == 226 ) return 226; - if (iKey == 77 ) return 186; - return iKey; -} - - - -/*bool KMX_Lin_ImportRules_Lin(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 - KMX_Loader loader; - const size_t BUF_sz= 256; - //Inspect_kp(kp); // _ _S2 only open for inspecting; if used when running the program it will crash :-( ) - KMX_HKL hkl = NULL; //_S2 added: but can I do this?? hkl is not needed in Linux?? - - BYTE lpKeyState[256];// = new KeysEx[256]; - std::vector rgKey; //= new VirtualKey[256]; - std::vector alDead; - - KMX_VirtualKey* rgKey_single = new KMX_VirtualKey(1, hkl, All_Vector, keymap); - UINT nkeys_single =0; - - rgKey.resize(256); - - // _S2 scroll through OTHER - // Scroll through the Scan Code (SC) values and get the valid Virtual Key (VK) - // values in it. Then, store the SC in each valid VK so it can act as both a - // flag that the VK is valid, and it can store the SC value. - for(UINT sc = 0x01; sc <= 0x7f; sc++) { - // fills m_vk with the VK of the US keyboard which is not right!! - // ( mcompile win uses MapVirtualKeyEx() to fill m_vk with the VK of the Other keyboard) - // Linux cant get a VK for the US Keyboard using USVirtualKeyToScanCode/ScanCodeToUSVirtualKey - // Linux cannot get a VK for Other Keyboard - // it could return SC if that helps - KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, All_Vector, keymap); - if((key->VK() != 0) && (key->VK()< 255)) { // if used without ScanCodeToUSVirtualKey[] - rgKey[key->VK()] = key; - } else { - delete key; - } - } - - for(UINT ke = VK_NUMPAD0; ke <= VK_NUMPAD9; ke++) { - rgKey[ke] = new KMX_VirtualKey(hkl, ke, All_Vector, keymap); - } - - rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE, All_Vector, keymap); - rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL, All_Vector, keymap); - rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL, All_Vector, keymap); - - -// // _S2 do we need special shift state now or later? -// // See if there is a special shift state added -// for(UINT vk = 0; vk <= VK_OEM_CLEAR; vk++) { -// UINT sc = MapVirtualKeyEx(vk, 0, hkl); -// UINT vkL = MapVirtualKeyEx(sc, 1, hkl); -// UINT vkR = MapVirtualKeyEx(sc, 3, hkl); -// if((vkL != vkR) && -// (vk != vkL)) { -// switch(vk) { -// case VK_LCONTROL: -// case VK_RCONTROL: -// case VK_LSHIFT: -// case VK_RSHIFT: -// case VK_LMENU: -// case VK_RMENU: -// break; -// -// default: -// loader.Set_XxxxVk(vk); -// break; -// } -// } -// } - - - - // _S2 in this part we skip shiftstates 4, 5, 8, 9 - for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { - if(rgKey[iKey] != NULL) { - WCHAR sbBuffer[256]; // Scratchpad we use many places - - for(ShiftState ss = Base; ss <= loader.MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { - if(ss == Menu || ss == ShftMenu) { - continue; // Alt and Shift+Alt don't work, so skip them - } - - KMX_DWORD SC_US = get_KeyCode_fromVKUS(iKey); // _S2 only for testing can go later helps to force filling rgkey[VK_DE] - - for(int caps = 0; caps <= 1; caps++) { - //_S2 TODO get char - do I need rc ?? ( was rc = ToUnicodeEx...) - std::wstring KeyVal_Other = get_KeyVals_according_to_keycode_and_Shiftstate( *keymap, SC_US, ss, caps); - - if (!IsKeymanUsedKeyVal(KeyVal_Other)) - KeyVal_Other = L"\0"; - - //_S2 TODO do I need that ?? - //if rc >0: it got 1 or more char AND buffer is empty ( nothing inside ) { - if(KeyVal_Other == L"") { - //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); - rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps)); - rgKey_single->KMX_SetShiftState(ss, L"", false, (caps)); - } - - //_S2 TODO - //else // if rc ==1 : it got 1 char && +40 in Buffer CTRl pressed { - //It's dealing with control characters. If ToUnicodeEx gets VK_A with the Ctrl key pressed, - //it will write 0x01 to sBuffer[0] , without Ctrl it's 0x41. The if detects this case. - //&& CTRl +0x40 in the buffer ( which indicates a ctrl press) - if( (ss == Ctrl || ss == ShftCtrl) //&& CTRl +0x40 in the buffer ( which indicates a ctrl press) //) { - continue; - } - - //_S2 TODO fill m_rgfDeadkey ( m_rgfDeadkey will be done later) - //rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps==0)); - rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps)); - rgKey_single->KMX_SetShiftState(ss, KeyVal_Other, false, (caps)); - //if( KeyVal_Other != L"") - if( IsKeymanUsedKeyVal(KeyVal_Other) ) - nkeys_single ++ ; - int ertzu=888; - - - //_S2 TODO - // _S2 handle deadkeys later - // if rc <0: it got a deadkey { - // fill m_rgss and m_rgfDeadkey and alDead - //SET_SHIFTSTATES( deadkey) //sbuffer is value out of ToUnicodeEx / AllVector - // do more stuff for deadkeys... - // } from rc<0 - } - } - } - } - - - //------------------------------------------------------------- - // Now that we've collected the key data, we need to - // translate it to kmx and append to the existing keyboard - //------------------------------------------------------------- - - int nDeadkey = 0; - LPKMX_GROUP gp = new KMX_GROUP[kp->cxGroupArray+4]; // leave space for old - memcpy(gp, kp->dpGroupArray, sizeof(KMX_GROUP) * kp->cxGroupArray); - - // - - // Find the current highest deadkey index - // - - kp->dpGroupArray = gp; - for(UINT i = 0; i < kp->cxGroupArray; i++, gp++) { - //if(gp->fUsingKeys && gp->dpNoMatch == NULL) { // I4550 - // WCHAR *p = gp->dpNoMatch = new WCHAR[4]; - // *p++ = UC_SENTINEL; - // *p++ = CODE_USE; - // *p++ = (WCHAR)(kp->cxGroupArray + 1); - // *p = 0; - //} - LPKMX_KEY kkp = gp->dpKeyArray; - - for(UINT j = 0; j < gp->cxKeyArray; j++, kkp++) { - nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpContext)); - nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpOutput)); - } - } - - // _S2 find nkeys - // kp->cxGroupArray++; - // gp = &kp->dpGroupArray[kp->cxGroupArray-1]; - // UINT nKeys = 0; - // for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { - // if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { - // nKeys+= rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); - // wprintf(L" iKey = %i, Delta: %i -> Sum %i\n", iKey, rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()), nKeys); - // } - // } - - nDeadkey++; // ensure a 1-based index above the max deadkey value already in the keyboard - - gp->fUsingKeys = TRUE; - gp->dpMatch = NULL; - gp->dpName = NULL; - gp->dpNoMatch = NULL; - //gp->cxKeyArray = nKeys; - gp->cxKeyArray = nkeys_single; - gp->dpKeyArray = new KMX_KEY[gp->cxKeyArray]; - UINT nKeys = 0; - - - // - // Fill in the new rules - // - for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { - if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { - if(rgKey[iKey]->KMX_LayoutRow_Lin(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 - //if(rgKey_single->KMX_LayoutRow_Lin(loader.MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 - - nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.MaxShiftState()); - wprintf(L"nKeys sum: %i\n", nKeys); - } - } - } - - // --------------------------------------------------------------------------------------------- - - // A _S2 Look at the character in the key rule, - - // e.g. + 'y' > '... (so, key->Key == 'y' && key->ShiftFlags == 0) - KMX_WCHAR key_key; - KMX_DWORD key_shiftFlag; - // --------------------------------------------------------------------------------------------- - // B _S2 Find the key data by finding 'y' keyval in the target layout. (DE?) - // --------------------------------------------------------------------------------------------- - // C _S2 Look up the scan code (and modifiers) associated with that keyval. - // --------------------------------------------------------------------------------------------- - // D _S2 Use that scan code to get the US english vkey equivalent via ScanCodeToUSVirtualKey[] - // --------------------------------------------------------------------------------------------- - // E _S2 Rewrite the key rule to + [K_Z] > ... - // --------------------------------------------------------------------------------------------- - // F _S2 Nuance needed around modifier keys (so it may need to be + [SHIFT K_Z] for 'Y', for example). - // --------------------------------------------------------------------------------------------- - // Keyval(DE) -> SC_DE -> SC_US -> VK_US - // --------------------------------------------------------------------------------------------- - - - // _S2 no changes here after removing rgkey - gp->cxKeyArray = nKeys; - - // - // Add nomatch control to each terminating 'using keys' group // I4550 - // - LPKMX_GROUP gp2 = kp->dpGroupArray; - for(UINT i = 0; i < kp->cxGroupArray - 1; i++, gp2++) { - if(gp2->fUsingKeys && gp2->dpNoMatch == NULL) { - KMX_WCHAR *p = gp2->dpNoMatch = new KMX_WCHAR[4]; - KMX_WCHAR *q = p; - *p++ = UC_SENTINEL; - *p++ = CODE_USE; - *p++ = (KMX_WCHAR)(kp->cxGroupArray); - *p = 0; - - // _S2 TODO not sure if this works OK -> we need to use more shiftstates than base+Shift - // I4550 - Each place we have a nomatch > use(baselayout) (this last group), we need to add all - // the AltGr and ShiftAltGr combinations as rules to allow them to be matched as well. Yes, this - // loop is not very efficient but it's not worthy of optimisation. - // - UINT j; - LPKMX_KEY kkp; - for(j = 0, kkp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kkp++) { - wprintf(L"key: kkp->key%i(%c) and SFlag %i\n",kkp->Key,kkp->Key,kkp->ShiftFlags ); - //wprintf(L"key: gp ->key%i(%c) and SFlag %i\n",gp->dpKeyArray->Key,gp->dpKeyArray->Key,gp->dpKeyArray->ShiftFlags ); - //wprintf(L"key: gp2->key%i(%c) and SFlag %i\n",gp2->dpKeyArray->Key,gp2->dpKeyArray->Key,gp2->dpKeyArray->ShiftFlags ); - //wprintf(L"key: kp ->key%i(%c) and SFlag %i\n",kp->dpGroupArray->dpKeyArray->Key,kp->dpGroupArray->dpKeyArray->Key,kp->dpGroupArray->dpKeyArray->ShiftFlags ); - //&& CTRl +0x40 in the buffer ( which indicates a ctrl press) // - if((kkp->ShiftFlags & (K_CTRLFLAG|K_ALTFLAG|LCTRLFLAG|LALTFLAG|RCTRLFLAG|RALTFLAG)) != 0) { - gp2->cxKeyArray++; - LPKMX_KEY kkp2 = new KMX_KEY[gp2->cxKeyArray]; - memcpy(kkp2, gp2->dpKeyArray, sizeof(KMX_KEY)*(gp2->cxKeyArray-1)); - gp2->dpKeyArray = kkp2; - kkp2 = &kkp2[gp2->cxKeyArray-1]; - kkp2->dpContext = new KMX_WCHAR; *kkp2->dpContext = 0; - kkp2->Key = kkp->Key; - kkp2->ShiftFlags = kkp->ShiftFlags; - kkp2->Line = 0; - KMX_WCHAR *p = kkp2->dpOutput = new KMX_WCHAR[4]; - KMX_WCHAR *q=p; - *p++ = UC_SENTINEL; - *p++ = CODE_USE; - *p++ = (KMX_WCHAR)(kp->cxGroupArray); - *p = 0; - } - } - } - } - - if (alDead.size() > 0 && !bDeadkeyConversion) { // I4552 - kp->cxGroupArray++; - - KMX_WCHAR *p = gp->dpMatch = new KMX_WCHAR[4]; - *p++ = UC_SENTINEL; - *p++ = CODE_USE; - *p++ = (KMX_WCHAR) kp->cxGroupArray; - *p = 0; - - gp++; - - gp->fUsingKeys = FALSE; - gp->dpMatch = NULL; - gp->dpName = NULL; - gp->dpNoMatch = NULL; - gp->cxKeyArray = alDead.size(); - LPKMX_KEY kkp = gp->dpKeyArray = new KMX_KEY[alDead.size()]; - - LPKMX_STORE sp = new KMX_STORE[kp->cxStoreArray + alDead.size() * 2]; - memcpy(sp, kp->dpStoreArray, sizeof(KMX_STORE) * kp->cxStoreArray); - - kp->dpStoreArray = sp; - - sp = &sp[kp->cxStoreArray]; - int nStoreBase = kp->cxStoreArray; - kp->cxStoreArray += alDead.size() * 2; - - for(UINT i = 0; i < alDead.size(); i++) { - DeadKey *dk = alDead[i]; - - sp->dpName = NULL; - sp->dwSystemID = 0; - sp->dpString = new KMX_WCHAR[dk->KMX_Count() + 1]; - for(int j = 0; j < dk->KMX_Count(); j++) - sp->dpString[j] = dk->KMX_GetBaseCharacter(j); - sp->dpString[dk->KMX_Count()] = 0; - sp++; - - sp->dpName = NULL; - sp->dwSystemID = 0; - sp->dpString = new KMX_WCHAR[dk->KMX_Count() + 1]; - for(int j = 0; j < dk->KMX_Count(); j++) - sp->dpString[j] = dk->KMX_GetCombinedCharacter(j); - sp->dpString[dk->KMX_Count()] = 0; - sp++; - - kkp->Line = 0; - kkp->ShiftFlags = 0; - kkp->Key = 0; - KMX_WCHAR *p = kkp->dpContext = new KMX_WCHAR[8]; - *p++ = UC_SENTINEL; - *p++ = CODE_DEADKEY; - *p++ = KMX_DeadKeyMap(dk->KMX_DeadCharacter(), &alDead, nDeadkey, FDeadkeys); // I4353 - // *p++ = nDeadkey+i; - *p++ = UC_SENTINEL; - *p++ = CODE_ANY; - *p++ = nStoreBase + i*2 + 1; - *p = 0; - - p = kkp->dpOutput = new KMX_WCHAR[5]; - *p++ = UC_SENTINEL; - *p++ = CODE_INDEX; - *p++ = nStoreBase + i*2 + 2; - *p++ = 2; - *p = 0; - - kkp++; - } - } -return true; -}*/ - - - - - -// _S2 maybe not needed -UINT find_SC_Other_from_SC_US_GDK(UINT SC_US,GdkKeymap *keymap) { - UINT SC__Other; - - for ( int i=0; i<255;i++) { - SC__Other= (UINT )get_KeyCode_From_KeyVal_GDK( keymap, i); - if(SC__Other==SC_US ) - return SC__Other; - } - return SC_US; -} - -std::wstring get_KeyVals_according_to_keycode_and_Shiftstate_Lin(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ - - GdkModifierType consumed; - GdkKeymapKey *maps; - guint *keyvals; - gint count; - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return L"\0"; - //return L"1"; -// _S2 remove! only for testing helps to force filling rgkey[VK_DE] -if((keycode == 49) && (ss == Base)) return L"^"; -if((keycode == 21) && (ss == Base)) return L"'"; -if((keycode == 21) && (ss == Shft)) return L"`"; -if((keycode == 21) && (ss == Base) && (caps == 1)) return L"'"; -if((keycode == 20) && (ss == Base) && (caps == 1)) return L"ß"; //L"ẞ"; -if((keycode == 20) && (ss == ShftMenuCtrl) && (caps == 0)) return L"ß"; //L"ẞ"; -if((keycode == 20) && (ss == ShftMenuCtrl) && (caps == 1)) return L"ß"; //L"ẞ"; - - //unshifted - if (( ss == Base ) && ( caps == 0 )) { - GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); - } - - //SHIFT+CAPS - else if ( ( ss == Shft ) && ( caps ==1 )) { - GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); - } - - //Shift - else if (( ss == Shft ) && ( caps == 0 )) { - GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); - std::wstring rV1= std::wstring(1, (int) *keyvals); - return std::wstring(1, (int) *keyvals); - } - - //caps - else if (( ss == Base ) && ( caps == 1 )) { - GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); - } - - //ALT-GR - else if (( ss == MenuCtrl ) && ( caps == 0 )){ - //GdkModifierType MOD_AltGr = (GdkModifierType) ( 144 ); - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); - } - - //ALT-GR - else if (( ss == MenuCtrl ) && ( caps == 1 )){ - //GdkModifierType MOD_AltGr = (GdkModifierType) ( 146 ); - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); - } - - else - return L"\0"; -} - - - -std::wstring get_KeyVals_according_to_keycode_and_Shiftstate(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps ){ - - GdkModifierType consumed; - GdkKeymapKey *maps; - guint *keyvals; - gint count; - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return L"\0"; - //return L"1"; - - //unshifted - if (( ss == Base ) && ( caps == 0 )) { - GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); - } - - //SHIFT+CAPS - else if ( ( ss == Shft ) && ( caps ==1 )) { - GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); - } - - //Shift - else if (( ss == Shft ) && ( caps == 0 )) { - GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); - std::wstring rV1= std::wstring(1, (int) *keyvals); - return std::wstring(1, (int) *keyvals); - } - - //caps - else if (( ss == Base ) && ( caps == 1 )) { - GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); - } - - //ALT-GR - else if (( ss == MenuCtrl ) && ( caps == 0 )){ - //GdkModifierType MOD_AltGr = (GdkModifierType) ( 144 ); - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); - } - - //ALT-GR - else if (( ss == MenuCtrl ) && ( caps == 1 )){ - //GdkModifierType MOD_AltGr = (GdkModifierType) ( 146 ); - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); - return std::wstring(1, (int) *keyvals); - } - - else - return L"\0"; -} - -// takes capital letter of Other returns cpital character of US keyboard -/*KMX_WORD VKUS(v_dw_3D &All_Vector,KMX_DWORD inOther) { - // loop and find char in Other; then return char of US - for( int i=0; i< (int)All_Vector[1].size();i++) { - for( int j=1; j< (int)All_Vector[1][0].size();j++) { - if((inOther == All_Vector[1][i][j] )) { - return All_Vector[0][i][2]; - } - } - } - return inOther; -}*/ - - -/*int KMX_ToUnicodeEx(GdkKeymap *keymap, guint ScanCode, const BYTE *lpKeyState, PWCHAR pwszBuff, int cchBuff, int shift_state, int caps) { - -int IIII = ShiftState(shift_state); - KMX_DWORD kvl= getKeyvalsFromKeyCode(keymap, ScanCode, shift_state); - - std::wstring KeyVal_Other = get_KeyVals_according_to_keycode_and_Shiftstate_new( keymap, ScanCode, ShiftState(shift_state), caps); - - WCHAR kv_wchar = (WCHAR) kvl; - PWCHAR kp_v_wchar = &kv_wchar; - pwszBuff= kp_v_wchar; - - //std::wstring wws= std::wstring(1, kvl); - KMX_WCHAR DeadKey; - //std::wstring wws= - KMX_WCHAR val= KMX_CharFromSC_underlying(keymap, shift_state, ScanCode, &DeadKey); -KMX_DWORD dw= getKeyvalsFromKeyCode(keymap, ScanCode, ShiftState(shift_state)); - -//std::wstring abc= get_KeyVals_according_to_keycode_and_Shiftstate_new(keymap, ScanCode, ShiftState(shift_state), 0); -WCHAR wchr= (WCHAR) dw; -PWCHAR pwchr = &wchr; -//PWCHAR pwcp2= (PWCHAR) abc.c_str(); - PWCHAR wwch= (PWCHAR) wws.c_str(); -PWCHAR KeyVal_Otherpwcp2= (PWCHAR) KeyVal_Other.c_str(); - //pwszBuff[0]= *pwchr; - pwszBuff[0]= *KeyVal_Otherpwcp2; - - int rc; - - if((kvl >= 0xfe50) && (kvl <= 0xfe93) ) - rc = -1; - else rc = 1; - - return rc; - -}*/ - diff --git a/linux/mcompile/keymap/helpers.h b/linux/mcompile/keymap/helpers.h deleted file mode 100755 index 5c7a2f24ac..0000000000 --- a/linux/mcompile/keymap/helpers.h +++ /dev/null @@ -1,63 +0,0 @@ -// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -//_S2 do not review - all this will be deleted later -// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -#pragma once -#ifndef HELPERS_H -#define HELPERS_H - -#include -#include "mc_savekeyboard.h" -#include "mc_kmxfile.h" -#include "keymap.h" - -// why again here? -typedef std::vector v_str_1D; -typedef std::vector v_dw_1D; -typedef std::vector > v_dw_2D; -typedef std::vector > > v_dw_3D; - -int test_helpers(); - -// append characters using VectorFile (Data for Other Language on [1][ ][ ] ) -int append_other_ToVector(v_dw_3D &All_Vector) ; - -// get Keyvals from File and insert into All_Vector -bool InsertKeyvalsFromVectorFile(v_dw_3D &complete_Vector) ; - -// create a Vector with all entries of file -int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector); - -bool writeVectorToFile(v_dw_3D V) ; -bool writeFileToVector(v_dw_3D& complete_Vector, const char* infile); -bool CompareVector_To_VectorOfFile(v_dw_3D All_Vector,v_dw_3D File_Vector); -bool test_In_Out(v_dw_3D All_Vector); - -// to check if content of Vector is ok -bool write_RGKEY_FileToVector(v_dw_2D& shift_states, const char* infile) ; -bool CompareVector_To_VectorOfFile_RGKEY(v_dw_2D Win_Vector,v_dw_2D Lin_Vector, v_dw_2D Map_Vector); -KMX_DWORD get_position_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector); - -int replace_PosKey_with_Keycode(std::string in); - -// query All_Vector -// _S2 can go later return the VirtualKey of the US Keyboard for given Scancode -KMX_DWORD get_VirtualKey_US_From_SC(KMX_DWORD SC , v_dw_3D &All_Vector); -// _S2 can go later return the Scancode of for given VirtualKey of Other Keyboard -KMX_DWORD get_SC_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector); -// _S2 can go later return the Scancode of for given VirtualKey of US -KMX_DWORD get_SC_From_VirtualKey_US(KMX_DWORD VK_US , v_dw_3D &All_Vector); -// _S2 can go later return the Scancode of for given VirtualKey of Other -KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_US , v_dw_3D &All_Vector); -// _S2 can go later return the Scancode of for given VirtualKey of Other in specific column. If column > available columns look in all columns; -KMX_DWORD get_position_From_VirtualKey_Other(KMX_DWORD VK_Other , v_dw_3D &All_Vector, int which_columns); -/* -// returns Keyvals fo ra given key (for unshifted: finds the Name of the Key e.g. A or 1 ) -std::wstring get_KeyVals_according_to_Shiftstate(GdkKeymap *keymap, guint VK, ShiftState ss, int caps); -*/ -//std::wstring get_VirtualKey_US_from_iKey(KMX_DWORD iKey, ShiftState &ss, int &caps, v_dw_3D &All_Vector); - -//bool KMX_ImportRules_bak(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 -//bool KMX_Lin_ImportRules_Lin(KMX_WCHAR *kbid, LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 - -#endif /* HELPERS_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 58ec2fec55..f268930aec 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -14,15 +14,10 @@ #include #include #include -#include "mc_kmxfile.h" #include "kmx_file.h" -#include "mc_savekeyboard.h" #include "u16.h" +#include "mc_savekeyboard.h" -typedef std::vector v_str_1D; -typedef std::vector v_dw_1D; -typedef std::vector > v_dw_2D; -typedef std::vector > > v_dw_3D; enum ShiftState { Base = 0, // 0 @@ -64,8 +59,14 @@ const KMX_DWORD KMX_VKMap[] = { 0 }; +typedef std::vector v_str_1D; + +typedef std::vector v_dw_1D; +typedef std::vector > v_dw_2D; +typedef std::vector > > v_dw_3D; + static KMX_DWORD returnIfCharInvalid = 0; -static KMX_DWORD keycode_max =94; +static KMX_DWORD keycode_max = 94; static KMX_DWORD deadkey_min = 0xfe50; static KMX_DWORD deadkey_max = 0xfe93; diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index 9ea50d381e..26e20b61f4 100755 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -57,18 +57,6 @@ typedef KMX_BYTE* PKMX_BYTE; typedef KMX_DWORD* PKMX_DWORD; typedef int BOOL; -//typedef uint8_t* PBYTE; -//typedef unsigned short WORD; -//typedef wchar_t* LPWSTR; -//typedef KMX_CHAR* PKMX_CHAR; -//typedef char* LPSTR; -//typedef uint8_t* LPBYTE; -//typedef KMX_WORD* PKMX_WORD; - -// in WIN: -// PVOID A pointer to any type. -// typedef PVOID HANDLE; -// typedef HANDLE HKL; typedef void* KMX_HKL; // _S2 QUESTION what is the equivalent to HKL and do I need it?? I assume a void* diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 8aea942a61..2818ad2317 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -21,7 +21,6 @@ #define MCOMPILE_H #include #include "keymap.h" -#include "helpers.h" #include "deadkey.h" #include "mc_kmxfile.h" diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index 60fb919de9..831a121a07 100755 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -11,7 +11,6 @@ libxklavier = dependency('libxklavier') deps = [gtk, x11, xkb,libxklavier] cpp_files = files( - 'helpers.cpp', 'keymap.cpp', 'deadkey.cpp', 'mcompile.cpp', From d0c7d348f34f53b821b44fb333b30f0a42100ddd Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 15 Feb 2024 12:37:33 +0100 Subject: [PATCH 208/327] feat(linux): mcompile-dk remove mc_savekeyboard --- linux/mcompile/keymap/keymap.h | 1 - linux/mcompile/keymap/mc_import_rules.cpp | 34 +- linux/mcompile/keymap/mc_kmxfile.cpp | 161 +------ linux/mcompile/keymap/mc_kmxfile.h | 71 --- linux/mcompile/keymap/mc_savekeyboard.cpp | 2 - linux/mcompile/keymap/mc_savekeyboard.h | 9 - linux/mcompile/keymap/mcompile.cpp | 539 +--------------------- linux/mcompile/keymap/mcompile.h | 9 - linux/mcompile/keymap/meson.build | 1 - 9 files changed, 27 insertions(+), 800 deletions(-) delete mode 100755 linux/mcompile/keymap/mc_savekeyboard.cpp delete mode 100755 linux/mcompile/keymap/mc_savekeyboard.h diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index f268930aec..5567a05fdc 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -16,7 +16,6 @@ #include #include "kmx_file.h" #include "u16.h" -#include "mc_savekeyboard.h" enum ShiftState { diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index e3eb9a3bd8..0576c06e20 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -39,28 +39,28 @@ const int KMX_ShiftStateMap[] = { 0 }; - DeadKey::DeadKey(KMX_WCHAR deadCharacter) { - this->m_deadchar = deadCharacter; - } +DeadKey::DeadKey(KMX_WCHAR deadCharacter) { + this->m_deadchar = deadCharacter; +} - KMX_WCHAR DeadKey::KMX_DeadCharacter() { - return this->m_deadchar; - } +KMX_WCHAR DeadKey::KMX_DeadCharacter() { + return this->m_deadchar; +} - void DeadKey::KMX_AddDeadKeyRow(KMX_WCHAR baseCharacter, KMX_WCHAR combinedCharacter) { - this->m_rgbasechar.push_back(baseCharacter); - this->m_rgcombchar.push_back(combinedCharacter); - } +void DeadKey::KMX_AddDeadKeyRow(KMX_WCHAR baseCharacter, KMX_WCHAR combinedCharacter) { + this->m_rgbasechar.push_back(baseCharacter); + this->m_rgcombchar.push_back(combinedCharacter); +} - bool DeadKey::KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter) { - std::vector::iterator it; - for(it=this->m_rgbasechar.begin(); it::iterator it; + for(it=this->m_rgbasechar.begin(); it +#define CERR_None 0x00000000 +#define CERR_CannotAllocateMemory 0x00008004 +#define CERR_UnableToWriteFully 0x00008007 +#define CERR_SomewhereIGotItWrong 0x00008009 + KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz); LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); @@ -219,8 +224,7 @@ PKMX_WCHAR KMX_StringOffset(PKMX_BYTE base, KMX_DWORD offset) { #ifdef KMX_64BIT -/** - CopyKeyboard will copy the data read into bufp from x86-sized structures into +/** CopyKeyboard will copy the data read into bufp from x86-sized structures into x64-sized structures starting at `base` * After this function finishes, we still need to keep the original data because we don't copy the strings @@ -304,9 +308,7 @@ LPKMX_KEYBOARD KMX_CopyKeyboard(PKMX_BYTE bufp, PKMX_BYTE base) } // else KMX_FixupKeyboard -#else -/** - Fixup the keyboard by expanding pointers. On disk the pointers are stored relative to the +#else /** Fixup the keyboard by expanding pointers. On disk the pointers are stored relative to the beginning of the file, but we need real pointers. This method is used on 32-bit architectures. */ @@ -346,6 +348,7 @@ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFil return kbp; } + #endif KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { @@ -510,151 +513,3 @@ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p) { return p; } - - -//---------------------old---------------------------------------- -/* -#include "pch.h" - - -static BOOL LoadKeyboardFile(LPSTR fileName, LPKEYBOARD *lpKeyboard); -BOOL VerifyKeyboard(LPBYTE filebase, DWORD sz); - -LPKEYBOARD FixupKeyboard(PBYTE bufp, PBYTE base, DWORD dwFileSize); - -void Err(wchar_t *s) { - LogError(L"LoadKeyboard: %s, last error = %d\n", s, GetLastError()); -} - -BOOL LoadKeyboard(LPWSTR fileName, LPKEYBOARD *lpKeyboard) { - DWORD sz; - LPBYTE buf; - HANDLE hFile; - LPKEYBOARD kbp; - PBYTE filebase; - - if(!fileName || !lpKeyboard) { - Err(L"Bad Filename"); - return FALSE; - } - - hFile = CreateFile(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - if(hFile == INVALID_HANDLE_VALUE) { - Err(L"Could not open file"); - return FALSE; - } - - sz = GetFileSize(hFile, NULL); - - buf = new BYTE[sz]; - - if(!buf) { - Err(L"Not allocmem"); - CloseHandle(hFile); - return FALSE; - } - - filebase = buf; - - if(!ReadFile(hFile, filebase, sz, &sz, NULL)) { - Err(L"errReadFile"); - CloseHandle(hFile); - delete[] buf; - return FALSE; - } - CloseHandle(hFile); - - if(!VerifyKeyboard(filebase, sz)) { - Err(L"errVerifyKeyboard"); - delete[] buf; - return FALSE; - } - - kbp = FixupKeyboard(buf, filebase, sz); - if(!kbp) { - Err(L"errFixupKeyboard"); - delete[] buf; - return FALSE; - } - - if(kbp->dwIdentifier != FILEID_COMPILED) { - Err(L"errNotFileID"); - delete[] buf; - return FALSE; - } - - *lpKeyboard = kbp; - return TRUE; -} - -PWCHAR StringOffset(PBYTE base, DWORD offset) { - if(offset == 0) return NULL; - return (PWCHAR)(base + offset); -} - -LPKEYBOARD FixupKeyboard(PBYTE bufp, PBYTE base, DWORD dwFileSize) { - UNREFERENCED_PARAMETER(dwFileSize); - - DWORD i, j; - PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD) base; - PCOMP_GROUP cgp; - PCOMP_STORE csp; - PCOMP_KEY ckp; - LPKEYBOARD kbp = (LPKEYBOARD) bufp; - LPSTORE sp; - LPGROUP gp; - LPKEY kp; - - kbp->dpStoreArray = (LPSTORE) (base + ckbp->dpStoreArray); - kbp->dpGroupArray = (LPGROUP) (base + ckbp->dpGroupArray); - - for(sp = kbp->dpStoreArray, csp = (PCOMP_STORE) sp, i = 0; i < kbp->cxStoreArray; i++, sp++, csp++) { - sp->dpName = StringOffset(base, csp->dpName); - sp->dpString = StringOffset(base, csp->dpString); - } - - for(gp = kbp->dpGroupArray, cgp = (PCOMP_GROUP) gp, i = 0; i < kbp->cxGroupArray; i++, gp++, cgp++) { - gp->dpName = StringOffset(base, cgp->dpName); - gp->dpKeyArray = (LPKEY) (base + cgp->dpKeyArray); - if(cgp->dpMatch != NULL) gp->dpMatch = (PWSTR) (base + cgp->dpMatch); - if(cgp->dpNoMatch != NULL) gp->dpNoMatch = (PWSTR) (base + cgp->dpNoMatch); - - for(kp = gp->dpKeyArray, ckp = (PCOMP_KEY) kp, j = 0; j < gp->cxKeyArray; j++, kp++, ckp++) { - kp->dpOutput = (PWSTR) (base + ckp->dpOutput); - kp->dpContext = (PWSTR) (base + ckp->dpContext); - } - } - - return kbp; -} - -BOOL VerifyKeyboard(LPBYTE filebase, DWORD sz) { - DWORD i; - PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD) filebase; - PCOMP_STORE csp; - - // Check file version // - - if(ckbp->dwFileVersion < VERSION_MIN || - ckbp->dwFileVersion > VERSION_MAX) { - // Old or new version -- identify the desired program version // - for(csp = (PCOMP_STORE)(filebase + ckbp->dpStoreArray), i = 0; i < ckbp->cxStoreArray; i++, csp++) { - if(csp->dwSystemID == TSS_COMPILEDVERSION) { - wchar_t buf2[256]; - if(csp->dpString == 0) { - wsprintf(buf2, L"errWrongFileVersion:NULL"); - } else { - wsprintf(buf2, L"errWrongFileVersion:%10.10ls", StringOffset(filebase, csp->dpString)); - } - Err(buf2); - return FALSE; - } - } - Err(L"errWrongFileVersion"); - return FALSE; - } - - - return TRUE; -} -*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index aa45af117e..5bc82a963c 100755 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -79,75 +79,4 @@ KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL #endif // _KMXFILE_H -//---------------------old---------------------------------------- -/* -#include - -#ifndef _KMXFILE_H -#define _KMXFILE_H - -typedef struct tagSTORE { - DWORD dwSystemID; - PWSTR dpName; - PWSTR dpString; -} STORE, *LPSTORE; - -typedef struct tagKEY { - WCHAR Key; - DWORD Line; - DWORD ShiftFlags; - PWSTR dpOutput; - PWSTR dpContext; -} KEY, *LPKEY; - - -typedef struct tagGROUP { - PWSTR dpName; - LPKEY dpKeyArray; // [LPKEY] address of first item in key array - PWSTR dpMatch; - PWSTR dpNoMatch; - DWORD cxKeyArray; // in array entries - BOOL fUsingKeys; // group(xx) [using keys] <-- specified or not -} GROUP, *LPGROUP; - - -typedef struct tagKEYBOARD { - DWORD dwIdentifier; // Keyman compiled keyboard id - - DWORD dwFileVersion; // Version of the file - Keyman 4.0 is 0x0400 - - DWORD dwCheckSum; // As stored in keyboard. DEPRECATED as of 16.0 - DWORD xxkbdlayout; // as stored in HKEY_LOCAL_MACHINE//system//currentcontrolset//control//keyboard layouts - DWORD IsRegistered; // layout id, from same registry key - DWORD version; // keyboard version - - DWORD cxStoreArray; // in array entries - DWORD cxGroupArray; // in array entries - - LPSTORE dpStoreArray; // [LPSTORE] address of first item in store array, from start of file - LPGROUP dpGroupArray; // [LPGROUP] address of first item in group array, from start of file - - DWORD StartGroup[2]; // index of starting groups [2 of them] - // Ansi=0, Unicode=1 - - DWORD dwFlags; // Flags for the keyboard file - - DWORD dwHotKey; // standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) - - //PWSTR dpName; // offset of name - //PWSTR dpLanguageName; // offset of language name; - //PWSTR dpCopyright; // offset of copyright - //PWSTR dpMessage; // offset of message in Keyboard About box - - DWORD dpBitmapOffset; // 0038 offset of the bitmaps in the file - DWORD dwBitmapSize; // 003C size in bytes of the bitmaps - //HBITMAP hBitmap; // handle to the bitmap in the file; -} KEYBOARD, *LPKEYBOARD; - -BOOL LoadKeyboard(LPWSTR fileName, LPKEYBOARD *lpKeyboard); - -#endif -*/ - - #endif /*MC_KMXFILE_H*/ diff --git a/linux/mcompile/keymap/mc_savekeyboard.cpp b/linux/mcompile/keymap/mc_savekeyboard.cpp deleted file mode 100755 index 571e919f89..0000000000 --- a/linux/mcompile/keymap/mc_savekeyboard.cpp +++ /dev/null @@ -1,2 +0,0 @@ - -// moved to mc_kmxfile.cpp/.h diff --git a/linux/mcompile/keymap/mc_savekeyboard.h b/linux/mcompile/keymap/mc_savekeyboard.h deleted file mode 100755 index 71f2e43749..0000000000 --- a/linux/mcompile/keymap/mc_savekeyboard.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include "km_types.h" -#include - -#define CERR_None 0x00000000 -#define CERR_CannotAllocateMemory 0x00008004 -#define CERR_UnableToWriteFully 0x00008007 -#define CERR_SomewhereIGotItWrong 0x00008009 diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 706421d1be..64c0876301 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -57,7 +57,6 @@ std::vector KMX_FDeadkeys; // I4353 int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ - // convert std::vector to std::vector std::vector argv; for (int i = 0; i < argc; i++) { const char16_t* cmdl_par = str_argv[i].c_str(); @@ -77,7 +76,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ return 1; } - // -u option was removed for Linux + // _S2 INFO -u option was removed for Linux int bDeadkeyConversion = u16cmp(argv[1], u"-d") == 0; // I4552 int n = (bDeadkeyConversion ? 2 : 1); @@ -131,7 +130,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ } #endif - //DeleteReallocatedPointers(kmxfile); :TODO // not my ToDo :-) + //DeleteReallocatedPointers(kmxfile); :TODO // _S2 not my ToDo :-) delete kmxfile; @@ -468,7 +467,6 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg KMX_ReportUnconvertedKeyboardRules(kbd); - // _S2 INFO use translated kbd and write data to rgkey[] then add things to rgkey[] to enable to write to kmx-format if(!KMX_ImportRules(kbd, All_Vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 return FALSE; @@ -476,7 +474,6 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg return TRUE; } - int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap) { KMX_WORD *p = OutputPairs; @@ -500,7 +497,6 @@ int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, return (p-OutputPairs); } - void KMX_LogError(PWCHAR fmt, ...) { WCHAR fmtbuf[256]; wchar_t *end = L"\0"; @@ -520,534 +516,3 @@ void KMX_LogError(PWCHAR fmt, ...) { putwchar(*nl); } -// ---- old copy code from here ---------------------------------------------------------- - -/* -BOOL ConvertKeyboardToUnicode(LPKEYBOARD kbd); // I4273 - - -#define KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE_MCOMPILE KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE ".mcompile" - -// -// Map of all shift states that we will work with -// -const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; - - -void ReportUnconvertedKeyRule(LPKEY key) { - if(key->ShiftFlags == 0) { - LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); - } else if(key->ShiftFlags & VIRTUALCHARKEY) { - LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); - } -} - -void ReportUnconvertedGroupRules(LPGROUP group) { - for(unsigned int i = 0; i < group->cxKeyArray; i++) { - ReportUnconvertedKeyRule(&group->dpKeyArray[i]); - } -} - -void ReportUnconvertedKeyboardRules(LPKEYBOARD kbd) { - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { - ReportUnconvertedGroupRules(&kbd->dpGroupArray[i]); - } - } -} - -void TranslateDeadkeyKey(LPKEY key, WCHAR deadkey, WORD vk, UINT shift, WORD ch) { - if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { - - // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. - // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" - // to provide an alternate.. - if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4327 - shift &= ~LCTRLFLAG; - - if(key->ShiftFlags == 0) { - //LogError("Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d]", key->Line, key->Key, deadkey, shift, vk); - key->ShiftFlags = ISVIRTUALKEY | shift; - } else { - //LogError("Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO dk(%d) + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, deadkey, key->ShiftFlags & ~VIRTUALCHARKEY, vk); - key->ShiftFlags &= ~VIRTUALCHARKEY; - } - - int len = wcslen(key->dpContext); - PWSTR context = new WCHAR[len + 4]; - memcpy(context, key->dpContext, len * sizeof(WCHAR)); - context[len] = UC_SENTINEL; - context[len+1] = CODE_DEADKEY; - context[len+2] = deadkey; - context[len+3] = 0; - key->dpContext = context; - key->Key = vk; - } -} - -void TranslateDeadkeyGroup(LPGROUP group, WCHAR deadkey, WORD vk, UINT shift, WORD ch) { - for(unsigned int i = 0; i < group->cxKeyArray; i++) { - TranslateDeadkeyKey(&group->dpKeyArray[i], deadkey, vk, shift, ch); - } -} - -void TranslateDeadkeyKeyboard(LPKEYBOARD kbd, WCHAR deadkey, WORD vk, UINT shift, WORD ch) { - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { - TranslateDeadkeyGroup(&kbd->dpGroupArray[i], deadkey, vk, shift, ch); - } - } -} - - -*/ - - - -//---------old- - original code------------------------------------------ -/*#include "pch.h" -#include - -#include -#include -#include - -BOOL DoConvert(LPKEYBOARD kbd, PWSTR kbid, BOOL bDeadkeyConversion); -BOOL SaveKeyboard(LPKEYBOARD kbd, PWSTR filename); -bool ImportRules(WCHAR *kbid, LPKEYBOARD kp, std::vector *FDeadkeys, BOOL bDeadkeyConversion); // I4353 // I4327 -BOOL ConvertKeyboardToUnicode(LPKEYBOARD kbd); // I4273 -int run(int argc, wchar_t * argv[]); - -std::vector FDeadkeys; // I4353 - -#define KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE_MCOMPILE KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE ".mcompile" - -int wmain(int argc, wchar_t * argv[]) -{ - return keyman_sentry_wmain(false, KEYMAN_SENTRY_LOGGER_DESKTOP_ENGINE_MCOMPILE, argc, argv, run); -} - -int run(int argc, wchar_t * argv[]) -{ - if(argc < 3 || (argc < 5 && wcscmp(argv[1], L"-u") != 0)) { // I4273 - printf( - "Usage: mcompile -u infile.kmx outfile.kmx\n" - " mcompile [-d] infile.kmx kbdfile.dll kbid outfile.kmx\n" - " With -u parameter, converts keyboard from ANSI to Unicode\n" - " Otherwise, mcompile converts a Keyman mnemonic layout to a\n" - " positional one based on the Windows keyboard\n" - " layout file given by kbdfile.dll\n\n" - " kbid should be a hexadecimal number e.g. 409 for US English\n" - " -d convert deadkeys to plain keys\n"); // I4552 - - return 1; - } - - if(wcscmp(argv[1], L"-u") == 0) { // I4273 - wchar_t *infile = argv[2], *outfile = argv[3]; - - LPKEYBOARD kmxfile; - - if(!LoadKeyboard(infile, &kmxfile)) { - LogError(L"Failed to load keyboard (%d)", GetLastError()); - return 3; - } - - if(ConvertKeyboardToUnicode(kmxfile)) { - SaveKeyboard(kmxfile, outfile); - } - - //DeleteReallocatedPointers(kmxfile); :TODO - delete[] kmxfile; - - return 0; // I4279 - } - - int bDeadkeyConversion = wcscmp(argv[1], L"-d") == 0; // I4552 - int n = (bDeadkeyConversion ? 2 : 1); - - wchar_t *infile = argv[n], *indll = argv[n+1], *kbid = argv[n+2], *outfile = argv[n+3]; - - wprintf(L"mcompile%ls \"%ls\" \"%ls\" \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d":L"", infile, indll, kbid, outfile); // I4174 - - // 1. Load the keyman keyboard file - - // 2. For each key on the system layout, determine its output character and perform a - // 1-1 replacement on the keyman keyboard of that character with the base VK + shift - // state. This fixup will transform the char to a vk, which will avoid any issues - // with the key. - // - // --> deadkeys we will attack after the POC - // - // For each deadkey, we need to determine its possible outputs. Then we generate a VK - // rule for that deadkey, e.g. [K_LBRKT] > dk(c101) - // - // Next, update each rule that references the output from that deadkey to add an extra - // context deadkey at the end of the context match, e.g. 'a' dk(c101) + [K_SPACE] > 'b'. - // This will require a memory layout change for the .kmx file, plus fixups on the - // context+output index offsets - // - // --> virtual character keys - // - // [CTRL ' '] : we look at the character, and replace it in the same way, but merely - // switch the shift state from the VIRTUALCHARKEY to VIRTUALKEY, without changing any - // other properties of the key. - // - - // 3. Write the new keyman keyboard file - - if(!LoadNewLibrary(indll)) { - LogError(L"Failed to load keyboard DLL (%d)", GetLastError()); - return 2; - } - - LPKEYBOARD kmxfile; - - if(!LoadKeyboard(infile, &kmxfile)) { - LogError(L"Failed to load keyboard (%d)", GetLastError()); - return 3; - } - - if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552 - SaveKeyboard(kmxfile, outfile); - } - - //DeleteReallocatedPointers(kmxfile); :TODO - delete kmxfile; - - return 0; -} - - -// -// Map of all US English virtual key codes that we can translate -// -const WORD VKMap[] = { - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - VK_SPACE, - VK_ACCENT, VK_HYPHEN, VK_EQUAL, - VK_LBRKT, VK_RBRKT, VK_BKSLASH, - VK_COLON, VK_QUOTE, - VK_COMMA, VK_PERIOD, VK_SLASH, - VK_xDF, VK_OEM_102, - 0 -}; - - -// -// Map of all shift states that we will work with -// -const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; - -// -// TranslateKey -// -// For each key rule on the keyboard, remap its key to the -// correct shift state and key. Adjust the LCTRL+RALT -> RALT if necessary -// -void TranslateKey(LPKEY key, WORD vk, UINT shift, WCHAR ch) { - - // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. - // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" - // to provide an alternate.. - if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) - shift &= ~LCTRLFLAG; - - if(key->ShiftFlags == 0 && key->Key == ch) { - // Key is a mnemonic key with no shift state defined. - // Remap the key according to the character on the key cap. - //LogError(L"Converted mnemonic rule on line %d, + '%c' TO + [%x K_%d]", key->Line, key->Key, shift, vk); - key->ShiftFlags = ISVIRTUALKEY | shift; - key->Key = vk; - } else if(key->ShiftFlags & VIRTUALCHARKEY && key->Key == ch) { - // Key is a virtual character key with a hard-coded shift state. - // Do not remap the shift state, just move the key. - // This will not result in 100% wonderful mappings as there could - // be overlap, depending on how keys are arranged on the target layout. - // But that is up to the designer. - //LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, key->ShiftFlags & ~VIRTUALCHARKEY, vk); - key->ShiftFlags &= ~VIRTUALCHARKEY; - key->Key = vk; - } -} - -void TranslateGroup(LPGROUP group, WORD vk, UINT shift, WCHAR ch) { - for(unsigned int i = 0; i < group->cxKeyArray; i++) { - TranslateKey(&group->dpKeyArray[i], vk, shift, ch); - } -} - -void TranslateKeyboard(LPKEYBOARD kbd, WORD vk, UINT shift, WCHAR ch) { - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { - TranslateGroup(&kbd->dpGroupArray[i], vk, shift, ch); - } - } -} - -void ReportUnconvertedKeyRule(LPKEY key) { - if(key->ShiftFlags == 0) { - LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); - } else if(key->ShiftFlags & VIRTUALCHARKEY) { - LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); - } -} - -void ReportUnconvertedGroupRules(LPGROUP group) { - for(unsigned int i = 0; i < group->cxKeyArray; i++) { - ReportUnconvertedKeyRule(&group->dpKeyArray[i]); - } -} - -void ReportUnconvertedKeyboardRules(LPKEYBOARD kbd) { - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { - ReportUnconvertedGroupRules(&kbd->dpGroupArray[i]); - } - } -} - -void TranslateDeadkeyKey(LPKEY key, WCHAR deadkey, WORD vk, UINT shift, WORD ch) { - if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { - - // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. - // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" - // to provide an alternate.. - if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4327 - shift &= ~LCTRLFLAG; - - if(key->ShiftFlags == 0) { - //LogError("Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d]", key->Line, key->Key, deadkey, shift, vk); - key->ShiftFlags = ISVIRTUALKEY | shift; - } else { - //LogError("Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO dk(%d) + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, deadkey, key->ShiftFlags & ~VIRTUALCHARKEY, vk); - key->ShiftFlags &= ~VIRTUALCHARKEY; - } - - int len = wcslen(key->dpContext); - PWSTR context = new WCHAR[len + 4]; - memcpy(context, key->dpContext, len * sizeof(WCHAR)); - context[len] = UC_SENTINEL; - context[len+1] = CODE_DEADKEY; - context[len+2] = deadkey; - context[len+3] = 0; - key->dpContext = context; - key->Key = vk; - } -} - -void TranslateDeadkeyGroup(LPGROUP group, WCHAR deadkey, WORD vk, UINT shift, WORD ch) { - for(unsigned int i = 0; i < group->cxKeyArray; i++) { - TranslateDeadkeyKey(&group->dpKeyArray[i], deadkey, vk, shift, ch); - } -} - -void TranslateDeadkeyKeyboard(LPKEYBOARD kbd, WCHAR deadkey, WORD vk, UINT shift, WORD ch) { - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { - TranslateDeadkeyGroup(&kbd->dpGroupArray[i], deadkey, vk, shift, ch); - } - } -} - -void AddDeadkeyRule(LPKEYBOARD kbd, WCHAR deadkey, WORD vk, UINT shift) { - // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. - // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" - // to provide an alternate.. - if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4549 - shift &= ~LCTRLFLAG; - - // If the first group is not a matching-keys group, then we need to add into - // each subgroup, otherwise just the match group - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { - LPKEY keys = new KEY[kbd->dpGroupArray[i].cxKeyArray + 1]; - memcpy(keys+1, kbd->dpGroupArray[i].dpKeyArray, kbd->dpGroupArray[i].cxKeyArray * sizeof(KEY)); - keys[0].dpContext = new WCHAR[1]; - keys[0].dpContext[0] = 0; - keys[0].dpOutput = new WCHAR[4]; // UC_SENTINEL, CODE_DEADKEY, deadkey_value, 0 - keys[0].dpOutput[0] = UC_SENTINEL; - keys[0].dpOutput[1] = CODE_DEADKEY; - keys[0].dpOutput[2] = deadkey; // TODO: translate to unique index - keys[0].dpOutput[3] = 0; - keys[0].Key = vk; - keys[0].Line = 0; - keys[0].ShiftFlags = shift | ISVIRTUALKEY; - kbd->dpGroupArray[i].dpKeyArray = keys; - kbd->dpGroupArray[i].cxKeyArray++; - //LogError("Add deadkey rule: + [%d K_%d] > dk(%d)", shift, vk, deadkey); - if(i == kbd->StartGroup[1]) break; // If this is the initial group, that's all we need to do. - } - } -} - -WCHAR ScanXStringForMaxDeadkeyID(LPWSTR str) { - WCHAR dkid = 0; - while(str && *str) { - if(*str == UC_SENTINEL) { - switch(*(str+1)) { - case CODE_DEADKEY: - dkid = max(dkid, *(str+2)); - } - } - str = incxstr(str); - } - return dkid; -} - -struct dkidmap { - WCHAR src_deadkey, dst_deadkey; -}; - -WCHAR GetUniqueDeadkeyID(LPKEYBOARD kbd, WCHAR deadkey) { - LPGROUP gp; - LPKEY kp; - LPSTORE sp; - UINT i, j; - WCHAR dkid = 0; - static WCHAR s_next_dkid = 0; - static dkidmap *s_dkids = NULL; - static int s_ndkids = 0; - - if(!kbd) { - if(s_dkids) { - delete s_dkids; - } - s_dkids = NULL; - s_ndkids = 0; - s_next_dkid = 0; - return 0; - } - - for(int i = 0; i < s_ndkids; i++) { - if(s_dkids[i].src_deadkey == deadkey) { - return s_dkids[i].dst_deadkey; - } - } - - if(s_next_dkid != 0) { - s_dkids = (dkidmap*) realloc(s_dkids, sizeof(dkidmap) * (s_ndkids+1)); - s_dkids[s_ndkids].src_deadkey = deadkey; - return s_dkids[s_ndkids++].dst_deadkey = ++s_next_dkid; - } - - for(i = 0, gp = kbd->dpGroupArray; i < kbd->cxGroupArray; i++, gp++) { - for(j = 0, kp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kp++) { - dkid = max(dkid, ScanXStringForMaxDeadkeyID(kp->dpContext)); - dkid = max(dkid, ScanXStringForMaxDeadkeyID(kp->dpOutput)); - } - dkid = max(dkid, ScanXStringForMaxDeadkeyID(gp->dpMatch)); - dkid = max(dkid, ScanXStringForMaxDeadkeyID(gp->dpNoMatch)); - } - - for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { - dkid = max(dkid, ScanXStringForMaxDeadkeyID(sp->dpString)); - } - - s_dkids = (dkidmap*) realloc(s_dkids, sizeof(dkidmap) * (s_ndkids+1)); - s_dkids[s_ndkids].src_deadkey = deadkey; - return s_dkids[s_ndkids++].dst_deadkey = s_next_dkid = ++dkid; -} - - -void ConvertDeadkey(LPKEYBOARD kbd, WORD vk, UINT shift, WCHAR deadkey) { - WORD deadkeys[512], *pdk; - - // Lookup the deadkey table for the deadkey in the physical keyboard - // Then for each character, go through and map it through - - WCHAR dkid = GetUniqueDeadkeyID(kbd, deadkey); - - // Add the deadkey to the mapping table for use in the import rules phase - DeadkeyMapping deadkeyMapping = { deadkey, dkid, shift, vk }; // I4353 - FDeadkeys.push_back(deadkeyMapping); //dkid, vk, shift); // I4353 - - AddDeadkeyRule(kbd, dkid, vk, shift); - - GetDeadkeys(deadkey, pdk = deadkeys); // returns array of [usvk, ch_out] pairs - while(*pdk) { - // Look up the ch - UINT vkUnderlying = VKUnderlyingLayoutToVKUS(*pdk); - TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); - pdk+=3; - } -} - -BOOL SetKeyboardToPositional(LPKEYBOARD kbd) { - LPSTORE sp; - UINT i; - for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { - if(sp->dwSystemID == TSS_MNEMONIC) { - if(!sp->dpString) { - LogError(L"Invalid &mnemoniclayout system store"); - return FALSE; - } - if(wcscmp(sp->dpString, L"1") != 0) { - LogError(L"Keyboard is not a mnemonic layout keyboard"); - return FALSE; - } - *sp->dpString = '0'; - return TRUE; - } - } - - LogError(L"Keyboard is not a mnemonic layout keyboard"); - return FALSE; -} - -BOOL DoConvert(LPKEYBOARD kbd, LPWSTR kbid, BOOL bDeadkeyConversion) { // I4552 - WCHAR DeadKey; - - if(!SetKeyboardToPositional(kbd)) return FALSE; - - // Go through each of the shift states - base, shift, ctrl+alt, ctrl+alt+shift, [caps vs ncaps?] - // Currently, we go in this order so the 102nd key works. But this is not ideal for keyboards without 102nd key: // I4651 - // it catches only the first key that matches a given rule, but multiple keys may match that rule. This is particularly - // evident for the 102nd key on UK, for example, where \ can be generated with VK_OEM_102 or AltGr+VK_QUOTE. - // For now, we get the least shifted version, which is hopefully adequate. - - for(int j = 0; VKShiftState[j] != 0xFFFF; j++) { // I4651 - // Go through each possible key on the keyboard - for(int i = 0; VKMap[i]; i++) { // I4651 - UINT vkUnderlying = VKUSToVKUnderlyingLayout(VKMap[i]); - - WCHAR ch = CharFromVK(vkUnderlying, VKShiftState[j], &DeadKey); - - //LogError("--- VK_%d -> VK_%d [%c] dk=%d", VKMap[i], vkUnderlying, ch == 0 ? 32 : ch, DeadKey); - - if(bDeadkeyConversion) { // I4552 - if(ch == 0xFFFF) { - ch = DeadKey; - } - } - - switch(ch) { - case 0x0000: break; - case 0xFFFF: ConvertDeadkey(kbd, VKMap[i], VKShiftState[j], DeadKey); break; - default: TranslateKeyboard(kbd, VKMap[i], VKShiftState[j], ch); - } - - // - } - } - - ReportUnconvertedKeyboardRules(kbd); - - if(!ImportRules(kbid, kbd, &FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 - return FALSE; - } - - return TRUE; -} - -void LogError(PWSTR fmt, ...) { - WCHAR fmtbuf[256]; - - va_list vars; - va_start(vars, fmt); - _vsnwprintf_s(fmtbuf, _countof(fmtbuf), _TRUNCATE, fmt, vars); // I2248 // I3547 - fmtbuf[255] = 0; - _putws(fmtbuf); -} -*/ diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 2818ad2317..b30fbfba8d 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -40,13 +40,4 @@ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap); - -//--------------------old -/* - -void LogError(PWSTR message, ...); - - -*/ - #endif /*MCOMPILE_H*/ diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index 831a121a07..d8f71ffaea 100755 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -16,7 +16,6 @@ cpp_files = files( 'mcompile.cpp', 'filesystem.cpp', 'mc_kmxfile.cpp', - 'mc_savekeyboard.cpp', 'mc_import_rules.cpp', 'u16.cpp',) From e2af2d0d34bf9970d8c1df3c8781e0c24aaaefab Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 19 Feb 2024 20:47:50 +0100 Subject: [PATCH 209/327] feat(linux): mcompile-dk looking at this->SC() vs. KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK --- linux/mcompile/keymap/README.md | 1 + linux/mcompile/keymap/deadkey.cpp | 2 +- linux/mcompile/keymap/deadkey.h | 2 +- linux/mcompile/keymap/keymap.cpp | 15 ++++++++---- linux/mcompile/keymap/keymap.h | 10 ++++++-- linux/mcompile/keymap/mc_import_rules.cpp | 15 +++++++----- linux/mcompile/keymap/mcompile.cpp | 28 ++++++++++------------- 7 files changed, 42 insertions(+), 31 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index 9f2a624f67..92bd6f646e 100755 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -14,6 +14,7 @@ _S2 TODO TODO keymap* or keymap** everywhere? _S2 TODO check call by reference/value _S2 TODO replace GDK _S2 TODO what is wrong with kp->dpBitmapOffset/BitmapSize ? +_S2 TODO all wprintf gone ? _S2 ... diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 60f181e15d..f9a174cfec 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -112,7 +112,7 @@ KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap return Cap; } -// _S2 DESIGN NEEDED is this the right place to get dk from? if not wher are they stored? +// _S2 DESIGN NEEDED is this the right place to get dk from? if not where are they stored? void create_DKTable(v_dw_2D & dk_ComposeTable) { //values taken from: https://help.ubuntu.com/community/GtkDeadKeyTable#Latin diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index b4c6de7aeb..9f6713a805 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -23,7 +23,7 @@ bool found_dk_inVector(KMX_WCHAR dk, std::vector &myVec); // finds all combination for a specific deadkey(dk) ^-> â,ê,î,ô,û,... bool find_dk_combinations_for_specific_dk(v_dw_2D * dk_ComposeTable, v_dw_2D & dk_SingleTable, KMX_DWORD dk); -// gets the shifted character of a key +// gets the shifted character of a key and writes shiftstate of KValto shift KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap); // _S2 TODO probably not used diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 4111e317cb..10947ac77f 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -546,7 +546,6 @@ KMX_DWORD KMX_get_KeyvalUnderlying_DK_From_KeyCodeUnderlying_GDK(GdkKeymap *keym g_free(keyvals); g_free(maps); - // _S2 AHA output for dk4-12 at the top after dk... from here if((All_Keyvals >= deadkey_min) && (All_Keyvals <= deadkey_max)) // deadkeys return 0xFFFF; else if((All_Keyvals > deadkey_max) || ((All_Keyvals < deadkey_min) && ( All_Keyvals > 0xFF))) // out of range @@ -568,6 +567,12 @@ KMX_DWORD KMX_get_CharUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, U return 0xFFFE; else // usable char return keyvals_dw; + +/*if( keyvals_dw == 0xFFFF) + *DeadKey = *dky; + + return keyvals_dw;*/ + } KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { @@ -583,7 +588,7 @@ KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD return 0; } - +//_S2 TODO condense these 2 fun to one KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector, KMX_DWORD KC_US, ShiftState ss, int caps) { KMX_DWORD Character; @@ -592,7 +597,7 @@ KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3 //Find underlying KC of character for( int i=0; i< (int)All_Vector[1].size()-1 ;i++) { - for( int j=1; j< (int)All_Vector[01][0].size();j++) { + for( int j=1; j< (int)All_Vector[1][0].size();j++) { if ( ( All_Vector[1][i][j] == Character ) ) { KC_US = All_Vector[1][i][j]; return All_Vector[1][i][0]; @@ -602,12 +607,12 @@ KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3 return KC_US; } -KMX_WCHAR KMX_get_CharUS_From_VKUnderlying_VEC(v_dw_3D & All_Vector, KMX_DWORD VK_underlying) { +KMX_WCHAR KMX_get_KValUnderlying_From_KValUS_VEC(v_dw_3D & All_Vector, KMX_DWORD VK_underlying) { KMX_DWORD VK_US; for( int i=0; i< (int)All_Vector[0].size()-1 ;i++) { for( int j=1; j< (int)All_Vector[0][0].size();j++) { if ( ( All_Vector[0][i][j] == VK_underlying ) ) { - VK_US = All_Vector[1][i][j];; + VK_US = All_Vector[1][i][j]; return VK_US; } } diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 5567a05fdc..c1c99e7f3d 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -68,6 +68,7 @@ static KMX_DWORD returnIfCharInvalid = 0; static KMX_DWORD keycode_max = 94; static KMX_DWORD deadkey_min = 0xfe50; static KMX_DWORD deadkey_max = 0xfe93; +//static KMX_DWORD deadkey_max = 0xfe52; // _S2 TODO This has to go! my test: to only return 3 dk int map_VKShiftState_to_LinModifier(int VKShiftState); @@ -509,19 +510,24 @@ std::u16string convert_DeadkeyValues_To_U16str(int in); // use gdk_keymap_translate_keyboard_state to get keyval - base function to get keyvals int KMX_get_keyval_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); +// uses KMX_get_keyval_From_Keycode and forbids use of certain keycodes KMX_DWORD KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos); + +// _S2 uses KMX_get_keyval_From_Keycode and returns CATEGORY off keyval and forbids use of certain keycodes KMX_DWORD KMX_get_KeyvalUnderlying_DK_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky); +// _S2 fills Deadkey with dk and returns CATEGORY KMX_DWORD KMX_get_CharUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, UINT VKShiftState, UINT KC_underlying, PKMX_WCHAR DeadKey); // return the VirtualKey of the underlying Keyboard for a given Keyode using GDK KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD keycode); -// return the Keycode of the underlying Keyboard for given VK_US using GDK +// uses Vector to return the Keycode of the underlying Keyboard for given VK_US using GDK KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector,KMX_DWORD KC_US, ShiftState ss, int caps); -KMX_WCHAR KMX_get_CharUS_From_VKUnderlying_VEC(v_dw_3D &All_Vector,KMX_DWORD VK_underlying); + // _S2 HÄÄ + KMX_WCHAR KMX_get_KValUnderlying_From_KValUS_VEC(v_dw_3D &All_Vector,KMX_DWORD VK_underlying); // return the Keycode of the underlying Keyboard for given VK_US UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 0576c06e20..409c17336b 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -77,7 +77,6 @@ int KMX_ToUnicodeEx(guint keycode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, return 0; std::wstring str = convert_DeadkeyValues_ToWstr(KMX_get_keyval_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), caps)); - pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(str).c_str(); KMX_DWORD keyvals_dw= (KMX_DWORD) KMX_get_keyval_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), caps); @@ -290,10 +289,13 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0;*/ (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); - // _S2 DIFFERENCE TO MCOMPILE WINDOWS + // DIFFERENCE TO MCOMPILE WINDOWS // _S2 DESIGN NEEDED on how to replace capslock // capslock has different values for linux. Therefore key->ShiftFlags will be different for numbers, special characters + // Therefore CAPS/NCAPS will be added differently for Lin<->Win // for now set capslock=1 + // capslock=1 <-> capslock=0; + // [ CTRL NCAPS K_I] <-> [CTRL K_I] capslock=1; for (int ss = 0; ss <= MaxShiftState; ss++) { @@ -344,7 +346,9 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0;*/ // key->Key stores VK-US ( not underlying !!) // key->dpOutput stores character Underlying - KMX_DWORD SC_Underlying = KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(keymap, All_Vector, this->SC(), (ShiftState) ss, caps); + // _S2 ToDo which one ??? is different if a char is on different keys- then it may find the wrong key. + //KMX_DWORD SC_Underlying = KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(keymap, All_Vector, this->SC(), (ShiftState) ss, caps); + KMX_DWORD SC_Underlying = this->SC(); key->Key = KMX_get_VKUS_From_KeyCodeUnderlying_GDK( keymap, SC_Underlying); key->Line = 0; @@ -518,7 +522,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // _S2 TODO not finished; Ctrl, Shft +40 not tested for(int caps = 0; caps <= 1; caps++) { - // _S2 TODO Do we need this? //loader.KMX_ClearKeyboardBuffer(); loader.KMX_FillKeyState(lpKeyState, ss, (caps == 0)); @@ -545,6 +548,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // VK_A ~ VK_Z keys to produce the control characters, // when the conversion rule is not provided in keyboard // layout files + continue; } if( (ss == Ctrl || ss == ShftCtrl) ) { @@ -657,7 +661,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, UINT j; LPKMX_KEY kkp; for(j = 0, kkp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kkp++) { - // _S2 AHA! missing 26 lines from here: since capalock is not correct this loop will never be done if((kkp->ShiftFlags & (K_CTRLFLAG|K_ALTFLAG|LCTRLFLAG|LALTFLAG|RCTRLFLAG|RALTFLAG)) != 0) { gp2->cxKeyArray++; LPKMX_KEY kkp2 = new KMX_KEY[gp2->cxKeyArray]; @@ -682,7 +685,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // If we have deadkeys, then add a new group to translate the deadkeys per the deadkey tables // We only do this if not in deadkey conversion mode // - // DK_PART + if (alDead.size() > 0 && !bDeadkeyConversion) { // I4552 kp->cxGroupArray++; diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 64c0876301..0839ddf1bc 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -222,6 +222,7 @@ void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift &= ~LCTRLFLAG; if(key->ShiftFlags == 0) { + // _S2 TODO enable logError //LogError("Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d]", key->Line, key->Key, deadkey, shift, vk); //wprintf(L"DK Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d], %i(%c)\n", key->Line, key->Key, deadkey, shift, vk, ch, ch); key->ShiftFlags = ISVIRTUALKEY | shift; @@ -360,7 +361,7 @@ KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { return s_dkids[s_ndkids++].dst_deadkey = s_next_dkid = ++dkid; } -void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR deadkey, v_dw_3D &All_Vector, GdkKeymap* keymap,v_dw_2D dk_Table) { +void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, UINT shift, KMX_WCHAR deadkey, v_dw_3D &All_Vector, GdkKeymap* keymap,v_dw_2D dk_Table) { KMX_WORD deadkeys[512], *pdk; // Lookup the deadkey table for the deadkey in the physical keyboard @@ -368,16 +369,15 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR d KMX_WCHAR dkid = KMX_GetUniqueDeadkeyID(kbd, deadkey); // Add the deadkey to the mapping table for use in the import rules phase - KMX_DeadkeyMapping KMX_deadkeyMapping = { deadkey, dkid, shift, vk}; // I4353 + KMX_DeadkeyMapping KMX_deadkeyMapping = { deadkey, dkid, shift, vk_US}; // I4353 KMX_FDeadkeys.push_back(KMX_deadkeyMapping); //dkid, vk, shift); // I4353 - KMX_AddDeadkeyRule(kbd, dkid, vk, shift); + KMX_AddDeadkeyRule(kbd, dkid, vk_US, shift); KMX_GetDeadkeys(dk_Table, deadkey, pdk = deadkeys, keymap); // returns array of [usvk, ch_out] pairs while(*pdk) { // Look up the ch - UINT vkUnderlying = KMX_get_CharUS_From_VKUnderlying_VEC(All_Vector, *pdk); - + UINT vkUnderlying = KMX_get_KValUnderlying_From_KValUS_VEC(All_Vector, *pdk); KMX_TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); pdk+=3; } @@ -439,11 +439,8 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg // Loop through each possible key on the keyboard for (int i = 0;KMX_VKMap[i]; i++) { // I4651 - - // _S2 DIFFERENT TO MCOMPILE WINDOWS // win goes via VK, Lin goes via SC/Keycode - UINT scUnderlying = KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]); KMX_WCHAR ch = KMX_get_CharUnderlying_From_KeyCodeUnderlying_GDK(keymap, VKShiftState[j], scUnderlying, &DeadKey); @@ -484,14 +481,13 @@ int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, for ( int i=0; i< (int) dk_SingleTable.size();i++) { KMX_WORD vk = KMX_changeKeynameToCapital(dk_SingleTable[i][1], shift, keymap); if(vk != 0) { - *p++ = vk; - *p++ = shift; - *p++ = dk_SingleTable[i][2]; - } - // _S2 TODO - //else { - // LogError(L"Warning: complex deadkey not supported."); - // } + *p++ = vk; + *p++ = shift; + *p++ = dk_SingleTable[i][2]; + } + else { + KMX_LogError(L"Warning: complex deadkey not supported."); + } } *p = 0; return (p-OutputPairs); From fb1ad0cad77e71c55fd191c6a821812855819813 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 20 Feb 2024 09:33:54 +0100 Subject: [PATCH 210/327] feat(linux): mcompile-dk LogErrror,naming,tidy up --- linux/mcompile/keymap/README.md | 4 +++- linux/mcompile/keymap/deadkey.h | 4 ++-- linux/mcompile/keymap/keymap.cpp | 16 +++++++++------- linux/mcompile/keymap/keymap.h | 13 ++++++------- linux/mcompile/keymap/mc_import_rules.cpp | 19 ++----------------- linux/mcompile/keymap/mcompile.cpp | 13 +++---------- 6 files changed, 25 insertions(+), 44 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index 92bd6f646e..a8d525c855 100755 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -14,7 +14,9 @@ _S2 TODO TODO keymap* or keymap** everywhere? _S2 TODO check call by reference/value _S2 TODO replace GDK _S2 TODO what is wrong with kp->dpBitmapOffset/BitmapSize ? -_S2 TODO all wprintf gone ? + +_s2 INFO idee spanish keyboard has dk on altgr !! + _S2 ... diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index 9f6713a805..d48890d5b2 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -20,10 +20,10 @@ std::vector create_alDead(); void refine_alDead(KMX_WCHAR dk, std::vector &myVec, std::vector *p_All_Vec); bool found_dk_inVector(KMX_WCHAR dk, std::vector &myVec); -// finds all combination for a specific deadkey(dk) ^-> â,ê,î,ô,û,... +// find all combination for a specific deadkey(dk) ^-> â,ê,î,ô,û,... bool find_dk_combinations_for_specific_dk(v_dw_2D * dk_ComposeTable, v_dw_2D & dk_SingleTable, KMX_DWORD dk); -// gets the shifted character of a key and writes shiftstate of KValto shift +// get the shifted character of a key and write shiftstate of KVal to shift KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap); // _S2 TODO probably not used diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 10947ac77f..18deb04ed2 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -588,7 +588,7 @@ KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD return 0; } -//_S2 TODO condense these 2 fun to one + KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector, KMX_DWORD KC_US, ShiftState ss, int caps) { KMX_DWORD Character; @@ -607,19 +607,21 @@ KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3 return KC_US; } -KMX_WCHAR KMX_get_KValUnderlying_From_KValUS_VEC(v_dw_3D & All_Vector, KMX_DWORD VK_underlying) { - KMX_DWORD VK_US; + +KMX_WCHAR KMX_get_KValUnderlying_From_KValUS_VEC(v_dw_3D & All_Vector, KMX_DWORD VK_US) { + KMX_DWORD VK_underlying; for( int i=0; i< (int)All_Vector[0].size()-1 ;i++) { for( int j=1; j< (int)All_Vector[0][0].size();j++) { - if ( ( All_Vector[0][i][j] == VK_underlying ) ) { - VK_US = All_Vector[1][i][j]; - return VK_US; + if ( ( All_Vector[0][i][j] == VK_US ) ) { + VK_underlying = All_Vector[1][i][j]; + return VK_underlying; } } } - return VK_underlying; + return VK_US; } + UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS) { return (8 + USVirtualKeyToScanCode[VirtualKeyUS]); } diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index c1c99e7f3d..880bc8f8e1 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -510,24 +510,23 @@ std::u16string convert_DeadkeyValues_To_U16str(int in); // use gdk_keymap_translate_keyboard_state to get keyval - base function to get keyvals int KMX_get_keyval_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); -// uses KMX_get_keyval_From_Keycode and forbids use of certain keycodes +// use KMX_get_keyval_From_Keycode and forbids use of certain keycodes KMX_DWORD KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos); - -// _S2 uses KMX_get_keyval_From_Keycode and returns CATEGORY off keyval and forbids use of certain keycodes +// use KMX_get_keyval_From_Keycode and return CATEGORY off keyval and prevent use of certain keycodes KMX_DWORD KMX_get_KeyvalUnderlying_DK_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky); -// _S2 fills Deadkey with dk and returns CATEGORY +// fill Deadkey with dk and return CATEGORY KMX_DWORD KMX_get_CharUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, UINT VKShiftState, UINT KC_underlying, PKMX_WCHAR DeadKey); // return the VirtualKey of the underlying Keyboard for a given Keyode using GDK KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD keycode); -// uses Vector to return the Keycode of the underlying Keyboard for given VK_US using GDK +// use Vector to return the Keycode of the underlying Keyboard for given VK_US using GDK KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector,KMX_DWORD KC_US, ShiftState ss, int caps); - // _S2 HÄÄ - KMX_WCHAR KMX_get_KValUnderlying_From_KValUS_VEC(v_dw_3D &All_Vector,KMX_DWORD VK_underlying); +// use Vector to return the Keyval of underlying Keyboard +KMX_WCHAR KMX_get_KValUnderlying_From_KValUS_VEC(v_dw_3D &All_Vector,KMX_DWORD VK_underlying); // return the Keycode of the underlying Keyboard for given VK_US UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 409c17336b..24e1fbfacc 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -346,9 +346,7 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0;*/ // key->Key stores VK-US ( not underlying !!) // key->dpOutput stores character Underlying - // _S2 ToDo which one ??? is different if a char is on different keys- then it may find the wrong key. - //KMX_DWORD SC_Underlying = KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(keymap, All_Vector, this->SC(), (ShiftState) ss, caps); - KMX_DWORD SC_Underlying = this->SC(); + KMX_DWORD SC_Underlying = KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(keymap, All_Vector, this->SC(), (ShiftState) ss, caps); key->Key = KMX_get_VKUS_From_KeyCodeUnderlying_GDK( keymap, SC_Underlying); key->Line = 0; @@ -412,13 +410,6 @@ public: return (ch < 0x0020) || (ch >= 0x007F && ch <= 0x009F); } - // _S2 TODO Do we need this? - void KMX_ClearKeyboardBuffer() { - KMX_WCHAR sb[16]; - for( int i=0; i<16; i++) { - sb[i] = L'\0'; - } - } }; int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { @@ -522,14 +513,12 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // _S2 TODO not finished; Ctrl, Shft +40 not tested for(int caps = 0; caps <= 1; caps++) { - // _S2 TODO Do we need this? - //loader.KMX_ClearKeyboardBuffer(); loader.KMX_FillKeyState(lpKeyState, ss, (caps == 0)); int rc = KMX_ToUnicodeEx(KC_US, lpKeyState, sbBuffer, ss, caps, *keymap); if(rc > 0) { if(*sbBuffer == 0) { - //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); // _S2 + //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); // _S2 INFO rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps)); } else { @@ -564,10 +553,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, //rgKey[iKey]->SetShiftState(ss, sbBuffer, true, (caps == 0)); rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); //_S2 INFO - // It's a dead key; let's flush out whats stored in the keyboard state. - // _S2 TODO Do we need this? - //loader.KMX_ClearKeyboardBuffer(); - // _S2 DIFFERENCE TO MCOMPILE WINDOWS refine_alDead(sbBuffer[0], alDead, &alDead_cpl); } diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 0839ddf1bc..a0b5ed5b7e 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -222,13 +222,10 @@ void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift &= ~LCTRLFLAG; if(key->ShiftFlags == 0) { - // _S2 TODO enable logError - //LogError("Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d]", key->Line, key->Key, deadkey, shift, vk); - //wprintf(L"DK Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d], %i(%c)\n", key->Line, key->Key, deadkey, shift, vk, ch, ch); + //KMX_LogError(L"Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d]", key->Line, key->Key, deadkey, shift, vk); key->ShiftFlags = ISVIRTUALKEY | shift; } else { - //LogError("Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO dk(%d) + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, deadkey, key->ShiftFlags & ~VIRTUALCHARKEY, vk); - //wprintf(L"DK Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO dk(%d) + [%x K_%d], %i(%c)\n", key->Line, key->ShiftFlags, key->Key, deadkey, key->ShiftFlags & ~VIRTUALCHARKEY, vk, ch, ch); + //KMX_LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO dk(%d) + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, deadkey, key->ShiftFlags & ~VIRTUALCHARKEY, vk); key->ShiftFlags &= ~VIRTUALCHARKEY; } @@ -265,8 +262,6 @@ void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT // to provide an alternate.. if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4549 shift &= ~LCTRLFLAG; - // _s2 INFO idee spanish keyboard has dk on altgr !! - // If the first group is not a matching-keys group, then we need to add into // each subgroup, otherwise just the match group for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { @@ -285,9 +280,7 @@ void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT keys[0].ShiftFlags = shift | ISVIRTUALKEY; kbd->dpGroupArray[i].dpKeyArray = keys; kbd->dpGroupArray[i].cxKeyArray++; - //LogError("Add deadkey rule: + [%d K_%d] > dk(%d)", shift, vk, deadkey); - wprintf(L"Add deadkey rule: + [%d K_%d] > dk(%d) \n", shift, vk, deadkey); - + KMX_LogError(L"Add deadkey rule: + [%d K_%d] > dk(%d)", shift, vk, deadkey); if(i == kbd->StartGroup[1]) break; // If this is the initial group, that's all we need to do. } } From 76adcd07cae8ef0d81f2e4e074535b426ca9615a Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 20 Feb 2024 10:09:17 +0100 Subject: [PATCH 211/327] feat(linux): mcompile-dk naming of Var,Function (KeyVal,KeyCode,VK) --- linux/mcompile/keymap/keymap.cpp | 129 ++++++++++------------ linux/mcompile/keymap/keymap.h | 26 ++--- linux/mcompile/keymap/mc_import_rules.cpp | 16 +-- linux/mcompile/keymap/mcompile.cpp | 6 +- 4 files changed, 84 insertions(+), 93 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 18deb04ed2..d61148c840 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -327,8 +327,8 @@ int append_underlying_ToVector(v_dw_3D &All_Vector,GdkKeymap *keymap) { All_Vector[1][i][0] = All_Vector[0][i][0]; // get Keyvals of this key and copy to unshifted/shifted in "underlying"-block[1][i][1] / block[1][i][2] - All_Vector[1][i][0+1] = KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(keymap,All_Vector[0][i][0],0); //shift state: unshifted:0 - All_Vector[1][i][1+1] = KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(keymap,All_Vector[0][i][0],1); //shift state: shifted:1 + All_Vector[1][i][0+1] = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap,All_Vector[0][i][0],0); //shift state: unshifted:0 + All_Vector[1][i][1+1] = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap,All_Vector[0][i][0],1); //shift state: shifted:1 } return 0; @@ -407,7 +407,7 @@ std::u16string convert_DeadkeyValues_To_U16str(int in) { return u"\0"; } -int KMX_get_keyval_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps) { +int KMX_get_KeyVal_From_KeyCode(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps) { GdkModifierType consumed; GdkKeymapKey *maps; @@ -494,11 +494,11 @@ int KMX_get_keyval_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss, return (int) *keyvals; } -KMX_DWORD KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos) { +KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, guint keycode, int shift_state_pos) { GdkKeymapKey *maps; guint *keyvals; gint count; - KMX_DWORD out; + KMX_DWORD KVal; if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; @@ -509,15 +509,29 @@ KMX_DWORD KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, if (!(keycode <= keycode_max)) return 0; - out = (KMX_DWORD) KMX_get_keyval_From_Keycode(keymap, keycode, (ShiftState) shift_state_pos, 0); + KVal = (KMX_DWORD) KMX_get_KeyVal_From_KeyCode(keymap, keycode, (ShiftState) shift_state_pos, 0); g_free(keyvals); g_free(maps); - return out; + return KVal; } -KMX_DWORD KMX_get_KeyvalUnderlying_DK_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky) { +KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, UINT VKShiftState, UINT KC_underlying, PKMX_WCHAR DeadKey) { + PKMX_WCHAR dky; + KMX_DWORD KeyVal = KMX_get_KeyValUnderlying_DK_From_KeyCodeUnderlying(keymap, KC_underlying, map_VKShiftState_to_LinModifier(VKShiftState), dky); + + if(KeyVal >= deadkey_min) { // deadkey + *DeadKey = *dky; + return 0xFFFF; + } + else if((KeyVal > deadkey_max) || ((KeyVal < deadkey_min) && ( KeyVal > 0xFF))) // out of range + return 0xFFFE; + else // usable char + return KeyVal; +} + +KMX_DWORD KMX_get_KeyValUnderlying_DK_From_KeyCodeUnderlying(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky) { GdkKeymapKey *maps; guint *keyvals; gint count; @@ -536,79 +550,25 @@ KMX_DWORD KMX_get_KeyvalUnderlying_DK_From_KeyCodeUnderlying_GDK(GdkKeymap *keym if (!(keycode <= keycode_max)) return 0; - KMX_DWORD All_Keyvals = KMX_get_keyval_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), 0); + KMX_DWORD KeyV = KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(shift_state_pos), 0); - if(( (All_Keyvals >= deadkey_min) && (All_Keyvals <= deadkey_max))) - deadkey = All_Keyvals; + if(( (KeyV >= deadkey_min) && (KeyV <= deadkey_max))) + deadkey = KeyV; dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str(); g_free(keyvals); g_free(maps); - if((All_Keyvals >= deadkey_min) && (All_Keyvals <= deadkey_max)) // deadkeys + if((KeyV >= deadkey_min) && (KeyV <= deadkey_max)) // deadkeys return 0xFFFF; - else if((All_Keyvals > deadkey_max) || ((All_Keyvals < deadkey_min) && ( All_Keyvals > 0xFF))) // out of range + else if((KeyV > deadkey_max) || ((KeyV < deadkey_min) && ( KeyV > 0xFF))) // out of range return 0xFFFE; else // usable char - return All_Keyvals; + return KeyV; } -KMX_DWORD KMX_get_CharUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, UINT VKShiftState, UINT KC_underlying, PKMX_WCHAR DeadKey) { - - PKMX_WCHAR dky; - KMX_DWORD keyvals_dw = KMX_get_KeyvalUnderlying_DK_From_KeyCodeUnderlying_GDK(keymap, KC_underlying, map_VKShiftState_to_LinModifier(VKShiftState), dky); - - if(keyvals_dw >= deadkey_min) { // deadkey - *DeadKey = *dky; - return 0xFFFF; - } - else if((keyvals_dw > deadkey_max) || ((keyvals_dw < deadkey_min) && ( keyvals_dw > 0xFF))) // out of range - return 0xFFFE; - else // usable char - return keyvals_dw; - -/*if( keyvals_dw == 0xFFFF) - *DeadKey = *dky; - - return keyvals_dw;*/ - -} - -KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD keycode) { - GdkKeymapKey *maps; - guint *keyvals; - gint count; - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return 0; - - if ( keycode >7) - return (KMX_DWORD) ScanCodeToUSVirtualKey[keycode-8]; - - return 0; -} - -KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector, KMX_DWORD KC_US, ShiftState ss, int caps) { - - KMX_DWORD Character; - std::wstring ws = convert_DeadkeyValues_ToWstr(KMX_get_keyval_From_Keycode(keymap, KC_US, ss, caps)); - Character = *ws.c_str(); - - //Find underlying KC of character - for( int i=0; i< (int)All_Vector[1].size()-1 ;i++) { - for( int j=1; j< (int)All_Vector[1][0].size();j++) { - if ( ( All_Vector[1][i][j] == Character ) ) { - KC_US = All_Vector[1][i][j]; - return All_Vector[1][i][0]; - } - } - } - return KC_US; -} - - -KMX_WCHAR KMX_get_KValUnderlying_From_KValUS_VEC(v_dw_3D & All_Vector, KMX_DWORD VK_US) { +KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(v_dw_3D & All_Vector, KMX_DWORD VK_US) { KMX_DWORD VK_underlying; for( int i=0; i< (int)All_Vector[0].size()-1 ;i++) { for( int j=1; j< (int)All_Vector[0][0].size();j++) { @@ -621,11 +581,42 @@ KMX_WCHAR KMX_get_KValUnderlying_From_KValUS_VEC(v_dw_3D & All_Vector, KMX_DWORD return VK_US; } +KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap *keymap, v_dw_3D &All_Vector, KMX_DWORD KC_US, ShiftState ss, int caps) { + KMX_DWORD KC_underlying; + KMX_DWORD Character; + std::wstring ws = convert_DeadkeyValues_ToWstr(KMX_get_KeyVal_From_KeyCode(keymap, KC_US, ss, caps)); + Character = *ws.c_str(); + + //Find underlying KC of character + for( int i=0; i< (int)All_Vector[1].size()-1 ;i++) { + for( int j=1; j< (int)All_Vector[1][0].size();j++) { + if ( ( All_Vector[1][i][j] == Character ) ) { + KC_underlying = All_Vector[1][i][0]; + return KC_underlying; + } + } + } + return KC_US; +} UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS) { return (8 + USVirtualKeyToScanCode[VirtualKeyUS]); } +KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying( GdkKeymap *keymap, KMX_DWORD keycode) { + GdkKeymapKey *maps; + guint *keyvals; + gint count; + + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + return 0; + + if ( keycode >7) + return (KMX_DWORD) ScanCodeToUSVirtualKey[keycode-8]; + + return 0; +} + std::wstring CodePointToWString(unsigned int codepoint) { std::wstring str; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 880bc8f8e1..1cb1da304c 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -508,29 +508,29 @@ std::wstring convert_DeadkeyValues_ToWstr(int in); std::u16string convert_DeadkeyValues_To_U16str(int in); // use gdk_keymap_translate_keyboard_state to get keyval - base function to get keyvals -int KMX_get_keyval_From_Keycode(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); +int KMX_get_KeyVal_From_KeyCode(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); -// use KMX_get_keyval_From_Keycode and forbids use of certain keycodes -KMX_DWORD KMX_get_KeyvalUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos); - -// use KMX_get_keyval_From_Keycode and return CATEGORY off keyval and prevent use of certain keycodes -KMX_DWORD KMX_get_KeyvalUnderlying_DK_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky); +// use KMX_get_KeyVal_From_KeyCode and prevent use of certain keycodes +KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, guint keycode, int shift_state_pos); // fill Deadkey with dk and return CATEGORY -KMX_DWORD KMX_get_CharUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, UINT VKShiftState, UINT KC_underlying, PKMX_WCHAR DeadKey); +KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, UINT VKShiftState, UINT KC_underlying, PKMX_WCHAR DeadKey); -// return the VirtualKey of the underlying Keyboard for a given Keyode using GDK -KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying_GDK( GdkKeymap *keymap, KMX_DWORD keycode); - -// use Vector to return the Keycode of the underlying Keyboard for given VK_US using GDK -KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(GdkKeymap *keymap, v_dw_3D &All_Vector,KMX_DWORD KC_US, ShiftState ss, int caps); +// use KMX_get_KeyVal_From_KeyCode and return CATEGORY off keyval and prevent use of certain keycodes +KMX_DWORD KMX_get_KeyValUnderlying_DK_From_KeyCodeUnderlying(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky); // use Vector to return the Keyval of underlying Keyboard -KMX_WCHAR KMX_get_KValUnderlying_From_KValUS_VEC(v_dw_3D &All_Vector,KMX_DWORD VK_underlying); +KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(v_dw_3D &All_Vector,KMX_DWORD VK_underlying); + +// use Vector to return the Keycode of the underlying Keyboard for given VK_US using GDK +KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap *keymap, v_dw_3D &All_Vector,KMX_DWORD KC_US, ShiftState ss, int caps); // return the Keycode of the underlying Keyboard for given VK_US UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); +// return the VirtualKey of the US Keyboard for a given Keyode using GDK +KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying( GdkKeymap *keymap, KMX_DWORD keycode); + // convert codePoint to wstring std::wstring CodePointToWString(unsigned int codepoint); std::u16string CodePointToString_16(unsigned int codepoint); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 24e1fbfacc..323ad6ccb6 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -76,19 +76,19 @@ int KMX_ToUnicodeEx(guint keycode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, if (!(keycode <= keycode_max)) return 0; - std::wstring str = convert_DeadkeyValues_ToWstr(KMX_get_keyval_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), caps)); + std::wstring str = convert_DeadkeyValues_ToWstr(KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(shift_state_pos), caps)); pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(str).c_str(); - KMX_DWORD keyvals_dw= (KMX_DWORD) KMX_get_keyval_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), caps); + KMX_DWORD KeyVal= (KMX_DWORD) KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(shift_state_pos), caps); g_free(keyvals); g_free(maps); - if((keyvals_dw >= deadkey_min) && (keyvals_dw <= deadkey_max)) // deadkeys + if((KeyVal >= deadkey_min) && (KeyVal <= deadkey_max)) // deadkeys return -1; - else if(gdk_keyval_to_unicode(keyvals_dw) == 0) // NO UNICODE + else if(gdk_keyval_to_unicode(KeyVal) == 0) // NO UNICODE return 0; - else // usable char + else /// usable char return 1; } @@ -125,7 +125,7 @@ public: } KMX_VirtualKey(UINT scanCode, KMX_HKL hkl, GdkKeymap **keymap) { - this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying_GDK(*keymap, scanCode); + this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying(*keymap, scanCode); this->m_hkl = hkl; this->m_sc = scanCode; memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); @@ -346,8 +346,8 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0;*/ // key->Key stores VK-US ( not underlying !!) // key->dpOutput stores character Underlying - KMX_DWORD SC_Underlying = KMX_get_KeyCodeUnderlying_From_KeycodeUS_GDK(keymap, All_Vector, this->SC(), (ShiftState) ss, caps); - key->Key = KMX_get_VKUS_From_KeyCodeUnderlying_GDK( keymap, SC_Underlying); + KMX_DWORD SC_Underlying = KMX_get_KeyCodeUnderlying_From_KeyCodeUS(keymap, All_Vector, this->SC(), (ShiftState) ss, caps); + key->Key = KMX_get_VKUS_From_KeyCodeUnderlying( keymap, SC_Underlying); key->Line = 0; key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index a0b5ed5b7e..478e1f6c4d 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -370,8 +370,8 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, UINT shift, KMX_WCHA KMX_GetDeadkeys(dk_Table, deadkey, pdk = deadkeys, keymap); // returns array of [usvk, ch_out] pairs while(*pdk) { // Look up the ch - UINT vkUnderlying = KMX_get_KValUnderlying_From_KValUS_VEC(All_Vector, *pdk); - KMX_TranslateDeadkeyKeyboard(kbd, dkid, vkUnderlying, *(pdk+1), *(pdk+2)); + UINT KeyValUnderlying = KMX_get_KeyValUnderlying_From_KeyValUS(All_Vector, *pdk); + KMX_TranslateDeadkeyKeyboard(kbd, dkid, KeyValUnderlying, *(pdk+1), *(pdk+2)); pdk+=3; } } @@ -435,7 +435,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg // _S2 DIFFERENT TO MCOMPILE WINDOWS // win goes via VK, Lin goes via SC/Keycode UINT scUnderlying = KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]); - KMX_WCHAR ch = KMX_get_CharUnderlying_From_KeyCodeUnderlying_GDK(keymap, VKShiftState[j], scUnderlying, &DeadKey); + KMX_WCHAR ch = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap, VKShiftState[j], scUnderlying, &DeadKey); //wprintf(L"--- VK_%d -> SC_ [%c] dk=%d ( ss %i) \n", VKMap[i], ch == 0 ? 32 : ch, DeadKey, VKShiftState[j]); From 002d9e19ce48a69ecc4734050e6b4892ca589d4a Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 20 Feb 2024 13:57:40 +0100 Subject: [PATCH 212/327] feat(linux): mcompile-dk remove keymap in some functions --- linux/mcompile/keymap/README.md | 3 +- linux/mcompile/keymap/deadkey.cpp | 1 + linux/mcompile/keymap/keymap.cpp | 29 +++++--------- linux/mcompile/keymap/keymap.h | 2 +- linux/mcompile/keymap/mc_import_rules.cpp | 49 +++++++---------------- linux/mcompile/keymap/mcompile.cpp | 3 +- 6 files changed, 31 insertions(+), 56 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index a8d525c855..2278b47a40 100755 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -14,7 +14,8 @@ _S2 TODO TODO keymap* or keymap** everywhere? _S2 TODO check call by reference/value _S2 TODO replace GDK _S2 TODO what is wrong with kp->dpBitmapOffset/BitmapSize ? - +_S2 TODO do I use all var in a function or are there unsused var? +_S2 TODO explain fields of aldead and All_Vector somewher _s2 INFO idee spanish keyboard has dk on altgr !! _S2 ... diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index f9a174cfec..53b82b5ebd 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -32,6 +32,7 @@ bool find_dk_combinations_for_specific_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D std::vector create_alDead() { std::vector alDead; v_dw_2D dk_ComposeTable; + create_DKTable(dk_ComposeTable); for( int i=0; i < (int) dk_ComposeTable.size()-1; i++) { diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index d61148c840..31641da53d 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -68,8 +68,6 @@ KMX_DWORD convertNamesTo_DWORD_Value(std::wstring tok_wstr) { first[L"acute accent"] = 0xB4; - //first[L" ?? "] = VK_OEM_102; /* DE = 226 ' " ? VK_OEM_102 */ - if ( tok_wstr.size() == 1) { return (KMX_DWORD) ( *tok_wstr.c_str() ); } @@ -516,8 +514,9 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, gui return KVal; } - +// _S2 ToDo combine those?? KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, UINT VKShiftState, UINT KC_underlying, PKMX_WCHAR DeadKey) { + PKMX_WCHAR dky; KMX_DWORD KeyVal = KMX_get_KeyValUnderlying_DK_From_KeyCodeUnderlying(keymap, KC_underlying, map_VKShiftState_to_LinModifier(VKShiftState), dky); @@ -525,9 +524,9 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, UIN *DeadKey = *dky; return 0xFFFF; } - else if((KeyVal > deadkey_max) || ((KeyVal < deadkey_min) && ( KeyVal > 0xFF))) // out of range + else if((KeyVal > deadkey_max) || ((KeyVal < deadkey_min) && ( KeyVal > 0xFF))) // out of range return 0xFFFE; - else // usable char + else // usable char return KeyVal; } @@ -562,9 +561,9 @@ KMX_DWORD KMX_get_KeyValUnderlying_DK_From_KeyCodeUnderlying(GdkKeymap *keymap, if((KeyV >= deadkey_min) && (KeyV <= deadkey_max)) // deadkeys return 0xFFFF; - else if((KeyV > deadkey_max) || ((KeyV < deadkey_min) && ( KeyV > 0xFF))) // out of range + else if((KeyV > deadkey_max) || ((KeyV < deadkey_min) && ( KeyV > 0xFF))) // out of range return 0xFFFE; - else // usable char + else // usable char return KeyV; } @@ -583,14 +582,12 @@ KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(v_dw_3D & All_Vector, KMX_DWORD KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap *keymap, v_dw_3D &All_Vector, KMX_DWORD KC_US, ShiftState ss, int caps) { KMX_DWORD KC_underlying; - KMX_DWORD Character; std::wstring ws = convert_DeadkeyValues_ToWstr(KMX_get_KeyVal_From_KeyCode(keymap, KC_US, ss, caps)); - Character = *ws.c_str(); - //Find underlying KC of character + //Find KC_underlying character for( int i=0; i< (int)All_Vector[1].size()-1 ;i++) { for( int j=1; j< (int)All_Vector[1][0].size();j++) { - if ( ( All_Vector[1][i][j] == Character ) ) { + if ( ( All_Vector[1][i][j] == *ws.c_str() ) ) { KC_underlying = All_Vector[1][i][0]; return KC_underlying; } @@ -603,20 +600,14 @@ UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS) { return (8 + USVirtualKeyToScanCode[VirtualKeyUS]); } -KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying( GdkKeymap *keymap, KMX_DWORD keycode) { - GdkKeymapKey *maps; - guint *keyvals; - gint count; - - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - return 0; - +KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying(KMX_DWORD keycode) { if ( keycode >7) return (KMX_DWORD) ScanCodeToUSVirtualKey[keycode-8]; return 0; } +// _S2 ToDo only use one std::wstring CodePointToWString(unsigned int codepoint) { std::wstring str; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 1cb1da304c..c0e6a71d0e 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -529,7 +529,7 @@ KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap *keymap, v_dw_3D &A UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); // return the VirtualKey of the US Keyboard for a given Keyode using GDK -KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying( GdkKeymap *keymap, KMX_DWORD keycode); +KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying(KMX_DWORD keycode); // convert codePoint to wstring std::wstring CodePointToWString(unsigned int codepoint); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 323ad6ccb6..78c897ef90 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -62,7 +62,7 @@ bool DeadKey::KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter) { return false; } -int KMX_ToUnicodeEx(guint keycode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, int shift_state_pos, int caps,GdkKeymap *keymap) { +int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int caps,GdkKeymap *keymap) { GdkKeymapKey *maps; guint *keyvals; gint count; @@ -76,10 +76,10 @@ int KMX_ToUnicodeEx(guint keycode, const BYTE *lpKeyState, PKMX_WCHAR pwszBuff, if (!(keycode <= keycode_max)) return 0; - std::wstring str = convert_DeadkeyValues_ToWstr(KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(shift_state_pos), caps)); + KMX_DWORD KeyVal= (KMX_DWORD) KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(shift_state_pos), caps); + std::wstring str = convert_DeadkeyValues_ToWstr(KeyVal); pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(str).c_str(); - KMX_DWORD KeyVal= (KMX_DWORD) KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(shift_state_pos), caps); g_free(keyvals); g_free(maps); @@ -117,15 +117,15 @@ private: public: - KMX_VirtualKey(KMX_HKL hkl,UINT virtualKey, GdkKeymap **keymap) { + KMX_VirtualKey(KMX_HKL hkl,UINT virtualKey) { this->m_sc = KMX_get_KeyCodeUnderlying_From_VKUS(virtualKey); this->m_hkl = hkl; this->m_vk = virtualKey; memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); } - KMX_VirtualKey(UINT scanCode, KMX_HKL hkl, GdkKeymap **keymap) { - this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying(*keymap, scanCode); + KMX_VirtualKey(UINT scanCode, KMX_HKL hkl) { + this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying(scanCode); this->m_hkl = hkl; this->m_sc = scanCode; memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); @@ -347,7 +347,7 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0;*/ // key->dpOutput stores character Underlying KMX_DWORD SC_Underlying = KMX_get_KeyCodeUnderlying_From_KeyCodeUS(keymap, All_Vector, this->SC(), (ShiftState) ss, caps); - key->Key = KMX_get_VKUS_From_KeyCodeUnderlying( keymap, SC_Underlying); + key->Key = KMX_get_VKUS_From_KeyCodeUnderlying( SC_Underlying); key->Line = 0; key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); @@ -392,6 +392,7 @@ public: return (Get_XxxxVk() == 0 ? ShftMenuCtrl : ShftXxxx); } +// _S2 ToDo needed??? - no? void KMX_FillKeyState(KMX_BYTE *lpKeyState, ShiftState ss, bool fCapsLock) { lpKeyState[VK_SHIFT] = (((ss & Shft) != 0) ? 0x80 : 0x00); lpKeyState[VK_CONTROL] = (((ss & Ctrl) != 0) ? 0x80 : 0x00); @@ -447,7 +448,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // Linux cant get a VK for the US Keyboard using USVirtualKeyToScanCode/ScanCodeToUSVirtualKey // Linux cannot get a VK for the underling Keyboard // this "connection" is possible only while using All_Vector - KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl, keymap); + KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl); if((key->VK() != 0) ) { rgKey[key->VK()] = key; @@ -457,12 +458,12 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, } for(UINT ke = VK_NUMPAD0; ke <= VK_NUMPAD9; ke++) { - rgKey[ke] = new KMX_VirtualKey(hkl, ke, keymap); + rgKey[ke] = new KMX_VirtualKey(hkl, ke); } - rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE, keymap); - rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL, keymap); - rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL, keymap); + rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE); + rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL); + rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL); /* // _S2 DESIGN NEEDED do we need special shift state now or later? @@ -499,7 +500,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, for(ShiftState ss = Base; ss <= loader.KMX_MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { if(ss == Menu || ss == ShftMenu) { - // Alt and Shift+Alt don't work, so skip them + // Alt and Shift+Alt don't work, so skip them 4+5 continue; } @@ -510,11 +511,9 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, KMX_DWORD KC_US = (KMX_DWORD) KMX_get_KeyCodeUnderlying_From_VKUS(iKey); - - // _S2 TODO not finished; Ctrl, Shft +40 not tested for(int caps = 0; caps <= 1; caps++) { loader.KMX_FillKeyState(lpKeyState, ss, (caps == 0)); - int rc = KMX_ToUnicodeEx(KC_US, lpKeyState, sbBuffer, ss, caps, *keymap); + int rc = KMX_ToUnicodeEx(KC_US, sbBuffer, ss, caps, *keymap); if(rc > 0) { if(*sbBuffer == 0) { @@ -522,24 +521,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps)); } else { - if((rc == 1) && - (ss == Ctrl || ss == ShftCtrl) && - (rgKey[iKey]->VK() == ((UINT)sbBuffer[0] + 0x40))) { - // is this the same behavior on Linux? - // if rc ==1 : it got 1 char && +40 in Buffer CTRl pressed - // && CTRl +0x40 in the buffer ( which indicates a ctrl press) - - // It's dealing with control characters. If ToUnicodeEx gets - // VK_A with the Ctrl key pressed, it will write 0x01 to sBuffer[0], - // without Ctrl it's 0x41. The if detects this case. - - // ToUnicodeEx has an internal knowledge about those - // VK_A ~ VK_Z keys to produce the control characters, - // when the conversion rule is not provided in keyboard - // layout files - - continue; - } if( (ss == Ctrl || ss == ShftCtrl) ) { continue; } diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 478e1f6c4d..4ca09cde9d 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -270,7 +270,7 @@ void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT memcpy(keys+1, kbd->dpGroupArray[i].dpKeyArray, kbd->dpGroupArray[i].cxKeyArray * sizeof(KMX_KEY)); keys[0].dpContext = new KMX_WCHAR[1]; keys[0].dpContext[0] = 0; - keys[0].dpOutput = new KMX_WCHAR[4]; // UC_SENTINEL, CODE_DEADKEY, deadkey_value, 0 + keys[0].dpOutput = new KMX_WCHAR[4]; keys[0].dpOutput[0] = UC_SENTINEL; keys[0].dpOutput[1] = CODE_DEADKEY; keys[0].dpOutput[2] = deadkey; // TODO: translate to unique index @@ -368,6 +368,7 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, UINT shift, KMX_WCHA KMX_AddDeadkeyRule(kbd, dkid, vk_US, shift); KMX_GetDeadkeys(dk_Table, deadkey, pdk = deadkeys, keymap); // returns array of [usvk, ch_out] pairs + while(*pdk) { // Look up the ch UINT KeyValUnderlying = KMX_get_KeyValUnderlying_From_KeyValUS(All_Vector, *pdk); From 77d50eee7a921756f2a3183ea6edcd099b1d1f68 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 20 Feb 2024 15:41:36 +0100 Subject: [PATCH 213/327] feat(linux): mcompile-dk combine KMX_get_KeyValUnderlying_From_KeyCodeUnderlying --- linux/mcompile/keymap/keymap.cpp | 42 +++++++++----------------------- linux/mcompile/keymap/keymap.h | 7 ++---- 2 files changed, 14 insertions(+), 35 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 31641da53d..2ba7247246 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -514,56 +514,38 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, gui return KVal; } -// _S2 ToDo combine those?? + KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, UINT VKShiftState, UINT KC_underlying, PKMX_WCHAR DeadKey) { - PKMX_WCHAR dky; - KMX_DWORD KeyVal = KMX_get_KeyValUnderlying_DK_From_KeyCodeUnderlying(keymap, KC_underlying, map_VKShiftState_to_LinModifier(VKShiftState), dky); - - if(KeyVal >= deadkey_min) { // deadkey - *DeadKey = *dky; - return 0xFFFF; - } - else if((KeyVal > deadkey_max) || ((KeyVal < deadkey_min) && ( KeyVal > 0xFF))) // out of range - return 0xFFFE; - else // usable char - return KeyVal; -} - -KMX_DWORD KMX_get_KeyValUnderlying_DK_From_KeyCodeUnderlying(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky) { GdkKeymapKey *maps; guint *keyvals; gint count; KMX_DWORD deadkey=0; + PKMX_WCHAR dky=NULL; - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) + if (!gdk_keymap_get_entries_for_keycode(keymap, KC_underlying, &maps, &keyvals, &count)) return 0; - // _S2 INFO maybe later use something like - //if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) - // return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html - if (!(shift_state_pos <= count)) + if (!(map_VKShiftState_to_LinModifier(VKShiftState) <= count)) return 0; - if (!(keycode <= keycode_max)) + if (!(KC_underlying <= keycode_max)) return 0; - KMX_DWORD KeyV = KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(shift_state_pos), 0); - - if(( (KeyV >= deadkey_min) && (KeyV <= deadkey_max))) - deadkey = KeyV; - - dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str(); + KMX_DWORD KeyV = KMX_get_KeyVal_From_KeyCode(keymap, KC_underlying, ShiftState(map_VKShiftState_to_LinModifier(VKShiftState)), 0); g_free(keyvals); g_free(maps); - if((KeyV >= deadkey_min) && (KeyV <= deadkey_max)) // deadkeys + if ((KeyV >= deadkey_min) && (KeyV <= deadkey_max) ){ // deadkey + dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) KeyV)).c_str(); + *DeadKey = *dky; return 0xFFFF; - else if((KeyV > deadkey_max) || ((KeyV < deadkey_min) && ( KeyV > 0xFF))) // out of range + } + else if((KeyV > deadkey_max) || ((KeyV < deadkey_min) && ( KeyV > 0xFF))) // out of range return 0xFFFE; - else // usable char + else // usable char return KeyV; } diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index c0e6a71d0e..f42f38e065 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -67,8 +67,8 @@ typedef std::vector > > v_dw_3D; static KMX_DWORD returnIfCharInvalid = 0; static KMX_DWORD keycode_max = 94; static KMX_DWORD deadkey_min = 0xfe50; -static KMX_DWORD deadkey_max = 0xfe93; -//static KMX_DWORD deadkey_max = 0xfe52; // _S2 TODO This has to go! my test: to only return 3 dk +//static KMX_DWORD deadkey_max = 0xfe93; +static KMX_DWORD deadkey_max = 0xfe52; // _S2 TODO This has to go! my test: to only return 3 dk int map_VKShiftState_to_LinModifier(int VKShiftState); @@ -516,9 +516,6 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, gui // fill Deadkey with dk and return CATEGORY KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, UINT VKShiftState, UINT KC_underlying, PKMX_WCHAR DeadKey); -// use KMX_get_KeyVal_From_KeyCode and return CATEGORY off keyval and prevent use of certain keycodes -KMX_DWORD KMX_get_KeyValUnderlying_DK_From_KeyCodeUnderlying(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky); - // use Vector to return the Keyval of underlying Keyboard KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(v_dw_3D &All_Vector,KMX_DWORD VK_underlying); From 001dc52021b72435e928672f883da2ce17569f5a Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 20 Feb 2024 16:13:27 +0100 Subject: [PATCH 214/327] feat(linux): mcompile-dk remove KMX_FillKeyState --- linux/mcompile/keymap/deadkey.cpp | 2 +- linux/mcompile/keymap/mc_import_rules.cpp | 13 ------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 53b82b5ebd..26f7530173 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -410,7 +410,7 @@ void create_DKTable(v_dw_2D & dk_ComposeTable) { line = createLine(L"dead_acute", L"space", 0x0027, L"APOSTROPHE"); dk_ComposeTable.push_back(line); line.clear(); - /*line = createLine(L"dead_acute", L"space", 0x00B4, L"ACUTE_ACCENT"); + /*line = createLine(L"dead_acute", L"space", 0x00B4, L"ACUTE_ACCENT"); // _S2 ToDo remove - just for testing dk_ComposeTable.push_back(line); line.clear();*/ line = createLine(L"dead_grave", L"space", 0x0060, L"GRAVE_ACCENT"); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 78c897ef90..4858cf0159 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -392,18 +392,6 @@ public: return (Get_XxxxVk() == 0 ? ShftMenuCtrl : ShftXxxx); } -// _S2 ToDo needed??? - no? - void KMX_FillKeyState(KMX_BYTE *lpKeyState, ShiftState ss, bool fCapsLock) { - lpKeyState[VK_SHIFT] = (((ss & Shft) != 0) ? 0x80 : 0x00); - lpKeyState[VK_CONTROL] = (((ss & Ctrl) != 0) ? 0x80 : 0x00); - lpKeyState[VK_MENU] = (((ss & Menu) != 0) ? 0x80 : 0x00); - if (Get_XxxxVk() != 0) { - // The Xxxx key has been assigned, so let's include it - lpKeyState[Get_XxxxVk()] = (((ss & Xxxx) != 0) ? 0x80 : 0x00); - } - lpKeyState[VK_CAPITAL] = (fCapsLock ? 0x01 : 0x00); - } - bool KMX_IsControlChar(wchar_t ch) { return (ch < 0x0020) || (ch >= 0x007F && ch <= 0x009F); } @@ -512,7 +500,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, KMX_DWORD KC_US = (KMX_DWORD) KMX_get_KeyCodeUnderlying_From_VKUS(iKey); for(int caps = 0; caps <= 1; caps++) { - loader.KMX_FillKeyState(lpKeyState, ss, (caps == 0)); int rc = KMX_ToUnicodeEx(KC_US, sbBuffer, ss, caps, *keymap); if(rc > 0) { From aa36aadcc0977d74151bf5d1d16bb1a64d1369a4 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 20 Feb 2024 17:16:31 +0100 Subject: [PATCH 215/327] feat(linux): mcompile-dk edit comments --- linux/mcompile/keymap/README.md | 3 - linux/mcompile/keymap/deadkey.cpp | 68 +++++++++++------------ linux/mcompile/keymap/deadkey.h | 10 ++-- linux/mcompile/keymap/filesystem.h | 4 +- linux/mcompile/keymap/keymap.cpp | 10 ++++ linux/mcompile/keymap/keymap.h | 6 +- linux/mcompile/keymap/mc_import_rules.cpp | 23 +++----- linux/mcompile/keymap/mc_import_rules.h | 1 + linux/mcompile/keymap/mcompile.cpp | 14 +---- linux/mcompile/keymap/mcompile.h | 4 +- 10 files changed, 69 insertions(+), 74 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index 2278b47a40..cd59b2735c 100755 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -10,12 +10,9 @@ _S2 TODO QUESTION check if US basic is the right Keyboard to compare with _S2 TODO check if I can use files from some other keyman path instead of a copy here ( e.g. filesystem.h exists elsewhere); where can I use incxstr from _S2 TODO Do I need HKL for Linux / can I just use a void* or remove HKL ??, typeddef of KMX_HKL - can I delete all m_hkl from classes? _S2 TODO Check/find use of wchar_t/wstring and replace with char16_t/u16string -_S2 TODO TODO keymap* or keymap** everywhere? _S2 TODO check call by reference/value _S2 TODO replace GDK _S2 TODO what is wrong with kp->dpBitmapOffset/BitmapSize ? -_S2 TODO do I use all var in a function or are there unsused var? -_S2 TODO explain fields of aldead and All_Vector somewher _s2 INFO idee spanish keyboard has dk on altgr !! _S2 ... diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 26f7530173..1f7fa5ff26 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -10,25 +10,6 @@ v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, s return line; } -bool find_dk_combinations_for_specific_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &dk_SingleTable, KMX_DWORD dk) { - v_dw_1D line; - - for ( int i =0; i< (int) (*p_dk_ComposeTable).size(); i++) { - if (((*p_dk_ComposeTable)[i][0] == dk) && (IsKeymanUsedChar((*p_dk_ComposeTable)[i][1]))) { - line.push_back((*p_dk_ComposeTable)[i][0]); - line.push_back((*p_dk_ComposeTable)[i][1]); - line.push_back((*p_dk_ComposeTable)[i][2]); - dk_SingleTable.push_back(line); - line.clear(); - } - } - - if( dk_SingleTable.size()>0) - return true; - else - return false; -} - std::vector create_alDead() { std::vector alDead; v_dw_2D dk_ComposeTable; @@ -46,18 +27,6 @@ std::vector create_alDead() { return alDead; } -bool found_dk_inVector(KMX_WCHAR dk, std::vector &dkVec) { - int i=0; - if( dkVec.size() > 0) { - do { - if( dk == dkVec[i]->KMX_GetDeadCharacter()) - return true; - i++; - } while (i < (int) dkVec.size()); - } - return false; -} - void refine_alDead(KMX_WCHAR dk, std::vector &dkVec, std::vector *p_All_Vec) { if( dk == 0) return; @@ -73,6 +42,18 @@ void refine_alDead(KMX_WCHAR dk, std::vector &dkVec, std::vector &dkVec) { + int i=0; + if( dkVec.size() > 0) { + do { + if( dk == dkVec[i]->KMX_GetDeadCharacter()) + return true; + i++; + } while (i < (int) dkVec.size()); + } + return false; +} + void sort_alDead(std::vector &small_Vec, std::vector *p_All_Vec) { std::vector small_sorted; int Vsmall_size; @@ -95,6 +76,25 @@ void sort_alDead(std::vector &small_Vec, std::vector *p_All_ small_Vec = small_sorted; } +bool find_dk_combinations_for_specific_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &dk_SingleTable, KMX_DWORD dk) { + v_dw_1D line; + + for ( int i =0; i< (int) (*p_dk_ComposeTable).size(); i++) { + if (((*p_dk_ComposeTable)[i][0] == dk) && (IsKeymanUsedChar((*p_dk_ComposeTable)[i][1]))) { + line.push_back((*p_dk_ComposeTable)[i][0]); + line.push_back((*p_dk_ComposeTable)[i][1]); + line.push_back((*p_dk_ComposeTable)[i][2]); + dk_SingleTable.push_back(line); + line.clear(); + } + } + + if( dk_SingleTable.size()>0) + return true; + else + return false; +} + KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap) { guint Keyval = (guint) KVal; GdkKeymapKey* keys; @@ -115,12 +115,12 @@ KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap // _S2 DESIGN NEEDED is this the right place to get dk from? if not where are they stored? void create_DKTable(v_dw_2D & dk_ComposeTable) { - - //values taken from: https://help.ubuntu.com/community/GtkDeadKeyTable#Latin + //create a 2D-Vector which contains data for ALL existing deadkey combinations on a Linux Keyboard: //dk_ComposeTable[i][0] : First (e.g. dead_circumflex) //dk_ComposeTable[i][1] : Second (e.g. a) //dk_ComposeTable[i][3] : Unicode-Value (e.g. 0x00E2) - //dk_ComposeTable[i][4] : Character (e.g. small A with circumflex) + + //values taken from: https://help.ubuntu.com/community/GtkDeadKeyTable#Latin v_dw_1D line; diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index d48890d5b2..69dd8130f6 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -7,10 +7,10 @@ #include "mc_import_rules.h" -// creates a vector for a dk combination ( ` + a -> à ) +// create a vector for a dk combination ( ` + a -> à ) v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult); -// creates a 2D-vector of all dk combinations ( ` + a -> à ; ^ + a -> â ; `+ e -> è; ...) +// create a 2D-vector of all dk combinations ( ` + a -> à ; ^ + a -> â ; `+ e -> è; ...) void create_DKTable(v_dw_2D & dk_ComposeTable); // find all possible dk combinations that exist @@ -20,13 +20,13 @@ std::vector create_alDead(); void refine_alDead(KMX_WCHAR dk, std::vector &myVec, std::vector *p_All_Vec); bool found_dk_inVector(KMX_WCHAR dk, std::vector &myVec); +// _S2 TODO probably not used +void sort_alDead(std::vector &myVec, std::vector *p_All_Vec); + // find all combination for a specific deadkey(dk) ^-> â,ê,î,ô,û,... bool find_dk_combinations_for_specific_dk(v_dw_2D * dk_ComposeTable, v_dw_2D & dk_SingleTable, KMX_DWORD dk); // get the shifted character of a key and write shiftstate of KVal to shift KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap); -// _S2 TODO probably not used -void sort_alDead(std::vector &myVec, std::vector *p_All_Vec); - # endif /*DEADKEY_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/filesystem.h b/linux/mcompile/keymap/filesystem.h index eec98f9ecf..af3d6aa7d6 100755 --- a/linux/mcompile/keymap/filesystem.h +++ b/linux/mcompile/keymap/filesystem.h @@ -3,8 +3,8 @@ #include #include "u16.h" -// Opens files on windows and non-windows platforms. Datatypes for Filename and mode must be the same. -// returns FILE* if file could be opened; FILE needs to be closed in calling function +// Open files on windows and non-windows platforms. Datatypes for Filename and mode must be the same. +// return FILE* if file could be opened; FILE must to be closed in calling function FILE* Open_File(const KMX_CHAR* Filename, const KMX_CHAR* mode); FILE* Open_File(const KMX_WCHART* Filename, const KMX_WCHART* mode); FILE* Open_File(const KMX_WCHAR* Filename, const KMX_WCHAR* mode); diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 2ba7247246..36bcd2d0ac 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -82,6 +82,16 @@ KMX_DWORD convertNamesTo_DWORD_Value(std::wstring tok_wstr) { } int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap) { + // create a 3D-Vector which contains data of the US keyboard and the underlying Keyboard: + // All_Vector[ US_Keyboard ] + // [KeyCode_US ] + // [Keyval unshifted ] + // [Keyval shifted ] + // [Underlying Kbd] + // [KeyCode_underlying] + // [Keyval unshifted ] + // [Keyval shifted ] + std::string US_language = "us"; const char* text_us = "xkb_symbols \"basic\""; //const char* text_us = "xkb_symbols \"intl\""; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index f42f38e065..f00f31cc8b 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -67,12 +67,12 @@ typedef std::vector > > v_dw_3D; static KMX_DWORD returnIfCharInvalid = 0; static KMX_DWORD keycode_max = 94; static KMX_DWORD deadkey_min = 0xfe50; -//static KMX_DWORD deadkey_max = 0xfe93; -static KMX_DWORD deadkey_max = 0xfe52; // _S2 TODO This has to go! my test: to only return 3 dk +static KMX_DWORD deadkey_max = 0xfe93; +//static KMX_DWORD deadkey_max = 0xfe52; // _S2 TODO This has to go! my test: to only return 3 dk int map_VKShiftState_to_LinModifier(int VKShiftState); -// takes a std::wstring (=contents of line symbols-file ) and returns the (int) value of the character +// take a std::wstring (=contents of line symbols-file ) and returns the (int) value of the character KMX_DWORD convertNamesTo_DWORD_Value(std::wstring tok_wstr); // create a Vector with all entries of both keymaps+ keymap diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 4858cf0159..8270aa103e 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -139,15 +139,6 @@ public: return this->m_sc; } - // _S2 TODO can go later - std::wstring get_m_rgss(int i,int j) { - return m_rgss[i][j]; - } - // _S2 TODO can go later - bool get_m_rgfDeadkey(int i,int j) { - return m_rgfDeadKey[i][j]; - } - std::wstring KMX_GetShiftState(ShiftState shiftState, bool capsLock) { return this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)]; } @@ -340,6 +331,7 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0;*/ if(st[ich] < 0x20 || st[ich] == 0x7F) { isvalid=false; break; } } if(isvalid) { + // _S2 DIFFERENCE TO MCOMPILE WINDOWS // this is different to mcompile windows !!!! // this->m_sc stores SC-US = SCUnderlying // this->m_vk stores VK-US ( not underlying !!) @@ -392,6 +384,7 @@ public: return (Get_XxxxVk() == 0 ? ShftMenuCtrl : ShftXxxx); } + // _S2 ToDo Do we need one/none? bool KMX_IsControlChar(wchar_t ch) { return (ch < 0x0020) || (ch >= 0x007F && ch <= 0x009F); } @@ -431,11 +424,13 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // flag that the VK is valid, and it can store the SC value. for(UINT sc = 0x01; sc <= 0x7f; sc++) { + // _S2 DIFFERENCE TO MCOMPILE WINDOWS // fills m_vk with the VK of the US keyboard // ( mcompile win uses MapVirtualKeyEx() to fill m_vk with the VK of the Underlying keyboard) - // Linux cant get a VK for the US Keyboard using USVirtualKeyToScanCode/ScanCodeToUSVirtualKey + // Linux can get a VK for the US Keyboard using USVirtualKeyToScanCode/ScanCodeToUSVirtualKey // Linux cannot get a VK for the underling Keyboard - // this "connection" is possible only while using All_Vector + // this "connection" is possible only when using All_Vector + KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl); if((key->VK() != 0) ) { @@ -488,14 +483,14 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, for(ShiftState ss = Base; ss <= loader.KMX_MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { if(ss == Menu || ss == ShftMenu) { - // Alt and Shift+Alt don't work, so skip them 4+5 + // Alt and Shift+Alt don't work, so skip them (ss 4+5) continue; } //_S2 TODO to compare win-lin kmn-files skip ss6+7; MUST BE removed later!!!! - /*if(ss == MenuCtrl|| ss == ShftMenuCtrl) { + if(ss == MenuCtrl|| ss == ShftMenuCtrl) { continue; - }*/ + } KMX_DWORD KC_US = (KMX_DWORD) KMX_get_KeyCodeUnderlying_From_VKUS(iKey); diff --git a/linux/mcompile/keymap/mc_import_rules.h b/linux/mcompile/keymap/mc_import_rules.h index 2725b4860f..f8f958d7d4 100644 --- a/linux/mcompile/keymap/mc_import_rules.h +++ b/linux/mcompile/keymap/mc_import_rules.h @@ -11,6 +11,7 @@ private: public: DeadKey(KMX_WCHAR deadCharacter) ; + KMX_WCHAR KMX_DeadCharacter() ; void KMX_AddDeadKeyRow(KMX_WCHAR baseCharacter, KMX_WCHAR combinedCharacter) ; diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 4ca09cde9d..0d33abc579 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -71,7 +71,6 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ L" positional one based on the Linux keyboard\n" L" layout on top position\n" L" (-d convert deadkeys to plain keys) not available yet \n\n" - ); // I4552 return 1; @@ -133,9 +132,6 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ //DeleteReallocatedPointers(kmxfile); :TODO // _S2 not my ToDo :-) delete kmxfile; - - wprintf(L"\nmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm end\n"); - wprintf(L"\n"); return 0; } @@ -147,7 +143,6 @@ const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCT // // For each key rule on the keyboard, remap its key to the // correct shift state and key. Adjust the LCTRL+RALT -> RALT if necessary -// _S2 INFO exchange key->Key with the new value ( use vk instead of ch) // void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. @@ -214,7 +209,6 @@ void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT // _S2 INFO this produces a different output due to different layouts for Lin<-> win ( for the same language!!) if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { - // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. @@ -433,6 +427,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg // Loop through each possible key on the keyboard for (int i = 0;KMX_VKMap[i]; i++) { // I4651 + // _S2 DIFFERENT TO MCOMPILE WINDOWS // win goes via VK, Lin goes via SC/Keycode UINT scUnderlying = KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]); @@ -448,17 +443,14 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg switch(ch) { case 0x0000: break; - case 0xFFFF: // _S2 INFO in kbd (=loaded from kmx-file): replace LCTRL+RALT -> Ctrl+Alt + write deadkey-> FFFF + CODE_DEADKEY + deadkey into context - KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap , dk_Table); break; - default: // _S2 INFO in kbd (=loaded from kmx-file): replace LCTRL+RALT -> Ctrl+Alt + switch keyvalues e.g. y<->z - KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); + case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap , dk_Table); break; + default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); } } } KMX_ReportUnconvertedKeyboardRules(kbd); - // _S2 INFO use translated kbd and write data to rgkey[] then add things to rgkey[] to enable to write to kmx-format if(!KMX_ImportRules(kbd, All_Vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 return FALSE; } diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index b30fbfba8d..b352352219 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -24,8 +24,6 @@ #include "deadkey.h" #include "mc_kmxfile.h" -void KMX_LogError(PWCHAR fmt, ...) ; - struct KMX_DeadkeyMapping { // I4353 KMX_WCHAR deadkey, dkid; UINT shift; @@ -40,4 +38,6 @@ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap); +void KMX_LogError(PWCHAR fmt, ...) ; + #endif /*MCOMPILE_H*/ From 4687fdc9557e928e7672741a56bafa0f019eb08a Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 26 Feb 2024 08:59:19 +0100 Subject: [PATCH 216/327] feat(linux): mcompile-dk remove numpad, special shift states, sort_dk --- linux/mcompile/keymap/README.md | 3 +- linux/mcompile/keymap/deadkey.h | 3 -- linux/mcompile/keymap/keymap.h | 4 +-- linux/mcompile/keymap/km_types.h | 39 ----------------------- linux/mcompile/keymap/mc_import_rules.cpp | 33 ------------------- linux/mcompile/keymap/mcompile.cpp | 2 +- 6 files changed, 4 insertions(+), 80 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index cd59b2735c..7e540dd870 100755 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -6,8 +6,7 @@ Sample program that reads US basic keyboard and compares to key value group # Keymap -_S2 TODO QUESTION check if US basic is the right Keyboard to compare with -_S2 TODO check if I can use files from some other keyman path instead of a copy here ( e.g. filesystem.h exists elsewhere); where can I use incxstr from +__S2 TODO check if I can use files from some other keyman path instead of a copy here ( e.g. filesystem.h exists elsewhere); where can I use incxstr from _S2 TODO Do I need HKL for Linux / can I just use a void* or remove HKL ??, typeddef of KMX_HKL - can I delete all m_hkl from classes? _S2 TODO Check/find use of wchar_t/wstring and replace with char16_t/u16string _S2 TODO check call by reference/value diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index 69dd8130f6..18805734df 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -20,9 +20,6 @@ std::vector create_alDead(); void refine_alDead(KMX_WCHAR dk, std::vector &myVec, std::vector *p_All_Vec); bool found_dk_inVector(KMX_WCHAR dk, std::vector &myVec); -// _S2 TODO probably not used -void sort_alDead(std::vector &myVec, std::vector *p_All_Vec); - // find all combination for a specific deadkey(dk) ^-> â,ê,î,ô,û,... bool find_dk_combinations_for_specific_dk(v_dw_2D * dk_ComposeTable, v_dw_2D & dk_SingleTable, KMX_DWORD dk); diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index f00f31cc8b..27274e3743 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -67,8 +67,8 @@ typedef std::vector > > v_dw_3D; static KMX_DWORD returnIfCharInvalid = 0; static KMX_DWORD keycode_max = 94; static KMX_DWORD deadkey_min = 0xfe50; -static KMX_DWORD deadkey_max = 0xfe93; -//static KMX_DWORD deadkey_max = 0xfe52; // _S2 TODO This has to go! my test: to only return 3 dk +//static KMX_DWORD deadkey_max = 0xfe93; +static KMX_DWORD deadkey_max = 0xfe52; // _S2 TODO This has to go! my test: to only return 3 dk int map_VKShiftState_to_LinModifier(int VKShiftState); diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index 26e20b61f4..91bff6ec96 100755 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -95,45 +95,6 @@ typedef KMX_UCHAR* KMX_PUCHAR; #define VK_xDF 0xDF #define VK_OEM_102 0xE2 // "<>" or "\|" on RT 102-key kbd. -/*#define VK_NUMPAD0 0x5A -#define VK_NUMPAD1 0x57 -#define VK_NUMPAD2 0x58 -#define VK_NUMPAD3 0x59 -#define VK_NUMPAD4 0x53 -#define VK_NUMPAD5 0x54 -#define VK_NUMPAD6 0x55 -#define VK_NUMPAD7 0x4F -#define VK_NUMPAD8 0x50 -#define VK_NUMPAD9 0x51 -#define VK_DIVIDE 0x6A -#define VK_CANCEL 0x09 -#define VK_DECIMAL 0x5B*/ - -// _S2 TODO correct?? ?? -#define VK_NUMPAD0 0x60 -#define VK_NUMPAD1 0x61 -#define VK_NUMPAD2 0x62 -#define VK_NUMPAD3 0x63 -#define VK_NUMPAD4 0x64 -#define VK_NUMPAD5 0x65 -#define VK_NUMPAD6 0x66 -#define VK_NUMPAD7 0x67 -#define VK_NUMPAD8 0x68 -#define VK_NUMPAD9 0x69 - - -// _S2 TODO correct?? ?? -/*#define VK_NUMPAD0 0x2D -#define VK_NUMPAD1 0x23 -#define VK_NUMPAD2 0x28 -#define VK_NUMPAD3 0x22 -#define VK_NUMPAD4 0x25 -#define VK_NUMPAD5 0x0C -#define VK_NUMPAD6 0x27 -#define VK_NUMPAD7 0x24 -#define VK_NUMPAD8 0x26 -#define VK_NUMPAD9 0x21*/ - #define VK_DIVIDE 0x6F #define VK_CANCEL 3 #define VK_DECIMAL 0x2E diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 8270aa103e..b389619a0a 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -440,41 +440,10 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, } } - for(UINT ke = VK_NUMPAD0; ke <= VK_NUMPAD9; ke++) { - rgKey[ke] = new KMX_VirtualKey(hkl, ke); - } - rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE); rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL); rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL); - /* - // _S2 DESIGN NEEDED do we need special shift state now or later? - // See if there is a special shift state added - for(UINT vk = 0; vk <= VK_OEM_CLEAR; vk++) { - UINT sc = MapVirtualKeyEx(vk, 0, hkl); - UINT vkL = MapVirtualKeyEx(sc, 1, hkl); - UINT vkR = MapVirtualKeyEx(sc, 3, hkl); - if((vkL != vkR) && - (vk != vkL)) { - switch(vk) { - case VK_LCONTROL: - case VK_RCONTROL: - case VK_LSHIFT: - case VK_RSHIFT: - case VK_LMENU: - case VK_RMENU: - break; - - default: - loader.Set_XxxxVk(vk); - break; - } - } - } - */ - - // in this part we skip shiftstates 4, 5, 8, 9 for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { @@ -523,8 +492,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, } } } - // _S2 DESIGN NEEDED do we need to sort alDead? And if so how? - sort_alDead(alDead, &alDead_cpl); //------------------------------------------------------------- // Now that we've collected the key data, we need to diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 0d33abc579..45c787f01a 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -130,7 +130,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ #endif //DeleteReallocatedPointers(kmxfile); :TODO // _S2 not my ToDo :-) - +wprintf(L"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm end\n"); delete kmxfile; return 0; } From 78c4b5897c8a7302ac80500ed41ba24aaec7061d Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 26 Feb 2024 09:13:45 +0100 Subject: [PATCH 217/327] feat(linux): mcompile-dk disable functions to calculate capslock and set capslock =1 --- linux/mcompile/keymap/mc_import_rules.cpp | 37 +++++------------------ linux/mcompile/keymap/mcompile.cpp | 6 ++-- 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index b389619a0a..f44e62ad9c 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -154,8 +154,8 @@ public: this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; } -// _S2 DESIGN NEEDED how to change those? Do we need to change? - bool KMX_IsSGCAPS() { +// _S2 ToDo delete later + /* bool KMX_IsSGCAPS() { std::wstring stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß std::wstring stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? std::wstring stCaps = this->KMX_GetShiftState(Base, true); // 0,1 A 4 ẞ @@ -201,7 +201,7 @@ public: (stBase.compare(stShift) != 0) && (stShift.compare(stCaps) == 0)); } - +*/ bool KMX_IsEmpty() { for (int i = 0; i < 10; i++) { for (int j = 0; j <= 1; j++) { @@ -262,32 +262,14 @@ public: bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,v_dw_3D &All_Vector, GdkKeymap *keymap) { // I4552 // Get the CAPSLOCK value -// _S2 TODO needs to go later // this should be true for char, number, special -/*bool b1= this->KMX_IsCapsEqualToShift(); // but is false for numbers and special -bool b2= this->KMX_IsSGCAPS(); -bool b3= this->KMX_IsAltGrCapsEqualToAltGrShift(); -bool b4= this->KMX_IsXxxxGrCapsEqualToXxxxShift(); - -int i1 = this->KMX_IsCapsEqualToShift() ? 1 : 0; -int i2 = this->KMX_IsSGCAPS() ? 2 : 0; -int i3 = this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0; -int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0;*/ - - int capslock = + // _S2 TODO delete later + /* int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | (this->KMX_IsSGCAPS() ? 2 : 0) | (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); - - - // DIFFERENCE TO MCOMPILE WINDOWS - // _S2 DESIGN NEEDED on how to replace capslock - // capslock has different values for linux. Therefore key->ShiftFlags will be different for numbers, special characters - // Therefore CAPS/NCAPS will be added differently for Lin<->Win - // for now set capslock=1 - // capslock=1 <-> capslock=0; - // [ CTRL NCAPS K_I] <-> [CTRL K_I] - capslock=1; + (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0);*/ + // _S2 replaced + int capslock=1; for (int ss = 0; ss <= MaxShiftState; ss++) { if (ss == Menu || ss == ShftMenu) { @@ -331,7 +313,6 @@ int i4 = this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0;*/ if(st[ich] < 0x20 || st[ich] == 0x7F) { isvalid=false; break; } } if(isvalid) { - // _S2 DIFFERENCE TO MCOMPILE WINDOWS // this is different to mcompile windows !!!! // this->m_sc stores SC-US = SCUnderlying // this->m_vk stores VK-US ( not underlying !!) @@ -424,7 +405,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // flag that the VK is valid, and it can store the SC value. for(UINT sc = 0x01; sc <= 0x7f; sc++) { - // _S2 DIFFERENCE TO MCOMPILE WINDOWS // fills m_vk with the VK of the US keyboard // ( mcompile win uses MapVirtualKeyEx() to fill m_vk with the VK of the Underlying keyboard) // Linux can get a VK for the US Keyboard using USVirtualKeyToScanCode/ScanCodeToUSVirtualKey @@ -485,7 +465,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, //rgKey[iKey]->SetShiftState(ss, sbBuffer, true, (caps == 0)); rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); //_S2 INFO - // _S2 DIFFERENCE TO MCOMPILE WINDOWS refine_alDead(sbBuffer[0], alDead, &alDead_cpl); } } diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 45c787f01a..adb02e5ea4 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -412,8 +412,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg return FALSE; } - // _S2 DIFFERENT TO MCOMPILE WINDOWS - // create vector + // create vector that contains Keycode, base, shift for US-KEyboard and underlying keyboard v_dw_3D All_Vector; if(createOneVectorFromBothKeyboards(All_Vector, keymap)){ wprintf(L"ERROR: can't create one vector from both keyboards\n"); @@ -428,8 +427,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg // Loop through each possible key on the keyboard for (int i = 0;KMX_VKMap[i]; i++) { // I4651 - // _S2 DIFFERENT TO MCOMPILE WINDOWS - // win goes via VK, Lin goes via SC/Keycode + // windows uses VK, Linux uses SC/Keycode UINT scUnderlying = KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]); KMX_WCHAR ch = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap, VKShiftState[j], scUnderlying, &DeadKey); From f6e887a6bef73ca638b50d96126b1ada6c4caee3 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 27 Feb 2024 08:12:12 +0100 Subject: [PATCH 218/327] feat(linux): mcompile-dk remove comments --- linux/mcompile/keymap/README.md | 1 - linux/mcompile/keymap/mc_import_rules.cpp | 5 ++--- linux/mcompile/keymap/mcompile.cpp | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index 7e540dd870..f39e10b473 100755 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -10,7 +10,6 @@ __S2 TODO check if I can use files from some other keyman path instead of a copy _S2 TODO Do I need HKL for Linux / can I just use a void* or remove HKL ??, typeddef of KMX_HKL - can I delete all m_hkl from classes? _S2 TODO Check/find use of wchar_t/wstring and replace with char16_t/u16string _S2 TODO check call by reference/value -_S2 TODO replace GDK _S2 TODO what is wrong with kp->dpBitmapOffset/BitmapSize ? _s2 INFO idee spanish keyboard has dk on altgr !! diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index f44e62ad9c..44ee1a2e22 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -202,6 +202,7 @@ public: (stShift.compare(stCaps) == 0)); } */ + bool KMX_IsEmpty() { for (int i = 0; i < 10; i++) { for (int j = 0; j <= 1; j++) { @@ -393,9 +394,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, BYTE lpKeyState[256];// = new KeysEx[256]; std::vector rgKey; //= new VirtualKey[256]; std::vector alDead; - - - // _S2 DIFFERENCE TO MCOMPILE WINDOWS std::vector alDead_cpl = create_alDead(); rgKey.resize(256); @@ -555,6 +553,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, UINT j; LPKMX_KEY kkp; for(j = 0, kkp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kkp++) { + // _S2 0110 1111 if((kkp->ShiftFlags & (K_CTRLFLAG|K_ALTFLAG|LCTRLFLAG|LALTFLAG|RCTRLFLAG|RALTFLAG)) != 0) { gp2->cxKeyArray++; LPKMX_KEY kkp2 = new KMX_KEY[gp2->cxKeyArray]; diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index adb02e5ea4..fecc1cac98 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -75,7 +75,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ return 1; } - // _S2 INFO -u option was removed for Linux + // -u option not available for Linux int bDeadkeyConversion = u16cmp(argv[1], u"-d") == 0; // I4552 int n = (bDeadkeyConversion ? 2 : 1); @@ -404,8 +404,6 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg // evident for the 102nd key on UK, for example, where \ can be generated with VK_OEM_102 or AltGr+VK_QUOTE. // For now, we get the least shifted version, which is hopefully adequate. - // _S2 INFO first version with GTK - maybe change later to XklGetGroupNames und XklGetCurrentState as Eberhard suggested - //_ init gdk GdkKeymap *keymap; if(InitializeGDK(&keymap , argc, argv)) { wprintf(L"ERROR: can't Initialize GDK\n"); From b0811ba991f24b6631eb68c1d51b3332bbde1b41 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 27 Feb 2024 16:05:03 +0100 Subject: [PATCH 219/327] feat(linux): mcompile-dk capslock-equation added again. We need it! (we cannot set capslock=1 ) --- linux/mcompile/keymap/README.md | 7 ++++ linux/mcompile/keymap/deadkey.cpp | 4 +- linux/mcompile/keymap/keymap.cpp | 2 +- linux/mcompile/keymap/keymap.h | 2 +- linux/mcompile/keymap/km_types.h | 2 +- linux/mcompile/keymap/mc_import_rules.cpp | 46 ++++++++++++++--------- linux/mcompile/keymap/mc_kmxfile.cpp | 2 +- linux/mcompile/keymap/mcompile.cpp | 7 ++-- 8 files changed, 46 insertions(+), 26 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index f39e10b473..317d8c7ca5 100755 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -15,6 +15,13 @@ _s2 INFO idee spanish keyboard has dk on altgr !! _S2 ... +_S2 TOP_1 NCAPS/capslock +_S2 TOP_2 Shiftflags +_S2 TOP_3 dk-table from file->from functions +_S2 TOP_4 HKL +_S2 TOP_5 use files/functions from other places +_S2 TOP_6 remaining + ./mcompile -d /Projects/keyman/keyman/linux/mcompile/keymap/mcompile_test.kmx bla.dll 0407 /Projects/keyman/keyman/linux/mcompile/keymap/mcompile_test_out.kmx diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 1f7fa5ff26..ca4d66b352 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -113,7 +113,7 @@ KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap return Cap; } -// _S2 DESIGN NEEDED is this the right place to get dk from? if not where are they stored? +// _S2 TOP_3 is this the right place to get dk from? if not where are they stored? void create_DKTable(v_dw_2D & dk_ComposeTable) { //create a 2D-Vector which contains data for ALL existing deadkey combinations on a Linux Keyboard: //dk_ComposeTable[i][0] : First (e.g. dead_circumflex) @@ -410,7 +410,7 @@ void create_DKTable(v_dw_2D & dk_ComposeTable) { line = createLine(L"dead_acute", L"space", 0x0027, L"APOSTROPHE"); dk_ComposeTable.push_back(line); line.clear(); - /*line = createLine(L"dead_acute", L"space", 0x00B4, L"ACUTE_ACCENT"); // _S2 ToDo remove - just for testing + /*line = createLine(L"dead_acute", L"space", 0x00B4, L"ACUTE_ACCENT"); // _S2 TOP_3 ToDo remove - just for testing dk_ComposeTable.push_back(line); line.clear();*/ line = createLine(L"dead_grave", L"space", 0x0060, L"GRAVE_ACCENT"); diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 36bcd2d0ac..bba20dec6a 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -599,7 +599,7 @@ KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying(KMX_DWORD keycode) { return 0; } -// _S2 ToDo only use one +// _S2 TOP_6 ToDo only use one std::wstring CodePointToWString(unsigned int codepoint) { std::wstring str; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 27274e3743..cb98927fa1 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -68,7 +68,7 @@ static KMX_DWORD returnIfCharInvalid = 0; static KMX_DWORD keycode_max = 94; static KMX_DWORD deadkey_min = 0xfe50; //static KMX_DWORD deadkey_max = 0xfe93; -static KMX_DWORD deadkey_max = 0xfe52; // _S2 TODO This has to go! my test: to only return 3 dk +static KMX_DWORD deadkey_max = 0xfe52; // _S2 TOP_6 TODO This has to go! my test: to only return 3 dk int map_VKShiftState_to_LinModifier(int VKShiftState); diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index 91bff6ec96..963a343f1d 100755 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -57,7 +57,7 @@ typedef KMX_BYTE* PKMX_BYTE; typedef KMX_DWORD* PKMX_DWORD; typedef int BOOL; -typedef void* KMX_HKL; // _S2 QUESTION what is the equivalent to HKL and do I need it?? I assume a void* +typedef void* KMX_HKL; // _S2 TOP_4 QUESTION what is the equivalent to HKL and do I need it?? I assume a void* #ifndef FALSE diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 44ee1a2e22..510c0a2e28 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -109,7 +109,7 @@ int KMX_DeadKeyMap(int index, std::vector *deadkeys, int deadkeyBase, class KMX_VirtualKey { private: - KMX_HKL m_hkl; // _S2 QUESTION do I need this and is void* OK to assume? If I remove this, will there be changes in Data-Vectors? + KMX_HKL m_hkl; // _S2 TOP_4 QUESTION do I need this and is void* OK to assume? If I remove this, will there be changes in Data-Vectors? UINT m_vk; UINT m_sc; bool m_rgfDeadKey[10][2]; @@ -154,8 +154,8 @@ public: this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; } -// _S2 ToDo delete later - /* bool KMX_IsSGCAPS() { +// _S2 TOP_1 ToDo delete later + bool KMX_IsSGCAPS() { std::wstring stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß std::wstring stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? std::wstring stCaps = this->KMX_GetShiftState(Base, true); // 0,1 A 4 ẞ @@ -201,7 +201,7 @@ public: (stBase.compare(stShift) != 0) && (stShift.compare(stCaps) == 0)); } -*/ + bool KMX_IsEmpty() { for (int i = 0; i < 10; i++) { @@ -226,7 +226,7 @@ public: int nkeys = 0; // Get the CAPSLOCK value - //_S2 INFO not used in original code; can be deleted + //_S2 TOP_6 INFO not used in original code; can be deleted /*int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | (this->KMX_IsSGCAPS() ? 2 : 0) | @@ -263,14 +263,14 @@ public: bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,v_dw_3D &All_Vector, GdkKeymap *keymap) { // I4552 // Get the CAPSLOCK value - // _S2 TODO delete later - /* int capslock = + // _S2 TOP_1 TODO delete later + int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | (this->KMX_IsSGCAPS() ? 2 : 0) | (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0);*/ - // _S2 replaced - int capslock=1; + (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + // _S2 TOP_1 -> we need capslock calculation + //capslock=1; for (int ss = 0; ss <= MaxShiftState; ss++) { if (ss == Menu || ss == ShftMenu) { @@ -289,8 +289,9 @@ public: key->dpContext = new KMX_WCHAR[1]; *key->dpContext = 0; + //key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); - // we already use VK_US so no need to convert it + // we already use VK_US so no need to convert it as we do on windows key->Key = this->VK(); key->Line = 0; @@ -326,6 +327,8 @@ public: key->Line = 0; key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); + //wprintf(L"capslock = %i, shiftflgs= %i \n", capslock, key->ShiftFlags ); + key->dpContext = new KMX_WCHAR; *key->dpContext = 0; p = key->dpOutput = new KMX_WCHAR[st.size() + 1]; @@ -366,7 +369,7 @@ public: return (Get_XxxxVk() == 0 ? ShftMenuCtrl : ShftXxxx); } - // _S2 ToDo Do we need one/none? + // _S2 TOP_6 ToDo Do we need one/none? bool KMX_IsControlChar(wchar_t ch) { return (ch < 0x0020) || (ch >= 0x007F && ch <= 0x009F); } @@ -434,7 +437,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, continue; } - //_S2 TODO to compare win-lin kmn-files skip ss6+7; MUST BE removed later!!!! + //_S2 TOP_6 TODO to compare win-lin kmn-files skip ss6+7; MUST BE removed later!!!! if(ss == MenuCtrl|| ss == ShftMenuCtrl) { continue; } @@ -446,7 +449,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, if(rc > 0) { if(*sbBuffer == 0) { - //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); // _S2 INFO + //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); // _S2 TOP_6 INFO rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps)); } else { @@ -455,13 +458,13 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, } sbBuffer[rc] = 0; //rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps==0)); - rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps)); //_S2 INFO + rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps)); //_S2 TOP_6 INFO } } else if(rc < 0) { sbBuffer[2] = 0; //rgKey[iKey]->SetShiftState(ss, sbBuffer, true, (caps == 0)); - rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); //_S2 INFO + rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); //_S2 TOP_6 INFO refine_alDead(sbBuffer[0], alDead, &alDead_cpl); } @@ -524,6 +527,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // // Fill in the new rules // + // _S2 group 2 using keys for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { if(rgKey[iKey]->KMX_LayoutRow(loader.KMX_MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 @@ -537,6 +541,10 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // // Add nomatch control to each terminating 'using keys' group // I4550 // + // _adds + [CTRL NCAPS K_QUOTE] > use(group2) c line(0) + // + [CTRL CAPS K_QUOTE] > use(group2) c line(0) + //nomatch > use(group2) + // after dk-section LPKMX_GROUP gp2 = kp->dpGroupArray; for(UINT i = 0; i < kp->cxGroupArray - 1; i++, gp2++) { if(gp2->fUsingKeys && gp2->dpNoMatch == NULL) { @@ -553,7 +561,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, UINT j; LPKMX_KEY kkp; for(j = 0, kkp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kkp++) { - // _S2 0110 1111 + // _S2 TOP_2 0110 1111 if((kkp->ShiftFlags & (K_CTRLFLAG|K_ALTFLAG|LCTRLFLAG|LALTFLAG|RCTRLFLAG|RALTFLAG)) != 0) { gp2->cxKeyArray++; LPKMX_KEY kkp2 = new KMX_KEY[gp2->cxKeyArray]; @@ -578,6 +586,9 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // If we have deadkeys, then add a new group to translate the deadkeys per the deadkey tables // We only do this if not in deadkey conversion mode // + // _S2 writes âêîôû^for dk at the beginning + // _S2 writes deadkey(1) at the end + if (alDead.size() > 0 && !bDeadkeyConversion) { // I4552 kp->cxGroupArray++; @@ -647,6 +658,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, kkp++; } } + return true; } diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 72798b781e..9669f88f2a 100755 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -478,7 +478,7 @@ KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz){ return TRUE; } -// _S2 TODO use incxstr from elsewhere +// _S2 TOP_6 TODO use incxstr from elsewhere PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p) { if (*p == 0) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index fecc1cac98..f7f058ea0c 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -129,7 +129,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ } #endif - //DeleteReallocatedPointers(kmxfile); :TODO // _S2 not my ToDo :-) + //DeleteReallocatedPointers(kmxfile); :TODO // _S2 TOP_6 not my ToDo :-) wprintf(L"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm end\n"); delete kmxfile; return 0; @@ -206,7 +206,7 @@ void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { } void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { -// _S2 INFO this produces a different output due to different layouts for Lin<-> win ( for the same language!!) +// _S2 TOP_2 INFO this produces a different output due to different layouts for Lin<-> win ( for the same language!!) if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. @@ -436,7 +436,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg ch = DeadKey; } } - +// _S2 group1 using keys here switch(ch) { case 0x0000: break; case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap , dk_Table); break; @@ -447,6 +447,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg KMX_ReportUnconvertedKeyboardRules(kbd); +// _S2 add everything after dk-section group1 if(!KMX_ImportRules(kbd, All_Vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 return FALSE; } From 754f13fa226056cde5ce84475720b8455cb40131 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 27 Feb 2024 16:28:24 +0100 Subject: [PATCH 220/327] feat(linux): mcompile-dkcomments on capslock --- linux/mcompile/keymap/README.md | 5 ++--- linux/mcompile/keymap/mc_import_rules.cpp | 9 ++++----- linux/mcompile/keymap/mcompile.cpp | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index 317d8c7ca5..b12d639014 100755 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -12,10 +12,9 @@ _S2 TODO Check/find use of wchar_t/wstring and replace with char16_t/u16string _S2 TODO check call by reference/value _S2 TODO what is wrong with kp->dpBitmapOffset/BitmapSize ? _s2 INFO idee spanish keyboard has dk on altgr !! +_S2 TODO new Problem: RALT-dk(4): Why do we havea RALT in dk 4? It makes sense but how do we handle this?? -_S2 ... - -_S2 TOP_1 NCAPS/capslock +_S2 TOP_1 NCAPS/capslock-> we need capslock-equation. ---> new Problem: RALT-dk(4) RALT+Ä _S2 TOP_2 Shiftflags _S2 TOP_3 dk-table from file->from functions _S2 TOP_4 HKL diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 510c0a2e28..6d73a353d7 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -154,7 +154,7 @@ public: this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; } -// _S2 TOP_1 ToDo delete later +// _S2 TOP_1 ToDo delete comments later bool KMX_IsSGCAPS() { std::wstring stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß std::wstring stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? @@ -263,13 +263,12 @@ public: bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,v_dw_3D &All_Vector, GdkKeymap *keymap) { // I4552 // Get the CAPSLOCK value - // _S2 TOP_1 TODO delete later int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | (this->KMX_IsSGCAPS() ? 2 : 0) | (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); - // _S2 TOP_1 -> we need capslock calculation + // _S2 TOP_1 -> we need this capslock calculation //capslock=1; for (int ss = 0; ss <= MaxShiftState; ss++) { @@ -527,7 +526,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // // Fill in the new rules // - // _S2 group 2 using keys + // _S2 fills group 2 using keys for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { if(rgKey[iKey]->KMX_LayoutRow(loader.KMX_MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 @@ -586,7 +585,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // If we have deadkeys, then add a new group to translate the deadkeys per the deadkey tables // We only do this if not in deadkey conversion mode // - // _S2 writes âêîôû^for dk at the beginning + // _S2 writes âêîôû^for dk at the beginning + // _S2 writes deadkey(1) at the end diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index f7f058ea0c..acd51c9d67 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -436,7 +436,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg ch = DeadKey; } } -// _S2 group1 using keys here +// _S2 group1 writes using keys here switch(ch) { case 0x0000: break; case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap , dk_Table); break; From 08085e34a05a07cae4460f2184565e1c8725508f Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 28 Feb 2024 15:38:27 +0100 Subject: [PATCH 221/327] feat(linux): mcompile-dk comment out some #includes that are not needed --- linux/mcompile/keymap/README.md | 6 +++--- linux/mcompile/keymap/deadkey.cpp | 4 ++-- linux/mcompile/keymap/keymap.h | 2 +- linux/mcompile/keymap/kmx_file.h | 2 +- linux/mcompile/keymap/mc_import_rules.cpp | 4 ++-- linux/mcompile/keymap/mc_kmxfile.cpp | 3 +-- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index b12d639014..25096ddf80 100755 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -14,11 +14,11 @@ _S2 TODO what is wrong with kp->dpBitmapOffset/BitmapSize ? _s2 INFO idee spanish keyboard has dk on altgr !! _S2 TODO new Problem: RALT-dk(4): Why do we havea RALT in dk 4? It makes sense but how do we handle this?? -_S2 TOP_1 NCAPS/capslock-> we need capslock-equation. ---> new Problem: RALT-dk(4) RALT+Ä +_ S2 TOP_1 NCAPS/capslock-> we need capslock-equation. ---> new Problem: RALT-dk(4) RALT+Ä _S2 TOP_2 Shiftflags -_S2 TOP_3 dk-table from file->from functions + _S2 TOP_3 dk-table from file->from functions -> ask EB, MD in TX to setup gtk _S2 TOP_4 HKL -_S2 TOP_5 use files/functions from other places + _S2 TOP_5 use files/functions from other places _S2 TOP_6 remaining diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index ca4d66b352..9c273d9c83 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -54,7 +54,7 @@ bool found_dk_inVector(KMX_WCHAR dk, std::vector &dkVec) { return false; } -void sort_alDead(std::vector &small_Vec, std::vector *p_All_Vec) { +/*void sort_alDead(std::vector &small_Vec, std::vector *p_All_Vec) { std::vector small_sorted; int Vsmall_size; int i = 0; @@ -75,7 +75,7 @@ void sort_alDead(std::vector &small_Vec, std::vector *p_All_ } while ((i < (int) (*p_All_Vec).size()) && (Vsmall_size>0)); small_Vec = small_sorted; } - +*/ bool find_dk_combinations_for_specific_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &dk_SingleTable, KMX_DWORD dk) { v_dw_1D line; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index cb98927fa1..401a697ebc 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -14,7 +14,7 @@ #include #include #include -#include "kmx_file.h" +//#include "kmx_file.h" #include "u16.h" diff --git a/linux/mcompile/keymap/kmx_file.h b/linux/mcompile/keymap/kmx_file.h index 1cf49c61b5..51e051db11 100755 --- a/linux/mcompile/keymap/kmx_file.h +++ b/linux/mcompile/keymap/kmx_file.h @@ -7,7 +7,7 @@ #ifndef KMX_FILE_H #define KMX_FILE_H -#include +//#include #define UNREFERENCED_PARAMETER(P) (P) #define TRUNCATE ((size_t)-1) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 6d73a353d7..b9b230b210 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -22,7 +22,7 @@ #include #include #include -#include "km_types.h" +//#include "km_types.h" #include "mc_kmxfile.h" #include "keymap.h" @@ -154,7 +154,7 @@ public: this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; } -// _S2 TOP_1 ToDo delete comments later +// _S2 TOP_6 ToDo delete comments later bool KMX_IsSGCAPS() { std::wstring stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß std::wstring stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 9669f88f2a..2a2b5e070b 100755 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -1,5 +1,5 @@ #include "mc_kmxfile.h" -#include "u16.h" +//#include "u16.h" #include #define CERR_None 0x00000000 @@ -478,7 +478,6 @@ KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz){ return TRUE; } -// _S2 TOP_6 TODO use incxstr from elsewhere PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p) { if (*p == 0) From f04b1df60e630ecf78fbd7e9d4ee0001e05f37c2 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 28 Feb 2024 15:45:14 +0100 Subject: [PATCH 222/327] feat(linux): mcompile-dk disable KMX_VirtualKey(KMX_HKL hkl,UINT virtualKey) --- linux/mcompile/keymap/mc_import_rules.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index b9b230b210..c790768812 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -117,12 +117,13 @@ private: public: - KMX_VirtualKey(KMX_HKL hkl,UINT virtualKey) { + // _S2 TODO I assume we do not need those... + /*KMX_VirtualKey(KMX_HKL hkl,UINT virtualKey) { this->m_sc = KMX_get_KeyCodeUnderlying_From_VKUS(virtualKey); this->m_hkl = hkl; this->m_vk = virtualKey; memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); - } + }*/ KMX_VirtualKey(UINT scanCode, KMX_HKL hkl) { this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying(scanCode); @@ -420,9 +421,10 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, } } - rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE); + // _S2 TODO I assume we do not need those... + /*rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE); rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL); - rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL); + rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL);*/ // in this part we skip shiftstates 4, 5, 8, 9 for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { From afb391fea768df62cfd77ff5b399c88523549b21 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 28 Feb 2024 16:27:59 +0100 Subject: [PATCH 223/327] feat(linux): mcompile-dk disable use of HKL --- linux/mcompile/keymap/README.md | 2 +- linux/mcompile/keymap/km_types.h | 2 +- linux/mcompile/keymap/mc_import_rules.cpp | 14 ++++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index 25096ddf80..a621adda75 100755 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -17,7 +17,7 @@ _S2 TODO new Problem: RALT-dk(4): Why do we havea RALT in dk 4? It makes sense b _ S2 TOP_1 NCAPS/capslock-> we need capslock-equation. ---> new Problem: RALT-dk(4) RALT+Ä _S2 TOP_2 Shiftflags _S2 TOP_3 dk-table from file->from functions -> ask EB, MD in TX to setup gtk -_S2 TOP_4 HKL + _S2 TOP_4 HKL _S2 TOP_5 use files/functions from other places _S2 TOP_6 remaining diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index 963a343f1d..b92862602d 100755 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -57,7 +57,7 @@ typedef KMX_BYTE* PKMX_BYTE; typedef KMX_DWORD* PKMX_DWORD; typedef int BOOL; -typedef void* KMX_HKL; // _S2 TOP_4 QUESTION what is the equivalent to HKL and do I need it?? I assume a void* +//typedef void* KMX_HKL; // _S2 QUESTION what is the equivalent to HKL and do I need it?? I assume a void* #ifndef FALSE diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index c790768812..9339cc5d8e 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -109,7 +109,7 @@ int KMX_DeadKeyMap(int index, std::vector *deadkeys, int deadkeyBase, class KMX_VirtualKey { private: - KMX_HKL m_hkl; // _S2 TOP_4 QUESTION do I need this and is void* OK to assume? If I remove this, will there be changes in Data-Vectors? + //KMX_HKL m_hkl; // _S2 QUESTION do I need this and is void* OK to assume? If I remove this, will there be changes in Data-Vectors? UINT m_vk; UINT m_sc; bool m_rgfDeadKey[10][2]; @@ -125,9 +125,10 @@ public: memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); }*/ - KMX_VirtualKey(UINT scanCode, KMX_HKL hkl) { + //KMX_VirtualKey(UINT scanCode, KMX_HKL hkl) { + KMX_VirtualKey(UINT scanCode) { this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying(scanCode); - this->m_hkl = hkl; + //this->m_hkl = hkl; this->m_sc = scanCode; memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); } @@ -269,7 +270,7 @@ public: (this->KMX_IsSGCAPS() ? 2 : 0) | (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); - // _S2 TOP_1 -> we need this capslock calculation + // _S2 we need this capslock calculation //capslock=1; for (int ss = 0; ss <= MaxShiftState; ss++) { @@ -392,7 +393,7 @@ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 KMX_Loader loader; - KMX_HKL hkl = NULL; + //KMX_HKL hkl = NULL; BYTE lpKeyState[256];// = new KeysEx[256]; std::vector rgKey; //= new VirtualKey[256]; @@ -412,7 +413,8 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // Linux cannot get a VK for the underling Keyboard // this "connection" is possible only when using All_Vector - KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl); + //KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl); + KMX_VirtualKey *key = new KMX_VirtualKey(sc); if((key->VK() != 0) ) { rgKey[key->VK()] = key; From 5d43f0a24e4dceefd09383c067e4ffed47e03365 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 29 Feb 2024 17:58:05 +0100 Subject: [PATCH 224/327] feat(linux): mcompile-dk use const wchar_t* in LogError --- linux/mcompile/keymap/README.md | 2 -- linux/mcompile/keymap/keymap.cpp | 4 +--- linux/mcompile/keymap/mc_import_rules.cpp | 11 +++-------- linux/mcompile/keymap/mcompile.cpp | 6 +++--- linux/mcompile/keymap/mcompile.h | 2 +- 5 files changed, 8 insertions(+), 17 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index a621adda75..6fac301e91 100755 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -6,8 +6,6 @@ Sample program that reads US basic keyboard and compares to key value group # Keymap -__S2 TODO check if I can use files from some other keyman path instead of a copy here ( e.g. filesystem.h exists elsewhere); where can I use incxstr from -_S2 TODO Do I need HKL for Linux / can I just use a void* or remove HKL ??, typeddef of KMX_HKL - can I delete all m_hkl from classes? _S2 TODO Check/find use of wchar_t/wstring and replace with char16_t/u16string _S2 TODO check call by reference/value _S2 TODO what is wrong with kp->dpBitmapOffset/BitmapSize ? diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index bba20dec6a..53665137f9 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -1,5 +1,4 @@ #include "keymap.h" - #include // unmodified, shift, RALT, shift+RALT @@ -530,7 +529,6 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, UIN GdkKeymapKey *maps; guint *keyvals; gint count; - KMX_DWORD deadkey=0; PKMX_WCHAR dky=NULL; @@ -579,7 +577,7 @@ KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap *keymap, v_dw_3D &A //Find KC_underlying character for( int i=0; i< (int)All_Vector[1].size()-1 ;i++) { for( int j=1; j< (int)All_Vector[1][0].size();j++) { - if ( ( All_Vector[1][i][j] == *ws.c_str() ) ) { + if ( ( All_Vector[1][i][j] == (KMX_DWORD) *ws.c_str() ) ) { KC_underlying = All_Vector[1][i][0]; return KC_underlying; } diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 9339cc5d8e..6a7378facd 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -290,7 +290,6 @@ public: key->dpContext = new KMX_WCHAR[1]; *key->dpContext = 0; - //key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); // we already use VK_US so no need to convert it as we do on windows key->Key = this->VK(); @@ -328,8 +327,6 @@ public: key->Line = 0; key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); - //wprintf(L"capslock = %i, shiftflgs= %i \n", capslock, key->ShiftFlags ); - key->dpContext = new KMX_WCHAR; *key->dpContext = 0; p = key->dpOutput = new KMX_WCHAR[st.size() + 1]; @@ -395,7 +392,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, //KMX_HKL hkl = NULL; - BYTE lpKeyState[256];// = new KeysEx[256]; std::vector rgKey; //= new VirtualKey[256]; std::vector alDead; std::vector alDead_cpl = create_alDead(); @@ -452,7 +448,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, if(rc > 0) { if(*sbBuffer == 0) { - //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); // _S2 TOP_6 INFO + //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); // different to windows since behavior on Linux is different rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps)); } else { @@ -461,13 +457,13 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, } sbBuffer[rc] = 0; //rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps==0)); - rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps)); //_S2 TOP_6 INFO + rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps)); // different to windows since behavior on Linux is different } } else if(rc < 0) { sbBuffer[2] = 0; //rgKey[iKey]->SetShiftState(ss, sbBuffer, true, (caps == 0)); - rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); //_S2 TOP_6 INFO + rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); // different to windows since behavior on Linux is different refine_alDead(sbBuffer[0], alDead, &alDead_cpl); } @@ -564,7 +560,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, UINT j; LPKMX_KEY kkp; for(j = 0, kkp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kkp++) { - // _S2 TOP_2 0110 1111 if((kkp->ShiftFlags & (K_CTRLFLAG|K_ALTFLAG|LCTRLFLAG|LALTFLAG|RCTRLFLAG|RALTFLAG)) != 0) { gp2->cxKeyArray++; LPKMX_KEY kkp2 = new KMX_KEY[gp2->cxKeyArray]; diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index acd51c9d67..27f6026fd0 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -476,10 +476,10 @@ int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, return (p-OutputPairs); } -void KMX_LogError(PWCHAR fmt, ...) { +void KMX_LogError(const wchar_t* fmt, ...) { WCHAR fmtbuf[256]; - wchar_t *end = L"\0"; - wchar_t *nl = L"\n"; + const wchar_t* end = L"\0"; + const wchar_t* nl = L"\n"; va_list vars; int j=0; diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index b352352219..a00c39afb4 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -38,6 +38,6 @@ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap); -void KMX_LogError(PWCHAR fmt, ...) ; +void KMX_LogError(const wchar_t* fmt, ...); #endif /*MCOMPILE_H*/ From cc7997e17fd2e54a422b3da0548c19910392f16e Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 1 Mar 2024 15:59:57 +0100 Subject: [PATCH 225/327] feat(linux): mcompile-dk start replace wchar_t --- .gitignore | 2 ++ linux/mcompile/keymap/deadkey.h | 1 + linux/mcompile/keymap/keymap.h | 1 + 3 files changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 6b9eb20370..6a40380344 100644 --- a/.gitignore +++ b/.gitignore @@ -204,3 +204,5 @@ lcov.info /linux/mcompile/keymap/*.kmx + +/GTK_PLAYGROUND \ No newline at end of file diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index 18805734df..27df59b012 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -9,6 +9,7 @@ // create a vector for a dk combination ( ` + a -> à ) v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult); +v_dw_1D createLine(std::string first, std::string second, KMX_DWORD number, std::string nameresult); // create a 2D-vector of all dk combinations ( ` + a -> à ; ^ + a -> â ; `+ e -> è; ...) void create_DKTable(v_dw_2D & dk_ComposeTable); diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 401a697ebc..f9085651a8 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -74,6 +74,7 @@ int map_VKShiftState_to_LinModifier(int VKShiftState); // take a std::wstring (=contents of line symbols-file ) and returns the (int) value of the character KMX_DWORD convertNamesTo_DWORD_Value(std::wstring tok_wstr); +KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str); // create a Vector with all entries of both keymaps+ keymap int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap); From 901ff2bf68d12665ea8659761b4c1c76cd38e770 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 1 Mar 2024 17:17:23 +0100 Subject: [PATCH 226/327] feat(linux): mcompile-dk replace wchar_t create duplicate u16.functions (no implem. yet) --- linux/mcompile/keymap/README.md | 1 + linux/mcompile/keymap/deadkey.cpp | 389 +++++++++++++++++++++- linux/mcompile/keymap/deadkey.h | 2 +- linux/mcompile/keymap/keymap.cpp | 301 ++++++++++++++++- linux/mcompile/keymap/keymap.h | 5 +- linux/mcompile/keymap/mc_import_rules.cpp | 103 +++++- 6 files changed, 778 insertions(+), 23 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index 6fac301e91..f0d61f8dab 100755 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -18,6 +18,7 @@ _S2 TOP_2 Shiftflags _S2 TOP_4 HKL _S2 TOP_5 use files/functions from other places _S2 TOP_6 remaining +_S2 TOP_7 wchar_t->char16_t ./mcompile -d /Projects/keyman/keyman/linux/mcompile/keymap/mcompile_test.kmx bla.dll 0407 /Projects/keyman/keyman/linux/mcompile/keymap/mcompile_test_out.kmx diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 9c273d9c83..3d9633549f 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -1,6 +1,7 @@ #include "keymap.h" #include "deadkey.h" +// _S2 TOP_7 v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult) { v_dw_1D line; line.push_back(convertNamesTo_DWORD_Value(first)); @@ -10,6 +11,15 @@ v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, s return line; } +v_dw_1D createLine(std::string first, std::string second, KMX_DWORD number, std::string nameresult) { + v_dw_1D line; + line.push_back(convertNamesTo_DWORD_Value(first)); + line.push_back(convertNamesTo_DWORD_Value(second)); + //line.push_back(convertNamesTo_DWORD_Value(nameresult)); + line.push_back(number); + return line; +} + std::vector create_alDead() { std::vector alDead; v_dw_2D dk_ComposeTable; @@ -113,13 +123,390 @@ KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap return Cap; } -// _S2 TOP_3 is this the right place to get dk from? if not where are they stored? void create_DKTable(v_dw_2D & dk_ComposeTable) { //create a 2D-Vector which contains data for ALL existing deadkey combinations on a Linux Keyboard: //dk_ComposeTable[i][0] : First (e.g. dead_circumflex) //dk_ComposeTable[i][1] : Second (e.g. a) //dk_ComposeTable[i][3] : Unicode-Value (e.g. 0x00E2) + //values taken from: https://help.ubuntu.com/community/GtkDeadKeyTable#Accents + // _S2 Do we really want to use GTK instead of this function? + + v_dw_1D line; + + line = createLine("dead_circumflex", "a", 0x00E2, "small A with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "A", 0x00C2, "capital A with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "e", 0x00EA, "small E with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "E", 0x00CA, "capital E with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "i", 0x00EE, "small I with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "I", 0x00CE, "capital I with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "o", 0x00F4, "small O with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "O", 0x00D4, "capital O with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "u", 0x00FB, "small U with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "U", 0x00DB, "capital U with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_acute", "a", 0x00E1, "small A with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "A", 0x00C1, "capital A with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "c", 0x0107, "small C with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "C", 0x0106, "capital C with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "e", 0x00E9, "small E with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "E", 0x00C9, "capital E with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "i", 0x00ED, "small I with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "I", 0x00CD, "capital I with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "l", 0x013A, "small L with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "L", 0x0139, "capital L with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "n", 0x0144, "small N with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "N", 0x0143, "capital N with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "o", 0x00F3, "small O with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "O", 0x00D3, "capital O with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "r", 0x0155, "small R with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "R", 0x0154, "capital R with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "s", 0x015B, "small S with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "S", 0x015A, "capital S with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "u", 0x00FA, "small U with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "U", 0x00DA, "capital U with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "y", 0x00FD, "small Y with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "Y", 0x00DD, "capital Y with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "z", 0x017A, "small Z with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "Z", 0x0179, "capital Z with acute"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_grave", "a", 0x00E0, "small A with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_grave", "A", 0x00C0, "capital A with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_grave", "e", 0x00E8, "small E with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_grave", "E", 0x00C8, "capital E with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_grave", "i", 0x00EC, "small I with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_grave", "I", 0x00CC, "capital I with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_grave", "o", 0x00F2, "small O with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_grave", "O", 0x00D2, "capital O with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_grave", "u", 0x00F9, "small U with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_grave", "U", 0x00D9, "capital U with grave"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_tilde", "a", 0x00E3, "small A with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_tilde", "A", 0x00C3, "capital A with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_tilde", "i", 0x0129, "small I with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_tilde", "I", 0x0128, "capital I with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_tilde", "n", 0x00F1, "small N with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_tilde", "N", 0x00D1, "capital N with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_tilde", "o", 0x00F5, "small O with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_tilde", "O", 0x00D5, "capital O with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_tilde", "u", 0x0169, "small U with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_tilde", "U", 0x0168, "capital U with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_macron", "a", 0x0101, "small A with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_macron", "A", 0x0100, "capital A with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_macron", "e", 0x0113, "small E with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_macron", "E", 0x0112, "capital E with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_macron", "i", 0x012B, "small I with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_macron", "I", 0x012A, "capital I with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_macron", "o", 0x014D, "small O with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_macron", "O", 0x014C, "capital O with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_macron", "u", 0x016B, "small U with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_macron", "U", 0x016A, "capital U with macron"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_breve", "a", 0x0103, "small A with breve"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_breve", "A", 0x0102, "capital A with breve"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_breve", "g", 0x011F, "small G with breve"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_breve", "G", 0x011E, "capital G with breve"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_abovedot", "e", 0x0117, "small E with dot above"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovedot", "E", 0x0116, "capital E with dot above"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovedot", "i", 0x0131, "small DOTLESS_I"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovedot", "I", 0x0130, "capital I with dot above"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovedot", "z", 0x017C, "small Z with dot above"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovedot", "Z", 0x017B, "capital Z with dot above"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_diaeresis", "a", 0x00E4, "small A with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "A", 0x00C4, "capital A with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "e", 0x00EB, "small E with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "E", 0x00CB, "capital E with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "i", 0x00EF, "small I with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "I", 0x00CF, "capital I with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "o", 0x00F6, "small O with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "O", 0x00D6, "capital O with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "u", 0x00FC, "small U with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "U", 0x00DC, "capital U with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "y", 0x00FF, "small Y with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "Y", 0x0178, "capital Y with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_abovering", "a", 0x00E5, "small A with ring above"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovering", "A", 0x00C5, "capital A with ring above"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovering", "u", 0x016F, "small U with ring above"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovering", "U", 0x016E, "capital U with ring above"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_doubleacute", "o", 0x0151, "small O with double acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_doubleacute", "O", 0x0150, "capital O with double acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_doubleacute", "u", 0x0171, "small U with double acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_doubleacute", "U", 0x0170, "capital U with double acute"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_caron", "c", 0x010D, "small C with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "C", 0x010C, "capital C with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "d", 0x010F, "small D with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "D", 0x010E, "capital D with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "e", 0x011B, "small E with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "E", 0x011A, "capital E with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "l", 0x013E, "small L with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "L", 0x013D, "capital L with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "n", 0x0148, "small N with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "N", 0x0147, "capital N with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "r", 0x0159, "small R with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "R", 0x0158, "capital R with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "s", 0x0161, "small S with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "S", 0x0160, "capital S with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "t", 0x0165, "small T with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "T", 0x0164, "capital T with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "z", 0x017E, "small Z with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "Z", 0x017D, "capital Z with caron"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_cedilla", "c", 0x00E7, "small C with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "C", 0x00C7, "capital C with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "g", 0x0123, "small G with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "G", 0x0122, "capital G with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "k", 0x0137, "small K with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "K", 0x0136, "capital K with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "l", 0x013C, "small L with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "L", 0x013B, "capital L with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "n", 0x0146, "small N with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "N", 0x0145, "capital N with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "r", 0x0157, "small R with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "R", 0x0156, "capital R with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "s", 0x015F, "small S with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "S", 0x015E, "capital S with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_ogonek", "a", 0x0105, "small A with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_ogonek", "A", 0x0104, "capital A with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_ogonek", "e", 0x0119, "small E with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_ogonek", "E", 0x0118, "capital E with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_ogonek", "i", 0x012F, "small I with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_ogonek", "I", 0x012E, "capital I with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_ogonek", "u", 0x0173, "small U with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_ogonek", "U", 0x0172, "capital U with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_circumflex", "space", 0x005E, "CIRCUMFLEX_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_acute", "space", 0x0027, "APOSTROPHE"); + dk_ComposeTable.push_back(line); line.clear(); + /*line = createLine("dead_acute", "space", 0x00B4, "ACUTE_ACCENT"); // _S2 TOP_3 ToDo remove - just for testing + dk_ComposeTable.push_back(line); line.clear();*/ + + line = createLine("dead_grave", "space", 0x0060, "GRAVE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_breve", "space", 0x02D8, "BREVE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovedot", "space", 0x02D9, "DOT_ABOVE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovering", "space", 0x02DA, "RING_ABOVE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_doubleacute", "space", 0x02DD, "DOUBLE_ACUTE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "space", 0x02C7, "CARON"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "space", 0x00B8, "CEDILLA"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_ogonek", "space", 0x02DB, "OGONEK"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_tilde", "space", 0x007E, "TILDE"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_breve", "dead_breve", 0x02D8, "BREVE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovedot", "abovedot", 0x02D9, "DOT_ABOVE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovedot", "dead_abovedot", 0x02D9, "DOT_ABOVE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovering", "dead_abovering", 0x02DA, "RING_ABOVE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "apostrophe", 0x00B4, "ACUTE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "acute", 0x00B4, "ACUTE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "dead_acute", 0x00B4, "ACUTE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_doubleacute", "dead_doubleacute", 0x02DD, "DOUBLE_ACUTE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "caron", 0x02C7, "CARON"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "dead_caron", 0x02C7, "CARON"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "comma", 0x00B8, "CEDILLA"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "cedilla", 0x00B8, "CEDILLA"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "dead_cedilla", 0x00B8, "CEDILLA"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "minus", 0x00AF, "MACRON"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "asciicircum", 0x005E, "CIRCUMFLEX_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "underscore", 0x00AF, "MACRON"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "dead_circumflex", 0x005E, "CIRCUMFLEX_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "quotedbl", 0x00A8, "DIAERESIS"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "diaeresis", 0x00A8, "DIAERESIS"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "dead_diaeresis", 0x00A8, "DIAERESIS"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_grave", "grave", 0x0060, "GRAVE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_grave", "dead_grave", 0x0060, "GRAVE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_macron", "macron", 0x00AF, "MACRON"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_macron", "dead_macron", 0x00AF, "MACRON"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_ogonek", "ogonek", 0x02DB, "OGONEK"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_ogonek", "dead_ogonek", 0x02DB, "OGONEK"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_tilde", "asciitilde", 0x007E, "TILDE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_tilde", "dead_tilde", 0x007E, "TILDE"); + dk_ComposeTable.push_back(line); line.clear(); +} + +// _S2 TOP_3 is this the right place to get dk from? if not where are they stored? +void create_DKTable_old(v_dw_2D & dk_ComposeTable) { + //create a 2D-Vector which contains data for ALL existing deadkey combinations on a Linux Keyboard: + //dk_ComposeTable[i][0] : First (e.g. dead_circumflex) + //dk_ComposeTable[i][1] : Second (e.g. a) + //dk_ComposeTable[i][3] : Unicode-Value (e.g. 0x00E2) + //values taken from: https://help.ubuntu.com/community/GtkDeadKeyTable#Latin v_dw_1D line; diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index 27df59b012..611c862c6f 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -6,7 +6,7 @@ #include #include "mc_import_rules.h" - +// _S2 TOP_7 // create a vector for a dk combination ( ` + a -> à ) v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult); v_dw_1D createLine(std::string first, std::string second, KMX_DWORD number, std::string nameresult); diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 53665137f9..ba3765e2f3 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -10,6 +10,7 @@ int map_VKShiftState_to_LinModifier(int VKShiftState) { else return VKShiftState; } +// _S2 TOP_7 KMX_DWORD convertNamesTo_DWORD_Value(std::wstring tok_wstr) { // more on https://manpages.ubuntu.com/manpages/jammy/man3/keysyms.3tk.html std::map first; @@ -79,6 +80,286 @@ KMX_DWORD convertNamesTo_DWORD_Value(std::wstring tok_wstr) { } return returnIfCharInvalid; } +KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str) { + // more on https://manpages.ubuntu.com/manpages/jammy/man3/keysyms.3tk.html + std::map first; + + first["ampersand"] = 38; + first["apostrophe"] = 39; + first["asciicircum"] = 136; + first["asciitilde"] = 126; + first["asterisk"] = 42; + first["at"] = 64; + first["backslash"] = 92; + first["BackSpace"] = 65288; + first["bar"] = 124; + first["braceleft"] = 123; + first["braceright"] = 125; + first["bracketleft"] = 91; + first["bracketright"] = 93; + first["colon"] = 58; + first["comma"] = 44; + first["diaeresis"] = 168; + first["dollar"] = 36; + first["equal"] = 61; + first["exclam"] = 33; + first["grave"] = 96; + first["greater"] = 62; + first["less"] = 60; + first["minus"] = 45; + first["numbersign"] = 35; + first["parenleft"] = 40; + first["parenright"] = 41; + first["percent"] = 37; + first["period"] = 46; + first["plus"] = 43; + first["question"] = 63; + first["quotedbl"] = 34; + first["semicolon"] = 59; + first["slash"] = 47; + first["space"] = 32; + first["ssharp"] = 223; + first["underscore"] = 95; + + + first["nobreakspace"] = 160; + first["exclamdown"] = 161; + first["cent"] = 162; + first["sterling"] = 163; + first["currency"] = 164; + first["yen"] = 165; + first["brokenbar"] = 166; + first["section"] = 167; + first["copyright"] = 169; + first["ordfeminine"] = 170; + first["guillemotleft"] = 171; + first["notsign"] = 172; + first["hyphen"] = 173; + first["registered"] = 174; + first["macron"] = 175; + first["degree"] = 176; + first["plusminus"] = 177; + first["twosuperior"] = 178; + first["threesuperior"] = 179; + first["acute"] = 180; + first["mu"] = 181; + first["paragraph"] = 182; + first["periodcentered"] = 183; + first["cedilla"] = 184; + first["onesuperior"] = 185; + first["masculine"] = 186; + first["guillemotright"] = 187; + first["onequarter"] = 188; + first["onehalf"] = 189; + first["threequarters"] = 190; + first["questiondown"] = 191; + first["Agrave"] = 192; + first["Aacute"] = 193; + first["Acircumflex"] = 194; + first["Atilde"] = 195; + first["Adiaeresis"] = 196; + first["Aring"] = 197; + first["AE"] = 198; + first["Ccedilla"] = 199; + first["Egrave"] = 200; + first["Eacute"] = 201; + first["Ecircumflex"] = 202; + first["Ediaeresis"] = 203; + first["Igrave"] = 204; + first["Iacute"] = 205; + first["Icircumflex"] = 206; + first["Idiaeresis"] = 207; + first["ETH"] = 208; + first["Ntilde"] = 209; + first["Ograve"] = 210; + first["Oacute"] = 211; + first["Ocircumflex"] = 212; + first["Otilde"] = 213; + first["Odiaeresis"] = 214; + first["multiply"] = 215; + first["Oslash"] = 216; + first["Ugrave"] = 217; + first["Uacute"] = 218; + first["Ucircumflex"] = 219; + first["Udiaeresis"] = 220; + first["Yacute"] = 221; + first["THORN"] = 222; + first["agrave"] = 224; + first["aacute"] = 225; + first["acircumflex"] = 226; + first["atilde"] = 227; + first["adiaeresis"] = 228; + first["aring"] = 229; + first["ae"] = 230; + first["ccedilla"] = 231; + first["egrave"] = 232; + first["eacute"] = 233; + first["ecircumflex"] = 234; + first["ediaeresis"] = 235; + first["igrave"] = 236; + first["iacute"] = 237; + first["icircumflex"] = 238; + first["idiaeresis"] = 239; + first["eth"] = 240; + first["ntilde"] = 241; + first["ograve"] = 242; + first["oacute"] = 243; + first["ocircumflex"] = 244; + first["otilde"] = 245; + first["odiaeresis"] = 246; + first["division"] = 247; + first["oslash"] = 248; + first["ugrave"] = 249; + first["uacute"] = 250; + first["ucircumflex"] = 251; + first["udiaeresis"] = 252; + first["yacute"] = 253; + first["thorn"] = 254; + first["ydiaeresis"] = 255; + first["Aogonek"] = 417; + first["breve"] = 418; + first["Lstroke"] = 419; + first["Lcaron"] = 421; + first["Sacute"] = 422; + first["Scaron"] = 425; + first["Scedilla"] = 426; + first["Tcaron"] = 427; + first["Zacute"] = 428; + first["Zcaron"] = 430; + first["Zabovedot"] = 431; + first["aogonek"] = 433; + first["ogonek"] = 434; + first["lstroke"] = 435; + first["lcaron"] = 437; + first["sacute"] = 438; + first["caron"] = 439; + first["scaron"] = 441; + first["scedilla"] = 442; + first["tcaron"] = 443; + first["zacute"] = 444; + first["doubleacute"] = 445; + first["zcaron"] = 446; + first["zabovedot"] = 447; + first["Racute"] = 448; + first["Abreve"] = 451; + first["Lacute"] = 453; + first["Cacute"] = 454; + first["Ccaron"] = 456; + first["Eogonek"] = 458; + first["Ecaron"] = 460; + first["Dcaron"] = 463; + first["Dstroke"] = 464; + first["Nacute"] = 465; + first["Ncaron"] = 466; + first["Odoubleacute"] = 469; + first["Rcaron"] = 472; + first["Uring"] = 473; + first["Udoubleacute"] = 475; + first["Tcedilla"] = 478; + first["racute"] = 480; + first["abreve"] = 483; + first["lacute"] = 485; + first["cacute"] = 486; + first["ccaron"] = 488; + first["eogonek"] = 490; + first["ecaron"] = 492; + first["dcaron"] = 495; + first["dstroke"] = 496; + first["nacute"] = 497; + first["ncaron"] = 498; + first["odoubleacute"] = 501; + first["rcaron"] = 504; + first["uring"] = 505; + first["udoubleacute"] = 507; + first["tcedilla"] = 510; + first["abovedot"] = 511; + first["Hstroke"] = 673; + first["Hcircumflex"] = 678; + first["Iabovedot"] = 681; + first["Gbreve"] = 683; + first["Jcircumflex"] = 684; + first["hstroke"] = 689; + first["hcircumflex"] = 694; + first["idotless"] = 697; + first["gbreve"] = 699; + first["jcircumflex"] = 700; + first["Cabovedot"] = 709; + first["Ccircumflex"] = 710; + first["Gabovedot"] = 725; + first["Gcircumflex"] = 728; + first["Ubreve"] = 733; + first["Scircumflex"] = 734; + first["cabovedot"] = 741; + first["ccircumflex"] = 742; + first["gabovedot"] = 757; + first["gcircumflex"] = 760; + first["ubreve"] = 765; + first["scircumflex"] = 766; + first["kra"] = 930; + first["Rcedilla"] = 931; + first["Itilde"] = 933; + first["Lcedilla"] = 934; + first["Emacron"] = 938; + first["Gcedilla"] = 939; + first["Tslash"] = 940; + first["rcedilla"] = 947; + first["itilde"] = 949; + first["lcedilla"] = 950; + first["emacron"] = 954; + first["gcedilla"] = 955; + first["tslash"] = 956; + first["ENG"] = 957; + first["eng"] = 959; + first["Amacron"] = 960; + first["Iogonek"] = 967; + first["Eabovedot"] = 972; + first["Imacron"] = 975; + first["Ncedilla"] = 977; + first["Omacron"] = 978; + first["Kcedilla"] = 979; + first["Uogonek"] = 985; + first["Utilde"] = 989; + first["Umacron"] = 990; + first["amacron"] = 992; + first["iogonek"] = 999; + first["eabovedot"] = 1004; + first["imacron"] = 1007; + first["ncedilla"] = 1009; + first["omacron"] = 1010; + first["kcedilla"] = 1011; + first["uogonek"] = 1017; + first["utilde"] = 1021; + first["umacron"] = 1022; + first["overline"] = 1150; + + first["dead_abovedot"] = 729; + first["dead_abovering"] = 730; + first["dead_acute"] = 180; + first["dead_breve"] = 728; + first["dead_caron"] = 711; + first["dead_cedilla"] = 184; + first["dead_circumflex"] = 94; + first["dead_diaeresis"] = 168; + first["dead_doubleacute"] = 733; + first["dead_grave"] = 96; + first["dead_ogonek"] = 731; + first["dead_perispomeni"] = 126; + first["dead_tilde"] = 126; + + first["acute accent"] = 0xB4; + + if ( tok_str.size() == 1) { + return (KMX_DWORD) ( *tok_str.c_str() ); + } + else { + std::map ::iterator it; + for (it = first.begin(); it != first.end(); ++it) { + if (it->first == tok_str) + return it->second; + } + } + return returnIfCharInvalid; +} int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap) { // create a 3D-Vector which contains data of the US keyboard and the underlying Keyboard: @@ -279,7 +560,10 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { for ( int i = 1; i< (int) tokens.size();i++) { // replace a name with a single character ( a -> a ; equal -> = ) + // _S2 TOP_7 + //tokens_int = convertNamesTo_DWORD_Value(tokens[i]); tokens_int = convertNamesTo_DWORD_Value( wstring_from_string(tokens[i])); + tokens_dw.push_back(tokens_int); } @@ -367,7 +651,7 @@ bool IsKeymanUsedChar(int KV) { else return false; } - +// _S2 TOP_7 std::wstring convert_DeadkeyValues_ToWstr(int in) { if (in == 0 ) @@ -381,8 +665,9 @@ std::wstring convert_DeadkeyValues_ToWstr(int in) { if (in < (int) deadkey_min) { // no deadkey; no Unicode return std::wstring(1, in); } - - KMX_DWORD lname = convertNamesTo_DWORD_Value( wstring_from_string(long_name)); // 65106 => "dead_circumflex" => 94 => "^" +// _S2 TOP_7 + KMX_DWORD lname = convertNamesTo_DWORD_Value( long_name); // 65106 => "dead_circumflex" => 94 => "^" + //KMX_DWORD lname = convertNamesTo_DWORD_Value( wstring_from_string(long_name)); // 65106 => "dead_circumflex" => 94 => "^" if (lname != returnIfCharInvalid) { return std::wstring(1, lname ); @@ -569,15 +854,17 @@ KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(v_dw_3D & All_Vector, KMX_DWORD } return VK_US; } - +// _S2 TOP_7 KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap *keymap, v_dw_3D &All_Vector, KMX_DWORD KC_US, ShiftState ss, int caps) { KMX_DWORD KC_underlying; - std::wstring ws = convert_DeadkeyValues_ToWstr(KMX_get_KeyVal_From_KeyCode(keymap, KC_US, ss, caps)); + std::u16string u16str = convert_DeadkeyValues_To_U16str(KMX_get_KeyVal_From_KeyCode(keymap, KC_US, ss, caps)); + // std::wstring ws = convert_DeadkeyValues_ToWstr(KMX_get_KeyVal_From_KeyCode(keymap, KC_US, ss, caps)); //Find KC_underlying character for( int i=0; i< (int)All_Vector[1].size()-1 ;i++) { for( int j=1; j< (int)All_Vector[1][0].size();j++) { - if ( ( All_Vector[1][i][j] == (KMX_DWORD) *ws.c_str() ) ) { + //if ( ( All_Vector[1][i][j] == (KMX_DWORD) *ws.c_str() ) ) { + if ( ( All_Vector[1][i][j] == (KMX_DWORD) *u16str.c_str() ) ) { KC_underlying = All_Vector[1][i][0]; return KC_underlying; } @@ -597,7 +884,7 @@ KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying(KMX_DWORD keycode) { return 0; } -// _S2 TOP_6 ToDo only use one +// _S2 TOP_7 std::wstring CodePointToWString(unsigned int codepoint) { std::wstring str; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index f9085651a8..9436aba360 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -71,7 +71,7 @@ static KMX_DWORD deadkey_min = 0xfe50; static KMX_DWORD deadkey_max = 0xfe52; // _S2 TOP_6 TODO This has to go! my test: to only return 3 dk int map_VKShiftState_to_LinModifier(int VKShiftState); - +// _S2 TOP_7 // take a std::wstring (=contents of line symbols-file ) and returns the (int) value of the character KMX_DWORD convertNamesTo_DWORD_Value(std::wstring tok_wstr); KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str); @@ -503,7 +503,7 @@ const UINT ScanCodeToUSVirtualKey[128] = { bool IsKeymanUsedChar(int KV); //------------------------------ - +// _S2 TOP_7 // take deadkey-value (e.g.65106) and return wstring (e.g. '^' ) std::wstring convert_DeadkeyValues_ToWstr(int in); std::u16string convert_DeadkeyValues_To_U16str(int in); @@ -530,6 +530,7 @@ UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying(KMX_DWORD keycode); // convert codePoint to wstring +// _S2 TOP_7 std::wstring CodePointToWString(unsigned int codepoint); std::u16string CodePointToString_16(unsigned int codepoint); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 6a7378facd..a4903c642c 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -75,7 +75,7 @@ int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int if (!(keycode <= keycode_max)) return 0; - +// _S2 TOP_7 KMX_DWORD KeyVal= (KMX_DWORD) KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(shift_state_pos), caps); std::wstring str = convert_DeadkeyValues_ToWstr(KeyVal); pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(str).c_str(); @@ -114,6 +114,8 @@ private: UINT m_sc; bool m_rgfDeadKey[10][2]; std::wstring m_rgss[10][2]; + // _S2 TOP_7 + std::u16string m_rgss_16[10][2]; public: @@ -140,23 +142,31 @@ public: UINT SC() { return this->m_sc; } - +// _S2 TOP_7 std::wstring KMX_GetShiftState(ShiftState shiftState, bool capsLock) { return this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)]; } + std::u16string KMX_GetShiftState_16(ShiftState shiftState, bool capsLock) { + return this->m_rgss_16[(UINT)shiftState][(capsLock ? 1 : 0)]; + } - void KMX_SetShiftState(ShiftState shiftState, std::wstring value, bool isDeadKey, bool capsLock) { + /* void KMX_SetShiftState(ShiftState shiftState, std::wstring value, bool isDeadKey, bool capsLock) { this->m_rgfDeadKey[(UINT)shiftState][(capsLock ? 1 : 0)] = isDeadKey; this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; - } - + }*/ + // _S2 TOP_7 void KMX_SetShiftState(ShiftState shiftState, std::u16string value16, bool isDeadKey, bool capsLock) { std::wstring value = wstring_from_u16string(value16); this->m_rgfDeadKey[(UINT)shiftState][(capsLock ? 1 : 0)] = isDeadKey; this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; } + void KMX_SetShiftState_16(ShiftState shiftState, std::u16string value_16, bool isDeadKey, bool capsLock) { + std::u16string value = value_16; + this->m_rgfDeadKey[(UINT)shiftState][(capsLock ? 1 : 0)] = isDeadKey; + this->m_rgss_16[(UINT)shiftState][(capsLock ? 1 : 0)] = value; + } -// _S2 TOP_6 ToDo delete comments later +// _S2 TOP_7 bool KMX_IsSGCAPS() { std::wstring stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß std::wstring stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? @@ -170,7 +180,20 @@ public: (stBase.compare(stShiftCaps) != 0) && // stBase != stShiftCaps (stShift.compare(stShiftCaps) != 0))); // stShift!= stShiftCaps } - + bool KMX_IsSGCAPS_16() { + std::u16string stBase = this->KMX_GetShiftState_16(Base, false); // 0,0 a 4 ß + std::u16string stShift = this->KMX_GetShiftState_16(Shft, false); // 1,0 A $ ? + std::u16string stCaps = this->KMX_GetShiftState_16(Base, true); // 0,1 A 4 ẞ + std::u16string stShiftCaps = this->KMX_GetShiftState_16(Shft, true); // 1,1 a $ ? + return ( + ((stCaps.size() > 0) && + (stBase.compare(stCaps) != 0) && // stBase != stCaps + (stShift.compare(stCaps) != 0)) || // stShift!= stCaps + ((stShiftCaps.size() > 0) && + (stBase.compare(stShiftCaps) != 0) && // stBase != stShiftCaps + (stShift.compare(stShiftCaps) != 0))); // stShift!= stShiftCaps + } +// _S2 TOP_7 bool KMX_IsCapsEqualToShift() { std::wstring stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß std::wstring stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? @@ -181,7 +204,17 @@ public: (stBase.compare(stShift) != 0) && // stBase != stShft (stShift.compare(stCaps) == 0)); // stShft == stCaps } - + bool KMX_IsCapsEqualToShift_16() { + std::u16string stBase = this->KMX_GetShiftState_16(Base, false); // 0,0 a 4 ß + std::u16string stShift = this->KMX_GetShiftState_16(Shft, false); // 1,0 A $ ? + std::u16string stCaps = this->KMX_GetShiftState_16(Base, true); // 0,1 A 4 ẞ + return ( + (stBase.size() > 0) && // unshifted char inside + (stShift.size() > 0) && // shifted char inside + (stBase.compare(stShift) != 0) && // stBase != stShft + (stShift.compare(stCaps) == 0)); // stShft == stCaps + } +// _S2 TOP_7 bool KMX_IsAltGrCapsEqualToAltGrShift() { std::wstring stBase = this->KMX_GetShiftState(MenuCtrl, false); // 0,0 std::wstring stShift = this->KMX_GetShiftState(ShftMenuCtrl, false); // 1,0 @@ -192,7 +225,17 @@ public: (stBase.compare(stShift) != 0) && // stBase != stShft (stShift.compare(stCaps) == 0)); // stShft == stCaps } - + bool KMX_IsAltGrCapsEqualToAltGrShift_16() { + std::u16string stBase = this->KMX_GetShiftState_16(MenuCtrl, false); // 0,0 + std::u16string stShift = this->KMX_GetShiftState_16(ShftMenuCtrl, false); // 1,0 + std::u16string stCaps = this->KMX_GetShiftState_16(MenuCtrl, true); // 0,1 + return ( + (stBase.size() > 0) && // unshifted MenuCtrl/AltGr char inside + (stShift.size() > 0) && // shifted MenuCtrl/AltGr char inside + (stBase.compare(stShift) != 0) && // stBase != stShft + (stShift.compare(stCaps) == 0)); // stShft == stCaps + } +// _S2 TOP_7 bool KMX_IsXxxxGrCapsEqualToXxxxShift() { std::wstring stBase = this->KMX_GetShiftState(Xxxx, false); std::wstring stShift = this->KMX_GetShiftState(ShftXxxx, false); @@ -203,8 +246,18 @@ public: (stBase.compare(stShift) != 0) && (stShift.compare(stCaps) == 0)); } + bool KMX_IsXxxxGrCapsEqualToXxxxShift_16() { +std::u16string stBase = this->KMX_GetShiftState_16(Xxxx, false); +std::u16string stShift = this->KMX_GetShiftState_16(ShftXxxx, false); +std::u16string stCaps = this->KMX_GetShiftState_16(Xxxx, true); +return ( + (stBase.size() > 0) && + (stShift.size() > 0) && + (stBase.compare(stShift) != 0) && + (stShift.compare(stCaps) == 0)); +} - +// _S2 TOP_7 bool KMX_IsEmpty() { for (int i = 0; i < 10; i++) { for (int j = 0; j <= 1; j++) { @@ -215,6 +268,16 @@ public: } return true; } + bool KMX_IsEmpty_16() { + for (int i = 0; i < 10; i++) { + for (int j = 0; j <= 1; j++) { + if (this->KMX_GetShiftState_16((ShiftState)i, (j == 1)).size() > 0) { + return (false); + } + } + } + return true; + } bool KMX_IsKeymanUsedKey() { return (this->m_vk >= 0x20 && this->m_vk <= 0x5F) || (this->m_vk >= 0x88); @@ -241,7 +304,9 @@ public: continue; } for (int caps = 0; caps <= 1; caps++) { + // _S2 TOP_7 std::wstring st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); + //std::u16string st16 = this->KMX_GetShiftState_16((ShiftState) ss, (caps == 1)); if (st.size() == 0) { // No character assigned here @@ -264,6 +329,7 @@ public: bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,v_dw_3D &All_Vector, GdkKeymap *keymap) { // I4552 // Get the CAPSLOCK value +// _S2 TOP_7 int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | @@ -271,7 +337,14 @@ public: (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); // _S2 we need this capslock calculation - //capslock=1; + + /*int capslock = + (this->KMX_IsCapsEqualToShift_16() ? 1 : 0) | + (this->KMX_IsSGCAPS_16() ? 2 : 0) | + (this->KMX_IsAltGrCapsEqualToAltGrShift_16() ? 4 : 0) | + (this->KMX_IsXxxxGrCapsEqualToXxxxShift_16() ? 8 : 0); + // _S2 we need this capslock calculation + //capslock=1;*/ for (int ss = 0; ss <= MaxShiftState; ss++) { if (ss == Menu || ss == ShftMenu) { @@ -279,7 +352,9 @@ public: continue; } for (int caps = 0; caps <= 1; caps++) { + // _S2 TOP_7 std::wstring st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); + //std::u16string st_16 = this->KMX_GetShiftState_16((ShiftState) ss, (caps == 1)); PKMX_WCHAR p; if (st.size() == 0) { @@ -449,7 +524,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, if(rc > 0) { if(*sbBuffer == 0) { //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); // different to windows since behavior on Linux is different - rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps)); + rgKey[iKey]->KMX_SetShiftState(ss, u"", false, (caps)); } else { if( (ss == Ctrl || ss == ShftCtrl) ) { @@ -506,7 +581,9 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, gp = &kp->dpGroupArray[kp->cxGroupArray-1]; UINT nKeys = 0; for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { + // _S2 TOP_7 if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { + //if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty_16())) { nKeys+= rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()); } } @@ -528,7 +605,9 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // // _S2 fills group 2 using keys for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { + // _S2 TOP_7 if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { + // if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty_16())) { if(rgKey[iKey]->KMX_LayoutRow(loader.KMX_MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()); } From 7bb97981a7f620591e1231a6441c87a1d4bb857b Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 1 Mar 2024 22:10:57 +0100 Subject: [PATCH 227/327] feat(linux): mcompile-dk replace wchar_t disable some old wchar_t functions --- linux/mcompile/keymap/deadkey.cpp | 13 ++++++------- linux/mcompile/keymap/deadkey.h | 2 +- linux/mcompile/keymap/keymap.cpp | 15 +++++++-------- linux/mcompile/keymap/keymap.h | 2 +- linux/mcompile/keymap/mc_import_rules.cpp | 6 ++++-- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 3d9633549f..3db2402086 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -2,15 +2,14 @@ #include "deadkey.h" // _S2 TOP_7 -v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult) { +/*v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult) { v_dw_1D line; line.push_back(convertNamesTo_DWORD_Value(first)); line.push_back(convertNamesTo_DWORD_Value(second)); //line.push_back(convertNamesTo_DWORD_Value(nameresult)); line.push_back(number); return line; -} - +}*/ v_dw_1D createLine(std::string first, std::string second, KMX_DWORD number, std::string nameresult) { v_dw_1D line; line.push_back(convertNamesTo_DWORD_Value(first)); @@ -500,7 +499,7 @@ void create_DKTable(v_dw_2D & dk_ComposeTable) { dk_ComposeTable.push_back(line); line.clear(); } -// _S2 TOP_3 is this the right place to get dk from? if not where are they stored? +/*// _S2 TOP_3 is this the right place to get dk from? if not where are they stored? void create_DKTable_old(v_dw_2D & dk_ComposeTable) { //create a 2D-Vector which contains data for ALL existing deadkey combinations on a Linux Keyboard: //dk_ComposeTable[i][0] : First (e.g. dead_circumflex) @@ -797,8 +796,8 @@ void create_DKTable_old(v_dw_2D & dk_ComposeTable) { line = createLine(L"dead_acute", L"space", 0x0027, L"APOSTROPHE"); dk_ComposeTable.push_back(line); line.clear(); - /*line = createLine(L"dead_acute", L"space", 0x00B4, L"ACUTE_ACCENT"); // _S2 TOP_3 ToDo remove - just for testing - dk_ComposeTable.push_back(line); line.clear();*/ + //line = createLine(L"dead_acute", L"space", 0x00B4, L"ACUTE_ACCENT"); // _S2 TOP_3 ToDo remove - just for testing + // dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_grave", L"space", 0x0060, L"GRAVE_ACCENT"); dk_ComposeTable.push_back(line); line.clear(); @@ -876,4 +875,4 @@ void create_DKTable_old(v_dw_2D & dk_ComposeTable) { line = createLine(L"dead_tilde", L"dead_tilde", 0x007E, L"TILDE"); dk_ComposeTable.push_back(line); line.clear(); } - +*/ diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index 611c862c6f..af9fef054b 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -8,7 +8,7 @@ // _S2 TOP_7 // create a vector for a dk combination ( ` + a -> à ) -v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult); +//v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult); v_dw_1D createLine(std::string first, std::string second, KMX_DWORD number, std::string nameresult); // create a 2D-vector of all dk combinations ( ` + a -> à ; ^ + a -> â ; `+ e -> è; ...) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index ba3765e2f3..739b1215f7 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -11,7 +11,7 @@ int map_VKShiftState_to_LinModifier(int VKShiftState) { } // _S2 TOP_7 -KMX_DWORD convertNamesTo_DWORD_Value(std::wstring tok_wstr) { +/*KMX_DWORD convertNamesTo_DWORD_Value(std::wstring tok_wstr) { // more on https://manpages.ubuntu.com/manpages/jammy/man3/keysyms.3tk.html std::map first; @@ -80,6 +80,7 @@ KMX_DWORD convertNamesTo_DWORD_Value(std::wstring tok_wstr) { } return returnIfCharInvalid; } +*/ KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str) { // more on https://manpages.ubuntu.com/manpages/jammy/man3/keysyms.3tk.html std::map first; @@ -561,8 +562,8 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { // replace a name with a single character ( a -> a ; equal -> = ) // _S2 TOP_7 - //tokens_int = convertNamesTo_DWORD_Value(tokens[i]); - tokens_int = convertNamesTo_DWORD_Value( wstring_from_string(tokens[i])); + tokens_int = convertNamesTo_DWORD_Value(tokens[i]); + //tokens_int = convertNamesTo_DWORD_Value( wstring_from_string(tokens[i])); tokens_dw.push_back(tokens_int); } @@ -665,7 +666,6 @@ std::wstring convert_DeadkeyValues_ToWstr(int in) { if (in < (int) deadkey_min) { // no deadkey; no Unicode return std::wstring(1, in); } -// _S2 TOP_7 KMX_DWORD lname = convertNamesTo_DWORD_Value( long_name); // 65106 => "dead_circumflex" => 94 => "^" //KMX_DWORD lname = convertNamesTo_DWORD_Value( wstring_from_string(long_name)); // 65106 => "dead_circumflex" => 94 => "^" @@ -675,7 +675,6 @@ std::wstring convert_DeadkeyValues_ToWstr(int in) { else return L"\0"; } - std::u16string convert_DeadkeyValues_To_U16str(int in) { if (in == 0 ) @@ -690,7 +689,8 @@ std::u16string convert_DeadkeyValues_To_U16str(int in) { return std::u16string(1, in); } - KMX_DWORD lname = convertNamesTo_DWORD_Value( wstring_from_string(long_name)); // 65106 => "dead_circumflex" => 94 => "^" + //KMX_DWORD lname_old = convertNamesTo_DWORD_Value( wstring_from_string(long_name)); // 65106 => "dead_circumflex" => 94 => "^" + KMX_DWORD lname = convertNamesTo_DWORD_Value(long_name); // 65106 => "dead_circumflex" => 94 => "^" if (lname != returnIfCharInvalid) { return std::u16string(1, lname ); @@ -854,7 +854,7 @@ KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(v_dw_3D & All_Vector, KMX_DWORD } return VK_US; } -// _S2 TOP_7 + KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap *keymap, v_dw_3D &All_Vector, KMX_DWORD KC_US, ShiftState ss, int caps) { KMX_DWORD KC_underlying; std::u16string u16str = convert_DeadkeyValues_To_U16str(KMX_get_KeyVal_From_KeyCode(keymap, KC_US, ss, caps)); @@ -903,7 +903,6 @@ std::wstring CodePointToWString(unsigned int codepoint) { return str; } - std::u16string CodePointToString_16(unsigned int codepoint) { std::u16string str; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 9436aba360..1909a7bdc3 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -73,7 +73,7 @@ static KMX_DWORD deadkey_max = 0xfe52; // _S2 TOP_6 TODO This has to go! my tes int map_VKShiftState_to_LinModifier(int VKShiftState); // _S2 TOP_7 // take a std::wstring (=contents of line symbols-file ) and returns the (int) value of the character -KMX_DWORD convertNamesTo_DWORD_Value(std::wstring tok_wstr); +//KMX_DWORD convertNamesTo_DWORD_Value(std::wstring tok_wstr); KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str); // create a Vector with all entries of both keymaps+ keymap diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index a4903c642c..f987c4055c 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -77,8 +77,10 @@ int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int return 0; // _S2 TOP_7 KMX_DWORD KeyVal= (KMX_DWORD) KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(shift_state_pos), caps); - std::wstring str = convert_DeadkeyValues_ToWstr(KeyVal); - pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(str).c_str(); + //std::wstring str = convert_DeadkeyValues_ToWstr(KeyVal); + // pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(str).c_str(); + std::u16string str_16 = convert_DeadkeyValues_To_U16str(KeyVal); + pwszBuff[0]= * (PKMX_WCHAR) str_16.c_str(); g_free(keyvals); From 1c9f879780cfb7eeedc2a6767ca1cdc6cf98833a Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 1 Mar 2024 22:38:03 +0100 Subject: [PATCH 228/327] feat(linux): mcompile-dk replace wchar_t disable more old wchar_t functions --- linux/mcompile/keymap/deadkey.cpp | 2 +- linux/mcompile/keymap/deadkey.h | 2 +- linux/mcompile/keymap/keymap.cpp | 8 ++++---- linux/mcompile/keymap/keymap.h | 6 +++--- linux/mcompile/keymap/mc_import_rules.cpp | 19 +++++++++++-------- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 3db2402086..a287b5303a 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -1,7 +1,7 @@ #include "keymap.h" #include "deadkey.h" -// _S2 TOP_7 +// _S2 TOP_7 ok /*v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult) { v_dw_1D line; line.push_back(convertNamesTo_DWORD_Value(first)); diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index af9fef054b..c68791bd78 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -6,7 +6,7 @@ #include #include "mc_import_rules.h" -// _S2 TOP_7 +// _S2 TOP_7 ok // create a vector for a dk combination ( ` + a -> à ) //v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult); v_dw_1D createLine(std::string first, std::string second, KMX_DWORD number, std::string nameresult); diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 739b1215f7..52a4f53a0f 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -10,7 +10,7 @@ int map_VKShiftState_to_LinModifier(int VKShiftState) { else return VKShiftState; } -// _S2 TOP_7 +// _S2 TOP_7 ok /*KMX_DWORD convertNamesTo_DWORD_Value(std::wstring tok_wstr) { // more on https://manpages.ubuntu.com/manpages/jammy/man3/keysyms.3tk.html std::map first; @@ -561,7 +561,7 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { for ( int i = 1; i< (int) tokens.size();i++) { // replace a name with a single character ( a -> a ; equal -> = ) - // _S2 TOP_7 + // _S2 TOP_7 ok tokens_int = convertNamesTo_DWORD_Value(tokens[i]); //tokens_int = convertNamesTo_DWORD_Value( wstring_from_string(tokens[i])); @@ -652,7 +652,7 @@ bool IsKeymanUsedChar(int KV) { else return false; } -// _S2 TOP_7 +// _S2 TOP_7 ok std::wstring convert_DeadkeyValues_ToWstr(int in) { if (in == 0 ) @@ -884,7 +884,7 @@ KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying(KMX_DWORD keycode) { return 0; } -// _S2 TOP_7 +// _S2 TOP_7 ok std::wstring CodePointToWString(unsigned int codepoint) { std::wstring str; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 1909a7bdc3..99a10028da 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -71,7 +71,7 @@ static KMX_DWORD deadkey_min = 0xfe50; static KMX_DWORD deadkey_max = 0xfe52; // _S2 TOP_6 TODO This has to go! my test: to only return 3 dk int map_VKShiftState_to_LinModifier(int VKShiftState); -// _S2 TOP_7 +// _S2 TOP_7 ok // take a std::wstring (=contents of line symbols-file ) and returns the (int) value of the character //KMX_DWORD convertNamesTo_DWORD_Value(std::wstring tok_wstr); KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str); @@ -503,7 +503,7 @@ const UINT ScanCodeToUSVirtualKey[128] = { bool IsKeymanUsedChar(int KV); //------------------------------ -// _S2 TOP_7 +// _S2 TOP_7 ok // take deadkey-value (e.g.65106) and return wstring (e.g. '^' ) std::wstring convert_DeadkeyValues_ToWstr(int in); std::u16string convert_DeadkeyValues_To_U16str(int in); @@ -530,7 +530,7 @@ UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying(KMX_DWORD keycode); // convert codePoint to wstring -// _S2 TOP_7 +// _S2 TOP_7 ok std::wstring CodePointToWString(unsigned int codepoint); std::u16string CodePointToString_16(unsigned int codepoint); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index f987c4055c..8b1dc2db70 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -75,7 +75,7 @@ int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int if (!(keycode <= keycode_max)) return 0; -// _S2 TOP_7 +// _S2 TOP_7 ok KMX_DWORD KeyVal= (KMX_DWORD) KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(shift_state_pos), caps); //std::wstring str = convert_DeadkeyValues_ToWstr(KeyVal); // pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(str).c_str(); @@ -144,7 +144,7 @@ public: UINT SC() { return this->m_sc; } -// _S2 TOP_7 +// _S2 TOP_7 ok std::wstring KMX_GetShiftState(ShiftState shiftState, bool capsLock) { return this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)]; } @@ -168,7 +168,7 @@ public: this->m_rgss_16[(UINT)shiftState][(capsLock ? 1 : 0)] = value; } -// _S2 TOP_7 +// _S2 TOP_7 ok bool KMX_IsSGCAPS() { std::wstring stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß std::wstring stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? @@ -195,7 +195,7 @@ public: (stBase.compare(stShiftCaps) != 0) && // stBase != stShiftCaps (stShift.compare(stShiftCaps) != 0))); // stShift!= stShiftCaps } -// _S2 TOP_7 +// _S2 TOP_7 ok bool KMX_IsCapsEqualToShift() { std::wstring stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß std::wstring stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? @@ -216,7 +216,7 @@ public: (stBase.compare(stShift) != 0) && // stBase != stShft (stShift.compare(stCaps) == 0)); // stShft == stCaps } -// _S2 TOP_7 +// _S2 TOP_7 ok bool KMX_IsAltGrCapsEqualToAltGrShift() { std::wstring stBase = this->KMX_GetShiftState(MenuCtrl, false); // 0,0 std::wstring stShift = this->KMX_GetShiftState(ShftMenuCtrl, false); // 1,0 @@ -237,7 +237,7 @@ public: (stBase.compare(stShift) != 0) && // stBase != stShft (stShift.compare(stCaps) == 0)); // stShft == stCaps } -// _S2 TOP_7 +// _S2 TOP_7 ok bool KMX_IsXxxxGrCapsEqualToXxxxShift() { std::wstring stBase = this->KMX_GetShiftState(Xxxx, false); std::wstring stShift = this->KMX_GetShiftState(ShftXxxx, false); @@ -308,7 +308,7 @@ return ( for (int caps = 0; caps <= 1; caps++) { // _S2 TOP_7 std::wstring st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); - //std::u16string st16 = this->KMX_GetShiftState_16((ShiftState) ss, (caps == 1)); + //std::u16string st = this->KMX_GetShiftState_16((ShiftState) ss, (caps == 1)); if (st.size() == 0) { // No character assigned here @@ -356,7 +356,7 @@ return ( for (int caps = 0; caps <= 1; caps++) { // _S2 TOP_7 std::wstring st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); - //std::u16string st_16 = this->KMX_GetShiftState_16((ShiftState) ss, (caps == 1)); + //std::u16string st = this->KMX_GetShiftState_16((ShiftState) ss, (caps == 1)); PKMX_WCHAR p; if (st.size() == 0) { @@ -527,6 +527,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, if(*sbBuffer == 0) { //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); // different to windows since behavior on Linux is different rgKey[iKey]->KMX_SetShiftState(ss, u"", false, (caps)); + //rgKey[iKey]->KMX_SetShiftState_16(ss, u"", false, (caps)); } else { if( (ss == Ctrl || ss == ShftCtrl) ) { @@ -535,12 +536,14 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, sbBuffer[rc] = 0; //rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps==0)); rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps)); // different to windows since behavior on Linux is different + //rgKey[iKey]->KMX_SetShiftState_16(ss, sbBuffer, false, (caps)); // different to windows since behavior on Linux is different } } else if(rc < 0) { sbBuffer[2] = 0; //rgKey[iKey]->SetShiftState(ss, sbBuffer, true, (caps == 0)); rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); // different to windows since behavior on Linux is different + //rgKey[iKey]->KMX_SetShiftState_16(ss, sbBuffer, true, (caps )); // different to windows since behavior on Linux is different refine_alDead(sbBuffer[0], alDead, &alDead_cpl); } From 19e120d8bb5452dabcf35287f400bb7e497b0609 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 5 Mar 2024 16:57:16 +0100 Subject: [PATCH 229/327] feat(linux): mcompile-dk char16 works --- linux/mcompile/keymap/mc_import_rules.cpp | 282 +++++++++++++++++++++- 1 file changed, 277 insertions(+), 5 deletions(-) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 8b1dc2db70..d42cf94056 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -259,7 +259,7 @@ return ( (stShift.compare(stCaps) == 0)); } -// _S2 TOP_7 +// _S2 TOP_7 ok bool KMX_IsEmpty() { for (int i = 0; i < 10; i++) { for (int j = 0; j <= 1; j++) { @@ -407,7 +407,247 @@ return ( key->dpContext = new KMX_WCHAR; *key->dpContext = 0; p = key->dpOutput = new KMX_WCHAR[st.size() + 1]; + for(size_t ich = 0; ich < st.size(); ich++) { + *p++ = st[ich]; + } + *p = 0; + key++; + } + } + } + } + return true; + } +}; + +class KMX_VirtualKey_16 { +private: + //KMX_HKL m_hkl; // _S2 QUESTION do I need this and is void* OK to assume? If I remove this, will there be changes in Data-Vectors? + UINT m_vk; + UINT m_sc; + bool m_rgfDeadKey[10][2]; + std::u16string m_rgss_16[10][2]; + +public: + + // _S2 TODO I assume we do not need those... + /*KMX_VirtualKey(KMX_HKL hkl,UINT virtualKey) { + this->m_sc = KMX_get_KeyCodeUnderlying_From_VKUS(virtualKey); + this->m_hkl = hkl; + this->m_vk = virtualKey; + memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); + }*/ + + //KMX_VirtualKey(UINT scanCode, KMX_HKL hkl) { + KMX_VirtualKey_16(UINT scanCode) { + this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying(scanCode); + //this->m_hkl = hkl; + this->m_sc = scanCode; + memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); + } + + UINT VK() { + return this->m_vk; + } + + UINT SC() { + return this->m_sc; + } +// _S2 TOP_7 ok + std::u16string KMX_GetShiftState_16(ShiftState shiftState, bool capsLock) { + return this->m_rgss_16[(UINT)shiftState][(capsLock ? 1 : 0)]; + } + // _S2 TOP_7 + void KMX_SetShiftState_16(ShiftState shiftState, std::u16string value_16, bool isDeadKey, bool capsLock) { + std::u16string value = value_16; + this->m_rgfDeadKey[(UINT)shiftState][(capsLock ? 1 : 0)] = isDeadKey; + this->m_rgss_16[(UINT)shiftState][(capsLock ? 1 : 0)] = value; + } + +bool KMX_IsSGCAPS_16() { + std::u16string stBase = this->KMX_GetShiftState_16(Base, false); // 0,0 a 4 ß + std::u16string stShift = this->KMX_GetShiftState_16(Shft, false); // 1,0 A $ ? + std::u16string stCaps = this->KMX_GetShiftState_16(Base, true); // 0,1 A 4 ẞ + std::u16string stShiftCaps = this->KMX_GetShiftState_16(Shft, true); // 1,1 a $ ? + return ( + ((stCaps.size() > 0) && + (stBase.compare(stCaps) != 0) && // stBase != stCaps + (stShift.compare(stCaps) != 0)) || // stShift!= stCaps + ((stShiftCaps.size() > 0) && + (stBase.compare(stShiftCaps) != 0) && // stBase != stShiftCaps + (stShift.compare(stShiftCaps) != 0))); // stShift!= stShiftCaps + } + +bool KMX_IsCapsEqualToShift_16() { + std::u16string stBase = this->KMX_GetShiftState_16(Base, false); // 0,0 a 4 ß + std::u16string stShift = this->KMX_GetShiftState_16(Shft, false); // 1,0 A $ ? + std::u16string stCaps = this->KMX_GetShiftState_16(Base, true); // 0,1 A 4 ẞ + return ( + (stBase.size() > 0) && // unshifted char inside + (stShift.size() > 0) && // shifted char inside + (stBase.compare(stShift) != 0) && // stBase != stShft + (stShift.compare(stCaps) == 0)); // stShft == stCaps + } + +bool KMX_IsAltGrCapsEqualToAltGrShift_16() { + std::u16string stBase = this->KMX_GetShiftState_16(MenuCtrl, false); // 0,0 + std::u16string stShift = this->KMX_GetShiftState_16(ShftMenuCtrl, false); // 1,0 + std::u16string stCaps = this->KMX_GetShiftState_16(MenuCtrl, true); // 0,1 + return ( + (stBase.size() > 0) && // unshifted MenuCtrl/AltGr char inside + (stShift.size() > 0) && // shifted MenuCtrl/AltGr char inside + (stBase.compare(stShift) != 0) && // stBase != stShft + (stShift.compare(stCaps) == 0)); // stShft == stCaps + } + +bool KMX_IsXxxxGrCapsEqualToXxxxShift_16() { +std::u16string stBase = this->KMX_GetShiftState_16(Xxxx, false); +std::u16string stShift = this->KMX_GetShiftState_16(ShftXxxx, false); +std::u16string stCaps = this->KMX_GetShiftState_16(Xxxx, true); +return ( + (stBase.size() > 0) && + (stShift.size() > 0) && + (stBase.compare(stShift) != 0) && + (stShift.compare(stCaps) == 0)); +} + + bool KMX_IsEmpty_16() { + for (int i = 0; i < 10; i++) { + for (int j = 0; j <= 1; j++) { + if (this->KMX_GetShiftState_16((ShiftState)i, (j == 1)).size() > 0) { + return (false); + } + } + } + return true; + } + + bool KMX_IsKeymanUsedKey() { + return (this->m_vk >= 0x20 && this->m_vk <= 0x5F) || (this->m_vk >= 0x88); + } + + UINT KMX_GetShiftStateValue_16(int capslock, int caps, ShiftState ss) { + return KMX_ShiftStateMap[(int)ss] | (capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0); + } + + int KMX_GetKeyCount_16(int MaxShiftState) { + int nkeys_16 = 0; + + // Get the CAPSLOCK value + //_S2 TOP_6 INFO not used in original code; can be deleted + /*int capslock = + (this->KMX_IsCapsEqualToShift() ? 1 : 0) | + (this->KMX_IsSGCAPS() ? 2 : 0) | + (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | + (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0);*/ + + for (int ss = 0; ss <= MaxShiftState; ss++) { + if (ss == Menu || ss == ShftMenu) { + // Alt and Shift+Alt don't work, so skip them + continue; + } + for (int caps = 0; caps <= 1; caps++) { + // _S2 TOP_7 + std::u16string st = this->KMX_GetShiftState_16((ShiftState) ss, (caps == 1)); + //std::u16string st = this->KMX_GetShiftState_16((ShiftState) ss, (caps == 1)); + + if (st.size() == 0) { + // No character assigned here + } else if (this->m_rgfDeadKey[(int)ss][caps]) { + // It's a dead key, append an @ sign. + nkeys_16++; + } else { + bool isvalid = true; + for (size_t ich = 0; ich < st.size(); ich++) { + if(st[ich] < 0x20 || st[ich] == 0x7F) { + isvalid=false; + + wprintf(L"invalid for: %i\n", st[ich]); + break; } + } + if(isvalid) { + nkeys_16++; + } + } + } + } + return nkeys_16; + } + + bool KMX_LayoutRow_16(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,v_dw_3D &All_Vector, GdkKeymap *keymap) { // I4552 + // Get the CAPSLOCK value + int capslock = + (this->KMX_IsCapsEqualToShift_16() ? 1 : 0) | + (this->KMX_IsSGCAPS_16() ? 2 : 0) | + (this->KMX_IsAltGrCapsEqualToAltGrShift_16() ? 4 : 0) | + (this->KMX_IsXxxxGrCapsEqualToXxxxShift_16() ? 8 : 0); + // _S2 we need this capslock calculation + //capslock=1;*/ + + for (int ss = 0; ss <= MaxShiftState; ss++) { + if (ss == Menu || ss == ShftMenu) { + // Alt and Shift+Alt don't work, so skip them + continue; + } + for (int caps = 0; caps <= 1; caps++) { + // _S2 TOP_7 + std::u16string st = this->KMX_GetShiftState_16((ShiftState) ss, (caps == 1)); + //std::u16string st = this->KMX_GetShiftState_16((ShiftState) ss, (caps == 1)); + + PKMX_WCHAR p; + + if (st.size() == 0) { + // No character assigned here + } + else if (this->m_rgfDeadKey[(int)ss][caps]) { + // It's a dead key, append an @ sign. + key->dpContext = new KMX_WCHAR[1]; + *key->dpContext = 0; + + key->ShiftFlags = this->KMX_GetShiftStateValue_16(capslock, caps, (ShiftState) ss); + // we already use VK_US so no need to convert it as we do on windows + key->Key = this->VK(); + key->Line = 0; + + if(bDeadkeyConversion) { // I4552 + p = key->dpOutput = new KMX_WCHAR[2]; + *p++ = st[0]; + *p = 0; + } else { + + p = key->dpOutput = new KMX_WCHAR[4]; + *p++ = UC_SENTINEL; + *p++ = CODE_DEADKEY; + *p++ = KMX_DeadKeyMap(st[0], deadkeys, deadkeyBase, &KMX_FDeadkeys); // I4353 + *p = 0; + } + key++; + } + else { + bool isvalid = true; + for (size_t ich = 0; ich < st.size(); ich++) { + if(st[ich] < 0x20 || st[ich] == 0x7F) { + isvalid=false; + wprintf(L"invalid 16 for: %i\n", st[ich]); + break; } + } + if(isvalid) { + // this is different to mcompile windows !!!! + // this->m_sc stores SC-US = SCUnderlying + // this->m_vk stores VK-US ( not underlying !!) + // key->Key stores VK-US ( not underlying !!) + // key->dpOutput stores character Underlying + + KMX_DWORD SC_Underlying = KMX_get_KeyCodeUnderlying_From_KeyCodeUS(keymap, All_Vector, this->SC(), (ShiftState) ss, caps); + key->Key = KMX_get_VKUS_From_KeyCodeUnderlying( SC_Underlying); + + key->Line = 0; + key->ShiftFlags = this->KMX_GetShiftStateValue_16(capslock, caps, (ShiftState) ss); + + key->dpContext = new KMX_WCHAR; + *key->dpContext = 0; + p = key->dpOutput = new KMX_WCHAR[st.size() + 1]; for(size_t ich = 0; ich < st.size(); ich++) { *p++ = st[ich]; } @@ -470,10 +710,12 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, //KMX_HKL hkl = NULL; std::vector rgKey; //= new VirtualKey[256]; + std::vector rgKey_16; //= new VirtualKey[256]; std::vector alDead; std::vector alDead_cpl = create_alDead(); rgKey.resize(256); + rgKey_16.resize(256); // Scroll through the Scan Code (SC) values and get the valid Virtual Key (VK) // values in it. Then, store the SC in each valid VK so it can act as both a @@ -488,12 +730,19 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, //KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl); KMX_VirtualKey *key = new KMX_VirtualKey(sc); + KMX_VirtualKey_16 *key_16 = new KMX_VirtualKey_16(sc); if((key->VK() != 0) ) { rgKey[key->VK()] = key; } else { delete key; } + + if((key_16->VK() != 0) ) { + rgKey_16[key_16->VK()] = key_16; + } else { + delete key_16; + } } // _S2 TODO I assume we do not need those... @@ -527,6 +776,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, if(*sbBuffer == 0) { //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); // different to windows since behavior on Linux is different rgKey[iKey]->KMX_SetShiftState(ss, u"", false, (caps)); + rgKey_16[iKey]->KMX_SetShiftState_16(ss, u"", false, (caps)); //rgKey[iKey]->KMX_SetShiftState_16(ss, u"", false, (caps)); } else { @@ -536,6 +786,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, sbBuffer[rc] = 0; //rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps==0)); rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps)); // different to windows since behavior on Linux is different + rgKey_16[iKey]->KMX_SetShiftState_16(ss, sbBuffer, false, (caps)); // different to windows since behavior on Linux is different //rgKey[iKey]->KMX_SetShiftState_16(ss, sbBuffer, false, (caps)); // different to windows since behavior on Linux is different } } @@ -543,6 +794,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, sbBuffer[2] = 0; //rgKey[iKey]->SetShiftState(ss, sbBuffer, true, (caps == 0)); rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); // different to windows since behavior on Linux is different + rgKey_16[iKey]->KMX_SetShiftState_16(ss, sbBuffer, true, (caps )); // different to windows since behavior on Linux is different //rgKey[iKey]->KMX_SetShiftState_16(ss, sbBuffer, true, (caps )); // different to windows since behavior on Linux is different refine_alDead(sbBuffer[0], alDead, &alDead_cpl); @@ -594,6 +846,17 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, } + + UINT nKeys_16 = 0; + for (UINT iKey_16 = 0; iKey_16 < rgKey_16.size(); iKey_16++) { + // _S2 TOP_7 + if ((rgKey_16[iKey_16] != NULL) && rgKey_16[iKey_16]->KMX_IsKeymanUsedKey() && (!rgKey_16[iKey_16]->KMX_IsEmpty_16())) { + //if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty_16())) { + nKeys_16+= rgKey_16[iKey_16]->KMX_GetKeyCount_16(loader.KMX_MaxShiftState()); + } + } + + nDeadkey++; // ensure a 1-based index above the max deadkey value already in the keyboard gp->fUsingKeys = TRUE; @@ -603,30 +866,39 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, gp->cxKeyArray = nKeys; gp->dpKeyArray = new KMX_KEY[gp->cxKeyArray]; nKeys = 0; + nKeys_16 = 0; // // Fill in the new rules // // _S2 fills group 2 using keys - for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { + /*for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { // _S2 TOP_7 if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { - // if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty_16())) { if(rgKey[iKey]->KMX_LayoutRow(loader.KMX_MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()); } } + }*/ + + //fills group3: group(group3) using keys + for (UINT iKey_16 = 0; iKey_16 < rgKey_16.size(); iKey_16++) { + if ((rgKey_16[iKey_16] != NULL) && rgKey_16[iKey_16]->KMX_IsKeymanUsedKey() && (!rgKey_16[iKey_16]->KMX_IsEmpty_16())) { + if(rgKey_16[iKey_16]->KMX_LayoutRow_16(loader.KMX_MaxShiftState(), &gp->dpKeyArray[nKeys_16], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 + nKeys_16+=rgKey_16[iKey_16]->KMX_GetKeyCount_16(loader.KMX_MaxShiftState()); + } + } } - gp->cxKeyArray = nKeys; + gp->cxKeyArray = nKeys_16; // // Add nomatch control to each terminating 'using keys' group // I4550 // // _adds + [CTRL NCAPS K_QUOTE] > use(group2) c line(0) // + [CTRL CAPS K_QUOTE] > use(group2) c line(0) - //nomatch > use(group2) + //nomatch > use(group2) nomatch > use(group3) // after dk-section LPKMX_GROUP gp2 = kp->dpGroupArray; for(UINT i = 0; i < kp->cxGroupArray - 1; i++, gp2++) { From 99dd1fa29414f060dd1e9cb85f7ff919345cfbb2 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 5 Mar 2024 17:12:59 +0100 Subject: [PATCH 230/327] feat(linux): mcompile remove _16 where I do not need them --- linux/mcompile/keymap/mc_import_rules.cpp | 105 ++-------------------- 1 file changed, 5 insertions(+), 100 deletions(-) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index d42cf94056..31bb069588 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -117,7 +117,7 @@ private: bool m_rgfDeadKey[10][2]; std::wstring m_rgss[10][2]; // _S2 TOP_7 - std::u16string m_rgss_16[10][2]; + // std::u16string m_rgss_16[10][2]; public: @@ -148,27 +148,13 @@ public: std::wstring KMX_GetShiftState(ShiftState shiftState, bool capsLock) { return this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)]; } - std::u16string KMX_GetShiftState_16(ShiftState shiftState, bool capsLock) { - return this->m_rgss_16[(UINT)shiftState][(capsLock ? 1 : 0)]; - } - - /* void KMX_SetShiftState(ShiftState shiftState, std::wstring value, bool isDeadKey, bool capsLock) { - this->m_rgfDeadKey[(UINT)shiftState][(capsLock ? 1 : 0)] = isDeadKey; - this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; - }*/ - // _S2 TOP_7 + void KMX_SetShiftState(ShiftState shiftState, std::u16string value16, bool isDeadKey, bool capsLock) { std::wstring value = wstring_from_u16string(value16); this->m_rgfDeadKey[(UINT)shiftState][(capsLock ? 1 : 0)] = isDeadKey; this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; } - void KMX_SetShiftState_16(ShiftState shiftState, std::u16string value_16, bool isDeadKey, bool capsLock) { - std::u16string value = value_16; - this->m_rgfDeadKey[(UINT)shiftState][(capsLock ? 1 : 0)] = isDeadKey; - this->m_rgss_16[(UINT)shiftState][(capsLock ? 1 : 0)] = value; - } -// _S2 TOP_7 ok bool KMX_IsSGCAPS() { std::wstring stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß std::wstring stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? @@ -182,20 +168,7 @@ public: (stBase.compare(stShiftCaps) != 0) && // stBase != stShiftCaps (stShift.compare(stShiftCaps) != 0))); // stShift!= stShiftCaps } - bool KMX_IsSGCAPS_16() { - std::u16string stBase = this->KMX_GetShiftState_16(Base, false); // 0,0 a 4 ß - std::u16string stShift = this->KMX_GetShiftState_16(Shft, false); // 1,0 A $ ? - std::u16string stCaps = this->KMX_GetShiftState_16(Base, true); // 0,1 A 4 ẞ - std::u16string stShiftCaps = this->KMX_GetShiftState_16(Shft, true); // 1,1 a $ ? - return ( - ((stCaps.size() > 0) && - (stBase.compare(stCaps) != 0) && // stBase != stCaps - (stShift.compare(stCaps) != 0)) || // stShift!= stCaps - ((stShiftCaps.size() > 0) && - (stBase.compare(stShiftCaps) != 0) && // stBase != stShiftCaps - (stShift.compare(stShiftCaps) != 0))); // stShift!= stShiftCaps - } -// _S2 TOP_7 ok + bool KMX_IsCapsEqualToShift() { std::wstring stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß std::wstring stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? @@ -206,17 +179,7 @@ public: (stBase.compare(stShift) != 0) && // stBase != stShft (stShift.compare(stCaps) == 0)); // stShft == stCaps } - bool KMX_IsCapsEqualToShift_16() { - std::u16string stBase = this->KMX_GetShiftState_16(Base, false); // 0,0 a 4 ß - std::u16string stShift = this->KMX_GetShiftState_16(Shft, false); // 1,0 A $ ? - std::u16string stCaps = this->KMX_GetShiftState_16(Base, true); // 0,1 A 4 ẞ - return ( - (stBase.size() > 0) && // unshifted char inside - (stShift.size() > 0) && // shifted char inside - (stBase.compare(stShift) != 0) && // stBase != stShft - (stShift.compare(stCaps) == 0)); // stShft == stCaps - } -// _S2 TOP_7 ok + bool KMX_IsAltGrCapsEqualToAltGrShift() { std::wstring stBase = this->KMX_GetShiftState(MenuCtrl, false); // 0,0 std::wstring stShift = this->KMX_GetShiftState(ShftMenuCtrl, false); // 1,0 @@ -227,17 +190,7 @@ public: (stBase.compare(stShift) != 0) && // stBase != stShft (stShift.compare(stCaps) == 0)); // stShft == stCaps } - bool KMX_IsAltGrCapsEqualToAltGrShift_16() { - std::u16string stBase = this->KMX_GetShiftState_16(MenuCtrl, false); // 0,0 - std::u16string stShift = this->KMX_GetShiftState_16(ShftMenuCtrl, false); // 1,0 - std::u16string stCaps = this->KMX_GetShiftState_16(MenuCtrl, true); // 0,1 - return ( - (stBase.size() > 0) && // unshifted MenuCtrl/AltGr char inside - (stShift.size() > 0) && // shifted MenuCtrl/AltGr char inside - (stBase.compare(stShift) != 0) && // stBase != stShft - (stShift.compare(stCaps) == 0)); // stShft == stCaps - } -// _S2 TOP_7 ok + bool KMX_IsXxxxGrCapsEqualToXxxxShift() { std::wstring stBase = this->KMX_GetShiftState(Xxxx, false); std::wstring stShift = this->KMX_GetShiftState(ShftXxxx, false); @@ -248,18 +201,7 @@ public: (stBase.compare(stShift) != 0) && (stShift.compare(stCaps) == 0)); } - bool KMX_IsXxxxGrCapsEqualToXxxxShift_16() { -std::u16string stBase = this->KMX_GetShiftState_16(Xxxx, false); -std::u16string stShift = this->KMX_GetShiftState_16(ShftXxxx, false); -std::u16string stCaps = this->KMX_GetShiftState_16(Xxxx, true); -return ( - (stBase.size() > 0) && - (stShift.size() > 0) && - (stBase.compare(stShift) != 0) && - (stShift.compare(stCaps) == 0)); -} -// _S2 TOP_7 ok bool KMX_IsEmpty() { for (int i = 0; i < 10; i++) { for (int j = 0; j <= 1; j++) { @@ -270,16 +212,6 @@ return ( } return true; } - bool KMX_IsEmpty_16() { - for (int i = 0; i < 10; i++) { - for (int j = 0; j <= 1; j++) { - if (this->KMX_GetShiftState_16((ShiftState)i, (j == 1)).size() > 0) { - return (false); - } - } - } - return true; - } bool KMX_IsKeymanUsedKey() { return (this->m_vk >= 0x20 && this->m_vk <= 0x5F) || (this->m_vk >= 0x88); @@ -331,7 +263,6 @@ return ( bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,v_dw_3D &All_Vector, GdkKeymap *keymap) { // I4552 // Get the CAPSLOCK value -// _S2 TOP_7 int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | @@ -339,13 +270,6 @@ return ( (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); // _S2 we need this capslock calculation - - /*int capslock = - (this->KMX_IsCapsEqualToShift_16() ? 1 : 0) | - (this->KMX_IsSGCAPS_16() ? 2 : 0) | - (this->KMX_IsAltGrCapsEqualToAltGrShift_16() ? 4 : 0) | - (this->KMX_IsXxxxGrCapsEqualToXxxxShift_16() ? 8 : 0); - // _S2 we need this capslock calculation //capslock=1;*/ for (int ss = 0; ss <= MaxShiftState; ss++) { @@ -356,7 +280,6 @@ return ( for (int caps = 0; caps <= 1; caps++) { // _S2 TOP_7 std::wstring st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); - //std::u16string st = this->KMX_GetShiftState_16((ShiftState) ss, (caps == 1)); PKMX_WCHAR p; if (st.size() == 0) { @@ -439,7 +362,6 @@ public: memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); }*/ - //KMX_VirtualKey(UINT scanCode, KMX_HKL hkl) { KMX_VirtualKey_16(UINT scanCode) { this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying(scanCode); //this->m_hkl = hkl; @@ -550,7 +472,6 @@ return ( for (int caps = 0; caps <= 1; caps++) { // _S2 TOP_7 std::u16string st = this->KMX_GetShiftState_16((ShiftState) ss, (caps == 1)); - //std::u16string st = this->KMX_GetShiftState_16((ShiftState) ss, (caps == 1)); if (st.size() == 0) { // No character assigned here @@ -593,7 +514,6 @@ return ( for (int caps = 0; caps <= 1; caps++) { // _S2 TOP_7 std::u16string st = this->KMX_GetShiftState_16((ShiftState) ss, (caps == 1)); - //std::u16string st = this->KMX_GetShiftState_16((ShiftState) ss, (caps == 1)); PKMX_WCHAR p; @@ -777,7 +697,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); // different to windows since behavior on Linux is different rgKey[iKey]->KMX_SetShiftState(ss, u"", false, (caps)); rgKey_16[iKey]->KMX_SetShiftState_16(ss, u"", false, (caps)); - //rgKey[iKey]->KMX_SetShiftState_16(ss, u"", false, (caps)); } else { if( (ss == Ctrl || ss == ShftCtrl) ) { @@ -787,7 +706,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, //rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps==0)); rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps)); // different to windows since behavior on Linux is different rgKey_16[iKey]->KMX_SetShiftState_16(ss, sbBuffer, false, (caps)); // different to windows since behavior on Linux is different - //rgKey[iKey]->KMX_SetShiftState_16(ss, sbBuffer, false, (caps)); // different to windows since behavior on Linux is different } } else if(rc < 0) { @@ -795,7 +713,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, //rgKey[iKey]->SetShiftState(ss, sbBuffer, true, (caps == 0)); rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); // different to windows since behavior on Linux is different rgKey_16[iKey]->KMX_SetShiftState_16(ss, sbBuffer, true, (caps )); // different to windows since behavior on Linux is different - //rgKey[iKey]->KMX_SetShiftState_16(ss, sbBuffer, true, (caps )); // different to windows since behavior on Linux is different refine_alDead(sbBuffer[0], alDead, &alDead_cpl); } @@ -840,7 +757,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { // _S2 TOP_7 if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { - //if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty_16())) { nKeys+= rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()); } } @@ -851,7 +767,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, for (UINT iKey_16 = 0; iKey_16 < rgKey_16.size(); iKey_16++) { // _S2 TOP_7 if ((rgKey_16[iKey_16] != NULL) && rgKey_16[iKey_16]->KMX_IsKeymanUsedKey() && (!rgKey_16[iKey_16]->KMX_IsEmpty_16())) { - //if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty_16())) { nKeys_16+= rgKey_16[iKey_16]->KMX_GetKeyCount_16(loader.KMX_MaxShiftState()); } } @@ -872,16 +787,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // // Fill in the new rules // - // _S2 fills group 2 using keys - /*for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { - // _S2 TOP_7 - if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { - if(rgKey[iKey]->KMX_LayoutRow(loader.KMX_MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 - nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()); - } - } - }*/ - //fills group3: group(group3) using keys for (UINT iKey_16 = 0; iKey_16 < rgKey_16.size(); iKey_16++) { if ((rgKey_16[iKey_16] != NULL) && rgKey_16[iKey_16]->KMX_IsKeymanUsedKey() && (!rgKey_16[iKey_16]->KMX_IsEmpty_16())) { From aa534f999e2de57b5fe26ce082d10547f0145add Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 5 Mar 2024 17:39:01 +0100 Subject: [PATCH 231/327] feat(linux): mcompile remove even more _16 where I do not need them --- linux/mcompile/keymap/mc_import_rules.cpp | 34 ++++------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 31bb069588..ed00746c09 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -629,12 +629,10 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, //KMX_HKL hkl = NULL; - std::vector rgKey; //= new VirtualKey[256]; std::vector rgKey_16; //= new VirtualKey[256]; std::vector alDead; std::vector alDead_cpl = create_alDead(); - rgKey.resize(256); rgKey_16.resize(256); // Scroll through the Scan Code (SC) values and get the valid Virtual Key (VK) @@ -649,14 +647,8 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // this "connection" is possible only when using All_Vector //KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl); - KMX_VirtualKey *key = new KMX_VirtualKey(sc); KMX_VirtualKey_16 *key_16 = new KMX_VirtualKey_16(sc); - if((key->VK() != 0) ) { - rgKey[key->VK()] = key; - } else { - delete key; - } if((key_16->VK() != 0) ) { rgKey_16[key_16->VK()] = key_16; @@ -671,9 +663,9 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL);*/ // in this part we skip shiftstates 4, 5, 8, 9 - for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { + for(UINT iKey = 0; iKey < rgKey_16.size(); iKey++) { - if(rgKey[iKey] != NULL) { + if(rgKey_16[iKey] != NULL) { KMX_WCHAR sbBuffer[256]; // Scratchpad we use many places for(ShiftState ss = Base; ss <= loader.KMX_MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { @@ -694,24 +686,18 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, if(rc > 0) { if(*sbBuffer == 0) { - //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); // different to windows since behavior on Linux is different - rgKey[iKey]->KMX_SetShiftState(ss, u"", false, (caps)); - rgKey_16[iKey]->KMX_SetShiftState_16(ss, u"", false, (caps)); + rgKey_16[iKey]->KMX_SetShiftState_16(ss, u"", false, (caps)); // different to windows since behavior on Linux is different } else { if( (ss == Ctrl || ss == ShftCtrl) ) { continue; } sbBuffer[rc] = 0; - //rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps==0)); - rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps)); // different to windows since behavior on Linux is different - rgKey_16[iKey]->KMX_SetShiftState_16(ss, sbBuffer, false, (caps)); // different to windows since behavior on Linux is different + rgKey_16[iKey]->KMX_SetShiftState_16(ss, sbBuffer, false, (caps)); // different to windows since behavior on Linux is different } } else if(rc < 0) { sbBuffer[2] = 0; - //rgKey[iKey]->SetShiftState(ss, sbBuffer, true, (caps == 0)); - rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); // different to windows since behavior on Linux is different rgKey_16[iKey]->KMX_SetShiftState_16(ss, sbBuffer, true, (caps )); // different to windows since behavior on Linux is different refine_alDead(sbBuffer[0], alDead, &alDead_cpl); @@ -753,15 +739,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, kp->cxGroupArray++; gp = &kp->dpGroupArray[kp->cxGroupArray-1]; - UINT nKeys = 0; - for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { - // _S2 TOP_7 - if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { - nKeys+= rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()); - } - } - - UINT nKeys_16 = 0; for (UINT iKey_16 = 0; iKey_16 < rgKey_16.size(); iKey_16++) { @@ -778,9 +755,8 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, gp->dpMatch = NULL; gp->dpName = NULL; gp->dpNoMatch = NULL; - gp->cxKeyArray = nKeys; + gp->cxKeyArray = nKeys_16; gp->dpKeyArray = new KMX_KEY[gp->cxKeyArray]; - nKeys = 0; nKeys_16 = 0; From bca7bd6fba734eca6b5823b6a22e571ba1809ce5 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 5 Mar 2024 18:18:29 +0100 Subject: [PATCH 232/327] feat(linux): mcompile rename functions with _16 back --- linux/mcompile/keymap/deadkey.cpp | 9 - linux/mcompile/keymap/deadkey.h | 2 - linux/mcompile/keymap/keymap.cpp | 118 +------ linux/mcompile/keymap/keymap.h | 9 +- linux/mcompile/keymap/mc_import_rules.cpp | 412 ++++------------------ 5 files changed, 82 insertions(+), 468 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index a287b5303a..27d9dd7f9c 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -1,15 +1,6 @@ #include "keymap.h" #include "deadkey.h" -// _S2 TOP_7 ok -/*v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult) { - v_dw_1D line; - line.push_back(convertNamesTo_DWORD_Value(first)); - line.push_back(convertNamesTo_DWORD_Value(second)); - //line.push_back(convertNamesTo_DWORD_Value(nameresult)); - line.push_back(number); - return line; -}*/ v_dw_1D createLine(std::string first, std::string second, KMX_DWORD number, std::string nameresult) { v_dw_1D line; line.push_back(convertNamesTo_DWORD_Value(first)); diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index c68791bd78..d460c29746 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -6,9 +6,7 @@ #include #include "mc_import_rules.h" -// _S2 TOP_7 ok // create a vector for a dk combination ( ` + a -> à ) -//v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult); v_dw_1D createLine(std::string first, std::string second, KMX_DWORD number, std::string nameresult); // create a 2D-vector of all dk combinations ( ` + a -> à ; ^ + a -> â ; `+ e -> è; ...) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 52a4f53a0f..58a2e6fb77 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -10,77 +10,6 @@ int map_VKShiftState_to_LinModifier(int VKShiftState) { else return VKShiftState; } -// _S2 TOP_7 ok -/*KMX_DWORD convertNamesTo_DWORD_Value(std::wstring tok_wstr) { - // more on https://manpages.ubuntu.com/manpages/jammy/man3/keysyms.3tk.html - std::map first; - - first[L"ampersand"] = 38; - first[L"apostrophe"] = 39; - first[L"asciicircum"] = 136; - first[L"asciitilde"] = 126; - first[L"asterisk"] = 42; - first[L"at"] = 64; - first[L"backslash"] = 92; - first[L"BackSpace"] = 65288; - first[L"bar"] = 124; - first[L"braceleft"] = 123; - first[L"braceright"] = 125; - first[L"bracketleft"] = 91; - first[L"bracketright"] = 93; - first[L"colon"] = 58; - first[L"comma"] = 44; - first[L"diaeresis"] = 168; - first[L"dollar"] = 36; - first[L"equal"] = 61; - first[L"exclam"] = 33; - first[L"grave"] = 96; - first[L"greater"] = 62; - first[L"less"] = 60; - first[L"minus"] = 45; - first[L"numbersign"] = 35; - first[L"parenleft"] = 40; - first[L"parenright"] = 41; - first[L"percent"] = 37; - first[L"period"] = 46; - first[L"plus"] = 43; - first[L"question"] = 63; - first[L"quotedbl"] = 34; - first[L"semicolon"] = 59; - first[L"slash"] = 47; - first[L"space"] = 32; - first[L"ssharp"] = 223; - first[L"underscore"] = 95; - - first[L"dead_abovedot"] = 729; - first[L"dead_abovering"] = 730; - first[L"dead_acute"] = 180; - first[L"dead_breve"] = 728; - first[L"dead_caron"] = 711; - first[L"dead_cedilla"] = 184; - first[L"dead_circumflex"] = 94; - first[L"dead_diaeresis"] = 168; - first[L"dead_doubleacute"] = 733; - first[L"dead_grave"] = 96; - first[L"dead_ogonek"] = 731; - first[L"dead_perispomeni"] = 126; - first[L"dead_tilde"] = 126; - - first[L"acute accent"] = 0xB4; - - if ( tok_wstr.size() == 1) { - return (KMX_DWORD) ( *tok_wstr.c_str() ); - } - else { - std::map ::iterator it; - for (it = first.begin(); it != first.end(); ++it) { - if (it->first == tok_wstr) - return it->second; - } - } - return returnIfCharInvalid; -} -*/ KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str) { // more on https://manpages.ubuntu.com/manpages/jammy/man3/keysyms.3tk.html std::map first; @@ -561,7 +490,6 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { for ( int i = 1; i< (int) tokens.size();i++) { // replace a name with a single character ( a -> a ; equal -> = ) - // _S2 TOP_7 ok tokens_int = convertNamesTo_DWORD_Value(tokens[i]); //tokens_int = convertNamesTo_DWORD_Value( wstring_from_string(tokens[i])); @@ -652,29 +580,7 @@ bool IsKeymanUsedChar(int KV) { else return false; } -// _S2 TOP_7 ok -std::wstring convert_DeadkeyValues_ToWstr(int in) { - if (in == 0 ) - return L"\0"; - - std::string long_name((const char*) gdk_keyval_name (in)); // e.g. "dead_circumflex" , "U+017F" , "t" - - if ( long_name.substr (0,2) == "U+" ) // U+... Unicode value - return CodePointToWString(in-0x1000000); - - if (in < (int) deadkey_min) { // no deadkey; no Unicode - return std::wstring(1, in); - } - KMX_DWORD lname = convertNamesTo_DWORD_Value( long_name); // 65106 => "dead_circumflex" => 94 => "^" - //KMX_DWORD lname = convertNamesTo_DWORD_Value( wstring_from_string(long_name)); // 65106 => "dead_circumflex" => 94 => "^" - - if (lname != returnIfCharInvalid) { - return std::wstring(1, lname ); - } - else - return L"\0"; -} std::u16string convert_DeadkeyValues_To_U16str(int in) { if (in == 0 ) @@ -683,7 +589,7 @@ std::u16string convert_DeadkeyValues_To_U16str(int in) { std::string long_name((const char*) gdk_keyval_name (in)); // e.g. "dead_circumflex" , "U+017F" , "t" if ( long_name.substr (0,2) == "U+" ) // U+... Unicode value - return CodePointToString_16(in-0x1000000); + return CodePointToU16String(in-0x1000000); if (in < (int) deadkey_min) { // no deadkey; no Unicode return std::u16string(1, in); @@ -858,7 +764,6 @@ KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(v_dw_3D & All_Vector, KMX_DWORD KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap *keymap, v_dw_3D &All_Vector, KMX_DWORD KC_US, ShiftState ss, int caps) { KMX_DWORD KC_underlying; std::u16string u16str = convert_DeadkeyValues_To_U16str(KMX_get_KeyVal_From_KeyCode(keymap, KC_US, ss, caps)); - // std::wstring ws = convert_DeadkeyValues_ToWstr(KMX_get_KeyVal_From_KeyCode(keymap, KC_US, ss, caps)); //Find KC_underlying character for( int i=0; i< (int)All_Vector[1].size()-1 ;i++) { @@ -884,26 +789,7 @@ KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying(KMX_DWORD keycode) { return 0; } -// _S2 TOP_7 ok -std::wstring CodePointToWString(unsigned int codepoint) { - std::wstring str; - - if constexpr (sizeof(wchar_t) > 2) { - str = static_cast(codepoint); - } - else if (codepoint <= 0xFFFF) { - str = static_cast(codepoint); - } - else { - codepoint -= 0x10000; - str.resize(2); - str[0] = static_cast(0xD800 + ((codepoint >> 10) & 0x3FF)); - str[1] = static_cast(0xDC00 + (codepoint & 0x3FF)); - } - - return str; -} -std::u16string CodePointToString_16(unsigned int codepoint) { +std::u16string CodePointToU16String(unsigned int codepoint) { std::u16string str; if constexpr (sizeof(wchar_t) > 2) { diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 99a10028da..06cfd05704 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -71,9 +71,8 @@ static KMX_DWORD deadkey_min = 0xfe50; static KMX_DWORD deadkey_max = 0xfe52; // _S2 TOP_6 TODO This has to go! my test: to only return 3 dk int map_VKShiftState_to_LinModifier(int VKShiftState); -// _S2 TOP_7 ok + // take a std::wstring (=contents of line symbols-file ) and returns the (int) value of the character -//KMX_DWORD convertNamesTo_DWORD_Value(std::wstring tok_wstr); KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str); // create a Vector with all entries of both keymaps+ keymap @@ -503,9 +502,7 @@ const UINT ScanCodeToUSVirtualKey[128] = { bool IsKeymanUsedChar(int KV); //------------------------------ -// _S2 TOP_7 ok // take deadkey-value (e.g.65106) and return wstring (e.g. '^' ) -std::wstring convert_DeadkeyValues_ToWstr(int in); std::u16string convert_DeadkeyValues_To_U16str(int in); // use gdk_keymap_translate_keyboard_state to get keyval - base function to get keyvals @@ -530,8 +527,6 @@ UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying(KMX_DWORD keycode); // convert codePoint to wstring -// _S2 TOP_7 ok -std::wstring CodePointToWString(unsigned int codepoint); -std::u16string CodePointToString_16(unsigned int codepoint); +std::u16string CodePointToU16String(unsigned int codepoint); # endif /*KEYMAP_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index ed00746c09..980e1c17f1 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -75,12 +75,10 @@ int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int if (!(keycode <= keycode_max)) return 0; -// _S2 TOP_7 ok + KMX_DWORD KeyVal= (KMX_DWORD) KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(shift_state_pos), caps); - //std::wstring str = convert_DeadkeyValues_ToWstr(KeyVal); - // pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(str).c_str(); - std::u16string str_16 = convert_DeadkeyValues_To_U16str(KeyVal); - pwszBuff[0]= * (PKMX_WCHAR) str_16.c_str(); + std::u16string str = convert_DeadkeyValues_To_U16str(KeyVal); + pwszBuff[0]= * (PKMX_WCHAR) str.c_str(); g_free(keyvals); @@ -111,28 +109,15 @@ int KMX_DeadKeyMap(int index, std::vector *deadkeys, int deadkeyBase, class KMX_VirtualKey { private: - //KMX_HKL m_hkl; // _S2 QUESTION do I need this and is void* OK to assume? If I remove this, will there be changes in Data-Vectors? UINT m_vk; UINT m_sc; bool m_rgfDeadKey[10][2]; - std::wstring m_rgss[10][2]; - // _S2 TOP_7 - // std::u16string m_rgss_16[10][2]; + std::u16string m_rgss[10][2]; public: - // _S2 TODO I assume we do not need those... - /*KMX_VirtualKey(KMX_HKL hkl,UINT virtualKey) { - this->m_sc = KMX_get_KeyCodeUnderlying_From_VKUS(virtualKey); - this->m_hkl = hkl; - this->m_vk = virtualKey; - memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); - }*/ - - //KMX_VirtualKey(UINT scanCode, KMX_HKL hkl) { KMX_VirtualKey(UINT scanCode) { this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying(scanCode); - //this->m_hkl = hkl; this->m_sc = scanCode; memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); } @@ -144,62 +129,61 @@ public: UINT SC() { return this->m_sc; } -// _S2 TOP_7 ok - std::wstring KMX_GetShiftState(ShiftState shiftState, bool capsLock) { + + std::u16string KMX_GetShiftState(ShiftState shiftState, bool capsLock) { return this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)]; } - void KMX_SetShiftState(ShiftState shiftState, std::u16string value16, bool isDeadKey, bool capsLock) { - std::wstring value = wstring_from_u16string(value16); + void KMX_SetShiftState(ShiftState shiftState, std::u16string value, bool isDeadKey, bool capsLock) { this->m_rgfDeadKey[(UINT)shiftState][(capsLock ? 1 : 0)] = isDeadKey; this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; } bool KMX_IsSGCAPS() { - std::wstring stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß - std::wstring stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? - std::wstring stCaps = this->KMX_GetShiftState(Base, true); // 0,1 A 4 ẞ - std::wstring stShiftCaps = this->KMX_GetShiftState(Shft, true); // 1,1 a $ ? - return ( - ((stCaps.size() > 0) && - (stBase.compare(stCaps) != 0) && // stBase != stCaps - (stShift.compare(stCaps) != 0)) || // stShift!= stCaps - ((stShiftCaps.size() > 0) && - (stBase.compare(stShiftCaps) != 0) && // stBase != stShiftCaps - (stShift.compare(stShiftCaps) != 0))); // stShift!= stShiftCaps - } + std::u16string stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß + std::u16string stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? + std::u16string stCaps = this->KMX_GetShiftState(Base, true); // 0,1 A 4 ẞ + std::u16string stShiftCaps = this->KMX_GetShiftState(Shft, true); // 1,1 a $ ? + return ( + ((stCaps.size() > 0) && + (stBase.compare(stCaps) != 0) && // stBase != stCaps + (stShift.compare(stCaps) != 0)) || // stShift!= stCaps + ((stShiftCaps.size() > 0) && + (stBase.compare(stShiftCaps) != 0) && // stBase != stShiftCaps + (stShift.compare(stShiftCaps) != 0))); // stShift!= stShiftCaps + } bool KMX_IsCapsEqualToShift() { - std::wstring stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß - std::wstring stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? - std::wstring stCaps = this->KMX_GetShiftState(Base, true); // 0,1 A 4 ẞ - return ( - (stBase.size() > 0) && // unshifted char inside - (stShift.size() > 0) && // shifted char inside - (stBase.compare(stShift) != 0) && // stBase != stShft - (stShift.compare(stCaps) == 0)); // stShft == stCaps - } + std::u16string stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß + std::u16string stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? + std::u16string stCaps = this->KMX_GetShiftState(Base, true); // 0,1 A 4 ẞ + return ( + (stBase.size() > 0) && // unshifted char inside + (stShift.size() > 0) && // shifted char inside + (stBase.compare(stShift) != 0) && // stBase != stShft + (stShift.compare(stCaps) == 0)); // stShft == stCaps + } bool KMX_IsAltGrCapsEqualToAltGrShift() { - std::wstring stBase = this->KMX_GetShiftState(MenuCtrl, false); // 0,0 - std::wstring stShift = this->KMX_GetShiftState(ShftMenuCtrl, false); // 1,0 - std::wstring stCaps = this->KMX_GetShiftState(MenuCtrl, true); // 0,1 - return ( - (stBase.size() > 0) && // unshifted MenuCtrl/AltGr char inside - (stShift.size() > 0) && // shifted MenuCtrl/AltGr char inside - (stBase.compare(stShift) != 0) && // stBase != stShft - (stShift.compare(stCaps) == 0)); // stShft == stCaps - } + std::u16string stBase = this->KMX_GetShiftState(MenuCtrl, false); // 0,0 + std::u16string stShift = this->KMX_GetShiftState(ShftMenuCtrl, false); // 1,0 + std::u16string stCaps = this->KMX_GetShiftState(MenuCtrl, true); // 0,1 + return ( + (stBase.size() > 0) && // unshifted MenuCtrl/AltGr char inside + (stShift.size() > 0) && // shifted MenuCtrl/AltGr char inside + (stBase.compare(stShift) != 0) && // stBase != stShft + (stShift.compare(stCaps) == 0)); // stShft == stCaps + } bool KMX_IsXxxxGrCapsEqualToXxxxShift() { - std::wstring stBase = this->KMX_GetShiftState(Xxxx, false); - std::wstring stShift = this->KMX_GetShiftState(ShftXxxx, false); - std::wstring stCaps = this->KMX_GetShiftState(Xxxx, true); - return ( - (stBase.size() > 0) && - (stShift.size() > 0) && - (stBase.compare(stShift) != 0) && - (stShift.compare(stCaps) == 0)); + std::u16string stBase = this->KMX_GetShiftState(Xxxx, false); + std::u16string stShift = this->KMX_GetShiftState(ShftXxxx, false); + std::u16string stCaps = this->KMX_GetShiftState(Xxxx, true); + return ( + (stBase.size() > 0) && + (stShift.size() > 0) && + (stBase.compare(stShift) != 0) && + (stShift.compare(stCaps) == 0)); } bool KMX_IsEmpty() { @@ -216,7 +200,7 @@ public: bool KMX_IsKeymanUsedKey() { return (this->m_vk >= 0x20 && this->m_vk <= 0x5F) || (this->m_vk >= 0x88); } - + UINT KMX_GetShiftStateValue(int capslock, int caps, ShiftState ss) { return KMX_ShiftStateMap[(int)ss] | (capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0); } @@ -238,9 +222,8 @@ public: continue; } for (int caps = 0; caps <= 1; caps++) { - // _S2 TOP_7 - std::wstring st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); - //std::u16string st = this->KMX_GetShiftState_16((ShiftState) ss, (caps == 1)); + + std::u16string st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); if (st.size() == 0) { // No character assigned here @@ -250,7 +233,11 @@ public: } else { bool isvalid = true; for (size_t ich = 0; ich < st.size(); ich++) { - if(st[ich] < 0x20 || st[ich] == 0x7F) { isvalid=false; break; } + if(st[ich] < 0x20 || st[ich] == 0x7F) { + isvalid=false; + + wprintf(L"invalid for: %i\n", st[ich]); + break; } } if(isvalid) { nkeys++; @@ -263,7 +250,6 @@ public: bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,v_dw_3D &All_Vector, GdkKeymap *keymap) { // I4552 // Get the CAPSLOCK value - int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | (this->KMX_IsSGCAPS() ? 2 : 0) | @@ -278,8 +264,8 @@ public: continue; } for (int caps = 0; caps <= 1; caps++) { - // _S2 TOP_7 - std::wstring st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); + std::u16string st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); + PKMX_WCHAR p; if (st.size() == 0) { @@ -295,241 +281,6 @@ public: key->Key = this->VK(); key->Line = 0; - if(bDeadkeyConversion) { // I4552 - p = key->dpOutput = new KMX_WCHAR[2]; - *p++ = st[0]; - *p = 0; - } else { - - p = key->dpOutput = new KMX_WCHAR[4]; - *p++ = UC_SENTINEL; - *p++ = CODE_DEADKEY; - *p++ = KMX_DeadKeyMap(st[0], deadkeys, deadkeyBase, &KMX_FDeadkeys); // I4353 - *p = 0; - } - key++; - } - else { - bool isvalid = true; - for (size_t ich = 0; ich < st.size(); ich++) { - if(st[ich] < 0x20 || st[ich] == 0x7F) { isvalid=false; break; } - } - if(isvalid) { - // this is different to mcompile windows !!!! - // this->m_sc stores SC-US = SCUnderlying - // this->m_vk stores VK-US ( not underlying !!) - // key->Key stores VK-US ( not underlying !!) - // key->dpOutput stores character Underlying - - KMX_DWORD SC_Underlying = KMX_get_KeyCodeUnderlying_From_KeyCodeUS(keymap, All_Vector, this->SC(), (ShiftState) ss, caps); - key->Key = KMX_get_VKUS_From_KeyCodeUnderlying( SC_Underlying); - - key->Line = 0; - key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); - - key->dpContext = new KMX_WCHAR; - *key->dpContext = 0; - p = key->dpOutput = new KMX_WCHAR[st.size() + 1]; - for(size_t ich = 0; ich < st.size(); ich++) { - *p++ = st[ich]; - } - *p = 0; - key++; - } - } - } - } - return true; - } -}; - - -class KMX_VirtualKey_16 { -private: - //KMX_HKL m_hkl; // _S2 QUESTION do I need this and is void* OK to assume? If I remove this, will there be changes in Data-Vectors? - UINT m_vk; - UINT m_sc; - bool m_rgfDeadKey[10][2]; - std::u16string m_rgss_16[10][2]; - -public: - - // _S2 TODO I assume we do not need those... - /*KMX_VirtualKey(KMX_HKL hkl,UINT virtualKey) { - this->m_sc = KMX_get_KeyCodeUnderlying_From_VKUS(virtualKey); - this->m_hkl = hkl; - this->m_vk = virtualKey; - memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); - }*/ - - KMX_VirtualKey_16(UINT scanCode) { - this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying(scanCode); - //this->m_hkl = hkl; - this->m_sc = scanCode; - memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); - } - - UINT VK() { - return this->m_vk; - } - - UINT SC() { - return this->m_sc; - } -// _S2 TOP_7 ok - std::u16string KMX_GetShiftState_16(ShiftState shiftState, bool capsLock) { - return this->m_rgss_16[(UINT)shiftState][(capsLock ? 1 : 0)]; - } - // _S2 TOP_7 - void KMX_SetShiftState_16(ShiftState shiftState, std::u16string value_16, bool isDeadKey, bool capsLock) { - std::u16string value = value_16; - this->m_rgfDeadKey[(UINT)shiftState][(capsLock ? 1 : 0)] = isDeadKey; - this->m_rgss_16[(UINT)shiftState][(capsLock ? 1 : 0)] = value; - } - -bool KMX_IsSGCAPS_16() { - std::u16string stBase = this->KMX_GetShiftState_16(Base, false); // 0,0 a 4 ß - std::u16string stShift = this->KMX_GetShiftState_16(Shft, false); // 1,0 A $ ? - std::u16string stCaps = this->KMX_GetShiftState_16(Base, true); // 0,1 A 4 ẞ - std::u16string stShiftCaps = this->KMX_GetShiftState_16(Shft, true); // 1,1 a $ ? - return ( - ((stCaps.size() > 0) && - (stBase.compare(stCaps) != 0) && // stBase != stCaps - (stShift.compare(stCaps) != 0)) || // stShift!= stCaps - ((stShiftCaps.size() > 0) && - (stBase.compare(stShiftCaps) != 0) && // stBase != stShiftCaps - (stShift.compare(stShiftCaps) != 0))); // stShift!= stShiftCaps - } - -bool KMX_IsCapsEqualToShift_16() { - std::u16string stBase = this->KMX_GetShiftState_16(Base, false); // 0,0 a 4 ß - std::u16string stShift = this->KMX_GetShiftState_16(Shft, false); // 1,0 A $ ? - std::u16string stCaps = this->KMX_GetShiftState_16(Base, true); // 0,1 A 4 ẞ - return ( - (stBase.size() > 0) && // unshifted char inside - (stShift.size() > 0) && // shifted char inside - (stBase.compare(stShift) != 0) && // stBase != stShft - (stShift.compare(stCaps) == 0)); // stShft == stCaps - } - -bool KMX_IsAltGrCapsEqualToAltGrShift_16() { - std::u16string stBase = this->KMX_GetShiftState_16(MenuCtrl, false); // 0,0 - std::u16string stShift = this->KMX_GetShiftState_16(ShftMenuCtrl, false); // 1,0 - std::u16string stCaps = this->KMX_GetShiftState_16(MenuCtrl, true); // 0,1 - return ( - (stBase.size() > 0) && // unshifted MenuCtrl/AltGr char inside - (stShift.size() > 0) && // shifted MenuCtrl/AltGr char inside - (stBase.compare(stShift) != 0) && // stBase != stShft - (stShift.compare(stCaps) == 0)); // stShft == stCaps - } - -bool KMX_IsXxxxGrCapsEqualToXxxxShift_16() { -std::u16string stBase = this->KMX_GetShiftState_16(Xxxx, false); -std::u16string stShift = this->KMX_GetShiftState_16(ShftXxxx, false); -std::u16string stCaps = this->KMX_GetShiftState_16(Xxxx, true); -return ( - (stBase.size() > 0) && - (stShift.size() > 0) && - (stBase.compare(stShift) != 0) && - (stShift.compare(stCaps) == 0)); -} - - bool KMX_IsEmpty_16() { - for (int i = 0; i < 10; i++) { - for (int j = 0; j <= 1; j++) { - if (this->KMX_GetShiftState_16((ShiftState)i, (j == 1)).size() > 0) { - return (false); - } - } - } - return true; - } - - bool KMX_IsKeymanUsedKey() { - return (this->m_vk >= 0x20 && this->m_vk <= 0x5F) || (this->m_vk >= 0x88); - } - - UINT KMX_GetShiftStateValue_16(int capslock, int caps, ShiftState ss) { - return KMX_ShiftStateMap[(int)ss] | (capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0); - } - - int KMX_GetKeyCount_16(int MaxShiftState) { - int nkeys_16 = 0; - - // Get the CAPSLOCK value - //_S2 TOP_6 INFO not used in original code; can be deleted - /*int capslock = - (this->KMX_IsCapsEqualToShift() ? 1 : 0) | - (this->KMX_IsSGCAPS() ? 2 : 0) | - (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0);*/ - - for (int ss = 0; ss <= MaxShiftState; ss++) { - if (ss == Menu || ss == ShftMenu) { - // Alt and Shift+Alt don't work, so skip them - continue; - } - for (int caps = 0; caps <= 1; caps++) { - // _S2 TOP_7 - std::u16string st = this->KMX_GetShiftState_16((ShiftState) ss, (caps == 1)); - - if (st.size() == 0) { - // No character assigned here - } else if (this->m_rgfDeadKey[(int)ss][caps]) { - // It's a dead key, append an @ sign. - nkeys_16++; - } else { - bool isvalid = true; - for (size_t ich = 0; ich < st.size(); ich++) { - if(st[ich] < 0x20 || st[ich] == 0x7F) { - isvalid=false; - - wprintf(L"invalid for: %i\n", st[ich]); - break; } - } - if(isvalid) { - nkeys_16++; - } - } - } - } - return nkeys_16; - } - - bool KMX_LayoutRow_16(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,v_dw_3D &All_Vector, GdkKeymap *keymap) { // I4552 - // Get the CAPSLOCK value - int capslock = - (this->KMX_IsCapsEqualToShift_16() ? 1 : 0) | - (this->KMX_IsSGCAPS_16() ? 2 : 0) | - (this->KMX_IsAltGrCapsEqualToAltGrShift_16() ? 4 : 0) | - (this->KMX_IsXxxxGrCapsEqualToXxxxShift_16() ? 8 : 0); - // _S2 we need this capslock calculation - //capslock=1;*/ - - for (int ss = 0; ss <= MaxShiftState; ss++) { - if (ss == Menu || ss == ShftMenu) { - // Alt and Shift+Alt don't work, so skip them - continue; - } - for (int caps = 0; caps <= 1; caps++) { - // _S2 TOP_7 - std::u16string st = this->KMX_GetShiftState_16((ShiftState) ss, (caps == 1)); - - PKMX_WCHAR p; - - if (st.size() == 0) { - // No character assigned here - } - else if (this->m_rgfDeadKey[(int)ss][caps]) { - // It's a dead key, append an @ sign. - key->dpContext = new KMX_WCHAR[1]; - *key->dpContext = 0; - - key->ShiftFlags = this->KMX_GetShiftStateValue_16(capslock, caps, (ShiftState) ss); - // we already use VK_US so no need to convert it as we do on windows - key->Key = this->VK(); - key->Line = 0; - if(bDeadkeyConversion) { // I4552 p = key->dpOutput = new KMX_WCHAR[2]; *p++ = st[0]; @@ -563,7 +314,7 @@ return ( key->Key = KMX_get_VKUS_From_KeyCodeUnderlying( SC_Underlying); key->Line = 0; - key->ShiftFlags = this->KMX_GetShiftStateValue_16(capslock, caps, (ShiftState) ss); + key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); key->dpContext = new KMX_WCHAR; *key->dpContext = 0; @@ -604,10 +355,6 @@ public: return (Get_XxxxVk() == 0 ? ShftMenuCtrl : ShftXxxx); } - // _S2 TOP_6 ToDo Do we need one/none? - bool KMX_IsControlChar(wchar_t ch) { - return (ch < 0x0020) || (ch >= 0x007F && ch <= 0x009F); - } bool KMX_IsControlChar(char16_t ch) { return (ch < 0x0020) || (ch >= 0x007F && ch <= 0x009F); } @@ -629,11 +376,11 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, //KMX_HKL hkl = NULL; - std::vector rgKey_16; //= new VirtualKey[256]; + std::vector rgKey; //= new VirtualKey[256]; std::vector alDead; std::vector alDead_cpl = create_alDead(); - rgKey_16.resize(256); + rgKey.resize(256); // Scroll through the Scan Code (SC) values and get the valid Virtual Key (VK) // values in it. Then, store the SC in each valid VK so it can act as both a @@ -646,14 +393,12 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // Linux cannot get a VK for the underling Keyboard // this "connection" is possible only when using All_Vector - //KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl); - KMX_VirtualKey_16 *key_16 = new KMX_VirtualKey_16(sc); + KMX_VirtualKey *key = new KMX_VirtualKey(sc); - - if((key_16->VK() != 0) ) { - rgKey_16[key_16->VK()] = key_16; + if((key->VK() != 0) ) { + rgKey[key->VK()] = key; } else { - delete key_16; + delete key; } } @@ -663,9 +408,9 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL);*/ // in this part we skip shiftstates 4, 5, 8, 9 - for(UINT iKey = 0; iKey < rgKey_16.size(); iKey++) { + for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { - if(rgKey_16[iKey] != NULL) { + if(rgKey[iKey] != NULL) { KMX_WCHAR sbBuffer[256]; // Scratchpad we use many places for(ShiftState ss = Base; ss <= loader.KMX_MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { @@ -686,19 +431,19 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, if(rc > 0) { if(*sbBuffer == 0) { - rgKey_16[iKey]->KMX_SetShiftState_16(ss, u"", false, (caps)); // different to windows since behavior on Linux is different + rgKey[iKey]->KMX_SetShiftState(ss, u"", false, (caps)); // different to windows since behavior on Linux is different } else { if( (ss == Ctrl || ss == ShftCtrl) ) { continue; } sbBuffer[rc] = 0; - rgKey_16[iKey]->KMX_SetShiftState_16(ss, sbBuffer, false, (caps)); // different to windows since behavior on Linux is different + rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps)); // different to windows since behavior on Linux is different } } else if(rc < 0) { sbBuffer[2] = 0; - rgKey_16[iKey]->KMX_SetShiftState_16(ss, sbBuffer, true, (caps )); // different to windows since behavior on Linux is different + rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); // different to windows since behavior on Linux is different refine_alDead(sbBuffer[0], alDead, &alDead_cpl); } @@ -740,11 +485,10 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, kp->cxGroupArray++; gp = &kp->dpGroupArray[kp->cxGroupArray-1]; - UINT nKeys_16 = 0; - for (UINT iKey_16 = 0; iKey_16 < rgKey_16.size(); iKey_16++) { - // _S2 TOP_7 - if ((rgKey_16[iKey_16] != NULL) && rgKey_16[iKey_16]->KMX_IsKeymanUsedKey() && (!rgKey_16[iKey_16]->KMX_IsEmpty_16())) { - nKeys_16+= rgKey_16[iKey_16]->KMX_GetKeyCount_16(loader.KMX_MaxShiftState()); + UINT nkeys = 0; + for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { + if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { + nkeys+= rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()); } } @@ -755,24 +499,24 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, gp->dpMatch = NULL; gp->dpName = NULL; gp->dpNoMatch = NULL; - gp->cxKeyArray = nKeys_16; + gp->cxKeyArray = nkeys; gp->dpKeyArray = new KMX_KEY[gp->cxKeyArray]; - nKeys_16 = 0; + nkeys = 0; // // Fill in the new rules // //fills group3: group(group3) using keys - for (UINT iKey_16 = 0; iKey_16 < rgKey_16.size(); iKey_16++) { - if ((rgKey_16[iKey_16] != NULL) && rgKey_16[iKey_16]->KMX_IsKeymanUsedKey() && (!rgKey_16[iKey_16]->KMX_IsEmpty_16())) { - if(rgKey_16[iKey_16]->KMX_LayoutRow_16(loader.KMX_MaxShiftState(), &gp->dpKeyArray[nKeys_16], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 - nKeys_16+=rgKey_16[iKey_16]->KMX_GetKeyCount_16(loader.KMX_MaxShiftState()); + for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { + if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { + if(rgKey[iKey]->KMX_LayoutRow(loader.KMX_MaxShiftState(), &gp->dpKeyArray[nkeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 + nkeys+=rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()); } } } - gp->cxKeyArray = nKeys_16; + gp->cxKeyArray = nkeys; // // Add nomatch control to each terminating 'using keys' group // I4550 From 2d364bfb6608e9754e83dd561510256ece84e2e4 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 1 Mar 2024 15:59:57 +0100 Subject: [PATCH 233/327] feat(linux): mcompile-dk start replace wchar_t feat(linux): mcompile-dk replace wchar_t create duplicate u16.functions (no implem. yet) feat(linux): mcompile-dk replace wchar_t disable some old wchar_t functions feat(linux): mcompile-dk replace wchar_t disable more old wchar_t functions feat(linux): mcompile-dk char16 works feat(linux): mcompile remove _16 where I do not need them feat(linux): mcompile remove even more _16 where I do not need them feat(linux): mcompile rename functions with _16 back --- .gitignore | 2 + linux/mcompile/keymap/README.md | 1 + linux/mcompile/keymap/deadkey.cpp | 387 +++++++++++++++++++++- linux/mcompile/keymap/deadkey.h | 3 +- linux/mcompile/keymap/keymap.cpp | 382 +++++++++++++++------ linux/mcompile/keymap/keymap.h | 7 +- linux/mcompile/keymap/mc_import_rules.cpp | 163 ++++----- 7 files changed, 737 insertions(+), 208 deletions(-) diff --git a/.gitignore b/.gitignore index 6b9eb20370..6a40380344 100644 --- a/.gitignore +++ b/.gitignore @@ -204,3 +204,5 @@ lcov.info /linux/mcompile/keymap/*.kmx + +/GTK_PLAYGROUND \ No newline at end of file diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index 6fac301e91..f0d61f8dab 100755 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -18,6 +18,7 @@ _S2 TOP_2 Shiftflags _S2 TOP_4 HKL _S2 TOP_5 use files/functions from other places _S2 TOP_6 remaining +_S2 TOP_7 wchar_t->char16_t ./mcompile -d /Projects/keyman/keyman/linux/mcompile/keymap/mcompile_test.kmx bla.dll 0407 /Projects/keyman/keyman/linux/mcompile/keymap/mcompile_test_out.kmx diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 9c273d9c83..27d9dd7f9c 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -1,7 +1,7 @@ #include "keymap.h" #include "deadkey.h" -v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult) { +v_dw_1D createLine(std::string first, std::string second, KMX_DWORD number, std::string nameresult) { v_dw_1D line; line.push_back(convertNamesTo_DWORD_Value(first)); line.push_back(convertNamesTo_DWORD_Value(second)); @@ -113,13 +113,390 @@ KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap return Cap; } -// _S2 TOP_3 is this the right place to get dk from? if not where are they stored? void create_DKTable(v_dw_2D & dk_ComposeTable) { //create a 2D-Vector which contains data for ALL existing deadkey combinations on a Linux Keyboard: //dk_ComposeTable[i][0] : First (e.g. dead_circumflex) //dk_ComposeTable[i][1] : Second (e.g. a) //dk_ComposeTable[i][3] : Unicode-Value (e.g. 0x00E2) + //values taken from: https://help.ubuntu.com/community/GtkDeadKeyTable#Accents + // _S2 Do we really want to use GTK instead of this function? + + v_dw_1D line; + + line = createLine("dead_circumflex", "a", 0x00E2, "small A with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "A", 0x00C2, "capital A with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "e", 0x00EA, "small E with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "E", 0x00CA, "capital E with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "i", 0x00EE, "small I with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "I", 0x00CE, "capital I with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "o", 0x00F4, "small O with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "O", 0x00D4, "capital O with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "u", 0x00FB, "small U with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "U", 0x00DB, "capital U with circumflex"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_acute", "a", 0x00E1, "small A with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "A", 0x00C1, "capital A with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "c", 0x0107, "small C with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "C", 0x0106, "capital C with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "e", 0x00E9, "small E with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "E", 0x00C9, "capital E with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "i", 0x00ED, "small I with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "I", 0x00CD, "capital I with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "l", 0x013A, "small L with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "L", 0x0139, "capital L with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "n", 0x0144, "small N with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "N", 0x0143, "capital N with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "o", 0x00F3, "small O with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "O", 0x00D3, "capital O with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "r", 0x0155, "small R with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "R", 0x0154, "capital R with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "s", 0x015B, "small S with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "S", 0x015A, "capital S with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "u", 0x00FA, "small U with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "U", 0x00DA, "capital U with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "y", 0x00FD, "small Y with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "Y", 0x00DD, "capital Y with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "z", 0x017A, "small Z with acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "Z", 0x0179, "capital Z with acute"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_grave", "a", 0x00E0, "small A with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_grave", "A", 0x00C0, "capital A with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_grave", "e", 0x00E8, "small E with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_grave", "E", 0x00C8, "capital E with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_grave", "i", 0x00EC, "small I with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_grave", "I", 0x00CC, "capital I with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_grave", "o", 0x00F2, "small O with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_grave", "O", 0x00D2, "capital O with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_grave", "u", 0x00F9, "small U with grave"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_grave", "U", 0x00D9, "capital U with grave"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_tilde", "a", 0x00E3, "small A with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_tilde", "A", 0x00C3, "capital A with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_tilde", "i", 0x0129, "small I with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_tilde", "I", 0x0128, "capital I with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_tilde", "n", 0x00F1, "small N with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_tilde", "N", 0x00D1, "capital N with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_tilde", "o", 0x00F5, "small O with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_tilde", "O", 0x00D5, "capital O with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_tilde", "u", 0x0169, "small U with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_tilde", "U", 0x0168, "capital U with tilde"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_macron", "a", 0x0101, "small A with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_macron", "A", 0x0100, "capital A with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_macron", "e", 0x0113, "small E with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_macron", "E", 0x0112, "capital E with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_macron", "i", 0x012B, "small I with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_macron", "I", 0x012A, "capital I with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_macron", "o", 0x014D, "small O with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_macron", "O", 0x014C, "capital O with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_macron", "u", 0x016B, "small U with macron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_macron", "U", 0x016A, "capital U with macron"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_breve", "a", 0x0103, "small A with breve"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_breve", "A", 0x0102, "capital A with breve"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_breve", "g", 0x011F, "small G with breve"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_breve", "G", 0x011E, "capital G with breve"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_abovedot", "e", 0x0117, "small E with dot above"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovedot", "E", 0x0116, "capital E with dot above"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovedot", "i", 0x0131, "small DOTLESS_I"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovedot", "I", 0x0130, "capital I with dot above"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovedot", "z", 0x017C, "small Z with dot above"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovedot", "Z", 0x017B, "capital Z with dot above"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_diaeresis", "a", 0x00E4, "small A with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "A", 0x00C4, "capital A with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "e", 0x00EB, "small E with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "E", 0x00CB, "capital E with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "i", 0x00EF, "small I with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "I", 0x00CF, "capital I with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "o", 0x00F6, "small O with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "O", 0x00D6, "capital O with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "u", 0x00FC, "small U with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "U", 0x00DC, "capital U with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "y", 0x00FF, "small Y with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "Y", 0x0178, "capital Y with diaeresis"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_abovering", "a", 0x00E5, "small A with ring above"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovering", "A", 0x00C5, "capital A with ring above"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovering", "u", 0x016F, "small U with ring above"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovering", "U", 0x016E, "capital U with ring above"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_doubleacute", "o", 0x0151, "small O with double acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_doubleacute", "O", 0x0150, "capital O with double acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_doubleacute", "u", 0x0171, "small U with double acute"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_doubleacute", "U", 0x0170, "capital U with double acute"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_caron", "c", 0x010D, "small C with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "C", 0x010C, "capital C with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "d", 0x010F, "small D with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "D", 0x010E, "capital D with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "e", 0x011B, "small E with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "E", 0x011A, "capital E with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "l", 0x013E, "small L with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "L", 0x013D, "capital L with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "n", 0x0148, "small N with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "N", 0x0147, "capital N with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "r", 0x0159, "small R with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "R", 0x0158, "capital R with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "s", 0x0161, "small S with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "S", 0x0160, "capital S with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "t", 0x0165, "small T with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "T", 0x0164, "capital T with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "z", 0x017E, "small Z with caron"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "Z", 0x017D, "capital Z with caron"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_cedilla", "c", 0x00E7, "small C with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "C", 0x00C7, "capital C with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "g", 0x0123, "small G with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "G", 0x0122, "capital G with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "k", 0x0137, "small K with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "K", 0x0136, "capital K with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "l", 0x013C, "small L with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "L", 0x013B, "capital L with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "n", 0x0146, "small N with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "N", 0x0145, "capital N with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "r", 0x0157, "small R with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "R", 0x0156, "capital R with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "s", 0x015F, "small S with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "S", 0x015E, "capital S with cedilla"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_ogonek", "a", 0x0105, "small A with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_ogonek", "A", 0x0104, "capital A with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_ogonek", "e", 0x0119, "small E with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_ogonek", "E", 0x0118, "capital E with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_ogonek", "i", 0x012F, "small I with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_ogonek", "I", 0x012E, "capital I with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_ogonek", "u", 0x0173, "small U with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_ogonek", "U", 0x0172, "capital U with ogonek"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_circumflex", "space", 0x005E, "CIRCUMFLEX_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_acute", "space", 0x0027, "APOSTROPHE"); + dk_ComposeTable.push_back(line); line.clear(); + /*line = createLine("dead_acute", "space", 0x00B4, "ACUTE_ACCENT"); // _S2 TOP_3 ToDo remove - just for testing + dk_ComposeTable.push_back(line); line.clear();*/ + + line = createLine("dead_grave", "space", 0x0060, "GRAVE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_breve", "space", 0x02D8, "BREVE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovedot", "space", 0x02D9, "DOT_ABOVE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovering", "space", 0x02DA, "RING_ABOVE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_doubleacute", "space", 0x02DD, "DOUBLE_ACUTE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "space", 0x02C7, "CARON"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "space", 0x00B8, "CEDILLA"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_ogonek", "space", 0x02DB, "OGONEK"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_tilde", "space", 0x007E, "TILDE"); + dk_ComposeTable.push_back(line); line.clear(); + + line = createLine("dead_breve", "dead_breve", 0x02D8, "BREVE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovedot", "abovedot", 0x02D9, "DOT_ABOVE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovedot", "dead_abovedot", 0x02D9, "DOT_ABOVE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_abovering", "dead_abovering", 0x02DA, "RING_ABOVE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "apostrophe", 0x00B4, "ACUTE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "acute", 0x00B4, "ACUTE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_acute", "dead_acute", 0x00B4, "ACUTE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_doubleacute", "dead_doubleacute", 0x02DD, "DOUBLE_ACUTE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "caron", 0x02C7, "CARON"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_caron", "dead_caron", 0x02C7, "CARON"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "comma", 0x00B8, "CEDILLA"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "cedilla", 0x00B8, "CEDILLA"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_cedilla", "dead_cedilla", 0x00B8, "CEDILLA"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "minus", 0x00AF, "MACRON"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "asciicircum", 0x005E, "CIRCUMFLEX_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "underscore", 0x00AF, "MACRON"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_circumflex", "dead_circumflex", 0x005E, "CIRCUMFLEX_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "quotedbl", 0x00A8, "DIAERESIS"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "diaeresis", 0x00A8, "DIAERESIS"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_diaeresis", "dead_diaeresis", 0x00A8, "DIAERESIS"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_grave", "grave", 0x0060, "GRAVE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_grave", "dead_grave", 0x0060, "GRAVE_ACCENT"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_macron", "macron", 0x00AF, "MACRON"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_macron", "dead_macron", 0x00AF, "MACRON"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_ogonek", "ogonek", 0x02DB, "OGONEK"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_ogonek", "dead_ogonek", 0x02DB, "OGONEK"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_tilde", "asciitilde", 0x007E, "TILDE"); + dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_tilde", "dead_tilde", 0x007E, "TILDE"); + dk_ComposeTable.push_back(line); line.clear(); +} + +/*// _S2 TOP_3 is this the right place to get dk from? if not where are they stored? +void create_DKTable_old(v_dw_2D & dk_ComposeTable) { + //create a 2D-Vector which contains data for ALL existing deadkey combinations on a Linux Keyboard: + //dk_ComposeTable[i][0] : First (e.g. dead_circumflex) + //dk_ComposeTable[i][1] : Second (e.g. a) + //dk_ComposeTable[i][3] : Unicode-Value (e.g. 0x00E2) + //values taken from: https://help.ubuntu.com/community/GtkDeadKeyTable#Latin v_dw_1D line; @@ -410,8 +787,8 @@ void create_DKTable(v_dw_2D & dk_ComposeTable) { line = createLine(L"dead_acute", L"space", 0x0027, L"APOSTROPHE"); dk_ComposeTable.push_back(line); line.clear(); - /*line = createLine(L"dead_acute", L"space", 0x00B4, L"ACUTE_ACCENT"); // _S2 TOP_3 ToDo remove - just for testing - dk_ComposeTable.push_back(line); line.clear();*/ + //line = createLine(L"dead_acute", L"space", 0x00B4, L"ACUTE_ACCENT"); // _S2 TOP_3 ToDo remove - just for testing + // dk_ComposeTable.push_back(line); line.clear(); line = createLine(L"dead_grave", L"space", 0x0060, L"GRAVE_ACCENT"); dk_ComposeTable.push_back(line); line.clear(); @@ -489,4 +866,4 @@ void create_DKTable(v_dw_2D & dk_ComposeTable) { line = createLine(L"dead_tilde", L"dead_tilde", 0x007E, L"TILDE"); dk_ComposeTable.push_back(line); line.clear(); } - +*/ diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index 18805734df..d460c29746 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -6,9 +6,8 @@ #include #include "mc_import_rules.h" - // create a vector for a dk combination ( ` + a -> à ) -v_dw_1D createLine(std::wstring first, std::wstring second, KMX_DWORD number, std::wstring nameresult); +v_dw_1D createLine(std::string first, std::string second, KMX_DWORD number, std::string nameresult); // create a 2D-vector of all dk combinations ( ` + a -> à ; ^ + a -> â ; `+ e -> è; ...) void create_DKTable(v_dw_2D & dk_ComposeTable); diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 53665137f9..58a2e6fb77 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -10,70 +10,281 @@ int map_VKShiftState_to_LinModifier(int VKShiftState) { else return VKShiftState; } -KMX_DWORD convertNamesTo_DWORD_Value(std::wstring tok_wstr) { +KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str) { // more on https://manpages.ubuntu.com/manpages/jammy/man3/keysyms.3tk.html - std::map first; + std::map first; - first[L"ampersand"] = 38; - first[L"apostrophe"] = 39; - first[L"asciicircum"] = 136; - first[L"asciitilde"] = 126; - first[L"asterisk"] = 42; - first[L"at"] = 64; - first[L"backslash"] = 92; - first[L"BackSpace"] = 65288; - first[L"bar"] = 124; - first[L"braceleft"] = 123; - first[L"braceright"] = 125; - first[L"bracketleft"] = 91; - first[L"bracketright"] = 93; - first[L"colon"] = 58; - first[L"comma"] = 44; - first[L"diaeresis"] = 168; - first[L"dollar"] = 36; - first[L"equal"] = 61; - first[L"exclam"] = 33; - first[L"grave"] = 96; - first[L"greater"] = 62; - first[L"less"] = 60; - first[L"minus"] = 45; - first[L"numbersign"] = 35; - first[L"parenleft"] = 40; - first[L"parenright"] = 41; - first[L"percent"] = 37; - first[L"period"] = 46; - first[L"plus"] = 43; - first[L"question"] = 63; - first[L"quotedbl"] = 34; - first[L"semicolon"] = 59; - first[L"slash"] = 47; - first[L"space"] = 32; - first[L"ssharp"] = 223; - first[L"underscore"] = 95; + first["ampersand"] = 38; + first["apostrophe"] = 39; + first["asciicircum"] = 136; + first["asciitilde"] = 126; + first["asterisk"] = 42; + first["at"] = 64; + first["backslash"] = 92; + first["BackSpace"] = 65288; + first["bar"] = 124; + first["braceleft"] = 123; + first["braceright"] = 125; + first["bracketleft"] = 91; + first["bracketright"] = 93; + first["colon"] = 58; + first["comma"] = 44; + first["diaeresis"] = 168; + first["dollar"] = 36; + first["equal"] = 61; + first["exclam"] = 33; + first["grave"] = 96; + first["greater"] = 62; + first["less"] = 60; + first["minus"] = 45; + first["numbersign"] = 35; + first["parenleft"] = 40; + first["parenright"] = 41; + first["percent"] = 37; + first["period"] = 46; + first["plus"] = 43; + first["question"] = 63; + first["quotedbl"] = 34; + first["semicolon"] = 59; + first["slash"] = 47; + first["space"] = 32; + first["ssharp"] = 223; + first["underscore"] = 95; - first[L"dead_abovedot"] = 729; - first[L"dead_abovering"] = 730; - first[L"dead_acute"] = 180; - first[L"dead_breve"] = 728; - first[L"dead_caron"] = 711; - first[L"dead_cedilla"] = 184; - first[L"dead_circumflex"] = 94; - first[L"dead_diaeresis"] = 168; - first[L"dead_doubleacute"] = 733; - first[L"dead_grave"] = 96; - first[L"dead_ogonek"] = 731; - first[L"dead_perispomeni"] = 126; - first[L"dead_tilde"] = 126; - first[L"acute accent"] = 0xB4; + first["nobreakspace"] = 160; + first["exclamdown"] = 161; + first["cent"] = 162; + first["sterling"] = 163; + first["currency"] = 164; + first["yen"] = 165; + first["brokenbar"] = 166; + first["section"] = 167; + first["copyright"] = 169; + first["ordfeminine"] = 170; + first["guillemotleft"] = 171; + first["notsign"] = 172; + first["hyphen"] = 173; + first["registered"] = 174; + first["macron"] = 175; + first["degree"] = 176; + first["plusminus"] = 177; + first["twosuperior"] = 178; + first["threesuperior"] = 179; + first["acute"] = 180; + first["mu"] = 181; + first["paragraph"] = 182; + first["periodcentered"] = 183; + first["cedilla"] = 184; + first["onesuperior"] = 185; + first["masculine"] = 186; + first["guillemotright"] = 187; + first["onequarter"] = 188; + first["onehalf"] = 189; + first["threequarters"] = 190; + first["questiondown"] = 191; + first["Agrave"] = 192; + first["Aacute"] = 193; + first["Acircumflex"] = 194; + first["Atilde"] = 195; + first["Adiaeresis"] = 196; + first["Aring"] = 197; + first["AE"] = 198; + first["Ccedilla"] = 199; + first["Egrave"] = 200; + first["Eacute"] = 201; + first["Ecircumflex"] = 202; + first["Ediaeresis"] = 203; + first["Igrave"] = 204; + first["Iacute"] = 205; + first["Icircumflex"] = 206; + first["Idiaeresis"] = 207; + first["ETH"] = 208; + first["Ntilde"] = 209; + first["Ograve"] = 210; + first["Oacute"] = 211; + first["Ocircumflex"] = 212; + first["Otilde"] = 213; + first["Odiaeresis"] = 214; + first["multiply"] = 215; + first["Oslash"] = 216; + first["Ugrave"] = 217; + first["Uacute"] = 218; + first["Ucircumflex"] = 219; + first["Udiaeresis"] = 220; + first["Yacute"] = 221; + first["THORN"] = 222; + first["agrave"] = 224; + first["aacute"] = 225; + first["acircumflex"] = 226; + first["atilde"] = 227; + first["adiaeresis"] = 228; + first["aring"] = 229; + first["ae"] = 230; + first["ccedilla"] = 231; + first["egrave"] = 232; + first["eacute"] = 233; + first["ecircumflex"] = 234; + first["ediaeresis"] = 235; + first["igrave"] = 236; + first["iacute"] = 237; + first["icircumflex"] = 238; + first["idiaeresis"] = 239; + first["eth"] = 240; + first["ntilde"] = 241; + first["ograve"] = 242; + first["oacute"] = 243; + first["ocircumflex"] = 244; + first["otilde"] = 245; + first["odiaeresis"] = 246; + first["division"] = 247; + first["oslash"] = 248; + first["ugrave"] = 249; + first["uacute"] = 250; + first["ucircumflex"] = 251; + first["udiaeresis"] = 252; + first["yacute"] = 253; + first["thorn"] = 254; + first["ydiaeresis"] = 255; + first["Aogonek"] = 417; + first["breve"] = 418; + first["Lstroke"] = 419; + first["Lcaron"] = 421; + first["Sacute"] = 422; + first["Scaron"] = 425; + first["Scedilla"] = 426; + first["Tcaron"] = 427; + first["Zacute"] = 428; + first["Zcaron"] = 430; + first["Zabovedot"] = 431; + first["aogonek"] = 433; + first["ogonek"] = 434; + first["lstroke"] = 435; + first["lcaron"] = 437; + first["sacute"] = 438; + first["caron"] = 439; + first["scaron"] = 441; + first["scedilla"] = 442; + first["tcaron"] = 443; + first["zacute"] = 444; + first["doubleacute"] = 445; + first["zcaron"] = 446; + first["zabovedot"] = 447; + first["Racute"] = 448; + first["Abreve"] = 451; + first["Lacute"] = 453; + first["Cacute"] = 454; + first["Ccaron"] = 456; + first["Eogonek"] = 458; + first["Ecaron"] = 460; + first["Dcaron"] = 463; + first["Dstroke"] = 464; + first["Nacute"] = 465; + first["Ncaron"] = 466; + first["Odoubleacute"] = 469; + first["Rcaron"] = 472; + first["Uring"] = 473; + first["Udoubleacute"] = 475; + first["Tcedilla"] = 478; + first["racute"] = 480; + first["abreve"] = 483; + first["lacute"] = 485; + first["cacute"] = 486; + first["ccaron"] = 488; + first["eogonek"] = 490; + first["ecaron"] = 492; + first["dcaron"] = 495; + first["dstroke"] = 496; + first["nacute"] = 497; + first["ncaron"] = 498; + first["odoubleacute"] = 501; + first["rcaron"] = 504; + first["uring"] = 505; + first["udoubleacute"] = 507; + first["tcedilla"] = 510; + first["abovedot"] = 511; + first["Hstroke"] = 673; + first["Hcircumflex"] = 678; + first["Iabovedot"] = 681; + first["Gbreve"] = 683; + first["Jcircumflex"] = 684; + first["hstroke"] = 689; + first["hcircumflex"] = 694; + first["idotless"] = 697; + first["gbreve"] = 699; + first["jcircumflex"] = 700; + first["Cabovedot"] = 709; + first["Ccircumflex"] = 710; + first["Gabovedot"] = 725; + first["Gcircumflex"] = 728; + first["Ubreve"] = 733; + first["Scircumflex"] = 734; + first["cabovedot"] = 741; + first["ccircumflex"] = 742; + first["gabovedot"] = 757; + first["gcircumflex"] = 760; + first["ubreve"] = 765; + first["scircumflex"] = 766; + first["kra"] = 930; + first["Rcedilla"] = 931; + first["Itilde"] = 933; + first["Lcedilla"] = 934; + first["Emacron"] = 938; + first["Gcedilla"] = 939; + first["Tslash"] = 940; + first["rcedilla"] = 947; + first["itilde"] = 949; + first["lcedilla"] = 950; + first["emacron"] = 954; + first["gcedilla"] = 955; + first["tslash"] = 956; + first["ENG"] = 957; + first["eng"] = 959; + first["Amacron"] = 960; + first["Iogonek"] = 967; + first["Eabovedot"] = 972; + first["Imacron"] = 975; + first["Ncedilla"] = 977; + first["Omacron"] = 978; + first["Kcedilla"] = 979; + first["Uogonek"] = 985; + first["Utilde"] = 989; + first["Umacron"] = 990; + first["amacron"] = 992; + first["iogonek"] = 999; + first["eabovedot"] = 1004; + first["imacron"] = 1007; + first["ncedilla"] = 1009; + first["omacron"] = 1010; + first["kcedilla"] = 1011; + first["uogonek"] = 1017; + first["utilde"] = 1021; + first["umacron"] = 1022; + first["overline"] = 1150; - if ( tok_wstr.size() == 1) { - return (KMX_DWORD) ( *tok_wstr.c_str() ); + first["dead_abovedot"] = 729; + first["dead_abovering"] = 730; + first["dead_acute"] = 180; + first["dead_breve"] = 728; + first["dead_caron"] = 711; + first["dead_cedilla"] = 184; + first["dead_circumflex"] = 94; + first["dead_diaeresis"] = 168; + first["dead_doubleacute"] = 733; + first["dead_grave"] = 96; + first["dead_ogonek"] = 731; + first["dead_perispomeni"] = 126; + first["dead_tilde"] = 126; + + first["acute accent"] = 0xB4; + + if ( tok_str.size() == 1) { + return (KMX_DWORD) ( *tok_str.c_str() ); } else { - std::map ::iterator it; + std::map ::iterator it; for (it = first.begin(); it != first.end(); ++it) { - if (it->first == tok_wstr) + if (it->first == tok_str) return it->second; } } @@ -279,7 +490,9 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { for ( int i = 1; i< (int) tokens.size();i++) { // replace a name with a single character ( a -> a ; equal -> = ) - tokens_int = convertNamesTo_DWORD_Value( wstring_from_string(tokens[i])); + tokens_int = convertNamesTo_DWORD_Value(tokens[i]); + //tokens_int = convertNamesTo_DWORD_Value( wstring_from_string(tokens[i])); + tokens_dw.push_back(tokens_int); } @@ -368,29 +581,6 @@ bool IsKeymanUsedChar(int KV) { return false; } -std::wstring convert_DeadkeyValues_ToWstr(int in) { - - if (in == 0 ) - return L"\0"; - - std::string long_name((const char*) gdk_keyval_name (in)); // e.g. "dead_circumflex" , "U+017F" , "t" - - if ( long_name.substr (0,2) == "U+" ) // U+... Unicode value - return CodePointToWString(in-0x1000000); - - if (in < (int) deadkey_min) { // no deadkey; no Unicode - return std::wstring(1, in); - } - - KMX_DWORD lname = convertNamesTo_DWORD_Value( wstring_from_string(long_name)); // 65106 => "dead_circumflex" => 94 => "^" - - if (lname != returnIfCharInvalid) { - return std::wstring(1, lname ); - } - else - return L"\0"; -} - std::u16string convert_DeadkeyValues_To_U16str(int in) { if (in == 0 ) @@ -399,13 +589,14 @@ std::u16string convert_DeadkeyValues_To_U16str(int in) { std::string long_name((const char*) gdk_keyval_name (in)); // e.g. "dead_circumflex" , "U+017F" , "t" if ( long_name.substr (0,2) == "U+" ) // U+... Unicode value - return CodePointToString_16(in-0x1000000); + return CodePointToU16String(in-0x1000000); if (in < (int) deadkey_min) { // no deadkey; no Unicode return std::u16string(1, in); } - KMX_DWORD lname = convertNamesTo_DWORD_Value( wstring_from_string(long_name)); // 65106 => "dead_circumflex" => 94 => "^" + //KMX_DWORD lname_old = convertNamesTo_DWORD_Value( wstring_from_string(long_name)); // 65106 => "dead_circumflex" => 94 => "^" + KMX_DWORD lname = convertNamesTo_DWORD_Value(long_name); // 65106 => "dead_circumflex" => 94 => "^" if (lname != returnIfCharInvalid) { return std::u16string(1, lname ); @@ -572,12 +763,13 @@ KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(v_dw_3D & All_Vector, KMX_DWORD KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap *keymap, v_dw_3D &All_Vector, KMX_DWORD KC_US, ShiftState ss, int caps) { KMX_DWORD KC_underlying; - std::wstring ws = convert_DeadkeyValues_ToWstr(KMX_get_KeyVal_From_KeyCode(keymap, KC_US, ss, caps)); + std::u16string u16str = convert_DeadkeyValues_To_U16str(KMX_get_KeyVal_From_KeyCode(keymap, KC_US, ss, caps)); //Find KC_underlying character for( int i=0; i< (int)All_Vector[1].size()-1 ;i++) { for( int j=1; j< (int)All_Vector[1][0].size();j++) { - if ( ( All_Vector[1][i][j] == (KMX_DWORD) *ws.c_str() ) ) { + //if ( ( All_Vector[1][i][j] == (KMX_DWORD) *ws.c_str() ) ) { + if ( ( All_Vector[1][i][j] == (KMX_DWORD) *u16str.c_str() ) ) { KC_underlying = All_Vector[1][i][0]; return KC_underlying; } @@ -597,27 +789,7 @@ KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying(KMX_DWORD keycode) { return 0; } -// _S2 TOP_6 ToDo only use one -std::wstring CodePointToWString(unsigned int codepoint) { - std::wstring str; - - if constexpr (sizeof(wchar_t) > 2) { - str = static_cast(codepoint); - } - else if (codepoint <= 0xFFFF) { - str = static_cast(codepoint); - } - else { - codepoint -= 0x10000; - str.resize(2); - str[0] = static_cast(0xD800 + ((codepoint >> 10) & 0x3FF)); - str[1] = static_cast(0xDC00 + (codepoint & 0x3FF)); - } - - return str; -} - -std::u16string CodePointToString_16(unsigned int codepoint) { +std::u16string CodePointToU16String(unsigned int codepoint) { std::u16string str; if constexpr (sizeof(wchar_t) > 2) { diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 401a697ebc..06cfd05704 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -73,7 +73,7 @@ static KMX_DWORD deadkey_max = 0xfe52; // _S2 TOP_6 TODO This has to go! my tes int map_VKShiftState_to_LinModifier(int VKShiftState); // take a std::wstring (=contents of line symbols-file ) and returns the (int) value of the character -KMX_DWORD convertNamesTo_DWORD_Value(std::wstring tok_wstr); +KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str); // create a Vector with all entries of both keymaps+ keymap int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap); @@ -502,9 +502,7 @@ const UINT ScanCodeToUSVirtualKey[128] = { bool IsKeymanUsedChar(int KV); //------------------------------ - // take deadkey-value (e.g.65106) and return wstring (e.g. '^' ) -std::wstring convert_DeadkeyValues_ToWstr(int in); std::u16string convert_DeadkeyValues_To_U16str(int in); // use gdk_keymap_translate_keyboard_state to get keyval - base function to get keyvals @@ -529,7 +527,6 @@ UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying(KMX_DWORD keycode); // convert codePoint to wstring -std::wstring CodePointToWString(unsigned int codepoint); -std::u16string CodePointToString_16(unsigned int codepoint); +std::u16string CodePointToU16String(unsigned int codepoint); # endif /*KEYMAP_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 6a7378facd..980e1c17f1 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -77,8 +77,8 @@ int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int return 0; KMX_DWORD KeyVal= (KMX_DWORD) KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(shift_state_pos), caps); - std::wstring str = convert_DeadkeyValues_ToWstr(KeyVal); - pwszBuff[0]= * (PKMX_WCHAR) u16string_from_wstring(str).c_str(); + std::u16string str = convert_DeadkeyValues_To_U16str(KeyVal); + pwszBuff[0]= * (PKMX_WCHAR) str.c_str(); g_free(keyvals); @@ -109,26 +109,15 @@ int KMX_DeadKeyMap(int index, std::vector *deadkeys, int deadkeyBase, class KMX_VirtualKey { private: - //KMX_HKL m_hkl; // _S2 QUESTION do I need this and is void* OK to assume? If I remove this, will there be changes in Data-Vectors? UINT m_vk; UINT m_sc; bool m_rgfDeadKey[10][2]; - std::wstring m_rgss[10][2]; + std::u16string m_rgss[10][2]; public: - // _S2 TODO I assume we do not need those... - /*KMX_VirtualKey(KMX_HKL hkl,UINT virtualKey) { - this->m_sc = KMX_get_KeyCodeUnderlying_From_VKUS(virtualKey); - this->m_hkl = hkl; - this->m_vk = virtualKey; - memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); - }*/ - - //KMX_VirtualKey(UINT scanCode, KMX_HKL hkl) { KMX_VirtualKey(UINT scanCode) { this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying(scanCode); - //this->m_hkl = hkl; this->m_sc = scanCode; memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); } @@ -141,70 +130,62 @@ public: return this->m_sc; } - std::wstring KMX_GetShiftState(ShiftState shiftState, bool capsLock) { + std::u16string KMX_GetShiftState(ShiftState shiftState, bool capsLock) { return this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)]; } - - void KMX_SetShiftState(ShiftState shiftState, std::wstring value, bool isDeadKey, bool capsLock) { + + void KMX_SetShiftState(ShiftState shiftState, std::u16string value, bool isDeadKey, bool capsLock) { this->m_rgfDeadKey[(UINT)shiftState][(capsLock ? 1 : 0)] = isDeadKey; this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; } - void KMX_SetShiftState(ShiftState shiftState, std::u16string value16, bool isDeadKey, bool capsLock) { - std::wstring value = wstring_from_u16string(value16); - this->m_rgfDeadKey[(UINT)shiftState][(capsLock ? 1 : 0)] = isDeadKey; - this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; - } - -// _S2 TOP_6 ToDo delete comments later bool KMX_IsSGCAPS() { - std::wstring stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß - std::wstring stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? - std::wstring stCaps = this->KMX_GetShiftState(Base, true); // 0,1 A 4 ẞ - std::wstring stShiftCaps = this->KMX_GetShiftState(Shft, true); // 1,1 a $ ? - return ( - ((stCaps.size() > 0) && - (stBase.compare(stCaps) != 0) && // stBase != stCaps - (stShift.compare(stCaps) != 0)) || // stShift!= stCaps - ((stShiftCaps.size() > 0) && - (stBase.compare(stShiftCaps) != 0) && // stBase != stShiftCaps - (stShift.compare(stShiftCaps) != 0))); // stShift!= stShiftCaps - } + std::u16string stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß + std::u16string stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? + std::u16string stCaps = this->KMX_GetShiftState(Base, true); // 0,1 A 4 ẞ + std::u16string stShiftCaps = this->KMX_GetShiftState(Shft, true); // 1,1 a $ ? + return ( + ((stCaps.size() > 0) && + (stBase.compare(stCaps) != 0) && // stBase != stCaps + (stShift.compare(stCaps) != 0)) || // stShift!= stCaps + ((stShiftCaps.size() > 0) && + (stBase.compare(stShiftCaps) != 0) && // stBase != stShiftCaps + (stShift.compare(stShiftCaps) != 0))); // stShift!= stShiftCaps + } bool KMX_IsCapsEqualToShift() { - std::wstring stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß - std::wstring stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? - std::wstring stCaps = this->KMX_GetShiftState(Base, true); // 0,1 A 4 ẞ - return ( - (stBase.size() > 0) && // unshifted char inside - (stShift.size() > 0) && // shifted char inside - (stBase.compare(stShift) != 0) && // stBase != stShft - (stShift.compare(stCaps) == 0)); // stShft == stCaps - } + std::u16string stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß + std::u16string stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? + std::u16string stCaps = this->KMX_GetShiftState(Base, true); // 0,1 A 4 ẞ + return ( + (stBase.size() > 0) && // unshifted char inside + (stShift.size() > 0) && // shifted char inside + (stBase.compare(stShift) != 0) && // stBase != stShft + (stShift.compare(stCaps) == 0)); // stShft == stCaps + } bool KMX_IsAltGrCapsEqualToAltGrShift() { - std::wstring stBase = this->KMX_GetShiftState(MenuCtrl, false); // 0,0 - std::wstring stShift = this->KMX_GetShiftState(ShftMenuCtrl, false); // 1,0 - std::wstring stCaps = this->KMX_GetShiftState(MenuCtrl, true); // 0,1 - return ( - (stBase.size() > 0) && // unshifted MenuCtrl/AltGr char inside - (stShift.size() > 0) && // shifted MenuCtrl/AltGr char inside - (stBase.compare(stShift) != 0) && // stBase != stShft - (stShift.compare(stCaps) == 0)); // stShft == stCaps - } + std::u16string stBase = this->KMX_GetShiftState(MenuCtrl, false); // 0,0 + std::u16string stShift = this->KMX_GetShiftState(ShftMenuCtrl, false); // 1,0 + std::u16string stCaps = this->KMX_GetShiftState(MenuCtrl, true); // 0,1 + return ( + (stBase.size() > 0) && // unshifted MenuCtrl/AltGr char inside + (stShift.size() > 0) && // shifted MenuCtrl/AltGr char inside + (stBase.compare(stShift) != 0) && // stBase != stShft + (stShift.compare(stCaps) == 0)); // stShft == stCaps + } bool KMX_IsXxxxGrCapsEqualToXxxxShift() { - std::wstring stBase = this->KMX_GetShiftState(Xxxx, false); - std::wstring stShift = this->KMX_GetShiftState(ShftXxxx, false); - std::wstring stCaps = this->KMX_GetShiftState(Xxxx, true); - return ( - (stBase.size() > 0) && - (stShift.size() > 0) && - (stBase.compare(stShift) != 0) && - (stShift.compare(stCaps) == 0)); + std::u16string stBase = this->KMX_GetShiftState(Xxxx, false); + std::u16string stShift = this->KMX_GetShiftState(ShftXxxx, false); + std::u16string stCaps = this->KMX_GetShiftState(Xxxx, true); + return ( + (stBase.size() > 0) && + (stShift.size() > 0) && + (stBase.compare(stShift) != 0) && + (stShift.compare(stCaps) == 0)); } - bool KMX_IsEmpty() { for (int i = 0; i < 10; i++) { for (int j = 0; j <= 1; j++) { @@ -219,7 +200,7 @@ public: bool KMX_IsKeymanUsedKey() { return (this->m_vk >= 0x20 && this->m_vk <= 0x5F) || (this->m_vk >= 0x88); } - + UINT KMX_GetShiftStateValue(int capslock, int caps, ShiftState ss) { return KMX_ShiftStateMap[(int)ss] | (capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0); } @@ -241,7 +222,8 @@ public: continue; } for (int caps = 0; caps <= 1; caps++) { - std::wstring st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); + + std::u16string st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); if (st.size() == 0) { // No character assigned here @@ -251,7 +233,11 @@ public: } else { bool isvalid = true; for (size_t ich = 0; ich < st.size(); ich++) { - if(st[ich] < 0x20 || st[ich] == 0x7F) { isvalid=false; break; } + if(st[ich] < 0x20 || st[ich] == 0x7F) { + isvalid=false; + + wprintf(L"invalid for: %i\n", st[ich]); + break; } } if(isvalid) { nkeys++; @@ -264,14 +250,13 @@ public: bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,v_dw_3D &All_Vector, GdkKeymap *keymap) { // I4552 // Get the CAPSLOCK value - int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | (this->KMX_IsSGCAPS() ? 2 : 0) | (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); // _S2 we need this capslock calculation - //capslock=1; + //capslock=1;*/ for (int ss = 0; ss <= MaxShiftState; ss++) { if (ss == Menu || ss == ShftMenu) { @@ -279,7 +264,8 @@ public: continue; } for (int caps = 0; caps <= 1; caps++) { - std::wstring st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); + std::u16string st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); + PKMX_WCHAR p; if (st.size() == 0) { @@ -308,11 +294,14 @@ public: *p = 0; } key++; - } + } else { bool isvalid = true; for (size_t ich = 0; ich < st.size(); ich++) { - if(st[ich] < 0x20 || st[ich] == 0x7F) { isvalid=false; break; } + if(st[ich] < 0x20 || st[ich] == 0x7F) { + isvalid=false; + wprintf(L"invalid 16 for: %i\n", st[ich]); + break; } } if(isvalid) { // this is different to mcompile windows !!!! @@ -327,10 +316,9 @@ public: key->Line = 0; key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); - key->dpContext = new KMX_WCHAR; + key->dpContext = new KMX_WCHAR; *key->dpContext = 0; p = key->dpOutput = new KMX_WCHAR[st.size() + 1]; - for(size_t ich = 0; ich < st.size(); ich++) { *p++ = st[ich]; } @@ -367,10 +355,6 @@ public: return (Get_XxxxVk() == 0 ? ShftMenuCtrl : ShftXxxx); } - // _S2 TOP_6 ToDo Do we need one/none? - bool KMX_IsControlChar(wchar_t ch) { - return (ch < 0x0020) || (ch >= 0x007F && ch <= 0x009F); - } bool KMX_IsControlChar(char16_t ch) { return (ch < 0x0020) || (ch >= 0x007F && ch <= 0x009F); } @@ -409,7 +393,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // Linux cannot get a VK for the underling Keyboard // this "connection" is possible only when using All_Vector - //KMX_VirtualKey *key = new KMX_VirtualKey(sc, hkl); KMX_VirtualKey *key = new KMX_VirtualKey(sc); if((key->VK() != 0) ) { @@ -448,21 +431,18 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, if(rc > 0) { if(*sbBuffer == 0) { - //rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps == 0)); // different to windows since behavior on Linux is different - rgKey[iKey]->KMX_SetShiftState(ss, L"", false, (caps)); + rgKey[iKey]->KMX_SetShiftState(ss, u"", false, (caps)); // different to windows since behavior on Linux is different } else { if( (ss == Ctrl || ss == ShftCtrl) ) { continue; } sbBuffer[rc] = 0; - //rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps==0)); rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps)); // different to windows since behavior on Linux is different } } else if(rc < 0) { sbBuffer[2] = 0; - //rgKey[iKey]->SetShiftState(ss, sbBuffer, true, (caps == 0)); rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); // different to windows since behavior on Linux is different refine_alDead(sbBuffer[0], alDead, &alDead_cpl); @@ -504,10 +484,11 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, kp->cxGroupArray++; gp = &kp->dpGroupArray[kp->cxGroupArray-1]; - UINT nKeys = 0; + + UINT nkeys = 0; for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { - nKeys+= rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()); + nkeys+= rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()); } } @@ -518,31 +499,31 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, gp->dpMatch = NULL; gp->dpName = NULL; gp->dpNoMatch = NULL; - gp->cxKeyArray = nKeys; + gp->cxKeyArray = nkeys; gp->dpKeyArray = new KMX_KEY[gp->cxKeyArray]; - nKeys = 0; + nkeys = 0; // // Fill in the new rules // - // _S2 fills group 2 using keys + //fills group3: group(group3) using keys for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { - if(rgKey[iKey]->KMX_LayoutRow(loader.KMX_MaxShiftState(), &gp->dpKeyArray[nKeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 - nKeys+=rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()); + if(rgKey[iKey]->KMX_LayoutRow(loader.KMX_MaxShiftState(), &gp->dpKeyArray[nkeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 + nkeys+=rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()); } } } - gp->cxKeyArray = nKeys; + gp->cxKeyArray = nkeys; // // Add nomatch control to each terminating 'using keys' group // I4550 // // _adds + [CTRL NCAPS K_QUOTE] > use(group2) c line(0) // + [CTRL CAPS K_QUOTE] > use(group2) c line(0) - //nomatch > use(group2) + //nomatch > use(group2) nomatch > use(group3) // after dk-section LPKMX_GROUP gp2 = kp->dpGroupArray; for(UINT i = 0; i < kp->cxGroupArray - 1; i++, gp2++) { From a6cec0921e7fef76bba0c7235c85bd3dcc8a65f4 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 14 Mar 2024 02:56:19 +0100 Subject: [PATCH 234/327] feat(linux): mcompile-dk remove comments --- linux/mcompile/keymap/README.md | 19 - linux/mcompile/keymap/deadkey.cpp | 409 +--------------------- linux/mcompile/keymap/deadkey.h | 5 +- linux/mcompile/keymap/keymap.cpp | 38 +- linux/mcompile/keymap/keymap.h | 164 ++++----- linux/mcompile/keymap/km_types.h | 3 - linux/mcompile/keymap/kmx_file.h | 3 - linux/mcompile/keymap/mc_import_rules.cpp | 71 ++-- linux/mcompile/keymap/mc_import_rules.h | 8 +- linux/mcompile/keymap/mc_kmxfile.cpp | 4 +- linux/mcompile/keymap/mc_kmxfile.h | 23 +- linux/mcompile/keymap/mcompile.cpp | 11 +- 12 files changed, 152 insertions(+), 606 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index f0d61f8dab..84635c5e5b 100755 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -5,22 +5,3 @@ Ideally, we'd rewrite mcompile to be cross-platform (Windows, Linux, macOS), so Sample program that reads US basic keyboard and compares to key value group # Keymap - -_S2 TODO Check/find use of wchar_t/wstring and replace with char16_t/u16string -_S2 TODO check call by reference/value -_S2 TODO what is wrong with kp->dpBitmapOffset/BitmapSize ? -_s2 INFO idee spanish keyboard has dk on altgr !! -_S2 TODO new Problem: RALT-dk(4): Why do we havea RALT in dk 4? It makes sense but how do we handle this?? - -_ S2 TOP_1 NCAPS/capslock-> we need capslock-equation. ---> new Problem: RALT-dk(4) RALT+Ä -_S2 TOP_2 Shiftflags - _S2 TOP_3 dk-table from file->from functions -> ask EB, MD in TX to setup gtk - _S2 TOP_4 HKL - _S2 TOP_5 use files/functions from other places -_S2 TOP_6 remaining -_S2 TOP_7 wchar_t->char16_t - - -./mcompile -d /Projects/keyman/keyman/linux/mcompile/keymap/mcompile_test.kmx bla.dll 0407 /Projects/keyman/keyman/linux/mcompile/keymap/mcompile_test_out.kmx - -./mcompile -d /home/mcompileTest/Source/mcompile_test.kmx bla.dll 0407 /home/mcompileTest/Source_after_run_mcompile/mcompile_test_out.kmx diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 27d9dd7f9c..8afee1d15a 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -54,29 +54,7 @@ bool found_dk_inVector(KMX_WCHAR dk, std::vector &dkVec) { return false; } -/*void sort_alDead(std::vector &small_Vec, std::vector *p_All_Vec) { - std::vector small_sorted; - int Vsmall_size; - int i = 0; - - do { - int j = 0; - Vsmall_size= small_Vec.size(); - - do { - if((*p_All_Vec)[i]->KMX_DeadCharacter() == small_Vec[j]->KMX_DeadCharacter()) { - small_sorted.push_back(small_Vec[j]); - small_Vec.erase(std::next(small_Vec.begin()+j-1)); - Vsmall_size--; - } - j++; - } while (j < Vsmall_size); - i++; - } while ((i < (int) (*p_All_Vec).size()) && (Vsmall_size>0)); - small_Vec = small_sorted; -} -*/ -bool find_dk_combinations_for_specific_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &dk_SingleTable, KMX_DWORD dk) { +bool query_dk_combinations_for_specific_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &dk_SingleTable, KMX_DWORD dk) { v_dw_1D line; for ( int i =0; i< (int) (*p_dk_ComposeTable).size(); i++) { @@ -120,7 +98,7 @@ void create_DKTable(v_dw_2D & dk_ComposeTable) { //dk_ComposeTable[i][3] : Unicode-Value (e.g. 0x00E2) //values taken from: https://help.ubuntu.com/community/GtkDeadKeyTable#Accents - // _S2 Do we really want to use GTK instead of this function? + // _S2 Do we want to use GTK instead of this function? v_dw_1D line; @@ -408,10 +386,10 @@ void create_DKTable(v_dw_2D & dk_ComposeTable) { line = createLine("dead_circumflex", "space", 0x005E, "CIRCUMFLEX_ACCENT"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "space", 0x0027, "APOSTROPHE"); - dk_ComposeTable.push_back(line); line.clear(); - /*line = createLine("dead_acute", "space", 0x00B4, "ACUTE_ACCENT"); // _S2 TOP_3 ToDo remove - just for testing + /*line = createLine("dead_acute", "space", 0x0027, "APOSTROPHE"); dk_ComposeTable.push_back(line); line.clear();*/ + line = createLine("dead_acute", "space", 0x00B4, "ACUTE_ACCENT"); // _S2 TOP_3 ToDo remove - just for testing + dk_ComposeTable.push_back(line); line.clear(); line = createLine("dead_grave", "space", 0x0060, "GRAVE_ACCENT"); dk_ComposeTable.push_back(line); line.clear(); @@ -490,380 +468,3 @@ void create_DKTable(v_dw_2D & dk_ComposeTable) { dk_ComposeTable.push_back(line); line.clear(); } -/*// _S2 TOP_3 is this the right place to get dk from? if not where are they stored? -void create_DKTable_old(v_dw_2D & dk_ComposeTable) { - //create a 2D-Vector which contains data for ALL existing deadkey combinations on a Linux Keyboard: - //dk_ComposeTable[i][0] : First (e.g. dead_circumflex) - //dk_ComposeTable[i][1] : Second (e.g. a) - //dk_ComposeTable[i][3] : Unicode-Value (e.g. 0x00E2) - - //values taken from: https://help.ubuntu.com/community/GtkDeadKeyTable#Latin - - v_dw_1D line; - - line = createLine(L"dead_circumflex", L"a", 0x00E2, L"small A with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"A", 0x00C2, L"capital A with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"e", 0x00EA, L"small E with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"E", 0x00CA, L"capital E with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"i", 0x00EE, L"small I with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"I", 0x00CE, L"capital I with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"o", 0x00F4, L"small O with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"O", 0x00D4, L"capital O with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"u", 0x00FB, L"small U with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"U", 0x00DB, L"capital U with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine(L"dead_acute", L"a", 0x00E1, L"small A with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"A", 0x00C1, L"capital A with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"c", 0x0107, L"small C with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"C", 0x0106, L"capital C with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"e", 0x00E9, L"small E with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"E", 0x00C9, L"capital E with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"i", 0x00ED, L"small I with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"I", 0x00CD, L"capital I with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"l", 0x013A, L"small L with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"L", 0x0139, L"capital L with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"n", 0x0144, L"small N with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"N", 0x0143, L"capital N with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"o", 0x00F3, L"small O with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"O", 0x00D3, L"capital O with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"r", 0x0155, L"small R with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"R", 0x0154, L"capital R with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"s", 0x015B, L"small S with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"S", 0x015A, L"capital S with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"u", 0x00FA, L"small U with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"U", 0x00DA, L"capital U with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"y", 0x00FD, L"small Y with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"Y", 0x00DD, L"capital Y with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"z", 0x017A, L"small Z with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"Z", 0x0179, L"capital Z with acute"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine(L"dead_grave", L"a", 0x00E0, L"small A with grave"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"A", 0x00C0, L"capital A with grave"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"e", 0x00E8, L"small E with grave"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"E", 0x00C8, L"capital E with grave"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"i", 0x00EC, L"small I with grave"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"I", 0x00CC, L"capital I with grave"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"o", 0x00F2, L"small O with grave"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"O", 0x00D2, L"capital O with grave"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"u", 0x00F9, L"small U with grave"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"U", 0x00D9, L"capital U with grave"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine(L"dead_tilde", L"a", 0x00E3, L"small A with tilde"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_tilde", L"A", 0x00C3, L"capital A with tilde"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_tilde", L"i", 0x0129, L"small I with tilde"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_tilde", L"I", 0x0128, L"capital I with tilde"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_tilde", L"n", 0x00F1, L"small N with tilde"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_tilde", L"N", 0x00D1, L"capital N with tilde"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_tilde", L"o", 0x00F5, L"small O with tilde"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_tilde", L"O", 0x00D5, L"capital O with tilde"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_tilde", L"u", 0x0169, L"small U with tilde"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_tilde", L"U", 0x0168, L"capital U with tilde"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine(L"dead_macron", L"a", 0x0101, L"small A with macron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_macron", L"A", 0x0100, L"capital A with macron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_macron", L"e", 0x0113, L"small E with macron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_macron", L"E", 0x0112, L"capital E with macron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_macron", L"i", 0x012B, L"small I with macron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_macron", L"I", 0x012A, L"capital I with macron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_macron", L"o", 0x014D, L"small O with macron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_macron", L"O", 0x014C, L"capital O with macron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_macron", L"u", 0x016B, L"small U with macron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_macron", L"U", 0x016A, L"capital U with macron"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine(L"dead_breve", L"a", 0x0103, L"small A with breve"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_breve", L"A", 0x0102, L"capital A with breve"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_breve", L"g", 0x011F, L"small G with breve"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_breve", L"G", 0x011E, L"capital G with breve"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine(L"dead_abovedot", L"e", 0x0117, L"small E with dot above"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_abovedot", L"E", 0x0116, L"capital E with dot above"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_abovedot", L"i", 0x0131, L"small DOTLESS_I"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_abovedot", L"I", 0x0130, L"capital I with dot above"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_abovedot", L"z", 0x017C, L"small Z with dot above"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_abovedot", L"Z", 0x017B, L"capital Z with dot above"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine(L"dead_diaeresis", L"a", 0x00E4, L"small A with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"A", 0x00C4, L"capital A with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"e", 0x00EB, L"small E with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"E", 0x00CB, L"capital E with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"i", 0x00EF, L"small I with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"I", 0x00CF, L"capital I with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"o", 0x00F6, L"small O with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"O", 0x00D6, L"capital O with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"u", 0x00FC, L"small U with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"U", 0x00DC, L"capital U with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"y", 0x00FF, L"small Y with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"Y", 0x0178, L"capital Y with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine(L"dead_abovering", L"a", 0x00E5, L"small A with ring above"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_abovering", L"A", 0x00C5, L"capital A with ring above"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_abovering", L"u", 0x016F, L"small U with ring above"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_abovering", L"U", 0x016E, L"capital U with ring above"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine(L"dead_doubleacute", L"o", 0x0151, L"small O with double acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_doubleacute", L"O", 0x0150, L"capital O with double acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_doubleacute", L"u", 0x0171, L"small U with double acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_doubleacute", L"U", 0x0170, L"capital U with double acute"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine(L"dead_caron", L"c", 0x010D, L"small C with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"C", 0x010C, L"capital C with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"d", 0x010F, L"small D with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"D", 0x010E, L"capital D with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"e", 0x011B, L"small E with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"E", 0x011A, L"capital E with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"l", 0x013E, L"small L with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"L", 0x013D, L"capital L with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"n", 0x0148, L"small N with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"N", 0x0147, L"capital N with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"r", 0x0159, L"small R with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"R", 0x0158, L"capital R with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"s", 0x0161, L"small S with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"S", 0x0160, L"capital S with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"t", 0x0165, L"small T with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"T", 0x0164, L"capital T with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"z", 0x017E, L"small Z with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"Z", 0x017D, L"capital Z with caron"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine(L"dead_cedilla", L"c", 0x00E7, L"small C with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"C", 0x00C7, L"capital C with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"g", 0x0123, L"small G with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"G", 0x0122, L"capital G with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"k", 0x0137, L"small K with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"K", 0x0136, L"capital K with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"l", 0x013C, L"small L with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"L", 0x013B, L"capital L with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"n", 0x0146, L"small N with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"N", 0x0145, L"capital N with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"r", 0x0157, L"small R with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"R", 0x0156, L"capital R with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"s", 0x015F, L"small S with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"S", 0x015E, L"capital S with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine(L"dead_ogonek", L"a", 0x0105, L"small A with ogonek"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_ogonek", L"A", 0x0104, L"capital A with ogonek"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_ogonek", L"e", 0x0119, L"small E with ogonek"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_ogonek", L"E", 0x0118, L"capital E with ogonek"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_ogonek", L"i", 0x012F, L"small I with ogonek"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_ogonek", L"I", 0x012E, L"capital I with ogonek"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_ogonek", L"u", 0x0173, L"small U with ogonek"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_ogonek", L"U", 0x0172, L"capital U with ogonek"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine(L"dead_circumflex", L"space", 0x005E, L"CIRCUMFLEX_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine(L"dead_acute", L"space", 0x0027, L"APOSTROPHE"); - dk_ComposeTable.push_back(line); line.clear(); - //line = createLine(L"dead_acute", L"space", 0x00B4, L"ACUTE_ACCENT"); // _S2 TOP_3 ToDo remove - just for testing - // dk_ComposeTable.push_back(line); line.clear(); - - line = createLine(L"dead_grave", L"space", 0x0060, L"GRAVE_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_breve", L"space", 0x02D8, L"BREVE"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_abovedot", L"space", 0x02D9, L"DOT_ABOVE"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_abovering", L"space", 0x02DA, L"RING_ABOVE"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_doubleacute", L"space", 0x02DD, L"DOUBLE_ACUTE_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"space", 0x02C7, L"CARON"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"space", 0x00B8, L"CEDILLA"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_ogonek", L"space", 0x02DB, L"OGONEK"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_tilde", L"space", 0x007E, L"TILDE"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine(L"dead_breve", L"dead_breve", 0x02D8, L"BREVE"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_abovedot", L"abovedot", 0x02D9, L"DOT_ABOVE"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_abovedot", L"dead_abovedot", 0x02D9, L"DOT_ABOVE"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_abovering", L"dead_abovering", 0x02DA, L"RING_ABOVE"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"apostrophe", 0x00B4, L"ACUTE_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"acute", 0x00B4, L"ACUTE_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_acute", L"dead_acute", 0x00B4, L"ACUTE_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_doubleacute", L"dead_doubleacute", 0x02DD, L"DOUBLE_ACUTE_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"caron", 0x02C7, L"CARON"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_caron", L"dead_caron", 0x02C7, L"CARON"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"comma", 0x00B8, L"CEDILLA"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"cedilla", 0x00B8, L"CEDILLA"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_cedilla", L"dead_cedilla", 0x00B8, L"CEDILLA"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"minus", 0x00AF, L"MACRON"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"asciicircum", 0x005E, L"CIRCUMFLEX_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"underscore", 0x00AF, L"MACRON"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_circumflex", L"dead_circumflex", 0x005E, L"CIRCUMFLEX_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"quotedbl", 0x00A8, L"DIAERESIS"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"diaeresis", 0x00A8, L"DIAERESIS"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_diaeresis", L"dead_diaeresis", 0x00A8, L"DIAERESIS"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"grave", 0x0060, L"GRAVE_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_grave", L"dead_grave", 0x0060, L"GRAVE_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_macron", L"macron", 0x00AF, L"MACRON"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_macron", L"dead_macron", 0x00AF, L"MACRON"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_ogonek", L"ogonek", 0x02DB, L"OGONEK"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_ogonek", L"dead_ogonek", 0x02DB, L"OGONEK"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_tilde", L"asciitilde", 0x007E, L"TILDE"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine(L"dead_tilde", L"dead_tilde", 0x007E, L"TILDE"); - dk_ComposeTable.push_back(line); line.clear(); -} -*/ diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index d460c29746..4110b498ea 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -17,10 +17,11 @@ std::vector create_alDead(); // refine dk to those used in the underlying keyboard void refine_alDead(KMX_WCHAR dk, std::vector &myVec, std::vector *p_All_Vec); +// check if entry is already there bool found_dk_inVector(KMX_WCHAR dk, std::vector &myVec); -// find all combination for a specific deadkey(dk) ^-> â,ê,î,ô,û,... -bool find_dk_combinations_for_specific_dk(v_dw_2D * dk_ComposeTable, v_dw_2D & dk_SingleTable, KMX_DWORD dk); +// get all combination for a specific deadkey(dk) from the dk_vector query_dk_combinations_for_specific_dk which holds all possible dk: ^-> â,ê,î,ô,û,... +bool query_dk_combinations_for_specific_dk(v_dw_2D * dk_ComposeTable, v_dw_2D & dk_SingleTable, KMX_DWORD dk); // get the shifted character of a key and write shiftstate of KVal to shift KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap); diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 58a2e6fb77..4786208352 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -304,7 +304,6 @@ int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap) { std::string US_language = "us"; const char* text_us = "xkb_symbols \"basic\""; - //const char* text_us = "xkb_symbols \"intl\""; if(write_US_ToVector(All_Vector,US_language, text_us)) { wprintf(L"ERROR: can't write US to Vector \n"); @@ -352,7 +351,7 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, s int buffer_size = 512; char buffer[buffer_size]; - bool print_OK = false; + bool create_row = false; const char* key = "key <"; std::string str_txt(text); std::string xbk_mark = "xkb_symbol"; @@ -363,14 +362,14 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, s // stop when finding the mark xkb_symbol if (std::string(str_buf).find(xbk_mark) != std::string::npos) - print_OK = false; + create_row = false; // start when finding the mark xkb_symbol + correct layout if (std::string(str_buf).find(str_txt) != std::string::npos) - print_OK = true; + create_row = true; // as long as we are in the same xkb_symbol layout block and find "key <" we push the whole line into a 1D-vector - if (print_OK && (std::string(str_buf).find(key) != std::string::npos)) { + if (create_row && (std::string(str_buf).find(key) != std::string::npos)) { complete_List.push_back(buffer); } } @@ -387,7 +386,6 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, s int replace_KeyName_with_Keycode(std::string in) { int out = returnIfCharInvalid; - // these are the keycode-Values we use in Keyman (= windows scancodes+8 ) if ( in == "key") out = 49; /* VK_ BKQUOTE */ else if ( in == "key") out = 10; /* VK_1 */ else if ( in == "key") out = 11; /* VK_2 */ @@ -399,8 +397,8 @@ int replace_KeyName_with_Keycode(std::string in) { else if ( in == "key") out = 17; /* VK_8 */ else if ( in == "key") out = 18; /* VK_9 */ else if ( in == "key") out = 19; /* VK_0 */ - else if ( in == "key") out = 20; /* VK_MINUS K_HYPHEN de ẞ */ - else if ( in == "key") out = 21; /* VK_EQUAL DE ' */ + else if ( in == "key") out = 20; /* VK_MINUS K_HYPHEN */ + else if ( in == "key") out = 21; /* VK_EQUAL */ else if ( in == "key") out = 24; /* VK_Q */ else if ( in == "key") out = 25; /* VK_W */ @@ -412,8 +410,8 @@ int replace_KeyName_with_Keycode(std::string in) { else if ( in == "key") out = 31; /* VK_I */ else if ( in == "key") out = 32; /* VK_O */ else if ( in == "key") out = 33; /* VK_P */ - else if ( in == "key") out = 34; /* VK_LEFTBRACE DE Ü */ - else if ( in == "key") out = 35; /* VK_RIGHTBRACE DE + */ + else if ( in == "key") out = 34; /* VK_LEFTBRACE */ + else if ( in == "key") out = 35; /* VK_RIGHTBRACE */ else if ( in == "key") out = 38; /* VK_A */ else if ( in == "key") out = 39; /* VK_S */ @@ -424,8 +422,8 @@ int replace_KeyName_with_Keycode(std::string in) { else if ( in == "key") out = 44; /* VK_J */ else if ( in == "key") out = 45; /* VK_K */ else if ( in == "key") out = 46; /* VK_L */ - else if ( in == "key") out = 47; /* VK_SEMICOLON DE Ö */ - else if ( in == "key") out = 48; /* VK_APOSTROPHE DE Ä */ + else if ( in == "key") out = 47; /* VK_SEMICOLON */ + else if ( in == "key") out = 48; /* VK_APOSTROPHE */ else if ( in == "key") out = 52; /* VK_Z */ else if ( in == "key") out = 53; /* VK_X */ @@ -436,7 +434,7 @@ int replace_KeyName_with_Keycode(std::string in) { else if ( in == "key") out = 58; /* VK_M */ else if ( in == "key") out = 59; /* VK_ COMMA */ else if ( in == "key") out = 60; /* VK_DOT */ - else if ( in == "key") out = 61; /* VK_SLASH DE - */ + else if ( in == "key") out = 61; /* VK_SLASH */ else if ( in == "key") out = 51; /* VK_BKSLASH */ else if ( in == "key") out = 63; /* VK_RIGHTSHIFT */ else if ( in == "key") out = 65; /* VK_SPACE */ @@ -452,7 +450,7 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; char split_bracel = '{'; - char split_char_komma = ','; + char split_comma = ','; int Keycde; v_str_1D tokens; v_dw_1D tokens_dw; @@ -482,17 +480,14 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { std::istringstream split(tokens[1]); tokens.pop_back(); - for (std::string each; std::getline(split, each, split_char_komma); tokens.push_back(each)); + for (std::string each; std::getline(split, each, split_comma); tokens.push_back(each)); // now convert all to KMX_DWORD and fill tokens tokens_dw.push_back((KMX_DWORD) Keycde); for ( int i = 1; i< (int) tokens.size();i++) { - // replace a name with a single character ( a -> a ; equal -> = ) tokens_int = convertNamesTo_DWORD_Value(tokens[i]); - //tokens_int = convertNamesTo_DWORD_Value( wstring_from_string(tokens[i])); - tokens_dw.push_back(tokens_int); } @@ -555,7 +550,7 @@ int append_underlying_ToVector(v_dw_3D &All_Vector,GdkKeymap *keymap) { } bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]) { -// get keymap of keyboard layout in use +// get keymap of underlying keyboard gdk_init(&argc, &argv); GdkDisplay *display = gdk_display_get_default(); @@ -595,8 +590,7 @@ std::u16string convert_DeadkeyValues_To_U16str(int in) { return std::u16string(1, in); } - //KMX_DWORD lname_old = convertNamesTo_DWORD_Value( wstring_from_string(long_name)); // 65106 => "dead_circumflex" => 94 => "^" - KMX_DWORD lname = convertNamesTo_DWORD_Value(long_name); // 65106 => "dead_circumflex" => 94 => "^" + KMX_DWORD lname = convertNamesTo_DWORD_Value(long_name); // 65106 => "dead_circumflex" => 94 => "^" if (lname != returnIfCharInvalid) { return std::u16string(1, lname ); @@ -765,10 +759,8 @@ KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap *keymap, v_dw_3D &A KMX_DWORD KC_underlying; std::u16string u16str = convert_DeadkeyValues_To_U16str(KMX_get_KeyVal_From_KeyCode(keymap, KC_US, ss, caps)); - //Find KC_underlying character for( int i=0; i< (int)All_Vector[1].size()-1 ;i++) { for( int j=1; j< (int)All_Vector[1][0].size();j++) { - //if ( ( All_Vector[1][i][j] == (KMX_DWORD) *ws.c_str() ) ) { if ( ( All_Vector[1][i][j] == (KMX_DWORD) *u16str.c_str() ) ) { KC_underlying = All_Vector[1][i][0]; return KC_underlying; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 06cfd05704..86baa3dc9f 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -14,7 +14,6 @@ #include #include #include -//#include "kmx_file.h" #include "u16.h" @@ -46,8 +45,8 @@ const KMX_DWORD KMX_VKMap[] = { VK_RBRKT, /* ] 221 VK_OEM_6 */ VK_BKSLASH, /* \ 220 VK_OEM_5 */ - VK_COLON, /* ; 186 VK_OEM_1 or ö */ - VK_QUOTE, /* ' 222 VK_OEM_7 or Ä */ + VK_COLON, /* ; 186 VK_OEM_1 */ + VK_QUOTE, /* ' 222 VK_OEM_7 */ VK_COMMA, /* , 188 VK_OEM_COMMA */ VK_PERIOD, /* . 190 VK_OEM_PERIOD */ @@ -67,33 +66,34 @@ typedef std::vector > > v_dw_3D; static KMX_DWORD returnIfCharInvalid = 0; static KMX_DWORD keycode_max = 94; static KMX_DWORD deadkey_min = 0xfe50; -//static KMX_DWORD deadkey_max = 0xfe93; -static KMX_DWORD deadkey_max = 0xfe52; // _S2 TOP_6 TODO This has to go! my test: to only return 3 dk +static KMX_DWORD deadkey_max = 0xfe93; +//static KMX_DWORD deadkey_max = 0xfe52; // _S2 TOP_6 TODO This has to go! my test: to only return 3 dk +// map Shiftstate to modifier (e.g. 0->0; 16-1; 9->2; 25->3) int map_VKShiftState_to_LinModifier(int VKShiftState); -// take a std::wstring (=contents of line symbols-file ) and returns the (int) value of the character +// take a std::string (=contents of line symbols-file ) and returns the (int) value of the character KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str); -// create a Vector with all entries of both keymaps+ keymap +// create a Vector with all entries of both keymaps int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap); -// read configuration file, split and write to 3D-Vector (Data for US on [0][ ][ ] ) +// read configuration file, split and write to 3D-Vector (Data for US on Vector[0][ ][ ] ) int write_US_ToVector(v_dw_3D &vec, std::string language, const char *text); // 1. step: read complete Row of Configuration file US bool createCompleteRow_US(v_str_1D &complete_List, FILE *fpp, const char *text, std::string language); -// replace Name of Key (e.g. ) wih Keycode ( e.g. 0x15 ) +// replace Name of Key (e.g. ) wih Keycode ( e.g. 15 ) int replace_KeyName_with_Keycode(std::string in); -// 2nd step: write contents to 3D vector +// 2. step: write contents to 3D vector int split_US_To_3D_Vector(v_dw_3D &all_US, v_str_1D completeList); -// create an empty 2D vector containing "--" in all fields +// create an empty 2D vector containing 0 in all fields v_dw_2D create_empty_2D_Vector(int dim_rows, int dim_shifts); -// append characters using GDK to 3D-Vector (Data for underlying Language on [1][ ][ ] ) +// append characters to 3D-Vector using GDK (Data for underlying Language on Vector[1][ ][ ] ) int append_underlying_ToVector(v_dw_3D &All_Vector, GdkKeymap *keymap); // initialize GDK @@ -103,44 +103,44 @@ bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); const UINT USVirtualKeyToScanCode[256] = { 0x00, // L"K_?00", // &H0 - 0x00, // L"K_LBUTTON", // &H1 - 0x00, // L"K_RBUTTON", // &H2 - 0x46, // L"K_CANCEL", // &H3 - 0x00, // L"K_MBUTTON", // &H4 + 0x00, // L"K_LBUTTON", // &H1 + 0x00, // L"K_RBUTTON", // &H2 + 0x46, // L"K_CANCEL", // &H3 + 0x00, // L"K_MBUTTON", // &H4 0x00, // L"K_?05", // &H5 0x00, // L"K_?06", // &H6 0x00, // L"K_?07", // &H7 - 0x0E, // L"K_BKSP", // &H8 - 0x0F, // L"K_TAB", // &H9 + 0x0E, // L"K_BKSP", // &H8 + 0x0F, // L"K_TAB", // &H9 0x00, // L"K_?0A", // &HA 0x00, // L"K_?0B", // &HB - 0x4C, // L"K_KP5", // &HC + 0x4C, // L"K_KP5", // &HC 0x1C, // L"K_ENTER", // &HD 0x00, // L"K_?0E", // &HE 0x00, // L"K_?0F", // &HF 0x2A, // L"K_SHIFT", // &H10 - 0x1D, // L"K_CONTRO0x00, // L", // &H11 + 0x1D, // L"K_CONTRO0x00, // L", // &H11 0x38, // L"K_ALT", // &H12 0x00, // L"K_PAUSE", // &H13 0x3A, // L"K_CAPS", // &H14 - 0x00, // L"K_KANJI?15", // &H15 - 0x00, // L"K_KANJI?16", // &H16 - 0x00, // L"K_KANJI?17", // &H17 - 0x00, // L"K_KANJI?18", // &H18 - 0x00, // L"K_KANJI?19", // &H19 + 0x00, // L"K_KANJI?15", // &H15 + 0x00, // L"K_KANJI?16", // &H16 + 0x00, // L"K_KANJI?17", // &H17 + 0x00, // L"K_KANJI?18", // &H18 + 0x00, // L"K_KANJI?19", // &H19 0x00, // L"K_?1A", // &H1A 0x01, // L"K_ESC", // &H1B - 0x00, // L"K_KANJI?1C", // &H1C - 0x00, // L"K_KANJI?1D", // &H1D - 0x00, // L"K_KANJI?1E", // &H1E - 0x00, // L"K_KANJI?1F", // &H1F + 0x00, // L"K_KANJI?1C", // &H1C + 0x00, // L"K_KANJI?1D", // &H1D + 0x00, // L"K_KANJI?1E", // &H1E + 0x00, // L"K_KANJI?1F", // &H1F 0x39, // L"K_SPACE", // &H20 0x49, // L"K_PGUP", // &H21 0x51, // L"K_PGDN", // &H22 0x4F, // L"K_END", // &H23 0x47, // L"K_HOME", // &H24 0x4B, // L"K_LEFT", // &H25 - 0x48, // L"K_UP", // &H26 + 0x48, // L"K_UP", // &H26 0x4D, // L"K_RIGHT", // &H27 0x50, // L"K_DOWN", // &H28 0x00, // L"K_SEL", // &H29 @@ -150,16 +150,16 @@ const UINT USVirtualKeyToScanCode[256] = { 0x52, // L"K_INS", // &H2D 0x53, // L"K_DEL", // &H2E 0x63, // L"K_HELP", // &H2F - 0x0B, // L"K_0", // &H30 - 0x02, // L"K_1", // &H31 - 0x03, // L"K_2", // &H32 - 0x04, // L"K_3", // &H33 - 0x05, // L"K_4", // &H34 - 0x06, // L"K_5", // &H35 - 0x07, // L"K_6", // &H36 - 0x08, // L"K_7", // &H37 - 0x09, // L"K_8", // &H38 - 0x0A, // L"K_9", // &H39 + 0x0B, // L"K_0", // &H30 + 0x02, // L"K_1", // &H31 + 0x03, // L"K_2", // &H32 + 0x04, // L"K_3", // &H33 + 0x05, // L"K_4", // &H34 + 0x06, // L"K_5", // &H35 + 0x07, // L"K_6", // &H36 + 0x08, // L"K_7", // &H37 + 0x09, // L"K_8", // &H38 + 0x0A, // L"K_9", // &H39 0x00, // L"K_?3A", // &H3A 0x00, // L"K_?3B", // &H3B 0x00, // L"K_?3C", // &H3C @@ -167,32 +167,32 @@ const UINT USVirtualKeyToScanCode[256] = { 0x00, // L"K_?3E", // &H3E 0x00, // L"K_?3F", // &H3F 0x00, // L"K_?40", // &H40 - 0x1E, // L"K_A", // &H41 - 0x30, // L"K_B", // &H42 - 0x2E, // L"K_C", // &H43 - 0x20, // L"K_D", // &H44 - 0x12, // L"K_E", // &H45 - 0x21, // L"K_F", // &H46 - 0x22, // L"K_G", // &H47 - 0x23, // L"K_H", // &H48 - 0x17, // L"K_I", // &H49 - 0x24, // L"K_J", // &H4A - 0x25, // L"K_K", // &H4B - 0x26, // L"K_L", // &H4C - 0x32, // L"K_M", // &H4D - 0x31, // L"K_N", // &H4E - 0x18, // L"K_O", // &H4F - 0x19, // L"K_P", // &H50 - 0x10, // L"K_Q", // &H51 - 0x13, // L"K_R", // &H52 - 0x1F, // L"K_S", // &H53 - 0x14, // L"K_T", // &H54 - 0x16, // L"K_U", // &H55 - 0x2F, // L"K_V", // &H56 - 0x11, // L"K_W", // &H57 - 0x2D, // L"K_X", // &H58 - 0x15, // L"K_Y", // &H59 - 0x2C, // L"K_Z", // &H5A + 0x1E, // L"K_A", // &H41 + 0x30, // L"K_B", // &H42 + 0x2E, // L"K_C", // &H43 + 0x20, // L"K_D", // &H44 + 0x12, // L"K_E", // &H45 + 0x21, // L"K_F", // &H46 + 0x22, // L"K_G", // &H47 + 0x23, // L"K_H", // &H48 + 0x17, // L"K_I", // &H49 + 0x24, // L"K_J", // &H4A + 0x25, // L"K_K", // &H4B + 0x26, // L"K_L", // &H4C + 0x32, // L"K_M", // &H4D + 0x31, // L"K_N", // &H4E + 0x18, // L"K_O", // &H4F + 0x19, // L"K_P", // &H50 + 0x10, // L"K_Q", // &H51 + 0x13, // L"K_R", // &H52 + 0x1F, // L"K_S", // &H53 + 0x14, // L"K_T", // &H54 + 0x16, // L"K_U", // &H55 + 0x2F, // L"K_V", // &H56 + 0x11, // L"K_W", // &H57 + 0x2D, // L"K_X", // &H58 + 0x15, // L"K_Y", // &H59 + 0x2C, // L"K_Z", // &H5A 0x5B, // L"K_?5B", // &H5B 0x5C, // L"K_?5C", // &H5C 0x5D, // L"K_?5D", // &H5D @@ -210,19 +210,19 @@ const UINT USVirtualKeyToScanCode[256] = { 0x49, // L"K_NP9", // &H69 0x37, // L"K_NPSTAR", // &H6A 0x4E, // L"K_NPPLUS", // &H6B - 0x7E, // L"K_SEPARATOR", // &H6C // MCD 01-11-02: Brazilian Fix, 00 -> 7E - 0x4A, // L"K_NPMINUS", // &H6D + 0x7E, // L"K_SEPARATOR", // &H6C // MCD 01-11-02: Brazilian Fix, 00 -> 7E + 0x4A, // L"K_NPMINUS", // &H6D 0x53, // L"K_NPDOT", // &H6E - 0x135, // L"K_NPSLASH", // &H6F - 0x3B, // L"K_F1", // &H70 - 0x3C, // L"K_F2", // &H71 - 0x3D, // L"K_F3", // &H72 - 0x3E, // L"K_F4", // &H73 - 0x3F, // L"K_F5", // &H74 - 0x40, // L"K_F6", // &H75 - 0x41, // L"K_F7", // &H76 - 0x42, // L"K_F8", // &H77 - 0x43, // L"K_F9", // &H78 + 0x135, // L"K_NPSLASH", // &H6F + 0x3B, // L"K_F1", // &H70 + 0x3C, // L"K_F2", // &H71 + 0x3D, // L"K_F3", // &H72 + 0x3E, // L"K_F4", // &H73 + 0x3F, // L"K_F5", // &H74 + 0x40, // L"K_F6", // &H75 + 0x41, // L"K_F7", // &H76 + 0x42, // L"K_F8", // &H77 + 0x43, // L"K_F9", // &H78 0x44, // L"K_F10", // &H79 0x57, // L"K_F11", // &H7A 0x58, // L"K_F12", // &H7B @@ -248,8 +248,8 @@ const UINT USVirtualKeyToScanCode[256] = { 0x00, // L"K_?8E", // &H8E 0x00, // L"K_?8F", // &H8F - 0x45, // L"K_NUMLOCK", // &H90 - 0x46, // L"K_SCROL0x00, // L", // &H91 + 0x45, // L"K_NUMLOCK", // &H90 + 0x46, // L"K_SCROL0x00, // &H91 0x00, // L"K_?92", // &H92 0x00, // L"K_?93", // &H93 @@ -502,7 +502,7 @@ const UINT ScanCodeToUSVirtualKey[128] = { bool IsKeymanUsedChar(int KV); //------------------------------ -// take deadkey-value (e.g.65106) and return wstring (e.g. '^' ) +// take deadkey-value (e.g.65106) and return u16string (e.g. '^' ) std::u16string convert_DeadkeyValues_To_U16str(int in); // use gdk_keymap_translate_keyboard_state to get keyval - base function to get keyvals @@ -526,7 +526,7 @@ UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); // return the VirtualKey of the US Keyboard for a given Keyode using GDK KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying(KMX_DWORD keycode); -// convert codePoint to wstring +// convert codePoint to u16string std::u16string CodePointToU16String(unsigned int codepoint); # endif /*KEYMAP_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index b92862602d..cf91203bd4 100755 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -57,9 +57,6 @@ typedef KMX_BYTE* PKMX_BYTE; typedef KMX_DWORD* PKMX_DWORD; typedef int BOOL; -//typedef void* KMX_HKL; // _S2 QUESTION what is the equivalent to HKL and do I need it?? I assume a void* - - #ifndef FALSE #define FALSE 0 #endif diff --git a/linux/mcompile/keymap/kmx_file.h b/linux/mcompile/keymap/kmx_file.h index 51e051db11..29543b703e 100755 --- a/linux/mcompile/keymap/kmx_file.h +++ b/linux/mcompile/keymap/kmx_file.h @@ -7,8 +7,6 @@ #ifndef KMX_FILE_H #define KMX_FILE_H -//#include - #define UNREFERENCED_PARAMETER(P) (P) #define TRUNCATE ((size_t)-1) #ifdef KMN_KBP @@ -19,7 +17,6 @@ namespace kmx { #endif #define KMX_MAX_ALLOWED_FILE_SIZE (128 * 1024 * 1024) /* 128MB */ -/* */ #define KEYMAN_LAYOUT_DEFAULT 0x000005FE diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 980e1c17f1..0295b3ff64 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -88,7 +88,7 @@ int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int return -1; else if(gdk_keyval_to_unicode(KeyVal) == 0) // NO UNICODE return 0; - else /// usable char + else // usable char return 1; } @@ -140,39 +140,39 @@ public: } bool KMX_IsSGCAPS() { - std::u16string stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß - std::u16string stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? - std::u16string stCaps = this->KMX_GetShiftState(Base, true); // 0,1 A 4 ẞ - std::u16string stShiftCaps = this->KMX_GetShiftState(Shft, true); // 1,1 a $ ? + std::u16string stBase = this->KMX_GetShiftState(Base, false); + std::u16string stShift = this->KMX_GetShiftState(Shft, false); + std::u16string stCaps = this->KMX_GetShiftState(Base, true); + std::u16string stShiftCaps = this->KMX_GetShiftState(Shft, true); return ( ((stCaps.size() > 0) && - (stBase.compare(stCaps) != 0) && // stBase != stCaps - (stShift.compare(stCaps) != 0)) || // stShift!= stCaps + (stBase.compare(stCaps) != 0) && + (stShift.compare(stCaps) != 0)) || ((stShiftCaps.size() > 0) && - (stBase.compare(stShiftCaps) != 0) && // stBase != stShiftCaps - (stShift.compare(stShiftCaps) != 0))); // stShift!= stShiftCaps + (stBase.compare(stShiftCaps) != 0) && + (stShift.compare(stShiftCaps) != 0))); } bool KMX_IsCapsEqualToShift() { - std::u16string stBase = this->KMX_GetShiftState(Base, false); // 0,0 a 4 ß - std::u16string stShift = this->KMX_GetShiftState(Shft, false); // 1,0 A $ ? - std::u16string stCaps = this->KMX_GetShiftState(Base, true); // 0,1 A 4 ẞ + std::u16string stBase = this->KMX_GetShiftState(Base, false); + std::u16string stShift = this->KMX_GetShiftState(Shft, false); + std::u16string stCaps = this->KMX_GetShiftState(Base, true); return ( - (stBase.size() > 0) && // unshifted char inside - (stShift.size() > 0) && // shifted char inside - (stBase.compare(stShift) != 0) && // stBase != stShft - (stShift.compare(stCaps) == 0)); // stShft == stCaps + (stBase.size() > 0) && + (stShift.size() > 0) && + (stBase.compare(stShift) != 0) && + (stShift.compare(stCaps) == 0)); } bool KMX_IsAltGrCapsEqualToAltGrShift() { - std::u16string stBase = this->KMX_GetShiftState(MenuCtrl, false); // 0,0 - std::u16string stShift = this->KMX_GetShiftState(ShftMenuCtrl, false); // 1,0 - std::u16string stCaps = this->KMX_GetShiftState(MenuCtrl, true); // 0,1 + std::u16string stBase = this->KMX_GetShiftState(MenuCtrl, false); + std::u16string stShift = this->KMX_GetShiftState(ShftMenuCtrl, false); + std::u16string stCaps = this->KMX_GetShiftState(MenuCtrl, true); return ( - (stBase.size() > 0) && // unshifted MenuCtrl/AltGr char inside - (stShift.size() > 0) && // shifted MenuCtrl/AltGr char inside - (stBase.compare(stShift) != 0) && // stBase != stShft - (stShift.compare(stCaps) == 0)); // stShft == stCaps + (stBase.size() > 0) && + (stShift.size() > 0) && + (stBase.compare(stShift) != 0) && + (stShift.compare(stCaps) == 0)); } bool KMX_IsXxxxGrCapsEqualToXxxxShift() { @@ -209,13 +209,6 @@ public: int nkeys = 0; // Get the CAPSLOCK value - //_S2 TOP_6 INFO not used in original code; can be deleted - /*int capslock = - (this->KMX_IsCapsEqualToShift() ? 1 : 0) | - (this->KMX_IsSGCAPS() ? 2 : 0) | - (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0);*/ - for (int ss = 0; ss <= MaxShiftState; ss++) { if (ss == Menu || ss == ShftMenu) { // Alt and Shift+Alt don't work, so skip them @@ -255,8 +248,6 @@ public: (this->KMX_IsSGCAPS() ? 2 : 0) | (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); - // _S2 we need this capslock calculation - //capslock=1;*/ for (int ss = 0; ss <= MaxShiftState; ss++) { if (ss == Menu || ss == ShftMenu) { @@ -374,8 +365,6 @@ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 KMX_Loader loader; - //KMX_HKL hkl = NULL; - std::vector rgKey; //= new VirtualKey[256]; std::vector alDead; std::vector alDead_cpl = create_alDead(); @@ -395,7 +384,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, KMX_VirtualKey *key = new KMX_VirtualKey(sc); - if((key->VK() != 0) ) { + if((key->VK() != 0) ) { rgKey[key->VK()] = key; } else { delete key; @@ -431,14 +420,14 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, if(rc > 0) { if(*sbBuffer == 0) { - rgKey[iKey]->KMX_SetShiftState(ss, u"", false, (caps)); // different to windows since behavior on Linux is different + rgKey[iKey]->KMX_SetShiftState(ss, u"", false, (caps)); // different to windows since behavior on Linux is different } else { if( (ss == Ctrl || ss == ShftCtrl) ) { continue; } sbBuffer[rc] = 0; - rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps)); // different to windows since behavior on Linux is different + rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps)); // different to windows since behavior on Linux is different } } else if(rc < 0) { @@ -507,7 +496,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // // Fill in the new rules // - //fills group3: group(group3) using keys for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { if(rgKey[iKey]->KMX_LayoutRow(loader.KMX_MaxShiftState(), &gp->dpKeyArray[nkeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 @@ -521,10 +509,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // // Add nomatch control to each terminating 'using keys' group // I4550 // - // _adds + [CTRL NCAPS K_QUOTE] > use(group2) c line(0) - // + [CTRL CAPS K_QUOTE] > use(group2) c line(0) - //nomatch > use(group2) nomatch > use(group3) - // after dk-section LPKMX_GROUP gp2 = kp->dpGroupArray; for(UINT i = 0; i < kp->cxGroupArray - 1; i++, gp2++) { if(gp2->fUsingKeys && gp2->dpNoMatch == NULL) { @@ -565,9 +549,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, // If we have deadkeys, then add a new group to translate the deadkeys per the deadkey tables // We only do this if not in deadkey conversion mode // - // _S2 writes âêîôû^for dk at the beginning + - // _S2 writes deadkey(1) at the end - if (alDead.size() > 0 && !bDeadkeyConversion) { // I4552 kp->cxGroupArray++; diff --git a/linux/mcompile/keymap/mc_import_rules.h b/linux/mcompile/keymap/mc_import_rules.h index f8f958d7d4..51fd5502f4 100644 --- a/linux/mcompile/keymap/mc_import_rules.h +++ b/linux/mcompile/keymap/mc_import_rules.h @@ -10,11 +10,11 @@ private: std::vector m_rgcombchar; public: - DeadKey(KMX_WCHAR deadCharacter) ; + DeadKey(KMX_WCHAR deadCharacter); - KMX_WCHAR KMX_DeadCharacter() ; + KMX_WCHAR KMX_DeadCharacter(); - void KMX_AddDeadKeyRow(KMX_WCHAR baseCharacter, KMX_WCHAR combinedCharacter) ; + void KMX_AddDeadKeyRow(KMX_WCHAR baseCharacter, KMX_WCHAR combinedCharacter); int KMX_Count() { return this->m_rgbasechar.size(); @@ -32,7 +32,7 @@ public: return this->m_rgcombchar[index]; } - bool KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter) ; + bool KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter); }; # endif /*MC_IMPORT_RULES_H*/ diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 2a2b5e070b..de9d8d1ded 100755 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -1,5 +1,4 @@ #include "mc_kmxfile.h" -//#include "u16.h" #include #define CERR_None 0x00000000 @@ -230,8 +229,7 @@ PKMX_WCHAR KMX_StringOffset(PKMX_BYTE base, KMX_DWORD offset) { we don't copy the strings This method is used on 64-bit architectures. */ -LPKMX_KEYBOARD KMX_CopyKeyboard(PKMX_BYTE bufp, PKMX_BYTE base) -{ +LPKMX_KEYBOARD KMX_CopyKeyboard(PKMX_BYTE bufp, PKMX_BYTE base) { PKMX_COMP_KEYBOARD ckbp = (PKMX_COMP_KEYBOARD) base; /* Copy keyboard structure */ diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 5bc82a963c..9d7f5556f0 100755 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -42,10 +42,10 @@ typedef struct KMX_tagKEYBOARD { KMX_DWORD dwFileVersion; // Version of the file - Keyman 4.0 is 0x0400 - KMX_DWORD dwCheckSum; // As stored in keyboard. DEPRECATED as of 16.0 - KMX_DWORD xxkbdlayout; // as stored in HKEY_LOCAL_MACHINE//system//currentcontrolset//control//keyboard layouts + KMX_DWORD dwCheckSum; // As stored in keyboard. DEPRECATED as of 16.0 + KMX_DWORD xxkbdlayout; // as stored in HKEY_LOCAL_MACHINE//system//currentcontrolset//control//keyboard layouts KMX_DWORD IsRegistered; // layout id, from same registry key - KMX_DWORD version; // keyboard version + KMX_DWORD version; // keyboard version KMX_DWORD cxStoreArray; // in array entries KMX_DWORD cxGroupArray; // in array entries @@ -54,23 +54,22 @@ typedef struct KMX_tagKEYBOARD { LPKMX_GROUP dpGroupArray; // [LPGROUP] address of first item in group array, from start of file KMX_DWORD StartGroup[2]; // index of starting groups [2 of them] - // Ansi=0, Unicode=1 + // Ansi=0, Unicode=1 - KMX_DWORD dwFlags; // Flags for the keyboard file + KMX_DWORD dwFlags; // Flags for the keyboard file - KMX_DWORD dwHotKey; // standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) + KMX_DWORD dwHotKey; // standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) - //PWSTR dpName; // offset of name - //PWSTR dpLanguageName; // offset of language name; - //PWSTR dpCopyright; // offset of copyright - //PWSTR dpMessage; // offset of message in Keyboard About box + //PWSTR dpName; // offset of name + //PWSTR dpLanguageName; // offset of language name; + //PWSTR dpCopyright; // offset of copyright + //PWSTR dpMessage; // offset of message in Keyboard About box KMX_DWORD dpBitmapOffset; // 0038 offset of the bitmaps in the file KMX_DWORD dwBitmapSize; // 003C size in bytes of the bitmaps - //HBITMAP hBitmap; // handle to the bitmap in the file; + //HBITMAP hBitmap; // handle to the bitmap in the file; } KMX_KEYBOARD, *LPKMX_KEYBOARD; - KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD *lpKeyboard); KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, PKMX_WCHAR filename); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 27f6026fd0..355b271d60 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -75,7 +75,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ return 1; } - // -u option not available for Linux + // -u option is not available for Linux int bDeadkeyConversion = u16cmp(argv[1], u"-d") == 0; // I4552 int n = (bDeadkeyConversion ? 2 : 1); @@ -129,8 +129,8 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ } #endif - //DeleteReallocatedPointers(kmxfile); :TODO // _S2 TOP_6 not my ToDo :-) -wprintf(L"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm end\n"); + //DeleteReallocatedPointers(kmxfile); :TODO // _S2 not my ToDo :-) +wprintf(L"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmxxxmmmmmmmmmmmmmmmmmmmmm _S2 end\n"); delete kmxfile; return 0; } @@ -436,7 +436,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg ch = DeadKey; } } -// _S2 group1 writes using keys here + switch(ch) { case 0x0000: break; case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap , dk_Table); break; @@ -447,7 +447,6 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg KMX_ReportUnconvertedKeyboardRules(kbd); -// _S2 add everything after dk-section group1 if(!KMX_ImportRules(kbd, All_Vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 return FALSE; } @@ -460,7 +459,7 @@ int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, KMX_DWORD shift; v_dw_2D dk_SingleTable; - find_dk_combinations_for_specific_dk(&dk_Table, dk_SingleTable, DeadKey); + query_dk_combinations_for_specific_dk(&dk_Table, dk_SingleTable, DeadKey); for ( int i=0; i< (int) dk_SingleTable.size();i++) { KMX_WORD vk = KMX_changeKeynameToCapital(dk_SingleTable[i][1], shift, keymap); if(vk != 0) { From 89844cb074966476ae8f17291fc652b95e4556bb Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 18 Mar 2024 01:16:32 +0100 Subject: [PATCH 235/327] feat(linux): mcompile-dk very last edits --- linux/mcompile/keymap/deadkey.cpp | 4 +--- linux/mcompile/keymap/mc_import_rules.cpp | 4 ++-- linux/mcompile/keymap/mcompile.cpp | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 8afee1d15a..33909f1f99 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -386,9 +386,7 @@ void create_DKTable(v_dw_2D & dk_ComposeTable) { line = createLine("dead_circumflex", "space", 0x005E, "CIRCUMFLEX_ACCENT"); dk_ComposeTable.push_back(line); line.clear(); - /*line = createLine("dead_acute", "space", 0x0027, "APOSTROPHE"); - dk_ComposeTable.push_back(line); line.clear();*/ - line = createLine("dead_acute", "space", 0x00B4, "ACUTE_ACCENT"); // _S2 TOP_3 ToDo remove - just for testing + line = createLine("dead_acute", "space", 0x0027, "APOSTROPHE"); dk_ComposeTable.push_back(line); line.clear(); line = createLine("dead_grave", "space", 0x0060, "GRAVE_ACCENT"); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 0295b3ff64..6b0438f941 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -409,9 +409,9 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, } //_S2 TOP_6 TODO to compare win-lin kmn-files skip ss6+7; MUST BE removed later!!!! - if(ss == MenuCtrl|| ss == ShftMenuCtrl) { + /*if(ss == MenuCtrl|| ss == ShftMenuCtrl) { continue; - } + }*/ KMX_DWORD KC_US = (KMX_DWORD) KMX_get_KeyCodeUnderlying_From_VKUS(iKey); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 355b271d60..c051f6d142 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -77,6 +77,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ } // -u option is not available for Linux + int bDeadkeyConversion = u16cmp(argv[1], u"-d") == 0; // I4552 int n = (bDeadkeyConversion ? 2 : 1); @@ -130,7 +131,6 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ #endif //DeleteReallocatedPointers(kmxfile); :TODO // _S2 not my ToDo :-) -wprintf(L"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmxxxmmmmmmmmmmmmmmmmmmmmm _S2 end\n"); delete kmxfile; return 0; } From 809bc35520dae4cd0cc99e960b71e2528290b452 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 18 Mar 2024 01:30:05 +0100 Subject: [PATCH 236/327] feat(linux): mcompile-dk solve conflict in .gitignore --- linux/.gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/linux/.gitignore b/linux/.gitignore index 82efe998cf..d5f0f43dd6 100644 --- a/linux/.gitignore +++ b/linux/.gitignore @@ -39,3 +39,7 @@ help/reference/ # Debian watch file - we generate it from watch.in watch +# Debian quilt metadata +.pc/ +# Debian patch files will be re-generated +debian/patches/ From 85620712c899c9791572cba9066c704e7e534423 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 18 Mar 2024 01:41:00 +0100 Subject: [PATCH 237/327] feat(linux): mcompile-dk still solve conflict in .gitignore --- linux/.gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/linux/.gitignore b/linux/.gitignore index d5f0f43dd6..d3240fda6a 100644 --- a/linux/.gitignore +++ b/linux/.gitignore @@ -38,7 +38,6 @@ help/reference/ # Debian watch file - we generate it from watch.in watch - # Debian quilt metadata .pc/ # Debian patch files will be re-generated From 977007be4d25a884b2b836eb624b90ddfc1be4ef Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 29 Apr 2024 09:40:16 +0200 Subject: [PATCH 238/327] feat(linux): mcompile add line --- linux/mcompile/keymap/deadkey.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 33909f1f99..1cb73aac48 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -389,6 +389,7 @@ void create_DKTable(v_dw_2D & dk_ComposeTable) { line = createLine("dead_acute", "space", 0x0027, "APOSTROPHE"); dk_ComposeTable.push_back(line); line.clear(); + line = createLine("dead_grave", "space", 0x0060, "GRAVE_ACCENT"); dk_ComposeTable.push_back(line); line.clear(); line = createLine("dead_breve", "space", 0x02D8, "BREVE"); From 55c70f7ce3ec28e00dbda1e90b0f50fa248711b9 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 11 Jun 2024 11:28:42 +0200 Subject: [PATCH 239/327] feat(linux): mcompile.cpp edit some text --- linux/mcompile/keymap/mcompile.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index c051f6d142..34d0eb59df 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -67,7 +67,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ wprintf( L"Usage: mcompile [-d] infile.kmx outfile.kmx\n" L" mmcompile -u ... (not available for Linux)\n " - L" mcompile converts a Keyman mnemonic layout to a\n" + L" mcompile converts a Keyman mnemonic layout to a\n" L" positional one based on the Linux keyboard\n" L" layout on top position\n" L" (-d convert deadkeys to plain keys) not available yet \n\n" @@ -154,7 +154,7 @@ void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { if(key->ShiftFlags == 0 && key->Key == ch) { // Key is a mnemonic key with no shift state defined. // Remap the key according to the character on the key cap. - //LogError(L"Converted mnemonic rule on line %d, + '%c' TO + [%x K_%d]", key->Line, key->Key, shift, vk); + //KMX_LogError(L"Converted mnemonic rule on line %d, + '%c' TO + [%x K_%d]", key->Line, key->Key, shift, vk); key->ShiftFlags = ISVIRTUALKEY | shift; key->Key = vk; } else if(key->ShiftFlags & VIRTUALCHARKEY && key->Key == ch) { @@ -163,7 +163,7 @@ void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { // This will not result in 100% wonderful mappings as there could // be overlap, depending on how keys are arranged on the target layout. // But that is up to the designer. - //LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, key->ShiftFlags & ~VIRTUALCHARKEY, vk); + //KMX_LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, key->ShiftFlags & ~VIRTUALCHARKEY, vk); key->ShiftFlags &= ~VIRTUALCHARKEY; key->Key = vk; } @@ -185,7 +185,7 @@ void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHA void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key) { if(key->ShiftFlags == 0) { - KMX_LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); + //KMX_LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); } else if(key->ShiftFlags & VIRTUALCHARKEY) { KMX_LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); } @@ -429,7 +429,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg UINT scUnderlying = KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]); KMX_WCHAR ch = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap, VKShiftState[j], scUnderlying, &DeadKey); - //wprintf(L"--- VK_%d -> SC_ [%c] dk=%d ( ss %i) \n", VKMap[i], ch == 0 ? 32 : ch, DeadKey, VKShiftState[j]); + //wprintf(L"--- VK_%d -> SC_ [%c] dk=%d ( ss %i) \n", KMX_VKMap[i], ch == 0 ? 32 : ch, DeadKey, VKShiftState[j]); if(bDeadkeyConversion) { // I4552 if(ch == 0xFFFF) { From 39c25c4cf0bb868d37fa9d7114126c9a754f63b5 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 11 Jun 2024 11:28:42 +0200 Subject: [PATCH 240/327] feat(linux): renaming symbols: mostly capital-non-capital at beginning of symbol name --- linux/mcompile/keymap/deadkey.cpp | 30 ++--- linux/mcompile/keymap/deadkey.h | 10 +- linux/mcompile/keymap/keymap.cpp | 152 +++++++++++----------- linux/mcompile/keymap/keymap.h | 35 +++-- linux/mcompile/keymap/mc_import_rules.cpp | 18 +-- linux/mcompile/keymap/mc_kmxfile.cpp | 26 +--- linux/mcompile/keymap/mc_kmxfile.h | 2 +- linux/mcompile/keymap/mcompile.cpp | 26 ++-- linux/mcompile/keymap/mcompile.h | 2 +- 9 files changed, 140 insertions(+), 161 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 1cb73aac48..bb5fa4fb65 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -1,8 +1,8 @@ #include "keymap.h" #include "deadkey.h" -v_dw_1D createLine(std::string first, std::string second, KMX_DWORD number, std::string nameresult) { - v_dw_1D line; +vec_dword_1D createLine(std::string first, std::string second, KMX_DWORD number, std::string nameresult) { + vec_dword_1D line; line.push_back(convertNamesTo_DWORD_Value(first)); line.push_back(convertNamesTo_DWORD_Value(second)); //line.push_back(convertNamesTo_DWORD_Value(nameresult)); @@ -10,9 +10,9 @@ v_dw_1D createLine(std::string first, std::string second, KMX_DWORD number, std return line; } -std::vector create_alDead() { +std::vector create_deadkeys_by_basechar() { std::vector alDead; - v_dw_2D dk_ComposeTable; + vec_dword_2D dk_ComposeTable; create_DKTable(dk_ComposeTable); @@ -54,8 +54,8 @@ bool found_dk_inVector(KMX_WCHAR dk, std::vector &dkVec) { return false; } -bool query_dk_combinations_for_specific_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D &dk_SingleTable, KMX_DWORD dk) { - v_dw_1D line; +bool query_dk_combinations_for_specific_dk(vec_dword_2D * p_dk_ComposeTable, vec_dword_2D &dk_SingleTable, KMX_DWORD dk) { + vec_dword_1D line; for ( int i =0; i< (int) (*p_dk_ComposeTable).size(); i++) { if (((*p_dk_ComposeTable)[i][0] == dk) && (IsKeymanUsedChar((*p_dk_ComposeTable)[i][1]))) { @@ -73,25 +73,25 @@ bool query_dk_combinations_for_specific_dk(v_dw_2D * p_dk_ComposeTable, v_dw_2D return false; } -KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap) { - guint Keyval = (guint) KVal; +KMX_DWORD KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD &shift, GdkKeymap* keymap) { + guint keyval = (guint) kVal; GdkKeymapKey* keys; gint n_keys; - KMX_DWORD Cap = (KMX_DWORD) gdk_keyval_to_upper (KVal); - if( Keyval !=0) { - gdk_keymap_get_entries_for_keyval(keymap, Keyval, &keys, &n_keys); + KMX_DWORD capitalKeyval = (KMX_DWORD) gdk_keyval_to_upper (kVal); + if( keyval !=0) { + gdk_keymap_get_entries_for_keyval(keymap, keyval, &keys, &n_keys); for (int i = 0; i < n_keys; i++) { if (keys[i].group == 0) { shift = keys[i].level; - return Cap; + return capitalKeyval; } } } - return Cap; + return capitalKeyval; } -void create_DKTable(v_dw_2D & dk_ComposeTable) { +void create_DKTable(vec_dword_2D & dk_ComposeTable) { //create a 2D-Vector which contains data for ALL existing deadkey combinations on a Linux Keyboard: //dk_ComposeTable[i][0] : First (e.g. dead_circumflex) //dk_ComposeTable[i][1] : Second (e.g. a) @@ -100,7 +100,7 @@ void create_DKTable(v_dw_2D & dk_ComposeTable) { //values taken from: https://help.ubuntu.com/community/GtkDeadKeyTable#Accents // _S2 Do we want to use GTK instead of this function? - v_dw_1D line; + vec_dword_1D line; line = createLine("dead_circumflex", "a", 0x00E2, "small A with circumflex"); dk_ComposeTable.push_back(line); line.clear(); diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index 4110b498ea..38185939d4 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -7,13 +7,13 @@ #include "mc_import_rules.h" // create a vector for a dk combination ( ` + a -> à ) -v_dw_1D createLine(std::string first, std::string second, KMX_DWORD number, std::string nameresult); +vec_dword_1D createLine(std::string first, std::string second, KMX_DWORD number, std::string nameresult); // create a 2D-vector of all dk combinations ( ` + a -> à ; ^ + a -> â ; `+ e -> è; ...) -void create_DKTable(v_dw_2D & dk_ComposeTable); +void create_DKTable(vec_dword_2D & dk_ComposeTable); // find all possible dk combinations that exist -std::vector create_alDead(); +std::vector create_deadkeys_by_basechar(); // refine dk to those used in the underlying keyboard void refine_alDead(KMX_WCHAR dk, std::vector &myVec, std::vector *p_All_Vec); @@ -21,9 +21,9 @@ void refine_alDead(KMX_WCHAR dk, std::vector &myVec, std::vector &myVec); // get all combination for a specific deadkey(dk) from the dk_vector query_dk_combinations_for_specific_dk which holds all possible dk: ^-> â,ê,î,ô,û,... -bool query_dk_combinations_for_specific_dk(v_dw_2D * dk_ComposeTable, v_dw_2D & dk_SingleTable, KMX_DWORD dk); +bool query_dk_combinations_for_specific_dk(vec_dword_2D * dk_ComposeTable, vec_dword_2D & dk_SingleTable, KMX_DWORD dk); // get the shifted character of a key and write shiftstate of KVal to shift -KMX_DWORD KMX_changeKeynameToCapital(KMX_DWORD KVal, KMX_DWORD &shift, GdkKeymap* keymap); +KMX_DWORD KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD &shift, GdkKeymap* keymap); # endif /*DEADKEY_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 4786208352..a2c26742ec 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -2,12 +2,12 @@ #include // unmodified, shift, RALT, shift+RALT -int map_VKShiftState_to_LinModifier(int VKShiftState) { - if (VKShiftState == 0 ) return 0; /* 0000 0000 */ - else if (VKShiftState == 16) return 1; /* 0001 0000 */ - else if (VKShiftState == 9 ) return 2; /* 0000 1001 */ - else if (VKShiftState == 25) return 3; /* 0001 1001 */ - else return VKShiftState; +int map_VKShiftState_to_LinModifier(int vk_ShiftState) { + if (vk_ShiftState == 0 ) return 0; /* 0000 0000 */ + else if (vk_ShiftState == 16) return 1; /* 0001 0000 */ + else if (vk_ShiftState == 9 ) return 2; /* 0000 1001 */ + else if (vk_ShiftState == 25) return 3; /* 0001 1001 */ + else return vk_ShiftState; } KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str) { @@ -288,10 +288,10 @@ KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str) { return it->second; } } - return returnIfCharInvalid; + return INVALID_NAME; } -int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap) { +int createOneVectorFromBothKeyboards(vec_dword_3D &All_Vector,GdkKeymap *keymap) { // create a 3D-Vector which contains data of the US keyboard and the underlying Keyboard: // All_Vector[ US_Keyboard ] // [KeyCode_US ] @@ -302,10 +302,10 @@ int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap) { // [Keyval unshifted ] // [Keyval shifted ] - std::string US_language = "us"; + std::string us_language = "us"; const char* text_us = "xkb_symbols \"basic\""; - if(write_US_ToVector(All_Vector,US_language, text_us)) { + if(write_US_ToVector(All_Vector,us_language, text_us)) { wprintf(L"ERROR: can't write US to Vector \n"); return 1; } @@ -318,11 +318,11 @@ int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap) { return 0; } -int write_US_ToVector( v_dw_3D &vec,std::string language, const char* text) { +int write_US_ToVector( vec_dword_3D &vec,std::string language, const char* section ) { - std::string FullPathName = "/usr/share/X11/xkb/symbols/" + language; + std::string fullPathName = "/usr/share/X11/xkb/symbols/" + language; - const char* path = FullPathName.c_str(); + const char* path = fullPathName.c_str(); FILE* fp = fopen((path), "r"); if ( !fp) { wprintf(L"ERROR: could not open file!\n"); @@ -330,14 +330,14 @@ int write_US_ToVector( v_dw_3D &vec,std::string language, const char* text) { } // create 1D-vector of the complete line - v_str_1D Vector_completeUS; - if( createCompleteRow_US(Vector_completeUS,fp , text, language)) { + vec_string_1D vector_completeUS; + if( createCompleteVector_US(fp, section , vector_completeUS)) { wprintf(L"ERROR: can't Create complete row US \n"); return 1; } // split contents of 1D Vector to 3D vector - if( split_US_To_3D_Vector( vec,Vector_completeUS)) { + if( split_US_To_3D_Vector( vec,vector_completeUS)) { return 1; } @@ -345,32 +345,32 @@ int write_US_ToVector( v_dw_3D &vec,std::string language, const char* text) { return 0; } -bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, std::string language) { +bool createCompleteVector_US(FILE* fp, const char* section , vec_string_1D &complete_List) { // in the Configuration file we find the appopriate paragraph between "xkb_symbol " and the next xkb_symbol // and then copy all rows starting with "key <" to a 1D-Vector int buffer_size = 512; - char buffer[buffer_size]; + char line[buffer_size]; bool create_row = false; const char* key = "key <"; - std::string str_txt(text); + std::string str_us_kbd_name(section ); std::string xbk_mark = "xkb_symbol"; if (fp) { - while (fgets(buffer, buffer_size, fp) != NULL) { - std::string str_buf(buffer); + while (fgets(line, buffer_size, fp) != NULL) { + std::string str_buf(line); // stop when finding the mark xkb_symbol if (std::string(str_buf).find(xbk_mark) != std::string::npos) create_row = false; // start when finding the mark xkb_symbol + correct layout - if (std::string(str_buf).find(str_txt) != std::string::npos) + if (std::string(str_buf).find(str_us_kbd_name) != std::string::npos) create_row = true; // as long as we are in the same xkb_symbol layout block and find "key <" we push the whole line into a 1D-vector if (create_row && (std::string(str_buf).find(key) != std::string::npos)) { - complete_List.push_back(buffer); + complete_List.push_back(line); } } } @@ -384,7 +384,7 @@ bool createCompleteRow_US(v_str_1D &complete_List, FILE* fp, const char* text, s } int replace_KeyName_with_Keycode(std::string in) { - int out = returnIfCharInvalid; + int out = INVALID_NAME; if ( in == "key") out = 49; /* VK_ BKQUOTE */ else if ( in == "key") out = 10; /* VK_1 */ @@ -442,7 +442,7 @@ int replace_KeyName_with_Keycode(std::string in) { return out; } -int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { +int split_US_To_3D_Vector(vec_dword_3D &all_US,vec_string_1D completeList) { // 1: take the whole line of the 1D-Vector and remove unwanted characters. // 2: seperate the name e.g. key from the shiftstates // 3: convert to KMX_DWORD @@ -451,10 +451,10 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; char split_bracel = '{'; char split_comma = ','; - int Keycde; - v_str_1D tokens; - v_dw_1D tokens_dw; - v_dw_2D shift_states; + int keyCode; + vec_string_1D tokens; + vec_dword_1D tokens_dw; + vec_dword_2D shift_states; KMX_DWORD tokens_int; // loop through the whole vector @@ -469,21 +469,23 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { if (completeList[k].find("key<") != std::string::npos) { //split off the key names - std::istringstream split1(completeList[k]); - for (std::string each; std::getline(split1, each, split_bracel); tokens.push_back(each)); + std::istringstream split_Keyname(completeList[k]); + for (std::string each; std::getline(split_Keyname, each, split_bracel); tokens.push_back(each)) { + // empty + } // replace keys names with Keycode ( with 21,...) - Keycde = replace_KeyName_with_Keycode(tokens[0]); - tokens[0] = std::to_string(Keycde); + keyCode = replace_KeyName_with_Keycode(tokens[0]); + tokens[0] = std::to_string(keyCode); // seperate rest of the vector to its elements and push to 'tokens' - std::istringstream split(tokens[1]); + std::istringstream split_Characters(tokens[1]); tokens.pop_back(); - for (std::string each; std::getline(split, each, split_comma); tokens.push_back(each)); + for (std::string each; std::getline(split_Characters, each, split_comma); tokens.push_back(each)); // now convert all to KMX_DWORD and fill tokens - tokens_dw.push_back((KMX_DWORD) Keycde); + tokens_dw.push_back((KMX_DWORD) keyCode); for ( int i = 1; i< (int) tokens.size();i++) { // replace a name with a single character ( a -> a ; equal -> = ) @@ -505,25 +507,25 @@ int split_US_To_3D_Vector(v_dw_3D &all_US,v_str_1D completeList) { return 0; } -v_dw_2D create_empty_2D_Vector( int dim_rows,int dim_ss) { +vec_dword_2D create_empty_2D_Vector( int dim_rows,int dim_ss) { - v_dw_1D shifts; - v_dw_2D Vector_2D; + vec_dword_1D shifts; + vec_dword_2D vector_2D; for ( int i=0; i< dim_rows;i++) { for ( int j=0; j< dim_ss;j++) { - shifts.push_back(returnIfCharInvalid); + shifts.push_back(INVALID_NAME); } - Vector_2D.push_back(shifts); + vector_2D.push_back(shifts); shifts.clear(); } - return Vector_2D; + return vector_2D; } -int append_underlying_ToVector(v_dw_3D &All_Vector,GdkKeymap *keymap) { +int append_underlying_ToVector(vec_dword_3D &All_Vector,GdkKeymap *keymap) { // create a 2D vector all filled with " " and push to 3D-Vector - v_dw_2D underlying_Vector2D = create_empty_2D_Vector(All_Vector[0].size(),All_Vector[0][0].size()); + vec_dword_2D underlying_Vector2D = create_empty_2D_Vector(All_Vector[0].size(),All_Vector[0][0].size()); if (underlying_Vector2D.size() == 0) { wprintf(L"ERROR: can't create empty 2D-Vector\n"); @@ -584,15 +586,15 @@ std::u16string convert_DeadkeyValues_To_U16str(int in) { std::string long_name((const char*) gdk_keyval_name (in)); // e.g. "dead_circumflex" , "U+017F" , "t" if ( long_name.substr (0,2) == "U+" ) // U+... Unicode value - return CodePointToU16String(in-0x1000000); - + return CodePointToU16String(in-0x1000000); // GDK's gdk_keymap_translate_keyboard_state() returns (Keyvalue | 0x01000000) + // since we never have a carry-over we can just subtract 0x01000000 if (in < (int) deadkey_min) { // no deadkey; no Unicode return std::u16string(1, in); } KMX_DWORD lname = convertNamesTo_DWORD_Value(long_name); // 65106 => "dead_circumflex" => 94 => "^" - if (lname != returnIfCharInvalid) { + if (lname != INVALID_NAME) { return std::u16string(1, lname ); } else @@ -690,7 +692,7 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, gui GdkKeymapKey *maps; guint *keyvals; gint count; - KMX_DWORD KVal; + KMX_DWORD kVal; if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; @@ -701,15 +703,15 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, gui if (!(keycode <= keycode_max)) return 0; - KVal = (KMX_DWORD) KMX_get_KeyVal_From_KeyCode(keymap, keycode, (ShiftState) shift_state_pos, 0); + kVal = (KMX_DWORD) KMX_get_KeyVal_From_KeyCode(keymap, keycode, (ShiftState) shift_state_pos, 0); g_free(keyvals); g_free(maps); - return KVal; + return kVal; } -KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, UINT VKShiftState, UINT KC_underlying, PKMX_WCHAR DeadKey) { +KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, UINT vk_ShiftState, UINT kc_underlying, PKMX_WCHAR deadkey) { GdkKeymapKey *maps; guint *keyvals; @@ -717,61 +719,61 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, UIN PKMX_WCHAR dky=NULL; - if (!gdk_keymap_get_entries_for_keycode(keymap, KC_underlying, &maps, &keyvals, &count)) + if (!gdk_keymap_get_entries_for_keycode(keymap, kc_underlying, &maps, &keyvals, &count)) return 0; - if (!(map_VKShiftState_to_LinModifier(VKShiftState) <= count)) + if (!(map_VKShiftState_to_LinModifier(vk_ShiftState) <= count)) return 0; - if (!(KC_underlying <= keycode_max)) + if (!(kc_underlying <= keycode_max)) return 0; - KMX_DWORD KeyV = KMX_get_KeyVal_From_KeyCode(keymap, KC_underlying, ShiftState(map_VKShiftState_to_LinModifier(VKShiftState)), 0); + KMX_DWORD keyV = KMX_get_KeyVal_From_KeyCode(keymap, kc_underlying, ShiftState(map_VKShiftState_to_LinModifier(vk_ShiftState)), 0); g_free(keyvals); g_free(maps); - if ((KeyV >= deadkey_min) && (KeyV <= deadkey_max) ){ // deadkey - dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) KeyV)).c_str(); - *DeadKey = *dky; + if ((keyV >= deadkey_min) && (keyV <= deadkey_max) ){ // deadkey + dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) keyV)).c_str(); + *deadkey = *dky; return 0xFFFF; } - else if((KeyV > deadkey_max) || ((KeyV < deadkey_min) && ( KeyV > 0xFF))) // out of range + else if((keyV > deadkey_max) || ((keyV < deadkey_min) && ( keyV > 0xFF))) // out of range return 0xFFFE; else // usable char - return KeyV; + return keyV; } - -KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(v_dw_3D & All_Vector, KMX_DWORD VK_US) { - KMX_DWORD VK_underlying; +//_S2 vk_us or underlying!!"!!" +KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(vec_dword_3D & All_Vector, KMX_DWORD vk_US) { + KMX_DWORD vk_underlying; for( int i=0; i< (int)All_Vector[0].size()-1 ;i++) { for( int j=1; j< (int)All_Vector[0][0].size();j++) { - if ( ( All_Vector[0][i][j] == VK_US ) ) { - VK_underlying = All_Vector[1][i][j]; - return VK_underlying; + if ( ( All_Vector[0][i][j] == vk_US ) ) { + vk_underlying = All_Vector[1][i][j]; + return vk_underlying; } } } - return VK_US; + return vk_US; } -KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap *keymap, v_dw_3D &All_Vector, KMX_DWORD KC_US, ShiftState ss, int caps) { - KMX_DWORD KC_underlying; - std::u16string u16str = convert_DeadkeyValues_To_U16str(KMX_get_KeyVal_From_KeyCode(keymap, KC_US, ss, caps)); +KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap *keymap, vec_dword_3D &All_Vector, KMX_DWORD kc_us, ShiftState ss, int caps) { + KMX_DWORD kc_underlying; + std::u16string u16str = convert_DeadkeyValues_To_U16str(KMX_get_KeyVal_From_KeyCode(keymap, kc_us, ss, caps)); for( int i=0; i< (int)All_Vector[1].size()-1 ;i++) { for( int j=1; j< (int)All_Vector[1][0].size();j++) { if ( ( All_Vector[1][i][j] == (KMX_DWORD) *u16str.c_str() ) ) { - KC_underlying = All_Vector[1][i][0]; - return KC_underlying; + kc_underlying = All_Vector[1][i][0]; + return kc_underlying; } } } - return KC_US; + return kc_us; } -UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS) { - return (8 + USVirtualKeyToScanCode[VirtualKeyUS]); +UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD virtualKeyUS) { + return (8 + USVirtualKeyToScanCode[virtualKeyUS]); } KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying(KMX_DWORD keycode) { diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 86baa3dc9f..a04c3860df 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -57,17 +57,16 @@ const KMX_DWORD KMX_VKMap[] = { 0 }; -typedef std::vector v_str_1D; +typedef std::vector vec_string_1D; -typedef std::vector v_dw_1D; -typedef std::vector > v_dw_2D; -typedef std::vector > > v_dw_3D; +typedef std::vector vec_dword_1D; +typedef std::vector > vec_dword_2D; +typedef std::vector > > vec_dword_3D; -static KMX_DWORD returnIfCharInvalid = 0; +static KMX_DWORD INVALID_NAME = 0; static KMX_DWORD keycode_max = 94; -static KMX_DWORD deadkey_min = 0xfe50; -static KMX_DWORD deadkey_max = 0xfe93; -//static KMX_DWORD deadkey_max = 0xfe52; // _S2 TOP_6 TODO This has to go! my test: to only return 3 dk +static KMX_DWORD deadkey_min = 0xfe50; // X11's keysymdef.h defines deadkeys between 0xfe50-0xfe93 +static KMX_DWORD deadkey_max = 0xfe93; // https://fossies.org/linux/tk/xlib/X11/keysymdef.h // map Shiftstate to modifier (e.g. 0->0; 16-1; 9->2; 25->3) int map_VKShiftState_to_LinModifier(int VKShiftState); @@ -76,25 +75,25 @@ int map_VKShiftState_to_LinModifier(int VKShiftState); KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str); // create a Vector with all entries of both keymaps -int createOneVectorFromBothKeyboards(v_dw_3D &All_Vector,GdkKeymap *keymap); +int createOneVectorFromBothKeyboards(vec_dword_3D &All_Vector,GdkKeymap *keymap); // read configuration file, split and write to 3D-Vector (Data for US on Vector[0][ ][ ] ) -int write_US_ToVector(v_dw_3D &vec, std::string language, const char *text); +int write_US_ToVector(vec_dword_3D &vec, std::string language, const char *text); // 1. step: read complete Row of Configuration file US -bool createCompleteRow_US(v_str_1D &complete_List, FILE *fpp, const char *text, std::string language); +bool createCompleteVector_US(FILE *fpp, const char *text, vec_string_1D &complete_List); // replace Name of Key (e.g. ) wih Keycode ( e.g. 15 ) int replace_KeyName_with_Keycode(std::string in); // 2. step: write contents to 3D vector -int split_US_To_3D_Vector(v_dw_3D &all_US, v_str_1D completeList); +int split_US_To_3D_Vector(vec_dword_3D &all_US, vec_string_1D completeList); // create an empty 2D vector containing 0 in all fields -v_dw_2D create_empty_2D_Vector(int dim_rows, int dim_shifts); +vec_dword_2D create_empty_2D_Vector(int dim_rows, int dim_shifts); // append characters to 3D-Vector using GDK (Data for underlying Language on Vector[1][ ][ ] ) -int append_underlying_ToVector(v_dw_3D &All_Vector, GdkKeymap *keymap); +int append_underlying_ToVector(vec_dword_3D &All_Vector, GdkKeymap *keymap); // initialize GDK bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); @@ -512,16 +511,16 @@ int KMX_get_KeyVal_From_KeyCode(GdkKeymap *keymap, guint keycode, ShiftState ss, KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, guint keycode, int shift_state_pos); // fill Deadkey with dk and return CATEGORY -KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, UINT VKShiftState, UINT KC_underlying, PKMX_WCHAR DeadKey); +KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, UINT vk_ShiftState, UINT kc_underlying, PKMX_WCHAR deadkey); // use Vector to return the Keyval of underlying Keyboard -KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(v_dw_3D &All_Vector,KMX_DWORD VK_underlying); +KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(vec_dword_3D &All_Vector,KMX_DWORD VK_underlying); // use Vector to return the Keycode of the underlying Keyboard for given VK_US using GDK -KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap *keymap, v_dw_3D &All_Vector,KMX_DWORD KC_US, ShiftState ss, int caps); +KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap *keymap, vec_dword_3D &All_Vector,KMX_DWORD kc_us, ShiftState ss, int caps); // return the Keycode of the underlying Keyboard for given VK_US -UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS); +UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD virtualKeyUS); // return the VirtualKey of the US Keyboard for a given Keyode using GDK KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying(KMX_DWORD keycode); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 6b0438f941..bdc9e0c1ff 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -76,17 +76,17 @@ int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int if (!(keycode <= keycode_max)) return 0; - KMX_DWORD KeyVal= (KMX_DWORD) KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(shift_state_pos), caps); - std::u16string str = convert_DeadkeyValues_To_U16str(KeyVal); + KMX_DWORD keyVal= (KMX_DWORD) KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(shift_state_pos), caps); + std::u16string str = convert_DeadkeyValues_To_U16str(keyVal); pwszBuff[0]= * (PKMX_WCHAR) str.c_str(); g_free(keyvals); g_free(maps); - if((KeyVal >= deadkey_min) && (KeyVal <= deadkey_max)) // deadkeys + if((keyVal >= deadkey_min) && (keyVal <= deadkey_max)) // deadkeys return -1; - else if(gdk_keyval_to_unicode(KeyVal) == 0) // NO UNICODE + else if(gdk_keyval_to_unicode(keyVal) == 0) // NO UNICODE return 0; else // usable char return 1; @@ -241,7 +241,7 @@ public: return nkeys; } - bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,v_dw_3D &All_Vector, GdkKeymap *keymap) { // I4552 + bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,vec_dword_3D &All_Vector, GdkKeymap *keymap) { // I4552 // Get the CAPSLOCK value int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | @@ -362,12 +362,12 @@ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { return n; } -bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 +bool KMX_ImportRules(LPKMX_KEYBOARD kp,vec_dword_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 KMX_Loader loader; std::vector rgKey; //= new VirtualKey[256]; std::vector alDead; - std::vector alDead_cpl = create_alDead(); + std::vector alDead_cpl = create_deadkeys_by_basechar(); rgKey.resize(256); @@ -413,10 +413,10 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap, continue; }*/ - KMX_DWORD KC_US = (KMX_DWORD) KMX_get_KeyCodeUnderlying_From_VKUS(iKey); + KMX_DWORD kc_us = (KMX_DWORD) KMX_get_KeyCodeUnderlying_From_VKUS(iKey); for(int caps = 0; caps <= 1; caps++) { - int rc = KMX_ToUnicodeEx(KC_US, sbBuffer, ss, caps, *keymap); + int rc = KMX_ToUnicodeEx(kc_us, sbBuffer, ss, caps, *keymap); if(rc > 0) { if(*sbBuffer == 0) { diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index de9d8d1ded..30d780a192 100755 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -21,7 +21,7 @@ KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, PKMX_WCHAR filename) { return FALSE; } - KMX_DWORD err = KMX_WriteCompiledKeyboard(kbd, fp, FALSE); + KMX_DWORD err = KMX_WriteCompiledKeyboardToFile(kbd, fp, FALSE); fclose(fp); if(err != CERR_None) { @@ -37,7 +37,7 @@ KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, PKMX_WCHAR filename) { return TRUE; } -KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL FSaveDebug) { +KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL FSaveDebug) { LPKMX_GROUP fgp; LPKMX_STORE fsp; @@ -103,22 +103,6 @@ KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL offset = sizeof(KMX_COMP_KEYBOARD); - // ck->dpLanguageName = offset; - //wcscpy((PWSTR)(buf + offset), fk->szLanguageName); - //offset += wcslen(fk->szLanguageName)*2 + 2; - - //ck->dpName = offset; - //wcscpy((PWSTR)(buf + offset), fk->szName); - //offset += wcslen(fk->szName)*2 + 2; - - //ck->dpCopyright = offset; - //wcscpy((PWSTR)(buf + offset), fk->szCopyright); - //offset += wcslen(fk->szCopyright)*2 + 2; - - //ck->dpMessage = offset; - //wcscpy((PWSTR)(buf + offset), fk->szMessage); - //offset += wcslen(fk->szMessage)*2 + 2; - ck->dpStoreArray = offset; sp = (PKMX_COMP_STORE)(buf+offset); fsp = fk->dpStoreArray; @@ -198,12 +182,6 @@ KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL ck->dpBitmapOffset = 0; } - if(offset != size) - { - delete[] buf; - return CERR_SomewhereIGotItWrong; - } - fwrite(buf, size,1,hOutfile); if(offset != size) { diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 9d7f5556f0..461fba4353 100755 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -74,7 +74,7 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD *lpKeyboard); KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, PKMX_WCHAR filename); -KMX_DWORD KMX_WriteCompiledKeyboard(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL FSaveDebug); +KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL FSaveDebug); #endif // _KMXFILE_H diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index c051f6d142..cc797a94cf 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -31,7 +31,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]); -bool KMX_ImportRules( LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 +bool KMX_ImportRules( LPKMX_KEYBOARD kp,vec_dword_3D &All_Vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 std::vector KMX_FDeadkeys; // I4353 @@ -67,7 +67,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ wprintf( L"Usage: mcompile [-d] infile.kmx outfile.kmx\n" L" mmcompile -u ... (not available for Linux)\n " - L" mcompile converts a Keyman mnemonic layout to a\n" + L" mcompile converts a Keyman mnemonic layout to a\n" L" positional one based on the Linux keyboard\n" L" layout on top position\n" L" (-d convert deadkeys to plain keys) not available yet \n\n" @@ -154,7 +154,7 @@ void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { if(key->ShiftFlags == 0 && key->Key == ch) { // Key is a mnemonic key with no shift state defined. // Remap the key according to the character on the key cap. - //LogError(L"Converted mnemonic rule on line %d, + '%c' TO + [%x K_%d]", key->Line, key->Key, shift, vk); + //KMX_LogError(L"Converted mnemonic rule on line %d, + '%c' TO + [%x K_%d]", key->Line, key->Key, shift, vk); key->ShiftFlags = ISVIRTUALKEY | shift; key->Key = vk; } else if(key->ShiftFlags & VIRTUALCHARKEY && key->Key == ch) { @@ -163,7 +163,7 @@ void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { // This will not result in 100% wonderful mappings as there could // be overlap, depending on how keys are arranged on the target layout. // But that is up to the designer. - //LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, key->ShiftFlags & ~VIRTUALCHARKEY, vk); + //KMX_LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, key->ShiftFlags & ~VIRTUALCHARKEY, vk); key->ShiftFlags &= ~VIRTUALCHARKEY; key->Key = vk; } @@ -185,7 +185,7 @@ void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHA void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key) { if(key->ShiftFlags == 0) { - KMX_LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); + //KMX_LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); } else if(key->ShiftFlags & VIRTUALCHARKEY) { KMX_LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); } @@ -348,7 +348,7 @@ KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { return s_dkids[s_ndkids++].dst_deadkey = s_next_dkid = ++dkid; } -void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, UINT shift, KMX_WCHAR deadkey, v_dw_3D &All_Vector, GdkKeymap* keymap,v_dw_2D dk_Table) { +void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, UINT shift, KMX_WCHAR deadkey, vec_dword_3D &All_Vector, GdkKeymap* keymap,vec_dword_2D dk_Table) { KMX_WORD deadkeys[512], *pdk; // Lookup the deadkey table for the deadkey in the physical keyboard @@ -411,13 +411,13 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg } // create vector that contains Keycode, base, shift for US-KEyboard and underlying keyboard - v_dw_3D All_Vector; + vec_dword_3D All_Vector; if(createOneVectorFromBothKeyboards(All_Vector, keymap)){ wprintf(L"ERROR: can't create one vector from both keyboards\n"); return FALSE; } - v_dw_2D dk_Table; + vec_dword_2D dk_Table; create_DKTable(dk_Table); for (int j = 0; VKShiftState[j] != 0xFFFF; j++) { // I4651 @@ -429,7 +429,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg UINT scUnderlying = KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]); KMX_WCHAR ch = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap, VKShiftState[j], scUnderlying, &DeadKey); - //wprintf(L"--- VK_%d -> SC_ [%c] dk=%d ( ss %i) \n", VKMap[i], ch == 0 ? 32 : ch, DeadKey, VKShiftState[j]); + //wprintf(L"--- VK_%d -> SC_ [%c] dk=%d ( ss %i) \n", KMX_VKMap[i], ch == 0 ? 32 : ch, DeadKey, VKShiftState[j]); if(bDeadkeyConversion) { // I4552 if(ch == 0xFFFF) { @@ -453,15 +453,15 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg return TRUE; } -int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap) { +int KMX_GetDeadkeys(vec_dword_2D & dk_Table, KMX_WORD deadkey, KMX_WORD *OutputPairs, GdkKeymap* keymap) { KMX_WORD *p = OutputPairs; KMX_DWORD shift; - v_dw_2D dk_SingleTable; - query_dk_combinations_for_specific_dk(&dk_Table, dk_SingleTable, DeadKey); + vec_dword_2D dk_SingleTable; + query_dk_combinations_for_specific_dk(&dk_Table, dk_SingleTable, deadkey); for ( int i=0; i< (int) dk_SingleTable.size();i++) { - KMX_WORD vk = KMX_changeKeynameToCapital(dk_SingleTable[i][1], shift, keymap); + KMX_WORD vk = KMX_change_keyname_to_capital(dk_SingleTable[i][1], shift, keymap); if(vk != 0) { *p++ = vk; *p++ = shift; diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index a00c39afb4..e000cf3461 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -36,7 +36,7 @@ int run(int argc, std::vector str_argv, char* argv[]); PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); -int KMX_GetDeadkeys(v_dw_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap); +int KMX_GetDeadkeys(vec_dword_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap); void KMX_LogError(const wchar_t* fmt, ...); From 724e5b6eaf8f67bb1e06fc83da5099defd193f67 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 14 Jun 2024 11:45:00 +0200 Subject: [PATCH 241/327] feat(linux): rename symbols more --- linux/mcompile/keymap/deadkey.cpp | 13 ++- linux/mcompile/keymap/keymap.cpp | 94 +++++++++---------- linux/mcompile/keymap/mc_import_rules.cpp | 18 ++-- linux/mcompile/keymap/mc_kmxfile.cpp | 4 +- linux/mcompile/keymap/mcompile.cpp | 16 ++-- .../src/engine/mcompile/mc_savekeyboard.cpp | 4 +- 6 files changed, 74 insertions(+), 75 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index bb5fa4fb65..89344b57a4 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -28,11 +28,11 @@ std::vector create_deadkeys_by_basechar() { } void refine_alDead(KMX_WCHAR dk, std::vector &dkVec, std::vector *p_All_Vec) { - if( dk == 0) + if (dk == 0) return; for (int j=0; j < (int) (*p_All_Vec).size()-1;j++) { - if( dk == (*p_All_Vec)[j]->KMX_GetDeadCharacter()) { + if (dk == (*p_All_Vec)[j]->KMX_GetDeadCharacter()) { if(! found_dk_inVector(dk, dkVec)) { dkVec.push_back((*p_All_Vec)[j]); return; @@ -44,9 +44,9 @@ void refine_alDead(KMX_WCHAR dk, std::vector &dkVec, std::vector &dkVec) { int i=0; - if( dkVec.size() > 0) { + if (dkVec.size() > 0) { do { - if( dk == dkVec[i]->KMX_GetDeadCharacter()) + if (dk == dkVec[i]->KMX_GetDeadCharacter()) return true; i++; } while (i < (int) dkVec.size()); @@ -67,7 +67,7 @@ bool query_dk_combinations_for_specific_dk(vec_dword_2D * p_dk_ComposeTable, vec } } - if( dk_SingleTable.size()>0) + if (dk_SingleTable.size()>0) return true; else return false; @@ -79,7 +79,7 @@ KMX_DWORD KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD &shift, GdkKey gint n_keys; KMX_DWORD capitalKeyval = (KMX_DWORD) gdk_keyval_to_upper (kVal); - if( keyval !=0) { + if (keyval !=0) { gdk_keymap_get_entries_for_keyval(keymap, keyval, &keys, &n_keys); for (int i = 0; i < n_keys; i++) { if (keys[i].group == 0) { @@ -382,7 +382,6 @@ void create_DKTable(vec_dword_2D & dk_ComposeTable) { dk_ComposeTable.push_back(line); line.clear(); line = createLine("dead_ogonek", "U", 0x0172, "capital U with ogonek"); dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_circumflex", "space", 0x005E, "CIRCUMFLEX_ACCENT"); dk_ComposeTable.push_back(line); line.clear(); diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index a2c26742ec..206f6a4d7a 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -278,7 +278,7 @@ KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str) { first["acute accent"] = 0xB4; - if ( tok_str.size() == 1) { + if (tok_str.size() == 1) { return (KMX_DWORD) ( *tok_str.c_str() ); } else { @@ -291,9 +291,9 @@ KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str) { return INVALID_NAME; } -int createOneVectorFromBothKeyboards(vec_dword_3D &All_Vector,GdkKeymap *keymap) { +int createOneVectorFromBothKeyboards(vec_dword_3D &all_vector,GdkKeymap *keymap) { // create a 3D-Vector which contains data of the US keyboard and the underlying Keyboard: - // All_Vector[ US_Keyboard ] + // all_vector[ US_Keyboard ] // [KeyCode_US ] // [Keyval unshifted ] // [Keyval shifted ] @@ -305,13 +305,13 @@ int createOneVectorFromBothKeyboards(vec_dword_3D &All_Vector,GdkKeymap *keymap) std::string us_language = "us"; const char* text_us = "xkb_symbols \"basic\""; - if(write_US_ToVector(All_Vector,us_language, text_us)) { + if (write_US_ToVector(all_vector,us_language, text_us)) { wprintf(L"ERROR: can't write US to Vector \n"); return 1; } - // add contents of other keyboard to All_Vector - if( append_underlying_ToVector(All_Vector,keymap)) { + // add contents of other keyboard to all_vector + if (append_underlying_ToVector(all_vector,keymap)) { wprintf(L"ERROR: can't append underlying ToVector \n"); return 2; } @@ -324,20 +324,20 @@ int write_US_ToVector( vec_dword_3D &vec,std::string language, const char* secti const char* path = fullPathName.c_str(); FILE* fp = fopen((path), "r"); - if ( !fp) { + if (!fp) { wprintf(L"ERROR: could not open file!\n"); return 1; } // create 1D-vector of the complete line vec_string_1D vector_completeUS; - if( createCompleteVector_US(fp, section , vector_completeUS)) { + if (createCompleteVector_US(fp, section, vector_completeUS)) { wprintf(L"ERROR: can't Create complete row US \n"); return 1; } // split contents of 1D Vector to 3D vector - if( split_US_To_3D_Vector( vec,vector_completeUS)) { + if (split_US_To_3D_Vector(vec,vector_completeUS)) { return 1; } @@ -345,7 +345,7 @@ int write_US_ToVector( vec_dword_3D &vec,std::string language, const char* secti return 0; } -bool createCompleteVector_US(FILE* fp, const char* section , vec_string_1D &complete_List) { +bool createCompleteVector_US(FILE* fp, const char* section, vec_string_1D &complete_List) { // in the Configuration file we find the appopriate paragraph between "xkb_symbol " and the next xkb_symbol // and then copy all rows starting with "key <" to a 1D-Vector @@ -353,7 +353,7 @@ bool createCompleteVector_US(FILE* fp, const char* section , vec_string_1D &comp char line[buffer_size]; bool create_row = false; const char* key = "key <"; - std::string str_us_kbd_name(section ); + std::string str_us_kbd_name(section); std::string xbk_mark = "xkb_symbol"; if (fp) { @@ -442,7 +442,7 @@ int replace_KeyName_with_Keycode(std::string in) { return out; } -int split_US_To_3D_Vector(vec_dword_3D &all_US,vec_string_1D completeList) { +int split_US_To_3D_Vector(vec_dword_3D& all_US, vec_string_1D completeList) { // 1: take the whole line of the 1D-Vector and remove unwanted characters. // 2: seperate the name e.g. key from the shiftstates // 3: convert to KMX_DWORD @@ -500,7 +500,7 @@ int split_US_To_3D_Vector(vec_dword_3D &all_US,vec_string_1D completeList) { } all_US.push_back(shift_states); - if ( all_US.size() == 0) { + if (all_US.size() == 0) { wprintf(L"ERROR: Can't split US to 3D-Vector\n"); return 1; } @@ -522,30 +522,30 @@ vec_dword_2D create_empty_2D_Vector( int dim_rows,int dim_ss) { return vector_2D; } -int append_underlying_ToVector(vec_dword_3D &All_Vector,GdkKeymap *keymap) { +int append_underlying_ToVector(vec_dword_3D& all_vector,GdkKeymap *keymap) { // create a 2D vector all filled with " " and push to 3D-Vector - vec_dword_2D underlying_Vector2D = create_empty_2D_Vector(All_Vector[0].size(),All_Vector[0][0].size()); + vec_dword_2D underlying_Vector2D = create_empty_2D_Vector(all_vector[0].size(),all_vector[0][0].size()); if (underlying_Vector2D.size() == 0) { wprintf(L"ERROR: can't create empty 2D-Vector\n"); return 1; } - All_Vector.push_back(underlying_Vector2D); + all_vector.push_back(underlying_Vector2D); - if (All_Vector.size() < 2) { + if (all_vector.size() < 2) { wprintf(L"ERROR: creation of 3D-Vector failed\n"); return 1; } - for(int i =0; i< (int) All_Vector[1].size();i++) { + for(int i =0; i< (int) all_vector[1].size();i++) { // get key name US stored in [0][i][0] and copy to name in "underlying"-block[1][i][0] - All_Vector[1][i][0] = All_Vector[0][i][0]; + all_vector[1][i][0] = all_vector[0][i][0]; // get Keyvals of this key and copy to unshifted/shifted in "underlying"-block[1][i][1] / block[1][i][2] - All_Vector[1][i][0+1] = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap,All_Vector[0][i][0],0); //shift state: unshifted:0 - All_Vector[1][i][1+1] = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap,All_Vector[0][i][0],1); //shift state: shifted:1 + all_vector[1][i][0+1] = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap,all_vector[0][i][0],0); //shift state: unshifted:0 + all_vector[1][i][1+1] = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap,all_vector[0][i][0],1); //shift state: shifted:1 } return 0; @@ -583,9 +583,9 @@ std::u16string convert_DeadkeyValues_To_U16str(int in) { if (in == 0 ) return u"\0"; - std::string long_name((const char*) gdk_keyval_name (in)); // e.g. "dead_circumflex" , "U+017F" , "t" + std::string long_name((const char*) gdk_keyval_name (in)); // e.g. "dead_circumflex", "U+017F", "t" - if ( long_name.substr (0,2) == "U+" ) // U+... Unicode value + if (long_name.substr (0,2) == "U+" ) // U+... Unicode value return CodePointToU16String(in-0x1000000); // GDK's gdk_keymap_translate_keyboard_state() returns (Keyvalue | 0x01000000) // since we never have a carry-over we can just subtract 0x01000000 if (in < (int) deadkey_min) { // no deadkey; no Unicode @@ -614,7 +614,7 @@ int KMX_get_KeyVal_From_KeyCode(GdkKeymap *keymap, guint keycode, ShiftState ss, //BASE (shiftstate: 0) if (( ss == Base ) && ( caps == 0 )) { GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base , 0, keyvals, NULL, NULL, & consumed); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base, 0, keyvals, NULL, NULL, & consumed); } //BASE + CAPS (shiftstate: 0) @@ -626,61 +626,61 @@ int KMX_get_KeyVal_From_KeyCode(GdkKeymap *keymap, guint keycode, ShiftState ss, //SHIFT (shiftstate: 1) else if (( ss == Shft ) && ( caps == 0 )) { GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift , 0, keyvals, NULL, NULL, & consumed); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift, 0, keyvals, NULL, NULL, & consumed); } //SHIFT + CAPS (shiftstate: 1) - else if ( ( ss == Shft ) && ( caps ==1 )) { + else if (( ss == Shft ) && ( caps ==1 )) { GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps , 0, keyvals, NULL, NULL, & consumed); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps, 0, keyvals, NULL, NULL, & consumed); } // Ctrl (shiftstate: 2) else if (( ss == Ctrl ) && ( caps == 0 )){ GdkModifierType MOD_Ctrl = (GdkModifierType) ( GDK_MOD5_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl , 0, keyvals, NULL, NULL, & consumed); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl, 0, keyvals, NULL, NULL, & consumed); } // Ctrl + CAPS (shiftstate: 2) else if (( ss == Ctrl ) && ( caps == 1 )){ GdkModifierType MOD_CtrlCaps = (GdkModifierType) (GDK_MOD5_MASK | GDK_LOCK_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps , 0, keyvals, NULL, NULL, & consumed); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps, 0, keyvals, NULL, NULL, & consumed); } // SHIFT+Ctrl (shiftstate: 3) else if (( ss == ShftCtrl ) && ( caps == 0 )){ GdkModifierType MOD_Ctrl = (GdkModifierType) (GDK_SHIFT_MASK | GDK_MOD5_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl , 0, keyvals, NULL, NULL, & consumed); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl, 0, keyvals, NULL, NULL, & consumed); } // SHIFT+Ctrl + CAPS (shiftstate: 3) else if (( ss == ShftCtrl ) && ( caps == 1 )){ GdkModifierType MOD_CtrlCaps = (GdkModifierType) ( GDK_SHIFT_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps , 0, keyvals, NULL, NULL, & consumed); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps, 0, keyvals, NULL, NULL, & consumed); } //ALT-GR (shiftstate: 6) else if (( ss == MenuCtrl ) && ( caps == 0 )){ GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr, 0, keyvals, NULL, NULL, & consumed); } //ALT-GR + CAPS (shiftstate: 6) else if (( ss == MenuCtrl ) && ( caps == 1 )){ GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr, 0, keyvals, NULL, NULL, & consumed); } //ALT-GR (shiftstate: 7) else if (( ss == ShftMenuCtrl ) && ( caps == 0 )){ GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr, 0, keyvals, NULL, NULL, & consumed); } //ALT-GR +CAPS (shiftstate: 7) else if (( ss == ShftMenuCtrl ) && ( caps == 1 )){ GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr , 0, keyvals, NULL, NULL, & consumed); + gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr, 0, keyvals, NULL, NULL, & consumed); } else return 0; @@ -738,18 +738,18 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, UIN *deadkey = *dky; return 0xFFFF; } - else if((keyV > deadkey_max) || ((keyV < deadkey_min) && ( keyV > 0xFF))) // out of range + else if ((keyV > deadkey_max) || ((keyV < deadkey_min) && ( keyV > 0xFF))) // out of range return 0xFFFE; else // usable char return keyV; } //_S2 vk_us or underlying!!"!!" -KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(vec_dword_3D & All_Vector, KMX_DWORD vk_US) { +KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(vec_dword_3D & all_vector, KMX_DWORD vk_US) { KMX_DWORD vk_underlying; - for( int i=0; i< (int)All_Vector[0].size()-1 ;i++) { - for( int j=1; j< (int)All_Vector[0][0].size();j++) { - if ( ( All_Vector[0][i][j] == vk_US ) ) { - vk_underlying = All_Vector[1][i][j]; + for( int i=0; i< (int)all_vector[0].size()-1 ;i++) { + for( int j=1; j< (int)all_vector[0][0].size();j++) { + if (( all_vector[0][i][j] == vk_US ) ) { + vk_underlying = all_vector[1][i][j]; return vk_underlying; } } @@ -757,14 +757,14 @@ KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(vec_dword_3D & All_Vector, KMX_ return vk_US; } -KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap *keymap, vec_dword_3D &All_Vector, KMX_DWORD kc_us, ShiftState ss, int caps) { +KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap *keymap, vec_dword_3D &all_vector, KMX_DWORD kc_us, ShiftState ss, int caps) { KMX_DWORD kc_underlying; std::u16string u16str = convert_DeadkeyValues_To_U16str(KMX_get_KeyVal_From_KeyCode(keymap, kc_us, ss, caps)); - for( int i=0; i< (int)All_Vector[1].size()-1 ;i++) { - for( int j=1; j< (int)All_Vector[1][0].size();j++) { - if ( ( All_Vector[1][i][j] == (KMX_DWORD) *u16str.c_str() ) ) { - kc_underlying = All_Vector[1][i][0]; + for( int i=0; i< (int)all_vector[1].size()-1 ;i++) { + for( int j=1; j< (int)all_vector[1][0].size();j++) { + if (( all_vector[1][i][j] == (KMX_DWORD) *u16str.c_str() ) ) { + kc_underlying = all_vector[1][i][0]; return kc_underlying; } } @@ -777,7 +777,7 @@ UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD virtualKeyUS) { } KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying(KMX_DWORD keycode) { - if ( keycode >7) + if (keycode >7) return (KMX_DWORD) ScanCodeToUSVirtualKey[keycode-8]; return 0; diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index bdc9e0c1ff..447711c571 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -241,7 +241,7 @@ public: return nkeys; } - bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,vec_dword_3D &All_Vector, GdkKeymap *keymap) { // I4552 + bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,vec_dword_3D& all_vector, GdkKeymap *keymap) { // I4552 // Get the CAPSLOCK value int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | @@ -301,7 +301,7 @@ public: // key->Key stores VK-US ( not underlying !!) // key->dpOutput stores character Underlying - KMX_DWORD SC_Underlying = KMX_get_KeyCodeUnderlying_From_KeyCodeUS(keymap, All_Vector, this->SC(), (ShiftState) ss, caps); + KMX_DWORD SC_Underlying = KMX_get_KeyCodeUnderlying_From_KeyCodeUS(keymap, all_vector, this->SC(), (ShiftState) ss, caps); key->Key = KMX_get_VKUS_From_KeyCodeUnderlying( SC_Underlying); key->Line = 0; @@ -362,7 +362,7 @@ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { return n; } -bool KMX_ImportRules(LPKMX_KEYBOARD kp,vec_dword_3D &All_Vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 +bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 KMX_Loader loader; std::vector rgKey; //= new VirtualKey[256]; @@ -380,7 +380,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,vec_dword_3D &All_Vector, GdkKeymap **ke // ( mcompile win uses MapVirtualKeyEx() to fill m_vk with the VK of the Underlying keyboard) // Linux can get a VK for the US Keyboard using USVirtualKeyToScanCode/ScanCodeToUSVirtualKey // Linux cannot get a VK for the underling Keyboard - // this "connection" is possible only when using All_Vector + // this "connection" is possible only when using all_vector KMX_VirtualKey *key = new KMX_VirtualKey(sc); @@ -409,9 +409,9 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,vec_dword_3D &All_Vector, GdkKeymap **ke } //_S2 TOP_6 TODO to compare win-lin kmn-files skip ss6+7; MUST BE removed later!!!! - /*if(ss == MenuCtrl|| ss == ShftMenuCtrl) { + if(ss == MenuCtrl|| ss == ShftMenuCtrl) { continue; - }*/ + } KMX_DWORD kc_us = (KMX_DWORD) KMX_get_KeyCodeUnderlying_From_VKUS(iKey); @@ -423,7 +423,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,vec_dword_3D &All_Vector, GdkKeymap **ke rgKey[iKey]->KMX_SetShiftState(ss, u"", false, (caps)); // different to windows since behavior on Linux is different } else { - if( (ss == Ctrl || ss == ShftCtrl) ) { + if ((ss == Ctrl || ss == ShftCtrl) ) { continue; } sbBuffer[rc] = 0; @@ -432,7 +432,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,vec_dword_3D &All_Vector, GdkKeymap **ke } else if(rc < 0) { sbBuffer[2] = 0; - rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); // different to windows since behavior on Linux is different + rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps)); // different to windows since behavior on Linux is different refine_alDead(sbBuffer[0], alDead, &alDead_cpl); } @@ -498,7 +498,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,vec_dword_3D &All_Vector, GdkKeymap **ke // for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { - if(rgKey[iKey]->KMX_LayoutRow(loader.KMX_MaxShiftState(), &gp->dpKeyArray[nkeys], &alDead, nDeadkey, bDeadkeyConversion, All_Vector,*keymap)) { // I4552 + if(rgKey[iKey]->KMX_LayoutRow(loader.KMX_MaxShiftState(), &gp->dpKeyArray[nkeys], &alDead, nDeadkey, bDeadkeyConversion, all_vector,*keymap)) { // I4552 nkeys+=rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()); } } diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 30d780a192..a96a01a022 100755 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -70,8 +70,8 @@ KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX size += u16len(fkp->dpContext)*2 + 2; } - if( fgp->dpMatch ) size += u16len(fgp->dpMatch)*2 + 2; - if( fgp->dpNoMatch ) size += u16len(fgp->dpNoMatch)*2 + 2; + if (fgp->dpMatch ) size += u16len(fgp->dpMatch)*2 + 2; + if (fgp->dpNoMatch ) size += u16len(fgp->dpNoMatch)*2 + 2; } for(i = 0; i < fk->cxStoreArray; i++) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index cc797a94cf..933299cdd9 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -31,7 +31,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]); -bool KMX_ImportRules( LPKMX_KEYBOARD kp,vec_dword_3D &All_Vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 +bool KMX_ImportRules( LPKMX_KEYBOARD kp,vec_dword_3D& all_vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 std::vector KMX_FDeadkeys; // I4353 @@ -348,7 +348,7 @@ KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { return s_dkids[s_ndkids++].dst_deadkey = s_next_dkid = ++dkid; } -void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, UINT shift, KMX_WCHAR deadkey, vec_dword_3D &All_Vector, GdkKeymap* keymap,vec_dword_2D dk_Table) { +void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, UINT shift, KMX_WCHAR deadkey, vec_dword_3D& all_vector, GdkKeymap* keymap,vec_dword_2D dk_Table) { KMX_WORD deadkeys[512], *pdk; // Lookup the deadkey table for the deadkey in the physical keyboard @@ -365,7 +365,7 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, UINT shift, KMX_WCHA while(*pdk) { // Look up the ch - UINT KeyValUnderlying = KMX_get_KeyValUnderlying_From_KeyValUS(All_Vector, *pdk); + UINT KeyValUnderlying = KMX_get_KeyValUnderlying_From_KeyValUS(all_vector, *pdk); KMX_TranslateDeadkeyKeyboard(kbd, dkid, KeyValUnderlying, *(pdk+1), *(pdk+2)); pdk+=3; } @@ -405,14 +405,14 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg // For now, we get the least shifted version, which is hopefully adequate. GdkKeymap *keymap; - if(InitializeGDK(&keymap , argc, argv)) { + if(InitializeGDK(&keymap, argc, argv)) { wprintf(L"ERROR: can't Initialize GDK\n"); return FALSE; } // create vector that contains Keycode, base, shift for US-KEyboard and underlying keyboard - vec_dword_3D All_Vector; - if(createOneVectorFromBothKeyboards(All_Vector, keymap)){ + vec_dword_3D all_vector; + if(createOneVectorFromBothKeyboards(all_vector, keymap)){ wprintf(L"ERROR: can't create one vector from both keyboards\n"); return FALSE; } @@ -439,7 +439,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg switch(ch) { case 0x0000: break; - case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap , dk_Table); break; + case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, all_vector, keymap, dk_Table); break; default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); } } @@ -447,7 +447,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg KMX_ReportUnconvertedKeyboardRules(kbd); - if(!KMX_ImportRules(kbd, All_Vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 + if(!KMX_ImportRules(kbd, all_vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 return FALSE; } return TRUE; diff --git a/windows/src/engine/mcompile/mc_savekeyboard.cpp b/windows/src/engine/mcompile/mc_savekeyboard.cpp index ce270104e7..781d6b1cbd 100644 --- a/windows/src/engine/mcompile/mc_savekeyboard.cpp +++ b/windows/src/engine/mcompile/mc_savekeyboard.cpp @@ -67,8 +67,8 @@ DWORD WriteCompiledKeyboard(LPKEYBOARD fk, HANDLE hOutfile, BOOL FSaveDebug) size += wcslen(fkp->dpContext)*2 + 2; } - if( fgp->dpMatch ) size += wcslen(fgp->dpMatch)*2 + 2; - if( fgp->dpNoMatch ) size += wcslen(fgp->dpNoMatch)*2 + 2; + if (fgp->dpMatch ) size += wcslen(fgp->dpMatch)*2 + 2; + if (fgp->dpNoMatch ) size += wcslen(fgp->dpNoMatch)*2 + 2; } for(i = 0; i < fk->cxStoreArray; i++) From 4cf80439f0c8e690f0045234c7c5081bfa45565e Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 17 Jun 2024 17:21:56 +0200 Subject: [PATCH 242/327] feat(linux): rework deadkey.cpp/.h --- linux/mcompile/keymap/deadkey.cpp | 714 ++++++++-------------- linux/mcompile/keymap/deadkey.h | 24 +- linux/mcompile/keymap/keymap.h | 5 +- linux/mcompile/keymap/mc_import_rules.cpp | 9 +- linux/mcompile/keymap/mcompile.cpp | 4 +- 5 files changed, 286 insertions(+), 470 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 89344b57a4..4130c04d05 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -1,468 +1,284 @@ #include "keymap.h" #include "deadkey.h" -vec_dword_1D createLine(std::string first, std::string second, KMX_DWORD number, std::string nameresult) { - vec_dword_1D line; - line.push_back(convertNamesTo_DWORD_Value(first)); - line.push_back(convertNamesTo_DWORD_Value(second)); - //line.push_back(convertNamesTo_DWORD_Value(nameresult)); - line.push_back(number); - return line; -} -std::vector create_deadkeys_by_basechar() { - std::vector alDead; - vec_dword_2D dk_ComposeTable; +std::vector create_deadkeys_by_basechar() { + std::vector alDead; + vec_dword_2D dk_ComposeTable; create_DKTable(dk_ComposeTable); - for( int i=0; i < (int) dk_ComposeTable.size()-1; i++) { - DeadKey *dk2 = new DeadKey(dk_ComposeTable[i][0]); - for ( int j=0; j< (int) dk_ComposeTable.size();j++) { - if(( dk_ComposeTable[i][0] == dk_ComposeTable[j][0]) && (IsKeymanUsedChar(dk_ComposeTable[j][1]))) - dk2->KMX_AddDeadKeyRow(dk_ComposeTable[j][1],dk_ComposeTable[j][2]); - } - alDead.push_back(dk2); - } - return alDead; + for (int i = 0; i < (int)dk_ComposeTable.size() - 1; i++) { + DeadKey *dk2 = new DeadKey(dk_ComposeTable[i][0]); + for (int j = 0; j < (int)dk_ComposeTable.size(); j++) { + if ((dk_ComposeTable[i][0] == dk_ComposeTable[j][0]) && (IsKeymanUsedChar(dk_ComposeTable[j][1]))) + dk2->KMX_AddDeadKeyRow(dk_ComposeTable[j][1], dk_ComposeTable[j][2]); + } + alDead.push_back(dk2); + } + return alDead; } -void refine_alDead(KMX_WCHAR dk, std::vector &dkVec, std::vector *p_All_Vec) { - if (dk == 0) - return; +void refine_alDead(KMX_WCHAR dk, std::vector &dkVec, std::vector &p_All_Vec) { + if (dk == 0) + return; - for (int j=0; j < (int) (*p_All_Vec).size()-1;j++) { - if (dk == (*p_All_Vec)[j]->KMX_GetDeadCharacter()) { - if(! found_dk_inVector(dk, dkVec)) { - dkVec.push_back((*p_All_Vec)[j]); - return; - } - else return; - } - } + for (int j = 0; j < (int)p_All_Vec.size() - 1; j++) { + if (dk == (p_All_Vec)[j]->KMX_GetDeadCharacter()) { + if (!found_dk_inVector(dk, dkVec)) { + dkVec.push_back((p_All_Vec)[j]); + return; + } else return; + } + } } -bool found_dk_inVector(KMX_WCHAR dk, std::vector &dkVec) { - int i=0; - if (dkVec.size() > 0) { - do { - if (dk == dkVec[i]->KMX_GetDeadCharacter()) - return true; - i++; - } while (i < (int) dkVec.size()); - } - return false; +bool found_dk_inVector(KMX_WCHAR dk, std::vector &dkVec) { + for (int i = 0; i < dkVec.size(); i++) { + if (dk == dkVec[i]->KMX_GetDeadCharacter()) + return true; + } + return false; } -bool query_dk_combinations_for_specific_dk(vec_dword_2D * p_dk_ComposeTable, vec_dword_2D &dk_SingleTable, KMX_DWORD dk) { - vec_dword_1D line; - - for ( int i =0; i< (int) (*p_dk_ComposeTable).size(); i++) { - if (((*p_dk_ComposeTable)[i][0] == dk) && (IsKeymanUsedChar((*p_dk_ComposeTable)[i][1]))) { - line.push_back((*p_dk_ComposeTable)[i][0]); - line.push_back((*p_dk_ComposeTable)[i][1]); - line.push_back((*p_dk_ComposeTable)[i][2]); - dk_SingleTable.push_back(line); - line.clear(); - } - } - - if (dk_SingleTable.size()>0) - return true; - else - return false; -} - -KMX_DWORD KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD &shift, GdkKeymap* keymap) { - guint keyval = (guint) kVal; - GdkKeymapKey* keys; - gint n_keys; - - KMX_DWORD capitalKeyval = (KMX_DWORD) gdk_keyval_to_upper (kVal); - if (keyval !=0) { - gdk_keymap_get_entries_for_keyval(keymap, keyval, &keys, &n_keys); - for (int i = 0; i < n_keys; i++) { - if (keys[i].group == 0) { - shift = keys[i].level; - return capitalKeyval; - } - } - } - return capitalKeyval; -} - -void create_DKTable(vec_dword_2D & dk_ComposeTable) { - //create a 2D-Vector which contains data for ALL existing deadkey combinations on a Linux Keyboard: - //dk_ComposeTable[i][0] : First (e.g. dead_circumflex) - //dk_ComposeTable[i][1] : Second (e.g. a) - //dk_ComposeTable[i][3] : Unicode-Value (e.g. 0x00E2) - - //values taken from: https://help.ubuntu.com/community/GtkDeadKeyTable#Accents - // _S2 Do we want to use GTK instead of this function? - +bool query_dk_combinations_for_specific_dk(vec_dword_2D &p_dk_ComposeTable, KMX_DWORD dk, vec_dword_2D &dk_SingleTable) { vec_dword_1D line; - line = createLine("dead_circumflex", "a", 0x00E2, "small A with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_circumflex", "A", 0x00C2, "capital A with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_circumflex", "e", 0x00EA, "small E with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_circumflex", "E", 0x00CA, "capital E with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_circumflex", "i", 0x00EE, "small I with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_circumflex", "I", 0x00CE, "capital I with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_circumflex", "o", 0x00F4, "small O with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_circumflex", "O", 0x00D4, "capital O with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_circumflex", "u", 0x00FB, "small U with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_circumflex", "U", 0x00DB, "capital U with circumflex"); - dk_ComposeTable.push_back(line); line.clear(); + for (int i = 0; i < (int)(p_dk_ComposeTable).size(); i++) { + if (((p_dk_ComposeTable)[i][0] == dk) && (IsKeymanUsedChar((p_dk_ComposeTable)[i][1]))) { + line.push_back((p_dk_ComposeTable)[i][0]); + line.push_back((p_dk_ComposeTable)[i][1]); + line.push_back((p_dk_ComposeTable)[i][2]); + dk_SingleTable.push_back(line); + line.clear(); + } + } - line = createLine("dead_acute", "a", 0x00E1, "small A with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "A", 0x00C1, "capital A with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "c", 0x0107, "small C with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "C", 0x0106, "capital C with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "e", 0x00E9, "small E with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "E", 0x00C9, "capital E with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "i", 0x00ED, "small I with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "I", 0x00CD, "capital I with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "l", 0x013A, "small L with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "L", 0x0139, "capital L with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "n", 0x0144, "small N with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "N", 0x0143, "capital N with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "o", 0x00F3, "small O with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "O", 0x00D3, "capital O with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "r", 0x0155, "small R with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "R", 0x0154, "capital R with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "s", 0x015B, "small S with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "S", 0x015A, "capital S with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "u", 0x00FA, "small U with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "U", 0x00DA, "capital U with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "y", 0x00FD, "small Y with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "Y", 0x00DD, "capital Y with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "z", 0x017A, "small Z with acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "Z", 0x0179, "capital Z with acute"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine("dead_grave", "a", 0x00E0, "small A with grave"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_grave", "A", 0x00C0, "capital A with grave"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_grave", "e", 0x00E8, "small E with grave"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_grave", "E", 0x00C8, "capital E with grave"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_grave", "i", 0x00EC, "small I with grave"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_grave", "I", 0x00CC, "capital I with grave"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_grave", "o", 0x00F2, "small O with grave"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_grave", "O", 0x00D2, "capital O with grave"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_grave", "u", 0x00F9, "small U with grave"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_grave", "U", 0x00D9, "capital U with grave"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine("dead_tilde", "a", 0x00E3, "small A with tilde"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_tilde", "A", 0x00C3, "capital A with tilde"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_tilde", "i", 0x0129, "small I with tilde"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_tilde", "I", 0x0128, "capital I with tilde"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_tilde", "n", 0x00F1, "small N with tilde"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_tilde", "N", 0x00D1, "capital N with tilde"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_tilde", "o", 0x00F5, "small O with tilde"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_tilde", "O", 0x00D5, "capital O with tilde"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_tilde", "u", 0x0169, "small U with tilde"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_tilde", "U", 0x0168, "capital U with tilde"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine("dead_macron", "a", 0x0101, "small A with macron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_macron", "A", 0x0100, "capital A with macron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_macron", "e", 0x0113, "small E with macron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_macron", "E", 0x0112, "capital E with macron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_macron", "i", 0x012B, "small I with macron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_macron", "I", 0x012A, "capital I with macron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_macron", "o", 0x014D, "small O with macron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_macron", "O", 0x014C, "capital O with macron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_macron", "u", 0x016B, "small U with macron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_macron", "U", 0x016A, "capital U with macron"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine("dead_breve", "a", 0x0103, "small A with breve"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_breve", "A", 0x0102, "capital A with breve"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_breve", "g", 0x011F, "small G with breve"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_breve", "G", 0x011E, "capital G with breve"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine("dead_abovedot", "e", 0x0117, "small E with dot above"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_abovedot", "E", 0x0116, "capital E with dot above"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_abovedot", "i", 0x0131, "small DOTLESS_I"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_abovedot", "I", 0x0130, "capital I with dot above"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_abovedot", "z", 0x017C, "small Z with dot above"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_abovedot", "Z", 0x017B, "capital Z with dot above"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine("dead_diaeresis", "a", 0x00E4, "small A with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_diaeresis", "A", 0x00C4, "capital A with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_diaeresis", "e", 0x00EB, "small E with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_diaeresis", "E", 0x00CB, "capital E with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_diaeresis", "i", 0x00EF, "small I with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_diaeresis", "I", 0x00CF, "capital I with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_diaeresis", "o", 0x00F6, "small O with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_diaeresis", "O", 0x00D6, "capital O with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_diaeresis", "u", 0x00FC, "small U with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_diaeresis", "U", 0x00DC, "capital U with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_diaeresis", "y", 0x00FF, "small Y with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_diaeresis", "Y", 0x0178, "capital Y with diaeresis"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine("dead_abovering", "a", 0x00E5, "small A with ring above"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_abovering", "A", 0x00C5, "capital A with ring above"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_abovering", "u", 0x016F, "small U with ring above"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_abovering", "U", 0x016E, "capital U with ring above"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine("dead_doubleacute", "o", 0x0151, "small O with double acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_doubleacute", "O", 0x0150, "capital O with double acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_doubleacute", "u", 0x0171, "small U with double acute"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_doubleacute", "U", 0x0170, "capital U with double acute"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine("dead_caron", "c", 0x010D, "small C with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_caron", "C", 0x010C, "capital C with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_caron", "d", 0x010F, "small D with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_caron", "D", 0x010E, "capital D with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_caron", "e", 0x011B, "small E with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_caron", "E", 0x011A, "capital E with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_caron", "l", 0x013E, "small L with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_caron", "L", 0x013D, "capital L with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_caron", "n", 0x0148, "small N with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_caron", "N", 0x0147, "capital N with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_caron", "r", 0x0159, "small R with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_caron", "R", 0x0158, "capital R with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_caron", "s", 0x0161, "small S with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_caron", "S", 0x0160, "capital S with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_caron", "t", 0x0165, "small T with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_caron", "T", 0x0164, "capital T with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_caron", "z", 0x017E, "small Z with caron"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_caron", "Z", 0x017D, "capital Z with caron"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine("dead_cedilla", "c", 0x00E7, "small C with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_cedilla", "C", 0x00C7, "capital C with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_cedilla", "g", 0x0123, "small G with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_cedilla", "G", 0x0122, "capital G with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_cedilla", "k", 0x0137, "small K with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_cedilla", "K", 0x0136, "capital K with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_cedilla", "l", 0x013C, "small L with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_cedilla", "L", 0x013B, "capital L with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_cedilla", "n", 0x0146, "small N with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_cedilla", "N", 0x0145, "capital N with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_cedilla", "r", 0x0157, "small R with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_cedilla", "R", 0x0156, "capital R with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_cedilla", "s", 0x015F, "small S with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_cedilla", "S", 0x015E, "capital S with cedilla"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine("dead_ogonek", "a", 0x0105, "small A with ogonek"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_ogonek", "A", 0x0104, "capital A with ogonek"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_ogonek", "e", 0x0119, "small E with ogonek"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_ogonek", "E", 0x0118, "capital E with ogonek"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_ogonek", "i", 0x012F, "small I with ogonek"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_ogonek", "I", 0x012E, "capital I with ogonek"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_ogonek", "u", 0x0173, "small U with ogonek"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_ogonek", "U", 0x0172, "capital U with ogonek"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_circumflex", "space", 0x005E, "CIRCUMFLEX_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine("dead_acute", "space", 0x0027, "APOSTROPHE"); - dk_ComposeTable.push_back(line); line.clear(); - - - line = createLine("dead_grave", "space", 0x0060, "GRAVE_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_breve", "space", 0x02D8, "BREVE"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_abovedot", "space", 0x02D9, "DOT_ABOVE"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_abovering", "space", 0x02DA, "RING_ABOVE"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_doubleacute", "space", 0x02DD, "DOUBLE_ACUTE_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_caron", "space", 0x02C7, "CARON"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_cedilla", "space", 0x00B8, "CEDILLA"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_ogonek", "space", 0x02DB, "OGONEK"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_tilde", "space", 0x007E, "TILDE"); - dk_ComposeTable.push_back(line); line.clear(); - - line = createLine("dead_breve", "dead_breve", 0x02D8, "BREVE"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_abovedot", "abovedot", 0x02D9, "DOT_ABOVE"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_abovedot", "dead_abovedot", 0x02D9, "DOT_ABOVE"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_abovering", "dead_abovering", 0x02DA, "RING_ABOVE"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "apostrophe", 0x00B4, "ACUTE_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "acute", 0x00B4, "ACUTE_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_acute", "dead_acute", 0x00B4, "ACUTE_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_doubleacute", "dead_doubleacute", 0x02DD, "DOUBLE_ACUTE_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_caron", "caron", 0x02C7, "CARON"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_caron", "dead_caron", 0x02C7, "CARON"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_cedilla", "comma", 0x00B8, "CEDILLA"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_cedilla", "cedilla", 0x00B8, "CEDILLA"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_cedilla", "dead_cedilla", 0x00B8, "CEDILLA"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_circumflex", "minus", 0x00AF, "MACRON"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_circumflex", "asciicircum", 0x005E, "CIRCUMFLEX_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_circumflex", "underscore", 0x00AF, "MACRON"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_circumflex", "dead_circumflex", 0x005E, "CIRCUMFLEX_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_diaeresis", "quotedbl", 0x00A8, "DIAERESIS"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_diaeresis", "diaeresis", 0x00A8, "DIAERESIS"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_diaeresis", "dead_diaeresis", 0x00A8, "DIAERESIS"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_grave", "grave", 0x0060, "GRAVE_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_grave", "dead_grave", 0x0060, "GRAVE_ACCENT"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_macron", "macron", 0x00AF, "MACRON"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_macron", "dead_macron", 0x00AF, "MACRON"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_ogonek", "ogonek", 0x02DB, "OGONEK"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_ogonek", "dead_ogonek", 0x02DB, "OGONEK"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_tilde", "asciitilde", 0x007E, "TILDE"); - dk_ComposeTable.push_back(line); line.clear(); - line = createLine("dead_tilde", "dead_tilde", 0x007E, "TILDE"); - dk_ComposeTable.push_back(line); line.clear(); + if (dk_SingleTable.size() > 0) + return true; + else + return false; } +KMX_DWORD KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD &shift, GdkKeymap *keymap) { + guint keyval = (guint)kVal; + GdkKeymapKey *keys; + gint n_keys; + + KMX_DWORD capitalKeyval = (KMX_DWORD)gdk_keyval_to_upper(kVal); + if (keyval != 0) { + gdk_keymap_get_entries_for_keyval(keymap, keyval, &keys, &n_keys); + for (int i = 0; i < n_keys; i++) { + if (keys[i].group == 0) { + shift = keys[i].level; + return capitalKeyval; + } + } + } + return capitalKeyval; +} + +void add_deadkey_combination(vec_dword_2D &dk_ComposeTable, std::string diacritic_name, std::string base_char, KMX_DWORD unicode_value) { + vec_dword_1D line; + line.push_back(convertNamesTo_DWORD_Value(diacritic_name)); + line.push_back(convertNamesTo_DWORD_Value(base_char)); + line.push_back(unicode_value); + dk_ComposeTable.push_back(line); +} + +void create_DKTable(vec_dword_2D &dk_ComposeTable) { + // create a 2D-Vector which contains data for ALL existing deadkey combinations on a Linux Keyboard: + // dk_ComposeTable[i][0] : diacritic_name (e.g. dead_circumflex) + // dk_ComposeTable[i][1] : base_char (e.g. a) + // dk_ComposeTable[i][2] : unicode_value-Value (e.g. 0x00E2) + + // values taken from: https://help.ubuntu.com/community/GtkDeadKeyTable#Accents + + add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "a", 0x00E2); // small A with circumflex + add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "A", 0x00C2); // capital A with circumflex + add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "e", 0x00EA); // small E with circumflex + add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "E", 0x00CA); // capital E with circumflex + add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "i", 0x00EE); // small I with circumflex + add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "I", 0x00CE); // capital I with circumflex + add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "o", 0x00F4); // small O with circumflex + add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "O", 0x00D4); // capital O with circumflex + add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "u", 0x00FB); // small U with circumflex + add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "U", 0x00DB); // capital U with circumflex + + add_deadkey_combination(dk_ComposeTable, "dead_acute", "a", 0x00E1); // small A with acute + add_deadkey_combination(dk_ComposeTable, "dead_acute", "A", 0x00C1); // capital A with acute + add_deadkey_combination(dk_ComposeTable, "dead_acute", "c", 0x0107); // small C with acute + add_deadkey_combination(dk_ComposeTable, "dead_acute", "C", 0x0106); // capital C with acute + add_deadkey_combination(dk_ComposeTable, "dead_acute", "e", 0x00E9); // small E with acute + add_deadkey_combination(dk_ComposeTable, "dead_acute", "E", 0x00C9); // capital E with acute + add_deadkey_combination(dk_ComposeTable, "dead_acute", "i", 0x00ED); // small I with acute + add_deadkey_combination(dk_ComposeTable, "dead_acute", "I", 0x00CD); // capital I with acute + add_deadkey_combination(dk_ComposeTable, "dead_acute", "l", 0x013A); // small L with acute + add_deadkey_combination(dk_ComposeTable, "dead_acute", "L", 0x0139); // capital L with acute + add_deadkey_combination(dk_ComposeTable, "dead_acute", "n", 0x0144); // small N with acute + add_deadkey_combination(dk_ComposeTable, "dead_acute", "N", 0x0143); // capital N with acute + add_deadkey_combination(dk_ComposeTable, "dead_acute", "o", 0x00F3); // small O with acute + add_deadkey_combination(dk_ComposeTable, "dead_acute", "O", 0x00D3); // capital O with acute + add_deadkey_combination(dk_ComposeTable, "dead_acute", "r", 0x0155); // small R with acute + add_deadkey_combination(dk_ComposeTable, "dead_acute", "R", 0x0154); // capital R with acute + add_deadkey_combination(dk_ComposeTable, "dead_acute", "s", 0x015B); // small S with acute + add_deadkey_combination(dk_ComposeTable, "dead_acute", "S", 0x015A); // capital S with acute + add_deadkey_combination(dk_ComposeTable, "dead_acute", "u", 0x00FA); // small U with acute + add_deadkey_combination(dk_ComposeTable, "dead_acute", "U", 0x00DA); // capital U with acute + add_deadkey_combination(dk_ComposeTable, "dead_acute", "y", 0x00FD); // small Y with acute + add_deadkey_combination(dk_ComposeTable, "dead_acute", "Y", 0x00DD); // capital Y with acute + add_deadkey_combination(dk_ComposeTable, "dead_acute", "z", 0x017A); // small Z with acute + add_deadkey_combination(dk_ComposeTable, "dead_acute", "Z", 0x0179); // capital Z with acute + + add_deadkey_combination(dk_ComposeTable, "dead_grave", "a", 0x00E0); // small A with grave + add_deadkey_combination(dk_ComposeTable, "dead_grave", "A", 0x00C0); // capital A with grave + add_deadkey_combination(dk_ComposeTable, "dead_grave", "e", 0x00E8); // small E with grave + add_deadkey_combination(dk_ComposeTable, "dead_grave", "E", 0x00C8); // capital E with grave + add_deadkey_combination(dk_ComposeTable, "dead_grave", "i", 0x00EC); // small I with grave + add_deadkey_combination(dk_ComposeTable, "dead_grave", "I", 0x00CC); // capital I with grave + add_deadkey_combination(dk_ComposeTable, "dead_grave", "o", 0x00F2); // small O with grave + add_deadkey_combination(dk_ComposeTable, "dead_grave", "O", 0x00D2); // capital O with grave + add_deadkey_combination(dk_ComposeTable, "dead_grave", "u", 0x00F9); // small U with grave + add_deadkey_combination(dk_ComposeTable, "dead_grave", "U", 0x00D9); // capital U with grave + + add_deadkey_combination(dk_ComposeTable, "dead_tilde", "a", 0x00E3); // small A with tilde + add_deadkey_combination(dk_ComposeTable, "dead_tilde", "A", 0x00C3); // capital A with tilde + add_deadkey_combination(dk_ComposeTable, "dead_tilde", "i", 0x0129); // small I with tilde + add_deadkey_combination(dk_ComposeTable, "dead_tilde", "I", 0x0128); // capital I with tilde + add_deadkey_combination(dk_ComposeTable, "dead_tilde", "n", 0x00F1); // small N with tilde + add_deadkey_combination(dk_ComposeTable, "dead_tilde", "N", 0x00D1); // capital N with tilde + add_deadkey_combination(dk_ComposeTable, "dead_tilde", "o", 0x00F5); // small O with tilde + add_deadkey_combination(dk_ComposeTable, "dead_tilde", "O", 0x00D5); // capital O with tilde + add_deadkey_combination(dk_ComposeTable, "dead_tilde", "u", 0x0169); // small U with tilde + add_deadkey_combination(dk_ComposeTable, "dead_tilde", "U", 0x0168); // capital U with tilde + + add_deadkey_combination(dk_ComposeTable, "dead_macron", "a", 0x0101); // small A with macron + add_deadkey_combination(dk_ComposeTable, "dead_macron", "A", 0x0100); // capital A with macron + add_deadkey_combination(dk_ComposeTable, "dead_macron", "e", 0x0113); // small E with macron + add_deadkey_combination(dk_ComposeTable, "dead_macron", "E", 0x0112); // capital E with macron + add_deadkey_combination(dk_ComposeTable, "dead_macron", "i", 0x012B); // small I with macron + add_deadkey_combination(dk_ComposeTable, "dead_macron", "I", 0x012A); // capital I with macron + add_deadkey_combination(dk_ComposeTable, "dead_macron", "o", 0x014D); // small O with macron + add_deadkey_combination(dk_ComposeTable, "dead_macron", "O", 0x014C); // capital O with macron + add_deadkey_combination(dk_ComposeTable, "dead_macron", "u", 0x016B); // small U with macron + add_deadkey_combination(dk_ComposeTable, "dead_macron", "U", 0x016A); // capital U with macron + + add_deadkey_combination(dk_ComposeTable, "dead_breve", "a", 0x0103); // small A with breve + add_deadkey_combination(dk_ComposeTable, "dead_breve", "A", 0x0102); // capital A with breve + add_deadkey_combination(dk_ComposeTable, "dead_breve", "g", 0x011F); // small G with breve + add_deadkey_combination(dk_ComposeTable, "dead_breve", "G", 0x011E); // capital G with breve + + add_deadkey_combination(dk_ComposeTable, "dead_abovedot", "e", 0x0117); // small E with dot above + add_deadkey_combination(dk_ComposeTable, "dead_abovedot", "E", 0x0116); // capital E with dot above + add_deadkey_combination(dk_ComposeTable, "dead_abovedot", "i", 0x0131); // small DOTLESS_I + add_deadkey_combination(dk_ComposeTable, "dead_abovedot", "I", 0x0130); // capital I with dot above + add_deadkey_combination(dk_ComposeTable, "dead_abovedot", "z", 0x017C); // small Z with dot above + add_deadkey_combination(dk_ComposeTable, "dead_abovedot", "Z", 0x017B); // capital Z with dot above + + add_deadkey_combination(dk_ComposeTable, "dead_diaeresis", "a", 0x00E4); // small A with diaeresis + add_deadkey_combination(dk_ComposeTable, "dead_diaeresis", "A", 0x00C4); // capital A with diaeresis + add_deadkey_combination(dk_ComposeTable, "dead_diaeresis", "e", 0x00EB); // small E with diaeresis + add_deadkey_combination(dk_ComposeTable, "dead_diaeresis", "E", 0x00CB); // capital E with diaeresis + add_deadkey_combination(dk_ComposeTable, "dead_diaeresis", "i", 0x00EF); // small I with diaeresis + add_deadkey_combination(dk_ComposeTable, "dead_diaeresis", "I", 0x00CF); // capital I with diaeresis + add_deadkey_combination(dk_ComposeTable, "dead_diaeresis", "o", 0x00F6); // small O with diaeresis + add_deadkey_combination(dk_ComposeTable, "dead_diaeresis", "O", 0x00D6); // capital O with diaeresis + add_deadkey_combination(dk_ComposeTable, "dead_diaeresis", "u", 0x00FC); // small U with diaeresis + add_deadkey_combination(dk_ComposeTable, "dead_diaeresis", "U", 0x00DC); // capital U with diaeresis + add_deadkey_combination(dk_ComposeTable, "dead_diaeresis", "y", 0x00FF); // small Y with diaeresis + add_deadkey_combination(dk_ComposeTable, "dead_diaeresis", "Y", 0x0178); // capital Y with diaeresis + + add_deadkey_combination(dk_ComposeTable, "dead_abovering", "a", 0x00E5); // small A with ring above + add_deadkey_combination(dk_ComposeTable, "dead_abovering", "A", 0x00C5); // capital A with ring above + add_deadkey_combination(dk_ComposeTable, "dead_abovering", "u", 0x016F); // small U with ring above + add_deadkey_combination(dk_ComposeTable, "dead_abovering", "U", 0x016E); // capital U with ring above + + add_deadkey_combination(dk_ComposeTable, "dead_doubleacute", "o", 0x0151); // small O with double acute + add_deadkey_combination(dk_ComposeTable, "dead_doubleacute", "O", 0x0150); // capital O with double acute + add_deadkey_combination(dk_ComposeTable, "dead_doubleacute", "u", 0x0171); // small U with double acute + add_deadkey_combination(dk_ComposeTable, "dead_doubleacute", "U", 0x0170); // capital U with double acute + + add_deadkey_combination(dk_ComposeTable, "dead_caron", "c", 0x010D); // small C with caron + add_deadkey_combination(dk_ComposeTable, "dead_caron", "C", 0x010C); // capital C with caron + add_deadkey_combination(dk_ComposeTable, "dead_caron", "d", 0x010F); // small D with caron + add_deadkey_combination(dk_ComposeTable, "dead_caron", "D", 0x010E); // capital D with caron + add_deadkey_combination(dk_ComposeTable, "dead_caron", "e", 0x011B); // small E with caron + add_deadkey_combination(dk_ComposeTable, "dead_caron", "E", 0x011A); // capital E with caron + add_deadkey_combination(dk_ComposeTable, "dead_caron", "l", 0x013E); // small L with caron + add_deadkey_combination(dk_ComposeTable, "dead_caron", "L", 0x013D); // capital L with caron + add_deadkey_combination(dk_ComposeTable, "dead_caron", "n", 0x0148); // small N with caron + add_deadkey_combination(dk_ComposeTable, "dead_caron", "N", 0x0147); // capital N with caron + add_deadkey_combination(dk_ComposeTable, "dead_caron", "r", 0x0159); // small R with caron + add_deadkey_combination(dk_ComposeTable, "dead_caron", "R", 0x0158); // capital R with caron + add_deadkey_combination(dk_ComposeTable, "dead_caron", "s", 0x0161); // small S with caron + add_deadkey_combination(dk_ComposeTable, "dead_caron", "S", 0x0160); // capital S with caron + add_deadkey_combination(dk_ComposeTable, "dead_caron", "t", 0x0165); // small T with caron + add_deadkey_combination(dk_ComposeTable, "dead_caron", "T", 0x0164); // capital T with caron + add_deadkey_combination(dk_ComposeTable, "dead_caron", "z", 0x017E); // small Z with caron + add_deadkey_combination(dk_ComposeTable, "dead_caron", "Z", 0x017D); // capital Z with caron + + add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "c", 0x00E7); // small C with cedilla + add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "C", 0x00C7); // capital C with cedilla + add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "g", 0x0123); // small G with cedilla + add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "G", 0x0122); // capital G with cedilla + add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "k", 0x0137); // small K with cedilla + add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "K", 0x0136); // capital K with cedilla + add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "l", 0x013C); // small L with cedilla + add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "L", 0x013B); // capital L with cedilla + add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "n", 0x0146); // small N with cedilla + add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "N", 0x0145); // capital N with cedilla + add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "r", 0x0157); // small R with cedilla + add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "R", 0x0156); // capital R with cedilla + add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "s", 0x015F); // small S with cedilla + add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "S", 0x015E); // capital S with cedilla + + add_deadkey_combination(dk_ComposeTable, "dead_ogonek", "a", 0x0105); // small A with ogonek + add_deadkey_combination(dk_ComposeTable, "dead_ogonek", "A", 0x0104); // capital A with ogonek + add_deadkey_combination(dk_ComposeTable, "dead_ogonek", "e", 0x0119); // small E with ogonek + add_deadkey_combination(dk_ComposeTable, "dead_ogonek", "E", 0x0118); // capital E with ogonek + add_deadkey_combination(dk_ComposeTable, "dead_ogonek", "i", 0x012F); // small I with ogonek + add_deadkey_combination(dk_ComposeTable, "dead_ogonek", "I", 0x012E); // capital I with ogonek + add_deadkey_combination(dk_ComposeTable, "dead_ogonek", "u", 0x0173); // small U with ogonek + add_deadkey_combination(dk_ComposeTable, "dead_ogonek", "U", 0x0172); // capital U with ogonek + + add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "space", 0x005E); // CIRCUMFLEX_ACCENT + add_deadkey_combination(dk_ComposeTable, "dead_acute", "space", 0x0027); // APOSTROPHE + add_deadkey_combination(dk_ComposeTable, "dead_grave", "space", 0x0060); // GRAVE_ACCENT + add_deadkey_combination(dk_ComposeTable, "dead_breve", "space", 0x02D8); // BREVE + add_deadkey_combination(dk_ComposeTable, "dead_abovedot", "space", 0x02D9); // DOT_ABOVE + add_deadkey_combination(dk_ComposeTable, "dead_abovering", "space", 0x02DA); // RING_ABOVE + add_deadkey_combination(dk_ComposeTable, "dead_doubleacute", "space", 0x02DD); // DOUBLE_ACUTE_ACCENT + add_deadkey_combination(dk_ComposeTable, "dead_caron", "space", 0x02C7); // CARON + add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "space", 0x00B8); // CEDILLA + add_deadkey_combination(dk_ComposeTable, "dead_ogonek", "space", 0x02DB); // OGONEK + add_deadkey_combination(dk_ComposeTable, "dead_tilde", "space", 0x007E); // TILDE + + add_deadkey_combination(dk_ComposeTable, "dead_breve", "dead_breve", 0x02D8); // BREVE + add_deadkey_combination(dk_ComposeTable, "dead_abovedot", "abovedot", 0x02D9); // DOT_ABOVE + add_deadkey_combination(dk_ComposeTable, "dead_abovedot", "dead_abovedot", 0x02D9); // DOT_ABOVE + add_deadkey_combination(dk_ComposeTable, "dead_abovering", "dead_abovering", 0x02DA); // RING_ABOVE + add_deadkey_combination(dk_ComposeTable, "dead_acute", "apostrophe", 0x00B4); // ACUTE_ACCENT + add_deadkey_combination(dk_ComposeTable, "dead_acute", "acute", 0x00B4); // ACUTE_ACCENT + add_deadkey_combination(dk_ComposeTable, "dead_acute", "dead_acute", 0x00B4); // ACUTE_ACCENT + add_deadkey_combination(dk_ComposeTable, "dead_doubleacute", "dead_doubleacute", 0x02DD); // DOUBLE_ACUTE_ACCENT + add_deadkey_combination(dk_ComposeTable, "dead_caron", "caron", 0x02C7); // CARON + add_deadkey_combination(dk_ComposeTable, "dead_caron", "dead_caron", 0x02C7); // CARON + add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "comma", 0x00B8); // CEDILLA + add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "cedilla", 0x00B8); // CEDILLA + add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "dead_cedilla", 0x00B8); // CEDILLA + add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "minus", 0x00AF); // MACRON + add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "asciicircum", 0x005E); // CIRCUMFLEX_ACCENT + add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "underscore", 0x00AF); // MACRON + add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "dead_circumflex", 0x005E); // CIRCUMFLEX_ACCENT + add_deadkey_combination(dk_ComposeTable, "dead_diaeresis", "quotedbl", 0x00A8); // DIAERESIS + add_deadkey_combination(dk_ComposeTable, "dead_diaeresis", "diaeresis", 0x00A8); // DIAERESIS + add_deadkey_combination(dk_ComposeTable, "dead_diaeresis", "dead_diaeresis", 0x00A8); // DIAERESIS + add_deadkey_combination(dk_ComposeTable, "dead_grave", "grave", 0x0060); // GRAVE_ACCENT + add_deadkey_combination(dk_ComposeTable, "dead_grave", "dead_grave", 0x0060); // GRAVE_ACCENT + add_deadkey_combination(dk_ComposeTable, "dead_macron", "macron", 0x00AF); // MACRON + add_deadkey_combination(dk_ComposeTable, "dead_macron", "dead_macron", 0x00AF); // MACRON + add_deadkey_combination(dk_ComposeTable, "dead_ogonek", "ogonek", 0x02DB); // OGONEK + add_deadkey_combination(dk_ComposeTable, "dead_ogonek", "dead_ogonek", 0x02DB); // OGONEK + add_deadkey_combination(dk_ComposeTable, "dead_tilde", "asciitilde", 0x007E); // TILDE + add_deadkey_combination(dk_ComposeTable, "dead_tilde", "dead_tilde", 0x007E); // TILDE +} diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index 38185939d4..3427533640 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -3,27 +3,25 @@ #ifndef DEADKEY_H #define DEADKEY_H -#include #include "mc_import_rules.h" - -// create a vector for a dk combination ( ` + a -> à ) -vec_dword_1D createLine(std::string first, std::string second, KMX_DWORD number, std::string nameresult); +#include // create a 2D-vector of all dk combinations ( ` + a -> à ; ^ + a -> â ; `+ e -> è; ...) -void create_DKTable(vec_dword_2D & dk_ComposeTable); +void create_DKTable(vec_dword_2D &dk_ComposeTable); // find all possible dk combinations that exist -std::vector create_deadkeys_by_basechar(); +std::vector create_deadkeys_by_basechar(); // refine dk to those used in the underlying keyboard -void refine_alDead(KMX_WCHAR dk, std::vector &myVec, std::vector *p_All_Vec); -// check if entry is already there -bool found_dk_inVector(KMX_WCHAR dk, std::vector &myVec); +void refine_alDead(KMX_WCHAR dk, std::vector &myVec, std::vector &p_All_Vec); -// get all combination for a specific deadkey(dk) from the dk_vector query_dk_combinations_for_specific_dk which holds all possible dk: ^-> â,ê,î,ô,û,... -bool query_dk_combinations_for_specific_dk(vec_dword_2D * dk_ComposeTable, vec_dword_2D & dk_SingleTable, KMX_DWORD dk); +// check if entry is already there +bool found_dk_inVector(KMX_WCHAR dk, std::vector &myVec); + +//query_dk_combinations_for_a specific_dk from dk_ComposeTable(which holds all dk combinations) e.g. for dk: ^ get â,ê,î,ô,û,... +bool query_dk_combinations_for_specific_dk(vec_dword_2D &dk_ComposeTable, KMX_DWORD dk, vec_dword_2D &dk_SingleTable); // get the shifted character of a key and write shiftstate of KVal to shift -KMX_DWORD KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD &shift, GdkKeymap* keymap); +KMX_DWORD KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD &shift, GdkKeymap *keymap); -# endif /*DEADKEY_H*/ \ No newline at end of file +#endif /*DEADKEY_H*/ \ No newline at end of file diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index a04c3860df..a79a608d0c 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -65,8 +65,9 @@ typedef std::vector > > vec_dword_3D; static KMX_DWORD INVALID_NAME = 0; static KMX_DWORD keycode_max = 94; -static KMX_DWORD deadkey_min = 0xfe50; // X11's keysymdef.h defines deadkeys between 0xfe50-0xfe93 -static KMX_DWORD deadkey_max = 0xfe93; // https://fossies.org/linux/tk/xlib/X11/keysymdef.h +static KMX_DWORD deadkey_min = 0xfe50; // X11's keysymdef.h defines deadkeys between 0xfe50-0xfe93 +//static KMX_DWORD deadkey_max = 0xfe52; // https://fossies.org/linux/tk/xlib/X11/keysymdef.h +static KMX_DWORD deadkey_max = 0xfe93; // https://fossies.org/linux/tk/xlib/X11/keysymdef.h _S2 // map Shiftstate to modifier (e.g. 0->0; 16-1; 9->2; 25->3) int map_VKShiftState_to_LinModifier(int VKShiftState); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 447711c571..58c700f02a 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -408,10 +408,10 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap **ke continue; } - //_S2 TOP_6 TODO to compare win-lin kmn-files skip ss6+7; MUST BE removed later!!!! - if(ss == MenuCtrl|| ss == ShftMenuCtrl) { + //_S2 TOP_6 TODO to compare win-lin kmn-files skip ss6+7; MUST BE removed later!!!! + /*if(ss == MenuCtrl|| ss == ShftMenuCtrl) { continue; - } + }*/ KMX_DWORD kc_us = (KMX_DWORD) KMX_get_KeyCodeUnderlying_From_VKUS(iKey); @@ -434,7 +434,8 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap **ke sbBuffer[2] = 0; rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps)); // different to windows since behavior on Linux is different - refine_alDead(sbBuffer[0], alDead, &alDead_cpl); + //refine_alDead(sbBuffer[0], alDead, &alDead_cpl); + refine_alDead(sbBuffer[0], alDead, alDead_cpl); } } } diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 933299cdd9..282b44b1c6 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -457,9 +457,9 @@ int KMX_GetDeadkeys(vec_dword_2D & dk_Table, KMX_WORD deadkey, KMX_WORD *OutputP KMX_WORD *p = OutputPairs; KMX_DWORD shift; + vec_dword_2D dk_SingleTable; - vec_dword_2D dk_SingleTable; - query_dk_combinations_for_specific_dk(&dk_Table, dk_SingleTable, deadkey); + query_dk_combinations_for_specific_dk(dk_Table, deadkey, dk_SingleTable); for ( int i=0; i< (int) dk_SingleTable.size();i++) { KMX_WORD vk = KMX_change_keyname_to_capital(dk_SingleTable[i][1], shift, keymap); if(vk != 0) { From fa192039b5605e15fe79850e8ff47898249f7712 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 17 Jun 2024 17:25:03 +0200 Subject: [PATCH 243/327] feat(linux): rework deadkey.cpp/.h format document --- linux/mcompile/keymap/deadkey.cpp | 107 ++++++++++++++++-------------- linux/mcompile/keymap/deadkey.h | 2 +- 2 files changed, 60 insertions(+), 49 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 4130c04d05..85e1f1f200 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -1,8 +1,8 @@ #include "keymap.h" #include "deadkey.h" - -std::vector create_deadkeys_by_basechar() { +std::vector +create_deadkeys_by_basechar() { std::vector alDead; vec_dword_2D dk_ComposeTable; @@ -19,7 +19,8 @@ std::vector create_deadkeys_by_basechar() { return alDead; } -void refine_alDead(KMX_WCHAR dk, std::vector &dkVec, std::vector &p_All_Vec) { +void +refine_alDead(KMX_WCHAR dk, std::vector &dkVec, std::vector &p_All_Vec) { if (dk == 0) return; @@ -28,12 +29,14 @@ void refine_alDead(KMX_WCHAR dk, std::vector &dkVec, std::vector &dkVec) { +bool +found_dk_inVector(KMX_WCHAR dk, std::vector &dkVec) { for (int i = 0; i < dkVec.size(); i++) { if (dk == dkVec[i]->KMX_GetDeadCharacter()) return true; @@ -41,7 +44,8 @@ bool found_dk_inVector(KMX_WCHAR dk, std::vector &dkVec) { return false; } -bool query_dk_combinations_for_specific_dk(vec_dword_2D &p_dk_ComposeTable, KMX_DWORD dk, vec_dword_2D &dk_SingleTable) { +bool +query_dk_combinations_for_specific_dk(vec_dword_2D &p_dk_ComposeTable, KMX_DWORD dk, vec_dword_2D &dk_SingleTable) { vec_dword_1D line; for (int i = 0; i < (int)(p_dk_ComposeTable).size(); i++) { @@ -60,7 +64,8 @@ bool query_dk_combinations_for_specific_dk(vec_dword_2D &p_dk_ComposeTable, KMX_ return false; } -KMX_DWORD KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD &shift, GdkKeymap *keymap) { +KMX_DWORD +KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD &shift, GdkKeymap *keymap) { guint keyval = (guint)kVal; GdkKeymapKey *keys; gint n_keys; @@ -78,7 +83,12 @@ KMX_DWORD KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD &shift, GdkKey return capitalKeyval; } -void add_deadkey_combination(vec_dword_2D &dk_ComposeTable, std::string diacritic_name, std::string base_char, KMX_DWORD unicode_value) { +void +add_deadkey_combination( + vec_dword_2D &dk_ComposeTable, + std::string diacritic_name, + std::string base_char, + KMX_DWORD unicode_value) { vec_dword_1D line; line.push_back(convertNamesTo_DWORD_Value(diacritic_name)); line.push_back(convertNamesTo_DWORD_Value(base_char)); @@ -86,7 +96,8 @@ void add_deadkey_combination(vec_dword_2D &dk_ComposeTable, std::string diacriti dk_ComposeTable.push_back(line); } -void create_DKTable(vec_dword_2D &dk_ComposeTable) { +void +create_DKTable(vec_dword_2D &dk_ComposeTable) { // create a 2D-Vector which contains data for ALL existing deadkey combinations on a Linux Keyboard: // dk_ComposeTable[i][0] : diacritic_name (e.g. dead_circumflex) // dk_ComposeTable[i][1] : base_char (e.g. a) @@ -241,44 +252,44 @@ void create_DKTable(vec_dword_2D &dk_ComposeTable) { add_deadkey_combination(dk_ComposeTable, "dead_ogonek", "u", 0x0173); // small U with ogonek add_deadkey_combination(dk_ComposeTable, "dead_ogonek", "U", 0x0172); // capital U with ogonek - add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "space", 0x005E); // CIRCUMFLEX_ACCENT - add_deadkey_combination(dk_ComposeTable, "dead_acute", "space", 0x0027); // APOSTROPHE - add_deadkey_combination(dk_ComposeTable, "dead_grave", "space", 0x0060); // GRAVE_ACCENT - add_deadkey_combination(dk_ComposeTable, "dead_breve", "space", 0x02D8); // BREVE - add_deadkey_combination(dk_ComposeTable, "dead_abovedot", "space", 0x02D9); // DOT_ABOVE - add_deadkey_combination(dk_ComposeTable, "dead_abovering", "space", 0x02DA); // RING_ABOVE - add_deadkey_combination(dk_ComposeTable, "dead_doubleacute", "space", 0x02DD); // DOUBLE_ACUTE_ACCENT - add_deadkey_combination(dk_ComposeTable, "dead_caron", "space", 0x02C7); // CARON - add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "space", 0x00B8); // CEDILLA - add_deadkey_combination(dk_ComposeTable, "dead_ogonek", "space", 0x02DB); // OGONEK - add_deadkey_combination(dk_ComposeTable, "dead_tilde", "space", 0x007E); // TILDE + add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "space", 0x005E); // CIRCUMFLEX_ACCENT + add_deadkey_combination(dk_ComposeTable, "dead_acute", "space", 0x0027); // APOSTROPHE + add_deadkey_combination(dk_ComposeTable, "dead_grave", "space", 0x0060); // GRAVE_ACCENT + add_deadkey_combination(dk_ComposeTable, "dead_breve", "space", 0x02D8); // BREVE + add_deadkey_combination(dk_ComposeTable, "dead_abovedot", "space", 0x02D9); // DOT_ABOVE + add_deadkey_combination(dk_ComposeTable, "dead_abovering", "space", 0x02DA); // RING_ABOVE + add_deadkey_combination(dk_ComposeTable, "dead_doubleacute", "space", 0x02DD); // DOUBLE_ACUTE_ACCENT + add_deadkey_combination(dk_ComposeTable, "dead_caron", "space", 0x02C7); // CARON + add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "space", 0x00B8); // CEDILLA + add_deadkey_combination(dk_ComposeTable, "dead_ogonek", "space", 0x02DB); // OGONEK + add_deadkey_combination(dk_ComposeTable, "dead_tilde", "space", 0x007E); // TILDE - add_deadkey_combination(dk_ComposeTable, "dead_breve", "dead_breve", 0x02D8); // BREVE - add_deadkey_combination(dk_ComposeTable, "dead_abovedot", "abovedot", 0x02D9); // DOT_ABOVE - add_deadkey_combination(dk_ComposeTable, "dead_abovedot", "dead_abovedot", 0x02D9); // DOT_ABOVE - add_deadkey_combination(dk_ComposeTable, "dead_abovering", "dead_abovering", 0x02DA); // RING_ABOVE - add_deadkey_combination(dk_ComposeTable, "dead_acute", "apostrophe", 0x00B4); // ACUTE_ACCENT - add_deadkey_combination(dk_ComposeTable, "dead_acute", "acute", 0x00B4); // ACUTE_ACCENT - add_deadkey_combination(dk_ComposeTable, "dead_acute", "dead_acute", 0x00B4); // ACUTE_ACCENT - add_deadkey_combination(dk_ComposeTable, "dead_doubleacute", "dead_doubleacute", 0x02DD); // DOUBLE_ACUTE_ACCENT - add_deadkey_combination(dk_ComposeTable, "dead_caron", "caron", 0x02C7); // CARON - add_deadkey_combination(dk_ComposeTable, "dead_caron", "dead_caron", 0x02C7); // CARON - add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "comma", 0x00B8); // CEDILLA - add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "cedilla", 0x00B8); // CEDILLA - add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "dead_cedilla", 0x00B8); // CEDILLA - add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "minus", 0x00AF); // MACRON - add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "asciicircum", 0x005E); // CIRCUMFLEX_ACCENT - add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "underscore", 0x00AF); // MACRON - add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "dead_circumflex", 0x005E); // CIRCUMFLEX_ACCENT - add_deadkey_combination(dk_ComposeTable, "dead_diaeresis", "quotedbl", 0x00A8); // DIAERESIS - add_deadkey_combination(dk_ComposeTable, "dead_diaeresis", "diaeresis", 0x00A8); // DIAERESIS - add_deadkey_combination(dk_ComposeTable, "dead_diaeresis", "dead_diaeresis", 0x00A8); // DIAERESIS - add_deadkey_combination(dk_ComposeTable, "dead_grave", "grave", 0x0060); // GRAVE_ACCENT - add_deadkey_combination(dk_ComposeTable, "dead_grave", "dead_grave", 0x0060); // GRAVE_ACCENT - add_deadkey_combination(dk_ComposeTable, "dead_macron", "macron", 0x00AF); // MACRON - add_deadkey_combination(dk_ComposeTable, "dead_macron", "dead_macron", 0x00AF); // MACRON - add_deadkey_combination(dk_ComposeTable, "dead_ogonek", "ogonek", 0x02DB); // OGONEK - add_deadkey_combination(dk_ComposeTable, "dead_ogonek", "dead_ogonek", 0x02DB); // OGONEK - add_deadkey_combination(dk_ComposeTable, "dead_tilde", "asciitilde", 0x007E); // TILDE - add_deadkey_combination(dk_ComposeTable, "dead_tilde", "dead_tilde", 0x007E); // TILDE + add_deadkey_combination(dk_ComposeTable, "dead_breve", "dead_breve", 0x02D8); // BREVE + add_deadkey_combination(dk_ComposeTable, "dead_abovedot", "abovedot", 0x02D9); // DOT_ABOVE + add_deadkey_combination(dk_ComposeTable, "dead_abovedot", "dead_abovedot", 0x02D9); // DOT_ABOVE + add_deadkey_combination(dk_ComposeTable, "dead_abovering", "dead_abovering", 0x02DA); // RING_ABOVE + add_deadkey_combination(dk_ComposeTable, "dead_acute", "apostrophe", 0x00B4); // ACUTE_ACCENT + add_deadkey_combination(dk_ComposeTable, "dead_acute", "acute", 0x00B4); // ACUTE_ACCENT + add_deadkey_combination(dk_ComposeTable, "dead_acute", "dead_acute", 0x00B4); // ACUTE_ACCENT + add_deadkey_combination(dk_ComposeTable, "dead_doubleacute", "dead_doubleacute", 0x02DD); // DOUBLE_ACUTE_ACCENT + add_deadkey_combination(dk_ComposeTable, "dead_caron", "caron", 0x02C7); // CARON + add_deadkey_combination(dk_ComposeTable, "dead_caron", "dead_caron", 0x02C7); // CARON + add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "comma", 0x00B8); // CEDILLA + add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "cedilla", 0x00B8); // CEDILLA + add_deadkey_combination(dk_ComposeTable, "dead_cedilla", "dead_cedilla", 0x00B8); // CEDILLA + add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "minus", 0x00AF); // MACRON + add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "asciicircum", 0x005E); // CIRCUMFLEX_ACCENT + add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "underscore", 0x00AF); // MACRON + add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "dead_circumflex", 0x005E); // CIRCUMFLEX_ACCENT + add_deadkey_combination(dk_ComposeTable, "dead_diaeresis", "quotedbl", 0x00A8); // DIAERESIS + add_deadkey_combination(dk_ComposeTable, "dead_diaeresis", "diaeresis", 0x00A8); // DIAERESIS + add_deadkey_combination(dk_ComposeTable, "dead_diaeresis", "dead_diaeresis", 0x00A8); // DIAERESIS + add_deadkey_combination(dk_ComposeTable, "dead_grave", "grave", 0x0060); // GRAVE_ACCENT + add_deadkey_combination(dk_ComposeTable, "dead_grave", "dead_grave", 0x0060); // GRAVE_ACCENT + add_deadkey_combination(dk_ComposeTable, "dead_macron", "macron", 0x00AF); // MACRON + add_deadkey_combination(dk_ComposeTable, "dead_macron", "dead_macron", 0x00AF); // MACRON + add_deadkey_combination(dk_ComposeTable, "dead_ogonek", "ogonek", 0x02DB); // OGONEK + add_deadkey_combination(dk_ComposeTable, "dead_ogonek", "dead_ogonek", 0x02DB); // OGONEK + add_deadkey_combination(dk_ComposeTable, "dead_tilde", "asciitilde", 0x007E); // TILDE + add_deadkey_combination(dk_ComposeTable, "dead_tilde", "dead_tilde", 0x007E); // TILDE } diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index 3427533640..0eb7cbbcdb 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -18,7 +18,7 @@ void refine_alDead(KMX_WCHAR dk, std::vector &myVec, std::vector &myVec); -//query_dk_combinations_for_a specific_dk from dk_ComposeTable(which holds all dk combinations) e.g. for dk: ^ get â,ê,î,ô,û,... +// query_dk_combinations_for_a specific_dk from dk_ComposeTable(which holds all dk combinations) e.g. for dk: ^ get â,ê,î,ô,û,... bool query_dk_combinations_for_specific_dk(vec_dword_2D &dk_ComposeTable, KMX_DWORD dk, vec_dword_2D &dk_SingleTable); // get the shifted character of a key and write shiftstate of KVal to shift From bfea2fa5213d801fb880a872155827536659a787 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 17 Jun 2024 19:20:46 +0200 Subject: [PATCH 244/327] feat(linux): change gitignore --- .gitignore | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/.gitignore b/.gitignore index 6a40380344..79ac5cf2db 100644 --- a/.gitignore +++ b/.gitignore @@ -191,18 +191,3 @@ lcov.info /keyman*.buildinfo /keyman*.changes /keyman*.tar.?z - -#Sabine: -# /common/test/keyboards/invalid/source/*.kmx -# /developer/src/test/auto/kmcomp/*.kmn -# /developer/src/test/auto/kmcomp/*.kvk -# /developer/src/test/auto/kmcomp/*.kvk* -# /developer/src/test/auto/kmcomp/*.txt -/linux/mcompile/keymap/X_bak -/linux/mcompile/keymap/anii.* - -/linux/mcompile/keymap/*.kmx - - - -/GTK_PLAYGROUND \ No newline at end of file From 433332d892d900904cd0ef8993c4c574c15e19c0 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 18 Jun 2024 09:03:02 +0200 Subject: [PATCH 245/327] feat(linux): undo changes in .gittignore --- .gitignore | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.gitignore b/.gitignore index 79ac5cf2db..6a40380344 100644 --- a/.gitignore +++ b/.gitignore @@ -191,3 +191,18 @@ lcov.info /keyman*.buildinfo /keyman*.changes /keyman*.tar.?z + +#Sabine: +# /common/test/keyboards/invalid/source/*.kmx +# /developer/src/test/auto/kmcomp/*.kmn +# /developer/src/test/auto/kmcomp/*.kvk +# /developer/src/test/auto/kmcomp/*.kvk* +# /developer/src/test/auto/kmcomp/*.txt +/linux/mcompile/keymap/X_bak +/linux/mcompile/keymap/anii.* + +/linux/mcompile/keymap/*.kmx + + + +/GTK_PLAYGROUND \ No newline at end of file From f724b4e79e3e9f67cecbf18fccbdf04feae518ab Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 18 Jun 2024 09:26:50 +0200 Subject: [PATCH 246/327] feat(linux): layout changes only --- linux/mcompile/keymap/deadkey.cpp | 25 +++++++---------------- linux/mcompile/keymap/keymap.h | 2 +- linux/mcompile/keymap/mc_import_rules.cpp | 5 ++--- 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 85e1f1f200..c4b599d32b 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -1,8 +1,7 @@ #include "keymap.h" #include "deadkey.h" -std::vector -create_deadkeys_by_basechar() { +std::vector create_deadkeys_by_basechar() { std::vector alDead; vec_dword_2D dk_ComposeTable; @@ -19,8 +18,7 @@ create_deadkeys_by_basechar() { return alDead; } -void -refine_alDead(KMX_WCHAR dk, std::vector &dkVec, std::vector &p_All_Vec) { +void refine_alDead(KMX_WCHAR dk, std::vector &dkVec, std::vector &p_All_Vec) { if (dk == 0) return; @@ -35,8 +33,7 @@ refine_alDead(KMX_WCHAR dk, std::vector &dkVec, std::vector &dkVec) { +bool found_dk_inVector(KMX_WCHAR dk, std::vector &dkVec) { for (int i = 0; i < dkVec.size(); i++) { if (dk == dkVec[i]->KMX_GetDeadCharacter()) return true; @@ -44,8 +41,7 @@ found_dk_inVector(KMX_WCHAR dk, std::vector &dkVec) { return false; } -bool -query_dk_combinations_for_specific_dk(vec_dword_2D &p_dk_ComposeTable, KMX_DWORD dk, vec_dword_2D &dk_SingleTable) { +bool query_dk_combinations_for_specific_dk(vec_dword_2D &p_dk_ComposeTable, KMX_DWORD dk, vec_dword_2D &dk_SingleTable) { vec_dword_1D line; for (int i = 0; i < (int)(p_dk_ComposeTable).size(); i++) { @@ -64,8 +60,7 @@ query_dk_combinations_for_specific_dk(vec_dword_2D &p_dk_ComposeTable, KMX_DWORD return false; } -KMX_DWORD -KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD &shift, GdkKeymap *keymap) { +KMX_DWORD KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD &shift, GdkKeymap *keymap) { guint keyval = (guint)kVal; GdkKeymapKey *keys; gint n_keys; @@ -83,12 +78,7 @@ KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD &shift, GdkKeymap *keyma return capitalKeyval; } -void -add_deadkey_combination( - vec_dword_2D &dk_ComposeTable, - std::string diacritic_name, - std::string base_char, - KMX_DWORD unicode_value) { +void add_deadkey_combination(vec_dword_2D &dk_ComposeTable, std::string diacritic_name, std::string base_char, KMX_DWORD unicode_value) { vec_dword_1D line; line.push_back(convertNamesTo_DWORD_Value(diacritic_name)); line.push_back(convertNamesTo_DWORD_Value(base_char)); @@ -96,8 +86,7 @@ add_deadkey_combination( dk_ComposeTable.push_back(line); } -void -create_DKTable(vec_dword_2D &dk_ComposeTable) { +void create_DKTable(vec_dword_2D &dk_ComposeTable) { // create a 2D-Vector which contains data for ALL existing deadkey combinations on a Linux Keyboard: // dk_ComposeTable[i][0] : diacritic_name (e.g. dead_circumflex) // dk_ComposeTable[i][1] : base_char (e.g. a) diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index a79a608d0c..443e62a5c0 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -66,8 +66,8 @@ typedef std::vector > > vec_dword_3D; static KMX_DWORD INVALID_NAME = 0; static KMX_DWORD keycode_max = 94; static KMX_DWORD deadkey_min = 0xfe50; // X11's keysymdef.h defines deadkeys between 0xfe50-0xfe93 -//static KMX_DWORD deadkey_max = 0xfe52; // https://fossies.org/linux/tk/xlib/X11/keysymdef.h static KMX_DWORD deadkey_max = 0xfe93; // https://fossies.org/linux/tk/xlib/X11/keysymdef.h _S2 +//static KMX_DWORD deadkey_max = 0xfe52; // https://fossies.org/linux/tk/xlib/X11/keysymdef.h // map Shiftstate to modifier (e.g. 0->0; 16-1; 9->2; 25->3) int map_VKShiftState_to_LinModifier(int VKShiftState); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 58c700f02a..38aa876d24 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -409,9 +409,9 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap **ke } //_S2 TOP_6 TODO to compare win-lin kmn-files skip ss6+7; MUST BE removed later!!!! - /*if(ss == MenuCtrl|| ss == ShftMenuCtrl) { + if(ss == MenuCtrl|| ss == ShftMenuCtrl) { continue; - }*/ + } KMX_DWORD kc_us = (KMX_DWORD) KMX_get_KeyCodeUnderlying_From_VKUS(iKey); @@ -434,7 +434,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap **ke sbBuffer[2] = 0; rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps)); // different to windows since behavior on Linux is different - //refine_alDead(sbBuffer[0], alDead, &alDead_cpl); refine_alDead(sbBuffer[0], alDead, alDead_cpl); } } From 801baf55d054c69b79f35aa6efb4fbe9ce2fc2bd Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 18 Jun 2024 09:34:45 +0200 Subject: [PATCH 247/327] feat(linux): remove comments --- linux/mcompile/keymap/keymap.h | 3 +-- linux/mcompile/keymap/mc_import_rules.cpp | 5 ----- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 443e62a5c0..2761e92066 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -66,8 +66,7 @@ typedef std::vector > > vec_dword_3D; static KMX_DWORD INVALID_NAME = 0; static KMX_DWORD keycode_max = 94; static KMX_DWORD deadkey_min = 0xfe50; // X11's keysymdef.h defines deadkeys between 0xfe50-0xfe93 -static KMX_DWORD deadkey_max = 0xfe93; // https://fossies.org/linux/tk/xlib/X11/keysymdef.h _S2 -//static KMX_DWORD deadkey_max = 0xfe52; // https://fossies.org/linux/tk/xlib/X11/keysymdef.h +static KMX_DWORD deadkey_max = 0xfe93; // https://fossies.org/linux/tk/xlib/X11/keysymdef.h // map Shiftstate to modifier (e.g. 0->0; 16-1; 9->2; 25->3) int map_VKShiftState_to_LinModifier(int VKShiftState); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 38aa876d24..c462774229 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -408,11 +408,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap **ke continue; } - //_S2 TOP_6 TODO to compare win-lin kmn-files skip ss6+7; MUST BE removed later!!!! - if(ss == MenuCtrl|| ss == ShftMenuCtrl) { - continue; - } - KMX_DWORD kc_us = (KMX_DWORD) KMX_get_KeyCodeUnderlying_From_VKUS(iKey); for(int caps = 0; caps <= 1; caps++) { From f07cb3a12e7531443dcd7291c97d551c57ebe999 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 18 Jun 2024 10:03:28 +0200 Subject: [PATCH 248/327] feat(linux): change variable names --- linux/mcompile/keymap/deadkey.cpp | 8 ++++---- linux/mcompile/keymap/deadkey.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index c4b599d32b..52eaf21f63 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -18,14 +18,14 @@ std::vector create_deadkeys_by_basechar() { return alDead; } -void refine_alDead(KMX_WCHAR dk, std::vector &dkVec, std::vector &p_All_Vec) { +void refine_alDead(KMX_WCHAR dk, std::vector &dkVec, std::vector &r_All_Vec) { if (dk == 0) return; - for (int j = 0; j < (int)p_All_Vec.size() - 1; j++) { - if (dk == (p_All_Vec)[j]->KMX_GetDeadCharacter()) { + for (int j = 0; j < (int)r_All_Vec.size() - 1; j++) { + if (dk == (r_All_Vec)[j]->KMX_GetDeadCharacter()) { if (!found_dk_inVector(dk, dkVec)) { - dkVec.push_back((p_All_Vec)[j]); + dkVec.push_back((r_All_Vec)[j]); return; } else return; diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index 0eb7cbbcdb..924b1044df 100755 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -13,7 +13,7 @@ void create_DKTable(vec_dword_2D &dk_ComposeTable); std::vector create_deadkeys_by_basechar(); // refine dk to those used in the underlying keyboard -void refine_alDead(KMX_WCHAR dk, std::vector &myVec, std::vector &p_All_Vec); +void refine_alDead(KMX_WCHAR dk, std::vector &myVec, std::vector &r_All_Vec); // check if entry is already there bool found_dk_inVector(KMX_WCHAR dk, std::vector &myVec); From 80390b6b61787dd4fdb7657c066ebefa0bc3382f Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 18 Jun 2024 11:10:38 +0200 Subject: [PATCH 249/327] feat(linux): start rework mc_import_rules --- linux/mcompile/keymap/mc_import_rules.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index c462774229..4da51e0123 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -391,8 +391,8 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap **ke } } - // _S2 TODO I assume we do not need those... - /*rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE); + /* _S2 TODO I assume we do not need those... + rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE); rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL); rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL);*/ From d2f031e9bc9ecbc9b420e91494feb5d676c15dac Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 19 Jun 2024 08:49:09 +0200 Subject: [PATCH 250/327] feat(linux): function ensureValidInputForKeyboardTranslation instead of 2 comparisons at several places --- linux/mcompile/keymap/keymap.cpp | 23 +++++++++++++-------- linux/mcompile/keymap/keymap.h | 4 +++- linux/mcompile/keymap/mc_import_rules.cpp | 25 ++++++++++++----------- linux/mcompile/keymap/mcompile.cpp | 6 ++++++ 4 files changed, 37 insertions(+), 21 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 206f6a4d7a..024f06a1d9 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -10,6 +10,16 @@ int map_VKShiftState_to_LinModifier(int vk_ShiftState) { else return vk_ShiftState; } +bool ensureValidInputForKeyboardTranslation(int shiftstate, gint count, guint keycode) { + if (!(shiftstate <= count)) + return false; + + if (!(keycode <= keycode_max)) + return false; + + return true; +} + KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str) { // more on https://manpages.ubuntu.com/manpages/jammy/man3/keysyms.3tk.html std::map first; @@ -611,6 +621,9 @@ int KMX_get_KeyVal_From_KeyCode(GdkKeymap *keymap, guint keycode, ShiftState ss, if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; + if (!(ensureValidInputForKeyboardTranslation( map_VKShiftState_to_LinModifier(ss), count, keycode))) + return 0; + //BASE (shiftstate: 0) if (( ss == Base ) && ( caps == 0 )) { GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); @@ -697,10 +710,7 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, gui if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - if (!(shift_state_pos <= count)) - return 0; - - if (!(keycode <= keycode_max)) + if (!(ensureValidInputForKeyboardTranslation( shift_state_pos, count, keycode))) return 0; kVal = (KMX_DWORD) KMX_get_KeyVal_From_KeyCode(keymap, keycode, (ShiftState) shift_state_pos, 0); @@ -722,10 +732,7 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, UIN if (!gdk_keymap_get_entries_for_keycode(keymap, kc_underlying, &maps, &keyvals, &count)) return 0; - if (!(map_VKShiftState_to_LinModifier(vk_ShiftState) <= count)) - return 0; - - if (!(kc_underlying <= keycode_max)) + if (!(ensureValidInputForKeyboardTranslation( map_VKShiftState_to_LinModifier(vk_ShiftState), count, kc_underlying))) return 0; KMX_DWORD keyV = KMX_get_KeyVal_From_KeyCode(keymap, kc_underlying, ShiftState(map_VKShiftState_to_LinModifier(vk_ShiftState)), 0); diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 2761e92066..3885428cdc 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -16,7 +16,6 @@ #include #include "u16.h" - enum ShiftState { Base = 0, // 0 Shft = 1, // 1 @@ -71,6 +70,9 @@ static KMX_DWORD deadkey_max = 0xfe93; // https://fossies.org/linux/tk/xlib/X1 // map Shiftstate to modifier (e.g. 0->0; 16-1; 9->2; 25->3) int map_VKShiftState_to_LinModifier(int VKShiftState); +// check if input is correct +bool ensureValidInputForKeyboardTranslation(int shift_state_pos, gint count, guint keycode); + // take a std::string (=contents of line symbols-file ) and returns the (int) value of the character KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 4da51e0123..5c9f94a940 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -62,7 +62,7 @@ bool DeadKey::KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter) { return false; } -int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int caps,GdkKeymap *keymap) { +int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int caps, GdkKeymap *keymap) { GdkKeymapKey *maps; guint *keyvals; gint count; @@ -70,10 +70,7 @@ int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - if (!(shift_state_pos <= count)) - return 0; - - if (!(keycode <= keycode_max)) + if (!(ensureValidInputForKeyboardTranslation( shift_state_pos, count, keycode))) return 0; KMX_DWORD keyVal= (KMX_DWORD) KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(shift_state_pos), caps); @@ -281,7 +278,8 @@ public: p = key->dpOutput = new KMX_WCHAR[4]; *p++ = UC_SENTINEL; *p++ = CODE_DEADKEY; - *p++ = KMX_DeadKeyMap(st[0], deadkeys, deadkeyBase, &KMX_FDeadkeys); // I4353 + // can convert since KMX_DeadKeyMap returns a small positive number + *p++ = (KMX_WCHAR) KMX_DeadKeyMap(st[0], deadkeys, deadkeyBase, &KMX_FDeadkeys); // I4353 *p = 0; } key++; @@ -468,7 +466,9 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap **ke kp->cxGroupArray++; gp = &kp->dpGroupArray[kp->cxGroupArray-1]; - + + // calculate the required size of `gp->dpKeyArray` + UINT nkeys = 0; for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { @@ -476,21 +476,21 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap **ke } } - - nDeadkey++; // ensure a 1-based index above the max deadkey value already in the keyboard - gp->fUsingKeys = TRUE; gp->dpMatch = NULL; gp->dpName = NULL; gp->dpNoMatch = NULL; gp->cxKeyArray = nkeys; gp->dpKeyArray = new KMX_KEY[gp->cxKeyArray]; - nkeys = 0; + + nDeadkey++; // ensure a 1-based index above the max deadkey value already in the keyboard + // // Fill in the new rules // + nkeys = 0; for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { if(rgKey[iKey]->KMX_LayoutRow(loader.KMX_MaxShiftState(), &gp->dpKeyArray[nkeys], &alDead, nDeadkey, bDeadkeyConversion, all_vector,*keymap)) { // I4552 @@ -597,7 +597,8 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap **ke KMX_WCHAR *p = kkp->dpContext = new KMX_WCHAR[8]; *p++ = UC_SENTINEL; *p++ = CODE_DEADKEY; - *p++ = KMX_DeadKeyMap(dk->KMX_DeadCharacter(), &alDead, nDeadkey, FDeadkeys); // I4353 + // can convert since KMX_DeadKeyMap returns a small positive number + *p++ = (KMX_WCHAR) KMX_DeadKeyMap(dk->KMX_DeadCharacter(), &alDead, nDeadkey, FDeadkeys); // I4353 // *p++ = nDeadkey+i; *p++ = UC_SENTINEL; *p++ = CODE_ANY; diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 282b44b1c6..6e5c83d672 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -22,6 +22,12 @@ 06 Feb 2015 - mcdurdin - I4552 - V9.0 - Add mnemonic recompile option to ignore deadkeys 08 Apr 2015 - mcdurdin - I4651 - V9.0 - Mnemonic layout recompiler maps AltGr+VK_BKSLASH rather than VK_OEM_102 */ +// +// m-to-p.cpp : Defines the entry point for the console application. +// +// Note: this program deliberately leaks memory as it has a very short life cycle and managing the memory allocations +// for the subcomponents of the compiled keyboard is an unnecessary optimisation. Just so you know. +// #include "mcompile.h" From ade07bb298c58436765736b1a02dce960db55eba Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 19 Jun 2024 12:18:54 +0200 Subject: [PATCH 251/327] feat(linux): move CODE__SIZE and #include <../../../../common/include/kmx_file.h> instead of double #include "kmx_file.h" --- linux/mcompile/keymap/kmx_file.h | 388 ---------------------- linux/mcompile/keymap/mc_import_rules.cpp | 29 -- linux/mcompile/keymap/mc_kmxfile.cpp | 98 ++++-- linux/mcompile/keymap/mc_kmxfile.h | 4 +- linux/mcompile/keymap/mcompile.h | 2 - 5 files changed, 66 insertions(+), 455 deletions(-) delete mode 100755 linux/mcompile/keymap/kmx_file.h diff --git a/linux/mcompile/keymap/kmx_file.h b/linux/mcompile/keymap/kmx_file.h deleted file mode 100755 index 29543b703e..0000000000 --- a/linux/mcompile/keymap/kmx_file.h +++ /dev/null @@ -1,388 +0,0 @@ -/* - Copyright: Copyright (C) 2003-2018 SIL International. - Authors: mcdurdin -*/ - -#pragma once -#ifndef KMX_FILE_H -#define KMX_FILE_H - -#define UNREFERENCED_PARAMETER(P) (P) -#define TRUNCATE ((size_t)-1) -#ifdef KMN_KBP -// TODO: move this to a common namespace keyman::common::kmx_file or similar in the future -namespace km { -namespace kbp { -namespace kmx { -#endif - -#define KMX_MAX_ALLOWED_FILE_SIZE (128 * 1024 * 1024) /* 128MB */ - -#define KEYMAN_LAYOUT_DEFAULT 0x000005FE - -#define KEYMANID_NONKEYMAN 0xFFFFFFFF -#define KEYMANID_IGNORE 0xFFFFFFFE -#define KEYMANID_INVALID 0xFFFFFFFD - -/* Shift flags for hotkeys (version 1.0) */ - -#define SHIFTFLAG 0x2000 -#define CTRLFLAG 0x4000 -#define ALTFLAG 0x8000 - -/* Miscellaneous flags and defines */ - -#define MAXGROUPS 128 - -/* File version identifiers */ - -#define VERSION_30 0x00000300 -#define VERSION_31 0x00000301 -#define VERSION_32 0x00000302 -#define VERSION_40 0x00000400 -#define VERSION_50 0x00000500 -#define VERSION_501 0x00000501 -#define VERSION_60 0x00000600 -#define VERSION_70 0x00000700 -#define VERSION_80 0x00000800 -#define VERSION_90 0x00000900 -#define VERSION_100 0x00000A00 -#define VERSION_140 0x00000E00 -#define VERSION_150 0x00000F00 - -#define VERSION_160 0x00001000 - -#define VERSION_MIN VERSION_50 -#define VERSION_MAX VERSION_160 - -// -// Backspace types -// - -#define BK_DEFAULT 0 -#define BK_DEADKEY 1 - -// Different begin types -#define BEGIN_ANSI 0 -#define BEGIN_UNICODE 1 -#define BEGIN_NEWCONTEXT 2 -#define BEGIN_POSTKEYSTROKE 3 - -#define TSS_NONE 0 -#define TSS_BITMAP 1 -#define TSS_COPYRIGHT 2 -#define TSS_HOTKEY 3 -#define TSS_LANGUAGE 4 -#define TSS_LAYOUT 5 -#define TSS_MESSAGE 6 -#define TSS_NAME 7 -#define TSS_VERSION 8 -#define TSS_CAPSONONLY 9 -#define TSS_CAPSALWAYSOFF 10 -#define TSS_SHIFTFREESCAPS 11 -#define TSS_LANGUAGENAME 12 - -#define TSS_CALLDEFINITION 13 -#define TSS_CALLDEFINITION_LOADFAILED 14 - -#define TSS_ETHNOLOGUECODE 15 - -#define TSS_DEBUG_LINE 16 - -#define TSS_MNEMONIC 17 - -#define TSS_INCLUDECODES 18 - -#define TSS_OLDCHARPOSMATCHING 19 - -#define TSS_COMPILEDVERSION 20 -#define TSS_KEYMANCOPYRIGHT 21 - -#define TSS_CUSTOMKEYMANEDITION 22 -#define TSS_CUSTOMKEYMANEDITIONNAME 23 - -/* Keyman 7.0 system stores */ - -#define TSS__KEYMAN_60_MAX 23 - -#define TSS_VISUALKEYBOARD 24 -#define TSS_KMW_RTL 25 -#define TSS_KMW_HELPFILE 26 -#define TSS_KMW_HELPTEXT 27 -#define TSS_KMW_EMBEDJS 28 - -#define TSS_WINDOWSLANGUAGES 29 - -#define TSS__KEYMAN_70_MAX 29 - -/* Keyman 8.0 system stores */ - -#define TSS_COMPARISON 30 - -#define TSS__KEYMAN_80_MAX 30 - -/* Keyman 9.0 system stores */ - -#define TSS_PLATFORM 31 -#define TSS_BASELAYOUT 32 -#define TSS_LAYER 33 - -#define TSS_PLATFORM_NOMATCH 0x8001 // Reserved for internal use - after platform statement is run, set to either TSS_PLATFORM_NOMATCH or TSS_PLATFORM_MATCH -#define TSS_PLATFORM_MATCH 0x8002 // Reserved for internal use - as the result will never change for the lifetime of the process. - -#define TSS_VKDICTIONARY 34 // Dictionary of virtual key names for v9 dynamic layouts -#define TSS_LAYOUTFILE 35 // Keyman 9 layer-based JSON OSK -#define TSS_KEYBOARDVERSION 36 // &keyboardversion system store // I4140 -#define TSS_KMW_EMBEDCSS 37 - -#define TSS_TARGETS 38 - -#define TSS__KEYMAN_90_MAX 38 - -/* Keyman 14.0 system stores */ - -#define TSS_CASEDKEYS 39 - -#define TSS__KEYMAN_140_MAX 39 - -/* Keyman 15.0 system stores */ - -#define TSS_BEGIN_NEWCONTEXT 40 -#define TSS_BEGIN_POSTKEYSTROKE 41 -#define TSS_NEWLAYER 42 -#define TSS_OLDLAYER 43 - -#define TSS__KEYMAN_150_MAX 43 - -#define TSS__MAX 43 - -/* wm_keyman_control_internal message control codes */ - -#define KMCI_SELECTKEYBOARD 3 // I3933 -#define KMCI_SELECTKEYBOARD_TSF 4 // I3933 -#define KMCI_GETACTIVEKEYBOARD 5 // I3933 -#define KMCI_SETFOREGROUND 6 // I3933 -#define KMCI_SELECTKEYBOARD_BACKGROUND 7 // I4271 -#define KMCI_SELECTKEYBOARD_BACKGROUND_TSF 8 // I4271 - -#define FILEID_COMPILED 0x5354584B - -#define SZMAX_LANGUAGENAME 80 -#define SZMAX_KEYBOARDNAME 80 -#define SZMAX_COPYRIGHT 256 -#define SZMAX_MESSAGE 1024 - -#define UC_SENTINEL 0xFFFF -#define UC_SENTINEL_EXTENDEDEND 0x10 // was ((CODE_LASTCODE)+1)... what was I thinking? - -#define U_UC_SENTINEL u"\uFFFF" - -/* - * VK__MAX defines the highest virtual key code defined in the system = 0xFF. Custom VK codes start at 256 - */ -#define VK__MAX 255 - -#define CODE_ANY 0x01 -#define CODE_INDEX 0x02 -#define CODE_CONTEXT 0x03 -#define CODE_NUL 0x04 -#define CODE_USE 0x05 -#define CODE_RETURN 0x06 -#define CODE_BEEP 0x07 -#define CODE_DEADKEY 0x08 -// 0x09 = bkspace.-- we don't need to keep this separate though with UC_SENTINEL -#define CODE_EXTENDED 0x0A -//#define CODE_EXTENDEDEND 0x0B deprecated -#define CODE_SWITCH 0x0C -#define CODE_KEY 0x0D -#define CODE_CLEARCONTEXT 0x0E -#define CODE_CALL 0x0F -// UC_SENTINEL_EXTENDEDEND 0x10 -#define CODE_CONTEXTEX 0x11 - -#define CODE_NOTANY 0x12 - -#define CODE_KEYMAN70_LASTCODE 0x12 - -#define CODE_SETOPT 0x13 -#define CODE_IFOPT 0x14 -#define CODE_SAVEOPT 0x15 -#define CODE_RESETOPT 0x16 - -#define CODE_KEYMAN80_LASTCODE 0x16 - -/* Keyman 9.0 codes */ - -#define CODE_IFSYSTEMSTORE 0x17 -#define CODE_SETSYSTEMSTORE 0x18 - -#define CODE_LASTCODE 0x18 - -#define U_CODE_ANY u"\u0001" -#define U_CODE_INDEX u"\u0002" -#define U_CODE_CONTEXT u"\u0003" -#define U_CODE_NUL u"\u0004" -#define U_CODE_USE u"\u0005" -#define U_CODE_RETURN u"\u0006" -#define U_CODE_BEEP u"\u0007" -#define U_CODE_DEADKEY u"\u0008" -#define U_CODE_EXTENDED u"\u000A" -#define U_CODE_SWITCH u"\u000C" -#define U_CODE_CLEARCONTEXT u"\u000E" -#define U_CODE_CALL u"\u000F" -#define U_CODE_EXTENDEDEND u"\u0010" -#define U_CODE_CONTEXTEX u"\u0011" -#define U_CODE_NOTANY u"\u0012" -#define U_CODE_SETOPT u"\u0013" -#define U_CODE_IFOPT u"\u0014" -#define U_CODE_SAVEOPT u"\u0015" -#define U_CODE_RESETOPT u"\u0016" -#define U_CODE_IFSYSTEMSTORE u"\u0017" -#define U_CODE_SETSYSTEMSTORE u"\u0018" - -#define C_CODE_ANY(store) U_UC_SENTINEL U_CODE_ANY store -#define C_CODE_INDEX(val1, val2) U_UC_SENTINEL U_CODE_INDEX val1 val2 -#define C_CODE_CONTEXT() U_UC_SENTINEL U_CODE_CONTEXT -#define C_CODE_NUL() U_UC_SENTINEL U_CODE_NUL -#define C_CODE_USE(val) U_UC_SENTINEL U_CODE_USE val -#define C_CODE_RETURN() U_UC_SENTINEL U_CODE_RETURN -#define C_CODE_BEEP() U_UC_SENTINEL U_CODE_BEEP -#define C_CODE_DEADKEY(deadkey) U_UC_SENTINEL U_CODE_DEADKEY deadkey -#define C_CODE_EXTENDED(varargs) U_UC_SENTINEL U_CODE_EXTENDED varargs -#define C_CODE_SWITCH(val) U_UC_SENTINEL U_CODE_SWITCH val -#define C_CODE_CLEARCONTEXT() U_UC_SENTINEL U_CODE_CLEARCONTEXT -#define C_CODE_CALL(val) U_UC_SENTINEL U_CODE_CALL val -#define C_CODE_CONTEXTEX(val) U_UC_SENTINEL U_CODE_CONTEXTEX val -#define C_CODE_NOTANY(val) U_UC_SENTINEL U_CODE_NOTANY val -#define C_CODE_SETOPT(val1, val2) U_UC_SENTINEL U_CODE_SETOPT val1 val2 -#define C_CODE_IFOPT(opt, val1, val2) U_UC_SENTINEL U_CODE_IFOPT opt val1 val2 -#define C_CODE_SAVEOPT(opt) U_UC_SENTINEL U_CODE_SAVEOPT opt -#define C_CODE_RESETOPT(opt) U_UC_SENTINEL U_CODE_RESETOPT opt -#define C_CODE_IFSYSTEMSTORE(store, val1, val2) U_UC_SENTINEL U_CODE_IFSYSTEMSTORE store val1 val2 -#define C_CODE_SETSYSTEMSTORE(store, val) U_UC_SENTINEL U_CODE_SETSYSTEMSTORE store val - -#define KF_SHIFTFREESCAPS 0x0001 -#define KF_CAPSONONLY 0x0002 -#define KF_CAPSALWAYSOFF 0x0004 -#define KF_LOGICALLAYOUT 0x0008 -#define KF_AUTOMATICVERSION 0x0010 - -// 16.0: Support for LDML Keyboards in KMXPlus file format -#define KF_KMXPLUS 0x0020 - -#define HK_ALT 0x00010000 -#define HK_CTRL 0x00020000 -#define HK_SHIFT 0x00040000 - -#define LCTRLFLAG 0x0001 // Left Control flag -#define RCTRLFLAG 0x0002 // Right Control flag -#define LALTFLAG 0x0004 // Left Alt flag -#define RALTFLAG 0x0008 // Right Alt flag -#define K_SHIFTFLAG 0x0010 // Either shift flag -#define K_CTRLFLAG 0x0020 // Either ctrl flag -#define K_ALTFLAG 0x0040 // Either alt flag -//#define K_METAFLAG 0x0080 // Either Meta-key flag (tentative). Not usable in keyboard rules; - // Used internally (currently, only by KMW) to ensure Meta-key - // shortcuts safely bypass rules - // Meta key = Command key on macOS, Windows key on Windows -#define CAPITALFLAG 0x0100 // Caps lock on -#define NOTCAPITALFLAG 0x0200 // Caps lock NOT on -#define NUMLOCKFLAG 0x0400 // Num lock on -#define NOTNUMLOCKFLAG 0x0800 // Num lock NOT on -#define SCROLLFLAG 0x1000 // Scroll lock on -#define NOTSCROLLFLAG 0x2000 // Scroll lock NOT on -#define ISVIRTUALKEY 0x4000 // It is a Virtual Key Sequence -#define VIRTUALCHARKEY 0x8000 // Keyman 6.0: Virtual Key Cap Sequence NOT YET - -#define K_MODIFIERFLAG 0x007F -#define K_NOTMODIFIERFLAG 0xFF00 // I4548 - -struct KMX_COMP_STORE { - KMX_DWORD dwSystemID; - KMX_DWORD dpName; - KMX_DWORD dpString; - }; - -struct KMX_COMP_KEY { - KMX_WORD Key; - KMX_WORD _reserved; - KMX_DWORD Line; - KMX_DWORD ShiftFlags; - KMX_DWORD dpOutput; - KMX_DWORD dpContext; - }; - - -struct KMX_COMP_GROUP { - KMX_DWORD dpName; - KMX_DWORD dpKeyArray; // [LPKEY] address of first item in key array - KMX_DWORD dpMatch; - KMX_DWORD dpNoMatch; - KMX_DWORD cxKeyArray; // in array entries - KMX_BOOL fUsingKeys; // group(xx) [using keys] <-- specified or not - }; - -struct KMX_COMP_KEYBOARD { - KMX_DWORD dwIdentifier; // 0000 Keyman compiled keyboard id - - KMX_DWORD dwFileVersion; // 0004 Version of the file - Keyman 4.0 is 0x0400 - - KMX_DWORD dwCheckSum; // 0008 As stored in keyboard. DEPRECATED as of 16.0 - KMX_DWORD KeyboardID; // 000C as stored in HKEY_LOCAL_MACHINE//system//currentcontrolset//control//keyboard layouts - KMX_DWORD IsRegistered; // 0010 - KMX_DWORD version; // 0014 keyboard version - - KMX_DWORD cxStoreArray; // 0018 in array entries - KMX_DWORD cxGroupArray; // 001C in array entries - - KMX_DWORD dpStoreArray; // 0020 [LPSTORE] address of first item in store array - KMX_DWORD dpGroupArray; // 0024 [LPGROUP] address of first item in group array - - KMX_DWORD StartGroup[2]; // 0028 index of starting groups [2 of them] - - KMX_DWORD dwFlags; // 0030 Flags for the keyboard file - - KMX_DWORD dwHotKey; // 0034 standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) - - KMX_DWORD dpBitmapOffset; // 0038 offset of the bitmaps in the file - KMX_DWORD dwBitmapSize; // 003C size in bytes of the bitmaps -}; - -struct KMX_COMP_KEYBOARD_KMXPLUSINFO { - KMX_DWORD dpKMXPlus; // 0040 offset of KMXPlus data, header is first - KMX_DWORD dwKMXPlusSize; // 0044 size in bytes of entire KMXPlus data -}; - -/** - * Only valid if comp_keyboard.dwFlags&KF_KMXPLUS - */ -struct KMX_COMP_KEYBOARD_EX { - KMX_COMP_KEYBOARD header; // 0000 see COMP_KEYBOARD - KMX_COMP_KEYBOARD_KMXPLUSINFO kmxplus; // 0040 see COMP_KEYBOARD_EXTRA -}; - -typedef KMX_COMP_KEYBOARD *PKMX_COMP_KEYBOARD; -typedef KMX_COMP_STORE *PKMX_COMP_STORE; -typedef KMX_COMP_KEY *PKMX_COMP_KEY; -typedef KMX_COMP_GROUP *PKMX_COMP_GROUP; - - -extern const int CODE__SIZE[]; -#define CODE__SIZE_MAX 5 - -#define KEYBOARDFILEHEADER_SIZE 64 -#define KEYBOARDFILESTORE_SIZE 12 -#define KEYBOARDFILEGROUP_SIZE 24 -#define KEYBOARDFILEKEY_SIZE 20 - -static_assert(sizeof(KMX_COMP_STORE) == KEYBOARDFILESTORE_SIZE, "COMP_STORE must be KEYBOARDFILESTORE_SIZE bytes"); -static_assert(sizeof(KMX_COMP_KEY) == KEYBOARDFILEKEY_SIZE, "COMP_KEY must be KEYBOARDFILEKEY_SIZE bytes"); -static_assert(sizeof(KMX_COMP_GROUP) == KEYBOARDFILEGROUP_SIZE, "COMP_GROUP must be KEYBOARDFILEGROUP_SIZE bytes"); -static_assert(sizeof(KMX_COMP_KEYBOARD) == KEYBOARDFILEHEADER_SIZE, "COMP_KEYBOARD must be KEYBOARDFILEHEADER_SIZE bytes"); - -#ifdef KMN_KBP -} // namespace kmx -} // namespace kbp -} // namespace km -#endif -#endif /*KMX_FILE_H*/ diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 5c9f94a940..32bb7cd245 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -22,7 +22,6 @@ #include #include #include -//#include "km_types.h" #include "mc_kmxfile.h" #include "keymap.h" @@ -617,31 +616,3 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap **ke return true; } - -const int CODE__SIZE[] = { - -1, // undefined 0x00 - 1, // CODE_ANY 0x01 - 2, // CODE_INDEX 0x02 - 0, // CODE_CONTEXT 0x03 - 0, // CODE_NUL 0x04 - 1, // CODE_USE 0x05 - 0, // CODE_RETURN 0x06 - 0, // CODE_BEEP 0x07 - 1, // CODE_DEADKEY 0x08 - -1, // unused 0x09 - 2, // CODE_EXTENDED 0x0A - -1, // CODE_EXTENDEDEND 0x0B (unused) - 1, // CODE_SWITCH 0x0C - -1, // CODE_KEY 0x0D (never used) - 0, // CODE_CLEARCONTEXT 0x0E - 1, // CODE_CALL 0x0F - -1, // UC_SENTINEL_EXTENDEDEND 0x10 (not valid with UC_SENTINEL) - 1, // CODE_CONTEXTEX 0x11 - 1, // CODE_NOTANY 0x12 - 2, // CODE_SETOPT 0x13 - 3, // CODE_IFOPT 0x14 - 1, // CODE_SAVEOPT 0x15 - 1, // CODE_RESETOPT 0x16 - 3, // CODE_IFSYSTEMSTORE 0x17 - 2 // CODE_SETSYSTEMSTORE 0x18 -}; diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index a96a01a022..4c90ef61bb 100755 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -6,6 +6,34 @@ #define CERR_UnableToWriteFully 0x00008007 #define CERR_SomewhereIGotItWrong 0x00008009 +const int CODE__SIZE[] = { + -1, // undefined 0x00 + 1, // CODE_ANY 0x01 + 2, // CODE_INDEX 0x02 + 0, // CODE_CONTEXT 0x03 + 0, // CODE_NUL 0x04 + 1, // CODE_USE 0x05 + 0, // CODE_RETURN 0x06 + 0, // CODE_BEEP 0x07 + 1, // CODE_DEADKEY 0x08 + -1, // unused 0x09 + 2, // CODE_EXTENDED 0x0A + -1, // CODE_EXTENDEDEND 0x0B (unused) + 1, // CODE_SWITCH 0x0C + -1, // CODE_KEY 0x0D (never used) + 0, // CODE_CLEARCONTEXT 0x0E + 1, // CODE_CALL 0x0F + -1, // UC_SENTINEL_EXTENDEDEND 0x10 (not valid with UC_SENTINEL) + 1, // CODE_CONTEXTEX 0x11 + 1, // CODE_NOTANY 0x12 + 2, // CODE_SETOPT 0x13 + 3, // CODE_IFOPT 0x14 + 1, // CODE_SAVEOPT 0x15 + 1, // CODE_RESETOPT 0x16 + 3, // CODE_IFSYSTEMSTORE 0x17 + 2 // CODE_SETSYSTEMSTORE 0x18 +}; + KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz); LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); @@ -43,18 +71,18 @@ KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX LPKMX_STORE fsp; LPKMX_KEY fkp; - PKMX_COMP_KEYBOARD ck; - PKMX_COMP_GROUP gp; - PKMX_COMP_STORE sp; - PKMX_COMP_KEY kp; + PCOMP_KEYBOARD ck; + PCOMP_GROUP gp; + PCOMP_STORE sp; + PCOMP_KEY kp; PKMX_BYTE buf; KMX_DWORD size, offset; DWORD i, j; // Calculate how much memory to allocate - size = sizeof(KMX_COMP_KEYBOARD) + - fk->cxGroupArray * sizeof(KMX_COMP_GROUP) + - fk->cxStoreArray * sizeof(KMX_COMP_STORE) + + size = sizeof(COMP_KEYBOARD) + + fk->cxGroupArray * sizeof(COMP_GROUP) + + fk->cxStoreArray * sizeof(COMP_STORE) + //wcslen(fk->szName)*2 + 2 + //wcslen(fk->szCopyright)*2 + 2 + //wcslen(fk->szLanguageName)*2 + 2 + @@ -64,7 +92,7 @@ KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX for(i = 0, fgp = fk->dpGroupArray; i < fk->cxGroupArray; i++, fgp++) { if(fgp->dpName) size += u16len(fgp->dpName)*2 + 2; - size += fgp->cxKeyArray * sizeof(KMX_COMP_KEY); + size += fgp->cxKeyArray * sizeof(COMP_KEY); for(j = 0, fkp = fgp->dpKeyArray; j < fgp->cxKeyArray; j++, fkp++) { size += u16len(fkp->dpOutput)*2 + 2; size += u16len(fkp->dpContext)*2 + 2; @@ -85,7 +113,7 @@ KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX if(!buf) return CERR_CannotAllocateMemory; memset(buf, 0, size); - ck = (PKMX_COMP_KEYBOARD) buf; + ck = (PCOMP_KEYBOARD) buf; ck->dwIdentifier = FILEID_COMPILED; @@ -101,12 +129,12 @@ KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX ck->dwFlags = fk->dwFlags; - offset = sizeof(KMX_COMP_KEYBOARD); + offset = sizeof(COMP_KEYBOARD); ck->dpStoreArray = offset; - sp = (PKMX_COMP_STORE)(buf+offset); + sp = (PCOMP_STORE)(buf+offset); fsp = fk->dpStoreArray; - offset += sizeof(KMX_COMP_STORE) * ck->cxStoreArray; + offset += sizeof(COMP_STORE) * ck->cxStoreArray; for(i = 0; i < ck->cxStoreArray; i++, sp++, fsp++) { sp->dwSystemID = fsp->dwSystemID; sp->dpString = offset; @@ -123,10 +151,10 @@ KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX } ck->dpGroupArray = offset; - gp = (PKMX_COMP_GROUP)(buf+offset); + gp = (PCOMP_GROUP)(buf+offset); fgp = fk->dpGroupArray; - offset += sizeof(KMX_COMP_GROUP) * ck->cxGroupArray; + offset += sizeof(COMP_GROUP) * ck->cxGroupArray; for(i = 0; i < ck->cxGroupArray; i++, gp++, fgp++) { gp->cxKeyArray = fgp->cxKeyArray; @@ -154,9 +182,9 @@ KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX } gp->dpKeyArray = offset; - kp = (PKMX_COMP_KEY) (buf + offset); + kp = (PCOMP_KEY) (buf + offset); fkp = fgp->dpKeyArray; - offset += gp->cxKeyArray * sizeof(KMX_COMP_KEY); + offset += gp->cxKeyArray * sizeof(COMP_KEY); for(j = 0; j < gp->cxKeyArray; j++, kp++, fkp++) { kp->Key = fkp->Key; kp->Line = fkp->Line; @@ -207,8 +235,8 @@ PKMX_WCHAR KMX_StringOffset(PKMX_BYTE base, KMX_DWORD offset) { we don't copy the strings This method is used on 64-bit architectures. */ -LPKMX_KEYBOARD KMX_CopyKeyboard(PKMX_BYTE bufp, PKMX_BYTE base) { - PKMX_COMP_KEYBOARD ckbp = (PKMX_COMP_KEYBOARD) base; +LPKMX_KEYBOARD CopyKeyboard(PKMX_BYTE bufp, PKMX_BYTE base) { + PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD) base; /* Copy keyboard structure */ @@ -234,12 +262,12 @@ LPKMX_KEYBOARD KMX_CopyKeyboard(PKMX_BYTE bufp, PKMX_BYTE base) { kbp->dpGroupArray = (LPKMX_GROUP) bufp; bufp += sizeof(KMX_GROUP) * kbp->cxGroupArray; - PKMX_COMP_STORE csp; + PCOMP_STORE csp; LPKMX_STORE sp; KMX_DWORD i; for( - csp = (PKMX_COMP_STORE)(base + ckbp->dpStoreArray), sp = kbp->dpStoreArray, i = 0; + csp = (PCOMP_STORE)(base + ckbp->dpStoreArray), sp = kbp->dpStoreArray, i = 0; i < kbp->cxStoreArray; i++, sp++, csp++) { @@ -248,11 +276,11 @@ LPKMX_KEYBOARD KMX_CopyKeyboard(PKMX_BYTE bufp, PKMX_BYTE base) { sp->dpString = KMX_StringOffset(base, csp->dpString); } - PKMX_COMP_GROUP cgp; + PCOMP_GROUP cgp; LPKMX_GROUP gp; for( - cgp = (PKMX_COMP_GROUP)(base + ckbp->dpGroupArray), gp = kbp->dpGroupArray, i = 0; + cgp = (PCOMP_GROUP)(base + ckbp->dpGroupArray), gp = kbp->dpGroupArray, i = 0; i < kbp->cxGroupArray; i++, gp++, cgp++) { @@ -264,12 +292,12 @@ LPKMX_KEYBOARD KMX_CopyKeyboard(PKMX_BYTE bufp, PKMX_BYTE base) { gp->dpNoMatch = KMX_StringOffset(base, cgp->dpNoMatch); gp->fUsingKeys = cgp->fUsingKeys; - PKMX_COMP_KEY ckp; + PCOMP_KEY ckp; LPKMX_KEY kp; KMX_DWORD j; for( - ckp = (PKMX_COMP_KEY)(base + cgp->dpKeyArray), kp = gp->dpKeyArray, j = 0; + ckp = (PCOMP_KEY)(base + cgp->dpKeyArray), kp = gp->dpKeyArray, j = 0; j < gp->cxKeyArray; j++, kp++, ckp++) { @@ -293,10 +321,10 @@ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFil UNREFERENCED_PARAMETER(dwFileSize); KMX_DWORD i, j; - PKMX_COMP_KEYBOARD ckbp = (PKMX_COMP_KEYBOARD) base; - PKMX_COMP_GROUP cgp; - PKMX_COMP_STORE csp; - PKMX_COMP_KEY ckp; + PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD) base; + PCOMP_GROUP cgp; + PCOMP_STORE csp; + PCOMP_KEY ckp; LPKMX_KEYBOARD kbp = (LPKMX_KEYBOARD) bufp; LPKMX_STORE sp; LPKMX_GROUP gp; @@ -305,18 +333,18 @@ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFil kbp->dpStoreArray = (LPKMX_STORE) (base + ckbp->dpStoreArray); kbp->dpGroupArray = (LPKMX_GROUP) (base + ckbp->dpGroupArray); - for(sp = kbp->dpStoreArray, csp = (PKMX_COMP_STORE) sp, i = 0; i < kbp->cxStoreArray; i++, sp++, csp++) { + for(sp = kbp->dpStoreArray, csp = (PCOMP_STORE) sp, i = 0; i < kbp->cxStoreArray; i++, sp++, csp++) { sp->dpName = KMX_StringOffset(base, csp->dpName); sp->dpString = KMX_StringOffset(base, csp->dpString); } - for(gp = kbp->dpGroupArray, cgp = (PKMX_COMP_GROUP) gp, i = 0; i < kbp->cxGroupArray; i++, gp++, cgp++) { + for(gp = kbp->dpGroupArray, cgp = (PCOMP_GROUP) gp, i = 0; i < kbp->cxGroupArray; i++, gp++, cgp++) { gp->dpName = KMX_StringOffset(base, cgp->dpName); gp->dpKeyArray = (LPKMX_KEY) (base + cgp->dpKeyArray); if(cgp->dpMatch != NULL) gp->dpMatch = (PKMX_WCHAR) (base + cgp->dpMatch); if(cgp->dpNoMatch != NULL) gp->dpNoMatch = (PKMX_WCHAR) (base + cgp->dpNoMatch); - for(kp = gp->dpKeyArray, ckp = (PKMX_COMP_KEY) kp, j = 0; j < gp->cxKeyArray; j++, kp++, ckp++) { + for(kp = gp->dpKeyArray, ckp = (PCOMP_KEY) kp, j = 0; j < gp->cxKeyArray; j++, kp++, ckp++) { kp->dpOutput = (PKMX_WCHAR) (base + ckp->dpOutput); kp->dpContext = (PKMX_WCHAR) (base + ckp->dpContext); } @@ -409,7 +437,7 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { } #ifdef KMX_64BIT - kbp = KMX_CopyKeyboard(buf, filebase); + kbp = CopyKeyboard(buf, filebase); #else kbp = KMX_FixupKeyboard(buf, filebase, sz); #endif @@ -431,14 +459,14 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz){ KMX_DWORD i; - PKMX_COMP_KEYBOARD ckbp = (PKMX_COMP_KEYBOARD)filebase; - PKMX_COMP_STORE csp; + PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD)filebase; + PCOMP_STORE csp; // Check file version // if (ckbp->dwFileVersion < VERSION_MIN || ckbp->dwFileVersion > VERSION_MAX) { // Old or new version -- identify the desired program version // - for (csp = (PKMX_COMP_STORE)(filebase + ckbp->dpStoreArray), i = 0; i < ckbp->cxStoreArray; i++, csp++) { + for (csp = (PCOMP_STORE)(filebase + ckbp->dpStoreArray), i = 0; i < ckbp->cxStoreArray; i++, csp++) { if (csp->dwSystemID == TSS_COMPILEDVERSION) { if (csp->dpString == 0) { KMX_LogError(L"errWrongFileVersion:NULL"); diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 461fba4353..b68b5e4707 100755 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -3,7 +3,7 @@ #define MC_KMXFILE_H #include "km_types.h" -#include "kmx_file.h" +#include <../../../../common/include/kmx_file.h> #include "filesystem.h" #include "mcompile.h" @@ -76,6 +76,8 @@ KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, PKMX_WCHAR filename); KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL FSaveDebug); +PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); + #endif // _KMXFILE_H #endif /*MC_KMXFILE_H*/ diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index e000cf3461..0812604b3d 100755 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -34,8 +34,6 @@ extern std::vector KMX_FDeadkeys; // I4353 int run(int argc, std::vector str_argv, char* argv[]); -PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); - int KMX_GetDeadkeys(vec_dword_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap); void KMX_LogError(const wchar_t* fmt, ...); From e0bd714f5f2ce7328a984959fb0a058e02101107 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 19 Jun 2024 15:33:17 +0200 Subject: [PATCH 252/327] feat(linux): edit nit picks --- linux/mcompile/keymap/deadkey.cpp | 41 +++++++++++++++---------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 52eaf21f63..56feb1d136 100755 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -9,7 +9,7 @@ std::vector create_deadkeys_by_basechar() { for (int i = 0; i < (int)dk_ComposeTable.size() - 1; i++) { DeadKey *dk2 = new DeadKey(dk_ComposeTable[i][0]); - for (int j = 0; j < (int)dk_ComposeTable.size(); j++) { + for (int j = i; j < (int)dk_ComposeTable.size(); j++) { if ((dk_ComposeTable[i][0] == dk_ComposeTable[j][0]) && (IsKeymanUsedChar(dk_ComposeTable[j][1]))) dk2->KMX_AddDeadKeyRow(dk_ComposeTable[j][1], dk_ComposeTable[j][2]); } @@ -18,22 +18,21 @@ std::vector create_deadkeys_by_basechar() { return alDead; } -void refine_alDead(KMX_WCHAR dk, std::vector &dkVec, std::vector &r_All_Vec) { +void refine_alDead(KMX_WCHAR dk, std::vector& dkVec, std::vector& r_All_Vec) { if (dk == 0) return; - for (int j = 0; j < (int)r_All_Vec.size() - 1; j++) { - if (dk == (r_All_Vec)[j]->KMX_GetDeadCharacter()) { + for (int j = 0; j < (int) r_All_Vec.size(); j++) { + if (dk == r_All_Vec[j]->KMX_GetDeadCharacter()) { if (!found_dk_inVector(dk, dkVec)) { - dkVec.push_back((r_All_Vec)[j]); - return; - } else - return; + dkVec.push_back(r_All_Vec[j]); + } + return; } } } -bool found_dk_inVector(KMX_WCHAR dk, std::vector &dkVec) { +bool found_dk_inVector(KMX_WCHAR dk, std::vector& dkVec) { for (int i = 0; i < dkVec.size(); i++) { if (dk == dkVec[i]->KMX_GetDeadCharacter()) return true; @@ -41,16 +40,16 @@ bool found_dk_inVector(KMX_WCHAR dk, std::vector &dkVec) { return false; } -bool query_dk_combinations_for_specific_dk(vec_dword_2D &p_dk_ComposeTable, KMX_DWORD dk, vec_dword_2D &dk_SingleTable) { - vec_dword_1D line; +bool query_dk_combinations_for_specific_dk(vec_dword_2D& r_dk_ComposeTable, KMX_DWORD dk, vec_dword_2D& dk_SingleTable) { + vec_dword_1D row; - for (int i = 0; i < (int)(p_dk_ComposeTable).size(); i++) { - if (((p_dk_ComposeTable)[i][0] == dk) && (IsKeymanUsedChar((p_dk_ComposeTable)[i][1]))) { - line.push_back((p_dk_ComposeTable)[i][0]); - line.push_back((p_dk_ComposeTable)[i][1]); - line.push_back((p_dk_ComposeTable)[i][2]); - dk_SingleTable.push_back(line); - line.clear(); + for (int i = 0; i < (int)r_dk_ComposeTable.size(); i++) { + if (r_dk_ComposeTable[i][0] == dk && IsKeymanUsedChar(r_dk_ComposeTable[i][1])) { + row.push_back(r_dk_ComposeTable[i][0]); + row.push_back(r_dk_ComposeTable[i][1]); + row.push_back(r_dk_ComposeTable[i][2]); + dk_SingleTable.push_back(row); + row.clear(); } } @@ -60,7 +59,7 @@ bool query_dk_combinations_for_specific_dk(vec_dword_2D &p_dk_ComposeTable, KMX_ return false; } -KMX_DWORD KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD &shift, GdkKeymap *keymap) { +KMX_DWORD KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD& shift, GdkKeymap* keymap) { guint keyval = (guint)kVal; GdkKeymapKey *keys; gint n_keys; @@ -78,7 +77,7 @@ KMX_DWORD KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD &shift, GdkKey return capitalKeyval; } -void add_deadkey_combination(vec_dword_2D &dk_ComposeTable, std::string diacritic_name, std::string base_char, KMX_DWORD unicode_value) { +void add_deadkey_combination(vec_dword_2D& dk_ComposeTable, std::string diacritic_name, std::string base_char, KMX_DWORD unicode_value) { vec_dword_1D line; line.push_back(convertNamesTo_DWORD_Value(diacritic_name)); line.push_back(convertNamesTo_DWORD_Value(base_char)); @@ -86,7 +85,7 @@ void add_deadkey_combination(vec_dword_2D &dk_ComposeTable, std::string diacriti dk_ComposeTable.push_back(line); } -void create_DKTable(vec_dword_2D &dk_ComposeTable) { +void create_DKTable(vec_dword_2D& dk_ComposeTable) { // create a 2D-Vector which contains data for ALL existing deadkey combinations on a Linux Keyboard: // dk_ComposeTable[i][0] : diacritic_name (e.g. dead_circumflex) // dk_ComposeTable[i][1] : base_char (e.g. a) From 9da9c8b8b776cc30f2659c87c0b9b3865d00972f Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 20 Jun 2024 09:35:01 +0200 Subject: [PATCH 253/327] feat(linux): change .clang-format --- .clang-format | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.clang-format b/.clang-format index 76e36e1d44..dc3c220bbc 100644 --- a/.clang-format +++ b/.clang-format @@ -9,7 +9,7 @@ AlignConsecutiveDeclarations: false AlignEscapedNewlines: Left AlignOperands: true AlignTrailingComments: true -AllowAllArgumentsOnNextLine: true +AllowAllArgumentsOnNextLine: trues AllowAllConstructorInitializersOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: false AllowShortBlocksOnASingleLine: Never @@ -19,7 +19,7 @@ AllowShortLambdasOnASingleLine: All AllowShortIfStatementsOnASingleLine: Never AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: AllDefinitions +AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: true AlwaysBreakTemplateDeclarations: MultiLine BinPackArguments: true @@ -58,7 +58,7 @@ ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 Cpp11BracedListStyle: true DeriveLineEnding: true -DerivePointerAlignment: true +DerivePointerAlignment: false DisableFormat: false ExperimentalAutoDetectBinPacking: false FixNamespaceComments: true @@ -134,4 +134,3 @@ TabWidth: 8 UseCRLF: false UseTab: Never ... - From 404d888fde5f3d421c26bcedd27cb75a4d9b78a8 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 20 Jun 2024 17:44:21 +0200 Subject: [PATCH 254/327] feat(linux): work on 2nd round of comments on PR 11816 --- .clang-format | 2 +- linux/mcompile/keymap/keymap.cpp | 15 +- linux/mcompile/keymap/mc_import_rules.cpp | 334 ++++++++++------------ linux/mcompile/keymap/mc_kmxfile.h | 2 +- linux/mcompile/keymap/mcompile.cpp | 3 +- linux/mcompile/keymap/meson.build | 9 +- 6 files changed, 175 insertions(+), 190 deletions(-) diff --git a/.clang-format b/.clang-format index dc3c220bbc..50df9fee12 100644 --- a/.clang-format +++ b/.clang-format @@ -9,7 +9,7 @@ AlignConsecutiveDeclarations: false AlignEscapedNewlines: Left AlignOperands: true AlignTrailingComments: true -AllowAllArgumentsOnNextLine: trues +AllowAllArgumentsOnNextLine: true AllowAllConstructorInitializersOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: false AllowShortBlocksOnASingleLine: Never diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 024f06a1d9..9eeef45f35 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -621,8 +621,11 @@ int KMX_get_KeyVal_From_KeyCode(GdkKeymap *keymap, guint keycode, ShiftState ss, if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation( map_VKShiftState_to_LinModifier(ss), count, keycode))) + if (!(ensureValidInputForKeyboardTranslation( map_VKShiftState_to_LinModifier(ss), count, keycode))){ + g_free(keyvals); + g_free(maps); return 0; + } //BASE (shiftstate: 0) if (( ss == Base ) && ( caps == 0 )) { @@ -710,8 +713,11 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, gui if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation( shift_state_pos, count, keycode))) + if (!(ensureValidInputForKeyboardTranslation( shift_state_pos, count, keycode))){ + g_free(keyvals); + g_free(maps); return 0; + } kVal = (KMX_DWORD) KMX_get_KeyVal_From_KeyCode(keymap, keycode, (ShiftState) shift_state_pos, 0); @@ -732,8 +738,11 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, UIN if (!gdk_keymap_get_entries_for_keycode(keymap, kc_underlying, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation( map_VKShiftState_to_LinModifier(vk_ShiftState), count, kc_underlying))) + if (!(ensureValidInputForKeyboardTranslation( map_VKShiftState_to_LinModifier(vk_ShiftState), count, kc_underlying))){ + g_free(keyvals); + g_free(maps); return 0; + } KMX_DWORD keyV = KMX_get_KeyVal_From_KeyCode(keymap, kc_underlying, ShiftState(map_VKShiftState_to_LinModifier(vk_ShiftState)), 0); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 32bb7cd245..2a966bfcca 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -26,17 +26,16 @@ #include "keymap.h" const int KMX_ShiftStateMap[] = { - ISVIRTUALKEY, - ISVIRTUALKEY | K_SHIFTFLAG, - ISVIRTUALKEY | K_CTRLFLAG, - ISVIRTUALKEY | K_SHIFTFLAG | K_CTRLFLAG, - 0, - 0, - ISVIRTUALKEY | RALTFLAG, - ISVIRTUALKEY | RALTFLAG | K_SHIFTFLAG, - 0, - 0 -}; + ISVIRTUALKEY, + ISVIRTUALKEY | K_SHIFTFLAG, + ISVIRTUALKEY | K_CTRLFLAG, + ISVIRTUALKEY | K_SHIFTFLAG | K_CTRLFLAG, + 0, + 0, + ISVIRTUALKEY | RALTFLAG, + ISVIRTUALKEY | RALTFLAG | K_SHIFTFLAG, + 0, + 0}; DeadKey::DeadKey(KMX_WCHAR deadCharacter) { this->m_deadchar = deadCharacter; @@ -53,51 +52,54 @@ void DeadKey::KMX_AddDeadKeyRow(KMX_WCHAR baseCharacter, KMX_WCHAR combinedChara bool DeadKey::KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter) { std::vector::iterator it; - for(it=this->m_rgbasechar.begin(); itm_rgbasechar.begin(); it < m_rgbasechar.end(); it++) { + if (*it == baseCharacter) { return true; } } return false; } -int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int caps, GdkKeymap *keymap) { - GdkKeymapKey *maps; - guint *keyvals; +int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int caps, GdkKeymap* keymap) { + GdkKeymapKey* maps; + guint* keyvals; gint count; + if (u16len(pwszBuff) < 1) + return 0; + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation( shift_state_pos, count, keycode))) + if (!(ensureValidInputForKeyboardTranslation(shift_state_pos, count, keycode))) return 0; - KMX_DWORD keyVal= (KMX_DWORD) KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(shift_state_pos), caps); + KMX_DWORD keyVal = (KMX_DWORD)KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(shift_state_pos), caps); std::u16string str = convert_DeadkeyValues_To_U16str(keyVal); - pwszBuff[0]= * (PKMX_WCHAR) str.c_str(); - + pwszBuff[0] = *(PKMX_WCHAR)str.c_str(); g_free(keyvals); g_free(maps); - if((keyVal >= deadkey_min) && (keyVal <= deadkey_max)) // deadkeys + + if ((keyVal >= deadkey_min) && (keyVal <= deadkey_max)) // deadkeys return -1; - else if(gdk_keyval_to_unicode(keyVal) == 0) // NO UNICODE + else if (gdk_keyval_to_unicode(keyVal) == 0) // NO UNICODE return 0; - else // usable char + else // usable char return 1; } -int KMX_DeadKeyMap(int index, std::vector *deadkeys, int deadkeyBase, std::vector *deadkeyMappings) { // I4327 // I4353 - for(size_t i = 0; i < deadkeyMappings->size(); i++) { - if((*deadkeyMappings)[i].deadkey == index) { +KMX_WCHAR KMX_DeadKeyMap( int index, std::vector* deadkeys, int deadkeyBase, std::vector* deadkeyMappings) { // I4327 // I4353 + for (size_t i = 0; i < deadkeyMappings->size(); i++) { + if ((*deadkeyMappings)[i].deadkey == index) { return (*deadkeyMappings)[i].dkid; } } - for(size_t i = 0; i < deadkeys->size(); i++) { - if((*deadkeys)[i]->KMX_DeadCharacter() == index) { - return deadkeyBase + i; + for (size_t i = 0; i < deadkeys->size(); i++) { + if ((*deadkeys)[i]->KMX_DeadCharacter() == index) { + return (KMX_WCHAR) (deadkeyBase + i); } } return 0xFFFF; @@ -111,11 +113,10 @@ private: std::u16string m_rgss[10][2]; public: - KMX_VirtualKey(UINT scanCode) { this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying(scanCode); this->m_sc = scanCode; - memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey)); + memset(this->m_rgfDeadKey, 0, sizeof(this->m_rgfDeadKey)); } UINT VK() { @@ -136,50 +137,34 @@ public: } bool KMX_IsSGCAPS() { - std::u16string stBase = this->KMX_GetShiftState(Base, false); - std::u16string stShift = this->KMX_GetShiftState(Shft, false); - std::u16string stCaps = this->KMX_GetShiftState(Base, true); - std::u16string stShiftCaps = this->KMX_GetShiftState(Shft, true); - return ( - ((stCaps.size() > 0) && - (stBase.compare(stCaps) != 0) && - (stShift.compare(stCaps) != 0)) || - ((stShiftCaps.size() > 0) && - (stBase.compare(stShiftCaps) != 0) && - (stShift.compare(stShiftCaps) != 0))); - } + std::u16string stBase = this->KMX_GetShiftState(Base, false); + std::u16string stShift = this->KMX_GetShiftState(Shft, false); + std::u16string stCaps = this->KMX_GetShiftState(Base, true); + std::u16string stShiftCaps = this->KMX_GetShiftState(Shft, true); + return ( + ((stCaps.size() > 0) && (stBase.compare(stCaps) != 0) && (stShift.compare(stCaps) != 0)) || + ((stShiftCaps.size() > 0) && (stBase.compare(stShiftCaps) != 0) && (stShift.compare(stShiftCaps) != 0))); + } bool KMX_IsCapsEqualToShift() { - std::u16string stBase = this->KMX_GetShiftState(Base, false); - std::u16string stShift = this->KMX_GetShiftState(Shft, false); - std::u16string stCaps = this->KMX_GetShiftState(Base, true); - return ( - (stBase.size() > 0) && - (stShift.size() > 0) && - (stBase.compare(stShift) != 0) && - (stShift.compare(stCaps) == 0)); - } + std::u16string stBase = this->KMX_GetShiftState(Base, false); + std::u16string stShift = this->KMX_GetShiftState(Shft, false); + std::u16string stCaps = this->KMX_GetShiftState(Base, true); + return ((stBase.size() > 0) && (stShift.size() > 0) && (stBase.compare(stShift) != 0) && (stShift.compare(stCaps) == 0)); + } bool KMX_IsAltGrCapsEqualToAltGrShift() { - std::u16string stBase = this->KMX_GetShiftState(MenuCtrl, false); - std::u16string stShift = this->KMX_GetShiftState(ShftMenuCtrl, false); - std::u16string stCaps = this->KMX_GetShiftState(MenuCtrl, true); - return ( - (stBase.size() > 0) && - (stShift.size() > 0) && - (stBase.compare(stShift) != 0) && - (stShift.compare(stCaps) == 0)); - } + std::u16string stBase = this->KMX_GetShiftState(MenuCtrl, false); + std::u16string stShift = this->KMX_GetShiftState(ShftMenuCtrl, false); + std::u16string stCaps = this->KMX_GetShiftState(MenuCtrl, true); + return ((stBase.size() > 0) && (stShift.size() > 0) && (stBase.compare(stShift) != 0) && (stShift.compare(stCaps) == 0)); + } bool KMX_IsXxxxGrCapsEqualToXxxxShift() { - std::u16string stBase = this->KMX_GetShiftState(Xxxx, false); - std::u16string stShift = this->KMX_GetShiftState(ShftXxxx, false); - std::u16string stCaps = this->KMX_GetShiftState(Xxxx, true); - return ( - (stBase.size() > 0) && - (stShift.size() > 0) && - (stBase.compare(stShift) != 0) && - (stShift.compare(stCaps) == 0)); + std::u16string stBase = this->KMX_GetShiftState(Xxxx, false); + std::u16string stShift = this->KMX_GetShiftState(ShftXxxx, false); + std::u16string stCaps = this->KMX_GetShiftState(Xxxx, true); + return ((stBase.size() > 0) && (stShift.size() > 0) && (stBase.compare(stShift) != 0) && (stShift.compare(stCaps) == 0)); } bool KMX_IsEmpty() { @@ -211,8 +196,7 @@ public: continue; } for (int caps = 0; caps <= 1; caps++) { - - std::u16string st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); + std::u16string st = this->KMX_GetShiftState((ShiftState)ss, (caps == 1)); if (st.size() == 0) { // No character assigned here @@ -222,13 +206,14 @@ public: } else { bool isvalid = true; for (size_t ich = 0; ich < st.size(); ich++) { - if(st[ich] < 0x20 || st[ich] == 0x7F) { - isvalid=false; + if (st[ich] < 0x20 || st[ich] == 0x7F) { + isvalid = false; wprintf(L"invalid for: %i\n", st[ich]); - break; } + break; + } } - if(isvalid) { + if (isvalid) { nkeys++; } } @@ -237,13 +222,10 @@ public: return nkeys; } - bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector *deadkeys, int deadkeyBase, BOOL bDeadkeyConversion,vec_dword_3D& all_vector, GdkKeymap *keymap) { // I4552 + bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector* deadkeys, int deadkeyBase, BOOL bDeadkeyConversion, vec_dword_3D& all_vector, GdkKeymap* keymap) { // I4552 // Get the CAPSLOCK value - int capslock = - (this->KMX_IsCapsEqualToShift() ? 1 : 0) | - (this->KMX_IsSGCAPS() ? 2 : 0) | - (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | (this->KMX_IsSGCAPS() ? 2 : 0) | + (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); for (int ss = 0; ss <= MaxShiftState; ss++) { if (ss == Menu || ss == ShftMenu) { @@ -251,63 +233,60 @@ public: continue; } for (int caps = 0; caps <= 1; caps++) { - std::u16string st = this->KMX_GetShiftState((ShiftState) ss, (caps == 1)); + std::u16string st = this->KMX_GetShiftState((ShiftState)ss, (caps == 1)); PKMX_WCHAR p; if (st.size() == 0) { // No character assigned here - } - else if (this->m_rgfDeadKey[(int)ss][caps]) { + } else if (this->m_rgfDeadKey[(int)ss][caps]) { // It's a dead key, append an @ sign. key->dpContext = new KMX_WCHAR[1]; *key->dpContext = 0; - key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); + key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState)ss); // we already use VK_US so no need to convert it as we do on windows key->Key = this->VK(); key->Line = 0; - if(bDeadkeyConversion) { // I4552 + if (bDeadkeyConversion) { // I4552 p = key->dpOutput = new KMX_WCHAR[2]; *p++ = st[0]; *p = 0; } else { - p = key->dpOutput = new KMX_WCHAR[4]; *p++ = UC_SENTINEL; *p++ = CODE_DEADKEY; - // can convert since KMX_DeadKeyMap returns a small positive number - *p++ = (KMX_WCHAR) KMX_DeadKeyMap(st[0], deadkeys, deadkeyBase, &KMX_FDeadkeys); // I4353 + *p++ = KMX_DeadKeyMap(st[0], deadkeys, deadkeyBase, &KMX_FDeadkeys); // I4353 *p = 0; } key++; - } - else { + } else { bool isvalid = true; for (size_t ich = 0; ich < st.size(); ich++) { - if(st[ich] < 0x20 || st[ich] == 0x7F) { - isvalid=false; + if (st[ich] < 0x20 || st[ich] == 0x7F) { + isvalid = false; wprintf(L"invalid 16 for: %i\n", st[ich]); - break; } + break; + } } - if(isvalid) { + if (isvalid) { // this is different to mcompile windows !!!! // this->m_sc stores SC-US = SCUnderlying // this->m_vk stores VK-US ( not underlying !!) // key->Key stores VK-US ( not underlying !!) // key->dpOutput stores character Underlying - KMX_DWORD SC_Underlying = KMX_get_KeyCodeUnderlying_From_KeyCodeUS(keymap, all_vector, this->SC(), (ShiftState) ss, caps); - key->Key = KMX_get_VKUS_From_KeyCodeUnderlying( SC_Underlying); + KMX_DWORD SC_Underlying = KMX_get_KeyCodeUnderlying_From_KeyCodeUS(keymap, all_vector, this->SC(), (ShiftState)ss, caps); + key->Key = KMX_get_VKUS_From_KeyCodeUnderlying(SC_Underlying); key->Line = 0; - key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState) ss); + key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState)ss); key->dpContext = new KMX_WCHAR; *key->dpContext = 0; p = key->dpOutput = new KMX_WCHAR[st.size() + 1]; - for(size_t ich = 0; ich < st.size(); ich++) { + for (size_t ich = 0; ich < st.size(); ich++) { *p++ = st[ich]; } *p = 0; @@ -346,25 +325,24 @@ public: bool KMX_IsControlChar(char16_t ch) { return (ch < 0x0020) || (ch >= 0x007F && ch <= 0x009F); } - }; -int KMX_GetMaxDeadkeyIndex(KMX_WCHAR *p) { +int KMX_GetMaxDeadkeyIndex(KMX_WCHAR* p) { int n = 0; - while(p && *p) { - if(*p == UC_SENTINEL && *(p+1) == CODE_DEADKEY) - n = std::max(n, (int) *(p+2)); + while (p && *p) { + if (*p == UC_SENTINEL && *(p + 1) == CODE_DEADKEY) + n = std::max(n, (int)*(p + 2)); p = KMX_incxstr(p); } return n; } -bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap **keymap, std::vector *FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 +bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** keymap, std::vector* FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 KMX_Loader loader; std::vector rgKey; //= new VirtualKey[256]; std::vector alDead; - std::vector alDead_cpl = create_deadkeys_by_basechar(); + std::vector alDead_byBasechar = create_deadkeys_by_basechar(); rgKey.resize(256); @@ -372,19 +350,19 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap **ke // values in it. Then, store the SC in each valid VK so it can act as both a // flag that the VK is valid, and it can store the SC value. - for(UINT sc = 0x01; sc <= 0x7f; sc++) { + for (UINT sc = 0x01; sc <= 0x7f; sc++) { // fills m_vk with the VK of the US keyboard // ( mcompile win uses MapVirtualKeyEx() to fill m_vk with the VK of the Underlying keyboard) // Linux can get a VK for the US Keyboard using USVirtualKeyToScanCode/ScanCodeToUSVirtualKey // Linux cannot get a VK for the underling Keyboard // this "connection" is possible only when using all_vector - KMX_VirtualKey *key = new KMX_VirtualKey(sc); + KMX_VirtualKey* key = new KMX_VirtualKey(sc); - if((key->VK() != 0) ) { - rgKey[key->VK()] = key; + if ((key->VK() != 0)) { + rgKey[key->VK()] = key; } else { - delete key; + delete key; } } @@ -393,40 +371,37 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap **ke rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL); rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL);*/ - // in this part we skip shiftstates 4, 5, 8, 9 - for(UINT iKey = 0; iKey < rgKey.size(); iKey++) { + // in this part we skip shiftstates 4, 5, 8, 9 + for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { + if (rgKey[iKey] != NULL) { + KMX_WCHAR sbBuffer[256]; // Scratchpad we use many places - if(rgKey[iKey] != NULL) { - KMX_WCHAR sbBuffer[256]; // Scratchpad we use many places + for (ShiftState ss = Base; ss <= loader.KMX_MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { + if (ss == Menu || ss == ShftMenu) { + // Alt and Shift+Alt don't work, so skip them (ss 4+5) + continue; + } - for(ShiftState ss = Base; ss <= loader.KMX_MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { - if(ss == Menu || ss == ShftMenu) { - // Alt and Shift+Alt don't work, so skip them (ss 4+5) - continue; - } + KMX_DWORD kc_us = (KMX_DWORD)KMX_get_KeyCodeUnderlying_From_VKUS(iKey); - KMX_DWORD kc_us = (KMX_DWORD) KMX_get_KeyCodeUnderlying_From_VKUS(iKey); + for (int caps = 0; caps <= 1; caps++) { + int rc = KMX_ToUnicodeEx(kc_us, sbBuffer, ss, caps, *keymap); - for(int caps = 0; caps <= 1; caps++) { - int rc = KMX_ToUnicodeEx(kc_us, sbBuffer, ss, caps, *keymap); - - if(rc > 0) { - if(*sbBuffer == 0) { - rgKey[iKey]->KMX_SetShiftState(ss, u"", false, (caps)); // different to windows since behavior on Linux is different - } - else { - if ((ss == Ctrl || ss == ShftCtrl) ) { + if (rc > 0) { + if (*sbBuffer == 0) { + rgKey[iKey]->KMX_SetShiftState(ss, u"", false, (caps)); // different to windows since behavior on Linux is different + } else { + if ((ss == Ctrl || ss == ShftCtrl)) { continue; } sbBuffer[rc] = 0; - rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps)); // different to windows since behavior on Linux is different + rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps)); // different to windows since behavior on Linux is different } - } - else if(rc < 0) { + } else if (rc < 0) { sbBuffer[2] = 0; - rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps)); // different to windows since behavior on Linux is different + rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps)); // different to windows since behavior on Linux is different - refine_alDead(sbBuffer[0], alDead, alDead_cpl); + refine_alDead(sbBuffer[0], alDead, alDead_byBasechar); } } } @@ -439,7 +414,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap **ke //------------------------------------------------------------- int nDeadkey = 0; - LPKMX_GROUP gp = new KMX_GROUP[kp->cxGroupArray+4]; // leave space for old + LPKMX_GROUP gp = new KMX_GROUP[kp->cxGroupArray + 4]; // leave space for old memcpy(gp, kp->dpGroupArray, sizeof(KMX_GROUP) * kp->cxGroupArray); // @@ -447,44 +422,42 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap **ke // kp->dpGroupArray = gp; - for(UINT i = 0; i < kp->cxGroupArray; i++, gp++) { - //if(gp->fUsingKeys && gp->dpNoMatch == NULL) { // I4550 - // WCHAR *p = gp->dpNoMatch = new WCHAR[4]; - // *p++ = UC_SENTINEL; - // *p++ = CODE_USE; - // *p++ = (WCHAR)(kp->cxGroupArray + 1); - // *p = 0; + for (UINT i = 0; i < kp->cxGroupArray; i++, gp++) { + // if(gp->fUsingKeys && gp->dpNoMatch == NULL) { // I4550 + // WCHAR *p = gp->dpNoMatch = new WCHAR[4]; + // *p++ = UC_SENTINEL; + // *p++ = CODE_USE; + // *p++ = (WCHAR)(kp->cxGroupArray + 1); + // *p = 0; //} LPKMX_KEY kkp = gp->dpKeyArray; - for(UINT j = 0; j < gp->cxKeyArray; j++, kkp++) { + for (UINT j = 0; j < gp->cxKeyArray; j++, kkp++) { nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpContext)); nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpOutput)); } } kp->cxGroupArray++; - gp = &kp->dpGroupArray[kp->cxGroupArray-1]; - + gp = &kp->dpGroupArray[kp->cxGroupArray - 1]; + // calculate the required size of `gp->dpKeyArray` - + UINT nkeys = 0; for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { - nkeys+= rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()); + nkeys += rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()); } } gp->fUsingKeys = TRUE; - gp->dpMatch = NULL; - gp->dpName = NULL; - gp->dpNoMatch = NULL; + gp->dpMatch = NULL; + gp->dpName = NULL; + gp->dpNoMatch = NULL; gp->cxKeyArray = nkeys; gp->dpKeyArray = new KMX_KEY[gp->cxKeyArray]; - nDeadkey++; // ensure a 1-based index above the max deadkey value already in the keyboard - - + nDeadkey++; // ensure a 1-based index above the max deadkey value already in the keyboard // // Fill in the new rules @@ -492,8 +465,8 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap **ke nkeys = 0; for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { - if(rgKey[iKey]->KMX_LayoutRow(loader.KMX_MaxShiftState(), &gp->dpKeyArray[nkeys], &alDead, nDeadkey, bDeadkeyConversion, all_vector,*keymap)) { // I4552 - nkeys+=rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()); + if (rgKey[iKey]->KMX_LayoutRow(loader.KMX_MaxShiftState(), &gp->dpKeyArray[nkeys], &alDead, nDeadkey, bDeadkeyConversion, all_vector, *keymap)) { // I4552 + nkeys += rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()); } } } @@ -504,9 +477,9 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap **ke // Add nomatch control to each terminating 'using keys' group // I4550 // LPKMX_GROUP gp2 = kp->dpGroupArray; - for(UINT i = 0; i < kp->cxGroupArray - 1; i++, gp2++) { - if(gp2->fUsingKeys && gp2->dpNoMatch == NULL) { - KMX_WCHAR *p = gp2->dpNoMatch = new KMX_WCHAR[4]; + for (UINT i = 0; i < kp->cxGroupArray - 1; i++, gp2++) { + if (gp2->fUsingKeys && gp2->dpNoMatch == NULL) { + KMX_WCHAR* p = gp2->dpNoMatch = new KMX_WCHAR[4]; *p++ = UC_SENTINEL; *p++ = CODE_USE; *p++ = (KMX_WCHAR)(kp->cxGroupArray); @@ -518,19 +491,19 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap **ke // UINT j; LPKMX_KEY kkp; - for(j = 0, kkp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kkp++) { - if((kkp->ShiftFlags & (K_CTRLFLAG|K_ALTFLAG|LCTRLFLAG|LALTFLAG|RCTRLFLAG|RALTFLAG)) != 0) { + for (j = 0, kkp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kkp++) { + if ((kkp->ShiftFlags & (K_CTRLFLAG | K_ALTFLAG | LCTRLFLAG | LALTFLAG | RCTRLFLAG | RALTFLAG)) != 0) { gp2->cxKeyArray++; LPKMX_KEY kkp2 = new KMX_KEY[gp2->cxKeyArray]; - memcpy(kkp2, gp2->dpKeyArray, sizeof(KMX_KEY)*(gp2->cxKeyArray-1)); + memcpy(kkp2, gp2->dpKeyArray, sizeof(KMX_KEY) * (gp2->cxKeyArray - 1)); gp2->dpKeyArray = kkp2; - kkp2 = &kkp2[gp2->cxKeyArray-1]; - kkp2->dpContext = new KMX_WCHAR; + kkp2 = &kkp2[gp2->cxKeyArray - 1]; + kkp2->dpContext = new KMX_WCHAR; *kkp2->dpContext = 0; kkp2->Key = kkp->Key; kkp2->ShiftFlags = kkp->ShiftFlags; kkp2->Line = 0; - KMX_WCHAR *p = kkp2->dpOutput = new KMX_WCHAR[4]; + KMX_WCHAR* p = kkp2->dpOutput = new KMX_WCHAR[4]; *p++ = UC_SENTINEL; *p++ = CODE_USE; *p++ = (KMX_WCHAR)(kp->cxGroupArray); @@ -544,21 +517,21 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap **ke // We only do this if not in deadkey conversion mode // - if (alDead.size() > 0 && !bDeadkeyConversion) { // I4552 + if (alDead.size() > 0 && !bDeadkeyConversion) { // I4552 kp->cxGroupArray++; - KMX_WCHAR *p = gp->dpMatch = new KMX_WCHAR[4]; + KMX_WCHAR* p = gp->dpMatch = new KMX_WCHAR[4]; *p++ = UC_SENTINEL; *p++ = CODE_USE; - *p++ = (KMX_WCHAR) kp->cxGroupArray; + *p++ = (KMX_WCHAR)kp->cxGroupArray; *p = 0; gp++; gp->fUsingKeys = FALSE; - gp->dpMatch = NULL; - gp->dpName = NULL; - gp->dpNoMatch = NULL; + gp->dpMatch = NULL; + gp->dpName = NULL; + gp->dpNoMatch = NULL; gp->cxKeyArray = alDead.size(); LPKMX_KEY kkp = gp->dpKeyArray = new KMX_KEY[alDead.size()]; @@ -571,13 +544,13 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap **ke int nStoreBase = kp->cxStoreArray; kp->cxStoreArray += alDead.size() * 2; - for(UINT i = 0; i < alDead.size(); i++) { - DeadKey *dk = alDead[i]; + for (UINT i = 0; i < alDead.size(); i++) { + DeadKey* dk = alDead[i]; sp->dpName = NULL; sp->dwSystemID = 0; sp->dpString = new KMX_WCHAR[dk->KMX_Count() + 1]; - for(int j = 0; j < dk->KMX_Count(); j++) + for (int j = 0; j < dk->KMX_Count(); j++) sp->dpString[j] = dk->KMX_GetBaseCharacter(j); sp->dpString[dk->KMX_Count()] = 0; sp++; @@ -585,7 +558,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap **ke sp->dpName = NULL; sp->dwSystemID = 0; sp->dpString = new KMX_WCHAR[dk->KMX_Count() + 1]; - for(int j = 0; j < dk->KMX_Count(); j++) + for (int j = 0; j < dk->KMX_Count(); j++) sp->dpString[j] = dk->KMX_GetCombinedCharacter(j); sp->dpString[dk->KMX_Count()] = 0; sp++; @@ -593,26 +566,25 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap **ke kkp->Line = 0; kkp->ShiftFlags = 0; kkp->Key = 0; - KMX_WCHAR *p = kkp->dpContext = new KMX_WCHAR[8]; + KMX_WCHAR* p = kkp->dpContext = new KMX_WCHAR[8]; *p++ = UC_SENTINEL; *p++ = CODE_DEADKEY; - // can convert since KMX_DeadKeyMap returns a small positive number - *p++ = (KMX_WCHAR) KMX_DeadKeyMap(dk->KMX_DeadCharacter(), &alDead, nDeadkey, FDeadkeys); // I4353 + *p++ = KMX_DeadKeyMap(dk->KMX_DeadCharacter(), &alDead, nDeadkey, FDeadkeys); // I4353 // *p++ = nDeadkey+i; *p++ = UC_SENTINEL; *p++ = CODE_ANY; - *p++ = nStoreBase + i*2 + 1; + *p++ = nStoreBase + i * 2 + 1; *p = 0; p = kkp->dpOutput = new KMX_WCHAR[5]; *p++ = UC_SENTINEL; *p++ = CODE_INDEX; - *p++ = nStoreBase + i*2 + 2; + *p++ = nStoreBase + i * 2 + 2; *p++ = 2; *p = 0; kkp++; } } -return true; + return true; } diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index b68b5e4707..22c9255481 100755 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -3,7 +3,7 @@ #define MC_KMXFILE_H #include "km_types.h" -#include <../../../../common/include/kmx_file.h> +#include #include "filesystem.h" #include "mcompile.h" diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 6e5c83d672..64d00273b6 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -23,7 +23,7 @@ 08 Apr 2015 - mcdurdin - I4651 - V9.0 - Mnemonic layout recompiler maps AltGr+VK_BKSLASH rather than VK_OEM_102 */ // -// m-to-p.cpp : Defines the entry point for the console application. +// Defines the entry point for the console application. // // Note: this program deliberately leaks memory as it has a very short life cycle and managing the memory allocations // for the subcomponents of the compiled keyboard is an unnecessary optimisation. Just so you know. @@ -499,4 +499,3 @@ void KMX_LogError(const wchar_t* fmt, ...) { while(fmtbuf[j] != *end); putwchar(*nl); } - diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index d8f71ffaea..237ff81132 100755 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -19,9 +19,14 @@ cpp_files = files( 'mc_import_rules.cpp', 'u16.cpp',) +comon_include_dir = [ + include_directories('../../../../common/include'), +] + + mcompile = executable( 'mcompile', sources: [cpp_files], - dependencies: deps + dependencies: deps, + include_directories : comon_include_dir ) - From e4e05a794fafcf76e41ee07f39bef30f8dd9f0a6 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 21 Jun 2024 09:40:52 +0200 Subject: [PATCH 255/327] feat(linux):check buffer size moved --- linux/mcompile/keymap/mc_import_rules.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 2a966bfcca..96e0b127f6 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -65,9 +65,6 @@ int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int guint* keyvals; gint count; - if (u16len(pwszBuff) < 1) - return 0; - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; @@ -81,6 +78,8 @@ int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int g_free(keyvals); g_free(maps); + if (u16len(pwszBuff) < 1) + return 0; if ((keyVal >= deadkey_min) && (keyVal <= deadkey_max)) // deadkeys return -1; From 0eb96a70ace5b3a8c400f3e906c465e747b87e20 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 21 Jun 2024 09:45:21 +0200 Subject: [PATCH 256/327] feat(linux):check buffer size moved --- linux/mcompile/keymap/mc_import_rules.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 2a966bfcca..96e0b127f6 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -65,9 +65,6 @@ int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int guint* keyvals; gint count; - if (u16len(pwszBuff) < 1) - return 0; - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; @@ -81,6 +78,8 @@ int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int g_free(keyvals); g_free(maps); + if (u16len(pwszBuff) < 1) + return 0; if ((keyVal >= deadkey_min) && (keyVal <= deadkey_max)) // deadkeys return -1; From 1ddbcf68be420c686c8f564a316cf2b2c221058e Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 21 Jun 2024 18:03:44 +0200 Subject: [PATCH 257/327] feat(linux):work on comments for keymap --- linux/mcompile/keymap/keymap.cpp | 1012 ++++++++++--------- linux/mcompile/keymap/keymap.h | 856 ++++++++-------- linux/mcompile/keymap/mc_import_rules.cpp | 9 +- linux/mcompile/keymap/mcompile.cpp | 8 +- windows/src/engine/keyman32/VKScanCodes.cpp | 8 +- windows/src/global/cpp/VKScanCodes.cpp | 6 +- 6 files changed, 972 insertions(+), 927 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 9eeef45f35..e9fcb8200f 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -1,20 +1,26 @@ #include "keymap.h" +#include "kmx_file.h" +#include "/usr/include/xcb/xproto.h" #include -// unmodified, shift, RALT, shift+RALT -int map_VKShiftState_to_LinModifier(int vk_ShiftState) { - if (vk_ShiftState == 0 ) return 0; /* 0000 0000 */ - else if (vk_ShiftState == 16) return 1; /* 0001 0000 */ - else if (vk_ShiftState == 9 ) return 2; /* 0000 1001 */ - else if (vk_ShiftState == 25) return 3; /* 0001 1001 */ - else return vk_ShiftState; +int convert_WinShiftstate_to_LinuxShiftstate(int win_ShiftState) { + if (win_ShiftState == 0) + return 0; + else if (win_ShiftState == K_SHIFTFLAG) + return XCB_MOD_MASK_SHIFT; + else if (win_ShiftState == (LCTRLFLAG | RALTFLAG)) + return XCB_MOD_MASK_LOCK; + else if (win_ShiftState == (K_SHIFTFLAG | LCTRLFLAG | RALTFLAG)) + return (XCB_MOD_MASK_SHIFT | XCB_MOD_MASK_LOCK); + else + return win_ShiftState; } -bool ensureValidInputForKeyboardTranslation(int shiftstate, gint count, guint keycode) { - if (!(shiftstate <= count)) - return false; +bool ensureValidInputForKeyboardTranslation(int shiftstate, int count, int keycode) { + if (shiftstate > count) + return false; - if (!(keycode <= keycode_max)) + if (keycode > (int)keycode_max) return false; return true; @@ -22,286 +28,284 @@ bool ensureValidInputForKeyboardTranslation(int shiftstate, gint count, guint ke KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str) { // more on https://manpages.ubuntu.com/manpages/jammy/man3/keysyms.3tk.html - std::map first; + std::map key_values; - first["ampersand"] = 38; - first["apostrophe"] = 39; - first["asciicircum"] = 136; - first["asciitilde"] = 126; - first["asterisk"] = 42; - first["at"] = 64; - first["backslash"] = 92; - first["BackSpace"] = 65288; - first["bar"] = 124; - first["braceleft"] = 123; - first["braceright"] = 125; - first["bracketleft"] = 91; - first["bracketright"] = 93; - first["colon"] = 58; - first["comma"] = 44; - first["diaeresis"] = 168; - first["dollar"] = 36; - first["equal"] = 61; - first["exclam"] = 33; - first["grave"] = 96; - first["greater"] = 62; - first["less"] = 60; - first["minus"] = 45; - first["numbersign"] = 35; - first["parenleft"] = 40; - first["parenright"] = 41; - first["percent"] = 37; - first["period"] = 46; - first["plus"] = 43; - first["question"] = 63; - first["quotedbl"] = 34; - first["semicolon"] = 59; - first["slash"] = 47; - first["space"] = 32; - first["ssharp"] = 223; - first["underscore"] = 95; + key_values["ampersand"] = 38; + key_values["apostrophe"] = 39; + key_values["asciicircum"] = 136; + key_values["asciitilde"] = 126; + key_values["asterisk"] = 42; + key_values["at"] = 64; + key_values["backslash"] = 92; + key_values["BackSpace"] = 65288; + key_values["bar"] = 124; + key_values["braceleft"] = 123; + key_values["braceright"] = 125; + key_values["bracketleft"] = 91; + key_values["bracketright"] = 93; + key_values["colon"] = 58; + key_values["comma"] = 44; + key_values["diaeresis"] = 168; + key_values["dollar"] = 36; + key_values["equal"] = 61; + key_values["exclam"] = 33; + key_values["grave"] = 96; + key_values["greater"] = 62; + key_values["less"] = 60; + key_values["minus"] = 45; + key_values["numbersign"] = 35; + key_values["parenleft"] = 40; + key_values["parenright"] = 41; + key_values["percent"] = 37; + key_values["period"] = 46; + key_values["plus"] = 43; + key_values["question"] = 63; + key_values["quotedbl"] = 34; + key_values["semicolon"] = 59; + key_values["slash"] = 47; + key_values["space"] = 32; + key_values["ssharp"] = 223; + key_values["underscore"] = 95; + key_values["nobreakspace"] = 160; + key_values["exclamdown"] = 161; + key_values["cent"] = 162; + key_values["sterling"] = 163; + key_values["currency"] = 164; + key_values["yen"] = 165; + key_values["brokenbar"] = 166; + key_values["section"] = 167; + key_values["copyright"] = 169; + key_values["ordfeminine"] = 170; + key_values["guillemotleft"] = 171; + key_values["notsign"] = 172; + key_values["hyphen"] = 173; + key_values["registered"] = 174; + key_values["macron"] = 175; + key_values["degree"] = 176; + key_values["plusminus"] = 177; + key_values["twosuperior"] = 178; + key_values["threesuperior"] = 179; + key_values["acute"] = 180; + key_values["mu"] = 181; + key_values["paragraph"] = 182; + key_values["periodcentered"] = 183; + key_values["cedilla"] = 184; + key_values["onesuperior"] = 185; + key_values["masculine"] = 186; + key_values["guillemotright"] = 187; + key_values["onequarter"] = 188; + key_values["onehalf"] = 189; + key_values["threequarters"] = 190; + key_values["questiondown"] = 191; + key_values["Agrave"] = 192; + key_values["Aacute"] = 193; + key_values["Acircumflex"] = 194; + key_values["Atilde"] = 195; + key_values["Adiaeresis"] = 196; + key_values["Aring"] = 197; + key_values["AE"] = 198; + key_values["Ccedilla"] = 199; + key_values["Egrave"] = 200; + key_values["Eacute"] = 201; + key_values["Ecircumflex"] = 202; + key_values["Ediaeresis"] = 203; + key_values["Igrave"] = 204; + key_values["Iacute"] = 205; + key_values["Icircumflex"] = 206; + key_values["Idiaeresis"] = 207; + key_values["ETH"] = 208; + key_values["Ntilde"] = 209; + key_values["Ograve"] = 210; + key_values["Oacute"] = 211; + key_values["Ocircumflex"] = 212; + key_values["Otilde"] = 213; + key_values["Odiaeresis"] = 214; + key_values["multiply"] = 215; + key_values["Oslash"] = 216; + key_values["Ugrave"] = 217; + key_values["Uacute"] = 218; + key_values["Ucircumflex"] = 219; + key_values["Udiaeresis"] = 220; + key_values["Yacute"] = 221; + key_values["THORN"] = 222; + key_values["agrave"] = 224; + key_values["aacute"] = 225; + key_values["acircumflex"] = 226; + key_values["atilde"] = 227; + key_values["adiaeresis"] = 228; + key_values["aring"] = 229; + key_values["ae"] = 230; + key_values["ccedilla"] = 231; + key_values["egrave"] = 232; + key_values["eacute"] = 233; + key_values["ecircumflex"] = 234; + key_values["ediaeresis"] = 235; + key_values["igrave"] = 236; + key_values["iacute"] = 237; + key_values["icircumflex"] = 238; + key_values["idiaeresis"] = 239; + key_values["eth"] = 240; + key_values["ntilde"] = 241; + key_values["ograve"] = 242; + key_values["oacute"] = 243; + key_values["ocircumflex"] = 244; + key_values["otilde"] = 245; + key_values["odiaeresis"] = 246; + key_values["division"] = 247; + key_values["oslash"] = 248; + key_values["ugrave"] = 249; + key_values["uacute"] = 250; + key_values["ucircumflex"] = 251; + key_values["udiaeresis"] = 252; + key_values["yacute"] = 253; + key_values["thorn"] = 254; + key_values["ydiaeresis"] = 255; + key_values["Aogonek"] = 417; + key_values["breve"] = 418; + key_values["Lstroke"] = 419; + key_values["Lcaron"] = 421; + key_values["Sacute"] = 422; + key_values["Scaron"] = 425; + key_values["Scedilla"] = 426; + key_values["Tcaron"] = 427; + key_values["Zacute"] = 428; + key_values["Zcaron"] = 430; + key_values["Zabovedot"] = 431; + key_values["aogonek"] = 433; + key_values["ogonek"] = 434; + key_values["lstroke"] = 435; + key_values["lcaron"] = 437; + key_values["sacute"] = 438; + key_values["caron"] = 439; + key_values["scaron"] = 441; + key_values["scedilla"] = 442; + key_values["tcaron"] = 443; + key_values["zacute"] = 444; + key_values["doubleacute"] = 445; + key_values["zcaron"] = 446; + key_values["zabovedot"] = 447; + key_values["Racute"] = 448; + key_values["Abreve"] = 451; + key_values["Lacute"] = 453; + key_values["Cacute"] = 454; + key_values["Ccaron"] = 456; + key_values["Eogonek"] = 458; + key_values["Ecaron"] = 460; + key_values["Dcaron"] = 463; + key_values["Dstroke"] = 464; + key_values["Nacute"] = 465; + key_values["Ncaron"] = 466; + key_values["Odoubleacute"] = 469; + key_values["Rcaron"] = 472; + key_values["Uring"] = 473; + key_values["Udoubleacute"] = 475; + key_values["Tcedilla"] = 478; + key_values["racute"] = 480; + key_values["abreve"] = 483; + key_values["lacute"] = 485; + key_values["cacute"] = 486; + key_values["ccaron"] = 488; + key_values["eogonek"] = 490; + key_values["ecaron"] = 492; + key_values["dcaron"] = 495; + key_values["dstroke"] = 496; + key_values["nacute"] = 497; + key_values["ncaron"] = 498; + key_values["odoubleacute"] = 501; + key_values["rcaron"] = 504; + key_values["uring"] = 505; + key_values["udoubleacute"] = 507; + key_values["tcedilla"] = 510; + key_values["abovedot"] = 511; + key_values["Hstroke"] = 673; + key_values["Hcircumflex"] = 678; + key_values["Iabovedot"] = 681; + key_values["Gbreve"] = 683; + key_values["Jcircumflex"] = 684; + key_values["hstroke"] = 689; + key_values["hcircumflex"] = 694; + key_values["idotless"] = 697; + key_values["gbreve"] = 699; + key_values["jcircumflex"] = 700; + key_values["Cabovedot"] = 709; + key_values["Ccircumflex"] = 710; + key_values["Gabovedot"] = 725; + key_values["Gcircumflex"] = 728; + key_values["Ubreve"] = 733; + key_values["Scircumflex"] = 734; + key_values["cabovedot"] = 741; + key_values["ccircumflex"] = 742; + key_values["gabovedot"] = 757; + key_values["gcircumflex"] = 760; + key_values["ubreve"] = 765; + key_values["scircumflex"] = 766; + key_values["kra"] = 930; + key_values["Rcedilla"] = 931; + key_values["Itilde"] = 933; + key_values["Lcedilla"] = 934; + key_values["Emacron"] = 938; + key_values["Gcedilla"] = 939; + key_values["Tslash"] = 940; + key_values["rcedilla"] = 947; + key_values["itilde"] = 949; + key_values["lcedilla"] = 950; + key_values["emacron"] = 954; + key_values["gcedilla"] = 955; + key_values["tslash"] = 956; + key_values["ENG"] = 957; + key_values["eng"] = 959; + key_values["Amacron"] = 960; + key_values["Iogonek"] = 967; + key_values["Eabovedot"] = 972; + key_values["Imacron"] = 975; + key_values["Ncedilla"] = 977; + key_values["Omacron"] = 978; + key_values["Kcedilla"] = 979; + key_values["Uogonek"] = 985; + key_values["Utilde"] = 989; + key_values["Umacron"] = 990; + key_values["amacron"] = 992; + key_values["iogonek"] = 999; + key_values["eabovedot"] = 1004; + key_values["imacron"] = 1007; + key_values["ncedilla"] = 1009; + key_values["omacron"] = 1010; + key_values["kcedilla"] = 1011; + key_values["uogonek"] = 1017; + key_values["utilde"] = 1021; + key_values["umacron"] = 1022; + key_values["overline"] = 1150; - first["nobreakspace"] = 160; - first["exclamdown"] = 161; - first["cent"] = 162; - first["sterling"] = 163; - first["currency"] = 164; - first["yen"] = 165; - first["brokenbar"] = 166; - first["section"] = 167; - first["copyright"] = 169; - first["ordfeminine"] = 170; - first["guillemotleft"] = 171; - first["notsign"] = 172; - first["hyphen"] = 173; - first["registered"] = 174; - first["macron"] = 175; - first["degree"] = 176; - first["plusminus"] = 177; - first["twosuperior"] = 178; - first["threesuperior"] = 179; - first["acute"] = 180; - first["mu"] = 181; - first["paragraph"] = 182; - first["periodcentered"] = 183; - first["cedilla"] = 184; - first["onesuperior"] = 185; - first["masculine"] = 186; - first["guillemotright"] = 187; - first["onequarter"] = 188; - first["onehalf"] = 189; - first["threequarters"] = 190; - first["questiondown"] = 191; - first["Agrave"] = 192; - first["Aacute"] = 193; - first["Acircumflex"] = 194; - first["Atilde"] = 195; - first["Adiaeresis"] = 196; - first["Aring"] = 197; - first["AE"] = 198; - first["Ccedilla"] = 199; - first["Egrave"] = 200; - first["Eacute"] = 201; - first["Ecircumflex"] = 202; - first["Ediaeresis"] = 203; - first["Igrave"] = 204; - first["Iacute"] = 205; - first["Icircumflex"] = 206; - first["Idiaeresis"] = 207; - first["ETH"] = 208; - first["Ntilde"] = 209; - first["Ograve"] = 210; - first["Oacute"] = 211; - first["Ocircumflex"] = 212; - first["Otilde"] = 213; - first["Odiaeresis"] = 214; - first["multiply"] = 215; - first["Oslash"] = 216; - first["Ugrave"] = 217; - first["Uacute"] = 218; - first["Ucircumflex"] = 219; - first["Udiaeresis"] = 220; - first["Yacute"] = 221; - first["THORN"] = 222; - first["agrave"] = 224; - first["aacute"] = 225; - first["acircumflex"] = 226; - first["atilde"] = 227; - first["adiaeresis"] = 228; - first["aring"] = 229; - first["ae"] = 230; - first["ccedilla"] = 231; - first["egrave"] = 232; - first["eacute"] = 233; - first["ecircumflex"] = 234; - first["ediaeresis"] = 235; - first["igrave"] = 236; - first["iacute"] = 237; - first["icircumflex"] = 238; - first["idiaeresis"] = 239; - first["eth"] = 240; - first["ntilde"] = 241; - first["ograve"] = 242; - first["oacute"] = 243; - first["ocircumflex"] = 244; - first["otilde"] = 245; - first["odiaeresis"] = 246; - first["division"] = 247; - first["oslash"] = 248; - first["ugrave"] = 249; - first["uacute"] = 250; - first["ucircumflex"] = 251; - first["udiaeresis"] = 252; - first["yacute"] = 253; - first["thorn"] = 254; - first["ydiaeresis"] = 255; - first["Aogonek"] = 417; - first["breve"] = 418; - first["Lstroke"] = 419; - first["Lcaron"] = 421; - first["Sacute"] = 422; - first["Scaron"] = 425; - first["Scedilla"] = 426; - first["Tcaron"] = 427; - first["Zacute"] = 428; - first["Zcaron"] = 430; - first["Zabovedot"] = 431; - first["aogonek"] = 433; - first["ogonek"] = 434; - first["lstroke"] = 435; - first["lcaron"] = 437; - first["sacute"] = 438; - first["caron"] = 439; - first["scaron"] = 441; - first["scedilla"] = 442; - first["tcaron"] = 443; - first["zacute"] = 444; - first["doubleacute"] = 445; - first["zcaron"] = 446; - first["zabovedot"] = 447; - first["Racute"] = 448; - first["Abreve"] = 451; - first["Lacute"] = 453; - first["Cacute"] = 454; - first["Ccaron"] = 456; - first["Eogonek"] = 458; - first["Ecaron"] = 460; - first["Dcaron"] = 463; - first["Dstroke"] = 464; - first["Nacute"] = 465; - first["Ncaron"] = 466; - first["Odoubleacute"] = 469; - first["Rcaron"] = 472; - first["Uring"] = 473; - first["Udoubleacute"] = 475; - first["Tcedilla"] = 478; - first["racute"] = 480; - first["abreve"] = 483; - first["lacute"] = 485; - first["cacute"] = 486; - first["ccaron"] = 488; - first["eogonek"] = 490; - first["ecaron"] = 492; - first["dcaron"] = 495; - first["dstroke"] = 496; - first["nacute"] = 497; - first["ncaron"] = 498; - first["odoubleacute"] = 501; - first["rcaron"] = 504; - first["uring"] = 505; - first["udoubleacute"] = 507; - first["tcedilla"] = 510; - first["abovedot"] = 511; - first["Hstroke"] = 673; - first["Hcircumflex"] = 678; - first["Iabovedot"] = 681; - first["Gbreve"] = 683; - first["Jcircumflex"] = 684; - first["hstroke"] = 689; - first["hcircumflex"] = 694; - first["idotless"] = 697; - first["gbreve"] = 699; - first["jcircumflex"] = 700; - first["Cabovedot"] = 709; - first["Ccircumflex"] = 710; - first["Gabovedot"] = 725; - first["Gcircumflex"] = 728; - first["Ubreve"] = 733; - first["Scircumflex"] = 734; - first["cabovedot"] = 741; - first["ccircumflex"] = 742; - first["gabovedot"] = 757; - first["gcircumflex"] = 760; - first["ubreve"] = 765; - first["scircumflex"] = 766; - first["kra"] = 930; - first["Rcedilla"] = 931; - first["Itilde"] = 933; - first["Lcedilla"] = 934; - first["Emacron"] = 938; - first["Gcedilla"] = 939; - first["Tslash"] = 940; - first["rcedilla"] = 947; - first["itilde"] = 949; - first["lcedilla"] = 950; - first["emacron"] = 954; - first["gcedilla"] = 955; - first["tslash"] = 956; - first["ENG"] = 957; - first["eng"] = 959; - first["Amacron"] = 960; - first["Iogonek"] = 967; - first["Eabovedot"] = 972; - first["Imacron"] = 975; - first["Ncedilla"] = 977; - first["Omacron"] = 978; - first["Kcedilla"] = 979; - first["Uogonek"] = 985; - first["Utilde"] = 989; - first["Umacron"] = 990; - first["amacron"] = 992; - first["iogonek"] = 999; - first["eabovedot"] = 1004; - first["imacron"] = 1007; - first["ncedilla"] = 1009; - first["omacron"] = 1010; - first["kcedilla"] = 1011; - first["uogonek"] = 1017; - first["utilde"] = 1021; - first["umacron"] = 1022; - first["overline"] = 1150; + key_values["dead_abovedot"] = 729; + key_values["dead_abovering"] = 730; + key_values["dead_acute"] = 180; + key_values["dead_breve"] = 728; + key_values["dead_caron"] = 711; + key_values["dead_cedilla"] = 184; + key_values["dead_circumflex"] = 94; + key_values["dead_diaeresis"] = 168; + key_values["dead_doubleacute"] = 733; + key_values["dead_grave"] = 96; + key_values["dead_ogonek"] = 731; + key_values["dead_perispomeni"] = 126; + key_values["dead_tilde"] = 126; - first["dead_abovedot"] = 729; - first["dead_abovering"] = 730; - first["dead_acute"] = 180; - first["dead_breve"] = 728; - first["dead_caron"] = 711; - first["dead_cedilla"] = 184; - first["dead_circumflex"] = 94; - first["dead_diaeresis"] = 168; - first["dead_doubleacute"] = 733; - first["dead_grave"] = 96; - first["dead_ogonek"] = 731; - first["dead_perispomeni"] = 126; - first["dead_tilde"] = 126; - - first["acute accent"] = 0xB4; + key_values["acute accent"] = 0xB4; if (tok_str.size() == 1) { - return (KMX_DWORD) ( *tok_str.c_str() ); - } - else { - std::map ::iterator it; - for (it = first.begin(); it != first.end(); ++it) { - if (it->first == tok_str) - return it->second; - } + return (KMX_DWORD)(*tok_str.c_str()); + } else { + std::map::iterator it; + for (it = key_values.begin(); it != key_values.end(); ++it) { + if (it->first == tok_str) + return it->second; + } } return INVALID_NAME; } -int createOneVectorFromBothKeyboards(vec_dword_3D &all_vector,GdkKeymap *keymap) { +int createOneVectorFromBothKeyboards(vec_dword_3D& all_vector, GdkKeymap* keymap) { // create a 3D-Vector which contains data of the US keyboard and the underlying Keyboard: // all_vector[ US_Keyboard ] // [KeyCode_US ] @@ -312,42 +316,38 @@ int createOneVectorFromBothKeyboards(vec_dword_3D &all_vector,GdkKeymap *keymap) // [Keyval unshifted ] // [Keyval shifted ] - std::string us_language = "us"; - const char* text_us = "xkb_symbols \"basic\""; - - if (write_US_ToVector(all_vector,us_language, text_us)) { - wprintf(L"ERROR: can't write US to Vector \n"); + if (write_US_ToVector(all_vector, "us", "xkb_symbols \"basic\"")) { + printf("ERROR: can't write US to Vector \n"); return 1; } // add contents of other keyboard to all_vector - if (append_underlying_ToVector(all_vector,keymap)) { - wprintf(L"ERROR: can't append underlying ToVector \n"); + if (append_underlying_ToVector(all_vector, keymap)) { + printf("ERROR: can't append underlying ToVector \n"); return 2; } return 0; } -int write_US_ToVector( vec_dword_3D &vec,std::string language, const char* section ) { - +int write_US_ToVector(vec_dword_3D& vec, std::string language, const char* section) { std::string fullPathName = "/usr/share/X11/xkb/symbols/" + language; const char* path = fullPathName.c_str(); - FILE* fp = fopen((path), "r"); + FILE* fp = fopen((path), "r"); if (!fp) { - wprintf(L"ERROR: could not open file!\n"); + printf("ERROR: could not open file!\n"); return 1; } // create 1D-vector of the complete line vec_string_1D vector_completeUS; if (createCompleteVector_US(fp, section, vector_completeUS)) { - wprintf(L"ERROR: can't Create complete row US \n"); + printf("ERROR: can't Create complete row US \n"); return 1; } // split contents of 1D Vector to 3D vector - if (split_US_To_3D_Vector(vec,vector_completeUS)) { + if (split_US_To_3D_Vector(vec, vector_completeUS)) { return 1; } @@ -355,13 +355,13 @@ int write_US_ToVector( vec_dword_3D &vec,std::string language, const char* secti return 0; } -bool createCompleteVector_US(FILE* fp, const char* section, vec_string_1D &complete_List) { +bool createCompleteVector_US(FILE* fp, const char* section, vec_string_1D& complete_List) { // in the Configuration file we find the appopriate paragraph between "xkb_symbol " and the next xkb_symbol // and then copy all rows starting with "key <" to a 1D-Vector int buffer_size = 512; char line[buffer_size]; - bool create_row = false; + bool create_row = false; const char* key = "key <"; std::string str_us_kbd_name(section); std::string xbk_mark = "xkb_symbol"; @@ -386,68 +386,117 @@ bool createCompleteVector_US(FILE* fp, const char* section, vec_string_1D &compl } complete_List.push_back(" key { [ space, space] };"); - if (complete_List.size() <1) { - wprintf(L"ERROR: can't create row from US \n"); + if (complete_List.size() < 1) { + printf("ERROR: can't create row from US \n"); return 1; } return 0; } -int replace_KeyName_with_Keycode(std::string in) { +int get_keycode_from_keyname(std::string key_name) { int out = INVALID_NAME; - if ( in == "key") out = 49; /* VK_ BKQUOTE */ - else if ( in == "key") out = 10; /* VK_1 */ - else if ( in == "key") out = 11; /* VK_2 */ - else if ( in == "key") out = 12; /* VK_3 */ - else if ( in == "key") out = 13; /* VK_4 */ - else if ( in == "key") out = 14; /* VK_5 */ - else if ( in == "key") out = 15; /* VK_6 */ - else if ( in == "key") out = 16; /* VK_7 */ - else if ( in == "key") out = 17; /* VK_8 */ - else if ( in == "key") out = 18; /* VK_9 */ - else if ( in == "key") out = 19; /* VK_0 */ - else if ( in == "key") out = 20; /* VK_MINUS K_HYPHEN */ - else if ( in == "key") out = 21; /* VK_EQUAL */ + if (key_name == "key") + out = 49; /* VK_ BKQUOTE */ + else if (key_name == "key") + out = 10; /* VK_1 */ + else if (key_name == "key") + out = 11; /* VK_2 */ + else if (key_name == "key") + out = 12; /* VK_3 */ + else if (key_name == "key") + out = 13; /* VK_4 */ + else if (key_name == "key") + out = 14; /* VK_5 */ + else if (key_name == "key") + out = 15; /* VK_6 */ + else if (key_name == "key") + out = 16; /* VK_7 */ + else if (key_name == "key") + out = 17; /* VK_8 */ + else if (key_name == "key") + out = 18; /* VK_9 */ + else if (key_name == "key") + out = 19; /* VK_0 */ + else if (key_name == "key") + out = 20; /* VK_MINUS K_HYPHEN */ + else if (key_name == "key") + out = 21; /* VK_EQUAL */ - else if ( in == "key") out = 24; /* VK_Q */ - else if ( in == "key") out = 25; /* VK_W */ - else if ( in == "key") out = 26; /* VK_E */ - else if ( in == "key") out = 27; /* VK_R */ - else if ( in == "key") out = 28; /* VK_T */ - else if ( in == "key") out = 29; /* VK_Y */ - else if ( in == "key") out = 30; /* VK_U */ - else if ( in == "key") out = 31; /* VK_I */ - else if ( in == "key") out = 32; /* VK_O */ - else if ( in == "key") out = 33; /* VK_P */ - else if ( in == "key") out = 34; /* VK_LEFTBRACE */ - else if ( in == "key") out = 35; /* VK_RIGHTBRACE */ + else if (key_name == "key") + out = 24; /* VK_Q */ + else if (key_name == "key") + out = 25; /* VK_W */ + else if (key_name == "key") + out = 26; /* VK_E */ + else if (key_name == "key") + out = 27; /* VK_R */ + else if (key_name == "key") + out = 28; /* VK_T */ + else if (key_name == "key") + out = 29; /* VK_Y */ + else if (key_name == "key") + out = 30; /* VK_U */ + else if (key_name == "key") + out = 31; /* VK_I */ + else if (key_name == "key") + out = 32; /* VK_O */ + else if (key_name == "key") + out = 33; /* VK_P */ + else if (key_name == "key") + out = 34; /* VK_LEFTBRACE */ + else if (key_name == "key") + out = 35; /* VK_RIGHTBRACE */ - else if ( in == "key") out = 38; /* VK_A */ - else if ( in == "key") out = 39; /* VK_S */ - else if ( in == "key") out = 40; /* VK_D */ - else if ( in == "key") out = 41; /* VK_F */ - else if ( in == "key") out = 42; /* VK_G */ - else if ( in == "key") out = 43; /* VK_H */ - else if ( in == "key") out = 44; /* VK_J */ - else if ( in == "key") out = 45; /* VK_K */ - else if ( in == "key") out = 46; /* VK_L */ - else if ( in == "key") out = 47; /* VK_SEMICOLON */ - else if ( in == "key") out = 48; /* VK_APOSTROPHE */ + else if (key_name == "key") + out = 38; /* VK_A */ + else if (key_name == "key") + out = 39; /* VK_S */ + else if (key_name == "key") + out = 40; /* VK_D */ + else if (key_name == "key") + out = 41; /* VK_F */ + else if (key_name == "key") + out = 42; /* VK_G */ + else if (key_name == "key") + out = 43; /* VK_H */ + else if (key_name == "key") + out = 44; /* VK_J */ + else if (key_name == "key") + out = 45; /* VK_K */ + else if (key_name == "key") + out = 46; /* VK_L */ + else if (key_name == "key") + out = 47; /* VK_SEMICOLON */ + else if (key_name == "key") + out = 48; /* VK_APOSTROPHE */ - else if ( in == "key") out = 52; /* VK_Z */ - else if ( in == "key") out = 53; /* VK_X */ - else if ( in == "key") out = 54; /* VK_C */ - else if ( in == "key") out = 55; /* VK_V */ - else if ( in == "key") out = 56; /* VK_B */ - else if ( in == "key") out = 57; /* VK_N */ - else if ( in == "key") out = 58; /* VK_M */ - else if ( in == "key") out = 59; /* VK_ COMMA */ - else if ( in == "key") out = 60; /* VK_DOT */ - else if ( in == "key") out = 61; /* VK_SLASH */ - else if ( in == "key") out = 51; /* VK_BKSLASH */ - else if ( in == "key") out = 63; /* VK_RIGHTSHIFT */ - else if ( in == "key") out = 65; /* VK_SPACE */ + else if (key_name == "key") + out = 52; /* VK_Z */ + else if (key_name == "key") + out = 53; /* VK_X */ + else if (key_name == "key") + out = 54; /* VK_C */ + else if (key_name == "key") + out = 55; /* VK_V */ + else if (key_name == "key") + out = 56; /* VK_B */ + else if (key_name == "key") + out = 57; /* VK_N */ + else if (key_name == "key") + out = 58; /* VK_M */ + else if (key_name == "key") + out = 59; /* VK_ COMMA */ + else if (key_name == "key") + out = 60; /* VK_DOT */ + else if (key_name == "key") + out = 61; /* VK_SLASH */ + else if (key_name == "key") + out = 51; /* VK_BKSLASH */ + else if (key_name == "key") + out = 63; /* VK_RIGHTSHIFT */ + else if (key_name == "key") + out = 65; /* VK_SPACE */ return out; } @@ -459,47 +508,43 @@ int split_US_To_3D_Vector(vec_dword_3D& all_US, vec_string_1D completeList) { // 4: push Names/Shiftstates to shift_states and then shift_states to All_US, our 3D-Vector holding all Elements std::vector delim{' ', '[', ']', '}', ';', '\t', '\n'}; - char split_bracel = '{'; - char split_comma = ','; int keyCode; vec_string_1D tokens; vec_dword_1D tokens_dw; vec_dword_2D shift_states; - KMX_DWORD tokens_int; // loop through the whole vector for (int k = 0; k < (int)completeList.size(); k++) { - // remove all unwanted char - for (int i = 0; i < (int) delim.size(); i++) { + for (int i = 0; i < (int)delim.size(); i++) { completeList[k].erase(remove(completeList[k].begin(), completeList[k].end(), delim[i]), completeList[k].end()); } // only lines with ("key<.. are of interest if (completeList[k].find("key<") != std::string::npos) { - - //split off the key names + // split off the key names std::istringstream split_Keyname(completeList[k]); - for (std::string each; std::getline(split_Keyname, each, split_bracel); tokens.push_back(each)) { - // empty + for (std::string each; std::getline(split_Keyname, each, '{'); tokens.push_back(each)) { + // empty } // replace keys names with Keycode ( with 21,...) - keyCode = replace_KeyName_with_Keycode(tokens[0]); + keyCode = get_keycode_from_keyname(tokens[0]); tokens[0] = std::to_string(keyCode); // seperate rest of the vector to its elements and push to 'tokens' std::istringstream split_Characters(tokens[1]); tokens.pop_back(); - for (std::string each; std::getline(split_Characters, each, split_comma); tokens.push_back(each)); + for (std::string each; std::getline(split_Characters, each, ','); tokens.push_back(each)) + ; // now convert all to KMX_DWORD and fill tokens - tokens_dw.push_back((KMX_DWORD) keyCode); + tokens_dw.push_back((KMX_DWORD)keyCode); - for ( int i = 1; i< (int) tokens.size();i++) { + for (int i = 1; i < (int)tokens.size(); i++) { // replace a name with a single character ( a -> a ; equal -> = ) - tokens_int = convertNamesTo_DWORD_Value(tokens[i]); + KMX_DWORD tokens_int = convertNamesTo_DWORD_Value(tokens[i]); tokens_dw.push_back(tokens_int); } @@ -511,19 +556,18 @@ int split_US_To_3D_Vector(vec_dword_3D& all_US, vec_string_1D completeList) { all_US.push_back(shift_states); if (all_US.size() == 0) { - wprintf(L"ERROR: Can't split US to 3D-Vector\n"); + printf("ERROR: Can't split US to 3D-Vector\n"); return 1; } return 0; } -vec_dword_2D create_empty_2D_Vector( int dim_rows,int dim_ss) { - +vec_dword_2D create_empty_2D_Vector(int dim_rows, int dim_ss) { vec_dword_1D shifts; vec_dword_2D vector_2D; - for ( int i=0; i< dim_rows;i++) { - for ( int j=0; j< dim_ss;j++) { + for (int i = 0; i < dim_rows; i++) { + for (int j = 0; j < dim_ss; j++) { shifts.push_back(INVALID_NAME); } vector_2D.push_back(shifts); @@ -532,48 +576,53 @@ vec_dword_2D create_empty_2D_Vector( int dim_rows,int dim_ss) { return vector_2D; } -int append_underlying_ToVector(vec_dword_3D& all_vector,GdkKeymap *keymap) { +int append_underlying_ToVector(vec_dword_3D& all_vector, GdkKeymap* keymap) { + if (all_vector.size() != 1) { + printf("ERROR: data for US keyboard not correct\n"); + return 1; + } // create a 2D vector all filled with " " and push to 3D-Vector - vec_dword_2D underlying_Vector2D = create_empty_2D_Vector(all_vector[0].size(),all_vector[0][0].size()); + vec_dword_2D underlying_Vector2D = create_empty_2D_Vector(all_vector[0].size(), all_vector[0][0].size()); if (underlying_Vector2D.size() == 0) { - wprintf(L"ERROR: can't create empty 2D-Vector\n"); + printf("ERROR: can't create empty 2D-Vector\n"); return 1; } all_vector.push_back(underlying_Vector2D); if (all_vector.size() < 2) { - wprintf(L"ERROR: creation of 3D-Vector failed\n"); + printf("ERROR: creation of 3D-Vector failed\n"); return 1; } - for(int i =0; i< (int) all_vector[1].size();i++) { - + for (int i = 0; i < (int)all_vector[1].size(); i++) { // get key name US stored in [0][i][0] and copy to name in "underlying"-block[1][i][0] all_vector[1][i][0] = all_vector[0][i][0]; // get Keyvals of this key and copy to unshifted/shifted in "underlying"-block[1][i][1] / block[1][i][2] - all_vector[1][i][0+1] = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap,all_vector[0][i][0],0); //shift state: unshifted:0 - all_vector[1][i][1+1] = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap,all_vector[0][i][0],1); //shift state: shifted:1 + all_vector[1][i][0 + 1] = + KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap, all_vector[0][i][0], 0); // shift state: unshifted:0 + all_vector[1][i][1 + 1] = + KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap, all_vector[0][i][0], 1); // shift state: shifted:1 } return 0; } -bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]) { -// get keymap of underlying keyboard +bool InitializeGDK(GdkKeymap** keymap, int argc, gchar* argv[]) { + // get keymap of underlying keyboard gdk_init(&argc, &argv); - GdkDisplay *display = gdk_display_get_default(); + GdkDisplay* display = gdk_display_get_default(); if (!display) { - wprintf(L"ERROR: can't get display\n"); + printf("ERROR: can't get display\n"); return 1; } *keymap = gdk_keymap_get_for_display(display); if (!keymap) { - wprintf(L"ERROR: Can't get keymap\n"); + printf("ERROR: Can't get keymap\n"); gdk_display_close(display); return 2; } @@ -582,144 +631,140 @@ bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]) { bool IsKeymanUsedChar(int KV) { // 32 A-Z a-z - if ((KV == 0x20 ) || (KV >= 65 && KV <= 90) || (KV >= 97 && KV <= 122) ) + if ((KV == 0x20) || (KV >= 65 && KV <= 90) || (KV >= 97 && KV <= 122)) return true; else return false; } std::u16string convert_DeadkeyValues_To_U16str(int in) { - - if (in == 0 ) + if (in == 0) return u"\0"; - std::string long_name((const char*) gdk_keyval_name (in)); // e.g. "dead_circumflex", "U+017F", "t" + std::string long_name((const char*)gdk_keyval_name(in)); // e.g. "dead_circumflex", "U+017F", "t" - if (long_name.substr (0,2) == "U+" ) // U+... Unicode value - return CodePointToU16String(in-0x1000000); // GDK's gdk_keymap_translate_keyboard_state() returns (Keyvalue | 0x01000000) - // since we never have a carry-over we can just subtract 0x01000000 - if (in < (int) deadkey_min) { // no deadkey; no Unicode - return std::u16string(1, in); + if (long_name.substr(0, 2) == "U+") // U+... Unicode value + return CodePointToU16String(in - 0x1000000); // GDK's gdk_keymap_translate_keyboard_state() returns (Keyvalue | 0x01000000) + // since we never have a carry-over we can just subtract 0x01000000 + if (in < (int)deadkey_min) { // no deadkey; no Unicode + return std::u16string(1, in); } - KMX_DWORD lname = convertNamesTo_DWORD_Value(long_name); // 65106 => "dead_circumflex" => 94 => "^" + KMX_DWORD lname = convertNamesTo_DWORD_Value(long_name); // 65106 => "dead_circumflex" => 94 => "^" if (lname != INVALID_NAME) { - return std::u16string(1, lname ); - } - else + return std::u16string(1, lname); + } else return u"\0"; } -int KMX_get_KeyVal_From_KeyCode(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps) { - +int KMX_get_KeyVal_From_KeyCode(GdkKeymap* keymap, guint keycode, ShiftState ss, int caps) { GdkModifierType consumed; - GdkKeymapKey *maps; - guint *keyvals; + GdkKeymapKey* maps; + guint* keyvals; gint count; if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation( map_VKShiftState_to_LinModifier(ss), count, keycode))){ + if (!(ensureValidInputForKeyboardTranslation(convert_WinShiftstate_to_LinuxShiftstate(ss), (int)count, (int)keycode))) { g_free(keyvals); g_free(maps); return 0; } - //BASE (shiftstate: 0) - if (( ss == Base ) && ( caps == 0 )) { - GdkModifierType MOD_base = (GdkModifierType) ( ~GDK_MODIFIER_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_base, 0, keyvals, NULL, NULL, & consumed); + // BASE (shiftstate: 0) + if ((ss == Base) && (caps == 0)) { + GdkModifierType MOD_base = (GdkModifierType)(~GDK_MODIFIER_MASK); + gdk_keymap_translate_keyboard_state(keymap, keycode, MOD_base, 0, keyvals, NULL, NULL, &consumed); } - //BASE + CAPS (shiftstate: 0) - else if (( ss == Base ) && ( caps == 1 )) { - GdkModifierType MOD_Caps = (GdkModifierType) ( GDK_LOCK_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, & consumed); + // BASE + CAPS (shiftstate: 0) + else if ((ss == Base) && (caps == 1)) { + GdkModifierType MOD_Caps = (GdkModifierType)(GDK_LOCK_MASK); + gdk_keymap_translate_keyboard_state(keymap, keycode, MOD_Caps, 0, keyvals, NULL, NULL, &consumed); } - //SHIFT (shiftstate: 1) - else if (( ss == Shft ) && ( caps == 0 )) { - GdkModifierType MOD_Shift = (GdkModifierType) ( GDK_SHIFT_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Shift, 0, keyvals, NULL, NULL, & consumed); + // SHIFT (shiftstate: 1) + else if ((ss == Shft) && (caps == 0)) { + GdkModifierType MOD_Shift = (GdkModifierType)(GDK_SHIFT_MASK); + gdk_keymap_translate_keyboard_state(keymap, keycode, MOD_Shift, 0, keyvals, NULL, NULL, &consumed); } - //SHIFT + CAPS (shiftstate: 1) - else if (( ss == Shft ) && ( caps ==1 )) { - GdkModifierType MOD_ShiftCaps= (GdkModifierType) ((GDK_SHIFT_MASK | GDK_LOCK_MASK)); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_ShiftCaps, 0, keyvals, NULL, NULL, & consumed); + // SHIFT + CAPS (shiftstate: 1) + else if ((ss == Shft) && (caps == 1)) { + GdkModifierType MOD_ShiftCaps = (GdkModifierType)((GDK_SHIFT_MASK | GDK_LOCK_MASK)); + gdk_keymap_translate_keyboard_state(keymap, keycode, MOD_ShiftCaps, 0, keyvals, NULL, NULL, &consumed); } // Ctrl (shiftstate: 2) - else if (( ss == Ctrl ) && ( caps == 0 )){ - GdkModifierType MOD_Ctrl = (GdkModifierType) ( GDK_MOD5_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl, 0, keyvals, NULL, NULL, & consumed); + else if ((ss == Ctrl) && (caps == 0)) { + GdkModifierType MOD_Ctrl = (GdkModifierType)(GDK_MOD5_MASK); + gdk_keymap_translate_keyboard_state(keymap, keycode, MOD_Ctrl, 0, keyvals, NULL, NULL, &consumed); } // Ctrl + CAPS (shiftstate: 2) - else if (( ss == Ctrl ) && ( caps == 1 )){ - GdkModifierType MOD_CtrlCaps = (GdkModifierType) (GDK_MOD5_MASK | GDK_LOCK_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps, 0, keyvals, NULL, NULL, & consumed); + else if ((ss == Ctrl) && (caps == 1)) { + GdkModifierType MOD_CtrlCaps = (GdkModifierType)(GDK_MOD5_MASK | GDK_LOCK_MASK); + gdk_keymap_translate_keyboard_state(keymap, keycode, MOD_CtrlCaps, 0, keyvals, NULL, NULL, &consumed); } // SHIFT+Ctrl (shiftstate: 3) - else if (( ss == ShftCtrl ) && ( caps == 0 )){ - GdkModifierType MOD_Ctrl = (GdkModifierType) (GDK_SHIFT_MASK | GDK_MOD5_MASK ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_Ctrl, 0, keyvals, NULL, NULL, & consumed); + else if ((ss == ShftCtrl) && (caps == 0)) { + GdkModifierType MOD_Ctrl = (GdkModifierType)(GDK_SHIFT_MASK | GDK_MOD5_MASK); + gdk_keymap_translate_keyboard_state(keymap, keycode, MOD_Ctrl, 0, keyvals, NULL, NULL, &consumed); } // SHIFT+Ctrl + CAPS (shiftstate: 3) - else if (( ss == ShftCtrl ) && ( caps == 1 )){ - GdkModifierType MOD_CtrlCaps = (GdkModifierType) ( GDK_SHIFT_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_CtrlCaps, 0, keyvals, NULL, NULL, & consumed); + else if ((ss == ShftCtrl) && (caps == 1)) { + GdkModifierType MOD_CtrlCaps = (GdkModifierType)(GDK_SHIFT_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); + gdk_keymap_translate_keyboard_state(keymap, keycode, MOD_CtrlCaps, 0, keyvals, NULL, NULL, &consumed); } - //ALT-GR (shiftstate: 6) - else if (( ss == MenuCtrl ) && ( caps == 0 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr, 0, keyvals, NULL, NULL, & consumed); + // ALT-GR (shiftstate: 6) + else if ((ss == MenuCtrl) && (caps == 0)) { + GdkModifierType MOD_AltGr = (GdkModifierType)(GDK_MOD2_MASK | GDK_MOD5_MASK); + gdk_keymap_translate_keyboard_state(keymap, keycode, MOD_AltGr, 0, keyvals, NULL, NULL, &consumed); } - //ALT-GR + CAPS (shiftstate: 6) - else if (( ss == MenuCtrl ) && ( caps == 1 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) (GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr, 0, keyvals, NULL, NULL, & consumed); + // ALT-GR + CAPS (shiftstate: 6) + else if ((ss == MenuCtrl) && (caps == 1)) { + GdkModifierType MOD_AltGr = (GdkModifierType)(GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK); + gdk_keymap_translate_keyboard_state(keymap, keycode, MOD_AltGr, 0, keyvals, NULL, NULL, &consumed); } - //ALT-GR (shiftstate: 7) - else if (( ss == ShftMenuCtrl ) && ( caps == 0 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr, 0, keyvals, NULL, NULL, & consumed); + // ALT-GR (shiftstate: 7) + else if ((ss == ShftMenuCtrl) && (caps == 0)) { + GdkModifierType MOD_AltGr = (GdkModifierType)((GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK)); + gdk_keymap_translate_keyboard_state(keymap, keycode, MOD_AltGr, 0, keyvals, NULL, NULL, &consumed); } - //ALT-GR +CAPS (shiftstate: 7) - else if (( ss == ShftMenuCtrl ) && ( caps == 1 )){ - GdkModifierType MOD_AltGr = (GdkModifierType) ( (GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK) ); - gdk_keymap_translate_keyboard_state (keymap, keycode, MOD_AltGr, 0, keyvals, NULL, NULL, & consumed); - } - else + // ALT-GR +CAPS (shiftstate: 7) + else if ((ss == ShftMenuCtrl) && (caps == 1)) { + GdkModifierType MOD_AltGr = (GdkModifierType)((GDK_SHIFT_MASK | GDK_MOD2_MASK | GDK_MOD5_MASK | GDK_LOCK_MASK)); + gdk_keymap_translate_keyboard_state(keymap, keycode, MOD_AltGr, 0, keyvals, NULL, NULL, &consumed); + } else return 0; - return (int) *keyvals; + return (int)*keyvals; } -KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, guint keycode, int shift_state_pos) { - GdkKeymapKey *maps; - guint *keyvals; +KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, guint keycode, int shift_state_pos) { + GdkKeymapKey* maps; + guint* keyvals; gint count; KMX_DWORD kVal; if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation( shift_state_pos, count, keycode))){ + if (!(ensureValidInputForKeyboardTranslation(shift_state_pos, (int)count, (int)keycode))) { g_free(keyvals); g_free(maps); return 0; } - kVal = (KMX_DWORD) KMX_get_KeyVal_From_KeyCode(keymap, keycode, (ShiftState) shift_state_pos, 0); + kVal = (KMX_DWORD)KMX_get_KeyVal_From_KeyCode(keymap, keycode, (ShiftState)shift_state_pos, 0); g_free(keyvals); g_free(maps); @@ -727,44 +772,44 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, gui return kVal; } -KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, UINT vk_ShiftState, UINT kc_underlying, PKMX_WCHAR deadkey) { - - GdkKeymapKey *maps; - guint *keyvals; +KMX_DWORD +KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, UINT vk_ShiftState, UINT kc_underlying, PKMX_WCHAR deadkey) { + GdkKeymapKey* maps; + guint* keyvals; gint count; - PKMX_WCHAR dky=NULL; - + PKMX_WCHAR dky = NULL; if (!gdk_keymap_get_entries_for_keycode(keymap, kc_underlying, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation( map_VKShiftState_to_LinModifier(vk_ShiftState), count, kc_underlying))){ + if (!(ensureValidInputForKeyboardTranslation( + convert_WinShiftstate_to_LinuxShiftstate(vk_ShiftState), (int)count, (int)kc_underlying))) { g_free(keyvals); g_free(maps); return 0; } - KMX_DWORD keyV = KMX_get_KeyVal_From_KeyCode(keymap, kc_underlying, ShiftState(map_VKShiftState_to_LinModifier(vk_ShiftState)), 0); + KMX_DWORD keyV = + KMX_get_KeyVal_From_KeyCode(keymap, kc_underlying, ShiftState(convert_WinShiftstate_to_LinuxShiftstate(vk_ShiftState)), 0); g_free(keyvals); g_free(maps); - if ((keyV >= deadkey_min) && (keyV <= deadkey_max) ){ // deadkey - dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) keyV)).c_str(); + if ((keyV >= deadkey_min) && (keyV <= deadkey_max)) { // deadkey + dky = (PKMX_WCHAR)(convert_DeadkeyValues_To_U16str((int)keyV)).c_str(); *deadkey = *dky; return 0xFFFF; - } - else if ((keyV > deadkey_max) || ((keyV < deadkey_min) && ( keyV > 0xFF))) // out of range + } else if ((keyV > deadkey_max) || ((keyV < deadkey_min) && (keyV > 0xFF))) // out of range return 0xFFFE; - else // usable char + else // usable char return keyV; } //_S2 vk_us or underlying!!"!!" -KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(vec_dword_3D & all_vector, KMX_DWORD vk_US) { +KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(vec_dword_3D& all_vector, KMX_DWORD vk_US) { KMX_DWORD vk_underlying; - for( int i=0; i< (int)all_vector[0].size()-1 ;i++) { - for( int j=1; j< (int)all_vector[0][0].size();j++) { - if (( all_vector[0][i][j] == vk_US ) ) { + for (int i = 0; i < (int)all_vector[0].size() - 1; i++) { + for (int j = 1; j < (int)all_vector[0][0].size(); j++) { + if ((all_vector[0][i][j] == vk_US)) { vk_underlying = all_vector[1][i][j]; return vk_underlying; } @@ -773,13 +818,14 @@ KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(vec_dword_3D & all_vector, KMX_ return vk_US; } -KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap *keymap, vec_dword_3D &all_vector, KMX_DWORD kc_us, ShiftState ss, int caps) { +KMX_DWORD +KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap* keymap, vec_dword_3D& all_vector, KMX_DWORD kc_us, ShiftState ss, int caps) { KMX_DWORD kc_underlying; std::u16string u16str = convert_DeadkeyValues_To_U16str(KMX_get_KeyVal_From_KeyCode(keymap, kc_us, ss, caps)); - for( int i=0; i< (int)all_vector[1].size()-1 ;i++) { - for( int j=1; j< (int)all_vector[1][0].size();j++) { - if (( all_vector[1][i][j] == (KMX_DWORD) *u16str.c_str() ) ) { + for (int i = 0; i < (int)all_vector[1].size() - 1; i++) { + for (int j = 1; j < (int)all_vector[1][0].size(); j++) { + if ((all_vector[1][i][j] == (KMX_DWORD)*u16str.c_str())) { kc_underlying = all_vector[1][i][0]; return kc_underlying; } @@ -788,13 +834,13 @@ KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap *keymap, vec_dword_ return kc_us; } -UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD virtualKeyUS) { +UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD virtualKeyUS) { return (8 + USVirtualKeyToScanCode[virtualKeyUS]); } KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying(KMX_DWORD keycode) { - if (keycode >7) - return (KMX_DWORD) ScanCodeToUSVirtualKey[keycode-8]; + if (keycode > 7) + return (KMX_DWORD)ScanCodeToUSVirtualKey[keycode - 8]; return 0; } @@ -803,16 +849,14 @@ std::u16string CodePointToU16String(unsigned int codepoint) { std::u16string str; if constexpr (sizeof(wchar_t) > 2) { - str = static_cast(codepoint); - } - else if (codepoint <= 0xFFFF) { - str = static_cast(codepoint); - } - else { - codepoint -= 0x10000; - str.resize(2); - str[0] = static_cast(0xD800 + ((codepoint >> 10) & 0x3FF)); - str[1] = static_cast(0xDC00 + (codepoint & 0x3FF)); + str = static_cast(codepoint); + } else if (codepoint <= 0xFFFF) { + str = static_cast(codepoint); + } else { + codepoint -= 0x10000; + str.resize(2); + str[0] = static_cast(0xD800 + ((codepoint >> 10) & 0x3FF)); + str[1] = static_cast(0xDC00 + (codepoint & 0x3FF)); } return str; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 3885428cdc..6bae6a8e94 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -17,44 +17,42 @@ #include "u16.h" enum ShiftState { - Base = 0, // 0 - Shft = 1, // 1 - Ctrl = 2, // 2 - ShftCtrl = Shft | Ctrl, // 3 - Menu = 4, // 4 -- NOT USED - ShftMenu = Shft | Menu, // 5 -- NOT USED - MenuCtrl = Menu | Ctrl, // 6 - ShftMenuCtrl = Shft | Menu | Ctrl, // 7 - Xxxx = 8, // 8 - ShftXxxx = Shft | Xxxx, // 9 + Base = 0, // 0 + Shft = 1, // 1 + Ctrl = 2, // 2 + ShftCtrl = Shft | Ctrl, // 3 + Menu = 4, // 4 -- NOT USED + ShftMenu = Shft | Menu, // 5 -- NOT USED + MenuCtrl = Menu | Ctrl, // 6 + ShftMenuCtrl = Shft | Menu | Ctrl, // 7 + Xxxx = 8, // 8 + ShftXxxx = Shft | Xxxx, // 9 }; // Map of all US English virtual key codes that we can translate -const KMX_DWORD KMX_VKMap[] = { - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', +const KMX_DWORD KMX_VKMap[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', + 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - VK_SPACE, /* 32 */ + VK_SPACE, /* 32 */ - VK_ACCENT, /* 192 VK_OEM_3 K_BKQUOTE */ - VK_HYPHEN, /* - 189 VK_OEM_MINUS */ - VK_EQUAL, /* = 187 VK_OEM_PLUS */ + VK_ACCENT, /* 192 VK_OEM_3 K_BKQUOTE */ + VK_HYPHEN, /* - 189 VK_OEM_MINUS */ + VK_EQUAL, /* = 187 VK_OEM_PLUS */ - VK_LBRKT, /* [ 219 VK_OEM_4 */ - VK_RBRKT, /* ] 221 VK_OEM_6 */ - VK_BKSLASH, /* \ 220 VK_OEM_5 */ + VK_LBRKT, /* [ 219 VK_OEM_4 */ + VK_RBRKT, /* ] 221 VK_OEM_6 */ + VK_BKSLASH, /* \ 220 VK_OEM_5 */ - VK_COLON, /* ; 186 VK_OEM_1 */ - VK_QUOTE, /* ' 222 VK_OEM_7 */ + VK_COLON, /* ; 186 VK_OEM_1 */ + VK_QUOTE, /* ' 222 VK_OEM_7 */ - VK_COMMA, /* , 188 VK_OEM_COMMA */ - VK_PERIOD, /* . 190 VK_OEM_PERIOD */ - VK_SLASH, /* / 191 VK_OEM_2 */ + VK_COMMA, /* , 188 VK_OEM_COMMA */ + VK_PERIOD, /* . 190 VK_OEM_PERIOD */ + VK_SLASH, /* / 191 VK_OEM_2 */ - VK_xDF, /* ß (?) 223*/ - VK_OEM_102, /* < > | 226 */ - 0 -}; + VK_xDF, /* ß (?) 223*/ + VK_OEM_102, /* < > | 226 */ + 0}; typedef std::vector vec_string_1D; @@ -63,442 +61,442 @@ typedef std::vector > vec_dword_2D; typedef std::vector > > vec_dword_3D; static KMX_DWORD INVALID_NAME = 0; -static KMX_DWORD keycode_max = 94; +static KMX_DWORD keycode_max = 94; static KMX_DWORD deadkey_min = 0xfe50; // X11's keysymdef.h defines deadkeys between 0xfe50-0xfe93 static KMX_DWORD deadkey_max = 0xfe93; // https://fossies.org/linux/tk/xlib/X11/keysymdef.h // map Shiftstate to modifier (e.g. 0->0; 16-1; 9->2; 25->3) -int map_VKShiftState_to_LinModifier(int VKShiftState); +int convert_WinShiftstate_to_LinuxShiftstate(int VKShiftState); // check if input is correct -bool ensureValidInputForKeyboardTranslation(int shift_state_pos, gint count, guint keycode); +bool ensureValidInputForKeyboardTranslation(int shiftstate, int count, int keycode); // take a std::string (=contents of line symbols-file ) and returns the (int) value of the character KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str); // create a Vector with all entries of both keymaps -int createOneVectorFromBothKeyboards(vec_dword_3D &All_Vector,GdkKeymap *keymap); +int createOneVectorFromBothKeyboards(vec_dword_3D& All_Vector, GdkKeymap* keymap); // read configuration file, split and write to 3D-Vector (Data for US on Vector[0][ ][ ] ) -int write_US_ToVector(vec_dword_3D &vec, std::string language, const char *text); +int write_US_ToVector(vec_dword_3D& vec, std::string language, const char* text); // 1. step: read complete Row of Configuration file US -bool createCompleteVector_US(FILE *fpp, const char *text, vec_string_1D &complete_List); +bool createCompleteVector_US(FILE* fpp, const char* text, vec_string_1D& complete_List); // replace Name of Key (e.g. ) wih Keycode ( e.g. 15 ) -int replace_KeyName_with_Keycode(std::string in); +int replace_KeyName_with_Keycode(std::string in); // 2. step: write contents to 3D vector -int split_US_To_3D_Vector(vec_dword_3D &all_US, vec_string_1D completeList); +int split_US_To_3D_Vector(vec_dword_3D& all_US, vec_string_1D completeList); // create an empty 2D vector containing 0 in all fields vec_dword_2D create_empty_2D_Vector(int dim_rows, int dim_shifts); // append characters to 3D-Vector using GDK (Data for underlying Language on Vector[1][ ][ ] ) -int append_underlying_ToVector(vec_dword_3D &All_Vector, GdkKeymap *keymap); +int append_underlying_ToVector(vec_dword_3D& All_Vector, GdkKeymap* keymap); // initialize GDK -bool InitializeGDK(GdkKeymap **keymap,int argc, gchar *argv[]); +bool InitializeGDK(GdkKeymap** keymap, int argc, gchar* argv[]); //------------------------------ const UINT USVirtualKeyToScanCode[256] = { - 0x00, // L"K_?00", // &H0 - 0x00, // L"K_LBUTTON", // &H1 - 0x00, // L"K_RBUTTON", // &H2 - 0x46, // L"K_CANCEL", // &H3 - 0x00, // L"K_MBUTTON", // &H4 - 0x00, // L"K_?05", // &H5 - 0x00, // L"K_?06", // &H6 - 0x00, // L"K_?07", // &H7 - 0x0E, // L"K_BKSP", // &H8 - 0x0F, // L"K_TAB", // &H9 - 0x00, // L"K_?0A", // &HA - 0x00, // L"K_?0B", // &HB - 0x4C, // L"K_KP5", // &HC - 0x1C, // L"K_ENTER", // &HD - 0x00, // L"K_?0E", // &HE - 0x00, // L"K_?0F", // &HF - 0x2A, // L"K_SHIFT", // &H10 - 0x1D, // L"K_CONTRO0x00, // L", // &H11 - 0x38, // L"K_ALT", // &H12 - 0x00, // L"K_PAUSE", // &H13 - 0x3A, // L"K_CAPS", // &H14 - 0x00, // L"K_KANJI?15", // &H15 - 0x00, // L"K_KANJI?16", // &H16 - 0x00, // L"K_KANJI?17", // &H17 - 0x00, // L"K_KANJI?18", // &H18 - 0x00, // L"K_KANJI?19", // &H19 - 0x00, // L"K_?1A", // &H1A - 0x01, // L"K_ESC", // &H1B - 0x00, // L"K_KANJI?1C", // &H1C - 0x00, // L"K_KANJI?1D", // &H1D - 0x00, // L"K_KANJI?1E", // &H1E - 0x00, // L"K_KANJI?1F", // &H1F - 0x39, // L"K_SPACE", // &H20 - 0x49, // L"K_PGUP", // &H21 - 0x51, // L"K_PGDN", // &H22 - 0x4F, // L"K_END", // &H23 - 0x47, // L"K_HOME", // &H24 - 0x4B, // L"K_LEFT", // &H25 - 0x48, // L"K_UP", // &H26 - 0x4D, // L"K_RIGHT", // &H27 - 0x50, // L"K_DOWN", // &H28 - 0x00, // L"K_SEL", // &H29 - 0x00, // L"K_PRINT", // &H2A - 0x00, // L"K_EXEC", // &H2B - 0x54, // L"K_PRTSCN", // &H2C - 0x52, // L"K_INS", // &H2D - 0x53, // L"K_DEL", // &H2E - 0x63, // L"K_HELP", // &H2F - 0x0B, // L"K_0", // &H30 - 0x02, // L"K_1", // &H31 - 0x03, // L"K_2", // &H32 - 0x04, // L"K_3", // &H33 - 0x05, // L"K_4", // &H34 - 0x06, // L"K_5", // &H35 - 0x07, // L"K_6", // &H36 - 0x08, // L"K_7", // &H37 - 0x09, // L"K_8", // &H38 - 0x0A, // L"K_9", // &H39 - 0x00, // L"K_?3A", // &H3A - 0x00, // L"K_?3B", // &H3B - 0x00, // L"K_?3C", // &H3C - 0x00, // L"K_?3D", // &H3D - 0x00, // L"K_?3E", // &H3E - 0x00, // L"K_?3F", // &H3F - 0x00, // L"K_?40", // &H40 - 0x1E, // L"K_A", // &H41 - 0x30, // L"K_B", // &H42 - 0x2E, // L"K_C", // &H43 - 0x20, // L"K_D", // &H44 - 0x12, // L"K_E", // &H45 - 0x21, // L"K_F", // &H46 - 0x22, // L"K_G", // &H47 - 0x23, // L"K_H", // &H48 - 0x17, // L"K_I", // &H49 - 0x24, // L"K_J", // &H4A - 0x25, // L"K_K", // &H4B - 0x26, // L"K_L", // &H4C - 0x32, // L"K_M", // &H4D - 0x31, // L"K_N", // &H4E - 0x18, // L"K_O", // &H4F - 0x19, // L"K_P", // &H50 - 0x10, // L"K_Q", // &H51 - 0x13, // L"K_R", // &H52 - 0x1F, // L"K_S", // &H53 - 0x14, // L"K_T", // &H54 - 0x16, // L"K_U", // &H55 - 0x2F, // L"K_V", // &H56 - 0x11, // L"K_W", // &H57 - 0x2D, // L"K_X", // &H58 - 0x15, // L"K_Y", // &H59 - 0x2C, // L"K_Z", // &H5A - 0x5B, // L"K_?5B", // &H5B - 0x5C, // L"K_?5C", // &H5C - 0x5D, // L"K_?5D", // &H5D - 0x00, // L"K_?5E", // &H5E - 0x5F, // L"K_?5F", // &H5F - 0x52, // L"K_NP0", // &H60 - 0x4F, // L"K_NP1", // &H61 - 0x50, // L"K_NP2", // &H62 - 0x51, // L"K_NP3", // &H63 - 0x4B, // L"K_NP4", // &H64 - 0x4C, // L"K_NP5", // &H65 - 0x4D, // L"K_NP6", // &H66 - 0x47, // L"K_NP7", // &H67 - 0x48, // L"K_NP8", // &H68 - 0x49, // L"K_NP9", // &H69 - 0x37, // L"K_NPSTAR", // &H6A - 0x4E, // L"K_NPPLUS", // &H6B - 0x7E, // L"K_SEPARATOR", // &H6C // MCD 01-11-02: Brazilian Fix, 00 -> 7E - 0x4A, // L"K_NPMINUS", // &H6D - 0x53, // L"K_NPDOT", // &H6E - 0x135, // L"K_NPSLASH", // &H6F - 0x3B, // L"K_F1", // &H70 - 0x3C, // L"K_F2", // &H71 - 0x3D, // L"K_F3", // &H72 - 0x3E, // L"K_F4", // &H73 - 0x3F, // L"K_F5", // &H74 - 0x40, // L"K_F6", // &H75 - 0x41, // L"K_F7", // &H76 - 0x42, // L"K_F8", // &H77 - 0x43, // L"K_F9", // &H78 - 0x44, // L"K_F10", // &H79 - 0x57, // L"K_F11", // &H7A - 0x58, // L"K_F12", // &H7B - 0x64, // L"K_F13", // &H7C - 0x65, // L"K_F14", // &H7D - 0x66, // L"K_F15", // &H7E - 0x67, // L"K_F16", // &H7F - 0x68, // L"K_F17", // &H80 - 0x69, // L"K_F18", // &H81 - 0x6A, // L"K_F19", // &H82 - 0x6B, // L"K_F20", // &H83 - 0x6C, // L"K_F21", // &H84 - 0x6D, // L"K_F22", // &H85 - 0x6E, // L"K_F23", // &H86 - 0x76, // L"K_F24", // &H87 + 0x00, // L"K_?00", // &H0 + 0x00, // L"K_LBUTTON", // &H1 + 0x00, // L"K_RBUTTON", // &H2 + 0x46, // L"K_CANCEL", // &H3 + 0x00, // L"K_MBUTTON", // &H4 + 0x00, // L"K_?05", // &H5 + 0x00, // L"K_?06", // &H6 + 0x00, // L"K_?07", // &H7 + 0x0E, // L"K_BKSP", // &H8 + 0x0F, // L"K_TAB", // &H9 + 0x00, // L"K_?0A", // &HA + 0x00, // L"K_?0B", // &HB + 0x4C, // L"K_KP5", // &HC + 0x1C, // L"K_ENTER", // &HD + 0x00, // L"K_?0E", // &HE + 0x00, // L"K_?0F", // &HF + 0x2A, // L"K_SHIFT", // &H10 + 0x1D, // L"K_CONTROL", // &H11 + 0x38, // L"K_ALT", // &H12 + 0x00, // L"K_PAUSE", // &H13 + 0x3A, // L"K_CAPS", // &H14 + 0x00, // L"K_KANJI?15", // &H15 + 0x00, // L"K_KANJI?16", // &H16 + 0x00, // L"K_KANJI?17", // &H17 + 0x00, // L"K_KANJI?18", // &H18 + 0x00, // L"K_KANJI?19", // &H19 + 0x00, // L"K_?1A", // &H1A + 0x01, // L"K_ESC", // &H1B + 0x00, // L"K_KANJI?1C", // &H1C + 0x00, // L"K_KANJI?1D", // &H1D + 0x00, // L"K_KANJI?1E", // &H1E + 0x00, // L"K_KANJI?1F", // &H1F + 0x39, // L"K_SPACE", // &H20 + 0x49, // L"K_PGUP", // &H21 + 0x51, // L"K_PGDN", // &H22 + 0x4F, // L"K_END", // &H23 + 0x47, // L"K_HOME", // &H24 + 0x4B, // L"K_LEFT", // &H25 + 0x48, // L"K_UP", // &H26 + 0x4D, // L"K_RIGHT", // &H27 + 0x50, // L"K_DOWN", // &H28 + 0x00, // L"K_SEL", // &H29 + 0x00, // L"K_PRINT", // &H2A + 0x00, // L"K_EXEC", // &H2B + 0x54, // L"K_PRTSCN", // &H2C + 0x52, // L"K_INS", // &H2D + 0x53, // L"K_DEL", // &H2E + 0x63, // L"K_HELP", // &H2F + 0x0B, // L"K_0", // &H30 + 0x02, // L"K_1", // &H31 + 0x03, // L"K_2", // &H32 + 0x04, // L"K_3", // &H33 + 0x05, // L"K_4", // &H34 + 0x06, // L"K_5", // &H35 + 0x07, // L"K_6", // &H36 + 0x08, // L"K_7", // &H37 + 0x09, // L"K_8", // &H38 + 0x0A, // L"K_9", // &H39 + 0x00, // L"K_?3A", // &H3A + 0x00, // L"K_?3B", // &H3B + 0x00, // L"K_?3C", // &H3C + 0x00, // L"K_?3D", // &H3D + 0x00, // L"K_?3E", // &H3E + 0x00, // L"K_?3F", // &H3F + 0x00, // L"K_?40", // &H40 + 0x1E, // L"K_A", // &H41 + 0x30, // L"K_B", // &H42 + 0x2E, // L"K_C", // &H43 + 0x20, // L"K_D", // &H44 + 0x12, // L"K_E", // &H45 + 0x21, // L"K_F", // &H46 + 0x22, // L"K_G", // &H47 + 0x23, // L"K_H", // &H48 + 0x17, // L"K_I", // &H49 + 0x24, // L"K_J", // &H4A + 0x25, // L"K_K", // &H4B + 0x26, // L"K_L", // &H4C + 0x32, // L"K_M", // &H4D + 0x31, // L"K_N", // &H4E + 0x18, // L"K_O", // &H4F + 0x19, // L"K_P", // &H50 + 0x10, // L"K_Q", // &H51 + 0x13, // L"K_R", // &H52 + 0x1F, // L"K_S", // &H53 + 0x14, // L"K_T", // &H54 + 0x16, // L"K_U", // &H55 + 0x2F, // L"K_V", // &H56 + 0x11, // L"K_W", // &H57 + 0x2D, // L"K_X", // &H58 + 0x15, // L"K_Y", // &H59 + 0x2C, // L"K_Z", // &H5A + 0x5B, // L"K_?5B", // &H5B + 0x5C, // L"K_?5C", // &H5C + 0x5D, // L"K_?5D", // &H5D + 0x00, // L"K_?5E", // &H5E + 0x5F, // L"K_?5F", // &H5F + 0x52, // L"K_NP0", // &H60 + 0x4F, // L"K_NP1", // &H61 + 0x50, // L"K_NP2", // &H62 + 0x51, // L"K_NP3", // &H63 + 0x4B, // L"K_NP4", // &H64 + 0x4C, // L"K_NP5", // &H65 + 0x4D, // L"K_NP6", // &H66 + 0x47, // L"K_NP7", // &H67 + 0x48, // L"K_NP8", // &H68 + 0x49, // L"K_NP9", // &H69 + 0x37, // L"K_NPSTAR", // &H6A + 0x4E, // L"K_NPPLUS", // &H6B + 0x7E, // L"K_SEPARATOR", // &H6C // MCD 01-11-02: Brazilian Fix, 00 -> 7E + 0x4A, // L"K_NPMINUS", // &H6D + 0x53, // L"K_NPDOT", // &H6E + 0x135, // L"K_NPSLASH", // &H6F + 0x3B, // L"K_F1", // &H70 + 0x3C, // L"K_F2", // &H71 + 0x3D, // L"K_F3", // &H72 + 0x3E, // L"K_F4", // &H73 + 0x3F, // L"K_F5", // &H74 + 0x40, // L"K_F6", // &H75 + 0x41, // L"K_F7", // &H76 + 0x42, // L"K_F8", // &H77 + 0x43, // L"K_F9", // &H78 + 0x44, // L"K_F10", // &H79 + 0x57, // L"K_F11", // &H7A + 0x58, // L"K_F12", // &H7B + 0x64, // L"K_F13", // &H7C + 0x65, // L"K_F14", // &H7D + 0x66, // L"K_F15", // &H7E + 0x67, // L"K_F16", // &H7F + 0x68, // L"K_F17", // &H80 + 0x69, // L"K_F18", // &H81 + 0x6A, // L"K_F19", // &H82 + 0x6B, // L"K_F20", // &H83 + 0x6C, // L"K_F21", // &H84 + 0x6D, // L"K_F22", // &H85 + 0x6E, // L"K_F23", // &H86 + 0x76, // L"K_F24", // &H87 - 0x00, // L"K_?88", // &H88 - 0x00, // L"K_?89", // &H89 - 0x00, // L"K_?8A", // &H8A - 0x00, // L"K_?8B", // &H8B - 0x00, // L"K_?8C", // &H8C - 0x00, // L"K_?8D", // &H8D - 0x00, // L"K_?8E", // &H8E - 0x00, // L"K_?8F", // &H8F + 0x00, // L"K_?88", // &H88 + 0x00, // L"K_?89", // &H89 + 0x00, // L"K_?8A", // &H8A + 0x00, // L"K_?8B", // &H8B + 0x00, // L"K_?8C", // &H8C + 0x00, // L"K_?8D", // &H8D + 0x00, // L"K_?8E", // &H8E + 0x00, // L"K_?8F", // &H8F - 0x45, // L"K_NUMLOCK", // &H90 - 0x46, // L"K_SCROL0x00, // &H91 + 0x45, // L"K_NUMLOCK", // &H90 + 0x46, // L"K_SCROL", // &H91 - 0x00, // L"K_?92", // &H92 - 0x00, // L"K_?93", // &H93 - 0x00, // L"K_?94", // &H94 - 0x00, // L"K_?95", // &H95 - 0x00, // L"K_?96", // &H96 - 0x00, // L"K_?97", // &H97 - 0x00, // L"K_?98", // &H98 - 0x00, // L"K_?99", // &H99 - 0x00, // L"K_?9A", // &H9A - 0x00, // L"K_?9B", // &H9B - 0x00, // L"K_?9C", // &H9C - 0x00, // L"K_?9D", // &H9D - 0x00, // L"K_?9E", // &H9E - 0x00, // L"K_?9F", // &H9F - 0x2A, // L"K_?A0", // &HA0 - 0x36, // L"K_?A1", // &HA1 - 0x1D, // L"K_?A2", // &HA2 - 0x1D, // L"K_?A3", // &HA3 - 0x38, // L"K_?A4", // &HA4 - 0x38, // L"K_?A5", // &HA5 - 0x6A, // L"K_?A6", // &HA6 - 0x69, // L"K_?A7", // &HA7 - 0x67, // L"K_?A8", // &HA8 - 0x68, // L"K_?A9", // &HA9 - 0x65, // L"K_?AA", // &HAA - 0x66, // L"K_?AB", // &HAB - 0x32, // L"K_?AC", // &HAC - 0x20, // L"K_?AD", // &HAD - 0x2E, // L"K_?AE", // &HAE - 0x30, // L"K_?AF", // &HAF - 0x19, // L"K_?B0", // &HB0 - 0x10, // L"K_?B1", // &HB1 - 0x24, // L"K_?B2", // &HB2 - 0x22, // L"K_?B3", // &HB3 - 0x6C, // L"K_?B4", // &HB4 - 0x6D, // L"K_?B5", // &HB5 - 0x6B, // L"K_?B6", // &HB6 - 0x21, // L"K_?B7", // &HB7 - 0x00, // L"K_?B8", // &HB8 - 0x00, // L"K_?B9", // &HB9 - 0x27, // L"K_COLON", // &HBA - 0x0D, // L"K_EQUA0x00, // L", // &HBB - 0x33, // L"K_COMMA", // &HBC - 0x0C, // L"K_HYPHEN", // &HBD - 0x34, // L"K_PERIOD", // &HBE - 0x35, // L"K_SLASH", // &HBF - 0x29, // L"K_BKQUOTE", // &HC0 + 0x00, // L"K_?92", // &H92 + 0x00, // L"K_?93", // &H93 + 0x00, // L"K_?94", // &H94 + 0x00, // L"K_?95", // &H95 + 0x00, // L"K_?96", // &H96 + 0x00, // L"K_?97", // &H97 + 0x00, // L"K_?98", // &H98 + 0x00, // L"K_?99", // &H99 + 0x00, // L"K_?9A", // &H9A + 0x00, // L"K_?9B", // &H9B + 0x00, // L"K_?9C", // &H9C + 0x00, // L"K_?9D", // &H9D + 0x00, // L"K_?9E", // &H9E + 0x00, // L"K_?9F", // &H9F + 0x2A, // L"K_?A0", // &HA0 + 0x36, // L"K_?A1", // &HA1 + 0x1D, // L"K_?A2", // &HA2 + 0x1D, // L"K_?A3", // &HA3 + 0x38, // L"K_?A4", // &HA4 + 0x38, // L"K_?A5", // &HA5 + 0x6A, // L"K_?A6", // &HA6 + 0x69, // L"K_?A7", // &HA7 + 0x67, // L"K_?A8", // &HA8 + 0x68, // L"K_?A9", // &HA9 + 0x65, // L"K_?AA", // &HAA + 0x66, // L"K_?AB", // &HAB + 0x32, // L"K_?AC", // &HAC + 0x20, // L"K_?AD", // &HAD + 0x2E, // L"K_?AE", // &HAE + 0x30, // L"K_?AF", // &HAF + 0x19, // L"K_?B0", // &HB0 + 0x10, // L"K_?B1", // &HB1 + 0x24, // L"K_?B2", // &HB2 + 0x22, // L"K_?B3", // &HB3 + 0x6C, // L"K_?B4", // &HB4 + 0x6D, // L"K_?B5", // &HB5 + 0x6B, // L"K_?B6", // &HB6 + 0x21, // L"K_?B7", // &HB7 + 0x00, // L"K_?B8", // &HB8 + 0x00, // L"K_?B9", // &HB9 + 0x27, // L"K_COLON", // &HBA + 0x0D, // L"K_EQUAL", // &HBB + 0x33, // L"K_COMMA", // &HBC + 0x0C, // L"K_HYPHEN", // &HBD + 0x34, // L"K_PERIOD", // &HBE + 0x35, // L"K_SLASH", // &HBF + 0x29, // L"K_BKQUOTE", // &HC0 - 0x73, // L"K_?C1", // &HC1 - 0x7E, // L"K_?C2", // &HC2 - 0x00, // L"K_?C3", // &HC3 - 0x00, // L"K_?C4", // &HC4 - 0x00, // L"K_?C5", // &HC5 - 0x00, // L"K_?C6", // &HC6 - 0x00, // L"K_?C7", // &HC7 - 0x00, // L"K_?C8", // &HC8 - 0x00, // L"K_?C9", // &HC9 - 0x00, // L"K_?CA", // &HCA - 0x00, // L"K_?CB", // &HCB - 0x00, // L"K_?CC", // &HCC - 0x00, // L"K_?CD", // &HCD - 0x00, // L"K_?CE", // &HCE - 0x00, // L"K_?CF", // &HCF - 0x00, // L"K_?D0", // &HD0 - 0x00, // L"K_?D1", // &HD1 - 0x00, // L"K_?D2", // &HD2 - 0x00, // L"K_?D3", // &HD3 - 0x00, // L"K_?D4", // &HD4 - 0x00, // L"K_?D5", // &HD5 - 0x00, // L"K_?D6", // &HD6 - 0x00, // L"K_?D7", // &HD7 - 0x00, // L"K_?D8", // &HD8 - 0x00, // L"K_?D9", // &HD9 - 0x00, // L"K_?DA", // &HDA - 0x1A, // L"K_LBRKT", // &HDB - 0x2B, // L"K_BKSLASH", // &HDC - 0x1B, // L"K_RBRKT", // &HDD - 0x28, // L"K_QUOTE", // &HDE - 0x73, // L"K_oDF", // &HDF // MCD 01-11-02: Brazilian fix: 00 -> 73 - 0x00, // L"K_oE0", // &HE0 - 0x00, // L"K_oE1", // &HE1 - 0x56, // L"K_oE2", // &HE2 - 0x00, // L"K_oE3", // &HE3 - 0x00, // L"K_oE4", // &HE4 + 0x73, // L"K_?C1", // &HC1 + 0x7E, // L"K_?C2", // &HC2 + 0x00, // L"K_?C3", // &HC3 + 0x00, // L"K_?C4", // &HC4 + 0x00, // L"K_?C5", // &HC5 + 0x00, // L"K_?C6", // &HC6 + 0x00, // L"K_?C7", // &HC7 + 0x00, // L"K_?C8", // &HC8 + 0x00, // L"K_?C9", // &HC9 + 0x00, // L"K_?CA", // &HCA + 0x00, // L"K_?CB", // &HCB + 0x00, // L"K_?CC", // &HCC + 0x00, // L"K_?CD", // &HCD + 0x00, // L"K_?CE", // &HCE + 0x00, // L"K_?CF", // &HCF + 0x00, // L"K_?D0", // &HD0 + 0x00, // L"K_?D1", // &HD1 + 0x00, // L"K_?D2", // &HD2 + 0x00, // L"K_?D3", // &HD3 + 0x00, // L"K_?D4", // &HD4 + 0x00, // L"K_?D5", // &HD5 + 0x00, // L"K_?D6", // &HD6 + 0x00, // L"K_?D7", // &HD7 + 0x00, // L"K_?D8", // &HD8 + 0x00, // L"K_?D9", // &HD9 + 0x00, // L"K_?DA", // &HDA + 0x1A, // L"K_LBRKT", // &HDB + 0x2B, // L"K_BKSLASH", // &HDC + 0x1B, // L"K_RBRKT", // &HDD + 0x28, // L"K_QUOTE", // &HDE + 0x73, // L"K_oDF", // &HDF // MCD 01-11-02: Brazilian fix: 00 -> 73 + 0x00, // L"K_oE0", // &HE0 + 0x00, // L"K_oE1", // &HE1 + 0x56, // L"K_oE2", // &HE2 + 0x00, // L"K_oE3", // &HE3 + 0x00, // L"K_oE4", // &HE4 - 0x00, // L"K_?E5", // &HE5 + 0x00, // L"K_?E5", // &HE5 - 0x00, // L"K_oE6", // &HE6 + 0x00, // L"K_oE6", // &HE6 - 0x00, // L"K_?E7", // &HE7 - 0x00, // L"K_?E8", // &HE8 + 0x00, // L"K_?E7", // &HE7 + 0x00, // L"K_?E8", // &HE8 - 0x71, // L"K_oE9", // &HE9 - 0x5C, // L"K_oEA", // &HEA - 0x7B, // L"K_oEB", // &HEB - 0x00, // L"K_oEC", // &HEC - 0x6F, // L"K_oED", // &HED - 0x5A, // L"K_oEE", // &HEE - 0x00, // L"K_oEF", // &HEF - 0x00, // L"K_oF0", // &HF0 - 0x5B, // L"K_oF1", // &HF1 - 0x00, // L"K_oF2", // &HF2 - 0x5F, // L"K_oF3", // &HF3 - 0x00, // L"K_oF4", // &HF4 - 0x5E, // L"K_oF5", // &HF5 + 0x71, // L"K_oE9", // &HE9 + 0x5C, // L"K_oEA", // &HEA + 0x7B, // L"K_oEB", // &HEB + 0x00, // L"K_oEC", // &HEC + 0x6F, // L"K_oED", // &HED + 0x5A, // L"K_oEE", // &HEE + 0x00, // L"K_oEF", // &HEF + 0x00, // L"K_oF0", // &HF0 + 0x5B, // L"K_oF1", // &HF1 + 0x00, // L"K_oF2", // &HF2 + 0x5F, // L"K_oF3", // &HF3 + 0x00, // L"K_oF4", // &HF4 + 0x5E, // L"K_oF5", // &HF5 - 0x00, // L"K_?F6", // &HF6 - 0x00, // L"K_?F7", // &HF7 - 0x00, // L"K_?F8", // &HF8 - 0x5D, // L"K_?F9", // &HF9 - 0x00, // L"K_?FA", // &HFA - 0x62, // L"K_?FB", // &HFB - 0x00, // L"K_?FC", // &HFC - 0x00, // L"K_?FD", // &HFD - 0x00, // L"K_?FE", // &HFE - 0x00 // L"K_?FF" // &HFF + 0x00, // L"K_?F6", // &HF6 + 0x00, // L"K_?F7", // &HF7 + 0x00, // L"K_?F8", // &HF8 + 0x5D, // L"K_?F9", // &HF9 + 0x00, // L"K_?FA", // &HFA + 0x62, // L"K_?FB", // &HFB + 0x00, // L"K_?FC", // &HFC + 0x00, // L"K_?FD", // &HFD + 0x00, // L"K_?FE", // &HFE + 0x00 // L"K_?FF" // &HFF }; const UINT ScanCodeToUSVirtualKey[128] = { - 0x01, // 0x00 => K_LBUTTON - 0x1b, // 0x01 => K_ESC - 0x31, // 0x02 => K_1 - 0x32, // 0x03 => K_2 - 0x33, // 0x04 => K_3 - 0x34, // 0x05 => K_4 - 0x35, // 0x06 => K_5 - 0x36, // 0x07 => K_6 - 0x37, // 0x08 => K_7 - 0x38, // 0x09 => K_8 - 0x39, // 0x0a => K_9 - 0x30, // 0x0b => K_0 - 0xbd, // 0x0c => K_HYPHEN - 0xbb, // 0x0d => K_EQUAL - 0x08, // 0x0e => K_BKSP - 0x09, // 0x0f => K_TAB - 0x51, // 0x10 => K_Q - 0x57, // 0x11 => K_W - 0x45, // 0x12 => K_E - 0x52, // 0x13 => K_R - 0x54, // 0x14 => K_T 20 - 0x59, // 0x15 => K_Y - 0x55, // 0x16 => K_U - 0x49, // 0x17 => K_I - 0x4f, // 0x18 => K_O - 0x50, // 0x19 => K_P - 0xdb, // 0x1a => K_LBRKT - 0xdd, // 0x1b => K_RBRKT - 0x0d, // 0x1c => K_ENTER - 0x11, // 0x1d => K_CONTROL - 0x41, // 0x1e => K_A - 0x53, // 0x1f => K_S - 0x44, // 0x20 => K_D - 0x46, // 0x21 => K_F - 0x47, // 0x22 => K_G - 0x48, // 0x23 => K_H - 0x4a, // 0x24 => K_J - 0x4b, // 0x25 => K_K - 0x4c, // 0x26 => K_L - 0xba, // 0x27 => K_COLON 39 - 0xde, // 0x28 => K_QUOTE - 0xc0, // 0x29 => K_BKQUOTE - 0x10, // 0x2a => K_SHIFT - 0xdc, // 0x2b => K_BKSLASH - 0x5a, // 0x2c => K_Z - 0x58, // 0x2d => K_X - 0x43, // 0x2e => K_C - 0x56, // 0x2f => K_V - 0x42, // 0x30 => K_B - 0x4e, // 0x31 => K_N - 0x4d, // 0x32 => K_M - 0xbc, // 0x33 => K_COMMA - 0xbe, // 0x34 => K_PERIOD - 0xbf, // 0x35 => K_SLASH - 0xa1, // 0x36 => K_?A1 - 0x6a, // 0x37 => K_NPSTAR - 0x12, // 0x38 => K_ALT - 0x20, // 0x39 => K_SPACE - 0x14, // 0x3a => K_CAPS - 0x70, // 0x3b => K_F1 59 - 0x71, // 0x3c => K_F2 - 0x72, // 0x3d => K_F3 - 0x73, // 0x3e => K_F4 - 0x74, // 0x3f => K_F5 - 0x75, // 0x40 => K_F6 - 0x76, // 0x41 => K_F7 - 0x77, // 0x42 => K_F8 - 0x78, // 0x43 => K_F9 - 0x79, // 0x44 => K_F10 - 0x90, // 0x45 => K_NUMLOCK - 0x03, // 0x46 => K_CANCEL - 0x24, // 0x47 => K_HOME - 0x26, // 0x48 => K_UP - 0x21, // 0x49 => K_PGUP - 0x6d, // 0x4a => K_NPMINUS - 0x25, // 0x4b => K_LEFT - 0x0c, // 0x4c => K_KP5 - 0x27, // 0x4d => K_RIGHT - 0x6b, // 0x4e => K_NPPLUS - 0x23, // 0x4f => K_END - 0x28, // 0x50 => K_DOWN - 0x22, // 0x51 => K_PGDN - 0x2d, // 0x52 => K_INS - 0x2e, // 0x53 => K_DEL - 0x2c, // 0x54 => K_PRTSCN - 0x00, // 0x55 => No match - 0xe2, // 0x56 => K_oE2 - 0x7a, // 0x57 => K_F11 - 0x7b, // 0x58 => K_F12 - 0x00, // 0x59 => No match - 0xee, // 0x5a => K_oEE - 0x5b, // 0x5b => K_?5B - 0x5c, // 0x5c => K_?5C - 0x5d, // 0x5d => K_?5D - 0xf5, // 0x5e => K_oF5 - 0x5f, // 0x5f => K_?5F - 0x00, // 0x60 => No match - 0x00, // 0x61 => No match - 0xfb, // 0x62 => K_?FB - 0x2f, // 0x63 => K_HELP - 0x7c, // 0x64 => K_F13 - 0x7d, // 0x65 => K_F14 - 0x7e, // 0x66 => K_F15 - 0x7f, // 0x67 => K_F16 - 0x80, // 0x68 => K_F17 - 0x81, // 0x69 => K_F18 - 0x82, // 0x6a => K_F19 - 0x83, // 0x6b => K_F20 - 0x84, // 0x6c => K_F21 - 0x85, // 0x6d => K_F22 - 0x86, // 0x6e => K_F23 - 0xed, // 0x6f => K_oED - 0x00, // 0x70 => No match - 0xe9, // 0x71 => K_oE9 - 0x00, // 0x72 => No match - 0xc1, // 0x73 => K_?C1 - 0x00, // 0x74 => No match - 0x00, // 0x75 => No match - 0x87, // 0x76 => K_F24 - 0x00, // 0x77 => No match - 0x00, // 0x78 => No match - 0x00, // 0x79 => No match - 0x00, // 0x7a => No match - 0xeb, // 0x7b => K_oEB - 0x00, // 0x7c => No match - 0x00, // 0x7d => No match - 0x6c, // 0x7e => K_SEPARATOR - 0x00 // 0x7f => No match + 0x01, // 0x00 => K_LBUTTON + 0x1b, // 0x01 => K_ESC + 0x31, // 0x02 => K_1 + 0x32, // 0x03 => K_2 + 0x33, // 0x04 => K_3 + 0x34, // 0x05 => K_4 + 0x35, // 0x06 => K_5 + 0x36, // 0x07 => K_6 + 0x37, // 0x08 => K_7 + 0x38, // 0x09 => K_8 + 0x39, // 0x0a => K_9 + 0x30, // 0x0b => K_0 + 0xbd, // 0x0c => K_HYPHEN + 0xbb, // 0x0d => K_EQUAL + 0x08, // 0x0e => K_BKSP + 0x09, // 0x0f => K_TAB + 0x51, // 0x10 => K_Q + 0x57, // 0x11 => K_W + 0x45, // 0x12 => K_E + 0x52, // 0x13 => K_R + 0x54, // 0x14 => K_T + 0x59, // 0x15 => K_Y + 0x55, // 0x16 => K_U + 0x49, // 0x17 => K_I + 0x4f, // 0x18 => K_O + 0x50, // 0x19 => K_P + 0xdb, // 0x1a => K_LBRKT + 0xdd, // 0x1b => K_RBRKT + 0x0d, // 0x1c => K_ENTER + 0x11, // 0x1d => K_CONTROL + 0x41, // 0x1e => K_A + 0x53, // 0x1f => K_S + 0x44, // 0x20 => K_D + 0x46, // 0x21 => K_F + 0x47, // 0x22 => K_G + 0x48, // 0x23 => K_H + 0x4a, // 0x24 => K_J + 0x4b, // 0x25 => K_K + 0x4c, // 0x26 => K_L + 0xba, // 0x27 => K_COLON + 0xde, // 0x28 => K_QUOTE + 0xc0, // 0x29 => K_BKQUOTE + 0x10, // 0x2a => K_SHIFT + 0xdc, // 0x2b => K_BKSLASH + 0x5a, // 0x2c => K_Z + 0x58, // 0x2d => K_X + 0x43, // 0x2e => K_C + 0x56, // 0x2f => K_V + 0x42, // 0x30 => K_B + 0x4e, // 0x31 => K_N + 0x4d, // 0x32 => K_M + 0xbc, // 0x33 => K_COMMA + 0xbe, // 0x34 => K_PERIOD + 0xbf, // 0x35 => K_SLASH + 0xa1, // 0x36 => K_?A1 + 0x6a, // 0x37 => K_NPSTAR + 0x12, // 0x38 => K_ALT + 0x20, // 0x39 => K_SPACE + 0x14, // 0x3a => K_CAPS + 0x70, // 0x3b => K_F1 + 0x71, // 0x3c => K_F2 + 0x72, // 0x3d => K_F3 + 0x73, // 0x3e => K_F4 + 0x74, // 0x3f => K_F5 + 0x75, // 0x40 => K_F6 + 0x76, // 0x41 => K_F7 + 0x77, // 0x42 => K_F8 + 0x78, // 0x43 => K_F9 + 0x79, // 0x44 => K_F10 + 0x90, // 0x45 => K_NUMLOCK + 0x03, // 0x46 => K_CANCEL + 0x24, // 0x47 => K_HOME + 0x26, // 0x48 => K_UP + 0x21, // 0x49 => K_PGUP + 0x6d, // 0x4a => K_NPMINUS + 0x25, // 0x4b => K_LEFT + 0x0c, // 0x4c => K_KP5 + 0x27, // 0x4d => K_RIGHT + 0x6b, // 0x4e => K_NPPLUS + 0x23, // 0x4f => K_END + 0x28, // 0x50 => K_DOWN + 0x22, // 0x51 => K_PGDN + 0x2d, // 0x52 => K_INS + 0x2e, // 0x53 => K_DEL + 0x2c, // 0x54 => K_PRTSCN + 0x00, // 0x55 => No match + 0xe2, // 0x56 => K_oE2 + 0x7a, // 0x57 => K_F11 + 0x7b, // 0x58 => K_F12 + 0x00, // 0x59 => No match + 0xee, // 0x5a => K_oEE + 0x5b, // 0x5b => K_?5B + 0x5c, // 0x5c => K_?5C + 0x5d, // 0x5d => K_?5D + 0xf5, // 0x5e => K_oF5 + 0x5f, // 0x5f => K_?5F + 0x00, // 0x60 => No match + 0x00, // 0x61 => No match + 0xfb, // 0x62 => K_?FB + 0x2f, // 0x63 => K_HELP + 0x7c, // 0x64 => K_F13 + 0x7d, // 0x65 => K_F14 + 0x7e, // 0x66 => K_F15 + 0x7f, // 0x67 => K_F16 + 0x80, // 0x68 => K_F17 + 0x81, // 0x69 => K_F18 + 0x82, // 0x6a => K_F19 + 0x83, // 0x6b => K_F20 + 0x84, // 0x6c => K_F21 + 0x85, // 0x6d => K_F22 + 0x86, // 0x6e => K_F23 + 0xed, // 0x6f => K_oED + 0x00, // 0x70 => No match + 0xe9, // 0x71 => K_oE9 + 0x00, // 0x72 => No match + 0xc1, // 0x73 => K_?C1 + 0x00, // 0x74 => No match + 0x00, // 0x75 => No match + 0x87, // 0x76 => K_F24 + 0x00, // 0x77 => No match + 0x00, // 0x78 => No match + 0x00, // 0x79 => No match + 0x00, // 0x7a => No match + 0xeb, // 0x7b => K_oEB + 0x00, // 0x7c => No match + 0x00, // 0x7d => No match + 0x6c, // 0x7e => K_SEPARATOR + 0x00 // 0x7f => No match }; bool IsKeymanUsedChar(int KV); @@ -507,19 +505,19 @@ bool IsKeymanUsedChar(int KV); std::u16string convert_DeadkeyValues_To_U16str(int in); // use gdk_keymap_translate_keyboard_state to get keyval - base function to get keyvals -int KMX_get_KeyVal_From_KeyCode(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps); +int KMX_get_KeyVal_From_KeyCode(GdkKeymap* keymap, guint keycode, ShiftState ss, int caps); // use KMX_get_KeyVal_From_KeyCode and prevent use of certain keycodes -KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, guint keycode, int shift_state_pos); +KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, guint keycode, int shift_state_pos); // fill Deadkey with dk and return CATEGORY -KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, UINT vk_ShiftState, UINT kc_underlying, PKMX_WCHAR deadkey); +KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, UINT vk_ShiftState, UINT kc_underlying, PKMX_WCHAR deadkey); // use Vector to return the Keyval of underlying Keyboard -KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(vec_dword_3D &All_Vector,KMX_DWORD VK_underlying); +KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(vec_dword_3D& All_Vector, KMX_DWORD VK_underlying); // use Vector to return the Keycode of the underlying Keyboard for given VK_US using GDK -KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap *keymap, vec_dword_3D &All_Vector,KMX_DWORD kc_us, ShiftState ss, int caps); +KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap* keymap, vec_dword_3D& All_Vector, KMX_DWORD kc_us, ShiftState ss, int caps); // return the Keycode of the underlying Keyboard for given VK_US UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD virtualKeyUS); @@ -530,4 +528,4 @@ KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying(KMX_DWORD keycode); // convert codePoint to u16string std::u16string CodePointToU16String(unsigned int codepoint); -# endif /*KEYMAP_H*/ \ No newline at end of file +#endif /*KEYMAP_H*/ diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 96e0b127f6..d830cec25a 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -68,8 +68,11 @@ int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation(shift_state_pos, count, keycode))) + if (!(ensureValidInputForKeyboardTranslation(shift_state_pos, (int)count, (int)keycode))){ + g_free(keyvals); + g_free(maps); return 0; + } KMX_DWORD keyVal = (KMX_DWORD)KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(shift_state_pos), caps); std::u16string str = convert_DeadkeyValues_To_U16str(keyVal); @@ -208,7 +211,7 @@ public: if (st[ich] < 0x20 || st[ich] == 0x7F) { isvalid = false; - wprintf(L"invalid for: %i\n", st[ich]); + printf("invalid for: %i\n", st[ich]); break; } } @@ -265,7 +268,7 @@ public: for (size_t ich = 0; ich < st.size(); ich++) { if (st[ich] < 0x20 || st[ich] == 0x7F) { isvalid = false; - wprintf(L"invalid 16 for: %i\n", st[ich]); + printf("invalid 16 for: %i\n", st[ich]); break; } } diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 64d00273b6..d3ad1577f5 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -89,7 +89,7 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ char16_t* infile = (char16_t*) argv[n], *outfile = (char16_t*) argv[n+1]; - wprintf(L"mcompile%ls \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d" : L"", u16fmt((const char16_t*) infile).c_str(), u16fmt((const char16_t*) outfile).c_str() ); // I4174 + printf("mcompile%ls \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d" : L"", u16fmt((const char16_t*) infile).c_str(), u16fmt((const char16_t*) outfile).c_str() ); // I4174 // 1. Load the keyman keyboard file @@ -412,14 +412,14 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg GdkKeymap *keymap; if(InitializeGDK(&keymap, argc, argv)) { - wprintf(L"ERROR: can't Initialize GDK\n"); + printf("ERROR: can't Initialize GDK\n"); return FALSE; } // create vector that contains Keycode, base, shift for US-KEyboard and underlying keyboard vec_dword_3D all_vector; if(createOneVectorFromBothKeyboards(all_vector, keymap)){ - wprintf(L"ERROR: can't create one vector from both keyboards\n"); + printf("ERROR: can't create one vector from both keyboards\n"); return FALSE; } @@ -435,7 +435,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg UINT scUnderlying = KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]); KMX_WCHAR ch = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap, VKShiftState[j], scUnderlying, &DeadKey); - //wprintf(L"--- VK_%d -> SC_ [%c] dk=%d ( ss %i) \n", KMX_VKMap[i], ch == 0 ? 32 : ch, DeadKey, VKShiftState[j]); + //printf("--- VK_%d -> SC_ [%c] dk=%d ( ss %i) \n", KMX_VKMap[i], ch == 0 ? 32 : ch, DeadKey, VKShiftState[j]); if(bDeadkeyConversion) { // I4552 if(ch == 0xFFFF) { diff --git a/windows/src/engine/keyman32/VKScanCodes.cpp b/windows/src/engine/keyman32/VKScanCodes.cpp index 6a806bcc32..6a7781b2b6 100644 --- a/windows/src/engine/keyman32/VKScanCodes.cpp +++ b/windows/src/engine/keyman32/VKScanCodes.cpp @@ -23,7 +23,7 @@ UINT USVirtualKeyToScanCode[256] = 0x00, // L"K_?00", // &H0 0x00, // L"K_LBUTTON", // &H1 0x00, // L"K_RBUTTON", // &H2 - 0x46, // L"K_CANCE0x00, // L", // &H3 + 0x46, // L"K_CANCEL", // &H3 0x00, // L"K_MBUTTON", // &H4 0x00, // L"K_?05", // &H5 0x00, // L"K_?06", // &H6 @@ -37,7 +37,7 @@ UINT USVirtualKeyToScanCode[256] = 0x00, // L"K_?0E", // &HE 0x00, // L"K_?0F", // &HF 0x2A, // L"K_SHIFT", // &H10 - 0x1D, // L"K_CONTRO0x00, // L", // &H11 + 0x1D, // L"K_CONTROL", // &H11 0x38, // L"K_ALT", // &H12 0x00, // L"K_PAUSE", // &H13 0x3A, // L"K_CAPS", // &H14 @@ -168,7 +168,7 @@ UINT USVirtualKeyToScanCode[256] = 0x00, // L"K_?8F", // &H8F 0x45, // L"K_NUMLOCK", // &H90 - 0x46, // L"K_SCROL0x00, // L", // &H91 + 0x46, // L"K_SCROL", // &H91 0x00, // L"K_?92", // &H92 0x00, // L"K_?93", // &H93 @@ -212,7 +212,7 @@ UINT USVirtualKeyToScanCode[256] = 0x00, // L"K_?B9", // &HB9 0x27, // L"K_COLON", // &HBA - 0x0D, // L"K_EQUA0x00, // L", // &HBB + 0x0D, // L"K_EQUAL", // &HBB 0x33, // L"K_COMMA", // &HBC 0x0C, // L"K_HYPHEN", // &HBD 0x34, // L"K_PERIOD", // &HBE diff --git a/windows/src/global/cpp/VKScanCodes.cpp b/windows/src/global/cpp/VKScanCodes.cpp index 93fb01ba90..dfc0c036f2 100644 --- a/windows/src/global/cpp/VKScanCodes.cpp +++ b/windows/src/global/cpp/VKScanCodes.cpp @@ -38,7 +38,7 @@ const UINT USVirtualKeyToScanCode[256] = 0x00, // L"K_?0E", // &HE 0x00, // L"K_?0F", // &HF 0x2A, // L"K_SHIFT", // &H10 - 0x1D, // L"K_CONTRO0x00, // L", // &H11 + 0x1D, // L"K_CONTROL", // &H11 0x38, // L"K_ALT", // &H12 0x00, // L"K_PAUSE", // &H13 0x3A, // L"K_CAPS", // &H14 @@ -169,7 +169,7 @@ const UINT USVirtualKeyToScanCode[256] = 0x00, // L"K_?8F", // &H8F 0x45, // L"K_NUMLOCK", // &H90 - 0x46, // L"K_SCROL0x00, // L", // &H91 + 0x46, // L"K_SCROL", // &H91 0x00, // L"K_?92", // &H92 0x00, // L"K_?93", // &H93 @@ -213,7 +213,7 @@ const UINT USVirtualKeyToScanCode[256] = 0x00, // L"K_?B9", // &HB9 0x27, // L"K_COLON", // &HBA - 0x0D, // L"K_EQUA0x00, // L", // &HBB + 0x0D, // L"K_EQUAL", // &HBB 0x33, // L"K_COMMA", // &HBC 0x0C, // L"K_HYPHEN", // &HBD 0x34, // L"K_PERIOD", // &HBE From f9c05b872a728b46c6eab627f17fe68608203174 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 24 Jun 2024 09:25:33 +0200 Subject: [PATCH 258/327] feat(linux): second round of comments for 11816 --- linux/mcompile/keymap/keymap.cpp | 21 +++++++++------------ linux/mcompile/keymap/mc_import_rules.cpp | 11 ++--------- linux/mcompile/keymap/meson.build | 2 +- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index e9fcb8200f..e6f98bd5a0 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -772,8 +772,7 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, gui return kVal; } -KMX_DWORD -KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, UINT vk_ShiftState, UINT kc_underlying, PKMX_WCHAR deadkey) { +KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, UINT vk_ShiftState, UINT kc_underlying, PKMX_WCHAR deadkey) { GdkKeymapKey* maps; guint* keyvals; gint count; @@ -783,28 +782,27 @@ KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, UINT vk_Shift return 0; if (!(ensureValidInputForKeyboardTranslation( - convert_WinShiftstate_to_LinuxShiftstate(vk_ShiftState), (int)count, (int)kc_underlying))) { + convert_WinShiftstate_to_LinuxShiftstate(vk_ShiftState), (int)count, (int)kc_underlying))) { g_free(keyvals); g_free(maps); return 0; } - KMX_DWORD keyV = - KMX_get_KeyVal_From_KeyCode(keymap, kc_underlying, ShiftState(convert_WinShiftstate_to_LinuxShiftstate(vk_ShiftState)), 0); + KMX_DWORD keyV = KMX_get_KeyVal_From_KeyCode(keymap, kc_underlying, ShiftState(convert_WinShiftstate_to_LinuxShiftstate(vk_ShiftState)), 0); g_free(keyvals); g_free(maps); - if ((keyV >= deadkey_min) && (keyV <= deadkey_max)) { // deadkey - dky = (PKMX_WCHAR)(convert_DeadkeyValues_To_U16str((int)keyV)).c_str(); + if ((keyV >= deadkey_min) && (keyV <= deadkey_max)) { // deadkey + dky = (PKMX_WCHAR)(convert_DeadkeyValues_To_U16str((int)keyV)).c_str(); *deadkey = *dky; return 0xFFFF; - } else if ((keyV > deadkey_max) || ((keyV < deadkey_min) && (keyV > 0xFF))) // out of range + } else if ((keyV > deadkey_max) || ((keyV < deadkey_min) && (keyV > 0xFF))) // out of range return 0xFFFE; - else // usable char + else // usable char return keyV; } -//_S2 vk_us or underlying!!"!!" + KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(vec_dword_3D& all_vector, KMX_DWORD vk_US) { KMX_DWORD vk_underlying; for (int i = 0; i < (int)all_vector[0].size() - 1; i++) { @@ -818,8 +816,7 @@ KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(vec_dword_3D& all_vector, KMX_D return vk_US; } -KMX_DWORD -KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap* keymap, vec_dword_3D& all_vector, KMX_DWORD kc_us, ShiftState ss, int caps) { +KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap* keymap, vec_dword_3D& all_vector, KMX_DWORD kc_us, ShiftState ss, int caps) { KMX_DWORD kc_underlying; std::u16string u16str = convert_DeadkeyValues_To_U16str(KMX_get_KeyVal_From_KeyCode(keymap, kc_us, ss, caps)); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index d830cec25a..9e54b7da18 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -92,7 +92,7 @@ int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int return 1; } -KMX_WCHAR KMX_DeadKeyMap( int index, std::vector* deadkeys, int deadkeyBase, std::vector* deadkeyMappings) { // I4327 // I4353 +KMX_WCHAR KMX_DeadKeyMap(int index, std::vector* deadkeys, int deadkeyBase, std::vector* deadkeyMappings) { // I4327 // I4353 for (size_t i = 0; i < deadkeyMappings->size(); i++) { if ((*deadkeyMappings)[i].deadkey == index) { return (*deadkeyMappings)[i].dkid; @@ -101,7 +101,7 @@ KMX_WCHAR KMX_DeadKeyMap( int index, std::vector* deadkeys, int deadke for (size_t i = 0; i < deadkeys->size(); i++) { if ((*deadkeys)[i]->KMX_DeadCharacter() == index) { - return (KMX_WCHAR) (deadkeyBase + i); + return (KMX_WCHAR)(deadkeyBase + i); } } return 0xFFFF; @@ -425,13 +425,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** ke kp->dpGroupArray = gp; for (UINT i = 0; i < kp->cxGroupArray; i++, gp++) { - // if(gp->fUsingKeys && gp->dpNoMatch == NULL) { // I4550 - // WCHAR *p = gp->dpNoMatch = new WCHAR[4]; - // *p++ = UC_SENTINEL; - // *p++ = CODE_USE; - // *p++ = (WCHAR)(kp->cxGroupArray + 1); - // *p = 0; - //} LPKMX_KEY kkp = gp->dpKeyArray; for (UINT j = 0; j < gp->cxKeyArray; j++, kkp++) { diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index 237ff81132..d27678c360 100755 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -20,7 +20,7 @@ cpp_files = files( 'u16.cpp',) comon_include_dir = [ - include_directories('../../../../common/include'), + include_directories('../../../common/include'), ] From 705175415426cdc59e5cc9672e65500324acbda1 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 24 Jun 2024 09:44:44 +0200 Subject: [PATCH 259/327] feat(linux): work on 2.nd round of comments 11816 --- linux/mcompile/keymap/keymap.cpp | 10 +++++----- linux/mcompile/keymap/mc_import_rules.cpp | 16 ++++++---------- linux/mcompile/keymap/meson.build | 2 +- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 9eeef45f35..23fa40e39d 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -621,7 +621,7 @@ int KMX_get_KeyVal_From_KeyCode(GdkKeymap *keymap, guint keycode, ShiftState ss, if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation( map_VKShiftState_to_LinModifier(ss), count, keycode))){ + if (!(ensureValidInputForKeyboardTranslation( map_VKShiftState_to_LinModifier(ss), count, keycode))) { g_free(keyvals); g_free(maps); return 0; @@ -713,7 +713,7 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, gui if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation( shift_state_pos, count, keycode))){ + if (!(ensureValidInputForKeyboardTranslation( shift_state_pos, count, keycode))) { g_free(keyvals); g_free(maps); return 0; @@ -738,7 +738,7 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, UIN if (!gdk_keymap_get_entries_for_keycode(keymap, kc_underlying, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation( map_VKShiftState_to_LinModifier(vk_ShiftState), count, kc_underlying))){ + if (!(ensureValidInputForKeyboardTranslation( map_VKShiftState_to_LinModifier(vk_ShiftState), count, kc_underlying))) { g_free(keyvals); g_free(maps); return 0; @@ -754,12 +754,12 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap *keymap, UIN *deadkey = *dky; return 0xFFFF; } - else if ((keyV > deadkey_max) || ((keyV < deadkey_min) && ( keyV > 0xFF))) // out of range + else if ((keyV > deadkey_max) || ((keyV < deadkey_min) && ( keyV > 0xFF))) // out of range return 0xFFFE; else // usable char return keyV; } -//_S2 vk_us or underlying!!"!!" + KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(vec_dword_3D & all_vector, KMX_DWORD vk_US) { KMX_DWORD vk_underlying; for( int i=0; i< (int)all_vector[0].size()-1 ;i++) { diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 96e0b127f6..51c388d5ef 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -68,8 +68,11 @@ int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation(shift_state_pos, count, keycode))) + if (!(ensureValidInputForKeyboardTranslation(shift_state_pos, count, keycode))) { + g_free(keyvals); + g_free(maps); return 0; + } KMX_DWORD keyVal = (KMX_DWORD)KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(shift_state_pos), caps); std::u16string str = convert_DeadkeyValues_To_U16str(keyVal); @@ -89,7 +92,7 @@ int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int return 1; } -KMX_WCHAR KMX_DeadKeyMap( int index, std::vector* deadkeys, int deadkeyBase, std::vector* deadkeyMappings) { // I4327 // I4353 +KMX_WCHAR KMX_DeadKeyMap(int index, std::vector* deadkeys, int deadkeyBase, std::vector* deadkeyMappings) { // I4327 // I4353 for (size_t i = 0; i < deadkeyMappings->size(); i++) { if ((*deadkeyMappings)[i].deadkey == index) { return (*deadkeyMappings)[i].dkid; @@ -98,7 +101,7 @@ KMX_WCHAR KMX_DeadKeyMap( int index, std::vector* deadkeys, int deadke for (size_t i = 0; i < deadkeys->size(); i++) { if ((*deadkeys)[i]->KMX_DeadCharacter() == index) { - return (KMX_WCHAR) (deadkeyBase + i); + return (KMX_WCHAR)(deadkeyBase + i); } } return 0xFFFF; @@ -422,13 +425,6 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** ke kp->dpGroupArray = gp; for (UINT i = 0; i < kp->cxGroupArray; i++, gp++) { - // if(gp->fUsingKeys && gp->dpNoMatch == NULL) { // I4550 - // WCHAR *p = gp->dpNoMatch = new WCHAR[4]; - // *p++ = UC_SENTINEL; - // *p++ = CODE_USE; - // *p++ = (WCHAR)(kp->cxGroupArray + 1); - // *p = 0; - //} LPKMX_KEY kkp = gp->dpKeyArray; for (UINT j = 0; j < gp->cxKeyArray; j++, kkp++) { diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index 237ff81132..d27678c360 100755 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -20,7 +20,7 @@ cpp_files = files( 'u16.cpp',) comon_include_dir = [ - include_directories('../../../../common/include'), + include_directories('../../../common/include'), ] From 252c40940043c7dbf6d41cdf339dc44c0125c970 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 24 Jun 2024 10:35:54 +0200 Subject: [PATCH 260/327] feat(linux): comment and assert in KMX_ToUnicodeEx when surrogate pairs are used --- linux/mcompile/keymap/mc_import_rules.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 51c388d5ef..a441f6a056 100755 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -61,6 +61,12 @@ bool DeadKey::KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter) { } int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int caps, GdkKeymap* keymap) { +/* + * Contrary to what the function name might suggest, the function KMX_ToUnicodeEx does not process surrogate pairs. + * This is because it is used in mcompile only which only deals with latin scripts. + * In case this function is used for surrogate pairs, they will be ignored and a message will be printed out +*/ + GdkKeymapKey* maps; guint* keyvals; gint count; @@ -76,7 +82,14 @@ int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int KMX_DWORD keyVal = (KMX_DWORD)KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(shift_state_pos), caps); std::u16string str = convert_DeadkeyValues_To_U16str(keyVal); - pwszBuff[0] = *(PKMX_WCHAR)str.c_str(); + KMX_WCHAR firstchar = *(PKMX_WCHAR)str.c_str(); + + if ((firstchar >= 0xD800) &&(firstchar <= 0xDFFF)) { + wprintf(L"Surrogate pair found that is not processed in KMX_ToUnicodeEx\n"); + return 0; + } + + pwszBuff[0] = firstchar; g_free(keyvals); g_free(maps); From 0075b8f04ab5a706acb4d066115ebcb2d7ef10aa Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 24 Jun 2024 14:57:37 +0200 Subject: [PATCH 261/327] feat(linux): createCompleteVector_US --- linux/mcompile/keymap/keymap.cpp | 29 +++++++++++++++-------------- linux/mcompile/keymap/keymap.h | 2 +- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index e6f98bd5a0..93a6405df9 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -331,9 +331,9 @@ int createOneVectorFromBothKeyboards(vec_dword_3D& all_vector, GdkKeymap* keymap int write_US_ToVector(vec_dword_3D& vec, std::string language, const char* section) { std::string fullPathName = "/usr/share/X11/xkb/symbols/" + language; - const char* path = fullPathName.c_str(); FILE* fp = fopen((path), "r"); + if (!fp) { printf("ERROR: could not open file!\n"); return 1; @@ -341,7 +341,7 @@ int write_US_ToVector(vec_dword_3D& vec, std::string language, const char* secti // create 1D-vector of the complete line vec_string_1D vector_completeUS; - if (createCompleteVector_US(fp, section, vector_completeUS)) { + if (createCompleteVector_US(fullPathName, section, vector_completeUS)) { printf("ERROR: can't Create complete row US \n"); return 1; } @@ -355,19 +355,19 @@ int write_US_ToVector(vec_dword_3D& vec, std::string language, const char* secti return 0; } -bool createCompleteVector_US(FILE* fp, const char* section, vec_string_1D& complete_List) { +bool createCompleteVector_US(std::string fullPathName, const char* section, vec_string_1D& complete_List) { // in the Configuration file we find the appopriate paragraph between "xkb_symbol " and the next xkb_symbol - // and then copy all rows starting with "key <" to a 1D-Vector + // then copy all rows starting with "key <" to a 1D-Vector - int buffer_size = 512; - char line[buffer_size]; bool create_row = false; const char* key = "key <"; + std::string line; std::string str_us_kbd_name(section); std::string xbk_mark = "xkb_symbol"; + std::ifstream inputFile(fullPathName); - if (fp) { - while (fgets(line, buffer_size, fp) != NULL) { + if (inputFile.is_open()) { + while (getline(inputFile, line)) { std::string str_buf(line); // stop when finding the mark xkb_symbol @@ -379,7 +379,7 @@ bool createCompleteVector_US(FILE* fp, const char* section, vec_string_1D& compl create_row = true; // as long as we are in the same xkb_symbol layout block and find "key <" we push the whole line into a 1D-vector - if (create_row && (std::string(str_buf).find(key) != std::string::npos)) { + else if (create_row && (std::string(str_buf).find(key) != std::string::npos)) { complete_List.push_back(line); } } @@ -566,12 +566,12 @@ vec_dword_2D create_empty_2D_Vector(int dim_rows, int dim_ss) { vec_dword_1D shifts; vec_dword_2D vector_2D; - for (int i = 0; i < dim_rows; i++) { for (int j = 0; j < dim_ss; j++) { shifts.push_back(INVALID_NAME); } + + for (int i = 0; i < dim_rows; i++) { vector_2D.push_back(shifts); - shifts.clear(); } return vector_2D; } @@ -641,14 +641,15 @@ std::u16string convert_DeadkeyValues_To_U16str(int in) { if (in == 0) return u"\0"; + if (in < (int)deadkey_min) { // no deadkey; no Unicode + return std::u16string(1, in); + } + std::string long_name((const char*)gdk_keyval_name(in)); // e.g. "dead_circumflex", "U+017F", "t" if (long_name.substr(0, 2) == "U+") // U+... Unicode value return CodePointToU16String(in - 0x1000000); // GDK's gdk_keymap_translate_keyboard_state() returns (Keyvalue | 0x01000000) // since we never have a carry-over we can just subtract 0x01000000 - if (in < (int)deadkey_min) { // no deadkey; no Unicode - return std::u16string(1, in); - } KMX_DWORD lname = convertNamesTo_DWORD_Value(long_name); // 65106 => "dead_circumflex" => 94 => "^" diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 6bae6a8e94..be90a75ed2 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -81,7 +81,7 @@ int createOneVectorFromBothKeyboards(vec_dword_3D& All_Vector, GdkKeymap* keymap int write_US_ToVector(vec_dword_3D& vec, std::string language, const char* text); // 1. step: read complete Row of Configuration file US -bool createCompleteVector_US(FILE* fpp, const char* text, vec_string_1D& complete_List); +bool createCompleteVector_US(std::string fullPathName, const char* section, vec_string_1D& complete_List) ; // replace Name of Key (e.g. ) wih Keycode ( e.g. 15 ) int replace_KeyName_with_Keycode(std::string in); From 2b59c3ca1b2636edf64b8aee2a7253982fe44f51 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 24 Jun 2024 16:05:49 +0200 Subject: [PATCH 262/327] feat(linux): CodePointToU16String --- linux/mcompile/keymap/keymap.cpp | 12 ++++++------ linux/mcompile/keymap/keymap.h | 6 ++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 93a6405df9..1b581158a2 100755 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -846,16 +846,16 @@ KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying(KMX_DWORD keycode) { std::u16string CodePointToU16String(unsigned int codepoint) { std::u16string str; - if constexpr (sizeof(wchar_t) > 2) { - str = static_cast(codepoint); - } else if (codepoint <= 0xFFFF) { + if (codepoint <= 0xFFFF) { str = static_cast(codepoint); } else { + assert(codepoint < 0x10FFFF); + assert(isLittleEndianSystem()); + codepoint -= 0x10000; str.resize(2); - str[0] = static_cast(0xD800 + ((codepoint >> 10) & 0x3FF)); - str[1] = static_cast(0xDC00 + (codepoint & 0x3FF)); + str[0] = static_cast(0xDC00 + (codepoint & 0x3FF)); + str[1] = static_cast(0xD800 + ((codepoint >> 10) & 0x3FF)); } - return str; } diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index be90a75ed2..5047e8c51f 100755 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -15,6 +15,7 @@ #include #include #include "u16.h" +#include enum ShiftState { Base = 0, // 0 @@ -65,6 +66,11 @@ static KMX_DWORD keycode_max = 94; static KMX_DWORD deadkey_min = 0xfe50; // X11's keysymdef.h defines deadkeys between 0xfe50-0xfe93 static KMX_DWORD deadkey_max = 0xfe93; // https://fossies.org/linux/tk/xlib/X11/keysymdef.h +inline bool isLittleEndianSystem() { + char16_t test = 0x0102; + return (reinterpret_cast(&test))[0] == 0x02; +} + // map Shiftstate to modifier (e.g. 0->0; 16-1; 9->2; 25->3) int convert_WinShiftstate_to_LinuxShiftstate(int VKShiftState); From bc5b502cf07c17422621ab6908a8b0ae666bcd56 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 25 Jun 2024 17:12:58 +0200 Subject: [PATCH 263/327] feat(linux): comments for mc_kmxfile --- linux/mcompile/keymap/mc_kmxfile.cpp | 136 ++++++++++++++------------- linux/mcompile/keymap/mc_kmxfile.h | 4 +- linux/mcompile/keymap/mcompile.cpp | 10 +- 3 files changed, 80 insertions(+), 70 deletions(-) diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 4c90ef61bb..861de1a8a3 100755 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -34,40 +34,9 @@ const int CODE__SIZE[] = { 2 // CODE_SETSYSTEMSTORE 0x18 }; -KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz); - -LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); - -KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, PKMX_WCHAR filename) { - - FILE *fp; - fp = Open_File(filename, u"wb"); - - if(fp == NULL) - { - KMX_LogError(L"Failed to create output file (%d)", errno); - return FALSE; - } - - KMX_DWORD err = KMX_WriteCompiledKeyboardToFile(kbd, fp, FALSE); - fclose(fp); - - if(err != CERR_None) { - KMX_LogError(L"Failed to write compiled keyboard with error %d", err); - - std::u16string u16_filname(filename); - std::string s = string_from_u16string(u16_filname); - - remove(s.c_str()); - return FALSE; - } - - return TRUE; -} - KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL FSaveDebug) { - LPKMX_GROUP fgp; + LPKMX_GROUP fgp; LPKMX_STORE fsp; LPKMX_KEY fkp; @@ -91,22 +60,22 @@ KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX for(i = 0, fgp = fk->dpGroupArray; i < fk->cxGroupArray; i++, fgp++) { if(fgp->dpName) - size += u16len(fgp->dpName)*2 + 2; + size += (u16len(fgp->dpName) + 1) * sizeof(KMX_WCHAR); size += fgp->cxKeyArray * sizeof(COMP_KEY); for(j = 0, fkp = fgp->dpKeyArray; j < fgp->cxKeyArray; j++, fkp++) { - size += u16len(fkp->dpOutput)*2 + 2; - size += u16len(fkp->dpContext)*2 + 2; + size += (u16len(fkp->dpOutput)+ 1) * sizeof(KMX_WCHAR); + size += (u16len(fkp->dpContext)+ 1) * sizeof(KMX_WCHAR); } - if (fgp->dpMatch ) size += u16len(fgp->dpMatch)*2 + 2; - if (fgp->dpNoMatch ) size += u16len(fgp->dpNoMatch)*2 + 2; + if (fgp->dpMatch ) size += (u16len(fgp->dpMatch)+ 1) * sizeof(KMX_WCHAR); + if (fgp->dpNoMatch ) size += (u16len(fgp->dpNoMatch)+ 1) * sizeof(KMX_WCHAR); } for(i = 0; i < fk->cxStoreArray; i++) { - size += u16len(fk->dpStoreArray[i].dpString)*2 + 2; + size += (u16len(fk->dpStoreArray[i].dpString)+ 1) * sizeof(KMX_WCHAR); if(fk->dpStoreArray[i].dpName) - size += u16len(fk->dpStoreArray[i].dpName)*2 + 2; + size +=(u16len(fk->dpStoreArray[i].dpName)+ 1) * sizeof(KMX_WCHAR); } buf = new KMX_BYTE[size]; @@ -139,24 +108,23 @@ KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX sp->dwSystemID = fsp->dwSystemID; sp->dpString = offset; u16ncpy((PKMX_WCHAR)(buf+offset), fsp->dpString, (size-offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 - offset += u16len(fsp->dpString)*2 + 2; + offset += (u16len(fsp->dpString)+ 1) * sizeof(KMX_WCHAR); if(!fsp->dpName) { sp->dpName = 0; } else { sp->dpName = offset; u16ncpy((PKMX_WCHAR)(buf+offset), fsp->dpName, (size-offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 - offset += u16len(fsp->dpName)*2 + 2; + offset += (u16len(fsp->dpName)+ 1) * sizeof(KMX_WCHAR); } } ck->dpGroupArray = offset; gp = (PCOMP_GROUP)(buf+offset); - fgp = fk->dpGroupArray; offset += sizeof(COMP_GROUP) * ck->cxGroupArray; - for(i = 0; i < ck->cxGroupArray; i++, gp++, fgp++) { + for(i = 0,fgp = fk->dpGroupArray; i < ck->cxGroupArray; i++, gp++, fgp++) { gp->cxKeyArray = fgp->cxKeyArray; gp->fUsingKeys = fgp->fUsingKeys; @@ -165,38 +133,38 @@ KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX if(fgp->dpMatch) { gp->dpMatch = offset; u16ncpy((PKMX_WCHAR)(buf+offset), fgp->dpMatch, (size-offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 - offset += u16len(fgp->dpMatch)*2 + 2; + offset += (u16len(fgp->dpMatch)+ 1) * sizeof(KMX_WCHAR); } if(fgp->dpNoMatch) { gp->dpNoMatch = offset; u16ncpy((PKMX_WCHAR)(buf+offset), fgp->dpNoMatch, (size-offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 - offset += u16len(fgp->dpNoMatch)*2 + 2; + offset += (u16len(fgp->dpNoMatch)+ 1) * sizeof(KMX_WCHAR); } if(fgp->dpName) { gp->dpName = offset; u16ncpy((PKMX_WCHAR)(buf+offset), fgp->dpName, (size-offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 - offset += u16len(fgp->dpName)*2 + 2; + offset += (u16len(fgp->dpName)+ 1) * sizeof(KMX_WCHAR); } else { gp->dpName = 0; } gp->dpKeyArray = offset; kp = (PCOMP_KEY) (buf + offset); - fkp = fgp->dpKeyArray; offset += gp->cxKeyArray * sizeof(COMP_KEY); - for(j = 0; j < gp->cxKeyArray; j++, kp++, fkp++) { + + for(j = 0, fkp = fgp->dpKeyArray; j < gp->cxKeyArray; j++, kp++, fkp++){ kp->Key = fkp->Key; kp->Line = fkp->Line; kp->ShiftFlags = fkp->ShiftFlags; kp->dpOutput = offset; u16ncpy((PKMX_WCHAR)(buf+offset), fkp->dpOutput, (size-offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 - offset += u16len(fkp->dpOutput)*2 + 2; + offset += (u16len(fkp->dpOutput)+ 1) * sizeof(KMX_WCHAR); kp->dpContext = offset; u16ncpy((PKMX_WCHAR)(buf+offset), fkp->dpContext, (size-offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 - offset += u16len(fkp->dpContext)*2 + 2; + offset += (u16len(fkp->dpContext)+ 1) * sizeof(KMX_WCHAR); } } @@ -210,9 +178,15 @@ KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX ck->dpBitmapOffset = 0; } - fwrite(buf, size,1,hOutfile); - if(offset != size) - { + size_t nr_elements = fwrite(buf, size, 1, hOutfile); + + if(nr_elements < 1) { + delete[] buf; + return CERR_SomewhereIGotItWrong; + } + + + if(offset != size) { delete[] buf; return CERR_UnableToWriteFully; } @@ -222,6 +196,34 @@ KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX return CERR_None; } +KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD file_size); + +LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); + +KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, KMX_CHAR* filename) { + + FILE *fp; + fp = Open_File(filename, "wb"); + + if(fp == NULL) + { + KMX_LogError(L"Failed to create output file (%d)", errno); + return FALSE; + } + + KMX_DWORD err = KMX_WriteCompiledKeyboardToFile(kbd, fp, FALSE); + fclose(fp); + + if(err != CERR_None) { + KMX_LogError(L"Failed to write compiled keyboard with error %d", err); + std::string s(filename); + remove(s.c_str()); + return FALSE; + } + + return TRUE; +} + PKMX_WCHAR KMX_StringOffset(PKMX_BYTE base, KMX_DWORD offset) { if(offset == 0) return NULL; return (PKMX_WCHAR)(base + offset); @@ -357,6 +359,7 @@ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFil KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { + *lpKeyboard = NULL; PKMX_BYTE buf; FILE* fp; LPKMX_KEYBOARD kbp; @@ -380,8 +383,8 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { return FALSE; } - auto sz = ftell(fp); - if (sz < 0) { + auto file_size = ftell(fp); + if (file_size <= 0) { fclose(fp); return FALSE; } @@ -399,39 +402,42 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { // the file. // We save the original data at the end of buf; we don't copy strings, so // those will remain in the location at the end of the buffer. - buf = new KMX_BYTE[sz * 3]; + buf = new KMX_BYTE[file_size * 3]; #else - buf = new KMX_BYTE[sz]; + buf = new KMX_BYTE[file_size]; #endif if (!buf) { + delete[] buf; fclose(fp); KMX_LogError(L"Not allocmem\n" ); return FALSE; } #ifdef KMX_64BIT - filebase = buf + sz*2; + filebase = buf + file_size*2; #else filebase = buf; #endif - if (fread(filebase, 1, sz, fp) < (size_t)sz) { + if (fread(filebase, 1, file_size, fp) < (size_t)file_size) { KMX_LogError(L"Could not read file\n" ); + delete[] buf; fclose(fp); return FALSE; } fclose(fp); - if(*PKMX_DWORD(filebase) != KMX_DWORD(FILEID_COMPILED)) + if(*((PKMX_DWORD)filebase) != (KMX_DWORD)FILEID_COMPILED) { delete [] buf; KMX_LogError(L"Invalid file - signature is invalid\n"); return FALSE; } - if (!KMX_VerifyKeyboard(filebase, sz)) { + if (!KMX_VerifyKeyboard(filebase, file_size)) { + delete[] buf; KMX_LogError(L"errVerifyKeyboard\n" ); return FALSE; } @@ -439,11 +445,12 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { #ifdef KMX_64BIT kbp = CopyKeyboard(buf, filebase); #else - kbp = KMX_FixupKeyboard(buf, filebase, sz); + kbp = KMX_FixupKeyboard(buf, filebase, file_size); #endif if (!kbp) { + delete[] buf; KMX_LogError(L"errFixupKeyboard\n" ); return FALSE; } @@ -457,7 +464,7 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { return TRUE; } -KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz){ +KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD file_size){ KMX_DWORD i; PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD)filebase; PCOMP_STORE csp; @@ -484,7 +491,7 @@ KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD sz){ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p) { - if (*p == 0) + if (p == NULL || *p == 0) return p; if (*p != UC_SENTINEL) { if (*p >= 0xD800 && *p <= 0xDBFF && *(p + 1) >= 0xDC00 && *(p + 1) <= 0xDFFF) @@ -515,4 +522,3 @@ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p) { } return p; } - diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 22c9255481..e71946f554 100755 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -72,9 +72,7 @@ typedef struct KMX_tagKEYBOARD { KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD *lpKeyboard); -KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, PKMX_WCHAR filename); - -KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL FSaveDebug); +KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, KMX_CHAR* filename); PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index d3ad1577f5..4b4c7648c6 100755 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -87,9 +87,15 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ int bDeadkeyConversion = u16cmp(argv[1], u"-d") == 0; // I4552 int n = (bDeadkeyConversion ? 2 : 1); - char16_t* infile = (char16_t*) argv[n], *outfile = (char16_t*) argv[n+1]; +// _S2 needs more work once mcompile is changed after review ( use char* only instead of char16_t*) + char16_t* infile = (char16_t*) argv[n]; + char16_t* outfile_16 = (char16_t*) argv[n+1]; + std::u16string u16stri(outfile_16); + std::string str= string_from_u16string(u16stri); + char* outfile = (char*) str.c_str(); - printf("mcompile%ls \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d" : L"", u16fmt((const char16_t*) infile).c_str(), u16fmt((const char16_t*) outfile).c_str() ); // I4174 + + printf("mcompile%ls \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d" : L"", u16fmt((const char16_t*) infile).c_str(), u16fmt((const char16_t*) outfile_16).c_str() ); // I4174 // 1. Load the keyman keyboard file From 6e9396c997e667d79e41b1479216101e80ec6c7f Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 26 Jun 2024 14:56:41 +0200 Subject: [PATCH 264/327] feat(linux): changes in file permission and other files --- .gitignore | 15 --------------- linux/mcompile/keymap/README.md | 0 linux/mcompile/keymap/deadkey.cpp | 0 linux/mcompile/keymap/deadkey.h | 0 linux/mcompile/keymap/filesystem.cpp | 0 linux/mcompile/keymap/filesystem.h | 0 linux/mcompile/keymap/keymap.cpp | 0 linux/mcompile/keymap/keymap.h | 0 linux/mcompile/keymap/km_types.h | 0 linux/mcompile/keymap/mc_import_rules.cpp | 0 linux/mcompile/keymap/mc_kmxfile.cpp | 0 linux/mcompile/keymap/mc_kmxfile.h | 0 linux/mcompile/keymap/mcompile.cpp | 0 linux/mcompile/keymap/mcompile.h | 0 linux/mcompile/keymap/meson.build | 0 linux/mcompile/keymap/u16.cpp | 0 linux/mcompile/keymap/u16.h | 0 windows/src/engine/keyman32/VKScanCodes.cpp | 4 ++-- windows/src/global/cpp/VKScanCodes.cpp | 4 ++-- 19 files changed, 4 insertions(+), 19 deletions(-) mode change 100755 => 100644 linux/mcompile/keymap/README.md mode change 100755 => 100644 linux/mcompile/keymap/deadkey.cpp mode change 100755 => 100644 linux/mcompile/keymap/deadkey.h mode change 100755 => 100644 linux/mcompile/keymap/filesystem.cpp mode change 100755 => 100644 linux/mcompile/keymap/filesystem.h mode change 100755 => 100644 linux/mcompile/keymap/keymap.cpp mode change 100755 => 100644 linux/mcompile/keymap/keymap.h mode change 100755 => 100644 linux/mcompile/keymap/km_types.h mode change 100755 => 100644 linux/mcompile/keymap/mc_import_rules.cpp mode change 100755 => 100644 linux/mcompile/keymap/mc_kmxfile.cpp mode change 100755 => 100644 linux/mcompile/keymap/mc_kmxfile.h mode change 100755 => 100644 linux/mcompile/keymap/mcompile.cpp mode change 100755 => 100644 linux/mcompile/keymap/mcompile.h mode change 100755 => 100644 linux/mcompile/keymap/meson.build mode change 100755 => 100644 linux/mcompile/keymap/u16.cpp mode change 100755 => 100644 linux/mcompile/keymap/u16.h diff --git a/.gitignore b/.gitignore index 6a40380344..79ac5cf2db 100644 --- a/.gitignore +++ b/.gitignore @@ -191,18 +191,3 @@ lcov.info /keyman*.buildinfo /keyman*.changes /keyman*.tar.?z - -#Sabine: -# /common/test/keyboards/invalid/source/*.kmx -# /developer/src/test/auto/kmcomp/*.kmn -# /developer/src/test/auto/kmcomp/*.kvk -# /developer/src/test/auto/kmcomp/*.kvk* -# /developer/src/test/auto/kmcomp/*.txt -/linux/mcompile/keymap/X_bak -/linux/mcompile/keymap/anii.* - -/linux/mcompile/keymap/*.kmx - - - -/GTK_PLAYGROUND \ No newline at end of file diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md old mode 100755 new mode 100644 diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp old mode 100755 new mode 100644 diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h old mode 100755 new mode 100644 diff --git a/linux/mcompile/keymap/filesystem.cpp b/linux/mcompile/keymap/filesystem.cpp old mode 100755 new mode 100644 diff --git a/linux/mcompile/keymap/filesystem.h b/linux/mcompile/keymap/filesystem.h old mode 100755 new mode 100644 diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp old mode 100755 new mode 100644 diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h old mode 100755 new mode 100644 diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h old mode 100755 new mode 100644 diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp old mode 100755 new mode 100644 diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp old mode 100755 new mode 100644 diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h old mode 100755 new mode 100644 diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp old mode 100755 new mode 100644 diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h old mode 100755 new mode 100644 diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build old mode 100755 new mode 100644 diff --git a/linux/mcompile/keymap/u16.cpp b/linux/mcompile/keymap/u16.cpp old mode 100755 new mode 100644 diff --git a/linux/mcompile/keymap/u16.h b/linux/mcompile/keymap/u16.h old mode 100755 new mode 100644 diff --git a/windows/src/engine/keyman32/VKScanCodes.cpp b/windows/src/engine/keyman32/VKScanCodes.cpp index 6a7781b2b6..4207cb931a 100644 --- a/windows/src/engine/keyman32/VKScanCodes.cpp +++ b/windows/src/engine/keyman32/VKScanCodes.cpp @@ -167,8 +167,8 @@ UINT USVirtualKeyToScanCode[256] = 0x00, // L"K_?8E", // &H8E 0x00, // L"K_?8F", // &H8F - 0x45, // L"K_NUMLOCK", // &H90 - 0x46, // L"K_SCROL", // &H91 + 0x45, // L"K_NUMLOCK", // &H90 + 0x46, // L"K_SCROLL", // &H91 0x00, // L"K_?92", // &H92 0x00, // L"K_?93", // &H93 diff --git a/windows/src/global/cpp/VKScanCodes.cpp b/windows/src/global/cpp/VKScanCodes.cpp index dfc0c036f2..60b6d47cf2 100644 --- a/windows/src/global/cpp/VKScanCodes.cpp +++ b/windows/src/global/cpp/VKScanCodes.cpp @@ -168,8 +168,8 @@ const UINT USVirtualKeyToScanCode[256] = 0x00, // L"K_?8E", // &H8E 0x00, // L"K_?8F", // &H8F - 0x45, // L"K_NUMLOCK", // &H90 - 0x46, // L"K_SCROL", // &H91 + 0x45, // L"K_NUMLOCK", // &H90 + 0x46, // L"K_SCROLL", // &H91 0x00, // L"K_?92", // &H92 0x00, // L"K_?93", // &H93 From 75c9850cfdd74778f56a251e52cddf06725ed710 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 26 Jun 2024 15:00:49 +0200 Subject: [PATCH 265/327] feat(linux): remove x11 from meson.build --- linux/mcompile/keymap/meson.build | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index d27678c360..0c04ce8c35 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -2,13 +2,11 @@ project('mcompile', 'c', 'cpp', license: 'MIT', meson_version: '>=1.0') -#do I need a Version of dependency? gtk = dependency('gtk+-3.0', version: '>= 2.4') -x11 = dependency('x11', version: '>= 1.6') xkb = dependency('xkbcommon') libxklavier = dependency('libxklavier') -deps = [gtk, x11, xkb,libxklavier] +deps = [gtk, xkb,libxklavier] cpp_files = files( 'keymap.cpp', From e8c8f165e106952626b23038acb37075312753e4 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 26 Jun 2024 15:30:19 +0200 Subject: [PATCH 266/327] feat(linux): add blanc lines to prevent github from stating "empty file" --- linux/mcompile/keymap/deadkey.cpp | 1 + linux/mcompile/keymap/deadkey.h | 3 ++- linux/mcompile/keymap/filesystem.cpp | 1 + linux/mcompile/keymap/filesystem.h | 1 - linux/mcompile/keymap/keymap.cpp | 1 + linux/mcompile/keymap/keymap.h | 1 + linux/mcompile/keymap/km_types.h | 1 - linux/mcompile/keymap/mc_import_rules.cpp | 1 + linux/mcompile/keymap/mc_import_rules.h | 1 + linux/mcompile/keymap/mc_kmxfile.cpp | 1 + linux/mcompile/keymap/mc_kmxfile.h | 1 - linux/mcompile/keymap/mcompile.cpp | 1 + linux/mcompile/keymap/mcompile.h | 1 + linux/mcompile/keymap/meson.build | 1 + linux/mcompile/keymap/u16.h | 3 ++- 15 files changed, 14 insertions(+), 5 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 56feb1d136..d5129734b5 100644 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -1,6 +1,7 @@ #include "keymap.h" #include "deadkey.h" + std::vector create_deadkeys_by_basechar() { std::vector alDead; vec_dword_2D dk_ComposeTable; diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index 924b1044df..e57b2fb9de 100644 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -6,6 +6,7 @@ #include "mc_import_rules.h" #include + // create a 2D-vector of all dk combinations ( ` + a -> à ; ^ + a -> â ; `+ e -> è; ...) void create_DKTable(vec_dword_2D &dk_ComposeTable); @@ -24,4 +25,4 @@ bool query_dk_combinations_for_specific_dk(vec_dword_2D &dk_ComposeTable, KMX_DW // get the shifted character of a key and write shiftstate of KVal to shift KMX_DWORD KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD &shift, GdkKeymap *keymap); -#endif /*DEADKEY_H*/ \ No newline at end of file +#endif /*DEADKEY_H*/ diff --git a/linux/mcompile/keymap/filesystem.cpp b/linux/mcompile/keymap/filesystem.cpp index a343641acc..05d4da511d 100644 --- a/linux/mcompile/keymap/filesystem.cpp +++ b/linux/mcompile/keymap/filesystem.cpp @@ -9,6 +9,7 @@ #include #include "filesystem.h" + #ifdef _MSC_VER #include #else diff --git a/linux/mcompile/keymap/filesystem.h b/linux/mcompile/keymap/filesystem.h index af3d6aa7d6..b9454e6007 100644 --- a/linux/mcompile/keymap/filesystem.h +++ b/linux/mcompile/keymap/filesystem.h @@ -1,5 +1,4 @@ #pragma once - #include #include "u16.h" diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 1b581158a2..a4bc3157a6 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -3,6 +3,7 @@ #include "/usr/include/xcb/xproto.h" #include + int convert_WinShiftstate_to_LinuxShiftstate(int win_ShiftState) { if (win_ShiftState == 0) return 0; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 5047e8c51f..0f59b11b14 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -17,6 +17,7 @@ #include "u16.h" #include + enum ShiftState { Base = 0, // 0 Shft = 1, // 1 diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index cf91203bd4..4b97663b00 100644 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -1,7 +1,6 @@ #pragma once #ifndef KM_TYPES #define KM_TYPES - #include /* diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 9e54b7da18..c29ad9ac68 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -19,6 +19,7 @@ 06 Feb 2015 - mcdurdin - I4552 - V9.0 - Add mnemonic recompile option to ignore deadkeys */ + #include #include #include diff --git a/linux/mcompile/keymap/mc_import_rules.h b/linux/mcompile/keymap/mc_import_rules.h index 51fd5502f4..fac3db87be 100644 --- a/linux/mcompile/keymap/mc_import_rules.h +++ b/linux/mcompile/keymap/mc_import_rules.h @@ -3,6 +3,7 @@ #ifndef MC_IMPORT_RULES_H #define MC_IMPORT_RULES_H + class DeadKey { private: KMX_WCHAR m_deadchar; diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 861de1a8a3..2fe65be90a 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -6,6 +6,7 @@ #define CERR_UnableToWriteFully 0x00008007 #define CERR_SomewhereIGotItWrong 0x00008009 + const int CODE__SIZE[] = { -1, // undefined 0x00 1, // CODE_ANY 0x01 diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index e71946f554..e8477edc24 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -10,7 +10,6 @@ #ifndef _KMXFILE_H #define _KMXFILE_H - typedef struct KMX_tagSTORE { KMX_DWORD dwSystemID; PKMX_WCHAR dpName; diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 4b4c7648c6..f6594a950f 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -29,6 +29,7 @@ // for the subcomponents of the compiled keyboard is an unnecessary optimisation. Just so you know. // + #include "mcompile.h" //------------------------------------------------------------------------------------------------ diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 0812604b3d..5888fdbf38 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -17,6 +17,7 @@ */ + #ifndef MCOMPILE_H #define MCOMPILE_H #include diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index 0c04ce8c35..db9baab6b2 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -8,6 +8,7 @@ libxklavier = dependency('libxklavier') deps = [gtk, xkb,libxklavier] + cpp_files = files( 'keymap.cpp', 'deadkey.cpp', diff --git a/linux/mcompile/keymap/u16.h b/linux/mcompile/keymap/u16.h index 34cc5f275b..53872dcb28 100644 --- a/linux/mcompile/keymap/u16.h +++ b/linux/mcompile/keymap/u16.h @@ -8,6 +8,7 @@ #include #include "km_types.h" + std::vector convert_argvW_to_Vector_u16str(int argc, wchar_t* argv[]); std::vector convert_argv_to_Vector_u16str(int argc, char* argv[]); @@ -44,4 +45,4 @@ const KMX_WCHAR* u16rchr_slash(KMX_WCHAR const* Name); std::string toHex(int num1); -#endif /* U16_H */ \ No newline at end of file +#endif /* U16_H */ From 98beb944c50ceaecf61329f463717822f7bcbe07 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 26 Jun 2024 16:02:18 +0200 Subject: [PATCH 267/327] feat(linux): ... and remove again --- linux/mcompile/keymap/README.md | 1 - linux/mcompile/keymap/deadkey.cpp | 1 - linux/mcompile/keymap/deadkey.h | 1 - linux/mcompile/keymap/filesystem.cpp | 1 - linux/mcompile/keymap/filesystem.h | 1 + linux/mcompile/keymap/keymap.cpp | 1 - linux/mcompile/keymap/keymap.h | 1 - linux/mcompile/keymap/km_types.h | 1 - linux/mcompile/keymap/mc_import_rules.cpp | 1 - linux/mcompile/keymap/mc_import_rules.h | 1 - linux/mcompile/keymap/mc_kmxfile.cpp | 1 - linux/mcompile/keymap/mc_kmxfile.h | 1 + linux/mcompile/keymap/mcompile.cpp | 1 - linux/mcompile/keymap/mcompile.h | 1 - linux/mcompile/keymap/meson.build | 1 - linux/mcompile/keymap/u16.h | 1 - 16 files changed, 2 insertions(+), 14 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index 84635c5e5b..cb154093d3 100644 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -1,4 +1,3 @@ - This is a proposal to rewrite mcompile for Linux. For this we need to query the base keyboard data from the Linux platform, then rewriting the keyboard .kmx using the same approach as is done in mcompile for Windows, but working from the data from the x11 keyboard on Linux. Ideally, we'd rewrite mcompile to be cross-platform (Windows, Linux, macOS), so that the keyboard interrogation would be separated from the .kmx rewriting, at least to some degree. Nevertheless it would probably be easiest to start from a standalone implementation. diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index d5129734b5..56feb1d136 100644 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -1,7 +1,6 @@ #include "keymap.h" #include "deadkey.h" - std::vector create_deadkeys_by_basechar() { std::vector alDead; vec_dword_2D dk_ComposeTable; diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index e57b2fb9de..652cf8808d 100644 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -6,7 +6,6 @@ #include "mc_import_rules.h" #include - // create a 2D-vector of all dk combinations ( ` + a -> à ; ^ + a -> â ; `+ e -> è; ...) void create_DKTable(vec_dword_2D &dk_ComposeTable); diff --git a/linux/mcompile/keymap/filesystem.cpp b/linux/mcompile/keymap/filesystem.cpp index 05d4da511d..a343641acc 100644 --- a/linux/mcompile/keymap/filesystem.cpp +++ b/linux/mcompile/keymap/filesystem.cpp @@ -9,7 +9,6 @@ #include #include "filesystem.h" - #ifdef _MSC_VER #include #else diff --git a/linux/mcompile/keymap/filesystem.h b/linux/mcompile/keymap/filesystem.h index b9454e6007..af3d6aa7d6 100644 --- a/linux/mcompile/keymap/filesystem.h +++ b/linux/mcompile/keymap/filesystem.h @@ -1,4 +1,5 @@ #pragma once + #include #include "u16.h" diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index a4bc3157a6..1b581158a2 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -3,7 +3,6 @@ #include "/usr/include/xcb/xproto.h" #include - int convert_WinShiftstate_to_LinuxShiftstate(int win_ShiftState) { if (win_ShiftState == 0) return 0; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 0f59b11b14..5047e8c51f 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -17,7 +17,6 @@ #include "u16.h" #include - enum ShiftState { Base = 0, // 0 Shft = 1, // 1 diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index 4b97663b00..5381ff1e6a 100644 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -2,7 +2,6 @@ #ifndef KM_TYPES #define KM_TYPES #include - /* #if defined(_WIN32) || defined(_WIN64) #define snprintf _snprintf diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index c29ad9ac68..9e54b7da18 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -19,7 +19,6 @@ 06 Feb 2015 - mcdurdin - I4552 - V9.0 - Add mnemonic recompile option to ignore deadkeys */ - #include #include #include diff --git a/linux/mcompile/keymap/mc_import_rules.h b/linux/mcompile/keymap/mc_import_rules.h index fac3db87be..51fd5502f4 100644 --- a/linux/mcompile/keymap/mc_import_rules.h +++ b/linux/mcompile/keymap/mc_import_rules.h @@ -3,7 +3,6 @@ #ifndef MC_IMPORT_RULES_H #define MC_IMPORT_RULES_H - class DeadKey { private: KMX_WCHAR m_deadchar; diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 2fe65be90a..861de1a8a3 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -6,7 +6,6 @@ #define CERR_UnableToWriteFully 0x00008007 #define CERR_SomewhereIGotItWrong 0x00008009 - const int CODE__SIZE[] = { -1, // undefined 0x00 1, // CODE_ANY 0x01 diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index e8477edc24..e71946f554 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -10,6 +10,7 @@ #ifndef _KMXFILE_H #define _KMXFILE_H + typedef struct KMX_tagSTORE { KMX_DWORD dwSystemID; PKMX_WCHAR dpName; diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index f6594a950f..4b4c7648c6 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -29,7 +29,6 @@ // for the subcomponents of the compiled keyboard is an unnecessary optimisation. Just so you know. // - #include "mcompile.h" //------------------------------------------------------------------------------------------------ diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 5888fdbf38..0812604b3d 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -17,7 +17,6 @@ */ - #ifndef MCOMPILE_H #define MCOMPILE_H #include diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index db9baab6b2..0c04ce8c35 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -8,7 +8,6 @@ libxklavier = dependency('libxklavier') deps = [gtk, xkb,libxklavier] - cpp_files = files( 'keymap.cpp', 'deadkey.cpp', diff --git a/linux/mcompile/keymap/u16.h b/linux/mcompile/keymap/u16.h index 53872dcb28..bfde3116a4 100644 --- a/linux/mcompile/keymap/u16.h +++ b/linux/mcompile/keymap/u16.h @@ -8,7 +8,6 @@ #include #include "km_types.h" - std::vector convert_argvW_to_Vector_u16str(int argc, wchar_t* argv[]); std::vector convert_argv_to_Vector_u16str(int argc, char* argv[]); From 5795625ca79679484b9f6b9c47e64373e2aedd81 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 26 Jun 2024 16:06:42 +0200 Subject: [PATCH 268/327] feat(linux): ... and back in --- linux/mcompile/keymap/README.md | 1 + linux/mcompile/keymap/deadkey.cpp | 1 + linux/mcompile/keymap/deadkey.h | 1 + linux/mcompile/keymap/filesystem.cpp | 1 + linux/mcompile/keymap/filesystem.h | 1 + linux/mcompile/keymap/keymap.cpp | 1 + linux/mcompile/keymap/keymap.h | 1 + linux/mcompile/keymap/km_types.h | 1 + linux/mcompile/keymap/mc_import_rules.cpp | 1 + linux/mcompile/keymap/mc_import_rules.h | 1 + linux/mcompile/keymap/mc_kmxfile.cpp | 1 + linux/mcompile/keymap/mc_kmxfile.h | 1 - linux/mcompile/keymap/mcompile.cpp | 1 - linux/mcompile/keymap/meson.build | 1 + linux/mcompile/keymap/u16.cpp | 4 ---- linux/mcompile/keymap/u16.h | 1 + 16 files changed, 13 insertions(+), 6 deletions(-) diff --git a/linux/mcompile/keymap/README.md b/linux/mcompile/keymap/README.md index cb154093d3..d12a0820e0 100644 --- a/linux/mcompile/keymap/README.md +++ b/linux/mcompile/keymap/README.md @@ -3,4 +3,5 @@ This is a proposal to rewrite mcompile for Linux. For this we need to query t Ideally, we'd rewrite mcompile to be cross-platform (Windows, Linux, macOS), so that the keyboard interrogation would be separated from the .kmx rewriting, at least to some degree. Nevertheless it would probably be easiest to start from a standalone implementation. Sample program that reads US basic keyboard and compares to key value group + # Keymap diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 56feb1d136..d5129734b5 100644 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -1,6 +1,7 @@ #include "keymap.h" #include "deadkey.h" + std::vector create_deadkeys_by_basechar() { std::vector alDead; vec_dword_2D dk_ComposeTable; diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index 652cf8808d..e57b2fb9de 100644 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -6,6 +6,7 @@ #include "mc_import_rules.h" #include + // create a 2D-vector of all dk combinations ( ` + a -> à ; ^ + a -> â ; `+ e -> è; ...) void create_DKTable(vec_dword_2D &dk_ComposeTable); diff --git a/linux/mcompile/keymap/filesystem.cpp b/linux/mcompile/keymap/filesystem.cpp index a343641acc..37458b9c33 100644 --- a/linux/mcompile/keymap/filesystem.cpp +++ b/linux/mcompile/keymap/filesystem.cpp @@ -15,6 +15,7 @@ #include #endif + //#define _DEBUG_FOPEN 1 #ifdef __EMSCRIPTEN__ diff --git a/linux/mcompile/keymap/filesystem.h b/linux/mcompile/keymap/filesystem.h index af3d6aa7d6..a3fcfeffef 100644 --- a/linux/mcompile/keymap/filesystem.h +++ b/linux/mcompile/keymap/filesystem.h @@ -3,6 +3,7 @@ #include #include "u16.h" + // Open files on windows and non-windows platforms. Datatypes for Filename and mode must be the same. // return FILE* if file could be opened; FILE must to be closed in calling function FILE* Open_File(const KMX_CHAR* Filename, const KMX_CHAR* mode); diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 1b581158a2..a4bc3157a6 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -3,6 +3,7 @@ #include "/usr/include/xcb/xproto.h" #include + int convert_WinShiftstate_to_LinuxShiftstate(int win_ShiftState) { if (win_ShiftState == 0) return 0; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 5047e8c51f..0f59b11b14 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -17,6 +17,7 @@ #include "u16.h" #include + enum ShiftState { Base = 0, // 0 Shft = 1, // 1 diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index 5381ff1e6a..89a806adce 100644 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -11,6 +11,7 @@ #endif */ + #if defined(__LP64__) || defined(_LP64) /* 64-bit, g++ */ #define KMX_64BIT diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 9e54b7da18..c29ad9ac68 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -19,6 +19,7 @@ 06 Feb 2015 - mcdurdin - I4552 - V9.0 - Add mnemonic recompile option to ignore deadkeys */ + #include #include #include diff --git a/linux/mcompile/keymap/mc_import_rules.h b/linux/mcompile/keymap/mc_import_rules.h index 51fd5502f4..fac3db87be 100644 --- a/linux/mcompile/keymap/mc_import_rules.h +++ b/linux/mcompile/keymap/mc_import_rules.h @@ -3,6 +3,7 @@ #ifndef MC_IMPORT_RULES_H #define MC_IMPORT_RULES_H + class DeadKey { private: KMX_WCHAR m_deadchar; diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 861de1a8a3..2fe65be90a 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -6,6 +6,7 @@ #define CERR_UnableToWriteFully 0x00008007 #define CERR_SomewhereIGotItWrong 0x00008009 + const int CODE__SIZE[] = { -1, // undefined 0x00 1, // CODE_ANY 0x01 diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index e71946f554..e8477edc24 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -10,7 +10,6 @@ #ifndef _KMXFILE_H #define _KMXFILE_H - typedef struct KMX_tagSTORE { KMX_DWORD dwSystemID; PKMX_WCHAR dpName; diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 4b4c7648c6..8428913314 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -34,7 +34,6 @@ //------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------ - KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]); bool KMX_ImportRules( LPKMX_KEYBOARD kp,vec_dword_3D& all_vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index 0c04ce8c35..db9baab6b2 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -8,6 +8,7 @@ libxklavier = dependency('libxklavier') deps = [gtk, xkb,libxklavier] + cpp_files = files( 'keymap.cpp', 'deadkey.cpp', diff --git a/linux/mcompile/keymap/u16.cpp b/linux/mcompile/keymap/u16.cpp index 2fbe03da5f..464212b1f4 100644 --- a/linux/mcompile/keymap/u16.cpp +++ b/linux/mcompile/keymap/u16.cpp @@ -1,12 +1,8 @@ #include "u16.h" - -//#include -//#include #include #include #include - std::vector convert_argv_to_Vector_u16str(int argc, char* argv[]) { std::vector vector_u16; diff --git a/linux/mcompile/keymap/u16.h b/linux/mcompile/keymap/u16.h index bfde3116a4..53872dcb28 100644 --- a/linux/mcompile/keymap/u16.h +++ b/linux/mcompile/keymap/u16.h @@ -8,6 +8,7 @@ #include #include "km_types.h" + std::vector convert_argvW_to_Vector_u16str(int argc, wchar_t* argv[]); std::vector convert_argv_to_Vector_u16str(int argc, char* argv[]); From fad203d84708767c3609280e5a020fd52e5816dd Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 26 Jun 2024 16:08:25 +0200 Subject: [PATCH 269/327] feat(linux): change mcompile.h --- linux/mcompile/keymap/mcompile.h | 1 + 1 file changed, 1 insertion(+) diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 0812604b3d..5888fdbf38 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -17,6 +17,7 @@ */ + #ifndef MCOMPILE_H #define MCOMPILE_H #include From 912b8ac9d4a43d615247a3d68c1df83a4dcbec4b Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 26 Jun 2024 21:28:10 +0200 Subject: [PATCH 270/327] feat(linux): more comments on keymap --- linux/mcompile/keymap/keymap.cpp | 41 ++++++++++++++++---------------- linux/mcompile/keymap/keymap.h | 4 ++-- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index a4bc3157a6..fdc1fa7ab8 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -317,7 +317,8 @@ int createOneVectorFromBothKeyboards(vec_dword_3D& all_vector, GdkKeymap* keymap // [Keyval unshifted ] // [Keyval shifted ] - if (write_US_ToVector(all_vector, "us", "xkb_symbols \"basic\"")) { + // use entries of English (US) for all_vector + if (write_US_ToVector(all_vector)) { printf("ERROR: can't write US to Vector \n"); return 1; } @@ -330,20 +331,19 @@ int createOneVectorFromBothKeyboards(vec_dword_3D& all_vector, GdkKeymap* keymap return 0; } -int write_US_ToVector(vec_dword_3D& vec, std::string language, const char* section) { - std::string fullPathName = "/usr/share/X11/xkb/symbols/" + language; +int write_US_ToVector(vec_dword_3D& vec) { + std::string fullPathName = "/usr/share/X11/xkb/symbols/usrdujuls"; const char* path = fullPathName.c_str(); - FILE* fp = fopen((path), "r"); - - if (!fp) { - printf("ERROR: could not open file!\n"); - return 1; - } // create 1D-vector of the complete line vec_string_1D vector_completeUS; - if (createCompleteVector_US(fullPathName, section, vector_completeUS)) { - printf("ERROR: can't Create complete row US \n"); + if (createCompleteVector_US(fullPathName, vector_completeUS)) { + printf("ERROR: can't create complete row US \n"); + return 1; + } + + if (vector_completeUS.size() < 2) { + printf("ERROR: several keys of US are not processed \n"); return 1; } @@ -352,35 +352,33 @@ int write_US_ToVector(vec_dword_3D& vec, std::string language, const char* secti return 1; } - fclose(fp); return 0; } -bool createCompleteVector_US(std::string fullPathName, const char* section, vec_string_1D& complete_List) { +bool createCompleteVector_US(std::string fullPathName, vec_string_1D& complete_List) { // in the Configuration file we find the appopriate paragraph between "xkb_symbol " and the next xkb_symbol // then copy all rows starting with "key <" to a 1D-Vector bool create_row = false; const char* key = "key <"; std::string line; - std::string str_us_kbd_name(section); + std::string str_us_kbd_name("xkb_symbols \"basic\""); std::string xbk_mark = "xkb_symbol"; std::ifstream inputFile(fullPathName); if (inputFile.is_open()) { while (getline(inputFile, line)) { - std::string str_buf(line); // stop when finding the mark xkb_symbol - if (std::string(str_buf).find(xbk_mark) != std::string::npos) + if (std::string(line).find(xbk_mark) != std::string::npos) create_row = false; // start when finding the mark xkb_symbol + correct layout - if (std::string(str_buf).find(str_us_kbd_name) != std::string::npos) + if (std::string(line).find(str_us_kbd_name) != std::string::npos) create_row = true; // as long as we are in the same xkb_symbol layout block and find "key <" we push the whole line into a 1D-vector - else if (create_row && (std::string(str_buf).find(key) != std::string::npos)) { + else if (create_row && (std::string(line).find(key) != std::string::npos)) { complete_List.push_back(line); } } @@ -567,9 +565,9 @@ vec_dword_2D create_empty_2D_Vector(int dim_rows, int dim_ss) { vec_dword_1D shifts; vec_dword_2D vector_2D; - for (int j = 0; j < dim_ss; j++) { - shifts.push_back(INVALID_NAME); - } + for (int j = 0; j < dim_ss; j++) { + shifts.push_back(INVALID_NAME); + } for (int i = 0; i < dim_rows; i++) { vector_2D.push_back(shifts); @@ -627,6 +625,7 @@ bool InitializeGDK(GdkKeymap** keymap, int argc, gchar* argv[]) { gdk_display_close(display); return 2; } + // intentionally leaking `display` in order to still be able to access `keymap` return 0; } diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 0f59b11b14..40b9f181de 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -85,10 +85,10 @@ KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str); int createOneVectorFromBothKeyboards(vec_dword_3D& All_Vector, GdkKeymap* keymap); // read configuration file, split and write to 3D-Vector (Data for US on Vector[0][ ][ ] ) -int write_US_ToVector(vec_dword_3D& vec, std::string language, const char* text); +int write_US_ToVector(vec_dword_3D& vec); // 1. step: read complete Row of Configuration file US -bool createCompleteVector_US(std::string fullPathName, const char* section, vec_string_1D& complete_List) ; +bool createCompleteVector_US(std::string fullPathName, vec_string_1D& complete_List) ; // replace Name of Key (e.g. ) wih Keycode ( e.g. 15 ) int replace_KeyName_with_Keycode(std::string in); From 7a0fcd11499a49a08786986e02bea2de0235a918 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 27 Jun 2024 15:48:01 +0200 Subject: [PATCH 271/327] feat(linux): more comments for keymap 2 --- linux/mcompile/keymap/keymap.cpp | 90 +++++++++++------------ linux/mcompile/keymap/keymap.h | 6 +- linux/mcompile/keymap/mc_import_rules.cpp | 2 +- 3 files changed, 49 insertions(+), 49 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index fdc1fa7ab8..7b4b620b4f 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -4,24 +4,23 @@ #include -int convert_WinShiftstate_to_LinuxShiftstate(int win_ShiftState) { - if (win_ShiftState == 0) - return 0; - else if (win_ShiftState == K_SHIFTFLAG) - return XCB_MOD_MASK_SHIFT; - else if (win_ShiftState == (LCTRLFLAG | RALTFLAG)) - return XCB_MOD_MASK_LOCK; - else if (win_ShiftState == (K_SHIFTFLAG | LCTRLFLAG | RALTFLAG)) - return (XCB_MOD_MASK_SHIFT | XCB_MOD_MASK_LOCK); - else - return win_ShiftState; +int convert_Shiftstate_to_LinuxShiftstate(int shiftState) { + // if shiftState is a windows ShiftState: convert the windows ShiftState (0,16,9,25) to a Linux ShiftState (0,1,2,3) that is then used as "Level" in gdk + // if shiftState is NOT a windows ShiftState (then in_ShiftState is already a Linux shiftstate): return the entered shiftstate + + if (shiftState == 0) return 0; // Win ss 0 -> Lin ss 0 + else if (shiftState == K_SHIFTFLAG) return XCB_MOD_MASK_SHIFT; // Win ss 16 -> Lin ss 1 + else if (shiftState == (LCTRLFLAG | RALTFLAG)) return XCB_MOD_MASK_LOCK; // Win ss 9 -> Lin ss 2 + else if (shiftState == (K_SHIFTFLAG | LCTRLFLAG | RALTFLAG)) return (XCB_MOD_MASK_SHIFT | XCB_MOD_MASK_LOCK); // Win ss 25 -> Lin ss 3 + else return shiftState; // Lin ss x -> Lin ss x } -bool ensureValidInputForKeyboardTranslation(int shiftstate, int count, int keycode) { - if (shiftstate > count) + +bool ensureValidInputForKeyboardTranslation(int gdk_level, gint count, gint keycode) { + if (gdk_level > (int) count) return false; - if (keycode > (int)keycode_max) + if ((int) keycode > (int)keycode_max) return false; return true; @@ -307,7 +306,7 @@ KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str) { } int createOneVectorFromBothKeyboards(vec_dword_3D& all_vector, GdkKeymap* keymap) { - // create a 3D-Vector which contains data of the US keyboard and the underlying Keyboard: + // create a 3D-Vector which contains data of the English (US) keyboard and the underlying Keyboard: // all_vector[ US_Keyboard ] // [KeyCode_US ] // [Keyval unshifted ] @@ -317,13 +316,13 @@ int createOneVectorFromBothKeyboards(vec_dword_3D& all_vector, GdkKeymap* keymap // [Keyval unshifted ] // [Keyval shifted ] - // use entries of English (US) for all_vector + // store contents of the English (US) keyboard in all_vector if (write_US_ToVector(all_vector)) { printf("ERROR: can't write US to Vector \n"); return 1; } - // add contents of other keyboard to all_vector + // add contents of underlying keyboard to all_vector if (append_underlying_ToVector(all_vector, keymap)) { printf("ERROR: can't append underlying ToVector \n"); return 2; @@ -332,30 +331,32 @@ int createOneVectorFromBothKeyboards(vec_dword_3D& all_vector, GdkKeymap* keymap } int write_US_ToVector(vec_dword_3D& vec) { - std::string fullPathName = "/usr/share/X11/xkb/symbols/usrdujuls"; - const char* path = fullPathName.c_str(); // create 1D-vector of the complete line vec_string_1D vector_completeUS; - if (createCompleteVector_US(fullPathName, vector_completeUS)) { + if (createCompleteVector_US(vector_completeUS)) { printf("ERROR: can't create complete row US \n"); return 1; } - if (vector_completeUS.size() < 2) { - printf("ERROR: several keys of US are not processed \n"); - return 1; - } - // split contents of 1D Vector to 3D vector if (split_US_To_3D_Vector(vec, vector_completeUS)) { return 1; } + if (vector_completeUS.size() != 48) { + printf("WARNING: the wrong keyboard input might have been chosen.\n"); + return 0; + } + + if (vector_completeUS.size() < 2) { + printf("ERROR: several keys of the US keyboard are not processed \n"); + return 1; + } return 0; } -bool createCompleteVector_US(std::string fullPathName, vec_string_1D& complete_List) { +bool createCompleteVector_US(vec_string_1D& complete_List) { // in the Configuration file we find the appopriate paragraph between "xkb_symbol " and the next xkb_symbol // then copy all rows starting with "key <" to a 1D-Vector @@ -364,31 +365,33 @@ bool createCompleteVector_US(std::string fullPathName, vec_string_1D& complete_L std::string line; std::string str_us_kbd_name("xkb_symbols \"basic\""); std::string xbk_mark = "xkb_symbol"; - std::ifstream inputFile(fullPathName); + std::ifstream inputFile("/usr/share/X11/xkb/symbols/us"); - if (inputFile.is_open()) { + if (!inputFile.is_open()) { + printf("ERROR: could not open file!\n"); + return 1; + } + + else { while (getline(inputFile, line)) { // stop when finding the mark xkb_symbol - if (std::string(line).find(xbk_mark) != std::string::npos) + if (line.find(xbk_mark) != std::string::npos) create_row = false; // start when finding the mark xkb_symbol + correct layout - if (std::string(line).find(str_us_kbd_name) != std::string::npos) + if (line.find(str_us_kbd_name) != std::string::npos) create_row = true; // as long as we are in the same xkb_symbol layout block and find "key <" we push the whole line into a 1D-vector - else if (create_row && (std::string(line).find(key) != std::string::npos)) { + else if (create_row && (line.find(key) != std::string::npos)) { complete_List.push_back(line); } } } complete_List.push_back(" key { [ space, space] };"); - if (complete_List.size() < 1) { - printf("ERROR: can't create row from US \n"); - return 1; - } + inputFile.close(); return 0; } @@ -588,8 +591,8 @@ int append_underlying_ToVector(vec_dword_3D& all_vector, GdkKeymap* keymap) { printf("ERROR: can't create empty 2D-Vector\n"); return 1; } - all_vector.push_back(underlying_Vector2D); + all_vector.push_back(underlying_Vector2D); if (all_vector.size() < 2) { printf("ERROR: creation of 3D-Vector failed\n"); return 1; @@ -600,10 +603,8 @@ int append_underlying_ToVector(vec_dword_3D& all_vector, GdkKeymap* keymap) { all_vector[1][i][0] = all_vector[0][i][0]; // get Keyvals of this key and copy to unshifted/shifted in "underlying"-block[1][i][1] / block[1][i][2] - all_vector[1][i][0 + 1] = - KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap, all_vector[0][i][0], 0); // shift state: unshifted:0 - all_vector[1][i][1 + 1] = - KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap, all_vector[0][i][0], 1); // shift state: shifted:1 + all_vector[1][i][0 + 1] = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap, all_vector[0][i][0], 0); // shift state: unshifted:0 + all_vector[1][i][1 + 1] = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap, all_vector[0][i][0], 1); // shift state: shifted:1 } return 0; @@ -668,7 +669,7 @@ int KMX_get_KeyVal_From_KeyCode(GdkKeymap* keymap, guint keycode, ShiftState ss, if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation(convert_WinShiftstate_to_LinuxShiftstate(ss), (int)count, (int)keycode))) { + if (!(ensureValidInputForKeyboardTranslation(convert_Shiftstate_to_LinuxShiftstate(ss), count, keycode))) { g_free(keyvals); g_free(maps); return 0; @@ -759,7 +760,7 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, gui if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation(shift_state_pos, (int)count, (int)keycode))) { + if (!(ensureValidInputForKeyboardTranslation(shift_state_pos, count, keycode))) { g_free(keyvals); g_free(maps); return 0; @@ -782,14 +783,13 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, UIN if (!gdk_keymap_get_entries_for_keycode(keymap, kc_underlying, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation( - convert_WinShiftstate_to_LinuxShiftstate(vk_ShiftState), (int)count, (int)kc_underlying))) { + if (!(ensureValidInputForKeyboardTranslation(convert_Shiftstate_to_LinuxShiftstate(vk_ShiftState), count, kc_underlying))) { g_free(keyvals); g_free(maps); return 0; } - KMX_DWORD keyV = KMX_get_KeyVal_From_KeyCode(keymap, kc_underlying, ShiftState(convert_WinShiftstate_to_LinuxShiftstate(vk_ShiftState)), 0); + KMX_DWORD keyV = KMX_get_KeyVal_From_KeyCode(keymap, kc_underlying, ShiftState(convert_Shiftstate_to_LinuxShiftstate(vk_ShiftState)), 0); g_free(keyvals); g_free(maps); diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 40b9f181de..faa80cc764 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -73,10 +73,10 @@ inline bool isLittleEndianSystem() { } // map Shiftstate to modifier (e.g. 0->0; 16-1; 9->2; 25->3) -int convert_WinShiftstate_to_LinuxShiftstate(int VKShiftState); +int convert_Shiftstate_to_LinuxShiftstate(int VKShiftState); // check if input is correct -bool ensureValidInputForKeyboardTranslation(int shiftstate, int count, int keycode); +bool ensureValidInputForKeyboardTranslation(int shiftstate, gint count, gint keycode); // take a std::string (=contents of line symbols-file ) and returns the (int) value of the character KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str); @@ -88,7 +88,7 @@ int createOneVectorFromBothKeyboards(vec_dword_3D& All_Vector, GdkKeymap* keymap int write_US_ToVector(vec_dword_3D& vec); // 1. step: read complete Row of Configuration file US -bool createCompleteVector_US(std::string fullPathName, vec_string_1D& complete_List) ; +bool createCompleteVector_US(vec_string_1D& complete_List) ; // replace Name of Key (e.g. ) wih Keycode ( e.g. 15 ) int replace_KeyName_with_Keycode(std::string in); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index c29ad9ac68..e91efd128e 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -69,7 +69,7 @@ int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation(shift_state_pos, (int)count, (int)keycode))){ + if (!(ensureValidInputForKeyboardTranslation(shift_state_pos, count, keycode))){ g_free(keyvals); g_free(maps); return 0; From 08f2b05384ce9cac816760658ff42e81e3c6bfd1 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 27 Jun 2024 17:19:54 +0200 Subject: [PATCH 272/327] feat(linux): >= instead of > for comparison with gdk_level --- linux/mcompile/keymap/keymap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 7b4b620b4f..40bb7074cc 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -17,7 +17,7 @@ int convert_Shiftstate_to_LinuxShiftstate(int shiftState) { bool ensureValidInputForKeyboardTranslation(int gdk_level, gint count, gint keycode) { - if (gdk_level > (int) count) + if (gdk_level >= (int) count) return false; if ((int) keycode > (int)keycode_max) From a488f61925bf2bfe2e02191990e1791f69690796 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 28 Jun 2024 09:05:43 +0200 Subject: [PATCH 273/327] feat(linux): rework mcompile switch --- linux/mcompile/keymap/mcompile.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 8428913314..fc34402190 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -294,11 +294,9 @@ void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT KMX_WCHAR KMX_ScanXStringForMaxDeadkeyID(PKMX_WCHAR str) { KMX_WCHAR dkid = 0; while(str && *str) { - if(*str == UC_SENTINEL) { - switch(*(str+1)) { - case CODE_DEADKEY: - dkid = max(dkid, *(str+2)); - } + if(*str == UC_SENTINEL && *(str+1) == CODE_DEADKEY) { + dkid = max(dkid, *(str+2)); + } } str = KMX_incxstr(str); } From 6647932a14b57a210dd95e0a9dc9f7b314eefa9a Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 28 Jun 2024 13:57:47 +0200 Subject: [PATCH 274/327] feat(linux): move run, GetDeadkeys: declaration to fwd-decl in cpp`s --- linux/mcompile/keymap/mcompile.cpp | 5 ++++- linux/mcompile/keymap/mcompile.h | 4 ---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index fc34402190..db8200a041 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -38,6 +38,10 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg bool KMX_ImportRules( LPKMX_KEYBOARD kp,vec_dword_3D& all_vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 +int run(int argc, std::vector str_argv, char* argv_ch[]); + +int KMX_GetDeadkeys(vec_dword_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap); + std::vector KMX_FDeadkeys; // I4353 // Note: max is not a standard c api function or macro @@ -297,7 +301,6 @@ KMX_WCHAR KMX_ScanXStringForMaxDeadkeyID(PKMX_WCHAR str) { if(*str == UC_SENTINEL && *(str+1) == CODE_DEADKEY) { dkid = max(dkid, *(str+2)); } - } str = KMX_incxstr(str); } return dkid; diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 5888fdbf38..77f6eceb46 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -33,10 +33,6 @@ struct KMX_DeadkeyMapping { // I4353 extern std::vector KMX_FDeadkeys; // I4353 -int run(int argc, std::vector str_argv, char* argv[]); - -int KMX_GetDeadkeys(vec_dword_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap); - void KMX_LogError(const wchar_t* fmt, ...); #endif /*MCOMPILE_H*/ From 69660376d925b4252959b178618ea58e379343ef Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 28 Jun 2024 13:59:16 +0200 Subject: [PATCH 275/327] feat(linux): remove filesystem.h/cpp and move OpenFile() function to mc_kmx_file --- linux/mcompile/keymap/filesystem.cpp | 189 --------------------------- linux/mcompile/keymap/filesystem.h | 13 -- linux/mcompile/keymap/mc_kmxfile.cpp | 29 ++++ linux/mcompile/keymap/mc_kmxfile.h | 6 +- linux/mcompile/keymap/meson.build | 1 - 5 files changed, 34 insertions(+), 204 deletions(-) delete mode 100644 linux/mcompile/keymap/filesystem.cpp delete mode 100644 linux/mcompile/keymap/filesystem.h diff --git a/linux/mcompile/keymap/filesystem.cpp b/linux/mcompile/keymap/filesystem.cpp deleted file mode 100644 index 37458b9c33..0000000000 --- a/linux/mcompile/keymap/filesystem.cpp +++ /dev/null @@ -1,189 +0,0 @@ - -#ifdef __EMSCRIPTEN__ -#include -#include -#endif - -#include -#include -#include -#include "filesystem.h" - -#ifdef _MSC_VER -#include -#else -#include -#endif - - -//#define _DEBUG_FOPEN 1 - -#ifdef __EMSCRIPTEN__ - -const std::string get_wasm_file_path(const std::string& filename) { - // Verify that we are passing a fully-qualified path - // TODO: we need to support relative paths based on CWD -#if _DEBUG_FOPEN - std::cout << "get_wasm_file_path ENTER (" << filename << ")" << std::endl; -#endif - - assert( - (filename.length() > 0 && filename.at(0) == '/') || - (filename.length() > 1 && filename.at(1) == ':') - ); - -#if _DEBUG_FOPEN - std::cout << "get_wasm_file_path assert passed " << std::endl; -#endif - - EM_ASM_({ - //console.log('EM_ASM enter'); - let path = Module.UTF8ToString($0); - const isWin32Path = path.match(/^[a-zA-Z]:/); - - //console.log('EM_ASM path = '+path); - let root = '/nodefs-mount'; - if(!FS.analyzePath(root).exists) { - //console.log('EM_ASM mkdir '+root); - FS.mkdir(root); - if(!isWin32Path) { - //console.log('EM_ASM mount '+root); - FS.mount(NODEFS, {root : '/'}, root); - } - } - - if(isWin32Path) { - // Win32 path, one mount per drive - root += "/" + path.charAt(0); - if(!FS.analyzePath(root).exists) { - //console.log('EM_ASM mkdir '+root); - FS.mkdir(root); - //console.log('EM_ASM mount '+root); - FS.mount(NODEFS, {root : path.substr(0,3) }, root); - } - } - }, filename.c_str()); - -#if _DEBUG_FOPEN - std::cout << "get_wasm_file_path EM_ASM_ passed " << std::endl; -#endif - - std::string f = std::string("/nodefs-mount"); - - if(filename.length() > 2 && filename.at(1) == ':') { - f += std::string("/") + filename.at(0) + filename.substr(2); - } else { - f += filename; - } - -#if _DEBUG_FOPEN - std::cout << "get_wasm_file_path opening virtual path: " << f << std::endl; -#endif - - return f; -} - -FILE* fopen_wasm(const std::string& filename, const std::string& mode) { - std::string f = get_wasm_file_path(filename); - FILE* fp = fopen(f.c_str(), mode.c_str()); - -#if _DEBUG_FOPEN - std::cout << "get_wasm_file_path fopen called, returned " << fp << std::endl; -#endif - - return fp; -} - -#endif - -#ifndef _MSC_VER -#ifdef __EMSCRIPTEN__ -#define fopen_wrapper fopen_wasm -#else -#define fopen_wrapper fopen -#endif -#endif - -FILE* Open_File(const KMX_CHAR* Filename, const KMX_CHAR* mode) { -#ifdef _MSC_VER - std::string cpath = Filename; //, cmode = mode; - std::replace(cpath.begin(), cpath.end(), '/', '\\'); - return fopen(cpath.c_str(), (const KMX_CHAR*) mode); -#else - return fopen_wrapper(Filename, mode); - std::string cpath, cmode; - cpath = (const KMX_CHAR*) Filename; - cmode = (const KMX_CHAR*) mode; - return fopen_wrapper(cpath.c_str(), cmode.c_str()); -#endif -}; - -FILE* Open_File(const KMX_WCHART* Filename, const KMX_WCHART* mode) { -#ifdef _MSC_VER - std::wstring cpath = Filename; //, cmode = mode; - std::replace(cpath.begin(), cpath.end(), '/', '\\'); - return _wfsopen(cpath.c_str(), mode, _SH_DENYWR); -#else - std::string cpath, cmode; - cpath = string_from_wstring(Filename); - cmode = string_from_wstring(mode); - return fopen_wrapper(cpath.c_str(), cmode.c_str()); -#endif -}; - -FILE* Open_File(const KMX_WCHAR* Filename, const KMX_WCHAR* mode) { -#ifdef _MSC_VER - std::wstring cpath = convert_pchar16T_To_wstr((KMX_WCHAR*) Filename); - std::wstring cmode = convert_pchar16T_To_wstr((KMX_WCHAR*) mode); - std::replace(cpath.begin(), cpath.end(), '/', '\\'); - return _wfsopen(cpath.c_str(), cmode.c_str(), _SH_DENYWR); -#else - std::string cpath, cmode; - cpath = string_from_u16string(Filename); - cmode = string_from_u16string(mode); - return fopen_wrapper(cpath.c_str(), cmode.c_str()); -#endif -}; - -KMX_BOOL kmcmp_FileExists(const KMX_CHAR *filename) { - -#ifdef _MSC_VER - intptr_t n; - _finddata_t fi; - if((n = _findfirst(filename, &fi)) != -1) { - _findclose(n); - return TRUE; - } -#else //!_MSC_VER - -#ifdef __EMSCRIPTEN__ - std::string f = get_wasm_file_path(filename); -#else //!__EMSCRIPTEN__ - std::string f = filename; -#endif // !__EMSCRIPTEN__ - - if(access(f.c_str(), F_OK) != -1) { - return TRUE; - } - -#endif // !_MSC_VER - - return FALSE; -} - -KMX_BOOL kmcmp_FileExists(const KMX_WCHAR* filename) { -#ifdef _MSC_VER - intptr_t n; - _wfinddata_t fi; - if((n = _wfindfirst((wchar_t*) filename, &fi)) != -1) { - _findclose(n); - return TRUE; - } -#else - std::string cpath; - cpath = string_from_u16string(filename); - return kmcmp_FileExists(cpath.c_str()); -#endif - - return FALSE; -}; diff --git a/linux/mcompile/keymap/filesystem.h b/linux/mcompile/keymap/filesystem.h deleted file mode 100644 index a3fcfeffef..0000000000 --- a/linux/mcompile/keymap/filesystem.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include -#include "u16.h" - - -// Open files on windows and non-windows platforms. Datatypes for Filename and mode must be the same. -// return FILE* if file could be opened; FILE must to be closed in calling function -FILE* Open_File(const KMX_CHAR* Filename, const KMX_CHAR* mode); -FILE* Open_File(const KMX_WCHART* Filename, const KMX_WCHART* mode); -FILE* Open_File(const KMX_WCHAR* Filename, const KMX_WCHAR* mode); -KMX_BOOL kmcmp_FileExists(const KMX_CHAR *filename); -KMX_BOOL kmcmp_FileExists(const KMX_WCHAR *filename); diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 2fe65be90a..262f78d4b0 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -523,3 +523,32 @@ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p) { } return p; } + + +FILE* Open_File(const KMX_CHAR* Filename, const KMX_CHAR* mode) { +#ifdef _MSC_VER + std::string cpath = Filename; //, cmode = mode; + std::replace(cpath.begin(), cpath.end(), '/', '\\'); + return fopen(cpath.c_str(), (const KMX_CHAR*) mode); +#else + return fopen(Filename, mode); + std::string cpath, cmode; + cpath = (const KMX_CHAR*) Filename; + cmode = (const KMX_CHAR*) mode; + return fopen(cpath.c_str(), cmode.c_str()); +#endif +}; + +FILE* Open_File(const KMX_WCHAR* Filename, const KMX_WCHAR* mode) { +#ifdef _MSC_VER + std::wstring cpath = convert_pchar16T_To_wstr((KMX_WCHAR*) Filename); + std::wstring cmode = convert_pchar16T_To_wstr((KMX_WCHAR*) mode); + std::replace(cpath.begin(), cpath.end(), '/', '\\'); + return _wfsopen(cpath.c_str(), cmode.c_str(), _SH_DENYWR); +#else + std::string cpath, cmode; + cpath = string_from_u16string(Filename); + cmode = string_from_u16string(mode); + return fopen(cpath.c_str(), cmode.c_str()); +#endif +}; diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index e8477edc24..692c378888 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -4,7 +4,6 @@ #include "km_types.h" #include -#include "filesystem.h" #include "mcompile.h" #ifndef _KMXFILE_H @@ -75,6 +74,11 @@ KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, KMX_CHAR* filename); PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); +// _S2 Open files on windows and non-windows platforms. Datatypes for Filename and mode must be the same. +// return FILE* if file could be opened; FILE must to be closed in calling function +FILE* Open_File(const KMX_CHAR* Filename, const KMX_CHAR* mode); +FILE* Open_File(const KMX_WCHAR* Filename, const KMX_WCHAR* mode); + #endif // _KMXFILE_H #endif /*MC_KMXFILE_H*/ diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index db9baab6b2..186173a1af 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -13,7 +13,6 @@ cpp_files = files( 'keymap.cpp', 'deadkey.cpp', 'mcompile.cpp', - 'filesystem.cpp', 'mc_kmxfile.cpp', 'mc_import_rules.cpp', 'u16.cpp',) From f6c5a4a81d4f3ba49b88c279d3d87bce5110add4 Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 28 Jun 2024 17:15:24 +0200 Subject: [PATCH 276/327] feat(linux): warning after Error, keycode_max --- linux/mcompile/keymap/keymap.cpp | 13 +++++++------ linux/mcompile/keymap/keymap.h | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 40bb7074cc..12d3bf5b0c 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -17,10 +17,10 @@ int convert_Shiftstate_to_LinuxShiftstate(int shiftState) { bool ensureValidInputForKeyboardTranslation(int gdk_level, gint count, gint keycode) { - if (gdk_level >= (int) count) + if (gdk_level > (int) count) return false; - if ((int) keycode > (int)keycode_max) + if (keycode > keycode_max) return false; return true; @@ -344,15 +344,16 @@ int write_US_ToVector(vec_dword_3D& vec) { return 1; } + if (vector_completeUS.size() < 2) { + printf("ERROR: several keys of the US keyboard are not processed \n"); + return 1; + } + if (vector_completeUS.size() != 48) { printf("WARNING: the wrong keyboard input might have been chosen.\n"); return 0; } - if (vector_completeUS.size() < 2) { - printf("ERROR: several keys of the US keyboard are not processed \n"); - return 1; - } return 0; } diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index faa80cc764..3f89bb66bc 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -63,7 +63,7 @@ typedef std::vector > vec_dword_2D; typedef std::vector > > vec_dword_3D; static KMX_DWORD INVALID_NAME = 0; -static KMX_DWORD keycode_max = 94; +static gint keycode_max = 94; static KMX_DWORD deadkey_min = 0xfe50; // X11's keysymdef.h defines deadkeys between 0xfe50-0xfe93 static KMX_DWORD deadkey_max = 0xfe93; // https://fossies.org/linux/tk/xlib/X11/keysymdef.h From ec05b415464a0aec7e4c8135662a71908df7301a Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 28 Jun 2024 20:00:22 +0200 Subject: [PATCH 277/327] feat(linux): char-filenames, check parameters in run() --- linux/mcompile/keymap/keymap.cpp | 2 +- linux/mcompile/keymap/mc_kmxfile.cpp | 4 +- linux/mcompile/keymap/mc_kmxfile.h | 3 +- linux/mcompile/keymap/mcompile.cpp | 246 +++++++++++++-------------- linux/mcompile/keymap/mcompile.h | 21 ++- 5 files changed, 132 insertions(+), 144 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 40bb7074cc..261fddbc84 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -17,7 +17,7 @@ int convert_Shiftstate_to_LinuxShiftstate(int shiftState) { bool ensureValidInputForKeyboardTranslation(int gdk_level, gint count, gint keycode) { - if (gdk_level >= (int) count) + if (gdk_level > (int) count) return false; if ((int) keycode > (int)keycode_max) diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 262f78d4b0..2a3d80ee85 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -358,7 +358,7 @@ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFil #endif -KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { +KMX_BOOL KMX_LoadKeyboard(KMX_CHAR* fileName, LPKMX_KEYBOARD* lpKeyboard) { *lpKeyboard = NULL; PKMX_BYTE buf; @@ -371,7 +371,7 @@ KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD* lpKeyboard) { return FALSE; } - fp = Open_File((const KMX_WCHAR*)fileName, u"rb"); + fp = Open_File((const KMX_CHAR*)fileName, "rb"); if(fp == NULL) { KMX_LogError(L"Could not open file\n" ); diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 692c378888..9e608c4444 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -68,8 +68,7 @@ typedef struct KMX_tagKEYBOARD { //HBITMAP hBitmap; // handle to the bitmap in the file; } KMX_KEYBOARD, *LPKMX_KEYBOARD; -KMX_BOOL KMX_LoadKeyboard(char16_t* fileName, LPKMX_KEYBOARD *lpKeyboard); - +KMX_BOOL KMX_LoadKeyboard(KMX_CHAR* fileName, LPKMX_KEYBOARD* lpKeyboard) ; KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, KMX_CHAR* filename); PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index db8200a041..f996721fc6 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -36,69 +36,58 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]); -bool KMX_ImportRules( LPKMX_KEYBOARD kp,vec_dword_3D& all_vector, GdkKeymap **keymap,std::vector *KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 +bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** keymap, std::vector* KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 -int run(int argc, std::vector str_argv, char* argv_ch[]); +int run(int argc, char* argv[], char* argv_gdk[] = NULL); -int KMX_GetDeadkeys(vec_dword_2D & dk_Table, KMX_WORD DeadKey, KMX_WORD *OutputPairs, GdkKeymap* keymap); +int KMX_GetDeadkeys(vec_dword_2D& dk_Table, KMX_WORD DeadKey, KMX_WORD* OutputPairs, GdkKeymap* keymap); std::vector KMX_FDeadkeys; // I4353 // Note: max is not a standard c api function or macro #ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) +#define max(a, b) (((a) > (b)) ? (a) : (b)) #endif -#define _countof(a) (sizeof(a)/sizeof(*(a))) +#define _countof(a) (sizeof(a) / sizeof(*(a))) #if defined(_WIN32) || defined(_WIN64) int wmain(int argc, wchar_t* argv[]) { - std::vector str_argv_16 = convert_argvW_to_Vector_u16str( argc, argv); - run(argc, str_argv_16); + run(argc, argv); #else // LINUX int main(int argc, char* argv[]) { - std::vector str_argv_16 = convert_argv_to_Vector_u16str(argc, argv); - run(argc, str_argv_16, argv); + run(argc, argv, argv); #endif - } -int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ +int run(int argc, char* argv[], char* argv_gdk[]) { - std::vector argv; - for (int i = 0; i < argc; i++) { - const char16_t* cmdl_par = str_argv[i].c_str(); - argv.push_back(cmdl_par); - } + int bDeadkeyConversion = 0; - if(argc < 3 || (argc > 4)) { // I4273// I4273 + if( argc > 1) + bDeadkeyConversion = (strcmp(argv[1], "-d") == 0); // I4552 + + int n = (bDeadkeyConversion ? 2 : 1); + + if (argc < 3 || argc > 4 || argc-n !=2) { // I4273// I4273 wprintf( - L"Usage: mcompile [-d] infile.kmx outfile.kmx\n" - L" mmcompile -u ... (not available for Linux)\n " - L" mcompile converts a Keyman mnemonic layout to a\n" - L" positional one based on the Linux keyboard\n" - L" layout on top position\n" - L" (-d convert deadkeys to plain keys) not available yet \n\n" - ); // I4552 + L"Usage: \tmcompile [-d] infile.kmx outfile.kmx\n" + L" \tmcompile -u ... (not available for Linux)\n " + L" \tmcompile converts a Keyman mnemonic layout to a\n" + L" \tpositional one based on the Linux keyboard\n" + L" \tlayout on top position\n" + L" \t(-d convert deadkeys to plain keys) \n \n"); // I4552 return 1; } + // -u option is not available for Linux + KMX_CHAR* infile = argv[n]; + KMX_CHAR* outfile = argv[n + 1]; - int bDeadkeyConversion = u16cmp(argv[1], u"-d") == 0; // I4552 - int n = (bDeadkeyConversion ? 2 : 1); - -// _S2 needs more work once mcompile is changed after review ( use char* only instead of char16_t*) - char16_t* infile = (char16_t*) argv[n]; - char16_t* outfile_16 = (char16_t*) argv[n+1]; - std::u16string u16stri(outfile_16); - std::string str= string_from_u16string(u16stri); - char* outfile = (char*) str.c_str(); - - - printf("mcompile%ls \"%ls\" \"%ls\"\n", bDeadkeyConversion ? L" -d" : L"", u16fmt((const char16_t*) infile).c_str(), u16fmt((const char16_t*) outfile_16).c_str() ); // I4174 + printf("mcompile%s \"%s\" \"%s\"\n", bDeadkeyConversion ? " -d" : "", infile, outfile); // I4174 // 1. Load the keyman keyboard file @@ -125,33 +114,36 @@ int run(int argc, std::vector str_argv, char* argv_ch[] = NULL){ // // 3. Write the new keyman keyboard file - LPKMX_KEYBOARD kmxfile; - if(!KMX_LoadKeyboard(infile, &kmxfile)) { - KMX_LogError(L"Failed to load keyboard (%d)\n", errno ); + if (!KMX_LoadKeyboard(infile, &kmxfile)) { + KMX_LogError(L"Failed to load keyboard (%d)\n", errno); return 3; } - #if defined(_WIN32) || defined(_WIN64) - /*if(DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552F + /*if (DoConvert(kmxfile, kbid, bDeadkeyConversion)) { // I4552F KMX_SaveKeyboard(kmxfile, outfile); }*/ #else // LINUX - if(KMX_DoConvert( kmxfile, bDeadkeyConversion, argc, (gchar**) argv_ch)) { // I4552F + if (argv_gdk == NULL) { + KMX_LogError(L"Missing parameter for initializing GdkKeymap \n"); + return 3; + } + + if (KMX_DoConvert(kmxfile, bDeadkeyConversion, argc, (gchar**)argv_gdk)) { // I4552F KMX_SaveKeyboard(kmxfile, outfile); } #endif - //DeleteReallocatedPointers(kmxfile); :TODO // _S2 not my ToDo :-) + // DeleteReallocatedPointers(kmxfile); :TODO // _S2 not my ToDo :-) delete kmxfile; return 0; } // Map of all shift states that we will work with -const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF}; +const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG | RALTFLAG, K_SHIFTFLAG | LCTRLFLAG | RALTFLAG, 0xFFFF}; // // TranslateKey @@ -163,58 +155,58 @@ void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. - if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) + if ((shift & (LCTRLFLAG | RALTFLAG)) == (LCTRLFLAG | RALTFLAG)) shift &= ~LCTRLFLAG; - if(key->ShiftFlags == 0 && key->Key == ch) { + if (key->ShiftFlags == 0 && key->Key == ch) { // Key is a mnemonic key with no shift state defined. // Remap the key according to the character on the key cap. - //KMX_LogError(L"Converted mnemonic rule on line %d, + '%c' TO + [%x K_%d]", key->Line, key->Key, shift, vk); + // KMX_LogError(L"Converted mnemonic rule on line %d, + '%c' TO + [%x K_%d]", key->Line, key->Key, shift, vk); key->ShiftFlags = ISVIRTUALKEY | shift; key->Key = vk; - } else if(key->ShiftFlags & VIRTUALCHARKEY && key->Key == ch) { + } else if (key->ShiftFlags & VIRTUALCHARKEY && key->Key == ch) { // Key is a virtual character key with a hard-coded shift state. // Do not remap the shift state, just move the key. // This will not result in 100% wonderful mappings as there could // be overlap, depending on how keys are arranged on the target layout. // But that is up to the designer. - //KMX_LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, key->ShiftFlags & ~VIRTUALCHARKEY, vk); + // KMX_LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, key->ShiftFlags & ~VIRTUALCHARKEY, vk); key->ShiftFlags &= ~VIRTUALCHARKEY; key->Key = vk; } } void KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { - for(unsigned int i = 0; i < group->cxKeyArray; i++) { + for (unsigned int i = 0; i < group->cxKeyArray; i++) { KMX_TranslateKey(&group->dpKeyArray[i], vk, shift, ch); } } void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { + for (unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if (kbd->dpGroupArray[i].fUsingKeys) { KMX_TranslateGroup(&kbd->dpGroupArray[i], vk, shift, ch); } } } void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key) { - if(key->ShiftFlags == 0) { - //KMX_LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); - } else if(key->ShiftFlags & VIRTUALCHARKEY) { + if (key->ShiftFlags == 0) { + // KMX_LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); + } else if (key->ShiftFlags & VIRTUALCHARKEY) { KMX_LogError(L"Did not find a match for mnemonic virtual character key rule on line %d, + [%x '%c'] > ...", key->Line, key->ShiftFlags, key->Key); } } void KMX_ReportUnconvertedGroupRules(LPKMX_GROUP group) { - for(unsigned int i = 0; i < group->cxKeyArray; i++) { + for (unsigned int i = 0; i < group->cxKeyArray; i++) { KMX_ReportUnconvertedKeyRule(&group->dpKeyArray[i]); } } void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { + for (unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if (kbd->dpGroupArray[i].fUsingKeys) { KMX_ReportUnconvertedGroupRules(&kbd->dpGroupArray[i]); } } @@ -223,18 +215,18 @@ void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { // _S2 TOP_2 INFO this produces a different output due to different layouts for Lin<-> win ( for the same language!!) - if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { + if ((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. - if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4327 + if ((shift & (LCTRLFLAG | RALTFLAG)) == (LCTRLFLAG | RALTFLAG)) // I4327 shift &= ~LCTRLFLAG; - if(key->ShiftFlags == 0) { - //KMX_LogError(L"Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d]", key->Line, key->Key, deadkey, shift, vk); + if (key->ShiftFlags == 0) { + // KMX_LogError(L"Converted mnemonic rule on line %d, + '%c' TO dk(%d) + [%x K_%d]", key->Line, key->Key, deadkey, shift, vk); key->ShiftFlags = ISVIRTUALKEY | shift; } else { - //KMX_LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO dk(%d) + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, deadkey, key->ShiftFlags & ~VIRTUALCHARKEY, vk); + // KMX_LogError(L"Converted mnemonic virtual char key rule on line %d, + [%x '%c'] TO dk(%d) + [%x K_%d]", key->Line, key->ShiftFlags, key->Key, deadkey, key->ShiftFlags & ~VIRTUALCHARKEY, vk); key->ShiftFlags &= ~VIRTUALCHARKEY; } @@ -243,23 +235,23 @@ void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT PKMX_WCHAR context = new KMX_WCHAR[len + 4]; memcpy(context, key->dpContext, len * sizeof(KMX_WCHAR)); context[len] = UC_SENTINEL; - context[len+1] = CODE_DEADKEY; - context[len+2] = deadkey; - context[len+3] = 0; + context[len + 1] = CODE_DEADKEY; + context[len + 2] = deadkey; + context[len + 3] = 0; key->dpContext = context; key->Key = vk; } } -void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group,KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { - for(unsigned int i = 0; i < group->cxKeyArray; i++) { +void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { + for (unsigned int i = 0; i < group->cxKeyArray; i++) { KMX_TranslateDeadkeyKey(&group->dpKeyArray[i], deadkey, vk, shift, ch); } } void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { + for (unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if (kbd->dpGroupArray[i].fUsingKeys) { KMX_TranslateDeadkeyGroup(&kbd->dpGroupArray[i], deadkey, vk, shift, ch); } } @@ -269,14 +261,14 @@ void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. - if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4549 + if ((shift & (LCTRLFLAG | RALTFLAG)) == (LCTRLFLAG | RALTFLAG)) // I4549 shift &= ~LCTRLFLAG; // If the first group is not a matching-keys group, then we need to add into // each subgroup, otherwise just the match group - for(unsigned int i = 0; i < kbd->cxGroupArray; i++) { - if(kbd->dpGroupArray[i].fUsingKeys) { + for (unsigned int i = 0; i < kbd->cxGroupArray; i++) { + if (kbd->dpGroupArray[i].fUsingKeys) { LPKMX_KEY keys = new KMX_KEY[kbd->dpGroupArray[i].cxKeyArray + 1]; - memcpy(keys+1, kbd->dpGroupArray[i].dpKeyArray, kbd->dpGroupArray[i].cxKeyArray * sizeof(KMX_KEY)); + memcpy(keys + 1, kbd->dpGroupArray[i].dpKeyArray, kbd->dpGroupArray[i].cxKeyArray * sizeof(KMX_KEY)); keys[0].dpContext = new KMX_WCHAR[1]; keys[0].dpContext[0] = 0; keys[0].dpOutput = new KMX_WCHAR[4]; @@ -290,16 +282,17 @@ void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT kbd->dpGroupArray[i].dpKeyArray = keys; kbd->dpGroupArray[i].cxKeyArray++; KMX_LogError(L"Add deadkey rule: + [%d K_%d] > dk(%d)", shift, vk, deadkey); - if(i == kbd->StartGroup[1]) break; // If this is the initial group, that's all we need to do. + if (i == kbd->StartGroup[1]) + break; // If this is the initial group, that's all we need to do. } } } KMX_WCHAR KMX_ScanXStringForMaxDeadkeyID(PKMX_WCHAR str) { KMX_WCHAR dkid = 0; - while(str && *str) { - if(*str == UC_SENTINEL && *(str+1) == CODE_DEADKEY) { - dkid = max(dkid, *(str+2)); + while (str && *str) { + if (*str == UC_SENTINEL && *(str + 1) == CODE_DEADKEY) { + dkid = max(dkid, *(str + 2)); } str = KMX_incxstr(str); } @@ -317,11 +310,11 @@ KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { UINT i, j; KMX_WCHAR dkid = 0; static KMX_WCHAR s_next_dkid = 0; - static KMX_dkidmap *s_dkids = NULL; + static KMX_dkidmap* s_dkids = NULL; static int s_ndkids = 0; - if(!kbd) { - if(s_dkids) { + if (!kbd) { + if (s_dkids) { delete s_dkids; } s_dkids = NULL; @@ -330,20 +323,20 @@ KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { return 0; } - for(int i = 0; i < s_ndkids; i++) { - if(s_dkids[i].src_deadkey == deadkey) { + for (int i = 0; i < s_ndkids; i++) { + if (s_dkids[i].src_deadkey == deadkey) { return s_dkids[i].dst_deadkey; } } - if(s_next_dkid != 0) { - s_dkids = (KMX_dkidmap*) realloc(s_dkids, sizeof(KMX_dkidmap) * (s_ndkids+1)); + if (s_next_dkid != 0) { + s_dkids = (KMX_dkidmap*)realloc(s_dkids, sizeof(KMX_dkidmap) * (s_ndkids + 1)); s_dkids[s_ndkids].src_deadkey = deadkey; return s_dkids[s_ndkids++].dst_deadkey = ++s_next_dkid; } - for(i = 0, gp = kbd->dpGroupArray; i < kbd->cxGroupArray; i++, gp++) { - for(j = 0, kp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kp++) { + for (i = 0, gp = kbd->dpGroupArray; i < kbd->cxGroupArray; i++, gp++) { + for (j = 0, kp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kp++) { dkid = max(dkid, KMX_ScanXStringForMaxDeadkeyID(kp->dpContext)); dkid = max(dkid, KMX_ScanXStringForMaxDeadkeyID(kp->dpOutput)); } @@ -351,16 +344,16 @@ KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { dkid = max(dkid, KMX_ScanXStringForMaxDeadkeyID(gp->dpNoMatch)); } - for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { + for (i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { dkid = max(dkid, KMX_ScanXStringForMaxDeadkeyID(sp->dpString)); } - s_dkids = (KMX_dkidmap*) realloc(s_dkids, sizeof(KMX_dkidmap) * (s_ndkids+1)); + s_dkids = (KMX_dkidmap*)realloc(s_dkids, sizeof(KMX_dkidmap) * (s_ndkids + 1)); s_dkids[s_ndkids].src_deadkey = deadkey; return s_dkids[s_ndkids++].dst_deadkey = s_next_dkid = ++dkid; } -void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, UINT shift, KMX_WCHAR deadkey, vec_dword_3D& all_vector, GdkKeymap* keymap,vec_dword_2D dk_Table) { +void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, UINT shift, KMX_WCHAR deadkey, vec_dword_3D& all_vector, GdkKeymap* keymap, vec_dword_2D dk_Table) { KMX_WORD deadkeys[512], *pdk; // Lookup the deadkey table for the deadkey in the physical keyboard @@ -368,31 +361,31 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, UINT shift, KMX_WCHA KMX_WCHAR dkid = KMX_GetUniqueDeadkeyID(kbd, deadkey); // Add the deadkey to the mapping table for use in the import rules phase - KMX_DeadkeyMapping KMX_deadkeyMapping = { deadkey, dkid, shift, vk_US}; // I4353 + KMX_DeadkeyMapping KMX_deadkeyMapping = {deadkey, dkid, shift, vk_US}; // I4353 - KMX_FDeadkeys.push_back(KMX_deadkeyMapping); //dkid, vk, shift); // I4353 + KMX_FDeadkeys.push_back(KMX_deadkeyMapping); // dkid, vk, shift); // I4353 KMX_AddDeadkeyRule(kbd, dkid, vk_US, shift); KMX_GetDeadkeys(dk_Table, deadkey, pdk = deadkeys, keymap); // returns array of [usvk, ch_out] pairs - while(*pdk) { + while (*pdk) { // Look up the ch UINT KeyValUnderlying = KMX_get_KeyValUnderlying_From_KeyValUS(all_vector, *pdk); - KMX_TranslateDeadkeyKeyboard(kbd, dkid, KeyValUnderlying, *(pdk+1), *(pdk+2)); - pdk+=3; + KMX_TranslateDeadkeyKeyboard(kbd, dkid, KeyValUnderlying, *(pdk + 1), *(pdk + 2)); + pdk += 3; } } KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { LPKMX_STORE sp; UINT i; - for(i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { - if(sp->dwSystemID == TSS_MNEMONIC) { - if(!sp->dpString) { + for (i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { + if (sp->dwSystemID == TSS_MNEMONIC) { + if (!sp->dpString) { KMX_LogError(L"Invalid &mnemoniclayout system store"); return FALSE; } - if(u16cmp((const KMX_WCHAR*)sp->dpString, u"1") != 0) { + if (u16cmp((const KMX_WCHAR*)sp->dpString, u"1") != 0) { KMX_LogError(L"Keyboard is not a mnemonic layout keyboard"); return FALSE; } @@ -404,11 +397,11 @@ KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { return FALSE; } -KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]) { +KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint argc, gchar* argv[]) { + KMX_WCHAR DeadKey = 0; - KMX_WCHAR DeadKey=0; - - if(!KMX_SetKeyboardToPositional(kbd)) return FALSE; + if (!KMX_SetKeyboardToPositional(kbd)) + return FALSE; // Go through each of the shift states - base, shift, ctrl+alt, ctrl+alt+shift, [caps vs ncaps?] // Currently, we go in this order so the 102nd key works. But this is not ideal for keyboards without 102nd key: // I4651 @@ -416,42 +409,42 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg // evident for the 102nd key on UK, for example, where \ can be generated with VK_OEM_102 or AltGr+VK_QUOTE. // For now, we get the least shifted version, which is hopefully adequate. - GdkKeymap *keymap; - if(InitializeGDK(&keymap, argc, argv)) { + GdkKeymap* keymap; + if (InitializeGDK(&keymap, argc, argv)) { printf("ERROR: can't Initialize GDK\n"); return FALSE; } // create vector that contains Keycode, base, shift for US-KEyboard and underlying keyboard vec_dword_3D all_vector; - if(createOneVectorFromBothKeyboards(all_vector, keymap)){ + if (createOneVectorFromBothKeyboards(all_vector, keymap)) { printf("ERROR: can't create one vector from both keyboards\n"); return FALSE; } - vec_dword_2D dk_Table; + vec_dword_2D dk_Table; create_DKTable(dk_Table); - for (int j = 0; VKShiftState[j] != 0xFFFF; j++) { // I4651 + for (int j = 0; VKShiftState[j] != 0xFFFF; j++) { // I4651 // Loop through each possible key on the keyboard - for (int i = 0;KMX_VKMap[i]; i++) { // I4651 + for (int i = 0; KMX_VKMap[i]; i++) { // I4651 // windows uses VK, Linux uses SC/Keycode - UINT scUnderlying = KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]); + UINT scUnderlying = KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]); KMX_WCHAR ch = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap, VKShiftState[j], scUnderlying, &DeadKey); - //printf("--- VK_%d -> SC_ [%c] dk=%d ( ss %i) \n", KMX_VKMap[i], ch == 0 ? 32 : ch, DeadKey, VKShiftState[j]); + // printf("--- VK_%d -> SC_ [%c] dk=%d ( ss %i) \n", KMX_VKMap[i], ch == 0 ? 32 : ch, DeadKey, VKShiftState[j]); - if(bDeadkeyConversion) { // I4552 - if(ch == 0xFFFF) { + if (bDeadkeyConversion) { // I4552 + if (ch == 0xFFFF) { ch = DeadKey; } } - switch(ch) { + switch (ch) { case 0x0000: break; - case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, all_vector, keymap, dk_Table); break; + case 0xFFFF: KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, all_vector, keymap, dk_Table); break; default: KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch); } } @@ -459,32 +452,30 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg KMX_ReportUnconvertedKeyboardRules(kbd); - if(!KMX_ImportRules(kbd, all_vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 + if (!KMX_ImportRules(kbd, all_vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552 return FALSE; } return TRUE; } -int KMX_GetDeadkeys(vec_dword_2D & dk_Table, KMX_WORD deadkey, KMX_WORD *OutputPairs, GdkKeymap* keymap) { - - KMX_WORD *p = OutputPairs; +int KMX_GetDeadkeys(vec_dword_2D& dk_Table, KMX_WORD deadkey, KMX_WORD* OutputPairs, GdkKeymap* keymap) { + KMX_WORD* p = OutputPairs; KMX_DWORD shift; vec_dword_2D dk_SingleTable; query_dk_combinations_for_specific_dk(dk_Table, deadkey, dk_SingleTable); - for ( int i=0; i< (int) dk_SingleTable.size();i++) { + for (int i = 0; i < (int)dk_SingleTable.size(); i++) { KMX_WORD vk = KMX_change_keyname_to_capital(dk_SingleTable[i][1], shift, keymap); - if(vk != 0) { + if (vk != 0) { *p++ = vk; *p++ = shift; *p++ = dk_SingleTable[i][2]; - } - else { + } else { KMX_LogError(L"Warning: complex deadkey not supported."); } } *p = 0; - return (p-OutputPairs); + return (p - OutputPairs); } void KMX_LogError(const wchar_t* fmt, ...) { @@ -492,16 +483,15 @@ void KMX_LogError(const wchar_t* fmt, ...) { const wchar_t* end = L"\0"; const wchar_t* nl = L"\n"; va_list vars; - int j=0; + int j = 0; va_start(vars, fmt); - vswprintf (fmtbuf,_countof(fmtbuf), fmt, vars ); + vswprintf(fmtbuf, _countof(fmtbuf), fmt, vars); fmtbuf[255] = 0; do { putwchar(fmtbuf[j]); j++; - } - while(fmtbuf[j] != *end); + } while (fmtbuf[j] != *end); putwchar(*nl); } diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 77f6eceb46..95c85b989e 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -1,22 +1,21 @@ /* Name: mcompile Copyright: Copyright (C) 2003-2017 SIL International. - Documentation: - Description: + Documentation: + Description: Create Date: 3 Aug 2014 Modified Date: 3 Aug 2014 Authors: mcdurdin - Related Files: - Dependencies: + Related Files: + Dependencies: - Bugs: - Todo: - Notes: + Bugs: + Todo: + Notes: History: 03 Aug 2014 - mcdurdin - I4353 - V9.0 - mnemonic layout recompiler mixes up deadkey rules - -*/ +*/ #ifndef MCOMPILE_H #define MCOMPILE_H @@ -25,13 +24,13 @@ #include "deadkey.h" #include "mc_kmxfile.h" -struct KMX_DeadkeyMapping { // I4353 +struct KMX_DeadkeyMapping { // I4353 KMX_WCHAR deadkey, dkid; UINT shift; KMX_WORD vk; }; -extern std::vector KMX_FDeadkeys; // I4353 +extern std::vector KMX_FDeadkeys; // I4353 void KMX_LogError(const wchar_t* fmt, ...); From 1c34bde6435780f08c76f5bd077c1b55a0c54f38 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 1 Jul 2024 12:08:16 +0200 Subject: [PATCH 278/327] feat(linux): formatting --- linux/mcompile/keymap/mcompile.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index f996721fc6..a5bde3a75e 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -65,12 +65,12 @@ int run(int argc, char* argv[], char* argv_gdk[]) { int bDeadkeyConversion = 0; - if( argc > 1) + if (argc > 1) bDeadkeyConversion = (strcmp(argv[1], "-d") == 0); // I4552 int n = (bDeadkeyConversion ? 2 : 1); - if (argc < 3 || argc > 4 || argc-n !=2) { // I4273// I4273 + if (argc < 3 || argc > 4 || argc - n != 2) { // I4273// I4273 wprintf( L"Usage: \tmcompile [-d] infile.kmx outfile.kmx\n" L" \tmcompile -u ... (not available for Linux)\n " @@ -261,7 +261,7 @@ void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. - if ((shift & (LCTRLFLAG | RALTFLAG)) == (LCTRLFLAG | RALTFLAG)) // I4549 + if ((shift & (LCTRLFLAG | RALTFLAG)) == (LCTRLFLAG | RALTFLAG)) // I4549 shift &= ~LCTRLFLAG; // If the first group is not a matching-keys group, then we need to add into // each subgroup, otherwise just the match group From 334ee3b4347ae8d6806e760d4689ffbbbbe25070 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 1 Jul 2024 12:28:05 +0200 Subject: [PATCH 279/327] feat(linux): remove unused function --- linux/mcompile/keymap/u16.cpp | 17 ----------------- linux/mcompile/keymap/u16.h | 2 -- 2 files changed, 19 deletions(-) diff --git a/linux/mcompile/keymap/u16.cpp b/linux/mcompile/keymap/u16.cpp index 464212b1f4..48ee71744b 100644 --- a/linux/mcompile/keymap/u16.cpp +++ b/linux/mcompile/keymap/u16.cpp @@ -111,23 +111,6 @@ long int u16tol(const KMX_WCHAR* str, KMX_WCHAR** endptr, int base) if (endptr != nullptr) *endptr = (KMX_WCHAR*)str + (t - s.c_str()); return result; } -/* -std::string toHex(int num1) { - if (num1 == 0) - return "0"; - int num = num1; - std::string s = ""; - while (num) { - int temp = num % 16; - if (temp <= 9) - s += (48 + temp); - else - s += (87 + temp); - num = num / 16; - } - reverse(s.begin(), s.end()); - return s; -}*/ const KMX_WCHAR * u16ncat(KMX_WCHAR *dst, const KMX_WCHAR *src, size_t max) { KMX_WCHAR* o = dst; diff --git a/linux/mcompile/keymap/u16.h b/linux/mcompile/keymap/u16.h index 53872dcb28..d2272f59f3 100644 --- a/linux/mcompile/keymap/u16.h +++ b/linux/mcompile/keymap/u16.h @@ -42,7 +42,5 @@ double u16tof( KMX_WCHAR* str); KMX_CHAR* strrchr_slash(KMX_CHAR* Name); const KMX_WCHAR* u16rchr_slash(KMX_WCHAR const* Name); -std::string toHex(int num1); - #endif /* U16_H */ From 683c062cbf3f5ec26b6665c7022740678410c486 Mon Sep 17 00:00:00 2001 From: Sabine Date: Mon, 1 Jul 2024 15:10:55 +0200 Subject: [PATCH 280/327] feat(linux): finish up comments on u16 --- linux/mcompile/keymap/u16.cpp | 41 +++++++++++++++-------------------- linux/mcompile/keymap/u16.h | 2 +- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/linux/mcompile/keymap/u16.cpp b/linux/mcompile/keymap/u16.cpp index 48ee71744b..03cd67d15a 100644 --- a/linux/mcompile/keymap/u16.cpp +++ b/linux/mcompile/keymap/u16.cpp @@ -62,24 +62,12 @@ std::wstring wstring_from_u16string(std::u16string const str16) { return wstr; } -// often used with c_str() e.g. u16fmt( DEBUGSTORE_MATCH).c_str() -// UTF16 (= const char16_t*) -> UTF8 (= std::string) -> UTF16 ( = std::wstring 16 bit) -std::wstring u16fmt(const KMX_WCHAR * str) { - std::wstring_convert, wchar_t> convert_wstring; - std::wstring_convert, char16_t> convert; - - // UTF16 (= const char16_t*) -> UTF8 (= std::string) -> UTF16 ( = std::wstring 16 bit) - std::string utf8str = convert.to_bytes(str); // UTF16 (= const char16_t*) -> UTF8 (= std::string) - std::wstring wstr = convert_wstring.from_bytes(utf8str); // UTF8 (= std::string) -> UTF16 ( = std::wstring 16 bit) - return wstr; -} - -void u16sprintf(KMX_WCHAR * dst, const size_t sz, const wchar_t* fmt, ...) { +void u16sprintf(KMX_WCHAR * dst, const size_t max_len, const wchar_t* fmt, ...) { // UTF16 (=const wchar_t*) -> -> std::string -> std::u16string -> UTF16 ( = char16_t*) - wchar_t* wbuf = new wchar_t[sz]; + wchar_t* wbuf = new wchar_t[max_len]; va_list args; va_start(args, fmt); - vswprintf(wbuf, sz, fmt, args); + vswprintf(wbuf, max_len, fmt, args); va_end(args); std::wstring_convert, wchar_t> convert_wstring; @@ -88,11 +76,11 @@ void u16sprintf(KMX_WCHAR * dst, const size_t sz, const wchar_t* fmt, ...) { // UTF16 (=const wchar_t*) -> -> std::string -> std::u16string -> UTF16 ( = char16_t*) std::string utf8str = convert_wstring.to_bytes(wbuf); // UTF16 ( = const wchar_t*) -> std::string std::u16string u16str = convert.from_bytes(utf8str); // std::string -> std::u16string - u16ncpy(dst, u16str.c_str(), sz); // std::u16string.c_str() -> char16_t* + u16ncpy(dst, u16str.c_str(), max_len); // std::u16string.c_str() -> char16_t* delete[] wbuf; } - std::wstring convert_pchar16T_To_wstr(KMX_WCHAR *Name){ + std::wstring convert_pchar16T_To_wstr(const KMX_WCHAR *Name){ // convert char16_t* -> std::u16string -> std::string -> std::wstring // char16_t* -> std::u16string std::u16string u16str(Name); @@ -107,7 +95,9 @@ long int u16tol(const KMX_WCHAR* str, KMX_WCHAR** endptr, int base) { auto s = string_from_u16string(str); char* t; - long int result = strtol(s.c_str(), &t, base); + size_t idx; + // long int result = strtol(s.c_str(), &t, base); + long int result = stol(s, &idx, base); if (endptr != nullptr) *endptr = (KMX_WCHAR*)str + (t - s.c_str()); return result; } @@ -143,11 +133,13 @@ KMX_CHAR* strrchr_slash(KMX_CHAR* Name) return cp; } */ -// u16rchr returns last occurence of ch in p; It returns NULL if ch = '\0' and NULL if ch is not found +// u16rchr returns last occurence of ch in p; It returns '\0' if ch == '\0' and NULL if ch is not found const KMX_WCHAR* u16rchr(const KMX_WCHAR* p, KMX_WCHAR ch) { - const KMX_WCHAR* p_end = p + u16len(p) - 1; + /*const KMX_WCHAR* p_end = p + u16len(p) - 1; + + if (ch == '\0') return p_end + 1; */ + const KMX_WCHAR* p_end = p + u16len(p); - if (ch == '\0') return p_end + 1; while (p_end >= p) { if (*p_end == ch) return p_end; p_end--; @@ -258,20 +250,21 @@ KMX_WCHAR * u16tok(KMX_WCHAR *p, KMX_WCHAR ch, KMX_WCHAR **ctx) { return p; } -KMX_WCHAR * u16tok(KMX_WCHAR* p, KMX_WCHAR* delim, KMX_WCHAR** ctx) { +// _S2 delimiters is array of char ( of size 2) +KMX_WCHAR * u16tok(KMX_WCHAR* p, KMX_WCHAR* delimiters, KMX_WCHAR** ctx) { if (!p) { p = *ctx; if (!p) return NULL; } KMX_WCHAR * q = p; - while (*q && !u16chr(delim, *q)) { + while (*q && !u16chr(delimiters, *q)) { q++; } if (*q) { *q = 0; q++; - while (u16chr(delim, *q)) q++; + while (u16chr(delimiters, *q)) q++; *ctx = q; } else { diff --git a/linux/mcompile/keymap/u16.h b/linux/mcompile/keymap/u16.h index d2272f59f3..ae686ee70c 100644 --- a/linux/mcompile/keymap/u16.h +++ b/linux/mcompile/keymap/u16.h @@ -19,10 +19,10 @@ std::u16string u16string_from_string(std::string const str); std::u16string u16string_from_wstring(std::wstring const wstr); std::string string_from_u16string(std::u16string const str); -std::wstring u16fmt(const KMX_WCHAR * str); void u16sprintf(KMX_WCHAR * dst, const size_t sz, const wchar_t* fmt, ...); std::wstring convert_pchar16T_To_wstr(KMX_WCHAR *Name); +std::wstring convert_pchar16T_To_wstr(const KMX_WCHAR *Name); size_t u16len(const KMX_WCHAR *p); int u16cmp(const KMX_WCHAR *p, const KMX_WCHAR *q); From 536ef544573d6e679fb3f5d0ebc3a53841359d50 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 2 Jul 2024 17:03:32 +0200 Subject: [PATCH 281/327] feat(linux): macro max to std::max; wprintf->printf in run() --- linux/mcompile/keymap/mcompile.cpp | 31 +++++++++++++----------------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index a5bde3a75e..1d88a05e71 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -44,11 +44,6 @@ int KMX_GetDeadkeys(vec_dword_2D& dk_Table, KMX_WORD DeadKey, KMX_WORD* OutputPa std::vector KMX_FDeadkeys; // I4353 -// Note: max is not a standard c api function or macro -#ifndef max -#define max(a, b) (((a) > (b)) ? (a) : (b)) -#endif - #define _countof(a) (sizeof(a) / sizeof(*(a))) #if defined(_WIN32) || defined(_WIN64) @@ -71,13 +66,13 @@ int run(int argc, char* argv[], char* argv_gdk[]) { int n = (bDeadkeyConversion ? 2 : 1); if (argc < 3 || argc > 4 || argc - n != 2) { // I4273// I4273 - wprintf( - L"Usage: \tmcompile [-d] infile.kmx outfile.kmx\n" - L" \tmcompile -u ... (not available for Linux)\n " - L" \tmcompile converts a Keyman mnemonic layout to a\n" - L" \tpositional one based on the Linux keyboard\n" - L" \tlayout on top position\n" - L" \t(-d convert deadkeys to plain keys) \n \n"); // I4552 + printf( + "Usage: \tmcompile [-d] infile.kmx outfile.kmx\n" + " \tmcompile -u ... (not available for Linux)\n " + " \tmcompile converts a Keyman mnemonic layout to\n" + " \ta positional one based on the currently used \n" + " \tLinux keyboard layout\n" + " \t(-d convert deadkeys to plain keys) \n \n"); // I4552 return 1; } @@ -292,7 +287,7 @@ KMX_WCHAR KMX_ScanXStringForMaxDeadkeyID(PKMX_WCHAR str) { KMX_WCHAR dkid = 0; while (str && *str) { if (*str == UC_SENTINEL && *(str + 1) == CODE_DEADKEY) { - dkid = max(dkid, *(str + 2)); + dkid = std::max(dkid, *(str + 2)); } str = KMX_incxstr(str); } @@ -337,15 +332,15 @@ KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { for (i = 0, gp = kbd->dpGroupArray; i < kbd->cxGroupArray; i++, gp++) { for (j = 0, kp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kp++) { - dkid = max(dkid, KMX_ScanXStringForMaxDeadkeyID(kp->dpContext)); - dkid = max(dkid, KMX_ScanXStringForMaxDeadkeyID(kp->dpOutput)); + dkid = std::max(dkid, KMX_ScanXStringForMaxDeadkeyID(kp->dpContext)); + dkid = std::max(dkid, KMX_ScanXStringForMaxDeadkeyID(kp->dpOutput)); } - dkid = max(dkid, KMX_ScanXStringForMaxDeadkeyID(gp->dpMatch)); - dkid = max(dkid, KMX_ScanXStringForMaxDeadkeyID(gp->dpNoMatch)); + dkid = std::max(dkid, KMX_ScanXStringForMaxDeadkeyID(gp->dpMatch)); + dkid = std::max(dkid, KMX_ScanXStringForMaxDeadkeyID(gp->dpNoMatch)); } for (i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { - dkid = max(dkid, KMX_ScanXStringForMaxDeadkeyID(sp->dpString)); + dkid = std::max(dkid, KMX_ScanXStringForMaxDeadkeyID(sp->dpString)); } s_dkids = (KMX_dkidmap*)realloc(s_dkids, sizeof(KMX_dkidmap) * (s_ndkids + 1)); From d40ef153e4421a6c26a11d9623ce1473932ad63e Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 3 Jul 2024 13:31:31 +0200 Subject: [PATCH 282/327] feat(linux): prevent buffer overrun #11910 --- linux/mcompile/keymap/u16.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/linux/mcompile/keymap/u16.cpp b/linux/mcompile/keymap/u16.cpp index 03cd67d15a..32a3bd52c4 100644 --- a/linux/mcompile/keymap/u16.cpp +++ b/linux/mcompile/keymap/u16.cpp @@ -228,12 +228,11 @@ int u16ncmp(const KMX_WCHAR *p, const KMX_WCHAR *q, size_t count) { return 0; } -KMX_WCHAR * u16tok(KMX_WCHAR *p, KMX_WCHAR ch, KMX_WCHAR **ctx) { +KMX_WCHAR * u16tok(KMX_WCHAR *p, const KMX_WCHAR ch, KMX_WCHAR **ctx) { if (!p) { p = *ctx; if (!p) return NULL; } - KMX_WCHAR *q = p; while (*q && *q != ch) { q++; @@ -247,7 +246,7 @@ KMX_WCHAR * u16tok(KMX_WCHAR *p, KMX_WCHAR ch, KMX_WCHAR **ctx) { else { *ctx = NULL; } - return p; + return *p ? p : NULL; } // _S2 delimiters is array of char ( of size 2) @@ -264,13 +263,13 @@ KMX_WCHAR * u16tok(KMX_WCHAR* p, KMX_WCHAR* delimiters, KMX_WCHAR** ctx) { if (*q) { *q = 0; q++; - while (u16chr(delimiters, *q)) q++; + while (*q && u16chr(delimiters, *q)) q++; *ctx = q; } else { *ctx = NULL; } - return p; + return *p ? p : NULL; } double u16tof( KMX_WCHAR* str) From e9d158fffebf728a0715c74e561aaaf4e1ebd861 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 3 Jul 2024 14:10:38 +0200 Subject: [PATCH 283/327] feat(linux): remaining comments on u16 --- linux/mcompile/keymap/u16.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/linux/mcompile/keymap/u16.cpp b/linux/mcompile/keymap/u16.cpp index 32a3bd52c4..f5deaeaa04 100644 --- a/linux/mcompile/keymap/u16.cpp +++ b/linux/mcompile/keymap/u16.cpp @@ -25,6 +25,8 @@ std::vector convert_argvW_to_Vector_u16str(int argc, wchar_t* ar return vector_u16; } +// ToDo codecvt needs to be replaced !! + //String <- wstring std::string string_from_wstring(std::wstring const str) { std::wstring_convert, wchar_t> converter; @@ -96,7 +98,6 @@ long int u16tol(const KMX_WCHAR* str, KMX_WCHAR** endptr, int base) auto s = string_from_u16string(str); char* t; size_t idx; - // long int result = strtol(s.c_str(), &t, base); long int result = stol(s, &idx, base); if (endptr != nullptr) *endptr = (KMX_WCHAR*)str + (t - s.c_str()); return result; @@ -135,10 +136,7 @@ KMX_CHAR* strrchr_slash(KMX_CHAR* Name) */ // u16rchr returns last occurence of ch in p; It returns '\0' if ch == '\0' and NULL if ch is not found const KMX_WCHAR* u16rchr(const KMX_WCHAR* p, KMX_WCHAR ch) { - /*const KMX_WCHAR* p_end = p + u16len(p) - 1; - - if (ch == '\0') return p_end + 1; */ - const KMX_WCHAR* p_end = p + u16len(p); + const KMX_WCHAR* p_end = p + u16len(p); while (p_end >= p) { if (*p_end == ch) return p_end; From e6b108ac1ea69d3f3ffba4d4998b3168b1e2a598 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 2 Jul 2024 17:03:32 +0200 Subject: [PATCH 284/327] feat(linux): macro max to std::max; wprintf->printf in run() --- linux/mcompile/keymap/mcompile.cpp | 31 +++++++++++++----------------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index a5bde3a75e..1d88a05e71 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -44,11 +44,6 @@ int KMX_GetDeadkeys(vec_dword_2D& dk_Table, KMX_WORD DeadKey, KMX_WORD* OutputPa std::vector KMX_FDeadkeys; // I4353 -// Note: max is not a standard c api function or macro -#ifndef max -#define max(a, b) (((a) > (b)) ? (a) : (b)) -#endif - #define _countof(a) (sizeof(a) / sizeof(*(a))) #if defined(_WIN32) || defined(_WIN64) @@ -71,13 +66,13 @@ int run(int argc, char* argv[], char* argv_gdk[]) { int n = (bDeadkeyConversion ? 2 : 1); if (argc < 3 || argc > 4 || argc - n != 2) { // I4273// I4273 - wprintf( - L"Usage: \tmcompile [-d] infile.kmx outfile.kmx\n" - L" \tmcompile -u ... (not available for Linux)\n " - L" \tmcompile converts a Keyman mnemonic layout to a\n" - L" \tpositional one based on the Linux keyboard\n" - L" \tlayout on top position\n" - L" \t(-d convert deadkeys to plain keys) \n \n"); // I4552 + printf( + "Usage: \tmcompile [-d] infile.kmx outfile.kmx\n" + " \tmcompile -u ... (not available for Linux)\n " + " \tmcompile converts a Keyman mnemonic layout to\n" + " \ta positional one based on the currently used \n" + " \tLinux keyboard layout\n" + " \t(-d convert deadkeys to plain keys) \n \n"); // I4552 return 1; } @@ -292,7 +287,7 @@ KMX_WCHAR KMX_ScanXStringForMaxDeadkeyID(PKMX_WCHAR str) { KMX_WCHAR dkid = 0; while (str && *str) { if (*str == UC_SENTINEL && *(str + 1) == CODE_DEADKEY) { - dkid = max(dkid, *(str + 2)); + dkid = std::max(dkid, *(str + 2)); } str = KMX_incxstr(str); } @@ -337,15 +332,15 @@ KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { for (i = 0, gp = kbd->dpGroupArray; i < kbd->cxGroupArray; i++, gp++) { for (j = 0, kp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kp++) { - dkid = max(dkid, KMX_ScanXStringForMaxDeadkeyID(kp->dpContext)); - dkid = max(dkid, KMX_ScanXStringForMaxDeadkeyID(kp->dpOutput)); + dkid = std::max(dkid, KMX_ScanXStringForMaxDeadkeyID(kp->dpContext)); + dkid = std::max(dkid, KMX_ScanXStringForMaxDeadkeyID(kp->dpOutput)); } - dkid = max(dkid, KMX_ScanXStringForMaxDeadkeyID(gp->dpMatch)); - dkid = max(dkid, KMX_ScanXStringForMaxDeadkeyID(gp->dpNoMatch)); + dkid = std::max(dkid, KMX_ScanXStringForMaxDeadkeyID(gp->dpMatch)); + dkid = std::max(dkid, KMX_ScanXStringForMaxDeadkeyID(gp->dpNoMatch)); } for (i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { - dkid = max(dkid, KMX_ScanXStringForMaxDeadkeyID(sp->dpString)); + dkid = std::max(dkid, KMX_ScanXStringForMaxDeadkeyID(sp->dpString)); } s_dkids = (KMX_dkidmap*)realloc(s_dkids, sizeof(KMX_dkidmap) * (s_ndkids + 1)); From 89f8ee7289a4bf777a3c31fa5fd21470a1de127c Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 4 Jul 2024 11:35:15 +0200 Subject: [PATCH 285/327] feat(linux): run and DoConvert without argv_gdk --- linux/mcompile/keymap/mcompile.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 1d88a05e71..793e62ea13 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -38,7 +38,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** keymap, std::vector* KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 -int run(int argc, char* argv[], char* argv_gdk[] = NULL); +int run(int argc, char* argv[]); int KMX_GetDeadkeys(vec_dword_2D& dk_Table, KMX_WORD DeadKey, KMX_WORD* OutputPairs, GdkKeymap* keymap); @@ -48,15 +48,14 @@ std::vector KMX_FDeadkeys; // I4353 #if defined(_WIN32) || defined(_WIN64) int wmain(int argc, wchar_t* argv[]) { - run(argc, argv); - #else // LINUX int main(int argc, char* argv[]) { - run(argc, argv, argv); #endif + + run(argc, argv); } -int run(int argc, char* argv[], char* argv_gdk[]) { +int run(int argc, char* argv[]) { int bDeadkeyConversion = 0; @@ -122,12 +121,7 @@ int run(int argc, char* argv[], char* argv_gdk[]) { }*/ #else // LINUX - if (argv_gdk == NULL) { - KMX_LogError(L"Missing parameter for initializing GdkKeymap \n"); - return 3; - } - - if (KMX_DoConvert(kmxfile, bDeadkeyConversion, argc, (gchar**)argv_gdk)) { // I4552F + if (KMX_DoConvert(kmxfile, bDeadkeyConversion, argc, (gchar**)argv)) { // I4552F KMX_SaveKeyboard(kmxfile, outfile); } From 81abbafc55f4a82107e9c65f8e3a7afa9af65239 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 4 Jul 2024 12:01:40 +0200 Subject: [PATCH 286/327] feat(linux): remove declaration of fun without definition --- linux/mcompile/keymap/u16.cpp | 2 +- linux/mcompile/keymap/u16.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/linux/mcompile/keymap/u16.cpp b/linux/mcompile/keymap/u16.cpp index f5deaeaa04..d70be8f057 100644 --- a/linux/mcompile/keymap/u16.cpp +++ b/linux/mcompile/keymap/u16.cpp @@ -25,7 +25,7 @@ std::vector convert_argvW_to_Vector_u16str(int argc, wchar_t* ar return vector_u16; } -// ToDo codecvt needs to be replaced !! +// TODO codecvt needs to be replaced !! //String <- wstring std::string string_from_wstring(std::wstring const str) { diff --git a/linux/mcompile/keymap/u16.h b/linux/mcompile/keymap/u16.h index ae686ee70c..8ef4d4e084 100644 --- a/linux/mcompile/keymap/u16.h +++ b/linux/mcompile/keymap/u16.h @@ -21,7 +21,6 @@ std::string string_from_u16string(std::u16string const str); void u16sprintf(KMX_WCHAR * dst, const size_t sz, const wchar_t* fmt, ...); -std::wstring convert_pchar16T_To_wstr(KMX_WCHAR *Name); std::wstring convert_pchar16T_To_wstr(const KMX_WCHAR *Name); size_t u16len(const KMX_WCHAR *p); From f6a969b1110a496dd7bf960413c74abb328bf0c9 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 4 Jul 2024 14:24:25 +0200 Subject: [PATCH 287/327] feat(linux): ensureValidInputForKeyboardTranslation --- linux/mcompile/keymap/keymap.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 12d3bf5b0c..1d6c65bbf7 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -12,12 +12,18 @@ int convert_Shiftstate_to_LinuxShiftstate(int shiftState) { else if (shiftState == K_SHIFTFLAG) return XCB_MOD_MASK_SHIFT; // Win ss 16 -> Lin ss 1 else if (shiftState == (LCTRLFLAG | RALTFLAG)) return XCB_MOD_MASK_LOCK; // Win ss 9 -> Lin ss 2 else if (shiftState == (K_SHIFTFLAG | LCTRLFLAG | RALTFLAG)) return (XCB_MOD_MASK_SHIFT | XCB_MOD_MASK_LOCK); // Win ss 25 -> Lin ss 3 - else return shiftState; // Lin ss x -> Lin ss x + else return shiftState; // Lin ss x -> Lin ss x } -bool ensureValidInputForKeyboardTranslation(int gdk_level, gint count, gint keycode) { - if (gdk_level > (int) count) +bool ensureValidInputForKeyboardTranslation(int shiftstate, gint count, gint keycode) { + + // We're dealing with shiftstates 0,1,2,3 or shiftstates 0,1,6,7 + if (shiftstate < 0 || shiftstate > 7) + return false; + + // For K_Space (keycode = 65) only Base and Shift are allowed + if (keycode == 65 && shiftstate > 3) return false; if (keycode > keycode_max) From 17eea39b4b9ef704cdc8e54268ec7fcf91202caa Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 4 Jul 2024 15:00:57 +0200 Subject: [PATCH 288/327] feat(linux): ensureValidInputForKeyboardTranslation more --- linux/mcompile/keymap/keymap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 1d6c65bbf7..ad559ce38f 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -18,7 +18,7 @@ int convert_Shiftstate_to_LinuxShiftstate(int shiftState) { bool ensureValidInputForKeyboardTranslation(int shiftstate, gint count, gint keycode) { - // We're dealing with shiftstates 0,1,2,3 or shiftstates 0,1,6,7 + // We're dealing with shiftstates 0,1,2,3 (Lin) or shiftstates 0,1,6,7 (rgkey) if (shiftstate < 0 || shiftstate > 7) return false; From 5a70d83b4ff34dc15731e52987edf17fdee031cf Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 4 Jul 2024 17:09:31 +0200 Subject: [PATCH 289/327] feat(linux): new fun convert_rgkey_Shiftstate_to_LinuxShiftstate() --- linux/mcompile/keymap/keymap.cpp | 21 +++++++++++++++------ linux/mcompile/keymap/keymap.h | 1 + linux/mcompile/keymap/mc_import_rules.cpp | 6 +++--- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index ad559ce38f..315d62cf51 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -15,15 +15,25 @@ int convert_Shiftstate_to_LinuxShiftstate(int shiftState) { else return shiftState; // Lin ss x -> Lin ss x } +int convert_rgkey_Shiftstate_to_LinuxShiftstate(int shiftState) { + // if shiftState is a windows ShiftState: convert the windows ShiftState (0,16,9,25) to a Linux ShiftState (0,1,2,3) that is then used as "Level" in gdk + // if shiftState is NOT a windows ShiftState (then in_ShiftState is already a Linux shiftstate): return the entered shiftstate + + if (shiftState == 0) return 0; // rgkey ss 0 -> Lin ss 0 + else if (shiftState ==1) return XCB_MOD_MASK_SHIFT; // rgkey ss 1 -> Lin ss 1 + else if (shiftState ==6) return XCB_MOD_MASK_LOCK; // rgkey ss 6 -> Lin ss 2 + else if (shiftState ==7) return (XCB_MOD_MASK_SHIFT | XCB_MOD_MASK_LOCK); // rgkey ss 7 -> Lin ss 3 + else return shiftState; // Lin ss x -> Lin ss x +} bool ensureValidInputForKeyboardTranslation(int shiftstate, gint count, gint keycode) { // We're dealing with shiftstates 0,1,2,3 (Lin) or shiftstates 0,1,6,7 (rgkey) - if (shiftstate < 0 || shiftstate > 7) + if (shiftstate < 0 || shiftstate > 3) return false; // For K_Space (keycode = 65) only Base and Shift are allowed - if (keycode == 65 && shiftstate > 3) + if (keycode == 65 && shiftstate > 1) return false; if (keycode > keycode_max) @@ -610,8 +620,8 @@ int append_underlying_ToVector(vec_dword_3D& all_vector, GdkKeymap* keymap) { all_vector[1][i][0] = all_vector[0][i][0]; // get Keyvals of this key and copy to unshifted/shifted in "underlying"-block[1][i][1] / block[1][i][2] - all_vector[1][i][0 + 1] = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap, all_vector[0][i][0], 0); // shift state: unshifted:0 - all_vector[1][i][1 + 1] = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap, all_vector[0][i][0], 1); // shift state: shifted:1 + all_vector[1][i][0 + 1] = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap, all_vector[0][i][0], convert_rgkey_Shiftstate_to_LinuxShiftstate(0)); // shift state: unshifted:0 + all_vector[1][i][1 + 1] = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap, all_vector[0][i][0], convert_rgkey_Shiftstate_to_LinuxShiftstate(1)); // shift state: shifted:1 } return 0; @@ -672,11 +682,10 @@ int KMX_get_KeyVal_From_KeyCode(GdkKeymap* keymap, guint keycode, ShiftState ss, GdkKeymapKey* maps; guint* keyvals; gint count; - if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation(convert_Shiftstate_to_LinuxShiftstate(ss), count, keycode))) { + if (!(ensureValidInputForKeyboardTranslation(convert_rgkey_Shiftstate_to_LinuxShiftstate((int) ss), count, keycode))) { g_free(keyvals); g_free(maps); return 0; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 3f89bb66bc..ff613a00d7 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -74,6 +74,7 @@ inline bool isLittleEndianSystem() { // map Shiftstate to modifier (e.g. 0->0; 16-1; 9->2; 25->3) int convert_Shiftstate_to_LinuxShiftstate(int VKShiftState); +int convert_rgkey_Shiftstate_to_LinuxShiftstate(int shiftState); // check if input is correct bool ensureValidInputForKeyboardTranslation(int shiftstate, gint count, gint keycode); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index e91efd128e..96d83063d8 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -61,7 +61,7 @@ bool DeadKey::KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter) { return false; } -int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int caps, GdkKeymap* keymap) { +int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int rgkey_ss, int caps, GdkKeymap* keymap) { GdkKeymapKey* maps; guint* keyvals; gint count; @@ -69,13 +69,13 @@ int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation(shift_state_pos, count, keycode))){ + if (!(ensureValidInputForKeyboardTranslation(convert_rgkey_Shiftstate_to_LinuxShiftstate(rgkey_ss), count, keycode))){ g_free(keyvals); g_free(maps); return 0; } - KMX_DWORD keyVal = (KMX_DWORD)KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(shift_state_pos), caps); + KMX_DWORD keyVal = (KMX_DWORD)KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(rgkey_ss), caps); std::u16string str = convert_DeadkeyValues_To_U16str(keyVal); pwszBuff[0] = *(PKMX_WCHAR)str.c_str(); From 83f079e685022ecfd7a3a12ff584db8947dd53cc Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 4 Jul 2024 17:16:45 +0200 Subject: [PATCH 290/327] feat(linux): remove count --- linux/mcompile/keymap/keymap.cpp | 8 ++++---- linux/mcompile/keymap/keymap.h | 2 +- linux/mcompile/keymap/mc_import_rules.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 315d62cf51..a30f75c95f 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -26,7 +26,7 @@ int convert_rgkey_Shiftstate_to_LinuxShiftstate(int shiftState) { else return shiftState; // Lin ss x -> Lin ss x } -bool ensureValidInputForKeyboardTranslation(int shiftstate, gint count, gint keycode) { +bool ensureValidInputForKeyboardTranslation(int shiftstate, gint keycode) { // We're dealing with shiftstates 0,1,2,3 (Lin) or shiftstates 0,1,6,7 (rgkey) if (shiftstate < 0 || shiftstate > 3) @@ -685,7 +685,7 @@ int KMX_get_KeyVal_From_KeyCode(GdkKeymap* keymap, guint keycode, ShiftState ss, if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation(convert_rgkey_Shiftstate_to_LinuxShiftstate((int) ss), count, keycode))) { + if (!(ensureValidInputForKeyboardTranslation(convert_rgkey_Shiftstate_to_LinuxShiftstate((int) ss), keycode))) { g_free(keyvals); g_free(maps); return 0; @@ -776,7 +776,7 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, gui if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation(shift_state_pos, count, keycode))) { + if (!(ensureValidInputForKeyboardTranslation(shift_state_pos, keycode))) { g_free(keyvals); g_free(maps); return 0; @@ -799,7 +799,7 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, UIN if (!gdk_keymap_get_entries_for_keycode(keymap, kc_underlying, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation(convert_Shiftstate_to_LinuxShiftstate(vk_ShiftState), count, kc_underlying))) { + if (!(ensureValidInputForKeyboardTranslation(convert_Shiftstate_to_LinuxShiftstate(vk_ShiftState), kc_underlying))) { g_free(keyvals); g_free(maps); return 0; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index ff613a00d7..d2b21c9c11 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -77,7 +77,7 @@ int convert_Shiftstate_to_LinuxShiftstate(int VKShiftState); int convert_rgkey_Shiftstate_to_LinuxShiftstate(int shiftState); // check if input is correct -bool ensureValidInputForKeyboardTranslation(int shiftstate, gint count, gint keycode); +bool ensureValidInputForKeyboardTranslation(int shiftstate, gint keycode); // take a std::string (=contents of line symbols-file ) and returns the (int) value of the character KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 96d83063d8..7b1b8975b7 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -69,7 +69,7 @@ int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int rgkey_ss, int caps, if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation(convert_rgkey_Shiftstate_to_LinuxShiftstate(rgkey_ss), count, keycode))){ + if (!(ensureValidInputForKeyboardTranslation(convert_rgkey_Shiftstate_to_LinuxShiftstate(rgkey_ss), keycode))){ g_free(keyvals); g_free(maps); return 0; From e6f212ce77bae0fad63e687f2af67b7af73ba327 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 4 Jul 2024 17:56:08 +0200 Subject: [PATCH 291/327] feat(linux): changes in convert_rgkey_Shiftstate_to_LinuxShiftstate --- linux/mcompile/keymap/keymap.cpp | 24 +++++++++++------------ linux/mcompile/keymap/keymap.h | 2 +- linux/mcompile/keymap/mc_import_rules.cpp | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index a30f75c95f..7f4b06f494 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -15,20 +15,20 @@ int convert_Shiftstate_to_LinuxShiftstate(int shiftState) { else return shiftState; // Lin ss x -> Lin ss x } -int convert_rgkey_Shiftstate_to_LinuxShiftstate(int shiftState) { - // if shiftState is a windows ShiftState: convert the windows ShiftState (0,16,9,25) to a Linux ShiftState (0,1,2,3) that is then used as "Level" in gdk - // if shiftState is NOT a windows ShiftState (then in_ShiftState is already a Linux shiftstate): return the entered shiftstate +int convert_rgkey_Shiftstate_to_LinuxShiftstate(ShiftState shiftState) { + // if shiftState is a rgkey ShiftState: convert the rgkey ShiftState (0,1,6,7) to a Linux ShiftState (0,1,2,3) that is then used as "Level" in gdk + // if shiftState is NOT a rgkey ShiftState (then in_ShiftState is already a Linux shiftstate): return the entered shiftstate - if (shiftState == 0) return 0; // rgkey ss 0 -> Lin ss 0 - else if (shiftState ==1) return XCB_MOD_MASK_SHIFT; // rgkey ss 1 -> Lin ss 1 - else if (shiftState ==6) return XCB_MOD_MASK_LOCK; // rgkey ss 6 -> Lin ss 2 - else if (shiftState ==7) return (XCB_MOD_MASK_SHIFT | XCB_MOD_MASK_LOCK); // rgkey ss 7 -> Lin ss 3 - else return shiftState; // Lin ss x -> Lin ss x + if (shiftState == Base) return 0; // rgkey ss 0 -> Lin ss 0 + else if (shiftState == Shft) return XCB_MOD_MASK_SHIFT; // rgkey ss 1 -> Lin ss 1 + else if (shiftState == MenuCtrl) return XCB_MOD_MASK_LOCK; // rgkey ss 6 -> Lin ss 2 + else if (shiftState == ShftMenuCtrl) return (XCB_MOD_MASK_SHIFT | XCB_MOD_MASK_LOCK); // rgkey ss 7 -> Lin ss 3 + else return shiftState; // Lin ss x -> Lin ss x } bool ensureValidInputForKeyboardTranslation(int shiftstate, gint keycode) { - // We're dealing with shiftstates 0,1,2,3 (Lin) or shiftstates 0,1,6,7 (rgkey) + // We're dealing with shiftstates 0,1,2,3 if (shiftstate < 0 || shiftstate > 3) return false; @@ -620,8 +620,8 @@ int append_underlying_ToVector(vec_dword_3D& all_vector, GdkKeymap* keymap) { all_vector[1][i][0] = all_vector[0][i][0]; // get Keyvals of this key and copy to unshifted/shifted in "underlying"-block[1][i][1] / block[1][i][2] - all_vector[1][i][0 + 1] = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap, all_vector[0][i][0], convert_rgkey_Shiftstate_to_LinuxShiftstate(0)); // shift state: unshifted:0 - all_vector[1][i][1 + 1] = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap, all_vector[0][i][0], convert_rgkey_Shiftstate_to_LinuxShiftstate(1)); // shift state: shifted:1 + all_vector[1][i][0 + 1] = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap, all_vector[0][i][0], convert_rgkey_Shiftstate_to_LinuxShiftstate(ShiftState::Base)); // shift state: unshifted:0 + all_vector[1][i][1 + 1] = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap, all_vector[0][i][0], convert_rgkey_Shiftstate_to_LinuxShiftstate(ShiftState::Shft)); // shift state: shifted:1 } return 0; @@ -685,7 +685,7 @@ int KMX_get_KeyVal_From_KeyCode(GdkKeymap* keymap, guint keycode, ShiftState ss, if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation(convert_rgkey_Shiftstate_to_LinuxShiftstate((int) ss), keycode))) { + if (!(ensureValidInputForKeyboardTranslation(convert_rgkey_Shiftstate_to_LinuxShiftstate(ss), keycode))) { g_free(keyvals); g_free(maps); return 0; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index d2b21c9c11..99a31fec45 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -74,7 +74,7 @@ inline bool isLittleEndianSystem() { // map Shiftstate to modifier (e.g. 0->0; 16-1; 9->2; 25->3) int convert_Shiftstate_to_LinuxShiftstate(int VKShiftState); -int convert_rgkey_Shiftstate_to_LinuxShiftstate(int shiftState); +int convert_rgkey_Shiftstate_to_LinuxShiftstate(ShiftState shiftState); // check if input is correct bool ensureValidInputForKeyboardTranslation(int shiftstate, gint keycode); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 7b1b8975b7..18a5bb5e65 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -61,7 +61,7 @@ bool DeadKey::KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter) { return false; } -int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int rgkey_ss, int caps, GdkKeymap* keymap) { +int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, ShiftState rgkey_ss, int caps, GdkKeymap* keymap) { GdkKeymapKey* maps; guint* keyvals; gint count; From 1828b46ab262c4e5b8bd18945d4b20f1f116e665 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 3 Jul 2024 16:47:36 +0200 Subject: [PATCH 292/327] feat(linux): start adding comments according to the new regulations feat(linux): more comments feat(linux): even more comments feat(linux): code comments deadkey feat(linux): code comments deadkey, keymap feat(linux): code comments mc_import_rules,mc_kmxfile, mcompile feat(linux): remaining stuff feat(linux): some more little edits feat(linux): format documents feat(linux): a few edits feat(linux): u16: comments and replace codecvt --- linux/mcompile/keymap/deadkey.cpp | 35 +- linux/mcompile/keymap/deadkey.h | 69 +++- linux/mcompile/keymap/keymap.cpp | 115 ++++--- linux/mcompile/keymap/keymap.h | 226 ++++++++++--- linux/mcompile/keymap/km_types.h | 1 - linux/mcompile/keymap/mc_import_rules.cpp | 194 ++++++----- linux/mcompile/keymap/mc_import_rules.h | 23 +- linux/mcompile/keymap/mc_kmxfile.cpp | 395 ++++++++++++---------- linux/mcompile/keymap/mc_kmxfile.h | 101 +++--- linux/mcompile/keymap/mcompile.cpp | 241 +++++++++---- linux/mcompile/keymap/mcompile.h | 5 + linux/mcompile/keymap/meson.build | 1 + linux/mcompile/keymap/u16.cpp | 251 +++++++------- linux/mcompile/keymap/u16.h | 207 ++++++++++-- 14 files changed, 1222 insertions(+), 642 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index d5129734b5..b7ebc1c665 100644 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -1,15 +1,21 @@ +/* + * Keyman is copyright (C) 2004 SIL International. MIT License. + * + * Mnemonic layout support for Linux + */ + #include "keymap.h" #include "deadkey.h" - -std::vector create_deadkeys_by_basechar() { - std::vector alDead; +/** @brief create a Vector of DeadKey containing all combinations of deadkey + character for ALL possible Linux keyboards */ +std::vector create_deadkeys_by_basechar() { + std::vector alDead; vec_dword_2D dk_ComposeTable; create_DKTable(dk_ComposeTable); for (int i = 0; i < (int)dk_ComposeTable.size() - 1; i++) { - DeadKey *dk2 = new DeadKey(dk_ComposeTable[i][0]); + DeadKey* dk2 = new DeadKey(dk_ComposeTable[i][0]); for (int j = i; j < (int)dk_ComposeTable.size(); j++) { if ((dk_ComposeTable[i][0] == dk_ComposeTable[j][0]) && (IsKeymanUsedChar(dk_ComposeTable[j][1]))) dk2->KMX_AddDeadKeyRow(dk_ComposeTable[j][1], dk_ComposeTable[j][2]); @@ -19,11 +25,12 @@ std::vector create_deadkeys_by_basechar() { return alDead; } -void refine_alDead(KMX_WCHAR dk, std::vector& dkVec, std::vector& r_All_Vec) { +/** @brief filter entries for the currently used Linux Keyboard out of a vector of all existing deadKey combinations */ +void refine_alDead(KMX_WCHAR dk, std::vector& dkVec, std::vector& r_All_Vec) { if (dk == 0) return; - for (int j = 0; j < (int) r_All_Vec.size(); j++) { + for (int j = 0; j < (int)r_All_Vec.size(); j++) { if (dk == r_All_Vec[j]->KMX_GetDeadCharacter()) { if (!found_dk_inVector(dk, dkVec)) { dkVec.push_back(r_All_Vec[j]); @@ -33,7 +40,8 @@ void refine_alDead(KMX_WCHAR dk, std::vector& dkVec, std::vector& dkVec) { +/** @brief check whether a deadkey already exists in the deadkey vector */ +bool found_dk_inVector(KMX_WCHAR dk, std::vector& dkVec) { for (int i = 0; i < dkVec.size(); i++) { if (dk == dkVec[i]->KMX_GetDeadCharacter()) return true; @@ -41,6 +49,7 @@ bool found_dk_inVector(KMX_WCHAR dk, std::vector& dkVec) { return false; } +/** @brief find all deadkey combinations for a certain deadkey in a vector of all deadkey combinations */ bool query_dk_combinations_for_specific_dk(vec_dword_2D& r_dk_ComposeTable, KMX_DWORD dk, vec_dword_2D& dk_SingleTable) { vec_dword_1D row; @@ -60,9 +69,10 @@ bool query_dk_combinations_for_specific_dk(vec_dword_2D& r_dk_ComposeTable, KMX_ return false; } +/** @brief convert a character to the upper-case equivalent and find the corresponding shiftstate */ KMX_DWORD KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD& shift, GdkKeymap* keymap) { guint keyval = (guint)kVal; - GdkKeymapKey *keys; + GdkKeymapKey* keys; gint n_keys; KMX_DWORD capitalKeyval = (KMX_DWORD)gdk_keyval_to_upper(kVal); @@ -78,6 +88,7 @@ KMX_DWORD KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD& shift, GdkKey return capitalKeyval; } +/** @brief append a 1D-vector containing name, base character and unicode_value to a 2D-Vector */ void add_deadkey_combination(vec_dword_2D& dk_ComposeTable, std::string diacritic_name, std::string base_char, KMX_DWORD unicode_value) { vec_dword_1D line; line.push_back(convertNamesTo_DWORD_Value(diacritic_name)); @@ -86,14 +97,8 @@ void add_deadkey_combination(vec_dword_2D& dk_ComposeTable, std::string diacriti dk_ComposeTable.push_back(line); } +/** @brief create a 2D-Vector containing all possible combinations of deadkey + character for all Linux keyboards */ void create_DKTable(vec_dword_2D& dk_ComposeTable) { - // create a 2D-Vector which contains data for ALL existing deadkey combinations on a Linux Keyboard: - // dk_ComposeTable[i][0] : diacritic_name (e.g. dead_circumflex) - // dk_ComposeTable[i][1] : base_char (e.g. a) - // dk_ComposeTable[i][2] : unicode_value-Value (e.g. 0x00E2) - - // values taken from: https://help.ubuntu.com/community/GtkDeadKeyTable#Accents - add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "a", 0x00E2); // small A with circumflex add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "A", 0x00C2); // capital A with circumflex add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "e", 0x00EA); // small E with circumflex diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index e57b2fb9de..8f1c61f355 100644 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -6,23 +6,68 @@ #include "mc_import_rules.h" #include +/** + * @brief create a Vector of DeadKey containing all combinations of deadkey + character for ALL possible Linux keyboards + * @return vector of Deadkey* that holds all combinations of deadkey + character + */ +std::vector create_deadkeys_by_basechar(); -// create a 2D-vector of all dk combinations ( ` + a -> à ; ^ + a -> â ; `+ e -> è; ...) -void create_DKTable(vec_dword_2D &dk_ComposeTable); +/** + * @brief filter entries for the currently used Linux Keyboard out of a vector of all existing deadKey combinations + * @param dk the deadkey for which all combinations will be found + * @param [in,out] dkVec combinations of deadkey + character for the currently used Linux Keyboard + * @param r_All_Vec all existing combinations of deadkey + character for ALL possible Linux keyboards + * @return void + */ +void refine_alDead(KMX_WCHAR dk, std::vector& dkVec, std::vector& r_All_Vec); -// find all possible dk combinations that exist -std::vector create_deadkeys_by_basechar(); +/** + * @brief check whether a deadkey already exists in the deadkey vector + * @param dk the deadkey to be found + * @param dkVec vector containing combinations of deadkey + character + * @return true if deadkey alredy exists; + * false if not + */ +bool found_dk_inVector(KMX_WCHAR dk, std::vector& dkVec); -// refine dk to those used in the underlying keyboard -void refine_alDead(KMX_WCHAR dk, std::vector &myVec, std::vector &r_All_Vec); +/** + * @brief find all deadkey combinations for a certain deadkey in a vector of all deadkey combinations + * @param r_dk_ComposeTable vector containing all possible deadkey combinations + * @param dk deadkey of interest + * @param [in,out] dk_SingleTable vector containing all dk-character combinations for a specific deadkey dk + * @return true if successful; false if not + */ +bool query_dk_combinations_for_specific_dk(vec_dword_2D& dk_ComposeTable, KMX_DWORD dk, vec_dword_2D& dk_SingleTable); -// check if entry is already there -bool found_dk_inVector(KMX_WCHAR dk, std::vector &myVec); +/** + * @brief convert a character to the upper-case equivalent and find the corresponding shiftstate + * of the entered keyval: a(97) -> A(65) + Base A(65) -> A(65) + Shift + * @param kval keyval that might be changed + * @param [in,out] shift the shiftstate of the entered keyval + * @param keymap a pointer to the currently used (underlying) keyboard layout + * @return the upper case equivalent of the keyval + */ +KMX_DWORD KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD& shift, GdkKeymap* keymap); -// query_dk_combinations_for_a specific_dk from dk_ComposeTable(which holds all dk combinations) e.g. for dk: ^ get â,ê,î,ô,û,... -bool query_dk_combinations_for_specific_dk(vec_dword_2D &dk_ComposeTable, KMX_DWORD dk, vec_dword_2D &dk_SingleTable); +/** + * @brief append a 1D-vector containing name, base character and unicode_value to a 2D-Vector + * holding all possible combinations of deadkey + character for all Linux keyboards + * @param [in,out] dk_ComposeTable + * @param diacritic_name the name of a diacritic + * @param base_char Base character + * @param unicode_value Unicode-value of the combined character + * @return void + */ +void add_deadkey_combination(vec_dword_2D& dk_ComposeTable, std::string diacritic_name, std::string base_char, KMX_DWORD unicode_value); -// get the shifted character of a key and write shiftstate of KVal to shift -KMX_DWORD KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD &shift, GdkKeymap *keymap); +/** + * @brief create a 2D-Vector containing all possible combinations of deadkey + character for all Linux keyboards + * the values are taken from from: https://help.ubuntu.com/community/GtkDeadKeyTable#Accents + * dk_ComposeTable[i][0] : diacritic_name (e.g. dead_circumflex) + * dk_ComposeTable[i][1] : base_char (e.g. a) + * dk_ComposeTable[i][2] : unicode_value-Value (e.g. 0x00E2) + * @param [in,out] dk_ComposeTable + */ +void create_DKTable(vec_dword_2D& dk_ComposeTable); #endif /*DEADKEY_H*/ diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 261fddbc84..540a68ad82 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -1,13 +1,22 @@ +/* + * Keyman is copyright (C) 2004 SIL International. MIT License. + * + * Mnemonic layout support for Linux + * + * Throughout mcompile we use the following naming conventions: + * KEYCODE: (name on Linux, Mac):The physical position of a key on a keyboard e.g. Keycode for 'Z' on US: 6 on Mac | 52 on Linux/x11 | 44 on Windows + * SCANCODE (name on Windows): The physical position of a key on a keyboard e.g. Keycode for 'Z' on US: 44 on Windows + * VIRTUAL KEY: The value of a character on a key e.g. 'A' = 65; 'a' = 97 - not neccessarily the same as ACSII- exists on a Windows keyboard only + * KEYVAL(UE): The value of a character on a key e.g. 'A' = 65; 'a' = 97 - not neccessarily the same as ACSII + */ + #include "keymap.h" #include "kmx_file.h" #include "/usr/include/xcb/xproto.h" #include - +/** @brief map a shiftstate used on Windows to a shiftstate suitable for gdk_keymap_translate_keyboard_state() on Linux */ int convert_Shiftstate_to_LinuxShiftstate(int shiftState) { - // if shiftState is a windows ShiftState: convert the windows ShiftState (0,16,9,25) to a Linux ShiftState (0,1,2,3) that is then used as "Level" in gdk - // if shiftState is NOT a windows ShiftState (then in_ShiftState is already a Linux shiftstate): return the entered shiftstate - if (shiftState == 0) return 0; // Win ss 0 -> Lin ss 0 else if (shiftState == K_SHIFTFLAG) return XCB_MOD_MASK_SHIFT; // Win ss 16 -> Lin ss 1 else if (shiftState == (LCTRLFLAG | RALTFLAG)) return XCB_MOD_MASK_LOCK; // Win ss 9 -> Lin ss 2 @@ -16,16 +25,18 @@ int convert_Shiftstate_to_LinuxShiftstate(int shiftState) { } +/** @brief check for correct input parameter that will later be used in gdk_keymap_translate_keyboard_state() */ bool ensureValidInputForKeyboardTranslation(int gdk_level, gint count, gint keycode) { - if (gdk_level > (int) count) + if (gdk_level > (int)count) return false; - if ((int) keycode > (int)keycode_max) + if ((int)keycode > (int)keycode_max) return false; return true; } +/** @brief convert names of keys stated in a symbol file to a keyvalue */ KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str) { // more on https://manpages.ubuntu.com/manpages/jammy/man3/keysyms.3tk.html std::map key_values; @@ -305,20 +316,11 @@ KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str) { return INVALID_NAME; } +/** @brief create a 3D-Vector containing data of the US keyboard and the currently used (underlying) keyboard */ int createOneVectorFromBothKeyboards(vec_dword_3D& all_vector, GdkKeymap* keymap) { - // create a 3D-Vector which contains data of the English (US) keyboard and the underlying Keyboard: - // all_vector[ US_Keyboard ] - // [KeyCode_US ] - // [Keyval unshifted ] - // [Keyval shifted ] - // [Underlying Kbd] - // [KeyCode_underlying] - // [Keyval unshifted ] - // [Keyval shifted ] - // store contents of the English (US) keyboard in all_vector if (write_US_ToVector(all_vector)) { - printf("ERROR: can't write US to Vector \n"); + printf("ERROR: can't write full US to Vector \n"); return 1; } @@ -330,8 +332,8 @@ int createOneVectorFromBothKeyboards(vec_dword_3D& all_vector, GdkKeymap* keymap return 0; } -int write_US_ToVector(vec_dword_3D& vec) { - +/** @brief write data of the US keyboard into a 3D-Vector */ +int write_US_ToVector(vec_dword_3D& vec_us) { // create 1D-vector of the complete line vec_string_1D vector_completeUS; if (createCompleteVector_US(vector_completeUS)) { @@ -340,7 +342,7 @@ int write_US_ToVector(vec_dword_3D& vec) { } // split contents of 1D Vector to 3D vector - if (split_US_To_3D_Vector(vec, vector_completeUS)) { + if (split_US_To_3D_Vector(vec_us, vector_completeUS)) { return 1; } @@ -356,6 +358,7 @@ int write_US_ToVector(vec_dword_3D& vec) { return 0; } +/** @brief create a 1D-Vector containing all relevant entries of the symbol file us basic */ bool createCompleteVector_US(vec_string_1D& complete_List) { // in the Configuration file we find the appopriate paragraph between "xkb_symbol " and the next xkb_symbol // then copy all rows starting with "key <" to a 1D-Vector @@ -374,7 +377,6 @@ bool createCompleteVector_US(vec_string_1D& complete_List) { else { while (getline(inputFile, line)) { - // stop when finding the mark xkb_symbol if (line.find(xbk_mark) != std::string::npos) create_row = false; @@ -395,6 +397,7 @@ bool createCompleteVector_US(vec_string_1D& complete_List) { return 0; } +/** @brief convert the key name obtained from symbol file to the matching keycode */ int get_keycode_from_keyname(std::string key_name) { int out = INVALID_NAME; @@ -503,6 +506,7 @@ int get_keycode_from_keyname(std::string key_name) { return out; } +/** @brief process each element of a 1D-Vector, split and write to a 3D-Vector */ int split_US_To_3D_Vector(vec_dword_3D& all_US, vec_string_1D completeList) { // 1: take the whole line of the 1D-Vector and remove unwanted characters. // 2: seperate the name e.g. key from the shiftstates @@ -538,8 +542,8 @@ int split_US_To_3D_Vector(vec_dword_3D& all_US, vec_string_1D completeList) { std::istringstream split_Characters(tokens[1]); tokens.pop_back(); - for (std::string each; std::getline(split_Characters, each, ','); tokens.push_back(each)) - ; + for (std::string each; std::getline(split_Characters, each, ','); + tokens.push_back(each)); // now convert all to KMX_DWORD and fill tokens tokens_dw.push_back((KMX_DWORD)keyCode); @@ -564,6 +568,7 @@ int split_US_To_3D_Vector(vec_dword_3D& all_US, vec_string_1D completeList) { return 0; } +/** @brief create an 2D-Vector with all fields initialized to INVALID_NAME */ vec_dword_2D create_empty_2D_Vector(int dim_rows, int dim_ss) { vec_dword_1D shifts; vec_dword_2D vector_2D; @@ -578,6 +583,7 @@ vec_dword_2D create_empty_2D_Vector(int dim_rows, int dim_ss) { return vector_2D; } +/** @brief append a 2D-vector containing data of the currently used (underlying) keyboard to the 3D-vector */ int append_underlying_ToVector(vec_dword_3D& all_vector, GdkKeymap* keymap) { if (all_vector.size() != 1) { printf("ERROR: data for US keyboard not correct\n"); @@ -595,7 +601,7 @@ int append_underlying_ToVector(vec_dword_3D& all_vector, GdkKeymap* keymap) { all_vector.push_back(underlying_Vector2D); if (all_vector.size() < 2) { printf("ERROR: creation of 3D-Vector failed\n"); - return 1; + return 2; } for (int i = 0; i < (int)all_vector[1].size(); i++) { @@ -610,6 +616,7 @@ int append_underlying_ToVector(vec_dword_3D& all_vector, GdkKeymap* keymap) { return 0; } +/** @brief create a pointer to pointer of the current keymap for later use */ bool InitializeGDK(GdkKeymap** keymap, int argc, gchar* argv[]) { // get keymap of underlying keyboard @@ -630,15 +637,17 @@ bool InitializeGDK(GdkKeymap** keymap, int argc, gchar* argv[]) { return 0; } -bool IsKeymanUsedChar(int KV) { +/** @brief check if keyval correponds to a character we use in mcompile */ +bool IsKeymanUsedChar(int kv) { // 32 A-Z a-z - if ((KV == 0x20) || (KV >= 65 && KV <= 90) || (KV >= 97 && KV <= 122)) + if ((kv == 0x20) || (kv >= 65 && kv <= 90) || (kv >= 97 && kv <= 122)) return true; else return false; } -std::u16string convert_DeadkeyValues_To_U16str(int in) { +/** @brief convert a deadkey-value to a u16string if it is in the range of deadkeys used for mcompile. */ +std::u16string convert_DeadkeyValues_To_U16str(KMX_DWORD in) { if (in == 0) return u"\0"; @@ -660,7 +669,8 @@ std::u16string convert_DeadkeyValues_To_U16str(int in) { return u"\0"; } -int KMX_get_KeyVal_From_KeyCode(GdkKeymap* keymap, guint keycode, ShiftState ss, int caps) { +/** @brief return the keyvalue for a given Keycode, shiftstate and caps*/ +KMX_DWORD KMX_get_KeyVal_From_KeyCode(GdkKeymap* keymap, guint keycode, ShiftState ss, int caps) { GdkModifierType consumed; GdkKeymapKey* maps; guint* keyvals; @@ -751,7 +761,8 @@ int KMX_get_KeyVal_From_KeyCode(GdkKeymap* keymap, guint keycode, ShiftState ss, return (int)*keyvals; } -KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, guint keycode, int shift_state_pos) { +/** @brief return the keyvalue for a given Keycode and shiftstate of the currently used (underlying) keyboard layout. */ +KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, guint keycode, int shiftState) { GdkKeymapKey* maps; guint* keyvals; gint count; @@ -760,13 +771,13 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, gui if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation(shift_state_pos, count, keycode))) { + if (!(ensureValidInputForKeyboardTranslation(shiftState, count, keycode))) { g_free(keyvals); g_free(maps); return 0; } - kVal = (KMX_DWORD)KMX_get_KeyVal_From_KeyCode(keymap, keycode, (ShiftState)shift_state_pos, 0); + kVal = KMX_get_KeyVal_From_KeyCode(keymap, keycode, (ShiftState)shiftState, 0); g_free(keyvals); g_free(maps); @@ -774,28 +785,29 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, gui return kVal; } -KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, UINT vk_ShiftState, UINT kc_underlying, PKMX_WCHAR deadkey) { +/** @brief return the keyvalue for a given Keycode and shiftstate of the currently used (underlying) keyboard layout. */ +KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, guint keycode, UINT shiftState, PKMX_WCHAR deadkey) { GdkKeymapKey* maps; guint* keyvals; gint count; PKMX_WCHAR dky = NULL; - if (!gdk_keymap_get_entries_for_keycode(keymap, kc_underlying, &maps, &keyvals, &count)) + if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation(convert_Shiftstate_to_LinuxShiftstate(vk_ShiftState), count, kc_underlying))) { + if (!(ensureValidInputForKeyboardTranslation(convert_Shiftstate_to_LinuxShiftstate(shiftState), count, keycode))) { g_free(keyvals); g_free(maps); return 0; } - KMX_DWORD keyV = KMX_get_KeyVal_From_KeyCode(keymap, kc_underlying, ShiftState(convert_Shiftstate_to_LinuxShiftstate(vk_ShiftState)), 0); + KMX_DWORD keyV = KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(convert_Shiftstate_to_LinuxShiftstate(shiftState)), 0); g_free(keyvals); g_free(maps); if ((keyV >= deadkey_min) && (keyV <= deadkey_max)) { // deadkey - dky = (PKMX_WCHAR)(convert_DeadkeyValues_To_U16str((int)keyV)).c_str(); + dky = (PKMX_WCHAR)(convert_DeadkeyValues_To_U16str(keyV)).c_str(); *deadkey = *dky; return 0xFFFF; } else if ((keyV > deadkey_max) || ((keyV < deadkey_min) && (keyV > 0xFF))) // out of range @@ -804,45 +816,48 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, UIN return keyV; } -KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(vec_dword_3D& all_vector, KMX_DWORD vk_US) { - KMX_DWORD vk_underlying; + +/** @brief return the keyvalue of a key of the the currently used (underlying) keyboard for a given keyvalue of the US keyboard */ +KMX_DWORD KMX_get_KeyValUnderlying_From_KeyValUS(vec_dword_3D& all_vector, KMX_DWORD kv_us) { + // look for kv_us for any shiftstate of US keyboard for (int i = 0; i < (int)all_vector[0].size() - 1; i++) { for (int j = 1; j < (int)all_vector[0][0].size(); j++) { - if ((all_vector[0][i][j] == vk_US)) { - vk_underlying = all_vector[1][i][j]; - return vk_underlying; - } + if (all_vector[0][i][j] == kv_us) + return all_vector[1][i][j]; } } - return vk_US; + return kv_us; } +/** @brief return the keycode of the currently used (underlying) keyboard for a given keycode of the US keyboard */ KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap* keymap, vec_dword_3D& all_vector, KMX_DWORD kc_us, ShiftState ss, int caps) { - KMX_DWORD kc_underlying; std::u16string u16str = convert_DeadkeyValues_To_U16str(KMX_get_KeyVal_From_KeyCode(keymap, kc_us, ss, caps)); for (int i = 0; i < (int)all_vector[1].size() - 1; i++) { for (int j = 1; j < (int)all_vector[1][0].size(); j++) { - if ((all_vector[1][i][j] == (KMX_DWORD)*u16str.c_str())) { - kc_underlying = all_vector[1][i][0]; - return kc_underlying; - } + if ((all_vector[1][i][j] == (KMX_DWORD)*u16str.c_str())) + return all_vector[1][i][0]; } } return kc_us; } -UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD virtualKeyUS) { - return (8 + USVirtualKeyToScanCode[virtualKeyUS]); +/** @brief return the keycode of the currently used (underlying) keyboard for a given virtual key of the US keyboard */ +KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD virtualKeyUS) { + // Linux virtualKeys are always 8 different to Windows virtualKeys + return (KMX_DWORD)(8 + USVirtualKeyToScanCode[virtualKeyUS]); } +/** @brief return a virtual key of the US keyboard for a given keycode of the currently used (underlying) keyboard */ KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying(KMX_DWORD keycode) { + // Linux virtualKeys are always 8 different to Windows virtualKeys if (keycode > 7) return (KMX_DWORD)ScanCodeToUSVirtualKey[keycode - 8]; return 0; } +/** @brief convert a codepoint to a u16string */ std::u16string CodePointToU16String(unsigned int codepoint) { std::u16string str; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index faa80cc764..4a859d910d 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -1,4 +1,3 @@ -// In ths program we use a 3D-Vector Vector[language][Keys][Shiftstates] #pragma once #ifndef KEYMAP_H #define KEYMAP_H @@ -15,8 +14,7 @@ #include #include #include "u16.h" -#include - +#include enum ShiftState { Base = 0, // 0 @@ -57,7 +55,6 @@ const KMX_DWORD KMX_VKMap[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 0}; typedef std::vector vec_string_1D; - typedef std::vector vec_dword_1D; typedef std::vector > vec_dword_2D; typedef std::vector > > vec_dword_3D; @@ -67,46 +64,120 @@ static KMX_DWORD keycode_max = 94; static KMX_DWORD deadkey_min = 0xfe50; // X11's keysymdef.h defines deadkeys between 0xfe50-0xfe93 static KMX_DWORD deadkey_max = 0xfe93; // https://fossies.org/linux/tk/xlib/X11/keysymdef.h +/** + * @brief check if current machine uses little endian + * @return true if little endian is used; else false + */ inline bool isLittleEndianSystem() { char16_t test = 0x0102; - return (reinterpret_cast(&test))[0] == 0x02; + return (reinterpret_cast(&test))[0] == 0x02; } -// map Shiftstate to modifier (e.g. 0->0; 16-1; 9->2; 25->3) -int convert_Shiftstate_to_LinuxShiftstate(int VKShiftState); +/** + * @brief map a shiftstate used on windows to a shiftstate suitable for gdk_keymap_translate_keyboard_state() on Linux + * Windows: (Base: 00000000 (0); Shift 00010000 (16); AltGr 00001001 (9); Shift+AltGr 00011001 (25)) + * Linux: (Base: 0; Shift 1; ALTGr 2; Shift+ALTGr 3 ) + * @param shiftState shiftstate used on Windows + * @return a shiftstate usable for gdk_keymap_translate_keyboard_state() on linux if available + * if shiftState is a windows ShiftState: convert the windows ShiftState (0,16,9,25) to a Linux ShiftState (0,1,2,3) that is then used as "Level" in gdk + * if shiftState is NOT a windows ShiftState (then in_ShiftState is already a Linux shiftstate): return the entered shiftstate + */ +int convert_Shiftstate_to_LinuxShiftstate(int shiftState); -// check if input is correct +/** + * @brief check for correct input parameter that will later be used in gdk_keymap_translate_keyboard_state() + * @param shiftstate the currently used shiftstate + * @param count the number of valid group/levels + * @param keycode the code of the key in question + * @return true if all parameters are OK; + * false if not + */ bool ensureValidInputForKeyboardTranslation(int shiftstate, gint count, gint keycode); -// take a std::string (=contents of line symbols-file ) and returns the (int) value of the character +/** + * @brief convert names of keys stated in a symbol file to a keyvalue + * @param tok_str the name stated in symbol file + * @return the keyvalue + */ KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str); -// create a Vector with all entries of both keymaps -int createOneVectorFromBothKeyboards(vec_dword_3D& All_Vector, GdkKeymap* keymap); +/** + * @brief create a 3D-Vector containing data of the US keyboard and the currently used (underlying) keyboard : + * all_vector [ US_Keyboard ] + * [KeyCode_US ] + * [Keyval unshifted ] + * [Keyval shifted ] + * [Underlying Kbd] + * [KeyCode_underlying] + * [Keyval unshifted ] + * [Keyval shifted ] + * @param[in,out] all_vector Vector that holds the data of the US keyboard as well as the currently used (underlying) keyboard + * @param keymap pointer to currently used (underlying) keyboard layout + * @return 0 on success; + * 1 if data of US keyboard was not written; + * 2 if data of underlying keyboard was not written + */ +int createOneVectorFromBothKeyboards(vec_dword_3D& all_vector, GdkKeymap* keymap); -// read configuration file, split and write to 3D-Vector (Data for US on Vector[0][ ][ ] ) -int write_US_ToVector(vec_dword_3D& vec); +/** + * @brief write data of the US keyboard into a 3D-Vector which later will contain + * data of the US keyboard and the currently used (underlying) keyboard + * @param[in,out] vec_us Vector that holds the data of the US keyboard + * @return 0 on success; + * 1 if data of US keyboard was not written; + */ +int write_US_ToVector(vec_dword_3D& vec_us); -// 1. step: read complete Row of Configuration file US -bool createCompleteVector_US(vec_string_1D& complete_List) ; +/** + * @brief create a 1D-Vector containing all relevant entries of the symbol file us basic + * @param [in,out] complete_List the 1D-Vector + * @return 0 on success; 1 if file could not be opened + */ +bool createCompleteVector_US(vec_string_1D& complete_List); -// replace Name of Key (e.g. ) wih Keycode ( e.g. 15 ) -int replace_KeyName_with_Keycode(std::string in); +/** + * @brief convert the key name obtained from symbol file to the matching keycode + * e.g. name of Key ) --> Keycode 15 + * @param key_name as stated in the symbol file + * @return the equivalent keycode + */ +int get_keycode_from_keyname(std::string key_name); -// 2. step: write contents to 3D vector +/** + * @brief process each element of a 1D-Vector, split and write to a 3D-Vector + * @param [in,out] all_US a 3D_Vector containing all keyvalues of the US keyboard + * @param completeList a 1D-Vector containing all relevant entries copied from the symbol file us basic + * @return 0 on success; 1 if entry can be split + */ int split_US_To_3D_Vector(vec_dword_3D& all_US, vec_string_1D completeList); -// create an empty 2D vector containing 0 in all fields -vec_dword_2D create_empty_2D_Vector(int dim_rows, int dim_shifts); +/** + * @brief create an 2D-Vector with all fields containing INVALID_NAME + * @param dim_rows number of rows in vector + * @param dim_ss number of columns in vector + * @return the 2D-Vector + */ +vec_dword_2D create_empty_2D_Vector(int dim_rows, int dim_ss); -// append characters to 3D-Vector using GDK (Data for underlying Language on Vector[1][ ][ ] ) -int append_underlying_ToVector(vec_dword_3D& All_Vector, GdkKeymap* keymap); +/** + * @brief append a 2D-vector containing data of the currently used (underlying) keyboard to the 3D-vector + * @param[in,out] all_vector 3D-vector that holds the data of the US keyboard and the currently used (underlying) keyboard + * @param keymap pointer to currently used (underlying) keybord layout + * @return 0 on success; + * 1 if the initialization of the underlying vector failes; + * 2 if data of less than 2 keyboards is contained in all_vector + */ +int append_underlying_ToVector(vec_dword_3D& all_vector, GdkKeymap* keymap); -// initialize GDK +/** + * @brief create a pointer to pointer of the current keymap for later use + * @param keymap pointer to pointer to currently used (underlying) keyborad layout + * @param argc count of arguments + * @param argv array of arguments + * @return 0 on success; 1 if the display is not found; 2 if the keymap is not found + */ bool InitializeGDK(GdkKeymap** keymap, int argc, gchar* argv[]); -//------------------------------ - const UINT USVirtualKeyToScanCode[256] = { 0x00, // L"K_?00", // &H0 0x00, // L"K_LBUTTON", // &H1 @@ -506,33 +577,104 @@ const UINT ScanCodeToUSVirtualKey[128] = { 0x00 // 0x7f => No match }; -bool IsKeymanUsedChar(int KV); -//------------------------------ -// take deadkey-value (e.g.65106) and return u16string (e.g. '^' ) -std::u16string convert_DeadkeyValues_To_U16str(int in); +/** + * @brief check if keyval correponds to a character used in mcompile + * @param kv the keyval to be checked + * @return 1 if keyval is used in mcompile; 0 if not + */ +bool IsKeymanUsedChar(int kv); -// use gdk_keymap_translate_keyboard_state to get keyval - base function to get keyvals -int KMX_get_KeyVal_From_KeyCode(GdkKeymap* keymap, guint keycode, ShiftState ss, int caps); +/** + * @brief convert a deadkey-value to a u16string if it is in the range of + * deadkeys used for mcompile e.g. 65106 -> '^' + * @param in value to be converted + * @return on success a u16string holding the converted value; else u"\0" + */ +std::u16string convert_DeadkeyValues_To_U16str(KMX_DWORD in); -// use KMX_get_KeyVal_From_KeyCode and prevent use of certain keycodes +/** + * @brief return the keyvalue for a given Keycode, shiftstate and caps of the + * currently used (underlying) keyboard layout + * "What character will be produced for a keypress of a key and modifier?" + * @param keymap pointer to the currently used (underlying) keyboard layout + * @param keycode a key of the currently used keyboard layout + * @param ss a (windows-)shiftstate of the currently used keyboard layout + * @param caps state of the caps key of the currently used keyboard layout + * @return the keyval obtained from keycode, shiftstate and caps + */ +KMX_DWORD KMX_get_KeyVal_From_KeyCode(GdkKeymap* keymap, guint keycode, ShiftState ss, int caps); + +/** + * @brief return the keyvalue for a given Keycode and shiftstate of the currently used (underlying) keyboard layout. + * "What character will be produced for a keypress of a key and modifiers on the underlying keyboard?" + * @param keymap a pointer to the currently used (underlying) keyboard layout + * @param keycode a key of the currently used keyboard + * @param shift_state_pos a shiftstate of the currently used keyboard layout + * @return the keyval obtained from Keycode and shiftstate; + */ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, guint keycode, int shift_state_pos); -// fill Deadkey with dk and return CATEGORY -KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, UINT vk_ShiftState, UINT kc_underlying, PKMX_WCHAR deadkey); +/** + * @brief return the keyvalue for a given Keycode and shiftstate of the currently used (underlying) keyboard layout. + * "What character will be produced for a keypress of a key and modifiers on the underlying keyboard? + * If a deadkey was found return 0xFFFF and copy the deadkey into deadKey + * This function is similar to KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, guint keycode, int shiftState) + * but processes deadkeys + * @param keymap a pointer to the currently used (underlying) keyboard layout + * @param keycode a key of the currently used keyboard + * @param shiftState a shiftstate of the currently used keyboard layout + * @param deadKey* pointer to keyvalue if a deadkey was found; if not NULL + * @return 0xFFFF in case a deadkey was found, then the deadkey is stored in deadKey + * 0xFFFE in case a deadkey is out of range + * the keyval obtained from Keycode and shiftstate and caps; + */ +KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, guint keycode, UINT shiftState, PKMX_WCHAR deadkey); -// use Vector to return the Keyval of underlying Keyboard -KMX_WCHAR KMX_get_KeyValUnderlying_From_KeyValUS(vec_dword_3D& All_Vector, KMX_DWORD VK_underlying); +/** + * @brief return the keyvalue of a key of the the currently used (underlying) keyboard for a given keyvalue of the US keyboard + * "What character is on the same position/shiftstats/caps on the currently used (underlying) keyboard as on the US keyboard?" + * @param all_vector 3D-vector that holds the data of the US keyboard and the currently used (underlying) keyboard + * @param kv_us a keyvalue on the US keyboard + * @return keyval of the underlying keyboard if available; + * else the keyval of the US keyboard + */ +KMX_DWORD KMX_get_KeyValUnderlying_From_KeyValUS(vec_dword_3D& all_vector, KMX_DWORD kv_us); -// use Vector to return the Keycode of the underlying Keyboard for given VK_US using GDK -KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap* keymap, vec_dword_3D& All_Vector, KMX_DWORD kc_us, ShiftState ss, int caps); +/** + * @brief return the keycode of the currently used (underlying) keyboard for a given keycode of the US keyboard + * "Where on an underlying keyboard do we find a character that is on a certain key on a US keyboard?" + * @param keymap the currently used (underlying) keyboard layout + * @param all_vector 3D-vector that holds the data of the US keyboard and the currently used (underlying) keyboard + * @param kc_us a key of the US keyboard + * @param ss a windows-type shiftstate + * @param caps state of the caps key + * @return the keycode of the underlying keyboard if found; + * else the keycode of the US keyboard + */ +KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap* keymap, vec_dword_3D& all_vector, KMX_DWORD kc_us, ShiftState ss, int caps); -// return the Keycode of the underlying Keyboard for given VK_US -UINT KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD virtualKeyUS); +/** + * @brief return the keycode of the currently used (underlying) keyboard for a given virtual key of the US keyboard + * "Where on an underlying keyboard do we find a character of a US keyboard?" + * @param virtualKeyUS a virtual key of the US keyboard + * @return the keycode of the currently used (underlying) keyboard + */ +KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD virtualKeyUS); -// return the VirtualKey of the US Keyboard for a given Keyode using GDK +/** + * @brief return a virtual key of the US keyboard for a given keycode of the currently used (underlying) keyboard + * "Which key of a underlying keyboard will be mapped to a virtual key of a US keyboard?" + * @param keycode a keycode of the currently used (underlying) keyboard + * @return the virtual key of the US keyboard or + * * 0 if the key is not used + */ KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying(KMX_DWORD keycode); -// convert codePoint to u16string +/** + * @brief convert a codepoint to a u16string + * @param codepoint to be converted + * @return a u16string holding the converted value; + */ std::u16string CodePointToU16String(unsigned int codepoint); #endif /*KEYMAP_H*/ diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h index 89a806adce..5381ff1e6a 100644 --- a/linux/mcompile/keymap/km_types.h +++ b/linux/mcompile/keymap/km_types.h @@ -11,7 +11,6 @@ #endif */ - #if defined(__LP64__) || defined(_LP64) /* 64-bit, g++ */ #define KMX_64BIT diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index e91efd128e..27f3ce119a 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -1,24 +1,8 @@ /* - Name: mc_import_rules - Copyright: Copyright (C) SIL International. - Documentation: - Description: - Create Date: 3 Aug 2014 - - Modified Date: 6 Feb 2015 - Authors: mcdurdin - Related Files: - Dependencies: - - Bugs: - Todo: - Notes: - History: 03 Aug 2014 - mcdurdin - I4327 - V9.0 - Mnemonic layout compiler follow-up - 03 Aug 2014 - mcdurdin - I4353 - V9.0 - mnemonic layout recompiler mixes up deadkey rules - 31 Dec 2014 - mcdurdin - I4550 - V9.0 - logical flaw in mnemonic layout recompiler means that AltGr base keys are never processed - 06 Feb 2015 - mcdurdin - I4552 - V9.0 - Add mnemonic recompile option to ignore deadkeys -*/ - + * Keyman is copyright (C) 2004 SIL International. MIT License. + * + * Mnemonic layout support for Linux + */ #include #include @@ -38,19 +22,23 @@ const int KMX_ShiftStateMap[] = { 0, 0}; +/** @brief Constructor */ DeadKey::DeadKey(KMX_WCHAR deadCharacter) { this->m_deadchar = deadCharacter; } +/** @brief return dead character */ KMX_WCHAR DeadKey::KMX_DeadCharacter() { return this->m_deadchar; } +/** @brief set Deadkey with values */ void DeadKey::KMX_AddDeadKeyRow(KMX_WCHAR baseCharacter, KMX_WCHAR combinedCharacter) { this->m_rgbasechar.push_back(baseCharacter); this->m_rgcombchar.push_back(combinedCharacter); } +/** @brief check if character exists in DeadKey */ bool DeadKey::KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter) { std::vector::iterator it; for (it = this->m_rgbasechar.begin(); it < m_rgbasechar.end(); it++) { @@ -61,7 +49,18 @@ bool DeadKey::KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter) { return false; } -int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int caps, GdkKeymap* keymap) { +/** // _S2 at merge: better description in other branch: + * @brief Find a keyvalue for given keycode, shiftstate and caps. A function similar to Window`s ToUnicodeEx() function. + * @param keycode a key of the currently used keyboard Layout + * @param pwszBuff Buffer to store resulting character + * @param ss a shiftstate of the currently used keyboard Layout + * @param caps state of the caps key of the currently used keyboard Layout + * @param keymap the currently used (underlying)keyboard Layout + * @return -1 if a deadkey was found; + * 0 if no translation is available; + * +1 if character was found and written to pwszBuff + */ +int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int ss, int caps, GdkKeymap* keymap) { GdkKeymapKey* maps; guint* keyvals; gint count; @@ -69,13 +68,13 @@ int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count)) return 0; - if (!(ensureValidInputForKeyboardTranslation(shift_state_pos, count, keycode))){ + if (!(ensureValidInputForKeyboardTranslation(ss, count, keycode))) { g_free(keyvals); g_free(maps); return 0; } - KMX_DWORD keyVal = (KMX_DWORD)KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(shift_state_pos), caps); + KMX_DWORD keyVal = KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(ss), caps); std::u16string str = convert_DeadkeyValues_To_U16str(keyVal); pwszBuff[0] = *(PKMX_WCHAR)str.c_str(); @@ -108,6 +107,7 @@ KMX_WCHAR KMX_DeadKeyMap(int index, std::vector* deadkeys, int deadkey return 0xFFFF; } +/** @brief Base class for dealing with rgkey*/ class KMX_VirtualKey { private: UINT m_vk; @@ -122,10 +122,12 @@ public: memset(this->m_rgfDeadKey, 0, sizeof(this->m_rgfDeadKey)); } +/** @brief return member variable virtual key */ UINT VK() { return this->m_vk; } +/** @brief return member variable scancode */ UINT SC() { return this->m_sc; } @@ -140,35 +142,51 @@ public: } bool KMX_IsSGCAPS() { - std::u16string stBase = this->KMX_GetShiftState(Base, false); - std::u16string stShift = this->KMX_GetShiftState(Shft, false); - std::u16string stCaps = this->KMX_GetShiftState(Base, true); + std::u16string stBase = this->KMX_GetShiftState(Base, false); + std::u16string stShift = this->KMX_GetShiftState(Shft, false); + std::u16string stCaps = this->KMX_GetShiftState(Base, true); std::u16string stShiftCaps = this->KMX_GetShiftState(Shft, true); return ( - ((stCaps.size() > 0) && (stBase.compare(stCaps) != 0) && (stShift.compare(stCaps) != 0)) || - ((stShiftCaps.size() > 0) && (stBase.compare(stShiftCaps) != 0) && (stShift.compare(stShiftCaps) != 0))); + ((stCaps.size() > 0) && + (stBase.compare(stCaps) != 0) && + (stShift.compare(stCaps) != 0)) || + ((stShiftCaps.size() > 0) && + (stBase.compare(stShiftCaps) != 0) && + (stShift.compare(stShiftCaps) != 0))); } bool KMX_IsCapsEqualToShift() { - std::u16string stBase = this->KMX_GetShiftState(Base, false); + std::u16string stBase = this->KMX_GetShiftState(Base, false); std::u16string stShift = this->KMX_GetShiftState(Shft, false); - std::u16string stCaps = this->KMX_GetShiftState(Base, true); - return ((stBase.size() > 0) && (stShift.size() > 0) && (stBase.compare(stShift) != 0) && (stShift.compare(stCaps) == 0)); + std::u16string stCaps = this->KMX_GetShiftState(Base, true); + return ( + (stBase.size() > 0) && + (stShift.size() > 0) && + (stBase.compare(stShift) != 0) && + (stShift.compare(stCaps) == 0)); } bool KMX_IsAltGrCapsEqualToAltGrShift() { std::u16string stBase = this->KMX_GetShiftState(MenuCtrl, false); std::u16string stShift = this->KMX_GetShiftState(ShftMenuCtrl, false); std::u16string stCaps = this->KMX_GetShiftState(MenuCtrl, true); - return ((stBase.size() > 0) && (stShift.size() > 0) && (stBase.compare(stShift) != 0) && (stShift.compare(stCaps) == 0)); + return ( + (stBase.size() > 0) && + (stShift.size() > 0) && + (stBase.compare(stShift) != 0) && + (stShift.compare(stCaps) == 0)); } bool KMX_IsXxxxGrCapsEqualToXxxxShift() { - std::u16string stBase = this->KMX_GetShiftState(Xxxx, false); + std::u16string stBase = this->KMX_GetShiftState(Xxxx, false); std::u16string stShift = this->KMX_GetShiftState(ShftXxxx, false); - std::u16string stCaps = this->KMX_GetShiftState(Xxxx, true); - return ((stBase.size() > 0) && (stShift.size() > 0) && (stBase.compare(stShift) != 0) && (stShift.compare(stCaps) == 0)); - } + std::u16string stCaps = this->KMX_GetShiftState(Xxxx, true); + return ( + (stBase.size() > 0) && + (stShift.size() > 0) && + (stBase.compare(stShift) != 0) && + (stShift.compare(stCaps) == 0)); + } bool KMX_IsEmpty() { for (int i = 0; i < 10; i++) { @@ -180,7 +198,7 @@ public: } return true; } - +/** @brief check if we use only keys used in mcompile */ bool KMX_IsKeymanUsedKey() { return (this->m_vk >= 0x20 && this->m_vk <= 0x5F) || (this->m_vk >= 0x88); } @@ -189,6 +207,7 @@ public: return KMX_ShiftStateMap[(int)ss] | (capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0); } +/** @brief count the number of keys */ int KMX_GetKeyCount(int MaxShiftState) { int nkeys = 0; @@ -200,7 +219,7 @@ public: } for (int caps = 0; caps <= 1; caps++) { std::u16string st = this->KMX_GetShiftState((ShiftState)ss, (caps == 1)); - + // ctrl and shift+ctrl will be skipped since rgkey has no entries in m_rgss[2] m_rgss[3] if (st.size() == 0) { // No character assigned here } else if (this->m_rgfDeadKey[(int)ss][caps]) { @@ -211,7 +230,6 @@ public: for (size_t ich = 0; ich < st.size(); ich++) { if (st[ich] < 0x20 || st[ich] == 0x7F) { isvalid = false; - printf("invalid for: %i\n", st[ich]); break; } @@ -227,8 +245,13 @@ public: bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector* deadkeys, int deadkeyBase, BOOL bDeadkeyConversion, vec_dword_3D& all_vector, GdkKeymap* keymap) { // I4552 // Get the CAPSLOCK value - int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | (this->KMX_IsSGCAPS() ? 2 : 0) | - (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + int capslock = + (this->KMX_IsCapsEqualToShift() ? 1 : 0) | + (this->KMX_IsSGCAPS() ? 2 : 0) | + (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | + (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + + //int capslock = 1; // we do not use the equation to obtain capslock. On Linux we set capslock = 1 for (int ss = 0; ss <= MaxShiftState; ss++) { if (ss == Menu || ss == ShftMenu) { @@ -248,7 +271,7 @@ public: *key->dpContext = 0; key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState)ss); - // we already use VK_US so no need to convert it as we do on windows + // we already use VK_US so no need to convert it as we do on Windows key->Key = this->VK(); key->Line = 0; @@ -274,14 +297,16 @@ public: } } if (isvalid) { - // this is different to mcompile windows !!!! - // this->m_sc stores SC-US = SCUnderlying - // this->m_vk stores VK-US ( not underlying !!) - // key->Key stores VK-US ( not underlying !!) - // key->dpOutput stores character Underlying + /* + * this is different to mcompile Windows !!!! + * this->m_sc stores SC-US = SCUnderlying + * this->m_vk stores VK-US ( not VK underlying !!) + * key->Key stores VK-US ( not VK underlying !!) + * key->dpOutput stores character Underlying + */ + KMX_DWORD sc_underlying = KMX_get_KeyCodeUnderlying_From_KeyCodeUS(keymap, all_vector, this->SC(), (ShiftState)ss, caps); - KMX_DWORD SC_Underlying = KMX_get_KeyCodeUnderlying_From_KeyCodeUS(keymap, all_vector, this->SC(), (ShiftState)ss, caps); - key->Key = KMX_get_VKUS_From_KeyCodeUnderlying(SC_Underlying); + key->Key = KMX_get_VKUS_From_KeyCodeUnderlying(sc_underlying); key->Line = 0; key->ShiftFlags = this->KMX_GetShiftStateValue(capslock, caps, (ShiftState)ss); @@ -302,6 +327,7 @@ public: } }; +/** @brief Base class for KMX_loader*/ class KMX_Loader { private: KMX_BYTE lpKeyStateNull[256]; @@ -330,6 +356,11 @@ public: } }; +/** + * @brief find the maximum index of a deadkey + * @param p pointer to deadkey + * @return index of deadkey + */ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR* p) { int n = 0; while (p && *p) { @@ -340,10 +371,24 @@ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR* p) { return n; } +/** + * @brief Collect the key data, translate it to kmx and append to the existing keyboard + * It is important to understand that this function has different sorting order in rgkey compared to mcompile-windows! + * On Windows the values of rgkey are sorted according to the VK of the underlying keyboard + * On Linux the values of rgkey are sorted according to the VK of the the US keyboard + * Since Linux Keyboards do not use a VK mcompile uses the VK of the the US keyboard because + * these are available in mcompile through USVirtualKeyToScanCode/ScanCodeToUSVirtualKey and an offset of 8 + * @param kp pointer to keyboard + * @param all_vector vector that holds the data of the US keyboard and the currently used (underlying) keyboard + * @param keymap the currently used (underlying)keyboard Layout + * @param FDeadkeys vector of all deadkeys for the currently used (underlying)keyboard Layout + * @param bDeadkeyConversion 1 to convert a deadkey to a character; 0 no conversion + * @return true in case of success + */ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** keymap, std::vector* FDeadkeys, KMX_BOOL bDeadkeyConversion) { // I4353 // I4552 KMX_Loader loader; - std::vector rgKey; //= new VirtualKey[256]; + std::vector rgKey; //= new VirtualKey[256]; std::vector alDead; std::vector alDead_byBasechar = create_deadkeys_by_basechar(); @@ -353,13 +398,17 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** ke // values in it. Then, store the SC in each valid VK so it can act as both a // flag that the VK is valid, and it can store the SC value. + // Windows and Linux Keycodes start with 1; Mac keycodes start with 0 for (UINT sc = 0x01; sc <= 0x7f; sc++) { - // fills m_vk with the VK of the US keyboard - // ( mcompile win uses MapVirtualKeyEx() to fill m_vk with the VK of the Underlying keyboard) - // Linux can get a VK for the US Keyboard using USVirtualKeyToScanCode/ScanCodeToUSVirtualKey - // Linux cannot get a VK for the underling Keyboard - // this "connection" is possible only when using all_vector + /* HERE IS A BIG DIFFERENCE COMPARED TO MCOMPILE FOR WINDOWS: + * mcompile on Windows fills rgkey.m_vk with the VK of the Underlying keyboard + * mcompile for Linux fills rgkey.m_vk with the VK of the US keyboard + * this results in a different sorting order in rgkey[] ! + * Linux cannot get a VK for the underling Keyboard since this does not exist + * Linux can only get a VK for the US Keyboard (by using USVirtualKeyToScanCode/ScanCodeToUSVirtualKey) + * therefore we use VK_US in rgkey[ ] which we get from all_vector + */ KMX_VirtualKey* key = new KMX_VirtualKey(sc); if ((key->VK() != 0)) { @@ -369,40 +418,34 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** ke } } - /* _S2 TODO I assume we do not need those... - rgKey[VK_DIVIDE] = new KMX_VirtualKey(hkl, VK_DIVIDE); - rgKey[VK_CANCEL] = new KMX_VirtualKey(hkl, VK_CANCEL); - rgKey[VK_DECIMAL] = new KMX_VirtualKey(hkl, VK_DECIMAL);*/ - // in this part we skip shiftstates 4, 5, 8, 9 for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { if (rgKey[iKey] != NULL) { KMX_WCHAR sbBuffer[256]; // Scratchpad we use many places - for (ShiftState ss = Base; ss <= loader.KMX_MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { if (ss == Menu || ss == ShftMenu) { // Alt and Shift+Alt don't work, so skip them (ss 4+5) continue; } - KMX_DWORD kc_us = (KMX_DWORD)KMX_get_KeyCodeUnderlying_From_VKUS(iKey); + KMX_DWORD kc_underlying = KMX_get_KeyCodeUnderlying_From_VKUS(iKey); for (int caps = 0; caps <= 1; caps++) { - int rc = KMX_ToUnicodeEx(kc_us, sbBuffer, ss, caps, *keymap); + int rc = KMX_ToUnicodeEx(kc_underlying, sbBuffer, ss, caps, *keymap); if (rc > 0) { if (*sbBuffer == 0) { - rgKey[iKey]->KMX_SetShiftState(ss, u"", false, (caps)); // different to windows since behavior on Linux is different + rgKey[iKey]->KMX_SetShiftState(ss, u"", false, (caps)); // different to windows since behavior on Linux is different (see above) } else { - if ((ss == Ctrl || ss == ShftCtrl)) { + if ((ss == Ctrl || ss == ShftCtrl)) { continue; } sbBuffer[rc] = 0; - rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps)); // different to windows since behavior on Linux is different - } + rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps)); // different to windows since behavior on Linux is different (see above) + } } else if (rc < 0) { sbBuffer[2] = 0; - rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps)); // different to windows since behavior on Linux is different + rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps)); // different to windows since behavior on Linux is different (see above) refine_alDead(sbBuffer[0], alDead, alDead_byBasechar); } @@ -447,9 +490,9 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** ke } gp->fUsingKeys = TRUE; - gp->dpMatch = NULL; - gp->dpName = NULL; - gp->dpNoMatch = NULL; + gp->dpMatch = NULL; + gp->dpName = NULL; + gp->dpNoMatch = NULL; gp->cxKeyArray = nkeys; gp->dpKeyArray = new KMX_KEY[gp->cxKeyArray]; @@ -525,9 +568,9 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** ke gp++; gp->fUsingKeys = FALSE; - gp->dpMatch = NULL; - gp->dpName = NULL; - gp->dpNoMatch = NULL; + gp->dpMatch = NULL; + gp->dpName = NULL; + gp->dpNoMatch = NULL; gp->cxKeyArray = alDead.size(); LPKMX_KEY kkp = gp->dpKeyArray = new KMX_KEY[alDead.size()]; @@ -581,6 +624,5 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** ke kkp++; } } - - return true; +return true; } diff --git a/linux/mcompile/keymap/mc_import_rules.h b/linux/mcompile/keymap/mc_import_rules.h index fac3db87be..a6c2cc014a 100644 --- a/linux/mcompile/keymap/mc_import_rules.h +++ b/linux/mcompile/keymap/mc_import_rules.h @@ -3,7 +3,7 @@ #ifndef MC_IMPORT_RULES_H #define MC_IMPORT_RULES_H - +/** @brief Base class for Deadkey*/ class DeadKey { private: KMX_WCHAR m_deadchar; @@ -11,10 +11,24 @@ private: std::vector m_rgcombchar; public: + /** + * @brief Constructor + * @param deadCharacter a deadkey + */ DeadKey(KMX_WCHAR deadCharacter); + /** + * @brief return dead character + * @return deadkey character + */ KMX_WCHAR KMX_DeadCharacter(); + /** + * @brief set Deadkey with values + * @param baseCharacter the base character + * @param combinedCharacter the combined character + * @return void + */ void KMX_AddDeadKeyRow(KMX_WCHAR baseCharacter, KMX_WCHAR combinedCharacter); int KMX_Count() { @@ -33,7 +47,12 @@ public: return this->m_rgcombchar[index]; } + /** + * @brief check if character exists in DeadKey + * @param baseCharacter a character to be found + * @return true if found; false if not found + */ bool KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter); }; -# endif /*MC_IMPORT_RULES_H*/ +#endif /*MC_IMPORT_RULES_H*/ diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 2a3d80ee85..f96e2cfe68 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -1,3 +1,9 @@ +/* + * Keyman is copyright (C) 2004 SIL International. MIT License. + * + * Mnemonic layout support for Linux + */ + #include "mc_kmxfile.h" #include @@ -17,14 +23,14 @@ const int CODE__SIZE[] = { 0, // CODE_RETURN 0x06 0, // CODE_BEEP 0x07 1, // CODE_DEADKEY 0x08 - -1, // unused 0x09 + -1, // unused 0x09 2, // CODE_EXTENDED 0x0A - -1, // CODE_EXTENDEDEND 0x0B (unused) + -1, // CODE_EXTENDEDEND 0x0B (unused) 1, // CODE_SWITCH 0x0C - -1, // CODE_KEY 0x0D (never used) + -1, // CODE_KEY 0x0D (never used) 0, // CODE_CLEARCONTEXT 0x0E 1, // CODE_CALL 0x0F - -1, // UC_SENTINEL_EXTENDEDEND 0x10 (not valid with UC_SENTINEL) + -1, // UC_SENTINEL_EXTENDEDEND 0x10 (not valid with UC_SENTINEL) 1, // CODE_CONTEXTEX 0x11 1, // CODE_NOTANY 0x12 2, // CODE_SETOPT 0x13 @@ -35,55 +41,82 @@ const int CODE__SIZE[] = { 2 // CODE_SETSYSTEMSTORE 0x18 }; +/** + * @brief check if the file has correct version + * @param filebase containing data of the input file + * @param file_size a size + * @return true if successful; + * false if not + */ +KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD file_size); + +/** + * @brief Fixup the keyboard by expanding pointers. On disk the pointers are stored relative to the + * beginning of the file, but we need real pointers. This method is used on 32-bit architectures. + * @param bufp pointer to buffer where data will be copied into + * @param base pointer to starting point + * @param dwFileSize size of the file + * @return pointer to the keyboard + */ +LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); + +/** + * @brief Save a Keyboard to a file + * @param fk pointer to the keyboard + * @param hOutfile pointer to the output file + * @param FSaveDebug + * @return an Error in case of failure + */ KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL FSaveDebug) { - LPKMX_GROUP fgp; - LPKMX_STORE fsp; - LPKMX_KEY fkp; + LPKMX_STORE fsp; + LPKMX_KEY fkp; - PCOMP_KEYBOARD ck; - PCOMP_GROUP gp; - PCOMP_STORE sp; - PCOMP_KEY kp; - PKMX_BYTE buf; - KMX_DWORD size, offset; - DWORD i, j; + PCOMP_KEYBOARD ck; + PCOMP_GROUP gp; + PCOMP_STORE sp; + PCOMP_KEY kp; + PKMX_BYTE buf; + KMX_DWORD size, offset; + DWORD i, j; // Calculate how much memory to allocate size = sizeof(COMP_KEYBOARD) + fk->cxGroupArray * sizeof(COMP_GROUP) + fk->cxStoreArray * sizeof(COMP_STORE) + - //wcslen(fk->szName)*2 + 2 + - //wcslen(fk->szCopyright)*2 + 2 + - //wcslen(fk->szLanguageName)*2 + 2 + - //wcslen(fk->szMessage)*2 + 2 + - fk->dwBitmapSize; + // wcslen(fk->szName)*2 + 2 + + // wcslen(fk->szCopyright)*2 + 2 + + // wcslen(fk->szLanguageName)*2 + 2 + + // wcslen(fk->szMessage)*2 + 2 + + fk->dwBitmapSize; - for(i = 0, fgp = fk->dpGroupArray; i < fk->cxGroupArray; i++, fgp++) { - if(fgp->dpName) - size += (u16len(fgp->dpName) + 1) * sizeof(KMX_WCHAR); - size += fgp->cxKeyArray * sizeof(COMP_KEY); - for(j = 0, fkp = fgp->dpKeyArray; j < fgp->cxKeyArray; j++, fkp++) { - size += (u16len(fkp->dpOutput)+ 1) * sizeof(KMX_WCHAR); - size += (u16len(fkp->dpContext)+ 1) * sizeof(KMX_WCHAR); - } + for (i = 0, fgp = fk->dpGroupArray; i < fk->cxGroupArray; i++, fgp++) { + if (fgp->dpName) + size += (u16len(fgp->dpName) + 1) * sizeof(KMX_WCHAR); + size += fgp->cxKeyArray * sizeof(COMP_KEY); + for (j = 0, fkp = fgp->dpKeyArray; j < fgp->cxKeyArray; j++, fkp++) { + size += (u16len(fkp->dpOutput) + 1) * sizeof(KMX_WCHAR); + size += (u16len(fkp->dpContext) + 1) * sizeof(KMX_WCHAR); + } - if (fgp->dpMatch ) size += (u16len(fgp->dpMatch)+ 1) * sizeof(KMX_WCHAR); - if (fgp->dpNoMatch ) size += (u16len(fgp->dpNoMatch)+ 1) * sizeof(KMX_WCHAR); - } + if (fgp->dpMatch) + size += (u16len(fgp->dpMatch) + 1) * sizeof(KMX_WCHAR); + if (fgp->dpNoMatch) + size += (u16len(fgp->dpNoMatch) + 1) * sizeof(KMX_WCHAR); + } - for(i = 0; i < fk->cxStoreArray; i++) - { - size += (u16len(fk->dpStoreArray[i].dpString)+ 1) * sizeof(KMX_WCHAR); - if(fk->dpStoreArray[i].dpName) - size +=(u16len(fk->dpStoreArray[i].dpName)+ 1) * sizeof(KMX_WCHAR); - } + for (i = 0; i < fk->cxStoreArray; i++) { + size += (u16len(fk->dpStoreArray[i].dpString) + 1) * sizeof(KMX_WCHAR); + if (fk->dpStoreArray[i].dpName) + size += (u16len(fk->dpStoreArray[i].dpName) + 1) * sizeof(KMX_WCHAR); + } - buf = new KMX_BYTE[size]; - if(!buf) return CERR_CannotAllocateMemory; - memset(buf, 0, size); + buf = new KMX_BYTE[size]; + if (!buf) + return CERR_CannotAllocateMemory; + memset(buf, 0, size); - ck = (PCOMP_KEYBOARD) buf; + ck = (PCOMP_KEYBOARD)buf; ck->dwIdentifier = FILEID_COMPILED; @@ -102,74 +135,74 @@ KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX offset = sizeof(COMP_KEYBOARD); ck->dpStoreArray = offset; - sp = (PCOMP_STORE)(buf+offset); + sp = (PCOMP_STORE)(buf + offset); fsp = fk->dpStoreArray; offset += sizeof(COMP_STORE) * ck->cxStoreArray; - for(i = 0; i < ck->cxStoreArray; i++, sp++, fsp++) { + for (i = 0; i < ck->cxStoreArray; i++, sp++, fsp++) { sp->dwSystemID = fsp->dwSystemID; sp->dpString = offset; - u16ncpy((PKMX_WCHAR)(buf+offset), fsp->dpString, (size-offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 + u16ncpy((PKMX_WCHAR)(buf + offset), fsp->dpString, (size - offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 - offset += (u16len(fsp->dpString)+ 1) * sizeof(KMX_WCHAR); - if(!fsp->dpName) { + offset += (u16len(fsp->dpString) + 1) * sizeof(KMX_WCHAR); + if (!fsp->dpName) { sp->dpName = 0; } else { sp->dpName = offset; - u16ncpy((PKMX_WCHAR)(buf+offset), fsp->dpName, (size-offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 - offset += (u16len(fsp->dpName)+ 1) * sizeof(KMX_WCHAR); + u16ncpy((PKMX_WCHAR)(buf + offset), fsp->dpName, (size - offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 + offset += (u16len(fsp->dpName) + 1) * sizeof(KMX_WCHAR); } - } + } - ck->dpGroupArray = offset; - gp = (PCOMP_GROUP)(buf+offset); + ck->dpGroupArray = offset; + gp = (PCOMP_GROUP)(buf + offset); - offset += sizeof(COMP_GROUP) * ck->cxGroupArray; + offset += sizeof(COMP_GROUP) * ck->cxGroupArray; - for(i = 0,fgp = fk->dpGroupArray; i < ck->cxGroupArray; i++, gp++, fgp++) { - gp->cxKeyArray = fgp->cxKeyArray; - gp->fUsingKeys = fgp->fUsingKeys; + for (i = 0, fgp = fk->dpGroupArray; i < ck->cxGroupArray; i++, gp++, fgp++) { + gp->cxKeyArray = fgp->cxKeyArray; + gp->fUsingKeys = fgp->fUsingKeys; - gp->dpMatch = gp->dpNoMatch = 0; + gp->dpMatch = gp->dpNoMatch = 0; - if(fgp->dpMatch) { - gp->dpMatch = offset; - u16ncpy((PKMX_WCHAR)(buf+offset), fgp->dpMatch, (size-offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 - offset += (u16len(fgp->dpMatch)+ 1) * sizeof(KMX_WCHAR); - } - if(fgp->dpNoMatch) { - gp->dpNoMatch = offset; - u16ncpy((PKMX_WCHAR)(buf+offset), fgp->dpNoMatch, (size-offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 - offset += (u16len(fgp->dpNoMatch)+ 1) * sizeof(KMX_WCHAR); - } + if (fgp->dpMatch) { + gp->dpMatch = offset; + u16ncpy((PKMX_WCHAR)(buf + offset), fgp->dpMatch, (size - offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 + offset += (u16len(fgp->dpMatch) + 1) * sizeof(KMX_WCHAR); + } + if (fgp->dpNoMatch) { + gp->dpNoMatch = offset; + u16ncpy((PKMX_WCHAR)(buf + offset), fgp->dpNoMatch, (size - offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 + offset += (u16len(fgp->dpNoMatch) + 1) * sizeof(KMX_WCHAR); + } - if(fgp->dpName) { - gp->dpName = offset; - u16ncpy((PKMX_WCHAR)(buf+offset), fgp->dpName, (size-offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 - offset += (u16len(fgp->dpName)+ 1) * sizeof(KMX_WCHAR); - } else { + if (fgp->dpName) { + gp->dpName = offset; + u16ncpy((PKMX_WCHAR)(buf + offset), fgp->dpName, (size - offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 + offset += (u16len(fgp->dpName) + 1) * sizeof(KMX_WCHAR); + } else { gp->dpName = 0; } gp->dpKeyArray = offset; - kp = (PCOMP_KEY) (buf + offset); + kp = (PCOMP_KEY)(buf + offset); offset += gp->cxKeyArray * sizeof(COMP_KEY); - for(j = 0, fkp = fgp->dpKeyArray; j < gp->cxKeyArray; j++, kp++, fkp++){ + for (j = 0, fkp = fgp->dpKeyArray; j < gp->cxKeyArray; j++, kp++, fkp++) { kp->Key = fkp->Key; kp->Line = fkp->Line; kp->ShiftFlags = fkp->ShiftFlags; kp->dpOutput = offset; - u16ncpy((PKMX_WCHAR)(buf+offset), fkp->dpOutput, (size-offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 - offset += (u16len(fkp->dpOutput)+ 1) * sizeof(KMX_WCHAR); + u16ncpy((PKMX_WCHAR)(buf + offset), fkp->dpOutput, (size - offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 + offset += (u16len(fkp->dpOutput) + 1) * sizeof(KMX_WCHAR); kp->dpContext = offset; - u16ncpy((PKMX_WCHAR)(buf+offset), fkp->dpContext, (size-offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 - offset += (u16len(fkp->dpContext)+ 1) * sizeof(KMX_WCHAR); + u16ncpy((PKMX_WCHAR)(buf + offset), fkp->dpContext, (size - offset) / sizeof(KMX_WCHAR)); // I3481 // I3641 + offset += (u16len(fkp->dpContext) + 1) * sizeof(KMX_WCHAR); } } - if(fk->dwBitmapSize > 0) { + if (fk->dwBitmapSize > 0) { ck->dwBitmapSize = fk->dwBitmapSize; ck->dpBitmapOffset = offset; memcpy(buf + offset, ((PKMX_BYTE)fk) + fk->dpBitmapOffset, fk->dwBitmapSize); @@ -177,37 +210,31 @@ KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX } else { ck->dwBitmapSize = 0; ck->dpBitmapOffset = 0; - } + } size_t nr_elements = fwrite(buf, size, 1, hOutfile); - if(nr_elements < 1) { + if (nr_elements < 1) { delete[] buf; return CERR_SomewhereIGotItWrong; } - - if(offset != size) { + if (offset != size) { delete[] buf; return CERR_UnableToWriteFully; } - delete[] buf; + delete[] buf; - return CERR_None; + return CERR_None; } -KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD file_size); - -LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); - +/** @brief save keyboard to file */ KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, KMX_CHAR* filename) { - - FILE *fp; + FILE* fp; fp = Open_File(filename, "wb"); - if(fp == NULL) - { + if (fp == NULL) { KMX_LogError(L"Failed to create output file (%d)", errno); return FALSE; } @@ -215,7 +242,7 @@ KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, KMX_CHAR* filename) { KMX_DWORD err = KMX_WriteCompiledKeyboardToFile(kbd, fp, FALSE); fclose(fp); - if(err != CERR_None) { + if (err != CERR_None) { KMX_LogError(L"Failed to write compiled keyboard with error %d", err); std::string s(filename); remove(s.c_str()); @@ -225,25 +252,35 @@ KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, KMX_CHAR* filename) { return TRUE; } +/** + * @brief add an offset + * @param base pointer to starting point + * @param offset a given offset + * @return pointer to base + offset + */ PKMX_WCHAR KMX_StringOffset(PKMX_BYTE base, KMX_DWORD offset) { - if(offset == 0) return NULL; + if (offset == 0) + return NULL; return (PKMX_WCHAR)(base + offset); } #ifdef KMX_64BIT -/** CopyKeyboard will copy the data read into bufp from x86-sized structures into - x64-sized structures starting at `base` - * After this function finishes, we still need to keep the original data because - we don't copy the strings - This method is used on 64-bit architectures. -*/ +/** + * @brief CopyKeyboard will copy the data into bufp from x86-sized structures into + * x64-sized structures starting at `base`. After this function finishes, we still + * need to keep the original data because we don't copy the strings. The method is + * used on 64-bit architectures. + * @param bufp pointer to buffer where data is copied into + * @param base pointer to starting point + * @return pointer to the keyboard + */ LPKMX_KEYBOARD CopyKeyboard(PKMX_BYTE bufp, PKMX_BYTE base) { - PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD) base; + PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD)base; /* Copy keyboard structure */ - LPKMX_KEYBOARD kbp = (LPKMX_KEYBOARD) bufp; + LPKMX_KEYBOARD kbp = (LPKMX_KEYBOARD)bufp; bufp += sizeof(KMX_KEYBOARD); kbp->dwIdentifier = ckbp->dwIdentifier; @@ -259,21 +296,17 @@ LPKMX_KEYBOARD CopyKeyboard(PKMX_BYTE bufp, PKMX_BYTE base) { kbp->dwFlags = ckbp->dwFlags; kbp->dwHotKey = ckbp->dwHotKey; - kbp->dpStoreArray = (LPKMX_STORE) bufp; + kbp->dpStoreArray = (LPKMX_STORE)bufp; bufp += sizeof(KMX_STORE) * kbp->cxStoreArray; - kbp->dpGroupArray = (LPKMX_GROUP) bufp; + kbp->dpGroupArray = (LPKMX_GROUP)bufp; bufp += sizeof(KMX_GROUP) * kbp->cxGroupArray; PCOMP_STORE csp; LPKMX_STORE sp; KMX_DWORD i; - for( - csp = (PCOMP_STORE)(base + ckbp->dpStoreArray), sp = kbp->dpStoreArray, i = 0; - i < kbp->cxStoreArray; - i++, sp++, csp++) - { + for (csp = (PCOMP_STORE)(base + ckbp->dpStoreArray), sp = kbp->dpStoreArray, i = 0; i < kbp->cxStoreArray; i++, sp++, csp++) { sp->dwSystemID = csp->dwSystemID; sp->dpName = KMX_StringOffset(base, csp->dpName); sp->dpString = KMX_StringOffset(base, csp->dpString); @@ -282,13 +315,9 @@ LPKMX_KEYBOARD CopyKeyboard(PKMX_BYTE bufp, PKMX_BYTE base) { PCOMP_GROUP cgp; LPKMX_GROUP gp; - for( - cgp = (PCOMP_GROUP)(base + ckbp->dpGroupArray), gp = kbp->dpGroupArray, i = 0; - i < kbp->cxGroupArray; - i++, gp++, cgp++) - { + for (cgp = (PCOMP_GROUP)(base + ckbp->dpGroupArray), gp = kbp->dpGroupArray, i = 0; i < kbp->cxGroupArray; i++, gp++, cgp++) { gp->dpName = KMX_StringOffset(base, cgp->dpName); - gp->dpKeyArray = cgp->cxKeyArray > 0 ? (LPKMX_KEY) bufp : NULL; + gp->dpKeyArray = cgp->cxKeyArray > 0 ? (LPKMX_KEY)bufp : NULL; gp->cxKeyArray = cgp->cxKeyArray; bufp += sizeof(KMX_KEY) * gp->cxKeyArray; gp->dpMatch = KMX_StringOffset(base, cgp->dpMatch); @@ -299,11 +328,7 @@ LPKMX_KEYBOARD CopyKeyboard(PKMX_BYTE bufp, PKMX_BYTE base) { LPKMX_KEY kp; KMX_DWORD j; - for( - ckp = (PCOMP_KEY)(base + cgp->dpKeyArray), kp = gp->dpKeyArray, j = 0; - j < gp->cxKeyArray; - j++, kp++, ckp++) - { + for (ckp = (PCOMP_KEY)(base + cgp->dpKeyArray), kp = gp->dpKeyArray, j = 0; j < gp->cxKeyArray; j++, kp++, ckp++) { kp->Key = ckp->Key; kp->Line = ckp->Line; kp->ShiftFlags = ckp->ShiftFlags; @@ -315,72 +340,71 @@ LPKMX_KEYBOARD CopyKeyboard(PKMX_BYTE bufp, PKMX_BYTE base) { } // else KMX_FixupKeyboard -#else /** Fixup the keyboard by expanding pointers. On disk the pointers are stored relative to the - beginning of the file, but we need real pointers. This method is used on 32-bit architectures. -*/ - +#else +/** @brief Fixup the keyboard by expanding pointers. */ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize) { - UNREFERENCED_PARAMETER(dwFileSize); KMX_DWORD i, j; - PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD) base; + PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD)base; PCOMP_GROUP cgp; PCOMP_STORE csp; PCOMP_KEY ckp; - LPKMX_KEYBOARD kbp = (LPKMX_KEYBOARD) bufp; + LPKMX_KEYBOARD kbp = (LPKMX_KEYBOARD)bufp; LPKMX_STORE sp; LPKMX_GROUP gp; LPKMX_KEY kp; - kbp->dpStoreArray = (LPKMX_STORE) (base + ckbp->dpStoreArray); - kbp->dpGroupArray = (LPKMX_GROUP) (base + ckbp->dpGroupArray); + kbp->dpStoreArray = (LPKMX_STORE)(base + ckbp->dpStoreArray); + kbp->dpGroupArray = (LPKMX_GROUP)(base + ckbp->dpGroupArray); - for(sp = kbp->dpStoreArray, csp = (PCOMP_STORE) sp, i = 0; i < kbp->cxStoreArray; i++, sp++, csp++) { + for (sp = kbp->dpStoreArray, csp = (PCOMP_STORE)sp, i = 0; i < kbp->cxStoreArray; i++, sp++, csp++) { sp->dpName = KMX_StringOffset(base, csp->dpName); - sp->dpString = KMX_StringOffset(base, csp->dpString); - } + sp->dpString = KMX_StringOffset(base, csp->dpString); + } - for(gp = kbp->dpGroupArray, cgp = (PCOMP_GROUP) gp, i = 0; i < kbp->cxGroupArray; i++, gp++, cgp++) { + for (gp = kbp->dpGroupArray, cgp = (PCOMP_GROUP)gp, i = 0; i < kbp->cxGroupArray; i++, gp++, cgp++) { gp->dpName = KMX_StringOffset(base, cgp->dpName); - gp->dpKeyArray = (LPKMX_KEY) (base + cgp->dpKeyArray); - if(cgp->dpMatch != NULL) gp->dpMatch = (PKMX_WCHAR) (base + cgp->dpMatch); - if(cgp->dpNoMatch != NULL) gp->dpNoMatch = (PKMX_WCHAR) (base + cgp->dpNoMatch); + gp->dpKeyArray = (LPKMX_KEY)(base + cgp->dpKeyArray); + if (cgp->dpMatch != NULL) + gp->dpMatch = (PKMX_WCHAR)(base + cgp->dpMatch); + if (cgp->dpNoMatch != NULL) + gp->dpNoMatch = (PKMX_WCHAR)(base + cgp->dpNoMatch); - for(kp = gp->dpKeyArray, ckp = (PCOMP_KEY) kp, j = 0; j < gp->cxKeyArray; j++, kp++, ckp++) { - kp->dpOutput = (PKMX_WCHAR) (base + ckp->dpOutput); - kp->dpContext = (PKMX_WCHAR) (base + ckp->dpContext); - } - } + for (kp = gp->dpKeyArray, ckp = (PCOMP_KEY)kp, j = 0; j < gp->cxKeyArray; j++, kp++, ckp++) { + kp->dpOutput = (PKMX_WCHAR)(base + ckp->dpOutput); + kp->dpContext = (PKMX_WCHAR)(base + ckp->dpContext); + } + } return kbp; } #endif +/** @brief load a keyboard kmx-file */ KMX_BOOL KMX_LoadKeyboard(KMX_CHAR* fileName, LPKMX_KEYBOARD* lpKeyboard) { - *lpKeyboard = NULL; PKMX_BYTE buf; FILE* fp; LPKMX_KEYBOARD kbp; PKMX_BYTE filebase; - if(!fileName || !lpKeyboard) { - KMX_LogError(L"Bad Filename\n" ); + if (!fileName || !lpKeyboard) { + KMX_LogError(L"Bad Filename\n"); return FALSE; } fp = Open_File((const KMX_CHAR*)fileName, "rb"); - if(fp == NULL) { - KMX_LogError(L"Could not open file\n" ); + if (fp == NULL) { + KMX_LogError(L"Could not open file\n"); return FALSE; } if (fseek(fp, 0, SEEK_END) != 0) { fclose(fp); - KMX_LogError(L"Could not fseek file\n" ); + KMX_LogError(L"Could not fseek file\n"); return FALSE; } @@ -392,54 +416,54 @@ KMX_BOOL KMX_LoadKeyboard(KMX_CHAR* fileName, LPKMX_KEYBOARD* lpKeyboard) { if (fseek(fp, 0, SEEK_SET) != 0) { fclose(fp); - KMX_LogError(L"Could not fseek(set) file\n" ); + KMX_LogError(L"Could not fseek(set) file\n"); return FALSE; } - #ifdef KMX_64BIT - // allocate enough memory for expanded data structure + original data. - // Expanded data structure is double the size of data on disk (8-byte - // pointers) - on disk the "pointers" are relative to the beginning of - // the file. - // We save the original data at the end of buf; we don't copy strings, so - // those will remain in the location at the end of the buffer. - buf = new KMX_BYTE[file_size * 3]; - #else - buf = new KMX_BYTE[file_size]; - #endif +#ifdef KMX_64BIT + /** + * allocate enough memory for expanded data structure + original data. + * Expanded data structure is double the size of data on disk (8-byte + * pointers) - on disk the "pointers" are relative to the beginning of + * the file. + * We save the original data at the end of buf; we don't copy strings, so + * those will remain in the location at the end of the buffer. + */ + buf = new KMX_BYTE[file_size * 3]; +#else + buf = new KMX_BYTE[file_size]; +#endif if (!buf) { delete[] buf; fclose(fp); - KMX_LogError(L"Not allocmem\n" ); + KMX_LogError(L"Not allocmem\n"); return FALSE; } - #ifdef KMX_64BIT - filebase = buf + file_size*2; - #else - filebase = buf; - #endif +#ifdef KMX_64BIT + filebase = buf + file_size * 2; +#else + filebase = buf; +#endif if (fread(filebase, 1, file_size, fp) < (size_t)file_size) { - KMX_LogError(L"Could not read file\n" ); + KMX_LogError(L"Could not read file\n"); delete[] buf; fclose(fp); return FALSE; } - fclose(fp); - if(*((PKMX_DWORD)filebase) != (KMX_DWORD)FILEID_COMPILED) - { - delete [] buf; + if (*((PKMX_DWORD)filebase) != (KMX_DWORD)FILEID_COMPILED) { + delete[] buf; KMX_LogError(L"Invalid file - signature is invalid\n"); return FALSE; } if (!KMX_VerifyKeyboard(filebase, file_size)) { delete[] buf; - KMX_LogError(L"errVerifyKeyboard\n" ); + KMX_LogError(L"errVerifyKeyboard\n"); return FALSE; } @@ -449,23 +473,23 @@ KMX_BOOL KMX_LoadKeyboard(KMX_CHAR* fileName, LPKMX_KEYBOARD* lpKeyboard) { kbp = KMX_FixupKeyboard(buf, filebase, file_size); #endif - if (!kbp) { delete[] buf; - KMX_LogError(L"errFixupKeyboard\n" ); + KMX_LogError(L"errFixupKeyboard\n"); return FALSE; } if (kbp->dwIdentifier != FILEID_COMPILED) { delete[] buf; - KMX_LogError(L"errNotFileID\n" ); + KMX_LogError(L"errNotFileID\n"); return FALSE; } *lpKeyboard = kbp; return TRUE; } -KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD file_size){ +/** @brief check if the file has correct version */ +KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD file_size) { KMX_DWORD i; PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD)filebase; PCOMP_STORE csp; @@ -479,7 +503,7 @@ KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD file_size){ if (csp->dpString == 0) { KMX_LogError(L"errWrongFileVersion:NULL"); } else { - KMX_LogError(L"errWrongFileVersion:%10.10ls",(const PKMX_WCHAR) KMX_StringOffset((PKMX_BYTE)filebase, csp->dpString)); + KMX_LogError(L"errWrongFileVersion:%10.10ls", (const PKMX_WCHAR)KMX_StringOffset((PKMX_BYTE)filebase, csp->dpString)); } return FALSE; } @@ -490,8 +514,8 @@ KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD file_size){ return TRUE; } +/** @brief increment in a string */ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p) { - if (p == NULL || *p == 0) return p; if (*p != UC_SENTINEL) { @@ -499,13 +523,14 @@ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p) { return p + 2; return p + 1; } - // UC_SENTINEL(FFFF) with UC_SENTINEL_EXTENDEDEND(0x10) == variable length + // UC_SENTINEL(FFFF) with UC_SENTINEL_EXTENDEDEND(0x10) ==> variable length if (*(p + 1) == CODE_EXTENDED) { p += 2; while (*p && *p != UC_SENTINEL_EXTENDEDEND) p++; - if (*p == 0) return p; + if (*p == 0) + return p; return p + 1; } @@ -524,25 +549,25 @@ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p) { return p; } - +/** @brief open a file */ FILE* Open_File(const KMX_CHAR* Filename, const KMX_CHAR* mode) { #ifdef _MSC_VER - std::string cpath = Filename; //, cmode = mode; + std::string cpath = Filename; //, cmode = mode; std::replace(cpath.begin(), cpath.end(), '/', '\\'); - return fopen(cpath.c_str(), (const KMX_CHAR*) mode); + return fopen(cpath.c_str(), (const KMX_CHAR*)mode); #else return fopen(Filename, mode); std::string cpath, cmode; - cpath = (const KMX_CHAR*) Filename; - cmode = (const KMX_CHAR*) mode; + cpath = (const KMX_CHAR*)Filename; + cmode = (const KMX_CHAR*)mode; return fopen(cpath.c_str(), cmode.c_str()); #endif }; FILE* Open_File(const KMX_WCHAR* Filename, const KMX_WCHAR* mode) { #ifdef _MSC_VER - std::wstring cpath = convert_pchar16T_To_wstr((KMX_WCHAR*) Filename); - std::wstring cmode = convert_pchar16T_To_wstr((KMX_WCHAR*) mode); + std::wstring cpath = convert_pchar16T_To_wstr((KMX_WCHAR*)Filename); + std::wstring cmode = convert_pchar16T_To_wstr((KMX_WCHAR*)mode); std::replace(cpath.begin(), cpath.end(), '/', '\\'); return _wfsopen(cpath.c_str(), cmode.c_str(), _SH_DENYWR); #else diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 9e608c4444..78baf10810 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -10,74 +10,93 @@ #define _KMXFILE_H typedef struct KMX_tagSTORE { - KMX_DWORD dwSystemID; - PKMX_WCHAR dpName; - PKMX_WCHAR dpString; + KMX_DWORD dwSystemID; + PKMX_WCHAR dpName; + PKMX_WCHAR dpString; } KMX_STORE, *LPKMX_STORE; - typedef struct KMX_tagKEY { - KMX_WCHAR Key; - KMX_DWORD Line; - KMX_DWORD ShiftFlags; - PKMX_WCHAR dpOutput; - PKMX_WCHAR dpContext; + KMX_WCHAR Key; + KMX_DWORD Line; + KMX_DWORD ShiftFlags; + PKMX_WCHAR dpOutput; + PKMX_WCHAR dpContext; } KMX_KEY, *LPKMX_KEY; - typedef struct KMX_tagGROUP { - KMX_WCHAR* dpName; - LPKMX_KEY dpKeyArray; // [LPKEY] address of first item in key array - PKMX_WCHAR dpMatch; - PKMX_WCHAR dpNoMatch; - KMX_DWORD cxKeyArray; // in array entries - int32_t fUsingKeys; // group(xx) [using keys] <-- specified or not + KMX_WCHAR* dpName; + LPKMX_KEY dpKeyArray; // [LPKEY] address of first item in key array + PKMX_WCHAR dpMatch; + PKMX_WCHAR dpNoMatch; + KMX_DWORD cxKeyArray; // in array entries + int32_t fUsingKeys; // group(xx) [using keys] <-- specified or not } KMX_GROUP, *LPKMX_GROUP; - typedef struct KMX_tagKEYBOARD { - KMX_DWORD dwIdentifier; // Keyman compiled keyboard id + KMX_DWORD dwIdentifier; // Keyman compiled keyboard id - KMX_DWORD dwFileVersion; // Version of the file - Keyman 4.0 is 0x0400 + KMX_DWORD dwFileVersion; // Version of the file - Keyman 4.0 is 0x0400 - KMX_DWORD dwCheckSum; // As stored in keyboard. DEPRECATED as of 16.0 - KMX_DWORD xxkbdlayout; // as stored in HKEY_LOCAL_MACHINE//system//currentcontrolset//control//keyboard layouts - KMX_DWORD IsRegistered; // layout id, from same registry key - KMX_DWORD version; // keyboard version + KMX_DWORD dwCheckSum; // As stored in keyboard. DEPRECATED as of 16.0 + KMX_DWORD xxkbdlayout; // as stored in HKEY_LOCAL_MACHINE//system//currentcontrolset//control//keyboard layouts + KMX_DWORD IsRegistered; // layout id, from same registry key + KMX_DWORD version; // keyboard version - KMX_DWORD cxStoreArray; // in array entries - KMX_DWORD cxGroupArray; // in array entries + KMX_DWORD cxStoreArray; // in array entries + KMX_DWORD cxGroupArray; // in array entries - LPKMX_STORE dpStoreArray; // [LPSTORE] address of first item in store array, from start of file - LPKMX_GROUP dpGroupArray; // [LPGROUP] address of first item in group array, from start of file + LPKMX_STORE dpStoreArray; // [LPSTORE] address of first item in store array, from start of file + LPKMX_GROUP dpGroupArray; // [LPGROUP] address of first item in group array, from start of file - KMX_DWORD StartGroup[2]; // index of starting groups [2 of them] - // Ansi=0, Unicode=1 + KMX_DWORD StartGroup[2]; // index of starting groups [2 of them] + // Ansi=0, Unicode=1 - KMX_DWORD dwFlags; // Flags for the keyboard file + KMX_DWORD dwFlags; // Flags for the keyboard file - KMX_DWORD dwHotKey; // standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) + KMX_DWORD dwHotKey; // standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey) - //PWSTR dpName; // offset of name - //PWSTR dpLanguageName; // offset of language name; - //PWSTR dpCopyright; // offset of copyright - //PWSTR dpMessage; // offset of message in Keyboard About box + // PWSTR dpName; // offset of name + // PWSTR dpLanguageName; // offset of language name; + // PWSTR dpCopyright; // offset of copyright + // PWSTR dpMessage; // offset of message in Keyboard About box - KMX_DWORD dpBitmapOffset; // 0038 offset of the bitmaps in the file - KMX_DWORD dwBitmapSize; // 003C size in bytes of the bitmaps + KMX_DWORD dpBitmapOffset; // 0038 offset of the bitmaps in the file + KMX_DWORD dwBitmapSize; // 003C size in bytes of the bitmaps //HBITMAP hBitmap; // handle to the bitmap in the file; } KMX_KEYBOARD, *LPKMX_KEYBOARD; -KMX_BOOL KMX_LoadKeyboard(KMX_CHAR* fileName, LPKMX_KEYBOARD* lpKeyboard) ; +/** + * @brief load a keyboard kmx-file + * @param fileName pointer to filename of kmx-file + * @param [in,out] lpKeyboard pointer to pointer to keyboard + * @return TRUE on success; else FALSE + */ +KMX_BOOL KMX_LoadKeyboard(KMX_CHAR* fileName, LPKMX_KEYBOARD* lpKeyboard); + +/** + * @brief save keyboard to file + * @param kbd pointer to the keyboard + * @param filename pointer to filename of a kmx-file + * @return TRUE on success; else FALSE + */ KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, KMX_CHAR* filename); +/** + * @brief increment in a string + * @param p pointer to a character + * @return pointer to the incremented character + */ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); -// _S2 Open files on windows and non-windows platforms. Datatypes for Filename and mode must be the same. -// return FILE* if file could be opened; FILE must to be closed in calling function +/** + * @brief open a file + * @param Filename name of the file + * @param mode same as mode in fopen + * @return pointer to file. On error, returns a null pointer + */ FILE* Open_File(const KMX_CHAR* Filename, const KMX_CHAR* mode); FILE* Open_File(const KMX_WCHAR* Filename, const KMX_WCHAR* mode); -#endif // _KMXFILE_H +#endif // _KMXFILE_H #endif /*MC_KMXFILE_H*/ diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 1d88a05e71..8288e950b7 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -1,63 +1,76 @@ /* - Name: mcompile - Copyright: Copyright (C) SIL International. - Documentation: - Description: - Create Date: 24 Apr 2014 - - Modified Date: 8 Apr 2015 - Authors: mcdurdin - Related Files: - Dependencies: - - Bugs: - Todo: - Notes: - History: 24 Apr 2014 - mcdurdin - I4174 - V9 - mcompile logs should be stored in diag folder - 16 Jun 2014 - mcdurdin - I4273 - V9.0 - Convert keyboards to Unicode before installing - 23 Jun 2014 - mcdurdin - I4279 - V9.0 - mcompile fails to start when converting keyboard to Unicode - 03 Aug 2014 - mcdurdin - I4353 - V9.0 - mnemonic layout recompiler mixes up deadkey rules - 03 Aug 2014 - mcdurdin - I4327 - V9.0 - Mnemonic layout compiler follow-up - 31 Dec 2014 - mcdurdin - I4549 - V9.0 - Mnemonic layout recompiler does not translate Lctrl Ralt for deadkeys correctly - 06 Feb 2015 - mcdurdin - I4552 - V9.0 - Add mnemonic recompile option to ignore deadkeys - 08 Apr 2015 - mcdurdin - I4651 - V9.0 - Mnemonic layout recompiler maps AltGr+VK_BKSLASH rather than VK_OEM_102 -*/ -// -// Defines the entry point for the console application. -// -// Note: this program deliberately leaks memory as it has a very short life cycle and managing the memory allocations -// for the subcomponents of the compiled keyboard is an unnecessary optimisation. Just so you know. -// + * Keyman is copyright (C) 2004 SIL International. MIT License. + * + * Mnemonic layout support for Linux + * + * Defines the entry point for the console application. + * + * Note: this program deliberately leaks memory as it has a very short life cycle and managing the memory allocations + * for the subcomponents of the compiled keyboard is an unnecessary optimisation. Just so you know. + */ #include "mcompile.h" -//------------------------------------------------------------------------------------------------ -//------------------------------------------------------------------------------------------------ +/** + * @brief convert mnemonic keyboard layout to positional keyboard layout and translate keyboard + * @param kbd pointer to US keyboard + * @param bDeadkeyConversion option for converting a deadkey to a character: 1 = dk conversion; 0 = no dk conversion + * @param argc number of command line arguments + * @param argv pointer to command line arguments + * @return TRUE if conversion was successful; + * FALSE if not + */ +KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint argc, gchar* argv[]); -KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint argc, gchar *argv[]); - -bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** keymap, std::vector* KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 +/** @brief Collect the key data, translate it to kmx and append to the existing keyboard */ +bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** keymap, std::vector* KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 +/** + * @brief start of mcompile; load, convert and save keyboard + * @param argc number of commandline arguments + * @param argv pointer to commandline arguments: executable, inputfile, outputfile + * @param argv_gdk pointer to (commandline arguments) + * @return 0 on success, 1 for wrong usage of calling parameters, 3 if unable to load keyboard + */ int run(int argc, char* argv[], char* argv_gdk[] = NULL); -int KMX_GetDeadkeys(vec_dword_2D& dk_Table, KMX_WORD DeadKey, KMX_WORD* OutputPairs, GdkKeymap* keymap); +/** + * @brief return an array of [usvk, ch_out] pairs: all existing combinations of a deadkey + character for the underlying keyboard + * @param dk_Table shiftstate of the deadkey + * @param deadkey deadkey character + * @param [out] outputPairs pointer to array of [usvk, ch_out] pairs + * @param keymap pointer to the currently used (underlying) keyboard Layout + * @return size of array of [usvk, ch_out] pairs + */ +int KMX_GetDeadkeys(vec_dword_2D& dk_Table, KMX_WORD deadkey, KMX_WORD* outputPairs, GdkKeymap* keymap); -std::vector KMX_FDeadkeys; // I4353 +std::vector KMX_FDeadkeys; // I4353 #define _countof(a) (sizeof(a) / sizeof(*(a))) +/** + * @brief main function for mcompile for Windows, Linux, Mac + * @param argc number of commandline arguments + * @param argv commandline arguments + * @return 0 on success + */ #if defined(_WIN32) || defined(_WIN64) - int wmain(int argc, wchar_t* argv[]) { - run(argc, argv); +int wmain(int argc, wchar_t* argv[]) { + /** + * TODO for cros platform use: if we want to use wmain instead of main: + * inside wmain convert wchar_t* argv[] to char* argv_ch[] + * to be able to use run(int argc, char* argv[]) + */ + run(argc, argv); #else // LINUX - int main(int argc, char* argv[]) { - run(argc, argv, argv); +int main(int argc, char* argv[]) { + run(argc, argv, argv); #endif } +/** @brief start of mcompile; load, convert and save keyboard */ int run(int argc, char* argv[], char* argv_gdk[]) { - int bDeadkeyConversion = 0; if (argc > 1) @@ -65,7 +78,7 @@ int run(int argc, char* argv[], char* argv_gdk[]) { int n = (bDeadkeyConversion ? 2 : 1); - if (argc < 3 || argc > 4 || argc - n != 2) { // I4273// I4273 + if (argc < 3 || argc > 4 || (argc - n) != 2) { // I4273// I4273 printf( "Usage: \tmcompile [-d] infile.kmx outfile.kmx\n" " \tmcompile -u ... (not available for Linux)\n " @@ -77,7 +90,7 @@ int run(int argc, char* argv[], char* argv_gdk[]) { return 1; } - // -u option is not available for Linux + // -u option is not available for Linux and macOS KMX_CHAR* infile = argv[n]; KMX_CHAR* outfile = argv[n + 1]; @@ -129,7 +142,7 @@ int run(int argc, char* argv[], char* argv_gdk[]) { if (KMX_DoConvert(kmxfile, bDeadkeyConversion, argc, (gchar**)argv_gdk)) { // I4552F KMX_SaveKeyboard(kmxfile, outfile); -} + } #endif // DeleteReallocatedPointers(kmxfile); :TODO // _S2 not my ToDo :-) @@ -146,6 +159,15 @@ const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG | RALTFLAG, K_SHIFTFLAG | // For each key rule on the keyboard, remap its key to the // correct shift state and key. Adjust the LCTRL+RALT -> RALT if necessary // + +/** + * @brief translate each key of a group: remap the content of a key (key->Key) of the US keyboard to a character (ch) + * @param key pointer to a key + * @param vk a keyvalue of the US keyboard + * @param shift shiftstate + * @param ch character of the underlying keyboard to be remapped + * @return void + */ void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" @@ -171,12 +193,28 @@ void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { } } +/** + * @brief translate a group of a keyboard + * @param group pointer to a keyboard group + * @param vk a keyvalue of the US keyboard + * @param shift shiftstate + * @param ch character of the underlying keyboard to be remapped + * @return void + */ void KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { for (unsigned int i = 0; i < group->cxKeyArray; i++) { KMX_TranslateKey(&group->dpKeyArray[i], vk, shift, ch); } } +/** + * @brief translate a keyboard + * @param kbd pointer to the US keyboard + * @param vk a keyvalue of the US keyboard + * @param shift shiftstate + * @param ch character of the underlying keyboard to be remapped + * @return void + */ void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { for (unsigned int i = 0; i < kbd->cxGroupArray; i++) { if (kbd->dpGroupArray[i].fUsingKeys) { @@ -185,6 +223,11 @@ void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHA } } +/** + * @brief check key for unconverted key rules + * @param key pointer to a key + * @return void + */ void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key) { if (key->ShiftFlags == 0) { // KMX_LogError(L"Did not find a match for mnemonic rule on line %d, + '%c' > ...", key->Line, key->Key); @@ -193,12 +236,22 @@ void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key) { } } +/** + * @brief check a group for unconverted rules + * @param group pointer to a keyboard group + * @return void + */ void KMX_ReportUnconvertedGroupRules(LPKMX_GROUP group) { for (unsigned int i = 0; i < group->cxKeyArray; i++) { KMX_ReportUnconvertedKeyRule(&group->dpKeyArray[i]); } } +/** + * @brief check a keyboard for unconverted rules + * @param kbd pointer to the US keyboard + * @return void + */ void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { for (unsigned int i = 0; i < kbd->cxGroupArray; i++) { if (kbd->dpGroupArray[i].fUsingKeys) { @@ -207,10 +260,18 @@ void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { } } +/** + * @brief remap the content of a key (key->dpContext) of the US keyboard to a deadkey sequence + * @param key pointer to a key + * @param deadkey a deadkey to be remapped + * @param vk a keyvalue of the US keyboard + * @param shift shiftstate + * @param ch character of the underlying keyboard + * @return void + */ void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { -// _S2 TOP_2 INFO this produces a different output due to different layouts for Lin<-> win ( for the same language!!) - if ((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { + if ((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. @@ -238,12 +299,30 @@ void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT } } +/** + * @brief translate a group + * @param group pointer to a keyboard group + * @param a deadkey to be remapped + * @param vk a keyvalue of the US keyboard + * @param shift shiftstate + * @param character of the underlying keyboard + * @return void + */ void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { for (unsigned int i = 0; i < group->cxKeyArray; i++) { KMX_TranslateDeadkeyKey(&group->dpKeyArray[i], deadkey, vk, shift, ch); } } +/** + * @brief translate a keyboard + * @param kbd pointer to the US keyboard + * @param a deadkey to be remapped + * @param vk a keyvalue of the US keyboard + * @param shift shiftstate + * @param character of the underlying keyboard + * @return void + */ void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { for (unsigned int i = 0; i < kbd->cxGroupArray; i++) { if (kbd->dpGroupArray[i].fUsingKeys) { @@ -252,6 +331,14 @@ void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WOR } } +/** + * @brief add a deadkey rule + * @param kbd pointer to the US keyboard + * @param deadkey a deadkey to be added + * @param vk a keyvalue of the US keyboard + * @param shift shiftstate + * @return void + */ void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" @@ -283,6 +370,11 @@ void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT } } +/** + * @brief find the maximal deadkey id + * @param str the deadkey + * @return the maximum deadkey id + */ KMX_WCHAR KMX_ScanXStringForMaxDeadkeyID(PKMX_WCHAR str) { KMX_WCHAR dkid = 0; while (str && *str) { @@ -298,6 +390,12 @@ struct KMX_dkidmap { KMX_WCHAR src_deadkey, dst_deadkey; }; +/** + * @brief find the deadkey id for a given deadkey + * @param kbd pointer to the keyboard + * @param deadkey for which an id is to be found + * @return 0 if failed; otherwise a deadkey-id + */ KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { LPKMX_GROUP gp; LPKMX_KEY kp; @@ -348,6 +446,17 @@ KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { return s_dkids[s_ndkids++].dst_deadkey = s_next_dkid = ++dkid; } +/** + * @brief Lookup the deadkey table for the deadkey in the physical keyboard. Then for each character, go through and map it through + * @param kbd pointer to the keyboard + * @param vk_US virtual key of the us keyboard + * @param shift shiftstate + * @param deadkey character produced by a deadkey + * @param all_vector vector that holds the data of the US keyboard and the currently used (underlying) keyboard + * @param keymap pointer to the currently used (underlying) keyboard Layout + * @param dk_Table a vector of all possible deadkey combinations for all Linux keyboards + * @return void + */ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, UINT shift, KMX_WCHAR deadkey, vec_dword_3D& all_vector, GdkKeymap* keymap, vec_dword_2D dk_Table) { KMX_WORD deadkeys[512], *pdk; @@ -365,12 +474,18 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, UINT shift, KMX_WCHA while (*pdk) { // Look up the ch - UINT KeyValUnderlying = KMX_get_KeyValUnderlying_From_KeyValUS(all_vector, *pdk); + UINT KeyValUnderlying = (UINT) KMX_get_KeyValUnderlying_From_KeyValUS(all_vector, *pdk); KMX_TranslateDeadkeyKeyboard(kbd, dkid, KeyValUnderlying, *(pdk + 1), *(pdk + 2)); pdk += 3; } } +/** + * @brief convert a mnemonic keyboard to a positional keyboard + * (i.e. setting *sp->dpString = '0' / TSS_MNEMONIC=0) + * @param kbd pointer to keyboard + * @return TRUE if conversion was successful; FALSE otherwise + */ KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { LPKMX_STORE sp; UINT i; @@ -392,6 +507,7 @@ KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { return FALSE; } +/** @brief convert mnemonic keyboard layout to positional keyboard layout and translate keyboard */ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint argc, gchar* argv[]) { KMX_WCHAR DeadKey = 0; @@ -406,8 +522,8 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg GdkKeymap* keymap; if (InitializeGDK(&keymap, argc, argv)) { - printf("ERROR: can't Initialize GDK\n"); - return FALSE; + printf("ERROR: can't Initialize GDK\n"); + return FALSE; } // create vector that contains Keycode, base, shift for US-KEyboard and underlying keyboard @@ -426,8 +542,8 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg for (int i = 0; KMX_VKMap[i]; i++) { // I4651 // windows uses VK, Linux uses SC/Keycode - UINT scUnderlying = KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]); - KMX_WCHAR ch = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap, VKShiftState[j], scUnderlying, &DeadKey); + UINT scUnderlying = (UINT)KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]); + KMX_WCHAR ch = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap, scUnderlying, VKShiftState[j], &DeadKey); // printf("--- VK_%d -> SC_ [%c] dk=%d ( ss %i) \n", KMX_VKMap[i], ch == 0 ? 32 : ch, DeadKey, VKShiftState[j]); @@ -453,8 +569,16 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg return TRUE; } -int KMX_GetDeadkeys(vec_dword_2D& dk_Table, KMX_WORD deadkey, KMX_WORD* OutputPairs, GdkKeymap* keymap) { - KMX_WORD* p = OutputPairs; +/** + * @brief return an array of [usvk, ch_out] pairs: all existing combinations of a deadkey + character for the underlying keyboard + * @param deadkey deadkey character + * @param [out] OutputPairs pointer to array of [usvk, ch_out] pairs + * @param keymap pointer to the currently used (underlying) keyboard Layout + * @param dk_Table shiftstate of the deadkey + * @return size of array of [usvk, ch_out] pairs + */ +int KMX_GetDeadkeys(vec_dword_2D& dk_Table, KMX_WORD deadkey, KMX_WORD* outputPairs, GdkKeymap* keymap) { + KMX_WORD* p = outputPairs; KMX_DWORD shift; vec_dword_2D dk_SingleTable; @@ -470,19 +594,20 @@ int KMX_GetDeadkeys(vec_dword_2D& dk_Table, KMX_WORD deadkey, KMX_WORD* OutputPa } } *p = 0; - return (p - OutputPairs); + return (p - outputPairs); } +/** @brief print (error) messages */ void KMX_LogError(const wchar_t* fmt, ...) { - WCHAR fmtbuf[256]; + WCHAR fmtbuf[256]; const wchar_t* end = L"\0"; const wchar_t* nl = L"\n"; - va_list vars; + va_list vars; int j = 0; - va_start(vars, fmt); + va_start(vars, fmt); vswprintf(fmtbuf, _countof(fmtbuf), fmt, vars); - fmtbuf[255] = 0; + fmtbuf[255] = 0; do { putwchar(fmtbuf[j]); diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 95c85b989e..03a03c46be 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -32,6 +32,11 @@ struct KMX_DeadkeyMapping { // I4353 extern std::vector KMX_FDeadkeys; // I4353 +/** + * @brief print (error) messages + * @param fmt text to print + * @return void + */ void KMX_LogError(const wchar_t* fmt, ...); #endif /*MCOMPILE_H*/ diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index 186173a1af..276efe0e29 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -19,6 +19,7 @@ cpp_files = files( comon_include_dir = [ include_directories('../../../common/include'), + include_directories('../../../core/src'), ] diff --git a/linux/mcompile/keymap/u16.cpp b/linux/mcompile/keymap/u16.cpp index f5deaeaa04..993711941e 100644 --- a/linux/mcompile/keymap/u16.cpp +++ b/linux/mcompile/keymap/u16.cpp @@ -1,121 +1,94 @@ +/* + * Keyman is copyright 2024 (C) SIL International. MIT License. + * + * Functions for u16string + */ + #include "u16.h" #include #include #include +#include "utfcodec.hpp" -std::vector convert_argv_to_Vector_u16str(int argc, char* argv[]) { - std::vector vector_u16; - - // for each arg convert to u16string and push to vector - for (char** arg = argv, i=0; *arg; ++arg,i++) { - std::string S(*arg); - vector_u16.push_back(u16string_from_string(S)); - } - return vector_u16; -} - -std::vector convert_argvW_to_Vector_u16str(int argc, wchar_t* argv[]) { - std::vector vector_u16; - - // for each arg convert to u16string and push to vector - for (wchar_t** arg = argv, i=0; *arg; ++arg,i++) { - std::wstring S(*arg); - vector_u16.push_back(u16string_from_wstring(S)); - } - return vector_u16; -} - -// ToDo codecvt needs to be replaced !! //String <- wstring +/** @brief Obtain a std::string from a std::wstring */ std::string string_from_wstring(std::wstring const str) { - std::wstring_convert, wchar_t> converter; - return converter.to_bytes(str); + return convert((const std::wstring)str); } //wstring <- string +/** @brief Obtain a std::wstring from a std::string */ std::wstring wstring_from_string(std::string const str) { - std::wstring_convert, wchar_t> converter; - return converter.from_bytes(str); -} - -// u16String <- wstring -std::u16string u16string_from_wstring(std::wstring const wstr) { - std::string str= string_from_wstring(wstr); - std::u16string str16 = u16string_from_string(str); - return str16; + return convert((const std::string)str); } //u16String <- string +/** @brief Obtain a std::string from a std::wstring */ std::u16string u16string_from_string(std::string const str) { - std::wstring_convert, char16_t> converter; - return converter.from_bytes(str); + return convert((const std::string)str); } //string <- u16string +/** @brief Obtain a std::string from a std::u16string */ std::string string_from_u16string(std::u16string const str) { - std::wstring_convert, char16_t> converter; - return converter.to_bytes(str); + return convert((const std::u16string)str); } + //wstring <- u16string -std::wstring wstring_from_u16string(std::u16string const str16) { - std::string str = string_from_u16string(str16); - std::wstring wstr = wstring_from_string( str); - return wstr; +/** @brief Obtain a std::wstring from a std::u16string */ +std::wstring wstring_from_u16string(std::u16string const str) { + std::string s = convert((const std::u16string)str); + std::wstring ws = convert((const std::string)s); + return ws; } -void u16sprintf(KMX_WCHAR * dst, const size_t max_len, const wchar_t* fmt, ...) { - // UTF16 (=const wchar_t*) -> -> std::string -> std::u16string -> UTF16 ( = char16_t*) - wchar_t* wbuf = new wchar_t[max_len]; - va_list args; - va_start(args, fmt); - vswprintf(wbuf, max_len, fmt, args); - va_end(args); - - std::wstring_convert, wchar_t> convert_wstring; - std::wstring_convert, char16_t> convert; - - // UTF16 (=const wchar_t*) -> -> std::string -> std::u16string -> UTF16 ( = char16_t*) - std::string utf8str = convert_wstring.to_bytes(wbuf); // UTF16 ( = const wchar_t*) -> std::string - std::u16string u16str = convert.from_bytes(utf8str); // std::string -> std::u16string - u16ncpy(dst, u16str.c_str(), max_len); // std::u16string.c_str() -> char16_t* - delete[] wbuf; +//u16string <- wstring +/** @brief Obtain a std::u16string from a std::wstring */ +std::u16string u16string_from_wstring(std::wstring const str) { + std::string s = convert((const std::wstring)str); + std::u16string utf16 = convert((const std::string)s); + return utf16; } - std::wstring convert_pchar16T_To_wstr(const KMX_WCHAR *Name){ - // convert char16_t* -> std::u16string -> std::string -> std::wstring - // char16_t* -> std::u16string - std::u16string u16str(Name); - // std::u16string -> std::string - std::string stri = string_from_u16string(u16str); - // std::string -> std::wstring - std::wstring wstr = wstring_from_string(stri); - return wstr; - } + // UTF16 (=const wchar_t*) -> -> std::string -> std::u16string -> UTF16 ( = char16_t*) +/** @brief @brief Convert pointer to wchar_t to pointer to char16_t and copy sz elements into dst */ +void u16sprintf(KMX_WCHAR* dst, const size_t sz, const wchar_t* fmt, ...) { + wchar_t* wbuf = new wchar_t[sz]; + va_list args; + va_start(args, fmt); + vswprintf(wbuf, sz, fmt, args); + va_end(args); -long int u16tol(const KMX_WCHAR* str, KMX_WCHAR** endptr, int base) -{ + std::u16string u16str = u16string_from_wstring(wbuf); + u16ncpy(dst, u16str.c_str(), sz); + delete[] wbuf; +} + +/** @brief @brief Convert u16string to long integer */ +long int u16tol(const KMX_WCHAR* str, KMX_WCHAR** endptr, int base) { auto s = string_from_u16string(str); char* t; - size_t idx; - long int result = stol(s, &idx, base); + long int result = strtol(s.c_str(), &t, base); if (endptr != nullptr) *endptr = (KMX_WCHAR*)str + (t - s.c_str()); return result; } -const KMX_WCHAR * u16ncat(KMX_WCHAR *dst, const KMX_WCHAR *src, size_t max) { +/** @brief Append n characters from u16string */ +const KMX_WCHAR* u16ncat(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max) { KMX_WCHAR* o = dst; - dst = (KMX_WCHAR*) u16chr(dst, 0); - //max -= (dst-o); + dst = (KMX_WCHAR*)u16chr(dst, 0); + //max -= (dst-o); while (*src && max > 0) { *dst++ = *src++; max--; } - if(max > 0) - *dst = 0; + if (max > 0) + *dst = 0; return o; } +/** @brief Append a '/' or '\\' to an array of char16_t */ const KMX_WCHAR* u16rchr_slash(KMX_WCHAR const* Name) { const KMX_WCHAR* cp = NULL; @@ -124,7 +97,8 @@ const KMX_WCHAR* u16rchr_slash(KMX_WCHAR const* Name) cp = u16rchr(Name, '/'); return cp; } -/* + +/** @brief Append a '/' or '\\' to an array of char */ KMX_CHAR* strrchr_slash(KMX_CHAR* Name) { KMX_CHAR* cp = NULL; @@ -133,19 +107,23 @@ KMX_CHAR* strrchr_slash(KMX_CHAR* Name) cp = strrchr(Name, '/'); return cp; } -*/ -// u16rchr returns last occurence of ch in p; It returns '\0' if ch == '\0' and NULL if ch is not found -const KMX_WCHAR* u16rchr(const KMX_WCHAR* p, KMX_WCHAR ch) { - const KMX_WCHAR* p_end = p + u16len(p); - while (p_end >= p) { - if (*p_end == ch) return p_end; - p_end--; - } - return NULL; +/** @brief Locate last occurrence of character in u16string */ +const KMX_WCHAR* u16rchr(const KMX_WCHAR* p, KMX_WCHAR ch) { + const KMX_WCHAR* p_end = p + u16len(p) - 1; + + if (ch == '\0') + return p_end + 1; + while (p_end >= p) { + if (*p_end == ch) + return p_end; + p_end--; + } + return NULL; } -const KMX_WCHAR * u16chr(const KMX_WCHAR *p, KMX_WCHAR ch) { +/** @brief @brief Locate first occurrence of character in u16string */ +const KMX_WCHAR* u16chr(const KMX_WCHAR* p, KMX_WCHAR ch) { while (*p) { if (*p == ch) return p; p++; @@ -153,8 +131,9 @@ const KMX_WCHAR * u16chr(const KMX_WCHAR *p, KMX_WCHAR ch) { return ch == 0 ? p : NULL; } -const KMX_WCHAR * u16cpy(KMX_WCHAR *dst, const KMX_WCHAR *src) { - KMX_WCHAR *o = dst; +/** @brief @brief Copy the u16string pointed to by source into the array pointed to by destination */ +const KMX_WCHAR* u16cpy(KMX_WCHAR* dst, const KMX_WCHAR* src) { + KMX_WCHAR* o = dst; while (*src) { *dst++ = *src++; } @@ -162,20 +141,21 @@ const KMX_WCHAR * u16cpy(KMX_WCHAR *dst, const KMX_WCHAR *src) { return o; } -const KMX_WCHAR * u16ncpy(KMX_WCHAR *dst, const KMX_WCHAR *src, size_t max) { - KMX_WCHAR *o = dst; +/** @brief Copy n characters of the u16string pointed to by source into the array pointed to by destination */ +const KMX_WCHAR* u16ncpy(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max) { + KMX_WCHAR* o = dst; while (*src && max > 0) { *dst++ = *src++; max--; } - while(max > 0) { - *dst++ = 0; - max--; + if (max > 0) { + *dst = 0; } return o; } -size_t u16len(const KMX_WCHAR *p) { +/** @brief @brief Return the length of the u16string str */ +size_t u16len(const KMX_WCHAR* p) { int i = 0; while (*p) { p++; @@ -184,7 +164,8 @@ size_t u16len(const KMX_WCHAR *p) { return i; } -int u16cmp(const KMX_WCHAR *p, const KMX_WCHAR *q) { +/** @brief @brief Compare two u16strings */ +int u16cmp(const KMX_WCHAR* p, const KMX_WCHAR* q) { while (*p && *q) { if (*p != *q) return *p - *q; p++; @@ -193,7 +174,8 @@ int u16cmp(const KMX_WCHAR *p, const KMX_WCHAR *q) { return *p - *q; } -int u16nicmp(const KMX_WCHAR *p, const KMX_WCHAR *q, size_t count) { +/** @brief @brief Case sensitive comparison of up to count characters in two strings */ +int u16nicmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count) { while (*p && *q && count) { if (toupper(*p) != toupper(*q)) return *p - *q; p++; @@ -205,7 +187,8 @@ int u16nicmp(const KMX_WCHAR *p, const KMX_WCHAR *q, size_t count) { return 0; } -int u16icmp(const KMX_WCHAR *p, const KMX_WCHAR *q) { +/** @brief @brief Case sensitive comparison of two strings */ +int u16icmp(const KMX_WCHAR* p, const KMX_WCHAR* q) { while (*p && *q) { if (toupper(*p) != toupper(*q)) return *p - *q; p++; @@ -214,7 +197,8 @@ int u16icmp(const KMX_WCHAR *p, const KMX_WCHAR *q) { return *p - *q; } -int u16ncmp(const KMX_WCHAR *p, const KMX_WCHAR *q, size_t count) { +/** @brief Comparison of up to count characters in two strings */ +int u16ncmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count) { while (*p && *q && count) { if (*p != *q) return *p - *q; p++; @@ -226,73 +210,74 @@ int u16ncmp(const KMX_WCHAR *p, const KMX_WCHAR *q, size_t count) { return 0; } -KMX_WCHAR * u16tok(KMX_WCHAR *p, const KMX_WCHAR ch, KMX_WCHAR **ctx) { +/** @brief Split u16string into tokens */ +KMX_WCHAR* u16tok(KMX_WCHAR* p, const KMX_WCHAR ch, KMX_WCHAR** ctx) { if (!p) { p = *ctx; - if (!p) return NULL; + if (!p) + return NULL; } - KMX_WCHAR *q = p; + KMX_WCHAR* q = p; while (*q && *q != ch) { q++; } if (*q) { *q = 0; q++; - while (*q == ch) q++; + while (*q == ch) + q++; *ctx = q; - } - else { + } else { *ctx = NULL; } - return *p ? p : NULL; + return *p ? p : NULL; } -// _S2 delimiters is array of char ( of size 2) -KMX_WCHAR * u16tok(KMX_WCHAR* p, KMX_WCHAR* delimiters, KMX_WCHAR** ctx) { +/** @brief Split u16string into tokens */ +KMX_WCHAR* u16tok(KMX_WCHAR* p, const KMX_WCHAR* delimiters, KMX_WCHAR** ctx) { if (!p) { p = *ctx; - if (!p) return NULL; + if (!p) + return NULL; } - KMX_WCHAR * q = p; + KMX_WCHAR* q = p; while (*q && !u16chr(delimiters, *q)) { q++; } if (*q) { *q = 0; q++; - while (*q && u16chr(delimiters, *q)) q++; + while (*q && u16chr(delimiters, *q)) + q++; *ctx = q; - } - else { + } else { *ctx = NULL; } return *p ? p : NULL; } -double u16tof( KMX_WCHAR* str) +/** @brief Convert a u16string to a double */ +double u16tof(KMX_WCHAR* str) { - double val = 0; - int offsetdot=0; - char digit; + double val = 0; + int offsetdot = 0; + char digit; - PKMX_WCHAR q = (PKMX_WCHAR)u16chr(str, '.'); - size_t pos_dot = q-str ; + PKMX_WCHAR q = (PKMX_WCHAR)u16chr(str, '.'); + size_t pos_dot = (q - str < 0) ? u16len(str) : q - str; - if (pos_dot < 0) - pos_dot = u16len(str); + for (size_t i = 0; i < u16len(str); i++) + { + digit = static_cast(towupper(*str)); - for (size_t i = 0; i < u16len(str); i++) - { - digit = static_cast(towupper(*str)); + if (i > pos_dot - 1) + offsetdot = 1; - if (i > pos_dot - 1) - offsetdot = 1; + if (digit != '.') + val = val + ((int(digit)) - 48) * pow(10, (pos_dot - 1 - i + offsetdot)); - if (digit != '.') - val =val+ ((int(digit)) - 48) * pow(10, (pos_dot - 1- i + offsetdot)); - - str++; - } - return val; + str++; + } + return val; } diff --git a/linux/mcompile/keymap/u16.h b/linux/mcompile/keymap/u16.h index ae686ee70c..0e441a9f4a 100644 --- a/linux/mcompile/keymap/u16.h +++ b/linux/mcompile/keymap/u16.h @@ -1,46 +1,199 @@ #ifndef U16_H #define U16_H +#pragma once -#include -#include -#include -#include -#include #include "km_types.h" +#include +#include +#include +#include +#include +#include -std::vector convert_argvW_to_Vector_u16str(int argc, wchar_t* argv[]); -std::vector convert_argv_to_Vector_u16str(int argc, char* argv[]); - +/** + * @brief Obtain a std::string from a std::wstring + * @param str the std::wstring to be converted + * @return a std::string + */ std::string string_from_wstring(std::wstring const str); + +/** + * @brief Obtain a std::wstring from a std::string + * @param str the std::string to be converted + * @return a std::wstring + */ std::wstring wstring_from_string(std::string const str); -std::wstring wstring_from_u16string(std::u16string const str16); + +/** + * @brief Obtain a std::string from a std::wstring + * @param str the std::wstring to be converted + * @return a std::string + */ std::u16string u16string_from_string(std::string const str); -std::u16string u16string_from_wstring(std::wstring const wstr); + +/** + * @brief Obtain a std::string from a std::u16string + * @param str the std::string to be converted + * @return a std::u16string + */ std::string string_from_u16string(std::u16string const str); -void u16sprintf(KMX_WCHAR * dst, const size_t sz, const wchar_t* fmt, ...); +/** + * @brief Obtain a std::wstring from a std::u16string + * @param str the std::u16string to be converted + * @return a std::wstring + */ +std::wstring wstring_from_u16string(std::u16string const str); -std::wstring convert_pchar16T_To_wstr(KMX_WCHAR *Name); -std::wstring convert_pchar16T_To_wstr(const KMX_WCHAR *Name); +/** + * @brief Obtain a std::u16string from a std::wstring + * @param str the std::wstring to be converted + * @return a std::u16string + */ +std::u16string u16string_from_wstring(std::wstring const str); -size_t u16len(const KMX_WCHAR *p); -int u16cmp(const KMX_WCHAR *p, const KMX_WCHAR *q); -int u16icmp(const KMX_WCHAR *p, const KMX_WCHAR *q); -int u16ncmp(const KMX_WCHAR *p, const KMX_WCHAR *q, size_t count); -int u16nicmp(const KMX_WCHAR *p, const KMX_WCHAR *q, size_t count); -const KMX_WCHAR * u16ncpy(KMX_WCHAR *dst, const KMX_WCHAR *src, size_t max); -const KMX_WCHAR * u16cpy(KMX_WCHAR *dst, const KMX_WCHAR *src); -const KMX_WCHAR * u16rchr(const KMX_WCHAR *p, KMX_WCHAR ch); -const KMX_WCHAR * u16chr(const KMX_WCHAR *p, KMX_WCHAR ch); -const KMX_WCHAR * u16ncat(KMX_WCHAR *dst, const KMX_WCHAR *src, size_t max); -KMX_WCHAR * u16tok(KMX_WCHAR *p, KMX_WCHAR ch, KMX_WCHAR **ctx); -KMX_WCHAR * u16tok(KMX_WCHAR* p, KMX_WCHAR* ch, KMX_WCHAR** ctx); +/** + * @brief Convert pointer to wchar_t to pointer to char16_t and copy sz elements into dst + * @param dst destination + * @param sz nr of characters to be copied + * @param fmt source to convert and copy + * @return void + */ +void u16sprintf(KMX_WCHAR* dst, const size_t sz, const wchar_t* fmt, ...); + +/** + * @brief Convert u16string to long integer + * @param str u16string beginning with the representation of an integral number. + * @param endptr Reference to the next character in str + * @param base Numerical base (radix) that determines the valid characters and their interpretation + * @return a std::string + */ long int u16tol(const KMX_WCHAR* str, KMX_WCHAR** endptr, int base); -double u16tof( KMX_WCHAR* str); -KMX_CHAR* strrchr_slash(KMX_CHAR* Name); +/** + * @brief Append n characters from u16string + * @param dst Pointer to the destination array + * @param src u16string to be appended + * @param max Maximum number of characters to be appended. + * @return Pointer to the destination array + */ +const KMX_WCHAR* u16ncat(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max); + +/** + * @brief Append a '/' or '\\' to an array of char16_t + * @param Name Pointer to the source + * @return Pointer to the source with slash/backslash added + */ const KMX_WCHAR* u16rchr_slash(KMX_WCHAR const* Name); +/** + * @brief Append a '/' or '\\' to an array of char + * @param Name Pointer to the source + * @return Pointer to the source with slash/backslash added + */ +KMX_CHAR* strrchr_slash(KMX_CHAR* Name); +/** + * @brief Locate last occurrence of character in u16string + * @param p Pointer to the source + * @param ch The character to be found + * @return A pointer to the last occurrence of character in u16str + */ +const KMX_WCHAR* u16rchr(const KMX_WCHAR* p, KMX_WCHAR ch); + +/** + * @brief Locate first occurrence of character in u16string + * @param p Pointer to the source + * @param ch The character to be found + * @return A pointer to the first occurrence of character in u16str + */ +const KMX_WCHAR* u16chr(const KMX_WCHAR* p, KMX_WCHAR ch); + +/** + * @brief Copy the u16string pointed by source into the array pointed by destination + * @param dst Pointer to the destination + * @param src Pointer to the source to be copied + * @return Pointer to the destination + */ + +const KMX_WCHAR* u16cpy(KMX_WCHAR* dst, const KMX_WCHAR* src); +/** + * @brief Copy n characters of the u16string pointed by source into the array pointed by destination + * @param dst Pointer to the destination + * @param src Pointer to the source to be copied + * @param max Maximum number of characters to be copied + * @return Pointer to the destination + */ +const KMX_WCHAR* u16ncpy(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max); + +/** + * @brief Return the length of the u16string str + * @param p Pointer to the source + * @return The length of u16string + */ +size_t u16len(const KMX_WCHAR* p); + +/** + * @brief Compare two u16strings + * @param p Pointer one u16string + * @param q Pointer another u16string + * @return 0 if strings are eqaual + * ! = 0 if unequal + */ +int u16cmp(const KMX_WCHAR* p, const KMX_WCHAR* q); + +/** + * @brief Case sensitive comparison of up to count characters in two strings + * @param p Pointer one u16string + * @param q Pointer another u16string + * @param count Maximum number of characters to compare + * @return 0 if strings are eqaual + * ! = 0 if unequal + */ +int u16nicmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count); + +/** + * @brief Case sensitive comparison of two strings + * @param p Pointer one u16string + * @param q Pointer another u16string + * @return 0 if strings are eqaual + * ! = 0 if unequal + */ +int u16icmp(const KMX_WCHAR* p, const KMX_WCHAR* q); + +/** + * @brief Comparison of up to count characters in two strings + * @param p Pointer one u16string + * @param q Pointer another u16string + * @param count Maximum number of characters to compare + * @return 0 if strings are eqaual + * ! = 0 if unequal + */ +int u16ncmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count); + +/** + * @brief Split u16string into tokens + * @param p Pointer to u16string to truncate. + * @param ch the delimiter character + * @param ctx the string until and without the delimiter + * @return Pointer to the destination or NULL + */ +KMX_WCHAR* u16tok(KMX_WCHAR* p, const KMX_WCHAR ch, KMX_WCHAR** ctx); + +/** + * @brief Split u16string into tokens + * @param p Pointer to u16string to truncate. + * @param delim the delimiter character + * @param ctx the string until and without the delimiter + * @return Pointer to the destination or NULL + */ +KMX_WCHAR* u16tok(KMX_WCHAR* p, const KMX_WCHAR* delim, KMX_WCHAR** ctx); + +/** + * @brief Convert a u16string to a double + * @param str Pointer to u16string + * @return double value equivalent to the string + */ +double u16tof(KMX_WCHAR* str); #endif /* U16_H */ From ddcd45216ebc8aafdfff9266932509fb7daab4f4 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 30 Jul 2024 16:06:30 +0200 Subject: [PATCH 293/327] feat(linux): info for KMX_ToUnicodeEx --- linux/mcompile/keymap/mc_import_rules.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 27f3ce119a..0c5aff97ac 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -49,8 +49,13 @@ bool DeadKey::KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter) { return false; } -/** // _S2 at merge: better description in other branch: +/** * @brief Find a keyvalue for given keycode, shiftstate and caps. A function similar to Window`s ToUnicodeEx() function. + * + * Contrary to what the function name might suggest, the function KMX_ToUnicodeEx does not process surrogate pairs. + * This is because it is used in mcompile only which only deals with latin scripts. + * In case this function should be used for surrogate pairs, they will be ignored and a message will be printed out + * @param keycode a key of the currently used keyboard Layout * @param pwszBuff Buffer to store resulting character * @param ss a shiftstate of the currently used keyboard Layout From bf792874813ed2a2ab5cde461f1b75267ad31905 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 30 Jul 2024 16:25:13 +0200 Subject: [PATCH 294/327] feat(linux): remove Open_File for KMX_WCHAR ;capslock=1 --- linux/mcompile/keymap/mc_import_rules.cpp | 6 +++--- linux/mcompile/keymap/mc_kmxfile.cpp | 16 +--------------- linux/mcompile/keymap/u16.cpp | 14 +++++++------- 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 0c5aff97ac..225ddd0508 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -250,13 +250,13 @@ public: bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector* deadkeys, int deadkeyBase, BOOL bDeadkeyConversion, vec_dword_3D& all_vector, GdkKeymap* keymap) { // I4552 // Get the CAPSLOCK value - int capslock = + /*int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | (this->KMX_IsSGCAPS() ? 2 : 0) | (this->KMX_IsAltGrCapsEqualToAltGrShift() ? 4 : 0) | - (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0); + (this->KMX_IsXxxxGrCapsEqualToXxxxShift() ? 8 : 0);*/ - //int capslock = 1; // we do not use the equation to obtain capslock. On Linux we set capslock = 1 + int capslock = 1; // we do not use the equation to obtain capslock. On Linux we set capslock = 1 for (int ss = 0; ss <= MaxShiftState; ss++) { if (ss == Menu || ss == ShftMenu) { diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index f96e2cfe68..e06e95f563 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -210,7 +210,7 @@ KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX } else { ck->dwBitmapSize = 0; ck->dpBitmapOffset = 0; - } + } size_t nr_elements = fwrite(buf, size, 1, hOutfile); @@ -563,17 +563,3 @@ FILE* Open_File(const KMX_CHAR* Filename, const KMX_CHAR* mode) { return fopen(cpath.c_str(), cmode.c_str()); #endif }; - -FILE* Open_File(const KMX_WCHAR* Filename, const KMX_WCHAR* mode) { -#ifdef _MSC_VER - std::wstring cpath = convert_pchar16T_To_wstr((KMX_WCHAR*)Filename); - std::wstring cmode = convert_pchar16T_To_wstr((KMX_WCHAR*)mode); - std::replace(cpath.begin(), cpath.end(), '/', '\\'); - return _wfsopen(cpath.c_str(), cmode.c_str(), _SH_DENYWR); -#else - std::string cpath, cmode; - cpath = string_from_u16string(Filename); - cmode = string_from_u16string(mode); - return fopen(cpath.c_str(), cmode.c_str()); -#endif -}; diff --git a/linux/mcompile/keymap/u16.cpp b/linux/mcompile/keymap/u16.cpp index 993711941e..8ebb20d123 100644 --- a/linux/mcompile/keymap/u16.cpp +++ b/linux/mcompile/keymap/u16.cpp @@ -11,31 +11,31 @@ #include "utfcodec.hpp" -//String <- wstring +// string <- wstring /** @brief Obtain a std::string from a std::wstring */ std::string string_from_wstring(std::wstring const str) { return convert((const std::wstring)str); } -//wstring <- string +// wstring <- string /** @brief Obtain a std::wstring from a std::string */ std::wstring wstring_from_string(std::string const str) { return convert((const std::string)str); } -//u16String <- string +// u16string <- string /** @brief Obtain a std::string from a std::wstring */ std::u16string u16string_from_string(std::string const str) { return convert((const std::string)str); } -//string <- u16string +// string <- u16string /** @brief Obtain a std::string from a std::u16string */ std::string string_from_u16string(std::u16string const str) { return convert((const std::u16string)str); } -//wstring <- u16string +// wstring <- u16string /** @brief Obtain a std::wstring from a std::u16string */ std::wstring wstring_from_u16string(std::u16string const str) { std::string s = convert((const std::u16string)str); @@ -43,7 +43,7 @@ std::wstring wstring_from_u16string(std::u16string const str) { return ws; } -//u16string <- wstring +// u16string <- wstring /** @brief Obtain a std::u16string from a std::wstring */ std::u16string u16string_from_wstring(std::wstring const str) { std::string s = convert((const std::wstring)str); @@ -52,7 +52,7 @@ std::u16string u16string_from_wstring(std::wstring const str) { } // UTF16 (=const wchar_t*) -> -> std::string -> std::u16string -> UTF16 ( = char16_t*) -/** @brief @brief Convert pointer to wchar_t to pointer to char16_t and copy sz elements into dst */ +/** @brief @brief Convert pointer to wchar_t to u16string and copy sz elements into dst */ void u16sprintf(KMX_WCHAR* dst, const size_t sz, const wchar_t* fmt, ...) { wchar_t* wbuf = new wchar_t[sz]; va_list args; From 2aacc783e35415633af088f9c090713325992717 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 30 Jul 2024 18:43:06 +0200 Subject: [PATCH 295/327] feat(linux): use Shiftstate instead of int in ToUnicodeEx --- linux/mcompile/keymap/mc_import_rules.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 514c93a6d7..d9487870b8 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -61,7 +61,7 @@ bool DeadKey::KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter) { return false; } -int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int caps, GdkKeymap* keymap) { +int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, ShiftState rgkey_ss, int caps, GdkKeymap* keymap) { /* * Contrary to what the function name might suggest, the function KMX_ToUnicodeEx does not process surrogate pairs. * This is because it is used in mcompile only which only deals with latin scripts. @@ -81,7 +81,7 @@ int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, int shift_state_pos, int return 0; } - KMX_DWORD keyVal = (KMX_DWORD)KMX_get_KeyVal_From_KeyCode(keymap, keycode, ShiftState(rgkey_ss), caps); + KMX_DWORD keyVal = (KMX_DWORD)KMX_get_KeyVal_From_KeyCode(keymap, keycode, rgkey_ss, caps); std::u16string str = convert_DeadkeyValues_To_U16str(keyVal); KMX_WCHAR firstchar = *(PKMX_WCHAR)str.c_str(); From 03df66deb138c07cbbdebf1e20361dd54a53316a Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 30 Jul 2024 18:51:22 +0200 Subject: [PATCH 296/327] feat(linux): use u16.cpp/h from feat/linux/mcompile-comments --- linux/mcompile/keymap/meson.build | 2 +- linux/mcompile/keymap/u16.cpp | 263 ++++++++++++++---------------- linux/mcompile/keymap/u16.h | 206 ++++++++++++++++++++--- 3 files changed, 305 insertions(+), 166 deletions(-) diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index 186173a1af..be907df26b 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -19,9 +19,9 @@ cpp_files = files( comon_include_dir = [ include_directories('../../../common/include'), + include_directories('../../../core/src'), ] - mcompile = executable( 'mcompile', sources: [cpp_files], diff --git a/linux/mcompile/keymap/u16.cpp b/linux/mcompile/keymap/u16.cpp index d70be8f057..8ebb20d123 100644 --- a/linux/mcompile/keymap/u16.cpp +++ b/linux/mcompile/keymap/u16.cpp @@ -1,121 +1,94 @@ +/* + * Keyman is copyright 2024 (C) SIL International. MIT License. + * + * Functions for u16string + */ + #include "u16.h" #include #include #include +#include "utfcodec.hpp" -std::vector convert_argv_to_Vector_u16str(int argc, char* argv[]) { - std::vector vector_u16; - // for each arg convert to u16string and push to vector - for (char** arg = argv, i=0; *arg; ++arg,i++) { - std::string S(*arg); - vector_u16.push_back(u16string_from_string(S)); - } - return vector_u16; -} - -std::vector convert_argvW_to_Vector_u16str(int argc, wchar_t* argv[]) { - std::vector vector_u16; - - // for each arg convert to u16string and push to vector - for (wchar_t** arg = argv, i=0; *arg; ++arg,i++) { - std::wstring S(*arg); - vector_u16.push_back(u16string_from_wstring(S)); - } - return vector_u16; -} - -// TODO codecvt needs to be replaced !! - -//String <- wstring +// string <- wstring +/** @brief Obtain a std::string from a std::wstring */ std::string string_from_wstring(std::wstring const str) { - std::wstring_convert, wchar_t> converter; - return converter.to_bytes(str); + return convert((const std::wstring)str); } -//wstring <- string +// wstring <- string +/** @brief Obtain a std::wstring from a std::string */ std::wstring wstring_from_string(std::string const str) { - std::wstring_convert, wchar_t> converter; - return converter.from_bytes(str); + return convert((const std::string)str); } -// u16String <- wstring -std::u16string u16string_from_wstring(std::wstring const wstr) { - std::string str= string_from_wstring(wstr); - std::u16string str16 = u16string_from_string(str); - return str16; -} - -//u16String <- string +// u16string <- string +/** @brief Obtain a std::string from a std::wstring */ std::u16string u16string_from_string(std::string const str) { - std::wstring_convert, char16_t> converter; - return converter.from_bytes(str); + return convert((const std::string)str); } -//string <- u16string +// string <- u16string +/** @brief Obtain a std::string from a std::u16string */ std::string string_from_u16string(std::u16string const str) { - std::wstring_convert, char16_t> converter; - return converter.to_bytes(str); -} -//wstring <- u16string -std::wstring wstring_from_u16string(std::u16string const str16) { - std::string str = string_from_u16string(str16); - std::wstring wstr = wstring_from_string( str); - return wstr; + return convert((const std::u16string)str); } -void u16sprintf(KMX_WCHAR * dst, const size_t max_len, const wchar_t* fmt, ...) { - // UTF16 (=const wchar_t*) -> -> std::string -> std::u16string -> UTF16 ( = char16_t*) - wchar_t* wbuf = new wchar_t[max_len]; - va_list args; - va_start(args, fmt); - vswprintf(wbuf, max_len, fmt, args); - va_end(args); - - std::wstring_convert, wchar_t> convert_wstring; - std::wstring_convert, char16_t> convert; - - // UTF16 (=const wchar_t*) -> -> std::string -> std::u16string -> UTF16 ( = char16_t*) - std::string utf8str = convert_wstring.to_bytes(wbuf); // UTF16 ( = const wchar_t*) -> std::string - std::u16string u16str = convert.from_bytes(utf8str); // std::string -> std::u16string - u16ncpy(dst, u16str.c_str(), max_len); // std::u16string.c_str() -> char16_t* - delete[] wbuf; +// wstring <- u16string +/** @brief Obtain a std::wstring from a std::u16string */ +std::wstring wstring_from_u16string(std::u16string const str) { + std::string s = convert((const std::u16string)str); + std::wstring ws = convert((const std::string)s); + return ws; } - std::wstring convert_pchar16T_To_wstr(const KMX_WCHAR *Name){ - // convert char16_t* -> std::u16string -> std::string -> std::wstring - // char16_t* -> std::u16string - std::u16string u16str(Name); - // std::u16string -> std::string - std::string stri = string_from_u16string(u16str); - // std::string -> std::wstring - std::wstring wstr = wstring_from_string(stri); - return wstr; - } +// u16string <- wstring +/** @brief Obtain a std::u16string from a std::wstring */ +std::u16string u16string_from_wstring(std::wstring const str) { + std::string s = convert((const std::wstring)str); + std::u16string utf16 = convert((const std::string)s); + return utf16; +} -long int u16tol(const KMX_WCHAR* str, KMX_WCHAR** endptr, int base) -{ + // UTF16 (=const wchar_t*) -> -> std::string -> std::u16string -> UTF16 ( = char16_t*) +/** @brief @brief Convert pointer to wchar_t to u16string and copy sz elements into dst */ +void u16sprintf(KMX_WCHAR* dst, const size_t sz, const wchar_t* fmt, ...) { + wchar_t* wbuf = new wchar_t[sz]; + va_list args; + va_start(args, fmt); + vswprintf(wbuf, sz, fmt, args); + va_end(args); + + std::u16string u16str = u16string_from_wstring(wbuf); + u16ncpy(dst, u16str.c_str(), sz); + delete[] wbuf; +} + +/** @brief @brief Convert u16string to long integer */ +long int u16tol(const KMX_WCHAR* str, KMX_WCHAR** endptr, int base) { auto s = string_from_u16string(str); char* t; - size_t idx; - long int result = stol(s, &idx, base); + long int result = strtol(s.c_str(), &t, base); if (endptr != nullptr) *endptr = (KMX_WCHAR*)str + (t - s.c_str()); return result; } -const KMX_WCHAR * u16ncat(KMX_WCHAR *dst, const KMX_WCHAR *src, size_t max) { +/** @brief Append n characters from u16string */ +const KMX_WCHAR* u16ncat(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max) { KMX_WCHAR* o = dst; - dst = (KMX_WCHAR*) u16chr(dst, 0); - //max -= (dst-o); + dst = (KMX_WCHAR*)u16chr(dst, 0); + //max -= (dst-o); while (*src && max > 0) { *dst++ = *src++; max--; } - if(max > 0) - *dst = 0; + if (max > 0) + *dst = 0; return o; } +/** @brief Append a '/' or '\\' to an array of char16_t */ const KMX_WCHAR* u16rchr_slash(KMX_WCHAR const* Name) { const KMX_WCHAR* cp = NULL; @@ -124,7 +97,8 @@ const KMX_WCHAR* u16rchr_slash(KMX_WCHAR const* Name) cp = u16rchr(Name, '/'); return cp; } -/* + +/** @brief Append a '/' or '\\' to an array of char */ KMX_CHAR* strrchr_slash(KMX_CHAR* Name) { KMX_CHAR* cp = NULL; @@ -133,19 +107,23 @@ KMX_CHAR* strrchr_slash(KMX_CHAR* Name) cp = strrchr(Name, '/'); return cp; } -*/ -// u16rchr returns last occurence of ch in p; It returns '\0' if ch == '\0' and NULL if ch is not found -const KMX_WCHAR* u16rchr(const KMX_WCHAR* p, KMX_WCHAR ch) { - const KMX_WCHAR* p_end = p + u16len(p); - while (p_end >= p) { - if (*p_end == ch) return p_end; - p_end--; - } - return NULL; +/** @brief Locate last occurrence of character in u16string */ +const KMX_WCHAR* u16rchr(const KMX_WCHAR* p, KMX_WCHAR ch) { + const KMX_WCHAR* p_end = p + u16len(p) - 1; + + if (ch == '\0') + return p_end + 1; + while (p_end >= p) { + if (*p_end == ch) + return p_end; + p_end--; + } + return NULL; } -const KMX_WCHAR * u16chr(const KMX_WCHAR *p, KMX_WCHAR ch) { +/** @brief @brief Locate first occurrence of character in u16string */ +const KMX_WCHAR* u16chr(const KMX_WCHAR* p, KMX_WCHAR ch) { while (*p) { if (*p == ch) return p; p++; @@ -153,8 +131,9 @@ const KMX_WCHAR * u16chr(const KMX_WCHAR *p, KMX_WCHAR ch) { return ch == 0 ? p : NULL; } -const KMX_WCHAR * u16cpy(KMX_WCHAR *dst, const KMX_WCHAR *src) { - KMX_WCHAR *o = dst; +/** @brief @brief Copy the u16string pointed to by source into the array pointed to by destination */ +const KMX_WCHAR* u16cpy(KMX_WCHAR* dst, const KMX_WCHAR* src) { + KMX_WCHAR* o = dst; while (*src) { *dst++ = *src++; } @@ -162,20 +141,21 @@ const KMX_WCHAR * u16cpy(KMX_WCHAR *dst, const KMX_WCHAR *src) { return o; } -const KMX_WCHAR * u16ncpy(KMX_WCHAR *dst, const KMX_WCHAR *src, size_t max) { - KMX_WCHAR *o = dst; +/** @brief Copy n characters of the u16string pointed to by source into the array pointed to by destination */ +const KMX_WCHAR* u16ncpy(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max) { + KMX_WCHAR* o = dst; while (*src && max > 0) { *dst++ = *src++; max--; } - while(max > 0) { - *dst++ = 0; - max--; + if (max > 0) { + *dst = 0; } return o; } -size_t u16len(const KMX_WCHAR *p) { +/** @brief @brief Return the length of the u16string str */ +size_t u16len(const KMX_WCHAR* p) { int i = 0; while (*p) { p++; @@ -184,7 +164,8 @@ size_t u16len(const KMX_WCHAR *p) { return i; } -int u16cmp(const KMX_WCHAR *p, const KMX_WCHAR *q) { +/** @brief @brief Compare two u16strings */ +int u16cmp(const KMX_WCHAR* p, const KMX_WCHAR* q) { while (*p && *q) { if (*p != *q) return *p - *q; p++; @@ -193,7 +174,8 @@ int u16cmp(const KMX_WCHAR *p, const KMX_WCHAR *q) { return *p - *q; } -int u16nicmp(const KMX_WCHAR *p, const KMX_WCHAR *q, size_t count) { +/** @brief @brief Case sensitive comparison of up to count characters in two strings */ +int u16nicmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count) { while (*p && *q && count) { if (toupper(*p) != toupper(*q)) return *p - *q; p++; @@ -205,7 +187,8 @@ int u16nicmp(const KMX_WCHAR *p, const KMX_WCHAR *q, size_t count) { return 0; } -int u16icmp(const KMX_WCHAR *p, const KMX_WCHAR *q) { +/** @brief @brief Case sensitive comparison of two strings */ +int u16icmp(const KMX_WCHAR* p, const KMX_WCHAR* q) { while (*p && *q) { if (toupper(*p) != toupper(*q)) return *p - *q; p++; @@ -214,7 +197,8 @@ int u16icmp(const KMX_WCHAR *p, const KMX_WCHAR *q) { return *p - *q; } -int u16ncmp(const KMX_WCHAR *p, const KMX_WCHAR *q, size_t count) { +/** @brief Comparison of up to count characters in two strings */ +int u16ncmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count) { while (*p && *q && count) { if (*p != *q) return *p - *q; p++; @@ -226,73 +210,74 @@ int u16ncmp(const KMX_WCHAR *p, const KMX_WCHAR *q, size_t count) { return 0; } -KMX_WCHAR * u16tok(KMX_WCHAR *p, const KMX_WCHAR ch, KMX_WCHAR **ctx) { +/** @brief Split u16string into tokens */ +KMX_WCHAR* u16tok(KMX_WCHAR* p, const KMX_WCHAR ch, KMX_WCHAR** ctx) { if (!p) { p = *ctx; - if (!p) return NULL; + if (!p) + return NULL; } - KMX_WCHAR *q = p; + KMX_WCHAR* q = p; while (*q && *q != ch) { q++; } if (*q) { *q = 0; q++; - while (*q == ch) q++; + while (*q == ch) + q++; *ctx = q; - } - else { + } else { *ctx = NULL; } - return *p ? p : NULL; + return *p ? p : NULL; } -// _S2 delimiters is array of char ( of size 2) -KMX_WCHAR * u16tok(KMX_WCHAR* p, KMX_WCHAR* delimiters, KMX_WCHAR** ctx) { +/** @brief Split u16string into tokens */ +KMX_WCHAR* u16tok(KMX_WCHAR* p, const KMX_WCHAR* delimiters, KMX_WCHAR** ctx) { if (!p) { p = *ctx; - if (!p) return NULL; + if (!p) + return NULL; } - KMX_WCHAR * q = p; + KMX_WCHAR* q = p; while (*q && !u16chr(delimiters, *q)) { q++; } if (*q) { *q = 0; q++; - while (*q && u16chr(delimiters, *q)) q++; + while (*q && u16chr(delimiters, *q)) + q++; *ctx = q; - } - else { + } else { *ctx = NULL; } return *p ? p : NULL; } -double u16tof( KMX_WCHAR* str) +/** @brief Convert a u16string to a double */ +double u16tof(KMX_WCHAR* str) { - double val = 0; - int offsetdot=0; - char digit; + double val = 0; + int offsetdot = 0; + char digit; - PKMX_WCHAR q = (PKMX_WCHAR)u16chr(str, '.'); - size_t pos_dot = q-str ; + PKMX_WCHAR q = (PKMX_WCHAR)u16chr(str, '.'); + size_t pos_dot = (q - str < 0) ? u16len(str) : q - str; - if (pos_dot < 0) - pos_dot = u16len(str); + for (size_t i = 0; i < u16len(str); i++) + { + digit = static_cast(towupper(*str)); - for (size_t i = 0; i < u16len(str); i++) - { - digit = static_cast(towupper(*str)); + if (i > pos_dot - 1) + offsetdot = 1; - if (i > pos_dot - 1) - offsetdot = 1; + if (digit != '.') + val = val + ((int(digit)) - 48) * pow(10, (pos_dot - 1 - i + offsetdot)); - if (digit != '.') - val =val+ ((int(digit)) - 48) * pow(10, (pos_dot - 1- i + offsetdot)); - - str++; - } - return val; + str++; + } + return val; } diff --git a/linux/mcompile/keymap/u16.h b/linux/mcompile/keymap/u16.h index 8ef4d4e084..0e441a9f4a 100644 --- a/linux/mcompile/keymap/u16.h +++ b/linux/mcompile/keymap/u16.h @@ -1,45 +1,199 @@ #ifndef U16_H #define U16_H +#pragma once -#include -#include -#include -#include -#include #include "km_types.h" +#include +#include +#include +#include +#include +#include -std::vector convert_argvW_to_Vector_u16str(int argc, wchar_t* argv[]); -std::vector convert_argv_to_Vector_u16str(int argc, char* argv[]); - +/** + * @brief Obtain a std::string from a std::wstring + * @param str the std::wstring to be converted + * @return a std::string + */ std::string string_from_wstring(std::wstring const str); + +/** + * @brief Obtain a std::wstring from a std::string + * @param str the std::string to be converted + * @return a std::wstring + */ std::wstring wstring_from_string(std::string const str); -std::wstring wstring_from_u16string(std::u16string const str16); + +/** + * @brief Obtain a std::string from a std::wstring + * @param str the std::wstring to be converted + * @return a std::string + */ std::u16string u16string_from_string(std::string const str); -std::u16string u16string_from_wstring(std::wstring const wstr); + +/** + * @brief Obtain a std::string from a std::u16string + * @param str the std::string to be converted + * @return a std::u16string + */ std::string string_from_u16string(std::u16string const str); -void u16sprintf(KMX_WCHAR * dst, const size_t sz, const wchar_t* fmt, ...); +/** + * @brief Obtain a std::wstring from a std::u16string + * @param str the std::u16string to be converted + * @return a std::wstring + */ +std::wstring wstring_from_u16string(std::u16string const str); -std::wstring convert_pchar16T_To_wstr(const KMX_WCHAR *Name); +/** + * @brief Obtain a std::u16string from a std::wstring + * @param str the std::wstring to be converted + * @return a std::u16string + */ +std::u16string u16string_from_wstring(std::wstring const str); -size_t u16len(const KMX_WCHAR *p); -int u16cmp(const KMX_WCHAR *p, const KMX_WCHAR *q); -int u16icmp(const KMX_WCHAR *p, const KMX_WCHAR *q); -int u16ncmp(const KMX_WCHAR *p, const KMX_WCHAR *q, size_t count); -int u16nicmp(const KMX_WCHAR *p, const KMX_WCHAR *q, size_t count); -const KMX_WCHAR * u16ncpy(KMX_WCHAR *dst, const KMX_WCHAR *src, size_t max); -const KMX_WCHAR * u16cpy(KMX_WCHAR *dst, const KMX_WCHAR *src); -const KMX_WCHAR * u16rchr(const KMX_WCHAR *p, KMX_WCHAR ch); -const KMX_WCHAR * u16chr(const KMX_WCHAR *p, KMX_WCHAR ch); -const KMX_WCHAR * u16ncat(KMX_WCHAR *dst, const KMX_WCHAR *src, size_t max); -KMX_WCHAR * u16tok(KMX_WCHAR *p, KMX_WCHAR ch, KMX_WCHAR **ctx); -KMX_WCHAR * u16tok(KMX_WCHAR* p, KMX_WCHAR* ch, KMX_WCHAR** ctx); +/** + * @brief Convert pointer to wchar_t to pointer to char16_t and copy sz elements into dst + * @param dst destination + * @param sz nr of characters to be copied + * @param fmt source to convert and copy + * @return void + */ +void u16sprintf(KMX_WCHAR* dst, const size_t sz, const wchar_t* fmt, ...); + +/** + * @brief Convert u16string to long integer + * @param str u16string beginning with the representation of an integral number. + * @param endptr Reference to the next character in str + * @param base Numerical base (radix) that determines the valid characters and their interpretation + * @return a std::string + */ long int u16tol(const KMX_WCHAR* str, KMX_WCHAR** endptr, int base); -double u16tof( KMX_WCHAR* str); -KMX_CHAR* strrchr_slash(KMX_CHAR* Name); +/** + * @brief Append n characters from u16string + * @param dst Pointer to the destination array + * @param src u16string to be appended + * @param max Maximum number of characters to be appended. + * @return Pointer to the destination array + */ +const KMX_WCHAR* u16ncat(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max); + +/** + * @brief Append a '/' or '\\' to an array of char16_t + * @param Name Pointer to the source + * @return Pointer to the source with slash/backslash added + */ const KMX_WCHAR* u16rchr_slash(KMX_WCHAR const* Name); +/** + * @brief Append a '/' or '\\' to an array of char + * @param Name Pointer to the source + * @return Pointer to the source with slash/backslash added + */ +KMX_CHAR* strrchr_slash(KMX_CHAR* Name); +/** + * @brief Locate last occurrence of character in u16string + * @param p Pointer to the source + * @param ch The character to be found + * @return A pointer to the last occurrence of character in u16str + */ +const KMX_WCHAR* u16rchr(const KMX_WCHAR* p, KMX_WCHAR ch); + +/** + * @brief Locate first occurrence of character in u16string + * @param p Pointer to the source + * @param ch The character to be found + * @return A pointer to the first occurrence of character in u16str + */ +const KMX_WCHAR* u16chr(const KMX_WCHAR* p, KMX_WCHAR ch); + +/** + * @brief Copy the u16string pointed by source into the array pointed by destination + * @param dst Pointer to the destination + * @param src Pointer to the source to be copied + * @return Pointer to the destination + */ + +const KMX_WCHAR* u16cpy(KMX_WCHAR* dst, const KMX_WCHAR* src); +/** + * @brief Copy n characters of the u16string pointed by source into the array pointed by destination + * @param dst Pointer to the destination + * @param src Pointer to the source to be copied + * @param max Maximum number of characters to be copied + * @return Pointer to the destination + */ +const KMX_WCHAR* u16ncpy(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max); + +/** + * @brief Return the length of the u16string str + * @param p Pointer to the source + * @return The length of u16string + */ +size_t u16len(const KMX_WCHAR* p); + +/** + * @brief Compare two u16strings + * @param p Pointer one u16string + * @param q Pointer another u16string + * @return 0 if strings are eqaual + * ! = 0 if unequal + */ +int u16cmp(const KMX_WCHAR* p, const KMX_WCHAR* q); + +/** + * @brief Case sensitive comparison of up to count characters in two strings + * @param p Pointer one u16string + * @param q Pointer another u16string + * @param count Maximum number of characters to compare + * @return 0 if strings are eqaual + * ! = 0 if unequal + */ +int u16nicmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count); + +/** + * @brief Case sensitive comparison of two strings + * @param p Pointer one u16string + * @param q Pointer another u16string + * @return 0 if strings are eqaual + * ! = 0 if unequal + */ +int u16icmp(const KMX_WCHAR* p, const KMX_WCHAR* q); + +/** + * @brief Comparison of up to count characters in two strings + * @param p Pointer one u16string + * @param q Pointer another u16string + * @param count Maximum number of characters to compare + * @return 0 if strings are eqaual + * ! = 0 if unequal + */ +int u16ncmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count); + +/** + * @brief Split u16string into tokens + * @param p Pointer to u16string to truncate. + * @param ch the delimiter character + * @param ctx the string until and without the delimiter + * @return Pointer to the destination or NULL + */ +KMX_WCHAR* u16tok(KMX_WCHAR* p, const KMX_WCHAR ch, KMX_WCHAR** ctx); + +/** + * @brief Split u16string into tokens + * @param p Pointer to u16string to truncate. + * @param delim the delimiter character + * @param ctx the string until and without the delimiter + * @return Pointer to the destination or NULL + */ +KMX_WCHAR* u16tok(KMX_WCHAR* p, const KMX_WCHAR* delim, KMX_WCHAR** ctx); + +/** + * @brief Convert a u16string to a double + * @param str Pointer to u16string + * @return double value equivalent to the string + */ +double u16tof(KMX_WCHAR* str); #endif /* U16_H */ From 56c6be2aa29cb3be3bc8fb709cecdb6165f2ed30 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 1 Aug 2024 15:08:58 +0200 Subject: [PATCH 297/327] feat(linux): comments of PR 12065 # Conflicts: # linux/mcompile/keymap/keymap.h # linux/mcompile/keymap/mcompile.cpp --- linux/mcompile/keymap/deadkey.cpp | 2 +- linux/mcompile/keymap/deadkey.h | 63 ++++++----- linux/mcompile/keymap/keymap.cpp | 12 +-- linux/mcompile/keymap/keymap.h | 126 +++++++++++----------- linux/mcompile/keymap/mc_import_rules.cpp | 29 ++--- linux/mcompile/keymap/mc_import_rules.h | 20 ++-- linux/mcompile/keymap/mc_kmxfile.cpp | 50 ++++----- linux/mcompile/keymap/mc_kmxfile.h | 34 +++--- linux/mcompile/keymap/mcompile.cpp | 126 ++++++++++++---------- linux/mcompile/keymap/mcompile.h | 1 - linux/mcompile/keymap/u16.cpp | 76 ++++++------- linux/mcompile/keymap/u16.h | 113 ++++++++++--------- 12 files changed, 331 insertions(+), 321 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index b7ebc1c665..1452d643ab 100644 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) 2004 SIL International. MIT License. + * Keyman is copyright (C) 2004 - 2024 SIL International. MIT License. * * Mnemonic layout support for Linux */ diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index 8f1c61f355..6e7bd7be58 100644 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -7,66 +7,65 @@ #include /** - * @brief create a Vector of DeadKey containing all combinations of deadkey + character for ALL possible Linux keyboards + * @brief create a Vector of DeadKey containing all combinations of deadkey + character for ALL possible Linux keyboards * @return vector of Deadkey* that holds all combinations of deadkey + character */ std::vector create_deadkeys_by_basechar(); /** - * @brief filter entries for the currently used Linux Keyboard out of a vector of all existing deadKey combinations - * @param dk the deadkey for which all combinations will be found - * @param [in,out] dkVec combinations of deadkey + character for the currently used Linux Keyboard - * @param r_All_Vec all existing combinations of deadkey + character for ALL possible Linux keyboards - * @return void + * @brief filter entries for the currently used Linux Keyboard out of a vector of all existing deadKey combinations + * @param dk the deadkey for which all combinations will be found + * @param[in,out] dkVec combinations of deadkey + character for the currently used Linux Keyboard + * @param r_All_Vec all existing combinations of deadkey + character for ALL possible Linux keyboards */ void refine_alDead(KMX_WCHAR dk, std::vector& dkVec, std::vector& r_All_Vec); /** - * @brief check whether a deadkey already exists in the deadkey vector - * @param dk the deadkey to be found - * @param dkVec vector containing combinations of deadkey + character + * @brief check whether a deadkey already exists in the deadkey vector + * @param dk the deadkey to be found + * @param dkVec vector containing combinations of deadkey + character * @return true if deadkey alredy exists; * false if not */ bool found_dk_inVector(KMX_WCHAR dk, std::vector& dkVec); /** - * @brief find all deadkey combinations for a certain deadkey in a vector of all deadkey combinations - * @param r_dk_ComposeTable vector containing all possible deadkey combinations - * @param dk deadkey of interest - * @param [in,out] dk_SingleTable vector containing all dk-character combinations for a specific deadkey dk - * @return true if successful; false if not + * @brief find all deadkey combinations for a certain deadkey in a vector of all deadkey combinations + * @param r_dk_ComposeTable vector containing all possible deadkey combinations + * @param dk deadkey of interest + * @param[in,out] dk_SingleTable vector containing all dk-character combinations for a specific deadkey dk + * @return true if successful; + * false if not */ bool query_dk_combinations_for_specific_dk(vec_dword_2D& dk_ComposeTable, KMX_DWORD dk, vec_dword_2D& dk_SingleTable); /** - * @brief convert a character to the upper-case equivalent and find the corresponding shiftstate - * of the entered keyval: a(97) -> A(65) + Base A(65) -> A(65) + Shift - * @param kval keyval that might be changed - * @param [in,out] shift the shiftstate of the entered keyval - * @param keymap a pointer to the currently used (underlying) keyboard layout + * @brief convert a character to the upper-case equivalent and find the corresponding shiftstate + * of the entered keyval: a(97) -> A(65) + Base A(65) -> A(65) + Shift + * @param kval keyval that might be changed + * @param[in,out] shift the shiftstate of the entered keyval + * @param keymap a pointer to the currently used (underlying) keyboard layout * @return the upper case equivalent of the keyval */ KMX_DWORD KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD& shift, GdkKeymap* keymap); /** - * @brief append a 1D-vector containing name, base character and unicode_value to a 2D-Vector - * holding all possible combinations of deadkey + character for all Linux keyboards - * @param [in,out] dk_ComposeTable - * @param diacritic_name the name of a diacritic - * @param base_char Base character - * @param unicode_value Unicode-value of the combined character - * @return void + * @brief append a 1D-vector containing name, base character and unicode_value to a 2D-Vector + * holding all possible combinations of deadkey + character for all Linux keyboards + * @param[in,out] dk_ComposeTable 2D-Vector holding all possible combinations of deadkey + character + * @param diacritic_name the name of a diacritic + * @param base_char base character + * @param unicode_value Unicode-value of the combined character */ void add_deadkey_combination(vec_dword_2D& dk_ComposeTable, std::string diacritic_name, std::string base_char, KMX_DWORD unicode_value); /** - * @brief create a 2D-Vector containing all possible combinations of deadkey + character for all Linux keyboards - * the values are taken from from: https://help.ubuntu.com/community/GtkDeadKeyTable#Accents - * dk_ComposeTable[i][0] : diacritic_name (e.g. dead_circumflex) - * dk_ComposeTable[i][1] : base_char (e.g. a) - * dk_ComposeTable[i][2] : unicode_value-Value (e.g. 0x00E2) - * @param [in,out] dk_ComposeTable + * @brief create a 2D-Vector containing all possible combinations of deadkey + character for all Linux keyboards + * the values are taken from from: https://help.ubuntu.com/community/GtkDeadKeyTable#Accents + * dk_ComposeTable[i][0] : diacritic_name (e.g. dead_circumflex) + * dk_ComposeTable[i][1] : base_char (e.g. a) + * dk_ComposeTable[i][2] : unicode_value-Value (e.g. 0x00E2) + * @param[in,out] dk_ComposeTable */ void create_DKTable(vec_dword_2D& dk_ComposeTable); diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 9f31256152..327c9fc24c 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) 2004 SIL International. MIT License. + * Keyman is copyright (C) 2004 - 2024 SIL International. MIT License. * * Mnemonic layout support for Linux * @@ -388,7 +388,7 @@ bool createCompleteVector_US(vec_string_1D& complete_List) { if (!inputFile.is_open()) { printf("ERROR: could not open file!\n"); - return 1; + return TRUE; } else { @@ -410,7 +410,7 @@ bool createCompleteVector_US(vec_string_1D& complete_List) { complete_List.push_back(" key { [ space, space] };"); inputFile.close(); - return 0; + return FALSE; } /** @brief convert the key name obtained from symbol file to the matching keycode */ @@ -640,17 +640,17 @@ bool InitializeGDK(GdkKeymap** keymap, int argc, gchar* argv[]) { GdkDisplay* display = gdk_display_get_default(); if (!display) { printf("ERROR: can't get display\n"); - return 1; + return TRUE; } *keymap = gdk_keymap_get_for_display(display); if (!keymap) { printf("ERROR: Can't get keymap\n"); gdk_display_close(display); - return 2; + return TRUE; } // intentionally leaking `display` in order to still be able to access `keymap` - return 0; + return FALSE; } /** @brief check if keyval correponds to a character we use in mcompile */ diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 91e9e16ea2..60655c80a8 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -65,8 +65,9 @@ static KMX_DWORD deadkey_min = 0xfe50; // X11's keysymdef.h defines deadkeys b static KMX_DWORD deadkey_max = 0xfe93; // https://fossies.org/linux/tk/xlib/X11/keysymdef.h /** - * @brief check if current machine uses little endian - * @return true if little endian is used; else false + * @brief check if current machine uses little endian + * @return true if little endian is used; + * else false */ inline bool isLittleEndianSystem() { char16_t test = 0x0102; @@ -103,52 +104,54 @@ bool ensureValidInputForKeyboardTranslation(int shiftstate, gint keycode); KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str); /** - * @brief create a 3D-Vector containing data of the US keyboard and the currently used (underlying) keyboard : - * all_vector [ US_Keyboard ] - * [KeyCode_US ] - * [Keyval unshifted ] - * [Keyval shifted ] + * @brief create a 3D-Vector containing data of the US keyboard and the currently used (underlying) keyboard : + * all_vector [ US_Keyboard ] + * [KeyCode_US ] + * [Keyval unshifted ] + * [Keyval shifted ] * [Underlying Kbd] - * [KeyCode_underlying] - * [Keyval unshifted ] - * [Keyval shifted ] + * [KeyCode_underlying] + * [Keyval unshifted ] + * [Keyval shifted ] * @param[in,out] all_vector Vector that holds the data of the US keyboard as well as the currently used (underlying) keyboard - * @param keymap pointer to currently used (underlying) keyboard layout - * @return 0 on success; - * 1 if data of US keyboard was not written; - * 2 if data of underlying keyboard was not written + * @param keymap pointer to currently used (underlying) keyboard layout + * @return 0 on success; + * 1 if data of US keyboard was not written; + * 2 if data of underlying keyboard was not written */ int createOneVectorFromBothKeyboards(vec_dword_3D& all_vector, GdkKeymap* keymap); /** - * @brief write data of the US keyboard into a 3D-Vector which later will contain - * data of the US keyboard and the currently used (underlying) keyboard + * @brief write data of the US keyboard into a 3D-Vector which later will contain + * data of the US keyboard and the currently used (underlying) keyboard * @param[in,out] vec_us Vector that holds the data of the US keyboard - * @return 0 on success; - * 1 if data of US keyboard was not written; + * @return 0 on success; + * 1 if data of US keyboard was not written; */ int write_US_ToVector(vec_dword_3D& vec_us); /** - * @brief create a 1D-Vector containing all relevant entries of the symbol file us basic - * @param [in,out] complete_List the 1D-Vector - * @return 0 on success; 1 if file could not be opened + * @brief create a 1D-Vector containing all relevant entries of the symbol file us basic + * @param[in,out] complete_List the 1D-Vector + * @return FALSE on success; + * TRUE if file could not be opened */ bool createCompleteVector_US(vec_string_1D& complete_List); /** - * @brief convert the key name obtained from symbol file to the matching keycode - * e.g. name of Key ) --> Keycode 15 - * @param key_name as stated in the symbol file + * @brief convert the key name obtained from symbol file to the matching keycode + * e.g. name of Key ) --> Keycode 15 + * @param key_name as stated in the symbol file * @return the equivalent keycode */ int get_keycode_from_keyname(std::string key_name); /** - * @brief process each element of a 1D-Vector, split and write to a 3D-Vector - * @param [in,out] all_US a 3D_Vector containing all keyvalues of the US keyboard - * @param completeList a 1D-Vector containing all relevant entries copied from the symbol file us basic - * @return 0 on success; 1 if entry can be split + * @brief process each element of a 1D-Vector, split and write to a 3D-Vector + * @param[in,out] all_US a 3D_Vector containing all keyvalues of the US keyboard + * @param completeList a 1D-Vector containing all relevant entries copied from the symbol file us basic + * @return 0 on success; + * if entry can be split */ int split_US_To_3D_Vector(vec_dword_3D& all_US, vec_string_1D completeList); @@ -161,21 +164,22 @@ int split_US_To_3D_Vector(vec_dword_3D& all_US, vec_string_1D completeList); vec_dword_2D create_empty_2D_Vector(int dim_rows, int dim_ss); /** - * @brief append a 2D-vector containing data of the currently used (underlying) keyboard to the 3D-vector + * @brief append a 2D-vector containing data of the currently used (underlying) keyboard to the 3D-vector * @param[in,out] all_vector 3D-vector that holds the data of the US keyboard and the currently used (underlying) keyboard - * @param keymap pointer to currently used (underlying) keybord layout - * @return 0 on success; - * 1 if the initialization of the underlying vector failes; - * 2 if data of less than 2 keyboards is contained in all_vector + * @param keymap pointer to currently used (underlying) keybord layout + * @return 0 on success; + * 1 if the initialization of the underlying vector failes; + * 2 if data of less than 2 keyboards is contained in all_vector */ int append_underlying_ToVector(vec_dword_3D& all_vector, GdkKeymap* keymap); /** * @brief create a pointer to pointer of the current keymap for later use - * @param keymap pointer to pointer to currently used (underlying) keyborad layout - * @param argc count of arguments - * @param argv array of arguments - * @return 0 on success; 1 if the display is not found; 2 if the keymap is not found + * @param keymap pointer to pointer to currently used (underlying) keyborad layout + * @param argc count of arguments + * @param argv array of arguments + * @return FALSE on success; + * TRUE if the display or keymap is not found */ bool InitializeGDK(GdkKeymap** keymap, int argc, gchar* argv[]); @@ -579,17 +583,19 @@ const UINT ScanCodeToUSVirtualKey[128] = { }; /** - * @brief check if keyval correponds to a character used in mcompile - * @param kv the keyval to be checked - * @return 1 if keyval is used in mcompile; 0 if not + * @brief check if keyval correponds to a character used in mcompile + * @param kv the keyval to be checked + * @return true if keyval is used in mcompile; + * false if not */ bool IsKeymanUsedChar(int kv); /** - * @brief convert a deadkey-value to a u16string if it is in the range of - * deadkeys used for mcompile e.g. 65106 -> '^' - * @param in value to be converted - * @return on success a u16string holding the converted value; else u"\0" + * @brief convert a deadkey-value to a u16string if it is in the range of + * deadkeys used for mcompile e.g. 65106 -> '^' + * @param in value to be converted + * @return on success a u16string holding the converted value; + * else u"\0" */ std::u16string convert_DeadkeyValues_To_U16str(KMX_DWORD in); @@ -597,10 +603,10 @@ std::u16string convert_DeadkeyValues_To_U16str(KMX_DWORD in); * @brief return the keyvalue for a given Keycode, shiftstate and caps of the * currently used (underlying) keyboard layout * "What character will be produced for a keypress of a key and modifier?" - * @param keymap pointer to the currently used (underlying) keyboard layout + * @param keymap pointer to the currently used (underlying) keyboard layout * @param keycode a key of the currently used keyboard layout - * @param ss a (windows-)shiftstate of the currently used keyboard layout - * @param caps state of the caps key of the currently used keyboard layout + * @param ss a (windows-)shiftstate of the currently used keyboard layout + * @param caps state of the caps key of the currently used keyboard layout * @return the keyval obtained from keycode, shiftstate and caps */ KMX_DWORD KMX_get_KeyVal_From_KeyCode(GdkKeymap* keymap, guint keycode, ShiftState ss, int caps); @@ -608,8 +614,8 @@ KMX_DWORD KMX_get_KeyVal_From_KeyCode(GdkKeymap* keymap, guint keycode, ShiftSta /** * @brief return the keyvalue for a given Keycode and shiftstate of the currently used (underlying) keyboard layout. * "What character will be produced for a keypress of a key and modifiers on the underlying keyboard?" - * @param keymap a pointer to the currently used (underlying) keyboard layout - * @param keycode a key of the currently used keyboard + * @param keymap a pointer to the currently used (underlying) keyboard layout + * @param keycode a key of the currently used keyboard * @param shift_state_pos a shiftstate of the currently used keyboard layout * @return the keyval obtained from Keycode and shiftstate; */ @@ -617,14 +623,14 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, gui /** * @brief return the keyvalue for a given Keycode and shiftstate of the currently used (underlying) keyboard layout. - * "What character will be produced for a keypress of a key and modifiers on the underlying keyboard? + * "What character will be produced for a keypress of a key and modifiers on the underlying keyboard?" * If a deadkey was found return 0xFFFF and copy the deadkey into deadKey * This function is similar to KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, guint keycode, int shiftState) * but processes deadkeys - * @param keymap a pointer to the currently used (underlying) keyboard layout - * @param keycode a key of the currently used keyboard + * @param keymap a pointer to the currently used (underlying) keyboard layout + * @param keycode a key of the currently used keyboard * @param shiftState a shiftstate of the currently used keyboard layout - * @param deadKey* pointer to keyvalue if a deadkey was found; if not NULL + * @param deadKey* pointer to keyvalue if a deadkey was found; if not NULL * @return 0xFFFF in case a deadkey was found, then the deadkey is stored in deadKey * 0xFFFE in case a deadkey is out of range * the keyval obtained from Keycode and shiftstate and caps; @@ -635,7 +641,7 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, gui * @brief return the keyvalue of a key of the the currently used (underlying) keyboard for a given keyvalue of the US keyboard * "What character is on the same position/shiftstats/caps on the currently used (underlying) keyboard as on the US keyboard?" * @param all_vector 3D-vector that holds the data of the US keyboard and the currently used (underlying) keyboard - * @param kv_us a keyvalue on the US keyboard + * @param kv_us a keyvalue on the US keyboard * @return keyval of the underlying keyboard if available; * else the keyval of the US keyboard */ @@ -644,18 +650,18 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyValUS(vec_dword_3D& all_vector, KMX_D /** * @brief return the keycode of the currently used (underlying) keyboard for a given keycode of the US keyboard * "Where on an underlying keyboard do we find a character that is on a certain key on a US keyboard?" - * @param keymap the currently used (underlying) keyboard layout + * @param keymap the currently used (underlying) keyboard layout * @param all_vector 3D-vector that holds the data of the US keyboard and the currently used (underlying) keyboard - * @param kc_us a key of the US keyboard - * @param ss a windows-type shiftstate - * @param caps state of the caps key + * @param kc_us a key of the US keyboard + * @param ss a windows-type shiftstate + * @param caps state of the caps key * @return the keycode of the underlying keyboard if found; * else the keycode of the US keyboard */ KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap* keymap, vec_dword_3D& all_vector, KMX_DWORD kc_us, ShiftState ss, int caps); /** - * @brief return the keycode of the currently used (underlying) keyboard for a given virtual key of the US keyboard + * return the keycode of the currently used (underlying) keyboard for a given virtual key of the US keyboard * "Where on an underlying keyboard do we find a character of a US keyboard?" * @param virtualKeyUS a virtual key of the US keyboard * @return the keycode of the currently used (underlying) keyboard @@ -663,7 +669,7 @@ KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap* keymap, vec_dword_ KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD virtualKeyUS); /** - * @brief return a virtual key of the US keyboard for a given keycode of the currently used (underlying) keyboard + * return a virtual key of the US keyboard for a given keycode of the currently used (underlying) keyboard * "Which key of a underlying keyboard will be mapped to a virtual key of a US keyboard?" * @param keycode a keycode of the currently used (underlying) keyboard * @return the virtual key of the US keyboard or diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 77bec96b89..69ad4ed398 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -1,9 +1,10 @@ /* - * Keyman is copyright (C) 2004 SIL International. MIT License. + * Keyman is copyright (C) 2004 - 2024 SIL International. MIT License. * * Mnemonic layout support for Linux */ + #include #include #include @@ -27,7 +28,7 @@ DeadKey::DeadKey(KMX_WCHAR deadCharacter) { this->m_deadchar = deadCharacter; } -/** @brief return dead character */ +/** @brief return dead character */ KMX_WCHAR DeadKey::KMX_DeadCharacter() { return this->m_deadchar; } @@ -56,11 +57,11 @@ bool DeadKey::KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter) { * This is because it is used in mcompile only which only deals with latin scripts. * In case this function should be used for surrogate pairs, they will be ignored and a message will be printed out - * @param keycode a key of the currently used keyboard Layout + * @param keycode a key of the currently used keyboard Layout * @param pwszBuff Buffer to store resulting character - * @param ss a shiftstate of the currently used keyboard Layout - * @param caps state of the caps key of the currently used keyboard Layout - * @param keymap the currently used (underlying)keyboard Layout + * @param ss a shiftstate of the currently used keyboard Layout + * @param caps state of the caps key of the currently used keyboard Layout + * @param keymap the currently used (underlying)keyboard Layout * @return -1 if a deadkey was found; * 0 if no translation is available; * +1 if character was found and written to pwszBuff @@ -119,7 +120,7 @@ KMX_WCHAR KMX_DeadKeyMap(int index, std::vector* deadkeys, int deadkey return 0xFFFF; } -/** @brief Base class for dealing with rgkey*/ +/** @brief Base class for dealing with rgkey*/ class KMX_VirtualKey { private: UINT m_vk; @@ -339,7 +340,7 @@ public: } }; -/** @brief Base class for KMX_loader*/ +/** @brief Base class for KMX_loader*/ class KMX_Loader { private: KMX_BYTE lpKeyStateNull[256]; @@ -369,8 +370,8 @@ public: }; /** - * @brief find the maximum index of a deadkey - * @param p pointer to deadkey + * @brief find the maximum index of a deadkey + * @param p pointer to deadkey * @return index of deadkey */ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR* p) { @@ -390,10 +391,10 @@ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR* p) { * On Linux the values of rgkey are sorted according to the VK of the the US keyboard * Since Linux Keyboards do not use a VK mcompile uses the VK of the the US keyboard because * these are available in mcompile through USVirtualKeyToScanCode/ScanCodeToUSVirtualKey and an offset of 8 - * @param kp pointer to keyboard - * @param all_vector vector that holds the data of the US keyboard and the currently used (underlying) keyboard - * @param keymap the currently used (underlying)keyboard Layout - * @param FDeadkeys vector of all deadkeys for the currently used (underlying)keyboard Layout + * @param kp pointer to keyboard + * @param all_vector vector that holds the data of the US keyboard and the currently used (underlying) keyboard + * @param keymap the currently used (underlying)keyboard Layout + * @param FDeadkeys vector of all deadkeys for the currently used (underlying)keyboard Layout * @param bDeadkeyConversion 1 to convert a deadkey to a character; 0 no conversion * @return true in case of success */ diff --git a/linux/mcompile/keymap/mc_import_rules.h b/linux/mcompile/keymap/mc_import_rules.h index a6c2cc014a..583890968f 100644 --- a/linux/mcompile/keymap/mc_import_rules.h +++ b/linux/mcompile/keymap/mc_import_rules.h @@ -3,7 +3,7 @@ #ifndef MC_IMPORT_RULES_H #define MC_IMPORT_RULES_H -/** @brief Base class for Deadkey*/ +/** @brief Base class for Deadkey*/ class DeadKey { private: KMX_WCHAR m_deadchar; @@ -12,8 +12,8 @@ private: public: /** - * @brief Constructor - * @param deadCharacter a deadkey + * @brief Constructor + * @param deadCharacter a deadkey */ DeadKey(KMX_WCHAR deadCharacter); @@ -24,10 +24,9 @@ public: KMX_WCHAR KMX_DeadCharacter(); /** - * @brief set Deadkey with values - * @param baseCharacter the base character - * @param combinedCharacter the combined character - * @return void + * @brief set Deadkey with values + * @param baseCharacter the base character + * @param combinedCharacter the combined character */ void KMX_AddDeadKeyRow(KMX_WCHAR baseCharacter, KMX_WCHAR combinedCharacter); @@ -48,9 +47,10 @@ public: } /** - * @brief check if character exists in DeadKey - * @param baseCharacter a character to be found - * @return true if found; false if not found + * @brief check if character exists in DeadKey + * @param baseCharacter a character to be found + * @return true if found; + * false if not found */ bool KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter); }; diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index e06e95f563..2988fe151b 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) 2004 SIL International. MIT License. + * Keyman is copyright (C) 2004 - 2024 SIL International. MIT License. * * Mnemonic layout support for Linux */ @@ -43,28 +43,28 @@ const int CODE__SIZE[] = { /** * @brief check if the file has correct version - * @param filebase containing data of the input file - * @param file_size a size + * @param filebase containing data of the input file + * @param file_size a size * @return true if successful; * false if not */ KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD file_size); /** - * @brief Fixup the keyboard by expanding pointers. On disk the pointers are stored relative to the - * beginning of the file, but we need real pointers. This method is used on 32-bit architectures. - * @param bufp pointer to buffer where data will be copied into - * @param base pointer to starting point - * @param dwFileSize size of the file + * @brief Fixup the keyboard by expanding pointers. On disk the pointers are stored relative to the + * beginning of the file, but we need real pointers. This method is used on 32-bit architectures. + * @param bufp pointer to buffer where data will be copied into + * @param base pointer to starting point + * @param dwFileSize size of the file * @return pointer to the keyboard */ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); /** - * @brief Save a Keyboard to a file - * @param fk pointer to the keyboard - * @param hOutfile pointer to the output file - * @param FSaveDebug + * @brief Save a Keyboard to a file + * @param fk pointer to the keyboard + * @param hOutfile pointer to the output file + * @param FSaveDebug * @return an Error in case of failure */ KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX_BOOL FSaveDebug) { @@ -253,9 +253,9 @@ KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, KMX_CHAR* filename) { } /** - * @brief add an offset - * @param base pointer to starting point - * @param offset a given offset + * @brief add an offset + * @param base pointer to starting point + * @param offset a given offset * @return pointer to base + offset */ PKMX_WCHAR KMX_StringOffset(PKMX_BYTE base, KMX_DWORD offset) { @@ -267,12 +267,12 @@ PKMX_WCHAR KMX_StringOffset(PKMX_BYTE base, KMX_DWORD offset) { #ifdef KMX_64BIT /** - * @brief CopyKeyboard will copy the data into bufp from x86-sized structures into - * x64-sized structures starting at `base`. After this function finishes, we still - * need to keep the original data because we don't copy the strings. The method is - * used on 64-bit architectures. - * @param bufp pointer to buffer where data is copied into - * @param base pointer to starting point + * @brief CopyKeyboard will copy the data into bufp from x86-sized structures into + * x64-sized structures starting at `base`. After this function finishes, we still + * need to keep the original data because we don't copy the strings. The method is + * used on 64-bit architectures. + * @param bufp pointer to buffer where data is copied into + * @param base pointer to starting point * @return pointer to the keyboard */ LPKMX_KEYBOARD CopyKeyboard(PKMX_BYTE bufp, PKMX_BYTE base) { @@ -550,15 +550,15 @@ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p) { } /** @brief open a file */ -FILE* Open_File(const KMX_CHAR* Filename, const KMX_CHAR* mode) { +FILE* Open_File(const KMX_CHAR* filename, const KMX_CHAR* mode) { #ifdef _MSC_VER - std::string cpath = Filename; //, cmode = mode; + std::string cpath = filename; //, cmode = mode; std::replace(cpath.begin(), cpath.end(), '/', '\\'); return fopen(cpath.c_str(), (const KMX_CHAR*)mode); #else - return fopen(Filename, mode); + return fopen(filename, mode); std::string cpath, cmode; - cpath = (const KMX_CHAR*)Filename; + cpath = (const KMX_CHAR*)filename; cmode = (const KMX_CHAR*)mode; return fopen(cpath.c_str(), cmode.c_str()); #endif diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 78baf10810..1377820fb6 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -66,36 +66,38 @@ typedef struct KMX_tagKEYBOARD { } KMX_KEYBOARD, *LPKMX_KEYBOARD; /** - * @brief load a keyboard kmx-file - * @param fileName pointer to filename of kmx-file - * @param [in,out] lpKeyboard pointer to pointer to keyboard - * @return TRUE on success; else FALSE + * @brief load a keyboard kmx-file + * @param fileName pointer to filename of kmx-file + * @param[in,out] lpKeyboard pointer to pointer to keyboard + * @return TRUE on success; + * else FALSE */ KMX_BOOL KMX_LoadKeyboard(KMX_CHAR* fileName, LPKMX_KEYBOARD* lpKeyboard); /** - * @brief save keyboard to file - * @param kbd pointer to the keyboard - * @param filename pointer to filename of a kmx-file - * @return TRUE on success; else FALSE + * @brief save keyboard to file + * @param kbd pointer to the keyboard + * @param filename pointer to filename of a kmx-file + * @return TRUE on success; + * else FALSE */ KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, KMX_CHAR* filename); /** - * @brief increment in a string - * @param p pointer to a character + * @brief increment in a string + * @param p pointer to a character * @return pointer to the incremented character */ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); /** - * @brief open a file - * @param Filename name of the file - * @param mode same as mode in fopen - * @return pointer to file. On error, returns a null pointer + * @brief xx open a file + * @param filename name of the file + * @param mode same as mode in fopen + * @return pointer to file. + * On error returns a null pointer */ -FILE* Open_File(const KMX_CHAR* Filename, const KMX_CHAR* mode); -FILE* Open_File(const KMX_WCHAR* Filename, const KMX_WCHAR* mode); +FILE* Open_File(const KMX_CHAR* filename, const KMX_CHAR* mode); #endif // _KMXFILE_H diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index f74a3ea5df..3d96741dc7 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) 2004 SIL International. MIT License. + * Keyman is copyright (C) 2004 - 2024 SIL International. MIT License. * * Mnemonic layout support for Linux * @@ -11,18 +11,37 @@ #include "mcompile.h" +/** + * @brief convert mnemonic keyboard layout to positional keyboard layout and translate keyboard + * @param kbd pointer to US keyboard + * @param bDeadkeyConversion option for converting a deadkey to a character: 1 = dk conversion; 0 = no dk conversion + * @param argc number of command line arguments + * @param argv pointer to command line arguments + * @return TRUE if conversion was successful; + * FALSE if not + */ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint argc, gchar* argv[]); -bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** keymap, std::vector* KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 +/** @brief Collect the key data, translate it to kmx and append to the existing keyboard */ +bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** keymap, std::vector* KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 +/** + * @brief start of mcompile; load, convert and save keyboard + * @param argc number of commandline arguments + * @param argv pointer to commandline arguments: executable, inputfile, outputfile + * @param argv_gdk pointer to (commandline arguments) + * @return 0 on success, + * 1 for wrong usage of calling parameters, + * 3 if unable to load keyboard + */ int run(int argc, char* argv[]); /** * @brief return an array of [usvk, ch_out] pairs: all existing combinations of a deadkey + character for the underlying keyboard - * @param dk_Table shiftstate of the deadkey - * @param deadkey deadkey character - * @param [out] outputPairs pointer to array of [usvk, ch_out] pairs - * @param keymap pointer to the currently used (underlying) keyboard Layout + * @param dk_Table shiftstate of the deadkey + * @param deadkey deadkey character + * @param[out] outputPairs pointer to array of [usvk, ch_out] pairs + * @param keymap pointer to the currently used (underlying) keyboard Layout * @return size of array of [usvk, ch_out] pairs */ int KMX_GetDeadkeys(vec_dword_2D& dk_Table, KMX_WORD deadkey, KMX_WORD* outputPairs, GdkKeymap* keymap); @@ -139,11 +158,10 @@ const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG | RALTFLAG, K_SHIFTFLAG | /** * @brief translate each key of a group: remap the content of a key (key->Key) of the US keyboard to a character (ch) - * @param key pointer to a key - * @param vk a keyvalue of the US keyboard + * @param key pointer to a key + * @param vk a keyvalue of the US keyboard * @param shift shiftstate - * @param ch character of the underlying keyboard to be remapped - * @return void + * @param ch character of the underlying keyboard to be remapped */ void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. @@ -173,10 +191,9 @@ void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { /** * @brief translate a group of a keyboard * @param group pointer to a keyboard group - * @param vk a keyvalue of the US keyboard + * @param vk a keyvalue of the US keyboard * @param shift shiftstate - * @param ch character of the underlying keyboard to be remapped - * @return void + * @param ch character of the underlying keyboard to be remapped */ void KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { for (unsigned int i = 0; i < group->cxKeyArray; i++) { @@ -186,11 +203,10 @@ void KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, UINT shift, KMX_WCHAR ch /** * @brief translate a keyboard - * @param kbd pointer to the US keyboard - * @param vk a keyvalue of the US keyboard + * @param kbd pointer to the US keyboard + * @param vk a keyvalue of the US keyboard * @param shift shiftstate - * @param ch character of the underlying keyboard to be remapped - * @return void + * @param ch character of the underlying keyboard to be remapped */ void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { for (unsigned int i = 0; i < kbd->cxGroupArray; i++) { @@ -203,7 +219,6 @@ void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHA /** * @brief check key for unconverted key rules * @param key pointer to a key - * @return void */ void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key) { if (key->ShiftFlags == 0) { @@ -216,7 +231,6 @@ void KMX_ReportUnconvertedKeyRule(LPKMX_KEY key) { /** * @brief check a group for unconverted rules * @param group pointer to a keyboard group - * @return void */ void KMX_ReportUnconvertedGroupRules(LPKMX_GROUP group) { for (unsigned int i = 0; i < group->cxKeyArray; i++) { @@ -227,7 +241,6 @@ void KMX_ReportUnconvertedGroupRules(LPKMX_GROUP group) { /** * @brief check a keyboard for unconverted rules * @param kbd pointer to the US keyboard - * @return void */ void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { for (unsigned int i = 0; i < kbd->cxGroupArray; i++) { @@ -239,12 +252,11 @@ void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { /** * @brief remap the content of a key (key->dpContext) of the US keyboard to a deadkey sequence - * @param key pointer to a key + * @param key pointer to a key * @param deadkey a deadkey to be remapped - * @param vk a keyvalue of the US keyboard - * @param shift shiftstate - * @param ch character of the underlying keyboard - * @return void + * @param vk a keyvalue of the US keyboard + * @param shift shiftstate + * @param ch character of the underlying keyboard */ void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { @@ -278,12 +290,11 @@ void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT /** * @brief translate a group - * @param group pointer to a keyboard group - * @param a deadkey to be remapped - * @param vk a keyvalue of the US keyboard - * @param shift shiftstate - * @param character of the underlying keyboard - * @return void + * @param group pointer to a keyboard group + * @param deadkey deadkey to be remapped + * @param vk a keyvalue of the US keyboard + * @param shift shiftstate + * @param ch character of the underlying keyboard */ void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { for (unsigned int i = 0; i < group->cxKeyArray; i++) { @@ -293,12 +304,11 @@ void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group, KMX_WCHAR deadkey, KMX_WORD vk /** * @brief translate a keyboard - * @param kbd pointer to the US keyboard - * @param a deadkey to be remapped - * @param vk a keyvalue of the US keyboard - * @param shift shiftstate - * @param character of the underlying keyboard - * @return void + * @param kbd pointer to the US keyboard + * @param deadkey a deadkey to be remapped + * @param vk a keyvalue of the US keyboard + * @param shift shiftstate + * @param ch character of the underlying keyboard */ void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { for (unsigned int i = 0; i < kbd->cxGroupArray; i++) { @@ -310,11 +320,10 @@ void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WOR /** * @brief add a deadkey rule - * @param kbd pointer to the US keyboard + * @param kbd pointer to the US keyboard * @param deadkey a deadkey to be added - * @param vk a keyvalue of the US keyboard - * @param shift shiftstate - * @return void + * @param vk a keyvalue of the US keyboard + * @param shift shiftstate */ void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. @@ -369,9 +378,10 @@ struct KMX_dkidmap { /** * @brief find the deadkey id for a given deadkey - * @param kbd pointer to the keyboard + * @param kbd pointer to the keyboard * @param deadkey for which an id is to be found - * @return 0 if failed; otherwise a deadkey-id + * @return 0 if failed; + * otherwise a deadkey-id */ KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { LPKMX_GROUP gp; @@ -425,14 +435,13 @@ KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { /** * @brief Lookup the deadkey table for the deadkey in the physical keyboard. Then for each character, go through and map it through - * @param kbd pointer to the keyboard - * @param vk_US virtual key of the us keyboard - * @param shift shiftstate - * @param deadkey character produced by a deadkey + * @param kbd pointer to the keyboard + * @param vk_US virtual key of the us keyboard + * @param shift shiftstate + * @param deadkey character produced by a deadkey * @param all_vector vector that holds the data of the US keyboard and the currently used (underlying) keyboard - * @param keymap pointer to the currently used (underlying) keyboard Layout - * @param dk_Table a vector of all possible deadkey combinations for all Linux keyboards - * @return void + * @param keymap pointer to the currently used (underlying) keyboard Layout + * @param dk_Table a vector of all possible deadkey combinations for all Linux keyboards */ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, UINT shift, KMX_WCHAR deadkey, vec_dword_3D& all_vector, GdkKeymap* keymap, vec_dword_2D dk_Table) { KMX_WORD deadkeys[512], *pdk; @@ -461,7 +470,8 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, UINT shift, KMX_WCHA * @brief convert a mnemonic keyboard to a positional keyboard * (i.e. setting *sp->dpString = '0' / TSS_MNEMONIC=0) * @param kbd pointer to keyboard - * @return TRUE if conversion was successful; FALSE otherwise + * @return TRUE if conversion was successful; + * FALSE otherwise */ KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { LPKMX_STORE sp; @@ -484,7 +494,7 @@ KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { return FALSE; } -/** @brief convert mnemonic keyboard layout to positional keyboard layout and translate keyboard */ +/** @brief convert mnemonic keyboard layout to positional keyboard layout and translate keyboard */ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint argc, gchar* argv[]) { KMX_WCHAR DeadKey = 0; @@ -548,11 +558,11 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg /** * @brief return an array of [usvk, ch_out] pairs: all existing combinations of a deadkey + character for the underlying keyboard - * @param deadkey deadkey character - * @param [out] OutputPairs pointer to array of [usvk, ch_out] pairs - * @param keymap pointer to the currently used (underlying) keyboard Layout - * @param dk_Table shiftstate of the deadkey - * @return size of array of [usvk, ch_out] pairs + * @param dk_Table shiftstate of the deadkey + * @param deadkey deadkey character + * @param[out] outputPairs pointer to array of [usvk, ch_out] pairs + * @param keymap pointer to the currently used (underlying) keyboard Layout + * @return size of array of [usvk, ch_out] pairs */ int KMX_GetDeadkeys(vec_dword_2D& dk_Table, KMX_WORD deadkey, KMX_WORD* outputPairs, GdkKeymap* keymap) { KMX_WORD* p = outputPairs; @@ -574,7 +584,7 @@ int KMX_GetDeadkeys(vec_dword_2D& dk_Table, KMX_WORD deadkey, KMX_WORD* outputPa return (p - outputPairs); } -/** @brief print (error) messages */ +/** @brief print (error) messages */ void KMX_LogError(const wchar_t* fmt, ...) { WCHAR fmtbuf[256]; const wchar_t* end = L"\0"; diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 03a03c46be..5436735ba7 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -35,7 +35,6 @@ extern std::vector KMX_FDeadkeys; // I4353 /** * @brief print (error) messages * @param fmt text to print - * @return void */ void KMX_LogError(const wchar_t* fmt, ...); diff --git a/linux/mcompile/keymap/u16.cpp b/linux/mcompile/keymap/u16.cpp index cc77596956..0170b5dfc5 100644 --- a/linux/mcompile/keymap/u16.cpp +++ b/linux/mcompile/keymap/u16.cpp @@ -1,5 +1,5 @@ /* - * Keyman is copyright 2024 (C) SIL International. MIT License. + * Keyman is copyright 2004 - 2024 (C) SIL International. MIT License. * * Functions for u16string */ @@ -12,8 +12,8 @@ // string <- wstring /** @brief Obtain a std::string from a std::wstring */ -std::string string_from_wstring(std::wstring const str) { - return convert((const std::wstring)str); +std::string string_from_wstring(std::wstring const wstr) { + return convert((const std::wstring)wstr); } // wstring <- string @@ -23,35 +23,31 @@ std::wstring wstring_from_string(std::string const str) { } // u16string <- string -/** @brief Obtain a std::string from a std::wstring */ +/** @brief Obtain a std::16string from a std::string */ std::u16string u16string_from_string(std::string const str) { return convert((const std::string)str); } // string <- u16string -/** @brief Obtain a std::string from a std::u16string */ -std::string string_from_u16string(std::u16string const str) { - return convert((const std::u16string)str); +/** @brief Obtain a std::string from a std::u16string */ +std::string string_from_u16string(std::u16string const str16) { + return convert((const std::u16string)str16); } // wstring <- u16string -/** @brief Obtain a std::wstring from a std::u16string */ -std::wstring wstring_from_u16string(std::u16string const str) { - std::string s = convert((const std::u16string)str); - std::wstring ws = convert((const std::string)s); - return ws; +/** @brief Obtain a std::wstring from a std::u16string */ +std::wstring wstring_from_u16string(std::u16string const str16) { + return convert((const std::u16string)str16); } // u16string <- wstring -/** @brief Obtain a std::u16string from a std::wstring */ -std::u16string u16string_from_wstring(std::wstring const str) { - std::string s = convert((const std::wstring)str); - std::u16string utf16 = convert((const std::string)s); - return utf16; +/** @brief Obtain a std::u16string from a std::wstring */ +std::u16string u16string_from_wstring(std::wstring const wstr) { + return convert((const std::wstring)wstr);; } - // UTF16 (=const wchar_t*) -> -> std::string -> std::u16string -> UTF16 ( = char16_t*) -/** @brief @brief Convert pointer to wchar_t to u16string and copy sz elements into dst */ +// UTF16 (=const wchar_t*) -> -> std::string -> std::u16string -> UTF16 ( = char16_t*) +/** @brief Convert pointer to wchar_t to u16string and copy sz elements into dst */ void u16sprintf(KMX_WCHAR* dst, const size_t sz, const wchar_t* fmt, ...) { wchar_t* wbuf = new wchar_t[sz]; va_list args; @@ -64,7 +60,7 @@ void u16sprintf(KMX_WCHAR* dst, const size_t sz, const wchar_t* fmt, ...) { delete[] wbuf; } -/** @brief @brief Convert u16string to long integer */ +/** @brief Convert u16string to long integer */ long int u16tol(const KMX_WCHAR* str, KMX_WCHAR** endptr, int base) { auto s = string_from_u16string(str); char* t; @@ -73,7 +69,7 @@ long int u16tol(const KMX_WCHAR* str, KMX_WCHAR** endptr, int base) { return result; } -/** @brief Append n characters from u16string */ +/** @brief Append max characters from u16string */ const KMX_WCHAR* u16ncat(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max) { KMX_WCHAR* o = dst; dst = (KMX_WCHAR*)u16chr(dst, 0); @@ -87,33 +83,31 @@ const KMX_WCHAR* u16ncat(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max) { return o; } -/** @brief Append a '/' or '\\' to an array of char16_t */ -const KMX_WCHAR* u16rchr_slash(KMX_WCHAR const* Name) +/** @brief find last '/' or '\\' in an array of char16_t */ +const KMX_WCHAR* u16rchr_slash(KMX_WCHAR const* name) { const KMX_WCHAR* cp = NULL; - cp = u16rchr(Name, '\\'); + cp = u16rchr(name, '\\'); if (cp == NULL) - cp = u16rchr(Name, '/'); + cp = u16rchr(name, '/'); return cp; } -/** @brief Append a '/' or '\\' to an array of char */ -KMX_CHAR* strrchr_slash(KMX_CHAR* Name) +/** @brief find last '/' or '\\' in an array of char */ +KMX_CHAR* strrchr_slash(KMX_CHAR* name) { KMX_CHAR* cp = NULL; - cp = strrchr(Name, '\\'); + cp = strrchr(name, '\\'); if (cp == NULL) - cp = strrchr(Name, '/'); + cp = strrchr(name, '/'); return cp; } -/** @brief Locate last occurrence of character in u16string */ +/** @brief Locate last occurrence of character in u16string */ const KMX_WCHAR* u16rchr(const KMX_WCHAR* p, KMX_WCHAR ch) { - const KMX_WCHAR* p_end = p + u16len(p) - 1; + const KMX_WCHAR* p_end = p + u16len(p); - if (ch == '\0') - return p_end + 1; - while (p_end >= p) { + while (p_end > p) { if (*p_end == ch) return p_end; p_end--; @@ -121,7 +115,7 @@ const KMX_WCHAR* u16rchr(const KMX_WCHAR* p, KMX_WCHAR ch) { return NULL; } -/** @brief @brief Locate first occurrence of character in u16string */ +/** @brief Locate first occurrence of character in u16string */ const KMX_WCHAR* u16chr(const KMX_WCHAR* p, KMX_WCHAR ch) { while (*p) { if (*p == ch) return p; @@ -130,7 +124,7 @@ const KMX_WCHAR* u16chr(const KMX_WCHAR* p, KMX_WCHAR ch) { return ch == 0 ? p : NULL; } -/** @brief @brief Copy the u16string pointed to by source into the array pointed to by destination */ +/** @brief Copy the u16string pointed to by src into the array pointed to by dst */ const KMX_WCHAR* u16cpy(KMX_WCHAR* dst, const KMX_WCHAR* src) { KMX_WCHAR* o = dst; while (*src) { @@ -140,7 +134,7 @@ const KMX_WCHAR* u16cpy(KMX_WCHAR* dst, const KMX_WCHAR* src) { return o; } -/** @brief Copy n characters of the u16string pointed to by source into the array pointed to by destination */ +/** @brief Copy max characters of the u16string pointed to by src into the array pointed to by dst */ const KMX_WCHAR* u16ncpy(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max) { KMX_WCHAR* o = dst; while (*src && max > 0) { @@ -153,7 +147,7 @@ const KMX_WCHAR* u16ncpy(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max) { return o; } -/** @brief @brief Return the length of the u16string str */ +/** @brief Return the length of the u16string str */ size_t u16len(const KMX_WCHAR* p) { int i = 0; while (*p) { @@ -163,7 +157,7 @@ size_t u16len(const KMX_WCHAR* p) { return i; } -/** @brief @brief Compare two u16strings */ +/** @brief Compare two u16strings */ int u16cmp(const KMX_WCHAR* p, const KMX_WCHAR* q) { while (*p && *q) { if (*p != *q) return *p - *q; @@ -173,7 +167,7 @@ int u16cmp(const KMX_WCHAR* p, const KMX_WCHAR* q) { return *p - *q; } -/** @brief @brief Case sensitive comparison of up to count characters in two strings */ +/** @brief Case insensitive comparison of up to count characters in two strings */ int u16nicmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count) { while (*p && *q && count) { if (toupper(*p) != toupper(*q)) return *p - *q; @@ -186,7 +180,7 @@ int u16nicmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count) { return 0; } -/** @brief @brief Case sensitive comparison of two strings */ +/** @brief Case insensitive comparison of two strings */ int u16icmp(const KMX_WCHAR* p, const KMX_WCHAR* q) { while (*p && *q) { if (toupper(*p) != toupper(*q)) return *p - *q; diff --git a/linux/mcompile/keymap/u16.h b/linux/mcompile/keymap/u16.h index 8a4f615e5d..5cf642515b 100644 --- a/linux/mcompile/keymap/u16.h +++ b/linux/mcompile/keymap/u16.h @@ -13,10 +13,10 @@ /** * @brief Obtain a std::string from a std::wstring - * @param str the std::wstring to be converted + * @param wstr the std::wstring to be converted * @return a std::string */ -std::string string_from_wstring(std::wstring const str); +std::string string_from_wstring(std::wstring const wstr); /** * @brief Obtain a std::wstring from a std::string @@ -26,78 +26,77 @@ std::string string_from_wstring(std::wstring const str); std::wstring wstring_from_string(std::string const str); /** - * @brief Obtain a std::string from a std::wstring - * @param str the std::wstring to be converted - * @return a std::string + * @brief Obtain a std::u16string from a std::string + * @param str the std::string to be converted + * @return a std::u16string */ std::u16string u16string_from_string(std::string const str); /** * @brief Obtain a std::string from a std::u16string - * @param str the std::string to be converted - * @return a std::u16string + * @param str16 the std::u16string to be converted + * @return a std::string */ -std::string string_from_u16string(std::u16string const str); +std::string string_from_u16string(std::u16string const str16); /** * @brief Obtain a std::wstring from a std::u16string - * @param str the std::u16string to be converted + * @param str16 the std::u16string to be converted * @return a std::wstring */ -std::wstring wstring_from_u16string(std::u16string const str); +std::wstring wstring_from_u16string(std::u16string const str16); /** * @brief Obtain a std::u16string from a std::wstring - * @param str the std::wstring to be converted + * @param wstr the std::wstring to be converted * @return a std::u16string */ -std::u16string u16string_from_wstring(std::wstring const str); +std::u16string u16string_from_wstring(std::wstring const wstr); /** * @brief Convert pointer to wchar_t to pointer to char16_t and copy sz elements into dst * @param dst destination - * @param sz nr of characters to be copied + * @param sz nr of characters to be copied * @param fmt source to convert and copy - * @return void */ void u16sprintf(KMX_WCHAR* dst, const size_t sz, const wchar_t* fmt, ...); /** * @brief Convert u16string to long integer - * @param str u16string beginning with the representation of an integral number. + * @param str u16string beginning with the representation of an integral number. * @param endptr Reference to the next character in str - * @param base Numerical base (radix) that determines the valid characters and their interpretation - * @return a std::string + * @param base Numerical base (radix) that determines the valid characters and their interpretation + * @return a long */ long int u16tol(const KMX_WCHAR* str, KMX_WCHAR** endptr, int base); /** - * @brief Append n characters from u16string + * @brief Append max characters from u16string * @param dst Pointer to the destination array * @param src u16string to be appended * @param max Maximum number of characters to be appended. - * @return Pointer to the destination array + * @return Pointer to dst */ const KMX_WCHAR* u16ncat(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max); /** - * @brief Append a '/' or '\\' to an array of char16_t - * @param Name Pointer to the source - * @return Pointer to the source with slash/backslash added + * @brief Find last '/' or '\\' in an array of char16_t + * @param name Pointer to the source + * @return Pointer to the last slash/backslash */ -const KMX_WCHAR* u16rchr_slash(KMX_WCHAR const* Name); +const KMX_WCHAR* u16rchr_slash(KMX_WCHAR const* name); /** - * @brief Append a '/' or '\\' to an array of char - * @param Name Pointer to the source - * @return Pointer to the source with slash/backslash added + * @brief Find last '/' or '\\' in an array of char + * @param name Pointer to the source + * @return Pointer to the last slash/backslash */ -KMX_CHAR* strrchr_slash(KMX_CHAR* Name); +KMX_CHAR* strrchr_slash(KMX_CHAR* name); /** * @brief Locate last occurrence of character in u16string - * @param p Pointer to the source + * @param p Pointer to the source * @param ch The character to be found * @return A pointer to the last occurrence of character in u16str */ @@ -105,26 +104,26 @@ const KMX_WCHAR* u16rchr(const KMX_WCHAR* p, KMX_WCHAR ch); /** * @brief Locate first occurrence of character in u16string - * @param p Pointer to the source + * @param p Pointer to the source * @param ch The character to be found * @return A pointer to the first occurrence of character in u16str */ const KMX_WCHAR* u16chr(const KMX_WCHAR* p, KMX_WCHAR ch); /** - * @brief Copy the u16string pointed by source into the array pointed by destination + * @brief Copy the u16string pointed by scr into the array pointed by dst * @param dst Pointer to the destination * @param src Pointer to the source to be copied - * @return Pointer to the destination + * @return Pointer to dst */ - const KMX_WCHAR* u16cpy(KMX_WCHAR* dst, const KMX_WCHAR* src); + /** - * @brief Copy n characters of the u16string pointed by source into the array pointed by destination + * @brief Copy max characters of the u16string pointed by src into the array pointed by dst * @param dst Pointer to the destination * @param src Pointer to the source to be copied * @param max Maximum number of characters to be copied - * @return Pointer to the destination + * @return Pointer to dst */ const KMX_WCHAR* u16ncpy(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max); @@ -139,61 +138,61 @@ size_t u16len(const KMX_WCHAR* p); * @brief Compare two u16strings * @param p Pointer one u16string * @param q Pointer another u16string - * @return 0 if strings are eqaual + * @return 0 if strings are equal * ! = 0 if unequal */ int u16cmp(const KMX_WCHAR* p, const KMX_WCHAR* q); /** - * @brief Case sensitive comparison of up to count characters in two strings - * @param p Pointer one u16string - * @param q Pointer another u16string + * @brief Case insensitive comparison of up to count characters in two strings + * @param p Pointer one u16string + * @param q Pointer another u16string * @param count Maximum number of characters to compare - * @return 0 if strings are eqaual + * @return 0 if strings are equal * ! = 0 if unequal */ int u16nicmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count); /** - * @brief Case sensitive comparison of two strings + * @brief Case insensitive comparison of two strings * @param p Pointer one u16string * @param q Pointer another u16string - * @return 0 if strings are eqaual + * @return 0 if strings are equal * ! = 0 if unequal */ int u16icmp(const KMX_WCHAR* p, const KMX_WCHAR* q); /** - * @brief Comparison of up to count characters in two strings - * @param p Pointer one u16string - * @param q Pointer another u16string + * @brief Comparison of up to count characters in two strings + * @param p Pointer one u16string + * @param q Pointer another u16string * @param count Maximum number of characters to compare - * @return 0 if strings are eqaual + * @return 0 if strings are equal * ! = 0 if unequal */ int u16ncmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count); /** - * @brief Split u16string into tokens - * @param p Pointer to u16string to truncate. - * @param ch the delimiter character - * @param ctx the string until and without the delimiter - * @return Pointer to the destination or NULL + * @brief Split u16string into tokens + * @param p Pointer to u16string to parse. + * @param ch the delimiter character + * @param ctx the remaining string after the first delimiter + * @return PPointer to the first token in p */ KMX_WCHAR* u16tok(KMX_WCHAR* p, const KMX_WCHAR ch, KMX_WCHAR** ctx); /** - * @brief Split u16string into tokens - * @param p Pointer to u16string to truncate. - * @param delim the delimiter character - * @param ctx the string until and without the delimiter - * @return Pointer to the destination or NULL + * @brief Split u16string into tokens + * @param p Pointer to u16string to parse. + * @param delim an array of delimiter characters + * @param ctx the remaining string after the first delimiter + * @return Pointer to the first token in p */ KMX_WCHAR* u16tok(KMX_WCHAR* p, const KMX_WCHAR* delim, KMX_WCHAR** ctx); /** - * @brief Convert a u16string to a double - * @param str Pointer to u16string + * @brief Convert a u16string to a double + * @param tr Pointer to u16string * @return double value equivalent to the string */ double u16tof(KMX_WCHAR* str); From 2b21d734fc49d517def3f009af05a1caad46997c Mon Sep 17 00:00:00 2001 From: SabineSIL <86713187+SabineSIL@users.noreply.github.com> Date: Thu, 1 Aug 2024 16:10:52 +0200 Subject: [PATCH 298/327] Apply suggestions from code review Co-authored-by: Eberhard Beilharz --- linux/mcompile/keymap/mcompile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 3d96741dc7..8629602f48 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -59,7 +59,7 @@ std::vector KMX_FDeadkeys; // I4353 #if defined(_WIN32) || defined(_WIN64) int wmain(int argc, wchar_t* argv[]) { /** - * TODO for cros platform use: if we want to use wmain instead of main: + * TODO for cross platform use: if we want to use wmain instead of main: * inside wmain convert wchar_t* argv[] to char* argv_ch[] * to be able to use run(int argc, char* argv[]) */ From e64c1ff4410a1df50a6597838d8e3d3fdaecabf8 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 1 Aug 2024 16:21:29 +0200 Subject: [PATCH 299/327] feat(linux): comment changes --- linux/mcompile/keymap/u16.h | 113 ++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 57 deletions(-) diff --git a/linux/mcompile/keymap/u16.h b/linux/mcompile/keymap/u16.h index 0e441a9f4a..bbb80ecd88 100644 --- a/linux/mcompile/keymap/u16.h +++ b/linux/mcompile/keymap/u16.h @@ -10,13 +10,12 @@ #include #include - /** * @brief Obtain a std::string from a std::wstring - * @param str the std::wstring to be converted + * @param wstr the std::wstring to be converted * @return a std::string */ -std::string string_from_wstring(std::wstring const str); +std::string string_from_wstring(std::wstring const wstr); /** * @brief Obtain a std::wstring from a std::string @@ -26,76 +25,76 @@ std::string string_from_wstring(std::wstring const str); std::wstring wstring_from_string(std::string const str); /** - * @brief Obtain a std::string from a std::wstring - * @param str the std::wstring to be converted - * @return a std::string + * @brief Obtain a std::u16string from a std::string + * @param str the std::string to be converted + * @return a std::u16string */ std::u16string u16string_from_string(std::string const str); /** * @brief Obtain a std::string from a std::u16string - * @param str the std::string to be converted - * @return a std::u16string + * @param str16 the std::u16string to be converted + * @return a std::string */ -std::string string_from_u16string(std::u16string const str); +std::string string_from_u16string(std::u16string const str16); /** * @brief Obtain a std::wstring from a std::u16string - * @param str the std::u16string to be converted + * @param str16 the std::u16string to be converted * @return a std::wstring */ -std::wstring wstring_from_u16string(std::u16string const str); +std::wstring wstring_from_u16string(std::u16string const str16); /** * @brief Obtain a std::u16string from a std::wstring - * @param str the std::wstring to be converted + * @param wstr the std::wstring to be converted * @return a std::u16string */ -std::u16string u16string_from_wstring(std::wstring const str); +std::u16string u16string_from_wstring(std::wstring const wstr); /** * @brief Convert pointer to wchar_t to pointer to char16_t and copy sz elements into dst * @param dst destination - * @param sz nr of characters to be copied + * @param sz nr of characters to be copied * @param fmt source to convert and copy - * @return void */ void u16sprintf(KMX_WCHAR* dst, const size_t sz, const wchar_t* fmt, ...); /** * @brief Convert u16string to long integer - * @param str u16string beginning with the representation of an integral number. + * @param str u16string beginning with the representation of an integral number. * @param endptr Reference to the next character in str - * @param base Numerical base (radix) that determines the valid characters and their interpretation - * @return a std::string + * @param base Numerical base (radix) that determines the valid characters and their interpretation + * @return a long */ long int u16tol(const KMX_WCHAR* str, KMX_WCHAR** endptr, int base); /** - * @brief Append n characters from u16string + * @brief Append max characters from u16string * @param dst Pointer to the destination array * @param src u16string to be appended * @param max Maximum number of characters to be appended. - * @return Pointer to the destination array + * @return Pointer to dst */ const KMX_WCHAR* u16ncat(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max); /** - * @brief Append a '/' or '\\' to an array of char16_t - * @param Name Pointer to the source - * @return Pointer to the source with slash/backslash added + * @brief Find last '/' or '\\' in an array of char16_t + * @param name Pointer to the source + * @return Pointer to the last slash/backslash */ -const KMX_WCHAR* u16rchr_slash(KMX_WCHAR const* Name); +const KMX_WCHAR* u16rchr_slash(KMX_WCHAR const* name); /** - * @brief Append a '/' or '\\' to an array of char - * @param Name Pointer to the source - * @return Pointer to the source with slash/backslash added + * @brief Find last '/' or '\\' in an array of char + * @param name Pointer to the source + * @return Pointer to the last slash/backslash */ -KMX_CHAR* strrchr_slash(KMX_CHAR* Name); +KMX_CHAR* strrchr_slash(KMX_CHAR* name); + /** * @brief Locate last occurrence of character in u16string - * @param p Pointer to the source + * @param p Pointer to the source * @param ch The character to be found * @return A pointer to the last occurrence of character in u16str */ @@ -103,26 +102,26 @@ const KMX_WCHAR* u16rchr(const KMX_WCHAR* p, KMX_WCHAR ch); /** * @brief Locate first occurrence of character in u16string - * @param p Pointer to the source + * @param p Pointer to the source * @param ch The character to be found * @return A pointer to the first occurrence of character in u16str */ const KMX_WCHAR* u16chr(const KMX_WCHAR* p, KMX_WCHAR ch); /** - * @brief Copy the u16string pointed by source into the array pointed by destination + * @brief Copy the u16string pointed by scr into the array pointed by dst * @param dst Pointer to the destination * @param src Pointer to the source to be copied - * @return Pointer to the destination + * @return Pointer to dst */ - const KMX_WCHAR* u16cpy(KMX_WCHAR* dst, const KMX_WCHAR* src); + /** - * @brief Copy n characters of the u16string pointed by source into the array pointed by destination + * @brief Copy max characters of the u16string pointed by src into the array pointed by dst * @param dst Pointer to the destination * @param src Pointer to the source to be copied * @param max Maximum number of characters to be copied - * @return Pointer to the destination + * @return Pointer to dst */ const KMX_WCHAR* u16ncpy(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max); @@ -137,60 +136,60 @@ size_t u16len(const KMX_WCHAR* p); * @brief Compare two u16strings * @param p Pointer one u16string * @param q Pointer another u16string - * @return 0 if strings are eqaual + * @return 0 if strings are equal * ! = 0 if unequal */ int u16cmp(const KMX_WCHAR* p, const KMX_WCHAR* q); /** - * @brief Case sensitive comparison of up to count characters in two strings - * @param p Pointer one u16string - * @param q Pointer another u16string + * @brief Case insensitive comparison of up to count characters in two strings + * @param p Pointer one u16string + * @param q Pointer another u16string * @param count Maximum number of characters to compare - * @return 0 if strings are eqaual + * @return 0 if strings are equal * ! = 0 if unequal */ int u16nicmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count); /** - * @brief Case sensitive comparison of two strings + * @brief Case insensitive comparison of two strings * @param p Pointer one u16string * @param q Pointer another u16string - * @return 0 if strings are eqaual + * @return 0 if strings are equal * ! = 0 if unequal */ int u16icmp(const KMX_WCHAR* p, const KMX_WCHAR* q); /** - * @brief Comparison of up to count characters in two strings - * @param p Pointer one u16string - * @param q Pointer another u16string + * @brief Comparison of up to count characters in two strings + * @param p Pointer one u16string + * @param q Pointer another u16string * @param count Maximum number of characters to compare - * @return 0 if strings are eqaual + * @return 0 if strings are equal * ! = 0 if unequal */ int u16ncmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count); /** - * @brief Split u16string into tokens - * @param p Pointer to u16string to truncate. - * @param ch the delimiter character - * @param ctx the string until and without the delimiter - * @return Pointer to the destination or NULL + * @brief Split u16string into tokens + * @param p Pointer to u16string to parse. + * @param ch the delimiter character + * @param ctx the remaining string after the first delimiter + * @return PPointer to the first token in p */ KMX_WCHAR* u16tok(KMX_WCHAR* p, const KMX_WCHAR ch, KMX_WCHAR** ctx); /** - * @brief Split u16string into tokens - * @param p Pointer to u16string to truncate. - * @param delim the delimiter character - * @param ctx the string until and without the delimiter - * @return Pointer to the destination or NULL + * @brief Split u16string into tokens + * @param p Pointer to u16string to parse. + * @param delim an array of delimiter characters + * @param ctx the remaining string after the first delimiter + * @return Pointer to the first token in p */ KMX_WCHAR* u16tok(KMX_WCHAR* p, const KMX_WCHAR* delim, KMX_WCHAR** ctx); /** - * @brief Convert a u16string to a double + * @brief Convert a u16string to a double * @param str Pointer to u16string * @return double value equivalent to the string */ From 038896781307ef1d574e42e5d68f75041dcca88a Mon Sep 17 00:00:00 2001 From: Sabine Date: Fri, 2 Aug 2024 12:20:00 +0200 Subject: [PATCH 300/327] feat(Linux): more comments PR 12065 --- linux/mcompile/keymap/deadkey.h | 2 +- linux/mcompile/keymap/keymap.h | 9 ++++----- linux/mcompile/keymap/u16.cpp | 1 - linux/mcompile/keymap/u16.h | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index 6e7bd7be58..913d81d456 100644 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -37,7 +37,7 @@ bool found_dk_inVector(KMX_WCHAR dk, std::vector& dkVec); * @return true if successful; * false if not */ -bool query_dk_combinations_for_specific_dk(vec_dword_2D& dk_ComposeTable, KMX_DWORD dk, vec_dword_2D& dk_SingleTable); +bool query_dk_combinations_for_specific_dk(vec_dword_2D& r_dk_ComposeTable, KMX_DWORD dk, vec_dword_2D& dk_SingleTable); /** * @brief convert a character to the upper-case equivalent and find the corresponding shiftstate diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 60655c80a8..3bbf3e86e8 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -150,8 +150,7 @@ int get_keycode_from_keyname(std::string key_name); * @brief process each element of a 1D-Vector, split and write to a 3D-Vector * @param[in,out] all_US a 3D_Vector containing all keyvalues of the US keyboard * @param completeList a 1D-Vector containing all relevant entries copied from the symbol file us basic - * @return 0 on success; - * if entry can be split + * @return 0 on success if entry can be split */ int split_US_To_3D_Vector(vec_dword_3D& all_US, vec_string_1D completeList); @@ -175,7 +174,7 @@ int append_underlying_ToVector(vec_dword_3D& all_vector, GdkKeymap* keymap); /** * @brief create a pointer to pointer of the current keymap for later use - * @param keymap pointer to pointer to currently used (underlying) keyborad layout + * @param keymap pointer to pointer to currently used (underlying) keyboard layout * @param argc count of arguments * @param argv array of arguments * @return FALSE on success; @@ -661,7 +660,7 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyValUS(vec_dword_3D& all_vector, KMX_D KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap* keymap, vec_dword_3D& all_vector, KMX_DWORD kc_us, ShiftState ss, int caps); /** - * return the keycode of the currently used (underlying) keyboard for a given virtual key of the US keyboard + * @brief return the keycode of the currently used (underlying) keyboard for a given virtual key of the US keyboard * "Where on an underlying keyboard do we find a character of a US keyboard?" * @param virtualKeyUS a virtual key of the US keyboard * @return the keycode of the currently used (underlying) keyboard @@ -669,7 +668,7 @@ KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap* keymap, vec_dword_ KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD virtualKeyUS); /** - * return a virtual key of the US keyboard for a given keycode of the currently used (underlying) keyboard + * @brief return a virtual key of the US keyboard for a given keycode of the currently used (underlying) keyboard * "Which key of a underlying keyboard will be mapped to a virtual key of a US keyboard?" * @param keycode a keycode of the currently used (underlying) keyboard * @return the virtual key of the US keyboard or diff --git a/linux/mcompile/keymap/u16.cpp b/linux/mcompile/keymap/u16.cpp index 24e01f47f6..d399dffd13 100644 --- a/linux/mcompile/keymap/u16.cpp +++ b/linux/mcompile/keymap/u16.cpp @@ -48,7 +48,6 @@ std::u16string u16string_from_wstring(std::wstring const wstr) { // UTF16 (=const wchar_t*) -> -> std::string -> std::u16string -> UTF16 ( = char16_t*) /** @brief Convert pointer to wchar_t to u16string and copy sz elements into dst */ - void u16sprintf(KMX_WCHAR* dst, const size_t sz, const wchar_t* fmt, ...) { wchar_t* wbuf = new wchar_t[sz]; va_list args; diff --git a/linux/mcompile/keymap/u16.h b/linux/mcompile/keymap/u16.h index bbb80ecd88..2413c30715 100644 --- a/linux/mcompile/keymap/u16.h +++ b/linux/mcompile/keymap/u16.h @@ -175,7 +175,7 @@ int u16ncmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count); * @param p Pointer to u16string to parse. * @param ch the delimiter character * @param ctx the remaining string after the first delimiter - * @return PPointer to the first token in p + * @return Pointer to the first token in p */ KMX_WCHAR* u16tok(KMX_WCHAR* p, const KMX_WCHAR ch, KMX_WCHAR** ctx); From 690caec12bd181ce4046bc8f270b9a0ed887383f Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 6 Aug 2024 09:26:00 +0200 Subject: [PATCH 301/327] feat(Linux): swap detailed comments <-> one-line comments --- linux/mcompile/keymap/deadkey.cpp | 56 +++++- linux/mcompile/keymap/deadkey.h | 56 +----- linux/mcompile/keymap/keymap.cpp | 200 +++++++++++++++++++--- linux/mcompile/keymap/keymap.h | 198 +++------------------ linux/mcompile/keymap/mc_import_rules.cpp | 57 ++++-- linux/mcompile/keymap/mc_import_rules.h | 23 +-- linux/mcompile/keymap/mc_kmxfile.cpp | 56 +++--- linux/mcompile/keymap/mc_kmxfile.h | 31 +--- linux/mcompile/keymap/mcompile.cpp | 54 +++--- linux/mcompile/keymap/mcompile.h | 5 +- linux/mcompile/keymap/u16.cpp | 168 ++++++++++++++---- linux/mcompile/keymap/u16.h | 164 +++--------------- 12 files changed, 535 insertions(+), 533 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 1452d643ab..325082026b 100644 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -7,7 +7,10 @@ #include "keymap.h" #include "deadkey.h" -/** @brief create a Vector of DeadKey containing all combinations of deadkey + character for ALL possible Linux keyboards */ +/** + * @brief create a Vector of DeadKey containing all combinations of deadkey + character for ALL possible Linux keyboards + * @return vector of Deadkey* that holds all combinations of deadkey + character +*/ std::vector create_deadkeys_by_basechar() { std::vector alDead; vec_dword_2D dk_ComposeTable; @@ -25,7 +28,12 @@ std::vector create_deadkeys_by_basechar() { return alDead; } -/** @brief filter entries for the currently used Linux Keyboard out of a vector of all existing deadKey combinations */ +/** + * @brief filter entries for the currently used Linux Keyboard out of a vector of all existing deadKey combinations + * @param dk the deadkey for which all combinations will be found + * @param[in,out] dkVec combinations of deadkey + character for the currently used Linux Keyboard + * @param r_All_Vec all existing combinations of deadkey + character for ALL possible Linux keyboards +*/ void refine_alDead(KMX_WCHAR dk, std::vector& dkVec, std::vector& r_All_Vec) { if (dk == 0) return; @@ -40,7 +48,13 @@ void refine_alDead(KMX_WCHAR dk, std::vector& dkVec, std::vector& dkVec) { for (int i = 0; i < dkVec.size(); i++) { if (dk == dkVec[i]->KMX_GetDeadCharacter()) @@ -49,7 +63,14 @@ bool found_dk_inVector(KMX_WCHAR dk, std::vector& dkVec) { return false; } -/** @brief find all deadkey combinations for a certain deadkey in a vector of all deadkey combinations */ +/** + * @brief find all deadkey combinations for a certain deadkey in a vector of all deadkey combinations + * @param r_dk_ComposeTable vector containing all possible deadkey combinations + * @param dk deadkey of interest + * @param[in,out] dk_SingleTable vector containing all dk-character combinations for a specific deadkey dk + * @return true if successful; + * false if not +*/ bool query_dk_combinations_for_specific_dk(vec_dword_2D& r_dk_ComposeTable, KMX_DWORD dk, vec_dword_2D& dk_SingleTable) { vec_dword_1D row; @@ -69,7 +90,14 @@ bool query_dk_combinations_for_specific_dk(vec_dword_2D& r_dk_ComposeTable, KMX_ return false; } -/** @brief convert a character to the upper-case equivalent and find the corresponding shiftstate */ +/** + * @brief convert a character to the upper-case equivalent and find the corresponding shiftstate + * of the entered keyval: a(97) -> A(65) + Base A(65) -> A(65) + Shift + * @param kval keyval that might be changed + * @param[in,out] shift the shiftstate of the entered keyval + * @param keymap a pointer to the currently used (underlying) keyboard layout + * @return the upper case equivalent of the keyval +*/ KMX_DWORD KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD& shift, GdkKeymap* keymap) { guint keyval = (guint)kVal; GdkKeymapKey* keys; @@ -88,7 +116,14 @@ KMX_DWORD KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD& shift, GdkKey return capitalKeyval; } -/** @brief append a 1D-vector containing name, base character and unicode_value to a 2D-Vector */ +/** + * @brief append a 1D-vector containing name, base character and unicode_value to a 2D-Vector + * holding all possible combinations of deadkey + character for all Linux keyboards + * @param[in,out] dk_ComposeTable 2D-Vector holding all possible combinations of deadkey + character + * @param diacritic_name the name of a diacritic + * @param base_char base character + * @param unicode_value Unicode-value of the combined character +*/ void add_deadkey_combination(vec_dword_2D& dk_ComposeTable, std::string diacritic_name, std::string base_char, KMX_DWORD unicode_value) { vec_dword_1D line; line.push_back(convertNamesTo_DWORD_Value(diacritic_name)); @@ -97,7 +132,14 @@ void add_deadkey_combination(vec_dword_2D& dk_ComposeTable, std::string diacriti dk_ComposeTable.push_back(line); } -/** @brief create a 2D-Vector containing all possible combinations of deadkey + character for all Linux keyboards */ +/** + * @brief create a 2D-Vector containing all possible combinations of deadkey + character for all Linux keyboards + * the values are taken from from: https://help.ubuntu.com/community/GtkDeadKeyTable#Accents + * dk_ComposeTable[i][0] : diacritic_name (e.g. dead_circumflex) + * dk_ComposeTable[i][1] : base_char (e.g. a) + * dk_ComposeTable[i][2] : unicode_value-Value (e.g. 0x00E2) + * @param[in,out] dk_ComposeTable +*/ void create_DKTable(vec_dword_2D& dk_ComposeTable) { add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "a", 0x00E2); // small A with circumflex add_deadkey_combination(dk_ComposeTable, "dead_circumflex", "A", 0x00C2); // capital A with circumflex diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index 913d81d456..5c52768ecf 100644 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -6,67 +6,25 @@ #include "mc_import_rules.h" #include -/** - * @brief create a Vector of DeadKey containing all combinations of deadkey + character for ALL possible Linux keyboards - * @return vector of Deadkey* that holds all combinations of deadkey + character - */ +/** @brief create a Vector of DeadKey containing all combinations of deadkey + character for ALL possible Linux keyboards */ std::vector create_deadkeys_by_basechar(); -/** - * @brief filter entries for the currently used Linux Keyboard out of a vector of all existing deadKey combinations - * @param dk the deadkey for which all combinations will be found - * @param[in,out] dkVec combinations of deadkey + character for the currently used Linux Keyboard - * @param r_All_Vec all existing combinations of deadkey + character for ALL possible Linux keyboards - */ +/** @brief filter entries for the currently used Linux Keyboard out of a vector of all existing deadKey combinations */ void refine_alDead(KMX_WCHAR dk, std::vector& dkVec, std::vector& r_All_Vec); -/** - * @brief check whether a deadkey already exists in the deadkey vector - * @param dk the deadkey to be found - * @param dkVec vector containing combinations of deadkey + character - * @return true if deadkey alredy exists; - * false if not - */ +/** @brief check whether a deadkey already exists in the deadkey vector */ bool found_dk_inVector(KMX_WCHAR dk, std::vector& dkVec); -/** - * @brief find all deadkey combinations for a certain deadkey in a vector of all deadkey combinations - * @param r_dk_ComposeTable vector containing all possible deadkey combinations - * @param dk deadkey of interest - * @param[in,out] dk_SingleTable vector containing all dk-character combinations for a specific deadkey dk - * @return true if successful; - * false if not - */ +/** @brief find all deadkey combinations for a certain deadkey in a vector of all deadkey combinations */ bool query_dk_combinations_for_specific_dk(vec_dword_2D& r_dk_ComposeTable, KMX_DWORD dk, vec_dword_2D& dk_SingleTable); -/** - * @brief convert a character to the upper-case equivalent and find the corresponding shiftstate - * of the entered keyval: a(97) -> A(65) + Base A(65) -> A(65) + Shift - * @param kval keyval that might be changed - * @param[in,out] shift the shiftstate of the entered keyval - * @param keymap a pointer to the currently used (underlying) keyboard layout - * @return the upper case equivalent of the keyval - */ +/** @brief convert a character to the upper-case equivalent and find the corresponding shiftstate of the entered keyval */ KMX_DWORD KMX_change_keyname_to_capital(KMX_DWORD kVal, KMX_DWORD& shift, GdkKeymap* keymap); -/** - * @brief append a 1D-vector containing name, base character and unicode_value to a 2D-Vector - * holding all possible combinations of deadkey + character for all Linux keyboards - * @param[in,out] dk_ComposeTable 2D-Vector holding all possible combinations of deadkey + character - * @param diacritic_name the name of a diacritic - * @param base_char base character - * @param unicode_value Unicode-value of the combined character - */ +/** @brief append a 1D-vector containing name, base character and unicode_value to a 2D-Vector */ void add_deadkey_combination(vec_dword_2D& dk_ComposeTable, std::string diacritic_name, std::string base_char, KMX_DWORD unicode_value); -/** - * @brief create a 2D-Vector containing all possible combinations of deadkey + character for all Linux keyboards - * the values are taken from from: https://help.ubuntu.com/community/GtkDeadKeyTable#Accents - * dk_ComposeTable[i][0] : diacritic_name (e.g. dead_circumflex) - * dk_ComposeTable[i][1] : base_char (e.g. a) - * dk_ComposeTable[i][2] : unicode_value-Value (e.g. 0x00E2) - * @param[in,out] dk_ComposeTable - */ +/** @brief create a 2D-Vector containing all possible combinations of deadkey + character for all Linux keyboards */ void create_DKTable(vec_dword_2D& dk_ComposeTable); #endif /*DEADKEY_H*/ diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 327c9fc24c..3fbcc040f5 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -15,7 +15,15 @@ #include "/usr/include/xcb/xproto.h" #include -/** @brief map a shiftstate used on Windows to a shiftstate suitable for gdk_keymap_translate_keyboard_state() on Linux */ +/** + * @brief map a shiftstate used on Windows to a shiftstate suitable for gdk_keymap_translate_keyboard_state() on Linux + * Windows: (Base: 00000000 (0); Shift 00010000 (16); AltGr 00001001 (9); Shift+AltGr 00011001 (25)) + * Linux: (Base: 0; Shift 1; ALTGr 2; Shift+ALTGr 3 ) + * @param shiftState shiftstate used on Windows + * @return a shiftstate usable for gdk_keymap_translate_keyboard_state() on linux if available + * if shiftState is a windows ShiftState: convert the windows ShiftState (0,16,9,25) to a Linux ShiftState (0,1,2,3) that is then used as "Level" in gdk + * if shiftState is NOT a windows ShiftState (then in_ShiftState is already a Linux shiftstate): return the entered shiftstate + */ int convert_Shiftstate_to_LinuxShiftstate(int shiftState) { if (shiftState == 0) return 0; // Win ss 0 -> Lin ss 0 else if (shiftState == K_SHIFTFLAG) return XCB_MOD_MASK_SHIFT; // Win ss 16 -> Lin ss 1 @@ -24,10 +32,16 @@ int convert_Shiftstate_to_LinuxShiftstate(int shiftState) { else return shiftState; // Lin ss x -> Lin ss x } +/** + * @brief map a shiftstate used for rgkey to a shiftstate suitable for gdk_keymap_translate_keyboard_state() on Linux + * rgkey: (Base: 0; Shift1 ; AltGr 6; Shift+AltGr 7) + * Linux: (Base: 0; Shift 1; ALTGr 2; Shift+ALTGr 3 ) + * @param shiftState shiftstate used for rgkey + * @return a shiftstate usable for gdk_keymap_translate_keyboard_state() on linux if available + * if shiftState is a rgkey ShiftState: convert the rgkey ShiftState (0,1,6,7) to a Linux ShiftState (0,1,2,3) that is then used as "Level" in gdk + * if shiftState is NOT a rgkey ShiftState (then in_ShiftState is already a Linux shiftstate): return the entered shiftstate + */ int convert_rgkey_Shiftstate_to_LinuxShiftstate(ShiftState shiftState) { - // if shiftState is a rgkey ShiftState: convert the rgkey ShiftState (0,1,6,7) to a Linux ShiftState (0,1,2,3) that is then used as "Level" in gdk - // if shiftState is NOT a rgkey ShiftState (then in_ShiftState is already a Linux shiftstate): return the entered shiftstate - if (shiftState == Base) return 0; // rgkey ss 0 -> Lin ss 0 else if (shiftState == Shft) return XCB_MOD_MASK_SHIFT; // rgkey ss 1 -> Lin ss 1 else if (shiftState == MenuCtrl) return XCB_MOD_MASK_LOCK; // rgkey ss 6 -> Lin ss 2 @@ -35,6 +49,13 @@ int convert_rgkey_Shiftstate_to_LinuxShiftstate(ShiftState shiftState) { else return shiftState; // Lin ss x -> Lin ss x } +/** + * @brief check for correct input parameter that will later be used in gdk_keymap_translate_keyboard_state() + * @param shiftstate the currently used shiftstate + * @param keycode the code of the key in question + * @return true if all parameters are OK; + * false if not + */ bool ensureValidInputForKeyboardTranslation(int shiftstate, gint keycode) { // We're dealing with shiftstates 0,1,2,3 @@ -51,7 +72,11 @@ bool ensureValidInputForKeyboardTranslation(int shiftstate, gint keycode) { return true; } -/** @brief convert names of keys stated in a symbol file to a keyvalue */ +/** + * @brief convert names of keys stated in a symbol file to a keyvalue + * @param tok_str the name stated in symbol file + * @return the keyvalue + */ KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str) { // more on https://manpages.ubuntu.com/manpages/jammy/man3/keysyms.3tk.html std::map key_values; @@ -331,7 +356,22 @@ KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str) { return INVALID_NAME; } -/** @brief create a 3D-Vector containing data of the US keyboard and the currently used (underlying) keyboard */ +/** + * @brief create a 3D-Vector containing data of the US keyboard and the currently used (underlying) keyboard + * all_vector [ US_Keyboard ] + * [KeyCode_US ] + * [Keyval unshifted ] + * [Keyval shifted ] + * [Underlying Kbd] + * [KeyCode_underlying] + * [Keyval unshifted ] + * [Keyval shifted ] + * @param[in,out] all_vector Vector that holds the data of the US keyboard as well as the currently used (underlying) keyboard + * @param keymap pointer to currently used (underlying) keyboard layout + * @return 0 on success; + * 1 if data of US keyboard was not written; + * 2 if data of underlying keyboard was not written +*/ int createOneVectorFromBothKeyboards(vec_dword_3D& all_vector, GdkKeymap* keymap) { // store contents of the English (US) keyboard in all_vector if (write_US_ToVector(all_vector)) { @@ -347,7 +387,13 @@ int createOneVectorFromBothKeyboards(vec_dword_3D& all_vector, GdkKeymap* keymap return 0; } -/** @brief write data of the US keyboard into a 3D-Vector */ +/** + * @brief write data of the US keyboard into a 3D-Vector which later will contain + * data of the US keyboard and the currently used (underlying) keyboard + * @param[in,out] vec_us Vector that holds the data of the US keyboard + * @return 0 on success; + * 1 if data of US keyboard was not written; +*/ int write_US_ToVector(vec_dword_3D& vec_us) { // create 1D-vector of the complete line vec_string_1D vector_completeUS; @@ -374,7 +420,12 @@ int write_US_ToVector(vec_dword_3D& vec_us) { return 0; } -/** @brief create a 1D-Vector containing all relevant entries of the symbol file us basic */ +/** + * @brief create a 1D-Vector containing all relevant entries of the symbol file us basic + * @param[in,out] complete_List the 1D-Vector + * @return FALSE on success; + * TRUE if file could not be opened +*/ bool createCompleteVector_US(vec_string_1D& complete_List) { // in the Configuration file we find the appopriate paragraph between "xkb_symbol " and the next xkb_symbol // then copy all rows starting with "key <" to a 1D-Vector @@ -413,7 +464,12 @@ bool createCompleteVector_US(vec_string_1D& complete_List) { return FALSE; } -/** @brief convert the key name obtained from symbol file to the matching keycode */ +/** + * @brief convert the key name obtained from symbol file to the matching keycode + * e.g. name of Key ) --> Keycode 15 + * @param key_name as stated in the symbol file + * @return the equivalent keycode +*/ int get_keycode_from_keyname(std::string key_name) { int out = INVALID_NAME; @@ -522,7 +578,12 @@ int get_keycode_from_keyname(std::string key_name) { return out; } -/** @brief process each element of a 1D-Vector, split and write to a 3D-Vector */ +/** + * @brief process each element of a 1D-Vector, split and write to a 3D-Vector + * @param[in,out] all_US a 3D_Vector containing all keyvalues of the US keyboard + * @param completeList a 1D-Vector containing all relevant entries copied from the symbol file us basic + * @return 0 on success if entry can be split +*/ int split_US_To_3D_Vector(vec_dword_3D& all_US, vec_string_1D completeList) { // 1: take the whole line of the 1D-Vector and remove unwanted characters. // 2: seperate the name e.g. key from the shiftstates @@ -584,7 +645,12 @@ int split_US_To_3D_Vector(vec_dword_3D& all_US, vec_string_1D completeList) { return 0; } -/** @brief create an 2D-Vector with all fields initialized to INVALID_NAME */ +/** + * @brief create an 2D-Vector with all fields initialized to INVALID_NAME + * @param dim_rows number of rows in vector + * @param dim_ss number of columns in vector + * @return the 2D-Vector +*/ vec_dword_2D create_empty_2D_Vector(int dim_rows, int dim_ss) { vec_dword_1D shifts; vec_dword_2D vector_2D; @@ -599,7 +665,14 @@ vec_dword_2D create_empty_2D_Vector(int dim_rows, int dim_ss) { return vector_2D; } -/** @brief append a 2D-vector containing data of the currently used (underlying) keyboard to the 3D-vector */ +/** + * @brief append a 2D-vector containing data of the currently used (underlying) keyboard to the 3D-vector + * @param[in,out] all_vector 3D-vector that holds the data of the US keyboard and the currently used (underlying) keyboard + * @param keymap pointer to currently used (underlying) keybord layout + * @return 0 on success; + * 1 if the initialization of the underlying vector failes; + * 2 if data of less than 2 keyboards is contained in all_vector +*/ int append_underlying_ToVector(vec_dword_3D& all_vector, GdkKeymap* keymap) { if (all_vector.size() != 1) { printf("ERROR: data for US keyboard not correct\n"); @@ -632,7 +705,14 @@ int append_underlying_ToVector(vec_dword_3D& all_vector, GdkKeymap* keymap) { return 0; } -/** @brief create a pointer to pointer of the current keymap for later use */ +/** + * @brief create a pointer to pointer of the current keymap for later use + * @param keymap pointer to pointer to currently used (underlying) keyboard layout + * @param argc count of arguments + * @param argv array of arguments + * @return FALSE on success; + * TRUE if the display or keymap is not found +*/ bool InitializeGDK(GdkKeymap** keymap, int argc, gchar* argv[]) { // get keymap of underlying keyboard @@ -653,7 +733,12 @@ bool InitializeGDK(GdkKeymap** keymap, int argc, gchar* argv[]) { return FALSE; } -/** @brief check if keyval correponds to a character we use in mcompile */ +/** + * @brief check if keyval correponds to a character we use in mcompile + * @param kv the keyval to be checked + * @return true if keyval is used in mcompile; + * false if not +*/ bool IsKeymanUsedChar(int kv) { // 32 A-Z a-z if ((kv == 0x20) || (kv >= 65 && kv <= 90) || (kv >= 97 && kv <= 122)) @@ -662,12 +747,18 @@ bool IsKeymanUsedChar(int kv) { return false; } -/** @brief convert a deadkey-value to a u16string if it is in the range of deadkeys used for mcompile. */ +/** + * @brief convert a deadkey-value to a u16string if it is in the range of deadkeys used for mcompile. + * deadkeys used for mcompile e.g. 65106 -> '^' + * @param in value to be converted + * @return on success a u16string holding the converted value; + * else u"\0" +*/ std::u16string convert_DeadkeyValues_To_U16str(KMX_DWORD in) { if (in == 0) return u"\0"; - if (in < (int)deadkey_min) { // no deadkey; no Unicode + if ((int)in < (int)deadkey_min) { // no deadkey; no Unicode return std::u16string(1, in); } @@ -685,7 +776,16 @@ std::u16string convert_DeadkeyValues_To_U16str(KMX_DWORD in) { return u"\0"; } -/** @brief return the keyvalue for a given Keycode, shiftstate and caps*/ +/** + * @brief return the keyvalue for a given Keycode, shiftstate and caps + * currently used (underlying) keyboard layout + * "What character will be produced for a keypress of a key and modifier?" + * @param keymap pointer to the currently used (underlying) keyboard layout + * @param keycode a key of the currently used keyboard layout + * @param ss a (windows-)shiftstate of the currently used keyboard layout + * @param caps state of the caps key of the currently used keyboard layout + * @return the keyval obtained from keycode, shiftstate and caps +*/ KMX_DWORD KMX_get_KeyVal_From_KeyCode(GdkKeymap* keymap, guint keycode, ShiftState ss, int caps) { GdkModifierType consumed; GdkKeymapKey* maps; @@ -776,7 +876,14 @@ KMX_DWORD KMX_get_KeyVal_From_KeyCode(GdkKeymap* keymap, guint keycode, ShiftSta return (int)*keyvals; } -/** @brief return the keyvalue for a given Keycode and shiftstate of the currently used (underlying) keyboard layout. */ +/** + * @brief return the keyvalue for a given Keycode and shiftstate of the currently used (underlying) keyboard layout. + * "What character will be produced for a keypress of a key and modifiers on the underlying keyboard?" + * @param keymap a pointer to the currently used (underlying) keyboard layout + * @param keycode a key of the currently used keyboard + * @param shiftState a shiftstate of the currently used keyboard layout + * @return the keyval obtained from Keycode and shiftstate; + */ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, guint keycode, int shiftState) { GdkKeymapKey* maps; guint* keyvals; @@ -801,7 +908,20 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, gui return kVal; } -/** @brief return the keyvalue for a given Keycode and shiftstate of the currently used (underlying) keyboard layout. */ +/** + * @brief return the keyvalue for a given Keycode and shiftstate of the currently used (underlying) keyboard layout. + * "What character will be produced for a keypress of a key and modifiers on the underlying keyboard?" + * If a deadkey was found return 0xFFFF and copy the deadkey into deadKey + * This function is similar to KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, guint keycode, int shiftState) + * but processes deadkeys + * @param keymap a pointer to the currently used (underlying) keyboard layout + * @param keycode a key of the currently used keyboard + * @param shiftState a shiftstate of the currently used keyboard layout + * @param deadKey* pointer to keyvalue if a deadkey was found; if not NULL + * @return 0xFFFF in case a deadkey was found, then the deadkey is stored in deadKey + * 0xFFFE in case a deadkey is out of range + * the keyval obtained from Keycode and shiftstate and caps; +*/ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, guint keycode, UINT shiftState, PKMX_WCHAR deadkey) { GdkKeymapKey* maps; guint* keyvals; @@ -833,7 +953,14 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, gui } -/** @brief return the keyvalue of a key of the the currently used (underlying) keyboard for a given keyvalue of the US keyboard */ +/** + * @brief return the keyvalue of a key of the the currently used (underlying) keyboard for a given keyvalue of the US keyboard + * "What character is on the same position/shiftstats/caps on the currently used (underlying) keyboard as on the US keyboard?" + * @param all_vector 3D-vector that holds the data of the US keyboard and the currently used (underlying) keyboard + * @param kv_us a keyvalue on the US keyboard + * @return keyval of the underlying keyboard if available; + * else the keyval of the US keyboard +*/ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyValUS(vec_dword_3D& all_vector, KMX_DWORD kv_us) { // look for kv_us for any shiftstate of US keyboard for (int i = 0; i < (int)all_vector[0].size() - 1; i++) { @@ -845,7 +972,17 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyValUS(vec_dword_3D& all_vector, KMX_D return kv_us; } -/** @brief return the keycode of the currently used (underlying) keyboard for a given keycode of the US keyboard */ +/** + * @brief return the keycode of the currently used (underlying) keyboard for a given keycode of the US keyboard + * "Where on an underlying keyboard do we find a character that is on a certain key on a US keyboard?" + * @param keymap the currently used (underlying) keyboard layout + * @param all_vector 3D-vector that holds the data of the US keyboard and the currently used (underlying) keyboard + * @param kc_us a key of the US keyboard + * @param ss a windows-type shiftstate + * @param caps state of the caps key + * @return the keycode of the underlying keyboard if found; + * else the keycode of the US keyboard +*/ KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap* keymap, vec_dword_3D& all_vector, KMX_DWORD kc_us, ShiftState ss, int caps) { std::u16string u16str = convert_DeadkeyValues_To_U16str(KMX_get_KeyVal_From_KeyCode(keymap, kc_us, ss, caps)); @@ -858,13 +995,24 @@ KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap* keymap, vec_dword_ return kc_us; } -/** @brief return the keycode of the currently used (underlying) keyboard for a given virtual key of the US keyboard */ +/** + * @brief return the keycode of the currently used (underlying) keyboard for a given virtual key of the US keyboard + * "Where on an underlying keyboard do we find a character of a US keyboard?" + * @param virtualKeyUS a virtual key of the US keyboard + * @return the keycode of the currently used (underlying) keyboard +*/ KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD virtualKeyUS) { // Linux virtualKeys are always 8 different to Windows virtualKeys return (KMX_DWORD)(8 + USVirtualKeyToScanCode[virtualKeyUS]); } -/** @brief return a virtual key of the US keyboard for a given keycode of the currently used (underlying) keyboard */ +/** + * @brief return a virtual key of the US keyboard for a given keycode of the currently used (underlying) keyboard + * "Which key of a underlying keyboard will be mapped to a virtual key of a US keyboard?" + * @param keycode a keycode of the currently used (underlying) keyboard + * @return the virtual key of the US keyboard or + * 0 if the key is not used +*/ KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying(KMX_DWORD keycode) { // Linux virtualKeys are always 8 different to Windows virtualKeys if (keycode > 7) @@ -873,7 +1021,11 @@ KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying(KMX_DWORD keycode) { return 0; } -/** @brief convert a codepoint to a u16string */ +/** + * @brief convert a codepoint to a u16string + * @param codepoint to be converted + * @return a u16string holding the converted value; +*/ std::u16string CodePointToU16String(unsigned int codepoint) { std::u16string str; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 3bbf3e86e8..bed159898d 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -64,122 +64,48 @@ static gint keycode_max = 94; static KMX_DWORD deadkey_min = 0xfe50; // X11's keysymdef.h defines deadkeys between 0xfe50-0xfe93 static KMX_DWORD deadkey_max = 0xfe93; // https://fossies.org/linux/tk/xlib/X11/keysymdef.h -/** - * @brief check if current machine uses little endian +/** @brief check if current machine uses little endian * @return true if little endian is used; - * else false - */ + * else false */ inline bool isLittleEndianSystem() { char16_t test = 0x0102; return (reinterpret_cast(&test))[0] == 0x02; } - -/** - * @brief map a shiftstate used on windows to a shiftstate suitable for gdk_keymap_translate_keyboard_state() on Linux - * Windows: (Base: 00000000 (0); Shift 00010000 (16); AltGr 00001001 (9); Shift+AltGr 00011001 (25)) - * Linux: (Base: 0; Shift 1; ALTGr 2; Shift+ALTGr 3 ) - * @param shiftState shiftstate used on Windows - * @return a shiftstate usable for gdk_keymap_translate_keyboard_state() on linux if available - * if shiftState is a windows ShiftState: convert the windows ShiftState (0,16,9,25) to a Linux ShiftState (0,1,2,3) that is then used as "Level" in gdk - * if shiftState is NOT a windows ShiftState (then in_ShiftState is already a Linux shiftstate): return the entered shiftstate - */ +/** @brief map a shiftstate used on windows to a shiftstate suitable for gdk_keymap_translate_keyboard_state() on Linux */ int convert_Shiftstate_to_LinuxShiftstate(int shiftState); + +/** @brief map a shiftstate used for rgkey to a shiftstate suitable for gdk_keymap_translate_keyboard_state() on Linux */ int convert_rgkey_Shiftstate_to_LinuxShiftstate(ShiftState shiftState); -/** - * @brief check for correct input parameter that will later be used in gdk_keymap_translate_keyboard_state() - * @param shiftstate the currently used shiftstate - * @param keycode the code of the key in question - * @return true if all parameters are OK; - * false if not - */ +/** @brief check for correct input parameter that will later be used in gdk_keymap_translate_keyboard_state() */ bool ensureValidInputForKeyboardTranslation(int shiftstate, gint keycode); -/** - * @brief convert names of keys stated in a symbol file to a keyvalue - * @param tok_str the name stated in symbol file - * @return the keyvalue - */ +/** @brief convert names of keys stated in a symbol file to a keyvalue */ KMX_DWORD convertNamesTo_DWORD_Value(std::string tok_str); -/** - * @brief create a 3D-Vector containing data of the US keyboard and the currently used (underlying) keyboard : - * all_vector [ US_Keyboard ] - * [KeyCode_US ] - * [Keyval unshifted ] - * [Keyval shifted ] - * [Underlying Kbd] - * [KeyCode_underlying] - * [Keyval unshifted ] - * [Keyval shifted ] - * @param[in,out] all_vector Vector that holds the data of the US keyboard as well as the currently used (underlying) keyboard - * @param keymap pointer to currently used (underlying) keyboard layout - * @return 0 on success; - * 1 if data of US keyboard was not written; - * 2 if data of underlying keyboard was not written - */ +/** @brief create a 3D-Vector containing data of the US keyboard and the currently used (underlying) keyboard */ int createOneVectorFromBothKeyboards(vec_dword_3D& all_vector, GdkKeymap* keymap); -/** - * @brief write data of the US keyboard into a 3D-Vector which later will contain - * data of the US keyboard and the currently used (underlying) keyboard - * @param[in,out] vec_us Vector that holds the data of the US keyboard - * @return 0 on success; - * 1 if data of US keyboard was not written; - */ +/** @brief write data of the US keyboard into a 3D-Vector which later will contain data of the US keyboard and the currently used (underlying) keyboard */ int write_US_ToVector(vec_dword_3D& vec_us); -/** - * @brief create a 1D-Vector containing all relevant entries of the symbol file us basic - * @param[in,out] complete_List the 1D-Vector - * @return FALSE on success; - * TRUE if file could not be opened - */ +/** @brief create a 1D-Vector containing all relevant entries of the symbol file us basic */ bool createCompleteVector_US(vec_string_1D& complete_List); -/** - * @brief convert the key name obtained from symbol file to the matching keycode - * e.g. name of Key ) --> Keycode 15 - * @param key_name as stated in the symbol file - * @return the equivalent keycode - */ +/** @brief convert the key name obtained from symbol file to the matching keycode */ int get_keycode_from_keyname(std::string key_name); -/** - * @brief process each element of a 1D-Vector, split and write to a 3D-Vector - * @param[in,out] all_US a 3D_Vector containing all keyvalues of the US keyboard - * @param completeList a 1D-Vector containing all relevant entries copied from the symbol file us basic - * @return 0 on success if entry can be split - */ +/** @brief process each element of a 1D-Vector, split and write to a 3D-Vector */ int split_US_To_3D_Vector(vec_dword_3D& all_US, vec_string_1D completeList); -/** - * @brief create an 2D-Vector with all fields containing INVALID_NAME - * @param dim_rows number of rows in vector - * @param dim_ss number of columns in vector - * @return the 2D-Vector - */ +/** @brief create an 2D-Vector with all fields containing INVALID_NAME */ vec_dword_2D create_empty_2D_Vector(int dim_rows, int dim_ss); -/** - * @brief append a 2D-vector containing data of the currently used (underlying) keyboard to the 3D-vector - * @param[in,out] all_vector 3D-vector that holds the data of the US keyboard and the currently used (underlying) keyboard - * @param keymap pointer to currently used (underlying) keybord layout - * @return 0 on success; - * 1 if the initialization of the underlying vector failes; - * 2 if data of less than 2 keyboards is contained in all_vector - */ +/** @brief append a 2D-vector containing data of the currently used (underlying) keyboard to the 3D-vector */ int append_underlying_ToVector(vec_dword_3D& all_vector, GdkKeymap* keymap); -/** - * @brief create a pointer to pointer of the current keymap for later use - * @param keymap pointer to pointer to currently used (underlying) keyboard layout - * @param argc count of arguments - * @param argv array of arguments - * @return FALSE on success; - * TRUE if the display or keymap is not found - */ +/** @brief create a pointer to pointer of the current keymap for later use */ bool InitializeGDK(GdkKeymap** keymap, int argc, gchar* argv[]); const UINT USVirtualKeyToScanCode[256] = { @@ -581,106 +507,34 @@ const UINT ScanCodeToUSVirtualKey[128] = { 0x00 // 0x7f => No match }; -/** - * @brief check if keyval correponds to a character used in mcompile - * @param kv the keyval to be checked - * @return true if keyval is used in mcompile; - * false if not - */ +/** @brief check if keyval correponds to a character used in mcompile */ bool IsKeymanUsedChar(int kv); -/** - * @brief convert a deadkey-value to a u16string if it is in the range of - * deadkeys used for mcompile e.g. 65106 -> '^' - * @param in value to be converted - * @return on success a u16string holding the converted value; - * else u"\0" - */ +/** @brief convert a deadkey-value to a u16string if it is in the range of deadkeys used for mcompile */ std::u16string convert_DeadkeyValues_To_U16str(KMX_DWORD in); -/** - * @brief return the keyvalue for a given Keycode, shiftstate and caps of the - * currently used (underlying) keyboard layout - * "What character will be produced for a keypress of a key and modifier?" - * @param keymap pointer to the currently used (underlying) keyboard layout - * @param keycode a key of the currently used keyboard layout - * @param ss a (windows-)shiftstate of the currently used keyboard layout - * @param caps state of the caps key of the currently used keyboard layout - * @return the keyval obtained from keycode, shiftstate and caps - */ +/** @brief return the keyvalue for a given Keycode, shiftstate and caps of the currently used (underlying) keyboard layout. */ KMX_DWORD KMX_get_KeyVal_From_KeyCode(GdkKeymap* keymap, guint keycode, ShiftState ss, int caps); -/** - * @brief return the keyvalue for a given Keycode and shiftstate of the currently used (underlying) keyboard layout. - * "What character will be produced for a keypress of a key and modifiers on the underlying keyboard?" - * @param keymap a pointer to the currently used (underlying) keyboard layout - * @param keycode a key of the currently used keyboard - * @param shift_state_pos a shiftstate of the currently used keyboard layout - * @return the keyval obtained from Keycode and shiftstate; - */ -KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, guint keycode, int shift_state_pos); +/** @brief return the keyvalue for a given Keycode and shiftstate of the currently used (underlying) keyboard layout. */ +KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, guint keycode, int shiftState); -/** - * @brief return the keyvalue for a given Keycode and shiftstate of the currently used (underlying) keyboard layout. - * "What character will be produced for a keypress of a key and modifiers on the underlying keyboard?" - * If a deadkey was found return 0xFFFF and copy the deadkey into deadKey - * This function is similar to KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, guint keycode, int shiftState) - * but processes deadkeys - * @param keymap a pointer to the currently used (underlying) keyboard layout - * @param keycode a key of the currently used keyboard - * @param shiftState a shiftstate of the currently used keyboard layout - * @param deadKey* pointer to keyvalue if a deadkey was found; if not NULL - * @return 0xFFFF in case a deadkey was found, then the deadkey is stored in deadKey - * 0xFFFE in case a deadkey is out of range - * the keyval obtained from Keycode and shiftstate and caps; - */ +/** @brief return the keyvalue for a given Keycode and shiftstate of the currently used (underlying) keyboard layout. */ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, guint keycode, UINT shiftState, PKMX_WCHAR deadkey); -/** - * @brief return the keyvalue of a key of the the currently used (underlying) keyboard for a given keyvalue of the US keyboard - * "What character is on the same position/shiftstats/caps on the currently used (underlying) keyboard as on the US keyboard?" - * @param all_vector 3D-vector that holds the data of the US keyboard and the currently used (underlying) keyboard - * @param kv_us a keyvalue on the US keyboard - * @return keyval of the underlying keyboard if available; - * else the keyval of the US keyboard - */ +/** @brief return the keyvalue of a key of the the currently used (underlying) keyboard for a given keyvalue of the US keyboard */ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyValUS(vec_dword_3D& all_vector, KMX_DWORD kv_us); -/** - * @brief return the keycode of the currently used (underlying) keyboard for a given keycode of the US keyboard - * "Where on an underlying keyboard do we find a character that is on a certain key on a US keyboard?" - * @param keymap the currently used (underlying) keyboard layout - * @param all_vector 3D-vector that holds the data of the US keyboard and the currently used (underlying) keyboard - * @param kc_us a key of the US keyboard - * @param ss a windows-type shiftstate - * @param caps state of the caps key - * @return the keycode of the underlying keyboard if found; - * else the keycode of the US keyboard - */ +/** @brief return the keycode of the currently used (underlying) keyboard for a given keycode of the US keyboard */ KMX_DWORD KMX_get_KeyCodeUnderlying_From_KeyCodeUS(GdkKeymap* keymap, vec_dword_3D& all_vector, KMX_DWORD kc_us, ShiftState ss, int caps); -/** - * @brief return the keycode of the currently used (underlying) keyboard for a given virtual key of the US keyboard - * "Where on an underlying keyboard do we find a character of a US keyboard?" - * @param virtualKeyUS a virtual key of the US keyboard - * @return the keycode of the currently used (underlying) keyboard - */ +/** @brief return the keycode of the currently used (underlying) keyboard for a given virtual key of the US keyboard */ KMX_DWORD KMX_get_KeyCodeUnderlying_From_VKUS(KMX_DWORD virtualKeyUS); -/** - * @brief return a virtual key of the US keyboard for a given keycode of the currently used (underlying) keyboard - * "Which key of a underlying keyboard will be mapped to a virtual key of a US keyboard?" - * @param keycode a keycode of the currently used (underlying) keyboard - * @return the virtual key of the US keyboard or - * * 0 if the key is not used - */ +/** @brief return a virtual key of the US keyboard for a given keycode of the currently used (underlying) keyboard */ KMX_DWORD KMX_get_VKUS_From_KeyCodeUnderlying(KMX_DWORD keycode); -/** - * @brief convert a codepoint to a u16string - * @param codepoint to be converted - * @return a u16string holding the converted value; - */ +/** @brief convert a codepoint to a u16string */ std::u16string CodePointToU16String(unsigned int codepoint); #endif /*KEYMAP_H*/ diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 0c267e539a..63f7ed3920 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -23,23 +23,38 @@ const int KMX_ShiftStateMap[] = { 0, 0}; -/** @brief Constructor */ +/** + * @brief Constructor + * @param deadCharacter a deadkey +*/ DeadKey::DeadKey(KMX_WCHAR deadCharacter) { this->m_deadchar = deadCharacter; } -/** @brief return dead character */ +/** + * @brief return dead character + * @return deadkey character +*/ KMX_WCHAR DeadKey::KMX_DeadCharacter() { return this->m_deadchar; } -/** @brief set Deadkey with values */ +/** + * @brief set Deadkey with values + * @param baseCharacter the base character + * @param combinedCharacter the combined character +*/ void DeadKey::KMX_AddDeadKeyRow(KMX_WCHAR baseCharacter, KMX_WCHAR combinedCharacter) { this->m_rgbasechar.push_back(baseCharacter); this->m_rgcombchar.push_back(combinedCharacter); } -/** @brief check if character exists in DeadKey */ +/** + * @brief check if character exists in DeadKey + * @param baseCharacter a character to be found + * @return true if found; + * false if not found +*/ bool DeadKey::KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter) { std::vector::iterator it; for (it = this->m_rgbasechar.begin(); it < m_rgbasechar.end(); it++) { @@ -53,10 +68,10 @@ bool DeadKey::KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter) { /** * @brief Find a keyvalue for given keycode, shiftstate and caps. A function similar to Window`s ToUnicodeEx() function. * - * Contrary to what the function name might suggest, the function KMX_ToUnicodeEx does not process surrogate pairs. + * Contrary to what the function name might suggest, the function KMX_ToUnicodeEx does not process surrogate pairs. * This is because it is used in mcompile only which only deals with latin scripts. * In case this function should be used for surrogate pairs, they will be ignored and a message will be printed out - + * * @param keycode a key of the currently used keyboard Layout * @param pwszBuff Buffer to store resulting character * @param ss a shiftstate of the currently used keyboard Layout @@ -65,7 +80,7 @@ bool DeadKey::KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter) { * @return -1 if a deadkey was found; * 0 if no translation is available; * +1 if character was found and written to pwszBuff - */ +*/ int KMX_ToUnicodeEx(guint keycode, PKMX_WCHAR pwszBuff, ShiftState rgkey_ss, int caps, GdkKeymap* keymap) { GdkKeymapKey* maps; @@ -121,7 +136,9 @@ KMX_WCHAR KMX_DeadKeyMap(int index, std::vector* deadkeys, int deadkey return 0xFFFF; } -/** @brief Base class for dealing with rgkey*/ +/** + * @brief Base class for dealing with rgkey +*/ class KMX_VirtualKey { private: UINT m_vk; @@ -136,12 +153,16 @@ public: memset(this->m_rgfDeadKey, 0, sizeof(this->m_rgfDeadKey)); } -/** @brief return member variable virtual key */ +/** + * @brief return member variable virtual key +*/ UINT VK() { return this->m_vk; } -/** @brief return member variable scancode */ +/** + * @brief return member variable scancode +*/ UINT SC() { return this->m_sc; } @@ -212,7 +233,9 @@ public: } return true; } -/** @brief check if we use only keys used in mcompile */ +/** + * @brief check if we use only keys used in mcompile +*/ bool KMX_IsKeymanUsedKey() { return (this->m_vk >= 0x20 && this->m_vk <= 0x5F) || (this->m_vk >= 0x88); } @@ -221,7 +244,9 @@ public: return KMX_ShiftStateMap[(int)ss] | (capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0); } -/** @brief count the number of keys */ +/** + * @brief count the number of keys +*/ int KMX_GetKeyCount(int MaxShiftState) { int nkeys = 0; @@ -341,7 +366,9 @@ public: } }; -/** @brief Base class for KMX_loader*/ +/** + * @brief Base class for KMX_loader + */ class KMX_Loader { private: KMX_BYTE lpKeyStateNull[256]; @@ -372,9 +399,9 @@ public: /** * @brief find the maximum index of a deadkey - * @param p pointer to deadkey + @param p pointer to deadkey * @return index of deadkey - */ +*/ int KMX_GetMaxDeadkeyIndex(KMX_WCHAR* p) { int n = 0; while (p && *p) { diff --git a/linux/mcompile/keymap/mc_import_rules.h b/linux/mcompile/keymap/mc_import_rules.h index 583890968f..f955830eac 100644 --- a/linux/mcompile/keymap/mc_import_rules.h +++ b/linux/mcompile/keymap/mc_import_rules.h @@ -11,23 +11,13 @@ private: std::vector m_rgcombchar; public: - /** - * @brief Constructor - * @param deadCharacter a deadkey - */ + /** @brief Constructor */ DeadKey(KMX_WCHAR deadCharacter); - /** - * @brief return dead character - * @return deadkey character - */ + /** @brief return dead character */ KMX_WCHAR KMX_DeadCharacter(); - /** - * @brief set Deadkey with values - * @param baseCharacter the base character - * @param combinedCharacter the combined character - */ + /** @brief set Deadkey with values */ void KMX_AddDeadKeyRow(KMX_WCHAR baseCharacter, KMX_WCHAR combinedCharacter); int KMX_Count() { @@ -46,12 +36,7 @@ public: return this->m_rgcombchar[index]; } - /** - * @brief check if character exists in DeadKey - * @param baseCharacter a character to be found - * @return true if found; - * false if not found - */ + /** @brief check if character exists in DeadKey */ bool KMX_ContainsBaseCharacter(KMX_WCHAR baseCharacter); }; diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 2988fe151b..d02e8f7661 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -41,23 +41,10 @@ const int CODE__SIZE[] = { 2 // CODE_SETSYSTEMSTORE 0x18 }; -/** - * @brief check if the file has correct version - * @param filebase containing data of the input file - * @param file_size a size - * @return true if successful; - * false if not - */ +/** @brief check if the file has correct version */ KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD file_size); -/** - * @brief Fixup the keyboard by expanding pointers. On disk the pointers are stored relative to the - * beginning of the file, but we need real pointers. This method is used on 32-bit architectures. - * @param bufp pointer to buffer where data will be copied into - * @param base pointer to starting point - * @param dwFileSize size of the file - * @return pointer to the keyboard - */ +/** @brief Fixup the keyboard by expanding pointers. */ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); /** @@ -229,7 +216,13 @@ KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX return CERR_None; } -/** @brief save keyboard to file */ +/** + * @brief save keyboard to file + * @param kbd pointer to the keyboard + * @param filename pointer to filename of a kmx-file + * @return TRUE on success; + * else FALSE + */ KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, KMX_CHAR* filename) { FILE* fp; fp = Open_File(filename, "wb"); @@ -341,7 +334,14 @@ LPKMX_KEYBOARD CopyKeyboard(PKMX_BYTE bufp, PKMX_BYTE base) { // else KMX_FixupKeyboard #else -/** @brief Fixup the keyboard by expanding pointers. */ +/** + * @brief Fixup the keyboard by expanding pointers. On disk the pointers are stored relative to the + * beginning of the file, but we need real pointers. This method is used on 32-bit architectures. + * @param bufp pointer to buffer where data will be copied into + * @param base pointer to starting point + * @param dwFileSize size of the file + * @return pointer to the keyboard + */ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize) { UNREFERENCED_PARAMETER(dwFileSize); @@ -488,7 +488,13 @@ KMX_BOOL KMX_LoadKeyboard(KMX_CHAR* fileName, LPKMX_KEYBOARD* lpKeyboard) { return TRUE; } -/** @brief check if the file has correct version */ +/** + * @brief check if the file has correct version + * @param filebase containing data of the input file + * @param file_size a size + * @return true if successful; + * false if not + */ KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD file_size) { KMX_DWORD i; PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD)filebase; @@ -514,7 +520,11 @@ KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD file_size) { return TRUE; } -/** @brief increment in a string */ +/** + * @brief increment in a string + * @param p pointer to a character + * @return pointer to the incremented character + */ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p) { if (p == NULL || *p == 0) return p; @@ -549,7 +559,13 @@ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p) { return p; } -/** @brief open a file */ +/** + * @brief open a file + * @param filename name of the file + * @param mode same as mode in fopen + * @return pointer to file. + * On error returns a null pointer + */ FILE* Open_File(const KMX_CHAR* filename, const KMX_CHAR* mode) { #ifdef _MSC_VER std::string cpath = filename; //, cmode = mode; diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 1377820fb6..f89a240a77 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -65,38 +65,17 @@ typedef struct KMX_tagKEYBOARD { //HBITMAP hBitmap; // handle to the bitmap in the file; } KMX_KEYBOARD, *LPKMX_KEYBOARD; -/** - * @brief load a keyboard kmx-file - * @param fileName pointer to filename of kmx-file - * @param[in,out] lpKeyboard pointer to pointer to keyboard - * @return TRUE on success; - * else FALSE - */ + +/** @brief load a keyboard kmx-file */ KMX_BOOL KMX_LoadKeyboard(KMX_CHAR* fileName, LPKMX_KEYBOARD* lpKeyboard); -/** - * @brief save keyboard to file - * @param kbd pointer to the keyboard - * @param filename pointer to filename of a kmx-file - * @return TRUE on success; - * else FALSE - */ +/** @brief save keyboard to file */ KMX_BOOL KMX_SaveKeyboard(LPKMX_KEYBOARD kbd, KMX_CHAR* filename); -/** - * @brief increment in a string - * @param p pointer to a character - * @return pointer to the incremented character - */ +/** @brief increment in a string */ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); -/** - * @brief xx open a file - * @param filename name of the file - * @param mode same as mode in fopen - * @return pointer to file. - * On error returns a null pointer - */ +/** @brief open a file */ FILE* Open_File(const KMX_CHAR* filename, const KMX_CHAR* mode); #endif // _KMXFILE_H diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 8629602f48..5d9787d0af 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -11,39 +11,16 @@ #include "mcompile.h" -/** - * @brief convert mnemonic keyboard layout to positional keyboard layout and translate keyboard - * @param kbd pointer to US keyboard - * @param bDeadkeyConversion option for converting a deadkey to a character: 1 = dk conversion; 0 = no dk conversion - * @param argc number of command line arguments - * @param argv pointer to command line arguments - * @return TRUE if conversion was successful; - * FALSE if not - */ +/** @brief convert mnemonic keyboard layout to positional keyboard layout and translate keyboard */ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint argc, gchar* argv[]); /** @brief Collect the key data, translate it to kmx and append to the existing keyboard */ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** keymap, std::vector* KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 -/** - * @brief start of mcompile; load, convert and save keyboard - * @param argc number of commandline arguments - * @param argv pointer to commandline arguments: executable, inputfile, outputfile - * @param argv_gdk pointer to (commandline arguments) - * @return 0 on success, - * 1 for wrong usage of calling parameters, - * 3 if unable to load keyboard - */ +/** @brief start of mcompile; load, convert and save keyboard */ int run(int argc, char* argv[]); -/** - * @brief return an array of [usvk, ch_out] pairs: all existing combinations of a deadkey + character for the underlying keyboard - * @param dk_Table shiftstate of the deadkey - * @param deadkey deadkey character - * @param[out] outputPairs pointer to array of [usvk, ch_out] pairs - * @param keymap pointer to the currently used (underlying) keyboard Layout - * @return size of array of [usvk, ch_out] pairs - */ +/** @brief return an array of [usvk, ch_out] pairs: all existing combinations of a deadkey + character for the underlying keyboard */ int KMX_GetDeadkeys(vec_dword_2D& dk_Table, KMX_WORD deadkey, KMX_WORD* outputPairs, GdkKeymap* keymap); std::vector KMX_FDeadkeys; // I4353 @@ -70,6 +47,16 @@ std::vector KMX_FDeadkeys; // I4353 run(argc, argv); } + +/** + * @brief start of mcompile; load, convert and save keyboard + * @param argc number of commandline arguments + * @param argv pointer to commandline arguments: executable, inputfile, outputfile + * @param argv_gdk pointer to (commandline arguments) + * @return 0 on success, + * 1 for wrong usage of calling parameters, + * 3 if unable to load keyboard + */ int run(int argc, char* argv[]) { int bDeadkeyConversion = 0; @@ -494,7 +481,15 @@ KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { return FALSE; } -/** @brief convert mnemonic keyboard layout to positional keyboard layout and translate keyboard */ +/** + * @brief convert mnemonic keyboard layout to positional keyboard layout and translate keyboard + * @param kbd pointer to US keyboard + * @param bDeadkeyConversion option for converting a deadkey to a character: 1 = dk conversion; 0 = no dk conversion + * @param argc number of command line arguments + * @param argv pointer to command line arguments + * @return TRUE if conversion was successful; + * FALSE if not + */ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint argc, gchar* argv[]) { KMX_WCHAR DeadKey = 0; @@ -584,7 +579,10 @@ int KMX_GetDeadkeys(vec_dword_2D& dk_Table, KMX_WORD deadkey, KMX_WORD* outputPa return (p - outputPairs); } -/** @brief print (error) messages */ +/** + * @brief print (error) messages + * @param fmt text to print + */ void KMX_LogError(const wchar_t* fmt, ...) { WCHAR fmtbuf[256]; const wchar_t* end = L"\0"; diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 5436735ba7..292db0bd03 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -32,10 +32,7 @@ struct KMX_DeadkeyMapping { // I4353 extern std::vector KMX_FDeadkeys; // I4353 -/** - * @brief print (error) messages - * @param fmt text to print - */ +/** @brief print (error) messages */ void KMX_LogError(const wchar_t* fmt, ...); #endif /*MCOMPILE_H*/ diff --git a/linux/mcompile/keymap/u16.cpp b/linux/mcompile/keymap/u16.cpp index d399dffd13..504bba3afd 100644 --- a/linux/mcompile/keymap/u16.cpp +++ b/linux/mcompile/keymap/u16.cpp @@ -11,43 +11,66 @@ #include #include "utfcodec.hpp" -// string <- wstring -/** @brief Obtain a std::string from a std::wstring */ +/** string <- wstring + * @brief Obtain a std::string from a std::wstring + * @param wstr the std::wstring to be converted + * @return a std::string + */ std::string string_from_wstring(std::wstring const wstr) { return convert((const std::wstring)wstr); } -// wstring <- string -/** @brief Obtain a std::wstring from a std::string */ +/** wstring <- string + * @brief Obtain a std::wstring from a std::string + * @param str the std::string to be converted + * @return a std::wstring + */ std::wstring wstring_from_string(std::string const str) { return convert((const std::string)str); } -// u16string <- string +/** u16string <- string + * @brief Obtain a std::u16string from a std::string + * @param str the std::string to be converted + * @return a std::u16string + */ std::u16string u16string_from_string(std::string const str) { return convert((const std::string)str); } -// string <- u16string -/** @brief Obtain a std::string from a std::u16string */ +/** string <- u16string + * @brief Obtain a std::string from a std::u16string + * @param str16 the std::u16string to be converted + * @return a std::string + */ std::string string_from_u16string(std::u16string const str16) { return convert((const std::u16string)str16); } -// wstring <- u16string -/** @brief Obtain a std::wstring from a std::u16string */ +/** wstring <- u16string + * @brief Obtain a std::wstring from a std::u16string + * @param str16 the std::u16string to be converted + * @return a std::wstring + */ std::wstring wstring_from_u16string(std::u16string const str16) { return convert((const std::u16string)str16); } -// u16string <- wstring -/** @brief Obtain a std::u16string from a std::wstring */ +/** u16string <- wstring + * @brief Obtain a std::u16string from a std::wstring + * @param wstr the std::wstring to be converted + * @return a std::u16string + */ std::u16string u16string_from_wstring(std::wstring const wstr) { return convert((const std::wstring)wstr);; } -// UTF16 (=const wchar_t*) -> -> std::string -> std::u16string -> UTF16 ( = char16_t*) -/** @brief Convert pointer to wchar_t to u16string and copy sz elements into dst */ +/** UTF16 (=const wchar_t*) -> -> std::string -> std::u16string -> UTF16 ( = char16_t*) + * @brief Convert pointer to wchar_t to pointer to char16_t and copy sz elements into dst + * @param dst destination + * @param sz nr of characters to be copied + * @param fmt source to convert and copy + */ void u16sprintf(KMX_WCHAR* dst, const size_t sz, const wchar_t* fmt, ...) { wchar_t* wbuf = new wchar_t[sz]; va_list args; @@ -60,7 +83,13 @@ void u16sprintf(KMX_WCHAR* dst, const size_t sz, const wchar_t* fmt, ...) { delete[] wbuf; } -/** @brief Convert u16string to long integer */ +/** + * @brief Convert u16string to long integer + * @param str u16string beginning with the representation of an integral number. + * @param endptr Reference to the next character in str + * @param base Numerical base (radix) that determines the valid characters and their interpretation + * @return a long + */ long int u16tol(const KMX_WCHAR* str, KMX_WCHAR** endptr, int base) { auto s = string_from_u16string(str); char* t; @@ -69,7 +98,13 @@ long int u16tol(const KMX_WCHAR* str, KMX_WCHAR** endptr, int base) { return result; } -/** @brief Append max characters from u16string */ +/** + * @brief Append max characters from u16string + * @param dst Pointer to the destination array + * @param src u16string to be appended + * @param max Maximum number of characters to be appended. + * @return Pointer to dst + */ const KMX_WCHAR* u16ncat(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max) { KMX_WCHAR* o = dst; dst = (KMX_WCHAR*)u16chr(dst, 0); @@ -83,7 +118,11 @@ const KMX_WCHAR* u16ncat(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max) { return o; } -/** @brief find last '/' or '\\' in an array of char16_t */ +/** + * @brief Find last '/' or '\\' in an array of char16_t + * @param name Pointer to the source + * @return Pointer to the last slash/backslash + */ const KMX_WCHAR* u16rchr_slash(KMX_WCHAR const* name) { const KMX_WCHAR* cp = NULL; cp = u16rchr(name, '\\'); @@ -92,7 +131,11 @@ const KMX_WCHAR* u16rchr_slash(KMX_WCHAR const* name) { return cp; } -/** @brief find last '/' or '\\' in an array of char */ +/** + * @brief Find last '/' or '\\' in an array of char + * @param name Pointer to the source + * @return Pointer to the last slash/backslash + */ KMX_CHAR* strrchr_slash(KMX_CHAR* name) { KMX_CHAR* cp = NULL; cp = strrchr(name, '\\'); @@ -101,7 +144,12 @@ KMX_CHAR* strrchr_slash(KMX_CHAR* name) { return cp; } -/** @brief Locate last occurrence of character in u16string */ +/** + * @brief Locate last occurrence of character in u16string + * @param p Pointer to the source + * @param ch The character to be found + * @return A pointer to the last occurrence of character in u16str + */ const KMX_WCHAR* u16rchr(const KMX_WCHAR* p, KMX_WCHAR ch) { const KMX_WCHAR* p_end = p + u16len(p); @@ -114,7 +162,12 @@ const KMX_WCHAR* u16rchr(const KMX_WCHAR* p, KMX_WCHAR ch) { return NULL; } -/** @brief Locate first occurrence of character in u16string */ +/** + * @brief Locate first occurrence of character in u16string + * @param p Pointer to the source + * @param ch The character to be found + * @return A pointer to the first occurrence of character in u16str + */ const KMX_WCHAR* u16chr(const KMX_WCHAR* p, KMX_WCHAR ch) { while (*p) { if (*p == ch) return p; @@ -123,7 +176,12 @@ const KMX_WCHAR* u16chr(const KMX_WCHAR* p, KMX_WCHAR ch) { return ch == 0 ? p : NULL; } -/** @brief Copy the u16string pointed to by src into the array pointed to by dst */ +/** + * @brief Copy the u16string pointed to by scr into the array pointed to by dst + * @param dst Pointer to the destination + * @param src Pointer to the source to be copied + * @return Pointer to dst + */ const KMX_WCHAR* u16cpy(KMX_WCHAR* dst, const KMX_WCHAR* src) { KMX_WCHAR* o = dst; while (*src) { @@ -133,7 +191,13 @@ const KMX_WCHAR* u16cpy(KMX_WCHAR* dst, const KMX_WCHAR* src) { return o; } -/** @brief Copy max characters of the u16string pointed to by src into the array pointed to by dst */ +/** + * @brief Copy max characters of the u16string pointed to by src into the array pointed by dst + * @param dst Pointer to the destination + * @param src Pointer to the source to be copied + * @param max Maximum number of characters to be copied + * @return Pointer to dst + */ const KMX_WCHAR* u16ncpy(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max) { KMX_WCHAR* o = dst; while (*src && max > 0) { @@ -146,7 +210,11 @@ const KMX_WCHAR* u16ncpy(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max) { return o; } -/** @brief Return the length of the u16string str */ +/** + * @brief Return the length of the u16string str + * @param p Pointer to the source + * @return The length of u16string + */ size_t u16len(const KMX_WCHAR* p) { int i = 0; while (*p) { @@ -156,7 +224,13 @@ size_t u16len(const KMX_WCHAR* p) { return i; } -/** @brief Compare two u16strings */ +/** + * @brief Compare two u16strings + * @param p Pointer one u16string + * @param q Pointer another u16string + * @return 0 if strings are equal + * ! = 0 if unequal + */ int u16cmp(const KMX_WCHAR* p, const KMX_WCHAR* q) { while (*p && *q) { if (*p != *q) return *p - *q; @@ -166,7 +240,14 @@ int u16cmp(const KMX_WCHAR* p, const KMX_WCHAR* q) { return *p - *q; } -/** @brief Case insensitive comparison of up to count characters in two strings */ +/** + * @brief Case insensitive comparison of up to count characters in two strings + * @param p Pointer one u16string + * @param q Pointer another u16string + * @param count Maximum number of characters to compare + * @return 0 if strings are equal + * ! = 0 if unequal + */ int u16nicmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count) { while (*p && *q && count) { if (toupper(*p) != toupper(*q)) @@ -180,7 +261,13 @@ int u16nicmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count) { return 0; } -/** @brief Case insensitive comparison of two strings */ +/** + * @brief Case insensitive comparison of two strings + * @param p Pointer one u16string + * @param q Pointer another u16string + * @return 0 if strings are equal + * ! = 0 if unequal + */ int u16icmp(const KMX_WCHAR* p, const KMX_WCHAR* q) { while (*p && *q) { if (toupper(*p) != toupper(*q)) @@ -191,7 +278,14 @@ int u16icmp(const KMX_WCHAR* p, const KMX_WCHAR* q) { return *p - *q; } -/** @brief Comparison of up to count characters in two strings */ +/** + * @brief Comparison of up to count characters in two strings + * @param p Pointer one u16string + * @param q Pointer another u16string + * @param count Maximum number of characters to compare + * @return 0 if strings are equal + * ! = 0 if unequal + */ int u16ncmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count) { while (*p && *q && count) { if (*p != *q) return *p - *q; @@ -204,7 +298,13 @@ int u16ncmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count) { return 0; } -/** @brief Split u16string into tokens */ +/** + * @brief Split u16string into tokens + * @param p Pointer to u16string to parse. + * @param ch the delimiter character + * @param ctx the remaining string after the first delimiter + * @return Pointer to the first token in p + */ KMX_WCHAR* u16tok(KMX_WCHAR* p, const KMX_WCHAR ch, KMX_WCHAR** ctx) { if (!p) { p = *ctx; @@ -227,7 +327,13 @@ KMX_WCHAR* u16tok(KMX_WCHAR* p, const KMX_WCHAR ch, KMX_WCHAR** ctx) { return *p ? p : NULL; } -/** @brief Split u16string into tokens */ +/** + * @brief Split u16string into tokens + * @param p Pointer to u16string to parse. + * @param delimiters an array of delimiter characters + * @param ctx the remaining string after the first delimiter + * @return Pointer to the first token in p + */ KMX_WCHAR* u16tok(KMX_WCHAR* p, const KMX_WCHAR* delimiters, KMX_WCHAR** ctx) { if (!p) { p = *ctx; @@ -251,7 +357,11 @@ KMX_WCHAR* u16tok(KMX_WCHAR* p, const KMX_WCHAR* delimiters, KMX_WCHAR** ctx) { return *p ? p : NULL; } -/** @brief Convert a u16string to a double */ +/** + * @brief Convert a u16string to a double + * @param str Pointer to u16string + * @return double value equivalent to the string + */ double u16tof(KMX_WCHAR* str) { double val = 0; int offsetdot = 0; diff --git a/linux/mcompile/keymap/u16.h b/linux/mcompile/keymap/u16.h index 2413c30715..11c1fc8c90 100644 --- a/linux/mcompile/keymap/u16.h +++ b/linux/mcompile/keymap/u16.h @@ -10,189 +10,73 @@ #include #include -/** - * @brief Obtain a std::string from a std::wstring - * @param wstr the std::wstring to be converted - * @return a std::string - */ +/** @brief Obtain a std::string from a std::wstring */ std::string string_from_wstring(std::wstring const wstr); -/** - * @brief Obtain a std::wstring from a std::string - * @param str the std::string to be converted - * @return a std::wstring - */ +/** @brief Obtain a std::wstring from a std::string */ std::wstring wstring_from_string(std::string const str); -/** - * @brief Obtain a std::u16string from a std::string - * @param str the std::string to be converted - * @return a std::u16string - */ +/** @brief Obtain a std::u16string from a std::string */ std::u16string u16string_from_string(std::string const str); -/** - * @brief Obtain a std::string from a std::u16string - * @param str16 the std::u16string to be converted - * @return a std::string - */ +/** @brief Obtain a std::string from a std::u16string */ std::string string_from_u16string(std::u16string const str16); -/** - * @brief Obtain a std::wstring from a std::u16string - * @param str16 the std::u16string to be converted - * @return a std::wstring - */ +/** @brief Obtain a std::wstring from a std::u16string */ std::wstring wstring_from_u16string(std::u16string const str16); -/** - * @brief Obtain a std::u16string from a std::wstring - * @param wstr the std::wstring to be converted - * @return a std::u16string - */ +/** @brief Obtain a std::u16string from a std::wstring */ std::u16string u16string_from_wstring(std::wstring const wstr); -/** - * @brief Convert pointer to wchar_t to pointer to char16_t and copy sz elements into dst - * @param dst destination - * @param sz nr of characters to be copied - * @param fmt source to convert and copy - */ +/** @brief Convert pointer to wchar_t to pointer to char16_t and copy sz elements into dst */ void u16sprintf(KMX_WCHAR* dst, const size_t sz, const wchar_t* fmt, ...); -/** - * @brief Convert u16string to long integer - * @param str u16string beginning with the representation of an integral number. - * @param endptr Reference to the next character in str - * @param base Numerical base (radix) that determines the valid characters and their interpretation - * @return a long - */ +/** @brief Convert u16string to long integer */ long int u16tol(const KMX_WCHAR* str, KMX_WCHAR** endptr, int base); -/** - * @brief Append max characters from u16string - * @param dst Pointer to the destination array - * @param src u16string to be appended - * @param max Maximum number of characters to be appended. - * @return Pointer to dst - */ +/** @brief Append max characters from u16string */ const KMX_WCHAR* u16ncat(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max); -/** - * @brief Find last '/' or '\\' in an array of char16_t - * @param name Pointer to the source - * @return Pointer to the last slash/backslash - */ +/** @brief find last '/' or '\\' in an array of char16_t */ const KMX_WCHAR* u16rchr_slash(KMX_WCHAR const* name); -/** - * @brief Find last '/' or '\\' in an array of char - * @param name Pointer to the source - * @return Pointer to the last slash/backslash - */ +/** @brief find last '/' or '\\' in an array of char */ KMX_CHAR* strrchr_slash(KMX_CHAR* name); -/** - * @brief Locate last occurrence of character in u16string - * @param p Pointer to the source - * @param ch The character to be found - * @return A pointer to the last occurrence of character in u16str - */ +/** @brief Locate last occurrence of character in u16string */ const KMX_WCHAR* u16rchr(const KMX_WCHAR* p, KMX_WCHAR ch); -/** - * @brief Locate first occurrence of character in u16string - * @param p Pointer to the source - * @param ch The character to be found - * @return A pointer to the first occurrence of character in u16str - */ +/** @brief Locate first occurrence of character in u16string */ const KMX_WCHAR* u16chr(const KMX_WCHAR* p, KMX_WCHAR ch); -/** - * @brief Copy the u16string pointed by scr into the array pointed by dst - * @param dst Pointer to the destination - * @param src Pointer to the source to be copied - * @return Pointer to dst - */ +/** @brief Copy the u16string pointed to by src into the array pointed to by dst */ const KMX_WCHAR* u16cpy(KMX_WCHAR* dst, const KMX_WCHAR* src); -/** - * @brief Copy max characters of the u16string pointed by src into the array pointed by dst - * @param dst Pointer to the destination - * @param src Pointer to the source to be copied - * @param max Maximum number of characters to be copied - * @return Pointer to dst - */ +/** @brief Copy max characters of the u16string pointed to by src into the array pointed to by dst */ const KMX_WCHAR* u16ncpy(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max); -/** - * @brief Return the length of the u16string str - * @param p Pointer to the source - * @return The length of u16string - */ +/** @brief Return the length of the u16string str */ size_t u16len(const KMX_WCHAR* p); -/** - * @brief Compare two u16strings - * @param p Pointer one u16string - * @param q Pointer another u16string - * @return 0 if strings are equal - * ! = 0 if unequal - */ +/** @brief Compare two u16strings */ int u16cmp(const KMX_WCHAR* p, const KMX_WCHAR* q); -/** - * @brief Case insensitive comparison of up to count characters in two strings - * @param p Pointer one u16string - * @param q Pointer another u16string - * @param count Maximum number of characters to compare - * @return 0 if strings are equal - * ! = 0 if unequal - */ +/** @brief Case insensitive comparison of up to count characters in two strings */ int u16nicmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count); -/** - * @brief Case insensitive comparison of two strings - * @param p Pointer one u16string - * @param q Pointer another u16string - * @return 0 if strings are equal - * ! = 0 if unequal - */ +/** @brief Case insensitive comparison of two strings */ int u16icmp(const KMX_WCHAR* p, const KMX_WCHAR* q); -/** - * @brief Comparison of up to count characters in two strings - * @param p Pointer one u16string - * @param q Pointer another u16string - * @param count Maximum number of characters to compare - * @return 0 if strings are equal - * ! = 0 if unequal - */ +/** @brief Comparison of up to count characters in two strings */ int u16ncmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count); -/** - * @brief Split u16string into tokens - * @param p Pointer to u16string to parse. - * @param ch the delimiter character - * @param ctx the remaining string after the first delimiter - * @return Pointer to the first token in p - */ +/** @brief Split u16string into tokens */ KMX_WCHAR* u16tok(KMX_WCHAR* p, const KMX_WCHAR ch, KMX_WCHAR** ctx); -/** - * @brief Split u16string into tokens - * @param p Pointer to u16string to parse. - * @param delim an array of delimiter characters - * @param ctx the remaining string after the first delimiter - * @return Pointer to the first token in p - */ -KMX_WCHAR* u16tok(KMX_WCHAR* p, const KMX_WCHAR* delim, KMX_WCHAR** ctx); +/** @brief Split u16string into tokens */ +KMX_WCHAR* u16tok(KMX_WCHAR* p, const KMX_WCHAR* delimiters, KMX_WCHAR** ctx); -/** - * @brief Convert a u16string to a double - * @param str Pointer to u16string - * @return double value equivalent to the string - */ +/** @brief Convert a u16string to a double */ double u16tof(KMX_WCHAR* str); #endif /* U16_H */ From e0f4e50dc7825bea5960ba31eff77e8ea8a1c090 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 8 Aug 2024 08:08:20 +0200 Subject: [PATCH 302/327] feat(Linux): "a few minor things" --- linux/mcompile/keymap/keymap.cpp | 8 +++----- linux/mcompile/keymap/mcompile.cpp | 1 - 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 3fbcc040f5..753c817a38 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -670,7 +670,7 @@ vec_dword_2D create_empty_2D_Vector(int dim_rows, int dim_ss) { * @param[in,out] all_vector 3D-vector that holds the data of the US keyboard and the currently used (underlying) keyboard * @param keymap pointer to currently used (underlying) keybord layout * @return 0 on success; - * 1 if the initialization of the underlying vector failes; + * 1 if the initialization of the underlying vector fails; * 2 if data of less than 2 keyboards is contained in all_vector */ int append_underlying_ToVector(vec_dword_3D& all_vector, GdkKeymap* keymap) { @@ -706,10 +706,8 @@ int append_underlying_ToVector(vec_dword_3D& all_vector, GdkKeymap* keymap) { } /** - * @brief create a pointer to pointer of the current keymap for later use - * @param keymap pointer to pointer to currently used (underlying) keyboard layout - * @param argc count of arguments - * @param argv array of arguments + * @brief initializes GDK and return the current keymap for later use + * @param keymap [out] currently used (underlying) keyboard layout * @return FALSE on success; * TRUE if the display or keymap is not found */ diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 5d9787d0af..8623640911 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -52,7 +52,6 @@ std::vector KMX_FDeadkeys; // I4353 * @brief start of mcompile; load, convert and save keyboard * @param argc number of commandline arguments * @param argv pointer to commandline arguments: executable, inputfile, outputfile - * @param argv_gdk pointer to (commandline arguments) * @return 0 on success, * 1 for wrong usage of calling parameters, * 3 if unable to load keyboard From 1719df281b268948151cf759d81e2b463cee1b19 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 8 Aug 2024 08:26:11 +0200 Subject: [PATCH 303/327] feat(Linux): "more minor things" --- linux/mcompile/keymap/mcompile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 8623640911..ec63d3e3d4 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -30,7 +30,7 @@ std::vector KMX_FDeadkeys; // I4353 /** * @brief main function for mcompile for Windows, Linux, Mac * @param argc number of commandline arguments - * @param argv commandline arguments + * @param argv pointer to commandline arguments: executable, inputfile, outputfile * @return 0 on success */ #if defined(_WIN32) || defined(_WIN64) From ef4e47c198477be36a0bb00a849041f8a47e5368 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 8 Aug 2024 08:37:50 +0200 Subject: [PATCH 304/327] feat(Linux): layout mcompile --- linux/mcompile/keymap/mcompile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index ec63d3e3d4..16a17e5d9e 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -50,8 +50,8 @@ std::vector KMX_FDeadkeys; // I4353 /** * @brief start of mcompile; load, convert and save keyboard - * @param argc number of commandline arguments - * @param argv pointer to commandline arguments: executable, inputfile, outputfile + * @param argc number of commandline arguments + * @param argv pointer to commandline arguments: executable, inputfile, outputfile * @return 0 on success, * 1 for wrong usage of calling parameters, * 3 if unable to load keyboard From 9e1d2f9e48fa40abac0a30a71dc6a5c5f4e738f8 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 8 Aug 2024 11:48:19 +0200 Subject: [PATCH 305/327] feat(linux): u16: change parameter name; while loop --- linux/mcompile/keymap/u16.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/linux/mcompile/keymap/u16.cpp b/linux/mcompile/keymap/u16.cpp index 504bba3afd..e2604352af 100644 --- a/linux/mcompile/keymap/u16.cpp +++ b/linux/mcompile/keymap/u16.cpp @@ -68,18 +68,18 @@ std::u16string u16string_from_wstring(std::wstring const wstr) { /** UTF16 (=const wchar_t*) -> -> std::string -> std::u16string -> UTF16 ( = char16_t*) * @brief Convert pointer to wchar_t to pointer to char16_t and copy sz elements into dst * @param dst destination - * @param sz nr of characters to be copied + * @param max nr of characters to be copied * @param fmt source to convert and copy */ -void u16sprintf(KMX_WCHAR* dst, const size_t sz, const wchar_t* fmt, ...) { - wchar_t* wbuf = new wchar_t[sz]; +void u16sprintf(KMX_WCHAR* dst, const size_t max, const wchar_t* fmt, ...) { + wchar_t* wbuf = new wchar_t[max]; va_list args; va_start(args, fmt); - vswprintf(wbuf, sz, fmt, args); + vswprintf(wbuf, max, fmt, args); va_end(args); std::u16string u16str = u16string_from_wstring(wbuf); - u16ncpy(dst, u16str.c_str(), sz); + u16ncpy(dst, u16str.c_str(), max); delete[] wbuf; } @@ -153,8 +153,7 @@ KMX_CHAR* strrchr_slash(KMX_CHAR* name) { const KMX_WCHAR* u16rchr(const KMX_WCHAR* p, KMX_WCHAR ch) { const KMX_WCHAR* p_end = p + u16len(p); - while (p_end > p) { - + while (p_end >= p) { if (*p_end == ch) return p_end; p_end--; From c09c895333ef5acb5872d92b8413feadf0282e12 Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Tue, 30 Jul 2024 18:08:41 +0200 Subject: [PATCH 306/327] =?UTF-8?q?refactor(web):=20move=20parts=20of=20`k?= =?UTF-8?q?eyboard-processor`=20=E2=86=92=20`js-processor`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move parts of `common/web/keyboard-processor/` → `web/src/engine/js-processor/`. Note this temporarily disable tests for keyboard-processor which depend on js-processor, until #12110 is fixed. Fixes: #12067 --- common/web/keyboard-processor/build.sh | 11 +- common/web/keyboard-processor/src/index.ts | 10 +- .../src/keyboards/keyboard.ts | 74 ++++++++++++- .../src/keyboards/keyboardHarness.ts | 3 + .../keyboard-processor/src/text/keyEvent.ts | 30 +++-- .../src/text/ruleBehavior.interface.ts | 12 ++ .../src/text/systemStores.ts | 36 +++++- .../keyboard-processor/tests/dom/readme.md | 5 - .../tests/dom/web-test-runner.CI.config.mjs | 13 --- .../tests/dom/web-test-runner.config.mjs | 62 ----------- .../keyboard-processor/tests/tsconfig.json | 11 -- .../web/keyboard-processor/tsconfig.all.json | 1 - web/README.md | 4 +- web/build.sh | 2 + web/package.json | 5 + web/src/app/browser/src/beepHandler.ts | 2 +- web/src/app/browser/src/configuration.ts | 3 +- .../app/browser/src/defaultBrowserRules.ts | 2 +- .../app/browser/src/hardwareEventKeyboard.ts | 3 +- web/src/app/webview/src/keymanEngine.ts | 3 +- .../events/src/keyEventSource.interface.ts | 4 +- web/src/engine/interfaces/build.sh | 1 + .../src/prediction/predictionContext.ts | 3 +- web/src/engine/interfaces/tsconfig.json | 1 + web/src/engine/js-processor/build.sh | 41 +++++++ .../engine/js-processor/src}/defaultRules.ts | 29 +++-- web/src/engine/js-processor/src/index.ts | 7 ++ .../engine/js-processor/src}/kbdInterface.ts | 103 +----------------- .../js-processor/src}/keyboardProcessor.ts | 40 +++---- .../engine/js-processor/src}/ruleBehavior.ts | 4 +- web/src/engine/js-processor/tsconfig.json | 13 +++ web/src/engine/main/build.sh | 1 + web/src/engine/main/src/contextManagerBase.ts | 3 +- .../engine/main/src/engineConfiguration.ts | 3 +- web/src/engine/main/src/hardKeyboard.ts | 3 +- .../main/src/headless/inputProcessor.ts | 6 +- web/src/engine/main/src/keyboardInterface.ts | 5 +- web/src/engine/main/src/keymanEngine.ts | 10 +- web/src/engine/main/tsconfig.json | 1 + .../domKeyboardLoader.spec.ts | 3 +- web/src/test/auto/dom/kbdLoader.ts | 2 +- .../prediction/predictionContext.spec.js | 3 +- .../testing/recorder-core/src/nodeProctor.ts | 3 +- .../tools/testing/recorder-core/tsconfig.json | 3 +- 44 files changed, 295 insertions(+), 289 deletions(-) create mode 100644 common/web/keyboard-processor/src/text/ruleBehavior.interface.ts delete mode 100644 common/web/keyboard-processor/tests/dom/readme.md delete mode 100644 common/web/keyboard-processor/tests/dom/web-test-runner.CI.config.mjs delete mode 100644 common/web/keyboard-processor/tests/dom/web-test-runner.config.mjs delete mode 100644 common/web/keyboard-processor/tests/tsconfig.json create mode 100755 web/src/engine/js-processor/build.sh rename {common/web/keyboard-processor/src/text => web/src/engine/js-processor/src}/defaultRules.ts (91%) create mode 100644 web/src/engine/js-processor/src/index.ts rename {common/web/keyboard-processor/src/text => web/src/engine/js-processor/src}/kbdInterface.ts (94%) rename {common/web/keyboard-processor/src/text => web/src/engine/js-processor/src}/keyboardProcessor.ts (96%) rename {common/web/keyboard-processor/src/text => web/src/engine/js-processor/src}/ruleBehavior.ts (96%) create mode 100644 web/src/engine/js-processor/tsconfig.json rename {common/web/keyboard-processor/tests/dom/cases => web/src/test/auto/dom/cases/keyboard-processor}/domKeyboardLoader.spec.ts (95%) diff --git a/common/web/keyboard-processor/build.sh b/common/web/keyboard-processor/build.sh index 3921063bb9..964370c2fb 100755 --- a/common/web/keyboard-processor/build.sh +++ b/common/web/keyboard-processor/build.sh @@ -17,6 +17,7 @@ BUNDLE_CMD="node ${KEYMAN_ROOT}/common/web/es-bundling/build/common-bundle.mjs" builder_describe \ "Compiles the web-oriented utility function module." \ "@/web/src/tools/testing/recorder-core test" \ + "@/web/src/engine/js-processor test" \ "@/common/web/keyman-version" \ "@/common/web/es-bundling" \ "@/common/web/types" \ @@ -64,10 +65,10 @@ function do_build() { --platform node # Tests - builder_echo "Bundle tests" - ${BUNDLE_CMD} "${KEYMAN_ROOT}/common/web/keyboard-processor/build/tests/dom/cases/domKeyboardLoader.spec.js" \ - --out "${KEYMAN_ROOT}/common/web/keyboard-processor/build/tests/dom/domKeyboardLoader.spec.mjs" \ - --format esm + # builder_echo "Bundle tests" + # ${BUNDLE_CMD} "${KEYMAN_ROOT}/common/web/keyboard-processor/build/tests/dom/cases/domKeyboardLoader.spec.js" \ + # --out "${KEYMAN_ROOT}/common/web/keyboard-processor/build/tests/dom/domKeyboardLoader.spec.mjs" \ + # --format esm # Declaration bundling. builder_echo "Declaration bundling" @@ -92,4 +93,4 @@ function do_test() { builder_run_action configure do_configure builder_run_action clean rm -rf ./build builder_run_action build do_build -builder_run_action test do_test +# builder_run_action test do_test diff --git a/common/web/keyboard-processor/src/index.ts b/common/web/keyboard-processor/src/index.ts index f800691cfa..c719d7ee8e 100644 --- a/common/web/keyboard-processor/src/index.ts +++ b/common/web/keyboard-processor/src/index.ts @@ -27,20 +27,14 @@ export { default as StateKeyMap } from "./keyboards/stateKeyMap.js"; export { default as Codes } from "./text/codes.js"; export * from "./text/codes.js"; export * from "./text/deadkeys.js"; -export { default as DefaultRules } from "./text/defaultRules.js"; -export * from "./text/defaultRules.js"; -export { default as KeyboardInterface } from "./text/kbdInterface.js"; -export * from "./text/kbdInterface.js"; -export { default as KeyboardProcessor } from "./text/keyboardProcessor.js"; -export * from "./text/keyboardProcessor.js"; export { default as KeyEvent } from "./text/keyEvent.js"; export * from "./text/keyEvent.js"; export { default as KeyMapping } from "./text/keyMapping.js"; export { default as OutputTarget } from "./text/outputTarget.js"; export * from "./text/outputTarget.js"; -export { default as RuleBehavior } from "./text/ruleBehavior.js"; export * from "./text/stringDivergence.js"; export * from "./text/systemStores.js"; +export * from "./text/ruleBehavior.interface.js"; export * from "@keymanapp/web-utils"; @@ -48,4 +42,4 @@ export * from "@keymanapp/web-utils"; // Without the line below... OutputTarget would likely be aliased there, as it's // the last `export { default as _ }` => `export * from` pairing seen above. -export default undefined; \ No newline at end of file +export default undefined; diff --git a/common/web/keyboard-processor/src/keyboards/keyboard.ts b/common/web/keyboard-processor/src/keyboards/keyboard.ts index 5312d825a6..6ca5f790fd 100644 --- a/common/web/keyboard-processor/src/keyboards/keyboard.ts +++ b/common/web/keyboard-processor/src/keyboards/keyboard.ts @@ -6,11 +6,83 @@ import type OutputTarget from "../text/outputTarget.js"; import { ModifierKeyConstants, TouchLayout } from "@keymanapp/common-types"; type TouchLayoutSpec = TouchLayout.TouchLayoutPlatform & { isDefault?: boolean}; -import type { ComplexKeyboardStore } from "../text/kbdInterface.js"; +import type { ComplexKeyboardStore, KeyboardStore } from "../text/systemStores.js"; import { Version, DeviceSpec } from "@keymanapp/web-utils"; import StateKeyMap from "./stateKeyMap.js"; +export class RuleDeadkey { + /** Discriminant field - 'd' for Deadkey. + */ + t: 'd'; + + /** + * Value: the deadkey's ID. + */ + d: number; // For 'd'eadkey; also reflects the Deadkey class's 'd' property. +} + +export class StoreBeep { + /** Discriminant field - 'b' for `beep` + */ + ['t']: 'b'; +} + +export type RuleChar = string; + +export class ContextAny { + /** Discriminant field - 'a' for `any()`. + */ + ['t']: 'a'; + + /** + * Value: the store to search. + */ + ['a']: KeyboardStore; // For 'a'ny statement. + + /** + * If set to true, negates the 'any'. + */ + ['n']: boolean | 0 | 1; +} + +export class RuleIndex { + /** Discriminant field - 'i' for `index()`. + */ + ['t']: 'i'; + + /** + * Value: the Store from which to output + */ + ['i']: KeyboardStore; + + /** + * Offset: the offset in context for the corresponding `any()`. + */ + ['o']: number; +} + +export class ContextEx { + /** Discriminant field - 'c' for `context()`. + */ + ['t']: 'c'; + + /** + * Value: The offset into the current rule's context to be matched. + */ + ['c']: number; // For 'c'ontext statement. +} + +export class ContextNul { + /** Discriminant field - 'n' for `nul` + */ + ['t']: 'n'; +} + + + +export type StoreNonCharEntry = RuleDeadkey | StoreBeep; + /** * Stores preprocessed properties of a keyboard for quick retrieval later. */ diff --git a/common/web/keyboard-processor/src/keyboards/keyboardHarness.ts b/common/web/keyboard-processor/src/keyboards/keyboardHarness.ts index 671c8fefd7..109d209067 100644 --- a/common/web/keyboard-processor/src/keyboards/keyboardHarness.ts +++ b/common/web/keyboard-processor/src/keyboards/keyboardHarness.ts @@ -1,5 +1,6 @@ import Keyboard from "./keyboard.js"; import Codes from "../text/codes.js"; +import { DeviceSpec } from '@keymanapp/web-utils'; /** * Defines members of the top-level `keyman` global object necessary to guarantee @@ -40,6 +41,8 @@ export const MinimalKeymanGlobal: KeyboardKeymanGlobal = { export class KeyboardHarness { public readonly _jsGlobal: any; public readonly keymanGlobal: KeyboardKeymanGlobal; + activeDevice: DeviceSpec; + /** * Constructs and configures a harness for receiving dynamically-loaded Keyman keyboards. diff --git a/common/web/keyboard-processor/src/text/keyEvent.ts b/common/web/keyboard-processor/src/text/keyEvent.ts index a38992a3a1..7c507cc170 100644 --- a/common/web/keyboard-processor/src/text/keyEvent.ts +++ b/common/web/keyboard-processor/src/text/keyEvent.ts @@ -10,18 +10,30 @@ import type Keyboard from "../keyboards/keyboard.js"; import { type DeviceSpec } from "@keymanapp/web-utils"; import Codes from './codes.js'; -import DefaultRules from './defaultRules.js'; import { ActiveKeyBase } from "../index.js"; +interface DefaultRulesInterface { + forAny(Lkc: KeyEvent, isMnemonic: boolean): string; +} + +export class BASE_DEFAULT_RULES { + private static _instance: DefaultRulesInterface; + + // Prevent direct instantiation. + private constructor() { } + + public static forAny(Lkc: KeyEvent, isMnemonic: boolean): string { + return this._instance.forAny(Lkc, isMnemonic); + } + + public static set instance(value: DefaultRulesInterface) { + this._instance = value; + } +} + // Represents a probability distribution over a keyboard's keys. // Defined here to avoid compilation issues. -export type KeyDistribution = {keySpec: ActiveKeyBase, p: number}[]; - -/** - * A simple instance of the standard 'default rules' for keystroke processing from the - * DefaultRules base class. - */ -const BASE_DEFAULT_RULES = new DefaultRules(); +export type KeyDistribution = { keySpec: ActiveKeyBase, p: number }[]; export interface KeyEventSpec { @@ -188,4 +200,4 @@ export default class KeyEvent implements KeyEventSpec { } } } -}; \ No newline at end of file +}; diff --git a/common/web/keyboard-processor/src/text/ruleBehavior.interface.ts b/common/web/keyboard-processor/src/text/ruleBehavior.interface.ts new file mode 100644 index 0000000000..29f81bcc8c --- /dev/null +++ b/common/web/keyboard-processor/src/text/ruleBehavior.interface.ts @@ -0,0 +1,12 @@ +import { type Transcription } from './outputTarget.js'; + +/** + * Represents the commands and state changes that result from a matched keyboard rule. + */ +export interface RuleBehaviorInterface { + /** + * The before-and-after Transform from matching a keyboard rule. May be `null` + * if no keyboard rules were matched for the keystroke. + */ + transcription: Transcription; +} diff --git a/common/web/keyboard-processor/src/text/systemStores.ts b/common/web/keyboard-processor/src/text/systemStores.ts index 13184baafe..a2f7abff34 100644 --- a/common/web/keyboard-processor/src/text/systemStores.ts +++ b/common/web/keyboard-processor/src/text/systemStores.ts @@ -1,5 +1,31 @@ -import type KeyboardInterface from "./kbdInterface.js"; -import { SystemStoreIDs } from "./kbdInterface.js"; +import { type KeyboardHarness } from "../keyboards/keyboardHarness.js"; +import { StoreNonCharEntry } from '../keyboards/keyboard.js'; + +export enum SystemStoreIDs { + TSS_LAYER = 33, + TSS_PLATFORM = 31, + TSS_NEWLAYER = 42, + TSS_OLDLAYER = 43 +} + +/* +* Type alias definitions to reflect the parameters of the fullContextMatch() callback (KMW 10+). +* No constructors or methods since keyboards will not utilize the same backing prototype, and +* property names are shorthanded to promote minification. +*/ +type PlainKeyboardStore = string; + +export type KeyboardStoreElement = (string | StoreNonCharEntry); +export type ComplexKeyboardStore = KeyboardStoreElement[]; + +export type KeyboardStore = PlainKeyboardStore | ComplexKeyboardStore; + +export type VariableStore = { [name: string]: string }; + +export interface VariableStoreSerializer { + loadStore(keyboardID: string, storeName: string): VariableStore; + saveStore(keyboardID: string, storeName: string, storeMap: VariableStore): void; +} /** * Defines common behaviors associated with system stores. @@ -61,9 +87,9 @@ export class MutableSystemStore extends SystemStore { * Handles checks against the current platform. */ export class PlatformSystemStore extends SystemStore { - private readonly kbdInterface: KeyboardInterface; + private readonly kbdInterface: KeyboardHarness; - constructor(keyboardInterface: KeyboardInterface) { + constructor(keyboardInterface: KeyboardHarness) { super(SystemStoreIDs.TSS_PLATFORM); this.kbdInterface = keyboardInterface; @@ -131,4 +157,4 @@ export class PlatformSystemStore extends SystemStore { // Everything we checked against was valid and had matches - it's a match! return true; } -} \ No newline at end of file +} diff --git a/common/web/keyboard-processor/tests/dom/readme.md b/common/web/keyboard-processor/tests/dom/readme.md deleted file mode 100644 index 153b7f4a1e..0000000000 --- a/common/web/keyboard-processor/tests/dom/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -Automated tests in this subfolder and its children are designed to facilitate simple, browser-independent -unit tests that are DOM-reliant. - -Tests for anything that may reasonably vary depending upon the browser used to run the code should go under -the "integrated" folder instead. \ No newline at end of file diff --git a/common/web/keyboard-processor/tests/dom/web-test-runner.CI.config.mjs b/common/web/keyboard-processor/tests/dom/web-test-runner.CI.config.mjs deleted file mode 100644 index d18a8a9cb0..0000000000 --- a/common/web/keyboard-processor/tests/dom/web-test-runner.CI.config.mjs +++ /dev/null @@ -1,13 +0,0 @@ -// @ts-check -import BASE_CONFIG from './web-test-runner.config.mjs'; -import teamcityReporter from '@keymanapp/common-test-resources/test-runner-TC-reporter.mjs'; -import { sessionStabilityReporter } from '@keymanapp/common-test-resources/test-runner-stability-reporter.mjs'; - -/** @type {import('@web/test-runner').TestRunnerConfig} */ -export default { - ...BASE_CONFIG, - reporters: [ - teamcityReporter(), /* custom-written, for CI-friendly reports */ - sessionStabilityReporter({ciMode: true}) - ] -} \ No newline at end of file diff --git a/common/web/keyboard-processor/tests/dom/web-test-runner.config.mjs b/common/web/keyboard-processor/tests/dom/web-test-runner.config.mjs deleted file mode 100644 index 76651182ac..0000000000 --- a/common/web/keyboard-processor/tests/dom/web-test-runner.config.mjs +++ /dev/null @@ -1,62 +0,0 @@ -// @ts-check -import { devices, playwrightLauncher } from '@web/test-runner-playwright'; -import { esbuildPlugin } from '@web/dev-server-esbuild'; -import { defaultReporter, summaryReporter } from '@web/test-runner'; -import { LauncherWrapper, sessionStabilityReporter } from '@keymanapp/common-test-resources/test-runner-stability-reporter.mjs'; -import { importMapsPlugin } from '@web/dev-server-import-maps'; -import { dirname, resolve } from 'path'; -import { fileURLToPath } from 'url'; - -const dir = dirname(fileURLToPath(import.meta.url)); -const KEYMAN_ROOT = resolve(dir, '../../../../..'); - -/** @type {import('@web/test-runner').TestRunnerConfig} */ -export default { - // debug: true, - browsers: [ - new LauncherWrapper(playwrightLauncher({ product: 'chromium' })), - new LauncherWrapper(playwrightLauncher({ product: 'firefox' })), - new LauncherWrapper(playwrightLauncher({ product: 'webkit', concurrency: 1 })), - ], - concurrency: 10, - nodeResolve: true, - files: [ - 'build/tests/dom/**/*.spec.mjs' - ], - middleware: [ - // Rewrites short-hand paths for test resources, making them fully relative to the repo root. - function rewriteResourcePath(context, next) { - if(context.url.startsWith('/resources/')) { - context.url = '/common/test' + context.url; - } - - return next(); - } - ], - plugins: [ - esbuildPlugin({ts: true, target: 'auto'}), - importMapsPlugin({ - inject: { - importMap: { - // Redirects `eventemitter3` imports to the bundled ESM library. The standard import is an - // ESM wrapper around the CommonJS implementation, and WTR fails when it hits the CommonJS. - imports: { - 'eventemitter3': '/node_modules/eventemitter3/dist/eventemitter3.esm.js' - } - } - } - }) - ], - reporters: [ - summaryReporter({}), /* local-dev mocha-style */ - sessionStabilityReporter({}), - defaultReporter({}) - ], - /* - Un-comment the next two lines for easy interactive debugging; it'll launch the - test page in your preferred browser. - */ - // open: true, - // manual: true, - rootDir: KEYMAN_ROOT -} diff --git a/common/web/keyboard-processor/tests/tsconfig.json b/common/web/keyboard-processor/tests/tsconfig.json deleted file mode 100644 index 0e978545b8..0000000000 --- a/common/web/keyboard-processor/tests/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "baseUrl": "../", - "outDir": "../build/tests/", - "tsBuildInfoFile": "../build/tests/tsconfig.tsbuildinfo", - "rootDir": "./" - }, - "include": [ "./dom/**/*.ts"], - "exclude": [] -} diff --git a/common/web/keyboard-processor/tsconfig.all.json b/common/web/keyboard-processor/tsconfig.all.json index dabb262d9c..79f10644d1 100644 --- a/common/web/keyboard-processor/tsconfig.all.json +++ b/common/web/keyboard-processor/tsconfig.all.json @@ -9,7 +9,6 @@ "references": [ { "path": "./src/keyboards/loaders/tsconfig.dom.json" }, { "path": "./src/keyboards/loaders/tsconfig.node.json" }, - { "path": "./tests/tsconfig.json" }, ], // Actual main-body compilation is in tsconfig.json. This config is just a wrapper // to trigger all three components at once. diff --git a/web/README.md b/web/README.md index 1249805165..775f303df5 100644 --- a/web/README.md +++ b/web/README.md @@ -82,6 +82,7 @@ title: Dependency Graph graph TD; OSK["/web/src/engine/osk"]; KP["@keymanapp/keyboard-processor
(/common/web/keyboard-processor)"]; + JSProc["/web/src/engine/js-processor"]; OSK-->KP; WebUtils["@keymanapp/web-utils
(/common/web/utils)"]; KP---->WebUtils; @@ -107,6 +108,7 @@ graph TD; Fully headless components`"] direction LR KP; + JSProc-->KP; WebUtils; PredText; Gestures; @@ -127,9 +129,9 @@ graph TD; OSK-->Gestures; Interfaces["/web/src/engine/interfaces"]; Interfaces-->KP; + Interfaces-->JSProc; OSK-->Interfaces; CommonEngine["/web/src/engine/main"]; - CommonEngine-->Interfaces; CommonEngine-->Device; CommonEngine-->KeyboardCache; CommonEngine-->OSK; diff --git a/web/build.sh b/web/build.sh index 7248f5c35a..6f4737710a 100755 --- a/web/build.sh +++ b/web/build.sh @@ -27,6 +27,7 @@ builder_describe "Builds engine modules for Keyman Engine for Web (KMW)." \ ":engine/dom-utils A common subset of function used for DOM calculations, layout, etc" \ ":engine/events Specialized classes utilized to support KMW API events" \ ":engine/element-wrappers Subset used to integrate with website elements" \ + ":engine/js-processor Build JS processor for KMW" \ ":engine/main Builds all common code used by KMW's app/-level targets" \ ":engine/osk Builds the Web OSK module" \ ":engine/package-cache Subset used to collate keyboards and request them from the cloud" \ @@ -57,6 +58,7 @@ builder_describe_outputs \ build:engine/dom-utils "/web/build/engine/dom-utils/obj/index.js" \ build:engine/events "/web/build/engine/events/lib/index.mjs" \ build:engine/element-wrappers "/web/build/engine/element-wrappers/lib/index.mjs" \ + build:engine/js-processor "/web/build/engine/js-processor/lib/index.mjs" \ build:engine/main "/web/build/engine/main/lib/index.mjs" \ build:engine/osk "/web/build/engine/osk/lib/index.mjs" \ build:engine/package-cache "/web/build/engine/package-cache/lib/index.mjs" \ diff --git a/web/package.json b/web/package.json index 458ea85de0..4baff29490 100644 --- a/web/package.json +++ b/web/package.json @@ -37,6 +37,11 @@ "types": "./build/engine/events/obj/index.d.ts", "import": "./build/engine/events/obj/index.js" }, + "./engine/js-processor": { + "es6-bundling": "./src/engine/js-processor/src/index.ts", + "types": "./build/engine/js-processor/obj/index.d.ts", + "import": "./build/engine/js-processor/obj/index.js" + }, "./engine/package-cache": { "es6-bundling": "./src/engine/package-cache/src/index.ts", "types": "./build/engine/package-cache/obj/index.d.ts", diff --git a/web/src/app/browser/src/beepHandler.ts b/web/src/app/browser/src/beepHandler.ts index 3659f8d7fd..eb6d6583ee 100644 --- a/web/src/app/browser/src/beepHandler.ts +++ b/web/src/app/browser/src/beepHandler.ts @@ -1,4 +1,4 @@ -import { type KeyboardInterface } from '@keymanapp/keyboard-processor'; +import { type KeyboardInterface } from 'keyman/engine/js-processor'; import { DesignIFrame, OutputTarget } from 'keyman/engine/element-wrappers'; // Utility object used to handle beep (keyboard error response) operations. diff --git a/web/src/app/browser/src/configuration.ts b/web/src/app/browser/src/configuration.ts index 07be8264e7..4f2f268438 100644 --- a/web/src/app/browser/src/configuration.ts +++ b/web/src/app/browser/src/configuration.ts @@ -1,7 +1,8 @@ import { EngineConfiguration, InitOptionSpec, InitOptionDefaults } from "keyman/engine/main"; import { OutputTarget as DOMOutputTarget } from 'keyman/engine/element-wrappers'; -import { isEmptyTransform, OutputTarget, RuleBehavior } from '@keymanapp/keyboard-processor'; +import { isEmptyTransform, OutputTarget } from '@keymanapp/keyboard-processor'; +import { RuleBehavior } from 'keyman/engine/js-processor'; import { AlertHost } from "./utils/alertHost.js"; import { whenDocumentReady } from "./utils/documentReady.js"; diff --git a/web/src/app/browser/src/defaultBrowserRules.ts b/web/src/app/browser/src/defaultBrowserRules.ts index 1ac4801689..fc084ec3f4 100644 --- a/web/src/app/browser/src/defaultBrowserRules.ts +++ b/web/src/app/browser/src/defaultBrowserRules.ts @@ -1,10 +1,10 @@ import { ModifierKeyConstants } from '@keymanapp/common-types'; import { Codes, - DefaultRules, type KeyEvent, type OutputTarget } from '@keymanapp/keyboard-processor'; +import { DefaultRules } from 'keyman/engine/js-processor'; import ContextManager from './contextManager.js'; diff --git a/web/src/app/browser/src/hardwareEventKeyboard.ts b/web/src/app/browser/src/hardwareEventKeyboard.ts index 29e867aa13..f6874fc77b 100644 --- a/web/src/app/browser/src/hardwareEventKeyboard.ts +++ b/web/src/app/browser/src/hardwareEventKeyboard.ts @@ -1,4 +1,5 @@ -import { Codes, DeviceSpec, KeyEvent, KeyMapping, Keyboard, KeyboardProcessor } from '@keymanapp/keyboard-processor'; +import { Codes, DeviceSpec, KeyEvent, KeyMapping, Keyboard } from '@keymanapp/keyboard-processor'; +import { KeyboardProcessor } from 'keyman/engine/js-processor'; import { ModifierKeyConstants } from '@keymanapp/common-types'; import { HardKeyboard, processForMnemonicsAndLegacy } from 'keyman/engine/main'; diff --git a/web/src/app/webview/src/keymanEngine.ts b/web/src/app/webview/src/keymanEngine.ts index ba98f8c477..2f07350548 100644 --- a/web/src/app/webview/src/keymanEngine.ts +++ b/web/src/app/webview/src/keymanEngine.ts @@ -1,4 +1,5 @@ -import { DefaultRules, DeviceSpec, RuleBehavior } from '@keymanapp/keyboard-processor' +import { DeviceSpec } from '@keymanapp/keyboard-processor' +import { DefaultRules, RuleBehavior } from 'keyman/engine/js-processor'; import { KeymanEngine as KeymanEngineBase, KeyboardInterface } from 'keyman/engine/main'; import { AnchoredOSKView, ViewConfiguration, StaticActivator } from 'keyman/engine/osk'; import { getAbsoluteX, getAbsoluteY } from 'keyman/engine/dom-utils'; diff --git a/web/src/engine/events/src/keyEventSource.interface.ts b/web/src/engine/events/src/keyEventSource.interface.ts index d3c39fa49d..22621d2de0 100644 --- a/web/src/engine/events/src/keyEventSource.interface.ts +++ b/web/src/engine/events/src/keyEventSource.interface.ts @@ -1,7 +1,7 @@ import { EventEmitter } from "eventemitter3"; -import { type KeyEvent, type RuleBehavior } from "@keymanapp/keyboard-processor"; +import { type KeyEvent, type RuleBehaviorInterface } from "@keymanapp/keyboard-processor"; -export type KeyEventResultCallback = (result: RuleBehavior, error?: Error) => void; +export type KeyEventResultCallback = (result: RuleBehaviorInterface, error?: Error) => void; export type KeyEventHandler = (event: KeyEvent, callback?: KeyEventResultCallback) => void; interface EventMap { diff --git a/web/src/engine/interfaces/build.sh b/web/src/engine/interfaces/build.sh index ca61e64865..528083d4d8 100755 --- a/web/src/engine/interfaces/build.sh +++ b/web/src/engine/interfaces/build.sh @@ -15,6 +15,7 @@ SUBPROJECT_NAME=engine/interfaces builder_describe "Builds configuration subclasses used by the Keyman Engine for Web (KMW)." \ "@/common/web/es-bundling" \ "@/common/web/keyboard-processor" \ + "@/web/src/engine/js-processor" \ "clean" \ "configure" \ "build" \ diff --git a/web/src/engine/interfaces/src/prediction/predictionContext.ts b/web/src/engine/interfaces/src/prediction/predictionContext.ts index d47bf4b8e2..90427c3020 100644 --- a/web/src/engine/interfaces/src/prediction/predictionContext.ts +++ b/web/src/engine/interfaces/src/prediction/predictionContext.ts @@ -1,6 +1,7 @@ import { EventEmitter } from "eventemitter3"; import { type LanguageProcessorSpec , ReadySuggestions, type InvalidateSourceEnum, StateChangeHandler } from './languageProcessor.interface.js'; -import { type KeyboardProcessor, type OutputTarget } from "@keymanapp/keyboard-processor"; +import { type OutputTarget } from "@keymanapp/keyboard-processor"; +import { type KeyboardProcessor } from 'keyman/engine/js-processor'; interface PredictionContextEventMap { update: (suggestions: Suggestion[]) => void; diff --git a/web/src/engine/interfaces/tsconfig.json b/web/src/engine/interfaces/tsconfig.json index d5a193e021..634e62bada 100644 --- a/web/src/engine/interfaces/tsconfig.json +++ b/web/src/engine/interfaces/tsconfig.json @@ -13,5 +13,6 @@ "references": [ { "path": "../../../../common/web/keyboard-processor" }, + { "path": "../js-processor" } ] } diff --git a/web/src/engine/js-processor/build.sh b/web/src/engine/js-processor/build.sh new file mode 100755 index 0000000000..57adbd1dd2 --- /dev/null +++ b/web/src/engine/js-processor/build.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +## START STANDARD BUILD SCRIPT INCLUDE +# adjust relative paths as necessary +THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" +. "${THIS_SCRIPT%/*}/../../../../resources/build/builder.inc.sh" +## END STANDARD BUILD SCRIPT INCLUDE + +SUBPROJECT_NAME=engine/js-processor + +. "${KEYMAN_ROOT}/web/common.inc.sh" +. "${KEYMAN_ROOT}/resources/shellHelperFunctions.sh" + +# ################################ Main script ################################ + +builder_describe "Builds configuration subclasses used by the Keyman Engine for Web (KMW)." \ + "clean" \ + "configure" \ + "build" \ + "test" \ + "--ci+ Set to utilize CI-based test configurations & reporting." + +builder_describe_outputs \ + configure "/node_modules" \ + build "/web/build/${SUBPROJECT_NAME}/lib/index.mjs" + +builder_parse "$@" + +#### Build action definitions #### + +do_build () { + compile "${SUBPROJECT_NAME}" + + ${BUNDLE_CMD} "${KEYMAN_ROOT}/web/build/${SUBPROJECT_NAME}/obj/index.js" \ + --out "${KEYMAN_ROOT}/web/build/${SUBPROJECT_NAME}/lib/index.mjs" \ + --format esm +} + +builder_run_action configure verify_npm_setup +builder_run_action clean rm -rf "${KEYMAN_ROOT}/web/build/${SUBPROJECT_NAME}" +builder_run_action build do_build diff --git a/common/web/keyboard-processor/src/text/defaultRules.ts b/web/src/engine/js-processor/src/defaultRules.ts similarity index 91% rename from common/web/keyboard-processor/src/text/defaultRules.ts rename to web/src/engine/js-processor/src/defaultRules.ts index 931eb5200b..edaf440bf9 100644 --- a/common/web/keyboard-processor/src/text/defaultRules.ts +++ b/web/src/engine/js-processor/src/defaultRules.ts @@ -1,18 +1,11 @@ -// TODO: Move to separate folder: 'codes' -// We should start splitting off code needed by keyboards even without a KeyboardProcessor active. -// There's an upcoming `/common/web/types` package that 'codes' and 'keyboards' may fit well within. +/* + * Keyman is copyright (C) SIL International. MIT License. + * + * Implementation of default rules + */ -import { ModifierKeyConstants} from '@keymanapp/common-types'; -import Codes from "./codes.js"; -import type KeyEvent from "./keyEvent.js"; -import type OutputTarget from "./outputTarget.js"; - -// The only members referenced are to produce warning and error logs. A little abstraction -// via an optional 'logger' interface can maintain it while facilitating a the split alluded -// to above. -// -// Alternatively, we could just... not take in the parameter at all, which'd also facilitate -// the future modularization effort. +import { ModifierKeyConstants } from '@keymanapp/common-types'; +import { BASE_DEFAULT_RULES, Codes, type KeyEvent, type OutputTarget } from "@keymanapp/keyboard-processor"; import RuleBehavior from "./ruleBehavior.js"; export enum EmulationKeystrokes { @@ -191,7 +184,7 @@ export default class DefaultRules { // check if exact match to SHIFT's code. Only the 'default' and 'shift' layers should have default key outputs. // TODO: Extend to allow AltGr as well - better mnemonic support. - if(keyShiftState == ModifierKeyConstants.K_SHIFTFLAG) { + if (keyShiftState == ModifierKeyConstants.K_SHIFTFLAG) { keyShiftState = 1; } else if(keyShiftState != 0) { if(ruleBehavior) { @@ -224,3 +217,9 @@ export default class DefaultRules { return null; } } + +/** + * A simple instance of the standard 'default rules' for keystroke processing from the + * DefaultRules base class. + */ +BASE_DEFAULT_RULES.instance = new DefaultRules(); diff --git a/web/src/engine/js-processor/src/index.ts b/web/src/engine/js-processor/src/index.ts new file mode 100644 index 0000000000..1c51de80d9 --- /dev/null +++ b/web/src/engine/js-processor/src/index.ts @@ -0,0 +1,7 @@ +export { default as DefaultRules } from "./defaultRules.js"; +export * from "./defaultRules.js"; +export { default as KeyboardProcessor } from "./keyboardProcessor.js"; +export * from "./keyboardProcessor.js"; +export { default as RuleBehavior } from "./ruleBehavior.js"; +export * from './kbdInterface.js'; +export { default as KeyboardInterface } from "./kbdInterface.js"; diff --git a/common/web/keyboard-processor/src/text/kbdInterface.ts b/web/src/engine/js-processor/src/kbdInterface.ts similarity index 94% rename from common/web/keyboard-processor/src/text/kbdInterface.ts rename to web/src/engine/js-processor/src/kbdInterface.ts index 438d328f0d..2b34eadce9 100644 --- a/common/web/keyboard-processor/src/text/kbdInterface.ts +++ b/web/src/engine/js-processor/src/kbdInterface.ts @@ -7,18 +7,8 @@ import { type DeviceSpec } from "@keymanapp/web-utils"; import { ModifierKeyConstants } from '@keymanapp/common-types'; - -import Codes from "./codes.js"; -import type KeyEvent from "./keyEvent.js"; -import type { Deadkey } from "./deadkeys.js"; -import KeyMapping from "./keyMapping.js"; -import { SystemStore, MutableSystemStore, PlatformSystemStore } from "./systemStores.js"; -import type { VariableStoreSerializer } from "./keyboardProcessor.js"; -import type OutputTarget from "./outputTarget.js"; -import { Mock } from "./outputTarget.js"; +import { Codes, type KeyEvent, type Deadkey, ComplexKeyboardStore, type KeyboardStore, KeyboardStoreElement, KeyMapping, SystemStoreIDs, SystemStore, MutableSystemStore, PlatformSystemStore, type OutputTarget, Mock, Keyboard, VariableStore, VariableStoreDictionary, VariableStoreSerializer, KeyboardHarness, KeyboardKeymanGlobal, RuleDeadkey, ContextAny, RuleIndex, ContextEx, ContextNul, RuleChar } from "@keymanapp/keyboard-processor"; import RuleBehavior from "./ruleBehavior.js"; -import Keyboard, { VariableStoreDictionary } from "../keyboards/keyboard.js"; -import { KeyboardHarness, KeyboardKeymanGlobal } from "../keyboards/keyboardHarness.js"; //#endregion @@ -30,93 +20,9 @@ export class KeyInformation { modifiers: number; } -/* -* Type alias definitions to reflect the parameters of the fullContextMatch() callback (KMW 10+). -* No constructors or methods since keyboards will not utilize the same backing prototype, and -* property names are shorthanded to promote minification. -*/ -type PlainKeyboardStore = string; - -export type KeyboardStoreElement = (string|StoreNonCharEntry); -export type ComplexKeyboardStore = KeyboardStoreElement[]; - -type KeyboardStore = PlainKeyboardStore | ComplexKeyboardStore; - -export type VariableStore = {[name: string]: string}; - -type RuleChar = string; - -class RuleDeadkey { - /** Discriminant field - 'd' for Deadkey. - */ - t: 'd'; - - /** - * Value: the deadkey's ID. - */ - d: number; // For 'd'eadkey; also reflects the Deadkey class's 'd' property. -} - -class ContextAny { - /** Discriminant field - 'a' for `any()`. - */ - ['t']: 'a'; - - /** - * Value: the store to search. - */ - ['a']: KeyboardStore; // For 'a'ny statement. - - /** - * If set to true, negates the 'any'. - */ - ['n']: boolean|0|1; -} - -class RuleIndex { - /** Discriminant field - 'i' for `index()`. - */ - ['t']: 'i'; - - /** - * Value: the Store from which to output - */ - ['i']: KeyboardStore; - - /** - * Offset: the offset in context for the corresponding `any()`. - */ - ['o']: number; -} - -class ContextEx { - /** Discriminant field - 'c' for `context()`. - */ - ['t']: 'c'; - - /** - * Value: The offset into the current rule's context to be matched. - */ - ['c']: number; // For 'c'ontext statement. -} - -class ContextNul { - /** Discriminant field - 'n' for `nul` - */ - ['t']: 'n'; -} - -class StoreBeep { - /** Discriminant field - 'b' for `beep` - */ - ['t']: 'b'; -} - type ContextNonCharEntry = RuleDeadkey | ContextAny | RuleIndex | ContextEx | ContextNul; type ContextEntry = RuleChar | ContextNonCharEntry; -type StoreNonCharEntry = RuleDeadkey | StoreBeep; - /** * Cache of context storing and retrieving return values from KC * Must be reset prior to each keystroke and after any text changes @@ -183,13 +89,6 @@ class CachedContextEx { } }; -export enum SystemStoreIDs { - TSS_LAYER = 33, - TSS_PLATFORM = 31, - TSS_NEWLAYER = 42, - TSS_OLDLAYER = 43 -} - //#endregion export default class KeyboardInterface extends KeyboardHarness { diff --git a/common/web/keyboard-processor/src/text/keyboardProcessor.ts b/web/src/engine/js-processor/src/keyboardProcessor.ts similarity index 96% rename from common/web/keyboard-processor/src/text/keyboardProcessor.ts rename to web/src/engine/js-processor/src/keyboardProcessor.ts index 836c9912a6..1a6d216dce 100644 --- a/common/web/keyboard-processor/src/text/keyboardProcessor.ts +++ b/web/src/engine/js-processor/src/keyboardProcessor.ts @@ -1,23 +1,21 @@ +/* + * Keyman is copyright (C) SIL International. MIT License. + * + * Implementation of the JavaScript keyboard processor + */ + // #region Big ol' list of imports import { EventEmitter } from 'eventemitter3'; - -import Codes from "./codes.js"; -import type Keyboard from "../keyboards/keyboard.js"; -import { MinimalKeymanGlobal } from '../keyboards/keyboardHarness.js'; -import KeyEvent from "./keyEvent.js"; -import { Layouts } from "../keyboards/defaultLayouts.js"; -import type { MutableSystemStore } from "./systemStores.js"; - -import DefaultRules, { EmulationKeystrokes } from "./defaultRules.js"; -import type OutputTarget from "./outputTarget.js"; -import { Mock } from "./outputTarget.js"; - -import KeyboardInterface, { SystemStoreIDs, VariableStore } from "./kbdInterface.js"; -import RuleBehavior from "./ruleBehavior.js"; - -import { DeviceSpec, globalObject } from "@keymanapp/web-utils"; import { ModifierKeyConstants } from '@keymanapp/common-types'; +import { + Codes, type Keyboard, MinimalKeymanGlobal, KeyEvent, Layouts, type MutableSystemStore, + type OutputTarget, Mock, SystemStoreIDs, +} from "@keymanapp/keyboard-processor"; +import DefaultRules, { EmulationKeystrokes } from "./defaultRules.js"; +import RuleBehavior from "./ruleBehavior.js"; +import KeyboardInterface from './kbdInterface.js'; +import { DeviceSpec, globalObject } from "@keymanapp/web-utils"; // #endregion @@ -26,11 +24,6 @@ import { ModifierKeyConstants } from '@keymanapp/common-types'; export type BeepHandler = (outputTarget: OutputTarget) => void; export type LogMessageHandler = (str: string) => void; -export interface VariableStoreSerializer { - loadStore(keyboardID: string, storeName: string): VariableStore; - saveStore(keyboardID: string, storeName: string, storeMap: VariableStore): void; -} - export interface ProcessorInitOptions { baseLayout?: string; keyboardInterface?: KeyboardInterface; @@ -277,7 +270,8 @@ export default class KeyboardProcessor extends EventEmitter { const lockNames = ['CAPS', 'NUM_LOCK', 'SCROLL_LOCK'] as const; const lockKeys = ['K_CAPS', 'K_NUMLOCK', 'K_SCROLL'] as const; - const lockModifiers = [ ModifierKeyConstants.CAPITALFLAG, ModifierKeyConstants.NUMLOCKFLAG, ModifierKeyConstants.SCROLLFLAG] as const; + const lockModifiers = [ModifierKeyConstants.CAPITALFLAG, ModifierKeyConstants.NUMLOCKFLAG, ModifierKeyConstants.SCROLLFLAG] as const; + if(!this.activeKeyboard) { return true; @@ -329,6 +323,8 @@ export default class KeyboardProcessor extends EventEmitter { const lockModifiers = [ModifierKeyConstants.CAPITALFLAG, ModifierKeyConstants.NUMLOCKFLAG, ModifierKeyConstants.SCROLLFLAG] as const; const noLockModifers = [ModifierKeyConstants.NOTCAPITALFLAG, ModifierKeyConstants.NOTNUMLOCKFLAG, ModifierKeyConstants.NOTSCROLLFLAG] as const; + + for(let i=0; i < lockKeys.length; i++) { const key = lockKeys[i]; const flag = this.stateKeys[key]; diff --git a/common/web/keyboard-processor/src/text/ruleBehavior.ts b/web/src/engine/js-processor/src/ruleBehavior.ts similarity index 96% rename from common/web/keyboard-processor/src/text/ruleBehavior.ts rename to web/src/engine/js-processor/src/ruleBehavior.ts index e5d669e909..aced7065d2 100644 --- a/common/web/keyboard-processor/src/text/ruleBehavior.ts +++ b/web/src/engine/js-processor/src/ruleBehavior.ts @@ -1,9 +1,7 @@ /// import KeyboardProcessor from "./keyboardProcessor.js"; -import OutputTarget, { Mock, type Transcription } from "./outputTarget.js"; -import { VariableStoreDictionary } from "../keyboards/keyboard.js"; -import type { VariableStore } from "./kbdInterface.js"; +import { OutputTarget, Mock, type Transcription, VariableStoreDictionary, type VariableStore } from "@keymanapp/keyboard-processor"; /** * Represents the commands and state changes that result from a matched keyboard rule. diff --git a/web/src/engine/js-processor/tsconfig.json b/web/src/engine/js-processor/tsconfig.json new file mode 100644 index 0000000000..a57467139b --- /dev/null +++ b/web/src/engine/js-processor/tsconfig.json @@ -0,0 +1,13 @@ +{ + // While the actual references themselves are headless, it compiles against the DOM-reliant OSK module. + "extends": "../../tsconfig.dom.json", + + "compilerOptions": { + "baseUrl": "./", + "outDir": "../../../build/engine/js-processor/obj/", + "tsBuildInfoFile": "../../../build/engine/js-processor/obj/tsconfig.tsbuildinfo", + "rootDir": "./src" + }, + + "include": [ "**/*.ts" ], +} diff --git a/web/src/engine/main/build.sh b/web/src/engine/main/build.sh index cceb9b4b8b..4e6ca67db1 100755 --- a/web/src/engine/main/build.sh +++ b/web/src/engine/main/build.sh @@ -18,6 +18,7 @@ builder_describe "Builds the Keyman Engine for Web's common top-level base class "@/common/predictive-text" \ "@/web/src/engine/interfaces build" \ "@/web/src/engine/device-detect build" \ + "@/web/src/engine/js-processor build" \ "@/web/src/engine/package-cache build" \ "@/web/src/engine/osk build" \ "@/developer/src/kmc-model test" \ diff --git a/web/src/engine/main/src/contextManagerBase.ts b/web/src/engine/main/src/contextManagerBase.ts index c3f9581003..e745dbe312 100644 --- a/web/src/engine/main/src/contextManagerBase.ts +++ b/web/src/engine/main/src/contextManagerBase.ts @@ -1,5 +1,6 @@ import { EventEmitter } from 'eventemitter3'; -import { ManagedPromise, type Keyboard, type KeyboardInterface, type OutputTarget } from '@keymanapp/keyboard-processor'; +import { ManagedPromise, type Keyboard, type OutputTarget } from '@keymanapp/keyboard-processor'; +import { type KeyboardInterface } from 'keyman/engine/js-processor'; import { StubAndKeyboardCache, type KeyboardStub } from 'keyman/engine/package-cache'; import { PredictionContext } from 'keyman/engine/interfaces'; import { EngineConfiguration } from './engineConfiguration.js'; diff --git a/web/src/engine/main/src/engineConfiguration.ts b/web/src/engine/main/src/engineConfiguration.ts index c66d3bd805..bb82844c56 100644 --- a/web/src/engine/main/src/engineConfiguration.ts +++ b/web/src/engine/main/src/engineConfiguration.ts @@ -1,6 +1,7 @@ import { EventEmitter } from "eventemitter3"; -import { DeviceSpec, KeyboardProperties, ManagedPromise, OutputTarget, physicalKeyDeviceAlias, RuleBehavior, SpacebarText } from "@keymanapp/keyboard-processor"; +import { DeviceSpec, KeyboardProperties, ManagedPromise, OutputTarget, physicalKeyDeviceAlias, SpacebarText } from "@keymanapp/keyboard-processor"; +import { RuleBehavior } from 'keyman/engine/js-processor'; import { PathConfiguration, PathOptionDefaults, PathOptionSpec } from "keyman/engine/interfaces"; import { Device } from "keyman/engine/device-detect"; import { KeyboardStub } from "keyman/engine/package-cache"; diff --git a/web/src/engine/main/src/hardKeyboard.ts b/web/src/engine/main/src/hardKeyboard.ts index a07904f4a6..7dc9b5e357 100644 --- a/web/src/engine/main/src/hardKeyboard.ts +++ b/web/src/engine/main/src/hardKeyboard.ts @@ -1,5 +1,6 @@ import { EventEmitter } from "eventemitter3"; -import { Keyboard, KeyMapping, KeyEvent, type RuleBehavior, Codes } from "@keymanapp/keyboard-processor"; +import { Keyboard, KeyMapping, KeyEvent, Codes } from "@keymanapp/keyboard-processor"; +import { type RuleBehavior } from 'keyman/engine/js-processor'; import { KeyEventSourceInterface } from 'keyman/engine/events'; import { ModifierKeyConstants } from '@keymanapp/common-types'; diff --git a/web/src/engine/main/src/headless/inputProcessor.ts b/web/src/engine/main/src/headless/inputProcessor.ts index 7b89a0e242..a96170457e 100644 --- a/web/src/engine/main/src/headless/inputProcessor.ts +++ b/web/src/engine/main/src/headless/inputProcessor.ts @@ -12,15 +12,13 @@ import { Codes, isEmptyTransform, type Keyboard, - KeyboardInterface, - KeyboardProcessor, type KeyEvent, Mock, type OutputTarget, - type ProcessorInitOptions, - RuleBehavior, SystemStoreIDs, } from "@keymanapp/keyboard-processor"; +import { KeyboardInterface, KeyboardProcessor, RuleBehavior, type ProcessorInitOptions } from 'keyman/engine/js-processor'; + import { TranscriptionCache } from "./transcriptionCache.js"; export class InputProcessor { diff --git a/web/src/engine/main/src/keyboardInterface.ts b/web/src/engine/main/src/keyboardInterface.ts index a18bafecd0..d966c26bad 100644 --- a/web/src/engine/main/src/keyboardInterface.ts +++ b/web/src/engine/main/src/keyboardInterface.ts @@ -1,6 +1,5 @@ -import { - KeyboardInterface as KeyboardInterfaceBase, KeyboardObject, -} from "@keymanapp/keyboard-processor"; +import { KeyboardObject } from "@keymanapp/keyboard-processor"; +import { KeyboardInterface as KeyboardInterfaceBase } from 'keyman/engine/js-processor'; import { KeyboardStub, RawKeyboardStub, toUnprefixedKeyboardId as unprefixed } from 'keyman/engine/package-cache'; import { ContextManagerBase } from './contextManagerBase.js'; diff --git a/web/src/engine/main/src/keymanEngine.ts b/web/src/engine/main/src/keymanEngine.ts index eaa54e5994..86ff9d5898 100644 --- a/web/src/engine/main/src/keymanEngine.ts +++ b/web/src/engine/main/src/keymanEngine.ts @@ -1,4 +1,5 @@ -import { type Keyboard, KeyboardKeymanGlobal, ProcessorInitOptions } from "@keymanapp/keyboard-processor"; +import { type KeyEvent, type Keyboard, KeyboardKeymanGlobal } from "@keymanapp/keyboard-processor"; +import { ProcessorInitOptions, RuleBehavior } from 'keyman/engine/js-processor'; import { DOMKeyboardLoader as KeyboardLoader } from "@keymanapp/keyboard-processor/dom-keyboard-loader"; import { InputProcessor } from './headless/inputProcessor.js'; import { OSKView } from "keyman/engine/osk"; @@ -10,7 +11,7 @@ import KeyboardInterface from "./keyboardInterface.js"; import { ContextManagerBase } from "./contextManagerBase.js"; import HardKeyboardBase from "./hardKeyboard.js"; import { LegacyAPIEvents } from "./legacyAPIEvents.js"; -import { KeyEventHandler, EventNames, EventListener, LegacyEventEmitter } from "keyman/engine/events"; +import { EventNames, EventListener, LegacyEventEmitter } from "keyman/engine/events"; import DOMCloudRequester from "keyman/engine/package-cache/dom-requester"; import KEYMAN_VERSION from "@keymanapp/keyman-version"; @@ -29,6 +30,9 @@ function determineBaseLayout(): string { } } +export type KeyEventFullResultCallback = (result: RuleBehavior, error?: Error) => void; +export type KeyEventFullHandler = (event: KeyEvent, callback?: KeyEventFullResultCallback) => void; + export default class KeymanEngine< Configuration extends EngineConfiguration, ContextManager extends ContextManagerBase, @@ -47,7 +51,7 @@ export default class KeymanEngine< protected keyEventRefocus?: () => void; - private keyEventListener: KeyEventHandler = (event, callback) => { + private keyEventListener: KeyEventFullHandler = (event, callback) => { const outputTarget = this.contextManager.activeTarget; if(!this.contextManager.activeKeyboard || !outputTarget) { diff --git a/web/src/engine/main/tsconfig.json b/web/src/engine/main/tsconfig.json index 9711d06a77..e3b2b0616c 100644 --- a/web/src/engine/main/tsconfig.json +++ b/web/src/engine/main/tsconfig.json @@ -15,5 +15,6 @@ { "path": "../osk" }, { "path": "../package-cache" }, { "path": "../interfaces" }, + { "path": "../js-processor" } ] } diff --git a/common/web/keyboard-processor/tests/dom/cases/domKeyboardLoader.spec.ts b/web/src/test/auto/dom/cases/keyboard-processor/domKeyboardLoader.spec.ts similarity index 95% rename from common/web/keyboard-processor/tests/dom/cases/domKeyboardLoader.spec.ts rename to web/src/test/auto/dom/cases/keyboard-processor/domKeyboardLoader.spec.ts index 1965adc853..63414662fa 100644 --- a/common/web/keyboard-processor/tests/dom/cases/domKeyboardLoader.spec.ts +++ b/web/src/test/auto/dom/cases/keyboard-processor/domKeyboardLoader.spec.ts @@ -1,7 +1,8 @@ import { assert } from 'chai'; import { DOMKeyboardLoader } from '@keymanapp/keyboard-processor/dom-keyboard-loader'; -import { extendString, KeyboardHarness, Keyboard, KeyboardInterface, MinimalKeymanGlobal, Mock, DeviceSpec, KeyboardKeymanGlobal } from '@keymanapp/keyboard-processor'; +import { extendString, KeyboardHarness, Keyboard, MinimalKeymanGlobal, Mock, DeviceSpec, KeyboardKeymanGlobal } from '@keymanapp/keyboard-processor'; +import { KeyboardInterface } from 'keyman/engine/js-processor'; declare let window: typeof globalThis; // KeymanEngine from the web/ folder... when available. diff --git a/web/src/test/auto/dom/kbdLoader.ts b/web/src/test/auto/dom/kbdLoader.ts index 629ade205e..2254011857 100644 --- a/web/src/test/auto/dom/kbdLoader.ts +++ b/web/src/test/auto/dom/kbdLoader.ts @@ -4,11 +4,11 @@ import { import { Keyboard, - KeyboardInterface, KeyboardProperties, MinimalKeymanGlobal } from '@keymanapp/keyboard-processor'; +import { KeyboardInterface } from 'keyman/engine/js-processor'; import { KeyboardStub } from 'keyman/engine/package-cache'; const loader = new DOMKeyboardLoader(new KeyboardInterface(window, MinimalKeymanGlobal)); diff --git a/web/src/test/auto/headless/engine/interfaces/prediction/predictionContext.spec.js b/web/src/test/auto/headless/engine/interfaces/prediction/predictionContext.spec.js index ba4808e66a..97ce24d036 100644 --- a/web/src/test/auto/headless/engine/interfaces/prediction/predictionContext.spec.js +++ b/web/src/test/auto/headless/engine/interfaces/prediction/predictionContext.spec.js @@ -4,7 +4,8 @@ import sinon from 'sinon'; import { LanguageProcessor, TranscriptionCache } from 'keyman/engine/main'; import { PredictionContext } from 'keyman/engine/interfaces'; import { Worker as LMWorker } from "@keymanapp/lexical-model-layer/node"; -import { DeviceSpec, KeyboardProcessor, Mock } from '@keymanapp/keyboard-processor'; +import { DeviceSpec, Mock } from '@keymanapp/keyboard-processor'; +import { KeyboardProcessor } from 'keyman/engine/js-processor'; function compileDummyModel(suggestionSets) { return ` diff --git a/web/src/tools/testing/recorder-core/src/nodeProctor.ts b/web/src/tools/testing/recorder-core/src/nodeProctor.ts index 6f6d7fd6a0..852002d4b3 100644 --- a/web/src/tools/testing/recorder-core/src/nodeProctor.ts +++ b/web/src/tools/testing/recorder-core/src/nodeProctor.ts @@ -8,8 +8,9 @@ import { RecordedSyntheticKeystroke } from "./index.js"; -import { KeyboardInterface, KeyEvent, KeyEventSpec, KeyboardProcessor, Mock, type OutputTarget, KeyboardHarness } from "@keymanapp/keyboard-processor"; +import { KeyEvent, KeyEventSpec, Mock, type OutputTarget, KeyboardHarness } from "@keymanapp/keyboard-processor"; import { DeviceSpec } from "@keymanapp/web-utils"; +import { KeyboardInterface, KeyboardProcessor } from 'keyman/engine/js-processor'; export default class NodeProctor extends Proctor { private keyboardWithHarness: KeyboardHarness; diff --git a/web/src/tools/testing/recorder-core/tsconfig.json b/web/src/tools/testing/recorder-core/tsconfig.json index a7bd08c374..38af26e1a4 100644 --- a/web/src/tools/testing/recorder-core/tsconfig.json +++ b/web/src/tools/testing/recorder-core/tsconfig.json @@ -17,6 +17,7 @@ { "path": "../../../../../common/web/keyman-version" }, { "path": "../../../../../common/web/utils/" }, { "path": "../../../../../common/web/keyboard-processor/" }, - { "path": "../../../../../common/web/lm-message-types" } + { "path": "../../../../../common/web/lm-message-types" }, + { "path": "../../../engine/js-processor" } ], } From bba694c306d17a841b2e86606de86638bbfa4397 Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Mon, 12 Aug 2024 19:33:29 +0200 Subject: [PATCH 307/327] refactor(web): work around global in interface --- .../keyboard-processor/src/text/keyEvent.ts | 19 +++++-------------- .../engine/js-processor/src/defaultRules.ts | 12 ++++-------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/common/web/keyboard-processor/src/text/keyEvent.ts b/common/web/keyboard-processor/src/text/keyEvent.ts index 7c507cc170..2d0ee49322 100644 --- a/common/web/keyboard-processor/src/text/keyEvent.ts +++ b/common/web/keyboard-processor/src/text/keyEvent.ts @@ -12,23 +12,14 @@ import { type DeviceSpec } from "@keymanapp/web-utils"; import Codes from './codes.js'; import { ActiveKeyBase } from "../index.js"; -interface DefaultRulesInterface { +export interface DefaultRulesInterface { forAny(Lkc: KeyEvent, isMnemonic: boolean): string; } -export class BASE_DEFAULT_RULES { - private static _instance: DefaultRulesInterface; +let defaultRules: DefaultRulesInterface; - // Prevent direct instantiation. - private constructor() { } - - public static forAny(Lkc: KeyEvent, isMnemonic: boolean): string { - return this._instance.forAny(Lkc, isMnemonic); - } - - public static set instance(value: DefaultRulesInterface) { - this._instance = value; - } +export function setDefaultRules(rules: DefaultRulesInterface) { + defaultRules = rules; } // Represents a probability distribution over a keyboard's keys. @@ -168,7 +159,7 @@ export default class KeyEvent implements KeyEventSpec { // the actual keyname instead. mappingEvent.kName = 'K_xxxx'; mappingEvent.Lmodifiers = (shifted ? 0x10 : 0); // mnemonic lookups only exist for default & shift layers. - var mappedChar: string = BASE_DEFAULT_RULES.forAny(mappingEvent, true); + var mappedChar: string = defaultRules.forAny(mappingEvent, true); /* First, save a backup of the original code. This one won't needlessly trigger keyboard * rules, but allows us to replicate/emulate commands after rule processing if needed. diff --git a/web/src/engine/js-processor/src/defaultRules.ts b/web/src/engine/js-processor/src/defaultRules.ts index edaf440bf9..3d56a2dad8 100644 --- a/web/src/engine/js-processor/src/defaultRules.ts +++ b/web/src/engine/js-processor/src/defaultRules.ts @@ -5,7 +5,7 @@ */ import { ModifierKeyConstants } from '@keymanapp/common-types'; -import { BASE_DEFAULT_RULES, Codes, type KeyEvent, type OutputTarget } from "@keymanapp/keyboard-processor"; +import { Codes, type KeyEvent, type OutputTarget, setDefaultRules } from "@keymanapp/keyboard-processor"; import RuleBehavior from "./ruleBehavior.js"; export enum EmulationKeystrokes { @@ -13,11 +13,13 @@ export enum EmulationKeystrokes { Backspace = '\b' } + /** * Defines a collection of static library functions that define KeymanWeb's default (implied) keyboard rule behaviors. */ export default class DefaultRules { public constructor() { + setDefaultRules(this); } codeForEvent(Lkc: KeyEvent) { @@ -28,7 +30,7 @@ export default class DefaultRules { * Serves as a default keycode lookup table. This may be referenced safely by mnemonic handling without fear of side-effects. * Also used by Processor.defaultRuleBehavior to generate output after filtering for special cases. */ - public forAny(Lkc: KeyEvent, isMnemonic: boolean, ruleBehavior?: RuleBehavior) { + public forAny(Lkc: KeyEvent, isMnemonic: boolean, ruleBehavior?: RuleBehavior): string { var char = ''; // A pretty simple table of lookups, corresponding VERY closely to the original defaultKeyOutput. @@ -217,9 +219,3 @@ export default class DefaultRules { return null; } } - -/** - * A simple instance of the standard 'default rules' for keystroke processing from the - * DefaultRules base class. - */ -BASE_DEFAULT_RULES.instance = new DefaultRules(); From 46ecfd446676445cf880c7bc0d3c857c80bc2809 Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Wed, 7 Aug 2024 19:39:42 +0200 Subject: [PATCH 308/327] =?UTF-8?q?refactor(web):=20move=20remaining=20par?= =?UTF-8?q?ts=20of=20`keyboard-processor`=20=E2=86=92=20`keyboard`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit move parts of `common/web/keyboard-processor/` → `web/src/engine/keyboard/`. Fixes: #12110 --- common/web/keyboard-processor/package.json | 69 ------------------- .../src/keyboards/loaders/tsconfig.dom.json | 13 ---- .../src/keyboards/loaders/tsconfig.node.json | 14 ---- common/web/keyboard-processor/tsconfig.json | 18 ----- .../keyman-touch-layout-file.ts | 2 +- package-lock.json | 23 ------- tsconfig.base.json | 1 - tsconfig.json | 1 - web/README.md | 2 +- web/build.sh | 2 + web/ci.sh | 2 +- web/package.json | 16 ++++- web/src/app/browser/src/configuration.ts | 2 +- web/src/app/browser/src/contextManager.ts | 2 +- .../app/browser/src/defaultBrowserRules.ts | 2 +- .../app/browser/src/hardwareEventKeyboard.ts | 2 +- web/src/app/browser/src/keymanEngine.ts | 2 +- web/src/app/webview/src/contextManager.ts | 2 +- web/src/app/webview/src/keymanEngine.ts | 2 +- web/src/app/webview/src/oskConfiguration.ts | 2 +- .../app/webview/src/passthroughKeyboard.ts | 2 +- .../attachment/src/pageContextAttachment.ts | 2 +- web/src/engine/dom-utils/build.sh | 2 +- web/src/engine/dom-utils/src/stylesheets.ts | 2 +- web/src/engine/dom-utils/tsconfig.json | 2 +- web/src/engine/element-wrappers/build.sh | 2 +- web/src/engine/element-wrappers/readme.md | 2 +- .../element-wrappers/src/outputTarget.ts | 2 +- web/src/engine/element-wrappers/tsconfig.json | 2 +- web/src/engine/events/build.sh | 2 +- .../events/src/keyEventSource.interface.ts | 2 +- web/src/engine/events/tsconfig.json | 2 +- web/src/engine/interfaces/build.sh | 2 +- .../prediction/languageProcessor.interface.ts | 2 +- .../src/prediction/predictionContext.ts | 2 +- web/src/engine/interfaces/tsconfig.json | 2 +- .../engine/js-processor/src/defaultRules.ts | 3 +- .../engine/js-processor/src/kbdInterface.ts | 4 +- .../js-processor/src/keyboardProcessor.ts | 2 +- .../engine/js-processor/src/ruleBehavior.ts | 2 +- .../src/engine/keyboard}/.c8rc.json | 0 .../src/engine/keyboard}/.gitignore | 0 .../src/engine/keyboard}/README.md | 3 +- .../src/engine/keyboard}/build.sh | 43 ++++++------ .../src/engine/keyboard/src}/codes.ts | 0 .../src/engine/keyboard/src}/deadkeys.ts | 0 .../src/engine/keyboard}/src/index.ts | 22 +++--- .../src/engine/keyboard/src}/keyEvent.ts | 4 +- .../src/engine/keyboard/src}/keyMapping.ts | 0 .../keyboard}/src/keyboards/activeLayout.ts | 8 +-- .../keyboard}/src/keyboards/defaultLayouts.ts | 2 +- .../keyboard}/src/keyboards/keyboard.ts | 8 +-- .../src/keyboards/keyboardHarness.ts | 2 +- .../src/keyboards/keyboardLoaderBase.ts | 0 .../src/keyboards/keyboardProperties.ts | 0 .../keyboards/loaders/dom-keyboard-loader.ts | 0 .../keyboards/loaders/domKeyboardLoader.ts | 2 +- .../keyboards/loaders/node-keyboard-loader.ts | 0 .../keyboards/loaders/nodeKeyboardLoader.ts | 2 +- .../src/keyboards/loaders/tsconfig.dom.json | 13 ++++ .../src/keyboards/loaders/tsconfig.node.json | 14 ++++ .../keyboard}/src/keyboards/spacebarText.ts | 0 .../keyboard}/src/keyboards/stateKeyMap.ts | 2 +- .../src/engine/keyboard/src}/outputTarget.ts | 0 .../keyboard/src}/ruleBehavior.interface.ts | 0 .../engine/keyboard/src}/stringDivergence.ts | 0 .../src/engine/keyboard/src}/systemStores.ts | 4 +- .../keyboard}/tests/node/basic-engine.js | 7 +- .../engine/keyboard}/tests/node/basic-init.js | 4 +- .../keyboard}/tests/node/bundled-module.js | 6 +- .../engine/keyboard}/tests/node/chirality.js | 7 +- .../engine/keyboard}/tests/node/deadkeys.js | 7 +- .../keyboard}/tests/node/engine/context.js | 5 +- .../tests/node/engine/notany_context.js | 5 +- .../keyboard}/tests/node/engine/stores.js | 3 +- .../node/engine/unmatched_final_group.js | 7 +- .../keyboard}/tests/node/keyboard-loading.js | 5 +- .../tests/node/keyboard-properties.js | 2 +- .../src/engine/keyboard}/tests/node/mocks.js | 2 +- .../tests/node/non-positional-rules.js | 5 +- .../tests/node/specialized-backspace.js | 5 +- .../keyboard}/tests/node/transcriptions.js | 2 +- .../src/engine/keyboard}/tsconfig.all.json | 6 +- web/src/engine/keyboard/tsconfig.json | 12 ++++ web/src/engine/main/build.sh | 2 +- web/src/engine/main/src/contextManagerBase.ts | 2 +- .../engine/main/src/engineConfiguration.ts | 2 +- web/src/engine/main/src/hardKeyboard.ts | 2 +- .../engine/main/src/headless/contextWindow.ts | 2 +- .../main/src/headless/inputProcessor.ts | 2 +- .../main/src/headless/languageProcessor.ts | 2 +- .../main/src/headless/transcriptionCache.ts | 2 +- web/src/engine/main/src/keyboardInterface.ts | 2 +- web/src/engine/main/src/keymanEngine.ts | 6 +- .../main/src/variableStoreCookieSerializer.ts | 2 +- web/src/engine/osk/build.sh | 2 +- web/src/engine/osk/src/banner/banner.ts | 2 +- .../engine/osk/src/banner/bannerController.ts | 2 +- .../engine/osk/src/banner/suggestionBanner.ts | 2 +- .../engine/osk/src/components/helpPageView.ts | 2 +- web/src/engine/osk/src/components/titleBar.ts | 2 +- web/src/engine/osk/src/correctionLayout.ts | 2 +- web/src/engine/osk/src/corrections.ts | 2 +- web/src/engine/osk/src/index.ts | 2 +- .../osk/src/input/gestures/browser/flick.ts | 2 +- .../src/input/gestures/browser/modipress.ts | 2 +- .../src/input/gestures/browser/multitap.ts | 2 +- .../src/input/gestures/browser/oskSubKey.ts | 2 +- .../src/input/gestures/browser/subkeyPopup.ts | 2 +- .../osk/src/input/gestures/gestureHandler.ts | 2 +- .../osk/src/input/gestures/heldRepeater.ts | 2 +- .../osk/src/input/gestures/specsForLayout.ts | 2 +- web/src/engine/osk/src/keyElement.ts | 2 +- .../src/keyboard-layout/gesturePreviewHost.ts | 2 +- .../osk/src/keyboard-layout/oskBaseKey.ts | 2 +- .../engine/osk/src/keyboard-layout/oskKey.ts | 2 +- .../osk/src/keyboard-layout/oskLayer.ts | 2 +- .../osk/src/keyboard-layout/oskLayerGroup.ts | 2 +- .../engine/osk/src/keyboard-layout/oskRow.ts | 2 +- .../engine/osk/src/views/anchoredOskView.ts | 2 +- .../engine/osk/src/views/floatingOskView.ts | 2 +- .../engine/osk/src/views/inlinedOskView.ts | 2 +- web/src/engine/osk/src/views/oskView.ts | 2 +- web/src/engine/osk/src/visualKeyboard.ts | 2 +- .../package-cache/src/cloud/queryEngine.ts | 2 +- .../src/cloud/requesterInterface.ts | 2 +- .../package-cache/src/domCloudRequester.ts | 2 +- .../src/keyboardRequisitioner.ts | 2 +- .../engine/package-cache/src/keyboardStub.ts | 2 +- .../package-cache/src/nodeCloudRequester.ts | 2 +- .../package-cache/src/stubAndKeyboardCache.ts | 2 +- .../dom/cases/browser/contextManager.spec.ts | 4 +- .../element_interfaces.spec.ts | 4 +- .../element-wrappers/target_mocks.spec.ts | 2 +- .../domKeyboardLoader.spec.ts | 4 +- .../packages/keyboardRequisitioner.spec.ts | 4 +- web/src/test/auto/dom/kbdLoader.ts | 4 +- .../hardware-event-processing.tests.ts | 4 +- .../prediction/predictionContext.spec.js | 2 +- .../main/headless/inputProcessor.spec.js | 8 +-- .../main/headless/languageProcessor.spec.js | 6 +- .../gestures/browser/subkeyPopup.tests.ts | 2 +- .../package-cache/keyboardRequisitioner.js | 4 +- .../package-cache/stubAndKeyboardCache.js | 4 +- .../test/manual/web/chirality/chirality.js | 6 +- web/src/test/manual/web/osk/kbdLoader.mjs | 6 +- web/src/tools/build.sh | 2 +- .../tools/testing/recorder-core/package.json | 1 - .../tools/testing/recorder-core/src/index.ts | 4 +- .../testing/recorder-core/src/nodeProctor.ts | 2 +- .../testing/recorder-core/src/proctor.ts | 4 +- .../tools/testing/recorder-core/tsconfig.json | 4 +- .../tools/testing/recorder/browserProctor.ts | 2 +- web/src/tools/testing/recorder/build.sh | 2 +- web/src/tools/testing/recorder/scribe.ts | 2 +- web/src/tools/testing/recorder/tsconfig.json | 2 +- 156 files changed, 277 insertions(+), 351 deletions(-) delete mode 100644 common/web/keyboard-processor/package.json delete mode 100644 common/web/keyboard-processor/src/keyboards/loaders/tsconfig.dom.json delete mode 100644 common/web/keyboard-processor/src/keyboards/loaders/tsconfig.node.json delete mode 100644 common/web/keyboard-processor/tsconfig.json rename {common/web/keyboard-processor => web/src/engine/keyboard}/.c8rc.json (100%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/.gitignore (100%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/README.md (92%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/build.sh (54%) rename {common/web/keyboard-processor/src/text => web/src/engine/keyboard/src}/codes.ts (100%) rename {common/web/keyboard-processor/src/text => web/src/engine/keyboard/src}/deadkeys.ts (100%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/src/index.ts (70%) rename {common/web/keyboard-processor/src/text => web/src/engine/keyboard/src}/keyEvent.ts (98%) rename {common/web/keyboard-processor/src/text => web/src/engine/keyboard/src}/keyMapping.ts (100%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/src/keyboards/activeLayout.ts (99%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/src/keyboards/defaultLayouts.ts (99%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/src/keyboards/keyboard.ts (99%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/src/keyboards/keyboardHarness.ts (99%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/src/keyboards/keyboardLoaderBase.ts (100%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/src/keyboards/keyboardProperties.ts (100%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/src/keyboards/loaders/dom-keyboard-loader.ts (100%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/src/keyboards/loaders/domKeyboardLoader.ts (97%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/src/keyboards/loaders/node-keyboard-loader.ts (100%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/src/keyboards/loaders/nodeKeyboardLoader.ts (95%) create mode 100644 web/src/engine/keyboard/src/keyboards/loaders/tsconfig.dom.json create mode 100644 web/src/engine/keyboard/src/keyboards/loaders/tsconfig.node.json rename {common/web/keyboard-processor => web/src/engine/keyboard}/src/keyboards/spacebarText.ts (100%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/src/keyboards/stateKeyMap.ts (65%) rename {common/web/keyboard-processor/src/text => web/src/engine/keyboard/src}/outputTarget.ts (100%) rename {common/web/keyboard-processor/src/text => web/src/engine/keyboard/src}/ruleBehavior.interface.ts (100%) rename {common/web/keyboard-processor/src/text => web/src/engine/keyboard/src}/stringDivergence.ts (100%) rename {common/web/keyboard-processor/src/text => web/src/engine/keyboard/src}/systemStores.ts (96%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/tests/node/basic-engine.js (87%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/tests/node/basic-init.js (92%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/tests/node/bundled-module.js (91%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/tests/node/chirality.js (97%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/tests/node/deadkeys.js (87%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/tests/node/engine/context.js (99%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/tests/node/engine/notany_context.js (94%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/tests/node/engine/stores.js (94%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/tests/node/engine/unmatched_final_group.js (84%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/tests/node/keyboard-loading.js (96%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/tests/node/keyboard-properties.js (98%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/tests/node/mocks.js (98%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/tests/node/non-positional-rules.js (97%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/tests/node/specialized-backspace.js (98%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/tests/node/transcriptions.js (99%) rename {common/web/keyboard-processor => web/src/engine/keyboard}/tsconfig.all.json (66%) create mode 100644 web/src/engine/keyboard/tsconfig.json rename web/src/test/auto/dom/cases/{keyboard-processor => keyboard}/domKeyboardLoader.spec.ts (95%) diff --git a/common/web/keyboard-processor/package.json b/common/web/keyboard-processor/package.json deleted file mode 100644 index 3f0a595897..0000000000 --- a/common/web/keyboard-processor/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@keymanapp/keyboard-processor", - "description": "Core module for Keyman keyboard support in KeymanWeb.", - "repository": { - "type": "git", - "url": "git+https://github.com/keymanapp/keyman.git" - }, - "keywords": [ - "input", - "languages", - "keyboards" - ], - "author": "SIL International", - "license": "MIT", - "bugs": { - "url": "https://github.com/keymanapp/keyman/issues" - }, - "homepage": "https://github.com/keymanapp/keyman#readme", - "devDependencies": { - "@keymanapp/resources-gosh": "*", - "c8": "^7.12.0", - "mocha": "^10.0.0", - "mocha-teamcity-reporter": "^4.0.0", - "typescript": "^5.4.5" - }, - "scripts": { - "build": "gosh build.sh", - "clean": "gosh build.sh clean", - "test": "gosh build.sh test" - }, - "dependencies": { - "@keymanapp/common-types": "*", - "@keymanapp/models-types": "*", - "@keymanapp/keyman-version": "*", - "@keymanapp/web-utils": "*" - }, - "type": "module", - "main": "./build/obj/index.js", - "types": "./build/obj/index.d.ts", - "exports": { - ".": { - "es6-bundling": "./src/index.ts", - "default": "./build/obj/index.js" - }, - "./node-keyboard-loader": { - "es6-bundling": "./src/keyboards/loaders/node-keyboard-loader.ts", - "types": "./build/obj/keyboards/loaders/node-keyboard-loader.d.ts", - "import": "./build/obj/keyboards/loaders/node-keyboard-loader.js" - }, - "./dom-keyboard-loader": { - "es6-bundling": "./src/keyboards/loaders/dom-keyboard-loader.ts", - "types": "./build/obj/keyboards/loaders/dom-keyboard-loader.d.ts", - "import": "./build/obj/keyboards/loaders/dom-keyboard-loader.js" - }, - "./lib": { - "types": "./build/lib/index.d.ts", - "import": "./build/lib/index.mjs" - }, - "./lib/node-keyboard-loader": { - "types": "./build/lib/node-keyboard-loader.d.ts", - "import": "./build/lib/node-keyboard-loader.mjs" - }, - "./lib/dom-keyboard-loader": { - "types": "./build/lib/dom-keyboard-loader.d.ts", - "import": "./build/lib/dom-keyboard-loader.mjs" - }, - "./obj/*.js": "./build/obj/*.js" - } -} diff --git a/common/web/keyboard-processor/src/keyboards/loaders/tsconfig.dom.json b/common/web/keyboard-processor/src/keyboards/loaders/tsconfig.dom.json deleted file mode 100644 index 7ba2abe026..0000000000 --- a/common/web/keyboard-processor/src/keyboards/loaders/tsconfig.dom.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "../../../../tsconfig.kmw-main-base.json", - "compilerOptions": { - "baseUrl": "../../../", - "outDir": "../../../build/obj/keyboards/loaders/", - "tsBuildInfoFile": "../../../build/obj/keyboards/loaders/tsconfig.dom.tsbuildinfo", - "rootDir": "." - }, - "references": [ - { "path": "../../../tsconfig.json" } - ], - "include": ["dom-keyboard-loader.ts", "domKeyboardLoader.ts"], -} diff --git a/common/web/keyboard-processor/src/keyboards/loaders/tsconfig.node.json b/common/web/keyboard-processor/src/keyboards/loaders/tsconfig.node.json deleted file mode 100644 index 0be3f169ad..0000000000 --- a/common/web/keyboard-processor/src/keyboards/loaders/tsconfig.node.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "../../../../tsconfig.kmw-main-base.json", - "compilerOptions": { - "types": [ "node" ], - "baseUrl": "../../../", - "outDir": "../../../build/obj/keyboards/loaders/", - "tsBuildInfoFile": "../../../build/obj/keyboards/loaders/tsconfig.node.tsbuildinfo", - "rootDir": "." - }, - "references": [ - { "path": "../../../tsconfig.json" } - ], - "include": ["node-keyboard-loader.ts", "nodeKeyboardLoader.ts"], -} diff --git a/common/web/keyboard-processor/tsconfig.json b/common/web/keyboard-processor/tsconfig.json deleted file mode 100644 index 728935b74f..0000000000 --- a/common/web/keyboard-processor/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -// Is used by the keyboard-loader submodules. -{ - "extends": "../tsconfig.kmw-main-base.json", - "compilerOptions": { - "baseUrl": "./", - "outDir": "build/obj/", - "tsBuildInfoFile": "build/obj/tsconfig.tsbuildinfo", - "rootDir": "./src/" - }, - "references": [ - { "path": "../types" }, - { "path": "../../models/types" }, - { "path": "../keyman-version/" }, - { "path": "../utils/" } - ], - "include": [ "./src/**/*.ts"], - "exclude": ["./src/keyboards/loaders/**/*.ts"] -} diff --git a/common/web/types/src/keyman-touch-layout/keyman-touch-layout-file.ts b/common/web/types/src/keyman-touch-layout/keyman-touch-layout-file.ts index 757316a70a..786d9213e2 100644 --- a/common/web/types/src/keyman-touch-layout/keyman-touch-layout-file.ts +++ b/common/web/types/src/keyman-touch-layout/keyman-touch-layout-file.ts @@ -58,7 +58,7 @@ export const PRIVATE_USE_IDS = [ ] as const; /* A map of key field names with values matching the `typeof` the corresponding property - * exists in common/web/keyboard-processor, keyboards/activeLayout.ts. + * exists in /web/src/engine/keyboard/src/keyboards/activeLayout.ts. * * Make sure that when one is updated, the other also is. TS types are compile-time only, * so the run-time-accessible mapping in activeLayout.ts cannot be auto-generated by TS. */ diff --git a/package-lock.json b/package-lock.json index 6b1a73ef40..ae0082784f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -191,23 +191,6 @@ "typescript": "^5.4.5" } }, - "common/web/keyboard-processor": { - "name": "@keymanapp/keyboard-processor", - "license": "MIT", - "dependencies": { - "@keymanapp/common-types": "*", - "@keymanapp/keyman-version": "*", - "@keymanapp/models-types": "*", - "@keymanapp/web-utils": "*" - }, - "devDependencies": { - "@keymanapp/resources-gosh": "*", - "c8": "^7.12.0", - "mocha": "^10.0.0", - "mocha-teamcity-reporter": "^4.0.0", - "typescript": "^5.4.5" - } - }, "common/web/keyman-version": { "name": "@keymanapp/keyman-version", "license": "MIT", @@ -249,7 +232,6 @@ "name": "@keymanapp/recorder-core", "license": "MIT", "dependencies": { - "@keymanapp/keyboard-processor": "*", "@keymanapp/keyman-version": "*", "@keymanapp/models-types": "*", "@keymanapp/web-utils": "*" @@ -2785,10 +2767,6 @@ "resolved": "common/tools/hextobin", "link": true }, - "node_modules/@keymanapp/keyboard-processor": { - "resolved": "common/web/keyboard-processor", - "link": true - }, "node_modules/@keymanapp/keyman-version": { "resolved": "common/web/keyman-version", "link": true @@ -14548,7 +14526,6 @@ "name": "keyman", "license": "MIT", "dependencies": { - "@keymanapp/keyboard-processor": "*", "@keymanapp/keyman-version": "*", "@keymanapp/lexical-model-layer": "*", "@keymanapp/models-types": "*", diff --git a/tsconfig.base.json b/tsconfig.base.json index e34839a52c..c4e0599eef 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -26,7 +26,6 @@ "paths": { "@keymanapp/common-types": ["./common/web/types/src/main"], - "@keymanapp/keyboard-processor": ["./common/web/keyboard-processor/src"], "@keymanapp/keyman": ["./web" ], "@keymanapp/models-types": ["./common/models/types"], "@keymanapp/models-templates": ["./common/models/templates"], diff --git a/tsconfig.json b/tsconfig.json index 093cec46f4..8e6596a231 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,6 @@ { "path": "./common/web/gesture-recognizer/tsconfig.json" }, { "path": "./common/web/gesture-recognizer/src/tools/unit-test-resources/tsconfig.json" }, - { "path": "./common/web/keyboard-processor/tsconfig.json" }, { "path": "./common/web/keyman-version" }, { "path": "./common/web/lm-message-types/" }, { "path": "./common/web/lm-worker/" }, diff --git a/web/README.md b/web/README.md index 775f303df5..1a30362e9b 100644 --- a/web/README.md +++ b/web/README.md @@ -81,7 +81,7 @@ title: Dependency Graph %%{init: {"flowchart": {"htmlLabels": false}} }%% graph TD; OSK["/web/src/engine/osk"]; - KP["@keymanapp/keyboard-processor
(/common/web/keyboard-processor)"]; + KP["/web/src/engine/keyboard"]; JSProc["/web/src/engine/js-processor"]; OSK-->KP; WebUtils["@keymanapp/web-utils
(/common/web/utils)"]; diff --git a/web/build.sh b/web/build.sh index 6f4737710a..c3e17e9d43 100755 --- a/web/build.sh +++ b/web/build.sh @@ -28,6 +28,7 @@ builder_describe "Builds engine modules for Keyman Engine for Web (KMW)." \ ":engine/events Specialized classes utilized to support KMW API events" \ ":engine/element-wrappers Subset used to integrate with website elements" \ ":engine/js-processor Build JS processor for KMW" \ + ":engine/keyboard Builds KMW's keyboard-loading and caching code" \ ":engine/main Builds all common code used by KMW's app/-level targets" \ ":engine/osk Builds the Web OSK module" \ ":engine/package-cache Subset used to collate keyboards and request them from the cloud" \ @@ -59,6 +60,7 @@ builder_describe_outputs \ build:engine/events "/web/build/engine/events/lib/index.mjs" \ build:engine/element-wrappers "/web/build/engine/element-wrappers/lib/index.mjs" \ build:engine/js-processor "/web/build/engine/js-processor/lib/index.mjs" \ + build:engine/keyboard "/web/build/engine/keyboard/lib/index.mjs" \ build:engine/main "/web/build/engine/main/lib/index.mjs" \ build:engine/osk "/web/build/engine/osk/lib/index.mjs" \ build:engine/package-cache "/web/build/engine/package-cache/lib/index.mjs" \ diff --git a/web/ci.sh b/web/ci.sh index 6e5bc3b06a..5e26a1e30e 100755 --- a/web/ci.sh +++ b/web/ci.sh @@ -85,7 +85,7 @@ if builder_start_action test; then # No --reporter option exists yet for the headless modules. - "$KEYMAN_ROOT/common/web/keyboard-processor/build.sh" test $OPTIONS + "$KEYMAN_ROOT/web/src/engine/keyboard/build.sh" test $OPTIONS "$KEYMAN_ROOT/common/web/gesture-recognizer/test.sh" $OPTIONS ./build.sh test $OPTIONS diff --git a/web/package.json b/web/package.json index 4baff29490..b5727dd009 100644 --- a/web/package.json +++ b/web/package.json @@ -42,6 +42,21 @@ "types": "./build/engine/js-processor/obj/index.d.ts", "import": "./build/engine/js-processor/obj/index.js" }, + "./engine/keyboard": { + "es6-bundling": "./src/engine/keyboard/src/index.ts", + "types": "./build/engine/keyboard/obj/index.d.ts", + "import": "./build/engine/keyboard/obj/index.js" + }, + "./engine/keyboard/node-keyboard-loader": { + "es6-bundling": "./src/engine/keyboard/src/keyboards/loaders/node-keyboard-loader.ts", + "types": "./build/engine/keyboard/obj/keyboards/loaders/node-keyboard-loader.d.ts", + "import": "./build/engine/keyboard/obj/keyboards/loaders/node-keyboard-loader.js" + }, + "./engine/keyboard/dom-keyboard-loader": { + "es6-bundling": "./src/engine/keyboard/src/keyboards/loaders/dom-keyboard-loader.ts", + "types": "./build/engine/keyboard/obj/keyboards/loaders/dom-keyboard-loader.d.ts", + "import": "./build/engine/keyboard/obj/keyboards/loaders/dom-keyboard-loader.js" + }, "./engine/package-cache": { "es6-bundling": "./src/engine/package-cache/src/index.ts", "types": "./build/engine/package-cache/obj/index.d.ts", @@ -104,7 +119,6 @@ "test": "gosh ./test.sh" }, "dependencies": { - "@keymanapp/keyboard-processor": "*", "@keymanapp/keyman-version": "*", "@keymanapp/lexical-model-layer": "*", "@keymanapp/models-types": "*", diff --git a/web/src/app/browser/src/configuration.ts b/web/src/app/browser/src/configuration.ts index 4f2f268438..35983ac30c 100644 --- a/web/src/app/browser/src/configuration.ts +++ b/web/src/app/browser/src/configuration.ts @@ -1,7 +1,7 @@ import { EngineConfiguration, InitOptionSpec, InitOptionDefaults } from "keyman/engine/main"; import { OutputTarget as DOMOutputTarget } from 'keyman/engine/element-wrappers'; -import { isEmptyTransform, OutputTarget } from '@keymanapp/keyboard-processor'; +import { isEmptyTransform, OutputTarget } from 'keyman/engine/keyboard'; import { RuleBehavior } from 'keyman/engine/js-processor'; import { AlertHost } from "./utils/alertHost.js"; import { whenDocumentReady } from "./utils/documentReady.js"; diff --git a/web/src/app/browser/src/contextManager.ts b/web/src/app/browser/src/contextManager.ts index 1511269bbe..f17a17a529 100644 --- a/web/src/app/browser/src/contextManager.ts +++ b/web/src/app/browser/src/contextManager.ts @@ -1,4 +1,4 @@ -import { type Keyboard, KeyboardScriptError } from '@keymanapp/keyboard-processor'; +import { type Keyboard, KeyboardScriptError } from 'keyman/engine/keyboard'; import { type KeyboardStub } from 'keyman/engine/package-cache'; import { CookieSerializer } from 'keyman/engine/dom-utils'; import { eventOutputTarget, outputTargetForElement, PageContextAttachment } from 'keyman/engine/attachment'; diff --git a/web/src/app/browser/src/defaultBrowserRules.ts b/web/src/app/browser/src/defaultBrowserRules.ts index fc084ec3f4..0d40e476c7 100644 --- a/web/src/app/browser/src/defaultBrowserRules.ts +++ b/web/src/app/browser/src/defaultBrowserRules.ts @@ -3,7 +3,7 @@ import { Codes, type KeyEvent, type OutputTarget -} from '@keymanapp/keyboard-processor'; +} from 'keyman/engine/keyboard'; import { DefaultRules } from 'keyman/engine/js-processor'; import ContextManager from './contextManager.js'; diff --git a/web/src/app/browser/src/hardwareEventKeyboard.ts b/web/src/app/browser/src/hardwareEventKeyboard.ts index f6874fc77b..0bb594e897 100644 --- a/web/src/app/browser/src/hardwareEventKeyboard.ts +++ b/web/src/app/browser/src/hardwareEventKeyboard.ts @@ -1,4 +1,4 @@ -import { Codes, DeviceSpec, KeyEvent, KeyMapping, Keyboard } from '@keymanapp/keyboard-processor'; +import { Codes, DeviceSpec, KeyEvent, KeyMapping, Keyboard } from 'keyman/engine/keyboard'; import { KeyboardProcessor } from 'keyman/engine/js-processor'; import { ModifierKeyConstants } from '@keymanapp/common-types'; diff --git a/web/src/app/browser/src/keymanEngine.ts b/web/src/app/browser/src/keymanEngine.ts index d807c415eb..dc912f257b 100644 --- a/web/src/app/browser/src/keymanEngine.ts +++ b/web/src/app/browser/src/keymanEngine.ts @@ -7,7 +7,7 @@ import { VisualKeyboard } from 'keyman/engine/osk'; import { ErrorStub, KeyboardStub, CloudQueryResult, toPrefixedKeyboardId as prefixed } from 'keyman/engine/package-cache'; -import { DeviceSpec, Keyboard, KeyboardObject } from "@keymanapp/keyboard-processor"; +import { DeviceSpec, Keyboard, KeyboardObject } from "keyman/engine/keyboard"; import * as views from './viewsAnchorpoint.js'; import { BrowserConfiguration, BrowserInitOptionDefaults, BrowserInitOptionSpec } from './configuration.js'; diff --git a/web/src/app/webview/src/contextManager.ts b/web/src/app/webview/src/contextManager.ts index b0c322ea29..de41348142 100644 --- a/web/src/app/webview/src/contextManager.ts +++ b/web/src/app/webview/src/contextManager.ts @@ -1,4 +1,4 @@ -import { type Keyboard, Mock, OutputTarget, Transcription, findCommonSubstringEndIndex, isEmptyTransform, TextTransform } from '@keymanapp/keyboard-processor'; +import { type Keyboard, Mock, OutputTarget, Transcription, findCommonSubstringEndIndex, isEmptyTransform, TextTransform } from 'keyman/engine/keyboard'; import { KeyboardStub } from 'keyman/engine/package-cache'; import { ContextManagerBase } from 'keyman/engine/main'; import { WebviewConfiguration } from './configuration.js'; diff --git a/web/src/app/webview/src/keymanEngine.ts b/web/src/app/webview/src/keymanEngine.ts index 2f07350548..642f9afb7e 100644 --- a/web/src/app/webview/src/keymanEngine.ts +++ b/web/src/app/webview/src/keymanEngine.ts @@ -1,4 +1,4 @@ -import { DeviceSpec } from '@keymanapp/keyboard-processor' +import { DeviceSpec } from 'keyman/engine/keyboard' import { DefaultRules, RuleBehavior } from 'keyman/engine/js-processor'; import { KeymanEngine as KeymanEngineBase, KeyboardInterface } from 'keyman/engine/main'; import { AnchoredOSKView, ViewConfiguration, StaticActivator } from 'keyman/engine/osk'; diff --git a/web/src/app/webview/src/oskConfiguration.ts b/web/src/app/webview/src/oskConfiguration.ts index 26ceeb2872..9250b5a2a1 100644 --- a/web/src/app/webview/src/oskConfiguration.ts +++ b/web/src/app/webview/src/oskConfiguration.ts @@ -1,5 +1,5 @@ import { OSKView } from "keyman/engine/osk"; -import { DeviceSpec } from "@keymanapp/keyboard-processor"; +import { DeviceSpec } from "keyman/engine/keyboard"; import { type EmbeddedGestureConfig } from "keyman/engine/osk"; import { GlobeHint } from './osk/globeHint.js'; diff --git a/web/src/app/webview/src/passthroughKeyboard.ts b/web/src/app/webview/src/passthroughKeyboard.ts index d74ab7f99a..25dec7a8e6 100644 --- a/web/src/app/webview/src/passthroughKeyboard.ts +++ b/web/src/app/webview/src/passthroughKeyboard.ts @@ -1,4 +1,4 @@ -import { DeviceSpec, Keyboard, KeyEvent, ManagedPromise } from '@keymanapp/keyboard-processor'; +import { DeviceSpec, Keyboard, KeyEvent, ManagedPromise } from 'keyman/engine/keyboard'; import { HardKeyboard, processForMnemonicsAndLegacy } from 'keyman/engine/main'; diff --git a/web/src/engine/attachment/src/pageContextAttachment.ts b/web/src/engine/attachment/src/pageContextAttachment.ts index d63c113d5e..4325c88f15 100644 --- a/web/src/engine/attachment/src/pageContextAttachment.ts +++ b/web/src/engine/attachment/src/pageContextAttachment.ts @@ -1,6 +1,6 @@ import { EventEmitter } from 'eventemitter3'; -import { DeviceSpec, InternalKeyboardFont } from "@keymanapp/keyboard-processor"; +import { DeviceSpec, InternalKeyboardFont } from "keyman/engine/keyboard"; import { Input, nestedInstanceOf, wrapElement } from "keyman/engine/element-wrappers"; import { arrayFromNodeList, diff --git a/web/src/engine/dom-utils/build.sh b/web/src/engine/dom-utils/build.sh index 74b46051c4..d2e424db20 100755 --- a/web/src/engine/dom-utils/build.sh +++ b/web/src/engine/dom-utils/build.sh @@ -16,7 +16,7 @@ SUBPROJECT_NAME=engine/dom-utils builder_describe "Builds DOM-utility modules used by the Keyman Engine for Web (KMW)." \ "@/common/web/utils" \ - "@/common/web/keyboard-processor" \ + "@/web/src/engine/keyboard" \ "clean" \ "configure" \ "build" \ diff --git a/web/src/engine/dom-utils/src/stylesheets.ts b/web/src/engine/dom-utils/src/stylesheets.ts index 7312a62f05..977f253ff7 100644 --- a/web/src/engine/dom-utils/src/stylesheets.ts +++ b/web/src/engine/dom-utils/src/stylesheets.ts @@ -1,5 +1,5 @@ import { DeviceSpec, ManagedPromise } from '@keymanapp/web-utils'; -import { type InternalKeyboardFont as KeyboardFont } from '@keymanapp/keyboard-processor'; +import { type InternalKeyboardFont as KeyboardFont } from 'keyman/engine/keyboard'; type FontFamilyStyleMap = {[family: string]: HTMLStyleElement}; diff --git a/web/src/engine/dom-utils/tsconfig.json b/web/src/engine/dom-utils/tsconfig.json index c0b4a7d79d..dadf4db5c8 100644 --- a/web/src/engine/dom-utils/tsconfig.json +++ b/web/src/engine/dom-utils/tsconfig.json @@ -11,7 +11,7 @@ "include": [ "src/**/*.ts" ], "references": [ - { "path": "../../../../common/web/keyboard-processor" }, + { "path": "../keyboard" }, { "path": "../../../../common/web/utils" } ] } diff --git a/web/src/engine/element-wrappers/build.sh b/web/src/engine/element-wrappers/build.sh index cfcc58a44f..1d0f580213 100755 --- a/web/src/engine/element-wrappers/build.sh +++ b/web/src/engine/element-wrappers/build.sh @@ -13,7 +13,7 @@ SUBPROJECT_NAME=engine/element-wrappers # ################################ Main script ################################ builder_describe "Builds DOM-based OutputTarget subclasses used by the Keyman Engine for Web (KMW)." \ - "@/common/web/keyboard-processor" \ + "@/web/src/engine/keyboard" \ "clean" \ "configure" \ "build" \ diff --git a/web/src/engine/element-wrappers/readme.md b/web/src/engine/element-wrappers/readme.md index 1237237c7b..2a7685edbc 100644 --- a/web/src/engine/element-wrappers/readme.md +++ b/web/src/engine/element-wrappers/readme.md @@ -1,4 +1,4 @@ ## engine/element-wrappers This submodule provides a subset of the main engine's Web-oriented code that's used to 'wrap' webpage -elements as part of KMW attachment and interface the element with the `keyboard-processor` submodule. \ No newline at end of file +elements as part of KMW attachment and interface the element with the `keyboard` submodule. \ No newline at end of file diff --git a/web/src/engine/element-wrappers/src/outputTarget.ts b/web/src/engine/element-wrappers/src/outputTarget.ts index 3a288c1347..5d0f2e38ce 100644 --- a/web/src/engine/element-wrappers/src/outputTarget.ts +++ b/web/src/engine/element-wrappers/src/outputTarget.ts @@ -1,4 +1,4 @@ -import { OutputTarget as OutputTargetBase } from "@keymanapp/keyboard-processor"; +import { OutputTarget as OutputTargetBase } from "keyman/engine/keyboard"; import { EventEmitter } from 'eventemitter3'; export default abstract class OutputTarget extends OutputTargetBase { diff --git a/web/src/engine/element-wrappers/tsconfig.json b/web/src/engine/element-wrappers/tsconfig.json index ab6aa238a8..15a58bbf2a 100644 --- a/web/src/engine/element-wrappers/tsconfig.json +++ b/web/src/engine/element-wrappers/tsconfig.json @@ -11,6 +11,6 @@ "include": [ "src/**/*.ts" ], "references": [ - { "path": "../../../../common/web/keyboard-processor" } + { "path": "../keyboard" } ] } diff --git a/web/src/engine/events/build.sh b/web/src/engine/events/build.sh index 438d075c2c..1b8993f570 100755 --- a/web/src/engine/events/build.sh +++ b/web/src/engine/events/build.sh @@ -14,7 +14,7 @@ SUBPROJECT_NAME=engine/events builder_describe "Builds specialized event-related modules utilized by Keyman Engine for Web." \ "@/common/web/utils build" \ - "@/common/web/keyboard-processor build" \ + "@/web/src/engine/keyboard build" \ "clean" \ "configure" \ "build" \ diff --git a/web/src/engine/events/src/keyEventSource.interface.ts b/web/src/engine/events/src/keyEventSource.interface.ts index 22621d2de0..8f12893b28 100644 --- a/web/src/engine/events/src/keyEventSource.interface.ts +++ b/web/src/engine/events/src/keyEventSource.interface.ts @@ -1,5 +1,5 @@ import { EventEmitter } from "eventemitter3"; -import { type KeyEvent, type RuleBehaviorInterface } from "@keymanapp/keyboard-processor"; +import { type KeyEvent, type RuleBehaviorInterface } from "keyman/engine/keyboard"; export type KeyEventResultCallback = (result: RuleBehaviorInterface, error?: Error) => void; export type KeyEventHandler = (event: KeyEvent, callback?: KeyEventResultCallback) => void; diff --git a/web/src/engine/events/tsconfig.json b/web/src/engine/events/tsconfig.json index bb25ac9c99..5d0a45bbab 100644 --- a/web/src/engine/events/tsconfig.json +++ b/web/src/engine/events/tsconfig.json @@ -12,6 +12,6 @@ "references": [ { "path": "../../../../common/web/utils" }, - { "path": "../../../../common/web/keyboard-processor" } + { "path": "../keyboard" } ] } diff --git a/web/src/engine/interfaces/build.sh b/web/src/engine/interfaces/build.sh index 528083d4d8..568bd7940d 100755 --- a/web/src/engine/interfaces/build.sh +++ b/web/src/engine/interfaces/build.sh @@ -14,7 +14,7 @@ SUBPROJECT_NAME=engine/interfaces builder_describe "Builds configuration subclasses used by the Keyman Engine for Web (KMW)." \ "@/common/web/es-bundling" \ - "@/common/web/keyboard-processor" \ + "@/web/src/engine/keyboard" \ "@/web/src/engine/js-processor" \ "clean" \ "configure" \ diff --git a/web/src/engine/interfaces/src/prediction/languageProcessor.interface.ts b/web/src/engine/interfaces/src/prediction/languageProcessor.interface.ts index 7265d51f46..84e7851987 100644 --- a/web/src/engine/interfaces/src/prediction/languageProcessor.interface.ts +++ b/web/src/engine/interfaces/src/prediction/languageProcessor.interface.ts @@ -1,7 +1,7 @@ /// import { EventEmitter } from "eventemitter3"; -import { OutputTarget } from "@keymanapp/keyboard-processor"; +import { OutputTarget } from "keyman/engine/keyboard"; export class ReadySuggestions { suggestions: Suggestion[]; diff --git a/web/src/engine/interfaces/src/prediction/predictionContext.ts b/web/src/engine/interfaces/src/prediction/predictionContext.ts index 90427c3020..dabeb366da 100644 --- a/web/src/engine/interfaces/src/prediction/predictionContext.ts +++ b/web/src/engine/interfaces/src/prediction/predictionContext.ts @@ -1,6 +1,6 @@ import { EventEmitter } from "eventemitter3"; import { type LanguageProcessorSpec , ReadySuggestions, type InvalidateSourceEnum, StateChangeHandler } from './languageProcessor.interface.js'; -import { type OutputTarget } from "@keymanapp/keyboard-processor"; +import { type OutputTarget } from "keyman/engine/keyboard"; import { type KeyboardProcessor } from 'keyman/engine/js-processor'; interface PredictionContextEventMap { diff --git a/web/src/engine/interfaces/tsconfig.json b/web/src/engine/interfaces/tsconfig.json index 634e62bada..e53a808682 100644 --- a/web/src/engine/interfaces/tsconfig.json +++ b/web/src/engine/interfaces/tsconfig.json @@ -12,7 +12,7 @@ "include": [ "**/*.ts" ], "references": [ - { "path": "../../../../common/web/keyboard-processor" }, + { "path": "../keyboard" }, { "path": "../js-processor" } ] } diff --git a/web/src/engine/js-processor/src/defaultRules.ts b/web/src/engine/js-processor/src/defaultRules.ts index 3d56a2dad8..60409a5fe5 100644 --- a/web/src/engine/js-processor/src/defaultRules.ts +++ b/web/src/engine/js-processor/src/defaultRules.ts @@ -5,7 +5,7 @@ */ import { ModifierKeyConstants } from '@keymanapp/common-types'; -import { Codes, type KeyEvent, type OutputTarget, setDefaultRules } from "@keymanapp/keyboard-processor"; +import { Codes, type KeyEvent, type OutputTarget, setDefaultRules } from 'keyman/engine/keyboard'; import RuleBehavior from "./ruleBehavior.js"; export enum EmulationKeystrokes { @@ -13,7 +13,6 @@ export enum EmulationKeystrokes { Backspace = '\b' } - /** * Defines a collection of static library functions that define KeymanWeb's default (implied) keyboard rule behaviors. */ diff --git a/web/src/engine/js-processor/src/kbdInterface.ts b/web/src/engine/js-processor/src/kbdInterface.ts index 2b34eadce9..2bc283010c 100644 --- a/web/src/engine/js-processor/src/kbdInterface.ts +++ b/web/src/engine/js-processor/src/kbdInterface.ts @@ -7,7 +7,7 @@ import { type DeviceSpec } from "@keymanapp/web-utils"; import { ModifierKeyConstants } from '@keymanapp/common-types'; -import { Codes, type KeyEvent, type Deadkey, ComplexKeyboardStore, type KeyboardStore, KeyboardStoreElement, KeyMapping, SystemStoreIDs, SystemStore, MutableSystemStore, PlatformSystemStore, type OutputTarget, Mock, Keyboard, VariableStore, VariableStoreDictionary, VariableStoreSerializer, KeyboardHarness, KeyboardKeymanGlobal, RuleDeadkey, ContextAny, RuleIndex, ContextEx, ContextNul, RuleChar } from "@keymanapp/keyboard-processor"; +import { Codes, type KeyEvent, type Deadkey, ComplexKeyboardStore, type KeyboardStore, KeyboardStoreElement, KeyMapping, SystemStoreIDs, SystemStore, MutableSystemStore, PlatformSystemStore, type OutputTarget, Mock, Keyboard, VariableStore, VariableStoreDictionary, VariableStoreSerializer, KeyboardHarness, KeyboardKeymanGlobal, RuleDeadkey, ContextAny, RuleIndex, ContextEx, ContextNul, RuleChar } from "keyman/engine/keyboard"; import RuleBehavior from "./ruleBehavior.js"; //#endregion @@ -1076,6 +1076,6 @@ export default class KeyboardInterface extends KeyboardHarness { } (function() { - // This will be the only call within the keyboard-processor module. + // This will be the only call within the keyboard module. KeyboardInterface.__publishShorthandAPI(); }()); diff --git a/web/src/engine/js-processor/src/keyboardProcessor.ts b/web/src/engine/js-processor/src/keyboardProcessor.ts index 1a6d216dce..5886ee0a77 100644 --- a/web/src/engine/js-processor/src/keyboardProcessor.ts +++ b/web/src/engine/js-processor/src/keyboardProcessor.ts @@ -11,7 +11,7 @@ import { ModifierKeyConstants } from '@keymanapp/common-types'; import { Codes, type Keyboard, MinimalKeymanGlobal, KeyEvent, Layouts, type MutableSystemStore, type OutputTarget, Mock, SystemStoreIDs, -} from "@keymanapp/keyboard-processor"; +} from "keyman/engine/keyboard"; import DefaultRules, { EmulationKeystrokes } from "./defaultRules.js"; import RuleBehavior from "./ruleBehavior.js"; import KeyboardInterface from './kbdInterface.js'; diff --git a/web/src/engine/js-processor/src/ruleBehavior.ts b/web/src/engine/js-processor/src/ruleBehavior.ts index aced7065d2..29764425f5 100644 --- a/web/src/engine/js-processor/src/ruleBehavior.ts +++ b/web/src/engine/js-processor/src/ruleBehavior.ts @@ -1,7 +1,7 @@ /// import KeyboardProcessor from "./keyboardProcessor.js"; -import { OutputTarget, Mock, type Transcription, VariableStoreDictionary, type VariableStore } from "@keymanapp/keyboard-processor"; +import { OutputTarget, Mock, type Transcription, VariableStoreDictionary, type VariableStore } from "keyman/engine/keyboard"; /** * Represents the commands and state changes that result from a matched keyboard rule. diff --git a/common/web/keyboard-processor/.c8rc.json b/web/src/engine/keyboard/.c8rc.json similarity index 100% rename from common/web/keyboard-processor/.c8rc.json rename to web/src/engine/keyboard/.c8rc.json diff --git a/common/web/keyboard-processor/.gitignore b/web/src/engine/keyboard/.gitignore similarity index 100% rename from common/web/keyboard-processor/.gitignore rename to web/src/engine/keyboard/.gitignore diff --git a/common/web/keyboard-processor/README.md b/web/src/engine/keyboard/README.md similarity index 92% rename from common/web/keyboard-processor/README.md rename to web/src/engine/keyboard/README.md index 8ac9b8f9d0..a2a4eb8994 100644 --- a/common/web/keyboard-processor/README.md +++ b/web/src/engine/keyboard/README.md @@ -1,5 +1,6 @@ # Keyman: Keyboard Processor Module -The Original Code is (C) 2017-2020 SIL International + +The Original Code is (C) 2017-2024 SIL International The Keyboard Processor module is an internal component of KeymanWeb, seen within this repo at /web/. diff --git a/common/web/keyboard-processor/build.sh b/web/src/engine/keyboard/build.sh similarity index 54% rename from common/web/keyboard-processor/build.sh rename to web/src/engine/keyboard/build.sh index 964370c2fb..649e38a213 100755 --- a/common/web/keyboard-processor/build.sh +++ b/web/src/engine/keyboard/build.sh @@ -1,23 +1,23 @@ #!/usr/bin/env bash # -# Compile KeymanWeb's 'keyboard-processor' module, one of the components of Web's 'core' module. +# Compile KeymanWeb's 'keyboard' module, one of the components of Web's 'core' module. # ## START STANDARD BUILD SCRIPT INCLUDE # adjust relative paths as necessary THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" -. "${THIS_SCRIPT%/*}/../../../resources/build/builder.inc.sh" +. "${THIS_SCRIPT%/*}/../../../../resources/build/builder.inc.sh" ## END STANDARD BUILD SCRIPT INCLUDE -. "${KEYMAN_ROOT}/resources/shellHelperFunctions.sh" +SUBPROJECT_NAME=engine/keyboard -BUNDLE_CMD="node ${KEYMAN_ROOT}/common/web/es-bundling/build/common-bundle.mjs" +. "${KEYMAN_ROOT}/web/common.inc.sh" +. "${KEYMAN_ROOT}/resources/shellHelperFunctions.sh" ################################ Main script ################################ builder_describe \ "Compiles the web-oriented utility function module." \ "@/web/src/tools/testing/recorder-core test" \ - "@/web/src/engine/js-processor test" \ "@/common/web/keyman-version" \ "@/common/web/es-bundling" \ "@/common/web/types" \ @@ -30,7 +30,7 @@ builder_describe \ builder_describe_outputs \ configure /node_modules \ - build /common/web/keyboard-processor/build/lib/index.mjs + build /web/build/engine/keyboard/lib/index.mjs builder_parse "$@" @@ -42,39 +42,41 @@ function do_configure() { playwright install } +BUILD_DIR="${KEYMAN_ROOT}/web/build/${SUBPROJECT_NAME}" + function do_build() { tsc --build "${THIS_SCRIPT_PATH}/tsconfig.all.json" # Base product - the main keyboard processor builder_echo "Bundle base product - the main keyboard processor" - ${BUNDLE_CMD} "${KEYMAN_ROOT}/common/web/keyboard-processor/build/obj/index.js" \ - --out "${KEYMAN_ROOT}/common/web/keyboard-processor/build/lib/index.mjs" \ + ${BUNDLE_CMD} "${BUILD_DIR}/obj/index.js" \ + --out "${BUILD_DIR}/lib/index.mjs" \ --format esm # The DOM-oriented keyboard loader builder_echo "Bundle the DOM-oriented keyboard loader" - ${BUNDLE_CMD} "${KEYMAN_ROOT}/common/web/keyboard-processor/build/obj/keyboards/loaders/dom-keyboard-loader.js" \ - --out "${KEYMAN_ROOT}/common/web/keyboard-processor/build/lib/dom-keyboard-loader.mjs" \ + ${BUNDLE_CMD} "${BUILD_DIR}/obj/keyboards/loaders/dom-keyboard-loader.js" \ + --out "${BUILD_DIR}/lib/dom-keyboard-loader.mjs" \ --format esm # The Node-oriented keyboard loader builder_echo "Bundle the Node-oriented keyboard loader" - ${BUNDLE_CMD} "${KEYMAN_ROOT}/common/web/keyboard-processor/build/obj/keyboards/loaders/node-keyboard-loader.js" \ - --out "${KEYMAN_ROOT}/common/web/keyboard-processor/build/lib/node-keyboard-loader.mjs" \ + ${BUNDLE_CMD} "${BUILD_DIR}/obj/keyboards/loaders/node-keyboard-loader.js" \ + --out "${BUILD_DIR}/lib/node-keyboard-loader.mjs" \ --format esm \ --platform node - # Tests + # # Tests # builder_echo "Bundle tests" - # ${BUNDLE_CMD} "${KEYMAN_ROOT}/common/web/keyboard-processor/build/tests/dom/cases/domKeyboardLoader.spec.js" \ - # --out "${KEYMAN_ROOT}/common/web/keyboard-processor/build/tests/dom/domKeyboardLoader.spec.mjs" \ + # ${BUNDLE_CMD} "${BUILD_DIR}/tests/dom/cases/domKeyboardLoader.spec.js" \ + # --out "${BUILD_DIR}/tests/dom/domKeyboardLoader.spec.mjs" \ # --format esm # Declaration bundling. builder_echo "Declaration bundling" - tsc --emitDeclarationOnly --outFile ./build/lib/index.d.ts - tsc --emitDeclarationOnly --outFile ./build/lib/dom-keyboard-loader.d.ts -p src/keyboards/loaders/tsconfig.dom.json - tsc --emitDeclarationOnly --outFile ./build/lib/node-keyboard-loader.d.ts -p src/keyboards/loaders/tsconfig.node.json + tsc --emitDeclarationOnly --outFile "${BUILD_DIR}/lib/index.d.ts" + tsc --emitDeclarationOnly --outFile "${BUILD_DIR}/lib/dom-keyboard-loader.d.ts" -p src/keyboards/loaders/tsconfig.dom.json + tsc --emitDeclarationOnly --outFile "${BUILD_DIR}/lib/node-keyboard-loader.d.ts" -p src/keyboards/loaders/tsconfig.node.json } function do_test() { @@ -87,10 +89,9 @@ function do_test() { fi c8 mocha --recursive $MOCHA_FLAGS ./tests/node/ - web-test-runner --config tests/dom/web-test-runner${WTR_CONFIG}.config.mjs } builder_run_action configure do_configure -builder_run_action clean rm -rf ./build +builder_run_action clean rm -rf "${BUILD_DIR}" builder_run_action build do_build -# builder_run_action test do_test +builder_run_action test do_test diff --git a/common/web/keyboard-processor/src/text/codes.ts b/web/src/engine/keyboard/src/codes.ts similarity index 100% rename from common/web/keyboard-processor/src/text/codes.ts rename to web/src/engine/keyboard/src/codes.ts diff --git a/common/web/keyboard-processor/src/text/deadkeys.ts b/web/src/engine/keyboard/src/deadkeys.ts similarity index 100% rename from common/web/keyboard-processor/src/text/deadkeys.ts rename to web/src/engine/keyboard/src/deadkeys.ts diff --git a/common/web/keyboard-processor/src/index.ts b/web/src/engine/keyboard/src/index.ts similarity index 70% rename from common/web/keyboard-processor/src/index.ts rename to web/src/engine/keyboard/src/index.ts index c719d7ee8e..2871801f44 100644 --- a/common/web/keyboard-processor/src/index.ts +++ b/web/src/engine/keyboard/src/index.ts @@ -24,17 +24,17 @@ export { export { default as SpacebarText } from "./keyboards/spacebarText.js"; export { default as StateKeyMap } from "./keyboards/stateKeyMap.js"; -export { default as Codes } from "./text/codes.js"; -export * from "./text/codes.js"; -export * from "./text/deadkeys.js"; -export { default as KeyEvent } from "./text/keyEvent.js"; -export * from "./text/keyEvent.js"; -export { default as KeyMapping } from "./text/keyMapping.js"; -export { default as OutputTarget } from "./text/outputTarget.js"; -export * from "./text/outputTarget.js"; -export * from "./text/stringDivergence.js"; -export * from "./text/systemStores.js"; -export * from "./text/ruleBehavior.interface.js"; +export { default as Codes } from "./codes.js"; +export * from "./codes.js"; +export * from "./deadkeys.js"; +export { default as KeyEvent } from "./keyEvent.js"; +export * from "./keyEvent.js"; +export { default as KeyMapping } from "./keyMapping.js"; +export { default as OutputTarget } from "./outputTarget.js"; +export * from "./outputTarget.js"; +export * from "./stringDivergence.js"; +export * from "./systemStores.js"; +export * from "./ruleBehavior.interface.js"; export * from "@keymanapp/web-utils"; diff --git a/common/web/keyboard-processor/src/text/keyEvent.ts b/web/src/engine/keyboard/src/keyEvent.ts similarity index 98% rename from common/web/keyboard-processor/src/text/keyEvent.ts rename to web/src/engine/keyboard/src/keyEvent.ts index 2d0ee49322..0a128d725f 100644 --- a/common/web/keyboard-processor/src/text/keyEvent.ts +++ b/web/src/engine/keyboard/src/keyEvent.ts @@ -6,11 +6,11 @@ // a key event. The most straightforward way to integrate Web OSK events on other platforms is to have // other platforms recognize and utilize this type. -import type Keyboard from "../keyboards/keyboard.js"; +import type Keyboard from "./keyboards/keyboard.js"; import { type DeviceSpec } from "@keymanapp/web-utils"; import Codes from './codes.js'; -import { ActiveKeyBase } from "../index.js"; +import { ActiveKeyBase } from './keyboards/activeLayout.js'; export interface DefaultRulesInterface { forAny(Lkc: KeyEvent, isMnemonic: boolean): string; diff --git a/common/web/keyboard-processor/src/text/keyMapping.ts b/web/src/engine/keyboard/src/keyMapping.ts similarity index 100% rename from common/web/keyboard-processor/src/text/keyMapping.ts rename to web/src/engine/keyboard/src/keyMapping.ts diff --git a/common/web/keyboard-processor/src/keyboards/activeLayout.ts b/web/src/engine/keyboard/src/keyboards/activeLayout.ts similarity index 99% rename from common/web/keyboard-processor/src/keyboards/activeLayout.ts rename to web/src/engine/keyboard/src/keyboards/activeLayout.ts index 7b293db93c..c440511f17 100644 --- a/common/web/keyboard-processor/src/keyboards/activeLayout.ts +++ b/web/src/engine/keyboard/src/keyboards/activeLayout.ts @@ -1,6 +1,6 @@ -import Codes from "../text/codes.js"; -import KeyEvent, { KeyEventSpec } from "../text/keyEvent.js"; -import KeyMapping from "../text/keyMapping.js"; +import Codes from "../codes.js"; +import KeyEvent, { KeyEventSpec } from "../keyEvent.js"; +import KeyMapping from "../keyMapping.js"; import { ButtonClasses, Layouts } from "./defaultLayouts.js"; import type { LayoutKey, LayoutSubKey, LayoutRow, LayoutLayer, LayoutFormFactor, ButtonClass } from "./defaultLayouts.js"; import type Keyboard from "./keyboard.js"; @@ -105,7 +105,7 @@ export class ActiveKeyBase { pad: ActiveKeyBase.DEFAULT_PAD }; - /** WARNING - DO NOT USE DIRECTLY outside of @keymanapp/keyboard-processor! */ + /** WARNING - DO NOT USE DIRECTLY outside of keyman/engine/keyboard! */ id: TouchLayout.TouchLayoutKeyId; text: string; hint?: string; diff --git a/common/web/keyboard-processor/src/keyboards/defaultLayouts.ts b/web/src/engine/keyboard/src/keyboards/defaultLayouts.ts similarity index 99% rename from common/web/keyboard-processor/src/keyboards/defaultLayouts.ts rename to web/src/engine/keyboard/src/keyboards/defaultLayouts.ts index 109da53a0e..3b97659d4b 100644 --- a/common/web/keyboard-processor/src/keyboards/defaultLayouts.ts +++ b/web/src/engine/keyboard/src/keyboards/defaultLayouts.ts @@ -16,7 +16,7 @@ import ButtonClasses = TouchLayout.TouchLayoutKeySp; export { ButtonClasses }; -import Codes from "../text/codes.js"; +import Codes from "../codes.js"; import type Keyboard from "./keyboard.js"; export interface EncodedVisualKeyboard { diff --git a/common/web/keyboard-processor/src/keyboards/keyboard.ts b/web/src/engine/keyboard/src/keyboards/keyboard.ts similarity index 99% rename from common/web/keyboard-processor/src/keyboards/keyboard.ts rename to web/src/engine/keyboard/src/keyboards/keyboard.ts index 6ca5f790fd..17bec4ad70 100644 --- a/common/web/keyboard-processor/src/keyboards/keyboard.ts +++ b/web/src/engine/keyboard/src/keyboards/keyboard.ts @@ -1,12 +1,12 @@ -import Codes from "../text/codes.js"; +import Codes from "../codes.js"; import { EncodedVisualKeyboard, LayoutSpec, Layouts } from "./defaultLayouts.js"; import { ActiveKey, ActiveLayout, ActiveSubKey } from "./activeLayout.js"; -import KeyEvent from "../text/keyEvent.js"; -import type OutputTarget from "../text/outputTarget.js"; +import KeyEvent from "../keyEvent.js"; +import type OutputTarget from "../outputTarget.js"; import { ModifierKeyConstants, TouchLayout } from "@keymanapp/common-types"; type TouchLayoutSpec = TouchLayout.TouchLayoutPlatform & { isDefault?: boolean}; -import type { ComplexKeyboardStore, KeyboardStore } from "../text/systemStores.js"; +import type { ComplexKeyboardStore, KeyboardStore } from "../systemStores.js"; import { Version, DeviceSpec } from "@keymanapp/web-utils"; import StateKeyMap from "./stateKeyMap.js"; diff --git a/common/web/keyboard-processor/src/keyboards/keyboardHarness.ts b/web/src/engine/keyboard/src/keyboards/keyboardHarness.ts similarity index 99% rename from common/web/keyboard-processor/src/keyboards/keyboardHarness.ts rename to web/src/engine/keyboard/src/keyboards/keyboardHarness.ts index 109d209067..bb2e2d5ccb 100644 --- a/common/web/keyboard-processor/src/keyboards/keyboardHarness.ts +++ b/web/src/engine/keyboard/src/keyboards/keyboardHarness.ts @@ -1,5 +1,5 @@ import Keyboard from "./keyboard.js"; -import Codes from "../text/codes.js"; +import Codes from "../codes.js"; import { DeviceSpec } from '@keymanapp/web-utils'; /** diff --git a/common/web/keyboard-processor/src/keyboards/keyboardLoaderBase.ts b/web/src/engine/keyboard/src/keyboards/keyboardLoaderBase.ts similarity index 100% rename from common/web/keyboard-processor/src/keyboards/keyboardLoaderBase.ts rename to web/src/engine/keyboard/src/keyboards/keyboardLoaderBase.ts diff --git a/common/web/keyboard-processor/src/keyboards/keyboardProperties.ts b/web/src/engine/keyboard/src/keyboards/keyboardProperties.ts similarity index 100% rename from common/web/keyboard-processor/src/keyboards/keyboardProperties.ts rename to web/src/engine/keyboard/src/keyboards/keyboardProperties.ts diff --git a/common/web/keyboard-processor/src/keyboards/loaders/dom-keyboard-loader.ts b/web/src/engine/keyboard/src/keyboards/loaders/dom-keyboard-loader.ts similarity index 100% rename from common/web/keyboard-processor/src/keyboards/loaders/dom-keyboard-loader.ts rename to web/src/engine/keyboard/src/keyboards/loaders/dom-keyboard-loader.ts diff --git a/common/web/keyboard-processor/src/keyboards/loaders/domKeyboardLoader.ts b/web/src/engine/keyboard/src/keyboards/loaders/domKeyboardLoader.ts similarity index 97% rename from common/web/keyboard-processor/src/keyboards/loaders/domKeyboardLoader.ts rename to web/src/engine/keyboard/src/keyboards/loaders/domKeyboardLoader.ts index ea9cddecd4..fcb2c764cd 100644 --- a/common/web/keyboard-processor/src/keyboards/loaders/domKeyboardLoader.ts +++ b/web/src/engine/keyboard/src/keyboards/loaders/domKeyboardLoader.ts @@ -2,7 +2,7 @@ /// -import { Keyboard, KeyboardHarness, KeyboardLoaderBase, KeyboardLoadErrorBuilder, MinimalKeymanGlobal } from '@keymanapp/keyboard-processor'; +import { Keyboard, KeyboardHarness, KeyboardLoaderBase, KeyboardLoadErrorBuilder, MinimalKeymanGlobal } from 'keyman/engine/keyboard'; import { ManagedPromise } from '@keymanapp/web-utils'; diff --git a/common/web/keyboard-processor/src/keyboards/loaders/node-keyboard-loader.ts b/web/src/engine/keyboard/src/keyboards/loaders/node-keyboard-loader.ts similarity index 100% rename from common/web/keyboard-processor/src/keyboards/loaders/node-keyboard-loader.ts rename to web/src/engine/keyboard/src/keyboards/loaders/node-keyboard-loader.ts diff --git a/common/web/keyboard-processor/src/keyboards/loaders/nodeKeyboardLoader.ts b/web/src/engine/keyboard/src/keyboards/loaders/nodeKeyboardLoader.ts similarity index 95% rename from common/web/keyboard-processor/src/keyboards/loaders/nodeKeyboardLoader.ts rename to web/src/engine/keyboard/src/keyboards/loaders/nodeKeyboardLoader.ts index 143e1c16c1..b9f6a7cdfe 100644 --- a/common/web/keyboard-processor/src/keyboards/loaders/nodeKeyboardLoader.ts +++ b/web/src/engine/keyboard/src/keyboards/loaders/nodeKeyboardLoader.ts @@ -1,4 +1,4 @@ -import { Keyboard, KeyboardHarness, KeyboardLoaderBase, KeyboardLoadErrorBuilder, MinimalKeymanGlobal } from '@keymanapp/keyboard-processor'; +import { Keyboard, KeyboardHarness, KeyboardLoaderBase, KeyboardLoadErrorBuilder, MinimalKeymanGlobal } from 'keyman/engine/keyboard'; import vm from 'vm'; import fs from 'fs'; diff --git a/web/src/engine/keyboard/src/keyboards/loaders/tsconfig.dom.json b/web/src/engine/keyboard/src/keyboards/loaders/tsconfig.dom.json new file mode 100644 index 0000000000..1dd122f548 --- /dev/null +++ b/web/src/engine/keyboard/src/keyboards/loaders/tsconfig.dom.json @@ -0,0 +1,13 @@ +{ + "extends": "../../../../../../tsconfig.base.json", + "compilerOptions": { + "baseUrl": "../../../", + "outDir": "../../../../../../build/engine/keyboard/obj/keyboards/loaders/", + "tsBuildInfoFile": "../../../../../../build/engine/keyboard/obj/keyboards/loaders/tsconfig.dom.tsbuildinfo", + "rootDir": "." + }, + "references": [ + { "path": "../../../tsconfig.json" } + ], + "include": ["dom-keyboard-loader.ts", "domKeyboardLoader.ts"], +} diff --git a/web/src/engine/keyboard/src/keyboards/loaders/tsconfig.node.json b/web/src/engine/keyboard/src/keyboards/loaders/tsconfig.node.json new file mode 100644 index 0000000000..4a06decf4c --- /dev/null +++ b/web/src/engine/keyboard/src/keyboards/loaders/tsconfig.node.json @@ -0,0 +1,14 @@ +{ + "extends": "../../../../../../tsconfig.base.json", + "compilerOptions": { + "types": [ "node" ], + "baseUrl": "../../../", + "outDir": "../../../../../../build/engine/keyboard/obj/keyboards/loaders/", + "tsBuildInfoFile": "../../../../../../build/engine/keyboard/obj/keyboards/loaders/tsconfig.node.tsbuildinfo", + "rootDir": "." + }, + "references": [ + { "path": "../../../tsconfig.json" } + ], + "include": ["node-keyboard-loader.ts", "nodeKeyboardLoader.ts"], +} diff --git a/common/web/keyboard-processor/src/keyboards/spacebarText.ts b/web/src/engine/keyboard/src/keyboards/spacebarText.ts similarity index 100% rename from common/web/keyboard-processor/src/keyboards/spacebarText.ts rename to web/src/engine/keyboard/src/keyboards/spacebarText.ts diff --git a/common/web/keyboard-processor/src/keyboards/stateKeyMap.ts b/web/src/engine/keyboard/src/keyboards/stateKeyMap.ts similarity index 65% rename from common/web/keyboard-processor/src/keyboards/stateKeyMap.ts rename to web/src/engine/keyboard/src/keyboards/stateKeyMap.ts index c8e9ee8b76..e82ff417c4 100644 --- a/common/web/keyboard-processor/src/keyboards/stateKeyMap.ts +++ b/web/src/engine/keyboard/src/keyboards/stateKeyMap.ts @@ -1,5 +1,5 @@ /** - * Provided by @keymanapp/keyboard-processor's `KeyboardProcessor` class and utilized by the OSK + * Provided by keyman/engine/keyboard's `KeyboardProcessor` class and utilized by the OSK * to provide state feedback on any corresponding keys visible in the OSK. */ export default interface StateKeyMap { diff --git a/common/web/keyboard-processor/src/text/outputTarget.ts b/web/src/engine/keyboard/src/outputTarget.ts similarity index 100% rename from common/web/keyboard-processor/src/text/outputTarget.ts rename to web/src/engine/keyboard/src/outputTarget.ts diff --git a/common/web/keyboard-processor/src/text/ruleBehavior.interface.ts b/web/src/engine/keyboard/src/ruleBehavior.interface.ts similarity index 100% rename from common/web/keyboard-processor/src/text/ruleBehavior.interface.ts rename to web/src/engine/keyboard/src/ruleBehavior.interface.ts diff --git a/common/web/keyboard-processor/src/text/stringDivergence.ts b/web/src/engine/keyboard/src/stringDivergence.ts similarity index 100% rename from common/web/keyboard-processor/src/text/stringDivergence.ts rename to web/src/engine/keyboard/src/stringDivergence.ts diff --git a/common/web/keyboard-processor/src/text/systemStores.ts b/web/src/engine/keyboard/src/systemStores.ts similarity index 96% rename from common/web/keyboard-processor/src/text/systemStores.ts rename to web/src/engine/keyboard/src/systemStores.ts index a2f7abff34..24f3e8cc36 100644 --- a/common/web/keyboard-processor/src/text/systemStores.ts +++ b/web/src/engine/keyboard/src/systemStores.ts @@ -1,5 +1,5 @@ -import { type KeyboardHarness } from "../keyboards/keyboardHarness.js"; -import { StoreNonCharEntry } from '../keyboards/keyboard.js'; +import { type KeyboardHarness } from "./keyboards/keyboardHarness.js"; +import { StoreNonCharEntry } from './keyboards/keyboard.js'; export enum SystemStoreIDs { TSS_LAYER = 33, diff --git a/common/web/keyboard-processor/tests/node/basic-engine.js b/web/src/engine/keyboard/tests/node/basic-engine.js similarity index 87% rename from common/web/keyboard-processor/tests/node/basic-engine.js rename to web/src/engine/keyboard/tests/node/basic-engine.js index 1e7ff3a205..33d90b6567 100644 --- a/common/web/keyboard-processor/tests/node/basic-engine.js +++ b/web/src/engine/keyboard/tests/node/basic-engine.js @@ -4,8 +4,9 @@ import fs from 'fs'; import { createRequire } from 'module'; const require = createRequire(import.meta.url); -import { KeyboardInterface, MinimalKeymanGlobal } from '@keymanapp/keyboard-processor'; -import { NodeKeyboardLoader } from '@keymanapp/keyboard-processor/node-keyboard-loader'; +import { MinimalKeymanGlobal } from 'keyman/engine/keyboard'; +import { KeyboardInterface } from 'keyman/engine/js-processor'; +import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader'; import { KeyboardTest, NodeProctor } from '@keymanapp/recorder-core'; describe('Engine - Basic Simulation', function() { @@ -24,7 +25,7 @@ describe('Engine - Basic Simulation', function() { before(async function() { // -- START: Standard Recorder-based unit test loading boilerplate -- let keyboardLoader = new NodeKeyboardLoader(new KeyboardInterface({}, MinimalKeymanGlobal)); - let keyboard = await keyboardLoader.loadKeyboardFromPath('../../test/' + testSuite.keyboard.filename); + let keyboard = await keyboardLoader.loadKeyboardFromPath('../../../../common/test/' + testSuite.keyboard.filename); keyboardWithHarness = keyboardLoader.harness; keyboardWithHarness.activeKeyboard = keyboard; diff --git a/common/web/keyboard-processor/tests/node/basic-init.js b/web/src/engine/keyboard/tests/node/basic-init.js similarity index 92% rename from common/web/keyboard-processor/tests/node/basic-init.js rename to web/src/engine/keyboard/tests/node/basic-init.js index 8f04a6a6e8..cabdb9d432 100644 --- a/common/web/keyboard-processor/tests/node/basic-init.js +++ b/web/src/engine/keyboard/tests/node/basic-init.js @@ -3,8 +3,8 @@ import { assert } from 'chai'; import { createRequire } from 'module'; const require = createRequire(import.meta.url); -import { KeyboardProcessor } from '@keymanapp/keyboard-processor'; -import { NodeKeyboardLoader } from '@keymanapp/keyboard-processor/node-keyboard-loader'; +import { KeyboardProcessor } from 'keyman/engine/js-processor'; +import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader'; global.keyman = {}; // So that keyboard-based checks against the global `keyman` succeed. // 10.0+ dependent keyboards, like khmer_angkor, will otherwise fail to load. diff --git a/common/web/keyboard-processor/tests/node/bundled-module.js b/web/src/engine/keyboard/tests/node/bundled-module.js similarity index 91% rename from common/web/keyboard-processor/tests/node/bundled-module.js rename to web/src/engine/keyboard/tests/node/bundled-module.js index bfff937b62..cfc54480b6 100644 --- a/common/web/keyboard-processor/tests/node/bundled-module.js +++ b/web/src/engine/keyboard/tests/node/bundled-module.js @@ -1,5 +1,5 @@ import { assert } from "chai"; -import * as Package from "../../build/lib/index.mjs"; +import * as Package from "keyman/engine/keyboard"; // A few small tests to ensure that the ES Module bundle was successfully constructed and is usable. @@ -13,9 +13,9 @@ var toSupplementaryPairString = function(code){ let u = toSupplementaryPairString; describe('Bundled ES Module', function() { - describe('KeyboardProcessor', function () { + describe('Keyboard', function () { it('should initialize without errors', function () { - let kp = new Package.KeyboardProcessor(); + let kp = new Package.Keyboard(); assert.isNotNull(kp); }); }); diff --git a/common/web/keyboard-processor/tests/node/chirality.js b/web/src/engine/keyboard/tests/node/chirality.js similarity index 97% rename from common/web/keyboard-processor/tests/node/chirality.js rename to web/src/engine/keyboard/tests/node/chirality.js index 70dca3d47f..d812a21635 100644 --- a/common/web/keyboard-processor/tests/node/chirality.js +++ b/web/src/engine/keyboard/tests/node/chirality.js @@ -4,8 +4,9 @@ import fs from 'fs'; import { createRequire } from 'module'; const require = createRequire(import.meta.url); -import { KeyboardInterface, MinimalKeymanGlobal } from '@keymanapp/keyboard-processor'; -import { NodeKeyboardLoader } from '@keymanapp/keyboard-processor/node-keyboard-loader'; +import { MinimalKeymanGlobal } from 'keyman/engine/keyboard'; +import { KeyboardInterface } from 'keyman/engine/js-processor'; +import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader'; import { KeyboardTest, NodeProctor } from '@keymanapp/recorder-core'; import { ModifierKeyConstants } from '@keymanapp/common-types'; @@ -25,7 +26,7 @@ describe('Engine - Chirality', function() { before(async function() { // -- START: Standard Recorder-based unit test loading boilerplate -- let keyboardLoader = new NodeKeyboardLoader(new KeyboardInterface({}, MinimalKeymanGlobal)); - let keyboard = await keyboardLoader.loadKeyboardFromPath('../../test/' + testSuite.keyboard.filename); + let keyboard = await keyboardLoader.loadKeyboardFromPath('../../../../common/test/' + testSuite.keyboard.filename); keyboardWithHarness = keyboardLoader.harness; keyboardWithHarness.activeKeyboard = keyboard; diff --git a/common/web/keyboard-processor/tests/node/deadkeys.js b/web/src/engine/keyboard/tests/node/deadkeys.js similarity index 87% rename from common/web/keyboard-processor/tests/node/deadkeys.js rename to web/src/engine/keyboard/tests/node/deadkeys.js index e2fe70837e..51bf2aebf5 100644 --- a/common/web/keyboard-processor/tests/node/deadkeys.js +++ b/web/src/engine/keyboard/tests/node/deadkeys.js @@ -4,8 +4,9 @@ import fs from 'fs'; import { createRequire } from 'module'; const require = createRequire(import.meta.url); -import { KeyboardInterface, MinimalKeymanGlobal } from '@keymanapp/keyboard-processor'; -import { NodeKeyboardLoader } from '@keymanapp/keyboard-processor/node-keyboard-loader'; +import { MinimalKeymanGlobal } from 'keyman/engine/keyboard'; +import { KeyboardInterface } from 'keyman/engine/js-processor'; +import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader'; import { KeyboardTest, NodeProctor } from '@keymanapp/recorder-core'; describe('Engine - Deadkeys', function() { @@ -24,7 +25,7 @@ describe('Engine - Deadkeys', function() { before(async function() { // -- START: Standard Recorder-based unit test loading boilerplate -- let keyboardLoader = new NodeKeyboardLoader(new KeyboardInterface({}, MinimalKeymanGlobal)); - let keyboard = await keyboardLoader.loadKeyboardFromPath('../../test/' + testSuite.keyboard.filename); + let keyboard = await keyboardLoader.loadKeyboardFromPath('../../../../common/test/' + testSuite.keyboard.filename); keyboardWithHarness = keyboardLoader.harness; keyboardWithHarness.activeKeyboard = keyboard; diff --git a/common/web/keyboard-processor/tests/node/engine/context.js b/web/src/engine/keyboard/tests/node/engine/context.js similarity index 99% rename from common/web/keyboard-processor/tests/node/engine/context.js rename to web/src/engine/keyboard/tests/node/engine/context.js index a1fe5863df..3b318607a0 100644 --- a/common/web/keyboard-processor/tests/node/engine/context.js +++ b/web/src/engine/keyboard/tests/node/engine/context.js @@ -3,8 +3,9 @@ import { assert } from 'chai'; import { createRequire } from 'module'; const require = createRequire(import.meta.url); -import { KeyboardInterface, KeyboardProcessor, MinimalKeymanGlobal, Mock } from '@keymanapp/keyboard-processor'; -import { NodeKeyboardLoader } from '@keymanapp/keyboard-processor/node-keyboard-loader'; +import { MinimalKeymanGlobal, Mock } from 'keyman/engine/keyboard'; +import { KeyboardInterface, KeyboardProcessor } from 'keyman/engine/js-processor'; +import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader'; import { NodeProctor, RecordedKeystrokeSequence } from '@keymanapp/recorder-core'; diff --git a/common/web/keyboard-processor/tests/node/engine/notany_context.js b/web/src/engine/keyboard/tests/node/engine/notany_context.js similarity index 94% rename from common/web/keyboard-processor/tests/node/engine/notany_context.js rename to web/src/engine/keyboard/tests/node/engine/notany_context.js index 2329463d46..1fc2ec0129 100644 --- a/common/web/keyboard-processor/tests/node/engine/notany_context.js +++ b/web/src/engine/keyboard/tests/node/engine/notany_context.js @@ -3,8 +3,9 @@ import { assert } from 'chai'; import { createRequire } from 'module'; const require = createRequire(import.meta.url); -import { KeyboardInterface, MinimalKeymanGlobal, Mock } from '@keymanapp/keyboard-processor'; -import { NodeKeyboardLoader } from '@keymanapp/keyboard-processor/node-keyboard-loader'; +import { MinimalKeymanGlobal, Mock } from 'keyman/engine/keyboard'; +import { KeyboardInterface } from 'keyman/engine/js-processor'; +import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader'; import { NodeProctor, RecordedKeystrokeSequence } from '@keymanapp/recorder-core'; import { extendString } from '@keymanapp/web-utils'; diff --git a/common/web/keyboard-processor/tests/node/engine/stores.js b/web/src/engine/keyboard/tests/node/engine/stores.js similarity index 94% rename from common/web/keyboard-processor/tests/node/engine/stores.js rename to web/src/engine/keyboard/tests/node/engine/stores.js index ade1c2bd47..8174cbe077 100644 --- a/common/web/keyboard-processor/tests/node/engine/stores.js +++ b/web/src/engine/keyboard/tests/node/engine/stores.js @@ -1,6 +1,7 @@ import { assert } from 'chai'; -import { Keyboard, KeyboardProcessor } from '@keymanapp/keyboard-processor'; +import { Keyboard } from 'keyman/engine/keyboard'; +import { KeyboardProcessor } from 'keyman/engine/js-processor'; import { extendString } from '@keymanapp/web-utils'; extendString(); diff --git a/common/web/keyboard-processor/tests/node/engine/unmatched_final_group.js b/web/src/engine/keyboard/tests/node/engine/unmatched_final_group.js similarity index 84% rename from common/web/keyboard-processor/tests/node/engine/unmatched_final_group.js rename to web/src/engine/keyboard/tests/node/engine/unmatched_final_group.js index 81f9765da4..cf2f1e8803 100644 --- a/common/web/keyboard-processor/tests/node/engine/unmatched_final_group.js +++ b/web/src/engine/keyboard/tests/node/engine/unmatched_final_group.js @@ -4,8 +4,9 @@ import fs from 'fs'; import { createRequire } from 'module'; const require = createRequire(import.meta.url); -import { KeyboardInterface, MinimalKeymanGlobal } from '@keymanapp/keyboard-processor'; -import { NodeKeyboardLoader } from '@keymanapp/keyboard-processor/node-keyboard-loader'; +import { MinimalKeymanGlobal } from 'keyman/engine/keyboard'; +import { KeyboardInterface } from 'keyman/engine/js-processor'; +import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader'; import { KeyboardTest, NodeProctor } from '@keymanapp/recorder-core'; describe('Engine - Unmatched Final Groups', function() { @@ -23,7 +24,7 @@ describe('Engine - Unmatched Final Groups', function() { before(async function() { // -- START: Standard Recorder-based unit test loading boilerplate -- let keyboardLoader = new NodeKeyboardLoader(new KeyboardInterface({}, MinimalKeymanGlobal)); - const keyboard = await keyboardLoader.loadKeyboardFromPath('../../test/' + testSuite.keyboard.filename); + const keyboard = await keyboardLoader.loadKeyboardFromPath('../../../../common/test/' + testSuite.keyboard.filename); keyboardWithHarness = keyboardLoader.harness; keyboardWithHarness.activeKeyboard = keyboard; diff --git a/common/web/keyboard-processor/tests/node/keyboard-loading.js b/web/src/engine/keyboard/tests/node/keyboard-loading.js similarity index 96% rename from common/web/keyboard-processor/tests/node/keyboard-loading.js rename to web/src/engine/keyboard/tests/node/keyboard-loading.js index 500780dfed..6152f1b0de 100644 --- a/common/web/keyboard-processor/tests/node/keyboard-loading.js +++ b/web/src/engine/keyboard/tests/node/keyboard-loading.js @@ -4,8 +4,9 @@ import fs from 'fs'; import { createRequire } from 'module'; const require = createRequire(import.meta.url); -import { KeyboardHarness, KeyboardInterface, KeyboardLoaderBase, MinimalKeymanGlobal, Mock } from '@keymanapp/keyboard-processor'; -import { NodeKeyboardLoader } from '@keymanapp/keyboard-processor/node-keyboard-loader'; +import { KeyboardHarness, MinimalKeymanGlobal, Mock } from 'keyman/engine/keyboard'; +import { KeyboardInterface } from 'keyman/engine/js-processor'; +import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader'; describe('Headless keyboard loading', function() { const laoPath = require.resolve('@keymanapp/common-test-resources/keyboards/lao_2008_basic.js'); diff --git a/common/web/keyboard-processor/tests/node/keyboard-properties.js b/web/src/engine/keyboard/tests/node/keyboard-properties.js similarity index 98% rename from common/web/keyboard-processor/tests/node/keyboard-properties.js rename to web/src/engine/keyboard/tests/node/keyboard-properties.js index b6ec2dbf8d..f23d56e3b5 100644 --- a/common/web/keyboard-processor/tests/node/keyboard-properties.js +++ b/web/src/engine/keyboard/tests/node/keyboard-properties.js @@ -5,7 +5,7 @@ import path from 'path'; import { createRequire } from 'module'; const require = createRequire(import.meta.url); -import { KeyboardProperties, SpacebarText } from '@keymanapp/keyboard-processor'; +import { KeyboardProperties, SpacebarText } from 'keyman/engine/keyboard'; describe('Keyboard Properties', function() { let commonResourcesPackage = '@keymanapp/common-test-resources'; diff --git a/common/web/keyboard-processor/tests/node/mocks.js b/web/src/engine/keyboard/tests/node/mocks.js similarity index 98% rename from common/web/keyboard-processor/tests/node/mocks.js rename to web/src/engine/keyboard/tests/node/mocks.js index 9a84e2a8cc..b02f259886 100644 --- a/common/web/keyboard-processor/tests/node/mocks.js +++ b/web/src/engine/keyboard/tests/node/mocks.js @@ -1,5 +1,5 @@ import { assert } from 'chai'; -import { Mock } from '@keymanapp/keyboard-processor'; +import { Mock } from 'keyman/engine/keyboard'; describe('Mocks', function() { describe('app|les', () => { diff --git a/common/web/keyboard-processor/tests/node/non-positional-rules.js b/web/src/engine/keyboard/tests/node/non-positional-rules.js similarity index 97% rename from common/web/keyboard-processor/tests/node/non-positional-rules.js rename to web/src/engine/keyboard/tests/node/non-positional-rules.js index aba54643ae..2ab62a4840 100644 --- a/common/web/keyboard-processor/tests/node/non-positional-rules.js +++ b/web/src/engine/keyboard/tests/node/non-positional-rules.js @@ -4,8 +4,9 @@ import { ModifierKeyConstants } from '@keymanapp/common-types'; import { createRequire } from 'module'; const require = createRequire(import.meta.url); -import { Codes, KeyboardInterface, KeyEvent, MinimalKeymanGlobal, Mock } from '@keymanapp/keyboard-processor'; -import { NodeKeyboardLoader } from '@keymanapp/keyboard-processor/node-keyboard-loader'; +import { Codes, KeyEvent, MinimalKeymanGlobal, Mock } from 'keyman/engine/keyboard'; +import { KeyboardInterface } from 'keyman/engine/js-processor'; +import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader'; // Compare and contrast the unit tests here with those for app/browser key-event unit testing // in the hardware-event-processing set; the output objects there should have the same format diff --git a/common/web/keyboard-processor/tests/node/specialized-backspace.js b/web/src/engine/keyboard/tests/node/specialized-backspace.js similarity index 98% rename from common/web/keyboard-processor/tests/node/specialized-backspace.js rename to web/src/engine/keyboard/tests/node/specialized-backspace.js index db2be071e8..967701c63a 100644 --- a/common/web/keyboard-processor/tests/node/specialized-backspace.js +++ b/web/src/engine/keyboard/tests/node/specialized-backspace.js @@ -4,8 +4,9 @@ import fs from 'fs'; import { createRequire } from 'module'; const require = createRequire(import.meta.url); -import { Codes, KeyboardInterface, KeyboardProcessor, KeyEvent, MinimalKeymanGlobal, Mock } from '@keymanapp/keyboard-processor'; -import { NodeKeyboardLoader } from '@keymanapp/keyboard-processor/node-keyboard-loader'; +import { Codes, KeyEvent, MinimalKeymanGlobal, Mock } from 'keyman/engine/keyboard'; +import { KeyboardInterface, KeyboardProcessor } from 'keyman/engine/js-processor'; +import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader'; import { ModifierKeyConstants } from '@keymanapp/common-types'; diff --git a/common/web/keyboard-processor/tests/node/transcriptions.js b/web/src/engine/keyboard/tests/node/transcriptions.js similarity index 99% rename from common/web/keyboard-processor/tests/node/transcriptions.js rename to web/src/engine/keyboard/tests/node/transcriptions.js index b071532bf2..569b36d3cd 100644 --- a/common/web/keyboard-processor/tests/node/transcriptions.js +++ b/web/src/engine/keyboard/tests/node/transcriptions.js @@ -1,6 +1,6 @@ import { assert } from 'chai'; -import { Mock, findCommonSubstringEndIndex } from '@keymanapp/keyboard-processor'; +import { Mock, findCommonSubstringEndIndex } from 'keyman/engine/keyboard'; import { extendString } from '@keymanapp/web-utils'; extendString(); // Ensure KMW's string-extension functionality is available. diff --git a/common/web/keyboard-processor/tsconfig.all.json b/web/src/engine/keyboard/tsconfig.all.json similarity index 66% rename from common/web/keyboard-processor/tsconfig.all.json rename to web/src/engine/keyboard/tsconfig.all.json index 79f10644d1..1ee44d3e70 100644 --- a/common/web/keyboard-processor/tsconfig.all.json +++ b/web/src/engine/keyboard/tsconfig.all.json @@ -1,9 +1,9 @@ { - "extends": "../tsconfig.kmw-main-base.json", + "extends": "../../../tsconfig.base.json", "compilerOptions": { "baseUrl": "./", - "outDir": "build/obj/", - "tsBuildInfoFile": "build/obj/tsconfig.all.tsbuildinfo", + "outDir": "../../../build/engine/keyboard/obj/", + "tsBuildInfoFile": "../../../build/engine/keyboard/obj/tsconfig.all.tsbuildinfo", "rootDir": "./src/" }, "references": [ diff --git a/web/src/engine/keyboard/tsconfig.json b/web/src/engine/keyboard/tsconfig.json new file mode 100644 index 0000000000..84d96c8591 --- /dev/null +++ b/web/src/engine/keyboard/tsconfig.json @@ -0,0 +1,12 @@ +// Is used by the keyboard-loader submodules. +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "baseUrl": "./", + "outDir": "../../../build/engine/keyboard/obj/", + "tsBuildInfoFile": "../../../build/engine/keyboard/obj/tsconfig.tsbuildinfo", + "rootDir": "./src/" + }, + "include": [ "./src/**/*.ts"], + "exclude": ["./src/keyboards/loaders/**/*.ts"] +} diff --git a/web/src/engine/main/build.sh b/web/src/engine/main/build.sh index 4e6ca67db1..15eaf770f2 100755 --- a/web/src/engine/main/build.sh +++ b/web/src/engine/main/build.sh @@ -14,7 +14,7 @@ SUBPROJECT_NAME=engine/main builder_describe "Builds the Keyman Engine for Web's common top-level base classes." \ "@/common/web/keyman-version" \ - "@/common/web/keyboard-processor" \ + "@/web/src/engine/keyboard" \ "@/common/predictive-text" \ "@/web/src/engine/interfaces build" \ "@/web/src/engine/device-detect build" \ diff --git a/web/src/engine/main/src/contextManagerBase.ts b/web/src/engine/main/src/contextManagerBase.ts index e745dbe312..f20dd19d00 100644 --- a/web/src/engine/main/src/contextManagerBase.ts +++ b/web/src/engine/main/src/contextManagerBase.ts @@ -1,5 +1,5 @@ import { EventEmitter } from 'eventemitter3'; -import { ManagedPromise, type Keyboard, type OutputTarget } from '@keymanapp/keyboard-processor'; +import { ManagedPromise, type Keyboard, type OutputTarget } from 'keyman/engine/keyboard'; import { type KeyboardInterface } from 'keyman/engine/js-processor'; import { StubAndKeyboardCache, type KeyboardStub } from 'keyman/engine/package-cache'; import { PredictionContext } from 'keyman/engine/interfaces'; diff --git a/web/src/engine/main/src/engineConfiguration.ts b/web/src/engine/main/src/engineConfiguration.ts index bb82844c56..d6f6f0d698 100644 --- a/web/src/engine/main/src/engineConfiguration.ts +++ b/web/src/engine/main/src/engineConfiguration.ts @@ -1,6 +1,6 @@ import { EventEmitter } from "eventemitter3"; -import { DeviceSpec, KeyboardProperties, ManagedPromise, OutputTarget, physicalKeyDeviceAlias, SpacebarText } from "@keymanapp/keyboard-processor"; +import { DeviceSpec, KeyboardProperties, ManagedPromise, OutputTarget, physicalKeyDeviceAlias, SpacebarText } from "keyman/engine/keyboard"; import { RuleBehavior } from 'keyman/engine/js-processor'; import { PathConfiguration, PathOptionDefaults, PathOptionSpec } from "keyman/engine/interfaces"; import { Device } from "keyman/engine/device-detect"; diff --git a/web/src/engine/main/src/hardKeyboard.ts b/web/src/engine/main/src/hardKeyboard.ts index 7dc9b5e357..2e917ad77d 100644 --- a/web/src/engine/main/src/hardKeyboard.ts +++ b/web/src/engine/main/src/hardKeyboard.ts @@ -1,5 +1,5 @@ import { EventEmitter } from "eventemitter3"; -import { Keyboard, KeyMapping, KeyEvent, Codes } from "@keymanapp/keyboard-processor"; +import { Keyboard, KeyMapping, KeyEvent, Codes } from "keyman/engine/keyboard"; import { type RuleBehavior } from 'keyman/engine/js-processor'; import { KeyEventSourceInterface } from 'keyman/engine/events'; import { ModifierKeyConstants } from '@keymanapp/common-types'; diff --git a/web/src/engine/main/src/headless/contextWindow.ts b/web/src/engine/main/src/headless/contextWindow.ts index 2adb4f0b6a..b3337c29e5 100644 --- a/web/src/engine/main/src/headless/contextWindow.ts +++ b/web/src/engine/main/src/headless/contextWindow.ts @@ -1,4 +1,4 @@ -import { Mock } from "@keymanapp/keyboard-processor"; +import { Mock } from "keyman/engine/keyboard"; export default class ContextWindow implements Context { // Used to limit the range of context replicated for use of keyboard rules within diff --git a/web/src/engine/main/src/headless/inputProcessor.ts b/web/src/engine/main/src/headless/inputProcessor.ts index a96170457e..13eb67c2dc 100644 --- a/web/src/engine/main/src/headless/inputProcessor.ts +++ b/web/src/engine/main/src/headless/inputProcessor.ts @@ -16,7 +16,7 @@ import { Mock, type OutputTarget, SystemStoreIDs, -} from "@keymanapp/keyboard-processor"; +} from "keyman/engine/keyboard"; import { KeyboardInterface, KeyboardProcessor, RuleBehavior, type ProcessorInitOptions } from 'keyman/engine/js-processor'; import { TranscriptionCache } from "./transcriptionCache.js"; diff --git a/web/src/engine/main/src/headless/languageProcessor.ts b/web/src/engine/main/src/headless/languageProcessor.ts index 30a676bb6a..8f93d39d87 100644 --- a/web/src/engine/main/src/headless/languageProcessor.ts +++ b/web/src/engine/main/src/headless/languageProcessor.ts @@ -1,6 +1,6 @@ import { EventEmitter } from "eventemitter3"; import { LMLayer } from "@keymanapp/lexical-model-layer/web"; -import { OutputTarget, Transcription, Mock } from "@keymanapp/keyboard-processor"; +import { OutputTarget, Transcription, Mock } from "keyman/engine/keyboard"; import { LanguageProcessorEventMap, ModelSpec, StateChangeEnum, ReadySuggestions } from 'keyman/engine/interfaces'; import ContextWindow from "./contextWindow.js"; import { TranscriptionCache } from "./transcriptionCache.js"; diff --git a/web/src/engine/main/src/headless/transcriptionCache.ts b/web/src/engine/main/src/headless/transcriptionCache.ts index c173009171..9430bde5ee 100644 --- a/web/src/engine/main/src/headless/transcriptionCache.ts +++ b/web/src/engine/main/src/headless/transcriptionCache.ts @@ -1,4 +1,4 @@ -import { Transcription } from "@keymanapp/keyboard-processor"; +import { Transcription } from "keyman/engine/keyboard"; const TRANSCRIPTION_BUFFER_SIZE = 10; diff --git a/web/src/engine/main/src/keyboardInterface.ts b/web/src/engine/main/src/keyboardInterface.ts index d966c26bad..9d922477b2 100644 --- a/web/src/engine/main/src/keyboardInterface.ts +++ b/web/src/engine/main/src/keyboardInterface.ts @@ -1,4 +1,4 @@ -import { KeyboardObject } from "@keymanapp/keyboard-processor"; +import { KeyboardObject } from "keyman/engine/keyboard"; import { KeyboardInterface as KeyboardInterfaceBase } from 'keyman/engine/js-processor'; import { KeyboardStub, RawKeyboardStub, toUnprefixedKeyboardId as unprefixed } from 'keyman/engine/package-cache'; diff --git a/web/src/engine/main/src/keymanEngine.ts b/web/src/engine/main/src/keymanEngine.ts index 86ff9d5898..b91920e70d 100644 --- a/web/src/engine/main/src/keymanEngine.ts +++ b/web/src/engine/main/src/keymanEngine.ts @@ -1,6 +1,6 @@ -import { type KeyEvent, type Keyboard, KeyboardKeymanGlobal } from "@keymanapp/keyboard-processor"; +import { type KeyEvent, type Keyboard, KeyboardKeymanGlobal } from "keyman/engine/keyboard"; import { ProcessorInitOptions, RuleBehavior } from 'keyman/engine/js-processor'; -import { DOMKeyboardLoader as KeyboardLoader } from "@keymanapp/keyboard-processor/dom-keyboard-loader"; +import { DOMKeyboardLoader as KeyboardLoader } from "keyman/engine/keyboard/dom-keyboard-loader"; import { InputProcessor } from './headless/inputProcessor.js'; import { OSKView } from "keyman/engine/osk"; import { KeyboardRequisitioner, ModelCache, toUnprefixedKeyboardId as unprefixed } from "keyman/engine/package-cache"; @@ -244,7 +244,7 @@ export default class KeymanEngine< this.contextManager.configure({ resetContext: (target) => { // Could reset the target's deadkeys here, but it's really more of a 'core' task. - // So we delegate that to keyboard-processor. + // So we delegate that to keyboard. if(this.osk) { this.osk.batchLayoutAfter(() => { this.core.resetContext(target); diff --git a/web/src/engine/main/src/variableStoreCookieSerializer.ts b/web/src/engine/main/src/variableStoreCookieSerializer.ts index 35b51150c0..87a5c8b6ff 100644 --- a/web/src/engine/main/src/variableStoreCookieSerializer.ts +++ b/web/src/engine/main/src/variableStoreCookieSerializer.ts @@ -1,4 +1,4 @@ -import { VariableStore, VariableStoreSerializer } from "@keymanapp/keyboard-processor"; +import { VariableStore, VariableStoreSerializer } from "keyman/engine/keyboard"; import { CookieSerializer } from "keyman/engine/dom-utils"; // While there's little reason we couldn't store all of a keyboard's store values within diff --git a/web/src/engine/osk/build.sh b/web/src/engine/osk/build.sh index 4538b79d92..0d676a2d3e 100755 --- a/web/src/engine/osk/build.sh +++ b/web/src/engine/osk/build.sh @@ -13,7 +13,7 @@ SUBPROJECT_NAME=engine/osk # ################################ Main script ################################ builder_describe "Builds the Keyman Engine for Web's On-Screen Keyboard package (OSK)." \ - "@/common/web/keyboard-processor build" \ + "@/web/src/engine/keyboard build" \ "@/common/web/gesture-recognizer build" \ "@/web/src/engine/interfaces build" \ "@/web/src/engine/dom-utils build" \ diff --git a/web/src/engine/osk/src/banner/banner.ts b/web/src/engine/osk/src/banner/banner.ts index 39b3ddc708..e38b6b6625 100644 --- a/web/src/engine/osk/src/banner/banner.ts +++ b/web/src/engine/osk/src/banner/banner.ts @@ -1,4 +1,4 @@ -import { Keyboard, KeyboardProperties } from '@keymanapp/keyboard-processor'; +import { Keyboard, KeyboardProperties } from 'keyman/engine/keyboard'; import { createUnselectableElement } from 'keyman/engine/dom-utils'; // Base class for a banner above the keyboard in the OSK diff --git a/web/src/engine/osk/src/banner/bannerController.ts b/web/src/engine/osk/src/banner/bannerController.ts index a53ea2f9e9..7fbc8ceb9b 100644 --- a/web/src/engine/osk/src/banner/bannerController.ts +++ b/web/src/engine/osk/src/banner/bannerController.ts @@ -6,7 +6,7 @@ import { BannerView } from './bannerView.js'; import { Banner } from './banner.js'; import { BlankBanner } from './blankBanner.js'; import { HTMLBanner } from './htmlBanner.js'; -import { Keyboard, KeyboardProperties } from '@keymanapp/keyboard-processor'; +import { Keyboard, KeyboardProperties } from 'keyman/engine/keyboard'; export class BannerController { private container: BannerView; diff --git a/web/src/engine/osk/src/banner/suggestionBanner.ts b/web/src/engine/osk/src/banner/suggestionBanner.ts index adf6a5ea20..34455fd061 100644 --- a/web/src/engine/osk/src/banner/suggestionBanner.ts +++ b/web/src/engine/osk/src/banner/suggestionBanner.ts @@ -13,7 +13,7 @@ import { import { BANNER_GESTURE_SET } from './bannerGestureSet.js'; -import { DeviceSpec, Keyboard, KeyboardProperties, timedPromise } from '@keymanapp/keyboard-processor'; +import { DeviceSpec, Keyboard, KeyboardProperties, timedPromise } from 'keyman/engine/keyboard'; import { Banner } from './banner.js'; import { ParsedLengthStyle } from '../lengthStyle.js'; import { getFontSizeStyle } from '../fontSizeUtils.js'; diff --git a/web/src/engine/osk/src/components/helpPageView.ts b/web/src/engine/osk/src/components/helpPageView.ts index 7c66708be9..af489a2686 100644 --- a/web/src/engine/osk/src/components/helpPageView.ts +++ b/web/src/engine/osk/src/components/helpPageView.ts @@ -1,4 +1,4 @@ -import { Keyboard } from '@keymanapp/keyboard-processor'; +import { Keyboard } from 'keyman/engine/keyboard'; import KeyboardView from './keyboardView.interface.js'; import { ParsedLengthStyle } from "../lengthStyle.js"; diff --git a/web/src/engine/osk/src/components/titleBar.ts b/web/src/engine/osk/src/components/titleBar.ts index 815b8a1e4e..dd4eba3df7 100644 --- a/web/src/engine/osk/src/components/titleBar.ts +++ b/web/src/engine/osk/src/components/titleBar.ts @@ -1,6 +1,6 @@ import { EventEmitter } from 'eventemitter3'; -import { Keyboard } from '@keymanapp/keyboard-processor'; +import { Keyboard } from 'keyman/engine/keyboard'; import OSKViewComponent from './oskViewComponent.interface.js'; import { ParsedLengthStyle } from '../lengthStyle.js'; diff --git a/web/src/engine/osk/src/correctionLayout.ts b/web/src/engine/osk/src/correctionLayout.ts index c3c0ffa886..ba5f902ff4 100644 --- a/web/src/engine/osk/src/correctionLayout.ts +++ b/web/src/engine/osk/src/correctionLayout.ts @@ -1,4 +1,4 @@ -import { ActiveKey, ActiveKeyBase, ActiveLayer, ActiveRow, Codes } from "@keymanapp/keyboard-processor"; +import { ActiveKey, ActiveKeyBase, ActiveLayer, ActiveRow, Codes } from "keyman/engine/keyboard"; /** * Defines correction-layout mappings for keys to be considered by diff --git a/web/src/engine/osk/src/corrections.ts b/web/src/engine/osk/src/corrections.ts index 39c5ae2ef3..808e1c6dce 100644 --- a/web/src/engine/osk/src/corrections.ts +++ b/web/src/engine/osk/src/corrections.ts @@ -1,4 +1,4 @@ -import { ActiveKeyBase, KeyDistribution } from "@keymanapp/keyboard-processor"; +import { ActiveKeyBase, KeyDistribution } from "keyman/engine/keyboard"; import { CorrectionLayout } from "./correctionLayout.js"; /** diff --git a/web/src/engine/osk/src/index.ts b/web/src/engine/osk/src/index.ts index 388ea32750..380377257d 100644 --- a/web/src/engine/osk/src/index.ts +++ b/web/src/engine/osk/src/index.ts @@ -1,4 +1,4 @@ -export { Codes, DeviceSpec, Keyboard, KeyboardProperties, SpacebarText } from '@keymanapp/keyboard-processor'; +export { Codes, DeviceSpec, Keyboard, KeyboardProperties, SpacebarText } from 'keyman/engine/keyboard'; export { default as OSKView } from './views/oskView.js'; export { default as FloatingOSKView, FloatingOSKViewConfiguration } from './views/floatingOskView.js'; diff --git a/web/src/engine/osk/src/input/gestures/browser/flick.ts b/web/src/engine/osk/src/input/gestures/browser/flick.ts index c83a85121e..91d2071871 100644 --- a/web/src/engine/osk/src/input/gestures/browser/flick.ts +++ b/web/src/engine/osk/src/input/gestures/browser/flick.ts @@ -1,7 +1,7 @@ import { type KeyElement } from '../../../keyElement.js'; import VisualKeyboard from '../../../visualKeyboard.js'; -import { ActiveKey, ActiveKeyBase, ActiveSubKey, KeyDistribution, KeyEvent } from '@keymanapp/keyboard-processor'; +import { ActiveKey, ActiveKeyBase, ActiveSubKey, KeyDistribution, KeyEvent } from 'keyman/engine/keyboard'; import { ConfigChangeClosure, CumulativePathStats, GestureRecognizerConfiguration, GestureSequence, GestureSource, GestureSourceSubview, InputSample, RecognitionZoneSource } from '@keymanapp/gesture-recognizer'; import { GestureHandler } from '../gestureHandler.js'; import { distributionFromDistanceMaps } from '../../../corrections.js'; diff --git a/web/src/engine/osk/src/input/gestures/browser/modipress.ts b/web/src/engine/osk/src/input/gestures/browser/modipress.ts index f3670944a4..3ffd4c206c 100644 --- a/web/src/engine/osk/src/input/gestures/browser/modipress.ts +++ b/web/src/engine/osk/src/input/gestures/browser/modipress.ts @@ -1,7 +1,7 @@ import { type KeyElement } from '../../../keyElement.js'; import VisualKeyboard from '../../../visualKeyboard.js'; -import { KeyDistribution, ActiveKeyBase } from '@keymanapp/keyboard-processor'; +import { KeyDistribution, ActiveKeyBase } from 'keyman/engine/keyboard'; import { GestureSequence } from '@keymanapp/gesture-recognizer'; import { GestureHandler } from '../gestureHandler.js'; diff --git a/web/src/engine/osk/src/input/gestures/browser/multitap.ts b/web/src/engine/osk/src/input/gestures/browser/multitap.ts index 23c4898ff0..99e50810f9 100644 --- a/web/src/engine/osk/src/input/gestures/browser/multitap.ts +++ b/web/src/engine/osk/src/input/gestures/browser/multitap.ts @@ -1,7 +1,7 @@ import { type KeyElement } from '../../../keyElement.js'; import VisualKeyboard from '../../../visualKeyboard.js'; -import { ActiveSubKey, ActiveKey, KeyDistribution, ActiveKeyBase } from '@keymanapp/keyboard-processor'; +import { ActiveSubKey, ActiveKey, KeyDistribution, ActiveKeyBase } from 'keyman/engine/keyboard'; import { GestureSequence, GestureStageReport } from '@keymanapp/gesture-recognizer'; import { GestureHandler } from '../gestureHandler.js'; import { distributionFromDistanceMaps } from '../../../corrections.js'; diff --git a/web/src/engine/osk/src/input/gestures/browser/oskSubKey.ts b/web/src/engine/osk/src/input/gestures/browser/oskSubKey.ts index 7640c3b20e..abf3a9fb80 100644 --- a/web/src/engine/osk/src/input/gestures/browser/oskSubKey.ts +++ b/web/src/engine/osk/src/input/gestures/browser/oskSubKey.ts @@ -1,4 +1,4 @@ -import { ActiveSubKey } from '@keymanapp/keyboard-processor'; +import { ActiveSubKey } from 'keyman/engine/keyboard'; import OSKKey from '../../../keyboard-layout/oskKey.js'; import { KeyData, KeyElement, link } from '../../../keyElement.js'; import VisualKeyboard from '../../../visualKeyboard.js'; diff --git a/web/src/engine/osk/src/input/gestures/browser/subkeyPopup.ts b/web/src/engine/osk/src/input/gestures/browser/subkeyPopup.ts index e9388e96f2..d33d319211 100644 --- a/web/src/engine/osk/src/input/gestures/browser/subkeyPopup.ts +++ b/web/src/engine/osk/src/input/gestures/browser/subkeyPopup.ts @@ -3,7 +3,7 @@ import { type KeyElement } from '../../../keyElement.js'; import OSKBaseKey from '../../../keyboard-layout/oskBaseKey.js'; import VisualKeyboard from '../../../visualKeyboard.js'; -import { DeviceSpec, ActiveSubKey, KeyDistribution, ActiveKeyBase } from '@keymanapp/keyboard-processor'; +import { DeviceSpec, ActiveSubKey, KeyDistribution, ActiveKeyBase } from 'keyman/engine/keyboard'; import { ConfigChangeClosure, GestureRecognizerConfiguration, GestureSequence, PaddedZoneSource, RecognitionZoneSource } from '@keymanapp/gesture-recognizer'; import { GestureHandler } from '../gestureHandler.js'; import { CorrectionLayout, CorrectionLayoutEntry } from '../../../correctionLayout.js'; diff --git a/web/src/engine/osk/src/input/gestures/gestureHandler.ts b/web/src/engine/osk/src/input/gestures/gestureHandler.ts index 4c45c39e77..3c585de646 100644 --- a/web/src/engine/osk/src/input/gestures/gestureHandler.ts +++ b/web/src/engine/osk/src/input/gestures/gestureHandler.ts @@ -1,4 +1,4 @@ -import { ActiveKeyBase, KeyDistribution } from "@keymanapp/keyboard-processor"; +import { ActiveKeyBase, KeyDistribution } from "keyman/engine/keyboard"; export interface GestureHandler { /** diff --git a/web/src/engine/osk/src/input/gestures/heldRepeater.ts b/web/src/engine/osk/src/input/gestures/heldRepeater.ts index 0f74677dda..025d898912 100644 --- a/web/src/engine/osk/src/input/gestures/heldRepeater.ts +++ b/web/src/engine/osk/src/input/gestures/heldRepeater.ts @@ -1,5 +1,5 @@ import { GestureSequence } from "@keymanapp/gesture-recognizer"; -import { KeyDistribution } from "@keymanapp/keyboard-processor"; +import { KeyDistribution } from "keyman/engine/keyboard"; import { KeyElement } from "../../keyElement.js"; import { GestureHandler } from './gestureHandler.js'; diff --git a/web/src/engine/osk/src/input/gestures/specsForLayout.ts b/web/src/engine/osk/src/input/gestures/specsForLayout.ts index 943d8e91b9..5748960997 100644 --- a/web/src/engine/osk/src/input/gestures/specsForLayout.ts +++ b/web/src/engine/osk/src/input/gestures/specsForLayout.ts @@ -12,7 +12,7 @@ import ButtonClasses = TouchLayout.TouchLayoutKeySp; import { ActiveLayout, deepCopy -} from '@keymanapp/keyboard-processor'; +} from 'keyman/engine/keyboard'; import { type KeyElement } from '../../keyElement.js'; diff --git a/web/src/engine/osk/src/keyElement.ts b/web/src/engine/osk/src/keyElement.ts index 01ae3a0c99..c913bdfbff 100644 --- a/web/src/engine/osk/src/keyElement.ts +++ b/web/src/engine/osk/src/keyElement.ts @@ -1,4 +1,4 @@ -import { ActiveSubKey } from '@keymanapp/keyboard-processor'; +import { ActiveSubKey } from 'keyman/engine/keyboard'; import OSKKey from "./keyboard-layout/oskKey.js"; export class KeyData { diff --git a/web/src/engine/osk/src/keyboard-layout/gesturePreviewHost.ts b/web/src/engine/osk/src/keyboard-layout/gesturePreviewHost.ts index 321de328b8..32a30c3f5d 100644 --- a/web/src/engine/osk/src/keyboard-layout/gesturePreviewHost.ts +++ b/web/src/engine/osk/src/keyboard-layout/gesturePreviewHost.ts @@ -1,4 +1,4 @@ -import { ActiveKeyBase } from "@keymanapp/keyboard-processor"; +import { ActiveKeyBase } from "keyman/engine/keyboard"; import { EventEmitter } from "eventemitter3"; import { KeyElement } from "../keyElement.js"; diff --git a/web/src/engine/osk/src/keyboard-layout/oskBaseKey.ts b/web/src/engine/osk/src/keyboard-layout/oskBaseKey.ts index e48253df60..3d70ed4010 100644 --- a/web/src/engine/osk/src/keyboard-layout/oskBaseKey.ts +++ b/web/src/engine/osk/src/keyboard-layout/oskBaseKey.ts @@ -1,4 +1,4 @@ -import { ActiveKey, Codes } from '@keymanapp/keyboard-processor'; +import { ActiveKey, Codes } from 'keyman/engine/keyboard'; import OSKKey, { KeyLayoutParams, renameSpecialKey } from './oskKey.js'; import { KeyData, KeyElement, link } from '../keyElement.js'; diff --git a/web/src/engine/osk/src/keyboard-layout/oskKey.ts b/web/src/engine/osk/src/keyboard-layout/oskKey.ts index 6404658ef6..2b9381afe3 100644 --- a/web/src/engine/osk/src/keyboard-layout/oskKey.ts +++ b/web/src/engine/osk/src/keyboard-layout/oskKey.ts @@ -1,4 +1,4 @@ -import { ActiveKey, ActiveSubKey, ButtonClass, ButtonClasses, DeviceSpec } from '@keymanapp/keyboard-processor'; +import { ActiveKey, ActiveSubKey, ButtonClass, ButtonClasses, DeviceSpec } from 'keyman/engine/keyboard'; // At present, we don't use @keymanapp/keyman. Just `keyman`. (Refer to /web/package.json.) import specialChars from '../specialCharacters.js'; diff --git a/web/src/engine/osk/src/keyboard-layout/oskLayer.ts b/web/src/engine/osk/src/keyboard-layout/oskLayer.ts index 61c43f22cf..a08d2921a5 100644 --- a/web/src/engine/osk/src/keyboard-layout/oskLayer.ts +++ b/web/src/engine/osk/src/keyboard-layout/oskLayer.ts @@ -1,4 +1,4 @@ -import { ActiveLayer, ActiveLayout } from '@keymanapp/keyboard-processor'; +import { ActiveLayer, ActiveLayout } from 'keyman/engine/keyboard'; import OSKRow from './oskRow.js'; import OSKBaseKey from './oskBaseKey.js'; diff --git a/web/src/engine/osk/src/keyboard-layout/oskLayerGroup.ts b/web/src/engine/osk/src/keyboard-layout/oskLayerGroup.ts index 5f4a3f45a3..4bf4bc01b4 100644 --- a/web/src/engine/osk/src/keyboard-layout/oskLayerGroup.ts +++ b/web/src/engine/osk/src/keyboard-layout/oskLayerGroup.ts @@ -1,4 +1,4 @@ -import { type DeviceSpec, Keyboard, ActiveLayout, ButtonClasses } from '@keymanapp/keyboard-processor'; +import { type DeviceSpec, Keyboard, ActiveLayout, ButtonClasses } from 'keyman/engine/keyboard'; import { InputSample } from '@keymanapp/gesture-recognizer'; diff --git a/web/src/engine/osk/src/keyboard-layout/oskRow.ts b/web/src/engine/osk/src/keyboard-layout/oskRow.ts index 8012e8438a..91c6409cd7 100644 --- a/web/src/engine/osk/src/keyboard-layout/oskRow.ts +++ b/web/src/engine/osk/src/keyboard-layout/oskRow.ts @@ -1,4 +1,4 @@ -import { ActiveKey, ActiveLayer, ActiveRow } from '@keymanapp/keyboard-processor'; +import { ActiveKey, ActiveLayer, ActiveRow } from 'keyman/engine/keyboard'; import OSKBaseKey from './oskBaseKey.js'; import { ParsedLengthStyle } from '../lengthStyle.js'; diff --git a/web/src/engine/osk/src/views/anchoredOskView.ts b/web/src/engine/osk/src/views/anchoredOskView.ts index fe2670c0b9..25ab819e3c 100644 --- a/web/src/engine/osk/src/views/anchoredOskView.ts +++ b/web/src/engine/osk/src/views/anchoredOskView.ts @@ -1,4 +1,4 @@ -import { DeviceSpec } from '@keymanapp/keyboard-processor'; +import { DeviceSpec } from 'keyman/engine/keyboard'; import { landscapeView } from 'keyman/engine/dom-utils'; import OSKView, { OSKPos, OSKRect } from './oskView.js'; diff --git a/web/src/engine/osk/src/views/floatingOskView.ts b/web/src/engine/osk/src/views/floatingOskView.ts index c296bd374b..ba186fc99e 100644 --- a/web/src/engine/osk/src/views/floatingOskView.ts +++ b/web/src/engine/osk/src/views/floatingOskView.ts @@ -1,4 +1,4 @@ -import { DeviceSpec, ManagedPromise, Version } from '@keymanapp/keyboard-processor'; +import { DeviceSpec, ManagedPromise, Version } from 'keyman/engine/keyboard'; import { getAbsoluteX, getAbsoluteY, landscapeView } from 'keyman/engine/dom-utils'; import { EmitterListenerSpy } from 'keyman/engine/events'; diff --git a/web/src/engine/osk/src/views/inlinedOskView.ts b/web/src/engine/osk/src/views/inlinedOskView.ts index 06f89c0a92..d4dc48fd66 100644 --- a/web/src/engine/osk/src/views/inlinedOskView.ts +++ b/web/src/engine/osk/src/views/inlinedOskView.ts @@ -1,4 +1,4 @@ -import { DeviceSpec } from '@keymanapp/keyboard-processor'; +import { DeviceSpec } from 'keyman/engine/keyboard'; import OSKView, { OSKPos, OSKRect } from './oskView.js'; import VisualKeyboard from '../visualKeyboard.js'; diff --git a/web/src/engine/osk/src/views/oskView.ts b/web/src/engine/osk/src/views/oskView.ts index afdc99f882..c9dc3755d7 100644 --- a/web/src/engine/osk/src/views/oskView.ts +++ b/web/src/engine/osk/src/views/oskView.ts @@ -19,7 +19,7 @@ import { type MinimalCodesInterface, type MutableSystemStore, type SystemStoreMutationHandler -} from '@keymanapp/keyboard-processor'; +} from 'keyman/engine/keyboard'; import { createUnselectableElement, getAbsoluteX, getAbsoluteY, StylesheetManager } from 'keyman/engine/dom-utils'; import { EventListener, KeyEventHandler, KeyEventSourceInterface, LegacyEventEmitter } from 'keyman/engine/events'; diff --git a/web/src/engine/osk/src/visualKeyboard.ts b/web/src/engine/osk/src/visualKeyboard.ts index fac43d5125..796e5566cf 100644 --- a/web/src/engine/osk/src/visualKeyboard.ts +++ b/web/src/engine/osk/src/visualKeyboard.ts @@ -15,7 +15,7 @@ import { timedPromise, ActiveKeyBase, isEmptyTransform -} from '@keymanapp/keyboard-processor'; +} from 'keyman/engine/keyboard'; import { buildCorrectiveLayout } from './correctionLayout.js'; import { distributionFromDistanceMaps, keyTouchDistances } from './corrections.js'; diff --git a/web/src/engine/package-cache/src/cloud/queryEngine.ts b/web/src/engine/package-cache/src/cloud/queryEngine.ts index eb989d2f00..5f38c32aea 100644 --- a/web/src/engine/package-cache/src/cloud/queryEngine.ts +++ b/web/src/engine/package-cache/src/cloud/queryEngine.ts @@ -3,7 +3,7 @@ import { EventEmitter } from 'eventemitter3'; import { PathConfiguration } from 'keyman/engine/interfaces'; import { default as KeyboardStub, ErrorStub, KeyboardAPISpec, mergeAndResolveStubPromises } from '../keyboardStub.js'; -import { LanguageAPIPropertySpec, ManagedPromise, Version } from '@keymanapp/keyboard-processor'; +import { LanguageAPIPropertySpec, ManagedPromise, Version } from 'keyman/engine/keyboard'; import CloudRequesterInterface from './requesterInterface.js'; // For when the API call straight-up times out. diff --git a/web/src/engine/package-cache/src/cloud/requesterInterface.ts b/web/src/engine/package-cache/src/cloud/requesterInterface.ts index c0f8e6baf1..6c612d9cb2 100644 --- a/web/src/engine/package-cache/src/cloud/requesterInterface.ts +++ b/web/src/engine/package-cache/src/cloud/requesterInterface.ts @@ -1,4 +1,4 @@ -import { ManagedPromise } from '@keymanapp/keyboard-processor'; +import { ManagedPromise } from 'keyman/engine/keyboard'; export default interface CloudRequesterInterface { request(query: string): { diff --git a/web/src/engine/package-cache/src/domCloudRequester.ts b/web/src/engine/package-cache/src/domCloudRequester.ts index ee80b0f063..fe671d101f 100644 --- a/web/src/engine/package-cache/src/domCloudRequester.ts +++ b/web/src/engine/package-cache/src/domCloudRequester.ts @@ -1,4 +1,4 @@ -import { ManagedPromise } from '@keymanapp/keyboard-processor'; +import { ManagedPromise } from 'keyman/engine/keyboard'; import CloudRequesterInterface from './cloud/requesterInterface.js'; import { CLOUD_MALFORMED_OBJECT_ERR, CLOUD_TIMEOUT_ERR, CLOUD_STUB_REGISTRATION_ERR } from './cloud/queryEngine.js'; diff --git a/web/src/engine/package-cache/src/keyboardRequisitioner.ts b/web/src/engine/package-cache/src/keyboardRequisitioner.ts index 13cc7ecef8..fb2807de6f 100644 --- a/web/src/engine/package-cache/src/keyboardRequisitioner.ts +++ b/web/src/engine/package-cache/src/keyboardRequisitioner.ts @@ -3,7 +3,7 @@ import { KeyboardLoaderBase as KeyboardLoader, LanguageAPIPropertySpec, RawKeyboardMetadata -} from "@keymanapp/keyboard-processor"; +} from "keyman/engine/keyboard"; import { PathConfiguration } from "keyman/engine/interfaces"; // TODO: is cleanup needed here, to use local paths instead? diff --git a/web/src/engine/package-cache/src/keyboardStub.ts b/web/src/engine/package-cache/src/keyboardStub.ts index 474d4cc9ef..a2b1d87d6f 100644 --- a/web/src/engine/package-cache/src/keyboardStub.ts +++ b/web/src/engine/package-cache/src/keyboardStub.ts @@ -3,7 +3,7 @@ import { type KeyboardAPIPropertyMultilangSpec as APICompoundKeyboard, KeyboardProperties, type LanguageAPIPropertySpec, -} from '@keymanapp/keyboard-processor'; +} from 'keyman/engine/keyboard'; import { toPrefixedKeyboardId as prefixed } from './stubAndKeyboardCache.js'; diff --git a/web/src/engine/package-cache/src/nodeCloudRequester.ts b/web/src/engine/package-cache/src/nodeCloudRequester.ts index bd9ff85159..e8461ff20d 100644 --- a/web/src/engine/package-cache/src/nodeCloudRequester.ts +++ b/web/src/engine/package-cache/src/nodeCloudRequester.ts @@ -1,4 +1,4 @@ -import { ManagedPromise } from '@keymanapp/keyboard-processor'; +import { ManagedPromise } from 'keyman/engine/keyboard'; import CloudRequesterInterface from './cloud/requesterInterface.js'; import { CLOUD_TIMEOUT_ERR, diff --git a/web/src/engine/package-cache/src/stubAndKeyboardCache.ts b/web/src/engine/package-cache/src/stubAndKeyboardCache.ts index 9fd70e7472..67d62446be 100644 --- a/web/src/engine/package-cache/src/stubAndKeyboardCache.ts +++ b/web/src/engine/package-cache/src/stubAndKeyboardCache.ts @@ -1,4 +1,4 @@ -import { Keyboard, KeyboardLoaderBase as KeyboardLoader } from "@keymanapp/keyboard-processor"; +import { Keyboard, KeyboardLoaderBase as KeyboardLoader } from "keyman/engine/keyboard"; import { EventEmitter } from "eventemitter3"; import KeyboardStub from "./keyboardStub.js"; diff --git a/web/src/test/auto/dom/cases/browser/contextManager.spec.ts b/web/src/test/auto/dom/cases/browser/contextManager.spec.ts index f31cc45318..291c299b2b 100644 --- a/web/src/test/auto/dom/cases/browser/contextManager.spec.ts +++ b/web/src/test/auto/dom/cases/browser/contextManager.spec.ts @@ -5,8 +5,8 @@ import { import { LegacyEventEmitter } from 'keyman/engine/events'; import { StubAndKeyboardCache, toPrefixedKeyboardId as prefixed } from 'keyman/engine/package-cache'; -import { KeyboardHarness, MinimalKeymanGlobal } from '@keymanapp/keyboard-processor'; -import { DOMKeyboardLoader } from '@keymanapp/keyboard-processor/dom-keyboard-loader'; +import { KeyboardHarness, MinimalKeymanGlobal } from 'keyman/engine/keyboard'; +import { DOMKeyboardLoader } from 'keyman/engine/keyboard/dom-keyboard-loader'; import { loadKeyboardsFromStubs } from '../../kbdLoader.js'; import { DeviceSpec, ManagedPromise, timedPromise } from '@keymanapp/web-utils'; diff --git a/web/src/test/auto/dom/cases/element-wrappers/element_interfaces.spec.ts b/web/src/test/auto/dom/cases/element-wrappers/element_interfaces.spec.ts index cee86cc35e..813ce78911 100644 --- a/web/src/test/auto/dom/cases/element-wrappers/element_interfaces.spec.ts +++ b/web/src/test/auto/dom/cases/element-wrappers/element_interfaces.spec.ts @@ -1,6 +1,6 @@ import { assert } from 'chai'; -import { extendString, Mock } from '@keymanapp/keyboard-processor'; +import { extendString, Mock } from 'keyman/engine/keyboard'; import * as wrappers from 'keyman/engine/element-wrappers'; import { DynamicElements } from '../../test_utils.js'; @@ -1385,7 +1385,7 @@ describe('Element Input/Output Interfacing', function () { // Unique to the Mock type - element interface cloning tests. Is element state properly copied? // As those require a very different setup, they're in the target_mocks.js test case file instead. - // Basic text-retrieval unit tests are now done headlessly in @keymanapp/keyboard-processor. + // Basic text-retrieval unit tests are now done headlessly in keyman/engine/keyboard. describe('Text Mutation', function () { describe('deleteCharsBeforeCaret', function () { diff --git a/web/src/test/auto/dom/cases/element-wrappers/target_mocks.spec.ts b/web/src/test/auto/dom/cases/element-wrappers/target_mocks.spec.ts index e850efaa55..85116eaa8a 100644 --- a/web/src/test/auto/dom/cases/element-wrappers/target_mocks.spec.ts +++ b/web/src/test/auto/dom/cases/element-wrappers/target_mocks.spec.ts @@ -1,6 +1,6 @@ import { assert } from 'chai'; -import { extendString, Mock } from '@keymanapp/keyboard-processor'; +import { extendString, Mock } from 'keyman/engine/keyboard'; import { Input } from 'keyman/engine/element-wrappers'; import { DEFAULT_BROWSER_TIMEOUT } from '@keymanapp/common-test-resources/test-timeouts.mjs'; diff --git a/web/src/test/auto/dom/cases/keyboard-processor/domKeyboardLoader.spec.ts b/web/src/test/auto/dom/cases/keyboard/domKeyboardLoader.spec.ts similarity index 95% rename from web/src/test/auto/dom/cases/keyboard-processor/domKeyboardLoader.spec.ts rename to web/src/test/auto/dom/cases/keyboard/domKeyboardLoader.spec.ts index 63414662fa..bcf4afcf65 100644 --- a/web/src/test/auto/dom/cases/keyboard-processor/domKeyboardLoader.spec.ts +++ b/web/src/test/auto/dom/cases/keyboard/domKeyboardLoader.spec.ts @@ -1,7 +1,7 @@ import { assert } from 'chai'; -import { DOMKeyboardLoader } from '@keymanapp/keyboard-processor/dom-keyboard-loader'; -import { extendString, KeyboardHarness, Keyboard, MinimalKeymanGlobal, Mock, DeviceSpec, KeyboardKeymanGlobal } from '@keymanapp/keyboard-processor'; +import { DOMKeyboardLoader } from 'keyman/engine/keyboard/dom-keyboard-loader'; +import { extendString, KeyboardHarness, Keyboard, MinimalKeymanGlobal, Mock, DeviceSpec, KeyboardKeymanGlobal } from 'keyman/engine/keyboard'; import { KeyboardInterface } from 'keyman/engine/js-processor'; declare let window: typeof globalThis; diff --git a/web/src/test/auto/dom/cases/packages/keyboardRequisitioner.spec.ts b/web/src/test/auto/dom/cases/packages/keyboardRequisitioner.spec.ts index ab585bc9e0..7ad8356a32 100644 --- a/web/src/test/auto/dom/cases/packages/keyboardRequisitioner.spec.ts +++ b/web/src/test/auto/dom/cases/packages/keyboardRequisitioner.spec.ts @@ -1,8 +1,8 @@ import { assert } from 'chai'; import sinon from 'sinon'; -import { KeyboardHarness, MinimalKeymanGlobal } from '@keymanapp/keyboard-processor'; -import { DOMKeyboardLoader } from '@keymanapp/keyboard-processor/dom-keyboard-loader'; +import { KeyboardHarness, MinimalKeymanGlobal } from 'keyman/engine/keyboard'; +import { DOMKeyboardLoader } from 'keyman/engine/keyboard/dom-keyboard-loader'; import { PathConfiguration } from 'keyman/engine/interfaces'; import { CloudQueryEngine, KeyboardRequisitioner, type KeyboardStub } from 'keyman/engine/package-cache'; import DOMCloudRequester from 'keyman/engine/package-cache/dom-requester'; diff --git a/web/src/test/auto/dom/kbdLoader.ts b/web/src/test/auto/dom/kbdLoader.ts index 2254011857..8b5c081c75 100644 --- a/web/src/test/auto/dom/kbdLoader.ts +++ b/web/src/test/auto/dom/kbdLoader.ts @@ -1,12 +1,12 @@ import { DOMKeyboardLoader -} from '@keymanapp/keyboard-processor/dom-keyboard-loader'; +} from 'keyman/engine/keyboard/dom-keyboard-loader'; import { Keyboard, KeyboardProperties, MinimalKeymanGlobal -} from '@keymanapp/keyboard-processor'; +} from 'keyman/engine/keyboard'; import { KeyboardInterface } from 'keyman/engine/js-processor'; import { KeyboardStub } from 'keyman/engine/package-cache'; diff --git a/web/src/test/auto/headless/app/browser/hardware-event-processing.tests.ts b/web/src/test/auto/headless/app/browser/hardware-event-processing.tests.ts index 447b2b1806..d00425362d 100644 --- a/web/src/test/auto/headless/app/browser/hardware-event-processing.tests.ts +++ b/web/src/test/auto/headless/app/browser/hardware-event-processing.tests.ts @@ -4,14 +4,14 @@ import { preprocessKeyboardEvent } from 'keyman/app/browser'; import { processForMnemonicsAndLegacy } from 'keyman/engine/main'; import { PhysicalInputEventSpec } from '@keymanapp/recorder-core'; import { DeviceSpec } from '@keymanapp/web-utils'; -import { Codes, Keyboard, KeyEvent } from '@keymanapp/keyboard-processor'; +import { Codes, Keyboard, KeyEvent } from 'keyman/engine/keyboard'; const ModifierCodes = Codes.modifierCodes; const KeyCodes = Codes.keyCodes; const DUMMY_DEVICE = new DeviceSpec('chrome', 'desktop', 'windows', false); -// Compare and contrast the unit tests here with those for keyboard-processor unit testing +// Compare and contrast the unit tests here with those for keyboard unit testing // in the non-positional-rules set; the output objects here should have the same format // as the inputs for rules as used there. diff --git a/web/src/test/auto/headless/engine/interfaces/prediction/predictionContext.spec.js b/web/src/test/auto/headless/engine/interfaces/prediction/predictionContext.spec.js index 97ce24d036..39ab4aea59 100644 --- a/web/src/test/auto/headless/engine/interfaces/prediction/predictionContext.spec.js +++ b/web/src/test/auto/headless/engine/interfaces/prediction/predictionContext.spec.js @@ -4,7 +4,7 @@ import sinon from 'sinon'; import { LanguageProcessor, TranscriptionCache } from 'keyman/engine/main'; import { PredictionContext } from 'keyman/engine/interfaces'; import { Worker as LMWorker } from "@keymanapp/lexical-model-layer/node"; -import { DeviceSpec, Mock } from '@keymanapp/keyboard-processor'; +import { DeviceSpec, Mock } from 'keyman/engine/keyboard'; import { KeyboardProcessor } from 'keyman/engine/js-processor'; function compileDummyModel(suggestionSets) { diff --git a/web/src/test/auto/headless/engine/main/headless/inputProcessor.spec.js b/web/src/test/auto/headless/engine/main/headless/inputProcessor.spec.js index d1b728e625..f3f6622f9a 100644 --- a/web/src/test/auto/headless/engine/main/headless/inputProcessor.spec.js +++ b/web/src/test/auto/headless/engine/main/headless/inputProcessor.spec.js @@ -5,8 +5,8 @@ import { createRequire } from 'module'; const require = createRequire(import.meta.url); import { InputProcessor } from 'keyman/engine/main'; -import { KeyboardInterface, MinimalKeymanGlobal, Mock } from '@keymanapp/keyboard-processor'; -import { NodeKeyboardLoader } from '@keymanapp/keyboard-processor/node-keyboard-loader'; +import { KeyboardInterface, MinimalKeymanGlobal, Mock } from 'keyman/engine/keyboard'; +import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader'; import { KeyboardTest } from '@keymanapp/recorder-core'; import { Worker } from '@keymanapp/lexical-model-layer/node'; @@ -48,8 +48,8 @@ describe('InputProcessor', function() { assert.isUndefined(core.activeKeyboard); // No keyboard should be loaded yet. assert.isUndefined(core.activeModel); // Same for the model. - // These checks are lifted from the keyboard-processor init checks found in - // common/web/keyboard-processor/tests/cases/basic-init.js. + // These checks are lifted from the keyboard init checks found in + // common/web/keyboard/tests/cases/basic-init.js. assert.equal('us', core.keyboardProcessor.baseLayout, 'KeyboardProcessor has unexpected base layout') assert.isNotNull(global.KeymanWeb, 'KeymanWeb global was not automatically installed'); assert.equal('default', core.keyboardProcessor.layerId, 'Default layer is not set to "default"'); diff --git a/web/src/test/auto/headless/engine/main/headless/languageProcessor.spec.js b/web/src/test/auto/headless/engine/main/headless/languageProcessor.spec.js index a0eec4c531..6f2f321edf 100644 --- a/web/src/test/auto/headless/engine/main/headless/languageProcessor.spec.js +++ b/web/src/test/auto/headless/engine/main/headless/languageProcessor.spec.js @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { LanguageProcessor, TranscriptionCache } from 'keyman/engine/main'; import { SourcemappedWorker as LMWorker } from "@keymanapp/lexical-model-layer/node"; -import { Mock } from '@keymanapp/keyboard-processor'; +import { Mock } from 'keyman/engine/keyboard'; /* * Unit tests for the Dummy prediction model. @@ -43,8 +43,8 @@ describe('LanguageProcessor', function() { it('has expected default values after initialization', function () { let languageProcessor = new LanguageProcessor(worker, new TranscriptionCache()); - // These checks are lifted from the keyboard-processor init checks found in - // common/web/keyboard-processor/tests/cases/basic-init.js. + // These checks are lifted from the keyboard init checks found in + // engine/keyboard/tests/cases/basic-init.js. assert.isDefined(languageProcessor.lmEngine); assert.isUndefined(languageProcessor.activeModel); assert.isFalse(languageProcessor.isActive); diff --git a/web/src/test/auto/headless/engine/osk/input/gestures/browser/subkeyPopup.tests.ts b/web/src/test/auto/headless/engine/osk/input/gestures/browser/subkeyPopup.tests.ts index b70c17d7dc..72679897f3 100644 --- a/web/src/test/auto/headless/engine/osk/input/gestures/browser/subkeyPopup.tests.ts +++ b/web/src/test/auto/headless/engine/osk/input/gestures/browser/subkeyPopup.tests.ts @@ -4,7 +4,7 @@ import { JSDOM } from 'jsdom'; import sinon from 'sinon'; import { GesturePath, GestureSequence, GestureSource, GestureSourceSubview } from '@keymanapp/gesture-recognizer'; -import { ActiveSubKey, DeviceSpec } from '@keymanapp/keyboard-processor'; +import { ActiveSubKey, DeviceSpec } from 'keyman/engine/keyboard'; import { DEFAULT_GESTURE_PARAMS, KeyElement, VisualKeyboard } from 'keyman/engine/osk'; import { OSKBaseKey, OSKRow, SubkeyPopup, link } from 'keyman/engine/osk/internals'; diff --git a/web/src/test/auto/headless/engine/package-cache/keyboardRequisitioner.js b/web/src/test/auto/headless/engine/package-cache/keyboardRequisitioner.js index b2d64c0553..2ca0578790 100644 --- a/web/src/test/auto/headless/engine/package-cache/keyboardRequisitioner.js +++ b/web/src/test/auto/headless/engine/package-cache/keyboardRequisitioner.js @@ -2,8 +2,8 @@ import { assert } from 'chai'; import sinon from 'sinon'; import fs from 'fs'; -import { KeyboardHarness, ManagedPromise, MinimalKeymanGlobal } from '@keymanapp/keyboard-processor'; -import { NodeKeyboardLoader } from '@keymanapp/keyboard-processor/node-keyboard-loader'; +import { KeyboardHarness, ManagedPromise, MinimalKeymanGlobal } from 'keyman/engine/keyboard'; +import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader'; import { KeyboardRequisitioner, toPrefixedKeyboardId as prefixed diff --git a/web/src/test/auto/headless/engine/package-cache/stubAndKeyboardCache.js b/web/src/test/auto/headless/engine/package-cache/stubAndKeyboardCache.js index 03f6fbf5c5..f49bb1238f 100644 --- a/web/src/test/auto/headless/engine/package-cache/stubAndKeyboardCache.js +++ b/web/src/test/auto/headless/engine/package-cache/stubAndKeyboardCache.js @@ -4,8 +4,8 @@ import fs from 'fs'; import { KeyboardStub, StubAndKeyboardCache } from 'keyman/engine/package-cache'; -import { NodeKeyboardLoader } from '@keymanapp/keyboard-processor/node-keyboard-loader'; -import { KeyboardHarness, MinimalKeymanGlobal } from '@keymanapp/keyboard-processor'; +import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader'; +import { KeyboardHarness, MinimalKeymanGlobal } from 'keyman/engine/keyboard'; import path from 'path'; diff --git a/web/src/test/manual/web/chirality/chirality.js b/web/src/test/manual/web/chirality/chirality.js index eaf349463c..68740ffc30 100644 --- a/web/src/test/manual/web/chirality/chirality.js +++ b/web/src/test/manual/web/chirality/chirality.js @@ -10,10 +10,10 @@ */ function Keyboard_chirality() { - // Refer to $KEYMAN_ROOT/common/web/keyboard-processor/src/text/codes.ts, same method name. + // Refer to $KEYMAN_ROOT/web/src/engine/keyboard/src/text/codes.ts, same method name. // May be moved within common/web/types at some point in the future. var getModifierState = function(layerId) { - // Refer to C:\keymanapp\keyman\common\web\keyboard-processor\src\keyboards\keyboardHarness.ts, + // Refer to C:\keymanapp\keyman\web\src\engine\keyboard\src\keyboards\keyboardHarness.ts, // `MinimalKeyboardHarness`. let osk = keyman.osk; // Codes endpoint, as part of the standard keyboard harness. @@ -86,7 +86,7 @@ function Keyboard_chirality() { this.g0 = function (t, e) { var k = KeymanWeb, r = 0, m = 0; - // Refer to C:\keymanapp\keyman\common\web\keyboard-processor\src\keyboards\keyboardHarness.ts, + // Refer to C:\keymanapp\keyman\web\src\engine\keyboard\src\keyboards\keyboardHarness.ts, // `MinimalKeyboardHarness`. var Constants = keyman.osk; // Holds anchor points for relevant Codes properties. diff --git a/web/src/test/manual/web/osk/kbdLoader.mjs b/web/src/test/manual/web/osk/kbdLoader.mjs index a9db786c33..edf2d3a648 100644 --- a/web/src/test/manual/web/osk/kbdLoader.mjs +++ b/web/src/test/manual/web/osk/kbdLoader.mjs @@ -1,16 +1,16 @@ import { Keyboard, KeyboardProperties, Codes } from '../../../../../build/engine/osk/lib/index.mjs'; // // The following block would be sufficient to replace the `loadKeyboardFromPath` func below... -// // were it not for common/web/keyboard-processor being outside of the standard `localhost` config +// // were it not for web/src/engine/keyboard/ being outside of the standard `localhost` config // // used for manual Web testing. // import { // DOMKeyboardLoader -// } from '../../../../../../common/web/keyboard-processor/build/lib/dom-keyboard-loader.mjs'; +// } from '../../../keyboard/build/lib/dom-keyboard-loader.mjs'; // import { // KeyboardInterface, // MinimalKeymanGlobal -// } from '../../../../../../common/web/keyboard-processor/build/lib/index.mjs'; +// } from '../../../keyboard/build/lib/index.mjs'; // // This script may or may not be temporary; the KMW "KeyboardManager" class may be spun off in a manner // // that could replace this. diff --git a/web/src/tools/build.sh b/web/src/tools/build.sh index 24d455bc8f..b7670418ab 100755 --- a/web/src/tools/build.sh +++ b/web/src/tools/build.sh @@ -14,7 +14,7 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" builder_describe "Builds the Keyman Engine for Web's development & unit-testing tools" \ "@/common/web/keyman-version" \ - "@/common/web/keyboard-processor" \ + "@/web/src/engine/keyboard" \ "configure" \ "clean" \ "build" \ diff --git a/web/src/tools/testing/recorder-core/package.json b/web/src/tools/testing/recorder-core/package.json index 4812d8a778..426595e567 100644 --- a/web/src/tools/testing/recorder-core/package.json +++ b/web/src/tools/testing/recorder-core/package.json @@ -19,7 +19,6 @@ }, "homepage": "https://github.com/keymanapp/keyman#readme", "dependencies": { - "@keymanapp/keyboard-processor": "*", "@keymanapp/models-types": "*", "@keymanapp/keyman-version": "*", "@keymanapp/web-utils": "*" diff --git a/web/src/tools/testing/recorder-core/src/index.ts b/web/src/tools/testing/recorder-core/src/index.ts index 94c2c9dc4d..caa0262f6b 100644 --- a/web/src/tools/testing/recorder-core/src/index.ts +++ b/web/src/tools/testing/recorder-core/src/index.ts @@ -1,5 +1,5 @@ -import { type OutputTarget } from "@keymanapp/keyboard-processor"; -import { KeyDistribution, KeyEvent, Mock } from "@keymanapp/keyboard-processor"; +import { type OutputTarget } from "keyman/engine/keyboard"; +import { KeyDistribution, KeyEvent, Mock } from "keyman/engine/keyboard"; import Proctor from "./proctor.js"; diff --git a/web/src/tools/testing/recorder-core/src/nodeProctor.ts b/web/src/tools/testing/recorder-core/src/nodeProctor.ts index 852002d4b3..e9a08530c8 100644 --- a/web/src/tools/testing/recorder-core/src/nodeProctor.ts +++ b/web/src/tools/testing/recorder-core/src/nodeProctor.ts @@ -8,7 +8,7 @@ import { RecordedSyntheticKeystroke } from "./index.js"; -import { KeyEvent, KeyEventSpec, Mock, type OutputTarget, KeyboardHarness } from "@keymanapp/keyboard-processor"; +import { KeyEvent, KeyEventSpec, Mock, type OutputTarget, KeyboardHarness } from "keyman/engine/keyboard"; import { DeviceSpec } from "@keymanapp/web-utils"; import { KeyboardInterface, KeyboardProcessor } from 'keyman/engine/js-processor'; diff --git a/web/src/tools/testing/recorder-core/src/proctor.ts b/web/src/tools/testing/recorder-core/src/proctor.ts index 940fa4a76b..0242b911a1 100644 --- a/web/src/tools/testing/recorder-core/src/proctor.ts +++ b/web/src/tools/testing/recorder-core/src/proctor.ts @@ -1,5 +1,5 @@ import { type DeviceSpec } from "@keymanapp/web-utils"; -import { type OutputTarget } from "@keymanapp/keyboard-processor"; +import { type OutputTarget } from "keyman/engine/keyboard"; import type { KeyboardTest, TestSet, TestSequence } from "./index.js"; @@ -9,7 +9,7 @@ export type AssertCallback = (s1: any, s2: any, msg?: string) => void; * Facilitates running Recorder-generated tests on various platforms. * * Note that DOM-aware KeymanWeb will implement a Browser-based version, while - * keyboard-processor and input-processor will use a Node-based version instead. + * keyboard and input-processor will use a Node-based version instead. */ export default abstract class Proctor { device: DeviceSpec; diff --git a/web/src/tools/testing/recorder-core/tsconfig.json b/web/src/tools/testing/recorder-core/tsconfig.json index 38af26e1a4..920536eeee 100644 --- a/web/src/tools/testing/recorder-core/tsconfig.json +++ b/web/src/tools/testing/recorder-core/tsconfig.json @@ -16,8 +16,8 @@ "references": [ { "path": "../../../../../common/web/keyman-version" }, { "path": "../../../../../common/web/utils/" }, - { "path": "../../../../../common/web/keyboard-processor/" }, { "path": "../../../../../common/web/lm-message-types" }, - { "path": "../../../engine/js-processor" } + { "path": "../../../engine/js-processor" }, + { "path": "../../../engine/keyboard" }, ], } diff --git a/web/src/tools/testing/recorder/browserProctor.ts b/web/src/tools/testing/recorder/browserProctor.ts index 40e7247423..73e5a80ea7 100644 --- a/web/src/tools/testing/recorder/browserProctor.ts +++ b/web/src/tools/testing/recorder/browserProctor.ts @@ -4,7 +4,7 @@ import { type DeviceSpec } from "@keymanapp/web-utils"; -import { type OutputTarget } from "@keymanapp/keyboard-processor"; +import { type OutputTarget } from "keyman/engine/keyboard"; import { type KeymanEngine } from 'keyman/app/browser'; diff --git a/web/src/tools/testing/recorder/build.sh b/web/src/tools/testing/recorder/build.sh index 28cc43a767..91f27d09e5 100755 --- a/web/src/tools/testing/recorder/build.sh +++ b/web/src/tools/testing/recorder/build.sh @@ -16,7 +16,7 @@ SUBPROJECT_NAME=tools/testing/recorder builder_describe "Builds the Keyman Engine for Web's test-sequence recording tool" \ "@/common/web/keyman-version" \ - "@/common/web/keyboard-processor" \ + "@/web/src/engine/keyboard" \ "@../recorder-core" \ "clean" \ "configure" \ diff --git a/web/src/tools/testing/recorder/scribe.ts b/web/src/tools/testing/recorder/scribe.ts index 371afadeef..c266f1a5cc 100644 --- a/web/src/tools/testing/recorder/scribe.ts +++ b/web/src/tools/testing/recorder/scribe.ts @@ -1,7 +1,7 @@ import { EventEmitter } from "eventemitter3"; -import type { KeyEvent } from "@keymanapp/keyboard-processor"; +import type { KeyEvent } from "keyman/engine/keyboard"; import { Constraint, diff --git a/web/src/tools/testing/recorder/tsconfig.json b/web/src/tools/testing/recorder/tsconfig.json index 63cb543efa..f5974b5738 100644 --- a/web/src/tools/testing/recorder/tsconfig.json +++ b/web/src/tools/testing/recorder/tsconfig.json @@ -12,9 +12,9 @@ "references": [ { "path": "../../../../../common/web/keyman-version" }, { "path": "../../../../../common/web/utils" }, - { "path": "../../../../../common/web/keyboard-processor" }, { "path": "../../../../../common/web/lm-message-types" }, { "path": "../../../../../web/src/app/browser" }, { "path": "../recorder-core" }, + { "path": "../../../engine/keyboard" }, ] } From 58c1e507b42d23e9f481f5b8697d1a818e3c8c29 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 13 Aug 2024 17:03:41 +0200 Subject: [PATCH 309/327] chore(linux): remove mcompile-specific km_types.h --- linux/mcompile/keymap/keymap.cpp | 2 +- linux/mcompile/keymap/keymap.h | 40 +++++++- linux/mcompile/keymap/km_types.h | 111 ---------------------- linux/mcompile/keymap/mc_import_rules.cpp | 46 ++++----- linux/mcompile/keymap/mc_kmxfile.cpp | 6 +- linux/mcompile/keymap/mcompile.cpp | 28 +++--- linux/mcompile/keymap/mcompile.h | 2 +- 7 files changed, 79 insertions(+), 156 deletions(-) delete mode 100644 linux/mcompile/keymap/km_types.h diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 753c817a38..25d7721482 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -920,7 +920,7 @@ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, gui * 0xFFFE in case a deadkey is out of range * the keyval obtained from Keycode and shiftstate and caps; */ -KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, guint keycode, UINT shiftState, PKMX_WCHAR deadkey) { +KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, guint keycode, KMX_DWORD shiftState, PKMX_WCHAR deadkey) { GdkKeymapKey* maps; guint* keyvals; gint count; diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index bed159898d..c8e79a8c68 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -29,6 +29,40 @@ enum ShiftState { ShftXxxx = Shft | Xxxx, // 9 }; +#define VK_SPACE 0x20 +#define VK_COLON 0xBA +#define VK_EQUAL 0xBB +#define VK_COMMA 0xBC +#define VK_HYPHEN 0xBD +#define VK_PERIOD 0xBE +#define VK_SLASH 0xBF +#define VK_ACCENT 0xC0 +#define VK_LBRKT 0xDB +#define VK_BKSLASH 0xDC +#define VK_RBRKT 0xDD +#define VK_QUOTE 0xDE +#define VK_xDF 0xDF +#define VK_OEM_102 0xE2 // "<>" or "\|" on RT 102-key kbd. + +#define VK_DIVIDE 0x6F +#define VK_CANCEL 3 +#define VK_DECIMAL 0x2E + +#define VK_OEM_CLEAR 0xFE +#define VK_LSHIFT 0xA0 +#define VK_RSHIFT 0xA1 +#define VK_LCONTROL 0xA2 +#define VK_RCONTROL 0xA3 +#define VK_LMENU 0xA4 +#define VK_RMENU 0xA5 + +#define VK_SHIFT 0x10 +#define VK_CONTROL 0x11 +#define VK_MENU 0x12 +#define VK_PAUSE 0x13 +#define VK_CAPITAL 0x14 + + // Map of all US English virtual key codes that we can translate const KMX_DWORD KMX_VKMap[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', @@ -108,7 +142,7 @@ int append_underlying_ToVector(vec_dword_3D& all_vector, GdkKeymap* keymap); /** @brief create a pointer to pointer of the current keymap for later use */ bool InitializeGDK(GdkKeymap** keymap, int argc, gchar* argv[]); -const UINT USVirtualKeyToScanCode[256] = { +const KMX_DWORD USVirtualKeyToScanCode[256] = { 0x00, // L"K_?00", // &H0 0x00, // L"K_LBUTTON", // &H1 0x00, // L"K_RBUTTON", // &H2 @@ -376,7 +410,7 @@ const UINT USVirtualKeyToScanCode[256] = { 0x00 // L"K_?FF" // &HFF }; -const UINT ScanCodeToUSVirtualKey[128] = { +const KMX_DWORD ScanCodeToUSVirtualKey[128] = { 0x01, // 0x00 => K_LBUTTON 0x1b, // 0x01 => K_ESC 0x31, // 0x02 => K_1 @@ -520,7 +554,7 @@ KMX_DWORD KMX_get_KeyVal_From_KeyCode(GdkKeymap* keymap, guint keycode, ShiftSta KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, guint keycode, int shiftState); /** @brief return the keyvalue for a given Keycode and shiftstate of the currently used (underlying) keyboard layout. */ -KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, guint keycode, UINT shiftState, PKMX_WCHAR deadkey); +KMX_DWORD KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(GdkKeymap* keymap, guint keycode, KMX_DWORD shiftState, PKMX_WCHAR deadkey); /** @brief return the keyvalue of a key of the the currently used (underlying) keyboard for a given keyvalue of the US keyboard */ KMX_DWORD KMX_get_KeyValUnderlying_From_KeyValUS(vec_dword_3D& all_vector, KMX_DWORD kv_us); diff --git a/linux/mcompile/keymap/km_types.h b/linux/mcompile/keymap/km_types.h deleted file mode 100644 index 5381ff1e6a..0000000000 --- a/linux/mcompile/keymap/km_types.h +++ /dev/null @@ -1,111 +0,0 @@ -#pragma once -#ifndef KM_TYPES -#define KM_TYPES -#include -/* -#if defined(_WIN32) || defined(_WIN64) -#define snprintf _snprintf -#define vsnprintf _vsnprintf -#define strcasecmp _stricmp -#define strncasecmp _strnicmp -#endif -*/ - -#if defined(__LP64__) || defined(_LP64) -/* 64-bit, g++ */ -#define KMX_64BIT -#endif - -#if defined(_WIN64) && !defined(USE_64) -/* 64-bit, Windows */ -#define KMX_64BIT -#endif - -typedef uint32_t KMX_DWORD; -typedef int32_t KMX_BOOL; -typedef uint8_t KMX_BYTE; -typedef uint16_t KMX_WORD; - -#if defined(__cplusplus) -typedef char16_t km_kbp_cp; -typedef char32_t km_kbp_usv; -#else -typedef uint16_t km_kbp_cp; // code point -typedef uint32_t km_kbp_usv; // Unicode Scalar Value -#endif - -typedef unsigned int UINT; -typedef unsigned long DWORD; - -typedef unsigned char BYTE; -typedef char KMX_CHAR; - -typedef char16_t KMX_WCHAR; -typedef KMX_WCHAR* PKMX_WCHAR; - -typedef wchar_t WCHAR; -typedef WCHAR KMX_WCHART; -typedef wchar_t* PWSTR; -typedef WCHAR* PWCHAR; - -typedef uint8_t* LPKMX_BYTE; -typedef uint8_t* PKMX_BYTE; - -typedef KMX_BYTE* PKMX_BYTE; -typedef KMX_DWORD* PKMX_DWORD; -typedef int BOOL; - -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef TRUE -#define TRUE 1 -#endif - -// Macros and types to support char16_t vs wchar_t depending on project - -#ifdef USE_CHAR16_T -#define lpuch(x) u ## x -typedef km_kbp_cp KMX_UCHAR; -#else -#define lpuch(x) L ## x -typedef wchar_t KMX_UCHAR; -#endif - -typedef KMX_UCHAR* KMX_PUCHAR; - -#define VK_SPACE 0x20 -#define VK_COLON 0xBA -#define VK_EQUAL 0xBB -#define VK_COMMA 0xBC -#define VK_HYPHEN 0xBD -#define VK_PERIOD 0xBE -#define VK_SLASH 0xBF -#define VK_ACCENT 0xC0 -#define VK_LBRKT 0xDB -#define VK_BKSLASH 0xDC -#define VK_RBRKT 0xDD -#define VK_QUOTE 0xDE -#define VK_xDF 0xDF -#define VK_OEM_102 0xE2 // "<>" or "\|" on RT 102-key kbd. - -#define VK_DIVIDE 0x6F -#define VK_CANCEL 3 -#define VK_DECIMAL 0x2E - -#define VK_OEM_CLEAR 0xFE -#define VK_LSHIFT 0xA0 -#define VK_RSHIFT 0xA1 -#define VK_LCONTROL 0xA2 -#define VK_RCONTROL 0xA3 -#define VK_LMENU 0xA4 -#define VK_RMENU 0xA5 - -#define VK_SHIFT 0x10 -#define VK_CONTROL 0x11 -#define VK_MENU 0x12 -#define VK_PAUSE 0x13 -#define VK_CAPITAL 0x14 - -#endif /*KM_TYPES*/ diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 63f7ed3920..9c376dafd6 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -141,13 +141,13 @@ KMX_WCHAR KMX_DeadKeyMap(int index, std::vector* deadkeys, int deadkey */ class KMX_VirtualKey { private: - UINT m_vk; - UINT m_sc; + KMX_DWORD m_vk; + KMX_DWORD m_sc; bool m_rgfDeadKey[10][2]; std::u16string m_rgss[10][2]; public: - KMX_VirtualKey(UINT scanCode) { + KMX_VirtualKey(KMX_DWORD scanCode) { this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying(scanCode); this->m_sc = scanCode; memset(this->m_rgfDeadKey, 0, sizeof(this->m_rgfDeadKey)); @@ -156,24 +156,24 @@ public: /** * @brief return member variable virtual key */ - UINT VK() { + KMX_DWORD VK() { return this->m_vk; } /** * @brief return member variable scancode */ - UINT SC() { + KMX_DWORD SC() { return this->m_sc; } std::u16string KMX_GetShiftState(ShiftState shiftState, bool capsLock) { - return this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)]; + return this->m_rgss[(KMX_DWORD)shiftState][(capsLock ? 1 : 0)]; } void KMX_SetShiftState(ShiftState shiftState, std::u16string value, bool isDeadKey, bool capsLock) { - this->m_rgfDeadKey[(UINT)shiftState][(capsLock ? 1 : 0)] = isDeadKey; - this->m_rgss[(UINT)shiftState][(capsLock ? 1 : 0)] = value; + this->m_rgfDeadKey[(KMX_DWORD)shiftState][(capsLock ? 1 : 0)] = isDeadKey; + this->m_rgss[(KMX_DWORD)shiftState][(capsLock ? 1 : 0)] = value; } bool KMX_IsSGCAPS() { @@ -240,7 +240,7 @@ public: return (this->m_vk >= 0x20 && this->m_vk <= 0x5F) || (this->m_vk >= 0x88); } - UINT KMX_GetShiftStateValue(int capslock, int caps, ShiftState ss) { + KMX_DWORD KMX_GetShiftStateValue(int capslock, int caps, ShiftState ss) { return KMX_ShiftStateMap[(int)ss] | (capslock ? (caps ? CAPITALFLAG : NOTCAPITALFLAG) : 0); } @@ -282,7 +282,7 @@ public: return nkeys; } - bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector* deadkeys, int deadkeyBase, BOOL bDeadkeyConversion, vec_dword_3D& all_vector, GdkKeymap* keymap) { // I4552 + bool KMX_LayoutRow(int MaxShiftState, LPKMX_KEY key, std::vector* deadkeys, int deadkeyBase, bool bDeadkeyConversion, vec_dword_3D& all_vector, GdkKeymap* keymap) { // I4552 // Get the CAPSLOCK value /*int capslock = (this->KMX_IsCapsEqualToShift() ? 1 : 0) | @@ -372,7 +372,7 @@ public: class KMX_Loader { private: KMX_BYTE lpKeyStateNull[256]; - UINT m_XxxxVk; + KMX_DWORD m_XxxxVk; public: KMX_Loader() { @@ -380,11 +380,11 @@ public: memset(lpKeyStateNull, 0, sizeof(lpKeyStateNull)); } - UINT Get_XxxxVk() { + KMX_DWORD Get_XxxxVk() { return m_XxxxVk; } - void Set_XxxxVk(UINT value) { + void Set_XxxxVk(KMX_DWORD value) { m_XxxxVk = value; } @@ -440,7 +440,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** ke // flag that the VK is valid, and it can store the SC value. // Windows and Linux Keycodes start with 1; Mac keycodes start with 0 - for (UINT sc = 0x01; sc <= 0x7f; sc++) { + for (KMX_DWORD sc = 0x01; sc <= 0x7f; sc++) { /* HERE IS A BIG DIFFERENCE COMPARED TO MCOMPILE FOR WINDOWS: * mcompile on Windows fills rgkey.m_vk with the VK of the Underlying keyboard * mcompile for Linux fills rgkey.m_vk with the VK of the US keyboard @@ -460,7 +460,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** ke } // in this part we skip shiftstates 4, 5, 8, 9 - for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { + for (KMX_DWORD iKey = 0; iKey < rgKey.size(); iKey++) { if (rgKey[iKey] != NULL) { KMX_WCHAR sbBuffer[256]; // Scratchpad we use many places for (ShiftState ss = Base; ss <= loader.KMX_MaxShiftState(); ss = (ShiftState)((int)ss + 1)) { @@ -509,10 +509,10 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** ke // kp->dpGroupArray = gp; - for (UINT i = 0; i < kp->cxGroupArray; i++, gp++) { + for (KMX_DWORD i = 0; i < kp->cxGroupArray; i++, gp++) { LPKMX_KEY kkp = gp->dpKeyArray; - for (UINT j = 0; j < gp->cxKeyArray; j++, kkp++) { + for (KMX_DWORD j = 0; j < gp->cxKeyArray; j++, kkp++) { nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpContext)); nDeadkey = std::max(nDeadkey, KMX_GetMaxDeadkeyIndex(kkp->dpOutput)); } @@ -523,8 +523,8 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** ke // calculate the required size of `gp->dpKeyArray` - UINT nkeys = 0; - for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { + KMX_DWORD nkeys = 0; + for (KMX_DWORD iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { nkeys += rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()); } @@ -543,7 +543,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** ke // Fill in the new rules // nkeys = 0; - for (UINT iKey = 0; iKey < rgKey.size(); iKey++) { + for (KMX_DWORD iKey = 0; iKey < rgKey.size(); iKey++) { if ((rgKey[iKey] != NULL) && rgKey[iKey]->KMX_IsKeymanUsedKey() && (!rgKey[iKey]->KMX_IsEmpty())) { if (rgKey[iKey]->KMX_LayoutRow(loader.KMX_MaxShiftState(), &gp->dpKeyArray[nkeys], &alDead, nDeadkey, bDeadkeyConversion, all_vector, *keymap)) { // I4552 nkeys += rgKey[iKey]->KMX_GetKeyCount(loader.KMX_MaxShiftState()); @@ -557,7 +557,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** ke // Add nomatch control to each terminating 'using keys' group // I4550 // LPKMX_GROUP gp2 = kp->dpGroupArray; - for (UINT i = 0; i < kp->cxGroupArray - 1; i++, gp2++) { + for (KMX_DWORD i = 0; i < kp->cxGroupArray - 1; i++, gp2++) { if (gp2->fUsingKeys && gp2->dpNoMatch == NULL) { KMX_WCHAR* p = gp2->dpNoMatch = new KMX_WCHAR[4]; *p++ = UC_SENTINEL; @@ -569,7 +569,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** ke // the AltGr and ShiftAltGr combinations as rules to allow them to be matched as well. Yes, this // loop is not very efficient but it's not worthy of optimisation. // - UINT j; + KMX_DWORD j; LPKMX_KEY kkp; for (j = 0, kkp = gp->dpKeyArray; j < gp->cxKeyArray; j++, kkp++) { if ((kkp->ShiftFlags & (K_CTRLFLAG | K_ALTFLAG | LCTRLFLAG | LALTFLAG | RCTRLFLAG | RALTFLAG)) != 0) { @@ -624,7 +624,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** ke int nStoreBase = kp->cxStoreArray; kp->cxStoreArray += alDead.size() * 2; - for (UINT i = 0; i < alDead.size(); i++) { + for (KMX_DWORD i = 0; i < alDead.size(); i++) { DeadKey* dk = alDead[i]; sp->dpName = NULL; diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index d02e8f7661..f30ff5daef 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -42,7 +42,7 @@ const int CODE__SIZE[] = { }; /** @brief check if the file has correct version */ -KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD file_size); +KMX_BOOL KMX_VerifyKeyboard(PKMX_BYTE filebase, KMX_DWORD file_size); /** @brief Fixup the keyboard by expanding pointers. */ LPKMX_KEYBOARD KMX_FixupKeyboard(PKMX_BYTE bufp, PKMX_BYTE base, KMX_DWORD dwFileSize); @@ -65,7 +65,7 @@ KMX_DWORD KMX_WriteCompiledKeyboardToFile(LPKMX_KEYBOARD fk, FILE* hOutfile, KMX PCOMP_KEY kp; PKMX_BYTE buf; KMX_DWORD size, offset; - DWORD i, j; + KMX_DWORD i, j; // Calculate how much memory to allocate size = sizeof(COMP_KEYBOARD) + @@ -495,7 +495,7 @@ KMX_BOOL KMX_LoadKeyboard(KMX_CHAR* fileName, LPKMX_KEYBOARD* lpKeyboard) { * @return true if successful; * false if not */ -KMX_BOOL KMX_VerifyKeyboard(LPKMX_BYTE filebase, KMX_DWORD file_size) { +KMX_BOOL KMX_VerifyKeyboard(PKMX_BYTE filebase, KMX_DWORD file_size) { KMX_DWORD i; PCOMP_KEYBOARD ckbp = (PCOMP_KEYBOARD)filebase; PCOMP_STORE csp; diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 16a17e5d9e..8c8d8b7c17 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -133,7 +133,7 @@ int run(int argc, char* argv[]) { } // Map of all shift states that we will work with -const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG | RALTFLAG, K_SHIFTFLAG | LCTRLFLAG | RALTFLAG, 0xFFFF}; +const KMX_DWORD VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG | RALTFLAG, K_SHIFTFLAG | LCTRLFLAG | RALTFLAG, 0xFFFF}; // // TranslateKey @@ -149,7 +149,7 @@ const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG | RALTFLAG, K_SHIFTFLAG | * @param shift shiftstate * @param ch character of the underlying keyboard to be remapped */ -void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { +void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, KMX_DWORD shift, KMX_WCHAR ch) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. @@ -181,7 +181,7 @@ void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { * @param shift shiftstate * @param ch character of the underlying keyboard to be remapped */ -void KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { +void KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, KMX_DWORD shift, KMX_WCHAR ch) { for (unsigned int i = 0; i < group->cxKeyArray; i++) { KMX_TranslateKey(&group->dpKeyArray[i], vk, shift, ch); } @@ -194,7 +194,7 @@ void KMX_TranslateGroup(LPKMX_GROUP group, KMX_WORD vk, UINT shift, KMX_WCHAR ch * @param shift shiftstate * @param ch character of the underlying keyboard to be remapped */ -void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, UINT shift, KMX_WCHAR ch) { +void KMX_TranslateKeyboard(LPKMX_KEYBOARD kbd, KMX_WORD vk, KMX_DWORD shift, KMX_WCHAR ch) { for (unsigned int i = 0; i < kbd->cxGroupArray; i++) { if (kbd->dpGroupArray[i].fUsingKeys) { KMX_TranslateGroup(&kbd->dpGroupArray[i], vk, shift, ch); @@ -244,7 +244,7 @@ void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) { * @param shift shiftstate * @param ch character of the underlying keyboard */ -void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { +void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, KMX_DWORD shift, KMX_WORD ch) { if ((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. @@ -282,7 +282,7 @@ void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT * @param shift shiftstate * @param ch character of the underlying keyboard */ -void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { +void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group, KMX_WCHAR deadkey, KMX_WORD vk, KMX_DWORD shift, KMX_WORD ch) { for (unsigned int i = 0; i < group->cxKeyArray; i++) { KMX_TranslateDeadkeyKey(&group->dpKeyArray[i], deadkey, vk, shift, ch); } @@ -296,7 +296,7 @@ void KMX_TranslateDeadkeyGroup(LPKMX_GROUP group, KMX_WCHAR deadkey, KMX_WORD vk * @param shift shiftstate * @param ch character of the underlying keyboard */ -void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) { +void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, KMX_DWORD shift, KMX_WORD ch) { for (unsigned int i = 0; i < kbd->cxGroupArray; i++) { if (kbd->dpGroupArray[i].fUsingKeys) { KMX_TranslateDeadkeyGroup(&kbd->dpGroupArray[i], deadkey, vk, shift, ch); @@ -311,7 +311,7 @@ void KMX_TranslateDeadkeyKeyboard(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WOR * @param vk a keyvalue of the US keyboard * @param shift shiftstate */ -void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift) { +void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, KMX_DWORD shift) { // The weird LCTRL+RALT is Windows' way of mapping the AltGr key. // We store that as just RALT, and use the option "Simulate RAlt with Ctrl+Alt" // to provide an alternate.. @@ -373,7 +373,7 @@ KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { LPKMX_GROUP gp; LPKMX_KEY kp; LPKMX_STORE sp; - UINT i, j; + KMX_DWORD i, j; KMX_WCHAR dkid = 0; static KMX_WCHAR s_next_dkid = 0; static KMX_dkidmap* s_dkids = NULL; @@ -429,7 +429,7 @@ KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { * @param keymap pointer to the currently used (underlying) keyboard Layout * @param dk_Table a vector of all possible deadkey combinations for all Linux keyboards */ -void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, UINT shift, KMX_WCHAR deadkey, vec_dword_3D& all_vector, GdkKeymap* keymap, vec_dword_2D dk_Table) { +void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, KMX_DWORD shift, KMX_WCHAR deadkey, vec_dword_3D& all_vector, GdkKeymap* keymap, vec_dword_2D dk_Table) { KMX_WORD deadkeys[512], *pdk; // Lookup the deadkey table for the deadkey in the physical keyboard @@ -446,7 +446,7 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, UINT shift, KMX_WCHA while (*pdk) { // Look up the ch - UINT KeyValUnderlying = (UINT) KMX_get_KeyValUnderlying_From_KeyValUS(all_vector, *pdk); + KMX_DWORD KeyValUnderlying = (KMX_DWORD) KMX_get_KeyValUnderlying_From_KeyValUS(all_vector, *pdk); KMX_TranslateDeadkeyKeyboard(kbd, dkid, KeyValUnderlying, *(pdk + 1), *(pdk + 2)); pdk += 3; } @@ -461,7 +461,7 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, UINT shift, KMX_WCHA */ KMX_BOOL KMX_SetKeyboardToPositional(LPKMX_KEYBOARD kbd) { LPKMX_STORE sp; - UINT i; + KMX_DWORD i; for (i = 0, sp = kbd->dpStoreArray; i < kbd->cxStoreArray; i++, sp++) { if (sp->dwSystemID == TSS_MNEMONIC) { if (!sp->dpString) { @@ -523,7 +523,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg for (int i = 0; KMX_VKMap[i]; i++) { // I4651 // windows uses VK, Linux uses SC/Keycode - UINT scUnderlying = (UINT)KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]); + KMX_DWORD scUnderlying = (KMX_DWORD)KMX_get_KeyCodeUnderlying_From_VKUS(KMX_VKMap[i]); KMX_WCHAR ch = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(keymap, scUnderlying, VKShiftState[j], &DeadKey); // printf("--- VK_%d -> SC_ [%c] dk=%d ( ss %i) \n", KMX_VKMap[i], ch == 0 ? 32 : ch, DeadKey, VKShiftState[j]); @@ -583,7 +583,7 @@ int KMX_GetDeadkeys(vec_dword_2D& dk_Table, KMX_WORD deadkey, KMX_WORD* outputPa * @param fmt text to print */ void KMX_LogError(const wchar_t* fmt, ...) { - WCHAR fmtbuf[256]; + wchar_t fmtbuf[256]; const wchar_t* end = L"\0"; const wchar_t* nl = L"\n"; va_list vars; diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index 292db0bd03..ca3cd78395 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -26,7 +26,7 @@ struct KMX_DeadkeyMapping { // I4353 KMX_WCHAR deadkey, dkid; - UINT shift; + KMX_DWORD shift; KMX_WORD vk; }; From dedc18e15698249860ced0291a20eef2a9b9982c Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Tue, 13 Aug 2024 17:14:51 +0200 Subject: [PATCH 310/327] refactor(web): move some files around MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - move `systemStore.ts` → `js-processor` - move `keyEventSource.interface.ts` → `osk` - move `defaultRules.ts` → back to `keyboard-processor` - in `KeyboardProcessor` pass `ruleBehavior` as parameter to `forAny`, looks like that accidentally got omitted previously Addresses code review comments. --- common/web/keyboard-processor/src/index.ts | 4 +- .../src/keyboards/keyboard.ts | 74 +------------------ .../src/text}/defaultRules.ts | 35 ++++----- .../keyboard-processor/src/text/keyEvent.ts | 19 ++--- .../src/text/ruleBehavior.interface.ts | 12 --- .../app/browser/src/defaultBrowserRules.ts | 2 +- web/src/app/webview/src/keymanEngine.ts | 4 +- web/src/engine/events/src/index.ts | 1 - web/src/engine/js-processor/src/index.ts | 3 +- .../engine/js-processor/src/kbdInterface.ts | 73 +++++++++++++++++- .../js-processor/src/keyboardProcessor.ts | 8 +- .../engine/js-processor/src/ruleBehavior.ts | 3 +- .../engine/js-processor/src}/systemStores.ts | 4 +- web/src/engine/main/src/hardKeyboard.ts | 2 +- .../main/src/headless/inputProcessor.ts | 3 +- .../main/src/variableStoreCookieSerializer.ts | 2 +- web/src/engine/osk/src/index.ts | 1 + .../src/views}/keyEventSource.interface.ts | 5 +- web/src/engine/osk/src/views/oskView.ts | 8 +- web/src/engine/osk/src/visualKeyboard.ts | 2 +- 20 files changed, 125 insertions(+), 140 deletions(-) rename {web/src/engine/js-processor/src => common/web/keyboard-processor/src/text}/defaultRules.ts (88%) delete mode 100644 common/web/keyboard-processor/src/text/ruleBehavior.interface.ts rename {common/web/keyboard-processor/src/text => web/src/engine/js-processor/src}/systemStores.ts (96%) rename web/src/engine/{events/src => osk/src/views}/keyEventSource.interface.ts (63%) diff --git a/common/web/keyboard-processor/src/index.ts b/common/web/keyboard-processor/src/index.ts index c719d7ee8e..d9d0b2137f 100644 --- a/common/web/keyboard-processor/src/index.ts +++ b/common/web/keyboard-processor/src/index.ts @@ -27,14 +27,14 @@ export { default as StateKeyMap } from "./keyboards/stateKeyMap.js"; export { default as Codes } from "./text/codes.js"; export * from "./text/codes.js"; export * from "./text/deadkeys.js"; +export { default as DefaultRules } from "./text/defaultRules.js"; +export * from "./text/defaultRules.js"; export { default as KeyEvent } from "./text/keyEvent.js"; export * from "./text/keyEvent.js"; export { default as KeyMapping } from "./text/keyMapping.js"; export { default as OutputTarget } from "./text/outputTarget.js"; export * from "./text/outputTarget.js"; export * from "./text/stringDivergence.js"; -export * from "./text/systemStores.js"; -export * from "./text/ruleBehavior.interface.js"; export * from "@keymanapp/web-utils"; diff --git a/common/web/keyboard-processor/src/keyboards/keyboard.ts b/common/web/keyboard-processor/src/keyboards/keyboard.ts index 6ca5f790fd..d791d6ea75 100644 --- a/common/web/keyboard-processor/src/keyboards/keyboard.ts +++ b/common/web/keyboard-processor/src/keyboards/keyboard.ts @@ -6,82 +6,10 @@ import type OutputTarget from "../text/outputTarget.js"; import { ModifierKeyConstants, TouchLayout } from "@keymanapp/common-types"; type TouchLayoutSpec = TouchLayout.TouchLayoutPlatform & { isDefault?: boolean}; -import type { ComplexKeyboardStore, KeyboardStore } from "../text/systemStores.js"; - import { Version, DeviceSpec } from "@keymanapp/web-utils"; import StateKeyMap from "./stateKeyMap.js"; -export class RuleDeadkey { - /** Discriminant field - 'd' for Deadkey. - */ - t: 'd'; - - /** - * Value: the deadkey's ID. - */ - d: number; // For 'd'eadkey; also reflects the Deadkey class's 'd' property. -} - -export class StoreBeep { - /** Discriminant field - 'b' for `beep` - */ - ['t']: 'b'; -} - -export type RuleChar = string; - -export class ContextAny { - /** Discriminant field - 'a' for `any()`. - */ - ['t']: 'a'; - - /** - * Value: the store to search. - */ - ['a']: KeyboardStore; // For 'a'ny statement. - - /** - * If set to true, negates the 'any'. - */ - ['n']: boolean | 0 | 1; -} - -export class RuleIndex { - /** Discriminant field - 'i' for `index()`. - */ - ['t']: 'i'; - - /** - * Value: the Store from which to output - */ - ['i']: KeyboardStore; - - /** - * Offset: the offset in context for the corresponding `any()`. - */ - ['o']: number; -} - -export class ContextEx { - /** Discriminant field - 'c' for `context()`. - */ - ['t']: 'c'; - - /** - * Value: The offset into the current rule's context to be matched. - */ - ['c']: number; // For 'c'ontext statement. -} - -export class ContextNul { - /** Discriminant field - 'n' for `nul` - */ - ['t']: 'n'; -} - - - -export type StoreNonCharEntry = RuleDeadkey | StoreBeep; +type ComplexKeyboardStore = ( string | { t: 'd', d: number } | { ['t']: 'b' })[]; /** * Stores preprocessed properties of a keyboard for quick retrieval later. diff --git a/web/src/engine/js-processor/src/defaultRules.ts b/common/web/keyboard-processor/src/text/defaultRules.ts similarity index 88% rename from web/src/engine/js-processor/src/defaultRules.ts rename to common/web/keyboard-processor/src/text/defaultRules.ts index 3d56a2dad8..94acb02688 100644 --- a/web/src/engine/js-processor/src/defaultRules.ts +++ b/common/web/keyboard-processor/src/text/defaultRules.ts @@ -5,23 +5,24 @@ */ import { ModifierKeyConstants } from '@keymanapp/common-types'; -import { Codes, type KeyEvent, type OutputTarget, setDefaultRules } from "@keymanapp/keyboard-processor"; -import RuleBehavior from "./ruleBehavior.js"; +import Codes from './codes.js'; +import type KeyEvent from './keyEvent.js'; +import type OutputTarget from './outputTarget.js'; export enum EmulationKeystrokes { Enter = '\n', Backspace = '\b' } +export class LogMessages { + errorLog?: string; + warningLog?: string; +} /** * Defines a collection of static library functions that define KeymanWeb's default (implied) keyboard rule behaviors. */ export default class DefaultRules { - public constructor() { - setDefaultRules(this); - } - codeForEvent(Lkc: KeyEvent) { return Codes.keyCodes[Lkc.kName] || Lkc.Lcode;; } @@ -30,7 +31,7 @@ export default class DefaultRules { * Serves as a default keycode lookup table. This may be referenced safely by mnemonic handling without fear of side-effects. * Also used by Processor.defaultRuleBehavior to generate output after filtering for special cases. */ - public forAny(Lkc: KeyEvent, isMnemonic: boolean, ruleBehavior?: RuleBehavior): string { + public forAny(Lkc: KeyEvent, isMnemonic: boolean, logMessages?: LogMessages): string { var char = ''; // A pretty simple table of lookups, corresponding VERY closely to the original defaultKeyOutput. @@ -38,9 +39,9 @@ export default class DefaultRules { return char; } else if(!isMnemonic && ((char = this.forNumpadKeys(Lkc)) != null)) { return char; - } else if((char = this.forUnicodeKeynames(Lkc, ruleBehavior)) != null) { + } else if((char = this.forUnicodeKeynames(Lkc, logMessages)) != null) { return char; - } else if((char = this.forBaseKeys(Lkc, ruleBehavior)) != null) { + } else if((char = this.forBaseKeys(Lkc, logMessages)) != null) { return char; } else { // // For headless and embeddded, we may well allow '\t'. It's DOM mode that has other uses. @@ -147,7 +148,7 @@ export default class DefaultRules { // Test for fall back to U_xxxxxx key id // For this first test, we ignore the keyCode and use the keyName - public forUnicodeKeynames(Lkc: KeyEvent, ruleBehavior?: RuleBehavior) { + public forUnicodeKeynames(Lkc: KeyEvent, logMessages?: LogMessages) { const keyName = Lkc.kName; // Test for fall back to U_xxxxxx key id @@ -164,8 +165,8 @@ export default class DefaultRules { // Code points [U_0000 - U_001F] and [U_0080 - U_009F] refer to Unicode C0 and C1 control codes. // Check the codePoint number and do not allow output of these codes via U_xxxxxx shortcuts. // Also handles invalid identifiers (e.g. `U_ghij`) for which parseInt returns NaN - if(ruleBehavior) { - ruleBehavior.errorLog = ("Suppressing Unicode control code in " + keyName); + if(logMessages) { + logMessages.errorLog = ("Suppressing Unicode control code in " + keyName); } // We'll attempt to add valid chars continue; @@ -180,7 +181,7 @@ export default class DefaultRules { // Test for otherwise unimplemented keys on the the base default & shift layers. // Those keys must be blocked by keyboard rules if intentionally unimplemented; otherwise, this function will trigger. - public forBaseKeys(Lkc: KeyEvent, ruleBehavior?: RuleBehavior) { + public forBaseKeys(Lkc: KeyEvent, logMessages?: LogMessages) { let n = Lkc.Lcode; let keyShiftState = Lkc.Lmodifiers; @@ -189,8 +190,8 @@ export default class DefaultRules { if (keyShiftState == ModifierKeyConstants.K_SHIFTFLAG) { keyShiftState = 1; } else if(keyShiftState != 0) { - if(ruleBehavior) { - ruleBehavior.warningLog = "KMW only defines default key output for the 'default' and 'shift' layers!"; + if(logMessages) { + logMessages.warningLog = "KMW only defines default key output for the 'default' and 'shift' layers!"; } return null; } @@ -211,8 +212,8 @@ export default class DefaultRules { return keyShiftState ? '|' : '\\'; } } catch (e) { - if(ruleBehavior) { - ruleBehavior.errorLog = "Error detected with default mapping for key: code = " + n + ", shift state = " + (keyShiftState == 1 ? 'shift' : 'default'); + if(logMessages) { + logMessages.errorLog = "Error detected with default mapping for key: code = " + n + ", shift state = " + (keyShiftState == 1 ? 'shift' : 'default'); } } diff --git a/common/web/keyboard-processor/src/text/keyEvent.ts b/common/web/keyboard-processor/src/text/keyEvent.ts index 2d0ee49322..7d6483d0e9 100644 --- a/common/web/keyboard-processor/src/text/keyEvent.ts +++ b/common/web/keyboard-processor/src/text/keyEvent.ts @@ -10,22 +10,19 @@ import type Keyboard from "../keyboards/keyboard.js"; import { type DeviceSpec } from "@keymanapp/web-utils"; import Codes from './codes.js'; +import DefaultRules from "./defaultRules.js"; import { ActiveKeyBase } from "../index.js"; -export interface DefaultRulesInterface { - forAny(Lkc: KeyEvent, isMnemonic: boolean): string; -} - -let defaultRules: DefaultRulesInterface; - -export function setDefaultRules(rules: DefaultRulesInterface) { - defaultRules = rules; -} - // Represents a probability distribution over a keyboard's keys. // Defined here to avoid compilation issues. export type KeyDistribution = { keySpec: ActiveKeyBase, p: number }[]; +/** + * A simple instance of the standard 'default rules' for keystroke processing from the + * DefaultRules base class. + */ +const BASE_DEFAULT_RULES = new DefaultRules(); + export interface KeyEventSpec { Lcode: number; @@ -159,7 +156,7 @@ export default class KeyEvent implements KeyEventSpec { // the actual keyname instead. mappingEvent.kName = 'K_xxxx'; mappingEvent.Lmodifiers = (shifted ? 0x10 : 0); // mnemonic lookups only exist for default & shift layers. - var mappedChar: string = defaultRules.forAny(mappingEvent, true); + var mappedChar: string = BASE_DEFAULT_RULES.forAny(mappingEvent, true); /* First, save a backup of the original code. This one won't needlessly trigger keyboard * rules, but allows us to replicate/emulate commands after rule processing if needed. diff --git a/common/web/keyboard-processor/src/text/ruleBehavior.interface.ts b/common/web/keyboard-processor/src/text/ruleBehavior.interface.ts deleted file mode 100644 index 29f81bcc8c..0000000000 --- a/common/web/keyboard-processor/src/text/ruleBehavior.interface.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { type Transcription } from './outputTarget.js'; - -/** - * Represents the commands and state changes that result from a matched keyboard rule. - */ -export interface RuleBehaviorInterface { - /** - * The before-and-after Transform from matching a keyboard rule. May be `null` - * if no keyboard rules were matched for the keystroke. - */ - transcription: Transcription; -} diff --git a/web/src/app/browser/src/defaultBrowserRules.ts b/web/src/app/browser/src/defaultBrowserRules.ts index fc084ec3f4..1ac4801689 100644 --- a/web/src/app/browser/src/defaultBrowserRules.ts +++ b/web/src/app/browser/src/defaultBrowserRules.ts @@ -1,10 +1,10 @@ import { ModifierKeyConstants } from '@keymanapp/common-types'; import { Codes, + DefaultRules, type KeyEvent, type OutputTarget } from '@keymanapp/keyboard-processor'; -import { DefaultRules } from 'keyman/engine/js-processor'; import ContextManager from './contextManager.js'; diff --git a/web/src/app/webview/src/keymanEngine.ts b/web/src/app/webview/src/keymanEngine.ts index 2f07350548..dfae058a65 100644 --- a/web/src/app/webview/src/keymanEngine.ts +++ b/web/src/app/webview/src/keymanEngine.ts @@ -1,5 +1,5 @@ -import { DeviceSpec } from '@keymanapp/keyboard-processor' -import { DefaultRules, RuleBehavior } from 'keyman/engine/js-processor'; +import { DeviceSpec, DefaultRules } from '@keymanapp/keyboard-processor' +import { RuleBehavior } from 'keyman/engine/js-processor'; import { KeymanEngine as KeymanEngineBase, KeyboardInterface } from 'keyman/engine/main'; import { AnchoredOSKView, ViewConfiguration, StaticActivator } from 'keyman/engine/osk'; import { getAbsoluteX, getAbsoluteY } from 'keyman/engine/dom-utils'; diff --git a/web/src/engine/events/src/index.ts b/web/src/engine/events/src/index.ts index 2d95307bc9..ee5674b66c 100644 --- a/web/src/engine/events/src/index.ts +++ b/web/src/engine/events/src/index.ts @@ -1,4 +1,3 @@ export { DomEventTracker } from './domEventTracker.js'; export { EmitterListenerSpy } from './emitterListenerSpy.js'; -export * from './keyEventSource.interface.js'; export * from './legacyEventEmitter.js'; \ No newline at end of file diff --git a/web/src/engine/js-processor/src/index.ts b/web/src/engine/js-processor/src/index.ts index 1c51de80d9..f87a044bd7 100644 --- a/web/src/engine/js-processor/src/index.ts +++ b/web/src/engine/js-processor/src/index.ts @@ -1,7 +1,6 @@ -export { default as DefaultRules } from "./defaultRules.js"; -export * from "./defaultRules.js"; export { default as KeyboardProcessor } from "./keyboardProcessor.js"; export * from "./keyboardProcessor.js"; export { default as RuleBehavior } from "./ruleBehavior.js"; export * from './kbdInterface.js'; export { default as KeyboardInterface } from "./kbdInterface.js"; +export * from "./systemStores.js"; diff --git a/web/src/engine/js-processor/src/kbdInterface.ts b/web/src/engine/js-processor/src/kbdInterface.ts index 2b34eadce9..6272637d04 100644 --- a/web/src/engine/js-processor/src/kbdInterface.ts +++ b/web/src/engine/js-processor/src/kbdInterface.ts @@ -7,8 +7,9 @@ import { type DeviceSpec } from "@keymanapp/web-utils"; import { ModifierKeyConstants } from '@keymanapp/common-types'; -import { Codes, type KeyEvent, type Deadkey, ComplexKeyboardStore, type KeyboardStore, KeyboardStoreElement, KeyMapping, SystemStoreIDs, SystemStore, MutableSystemStore, PlatformSystemStore, type OutputTarget, Mock, Keyboard, VariableStore, VariableStoreDictionary, VariableStoreSerializer, KeyboardHarness, KeyboardKeymanGlobal, RuleDeadkey, ContextAny, RuleIndex, ContextEx, ContextNul, RuleChar } from "@keymanapp/keyboard-processor"; +import { Codes, type KeyEvent, type Deadkey, KeyMapping, type OutputTarget, Mock, Keyboard, KeyboardHarness, KeyboardKeymanGlobal, VariableStoreDictionary } from "@keymanapp/keyboard-processor"; import RuleBehavior from "./ruleBehavior.js"; +import { ComplexKeyboardStore, type KeyboardStore, KeyboardStoreElement, SystemStoreIDs, SystemStore, MutableSystemStore, PlatformSystemStore, VariableStore, VariableStoreSerializer } from "./systemStores.js"; //#endregion @@ -20,9 +21,79 @@ export class KeyInformation { modifiers: number; } +type RuleChar = string; + +class RuleDeadkey { + /** Discriminant field - 'd' for Deadkey. + */ + t: 'd'; + + /** + * Value: the deadkey's ID. + */ + d: number; // For 'd'eadkey; also reflects the Deadkey class's 'd' property. +} + +class ContextAny { + /** Discriminant field - 'a' for `any()`. + */ + ['t']: 'a'; + + /** + * Value: the store to search. + */ + ['a']: KeyboardStore; // For 'a'ny statement. + + /** + * If set to true, negates the 'any'. + */ + ['n']: boolean | 0 | 1; +} + +class RuleIndex { + /** Discriminant field - 'i' for `index()`. + */ + ['t']: 'i'; + + /** + * Value: the Store from which to output + */ + ['i']: KeyboardStore; + + /** + * Offset: the offset in context for the corresponding `any()`. + */ + ['o']: number; +} + +class ContextEx { + /** Discriminant field - 'c' for `context()`. + */ + ['t']: 'c'; + + /** + * Value: The offset into the current rule's context to be matched. + */ + ['c']: number; // For 'c'ontext statement. +} + +class ContextNul { + /** Discriminant field - 'n' for `nul` + */ + ['t']: 'n'; +} + +class StoreBeep { + /** Discriminant field - 'b' for `beep` + */ + ['t']: 'b'; +} + type ContextNonCharEntry = RuleDeadkey | ContextAny | RuleIndex | ContextEx | ContextNul; type ContextEntry = RuleChar | ContextNonCharEntry; +export type StoreNonCharEntry = RuleDeadkey | StoreBeep; + /** * Cache of context storing and retrieving return values from KC * Must be reset prior to each keystroke and after any text changes diff --git a/web/src/engine/js-processor/src/keyboardProcessor.ts b/web/src/engine/js-processor/src/keyboardProcessor.ts index 1a6d216dce..12efa4e951 100644 --- a/web/src/engine/js-processor/src/keyboardProcessor.ts +++ b/web/src/engine/js-processor/src/keyboardProcessor.ts @@ -9,13 +9,13 @@ import { EventEmitter } from 'eventemitter3'; import { ModifierKeyConstants } from '@keymanapp/common-types'; import { - Codes, type Keyboard, MinimalKeymanGlobal, KeyEvent, Layouts, type MutableSystemStore, - type OutputTarget, Mock, SystemStoreIDs, + Codes, type Keyboard, MinimalKeymanGlobal, KeyEvent, Layouts, + type OutputTarget, Mock, DefaultRules, EmulationKeystrokes } from "@keymanapp/keyboard-processor"; -import DefaultRules, { EmulationKeystrokes } from "./defaultRules.js"; import RuleBehavior from "./ruleBehavior.js"; import KeyboardInterface from './kbdInterface.js'; import { DeviceSpec, globalObject } from "@keymanapp/web-utils"; +import { type MutableSystemStore, SystemStoreIDs } from "./systemStores.js"; // #endregion @@ -167,7 +167,7 @@ export default class KeyboardProcessor extends EventEmitter { let isMnemonic = this.activeKeyboard && this.activeKeyboard.isMnemonic; if(!matched) { - if((char = this.defaultRules.forAny(Lkc, isMnemonic)) != null) { + if((char = this.defaultRules.forAny(Lkc, isMnemonic, ruleBehavior)) != null) { special = this.defaultRules.forSpecialEmulation(Lkc) if(special == EmulationKeystrokes.Backspace) { // A browser's default backspace may fail to delete both parts of an SMP character. diff --git a/web/src/engine/js-processor/src/ruleBehavior.ts b/web/src/engine/js-processor/src/ruleBehavior.ts index aced7065d2..08881eabcc 100644 --- a/web/src/engine/js-processor/src/ruleBehavior.ts +++ b/web/src/engine/js-processor/src/ruleBehavior.ts @@ -1,7 +1,8 @@ /// import KeyboardProcessor from "./keyboardProcessor.js"; -import { OutputTarget, Mock, type Transcription, VariableStoreDictionary, type VariableStore } from "@keymanapp/keyboard-processor"; +import { OutputTarget, Mock, type Transcription, VariableStoreDictionary } from "@keymanapp/keyboard-processor"; +import { type VariableStore } from "./systemStores.js"; /** * Represents the commands and state changes that result from a matched keyboard rule. diff --git a/common/web/keyboard-processor/src/text/systemStores.ts b/web/src/engine/js-processor/src/systemStores.ts similarity index 96% rename from common/web/keyboard-processor/src/text/systemStores.ts rename to web/src/engine/js-processor/src/systemStores.ts index a2f7abff34..9d02dbddbc 100644 --- a/common/web/keyboard-processor/src/text/systemStores.ts +++ b/web/src/engine/js-processor/src/systemStores.ts @@ -1,5 +1,5 @@ -import { type KeyboardHarness } from "../keyboards/keyboardHarness.js"; -import { StoreNonCharEntry } from '../keyboards/keyboard.js'; +import { type KeyboardHarness } from '@keymanapp/keyboard-processor'; +import { StoreNonCharEntry } from './kbdInterface.js'; export enum SystemStoreIDs { TSS_LAYER = 33, diff --git a/web/src/engine/main/src/hardKeyboard.ts b/web/src/engine/main/src/hardKeyboard.ts index 7dc9b5e357..491073f729 100644 --- a/web/src/engine/main/src/hardKeyboard.ts +++ b/web/src/engine/main/src/hardKeyboard.ts @@ -1,7 +1,7 @@ import { EventEmitter } from "eventemitter3"; import { Keyboard, KeyMapping, KeyEvent, Codes } from "@keymanapp/keyboard-processor"; import { type RuleBehavior } from 'keyman/engine/js-processor'; -import { KeyEventSourceInterface } from 'keyman/engine/events'; +import { KeyEventSourceInterface } from 'keyman/engine/osk'; import { ModifierKeyConstants } from '@keymanapp/common-types'; interface EventMap { diff --git a/web/src/engine/main/src/headless/inputProcessor.ts b/web/src/engine/main/src/headless/inputProcessor.ts index a96170457e..99a31db609 100644 --- a/web/src/engine/main/src/headless/inputProcessor.ts +++ b/web/src/engine/main/src/headless/inputProcessor.ts @@ -15,9 +15,8 @@ import { type KeyEvent, Mock, type OutputTarget, - SystemStoreIDs, } from "@keymanapp/keyboard-processor"; -import { KeyboardInterface, KeyboardProcessor, RuleBehavior, type ProcessorInitOptions } from 'keyman/engine/js-processor'; +import { KeyboardInterface, KeyboardProcessor, RuleBehavior, type ProcessorInitOptions, SystemStoreIDs } from 'keyman/engine/js-processor'; import { TranscriptionCache } from "./transcriptionCache.js"; diff --git a/web/src/engine/main/src/variableStoreCookieSerializer.ts b/web/src/engine/main/src/variableStoreCookieSerializer.ts index 35b51150c0..62c250329a 100644 --- a/web/src/engine/main/src/variableStoreCookieSerializer.ts +++ b/web/src/engine/main/src/variableStoreCookieSerializer.ts @@ -1,4 +1,4 @@ -import { VariableStore, VariableStoreSerializer } from "@keymanapp/keyboard-processor"; +import { VariableStore, VariableStoreSerializer } from 'keyman/engine/js-processor'; import { CookieSerializer } from "keyman/engine/dom-utils"; // While there's little reason we couldn't store all of a keyboard's store values within diff --git a/web/src/engine/osk/src/index.ts b/web/src/engine/osk/src/index.ts index 388ea32750..f2a543e175 100644 --- a/web/src/engine/osk/src/index.ts +++ b/web/src/engine/osk/src/index.ts @@ -4,6 +4,7 @@ export { default as OSKView } from './views/oskView.js'; export { default as FloatingOSKView, FloatingOSKViewConfiguration } from './views/floatingOskView.js'; export { default as AnchoredOSKView } from './views/anchoredOskView.js'; export { default as InlinedOSKView } from './views/inlinedOskView.js'; +export { type KeyEventResultCallback, type KeyEventHandler, KeyEventSourceInterface } from './views/keyEventSource.interface.js'; export { BannerController } from './banner/bannerController.js'; // Is referenced by at least one desktop UI module. export { FloatingOSKCookie as FloatingOSKViewCookie } from './views/floatingOskCookie.js'; diff --git a/web/src/engine/events/src/keyEventSource.interface.ts b/web/src/engine/osk/src/views/keyEventSource.interface.ts similarity index 63% rename from web/src/engine/events/src/keyEventSource.interface.ts rename to web/src/engine/osk/src/views/keyEventSource.interface.ts index 22621d2de0..36a065bd32 100644 --- a/web/src/engine/events/src/keyEventSource.interface.ts +++ b/web/src/engine/osk/src/views/keyEventSource.interface.ts @@ -1,7 +1,8 @@ import { EventEmitter } from "eventemitter3"; -import { type KeyEvent, type RuleBehaviorInterface } from "@keymanapp/keyboard-processor"; +import { type KeyEvent } from "@keymanapp/keyboard-processor"; +import { type RuleBehavior } from 'keyman/engine/js-processor'; -export type KeyEventResultCallback = (result: RuleBehaviorInterface, error?: Error) => void; +export type KeyEventResultCallback = (result: RuleBehavior, error?: Error) => void; export type KeyEventHandler = (event: KeyEvent, callback?: KeyEventResultCallback) => void; interface EventMap { diff --git a/web/src/engine/osk/src/views/oskView.ts b/web/src/engine/osk/src/views/oskView.ts index afdc99f882..09b3cbc827 100644 --- a/web/src/engine/osk/src/views/oskView.ts +++ b/web/src/engine/osk/src/views/oskView.ts @@ -16,16 +16,16 @@ import { Keyboard, KeyboardProperties, ManagedPromise, - type MinimalCodesInterface, - type MutableSystemStore, - type SystemStoreMutationHandler + type MinimalCodesInterface } from '@keymanapp/keyboard-processor'; import { createUnselectableElement, getAbsoluteX, getAbsoluteY, StylesheetManager } from 'keyman/engine/dom-utils'; -import { EventListener, KeyEventHandler, KeyEventSourceInterface, LegacyEventEmitter } from 'keyman/engine/events'; +import { EventListener, LegacyEventEmitter } from 'keyman/engine/events'; +import { type MutableSystemStore, type SystemStoreMutationHandler } from 'keyman/engine/js-processor'; import Configuration from '../config/viewConfiguration.js'; import Activator, { StaticActivator } from './activator.js'; import TouchEventPromiseMap from './touchEventPromiseMap.js'; +import { KeyEventHandler, KeyEventSourceInterface } from './keyEventSource.interface.js'; // These will likely be eliminated from THIS file at some point.\ diff --git a/web/src/engine/osk/src/visualKeyboard.ts b/web/src/engine/osk/src/visualKeyboard.ts index fac43d5125..1136e696ba 100644 --- a/web/src/engine/osk/src/visualKeyboard.ts +++ b/web/src/engine/osk/src/visualKeyboard.ts @@ -31,7 +31,7 @@ import { import { createStyleSheet, StylesheetManager } from 'keyman/engine/dom-utils'; -import { KeyEventHandler, KeyEventResultCallback } from 'keyman/engine/events'; +import { KeyEventHandler, KeyEventResultCallback } from './views/keyEventSource.interface.js'; import GlobeHint from './globehint.interface.js'; import KeyboardView from './components/keyboardView.interface.js'; From 3cdd84ff40b0c360682f9363c6e398b30cf4c67e Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Tue, 13 Aug 2024 19:00:38 +0200 Subject: [PATCH 311/327] refactor(web): move tests to `test/auto/headless` Addresses code review comments. --- web/src/engine/keyboard/build.sh | 14 +------------- .../auto/headless/engine/keyboard}/basic-engine.js | 2 +- .../auto/headless/engine/keyboard}/basic-init.js | 0 .../headless/engine/keyboard}/bundled-module.js | 0 .../auto/headless/engine/keyboard}/chirality.js | 2 +- .../auto/headless/engine/keyboard}/deadkeys.js | 2 +- .../headless/engine/keyboard}/engine/context.js | 0 .../engine/keyboard}/engine/notany_context.js | 0 .../headless/engine/keyboard}/engine/stores.js | 0 .../keyboard}/engine/unmatched_final_group.js | 2 +- .../headless/engine/keyboard}/keyboard-loading.js | 0 .../engine/keyboard}/keyboard-properties.js | 0 .../auto/headless/engine/keyboard}/mocks.js | 0 .../engine/keyboard}/non-positional-rules.js | 0 .../engine/keyboard}/specialized-backspace.js | 0 .../headless/engine/keyboard}/transcriptions.js | 0 16 files changed, 5 insertions(+), 17 deletions(-) rename web/src/{engine/keyboard/tests/node => test/auto/headless/engine/keyboard}/basic-engine.js (97%) rename web/src/{engine/keyboard/tests/node => test/auto/headless/engine/keyboard}/basic-init.js (100%) rename web/src/{engine/keyboard/tests/node => test/auto/headless/engine/keyboard}/bundled-module.js (100%) rename web/src/{engine/keyboard/tests/node => test/auto/headless/engine/keyboard}/chirality.js (99%) rename web/src/{engine/keyboard/tests/node => test/auto/headless/engine/keyboard}/deadkeys.js (97%) rename web/src/{engine/keyboard/tests/node => test/auto/headless/engine/keyboard}/engine/context.js (100%) rename web/src/{engine/keyboard/tests/node => test/auto/headless/engine/keyboard}/engine/notany_context.js (100%) rename web/src/{engine/keyboard/tests/node => test/auto/headless/engine/keyboard}/engine/stores.js (100%) rename web/src/{engine/keyboard/tests/node => test/auto/headless/engine/keyboard}/engine/unmatched_final_group.js (96%) rename web/src/{engine/keyboard/tests/node => test/auto/headless/engine/keyboard}/keyboard-loading.js (100%) rename web/src/{engine/keyboard/tests/node => test/auto/headless/engine/keyboard}/keyboard-properties.js (100%) rename web/src/{engine/keyboard/tests/node => test/auto/headless/engine/keyboard}/mocks.js (100%) rename web/src/{engine/keyboard/tests/node => test/auto/headless/engine/keyboard}/non-positional-rules.js (100%) rename web/src/{engine/keyboard/tests/node => test/auto/headless/engine/keyboard}/specialized-backspace.js (100%) rename web/src/{engine/keyboard/tests/node => test/auto/headless/engine/keyboard}/transcriptions.js (100%) diff --git a/web/src/engine/keyboard/build.sh b/web/src/engine/keyboard/build.sh index 649e38a213..226a7d9d75 100755 --- a/web/src/engine/keyboard/build.sh +++ b/web/src/engine/keyboard/build.sh @@ -79,19 +79,7 @@ function do_build() { tsc --emitDeclarationOnly --outFile "${BUILD_DIR}/lib/node-keyboard-loader.d.ts" -p src/keyboards/loaders/tsconfig.node.json } -function do_test() { - local MOCHA_FLAGS= - local WTR_CONFIG= - if builder_has_option --ci; then - echo "Replacing user-friendly test reports with CI-friendly versions." - MOCHA_FLAGS="$MOCHA_FLAGS --reporter mocha-teamcity-reporter" - WTR_CONFIG=.CI - fi - - c8 mocha --recursive $MOCHA_FLAGS ./tests/node/ -} - builder_run_action configure do_configure builder_run_action clean rm -rf "${BUILD_DIR}" builder_run_action build do_build -builder_run_action test do_test +builder_run_action test test-headless "${SUBPROJECT_NAME}" "" diff --git a/web/src/engine/keyboard/tests/node/basic-engine.js b/web/src/test/auto/headless/engine/keyboard/basic-engine.js similarity index 97% rename from web/src/engine/keyboard/tests/node/basic-engine.js rename to web/src/test/auto/headless/engine/keyboard/basic-engine.js index 33d90b6567..68eb5136e3 100644 --- a/web/src/engine/keyboard/tests/node/basic-engine.js +++ b/web/src/test/auto/headless/engine/keyboard/basic-engine.js @@ -25,7 +25,7 @@ describe('Engine - Basic Simulation', function() { before(async function() { // -- START: Standard Recorder-based unit test loading boilerplate -- let keyboardLoader = new NodeKeyboardLoader(new KeyboardInterface({}, MinimalKeymanGlobal)); - let keyboard = await keyboardLoader.loadKeyboardFromPath('../../../../common/test/' + testSuite.keyboard.filename); + let keyboard = await keyboardLoader.loadKeyboardFromPath('../../../../../common/test/' + testSuite.keyboard.filename); keyboardWithHarness = keyboardLoader.harness; keyboardWithHarness.activeKeyboard = keyboard; diff --git a/web/src/engine/keyboard/tests/node/basic-init.js b/web/src/test/auto/headless/engine/keyboard/basic-init.js similarity index 100% rename from web/src/engine/keyboard/tests/node/basic-init.js rename to web/src/test/auto/headless/engine/keyboard/basic-init.js diff --git a/web/src/engine/keyboard/tests/node/bundled-module.js b/web/src/test/auto/headless/engine/keyboard/bundled-module.js similarity index 100% rename from web/src/engine/keyboard/tests/node/bundled-module.js rename to web/src/test/auto/headless/engine/keyboard/bundled-module.js diff --git a/web/src/engine/keyboard/tests/node/chirality.js b/web/src/test/auto/headless/engine/keyboard/chirality.js similarity index 99% rename from web/src/engine/keyboard/tests/node/chirality.js rename to web/src/test/auto/headless/engine/keyboard/chirality.js index d812a21635..c2220b7f5d 100644 --- a/web/src/engine/keyboard/tests/node/chirality.js +++ b/web/src/test/auto/headless/engine/keyboard/chirality.js @@ -26,7 +26,7 @@ describe('Engine - Chirality', function() { before(async function() { // -- START: Standard Recorder-based unit test loading boilerplate -- let keyboardLoader = new NodeKeyboardLoader(new KeyboardInterface({}, MinimalKeymanGlobal)); - let keyboard = await keyboardLoader.loadKeyboardFromPath('../../../../common/test/' + testSuite.keyboard.filename); + let keyboard = await keyboardLoader.loadKeyboardFromPath('../../../../../common/test/' + testSuite.keyboard.filename); keyboardWithHarness = keyboardLoader.harness; keyboardWithHarness.activeKeyboard = keyboard; diff --git a/web/src/engine/keyboard/tests/node/deadkeys.js b/web/src/test/auto/headless/engine/keyboard/deadkeys.js similarity index 97% rename from web/src/engine/keyboard/tests/node/deadkeys.js rename to web/src/test/auto/headless/engine/keyboard/deadkeys.js index 51bf2aebf5..fd5d1457d3 100644 --- a/web/src/engine/keyboard/tests/node/deadkeys.js +++ b/web/src/test/auto/headless/engine/keyboard/deadkeys.js @@ -25,7 +25,7 @@ describe('Engine - Deadkeys', function() { before(async function() { // -- START: Standard Recorder-based unit test loading boilerplate -- let keyboardLoader = new NodeKeyboardLoader(new KeyboardInterface({}, MinimalKeymanGlobal)); - let keyboard = await keyboardLoader.loadKeyboardFromPath('../../../../common/test/' + testSuite.keyboard.filename); + let keyboard = await keyboardLoader.loadKeyboardFromPath('../../../../../common/test/' + testSuite.keyboard.filename); keyboardWithHarness = keyboardLoader.harness; keyboardWithHarness.activeKeyboard = keyboard; diff --git a/web/src/engine/keyboard/tests/node/engine/context.js b/web/src/test/auto/headless/engine/keyboard/engine/context.js similarity index 100% rename from web/src/engine/keyboard/tests/node/engine/context.js rename to web/src/test/auto/headless/engine/keyboard/engine/context.js diff --git a/web/src/engine/keyboard/tests/node/engine/notany_context.js b/web/src/test/auto/headless/engine/keyboard/engine/notany_context.js similarity index 100% rename from web/src/engine/keyboard/tests/node/engine/notany_context.js rename to web/src/test/auto/headless/engine/keyboard/engine/notany_context.js diff --git a/web/src/engine/keyboard/tests/node/engine/stores.js b/web/src/test/auto/headless/engine/keyboard/engine/stores.js similarity index 100% rename from web/src/engine/keyboard/tests/node/engine/stores.js rename to web/src/test/auto/headless/engine/keyboard/engine/stores.js diff --git a/web/src/engine/keyboard/tests/node/engine/unmatched_final_group.js b/web/src/test/auto/headless/engine/keyboard/engine/unmatched_final_group.js similarity index 96% rename from web/src/engine/keyboard/tests/node/engine/unmatched_final_group.js rename to web/src/test/auto/headless/engine/keyboard/engine/unmatched_final_group.js index cf2f1e8803..8bfee041eb 100644 --- a/web/src/engine/keyboard/tests/node/engine/unmatched_final_group.js +++ b/web/src/test/auto/headless/engine/keyboard/engine/unmatched_final_group.js @@ -24,7 +24,7 @@ describe('Engine - Unmatched Final Groups', function() { before(async function() { // -- START: Standard Recorder-based unit test loading boilerplate -- let keyboardLoader = new NodeKeyboardLoader(new KeyboardInterface({}, MinimalKeymanGlobal)); - const keyboard = await keyboardLoader.loadKeyboardFromPath('../../../../common/test/' + testSuite.keyboard.filename); + const keyboard = await keyboardLoader.loadKeyboardFromPath('../../../../../common/test/' + testSuite.keyboard.filename); keyboardWithHarness = keyboardLoader.harness; keyboardWithHarness.activeKeyboard = keyboard; diff --git a/web/src/engine/keyboard/tests/node/keyboard-loading.js b/web/src/test/auto/headless/engine/keyboard/keyboard-loading.js similarity index 100% rename from web/src/engine/keyboard/tests/node/keyboard-loading.js rename to web/src/test/auto/headless/engine/keyboard/keyboard-loading.js diff --git a/web/src/engine/keyboard/tests/node/keyboard-properties.js b/web/src/test/auto/headless/engine/keyboard/keyboard-properties.js similarity index 100% rename from web/src/engine/keyboard/tests/node/keyboard-properties.js rename to web/src/test/auto/headless/engine/keyboard/keyboard-properties.js diff --git a/web/src/engine/keyboard/tests/node/mocks.js b/web/src/test/auto/headless/engine/keyboard/mocks.js similarity index 100% rename from web/src/engine/keyboard/tests/node/mocks.js rename to web/src/test/auto/headless/engine/keyboard/mocks.js diff --git a/web/src/engine/keyboard/tests/node/non-positional-rules.js b/web/src/test/auto/headless/engine/keyboard/non-positional-rules.js similarity index 100% rename from web/src/engine/keyboard/tests/node/non-positional-rules.js rename to web/src/test/auto/headless/engine/keyboard/non-positional-rules.js diff --git a/web/src/engine/keyboard/tests/node/specialized-backspace.js b/web/src/test/auto/headless/engine/keyboard/specialized-backspace.js similarity index 100% rename from web/src/engine/keyboard/tests/node/specialized-backspace.js rename to web/src/test/auto/headless/engine/keyboard/specialized-backspace.js diff --git a/web/src/engine/keyboard/tests/node/transcriptions.js b/web/src/test/auto/headless/engine/keyboard/transcriptions.js similarity index 100% rename from web/src/engine/keyboard/tests/node/transcriptions.js rename to web/src/test/auto/headless/engine/keyboard/transcriptions.js From a77a0d3b672513d4911221cfc0507061b5b955b9 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 14 Aug 2024 10:20:39 +0200 Subject: [PATCH 312/327] chore(linux): undo changes in comments of VKScancodes --- windows/src/engine/keyman32/VKScanCodes.cpp | 10 +++++----- windows/src/engine/mcompile/mc_savekeyboard.cpp | 4 ++-- windows/src/global/cpp/VKScanCodes.cpp | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/windows/src/engine/keyman32/VKScanCodes.cpp b/windows/src/engine/keyman32/VKScanCodes.cpp index 4207cb931a..6a806bcc32 100644 --- a/windows/src/engine/keyman32/VKScanCodes.cpp +++ b/windows/src/engine/keyman32/VKScanCodes.cpp @@ -23,7 +23,7 @@ UINT USVirtualKeyToScanCode[256] = 0x00, // L"K_?00", // &H0 0x00, // L"K_LBUTTON", // &H1 0x00, // L"K_RBUTTON", // &H2 - 0x46, // L"K_CANCEL", // &H3 + 0x46, // L"K_CANCE0x00, // L", // &H3 0x00, // L"K_MBUTTON", // &H4 0x00, // L"K_?05", // &H5 0x00, // L"K_?06", // &H6 @@ -37,7 +37,7 @@ UINT USVirtualKeyToScanCode[256] = 0x00, // L"K_?0E", // &HE 0x00, // L"K_?0F", // &HF 0x2A, // L"K_SHIFT", // &H10 - 0x1D, // L"K_CONTROL", // &H11 + 0x1D, // L"K_CONTRO0x00, // L", // &H11 0x38, // L"K_ALT", // &H12 0x00, // L"K_PAUSE", // &H13 0x3A, // L"K_CAPS", // &H14 @@ -167,8 +167,8 @@ UINT USVirtualKeyToScanCode[256] = 0x00, // L"K_?8E", // &H8E 0x00, // L"K_?8F", // &H8F - 0x45, // L"K_NUMLOCK", // &H90 - 0x46, // L"K_SCROLL", // &H91 + 0x45, // L"K_NUMLOCK", // &H90 + 0x46, // L"K_SCROL0x00, // L", // &H91 0x00, // L"K_?92", // &H92 0x00, // L"K_?93", // &H93 @@ -212,7 +212,7 @@ UINT USVirtualKeyToScanCode[256] = 0x00, // L"K_?B9", // &HB9 0x27, // L"K_COLON", // &HBA - 0x0D, // L"K_EQUAL", // &HBB + 0x0D, // L"K_EQUA0x00, // L", // &HBB 0x33, // L"K_COMMA", // &HBC 0x0C, // L"K_HYPHEN", // &HBD 0x34, // L"K_PERIOD", // &HBE diff --git a/windows/src/engine/mcompile/mc_savekeyboard.cpp b/windows/src/engine/mcompile/mc_savekeyboard.cpp index 781d6b1cbd..ce270104e7 100644 --- a/windows/src/engine/mcompile/mc_savekeyboard.cpp +++ b/windows/src/engine/mcompile/mc_savekeyboard.cpp @@ -67,8 +67,8 @@ DWORD WriteCompiledKeyboard(LPKEYBOARD fk, HANDLE hOutfile, BOOL FSaveDebug) size += wcslen(fkp->dpContext)*2 + 2; } - if (fgp->dpMatch ) size += wcslen(fgp->dpMatch)*2 + 2; - if (fgp->dpNoMatch ) size += wcslen(fgp->dpNoMatch)*2 + 2; + if( fgp->dpMatch ) size += wcslen(fgp->dpMatch)*2 + 2; + if( fgp->dpNoMatch ) size += wcslen(fgp->dpNoMatch)*2 + 2; } for(i = 0; i < fk->cxStoreArray; i++) diff --git a/windows/src/global/cpp/VKScanCodes.cpp b/windows/src/global/cpp/VKScanCodes.cpp index 60b6d47cf2..93fb01ba90 100644 --- a/windows/src/global/cpp/VKScanCodes.cpp +++ b/windows/src/global/cpp/VKScanCodes.cpp @@ -38,7 +38,7 @@ const UINT USVirtualKeyToScanCode[256] = 0x00, // L"K_?0E", // &HE 0x00, // L"K_?0F", // &HF 0x2A, // L"K_SHIFT", // &H10 - 0x1D, // L"K_CONTROL", // &H11 + 0x1D, // L"K_CONTRO0x00, // L", // &H11 0x38, // L"K_ALT", // &H12 0x00, // L"K_PAUSE", // &H13 0x3A, // L"K_CAPS", // &H14 @@ -168,8 +168,8 @@ const UINT USVirtualKeyToScanCode[256] = 0x00, // L"K_?8E", // &H8E 0x00, // L"K_?8F", // &H8F - 0x45, // L"K_NUMLOCK", // &H90 - 0x46, // L"K_SCROLL", // &H91 + 0x45, // L"K_NUMLOCK", // &H90 + 0x46, // L"K_SCROL0x00, // L", // &H91 0x00, // L"K_?92", // &H92 0x00, // L"K_?93", // &H93 @@ -213,7 +213,7 @@ const UINT USVirtualKeyToScanCode[256] = 0x00, // L"K_?B9", // &HB9 0x27, // L"K_COLON", // &HBA - 0x0D, // L"K_EQUAL", // &HBB + 0x0D, // L"K_EQUA0x00, // L", // &HBB 0x33, // L"K_COMMA", // &HBC 0x0C, // L"K_HYPHEN", // &HBD 0x34, // L"K_PERIOD", // &HBE From ad21aa037b3f195c9154df22f70fcacd5f3d9cf5 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 14 Aug 2024 10:53:30 +0200 Subject: [PATCH 313/327] chore(linux): add build.sh for mcompile-lin --- linux/mcompile/keymap/.gitignore | 2 + linux/mcompile/keymap/build.sh | 63 +++++++++++++++++++++++++++++++ linux/mcompile/keymap/meson.build | 1 + 3 files changed, 66 insertions(+) create mode 100644 linux/mcompile/keymap/.gitignore create mode 100755 linux/mcompile/keymap/build.sh diff --git a/linux/mcompile/keymap/.gitignore b/linux/mcompile/keymap/.gitignore new file mode 100644 index 0000000000..fcea0ffb39 --- /dev/null +++ b/linux/mcompile/keymap/.gitignore @@ -0,0 +1,2 @@ +resources/ +build/ diff --git a/linux/mcompile/keymap/build.sh b/linux/mcompile/keymap/build.sh new file mode 100755 index 0000000000..7c66e4b0b4 --- /dev/null +++ b/linux/mcompile/keymap/build.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +## START STANDARD BUILD SCRIPT INCLUDE +# adjust relative paths as necessary +THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" +. "${THIS_SCRIPT%/*}/../../../resources/build/builder.inc.sh" +## END STANDARD BUILD SCRIPT INCLUDE + +#. "$KEYMAN_ROOT/resources/shellHelperFunctions.sh" + +################################ Main script ################################ + +builder_describe \ + "Mnemonic layout recompiler for Linux" \ + "@/common/include" \ + "clean" \ + "configure" \ + "build" \ + "test" + +builder_parse "$@" + +builder_describe_outputs \ + configure build/build.ninja \ + build build/mcompile + +TARGET_PATH="$THIS_SCRIPT_PATH/build" + +do_clean() { + rm -rf "$THIS_SCRIPT_PATH/resources" + rm -rf "$TARGET_PATH" +} + +do_configure() { + # Import our standard compiler defines; this is copied from + # /resources/build/meson/standard.meson.build by build.sh, because meson doesn't + # allow us to reference a file outside its root + mkdir -p "$THIS_SCRIPT_PATH/resources" + cp "$KEYMAN_ROOT/resources/build/meson/standard.meson.build" "$THIS_SCRIPT_PATH/resources/meson.build" + + pushd "$THIS_SCRIPT_PATH" > /dev/null + # Additional arguments are used by Linux build, e.g. -Dprefix=${INSTALLDIR} + meson setup build --buildtype $BUILDER_CONFIGURATION "${builder_extra_params[@]}" + popd > /dev/null + +} + +do_build() { + pushd "$TARGET_PATH" > /dev/null + ninja + popd > /dev/null +} + +do_test() { + pushd "$TARGET_PATH" > /dev/null + meson test "${builder_extra_params[@]}" + popd > /dev/null +} + +builder_run_action clean do_clean +builder_run_action configure do_configure +builder_run_action build do_build +builder_run_action test do_test diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index be907df26b..8d1f5eb641 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -8,6 +8,7 @@ libxklavier = dependency('libxklavier') deps = [gtk, xkb,libxklavier] +subdir('resources') cpp_files = files( 'keymap.cpp', From dd0ea90d66129e05b4788a2ad87747591027da75 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 14 Aug 2024 11:30:08 +0200 Subject: [PATCH 314/327] feat(linux): remove local u16 and use km_u16 --- linux/mcompile/keymap/keymap.h | 2 +- linux/mcompile/keymap/meson.build | 6 +- linux/mcompile/keymap/resources/meson.build | 86 +++++ linux/mcompile/keymap/u16.cpp | 385 -------------------- linux/mcompile/keymap/u16.h | 82 ----- 5 files changed, 90 insertions(+), 471 deletions(-) create mode 100644 linux/mcompile/keymap/resources/meson.build delete mode 100644 linux/mcompile/keymap/u16.cpp delete mode 100644 linux/mcompile/keymap/u16.h diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index c8e79a8c68..11c437378d 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -13,7 +13,7 @@ #include #include #include -#include "u16.h" +#include "km_u16.h" #include enum ShiftState { diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index be907df26b..32a9f37f11 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -15,11 +15,11 @@ cpp_files = files( 'mcompile.cpp', 'mc_kmxfile.cpp', 'mc_import_rules.cpp', - 'u16.cpp',) + '../../../common/cpp/km_u16.cpp', + ) comon_include_dir = [ - include_directories('../../../common/include'), - include_directories('../../../core/src'), + include_directories('../../../common/include') ] mcompile = executable( diff --git a/linux/mcompile/keymap/resources/meson.build b/linux/mcompile/keymap/resources/meson.build new file mode 100644 index 0000000000..87efed5ab5 --- /dev/null +++ b/linux/mcompile/keymap/resources/meson.build @@ -0,0 +1,86 @@ +# +# Shared configuration for all meson-based builds +# +# This file has the master location /resources/build/meson/standard.meson.build, +# and is copied into each project's /resources/meson.build in the +# configure step, so that it can be referenced by meson directly. +# +# Where possible, we want to use these flags everywhere +# + +cpp_compiler = meson.get_compiler('cpp') +c_compiler = meson.get_compiler('c') + +# Once we can assume meson 0.60 we can delete this +# (https://mesonbuild.com/Release-notes-for-0-60-0.html#msvc-compiler-now-assumes-utf8-source-code-by-default) +if cpp_compiler.get_id() == 'msvc' + add_global_arguments('/source-charset:utf-8', language: ['c', 'cpp']) +endif + +# +# Standard informational messages for our builds +# + +message('meson.project_version(): ' + meson.project_version()) +message('host_machine.system(): ' + host_machine.system()) +message('compiler.get_id(): ' + cpp_compiler.get_id()) + +# +# Standard compiler flags for all platforms +# + +warns = [] +flags = [] +links = [] +defns = [] + +if cpp_compiler.get_id() == 'gcc' or cpp_compiler.get_id() == 'clang' + warns += [ + '-Wctor-dtor-privacy', + '-Wdouble-promotion', + '-Wendif-labels', + '-Wno-unknown-pragmas', + '-Wno-missing-field-initializers', + '-Wnon-virtual-dtor', + '-Wshadow' + ] + flags += [ + '-fvisibility=hidden', + '-fvisibility-inlines-hidden' + ] + + if cpp_compiler.get_id() == 'clang' + warns += [ + '-Wimplicit-fallthrough', + '-Wno-double-promotion', + '-Wshorten-64-to-32' + ] + endif + + if host_machine.system() == 'darwin' + # TODO: this seems to be inverting above options, is this necessary, or can + # we resolve another way? + warns += [ + '-Wno-ctor-dtor-privacy', + '-Wno-non-virtual-dtor' + ] + endif +endif + +if cpp_compiler.get_id() == 'msvc' + defns += [ + '-D_SCL_SECURE_NO_WARNINGS', + '-D_CRT_SECURE_NO_WARNINGS' + ] +endif + +if cpp_compiler.get_id() == 'emscripten' + if get_option('buildtype') == 'debug' + # Enable DWARF symbols for debug builds + flags += ['-g'] + links += ['-g'] + else + flags += ['-O2'] + links += ['-O2'] + endif +endif diff --git a/linux/mcompile/keymap/u16.cpp b/linux/mcompile/keymap/u16.cpp deleted file mode 100644 index e2604352af..0000000000 --- a/linux/mcompile/keymap/u16.cpp +++ /dev/null @@ -1,385 +0,0 @@ -/* - * Keyman is copyright 2004 - 2024 (C) SIL International. MIT License. - - * - * Functions for u16string - */ - -#include "u16.h" -#include -#include -#include -#include "utfcodec.hpp" - -/** string <- wstring - * @brief Obtain a std::string from a std::wstring - * @param wstr the std::wstring to be converted - * @return a std::string - */ -std::string string_from_wstring(std::wstring const wstr) { - return convert((const std::wstring)wstr); -} - -/** wstring <- string - * @brief Obtain a std::wstring from a std::string - * @param str the std::string to be converted - * @return a std::wstring - */ -std::wstring wstring_from_string(std::string const str) { - return convert((const std::string)str); -} - -/** u16string <- string - * @brief Obtain a std::u16string from a std::string - * @param str the std::string to be converted - * @return a std::u16string - */ -std::u16string u16string_from_string(std::string const str) { - return convert((const std::string)str); -} - -/** string <- u16string - * @brief Obtain a std::string from a std::u16string - * @param str16 the std::u16string to be converted - * @return a std::string - */ -std::string string_from_u16string(std::u16string const str16) { - return convert((const std::u16string)str16); -} - -/** wstring <- u16string - * @brief Obtain a std::wstring from a std::u16string - * @param str16 the std::u16string to be converted - * @return a std::wstring - */ -std::wstring wstring_from_u16string(std::u16string const str16) { - return convert((const std::u16string)str16); -} - -/** u16string <- wstring - * @brief Obtain a std::u16string from a std::wstring - * @param wstr the std::wstring to be converted - * @return a std::u16string - */ -std::u16string u16string_from_wstring(std::wstring const wstr) { - return convert((const std::wstring)wstr);; -} - -/** UTF16 (=const wchar_t*) -> -> std::string -> std::u16string -> UTF16 ( = char16_t*) - * @brief Convert pointer to wchar_t to pointer to char16_t and copy sz elements into dst - * @param dst destination - * @param max nr of characters to be copied - * @param fmt source to convert and copy - */ -void u16sprintf(KMX_WCHAR* dst, const size_t max, const wchar_t* fmt, ...) { - wchar_t* wbuf = new wchar_t[max]; - va_list args; - va_start(args, fmt); - vswprintf(wbuf, max, fmt, args); - va_end(args); - - std::u16string u16str = u16string_from_wstring(wbuf); - u16ncpy(dst, u16str.c_str(), max); - delete[] wbuf; -} - -/** - * @brief Convert u16string to long integer - * @param str u16string beginning with the representation of an integral number. - * @param endptr Reference to the next character in str - * @param base Numerical base (radix) that determines the valid characters and their interpretation - * @return a long - */ -long int u16tol(const KMX_WCHAR* str, KMX_WCHAR** endptr, int base) { - auto s = string_from_u16string(str); - char* t; - long int result = strtol(s.c_str(), &t, base); - if (endptr != nullptr) *endptr = (KMX_WCHAR*)str + (t - s.c_str()); - return result; -} - -/** - * @brief Append max characters from u16string - * @param dst Pointer to the destination array - * @param src u16string to be appended - * @param max Maximum number of characters to be appended. - * @return Pointer to dst - */ -const KMX_WCHAR* u16ncat(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max) { - KMX_WCHAR* o = dst; - dst = (KMX_WCHAR*)u16chr(dst, 0); - //max -= (dst-o); - while (*src && max > 0) { - *dst++ = *src++; - max--; - } - if (max > 0) - *dst = 0; - return o; -} - -/** - * @brief Find last '/' or '\\' in an array of char16_t - * @param name Pointer to the source - * @return Pointer to the last slash/backslash - */ -const KMX_WCHAR* u16rchr_slash(KMX_WCHAR const* name) { - const KMX_WCHAR* cp = NULL; - cp = u16rchr(name, '\\'); - if (cp == NULL) - cp = u16rchr(name, '/'); - return cp; -} - -/** - * @brief Find last '/' or '\\' in an array of char - * @param name Pointer to the source - * @return Pointer to the last slash/backslash - */ -KMX_CHAR* strrchr_slash(KMX_CHAR* name) { - KMX_CHAR* cp = NULL; - cp = strrchr(name, '\\'); - if (cp == NULL) - cp = strrchr(name, '/'); - return cp; -} - -/** - * @brief Locate last occurrence of character in u16string - * @param p Pointer to the source - * @param ch The character to be found - * @return A pointer to the last occurrence of character in u16str - */ -const KMX_WCHAR* u16rchr(const KMX_WCHAR* p, KMX_WCHAR ch) { - const KMX_WCHAR* p_end = p + u16len(p); - - while (p_end >= p) { - if (*p_end == ch) - return p_end; - p_end--; - } - return NULL; -} - -/** - * @brief Locate first occurrence of character in u16string - * @param p Pointer to the source - * @param ch The character to be found - * @return A pointer to the first occurrence of character in u16str - */ -const KMX_WCHAR* u16chr(const KMX_WCHAR* p, KMX_WCHAR ch) { - while (*p) { - if (*p == ch) return p; - p++; - } - return ch == 0 ? p : NULL; -} - -/** - * @brief Copy the u16string pointed to by scr into the array pointed to by dst - * @param dst Pointer to the destination - * @param src Pointer to the source to be copied - * @return Pointer to dst - */ -const KMX_WCHAR* u16cpy(KMX_WCHAR* dst, const KMX_WCHAR* src) { - KMX_WCHAR* o = dst; - while (*src) { - *dst++ = *src++; - } - *dst = 0; - return o; -} - -/** - * @brief Copy max characters of the u16string pointed to by src into the array pointed by dst - * @param dst Pointer to the destination - * @param src Pointer to the source to be copied - * @param max Maximum number of characters to be copied - * @return Pointer to dst - */ -const KMX_WCHAR* u16ncpy(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max) { - KMX_WCHAR* o = dst; - while (*src && max > 0) { - *dst++ = *src++; - max--; - } - if (max > 0) { - *dst = 0; - } - return o; -} - -/** - * @brief Return the length of the u16string str - * @param p Pointer to the source - * @return The length of u16string - */ -size_t u16len(const KMX_WCHAR* p) { - int i = 0; - while (*p) { - p++; - i++; - } - return i; -} - -/** - * @brief Compare two u16strings - * @param p Pointer one u16string - * @param q Pointer another u16string - * @return 0 if strings are equal - * ! = 0 if unequal - */ -int u16cmp(const KMX_WCHAR* p, const KMX_WCHAR* q) { - while (*p && *q) { - if (*p != *q) return *p - *q; - p++; - q++; - } - return *p - *q; -} - -/** - * @brief Case insensitive comparison of up to count characters in two strings - * @param p Pointer one u16string - * @param q Pointer another u16string - * @param count Maximum number of characters to compare - * @return 0 if strings are equal - * ! = 0 if unequal - */ -int u16nicmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count) { - while (*p && *q && count) { - if (toupper(*p) != toupper(*q)) - return *p - *q; - p++; - q++; - count--; - } - if (count) - return *p - *q; - return 0; -} - -/** - * @brief Case insensitive comparison of two strings - * @param p Pointer one u16string - * @param q Pointer another u16string - * @return 0 if strings are equal - * ! = 0 if unequal - */ -int u16icmp(const KMX_WCHAR* p, const KMX_WCHAR* q) { - while (*p && *q) { - if (toupper(*p) != toupper(*q)) - return *p - *q; - p++; - q++; - } - return *p - *q; -} - -/** - * @brief Comparison of up to count characters in two strings - * @param p Pointer one u16string - * @param q Pointer another u16string - * @param count Maximum number of characters to compare - * @return 0 if strings are equal - * ! = 0 if unequal - */ -int u16ncmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count) { - while (*p && *q && count) { - if (*p != *q) return *p - *q; - p++; - q++; - count--; - } - if (count) - return *p - *q; - return 0; -} - -/** - * @brief Split u16string into tokens - * @param p Pointer to u16string to parse. - * @param ch the delimiter character - * @param ctx the remaining string after the first delimiter - * @return Pointer to the first token in p - */ -KMX_WCHAR* u16tok(KMX_WCHAR* p, const KMX_WCHAR ch, KMX_WCHAR** ctx) { - if (!p) { - p = *ctx; - if (!p) - return NULL; - } - KMX_WCHAR* q = p; - while (*q && *q != ch) { - q++; - } - if (*q) { - *q = 0; - q++; - while (*q == ch) - q++; - *ctx = q; - } else { - *ctx = NULL; - } - return *p ? p : NULL; -} - -/** - * @brief Split u16string into tokens - * @param p Pointer to u16string to parse. - * @param delimiters an array of delimiter characters - * @param ctx the remaining string after the first delimiter - * @return Pointer to the first token in p - */ -KMX_WCHAR* u16tok(KMX_WCHAR* p, const KMX_WCHAR* delimiters, KMX_WCHAR** ctx) { - if (!p) { - p = *ctx; - if (!p) - return NULL; - } - - KMX_WCHAR* q = p; - while (*q && !u16chr(delimiters, *q)) { - q++; - } - if (*q) { - *q = 0; - q++; - while (*q && u16chr(delimiters, *q)) - q++; - *ctx = q; - } else { - *ctx = NULL; - } - return *p ? p : NULL; -} - -/** - * @brief Convert a u16string to a double - * @param str Pointer to u16string - * @return double value equivalent to the string - */ -double u16tof(KMX_WCHAR* str) { - double val = 0; - int offsetdot = 0; - char digit; - - PKMX_WCHAR q = (PKMX_WCHAR)u16chr(str, '.'); - size_t pos_dot = (q - str < 0) ? u16len(str) : q - str; - - for (size_t i = 0; i < u16len(str); i++) { - digit = static_cast(towupper(*str)); - - if (i > pos_dot - 1) - offsetdot = 1; - - if (digit != '.') - val = val + ((int(digit)) - 48) * pow(10, (pos_dot - 1 - i + offsetdot)); - - - str++; - } - return val; -} diff --git a/linux/mcompile/keymap/u16.h b/linux/mcompile/keymap/u16.h deleted file mode 100644 index 11c1fc8c90..0000000000 --- a/linux/mcompile/keymap/u16.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef U16_H -#define U16_H -#pragma once - -#include "km_types.h" -#include -#include -#include -#include -#include -#include - -/** @brief Obtain a std::string from a std::wstring */ -std::string string_from_wstring(std::wstring const wstr); - -/** @brief Obtain a std::wstring from a std::string */ -std::wstring wstring_from_string(std::string const str); - -/** @brief Obtain a std::u16string from a std::string */ -std::u16string u16string_from_string(std::string const str); - -/** @brief Obtain a std::string from a std::u16string */ -std::string string_from_u16string(std::u16string const str16); - -/** @brief Obtain a std::wstring from a std::u16string */ -std::wstring wstring_from_u16string(std::u16string const str16); - -/** @brief Obtain a std::u16string from a std::wstring */ -std::u16string u16string_from_wstring(std::wstring const wstr); - -/** @brief Convert pointer to wchar_t to pointer to char16_t and copy sz elements into dst */ -void u16sprintf(KMX_WCHAR* dst, const size_t sz, const wchar_t* fmt, ...); - -/** @brief Convert u16string to long integer */ -long int u16tol(const KMX_WCHAR* str, KMX_WCHAR** endptr, int base); - -/** @brief Append max characters from u16string */ -const KMX_WCHAR* u16ncat(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max); - -/** @brief find last '/' or '\\' in an array of char16_t */ -const KMX_WCHAR* u16rchr_slash(KMX_WCHAR const* name); - -/** @brief find last '/' or '\\' in an array of char */ -KMX_CHAR* strrchr_slash(KMX_CHAR* name); - -/** @brief Locate last occurrence of character in u16string */ -const KMX_WCHAR* u16rchr(const KMX_WCHAR* p, KMX_WCHAR ch); - -/** @brief Locate first occurrence of character in u16string */ -const KMX_WCHAR* u16chr(const KMX_WCHAR* p, KMX_WCHAR ch); - -/** @brief Copy the u16string pointed to by src into the array pointed to by dst */ -const KMX_WCHAR* u16cpy(KMX_WCHAR* dst, const KMX_WCHAR* src); - -/** @brief Copy max characters of the u16string pointed to by src into the array pointed to by dst */ -const KMX_WCHAR* u16ncpy(KMX_WCHAR* dst, const KMX_WCHAR* src, size_t max); - -/** @brief Return the length of the u16string str */ -size_t u16len(const KMX_WCHAR* p); - -/** @brief Compare two u16strings */ -int u16cmp(const KMX_WCHAR* p, const KMX_WCHAR* q); - -/** @brief Case insensitive comparison of up to count characters in two strings */ -int u16nicmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count); - -/** @brief Case insensitive comparison of two strings */ -int u16icmp(const KMX_WCHAR* p, const KMX_WCHAR* q); - -/** @brief Comparison of up to count characters in two strings */ -int u16ncmp(const KMX_WCHAR* p, const KMX_WCHAR* q, size_t count); - -/** @brief Split u16string into tokens */ -KMX_WCHAR* u16tok(KMX_WCHAR* p, const KMX_WCHAR ch, KMX_WCHAR** ctx); - -/** @brief Split u16string into tokens */ -KMX_WCHAR* u16tok(KMX_WCHAR* p, const KMX_WCHAR* delimiters, KMX_WCHAR** ctx); - -/** @brief Convert a u16string to a double */ -double u16tof(KMX_WCHAR* str); - -#endif /* U16_H */ From 816175f9bfb24bf2443f9235bb556d941238793b Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 14 Aug 2024 11:43:41 +0200 Subject: [PATCH 315/327] refactor(linux): remove meson.build --- linux/mcompile/keymap/resources/meson.build | 86 --------------------- 1 file changed, 86 deletions(-) delete mode 100644 linux/mcompile/keymap/resources/meson.build diff --git a/linux/mcompile/keymap/resources/meson.build b/linux/mcompile/keymap/resources/meson.build deleted file mode 100644 index 87efed5ab5..0000000000 --- a/linux/mcompile/keymap/resources/meson.build +++ /dev/null @@ -1,86 +0,0 @@ -# -# Shared configuration for all meson-based builds -# -# This file has the master location /resources/build/meson/standard.meson.build, -# and is copied into each project's /resources/meson.build in the -# configure step, so that it can be referenced by meson directly. -# -# Where possible, we want to use these flags everywhere -# - -cpp_compiler = meson.get_compiler('cpp') -c_compiler = meson.get_compiler('c') - -# Once we can assume meson 0.60 we can delete this -# (https://mesonbuild.com/Release-notes-for-0-60-0.html#msvc-compiler-now-assumes-utf8-source-code-by-default) -if cpp_compiler.get_id() == 'msvc' - add_global_arguments('/source-charset:utf-8', language: ['c', 'cpp']) -endif - -# -# Standard informational messages for our builds -# - -message('meson.project_version(): ' + meson.project_version()) -message('host_machine.system(): ' + host_machine.system()) -message('compiler.get_id(): ' + cpp_compiler.get_id()) - -# -# Standard compiler flags for all platforms -# - -warns = [] -flags = [] -links = [] -defns = [] - -if cpp_compiler.get_id() == 'gcc' or cpp_compiler.get_id() == 'clang' - warns += [ - '-Wctor-dtor-privacy', - '-Wdouble-promotion', - '-Wendif-labels', - '-Wno-unknown-pragmas', - '-Wno-missing-field-initializers', - '-Wnon-virtual-dtor', - '-Wshadow' - ] - flags += [ - '-fvisibility=hidden', - '-fvisibility-inlines-hidden' - ] - - if cpp_compiler.get_id() == 'clang' - warns += [ - '-Wimplicit-fallthrough', - '-Wno-double-promotion', - '-Wshorten-64-to-32' - ] - endif - - if host_machine.system() == 'darwin' - # TODO: this seems to be inverting above options, is this necessary, or can - # we resolve another way? - warns += [ - '-Wno-ctor-dtor-privacy', - '-Wno-non-virtual-dtor' - ] - endif -endif - -if cpp_compiler.get_id() == 'msvc' - defns += [ - '-D_SCL_SECURE_NO_WARNINGS', - '-D_CRT_SECURE_NO_WARNINGS' - ] -endif - -if cpp_compiler.get_id() == 'emscripten' - if get_option('buildtype') == 'debug' - # Enable DWARF symbols for debug builds - flags += ['-g'] - links += ['-g'] - else - flags += ['-O2'] - links += ['-O2'] - endif -endif From 2041b54abb009b4bc21cf3a9c2f9b2474f874315 Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Wed, 14 Aug 2024 12:51:48 +0200 Subject: [PATCH 316/327] fix(web): allow `lm-worker` to build on Linux Linux' file system is case-sensitive. This change fixes building `lm-worker` on case-sensitive systems. --- common/web/lm-worker/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/web/lm-worker/build.sh b/common/web/lm-worker/build.sh index 22ffa9208c..0343d151c8 100755 --- a/common/web/lm-worker/build.sh +++ b/common/web/lm-worker/build.sh @@ -98,7 +98,7 @@ function do_test() { if builder_has_option --ci; then MOCHA_FLAGS="$MOCHA_FLAGS --reporter mocha-teamcity-reporter" - WTR_CONFIG=.ci + WTR_CONFIG=.CI fi if builder_has_option --debug; then From cd901a7f6da7a928a93a445d64b1cf75631095fe Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Wed, 14 Aug 2024 13:45:14 +0200 Subject: [PATCH 317/327] docs: update .kmx documentation around bitmaps, modifier state Addresses: keymanapp/keyman#12163#issuecomment-2287675497 --- docs/file-formats/kmx-file-format.md | 58 +++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/docs/file-formats/kmx-file-format.md b/docs/file-formats/kmx-file-format.md index 6de14df56f..67288bc123 100644 --- a/docs/file-formats/kmx-file-format.md +++ b/docs/file-formats/kmx-file-format.md @@ -44,12 +44,14 @@ The very first section is a header that describes the remainder of the file. |44 | 32 | `StartGroup_Unicode` | index of starting Unicode `COMP_GROUP`, `0xFFFFFFFF` means unused | |48 | 32 | `dwFlags` | global flags for the keyboard, see description below | |52 | 32 | `dwHotKey` | default hotkey for keyboard, from [`&Hotkey`], see description below | -|56 | 32 | `dpBitmapOffset` | offset of keyboard icon, `0x0` if not present | +|56 | 32 | `dpBitmapOffset` | offset of keyboard icon | |60 | 32 | `dwBitmapSize` | size in bytes of keyboard icon, `0x0` if not present | This structure is present at the start of every .kmx file. The `KXTS` identifier can be used as a 'magic' to determine whether a binary file is a .kmx file. +Note that `dpBitmapOffset` should be ignored if `dwBitmapSize` is `0x0` -- it may be a non-zero value. + ### `dwFileVersion`: Minimum version of Keyman required to read the file The `dwFileVersion` property should be checked before attempting to read any @@ -220,7 +222,7 @@ file and is never written to the binary format. | ∆ | Bits | Name | Description | |----|------|--------------|------------------------------------------------------------------------------------------------| -| 0 | 16 | `Key` | Keyman virtual key for the rule, 0 if unused | +| 0 | 16 | `Key` | [Keyman virtual key], virtual character key, or character, for the rule, 0 if unused | | 2 | 16 | (unused) | padding, reserved | | 4 | 32 | `Line` | Line number for the rule, 0 if not compiled with debug information | | 8 | 32 | `ShiftFlags` | Modifier flags for the key, see description below | @@ -232,6 +234,58 @@ compiler expands `any()` statements found in the key part of a rule into multiple rules -- so the key part of the rule is always only ever matching a single key combination. +`ShiftFlags` contains a set of modifier and state key flags, and some additional +flags that determine how to interpret `Key`. + +### Modifier and state key flags + +The modifier and state key flags are: + +| Bit mask | Name | Description | +|--------------|------------------|-----------------------------------------------------------| +| `0x00000001` | `LCTRLFLAG` | Left Control key | +| `0x00000002` | `RCTRLFLAG` | Right Control key | +| `0x00000004` | `LALTFLAG` | Left Alt key (Option on macOS) | +| `0x00000008` | `RALTFLAG` | Right Alt key | +| `0x00000010` | `K_SHIFTFLAG` | Either Shift key | +| `0x00000020` | `K_CTRLFLAG` | Either Ctrl key | +| `0x00000040` | `K_ALTFLAG` | Either Alt key | +| `0x00000080` | `K_METAFLAG` | Either Meta key. Reserved, not for use in .kmx | +| `0x00000100` | `CAPITALFLAG` | Caps lock on | +| `0x00000200` | `NOTCAPITALFLAG` | Caps lock NOT on | +| `0x00000400` | `NUMLOCKFLAG` | Num lock on | +| `0x00000800` | `NOTNUMLOCKFLAG` | Num lock NOT on | +| `0x00001000` | `SCROLLFLAG` | Scroll lock on | +| `0x00002000` | `NOTSCROLLFLAG` | Scroll lock NOT on | + +* The chiral (left/right) modifier flags should not be used together with the + non-chiral flags. +* If neither `CAPITALFLAG` nor `NOTCAPITALFLAG` are set, then the state of the + Caps Lock key is ignored, and the same principle applies for Num lock and + Scroll lock. +* The Meta key may be the Windows key on Windows, or the + Command key on macOS. This flag is reserved for internal use, and + is not valid in a .kmx file. + +### Additional flags + +The meaning of `Key` is determined by the flags `ISVIRTUALKEY` and +`VIRTUALCHARKEY` in `ShiftFlags` (mask `0x0000C000`): + +* `0`: `Key` is a character on a key cap (US English unless the keyboard is a + mnemonic layout). All other shift flags are ignord +* `ISVIRTUALKEY`: `Key` is a US English virtual key +* `VIRTUALCHARKEY`: `Key` is a character on a key cap, combined with the shift + flags (US English unless the keyboard is a mnemonic layout) + +| Bit mask | Name | Description | +|--------------|------------------|-----------------------------------------------| +| `0x00004000` | `ISVIRTUALKEY` | `Key` is a virtual key | +| `0x00008000` | `VIRTUALCHARKEY` | Keyman 6.0+: `Key` is a Virtual character key | + +Note that the shift flags for key rules do not use the same values as hotkeys +for historical reasons. + ## Debug information for keyboards When debug information is present, it will be found in four places in compiled From 7459ab0bf849a6ff5a5cd6d45d4857edc0b8422b Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Wed, 14 Aug 2024 17:23:52 +0200 Subject: [PATCH 318/327] refactor(web): move tests Some tests test functionality defined in `js-processor`, so we move these to the appropriate location. Addresses code review comments. --- web/src/engine/js-processor/build.sh | 7 +- .../basic-engine.js | 0 .../{keyboard => js-processor}/basic-init.js | 0 .../bundled-module.js | 26 ++++-- .../{keyboard => js-processor}/chirality.js | 0 .../{keyboard => js-processor}/deadkeys.js | 0 .../engine/context.js | 0 .../engine/notany_context.js | 0 .../engine/stores.js | 0 .../engine/unmatched_final_group.js | 0 .../engine/js-processor/kbdInterface.tests.js | 91 +++++++++++++++++++ .../{keyboard => js-processor}/mocks.js | 0 .../non-positional-rules.js | 0 .../specialized-backspace.js | 0 .../transcriptions.js | 0 .../engine/keyboard/keyboard-loading.js | 74 +-------------- .../main/headless/inputProcessor.spec.js | 2 +- .../main/headless/languageProcessor.spec.js | 2 +- 18 files changed, 117 insertions(+), 85 deletions(-) rename web/src/test/auto/headless/engine/{keyboard => js-processor}/basic-engine.js (100%) rename web/src/test/auto/headless/engine/{keyboard => js-processor}/basic-init.js (100%) rename web/src/test/auto/headless/engine/{keyboard => js-processor}/bundled-module.js (71%) rename web/src/test/auto/headless/engine/{keyboard => js-processor}/chirality.js (100%) rename web/src/test/auto/headless/engine/{keyboard => js-processor}/deadkeys.js (100%) rename web/src/test/auto/headless/engine/{keyboard => js-processor}/engine/context.js (100%) rename web/src/test/auto/headless/engine/{keyboard => js-processor}/engine/notany_context.js (100%) rename web/src/test/auto/headless/engine/{keyboard => js-processor}/engine/stores.js (100%) rename web/src/test/auto/headless/engine/{keyboard => js-processor}/engine/unmatched_final_group.js (100%) create mode 100644 web/src/test/auto/headless/engine/js-processor/kbdInterface.tests.js rename web/src/test/auto/headless/engine/{keyboard => js-processor}/mocks.js (100%) rename web/src/test/auto/headless/engine/{keyboard => js-processor}/non-positional-rules.js (100%) rename web/src/test/auto/headless/engine/{keyboard => js-processor}/specialized-backspace.js (100%) rename web/src/test/auto/headless/engine/{keyboard => js-processor}/transcriptions.js (100%) diff --git a/web/src/engine/js-processor/build.sh b/web/src/engine/js-processor/build.sh index 57adbd1dd2..db00593166 100755 --- a/web/src/engine/js-processor/build.sh +++ b/web/src/engine/js-processor/build.sh @@ -36,6 +36,7 @@ do_build () { --format esm } -builder_run_action configure verify_npm_setup -builder_run_action clean rm -rf "${KEYMAN_ROOT}/web/build/${SUBPROJECT_NAME}" -builder_run_action build do_build +builder_run_action configure verify_npm_setup +builder_run_action clean rm -rf "${KEYMAN_ROOT}/web/build/${SUBPROJECT_NAME}" +builder_run_action build do_build +builder_run_action test test-headless "${SUBPROJECT_NAME}" "" diff --git a/web/src/test/auto/headless/engine/keyboard/basic-engine.js b/web/src/test/auto/headless/engine/js-processor/basic-engine.js similarity index 100% rename from web/src/test/auto/headless/engine/keyboard/basic-engine.js rename to web/src/test/auto/headless/engine/js-processor/basic-engine.js diff --git a/web/src/test/auto/headless/engine/keyboard/basic-init.js b/web/src/test/auto/headless/engine/js-processor/basic-init.js similarity index 100% rename from web/src/test/auto/headless/engine/keyboard/basic-init.js rename to web/src/test/auto/headless/engine/js-processor/basic-init.js diff --git a/web/src/test/auto/headless/engine/keyboard/bundled-module.js b/web/src/test/auto/headless/engine/js-processor/bundled-module.js similarity index 71% rename from web/src/test/auto/headless/engine/keyboard/bundled-module.js rename to web/src/test/auto/headless/engine/js-processor/bundled-module.js index cfc54480b6..a6b80d5004 100644 --- a/web/src/test/auto/headless/engine/keyboard/bundled-module.js +++ b/web/src/test/auto/headless/engine/js-processor/bundled-module.js @@ -1,5 +1,6 @@ import { assert } from "chai"; -import * as Package from "keyman/engine/keyboard"; +import * as Package from "keyman/engine/js-processor"; +import * as Package2 from "keyman/engine/keyboard"; // A few small tests to ensure that the ES Module bundle was successfully constructed and is usable. @@ -12,10 +13,10 @@ var toSupplementaryPairString = function(code){ let u = toSupplementaryPairString; -describe('Bundled ES Module', function() { - describe('Keyboard', function () { +describe('Bundled ES Module for js-processor', function() { + describe('KeyboardProcessor', function () { it('should initialize without errors', function () { - let kp = new Package.Keyboard(); + let kp = new Package.KeyboardProcessor(); assert.isNotNull(kp); }); }); @@ -40,11 +41,20 @@ describe('Bundled ES Module', function() { } }); }); +}); - describe("Imported `utils`", function() { +describe('Bundled ES Module for keyboard', function () { + describe('Keyboard', function () { + it('should initialize without errors', function () { + let kp = new Package2.Keyboard(); + assert.isNotNull(kp); + }); + }); + + describe("Imported `utils`", function () { it("should include `utils` package's Version class", () => { - let v16 = new Package.Version([16, 1]); + let v16 = new Package2.Version([16, 1]); assert.equal(v16.toString(), "16.1"); }); - }) -}); \ No newline at end of file + }); +}); diff --git a/web/src/test/auto/headless/engine/keyboard/chirality.js b/web/src/test/auto/headless/engine/js-processor/chirality.js similarity index 100% rename from web/src/test/auto/headless/engine/keyboard/chirality.js rename to web/src/test/auto/headless/engine/js-processor/chirality.js diff --git a/web/src/test/auto/headless/engine/keyboard/deadkeys.js b/web/src/test/auto/headless/engine/js-processor/deadkeys.js similarity index 100% rename from web/src/test/auto/headless/engine/keyboard/deadkeys.js rename to web/src/test/auto/headless/engine/js-processor/deadkeys.js diff --git a/web/src/test/auto/headless/engine/keyboard/engine/context.js b/web/src/test/auto/headless/engine/js-processor/engine/context.js similarity index 100% rename from web/src/test/auto/headless/engine/keyboard/engine/context.js rename to web/src/test/auto/headless/engine/js-processor/engine/context.js diff --git a/web/src/test/auto/headless/engine/keyboard/engine/notany_context.js b/web/src/test/auto/headless/engine/js-processor/engine/notany_context.js similarity index 100% rename from web/src/test/auto/headless/engine/keyboard/engine/notany_context.js rename to web/src/test/auto/headless/engine/js-processor/engine/notany_context.js diff --git a/web/src/test/auto/headless/engine/keyboard/engine/stores.js b/web/src/test/auto/headless/engine/js-processor/engine/stores.js similarity index 100% rename from web/src/test/auto/headless/engine/keyboard/engine/stores.js rename to web/src/test/auto/headless/engine/js-processor/engine/stores.js diff --git a/web/src/test/auto/headless/engine/keyboard/engine/unmatched_final_group.js b/web/src/test/auto/headless/engine/js-processor/engine/unmatched_final_group.js similarity index 100% rename from web/src/test/auto/headless/engine/keyboard/engine/unmatched_final_group.js rename to web/src/test/auto/headless/engine/js-processor/engine/unmatched_final_group.js diff --git a/web/src/test/auto/headless/engine/js-processor/kbdInterface.tests.js b/web/src/test/auto/headless/engine/js-processor/kbdInterface.tests.js new file mode 100644 index 0000000000..03203a840f --- /dev/null +++ b/web/src/test/auto/headless/engine/js-processor/kbdInterface.tests.js @@ -0,0 +1,91 @@ +import { assert } from 'chai'; + +import { createRequire } from 'module'; +const require = createRequire(import.meta.url); + +import { MinimalKeymanGlobal, Mock } from 'keyman/engine/keyboard'; +import { KeyboardInterface } from 'keyman/engine/js-processor'; +import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader'; + +describe('Headless keyboard loading', function () { + const laoPath = require.resolve('@keymanapp/common-test-resources/keyboards/lao_2008_basic.js'); + const khmerPath = require.resolve('@keymanapp/common-test-resources/keyboards/khmer_angkor.js'); + const nonKeyboardPath = require.resolve('@keymanapp/common-test-resources/index.mjs'); + const ipaPath = require.resolve('@keymanapp/common-test-resources/keyboards/sil_ipa.js'); + // Common test suite setup. + + let device = { + formFactor: 'desktop', + OS: 'windows', + browser: 'native' + } + + describe('Full harness loading', () => { + it('successfully loads', async function () { + // -- START: Standard Recorder-based unit test loading boilerplate -- + let harness = new KeyboardInterface({}, MinimalKeymanGlobal); + let keyboardLoader = new NodeKeyboardLoader(harness); + let keyboard = await keyboardLoader.loadKeyboardFromPath(laoPath); + harness.activeKeyboard = keyboard; + // -- END: Standard Recorder-based unit test loading boilerplate -- + + // This part provides assurance that the keyboard properly loaded. + assert.equal(keyboard.id, "Keyboard_lao_2008_basic"); + }); + + it('can evaluate rules', async function () { + // -- START: Standard Recorder-based unit test loading boilerplate -- + let harness = new KeyboardInterface({}, MinimalKeymanGlobal); + let keyboardLoader = new NodeKeyboardLoader(harness); + let keyboard = await keyboardLoader.loadKeyboardFromPath(laoPath); + harness.activeKeyboard = keyboard; + // -- END: Standard Recorder-based unit test loading boilerplate -- + + // Runs a blank KeyEvent through the keyboard's rule processing. + harness.processKeystroke(new Mock(), keyboard.constructNullKeyEvent(device)); + }); + + it('does not change the active kehboard', async function () { + let harness = new KeyboardInterface({}, MinimalKeymanGlobal); + let keyboardLoader = new NodeKeyboardLoader(harness); + const lao_keyboard = await keyboardLoader.loadKeyboardFromPath(laoPath); + assert.isNotOk(harness.activeKeyboard); + assert.isOk(lao_keyboard); + + // This part provides assurance that the keyboard properly loaded. + assert.equal(lao_keyboard.id, "Keyboard_lao_2008_basic"); + + harness.activeKeyboard = lao_keyboard; + + const khmer_keyboard = await keyboardLoader.loadKeyboardFromPath(khmerPath); + assert.strictEqual(lao_keyboard, harness.activeKeyboard); + + assert.equal(khmer_keyboard.id, "Keyboard_khmer_angkor"); + }); + + it('throws distinct errors', async function () { + const invalidPath = 'totally_invalid_path.js'; + + let harness = new KeyboardInterface({}, MinimalKeymanGlobal); + let keyboardLoader = new NodeKeyboardLoader(harness); + let missingError; + try { + await keyboardLoader.loadKeyboardFromPath(invalidPath); + } catch (err) { + missingError = err; + } + assert.isOk(missingError); + + let scriptLoadError; + try { + await keyboardLoader.loadKeyboardFromPath(nonKeyboardPath); + } catch (err) { + scriptLoadError = err; + } + assert.isOk(scriptLoadError); + + // The main test: do the errors match? + assert.notEqual(scriptLoadError.message, missingError.message); + }); + }) +}); diff --git a/web/src/test/auto/headless/engine/keyboard/mocks.js b/web/src/test/auto/headless/engine/js-processor/mocks.js similarity index 100% rename from web/src/test/auto/headless/engine/keyboard/mocks.js rename to web/src/test/auto/headless/engine/js-processor/mocks.js diff --git a/web/src/test/auto/headless/engine/keyboard/non-positional-rules.js b/web/src/test/auto/headless/engine/js-processor/non-positional-rules.js similarity index 100% rename from web/src/test/auto/headless/engine/keyboard/non-positional-rules.js rename to web/src/test/auto/headless/engine/js-processor/non-positional-rules.js diff --git a/web/src/test/auto/headless/engine/keyboard/specialized-backspace.js b/web/src/test/auto/headless/engine/js-processor/specialized-backspace.js similarity index 100% rename from web/src/test/auto/headless/engine/keyboard/specialized-backspace.js rename to web/src/test/auto/headless/engine/js-processor/specialized-backspace.js diff --git a/web/src/test/auto/headless/engine/keyboard/transcriptions.js b/web/src/test/auto/headless/engine/js-processor/transcriptions.js similarity index 100% rename from web/src/test/auto/headless/engine/keyboard/transcriptions.js rename to web/src/test/auto/headless/engine/js-processor/transcriptions.js diff --git a/web/src/test/auto/headless/engine/keyboard/keyboard-loading.js b/web/src/test/auto/headless/engine/keyboard/keyboard-loading.js index 6152f1b0de..1dc2baad9b 100644 --- a/web/src/test/auto/headless/engine/keyboard/keyboard-loading.js +++ b/web/src/test/auto/headless/engine/keyboard/keyboard-loading.js @@ -1,5 +1,4 @@ import { assert } from 'chai'; -import fs from 'fs'; import { createRequire } from 'module'; const require = createRequire(import.meta.url); @@ -41,7 +40,7 @@ describe('Headless keyboard loading', function() { it('successfully loads (has variable stores)', async () => { // -- START: Standard Recorder-based unit test loading boilerplate -- - let harness = new KeyboardInterface({}, MinimalKeymanGlobal); + let harness = new KeyboardHarness({}, MinimalKeymanGlobal); let keyboardLoader = new NodeKeyboardLoader(harness); let keyboard = await keyboardLoader.loadKeyboardFromPath(ipaPath); // -- END: Standard Recorder-based unit test loading boilerplate -- @@ -92,73 +91,4 @@ describe('Headless keyboard loading', function() { assert.isFalse(mobileLayout.hasMultitaps); }); }); - - describe('Full harness loading', () => { - it('successfully loads', async function() { - // -- START: Standard Recorder-based unit test loading boilerplate -- - let harness = new KeyboardInterface({}, MinimalKeymanGlobal); - let keyboardLoader = new NodeKeyboardLoader(harness); - let keyboard = await keyboardLoader.loadKeyboardFromPath(laoPath); - harness.activeKeyboard = keyboard; - // -- END: Standard Recorder-based unit test loading boilerplate -- - - // This part provides assurance that the keyboard properly loaded. - assert.equal(keyboard.id, "Keyboard_lao_2008_basic"); - }); - - it('can evaluate rules', async function() { - // -- START: Standard Recorder-based unit test loading boilerplate -- - let harness = new KeyboardInterface({}, MinimalKeymanGlobal); - let keyboardLoader = new NodeKeyboardLoader(harness); - let keyboard = await keyboardLoader.loadKeyboardFromPath(laoPath); - harness.activeKeyboard = keyboard; - // -- END: Standard Recorder-based unit test loading boilerplate -- - - // Runs a blank KeyEvent through the keyboard's rule processing. - harness.processKeystroke(new Mock(), keyboard.constructNullKeyEvent(device)); - }); - - it('does not change the active kehboard', async function() { - let harness = new KeyboardInterface({}, MinimalKeymanGlobal); - let keyboardLoader = new NodeKeyboardLoader(harness); - const lao_keyboard = await keyboardLoader.loadKeyboardFromPath(laoPath); - assert.isNotOk(harness.activeKeyboard); - assert.isOk(lao_keyboard); - - // This part provides assurance that the keyboard properly loaded. - assert.equal(lao_keyboard.id, "Keyboard_lao_2008_basic"); - - harness.activeKeyboard = lao_keyboard; - - const khmer_keyboard = await keyboardLoader.loadKeyboardFromPath(khmerPath); - assert.strictEqual(lao_keyboard, harness.activeKeyboard); - - assert.equal(khmer_keyboard.id, "Keyboard_khmer_angkor"); - }); - - it('throws distinct errors', async function() { - const invalidPath = 'totally_invalid_path.js'; - - let harness = new KeyboardInterface({}, MinimalKeymanGlobal); - let keyboardLoader = new NodeKeyboardLoader(harness); - let missingError; - try { - await keyboardLoader.loadKeyboardFromPath(invalidPath); - } catch (err) { - missingError = err; - } - assert.isOk(missingError); - - let scriptLoadError; - try { - await keyboardLoader.loadKeyboardFromPath(nonKeyboardPath); - } catch (err) { - scriptLoadError = err; - } - assert.isOk(scriptLoadError); - - // The main test: do the errors match? - assert.notEqual(scriptLoadError.message, missingError.message); - }); - }) -}); \ No newline at end of file +}); diff --git a/web/src/test/auto/headless/engine/main/headless/inputProcessor.spec.js b/web/src/test/auto/headless/engine/main/headless/inputProcessor.spec.js index f3f6622f9a..56aa2f3e5e 100644 --- a/web/src/test/auto/headless/engine/main/headless/inputProcessor.spec.js +++ b/web/src/test/auto/headless/engine/main/headless/inputProcessor.spec.js @@ -49,7 +49,7 @@ describe('InputProcessor', function() { assert.isUndefined(core.activeModel); // Same for the model. // These checks are lifted from the keyboard init checks found in - // common/web/keyboard/tests/cases/basic-init.js. + // web/src/test/auto/headless/engine/js-processor/basic-init.js. assert.equal('us', core.keyboardProcessor.baseLayout, 'KeyboardProcessor has unexpected base layout') assert.isNotNull(global.KeymanWeb, 'KeymanWeb global was not automatically installed'); assert.equal('default', core.keyboardProcessor.layerId, 'Default layer is not set to "default"'); diff --git a/web/src/test/auto/headless/engine/main/headless/languageProcessor.spec.js b/web/src/test/auto/headless/engine/main/headless/languageProcessor.spec.js index 6f2f321edf..e4572de21d 100644 --- a/web/src/test/auto/headless/engine/main/headless/languageProcessor.spec.js +++ b/web/src/test/auto/headless/engine/main/headless/languageProcessor.spec.js @@ -44,7 +44,7 @@ describe('LanguageProcessor', function() { let languageProcessor = new LanguageProcessor(worker, new TranscriptionCache()); // These checks are lifted from the keyboard init checks found in - // engine/keyboard/tests/cases/basic-init.js. + // web/src/test/auto/headless/engine/js-processor/basic-init.js. assert.isDefined(languageProcessor.lmEngine); assert.isUndefined(languageProcessor.activeModel); assert.isFalse(languageProcessor.isActive); From 89abdbd64c8555bdba88ded14925d2607da653bc Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Wed, 14 Aug 2024 18:13:01 +0200 Subject: [PATCH 319/327] refactor(web): move some files around MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - move `outputTarget.ts` → `js-processor` - move `deadkeys.ts` → `js-processor` - move `stringDivergence.ts` → `js-processor` - split `Mock` into `mock.ts` - create `keyboard/outputTarget.interface.ts` --- web/README.md | 2 +- web/src/app/browser/src/configuration.ts | 3 +- .../app/browser/src/defaultBrowserRules.ts | 4 +- web/src/app/webview/src/contextManager.ts | 3 +- web/src/engine/element-wrappers/build.sh | 2 +- .../element-wrappers/src/outputTarget.ts | 2 +- .../prediction/languageProcessor.interface.ts | 2 +- .../src/prediction/predictionContext.ts | 3 +- .../src/deadkeys.ts | 0 web/src/engine/js-processor/src/index.ts | 5 + .../engine/js-processor/src/kbdInterface.ts | 5 +- .../js-processor/src/keyboardProcessor.ts | 4 +- web/src/engine/js-processor/src/mock.ts | 157 +++++++++++++++++ .../src/outputTarget.ts | 159 +----------------- .../engine/js-processor/src/ruleBehavior.ts | 4 +- .../src/stringDivergence.ts | 0 web/src/engine/keyboard/src/defaultRules.ts | 2 +- web/src/engine/keyboard/src/index.ts | 4 - .../engine/keyboard/src/keyboards/keyboard.ts | 2 +- .../keyboard/src/outputTarget.interface.ts | 104 ++++++++++++ web/src/engine/main/src/contextManagerBase.ts | 4 +- .../engine/main/src/engineConfiguration.ts | 4 +- .../engine/main/src/headless/contextWindow.ts | 2 +- .../main/src/headless/inputProcessor.ts | 12 +- .../main/src/headless/languageProcessor.ts | 2 +- .../main/src/headless/transcriptionCache.ts | 2 +- web/src/engine/osk/src/visualKeyboard.ts | 4 +- .../element_interfaces.spec.ts | 3 +- .../element-wrappers/target_mocks.spec.ts | 3 +- .../cases/keyboard/domKeyboardLoader.spec.ts | 4 +- .../prediction/predictionContext.spec.js | 4 +- .../engine/js-processor/engine/context.js | 4 +- .../js-processor/engine/notany_context.js | 4 +- .../engine/js-processor/kbdInterface.tests.js | 4 +- .../headless/engine/js-processor/mocks.js | 2 +- .../js-processor/non-positional-rules.js | 4 +- .../js-processor/specialized-backspace.js | 4 +- .../engine/js-processor/transcriptions.js | 2 +- .../engine/keyboard/keyboard-loading.js | 4 +- .../tools/testing/recorder-core/src/index.ts | 4 +- .../testing/recorder-core/src/nodeProctor.ts | 3 +- .../testing/recorder-core/src/proctor.ts | 2 +- .../tools/testing/recorder/browserProctor.ts | 2 +- 43 files changed, 334 insertions(+), 216 deletions(-) rename web/src/engine/{keyboard => js-processor}/src/deadkeys.ts (100%) create mode 100644 web/src/engine/js-processor/src/mock.ts rename web/src/engine/{keyboard => js-processor}/src/outputTarget.ts (69%) rename web/src/engine/{keyboard => js-processor}/src/stringDivergence.ts (100%) create mode 100644 web/src/engine/keyboard/src/outputTarget.interface.ts diff --git a/web/README.md b/web/README.md index 1a30362e9b..7cd9e02f00 100644 --- a/web/README.md +++ b/web/README.md @@ -119,7 +119,7 @@ graph TD; Device["/web/src/engine/device-detect"]; Device----->WebUtils; Elements["/web/src/engine/element-wrappers"]; - Elements-->KP; + Elements-->JSProc; KeyboardCache["/web/src/engine/package-cache"]; KeyboardCache-->Interfaces; DomUtils["/web/src/engine/dom-utils"]; diff --git a/web/src/app/browser/src/configuration.ts b/web/src/app/browser/src/configuration.ts index 35983ac30c..df2153df82 100644 --- a/web/src/app/browser/src/configuration.ts +++ b/web/src/app/browser/src/configuration.ts @@ -1,8 +1,7 @@ import { EngineConfiguration, InitOptionSpec, InitOptionDefaults } from "keyman/engine/main"; import { OutputTarget as DOMOutputTarget } from 'keyman/engine/element-wrappers'; -import { isEmptyTransform, OutputTarget } from 'keyman/engine/keyboard'; -import { RuleBehavior } from 'keyman/engine/js-processor'; +import { isEmptyTransform, OutputTarget, RuleBehavior } from 'keyman/engine/js-processor'; import { AlertHost } from "./utils/alertHost.js"; import { whenDocumentReady } from "./utils/documentReady.js"; diff --git a/web/src/app/browser/src/defaultBrowserRules.ts b/web/src/app/browser/src/defaultBrowserRules.ts index 46f80664f7..4f0ffbe012 100644 --- a/web/src/app/browser/src/defaultBrowserRules.ts +++ b/web/src/app/browser/src/defaultBrowserRules.ts @@ -2,9 +2,9 @@ import { ModifierKeyConstants } from '@keymanapp/common-types'; import { Codes, DefaultRules, - type KeyEvent, - type OutputTarget + type KeyEvent } from 'keyman/engine/keyboard'; +import { type OutputTarget } from 'keyman/engine/js-processor'; import ContextManager from './contextManager.js'; diff --git a/web/src/app/webview/src/contextManager.ts b/web/src/app/webview/src/contextManager.ts index de41348142..2b242de39c 100644 --- a/web/src/app/webview/src/contextManager.ts +++ b/web/src/app/webview/src/contextManager.ts @@ -1,4 +1,5 @@ -import { type Keyboard, Mock, OutputTarget, Transcription, findCommonSubstringEndIndex, isEmptyTransform, TextTransform } from 'keyman/engine/keyboard'; +import { type Keyboard } from 'keyman/engine/keyboard'; +import { Mock, OutputTarget, Transcription, findCommonSubstringEndIndex, isEmptyTransform, TextTransform } from 'keyman/engine/js-processor'; import { KeyboardStub } from 'keyman/engine/package-cache'; import { ContextManagerBase } from 'keyman/engine/main'; import { WebviewConfiguration } from './configuration.js'; diff --git a/web/src/engine/element-wrappers/build.sh b/web/src/engine/element-wrappers/build.sh index 1d0f580213..e188c7dd41 100755 --- a/web/src/engine/element-wrappers/build.sh +++ b/web/src/engine/element-wrappers/build.sh @@ -13,7 +13,7 @@ SUBPROJECT_NAME=engine/element-wrappers # ################################ Main script ################################ builder_describe "Builds DOM-based OutputTarget subclasses used by the Keyman Engine for Web (KMW)." \ - "@/web/src/engine/keyboard" \ + "@/web/src/engine/js-processor" \ "clean" \ "configure" \ "build" \ diff --git a/web/src/engine/element-wrappers/src/outputTarget.ts b/web/src/engine/element-wrappers/src/outputTarget.ts index 5d0f2e38ce..43623af781 100644 --- a/web/src/engine/element-wrappers/src/outputTarget.ts +++ b/web/src/engine/element-wrappers/src/outputTarget.ts @@ -1,4 +1,4 @@ -import { OutputTarget as OutputTargetBase } from "keyman/engine/keyboard"; +import { OutputTarget as OutputTargetBase } from "keyman/engine/js-processor"; import { EventEmitter } from 'eventemitter3'; export default abstract class OutputTarget extends OutputTargetBase { diff --git a/web/src/engine/interfaces/src/prediction/languageProcessor.interface.ts b/web/src/engine/interfaces/src/prediction/languageProcessor.interface.ts index 84e7851987..df5ebae896 100644 --- a/web/src/engine/interfaces/src/prediction/languageProcessor.interface.ts +++ b/web/src/engine/interfaces/src/prediction/languageProcessor.interface.ts @@ -1,7 +1,7 @@ /// import { EventEmitter } from "eventemitter3"; -import { OutputTarget } from "keyman/engine/keyboard"; +import { OutputTarget } from "keyman/engine/js-processor"; export class ReadySuggestions { suggestions: Suggestion[]; diff --git a/web/src/engine/interfaces/src/prediction/predictionContext.ts b/web/src/engine/interfaces/src/prediction/predictionContext.ts index dabeb366da..221875e62c 100644 --- a/web/src/engine/interfaces/src/prediction/predictionContext.ts +++ b/web/src/engine/interfaces/src/prediction/predictionContext.ts @@ -1,7 +1,6 @@ import { EventEmitter } from "eventemitter3"; import { type LanguageProcessorSpec , ReadySuggestions, type InvalidateSourceEnum, StateChangeHandler } from './languageProcessor.interface.js'; -import { type OutputTarget } from "keyman/engine/keyboard"; -import { type KeyboardProcessor } from 'keyman/engine/js-processor'; +import { type KeyboardProcessor, type OutputTarget } from 'keyman/engine/js-processor'; interface PredictionContextEventMap { update: (suggestions: Suggestion[]) => void; diff --git a/web/src/engine/keyboard/src/deadkeys.ts b/web/src/engine/js-processor/src/deadkeys.ts similarity index 100% rename from web/src/engine/keyboard/src/deadkeys.ts rename to web/src/engine/js-processor/src/deadkeys.ts diff --git a/web/src/engine/js-processor/src/index.ts b/web/src/engine/js-processor/src/index.ts index f87a044bd7..1755499119 100644 --- a/web/src/engine/js-processor/src/index.ts +++ b/web/src/engine/js-processor/src/index.ts @@ -4,3 +4,8 @@ export { default as RuleBehavior } from "./ruleBehavior.js"; export * from './kbdInterface.js'; export { default as KeyboardInterface } from "./kbdInterface.js"; export * from "./systemStores.js"; +export * from "./deadkeys.js"; +export { default as OutputTarget } from "./outputTarget.js"; +export * from "./outputTarget.js"; +export { Mock } from "./mock.js"; +export * from "./stringDivergence.js"; diff --git a/web/src/engine/js-processor/src/kbdInterface.ts b/web/src/engine/js-processor/src/kbdInterface.ts index 73332dc8c8..b39b2baea2 100644 --- a/web/src/engine/js-processor/src/kbdInterface.ts +++ b/web/src/engine/js-processor/src/kbdInterface.ts @@ -7,7 +7,10 @@ import { type DeviceSpec } from "@keymanapp/web-utils"; import { ModifierKeyConstants } from '@keymanapp/common-types'; -import { Codes, type KeyEvent, type Deadkey, KeyMapping, type OutputTarget, Mock, Keyboard, KeyboardHarness, KeyboardKeymanGlobal, VariableStoreDictionary } from "keyman/engine/keyboard"; +import { Codes, type KeyEvent, KeyMapping, Keyboard, KeyboardHarness, KeyboardKeymanGlobal, VariableStoreDictionary } from "keyman/engine/keyboard"; +import type OutputTarget from './outputTarget.js'; +import { type Deadkey } from './deadkeys.js'; +import { Mock } from "./mock.js"; import RuleBehavior from "./ruleBehavior.js"; import { ComplexKeyboardStore, type KeyboardStore, KeyboardStoreElement, SystemStoreIDs, SystemStore, MutableSystemStore, PlatformSystemStore, VariableStore, VariableStoreSerializer } from "./systemStores.js"; diff --git a/web/src/engine/js-processor/src/keyboardProcessor.ts b/web/src/engine/js-processor/src/keyboardProcessor.ts index 861ecadb36..dea537dfdf 100644 --- a/web/src/engine/js-processor/src/keyboardProcessor.ts +++ b/web/src/engine/js-processor/src/keyboardProcessor.ts @@ -10,8 +10,10 @@ import { EventEmitter } from 'eventemitter3'; import { ModifierKeyConstants } from '@keymanapp/common-types'; import { Codes, type Keyboard, MinimalKeymanGlobal, KeyEvent, Layouts, - type OutputTarget, Mock, DefaultRules, EmulationKeystrokes + DefaultRules, EmulationKeystrokes } from "keyman/engine/keyboard"; +import { Mock } from "./mock.js"; +import type OutputTarget from "./outputTarget.js"; import RuleBehavior from "./ruleBehavior.js"; import KeyboardInterface from './kbdInterface.js'; import { DeviceSpec, globalObject } from "@keymanapp/web-utils"; diff --git a/web/src/engine/js-processor/src/mock.ts b/web/src/engine/js-processor/src/mock.ts new file mode 100644 index 0000000000..151d8313ca --- /dev/null +++ b/web/src/engine/js-processor/src/mock.ts @@ -0,0 +1,157 @@ +import OutputTarget from './outputTarget.js'; + +// Due to some interesting requirements on compile ordering in TS, +// this needs to be in the same file as OutputTarget now. +export class Mock extends OutputTarget { + text: string; + + selStart: number; + selEnd: number; + selForward: boolean = true; + + constructor(text?: string, caretPos?: number); + constructor(text?: string, selStart?: number, selEnd?: number); + constructor(text?: string, selStart?: number, selEnd?: number) { + super(); + + this.text = text ? text : ""; + var defaultLength = this.text._kmwLength(); + + // Ensures that `caretPos == 0` is handled correctly. + this.selStart = typeof selStart == "number" ? selStart : defaultLength; + + // If no selection-end is set, selection length is implied to be 0. + this.selEnd = typeof selEnd == "number" ? selEnd : this.selStart; + + this.selForward = this.selEnd >= this.selStart; + } + + // Clones the state of an existing EditableElement, creating a Mock version of its state. + static from(outputTarget: OutputTarget, readonly?: boolean) { + let clone: Mock; + + if (outputTarget instanceof Mock) { + // Avoids the need to run expensive kmwstring.ts / `_kmwLength()` + // calculations when deep-copying Mock instances. + let priorMock = outputTarget as Mock; + clone = new Mock(priorMock.text, priorMock.selStart, priorMock.selEnd); + } else { + const text = outputTarget.getText(); + const textLen = text._kmwLength(); + + // If !hasSelection() + let selectionStart: number = textLen; + let selectionEnd: number = 0; + + if (outputTarget.hasSelection()) { + let beforeText = outputTarget.getTextBeforeCaret(); + let afterText = outputTarget.getTextAfterCaret(); + selectionStart = beforeText._kmwLength(); + selectionEnd = textLen - afterText._kmwLength(); + } + + // readonly group or not, the returned Mock remains the same. + // New-context events should act as if the caret were at the earlier-in-context + // side of the selection, same as standard keyboard rules. + clone = new Mock(text, selectionStart, selectionEnd); + } + + // Also duplicate deadkey state! (Needed for fat-finger ops.) + clone.setDeadkeys(outputTarget.deadkeys()); + + return clone; + } + + clearSelection(): void { + this.text = this.getTextBeforeCaret() + this.getTextAfterCaret(); + this.selEnd = this.selStart; + this.selForward = true; + } + + invalidateSelection(): void { + return; + } + + isSelectionEmpty(): boolean { + return this.selStart == this.selEnd; + } + + hasSelection(): boolean { + return true; + } + + getDeadkeyCaret(): number { + return this.selStart; + } + + setSelection(start: number, end?: number) { + this.selStart = start; + this.selEnd = typeof end == 'number' ? end : start; + + this.selForward = end >= start; + if (!this.selForward) { + let temp = this.selStart; + this.selStart = this.selEnd; + this.selEnd = temp; + } + } + + getTextBeforeCaret(): string { + return this.text.kmwSubstr(0, this.selStart); + } + + getSelectedText(): string { + return this.text.kmwSubstr(this.selStart, this.selEnd - this.selStart); + } + + getTextAfterCaret(): string { + return this.text.kmwSubstr(this.selEnd); + } + + getText(): string { + return this.text; + } + + deleteCharsBeforeCaret(dn: number): void { + if (dn >= 0) { + if (dn > this.selStart) { + dn = this.selStart; + } + this.adjustDeadkeys(-dn); + this.text = this.text.kmwSubstr(0, this.selStart - dn) + this.text.kmwSubstr(this.selStart); + this.selStart -= dn; + this.selEnd -= dn; + } + } + + insertTextBeforeCaret(s: string): void { + this.adjustDeadkeys(s._kmwLength()); + this.text = this.getTextBeforeCaret() + s + this.text.kmwSubstr(this.selStart); + this.selStart += s.kmwLength(); + this.selEnd += s.kmwLength(); + } + + handleNewlineAtCaret(): void { + this.insertTextBeforeCaret('\n'); + } + + protected setTextAfterCaret(s: string): void { + this.text = this.getTextBeforeCaret() + s; + } + + /** + * Indicates if this Mock represents an identical context to that of another Mock. + * @param other + * @returns + */ + isEqual(other: Mock) { + return this.text == other.text + && this.selStart == other.selStart + && this.selEnd == other.selEnd + && this.deadkeys().equal(other.deadkeys()); + } + + doInputEvent() { + // Mock isn't backed by an element, so it won't have any event listeners. + } +} diff --git a/web/src/engine/keyboard/src/outputTarget.ts b/web/src/engine/js-processor/src/outputTarget.ts similarity index 69% rename from web/src/engine/keyboard/src/outputTarget.ts rename to web/src/engine/js-processor/src/outputTarget.ts index 63c4c8a042..f48647092c 100644 --- a/web/src/engine/keyboard/src/outputTarget.ts +++ b/web/src/engine/js-processor/src/outputTarget.ts @@ -2,11 +2,12 @@ import { extendString } from "@keymanapp/web-utils"; import { findCommonSubstringEndIndex } from "./stringDivergence.js"; +import { Mock } from "./mock.js"; extendString(); // Defines deadkey management in a manner attachable to each element interface. -import type KeyEvent from "./keyEvent.js"; +import { type KeyEvent } from 'keyman/engine/keyboard'; import { Deadkey, DeadkeyTracker } from "./deadkeys.js"; // Also relies on string-extensions provided by the web-utils package. @@ -307,159 +308,3 @@ export default abstract class OutputTarget { */ abstract doInputEvent(): void; } - -// Due to some interesting requirements on compile ordering in TS, -// this needs to be in the same file as OutputTarget now. -export class Mock extends OutputTarget { - text: string; - - selStart: number; - selEnd: number; - selForward: boolean = true; - - constructor(text?: string, caretPos?: number); - constructor(text?: string, selStart?: number, selEnd?: number); - constructor(text?: string, selStart?: number, selEnd?: number) { - super(); - - this.text = text ? text : ""; - var defaultLength = this.text._kmwLength(); - - // Ensures that `caretPos == 0` is handled correctly. - this.selStart = typeof selStart == "number" ? selStart : defaultLength; - - // If no selection-end is set, selection length is implied to be 0. - this.selEnd = typeof selEnd == "number" ? selEnd : this.selStart; - - this.selForward = this.selEnd >= this.selStart; - } - - // Clones the state of an existing EditableElement, creating a Mock version of its state. - static from(outputTarget: OutputTarget, readonly?: boolean) { - let clone: Mock; - - if(outputTarget instanceof Mock) { - // Avoids the need to run expensive kmwstring.ts / `_kmwLength()` - // calculations when deep-copying Mock instances. - let priorMock = outputTarget as Mock; - clone = new Mock(priorMock.text, priorMock.selStart, priorMock.selEnd); - } else { - const text = outputTarget.getText(); - const textLen = text._kmwLength(); - - // If !hasSelection() - let selectionStart: number = textLen; - let selectionEnd: number = 0; - - if(outputTarget.hasSelection()) { - let beforeText = outputTarget.getTextBeforeCaret(); - let afterText = outputTarget.getTextAfterCaret(); - selectionStart = beforeText._kmwLength(); - selectionEnd = textLen - afterText._kmwLength(); - } - - // readonly group or not, the returned Mock remains the same. - // New-context events should act as if the caret were at the earlier-in-context - // side of the selection, same as standard keyboard rules. - clone = new Mock(text, selectionStart, selectionEnd); - } - - // Also duplicate deadkey state! (Needed for fat-finger ops.) - clone.setDeadkeys(outputTarget.deadkeys()); - - return clone; - } - - clearSelection(): void { - this.text = this.getTextBeforeCaret() + this.getTextAfterCaret(); - this.selEnd = this.selStart; - this.selForward = true; - } - - invalidateSelection(): void { - return; - } - - isSelectionEmpty(): boolean { - return this.selStart == this.selEnd; - } - - hasSelection(): boolean { - return true; - } - - getDeadkeyCaret(): number { - return this.selStart; - } - - setSelection(start: number, end?: number) { - this.selStart = start; - this.selEnd = typeof end == 'number' ? end : start; - - this.selForward = end >= start; - if(!this.selForward) { - let temp = this.selStart; - this.selStart = this.selEnd; - this.selEnd = temp; - } - } - - getTextBeforeCaret(): string { - return this.text.kmwSubstr(0, this.selStart); - } - - getSelectedText(): string { - return this.text.kmwSubstr(this.selStart, this.selEnd - this.selStart); - } - - getTextAfterCaret(): string { - return this.text.kmwSubstr(this.selEnd); - } - - getText(): string { - return this.text; - } - - deleteCharsBeforeCaret(dn: number): void { - if(dn >= 0) { - if(dn > this.selStart) { - dn = this.selStart; - } - this.adjustDeadkeys(-dn); - this.text = this.text.kmwSubstr(0, this.selStart - dn) + this.text.kmwSubstr(this.selStart); - this.selStart -= dn; - this.selEnd -= dn; - } - } - - insertTextBeforeCaret(s: string): void { - this.adjustDeadkeys(s._kmwLength()); - this.text = this.getTextBeforeCaret() + s + this.text.kmwSubstr(this.selStart); - this.selStart += s.kmwLength(); - this.selEnd += s.kmwLength(); - } - - handleNewlineAtCaret(): void { - this.insertTextBeforeCaret('\n'); - } - - protected setTextAfterCaret(s: string): void { - this.text = this.getTextBeforeCaret() + s; - } - - /** - * Indicates if this Mock represents an identical context to that of another Mock. - * @param other - * @returns - */ - isEqual(other: Mock) { - return this.text == other.text - && this.selStart == other.selStart - && this.selEnd == other.selEnd - && this.deadkeys().equal(other.deadkeys()); - } - - doInputEvent() { - // Mock isn't backed by an element, so it won't have any event listeners. - } -} \ No newline at end of file diff --git a/web/src/engine/js-processor/src/ruleBehavior.ts b/web/src/engine/js-processor/src/ruleBehavior.ts index 0c0f6c0db5..a6b2c9973a 100644 --- a/web/src/engine/js-processor/src/ruleBehavior.ts +++ b/web/src/engine/js-processor/src/ruleBehavior.ts @@ -1,7 +1,9 @@ /// import KeyboardProcessor from "./keyboardProcessor.js"; -import { OutputTarget, Mock, type Transcription, VariableStoreDictionary } from "keyman/engine/keyboard"; +import { VariableStoreDictionary } from "keyman/engine/keyboard"; +import OutputTarget, { type Transcription } from './outputTarget.js'; +import { Mock } from "./mock.js"; import { type VariableStore } from "./systemStores.js"; /** diff --git a/web/src/engine/keyboard/src/stringDivergence.ts b/web/src/engine/js-processor/src/stringDivergence.ts similarity index 100% rename from web/src/engine/keyboard/src/stringDivergence.ts rename to web/src/engine/js-processor/src/stringDivergence.ts diff --git a/web/src/engine/keyboard/src/defaultRules.ts b/web/src/engine/keyboard/src/defaultRules.ts index 94acb02688..5512114d93 100644 --- a/web/src/engine/keyboard/src/defaultRules.ts +++ b/web/src/engine/keyboard/src/defaultRules.ts @@ -7,7 +7,7 @@ import { ModifierKeyConstants } from '@keymanapp/common-types'; import Codes from './codes.js'; import type KeyEvent from './keyEvent.js'; -import type OutputTarget from './outputTarget.js'; +import { type OutputTarget } from './outputTarget.interface.js'; export enum EmulationKeystrokes { Enter = '\n', diff --git a/web/src/engine/keyboard/src/index.ts b/web/src/engine/keyboard/src/index.ts index 1963ed01c6..f5a4edea71 100644 --- a/web/src/engine/keyboard/src/index.ts +++ b/web/src/engine/keyboard/src/index.ts @@ -26,15 +26,11 @@ export { default as StateKeyMap } from "./keyboards/stateKeyMap.js"; export { default as Codes } from "./codes.js"; export * from "./codes.js"; -export * from "./deadkeys.js"; export { default as DefaultRules } from "./defaultRules.js"; export * from "./defaultRules.js"; export { default as KeyEvent } from "./keyEvent.js"; export * from "./keyEvent.js"; export { default as KeyMapping } from "./keyMapping.js"; -export { default as OutputTarget } from "./outputTarget.js"; -export * from "./outputTarget.js"; -export * from "./stringDivergence.js"; export * from "@keymanapp/web-utils"; diff --git a/web/src/engine/keyboard/src/keyboards/keyboard.ts b/web/src/engine/keyboard/src/keyboards/keyboard.ts index 0c0ff75512..42463cd6e7 100644 --- a/web/src/engine/keyboard/src/keyboards/keyboard.ts +++ b/web/src/engine/keyboard/src/keyboards/keyboard.ts @@ -2,7 +2,7 @@ import Codes from "../codes.js"; import { EncodedVisualKeyboard, LayoutSpec, Layouts } from "./defaultLayouts.js"; import { ActiveKey, ActiveLayout, ActiveSubKey } from "./activeLayout.js"; import KeyEvent from "../keyEvent.js"; -import type OutputTarget from "../outputTarget.js"; +import { type OutputTarget } from "../outputTarget.interface.js"; import { ModifierKeyConstants, TouchLayout } from "@keymanapp/common-types"; type TouchLayoutSpec = TouchLayout.TouchLayoutPlatform & { isDefault?: boolean}; diff --git a/web/src/engine/keyboard/src/outputTarget.interface.ts b/web/src/engine/keyboard/src/outputTarget.interface.ts new file mode 100644 index 0000000000..410094c812 --- /dev/null +++ b/web/src/engine/keyboard/src/outputTarget.interface.ts @@ -0,0 +1,104 @@ +export interface OutputTarget { + /** + * Signifies that this OutputTarget has no default key processing behaviors. This should be false + * for OutputTargets backed by web elements like HTMLInputElement or HTMLTextAreaElement. + */ + get isSynthetic(): boolean; + + resetContext(): void; + + hasDeadkeyMatch(n: number, d: number): boolean; + + insertDeadkeyBeforeCaret(d: number): void; + + /** + * Clears any selected text within the wrapper's element(s). + * Silently does nothing if no such text exists. + */ + clearSelection(): void; + + /** + * Clears any cached selection-related state values. + */ + invalidateSelection(): void; + + /** + * Indicates whether or not the underlying element has its own selection (input, textarea) + * or is part of (or possesses) the DOM's active selection. Don't confuse with isSelectionEmpty(). + * + * TODO: rename to supportsOwnSelection + */ + hasSelection(): boolean; + + /** + * Returns true if there is no current selection -- that is, the selection range is empty + */ + isSelectionEmpty(): boolean; + + /** + * Returns an index corresponding to the caret's position for use with deadkeys. + */ + getDeadkeyCaret(): number; + + /** + * Relative to the caret, gets the current context within the wrapper's element. + */ + getTextBeforeCaret(): string; + + /** + * Gets the element's-currently selected text. + */ + getSelectedText(): string; + + /** + * Relative to the caret (and/or active selection), gets the element's text after the caret, + * excluding any actively selected text that would be immediately replaced upon text entry. + */ + getTextAfterCaret(): string; + + /** + * Gets the element's full text, including any text that is actively selected. + */ + getText(): string; + + /** + * Performs context deletions (from the left of the caret) as needed by the KeymanWeb engine and + * corrects the location of any affected deadkeys. + * + * Does not delete deadkeys (b/c KMW 1 & 2 behavior maintenance). + * @param dn The number of characters to delete. If negative, context will be left unchanged. + */ + deleteCharsBeforeCaret(dn: number): void; + + /** + * Inserts text immediately before the caret's current position, moving the caret after the + * newly inserted text in the process along with any affected deadkeys. + * + * @param s Text to insert before the caret's current position. + */ + insertTextBeforeCaret(s: string): void; + + /** + * Allows element-specific handling for ENTER key inputs. Conceptually, this should usually + * correspond to `insertTextBeforeCaret('\n'), but actual implementation will vary greatly among + * elements. + */ + handleNewlineAtCaret(): void; + + /** + * Saves element-specific state properties prone to mutation, enabling restoration after + * text-output operations. + */ + saveProperties(): void; + + /** + * Restores previously-saved element-specific state properties. Designed for use after text-output + * ops to facilitate more-seamless web-dev and user interactions. + */ + restoreProperties(): void; + + /** + * Generates a synthetic event on the underlying element, signalling that its value has changed. + */ + doInputEvent(): void; +} diff --git a/web/src/engine/main/src/contextManagerBase.ts b/web/src/engine/main/src/contextManagerBase.ts index f20dd19d00..5c774aa72d 100644 --- a/web/src/engine/main/src/contextManagerBase.ts +++ b/web/src/engine/main/src/contextManagerBase.ts @@ -1,6 +1,6 @@ import { EventEmitter } from 'eventemitter3'; -import { ManagedPromise, type Keyboard, type OutputTarget } from 'keyman/engine/keyboard'; -import { type KeyboardInterface } from 'keyman/engine/js-processor'; +import { ManagedPromise, type Keyboard } from 'keyman/engine/keyboard'; +import { type KeyboardInterface, type OutputTarget } from 'keyman/engine/js-processor'; import { StubAndKeyboardCache, type KeyboardStub } from 'keyman/engine/package-cache'; import { PredictionContext } from 'keyman/engine/interfaces'; import { EngineConfiguration } from './engineConfiguration.js'; diff --git a/web/src/engine/main/src/engineConfiguration.ts b/web/src/engine/main/src/engineConfiguration.ts index d6f6f0d698..050a7be11e 100644 --- a/web/src/engine/main/src/engineConfiguration.ts +++ b/web/src/engine/main/src/engineConfiguration.ts @@ -1,7 +1,7 @@ import { EventEmitter } from "eventemitter3"; -import { DeviceSpec, KeyboardProperties, ManagedPromise, OutputTarget, physicalKeyDeviceAlias, SpacebarText } from "keyman/engine/keyboard"; -import { RuleBehavior } from 'keyman/engine/js-processor'; +import { DeviceSpec, KeyboardProperties, ManagedPromise, physicalKeyDeviceAlias, SpacebarText } from "keyman/engine/keyboard"; +import { OutputTarget, RuleBehavior } from 'keyman/engine/js-processor'; import { PathConfiguration, PathOptionDefaults, PathOptionSpec } from "keyman/engine/interfaces"; import { Device } from "keyman/engine/device-detect"; import { KeyboardStub } from "keyman/engine/package-cache"; diff --git a/web/src/engine/main/src/headless/contextWindow.ts b/web/src/engine/main/src/headless/contextWindow.ts index b3337c29e5..9fcd1458b2 100644 --- a/web/src/engine/main/src/headless/contextWindow.ts +++ b/web/src/engine/main/src/headless/contextWindow.ts @@ -1,4 +1,4 @@ -import { Mock } from "keyman/engine/keyboard"; +import { Mock } from "keyman/engine/js-processor"; export default class ContextWindow implements Context { // Used to limit the range of context replicated for use of keyboard rules within diff --git a/web/src/engine/main/src/headless/inputProcessor.ts b/web/src/engine/main/src/headless/inputProcessor.ts index 9ff0c4b81c..6d8904c563 100644 --- a/web/src/engine/main/src/headless/inputProcessor.ts +++ b/web/src/engine/main/src/headless/inputProcessor.ts @@ -7,16 +7,18 @@ import { LanguageProcessor } from "./languageProcessor.js"; import type { ModelSpec } from "keyman/engine/interfaces"; import { globalObject, DeviceSpec } from "@keymanapp/web-utils"; +import { Codes, type Keyboard, type KeyEvent } from "keyman/engine/keyboard"; import { type Alternate, - Codes, isEmptyTransform, - type Keyboard, - type KeyEvent, + KeyboardInterface, + KeyboardProcessor, Mock, type OutputTarget, -} from "keyman/engine/keyboard"; -import { KeyboardInterface, KeyboardProcessor, RuleBehavior, type ProcessorInitOptions, SystemStoreIDs } from 'keyman/engine/js-processor'; + RuleBehavior, + type ProcessorInitOptions, + SystemStoreIDs +} from 'keyman/engine/js-processor'; import { TranscriptionCache } from "./transcriptionCache.js"; diff --git a/web/src/engine/main/src/headless/languageProcessor.ts b/web/src/engine/main/src/headless/languageProcessor.ts index 8f93d39d87..c1c1721484 100644 --- a/web/src/engine/main/src/headless/languageProcessor.ts +++ b/web/src/engine/main/src/headless/languageProcessor.ts @@ -1,6 +1,6 @@ import { EventEmitter } from "eventemitter3"; import { LMLayer } from "@keymanapp/lexical-model-layer/web"; -import { OutputTarget, Transcription, Mock } from "keyman/engine/keyboard"; +import { OutputTarget, Transcription, Mock } from "keyman/engine/js-processor"; import { LanguageProcessorEventMap, ModelSpec, StateChangeEnum, ReadySuggestions } from 'keyman/engine/interfaces'; import ContextWindow from "./contextWindow.js"; import { TranscriptionCache } from "./transcriptionCache.js"; diff --git a/web/src/engine/main/src/headless/transcriptionCache.ts b/web/src/engine/main/src/headless/transcriptionCache.ts index 9430bde5ee..af05853e17 100644 --- a/web/src/engine/main/src/headless/transcriptionCache.ts +++ b/web/src/engine/main/src/headless/transcriptionCache.ts @@ -1,4 +1,4 @@ -import { Transcription } from "keyman/engine/keyboard"; +import { Transcription } from "keyman/engine/js-processor"; const TRANSCRIPTION_BUFFER_SIZE = 10; diff --git a/web/src/engine/osk/src/visualKeyboard.ts b/web/src/engine/osk/src/visualKeyboard.ts index dd898e1ee9..e88cf2ac74 100644 --- a/web/src/engine/osk/src/visualKeyboard.ts +++ b/web/src/engine/osk/src/visualKeyboard.ts @@ -13,9 +13,9 @@ import { StateKeyMap, ActiveSubKey, timedPromise, - ActiveKeyBase, - isEmptyTransform + ActiveKeyBase } from 'keyman/engine/keyboard'; +import { isEmptyTransform } from 'keyman/engine/js-processor'; import { buildCorrectiveLayout } from './correctionLayout.js'; import { distributionFromDistanceMaps, keyTouchDistances } from './corrections.js'; diff --git a/web/src/test/auto/dom/cases/element-wrappers/element_interfaces.spec.ts b/web/src/test/auto/dom/cases/element-wrappers/element_interfaces.spec.ts index 813ce78911..cdfc8814af 100644 --- a/web/src/test/auto/dom/cases/element-wrappers/element_interfaces.spec.ts +++ b/web/src/test/auto/dom/cases/element-wrappers/element_interfaces.spec.ts @@ -1,6 +1,7 @@ import { assert } from 'chai'; -import { extendString, Mock } from 'keyman/engine/keyboard'; +import { extendString } from 'keyman/engine/keyboard'; +import { Mock } from 'keyman/engine/js-processor'; import * as wrappers from 'keyman/engine/element-wrappers'; import { DynamicElements } from '../../test_utils.js'; diff --git a/web/src/test/auto/dom/cases/element-wrappers/target_mocks.spec.ts b/web/src/test/auto/dom/cases/element-wrappers/target_mocks.spec.ts index 85116eaa8a..707d863899 100644 --- a/web/src/test/auto/dom/cases/element-wrappers/target_mocks.spec.ts +++ b/web/src/test/auto/dom/cases/element-wrappers/target_mocks.spec.ts @@ -1,6 +1,7 @@ import { assert } from 'chai'; -import { extendString, Mock } from 'keyman/engine/keyboard'; +import { extendString } from 'keyman/engine/keyboard'; +import { Mock } from 'keyman/engine/js-processor'; import { Input } from 'keyman/engine/element-wrappers'; import { DEFAULT_BROWSER_TIMEOUT } from '@keymanapp/common-test-resources/test-timeouts.mjs'; diff --git a/web/src/test/auto/dom/cases/keyboard/domKeyboardLoader.spec.ts b/web/src/test/auto/dom/cases/keyboard/domKeyboardLoader.spec.ts index bcf4afcf65..da610402eb 100644 --- a/web/src/test/auto/dom/cases/keyboard/domKeyboardLoader.spec.ts +++ b/web/src/test/auto/dom/cases/keyboard/domKeyboardLoader.spec.ts @@ -1,8 +1,8 @@ import { assert } from 'chai'; import { DOMKeyboardLoader } from 'keyman/engine/keyboard/dom-keyboard-loader'; -import { extendString, KeyboardHarness, Keyboard, MinimalKeymanGlobal, Mock, DeviceSpec, KeyboardKeymanGlobal } from 'keyman/engine/keyboard'; -import { KeyboardInterface } from 'keyman/engine/js-processor'; +import { extendString, KeyboardHarness, Keyboard, MinimalKeymanGlobal, DeviceSpec, KeyboardKeymanGlobal } from 'keyman/engine/keyboard'; +import { KeyboardInterface, Mock } from 'keyman/engine/js-processor'; declare let window: typeof globalThis; // KeymanEngine from the web/ folder... when available. diff --git a/web/src/test/auto/headless/engine/interfaces/prediction/predictionContext.spec.js b/web/src/test/auto/headless/engine/interfaces/prediction/predictionContext.spec.js index 39ab4aea59..dbc24cad4f 100644 --- a/web/src/test/auto/headless/engine/interfaces/prediction/predictionContext.spec.js +++ b/web/src/test/auto/headless/engine/interfaces/prediction/predictionContext.spec.js @@ -4,8 +4,8 @@ import sinon from 'sinon'; import { LanguageProcessor, TranscriptionCache } from 'keyman/engine/main'; import { PredictionContext } from 'keyman/engine/interfaces'; import { Worker as LMWorker } from "@keymanapp/lexical-model-layer/node"; -import { DeviceSpec, Mock } from 'keyman/engine/keyboard'; -import { KeyboardProcessor } from 'keyman/engine/js-processor'; +import { DeviceSpec } from 'keyman/engine/keyboard'; +import { KeyboardProcessor, Mock } from 'keyman/engine/js-processor'; function compileDummyModel(suggestionSets) { return ` diff --git a/web/src/test/auto/headless/engine/js-processor/engine/context.js b/web/src/test/auto/headless/engine/js-processor/engine/context.js index 3b318607a0..a355ead265 100644 --- a/web/src/test/auto/headless/engine/js-processor/engine/context.js +++ b/web/src/test/auto/headless/engine/js-processor/engine/context.js @@ -3,8 +3,8 @@ import { assert } from 'chai'; import { createRequire } from 'module'; const require = createRequire(import.meta.url); -import { MinimalKeymanGlobal, Mock } from 'keyman/engine/keyboard'; -import { KeyboardInterface, KeyboardProcessor } from 'keyman/engine/js-processor'; +import { MinimalKeymanGlobal } from 'keyman/engine/keyboard'; +import { KeyboardInterface, KeyboardProcessor, Mock } from 'keyman/engine/js-processor'; import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader'; import { NodeProctor, RecordedKeystrokeSequence } from '@keymanapp/recorder-core'; diff --git a/web/src/test/auto/headless/engine/js-processor/engine/notany_context.js b/web/src/test/auto/headless/engine/js-processor/engine/notany_context.js index 1fc2ec0129..ecc7dd92d0 100644 --- a/web/src/test/auto/headless/engine/js-processor/engine/notany_context.js +++ b/web/src/test/auto/headless/engine/js-processor/engine/notany_context.js @@ -3,8 +3,8 @@ import { assert } from 'chai'; import { createRequire } from 'module'; const require = createRequire(import.meta.url); -import { MinimalKeymanGlobal, Mock } from 'keyman/engine/keyboard'; -import { KeyboardInterface } from 'keyman/engine/js-processor'; +import { MinimalKeymanGlobal } from 'keyman/engine/keyboard'; +import { KeyboardInterface, Mock } from 'keyman/engine/js-processor'; import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader'; import { NodeProctor, RecordedKeystrokeSequence } from '@keymanapp/recorder-core'; import { extendString } from '@keymanapp/web-utils'; diff --git a/web/src/test/auto/headless/engine/js-processor/kbdInterface.tests.js b/web/src/test/auto/headless/engine/js-processor/kbdInterface.tests.js index 03203a840f..0d08496442 100644 --- a/web/src/test/auto/headless/engine/js-processor/kbdInterface.tests.js +++ b/web/src/test/auto/headless/engine/js-processor/kbdInterface.tests.js @@ -3,8 +3,8 @@ import { assert } from 'chai'; import { createRequire } from 'module'; const require = createRequire(import.meta.url); -import { MinimalKeymanGlobal, Mock } from 'keyman/engine/keyboard'; -import { KeyboardInterface } from 'keyman/engine/js-processor'; +import { MinimalKeymanGlobal } from 'keyman/engine/keyboard'; +import { KeyboardInterface, Mock } from 'keyman/engine/js-processor'; import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader'; describe('Headless keyboard loading', function () { diff --git a/web/src/test/auto/headless/engine/js-processor/mocks.js b/web/src/test/auto/headless/engine/js-processor/mocks.js index b02f259886..bad81bfcca 100644 --- a/web/src/test/auto/headless/engine/js-processor/mocks.js +++ b/web/src/test/auto/headless/engine/js-processor/mocks.js @@ -1,5 +1,5 @@ import { assert } from 'chai'; -import { Mock } from 'keyman/engine/keyboard'; +import { Mock } from 'keyman/engine/js-processor'; describe('Mocks', function() { describe('app|les', () => { diff --git a/web/src/test/auto/headless/engine/js-processor/non-positional-rules.js b/web/src/test/auto/headless/engine/js-processor/non-positional-rules.js index 2ab62a4840..a65cec6708 100644 --- a/web/src/test/auto/headless/engine/js-processor/non-positional-rules.js +++ b/web/src/test/auto/headless/engine/js-processor/non-positional-rules.js @@ -4,8 +4,8 @@ import { ModifierKeyConstants } from '@keymanapp/common-types'; import { createRequire } from 'module'; const require = createRequire(import.meta.url); -import { Codes, KeyEvent, MinimalKeymanGlobal, Mock } from 'keyman/engine/keyboard'; -import { KeyboardInterface } from 'keyman/engine/js-processor'; +import { Codes, KeyEvent, MinimalKeymanGlobal } from 'keyman/engine/keyboard'; +import { KeyboardInterface, Mock } from 'keyman/engine/js-processor'; import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader'; // Compare and contrast the unit tests here with those for app/browser key-event unit testing diff --git a/web/src/test/auto/headless/engine/js-processor/specialized-backspace.js b/web/src/test/auto/headless/engine/js-processor/specialized-backspace.js index 967701c63a..7e35817f07 100644 --- a/web/src/test/auto/headless/engine/js-processor/specialized-backspace.js +++ b/web/src/test/auto/headless/engine/js-processor/specialized-backspace.js @@ -4,8 +4,8 @@ import fs from 'fs'; import { createRequire } from 'module'; const require = createRequire(import.meta.url); -import { Codes, KeyEvent, MinimalKeymanGlobal, Mock } from 'keyman/engine/keyboard'; -import { KeyboardInterface, KeyboardProcessor } from 'keyman/engine/js-processor'; +import { Codes, KeyEvent, MinimalKeymanGlobal } from 'keyman/engine/keyboard'; +import { KeyboardInterface, KeyboardProcessor, Mock } from 'keyman/engine/js-processor'; import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader'; import { ModifierKeyConstants } from '@keymanapp/common-types'; diff --git a/web/src/test/auto/headless/engine/js-processor/transcriptions.js b/web/src/test/auto/headless/engine/js-processor/transcriptions.js index 569b36d3cd..45c09b3b80 100644 --- a/web/src/test/auto/headless/engine/js-processor/transcriptions.js +++ b/web/src/test/auto/headless/engine/js-processor/transcriptions.js @@ -1,6 +1,6 @@ import { assert } from 'chai'; -import { Mock, findCommonSubstringEndIndex } from 'keyman/engine/keyboard'; +import { Mock, findCommonSubstringEndIndex } from 'keyman/engine/js-processor'; import { extendString } from '@keymanapp/web-utils'; extendString(); // Ensure KMW's string-extension functionality is available. diff --git a/web/src/test/auto/headless/engine/keyboard/keyboard-loading.js b/web/src/test/auto/headless/engine/keyboard/keyboard-loading.js index 1dc2baad9b..0dd89a3614 100644 --- a/web/src/test/auto/headless/engine/keyboard/keyboard-loading.js +++ b/web/src/test/auto/headless/engine/keyboard/keyboard-loading.js @@ -3,8 +3,8 @@ import { assert } from 'chai'; import { createRequire } from 'module'; const require = createRequire(import.meta.url); -import { KeyboardHarness, MinimalKeymanGlobal, Mock } from 'keyman/engine/keyboard'; -import { KeyboardInterface } from 'keyman/engine/js-processor'; +import { KeyboardHarness, MinimalKeymanGlobal } from 'keyman/engine/keyboard'; +import { KeyboardInterface, Mock } from 'keyman/engine/js-processor'; import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader'; describe('Headless keyboard loading', function() { diff --git a/web/src/tools/testing/recorder-core/src/index.ts b/web/src/tools/testing/recorder-core/src/index.ts index caa0262f6b..2a73971023 100644 --- a/web/src/tools/testing/recorder-core/src/index.ts +++ b/web/src/tools/testing/recorder-core/src/index.ts @@ -1,5 +1,5 @@ -import { type OutputTarget } from "keyman/engine/keyboard"; -import { KeyDistribution, KeyEvent, Mock } from "keyman/engine/keyboard"; +import { Mock, type OutputTarget } from "keyman/engine/js-processor"; +import { KeyDistribution, KeyEvent } from "keyman/engine/keyboard"; import Proctor from "./proctor.js"; diff --git a/web/src/tools/testing/recorder-core/src/nodeProctor.ts b/web/src/tools/testing/recorder-core/src/nodeProctor.ts index e9a08530c8..204ef21939 100644 --- a/web/src/tools/testing/recorder-core/src/nodeProctor.ts +++ b/web/src/tools/testing/recorder-core/src/nodeProctor.ts @@ -8,7 +8,8 @@ import { RecordedSyntheticKeystroke } from "./index.js"; -import { KeyEvent, KeyEventSpec, Mock, type OutputTarget, KeyboardHarness } from "keyman/engine/keyboard"; +import { KeyEvent, KeyEventSpec, KeyboardHarness } from "keyman/engine/keyboard"; +import { Mock, type OutputTarget } from "keyman/engine/js-processor"; import { DeviceSpec } from "@keymanapp/web-utils"; import { KeyboardInterface, KeyboardProcessor } from 'keyman/engine/js-processor'; diff --git a/web/src/tools/testing/recorder-core/src/proctor.ts b/web/src/tools/testing/recorder-core/src/proctor.ts index 0242b911a1..ec4f584b04 100644 --- a/web/src/tools/testing/recorder-core/src/proctor.ts +++ b/web/src/tools/testing/recorder-core/src/proctor.ts @@ -1,5 +1,5 @@ import { type DeviceSpec } from "@keymanapp/web-utils"; -import { type OutputTarget } from "keyman/engine/keyboard"; +import { type OutputTarget } from "keyman/engine/js-processor"; import type { KeyboardTest, TestSet, TestSequence } from "./index.js"; diff --git a/web/src/tools/testing/recorder/browserProctor.ts b/web/src/tools/testing/recorder/browserProctor.ts index 73e5a80ea7..a48e5572cb 100644 --- a/web/src/tools/testing/recorder/browserProctor.ts +++ b/web/src/tools/testing/recorder/browserProctor.ts @@ -4,7 +4,7 @@ import { type DeviceSpec } from "@keymanapp/web-utils"; -import { type OutputTarget } from "keyman/engine/keyboard"; +import { type OutputTarget } from "keyman/engine/js-processor"; import { type KeymanEngine } from 'keyman/app/browser'; From e557132ac6f81f4679de2c0754d8862966f4fa8d Mon Sep 17 00:00:00 2001 From: Keyman Build Agent Date: Wed, 14 Aug 2024 14:04:35 -0400 Subject: [PATCH 320/327] auto: increment master version to 18.0.90 --- HISTORY.md | 11 +++++++++++ VERSION.md | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index f45e1e85cd..185c9d7626 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,16 @@ # Keyman Version History +## 18.0.89 alpha 2024-08-14 + +* feat(web): test skipped prediction round handling (#12169) +* fix(web): support live configuration of longpress delay (#12175) +* feat(web): add osk.gestureParams for better gesture-config persistence (#12176) +* refactor(core): move utfcodec to common (#12171) +* refactor: move kmx_u16 to common and rename to km_u16 (#12177) +* refactor(developer): use npm or local source for server addons instead of github references (#12090) +* fix(developer): fix crash with Windows Clipboard by ignoring zero scan code in debugger (#12166) +* chore(developer): update SIL logo (#12168) + ## 18.0.88 alpha 2024-08-13 * docs: add .kmx specification (#12163) diff --git a/VERSION.md b/VERSION.md index 06ebe83646..49d6906226 100644 --- a/VERSION.md +++ b/VERSION.md @@ -1 +1 @@ -18.0.89 \ No newline at end of file +18.0.90 \ No newline at end of file From 4509805f58803c98142e2b4f1be16eb68be47dee Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Thu, 15 Aug 2024 09:04:35 +0700 Subject: [PATCH 321/327] fix(web): restore flick functionality --- .../osk/src/input/gestures/specsForLayout.ts | 115 ++++++++++-------- web/src/engine/osk/src/visualKeyboard.ts | 7 +- 2 files changed, 67 insertions(+), 55 deletions(-) diff --git a/web/src/engine/osk/src/input/gestures/specsForLayout.ts b/web/src/engine/osk/src/input/gestures/specsForLayout.ts index 34d5576e23..649c5537d0 100644 --- a/web/src/engine/osk/src/input/gestures/specsForLayout.ts +++ b/web/src/engine/osk/src/input/gestures/specsForLayout.ts @@ -20,20 +20,8 @@ import { calcLockedDistance, lockedAngleForDir, MAX_TOLERANCE_ANGLE_SKEW, type O import specs = gestures.specs; -export interface GestureParams { +export interface GestureParams { readonly longpress: { - /** - * Allows enabling or disabling the longpress up-flick shortcut for - * keyboards that do not include any defined flick gestures. - * - * Will be ignored (in favor of `false`) for keyboards that do have defined - * flicks. - * - * Note: this is automatically overwritten during keyboard initialization - * to match the keyboard's properties. - */ - permitsFlick: (item?: Item) => boolean, - /** * The minimum _net_ distance traveled before a longpress flick-shortcut will cancel any * conflicting flick models. @@ -98,19 +86,31 @@ export interface GestureParams { * Is currently also used as the max radius for valid flick-reset recentering targets. */ dirLockDist: number + } +} + +export interface FullGestureParams extends GestureParams { + readonly longpress: GestureParams["longpress"] & { + /** + * Allows enabling or disabling the longpress up-flick shortcut for + * keyboards that do not include any defined flick gestures. + * + * Will be ignored (in favor of `false`) for keyboards that do have defined + * flicks. + * + * Note: this is automatically overwritten during keyboard initialization + * to match the keyboard's properties. + */ + permitsFlick: (item?: Item) => boolean }, /** * Indicates whether roaming-touch oriented behaviors should be enabled. - * - * Note that run-time adjustments to this property after initialization will - * not take affect, unlike the other properties of the overall parameter object. */ roamingEnabled?: boolean; } export const DEFAULT_GESTURE_PARAMS: GestureParams = { longpress: { - permitsFlick: () => true, // Note: actual runtime value is determined at runtime based upon row height. // See `VisualKeyboard.refreshLayout`, CTRL-F "Step 3". flickDistStart: 8, @@ -206,17 +206,19 @@ let dummy: ActiveLayout; let dummy2: LayoutGestureSupportFlags = dummy; /** - * Defines the set of gestures appropriate for use with the specified Keyman keyboard. + * Defines the set of gestures appropriate for use with the specified Keyman + * keyboard. * @param layerGroup The active keyboard's layer group - * @param params A set of tweakable gesture parameters. It will be closure-captured - * and referred to by reference; changes to its values will take - * immediate effect during gesture processing. + * @param params A set of tweakable gesture parameters. It will be + * closure-captured and referred to by reference; changes to + * its values will take immediate effect during gesture + * processing. * - * If params.roamingEnabled is unset, it will be initialized by this + * `params.roamingEnabled` will be initialized by this * method based upon layout properties. * @returns */ -export function gestureSetForLayout(flags: LayoutGestureSupportFlags, params: GestureParams): GestureModelDefs { +export function gestureSetForLayout(flags: LayoutGestureSupportFlags, paramObj: GestureParams): GestureModelDefs { // To be used among the `allowsInitialState` contact-model specifications as needed. const gestureKeyFilter = (key: KeyElement, gestureId: string) => { if(!key) { @@ -248,18 +250,33 @@ export function gestureSetForLayout(flags: LayoutGestureSupportFlags, params: Ge } }; - const doRoaming = params.roamingEnabled ||= !flags.hasFlicks; + const params = paramObj as FullGestureParams; + + // Override any prior entries for keyboard-specific configuration. + params.longpress.permitsFlick = (key) => { + const flickSpec = key?.key.spec.flick; + return !flickSpec || !(flickSpec.n || flickSpec.nw || flickSpec.ne); + }; + const doRoaming = params.roamingEnabled = !flags.hasFlicks; const _initialTapModel: GestureModel = deepCopy(!doRoaming ? initialTapModel(params) : initialTapModelWithReset(params)); const _simpleTapModel: GestureModel = deepCopy(!doRoaming ? simpleTapModel(params) : simpleTapModelWithReset(params)); // Ensure all deep-copy operations for longpress modeling occur before the property-redefining block. const _longpressModel: GestureModel = withKeySpecFiltering(deepCopy(longpressModel(params, true, doRoaming)), 0); + const _multitapStartModel: GestureModel = withKeySpecFiltering(multitapStartModel(params), 0); + const _modipressMultitapStartModel: GestureModel = withKeySpecFiltering(modipressMultitapStartModel(params), 0); // `deepCopy` does not preserve property definitions, instead raw-copying its value. // We need to re-instate the longpress delay property here. Object.defineProperty(_longpressModel.contacts[0].model.timer, 'duration', { get: () => params.longpress.waitLength }); + Object.defineProperty(_multitapStartModel.sustainTimer, 'duration', { + get: () => params.multitap.waitLength + }); + Object.defineProperty(_modipressMultitapStartModel.sustainTimer, 'duration', { + get: () => params.multitap.waitLength + }); // #region Functions for implementing and/or extending path initial-state checks function withKeySpecFiltering(model: GestureModel, contactIndices: number | number[]) { @@ -293,7 +310,7 @@ export function gestureSetForLayout(flags: LayoutGestureSupportFlags, params: Ge const _modipressStartModel = modipressStartModel(); const gestureModels: GestureModel[] = [ _longpressModel, - withKeySpecFiltering(multitapStartModel(params), 0), + _multitapStartModel, multitapEndModel(params), _initialTapModel, _simpleTapModel, @@ -304,7 +321,7 @@ export function gestureSetForLayout(flags: LayoutGestureSupportFlags, params: Ge modipressHoldModel(params), modipressEndModel(), modipressMultitapTransitionModel(), - withKeySpecFiltering(modipressMultitapStartModel(params), 0), + _modipressMultitapStartModel, modipressMultitapEndModel(params), modipressMultitapLockModel() ]; @@ -367,7 +384,7 @@ export function instantContactResolutionModel(): ContactModel { }; } -export function flickStartContactModel(params: GestureParams): gestures.specs.ContactModel { +export function flickStartContactModel(params: FullGestureParams): gestures.specs.ContactModel { const flickParams = params.flick; return { @@ -426,7 +443,7 @@ function determineLockFromStats(pathStats: CumulativePathStats, base } } -export function flickMidContactModel(params: GestureParams): gestures.specs.ContactModel { +export function flickMidContactModel(params: FullGestureParams): gestures.specs.ContactModel { return { itemPriority: 1, pathModel: { @@ -461,7 +478,7 @@ export function flickMidContactModel(params: GestureParams): gestures.specs.Cont } -export function flickEndContactModel(params: GestureParams): ContactModel { +export function flickEndContactModel(params: FullGestureParams): ContactModel { return { itemPriority: 1, pathModel: { @@ -485,7 +502,7 @@ export function flickEndContactModel(params: GestureParams): ContactModel { } } -export function longpressContactModel(params: GestureParams, enabledFlicks: boolean, resetForRoaming: boolean): ContactModel { +export function longpressContactModel(params: FullGestureParams, enabledFlicks: boolean, resetForRoaming: boolean): ContactModel { const spec = params.longpress; return { @@ -581,7 +598,7 @@ export function modipressContactEndModel(): ContactModel { }; } -export function simpleTapContactModel(params: GestureParams, isNotInitial?: boolean): ContactModel { +export function simpleTapContactModel(params: FullGestureParams, isNotInitial?: boolean): ContactModel { // Snapshot at model construction; do not update if changed. const roamingEnabled = params?.roamingEnabled ?? true; // ?? true - used by the banner. @@ -650,7 +667,7 @@ export function specialKeyStartModel(): GestureModel { }; } -export function specialKeyEndModel(params: GestureParams): GestureModel { +export function specialKeyEndModel(params: FullGestureParams): GestureModel { return { id: 'special-key-end', resolutionPriority: 0, @@ -682,7 +699,7 @@ export function specialKeyEndModel(params: GestureParams): GestureModel { * - the common gesture configuration permits the shortcut where supported * @param allowRoaming Indicates whether "roaming touch" mode should be supported. */ -export function longpressModel(params: GestureParams, allowShortcut: boolean, allowRoaming: boolean): GestureModel { +export function longpressModel(params: FullGestureParams, allowShortcut: boolean, allowRoaming: boolean): GestureModel { const base: GestureModel = { id: 'longpress', // Needs to beat flick-start priority. @@ -732,7 +749,7 @@ export function longpressModel(params: GestureParams, allowShortcut: boolean, al /** * For use for transitioning out of roaming-touch. */ -export function longpressModelAfterRoaming(params: GestureParams): GestureModel { +export function longpressModelAfterRoaming(params: FullGestureParams): GestureModel { // The longpress-shortcut is always disabled for keys reached by roaming (param 2) // Only used when roaming is permitted; continued roaming should be allowed. (param 3) const base = longpressModel(params, false, true); @@ -782,7 +799,7 @@ export function longpressRoamRestoration(): GestureModel { } } -export function flickStartModel(params: GestureParams): GestureModel { +export function flickStartModel(params: FullGestureParams): GestureModel { return { id: 'flick-start', resolutionPriority: 3, @@ -799,7 +816,7 @@ export function flickStartModel(params: GestureParams): GestureModel { } } -export function flickRestartModel(params: GestureParams): GestureModel { +export function flickRestartModel(params: FullGestureParams): GestureModel { const base = flickStartModel(params); return { ...base, @@ -859,7 +876,7 @@ export function flickRestartModel(params: GestureParams): GestureModel { +export function flickMidModel(params: FullGestureParams): GestureModel { return { id: 'flick-mid', resolutionPriority: 0, @@ -889,7 +906,7 @@ export function flickMidModel(params: GestureParams): GestureModel { } // Clears existing flick-scrolling & primes the flick-reset recentering mechanism. -export function flickResetModel(params: GestureParams): GestureModel { +export function flickResetModel(params: FullGestureParams): GestureModel { return { id: 'flick-reset', resolutionPriority: 1, @@ -909,7 +926,7 @@ export function flickResetModel(params: GestureParams): GestureModel { }; } -export function flickResetCenteringModel(params: GestureParams): GestureModel { +export function flickResetCenteringModel(params: FullGestureParams): GestureModel { return { id: 'flick-reset-centering', resolutionPriority: 1, @@ -963,7 +980,7 @@ export function flickResetEndModel(): GestureModel { }; }; -export function flickEndModel(params: GestureParams): GestureModel { +export function flickEndModel(params: FullGestureParams): GestureModel { return { id: 'flick-end', resolutionPriority: 0, @@ -990,7 +1007,7 @@ export function flickEndModel(params: GestureParams): GestureModel { } } -export function multitapStartModel(params: GestureParams): GestureModel { +export function multitapStartModel(params: FullGestureParams): GestureModel { return { id: 'multitap-start', resolutionPriority: 2, @@ -1019,7 +1036,7 @@ export function multitapStartModel(params: GestureParams): GestureModel { } } -export function multitapEndModel(params: GestureParams): GestureModel { +export function multitapEndModel(params: FullGestureParams): GestureModel { return { id: 'multitap-end', resolutionPriority: 2, @@ -1053,7 +1070,7 @@ export function multitapEndModel(params: GestureParams): GestureModel { } } -export function initialTapModel(params: GestureParams): GestureModel { +export function initialTapModel(params: FullGestureParams): GestureModel { return { id: 'initial-tap', resolutionPriority: 1, @@ -1089,7 +1106,7 @@ export function initialTapModel(params: GestureParams): GestureModel { } } -export function simpleTapModel(params: GestureParams): GestureModel { +export function simpleTapModel(params: FullGestureParams): GestureModel { return { id: 'simple-tap', resolutionPriority: 1, @@ -1113,7 +1130,7 @@ export function simpleTapModel(params: GestureParams): GestureModel { }; } -export function initialTapModelWithReset(params: GestureParams): GestureModel { +export function initialTapModelWithReset(params: FullGestureParams): GestureModel { const base = initialTapModel(params); return { ...base, @@ -1127,7 +1144,7 @@ export function initialTapModelWithReset(params: GestureParams): GestureModel { +export function simpleTapModelWithReset(params: FullGestureParams): GestureModel { const simpleModel = simpleTapModel(params); return { ...simpleModel, @@ -1189,7 +1206,7 @@ export function modipressStartModel(): GestureModel { } } -export function modipressHoldModel(params: GestureParams): GestureModel { +export function modipressHoldModel(params: FullGestureParams): GestureModel { return { id: 'modipress-hold', resolutionPriority: 5, @@ -1281,7 +1298,7 @@ export function modipressEndModel(): GestureModel { } } -export function modipressMultitapStartModel(params: GestureParams): GestureModel { +export function modipressMultitapStartModel(params: FullGestureParams): GestureModel { return { id: 'modipress-multitap-start', resolutionPriority: 6, @@ -1316,7 +1333,7 @@ export function modipressMultitapStartModel(params: GestureParams): GestureModel } } -export function modipressMultitapEndModel(params: GestureParams): GestureModel { +export function modipressMultitapEndModel(params: FullGestureParams): GestureModel { return { id: 'modipress-multitap-end', resolutionPriority: 5, diff --git a/web/src/engine/osk/src/visualKeyboard.ts b/web/src/engine/osk/src/visualKeyboard.ts index a8152a0db0..68f0766b90 100644 --- a/web/src/engine/osk/src/visualKeyboard.ts +++ b/web/src/engine/osk/src/visualKeyboard.ts @@ -151,7 +151,7 @@ export default class VisualKeyboard extends EventEmitter implements Ke /** * Tweakable gesture parameters referenced by supported gestures and the gesture engine. */ - get gestureParams(): GestureParams { + get gestureParams(): GestureParams { return this.config.gestureParams; }; @@ -423,11 +423,6 @@ export default class VisualKeyboard extends EventEmitter implements Ke historyLength: DEBUG_HISTORY_COUNT }; - this.gestureParams.longpress.permitsFlick = (key) => { - const flickSpec = key?.key.spec.flick; - return !flickSpec || !(flickSpec.n || flickSpec.nw || flickSpec.ne); - }; - const recognizer = new GestureRecognizer(gestureSetForLayout(this.kbdLayout, this.gestureParams), config); recognizer.stateToken = this.layerId; From 8af17659a0d97b7ad6236d6c7d9ff8ea94a63102 Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Thu, 15 Aug 2024 10:30:33 +0700 Subject: [PATCH 322/327] docs(web): doc tweak --- web/src/engine/osk/src/input/gestures/specsForLayout.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/engine/osk/src/input/gestures/specsForLayout.ts b/web/src/engine/osk/src/input/gestures/specsForLayout.ts index 649c5537d0..541e07a5c0 100644 --- a/web/src/engine/osk/src/input/gestures/specsForLayout.ts +++ b/web/src/engine/osk/src/input/gestures/specsForLayout.ts @@ -209,7 +209,7 @@ let dummy2: LayoutGestureSupportFlags = dummy; * Defines the set of gestures appropriate for use with the specified Keyman * keyboard. * @param layerGroup The active keyboard's layer group - * @param params A set of tweakable gesture parameters. It will be + * @param paramObj A set of tweakable gesture parameters. It will be * closure-captured and referred to by reference; changes to * its values will take immediate effect during gesture * processing. From 88145326dc4036040970f442ff31024b217290bb Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Thu, 15 Aug 2024 10:31:36 +0700 Subject: [PATCH 323/327] docs(web): drops doc-reference to hidden field --- web/src/engine/osk/src/input/gestures/specsForLayout.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/web/src/engine/osk/src/input/gestures/specsForLayout.ts b/web/src/engine/osk/src/input/gestures/specsForLayout.ts index 541e07a5c0..7faf1a7fc1 100644 --- a/web/src/engine/osk/src/input/gestures/specsForLayout.ts +++ b/web/src/engine/osk/src/input/gestures/specsForLayout.ts @@ -213,9 +213,6 @@ let dummy2: LayoutGestureSupportFlags = dummy; * closure-captured and referred to by reference; changes to * its values will take immediate effect during gesture * processing. - * - * `params.roamingEnabled` will be initialized by this - * method based upon layout properties. * @returns */ export function gestureSetForLayout(flags: LayoutGestureSupportFlags, paramObj: GestureParams): GestureModelDefs { From 170ac4bb6bdbc62231e20a928ef63baa96a20aca Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Thu, 8 Aug 2024 18:09:38 +0200 Subject: [PATCH 324/327] =?UTF-8?q?refactor(web):=20rename=20`package-cach?= =?UTF-8?q?e`=20=E2=86=92=20`keyboard-storage`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move `web/src/engine/package-cache/` → `web/src/engine/keyboard-storage/`. Fixes: #12132 --- web/README.md | 6 ++--- web/build.sh | 8 +++--- web/package.json | 26 +++++++++---------- web/src/app/browser/src/contextManager.ts | 2 +- web/src/app/browser/src/keymanEngine.ts | 2 +- web/src/app/browser/src/languageMenu.ts | 2 +- web/src/app/webview/src/contextManager.ts | 2 +- web/src/app/webview/src/keymanEngine.ts | 2 +- .../.c8rc.json | 0 .../README.md | 0 .../build.sh | 2 +- .../src/cloud/index.ts | 0 .../src/cloud/queryEngine.ts | 0 .../src/cloud/requesterInterface.ts | 0 .../src/domCloudRequester.ts | 0 .../src/index.ts | 0 .../src/keyboardRequisitioner.ts | 0 .../src/keyboardStub.ts | 0 .../src/modelCache.ts | 0 .../src/nodeCloudRequester.ts | 0 .../src/stubAndKeyboardCache.ts | 0 .../tsconfig.json | 4 +-- web/src/engine/main/build.sh | 2 +- web/src/engine/main/src/contextManagerBase.ts | 2 +- .../engine/main/src/engineConfiguration.ts | 2 +- web/src/engine/main/src/keyboardInterface.ts | 2 +- web/src/engine/main/src/keymanEngine.ts | 4 +-- web/src/engine/main/tsconfig.json | 2 +- .../dom/cases/browser/contextManager.spec.ts | 2 +- .../cloudQueries.spec.ts | 4 +-- .../domCloudRequester.spec.ts | 2 +- .../keyboardRequisitioner.spec.ts | 6 ++--- web/src/test/auto/dom/kbdLoader.ts | 2 +- .../test/auto/dom/web-test-runner.config.mjs | 4 +-- .../cloudQueries.js | 4 +-- .../keyboardRequisitioner.js | 6 ++--- .../keyboardStub.js | 4 +-- .../nodeCloudRequester.js | 2 +- .../stubAndKeyboardCache.js | 2 +- .../test/auto/integrated/cases/engine.spec.ts | 2 +- web/src/test/auto/integrated/test_utils.ts | 2 +- 41 files changed, 56 insertions(+), 56 deletions(-) rename web/src/engine/{package-cache => keyboard-storage}/.c8rc.json (100%) rename web/src/engine/{package-cache => keyboard-storage}/README.md (100%) rename web/src/engine/{package-cache => keyboard-storage}/build.sh (97%) rename web/src/engine/{package-cache => keyboard-storage}/src/cloud/index.ts (100%) rename web/src/engine/{package-cache => keyboard-storage}/src/cloud/queryEngine.ts (100%) rename web/src/engine/{package-cache => keyboard-storage}/src/cloud/requesterInterface.ts (100%) rename web/src/engine/{package-cache => keyboard-storage}/src/domCloudRequester.ts (100%) rename web/src/engine/{package-cache => keyboard-storage}/src/index.ts (100%) rename web/src/engine/{package-cache => keyboard-storage}/src/keyboardRequisitioner.ts (100%) rename web/src/engine/{package-cache => keyboard-storage}/src/keyboardStub.ts (100%) rename web/src/engine/{package-cache => keyboard-storage}/src/modelCache.ts (100%) rename web/src/engine/{package-cache => keyboard-storage}/src/nodeCloudRequester.ts (100%) rename web/src/engine/{package-cache => keyboard-storage}/src/stubAndKeyboardCache.ts (100%) rename web/src/engine/{package-cache => keyboard-storage}/tsconfig.json (57%) rename web/src/test/auto/dom/cases/{packages => keyboard-storage}/cloudQueries.spec.ts (98%) rename web/src/test/auto/dom/cases/{packages => keyboard-storage}/domCloudRequester.spec.ts (97%) rename web/src/test/auto/dom/cases/{packages => keyboard-storage}/keyboardRequisitioner.spec.ts (95%) rename web/src/test/auto/headless/engine/{package-cache => keyboard-storage}/cloudQueries.js (98%) rename web/src/test/auto/headless/engine/{package-cache => keyboard-storage}/keyboardRequisitioner.js (98%) rename web/src/test/auto/headless/engine/{package-cache => keyboard-storage}/keyboardStub.js (96%) rename web/src/test/auto/headless/engine/{package-cache => keyboard-storage}/nodeCloudRequester.js (97%) rename web/src/test/auto/headless/engine/{package-cache => keyboard-storage}/stubAndKeyboardCache.js (99%) diff --git a/web/README.md b/web/README.md index 7cd9e02f00..4f35643e1a 100644 --- a/web/README.md +++ b/web/README.md @@ -120,8 +120,8 @@ graph TD; Device----->WebUtils; Elements["/web/src/engine/element-wrappers"]; Elements-->JSProc; - KeyboardCache["/web/src/engine/package-cache"]; - KeyboardCache-->Interfaces; + KeyboardStorage["/web/src/engine/keyboard-storage"]; + KeyboardStorage-->Interfaces; DomUtils["/web/src/engine/dom-utils"]; DomUtils-->WebUtils; DomUtils-->KP; @@ -133,7 +133,7 @@ graph TD; OSK-->Interfaces; CommonEngine["/web/src/engine/main"]; CommonEngine-->Device; - CommonEngine-->KeyboardCache; + CommonEngine-->KeyboardStorage; CommonEngine-->OSK; Attachment["/web/src/engine/attachment"]; Attachment-->DomUtils; diff --git a/web/build.sh b/web/build.sh index c3e17e9d43..4705bc55de 100755 --- a/web/build.sh +++ b/web/build.sh @@ -29,9 +29,9 @@ builder_describe "Builds engine modules for Keyman Engine for Web (KMW)." \ ":engine/element-wrappers Subset used to integrate with website elements" \ ":engine/js-processor Build JS processor for KMW" \ ":engine/keyboard Builds KMW's keyboard-loading and caching code" \ + ":engine/keyboard-storage Subset used to collate keyboards and request them from the cloud" \ ":engine/main Builds all common code used by KMW's app/-level targets" \ ":engine/osk Builds the Web OSK module" \ - ":engine/package-cache Subset used to collate keyboards and request them from the cloud" \ ":engine/interfaces Subset used to configure KMW" \ ":samples Builds all needed resources for the KMW sample-page set" \ ":tools Builds engine-related development resources" \ @@ -61,9 +61,9 @@ builder_describe_outputs \ build:engine/element-wrappers "/web/build/engine/element-wrappers/lib/index.mjs" \ build:engine/js-processor "/web/build/engine/js-processor/lib/index.mjs" \ build:engine/keyboard "/web/build/engine/keyboard/lib/index.mjs" \ + build:engine/keyboard-storage "/web/build/engine/keyboard-storage/lib/index.mjs" \ build:engine/main "/web/build/engine/main/lib/index.mjs" \ build:engine/osk "/web/build/engine/osk/lib/index.mjs" \ - build:engine/package-cache "/web/build/engine/package-cache/lib/index.mjs" \ build:engine/interfaces "/web/build/engine/interfaces/lib/index.mjs" \ build:samples "/web/src/samples/simplest/keymanweb.js" \ build:tools "/web/build/tools/building/sourcemap-root/index.js" \ @@ -152,9 +152,9 @@ builder_run_child_actions build:engine/osk builder_run_child_actions build:engine/attachment # Uses engine/interfaces (due to resource-path config interface) -builder_run_child_actions build:engine/package-cache +builder_run_child_actions build:engine/keyboard-storage -# Uses engine/interfaces, engine/device-detect, engine/package-cache, & engine/osk +# Uses engine/interfaces, engine/device-detect, engine/keyboard-storage, & engine/osk builder_run_child_actions build:engine/main # Uses all but engine/element-wrappers and engine/attachment diff --git a/web/package.json b/web/package.json index b5727dd009..96a11c0cd3 100644 --- a/web/package.json +++ b/web/package.json @@ -57,21 +57,21 @@ "types": "./build/engine/keyboard/obj/keyboards/loaders/dom-keyboard-loader.d.ts", "import": "./build/engine/keyboard/obj/keyboards/loaders/dom-keyboard-loader.js" }, - "./engine/package-cache": { - "es6-bundling": "./src/engine/package-cache/src/index.ts", - "types": "./build/engine/package-cache/obj/index.d.ts", - "import": "./build/engine/package-cache/obj/index.js", - "require": "./build/engine/package-cache/obj/index.js" + "./engine/keyboard-storage": { + "es6-bundling": "./src/engine/keyboard-storage/src/index.ts", + "types": "./build/engine/keyboard-storage/obj/index.d.ts", + "import": "./build/engine/keyboard-storage/obj/index.js", + "require": "./build/engine/keyboard-storage/obj/index.js" }, - "./engine/package-cache/dom-requester": { - "es6-bundling": "./src/engine/package-cache/src/domCloudRequester.ts", - "types": "./build/engine/package-cache/obj/domCloudRequester.d.ts", - "import": "./build/engine/package-cache/obj/domCloudRequester.js" + "./engine/keyboard-storage/dom-requester": { + "es6-bundling": "./src/engine/keyboard-storage/src/domCloudRequester.ts", + "types": "./build/engine/keyboard-storage/obj/domCloudRequester.d.ts", + "import": "./build/engine/keyboard-storage/obj/domCloudRequester.js" }, - "./engine/package-cache/node-requester": { - "es6-bundling": "./src/engine/package-cache/src/nodeCloudRequester.ts", - "types": "./build/engine/package-cache/obj/nodeCloudRequester.d.ts", - "import": "./build/engine/package-cache/obj/nodeCloudRequester.js" + "./engine/keyboard-storage/node-requester": { + "es6-bundling": "./src/engine/keyboard-storage/src/nodeCloudRequester.ts", + "types": "./build/engine/keyboard-storage/obj/nodeCloudRequester.d.ts", + "import": "./build/engine/keyboard-storage/obj/nodeCloudRequester.js" }, "./engine/main": { "es6-bundling": "./src/engine/main/src/index.ts", diff --git a/web/src/app/browser/src/contextManager.ts b/web/src/app/browser/src/contextManager.ts index f17a17a529..1fbc905203 100644 --- a/web/src/app/browser/src/contextManager.ts +++ b/web/src/app/browser/src/contextManager.ts @@ -1,5 +1,5 @@ import { type Keyboard, KeyboardScriptError } from 'keyman/engine/keyboard'; -import { type KeyboardStub } from 'keyman/engine/package-cache'; +import { type KeyboardStub } from 'keyman/engine/keyboard-storage'; import { CookieSerializer } from 'keyman/engine/dom-utils'; import { eventOutputTarget, outputTargetForElement, PageContextAttachment } from 'keyman/engine/attachment'; import { DomEventTracker, LegacyEventEmitter } from 'keyman/engine/events'; diff --git a/web/src/app/browser/src/keymanEngine.ts b/web/src/app/browser/src/keymanEngine.ts index dc912f257b..324394bae2 100644 --- a/web/src/app/browser/src/keymanEngine.ts +++ b/web/src/app/browser/src/keymanEngine.ts @@ -6,7 +6,7 @@ import { TwoStateActivator, VisualKeyboard } from 'keyman/engine/osk'; -import { ErrorStub, KeyboardStub, CloudQueryResult, toPrefixedKeyboardId as prefixed } from 'keyman/engine/package-cache'; +import { ErrorStub, KeyboardStub, CloudQueryResult, toPrefixedKeyboardId as prefixed } from 'keyman/engine/keyboard-storage'; import { DeviceSpec, Keyboard, KeyboardObject } from "keyman/engine/keyboard"; import * as views from './viewsAnchorpoint.js'; diff --git a/web/src/app/browser/src/languageMenu.ts b/web/src/app/browser/src/languageMenu.ts index eb9361ccba..d3144de6e5 100644 --- a/web/src/app/browser/src/languageMenu.ts +++ b/web/src/app/browser/src/languageMenu.ts @@ -1,6 +1,6 @@ // Manages the language selection UI for touch-form factors, which is triggered by an OSK key. import { getAbsoluteX, landscapeView } from "keyman/engine/dom-utils"; -import { KeyboardStub } from "keyman/engine/package-cache"; +import { KeyboardStub } from "keyman/engine/keyboard-storage"; import KeymanEngine from "./keymanEngine.js"; import * as util from "./utils/index.js"; diff --git a/web/src/app/webview/src/contextManager.ts b/web/src/app/webview/src/contextManager.ts index 2b242de39c..b0b90b4d96 100644 --- a/web/src/app/webview/src/contextManager.ts +++ b/web/src/app/webview/src/contextManager.ts @@ -1,6 +1,6 @@ import { type Keyboard } from 'keyman/engine/keyboard'; import { Mock, OutputTarget, Transcription, findCommonSubstringEndIndex, isEmptyTransform, TextTransform } from 'keyman/engine/js-processor'; -import { KeyboardStub } from 'keyman/engine/package-cache'; +import { KeyboardStub } from 'keyman/engine/keyboard-storage'; import { ContextManagerBase } from 'keyman/engine/main'; import { WebviewConfiguration } from './configuration.js'; diff --git a/web/src/app/webview/src/keymanEngine.ts b/web/src/app/webview/src/keymanEngine.ts index ca0c39fd43..d390a6ce1b 100644 --- a/web/src/app/webview/src/keymanEngine.ts +++ b/web/src/app/webview/src/keymanEngine.ts @@ -3,7 +3,7 @@ import { RuleBehavior } from 'keyman/engine/js-processor'; import { KeymanEngine as KeymanEngineBase, KeyboardInterface } from 'keyman/engine/main'; import { AnchoredOSKView, ViewConfiguration, StaticActivator } from 'keyman/engine/osk'; import { getAbsoluteX, getAbsoluteY } from 'keyman/engine/dom-utils'; -import { toPrefixedKeyboardId, toUnprefixedKeyboardId } from 'keyman/engine/package-cache'; +import { toPrefixedKeyboardId, toUnprefixedKeyboardId } from 'keyman/engine/keyboard-storage'; import { WebviewConfiguration, WebviewInitOptionDefaults, WebviewInitOptionSpec } from './configuration.js'; import ContextManager, { ContextHost } from './contextManager.js'; diff --git a/web/src/engine/package-cache/.c8rc.json b/web/src/engine/keyboard-storage/.c8rc.json similarity index 100% rename from web/src/engine/package-cache/.c8rc.json rename to web/src/engine/keyboard-storage/.c8rc.json diff --git a/web/src/engine/package-cache/README.md b/web/src/engine/keyboard-storage/README.md similarity index 100% rename from web/src/engine/package-cache/README.md rename to web/src/engine/keyboard-storage/README.md diff --git a/web/src/engine/package-cache/build.sh b/web/src/engine/keyboard-storage/build.sh similarity index 97% rename from web/src/engine/package-cache/build.sh rename to web/src/engine/keyboard-storage/build.sh index b413dd5be8..33873355ff 100755 --- a/web/src/engine/package-cache/build.sh +++ b/web/src/engine/keyboard-storage/build.sh @@ -6,7 +6,7 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" . "${THIS_SCRIPT%/*}/../../../../resources/build/builder.inc.sh" ## END STANDARD BUILD SCRIPT INCLUDE -SUBPROJECT_NAME=engine/package-cache +SUBPROJECT_NAME=engine/keyboard-storage . "$KEYMAN_ROOT/web/common.inc.sh" . "$KEYMAN_ROOT/resources/shellHelperFunctions.sh" diff --git a/web/src/engine/package-cache/src/cloud/index.ts b/web/src/engine/keyboard-storage/src/cloud/index.ts similarity index 100% rename from web/src/engine/package-cache/src/cloud/index.ts rename to web/src/engine/keyboard-storage/src/cloud/index.ts diff --git a/web/src/engine/package-cache/src/cloud/queryEngine.ts b/web/src/engine/keyboard-storage/src/cloud/queryEngine.ts similarity index 100% rename from web/src/engine/package-cache/src/cloud/queryEngine.ts rename to web/src/engine/keyboard-storage/src/cloud/queryEngine.ts diff --git a/web/src/engine/package-cache/src/cloud/requesterInterface.ts b/web/src/engine/keyboard-storage/src/cloud/requesterInterface.ts similarity index 100% rename from web/src/engine/package-cache/src/cloud/requesterInterface.ts rename to web/src/engine/keyboard-storage/src/cloud/requesterInterface.ts diff --git a/web/src/engine/package-cache/src/domCloudRequester.ts b/web/src/engine/keyboard-storage/src/domCloudRequester.ts similarity index 100% rename from web/src/engine/package-cache/src/domCloudRequester.ts rename to web/src/engine/keyboard-storage/src/domCloudRequester.ts diff --git a/web/src/engine/package-cache/src/index.ts b/web/src/engine/keyboard-storage/src/index.ts similarity index 100% rename from web/src/engine/package-cache/src/index.ts rename to web/src/engine/keyboard-storage/src/index.ts diff --git a/web/src/engine/package-cache/src/keyboardRequisitioner.ts b/web/src/engine/keyboard-storage/src/keyboardRequisitioner.ts similarity index 100% rename from web/src/engine/package-cache/src/keyboardRequisitioner.ts rename to web/src/engine/keyboard-storage/src/keyboardRequisitioner.ts diff --git a/web/src/engine/package-cache/src/keyboardStub.ts b/web/src/engine/keyboard-storage/src/keyboardStub.ts similarity index 100% rename from web/src/engine/package-cache/src/keyboardStub.ts rename to web/src/engine/keyboard-storage/src/keyboardStub.ts diff --git a/web/src/engine/package-cache/src/modelCache.ts b/web/src/engine/keyboard-storage/src/modelCache.ts similarity index 100% rename from web/src/engine/package-cache/src/modelCache.ts rename to web/src/engine/keyboard-storage/src/modelCache.ts diff --git a/web/src/engine/package-cache/src/nodeCloudRequester.ts b/web/src/engine/keyboard-storage/src/nodeCloudRequester.ts similarity index 100% rename from web/src/engine/package-cache/src/nodeCloudRequester.ts rename to web/src/engine/keyboard-storage/src/nodeCloudRequester.ts diff --git a/web/src/engine/package-cache/src/stubAndKeyboardCache.ts b/web/src/engine/keyboard-storage/src/stubAndKeyboardCache.ts similarity index 100% rename from web/src/engine/package-cache/src/stubAndKeyboardCache.ts rename to web/src/engine/keyboard-storage/src/stubAndKeyboardCache.ts diff --git a/web/src/engine/package-cache/tsconfig.json b/web/src/engine/keyboard-storage/tsconfig.json similarity index 57% rename from web/src/engine/package-cache/tsconfig.json rename to web/src/engine/keyboard-storage/tsconfig.json index 7a2ab5f235..f093be2cbc 100644 --- a/web/src/engine/package-cache/tsconfig.json +++ b/web/src/engine/keyboard-storage/tsconfig.json @@ -3,8 +3,8 @@ "compilerOptions": { "baseUrl": "./", - "outDir": "../../../build/engine/package-cache/obj/", - "tsBuildInfoFile": "../../../build/engine/package-cache/obj/tsconfig.tsbuildinfo", + "outDir": "../../../build/engine/keyboard-storage/obj/", + "tsBuildInfoFile": "../../../build/engine/keyboard-storage/obj/tsconfig.tsbuildinfo", "rootDir": "./src" }, diff --git a/web/src/engine/main/build.sh b/web/src/engine/main/build.sh index 15eaf770f2..737ca9a5bd 100755 --- a/web/src/engine/main/build.sh +++ b/web/src/engine/main/build.sh @@ -19,7 +19,7 @@ builder_describe "Builds the Keyman Engine for Web's common top-level base class "@/web/src/engine/interfaces build" \ "@/web/src/engine/device-detect build" \ "@/web/src/engine/js-processor build" \ - "@/web/src/engine/package-cache build" \ + "@/web/src/engine/keyboard-storage build" \ "@/web/src/engine/osk build" \ "@/developer/src/kmc-model test" \ "clean" \ diff --git a/web/src/engine/main/src/contextManagerBase.ts b/web/src/engine/main/src/contextManagerBase.ts index 5c774aa72d..17fed71bd2 100644 --- a/web/src/engine/main/src/contextManagerBase.ts +++ b/web/src/engine/main/src/contextManagerBase.ts @@ -1,7 +1,7 @@ import { EventEmitter } from 'eventemitter3'; import { ManagedPromise, type Keyboard } from 'keyman/engine/keyboard'; import { type KeyboardInterface, type OutputTarget } from 'keyman/engine/js-processor'; -import { StubAndKeyboardCache, type KeyboardStub } from 'keyman/engine/package-cache'; +import { StubAndKeyboardCache, type KeyboardStub } from 'keyman/engine/keyboard-storage'; import { PredictionContext } from 'keyman/engine/interfaces'; import { EngineConfiguration } from './engineConfiguration.js'; diff --git a/web/src/engine/main/src/engineConfiguration.ts b/web/src/engine/main/src/engineConfiguration.ts index 050a7be11e..aac559acab 100644 --- a/web/src/engine/main/src/engineConfiguration.ts +++ b/web/src/engine/main/src/engineConfiguration.ts @@ -4,7 +4,7 @@ import { DeviceSpec, KeyboardProperties, ManagedPromise, physicalKeyDeviceAlias, import { OutputTarget, RuleBehavior } from 'keyman/engine/js-processor'; import { PathConfiguration, PathOptionDefaults, PathOptionSpec } from "keyman/engine/interfaces"; import { Device } from "keyman/engine/device-detect"; -import { KeyboardStub } from "keyman/engine/package-cache"; +import { KeyboardStub } from "keyman/engine/keyboard-storage"; interface EventMap { 'spacebartext': (mode: SpacebarText) => void; diff --git a/web/src/engine/main/src/keyboardInterface.ts b/web/src/engine/main/src/keyboardInterface.ts index 9d922477b2..1019478594 100644 --- a/web/src/engine/main/src/keyboardInterface.ts +++ b/web/src/engine/main/src/keyboardInterface.ts @@ -1,6 +1,6 @@ import { KeyboardObject } from "keyman/engine/keyboard"; import { KeyboardInterface as KeyboardInterfaceBase } from 'keyman/engine/js-processor'; -import { KeyboardStub, RawKeyboardStub, toUnprefixedKeyboardId as unprefixed } from 'keyman/engine/package-cache'; +import { KeyboardStub, RawKeyboardStub, toUnprefixedKeyboardId as unprefixed } from 'keyman/engine/keyboard-storage'; import { ContextManagerBase } from './contextManagerBase.js'; import { VariableStoreCookieSerializer } from "./variableStoreCookieSerializer.js"; diff --git a/web/src/engine/main/src/keymanEngine.ts b/web/src/engine/main/src/keymanEngine.ts index b91920e70d..30160e683c 100644 --- a/web/src/engine/main/src/keymanEngine.ts +++ b/web/src/engine/main/src/keymanEngine.ts @@ -3,7 +3,7 @@ import { ProcessorInitOptions, RuleBehavior } from 'keyman/engine/js-processor'; import { DOMKeyboardLoader as KeyboardLoader } from "keyman/engine/keyboard/dom-keyboard-loader"; import { InputProcessor } from './headless/inputProcessor.js'; import { OSKView } from "keyman/engine/osk"; -import { KeyboardRequisitioner, ModelCache, toUnprefixedKeyboardId as unprefixed } from "keyman/engine/package-cache"; +import { KeyboardRequisitioner, ModelCache, toUnprefixedKeyboardId as unprefixed } from "keyman/engine/keyboard-storage"; import { ModelSpec, PredictionContext } from "keyman/engine/interfaces"; import { EngineConfiguration, InitOptionSpec } from "./engineConfiguration.js"; @@ -12,7 +12,7 @@ import { ContextManagerBase } from "./contextManagerBase.js"; import HardKeyboardBase from "./hardKeyboard.js"; import { LegacyAPIEvents } from "./legacyAPIEvents.js"; import { EventNames, EventListener, LegacyEventEmitter } from "keyman/engine/events"; -import DOMCloudRequester from "keyman/engine/package-cache/dom-requester"; +import DOMCloudRequester from "keyman/engine/keyboard-storage/dom-requester"; import KEYMAN_VERSION from "@keymanapp/keyman-version"; // From https://stackoverflow.com/a/69328045 diff --git a/web/src/engine/main/tsconfig.json b/web/src/engine/main/tsconfig.json index e3b2b0616c..d2e0580161 100644 --- a/web/src/engine/main/tsconfig.json +++ b/web/src/engine/main/tsconfig.json @@ -13,7 +13,7 @@ "references": [ { "path": "../device-detect" }, { "path": "../osk" }, - { "path": "../package-cache" }, + { "path": "../keyboard-storage" }, { "path": "../interfaces" }, { "path": "../js-processor" } ] diff --git a/web/src/test/auto/dom/cases/browser/contextManager.spec.ts b/web/src/test/auto/dom/cases/browser/contextManager.spec.ts index 291c299b2b..eabf6eefdd 100644 --- a/web/src/test/auto/dom/cases/browser/contextManager.spec.ts +++ b/web/src/test/auto/dom/cases/browser/contextManager.spec.ts @@ -3,7 +3,7 @@ import { outputTargetForElement } from 'keyman/engine/attachment'; import { LegacyEventEmitter } from 'keyman/engine/events'; -import { StubAndKeyboardCache, toPrefixedKeyboardId as prefixed } from 'keyman/engine/package-cache'; +import { StubAndKeyboardCache, toPrefixedKeyboardId as prefixed } from 'keyman/engine/keyboard-storage'; import { KeyboardHarness, MinimalKeymanGlobal } from 'keyman/engine/keyboard'; import { DOMKeyboardLoader } from 'keyman/engine/keyboard/dom-keyboard-loader'; diff --git a/web/src/test/auto/dom/cases/packages/cloudQueries.spec.ts b/web/src/test/auto/dom/cases/keyboard-storage/cloudQueries.spec.ts similarity index 98% rename from web/src/test/auto/dom/cases/packages/cloudQueries.spec.ts rename to web/src/test/auto/dom/cases/keyboard-storage/cloudQueries.spec.ts index 9a2fe93c45..4af873b23c 100644 --- a/web/src/test/auto/dom/cases/packages/cloudQueries.spec.ts +++ b/web/src/test/auto/dom/cases/keyboard-storage/cloudQueries.spec.ts @@ -1,9 +1,9 @@ import { assert } from 'chai'; import sinon from 'sinon'; -import { CloudQueryEngine, type KeyboardStub } from 'keyman/engine/package-cache'; +import { CloudQueryEngine, type KeyboardStub } from 'keyman/engine/keyboard-storage'; import { PathConfiguration } from 'keyman/engine/interfaces'; -import DOMCloudRequester from 'keyman/engine/package-cache/dom-requester'; +import DOMCloudRequester from 'keyman/engine/keyboard-storage/dom-requester'; import { ManagedPromise } from '@keymanapp/web-utils'; const pathConfig = new PathConfiguration({ diff --git a/web/src/test/auto/dom/cases/packages/domCloudRequester.spec.ts b/web/src/test/auto/dom/cases/keyboard-storage/domCloudRequester.spec.ts similarity index 97% rename from web/src/test/auto/dom/cases/packages/domCloudRequester.spec.ts rename to web/src/test/auto/dom/cases/keyboard-storage/domCloudRequester.spec.ts index 840acf9d99..7101bfd9f7 100644 --- a/web/src/test/auto/dom/cases/packages/domCloudRequester.spec.ts +++ b/web/src/test/auto/dom/cases/keyboard-storage/domCloudRequester.spec.ts @@ -1,7 +1,7 @@ import { assert } from 'chai'; import sinon from 'sinon'; -import DOMCloudRequester from 'keyman/engine/package-cache/dom-requester'; +import DOMCloudRequester from 'keyman/engine/keyboard-storage/dom-requester'; describe("Mocked cloud query results ('canary' testing)", () => { function performMockedRequest(mockedResultsPath: string) { diff --git a/web/src/test/auto/dom/cases/packages/keyboardRequisitioner.spec.ts b/web/src/test/auto/dom/cases/keyboard-storage/keyboardRequisitioner.spec.ts similarity index 95% rename from web/src/test/auto/dom/cases/packages/keyboardRequisitioner.spec.ts rename to web/src/test/auto/dom/cases/keyboard-storage/keyboardRequisitioner.spec.ts index 7ad8356a32..bada557bf8 100644 --- a/web/src/test/auto/dom/cases/packages/keyboardRequisitioner.spec.ts +++ b/web/src/test/auto/dom/cases/keyboard-storage/keyboardRequisitioner.spec.ts @@ -4,8 +4,8 @@ import sinon from 'sinon'; import { KeyboardHarness, MinimalKeymanGlobal } from 'keyman/engine/keyboard'; import { DOMKeyboardLoader } from 'keyman/engine/keyboard/dom-keyboard-loader'; import { PathConfiguration } from 'keyman/engine/interfaces'; -import { CloudQueryEngine, KeyboardRequisitioner, type KeyboardStub } from 'keyman/engine/package-cache'; -import DOMCloudRequester from 'keyman/engine/package-cache/dom-requester'; +import { CloudQueryEngine, KeyboardRequisitioner, type KeyboardStub } from 'keyman/engine/keyboard-storage'; +import DOMCloudRequester from 'keyman/engine/keyboard-storage/dom-requester'; const pathConfig = new PathConfiguration({ root: '', @@ -14,7 +14,7 @@ const pathConfig = new PathConfiguration({ fonts: '', // The primary / top-level module here is the keyboard-cache bundle. // So, we set up our path config based upon that module for verification purposes. -}, 'http://localhost:9876/@keymanapp/keyman/build/engine/package-cache/lib'); // TODO: set up the current path like actual KMW does it. +}, 'http://localhost:9876/@keymanapp/keyman/build/engine/keyboard-storage/lib'); // TODO: set up the current path like actual KMW does it. /** * Performs mocking setup to facilitate unit testing for the `CloudQueryEngine` class. diff --git a/web/src/test/auto/dom/kbdLoader.ts b/web/src/test/auto/dom/kbdLoader.ts index 8b5c081c75..b0d092c12d 100644 --- a/web/src/test/auto/dom/kbdLoader.ts +++ b/web/src/test/auto/dom/kbdLoader.ts @@ -9,7 +9,7 @@ import { } from 'keyman/engine/keyboard'; import { KeyboardInterface } from 'keyman/engine/js-processor'; -import { KeyboardStub } from 'keyman/engine/package-cache'; +import { KeyboardStub } from 'keyman/engine/keyboard-storage'; const loader = new DOMKeyboardLoader(new KeyboardInterface(window, MinimalKeymanGlobal)); diff --git a/web/src/test/auto/dom/web-test-runner.config.mjs b/web/src/test/auto/dom/web-test-runner.config.mjs index 1cd8ed0ca2..62edfc7dbf 100644 --- a/web/src/test/auto/dom/web-test-runner.config.mjs +++ b/web/src/test/auto/dom/web-test-runner.config.mjs @@ -56,9 +56,9 @@ export default { files: ['build/test/dom/cases/osk/**/*.spec.mjs'] }, { - name: 'engine/package-cache', + name: 'engine/keyboard-storage', // Relative, from the containing package.json - files: ['build/test/dom/cases/packages/**/*.spec.mjs'] + files: ['build/test/dom/cases/keyboard-storage/**/*.spec.mjs'] } ], middleware: [ diff --git a/web/src/test/auto/headless/engine/package-cache/cloudQueries.js b/web/src/test/auto/headless/engine/keyboard-storage/cloudQueries.js similarity index 98% rename from web/src/test/auto/headless/engine/package-cache/cloudQueries.js rename to web/src/test/auto/headless/engine/keyboard-storage/cloudQueries.js index 4f379ea563..eb078c1768 100644 --- a/web/src/test/auto/headless/engine/package-cache/cloudQueries.js +++ b/web/src/test/auto/headless/engine/keyboard-storage/cloudQueries.js @@ -2,9 +2,9 @@ import { assert } from 'chai'; import sinon from 'sinon'; import { ManagedPromise } from '@keymanapp/web-utils'; -import { CloudQueryEngine, StubAndKeyboardCache, toPrefixedKeyboardId as prefixed } from 'keyman/engine/package-cache'; +import { CloudQueryEngine, StubAndKeyboardCache, toPrefixedKeyboardId as prefixed } from 'keyman/engine/keyboard-storage'; import { PathConfiguration } from 'keyman/engine/interfaces'; -import NodeCloudRequester from 'keyman/engine/package-cache/node-requester'; +import NodeCloudRequester from 'keyman/engine/keyboard-storage/node-requester'; import path from 'path'; import { fileURLToPath } from 'url'; diff --git a/web/src/test/auto/headless/engine/package-cache/keyboardRequisitioner.js b/web/src/test/auto/headless/engine/keyboard-storage/keyboardRequisitioner.js similarity index 98% rename from web/src/test/auto/headless/engine/package-cache/keyboardRequisitioner.js rename to web/src/test/auto/headless/engine/keyboard-storage/keyboardRequisitioner.js index 2ca0578790..b158f4ef9a 100644 --- a/web/src/test/auto/headless/engine/package-cache/keyboardRequisitioner.js +++ b/web/src/test/auto/headless/engine/keyboard-storage/keyboardRequisitioner.js @@ -7,9 +7,9 @@ import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader' import { KeyboardRequisitioner, toPrefixedKeyboardId as prefixed -} from 'keyman/engine/package-cache'; +} from 'keyman/engine/keyboard-storage'; import { PathConfiguration } from 'keyman/engine/interfaces'; -import NodeCloudRequester from 'keyman/engine/package-cache/node-requester'; +import NodeCloudRequester from 'keyman/engine/keyboard-storage/node-requester'; import path from 'path'; import { fileURLToPath } from 'url'; @@ -33,7 +33,7 @@ const pathConfig = new PathConfiguration({ // Keyboard paths in fixtures are relative to the repository root. keyboards: `file:///${resolvedResourcePackage}/../../..`, // the one part NEEDED for unit tests below. fonts: '', -}, `file:///${path.dirname(require.resolve('keyman/engine/package-cache'))}`); +}, `file:///${path.dirname(require.resolve('keyman/engine/keyboard-storage'))}`); /** * Performs mocking setup to facilitate unit testing for the `CloudQueryEngine` class. diff --git a/web/src/test/auto/headless/engine/package-cache/keyboardStub.js b/web/src/test/auto/headless/engine/keyboard-storage/keyboardStub.js similarity index 96% rename from web/src/test/auto/headless/engine/package-cache/keyboardStub.js rename to web/src/test/auto/headless/engine/keyboard-storage/keyboardStub.js index 6b81e187a4..af7d6b6a57 100644 --- a/web/src/test/auto/headless/engine/package-cache/keyboardStub.js +++ b/web/src/test/auto/headless/engine/keyboard-storage/keyboardStub.js @@ -1,8 +1,8 @@ import { assert } from 'chai'; import sinon from 'sinon'; -import { KeyboardStub } from 'keyman/engine/package-cache'; -import NodeCloudRequester from 'keyman/engine/package-cache/node-requester'; +import { KeyboardStub } from 'keyman/engine/keyboard-storage'; +import NodeCloudRequester from 'keyman/engine/keyboard-storage/node-requester'; import path from 'path'; import { fileURLToPath } from 'url'; diff --git a/web/src/test/auto/headless/engine/package-cache/nodeCloudRequester.js b/web/src/test/auto/headless/engine/keyboard-storage/nodeCloudRequester.js similarity index 97% rename from web/src/test/auto/headless/engine/package-cache/nodeCloudRequester.js rename to web/src/test/auto/headless/engine/keyboard-storage/nodeCloudRequester.js index 708781932c..07ac9e98fb 100644 --- a/web/src/test/auto/headless/engine/package-cache/nodeCloudRequester.js +++ b/web/src/test/auto/headless/engine/keyboard-storage/nodeCloudRequester.js @@ -1,7 +1,7 @@ import { assert } from 'chai'; import sinon from 'sinon'; -import NodeCloudRequester from 'keyman/engine/package-cache/node-requester'; +import NodeCloudRequester from 'keyman/engine/keyboard-storage/node-requester'; import path from 'path'; import { fileURLToPath } from 'url'; diff --git a/web/src/test/auto/headless/engine/package-cache/stubAndKeyboardCache.js b/web/src/test/auto/headless/engine/keyboard-storage/stubAndKeyboardCache.js similarity index 99% rename from web/src/test/auto/headless/engine/package-cache/stubAndKeyboardCache.js rename to web/src/test/auto/headless/engine/keyboard-storage/stubAndKeyboardCache.js index f49bb1238f..7260b9982e 100644 --- a/web/src/test/auto/headless/engine/package-cache/stubAndKeyboardCache.js +++ b/web/src/test/auto/headless/engine/keyboard-storage/stubAndKeyboardCache.js @@ -2,7 +2,7 @@ import { assert } from 'chai'; import sinon from 'sinon'; import fs from 'fs'; -import { KeyboardStub, StubAndKeyboardCache } from 'keyman/engine/package-cache'; +import { KeyboardStub, StubAndKeyboardCache } from 'keyman/engine/keyboard-storage'; import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader'; import { KeyboardHarness, MinimalKeymanGlobal } from 'keyman/engine/keyboard'; diff --git a/web/src/test/auto/integrated/cases/engine.spec.ts b/web/src/test/auto/integrated/cases/engine.spec.ts index 1ef78358a2..a7e624cbf4 100644 --- a/web/src/test/auto/integrated/cases/engine.spec.ts +++ b/web/src/test/auto/integrated/cases/engine.spec.ts @@ -9,7 +9,7 @@ import { import * as KMWRecorder from '#recorder'; import { type KeymanEngine, type KeyboardInterface } from 'keyman/app/browser'; -import { type KeyboardStub } from 'keyman/engine/package-cache'; +import { type KeyboardStub } from 'keyman/engine/keyboard-storage'; import { type OSKInputEventSpec } from '#recorder'; type WindowKey = keyof typeof window; diff --git a/web/src/test/auto/integrated/test_utils.ts b/web/src/test/auto/integrated/test_utils.ts index e3c49ef0ee..6e04885b1a 100644 --- a/web/src/test/auto/integrated/test_utils.ts +++ b/web/src/test/auto/integrated/test_utils.ts @@ -3,7 +3,7 @@ import Device from 'keyman/engine/device-detect'; import * as KMWRecorder from '#recorder'; import { type BrowserInitOptionSpec, type KeymanEngine } from 'keyman/app/browser'; -import { ErrorStub, type KeyboardAPISpec, type KeyboardStub } from 'keyman/engine/package-cache'; +import { ErrorStub, type KeyboardAPISpec, type KeyboardStub } from 'keyman/engine/keyboard-storage'; type WindowKey = keyof typeof window; const keyman_window = 'keyman' as WindowKey; From b9aa9ccd8ca320207c5a3864933ff3ef960c1570 Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Fri, 9 Aug 2024 11:31:51 +0200 Subject: [PATCH 325/327] =?UTF-8?q?refactor(web):=20move=20`predictive-tex?= =?UTF-8?q?t`=20=E2=86=92=20`worker-main`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This moves `common/predictive-text/` → `web/src/engine/predictive-text/worker-main/`. This also moves `common/test/predictive-text/` → `web/src/test/manual/predictive-text/`. Note though that this testing tool is still broken. Fixes: #12134 --- common/predictive-text/.build-builder | 1 - common/predictive-text/src/tsconfig.json | 23 ---------- docs/CODEOWNERS | 42 +++++++++--------- linux/scripts/dist.sh | 37 ++++++++++----- package-lock.json | 8 ++-- package.json | 4 +- tsconfig.json | 2 +- web/README.md | 2 +- web/build.sh | 6 ++- web/src/engine/main/build.sh | 2 +- .../predictive-text/worker-main}/.gitignore | 0 .../predictive-text/worker-main}/README.md | 0 .../predictive-text/worker-main}/build.sh | 8 ++-- .../worker-main}/docs/build.sh | 0 .../worker-main}/docs/lmlayer-states.dot | 0 .../worker-main}/docs/lmlayer-states.png | Bin .../docs/predictive-text-sequence.png | Bin .../docs/worker-communication-protocol.md | 0 .../predictive-text/worker-main}/package.json | 0 .../predictive-text/worker-main}/src/index.ts | 0 .../worker-main}/src/lmlayer.ts | 0 .../worker-main}/src/node/index.ts | 0 .../worker-main}/src/node/mappedWorker.ts | 0 .../src/node/sourcemappedWorker.ts | 0 .../worker-main}/src/node/tsconfig.json | 2 +- .../worker-main}/src/node/worker.ts | 0 .../worker-main}/src/promise-store.ts | 0 .../worker-main/src/tsconfig.json | 23 ++++++++++ .../worker-main}/src/unwrap.ts | 0 .../worker-main}/src/web/index.ts | 0 .../src/web/sourcemappedWorker.ts | 0 .../worker-main}/src/web/tsconfig.json | 2 +- .../worker-main}/src/web/worker.ts | 0 .../worker-main}/src/worker-interface.d.ts | 0 .../worker-main}/tsconfig.all.json | 12 ++--- .../unit_tests/headless/promise-store.js | 0 .../unit_tests/headless/top-level-lmlayer.js | 0 .../headless/worker-dummy-integration.js | 0 .../headless/worker-trie-integration.js | 0 .../cases/top-level-lmlayer.spec.ts | 0 .../cases/worker-dummy-integration.spec.ts | 0 .../cases/worker-trie-integration.spec.ts | 0 .../unit_tests/in_browser/helpers.mjs | 0 .../in_browser/web-test-runner.CI.config.mjs | 0 .../in_browser/web-test-runner.config.mjs | 2 +- .../worker-main}/unit_tests/test.sh | 2 +- .../test/manual}/predictive-text/.gitignore | 0 .../test/manual}/predictive-text/README.md | 5 +-- .../src/test/manual}/predictive-text/index.js | 4 +- .../test/manual}/predictive-text/package.json | 0 50 files changed, 101 insertions(+), 86 deletions(-) delete mode 100644 common/predictive-text/.build-builder delete mode 100644 common/predictive-text/src/tsconfig.json rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/.gitignore (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/README.md (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/build.sh (84%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/docs/build.sh (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/docs/lmlayer-states.dot (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/docs/lmlayer-states.png (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/docs/predictive-text-sequence.png (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/docs/worker-communication-protocol.md (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/package.json (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/src/index.ts (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/src/lmlayer.ts (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/src/node/index.ts (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/src/node/mappedWorker.ts (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/src/node/sourcemappedWorker.ts (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/src/node/tsconfig.json (89%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/src/node/worker.ts (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/src/promise-store.ts (100%) create mode 100644 web/src/engine/predictive-text/worker-main/src/tsconfig.json rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/src/unwrap.ts (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/src/web/index.ts (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/src/web/sourcemappedWorker.ts (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/src/web/tsconfig.json (83%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/src/web/worker.ts (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/src/worker-interface.d.ts (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/tsconfig.all.json (63%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/unit_tests/headless/promise-store.js (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/unit_tests/headless/top-level-lmlayer.js (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/unit_tests/headless/worker-dummy-integration.js (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/unit_tests/headless/worker-trie-integration.js (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/unit_tests/in_browser/cases/top-level-lmlayer.spec.ts (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/unit_tests/in_browser/cases/worker-dummy-integration.spec.ts (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/unit_tests/in_browser/cases/worker-trie-integration.spec.ts (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/unit_tests/in_browser/helpers.mjs (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/unit_tests/in_browser/web-test-runner.CI.config.mjs (100%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/unit_tests/in_browser/web-test-runner.config.mjs (96%) rename {common/predictive-text => web/src/engine/predictive-text/worker-main}/unit_tests/test.sh (98%) rename {common/test => web/src/test/manual}/predictive-text/.gitignore (100%) rename {common/test => web/src/test/manual}/predictive-text/README.md (96%) rename {common/test => web/src/test/manual}/predictive-text/index.js (99%) rename {common/test => web/src/test/manual}/predictive-text/package.json (100%) diff --git a/common/predictive-text/.build-builder b/common/predictive-text/.build-builder deleted file mode 100644 index 4e15741a62..0000000000 --- a/common/predictive-text/.build-builder +++ /dev/null @@ -1 +0,0 @@ -The presence of this file tells CI to use the new builder_ style parameters for build.sh and unit_tests/test.sh. \ No newline at end of file diff --git a/common/predictive-text/src/tsconfig.json b/common/predictive-text/src/tsconfig.json deleted file mode 100644 index 675bf7cd53..0000000000 --- a/common/predictive-text/src/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "extends": "../../web/tsconfig.kmw-main-base.json", - - "compilerOptions": { - "baseUrl": "./", - "outDir": "../build/obj", - "tsBuildInfoFile": "../build/obj/tsconfig.tsbuildinfo", - "rootDir": "./" - }, - "references": [ - { "path": "../../web/utils" }, - { "path": "../../models/types"}, - { "path": "../../models/wordbreakers"}, - { "path": "../../web/lm-message-types"}, - { "path": "../../models/templates"} - ], - "include" : [ "./*.ts" ], - "exclude" : [ - "node", - "web", - "index.ts" // It's handled by the final layer. - ] -} diff --git a/docs/CODEOWNERS b/docs/CODEOWNERS index 7902ce7a68..75530e6bde 100644 --- a/docs/CODEOWNERS +++ b/docs/CODEOWNERS @@ -3,30 +3,30 @@ # # @darcywong00 @mcdurdin @ermshiperete @rc-swag @SabineSIL @sgschantz -/android/ @darcywong00 @sgschantz +/android/ @darcywong00 @sgschantz -/common/ @mcdurdin @rc-swag -/core/ @mcdurdin @rc-swag -/common/lexical-model-types/ @jahorton @mcdurdin -/common/models/ @jahorton @mcdurdin -/common/predictive-text/ @jahorton @mcdurdin -/common/schemas/ @mcdurdin @jahorton -/common/test/ @mcdurdin @ermshiperete -/common/web/ @jahorton @mcdurdin +/common/ @mcdurdin @rc-swag +/core/ @mcdurdin @rc-swag +/common/lexical-model-types/ @jahorton @mcdurdin +/common/models/ @jahorton @mcdurdin +/common/schemas/ @mcdurdin @jahorton +/common/test/ @mcdurdin @ermshiperete +/common/web/ @jahorton @mcdurdin -/developer/ @mcdurdin @darcywong00 -/docs/ @mcdurdin @jahorton -/ios/ @sgschantz @jahorton -/linux/ @ermshiperete @darcywong00 -/mac/ @sgschantz @SabineSIL +/developer/ @mcdurdin @darcywong00 +/docs/ @mcdurdin @jahorton +/ios/ @sgschantz @jahorton +/linux/ @ermshiperete @darcywong00 +/mac/ @sgschantz @SabineSIL -/oem/firstvoices/android/ @darcywong00 @sgschantz -/oem/firstvoices/common/ @mcdurdin @rc-swag -/oem/firstvoices/ios/ @sgschantz @jahorton -/oem/firstvoices/windows/ @rc-swag @ermshiperete -/resources/ @mcdurdin @jahorton +/oem/firstvoices/android/ @darcywong00 @sgschantz +/oem/firstvoices/common/ @mcdurdin @rc-swag +/oem/firstvoices/ios/ @sgschantz @jahorton +/oem/firstvoices/windows/ @rc-swag @ermshiperete +/resources/ @mcdurdin @jahorton # Web is currently shared between Eberhard and Joshua: -/web/ @ermshiperete @jahorton +/web/ @ermshiperete @jahorton +/web/src/engine/predictive-text/ @jahorton @mcdurdin -/windows/ @rc-swag @ermshiperete +/windows/ @rc-swag @ermshiperete diff --git a/linux/scripts/dist.sh b/linux/scripts/dist.sh index 0038034d42..6ef0be7d8b 100755 --- a/linux/scripts/dist.sh +++ b/linux/scripts/dist.sh @@ -30,28 +30,37 @@ cp -a debian ../ cd .. echo "3.0 (native)" > debian/source/format dch keyman --newversion "${VERSION}" --force-bad-version --nomultimaint -dpkg-source --tar-ignore=*~ --tar-ignore=.git --tar-ignore=.gitattributes \ - --tar-ignore=.gitignore --tar-ignore=experiments --tar-ignore=debian \ - --tar-ignore=.github --tar-ignore=.vscode --tar-ignore=android \ +dpkg-source --tar-ignore=*~ \ + --tar-ignore=.git \ + --tar-ignore=.gitattributes \ + --tar-ignore=.gitignore \ + --tar-ignore=experiments \ + --tar-ignore=debian \ + --tar-ignore=.github \ + --tar-ignore=.vscode \ + --tar-ignore=android \ --tar-ignore=.devcontainer \ --tar-ignore=artifacts \ \ --tar-ignore=common/models \ - --tar-ignore=common/predictive-text \ --tar-ignore=common/resources \ --tar-ignore=common/schemas \ --tar-ignore=common/test/keyboards/build.* \ - --tar-ignore=common/test/predictive-text \ --tar-ignore=common/test/resources \ --tar-ignore=common/web \ --tar-ignore=common/windows \ \ --tar-ignore=core/build \ - --tar-ignore=developer --tar-ignore=docs --tar-ignore=ios \ + --tar-ignore=developer \ + --tar-ignore=docs \ + --tar-ignore=ios \ --tar-ignore=linux/keyman-config/keyman_config/version.py \ - --tar-ignore=linux/keyman-config/buildtools/build-langtags.py --tar-ignore=__pycache__ \ + --tar-ignore=linux/keyman-config/buildtools/build-langtags.py \ + --tar-ignore=__pycache__ \ --tar-ignore=linux/help \ - --tar-ignore=mac --tar-ignore=node_modules --tar-ignore=oem \ + --tar-ignore=mac \ + --tar-ignore=node_modules \ + --tar-ignore=oem \ --tar-ignore=linux/build \ --tar-ignore=linux/builddebs \ --tar-ignore=linux/ibus-keyman/build \ @@ -60,11 +69,17 @@ dpkg-source --tar-ignore=*~ --tar-ignore=.git --tar-ignore=.gitattributes \ --tar-ignore=resources/environment.sh \ --tar-ignore=resources/git-hooks \ --tar-ignore=resources/scopes \ - --tar-ignore=resources/build/*.lua --tar-ignore=resources/build/jq* \ + --tar-ignore=resources/build/*.lua \ + --tar-ignore=resources/build/jq* \ --tar-ignore=results \ --tar-ignore=tmp \ - --tar-ignore=web --tar-ignore=windows --tar-ignore=keyman_1* \ - --tar-ignore=dist --tar-ignore=VERSION -Zgzip -b . + --tar-ignore=web \ + --tar-ignore=windows \ + --tar-ignore=keyman_1* \ + --tar-ignore=dist \ + --tar-ignore=VERSION \ + \ + -Zgzip -b . mv ../keyman_"${VERSION}".tar.gz linux/dist/keyman-"${VERSION}".tar.gz echo "3.0 (quilt)" > debian/source/format cd "$BASEDIR" diff --git a/package-lock.json b/package-lock.json index f6ea28257a..ad53581202 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,9 +25,9 @@ "common/test/resources", "common/tools/*", "common/web/*", - "common/predictive-text", "common/tools/hextobin", - "web" + "web", + "web/src/engine/predictive-text/*" ], "dependencies": { "@keymanapp/common-types": "file:common/web/types", @@ -108,7 +108,7 @@ "typescript": "^5.4.5" } }, - "common/predictive-text": { + "web/src/engine/predictive-text/worker-main": { "name": "@keymanapp/lexical-model-layer", "license": "MIT", "dependencies": { @@ -2892,7 +2892,7 @@ "link": true }, "node_modules/@keymanapp/lexical-model-layer": { - "resolved": "common/predictive-text", + "resolved": "web/src/engine/predictive-text/worker-main", "link": true }, "node_modules/@keymanapp/lm-message-types": { diff --git a/package.json b/package.json index 638f2b2fad..3f0012db10 100644 --- a/package.json +++ b/package.json @@ -50,9 +50,9 @@ "common/test/resources", "common/tools/*", "common/web/*", - "common/predictive-text", "common/tools/hextobin", - "web" + "web", + "web/src/engine/predictive-text/*" ], "dependencies": { "@keymanapp/common-types": "file:common/web/types", diff --git a/tsconfig.json b/tsconfig.json index 8e6596a231..42b3fd1a99 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,6 @@ { "path": "./common/models/templates/tsconfig.json" }, { "path": "./common/models/types/tsconfig.json" }, { "path": "./common/models/wordbreakers/tsconfig.json" }, - { "path": "./common/predictive-text/tsconfig.all.json" }, { "path": "./common/tools/hextobin/" }, { "path": "./common/web/gesture-recognizer/tsconfig.json" }, @@ -43,6 +42,7 @@ { "path": "./resources/build/version/" }, { "path": "./web/src/tsconfig.all.json" }, + { "path": "./web/src/engine/predictive-text/worker-main/tsconfig.all.json" }, // { "path": "./web/tools/recorder/tsconfig.json" }, // { "path": "./web/tools/sourcemap-root/tsconfig.json" }, ] diff --git a/web/README.md b/web/README.md index 4f35643e1a..1e41497657 100644 --- a/web/README.md +++ b/web/README.md @@ -92,7 +92,7 @@ graph TD; LMWorker["@keymanapp/lm-worker
(/common/web/lm-worker)"]; LMWorker-->Models; LMWorker-->Wordbreakers; - LMLayer["@keymanapp/lexical-model-layer
(/common/predictive-text)"]; + LMLayer["@keymanapp/lexical-model-layer
(/web/src/engine/predictive-text/worker-main)"]; LMLayer-->LMWorker; Gestures["@keymanapp/gesture-recognizer
(/common/web/gesture-recognizer)"]; Gestures-->WebUtils; diff --git a/web/build.sh b/web/build.sh index 4705bc55de..f0dd201bc8 100755 --- a/web/build.sh +++ b/web/build.sh @@ -27,12 +27,13 @@ builder_describe "Builds engine modules for Keyman Engine for Web (KMW)." \ ":engine/dom-utils A common subset of function used for DOM calculations, layout, etc" \ ":engine/events Specialized classes utilized to support KMW API events" \ ":engine/element-wrappers Subset used to integrate with website elements" \ + ":engine/interfaces Subset used to configure KMW" \ ":engine/js-processor Build JS processor for KMW" \ ":engine/keyboard Builds KMW's keyboard-loading and caching code" \ ":engine/keyboard-storage Subset used to collate keyboards and request them from the cloud" \ ":engine/main Builds all common code used by KMW's app/-level targets" \ ":engine/osk Builds the Web OSK module" \ - ":engine/interfaces Subset used to configure KMW" \ + ":engine/predictive-text=src/engine/predictive-text/worker-main Builds KMW's predictive text module" \ ":samples Builds all needed resources for the KMW sample-page set" \ ":tools Builds engine-related development resources" \ ":test-pages=src/test/manual Builds resources needed for the KMW manual testing pages" \ @@ -59,12 +60,13 @@ builder_describe_outputs \ build:engine/dom-utils "/web/build/engine/dom-utils/obj/index.js" \ build:engine/events "/web/build/engine/events/lib/index.mjs" \ build:engine/element-wrappers "/web/build/engine/element-wrappers/lib/index.mjs" \ + build:engine/interfaces "/web/build/engine/interfaces/lib/index.mjs" \ build:engine/js-processor "/web/build/engine/js-processor/lib/index.mjs" \ build:engine/keyboard "/web/build/engine/keyboard/lib/index.mjs" \ build:engine/keyboard-storage "/web/build/engine/keyboard-storage/lib/index.mjs" \ build:engine/main "/web/build/engine/main/lib/index.mjs" \ build:engine/osk "/web/build/engine/osk/lib/index.mjs" \ - build:engine/interfaces "/web/build/engine/interfaces/lib/index.mjs" \ + build:engine/predictive-text "/web/src/engine/predictive-text/worker-main/build/lib/web/index.mjs" \ build:samples "/web/src/samples/simplest/keymanweb.js" \ build:tools "/web/build/tools/building/sourcemap-root/index.js" \ build:test-pages "/web/build/test-resources/sentry-manager.js" diff --git a/web/src/engine/main/build.sh b/web/src/engine/main/build.sh index 737ca9a5bd..77673626e0 100755 --- a/web/src/engine/main/build.sh +++ b/web/src/engine/main/build.sh @@ -15,12 +15,12 @@ SUBPROJECT_NAME=engine/main builder_describe "Builds the Keyman Engine for Web's common top-level base classes." \ "@/common/web/keyman-version" \ "@/web/src/engine/keyboard" \ - "@/common/predictive-text" \ "@/web/src/engine/interfaces build" \ "@/web/src/engine/device-detect build" \ "@/web/src/engine/js-processor build" \ "@/web/src/engine/keyboard-storage build" \ "@/web/src/engine/osk build" \ + "@/web/src/engine/predictive-text/worker-main" \ "@/developer/src/kmc-model test" \ "clean" \ "configure" \ diff --git a/common/predictive-text/.gitignore b/web/src/engine/predictive-text/worker-main/.gitignore similarity index 100% rename from common/predictive-text/.gitignore rename to web/src/engine/predictive-text/worker-main/.gitignore diff --git a/common/predictive-text/README.md b/web/src/engine/predictive-text/worker-main/README.md similarity index 100% rename from common/predictive-text/README.md rename to web/src/engine/predictive-text/worker-main/README.md diff --git a/common/predictive-text/build.sh b/web/src/engine/predictive-text/worker-main/build.sh similarity index 84% rename from common/predictive-text/build.sh rename to web/src/engine/predictive-text/worker-main/build.sh index b9ab601691..4120fce53b 100755 --- a/common/predictive-text/build.sh +++ b/web/src/engine/predictive-text/worker-main/build.sh @@ -8,7 +8,7 @@ ## START STANDARD BUILD SCRIPT INCLUDE # adjust relative paths as necessary THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" -. "${THIS_SCRIPT%/*}/../../resources/build/builder.inc.sh" +. "${THIS_SCRIPT%/*}/../../../../../resources/build/builder.inc.sh" ## END STANDARD BUILD SCRIPT INCLUDE . "$KEYMAN_ROOT/resources/shellHelperFunctions.sh" @@ -31,7 +31,7 @@ builder_describe "Builds the lm-layer module" \ builder_describe_outputs \ configure /node_modules \ - build /common/predictive-text/build/lib/web/index.mjs # is built by the final step. + build /web/src/engine/predictive-text/worker-main/build/lib/web/index.mjs # is built by the final step. builder_parse "$@" @@ -48,8 +48,8 @@ function do_build() { tsc -b ./tsconfig.all.json # esbuild-bundled products at this level are not intended to be used for anything but testing. - $BUNDLE_CMD "${KEYMAN_ROOT}/common/predictive-text/build/obj/web/index.js" \ - --out "${KEYMAN_ROOT}/common/predictive-text/build/lib/web/index.mjs" \ + $BUNDLE_CMD "${KEYMAN_ROOT}/web/src/engine/predictive-text/worker-main/build/obj/web/index.js" \ + --out "${KEYMAN_ROOT}/web/src/engine/predictive-text/worker-main/build/lib/web/index.mjs" \ --format esm } diff --git a/common/predictive-text/docs/build.sh b/web/src/engine/predictive-text/worker-main/docs/build.sh similarity index 100% rename from common/predictive-text/docs/build.sh rename to web/src/engine/predictive-text/worker-main/docs/build.sh diff --git a/common/predictive-text/docs/lmlayer-states.dot b/web/src/engine/predictive-text/worker-main/docs/lmlayer-states.dot similarity index 100% rename from common/predictive-text/docs/lmlayer-states.dot rename to web/src/engine/predictive-text/worker-main/docs/lmlayer-states.dot diff --git a/common/predictive-text/docs/lmlayer-states.png b/web/src/engine/predictive-text/worker-main/docs/lmlayer-states.png similarity index 100% rename from common/predictive-text/docs/lmlayer-states.png rename to web/src/engine/predictive-text/worker-main/docs/lmlayer-states.png diff --git a/common/predictive-text/docs/predictive-text-sequence.png b/web/src/engine/predictive-text/worker-main/docs/predictive-text-sequence.png similarity index 100% rename from common/predictive-text/docs/predictive-text-sequence.png rename to web/src/engine/predictive-text/worker-main/docs/predictive-text-sequence.png diff --git a/common/predictive-text/docs/worker-communication-protocol.md b/web/src/engine/predictive-text/worker-main/docs/worker-communication-protocol.md similarity index 100% rename from common/predictive-text/docs/worker-communication-protocol.md rename to web/src/engine/predictive-text/worker-main/docs/worker-communication-protocol.md diff --git a/common/predictive-text/package.json b/web/src/engine/predictive-text/worker-main/package.json similarity index 100% rename from common/predictive-text/package.json rename to web/src/engine/predictive-text/worker-main/package.json diff --git a/common/predictive-text/src/index.ts b/web/src/engine/predictive-text/worker-main/src/index.ts similarity index 100% rename from common/predictive-text/src/index.ts rename to web/src/engine/predictive-text/worker-main/src/index.ts diff --git a/common/predictive-text/src/lmlayer.ts b/web/src/engine/predictive-text/worker-main/src/lmlayer.ts similarity index 100% rename from common/predictive-text/src/lmlayer.ts rename to web/src/engine/predictive-text/worker-main/src/lmlayer.ts diff --git a/common/predictive-text/src/node/index.ts b/web/src/engine/predictive-text/worker-main/src/node/index.ts similarity index 100% rename from common/predictive-text/src/node/index.ts rename to web/src/engine/predictive-text/worker-main/src/node/index.ts diff --git a/common/predictive-text/src/node/mappedWorker.ts b/web/src/engine/predictive-text/worker-main/src/node/mappedWorker.ts similarity index 100% rename from common/predictive-text/src/node/mappedWorker.ts rename to web/src/engine/predictive-text/worker-main/src/node/mappedWorker.ts diff --git a/common/predictive-text/src/node/sourcemappedWorker.ts b/web/src/engine/predictive-text/worker-main/src/node/sourcemappedWorker.ts similarity index 100% rename from common/predictive-text/src/node/sourcemappedWorker.ts rename to web/src/engine/predictive-text/worker-main/src/node/sourcemappedWorker.ts diff --git a/common/predictive-text/src/node/tsconfig.json b/web/src/engine/predictive-text/worker-main/src/node/tsconfig.json similarity index 89% rename from common/predictive-text/src/node/tsconfig.json rename to web/src/engine/predictive-text/worker-main/src/node/tsconfig.json index f95364c417..a1ab0f2f7c 100644 --- a/common/predictive-text/src/node/tsconfig.json +++ b/web/src/engine/predictive-text/worker-main/src/node/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../../web/tsconfig.kmw-main-base.json", + "extends": "../../../../../../tsconfig.base.json", "compilerOptions": { // The Worker class needs access to the `new` keyword, else Node will throw an // error when constructing the Worker for unit tests. ES6 is sufficient. diff --git a/common/predictive-text/src/node/worker.ts b/web/src/engine/predictive-text/worker-main/src/node/worker.ts similarity index 100% rename from common/predictive-text/src/node/worker.ts rename to web/src/engine/predictive-text/worker-main/src/node/worker.ts diff --git a/common/predictive-text/src/promise-store.ts b/web/src/engine/predictive-text/worker-main/src/promise-store.ts similarity index 100% rename from common/predictive-text/src/promise-store.ts rename to web/src/engine/predictive-text/worker-main/src/promise-store.ts diff --git a/web/src/engine/predictive-text/worker-main/src/tsconfig.json b/web/src/engine/predictive-text/worker-main/src/tsconfig.json new file mode 100644 index 0000000000..b7cd725cf9 --- /dev/null +++ b/web/src/engine/predictive-text/worker-main/src/tsconfig.json @@ -0,0 +1,23 @@ +{ + "extends": "../../../../../tsconfig.base.json", + + "compilerOptions": { + "baseUrl": "./", + "outDir": "../build/obj", + "tsBuildInfoFile": "../build/obj/tsconfig.tsbuildinfo", + "rootDir": "./" + }, + "references": [ + { "path": "../../../../../../common/web/utils" }, + { "path": "../../../../../../common/models/types"}, + { "path": "../../../../../../common/models/wordbreakers"}, + { "path": "../../../../../../common/web/lm-message-types"}, + { "path": "../../../../../../common/models/templates"} + ], + "include" : [ "./*.ts" ], + "exclude" : [ + "node", + "web", + "index.ts" // It's handled by the final layer. + ] +} diff --git a/common/predictive-text/src/unwrap.ts b/web/src/engine/predictive-text/worker-main/src/unwrap.ts similarity index 100% rename from common/predictive-text/src/unwrap.ts rename to web/src/engine/predictive-text/worker-main/src/unwrap.ts diff --git a/common/predictive-text/src/web/index.ts b/web/src/engine/predictive-text/worker-main/src/web/index.ts similarity index 100% rename from common/predictive-text/src/web/index.ts rename to web/src/engine/predictive-text/worker-main/src/web/index.ts diff --git a/common/predictive-text/src/web/sourcemappedWorker.ts b/web/src/engine/predictive-text/worker-main/src/web/sourcemappedWorker.ts similarity index 100% rename from common/predictive-text/src/web/sourcemappedWorker.ts rename to web/src/engine/predictive-text/worker-main/src/web/sourcemappedWorker.ts diff --git a/common/predictive-text/src/web/tsconfig.json b/web/src/engine/predictive-text/worker-main/src/web/tsconfig.json similarity index 83% rename from common/predictive-text/src/web/tsconfig.json rename to web/src/engine/predictive-text/worker-main/src/web/tsconfig.json index c16936db12..769c97d589 100644 --- a/common/predictive-text/src/web/tsconfig.json +++ b/web/src/engine/predictive-text/worker-main/src/web/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../../web/tsconfig.kmw-main-base.json", + "extends": "../../../../../../tsconfig.base.json", "compilerOptions": { "lib": ["es6", "DOM"], "baseUrl": "../", diff --git a/common/predictive-text/src/web/worker.ts b/web/src/engine/predictive-text/worker-main/src/web/worker.ts similarity index 100% rename from common/predictive-text/src/web/worker.ts rename to web/src/engine/predictive-text/worker-main/src/web/worker.ts diff --git a/common/predictive-text/src/worker-interface.d.ts b/web/src/engine/predictive-text/worker-main/src/worker-interface.d.ts similarity index 100% rename from common/predictive-text/src/worker-interface.d.ts rename to web/src/engine/predictive-text/worker-main/src/worker-interface.d.ts diff --git a/common/predictive-text/tsconfig.all.json b/web/src/engine/predictive-text/worker-main/tsconfig.all.json similarity index 63% rename from common/predictive-text/tsconfig.all.json rename to web/src/engine/predictive-text/worker-main/tsconfig.all.json index f47b208eda..6307444b96 100644 --- a/common/predictive-text/tsconfig.all.json +++ b/web/src/engine/predictive-text/worker-main/tsconfig.all.json @@ -3,7 +3,7 @@ // require separate sub-tsconfigs, both of which require common references. The multi-config // setup in this project and its subfolders ensure all modules can compile cleanly and in the // necessary compilation order. - "extends": "../web/tsconfig.kmw-main-base.json", + "extends": "../../../../tsconfig.base.json", "compilerOptions": { "baseUrl": "./", @@ -13,11 +13,11 @@ }, "files": [], "references": [ - { "path": "../web/utils" }, - { "path": "../models/types"}, - { "path": "../models/wordbreakers"}, - { "path": "../web/lm-message-types"}, - { "path": "../models/templates"}, + { "path": "../../../../../common/web/utils" }, + { "path": "../../../../../common/models/types"}, + { "path": "../../../../../common/models/wordbreakers"}, + { "path": "../../../../../common/web/lm-message-types"}, + { "path": "../../../../../common/models/templates"}, { "path": "src/node" }, { "path": "src/web" } ], diff --git a/common/predictive-text/unit_tests/headless/promise-store.js b/web/src/engine/predictive-text/worker-main/unit_tests/headless/promise-store.js similarity index 100% rename from common/predictive-text/unit_tests/headless/promise-store.js rename to web/src/engine/predictive-text/worker-main/unit_tests/headless/promise-store.js diff --git a/common/predictive-text/unit_tests/headless/top-level-lmlayer.js b/web/src/engine/predictive-text/worker-main/unit_tests/headless/top-level-lmlayer.js similarity index 100% rename from common/predictive-text/unit_tests/headless/top-level-lmlayer.js rename to web/src/engine/predictive-text/worker-main/unit_tests/headless/top-level-lmlayer.js diff --git a/common/predictive-text/unit_tests/headless/worker-dummy-integration.js b/web/src/engine/predictive-text/worker-main/unit_tests/headless/worker-dummy-integration.js similarity index 100% rename from common/predictive-text/unit_tests/headless/worker-dummy-integration.js rename to web/src/engine/predictive-text/worker-main/unit_tests/headless/worker-dummy-integration.js diff --git a/common/predictive-text/unit_tests/headless/worker-trie-integration.js b/web/src/engine/predictive-text/worker-main/unit_tests/headless/worker-trie-integration.js similarity index 100% rename from common/predictive-text/unit_tests/headless/worker-trie-integration.js rename to web/src/engine/predictive-text/worker-main/unit_tests/headless/worker-trie-integration.js diff --git a/common/predictive-text/unit_tests/in_browser/cases/top-level-lmlayer.spec.ts b/web/src/engine/predictive-text/worker-main/unit_tests/in_browser/cases/top-level-lmlayer.spec.ts similarity index 100% rename from common/predictive-text/unit_tests/in_browser/cases/top-level-lmlayer.spec.ts rename to web/src/engine/predictive-text/worker-main/unit_tests/in_browser/cases/top-level-lmlayer.spec.ts diff --git a/common/predictive-text/unit_tests/in_browser/cases/worker-dummy-integration.spec.ts b/web/src/engine/predictive-text/worker-main/unit_tests/in_browser/cases/worker-dummy-integration.spec.ts similarity index 100% rename from common/predictive-text/unit_tests/in_browser/cases/worker-dummy-integration.spec.ts rename to web/src/engine/predictive-text/worker-main/unit_tests/in_browser/cases/worker-dummy-integration.spec.ts diff --git a/common/predictive-text/unit_tests/in_browser/cases/worker-trie-integration.spec.ts b/web/src/engine/predictive-text/worker-main/unit_tests/in_browser/cases/worker-trie-integration.spec.ts similarity index 100% rename from common/predictive-text/unit_tests/in_browser/cases/worker-trie-integration.spec.ts rename to web/src/engine/predictive-text/worker-main/unit_tests/in_browser/cases/worker-trie-integration.spec.ts diff --git a/common/predictive-text/unit_tests/in_browser/helpers.mjs b/web/src/engine/predictive-text/worker-main/unit_tests/in_browser/helpers.mjs similarity index 100% rename from common/predictive-text/unit_tests/in_browser/helpers.mjs rename to web/src/engine/predictive-text/worker-main/unit_tests/in_browser/helpers.mjs diff --git a/common/predictive-text/unit_tests/in_browser/web-test-runner.CI.config.mjs b/web/src/engine/predictive-text/worker-main/unit_tests/in_browser/web-test-runner.CI.config.mjs similarity index 100% rename from common/predictive-text/unit_tests/in_browser/web-test-runner.CI.config.mjs rename to web/src/engine/predictive-text/worker-main/unit_tests/in_browser/web-test-runner.CI.config.mjs diff --git a/common/predictive-text/unit_tests/in_browser/web-test-runner.config.mjs b/web/src/engine/predictive-text/worker-main/unit_tests/in_browser/web-test-runner.config.mjs similarity index 96% rename from common/predictive-text/unit_tests/in_browser/web-test-runner.config.mjs rename to web/src/engine/predictive-text/worker-main/unit_tests/in_browser/web-test-runner.config.mjs index 523cd25457..6f9df64ddb 100644 --- a/common/predictive-text/unit_tests/in_browser/web-test-runner.config.mjs +++ b/web/src/engine/predictive-text/worker-main/unit_tests/in_browser/web-test-runner.config.mjs @@ -7,7 +7,7 @@ import { dirname, resolve } from 'path'; import { sessionStabilityReporter } from '@keymanapp/common-test-resources/test-runner-stability-reporter.mjs'; const dir = dirname(fileURLToPath(import.meta.url)); -const KEYMAN_ROOT = resolve(dir, '../../../../'); +const KEYMAN_ROOT = resolve(dir, '../../../../../../../'); /** @type {import('@web/test-runner').TestRunnerConfig} */ export default { diff --git a/common/predictive-text/unit_tests/test.sh b/web/src/engine/predictive-text/worker-main/unit_tests/test.sh similarity index 98% rename from common/predictive-text/unit_tests/test.sh rename to web/src/engine/predictive-text/worker-main/unit_tests/test.sh index 3eb87bae56..007bf36357 100755 --- a/common/predictive-text/unit_tests/test.sh +++ b/web/src/engine/predictive-text/worker-main/unit_tests/test.sh @@ -3,7 +3,7 @@ ## START STANDARD BUILD SCRIPT INCLUDE # adjust relative paths as necessary THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" -. "${THIS_SCRIPT%/*}/../../../resources/build/build-utils.sh" +. "${THIS_SCRIPT%/*}/../../../../../../resources/build/build-utils.sh" ## END STANDARD BUILD SCRIPT INCLUDE . "$KEYMAN_ROOT/resources/build/build-utils-ci.inc.sh" diff --git a/common/test/predictive-text/.gitignore b/web/src/test/manual/predictive-text/.gitignore similarity index 100% rename from common/test/predictive-text/.gitignore rename to web/src/test/manual/predictive-text/.gitignore diff --git a/common/test/predictive-text/README.md b/web/src/test/manual/predictive-text/README.md similarity index 96% rename from common/test/predictive-text/README.md rename to web/src/test/manual/predictive-text/README.md index ddf89bb8be..0ab038ca11 100644 --- a/common/test/predictive-text/README.md +++ b/web/src/test/manual/predictive-text/README.md @@ -9,10 +9,9 @@ Install **NOTE**: Requires Node >= 10.0 First, ensure that Keyman web and the LMLayer are built. You can run the -build script in `/web/source` to do this for you: +build script in `/web` to do this for you: - cd ../../../web/source - ./build.sh + ../../../../web/build.sh Then, you can install locally with `npm`: diff --git a/common/test/predictive-text/index.js b/web/src/test/manual/predictive-text/index.js similarity index 99% rename from common/test/predictive-text/index.js rename to web/src/test/manual/predictive-text/index.js index 934dcf67a6..605ed2939c 100755 --- a/common/test/predictive-text/index.js +++ b/web/src/test/manual/predictive-text/index.js @@ -13,7 +13,7 @@ const {EventIterator} = require('event-iterator'); const program = require('commander'); // Load the most recent LMLayer code locally. -const LMLayer = require('../../predictive-text'); +const LMLayer = require('../../../engine/predictive-text/worker-main'); ///////////////////////////////// Constants ///////////////////////////////// @@ -331,7 +331,7 @@ async function asyncRepl(modelFile) { function createAsyncWorker() { // XXX: import the LMLayerWorker directly -- I know where it is built. - const LMLayerWorker = require('../../predictive-text/build/intermediate'); + const LMLayerWorker = require('../../../engine/predictive-text/build/intermediate'); const vm = require('vm'); let worker = { diff --git a/common/test/predictive-text/package.json b/web/src/test/manual/predictive-text/package.json similarity index 100% rename from common/test/predictive-text/package.json rename to web/src/test/manual/predictive-text/package.json From 55ed18bc875db8a7dbc057aa0b697bc32346b491 Mon Sep 17 00:00:00 2001 From: Keyman Build Agent Date: Thu, 15 Aug 2024 14:03:17 -0400 Subject: [PATCH 326/327] auto: increment master version to 18.0.91 --- HISTORY.md | 8 ++++++++ VERSION.md | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 185c9d7626..f911703834 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,13 @@ # Keyman Version History +## 18.0.90 alpha 2024-08-15 + +* refactor(web): move parts of `keyboard-processor` → `js-processor` (#12111) +* fix(web): allow `lm-worker` to build on Linux (#12181) +* refactor(web): move remaining parts of `keyboard-processor` → `keyboard` (#12131) +* docs: update .kmx documentation around bitmaps, modifier state (#12183) +* refactor(web): rename `package-cache` → `keyboard-storage` (#12135) + ## 18.0.89 alpha 2024-08-14 * feat(web): test skipped prediction round handling (#12169) diff --git a/VERSION.md b/VERSION.md index 49d6906226..8f233fffc0 100644 --- a/VERSION.md +++ b/VERSION.md @@ -1 +1 @@ -18.0.90 \ No newline at end of file +18.0.91 \ No newline at end of file From e52937f907c60097dc1eb2d51ffbb0b39a5e85b5 Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Fri, 16 Aug 2024 06:58:05 +0200 Subject: [PATCH 327/327] Apply suggestions from code review Co-authored-by: Joshua Horton --- web/src/engine/predictive-text/worker-main/src/tsconfig.json | 4 +--- web/src/engine/predictive-text/worker-main/tsconfig.all.json | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/web/src/engine/predictive-text/worker-main/src/tsconfig.json b/web/src/engine/predictive-text/worker-main/src/tsconfig.json index b7cd725cf9..9c7a1f47ee 100644 --- a/web/src/engine/predictive-text/worker-main/src/tsconfig.json +++ b/web/src/engine/predictive-text/worker-main/src/tsconfig.json @@ -10,9 +10,7 @@ "references": [ { "path": "../../../../../../common/web/utils" }, { "path": "../../../../../../common/models/types"}, - { "path": "../../../../../../common/models/wordbreakers"}, - { "path": "../../../../../../common/web/lm-message-types"}, - { "path": "../../../../../../common/models/templates"} + { "path": "../../../../../../common/web/lm-message-types"} ], "include" : [ "./*.ts" ], "exclude" : [ diff --git a/web/src/engine/predictive-text/worker-main/tsconfig.all.json b/web/src/engine/predictive-text/worker-main/tsconfig.all.json index 6307444b96..f86c081542 100644 --- a/web/src/engine/predictive-text/worker-main/tsconfig.all.json +++ b/web/src/engine/predictive-text/worker-main/tsconfig.all.json @@ -15,9 +15,7 @@ "references": [ { "path": "../../../../../common/web/utils" }, { "path": "../../../../../common/models/types"}, - { "path": "../../../../../common/models/wordbreakers"}, { "path": "../../../../../common/web/lm-message-types"}, - { "path": "../../../../../common/models/templates"}, { "path": "src/node" }, { "path": "src/web" } ],