mouse support

This commit is contained in:
Devaev Maxim
2018-08-01 17:31:23 +03:00
parent cb8e5efbc7
commit 9a5c583f80
9 changed files with 230 additions and 73 deletions

View File

@@ -1,10 +1,4 @@
var hid = new function() {
var __install_timer = null;
var __installed = false;
var __hidden_attr = null;
var __visibility_change_attr = null;
this.init = function() {
keyboard.init();
mouse.init();
@@ -32,32 +26,12 @@ var hid = new function() {
};
this.installCapture = function(ws) {
var http = tools.makeRequest("GET", "/kvmd/hid", function() {
if (http.readyState === 4) {
if (http.status === 200) {
features = JSON.parse(http.responseText).result.features;
if (features.mouse) {
mouse.setSocket(ws);
}
keyboard.setSocket(ws);
__installed = true;
} else {
tools.error("Can't resolve HID features:", http.responseText);
__install_timer = setTimeout(() => hid.installCapture(ws), 1000);
}
}
});
keyboard.setSocket(ws);
mouse.setSocket(ws);
};
this.clearCapture = function() {
if (__install_timer) {
clearTimeout(__install_timer);
__install_timer = null;
}
if (__installed) {
mouse.setSocket(null);
keyboard.setSocket(null);
__installed = false;
}
mouse.setSocket(null);
keyboard.setSocket(null);
};
}