From b7e44260020f62f022101821c73ea3754f0a94e7 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sun, 26 Jan 2020 17:25:14 +1100 Subject: [PATCH] [c-host] inform the client if we have positional cursor information --- c-host/include/interface/capture.h | 3 ++- .../platform/Windows/capture/DXGI/src/dxgi.c | 13 ++++++------ .../Windows/capture/NVFBC/src/nvfbc.c | 16 ++++++++------ c-host/src/app.c | 18 ++++++++++------ common/include/common/KVMFR.h | 21 ++++++++++++------- 5 files changed, 45 insertions(+), 26 deletions(-) diff --git a/c-host/include/interface/capture.h b/c-host/include/interface/capture.h index 330b2870..783e7305 100644 --- a/c-host/include/interface/capture.h +++ b/c-host/include/interface/capture.h @@ -61,6 +61,7 @@ CaptureFrame; typedef struct CapturePointer { + bool positionUpdate; int x, y; bool visible; @@ -94,4 +95,4 @@ typedef struct CaptureInterface CaptureResult (*waitFrame )(CaptureFrame * frame); CaptureResult (*getFrame )(FrameBuffer * frame); } -CaptureInterface; \ No newline at end of file +CaptureInterface; diff --git a/c-host/platform/Windows/capture/DXGI/src/dxgi.c b/c-host/platform/Windows/capture/DXGI/src/dxgi.c index 6301b2be..2bcb8f0a 100644 --- a/c-host/platform/Windows/capture/DXGI/src/dxgi.c +++ b/c-host/platform/Windows/capture/DXGI/src/dxgi.c @@ -710,9 +710,15 @@ static CaptureResult dxgi_capture() frameInfo.PointerPosition.Visible != this->lastPointerVisible ) { + pointer.positionUpdate = true; this->lastPointerX = frameInfo.PointerPosition.Position.x; this->lastPointerY = frameInfo.PointerPosition.Position.y; this->lastPointerVisible = frameInfo.PointerPosition.Visible; + + pointer.x = this->lastPointerX; + pointer.y = this->lastPointerY; + pointer.visible = this->lastPointerVisible; + postPointer = true; } } @@ -754,12 +760,7 @@ static CaptureResult dxgi_capture() // post back the pointer information if (postPointer) - { - pointer.x = this->lastPointerX; - pointer.y = this->lastPointerY; - pointer.visible = this->lastPointerVisible; this->postPointerBufferFn(pointer); - } return CAPTURE_RESULT_OK; } @@ -868,4 +869,4 @@ struct CaptureInterface Capture_DXGI = .capture = dxgi_capture, .waitFrame = dxgi_waitFrame, .getFrame = dxgi_getFrame -}; \ No newline at end of file +}; diff --git a/c-host/platform/Windows/capture/NVFBC/src/nvfbc.c b/c-host/platform/Windows/capture/NVFBC/src/nvfbc.c index 7cb09938..0a2e860e 100644 --- a/c-host/platform/Windows/capture/NVFBC/src/nvfbc.c +++ b/c-host/platform/Windows/capture/NVFBC/src/nvfbc.c @@ -316,9 +316,9 @@ static int pointerThread(void * unused) if (this->stop) break; - CaptureResult result; + CaptureResult result; CapturePointer pointer = { 0 }; - pointer.shapeUpdate = false; + if (this->seperateCursor && events[1]) { void * data; @@ -341,9 +341,13 @@ static int pointerThread(void * unused) this->mouseHotY = pointer.y; } - pointer.visible = this->mouseVisible; - pointer.x = this->mouseX - this->mouseHotX; - pointer.y = this->mouseY - this->mouseHotY; + if (events[0]) + { + pointer.positionUpdate = true; + pointer.visible = this->mouseVisible; + pointer.x = this->mouseX - this->mouseHotX; + pointer.y = this->mouseY - this->mouseHotY; + } this->postPointerBufferFn(pointer); } @@ -365,4 +369,4 @@ struct CaptureInterface Capture_NVFBC = .capture = nvfbc_capture, .waitFrame = nvfbc_waitFrame, .getFrame = nvfbc_getFrame -}; \ No newline at end of file +}; diff --git a/c-host/src/app.c b/c-host/src/app.c index 67d422f0..df70e07a 100644 --- a/c-host/src/app.c +++ b/c-host/src/app.c @@ -312,10 +312,16 @@ void capturePostPointerBuffer(CapturePointer pointer) app.pointerIndex = 0; } + uint32_t flags = 0; KVMFRCursor *cursor = lgmpHostMemPtr(mem); - cursor->x = pointer.x; - cursor->y = pointer.y; - cursor->visible = pointer.visible; + + if (pointer.positionUpdate) + { + flags |= CURSOR_FLAG_POSITION; + cursor->x = pointer.x; + cursor->y = pointer.y; + cursor->visible = pointer.visible; + } if (pointer.shapeUpdate) { @@ -337,11 +343,11 @@ void capturePostPointerBuffer(CapturePointer pointer) app.pointerShapeValid = true; } - const uint32_t sendShape = - ((pointer.shapeUpdate || newClient) && app.pointerShapeValid) ? 1 : 0; + if ((pointer.shapeUpdate || newClient) && app.pointerShapeValid) + flags |= CURSOR_FLAG_SHAPE; LGMP_STATUS status; - while ((status = lgmpHostQueuePost(app.pointerQueue, sendShape, mem)) != LGMP_OK) + while ((status = lgmpHostQueuePost(app.pointerQueue, flags, mem)) != LGMP_OK) { if (status == LGMP_ERR_QUEUE_FULL) continue; diff --git a/common/include/common/KVMFR.h b/common/include/common/KVMFR.h index f01064c3..b5a92dc8 100644 --- a/common/include/common/KVMFR.h +++ b/common/include/common/KVMFR.h @@ -34,6 +34,13 @@ typedef enum FrameType } FrameType; +enum +{ + CURSOR_FLAG_POSITION = 0x1, + CURSOR_FLAG_SHAPE = 0x2 +}; +typedef uint32_t KVMFRCursorFlags; + typedef enum CursorType { CURSOR_TYPE_COLOR , @@ -55,11 +62,11 @@ KVMFRCursor; typedef struct KVMFRFrame { - FrameType type; // the frame data type - uint32_t width; // the width - uint32_t height; // the height - uint32_t stride; // the row stride (zero if compressed data) - uint32_t pitch; // the row pitch (stride in bytes or the compressed frame size) - uint32_t offset; // offset from the start of this header to the FrameBuffer header + FrameType type; // the frame data type + uint32_t width; // the width + uint32_t height; // the height + uint32_t stride; // the row stride (zero if compressed data) + uint32_t pitch; // the row pitch (stride in bytes or the compressed frame size) + uint32_t offset; // offset from the start of this header to the FrameBuffer header } -KVMFRFrame; \ No newline at end of file +KVMFRFrame;