diff --git a/meshcore/KVM/Linux/linux_events.c b/meshcore/KVM/Linux/linux_events.c index 9afa4cc..4630afa 100644 --- a/meshcore/KVM/Linux/linux_events.c +++ b/meshcore/KVM/Linux/linux_events.c @@ -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) { diff --git a/meshcore/KVM/Linux/linux_kvm.c b/meshcore/KVM/Linux/linux_kvm.c index 7b5fae3..7a64427 100644 --- a/meshcore/KVM/Linux/linux_kvm.c +++ b/meshcore/KVM/Linux/linux_kvm.c @@ -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;