diff options
author | Maxim Devaev <[email protected]> | 2023-06-07 05:12:22 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2023-06-07 05:12:22 +0300 |
commit | 9f98a2f701703a3f9f591868547c834463d3d6b1 (patch) | |
tree | f2fe4f4541c78edaa6ec791a304d73f0595d4751 /web/share/js/kvm/mouse.js | |
parent | 9c694da00c7d93cbff3aa910ffdeeb8dded691c0 (diff) |
binary keyboard protocol
Diffstat (limited to 'web/share/js/kvm/mouse.js')
-rw-r--r-- | web/share/js/kvm/mouse.js | 33 |
1 files changed, 3 insertions, 30 deletions
diff --git a/web/share/js/kvm/mouse.js b/web/share/js/kvm/mouse.js index fb510d27..f2d6afde 100644 --- a/web/share/js/kvm/mouse.js +++ b/web/share/js/kvm/mouse.js @@ -345,38 +345,11 @@ export function Mouse(__getGeometry, __recordWsEvent) { }; var __sendEvent = function(event_type, event) { - let wrapped_event = {"event_type": event_type, "event": event}; + event = {"event_type": event_type, "event": event}; if (__ws && !$("hid-mute-switch").checked) { - if (event_type == "mouse_move") { - let data = new Uint8Array([ - 3, - (event.to.x >> 8) & 0xFF, event.to.x & 0xFF, - (event.to.y >> 8) & 0xFF, event.to.y & 0xFF, - ]); - __ws.send(data); - - } else if (event_type == "mouse_relative" || event_type == "mouse_wheel") { - let data; - if (Array.isArray(event.delta)) { - data = new Int8Array(2 + event.delta.length * 2); - let index = 0; - for (let delta of event.delta) { - data[index + 2] = delta["x"]; - data[index + 3] = delta["y"]; - index += 2; - } - } else { - data = new Int8Array([0, 0, event.delta.x, event.delta.y]); - } - data[0] = (event_type == "mouse_relative" ? 4 : 5); - data[1] = (event.squash ? 1 : 0); - __ws.send(data); - - } else { - __ws.send(JSON.stringify(wrapped_event)); - } + __ws.sendHidEvent(event); } - __recordWsEvent(wrapped_event); + __recordWsEvent(event); }; __init__(); |