diff --git a/meshcore/KVM/Linux/linux_kvm.c b/meshcore/KVM/Linux/linux_kvm.c index 527b476..372886c 100644 --- a/meshcore/KVM/Linux/linux_kvm.c +++ b/meshcore/KVM/Linux/linux_kvm.c @@ -424,7 +424,7 @@ int kvm_server_inputdata(char* block, int blocklen) y = ((int)ntohs(((unsigned short*)(block))[4])); if (size == 12) w = ((short)ntohs(((short*)(block))[5])); // printf("x:%d, y:%d, b:%d, w:%d\n", x, y, block[5], w); - if (g_enableEvents) MouseAction(x, y, block[5], w, eventdisplay); + if (g_enableEvents) MouseAction(x, y, (int)(unsigned char)(block[5]), w, eventdisplay); } break; } diff --git a/meshcore/KVM/MacOS/mac_events.c b/meshcore/KVM/MacOS/mac_events.c index 894baef..3f1ee33 100644 --- a/meshcore/KVM/MacOS/mac_events.c +++ b/meshcore/KVM/MacOS/mac_events.c @@ -2,6 +2,8 @@ #include #include #include +#include "../../../microstack/ILibParsers.h" +#include "../../meshdefines.h" static const int g_keymapLen = 114; // Modify this when you change anything in g_keymap. static int g_capsLock = 0; @@ -124,6 +126,19 @@ static struct keymap_t g_keymap[] = { { kVK_ANSI_RightBracket, VK_OEM_6 }, { kVK_ANSI_Quote, VK_OEM_7 } }; +extern int KVM_SEND(char *buffer, int bufferLen); + +void kvm_server_sendmsg(char *msg) +{ + int msgLen = strnlen_s(msg, 255); + char buffer[512]; + + ((unsigned short*)buffer)[0] = (unsigned short)htons((unsigned short)MNG_ERROR); // Write the type + ((unsigned short*)buffer)[1] = (unsigned short)htons((unsigned short)(msgLen + 4)); // Write the size + memcpy_s(buffer + 4, 512 - 4, msg, msgLen); + + KVM_SEND(buffer, msgLen + 4); +} char* getCurrentSession() { SCDynamicStoreRef store; @@ -156,12 +171,6 @@ void MouseAction(double absX, double absY, int button, short wheel) CGEventType event; CGEventSourceRef source; - if (button == 0x88) { - // Double click, this is useful on MacOS. - // TODO - return; - } - curPos.x = absX; curPos.y = absY; @@ -202,22 +211,21 @@ void MouseAction(double absX, double absY, int button, short wheel) break; } - - /* - if (!strcmp(getCurrentSession(), "")) + if (button == 0x88) { - // This call is deprecated in OSX 10.6 - CGPostMouseEvent(curPos, TRUE, 3, (event == kCGEventLeftMouseDown) ? TRUE : FALSE, (event == kCGEventRightMouseDown) ? TRUE : FALSE, FALSE); // mouse down - } + // Double click, this is useful on MacOS. + e = CGEventCreateMouseEvent(source, kCGEventLeftMouseDown, curPos, 1); + CGEventSetIntegerValueField(e, kCGMouseEventClickState, 2); + CGEventPost(kCGHIDEventTap, e); + CGEventSetType(e, kCGEventLeftMouseUp); + CGEventPost(kCGHIDEventTap, e); + } else { - */ e = CGEventCreateMouseEvent(source, event, curPos, 1); CGEventPost(kCGHIDEventTap, e); - CFRelease(e); - /* } - */ + CFRelease(e); } else if (wheel != 0) { diff --git a/meshcore/KVM/MacOS/mac_kvm.c b/meshcore/KVM/MacOS/mac_kvm.c index 96bc7b2..acbca7c 100644 --- a/meshcore/KVM/MacOS/mac_kvm.c +++ b/meshcore/KVM/MacOS/mac_kvm.c @@ -176,8 +176,9 @@ int kvm_server_inputdata(char* block, int blocklen) x = ((int)ntohs(((unsigned short*)(block))[3])); y = ((int)ntohs(((unsigned short*)(block))[4])); if (size == 12) w = ((short)ntohs(((short*)(block))[5])); + //printf("x:%d, y:%d, b:%d, w:%d\n", x, y, block[5], w); - MouseAction(x, y, block[5], w); + MouseAction(x, y, (int)(unsigned char)(block[5]), w); } break; } diff --git a/meshcore/KVM/Windows/kvm.c b/meshcore/KVM/Windows/kvm.c index 1a5e01a..383b697 100644 --- a/meshcore/KVM/Windows/kvm.c +++ b/meshcore/KVM/Windows/kvm.c @@ -506,7 +506,7 @@ int kvm_server_inputdata(char* block, int blocklen, ILibKVM_WriteHandler writeHa // Perform the mouse movement if (size == 12) w = ((short)ntohs(((short*)(block))[5])); - MouseAction((((double)x / (double)SCREEN_WIDTH)), (((double)y / (double)SCREEN_HEIGHT)), block[5], w); + MouseAction((((double)x / (double)SCREEN_WIDTH)), (((double)y / (double)SCREEN_HEIGHT)), (int)(unsigned char)(block[5]), w); } break; }