mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-31 10:01:53 +08:00
separate state for hid offline
This commit is contained in:
@@ -153,8 +153,8 @@ export function Hid() {
|
|||||||
wm.switchEnabled($("hid-mouse-squash-checkbox"), (has_relative_squash && !state.busy));
|
wm.switchEnabled($("hid-mouse-squash-checkbox"), (has_relative_squash && !state.busy));
|
||||||
|
|
||||||
if (state) {
|
if (state) {
|
||||||
__keyboard.setState(state.keyboard);
|
__keyboard.setState(state.keyboard, state.online, state.busy);
|
||||||
__mouse.setState(state.mouse);
|
__mouse.setState(state.mouse, state.online, state.busy);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -73,8 +73,12 @@ export function Keyboard(record_callback) {
|
|||||||
__updateOnlineLeds();
|
__updateOnlineLeds();
|
||||||
};
|
};
|
||||||
|
|
||||||
self.setState = function(state) {
|
self.setState = function(state, hid_online, hid_busy) {
|
||||||
__online = state.online;
|
if (!hid_online) {
|
||||||
|
__online = null;
|
||||||
|
} else {
|
||||||
|
__online = (state.online && !hid_busy);
|
||||||
|
}
|
||||||
__updateOnlineLeds();
|
__updateOnlineLeds();
|
||||||
|
|
||||||
for (let led of ["caps", "scroll", "num"]) {
|
for (let led of ["caps", "scroll", "num"]) {
|
||||||
@@ -107,14 +111,17 @@ export function Keyboard(record_callback) {
|
|||||||
let title = "Keyboard free";
|
let title = "Keyboard free";
|
||||||
|
|
||||||
if (__ws) {
|
if (__ws) {
|
||||||
if (__online) {
|
if (__online === null) {
|
||||||
|
led = "led-red";
|
||||||
|
title = (is_captured ? "Keyboard captured, HID offline" : "Keyboard free, HID offline");
|
||||||
|
} else if (__online) {
|
||||||
if (is_captured) {
|
if (is_captured) {
|
||||||
led = "led-green";
|
led = "led-green";
|
||||||
title = "Keyboard captured";
|
title = "Keyboard captured";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
led = "led-yellow";
|
led = "led-yellow";
|
||||||
title = (is_captured ? "Keyboard captured, HID offline" : "Keyboard free, HID offline");
|
title = (is_captured ? "Keyboard captured, inactive/busy" : "Keyboard free, inactive/busy");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (is_captured) {
|
if (is_captured) {
|
||||||
|
|||||||
@@ -77,8 +77,12 @@ export function Mouse(record_callback) {
|
|||||||
__updateOnlineLeds();
|
__updateOnlineLeds();
|
||||||
};
|
};
|
||||||
|
|
||||||
self.setState = function(state) {
|
self.setState = function(state, hid_online, hid_busy) {
|
||||||
__online = state.online;
|
if (!hid_online) {
|
||||||
|
__online = null;
|
||||||
|
} else {
|
||||||
|
__online = (state.online && !hid_busy);
|
||||||
|
}
|
||||||
if (!__absolute && state.absolute && __isRelativeCaptured()) {
|
if (!__absolute && state.absolute && __isRelativeCaptured()) {
|
||||||
document.exitPointerLock();
|
document.exitPointerLock();
|
||||||
}
|
}
|
||||||
@@ -101,27 +105,30 @@ export function Mouse(record_callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var __updateOnlineLeds = function() {
|
var __updateOnlineLeds = function() {
|
||||||
let captured;
|
let is_captured;
|
||||||
if (__absolute) {
|
if (__absolute) {
|
||||||
captured = (__stream_hovered || tools.browser.is_ios);
|
is_captured = (__stream_hovered || tools.browser.is_ios);
|
||||||
} else {
|
} else {
|
||||||
captured = __isRelativeCaptured();
|
is_captured = __isRelativeCaptured();
|
||||||
}
|
}
|
||||||
let led = "led-gray";
|
let led = "led-gray";
|
||||||
let title = "Mouse free";
|
let title = "Mouse free";
|
||||||
|
|
||||||
if (__ws) {
|
if (__ws) {
|
||||||
if (__online) {
|
if (__online === null) {
|
||||||
if (captured) {
|
led = "led-red";
|
||||||
|
title = (is_captured ? "Mouse captured, HID offline" : "Mouse free, HID offline");
|
||||||
|
} else if (__online) {
|
||||||
|
if (is_captured) {
|
||||||
led = "led-green";
|
led = "led-green";
|
||||||
title = "Mouse captured";
|
title = "Mouse captured";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
led = "led-yellow";
|
led = "led-yellow";
|
||||||
title = (captured ? "Mouse captured, HID offline" : "Mouse free, HID offline");
|
title = (is_captured ? "Mouse captured, inactive/busy" : "Mouse free, inactive/busy");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (captured) {
|
if (is_captured) {
|
||||||
title = "Mouse captured, Pi-KVM offline";
|
title = "Mouse captured, Pi-KVM offline";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user