summaryrefslogtreecommitdiff
path: root/kvmd/web/js
diff options
context:
space:
mode:
Diffstat (limited to 'kvmd/web/js')
-rw-r--r--kvmd/web/js/mouse.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/kvmd/web/js/mouse.js b/kvmd/web/js/mouse.js
index 4be05c99..1ba1f850 100644
--- a/kvmd/web/js/mouse.js
+++ b/kvmd/web/js/mouse.js
@@ -21,6 +21,9 @@ function Mouse() {
$("stream-box").onmousemove = __moveHandler;
$("stream-box").onwheel = __wheelHandler;
+ $("stream-box").ontouchstart = (event) => __touchHandler(event, true);
+ $("stream-box").ontouchend = (event) => __touchHandler(event, false);
+
setInterval(__sendMove, 100);
};
@@ -55,6 +58,28 @@ function Mouse() {
self.updateLeds();
};
+ var __touchHandler = function(event, state) {
+ if (state) {
+ var rect = event.touches[0].target.getBoundingClientRect();
+ __current_pos = {
+ x: Math.round(event.touches[0].clientX - rect.left),
+ y: Math.round(event.touches[0].clientY - rect.top),
+ };
+ __sendMove();
+ }
+ var button = "left"; // TODO
+ tools.debug("Mouse button", (state ? "pressed:" : "released:"), button);
+ if (__ws) {
+ __ws.send(JSON.stringify({
+ event_type: "mouse_button",
+ button: button,
+ state: state,
+ }));
+ }
+ event.stopPropagation();
+ event.preventDefault();
+ };
+
var __buttonHandler = function(event, state) {
// https://www.w3schools.com/jsref/event_button.asp
var button = null;