From 9577a129b68136c12c417536bb159a12f14072fc Mon Sep 17 00:00:00 2001 From: Sabine Date: Tue, 17 Dec 2024 09:04:29 +0100 Subject: [PATCH 1/6] chore(linux): add changes from mcompile-mac(PR 11334) to mcompile-linux --- linux/mcompile/keymap/mcompile.cpp | 60 ++++++++++++++---------------- 1 file changed, 27 insertions(+), 33 deletions(-) diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 7edf69de16d..a167411a059 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -20,8 +20,8 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg /** @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 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); +/** @brief return a vector 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, std::vector &dk_vec, GdkKeymap* keymap); std::vector KMX_FDeadkeys; // I4353 @@ -94,7 +94,10 @@ std::vector KMX_FDeadkeys; // I4353 } if (KMX_DoConvert(kmxfile, bDeadkeyConversion, argc, (gchar**)argv)) { // I4552F - KMX_SaveKeyboard(kmxfile, outfile); + if(!KMX_SaveKeyboard(kmxfile, outfile)) { + KMX_LogError(L"Failed to save keyboard (%d)\n", errno); + return 3; + } } delete kmxfile; @@ -358,9 +361,9 @@ 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) { - return s_dkids[i].dst_deadkey; + for (int xi = 0; xi < s_ndkids; xi++) { + if (s_dkids[xi].src_deadkey == deadkey) { + return s_dkids[xi].dst_deadkey; } } @@ -399,8 +402,8 @@ KMX_WCHAR KMX_GetUniqueDeadkeyID(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey) { * @param dk_Table a vector of all possible deadkey combinations for all Linux keyboards */ 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[size_DK_array] = {0}; - KMX_WORD* pdk; + + std::vector vec_deadkeys; // Lookup the deadkey table for the deadkey in the physical keyboard // Then for each character, go through and map it through @@ -412,13 +415,14 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, KMX_DWORD shift, KMX 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 + KMX_GetDeadkeys(dk_Table, deadkey, vec_deadkeys, keymap); // returns vector of [usvk, ch_out] pairs - while (*pdk) { + int n=0; + while (n < (int)vec_deadkeys.size()) { // Look up the ch - KMX_DWORD KeyValUnderlying = (KMX_DWORD) KMX_get_KeyValUnderlying_From_KeyValUS(all_vector, *pdk); - KMX_TranslateDeadkeyKeyboard(kbd, dkid, KeyValUnderlying, *(pdk + 1), *(pdk + 2)); - pdk += 3; + KMX_DWORD KeyValUnderlying = (KMX_DWORD) KMX_get_KeyValUnderlying_From_KeyValUS(all_vector, vec_deadkeys[n]); + KMX_TranslateDeadkeyKeyboard(kbd, dkid, KeyValUnderlying, vec_deadkeys[n + 1], vec_deadkeys[n + 2]); + n += 3; } } @@ -521,44 +525,34 @@ 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 + * @brief return a vector 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[out] dk_vec vector 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; + +int KMX_GetDeadkeys(vec_dword_2D& dk_Table, KMX_WORD deadkey, std::vector &dk_vec, GdkKeymap* keymap) { + KMX_DWORD shift; vec_dword_2D dk_SingleTable; - int no_dk_counter = 0; - int p_counter = 0; 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) { - if( p_counter < size_DK_array - 3) { + dk_vec.push_back(vk); + dk_vec.push_back(shift); + dk_vec.push_back(dk_SingleTable[i][2]); - *p++ = vk; - *p++ = shift; - *p++ = dk_SingleTable[i][2]; - - p_counter = p_counter+3; - - } else { - no_dk_counter++; - } } else { KMX_LogError(L"Warning: complex deadkey not supported."); } } - if(p_counter >= size_DK_array -3) - KMX_LogError(L"Warning: %i deadkeys have not been processed.", no_dk_counter); - *p = 0; - return (p - outputPairs); + + return dk_vec.size(); } /** From 8d62a9a3912a611a64a6221b5f90f2b9bb305bb8 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 18 Dec 2024 13:53:59 +0100 Subject: [PATCH 2/6] chore(linux): mcompile edit comment --- 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 a167411a059..01c8fd585a1 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -530,7 +530,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg * @param deadkey deadkey character * @param[out] dk_vec vector of [usvk, ch_out] pairs * @param keymap pointer to the currently used (underlying) keyboard Layout - * @return size of array of [usvk, ch_out] pairs + * @return size of vector of [usvk, ch_out] pairs */ int KMX_GetDeadkeys(vec_dword_2D& dk_Table, KMX_WORD deadkey, std::vector &dk_vec, GdkKeymap* keymap) { From ef71a7485aeab5d244763d35725ce19a6bb5e9a4 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 18 Dec 2024 14:06:12 +0100 Subject: [PATCH 3/6] chore(linux): undo mcompile edit comment --- 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 01c8fd585a1..a167411a059 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -530,7 +530,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg * @param deadkey deadkey character * @param[out] dk_vec vector of [usvk, ch_out] pairs * @param keymap pointer to the currently used (underlying) keyboard Layout - * @return size of vector of [usvk, ch_out] pairs + * @return size of array of [usvk, ch_out] pairs */ int KMX_GetDeadkeys(vec_dword_2D& dk_Table, KMX_WORD deadkey, std::vector &dk_vec, GdkKeymap* keymap) { From 18976715f4b1f83ee2578c779e5e09e99dbb8e77 Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 18 Dec 2024 14:33:31 +0100 Subject: [PATCH 4/6] chore(linux): mcompile edit comment --- 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 a167411a059..01c8fd585a1 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -530,7 +530,7 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg * @param deadkey deadkey character * @param[out] dk_vec vector of [usvk, ch_out] pairs * @param keymap pointer to the currently used (underlying) keyboard Layout - * @return size of array of [usvk, ch_out] pairs + * @return size of vector of [usvk, ch_out] pairs */ int KMX_GetDeadkeys(vec_dword_2D& dk_Table, KMX_WORD deadkey, std::vector &dk_vec, GdkKeymap* keymap) { From 0529946511a3b4d112aec2de47ca5abfd083eedb Mon Sep 17 00:00:00 2001 From: Sabine Date: Wed, 18 Dec 2024 17:40:27 +0100 Subject: [PATCH 5/6] chore(linux): mcompile more edit --- 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 01c8fd585a1..731305eea5c 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -528,9 +528,9 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg * @brief return a vector 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] dk_vec vector of [usvk, ch_out] pairs + * @param[out] dk_vec vector of [usvk, shiftstate, ch_out] triplets * @param keymap pointer to the currently used (underlying) keyboard Layout - * @return size of vector of [usvk, ch_out] pairs + * @return size of vector of [usvk, shiftstate, ch_out] triplets */ int KMX_GetDeadkeys(vec_dword_2D& dk_Table, KMX_WORD deadkey, std::vector &dk_vec, GdkKeymap* keymap) { From c983380123f7976ed2fc02f09b727f119d8cea51 Mon Sep 17 00:00:00 2001 From: Sabine Date: Thu, 19 Dec 2024 09:32:42 +0100 Subject: [PATCH 6/6] chore(linux): change loop for filling the vector of dk triplets --- 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 731305eea5c..f8b96685b99 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -418,7 +418,7 @@ void KMX_ConvertDeadkey(LPKMX_KEYBOARD kbd, KMX_WORD vk_US, KMX_DWORD shift, KMX KMX_GetDeadkeys(dk_Table, deadkey, vec_deadkeys, keymap); // returns vector of [usvk, ch_out] pairs int n=0; - while (n < (int)vec_deadkeys.size()) { + while (n < (int)vec_deadkeys.size() - 2) { // Look up the ch KMX_DWORD KeyValUnderlying = (KMX_DWORD) KMX_get_KeyValUnderlying_From_KeyValUS(all_vector, vec_deadkeys[n]); KMX_TranslateDeadkeyKeyboard(kbd, dkid, KeyValUnderlying, vec_deadkeys[n + 1], vec_deadkeys[n + 2]);