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; -} -*/