From 606584bfdb4d8f7019899fcc26347554e755bf1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Tue, 23 Feb 2021 21:26:17 +0100 Subject: [PATCH] keysym as uint32. --- src/component/internal/webrtc.ts | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/component/internal/webrtc.ts b/src/component/internal/webrtc.ts index 8f6d4f06..7895d68e 100644 --- a/src/component/internal/webrtc.ts +++ b/src/component/internal/webrtc.ts @@ -6,6 +6,8 @@ export const OPCODE = { SCROLL: 0x02, KEY_DOWN: 0x03, KEY_UP: 0x04, + BTN_DOWN: 0x05, + BTN_UP: 0x06, } as const export interface WebRTCStats { @@ -183,20 +185,32 @@ export class NekoWebRTC extends EventEmitter { payload.setInt16(5, data.y) break case 'keydown': - case 'mousedown': - buffer = new ArrayBuffer(11) + buffer = new ArrayBuffer(7) payload = new DataView(buffer) payload.setUint8(0, OPCODE.KEY_DOWN) - payload.setUint16(1, 8) - payload.setBigUint64(3, BigInt(data.key)) + payload.setUint16(1, 4) + payload.setUint32(3, data.key) break case 'keyup': - case 'mouseup': - buffer = new ArrayBuffer(11) + buffer = new ArrayBuffer(7) payload = new DataView(buffer) payload.setUint8(0, OPCODE.KEY_UP) - payload.setUint16(1, 8) - payload.setBigUint64(3, BigInt(data.key)) + payload.setUint16(1, 4) + payload.setUint32(3, data.key) + break + case 'mousedown': + buffer = new ArrayBuffer(7) + payload = new DataView(buffer) + payload.setUint8(0, OPCODE.BTN_DOWN) + payload.setUint16(1, 4) + payload.setUint32(3, data.key) + break + case 'mouseup': + buffer = new ArrayBuffer(7) + payload = new DataView(buffer) + payload.setUint8(0, OPCODE.BTN_UP) + payload.setUint16(1, 4) + payload.setUint32(3, data.key) break default: this._log.warn(`unknown data event: ${event}`)