From bab7d372efc53f85e3b7f9b4e094bcefa345fdc6 Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 7 Nov 2023 13:19:15 +0100 Subject: [PATCH] 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; -}*/ -