From 0d00533153b66cb1ffca0516f2c8e4a1edd8fa34 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 13 Dec 2023 16:13:14 +0100 Subject: [PATCH] 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);