mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 00:51:53 +08:00
hid connection iface
This commit is contained in:
@@ -183,6 +183,18 @@
|
|||||||
</td>
|
</td>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="feature-disabled" id="hid-connect">
|
||||||
|
<hr>
|
||||||
|
<table class="kv">
|
||||||
|
<td>Connect HID to Server:</td>
|
||||||
|
<td align="right">
|
||||||
|
<div class="switch-box">
|
||||||
|
<input checked type="checkbox" id="hid-connect-checkbox">
|
||||||
|
<label for="hid-connect-checkbox"><span class="switch-inner"></span><span class="switch"></span></label>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="buttons buttons-row">
|
<div class="buttons buttons-row">
|
||||||
<button class="row50" data-force-hide-menu id="show-keyboard-button">• Show keyboard</button>
|
<button class="row50" data-force-hide-menu id="show-keyboard-button">• Show keyboard</button>
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ li(class="right")
|
|||||||
div(id="hid-mouse-squash" class="feature-disabled")
|
div(id="hid-mouse-squash" class="feature-disabled")
|
||||||
hr
|
hr
|
||||||
+menu_switch("hid-mouse-squash-checkbox", "Squash relative mouse moves", true, true)
|
+menu_switch("hid-mouse-squash-checkbox", "Squash relative mouse moves", true, true)
|
||||||
|
div(id="hid-connect" class="feature-disabled")
|
||||||
|
hr
|
||||||
|
+menu_switch("hid-connect-checkbox", "Connect HID to Server", true, true)
|
||||||
hr
|
hr
|
||||||
div(class="buttons buttons-row")
|
div(class="buttons buttons-row")
|
||||||
button(data-force-hide-menu id="show-keyboard-button" class="row50") • Show keyboard
|
button(data-force-hide-menu id="show-keyboard-button" class="row50") • Show keyboard
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ export function Hid() {
|
|||||||
window.addEventListener("blur", __releaseAll);
|
window.addEventListener("blur", __releaseAll);
|
||||||
|
|
||||||
tools.setOnClick($("hid-pak-button"), __clickPasteAsKeysButton);
|
tools.setOnClick($("hid-pak-button"), __clickPasteAsKeysButton);
|
||||||
|
tools.setOnClick($("hid-connect-checkbox"), __clickConnectCheckbox);
|
||||||
tools.setOnClick($("hid-reset-button"), __clickResetButton);
|
tools.setOnClick($("hid-reset-button"), __clickResetButton);
|
||||||
|
|
||||||
for (let el_shortcut of $$$("[data-shortcut]")) {
|
for (let el_shortcut of $$$("[data-shortcut]")) {
|
||||||
@@ -146,11 +147,14 @@ export function Hid() {
|
|||||||
}
|
}
|
||||||
tools.featureSetEnabled($("hid-outputs"), has_outputs);
|
tools.featureSetEnabled($("hid-outputs"), has_outputs);
|
||||||
tools.featureSetEnabled($("hid-mouse-squash"), has_relative);
|
tools.featureSetEnabled($("hid-mouse-squash"), has_relative);
|
||||||
|
tools.featureSetEnabled($("hid-connect"), (state.connected !== null));
|
||||||
|
$("hid-connect-checkbox").checked = !!state.connected;
|
||||||
}
|
}
|
||||||
|
|
||||||
wm.switchRadioEnabled("hid-outputs-keyboard-radio", (state && state.online && !state.busy));
|
wm.switchRadioEnabled("hid-outputs-keyboard-radio", (state && state.online && !state.busy));
|
||||||
wm.switchRadioEnabled("hid-outputs-mouse-radio", (state && state.online && !state.busy));
|
wm.switchRadioEnabled("hid-outputs-mouse-radio", (state && state.online && !state.busy));
|
||||||
wm.switchEnabled($("hid-mouse-squash-checkbox"), (has_relative_squash && !state.busy));
|
wm.switchEnabled($("hid-mouse-squash-checkbox"), (has_relative_squash && !state.busy));
|
||||||
|
wm.switchEnabled($("hid-connect-checkbox"), (state && state.online && !state.busy));
|
||||||
|
|
||||||
if (state) {
|
if (state) {
|
||||||
__keyboard.setState(state.keyboard, state.online, state.busy);
|
__keyboard.setState(state.keyboard, state.online, state.busy);
|
||||||
@@ -236,6 +240,17 @@ export function Hid() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var __clickConnectCheckbox = function() {
|
||||||
|
let connected = $("hid-connect-checkbox").checked;
|
||||||
|
let http = tools.makeRequest("POST", `/api/hid/set_connected?connected=${connected}`, function() {
|
||||||
|
if (http.readyState === 4) {
|
||||||
|
if (http.status !== 200) {
|
||||||
|
wm.error(`Can't ${connected ? "connect" : "disconnect"} HID:<br>`, http.responseText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
var __clickResetButton = function() {
|
var __clickResetButton = function() {
|
||||||
wm.confirm("Are you sure you want to reset HID (keyboard & mouse)?").then(function(ok) {
|
wm.confirm("Are you sure you want to reset HID (keyboard & mouse)?").then(function(ok) {
|
||||||
if (ok) {
|
if (ok) {
|
||||||
|
|||||||
Reference in New Issue
Block a user