mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-15 07:43:50 +00:00
Updated, so double-click events are propagated from browser to agent. On MacOS, this is then used to simulate double-click, as Linux/Windows doesn't need to explicitly simulate double-click.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include <assert.h>
|
||||
#include <SystemConfiguration/SystemConfiguration.h>
|
||||
#include <string.h>
|
||||
#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(), "<none>"))
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user