1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2026-02-04 02:33:51 +00:00

Fixed bug in mapping cache algorithm

This commit is contained in:
Bryan Roe
2020-11-21 19:34:30 -08:00
parent e0bf176c39
commit 4c82974aec
2 changed files with 21 additions and 5 deletions

View File

@@ -24,6 +24,7 @@ x11tst_struct *x11tst_exports = NULL;
extern void kvm_keyboard_unmap_unicode_key(Display *display, int keycode);
extern int kvm_keyboard_map_unicode_key(Display *display, uint16_t unicode, int *alreadyExists);
extern int kvm_keyboard_update_map_unicode_key(Display *display, uint16_t unicode, int keycode);
extern int SHIFT_STATE;
#define g_keyboardMapCount 8
int g_keyboardMap[g_keyboardMapCount] = { 0 };
@@ -225,6 +226,7 @@ void KeyAction(unsigned char vk, int up, Display *display)
if (!x11tst_exports->XTestFakeKeyEvent(display, keycode, !up, 0)) { return; }
x11tst_exports->XFlush(display);
if (vk == VK_SHIFT) { SHIFT_STATE = !up; }
}
}
void KeyActionUnicode_UNMAP_ALL(Display *display)
@@ -252,7 +254,7 @@ void KeyActionUnicode(uint16_t unicode, int up, Display *display)
// Check if a primary mapping already exists
mapping = kvm_keyboard_map_unicode_key(display, unicode, &exists);
if (mapping == 0)
if (exists == 0)
{
if (g_keyboardMap[g_keyboardMapIndex] != 0)
{

View File

@@ -110,6 +110,7 @@ extern void* tilebuffer;
extern char **environ;
struct timespec inputtime;
uint32_t inputcounter = 0;
int SHIFT_STATE = 0;
typedef struct x11ext_struct
{
@@ -206,7 +207,7 @@ int kvm_keyboard_map_unicode_key(Display *display, uint16_t unicode, int *alread
{
// Check to see if this mapping is the primary mapping
keycodeIndex = (foundCode - keycode_low) * keysyms_per_keycode;
if (keysyms[keycodeIndex] == sym)
if (keysyms[keycodeIndex] == sym && SHIFT_STATE == 0)
{
// We have a match!
//ILIBLOGMESSAGEX(" Already mapped at: %d", foundCode);
@@ -217,8 +218,10 @@ int kvm_keyboard_map_unicode_key(Display *display, uint16_t unicode, int *alread
{
// No match!
//ILIBLOGMESSAGEX(" Already mapped at: %d, but is not PRIMARY", foundCode);
//ILIBLOGMESSAGEX(" keycode_low: %d , keycode_high: %d , per: %d", keycode_low, keycode_high, keysyms_per_keycode);
}
}
return(empty_keycode);
}
@@ -231,14 +234,23 @@ int kvm_keyboard_map_unicode_key(Display *display, uint16_t unicode, int *alread
for (j = 0; j < keysyms_per_keycode; ++j)
{
keycodeIndex = (i - keycode_low) * keysyms_per_keycode + j;
if (keysyms[keycodeIndex] != 0) { empty = 0; }
else { break; }
if (keysyms[keycodeIndex] != 0)
{
empty = 0;
break;
}
}
if (empty) { empty_keycode = i; break; } // Found it!
if (empty)
{
empty_keycode = i;
break;
} // Found it!
}
// Map the unicode character to one of the unused keys above
//ILIBLOGMESSAGEX(" MAPPING SYM: %x on: %d", sym, empty_keycode);
KeySym keysym_list[] = { sym, sym };
x11_exports->XChangeKeyboardMapping(display, empty_keycode, 2, keysym_list, 1);
x11_exports->XSync(display, 0);
@@ -1321,6 +1333,8 @@ void* kvm_server_mainloop(void* parm)
slave2master[1] = 0;
master2slave[0] = 0;
//ILIBLOGMESSAGEX("UNMAPPING ALL");
KeyActionUnicode_UNMAP_ALL(eventdisplay);
x11_exports->XCloseDisplay(eventdisplay);
eventdisplay = NULL;