mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-18 01:15:46 +00:00
Add batching for mouse position packets
This commit is contained in:
parent
b44cad6598
commit
7b56ab755d
@ -297,6 +297,31 @@ static void inputSendThreadProc(void* context) {
|
||||
holder->packet.mouseMoveRel.deltaX = htons((short)totalDeltaX);
|
||||
holder->packet.mouseMoveRel.deltaY = htons((short)totalDeltaY);
|
||||
}
|
||||
// If it's an absolute mouse move packet, we should only send the latest
|
||||
else if (holder->packet.mouseMoveAbs.header.packetType == htonl(PACKET_TYPE_ABS_MOUSE_MOVE)) {
|
||||
for (;;) {
|
||||
PPACKET_HOLDER mouseBatchHolder;
|
||||
|
||||
// Peek at the next packet
|
||||
if (LbqPeekQueueElement(&packetQueue, (void**)&mouseBatchHolder) != LBQ_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
|
||||
// If it's not a mouse position packet, we're done
|
||||
if (mouseBatchHolder->packet.mouseMoveAbs.header.packetType != htonl(PACKET_TYPE_ABS_MOUSE_MOVE)) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Remove the mouse position packet
|
||||
if (LbqPollQueueElement(&packetQueue, (void**)&mouseBatchHolder) != LBQ_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Replace the current packet with the new one
|
||||
free(holder);
|
||||
holder = mouseBatchHolder;
|
||||
}
|
||||
}
|
||||
|
||||
// Encrypt the message into the output buffer while leaving room for the length
|
||||
encryptedSize = sizeof(encryptedBuffer) - 4;
|
||||
|
Loading…
x
Reference in New Issue
Block a user