feat(linux): again resolce conflict mcompile-dk remove KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw

This commit is contained in:
Sabine 2024-02-13 11:56:04 +01:00
parent b49f28f3ef
commit 80e044e106
6 changed files with 116 additions and 23 deletions

View file

@ -513,7 +513,7 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap
guint *keyvals;
gint count;
KMX_DWORD out;
KMX_DWORD deadkey;
KMX_DWORD deadkey=0;
if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count))
@ -523,7 +523,7 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap
if (!(shift_state_pos <= count))
return 0;
// _S2 94 as variable/const
if (!(keycode <= 94))
return 0;
@ -543,6 +543,70 @@ KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap
return out;
}
// _S2 TODO
KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK_New(GdkKeymap *keymap, guint keycode, int shift_state_pos, PKMX_WCHAR &dky) {
GdkKeymapKey *maps;
guint *keyvals;
gint count;
KMX_DWORD out;
KMX_DWORD deadkey=0;
if (!gdk_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count))
return 0;
//if(!gdk_wayland_keymap_get_entries_for_keycode(keymap, keycode, &maps, &keyvals, &count))
// return 0; https://codebrowser.dev/gtk/gtk/gdk/wayland/gdkkeys-wayland.c.html
if (!(shift_state_pos <= count))
return 0;
// _S2 94 as variable/const
if (!(keycode <= 94))
return 0;
// _S2 TODO take caps to this function
// here I get all kvals: normal char , my Deadkeys, allothr DK
KMX_DWORD All_Keyvals = KMX_get_keyvals_From_Keycode(keymap, keycode, ShiftState(shift_state_pos), 0);
if(( (All_Keyvals >= deadkey_min) && (All_Keyvals <= deadkey_max)))
deadkey = All_Keyvals;
// _S2 check if naming is correct: does get_char... return a char or a string or a DWORD;...?
dky = (PKMX_WCHAR) (convert_DeadkeyValues_To_U16str((int) deadkey)).c_str();
/*
// _S2 ToDo
KMX_DWORD KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){
KMX_DWORD keyvals_dw= (KMX_DWORD) KMX_get_keyvals_From_Keycode(keymap, keycode, ss, caps);
// _S2 AHA output for dk4-12 at the top after dk... from here
if((keyvals_dw >= deadkey_min) && (keyvals_dw <= deadkey_max)) // deadkeys
return 0xFFFF;
else if((keyvals_dw > deadkey_max) || ((keyvals_dw < deadkey_min) && ( keyvals_dw > 0xFF))) // out of range
return 0xFFFE;
else // usable char
return keyvals_dw;
}
*/
g_free(keyvals);
g_free(maps);
// _S2 AHA output for dk4-12 at the top after dk... from here
if((All_Keyvals >= deadkey_min) && (All_Keyvals <= deadkey_max)) // deadkeys
return 0xFFFF;
else if((All_Keyvals > deadkey_max) || ((All_Keyvals < deadkey_min) && ( All_Keyvals > 0xFF))) // out of range
return 0xFFFE;
else // usable char
return All_Keyvals;
//out = KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(keymap, keycode, (ShiftState) shift_state_pos, 0);
}
KMX_DWORD KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(GdkKeymap *keymap, guint keycode, int shift_state_pos) {
GdkKeymapKey *maps;
guint *keyvals;
@ -580,6 +644,28 @@ KMX_DWORD KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(Gdk
else // usable char
return keyvals_dw;
}
// _S2 remove term _other and use underlying instead
KMX_DWORD KMX_get_CharUnderlying_From_SCUnderlying_GDK_NEW(GdkKeymap *keymap, UINT VKShiftState, UINT SC_OTHER, PKMX_WCHAR DeadKey) {
//takes keymap, shift, scanCode
//fills ref deadkey
//returns character(KMX_DWORD)
PKMX_WCHAR dd;
KMX_DWORD keyvals_dw = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK_New(keymap, SC_OTHER, map_VKShiftState_to_Lin(VKShiftState), dd);
// _S2 rename dd
if((keyvals_dw >= deadkey_min) && (keyvals_dw >= deadkey_max)) {
*DeadKey = *dd;
return 0xFFFF;
}
else if((keyvals_dw > deadkey_max) || ((keyvals_dw < deadkey_min) && ( keyvals_dw > 0xFF))) // out of range
return 0xFFFE;
else // usable char
return keyvals_dw;
}
KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps){

View file

@ -520,7 +520,7 @@ KMX_DWORD KMX_get_CharsUnderlying_according_to_keycode_and_Shiftstate_GDK_dw(Gdk
// _S2 TODO returns char or FFFF / FFFE ????
KMX_DWORD KMX_get_FFFF_Underlying_according_to_keycode_and_Shiftstate_GDK_dw(GdkKeymap *keymap, guint keycode, ShiftState ss, int caps);
KMX_DWORD KMX_get_CharUnderlying_From_SCUnderlying_GDK_NEW(GdkKeymap *keymap, UINT VKShiftState, UINT SC_OTHER, PKMX_WCHAR DeadKey);

View file

@ -36,7 +36,7 @@ typedef uint16_t km_kbp_cp; // code point
typedef uint32_t km_kbp_usv; // Unicode Scalar Value
#endif
// _S2 which can be removed later?
// _S2 TODO which can be removed later?
typedef unsigned int UINT;
typedef unsigned long DWORD;

View file

@ -128,7 +128,7 @@ public:
// _S2 TODO deadkey
// memset(this->m_rgfDeadKey,0,sizeof(this->m_rgfDeadKey));
}
//_S2 keymap* or keymap**
//_S2 ToDo keymap* or keymap**
KMX_VirtualKey(UINT scanCode, KMX_HKL hkl, GdkKeymap **keymap) {
this->m_vk = KMX_get_VKUS_From_KeyCodeUnderlying_GDK(*keymap, scanCode);
@ -251,7 +251,7 @@ public:
int nkeys = 0;
// Get the CAPSLOCK value
//_S2 not used in original code; can be deleted
//_S2 INFO not used in original code; can be deleted
/*int capslock =
(this->KMX_IsCapsEqualToShift() ? 1 : 0) |
(this->KMX_IsSGCAPS() ? 2 : 0) |
@ -448,7 +448,7 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,
std::vector<KMX_VirtualKey*> rgKey; //= new VirtualKey[256];
std::vector<DeadKey*> alDead;
//_S2 remove alDead2
//_S2 TODO remove alDead2
std::vector<DeadKey*> alDead2 ;
std::vector<DeadKey*> alDead_cpl = create_alDead();
std::vector<DeadKey*> alDead_cpl = create_alDead();
@ -522,9 +522,9 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,
}
//_S2 to compare win-lin kmn-files skip ss6+7; MUST BE restored/removed later!!!!
if(ss == MenuCtrl|| ss == ShftMenuCtrl) {
/*if(ss == MenuCtrl|| ss == ShftMenuCtrl) {
continue;
}
}*/
KMX_DWORD SC_US = KMX_get_KeyCodeUnderlying_From_VKUS(iKey);
@ -562,14 +562,13 @@ bool KMX_ImportRules(LPKMX_KEYBOARD kp,v_dw_3D &All_Vector, GdkKeymap **keymap,
}
sbBuffer[rc] = 0;
//rgKey[iKey]->KMX_SetShiftState(ss, KeyVal_Other, false, (caps==0));
rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps)); //_S2
rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, false, (caps)); //_S2 INFO
}
}
else if(rc < 0) {
sbBuffer[2] = 0;
//rgKey[iKey]->SetShiftState(ss, sbBuffer, true, (caps == 0));
rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); //_S2
rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); //_S2
rgKey[iKey]->KMX_SetShiftState(ss, sbBuffer, true, (caps )); //_S2 INFO
// It's a dead key; let's flush out whats stored in the keyboard state.
loader.KMX_ClearKeyboardBuffer();

