mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
touch events as mouse - test
This commit is contained in:
parent
49b83948c0
commit
102b1b666d
@ -21,6 +21,9 @@ function Mouse() {
|
|||||||
$("stream-box").onmousemove = __moveHandler;
|
$("stream-box").onmousemove = __moveHandler;
|
||||||
$("stream-box").onwheel = __wheelHandler;
|
$("stream-box").onwheel = __wheelHandler;
|
||||||
|
|
||||||
|
$("stream-box").ontouchstart = (event) => __touchHandler(event, true);
|
||||||
|
$("stream-box").ontouchend = (event) => __touchHandler(event, false);
|
||||||
|
|
||||||
setInterval(__sendMove, 100);
|
setInterval(__sendMove, 100);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -55,6 +58,28 @@ function Mouse() {
|
|||||||
self.updateLeds();
|
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) {
|
var __buttonHandler = function(event, state) {
|
||||||
// https://www.w3schools.com/jsref/event_button.asp
|
// https://www.w3schools.com/jsref/event_button.asp
|
||||||
var button = null;
|
var button = null;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user