From 5d43f0a24e4dceefd09383c067e4ffed47e03365 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 29 Feb 2024 17:58:05 +0100 Subject: [PATCH] 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*/