mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-02-02 02:51:53 +08:00
simplified hid
This commit is contained in:
@@ -1,15 +1,20 @@
|
||||
var hid = new function() {
|
||||
var __install_timer = null;
|
||||
|
||||
this.init = function() {
|
||||
keyboard.init();
|
||||
mouse.init();
|
||||
}
|
||||
|
||||
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.installCapture(ws);
|
||||
mouse.setSocket(ws);
|
||||
}
|
||||
keyboard.installCapture(ws);
|
||||
keyboard.setSocket(ws);
|
||||
} else {
|
||||
tools.error("Can't resolve HID features:", http.responseText);
|
||||
__install_timer = setTimeout(() => hid.installCapture(ws), 1000);
|
||||
@@ -23,7 +28,7 @@ var hid = new function() {
|
||||
clearTimeout(__install_timer);
|
||||
__install_timer = null;
|
||||
}
|
||||
mouse.clearCapture();
|
||||
keyboard.clearCapture();
|
||||
mouse.setSocket(null);
|
||||
keyboard.setSocket(null);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user