diff options
author | Amitoj Kapoor <[email protected]> | 2022-10-21 19:15:41 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2022-10-22 02:15:41 +0300 |
commit | 2804f5fd150006a98eb96e96a7d8a63286529bb1 (patch) | |
tree | 5a97856cb9b63f4dfc13a4e9283b8f858288a486 /web | |
parent | 34bb202d623dff0280ade58fefd12505e397da27 (diff) |
Fixes relative mouse macro (#117)
Fixes relative mouse macro
Diffstat (limited to 'web')
-rw-r--r-- | web/share/js/kvm/recorder.js | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/web/share/js/kvm/recorder.js b/web/share/js/kvm/recorder.js index 0c03e258..a042525c 100644 --- a/web/share/js/kvm/recorder.js +++ b/web/share/js/kvm/recorder.js @@ -171,6 +171,9 @@ export function Recorder() { __checkType(event.event.to, "object", "Non-object mouse move target"); __checkInt(event.event.to.x, "Non-int mouse move X"); __checkInt(event.event.to.y, "Non-int mouse move Y"); + } else if (event.event_type === "mouse_relative") { + __checkMouseRelativeDelta(event.event.delta) + __checkType(event.event.squash, "boolean", "Non-boolean squash"); } else if (event.event_type === "mouse_wheel") { __checkType(event.event.delta, "object", "Non-object mouse wheel delta"); __checkInt(event.event.delta.x, "Non-int mouse delta X"); @@ -214,6 +217,21 @@ export function Recorder() { } }; + var __checkArray = function (obj, msg) { + if (!Array.isArray(obj)) { + throw msg; + } + }; + + var __checkMouseRelativeDelta = function(delta) { + __checkArray(delta, "Non-array relative mouse delta"); + delta.forEach(element => { + __checkType(element, "object", "Non-object relative mouse delta element"); + __checkInt(element.x, "Non-int mouse delta X"); + __checkInt(element.y, "Non-int mouse delta Y"); + }); + }; + var __runEvents = function(index, time=0) { while (index < __events.length) { __setCounters(__events.length - index + 1, __events_time - time); @@ -271,7 +289,7 @@ export function Recorder() { }); return; - } else if (["key", "mouse_button", "mouse_move", "mouse_wheel"].includes(event.event_type)) { + } else if (["key", "mouse_button", "mouse_move", "mouse_wheel", "mouse_relative"].includes(event.event_type)) { __ws.send(JSON.stringify(event)); } |