View file

@ -22,7 +22,7 @@
06 Feb 2015 - mcdurdin - I4552 - V9.0 - Add mnemonic recompile option to ignore deadkeys
08 Apr 2015 - mcdurdin - I4651 - V9.0 - Mnemonic layout recompiler maps AltGr+VK_BKSLASH rather than VK_OEM_102
*/
//_S2
//_S2 INFO
// in /Projects/keyman/keyman/linux/mcompile/keymap/build_mcompile
// run with:
//./mcompile -d in.kmx bla.dll 0407 out.kmx
@ -149,7 +149,7 @@ int run(int argc, std::vector<std::u16string> str_argv, char* argv_ch[] = NULL){
// Map of all shift states that we will work with
const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCTRLFLAG|RALTFLAG, 0xFFFF};
// _S2 my comment for Lin version
// _S2 INFO my comment for Lin version
// Ubuntu: Each of the 4 columns specifies a different modifier: unmodified, shift, right alt (altgr), shift+right alt(altgr)
// we have assigned these to columns 1-4 ( column o holds the keycode)
// const UINT VKShiftState[] = {0, 1, 2, 3, 0xFFFF};
@ -160,8 +160,7 @@ const UINT VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG|RALTFLAG, K_SHIFTFLAG|LCT
//
// For each key rule on the keyboard, remap its key to the
// correct shift state and key. Adjust the LCTRL+RALT -> RALT if necessary
// _S2 exchange key->Key with the new value ( use vk instead of ch)
// _S2 exchange key->Key with the new value ( use vk instead of ch)
// _S2 INFO exchange key->Key with the new value ( use vk instead of ch)
//
void KMX_TranslateKey(LPKMX_KEY key, KMX_WORD vk, UINT shift, KMX_WCHAR ch) {
// The weird LCTRL+RALT is Windows' way of mapping the AltGr key.
@ -227,7 +226,7 @@ void KMX_ReportUnconvertedKeyboardRules(LPKMX_KEYBOARD kbd) {
}
void KMX_TranslateDeadkeyKey(LPKMX_KEY key, KMX_WCHAR deadkey, KMX_WORD vk, UINT shift, KMX_WORD ch) {
// _S2 this produces a different output due to different layouts for Lin<-> win ( foe the same language!!)
// _S2 INFO this produces a different output due to different layouts for Lin<-> win ( foe the same language!!)
if((key->ShiftFlags == 0 || key->ShiftFlags & VIRTUALCHARKEY) && key->Key == ch) {
@ -281,7 +280,7 @@ void KMX_AddDeadkeyRule(LPKMX_KEYBOARD kbd, KMX_WCHAR deadkey, KMX_WORD vk, UINT
// to provide an alternate..
if((shift & (LCTRLFLAG|RALTFLAG)) == (LCTRLFLAG|RALTFLAG)) // I4549
shift &= ~LCTRLFLAG;
// _s2 idee spanish keyboard has dk on altgr !!
// _s2 INFO idee spanish keyboard has dk on altgr !!
// If the first group is not a matching-keys group, then we need to add into
// each subgroup, otherwise just the match group
@ -460,8 +459,17 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg
for (int i = 0;KMX_VKMap[i]; i++) { // I4651
// win goes via VK, Lin goes via SC
KMX_WCHAR DeadKey1=0;
DeadKey=0;
UINT scUnderlying = KMX_get_SCUnderlying_From_VKUS(KMX_VKMap[i]);
KMX_WCHAR ch = KMX_get_CharUnderlying_From_SCUnderlying_GDK(keymap, VKShiftState[j], scUnderlying, &DeadKey);
KMX_WCHAR ch1 = KMX_get_CharUnderlying_From_SCUnderlying_GDK_NEW(keymap, VKShiftState[j], scUnderlying, &DeadKey1);
if( ch!=ch1)
wprintf(L"IS DIFFERENT!!!! %i <--> %i\n", ch,ch1);
if( DeadKey!=DeadKey1)
wprintf(L"DDDDKKKK IS DIFFERENT!!!! %i <--> %i\n", DeadKey,DeadKey1);
//wprintf(L"--- VK_%d -> SC_ [%c] dk=%d ( ss %i) \n", VKMap[i], ch == 0 ? 32 : ch, DeadKey, VKShiftState[j]);
@ -473,9 +481,9 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg
switch(ch) {
case 0x0000: break;
case 0xFFFF: // _S2 in kbd (=loaded from kmx-file): replace LCTRL+RALT -> Ctrl+Alt + write deadkey-> FFFF + CODE_DEADKEY + deadkey into context
case 0xFFFF: // _S2 INFO in kbd (=loaded from kmx-file): replace LCTRL+RALT -> Ctrl+Alt + write deadkey-> FFFF + CODE_DEADKEY + deadkey into context
KMX_ConvertDeadkey(kbd, KMX_VKMap[i], VKShiftState[j], DeadKey, All_Vector, keymap , dk_Table); break;
default: // _S2 in kbd (=loaded from kmx-file): replace LCTRL+RALT -> Ctrl+Alt + switch keyvalues e.g. y<->z
default: // _S2 INFO in kbd (=loaded from kmx-file): replace LCTRL+RALT -> Ctrl+Alt + switch keyvalues e.g. y<->z
KMX_TranslateKeyboard(kbd, KMX_VKMap[i], VKShiftState[j], ch);
}
}
@ -483,9 +491,8 @@ KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint arg
KMX_ReportUnconvertedKeyboardRules(kbd);
// _S2 use translated kbd and write data to rgkey[] then add things to rgkey[] to enable to write to kmx-format
// _S2 use translated kbd and write data to rgkey[] then add things to rgkey[] to enable to write to kmx-format
// _S2 INFO use translated kbd and write data to rgkey[] then add things to rgkey[] to enable to write to kmx-format
if(!KMX_ImportRules(kbd, All_Vector, &keymap, &KMX_FDeadkeys, bDeadkeyConversion)) { // I4353 // I4552
return FALSE;
}
@ -528,7 +535,7 @@ KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, UINT
PKMX_WCHAR dky;
int VKShiftState_lin = map_VKShiftState_to_Lin(VKShiftState);
KMX_DWORD KeyvalOther = KMX_get_KeyvalsUnderlying_From_KeyCodeUnderlying_GDK(keymap,SC_OTHER, VKShiftState_lin, dky);
// _S2 < or >
if ((KeyvalOther >= deadkey_min) && (KeyvalOther >= deadkey_max)){
*DeadKey = *dky;
return 0xFFFF;

View file

@ -42,6 +42,7 @@ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p);
UINT KMX_get_SCUnderlying_From_VKUS(KMX_DWORD VirtualKeyUS);
// _S2 why is this function not in keymap.cpp/h
KMX_WCHAR KMX_get_CharUnderlying_From_SCUnderlying_GDK(GdkKeymap *keymap, UINT VKShiftState, UINT SC_OTHER, PKMX_WCHAR DeadKey);
KMX_WCHAR KMX_get_VKUS_From_VKUnderlying_VEC(v_dw_3D All_Vector,KMX_DWORD SC_US);