VNC-14 Update to relative mouse for better UX and app compatibility

This commit is contained in:
Matt McClaskey 2026-05-13 10:09:09 +00:00
parent dd1417229e
commit 9050929aa9
No known key found for this signature in database
22 changed files with 121 additions and 4 deletions

View file

@ -108,6 +108,9 @@ void SMsgReader::readMsg()
case msgTypeKeepAlive:
readKeepAlive();
break;
case msgTypeDirectMouseEvent:
readDirectMouseEvent();
break;
default:
fprintf(stderr, "unknown message type %d\n", msgType);
throw Exception("unknown message type");
@ -422,3 +425,20 @@ void SMsgReader::readVideoEncodersRequest() const {
handler->videoEncodersRequest(buf);
}
void SMsgReader::readDirectMouseEvent()
{
// Wire format (9 bytes after the type byte):
// byte 0: button mask (bit 0=left, 1=right, 2=middle, 3=side, 4=extra)
// bytes 1-2: dx (int16 BE)
// bytes 3-4: dy (int16 BE)
// bytes 5-6: scroll dx (int16 BE)
// bytes 7-8: scroll dy (int16 BE)
int buttonMask = is->readU8();
int dx = is->readS16();
int dy = is->readS16();
int scrollX = is->readS16();
int scrollY = is->readS16();
handler->directMouseEvent(dx, dy, buttonMask, scrollX, scrollY);
}