[host] windows: implement KVMFR_FEATURE_SETCURSORPOS

This commit is contained in:
Geoffrey McRae 2021-08-05 22:35:22 +10:00
parent afbee641b1
commit 2856928b57
4 changed files with 41 additions and 3 deletions

View File

@ -44,3 +44,5 @@ const char * os_getDataPath();
void os_showMessage(const char * caption, const char * msg);
bool os_blockScreensaver();
bool os_hasSetCursorPos(void);
void os_setCursorPos(int x, int y);

View File

@ -86,3 +86,12 @@ void os_showMessage(const char * caption, const char * msg)
{
DEBUG_INFO("%s: %s", caption, msg);
}
bool os_hasSetCursorPos(void)
{
return false;
}
void os_setCursorPos(int x, int y)
{
}

View File

@ -573,3 +573,13 @@ void os_showMessage(const char * caption, const char * msg)
{
MessageBoxA(NULL, msg, caption, MB_OK | MB_ICONINFORMATION);
}
bool os_hasSetCursorPos(void)
{
return true;
}
void os_setCursorPos(int x, int y)
{
SetCursorPos(x, y);
}

View File

@ -147,6 +147,22 @@ static bool lgmpTimer(void * opaque)
return false;
}
uint8_t data[LGMP_MSGS_SIZE];
size_t size;
while((status = lgmpHostReadData(app.pointerQueue, &data, &size)) == LGMP_OK)
{
KVMFRMessage *msg = (KVMFRMessage *)data;
switch(msg->type)
{
case KVMFR_MESSAGE_SETCURSORPOS:
{
KVMFRSetCursorPos *sp = (KVMFRSetCursorPos *)msg;
os_setCursorPos(sp->x, sp->y);
break;
}
}
}
return true;
}
@ -545,8 +561,9 @@ int app_main(int argc, char * argv[])
DEBUG_INFO("KVMFR Version : %u", KVMFR_VERSION);
KVMFR udata = {
.magic = KVMFR_MAGIC,
.version = KVMFR_VERSION,
.magic = KVMFR_MAGIC,
.version = KVMFR_VERSION,
.features = os_hasSetCursorPos() ? KVMFR_FEATURE_SETCURSORPOS : 0
};
strncpy(udata.hostver, BUILD_VERSION, sizeof(udata.hostver)-1);
@ -661,7 +678,7 @@ int app_main(int argc, char * argv[])
LG_LOCK_INIT(app.pointerLock);
if (!lgCreateTimer(100, lgmpTimer, NULL, &app.lgmpTimer))
if (!lgCreateTimer(10, lgmpTimer, NULL, &app.lgmpTimer))
{
DEBUG_ERROR("Failed to create the LGMP timer");