diff --git a/web/kvm/index.html b/web/kvm/index.html index 1697882b..59962dad 100644 --- a/web/kvm/index.html +++ b/web/kvm/index.html @@ -183,6 +183,18 @@ +
+
+ + + +
Connect HID to Server: +
+ + +
+
+

diff --git a/web/kvm/navbar-system.pug b/web/kvm/navbar-system.pug index cb6fc79f..03111535 100644 --- a/web/kvm/navbar-system.pug +++ b/web/kvm/navbar-system.pug @@ -45,6 +45,9 @@ li(class="right") div(id="hid-mouse-squash" class="feature-disabled") hr +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 div(class="buttons buttons-row") button(data-force-hide-menu id="show-keyboard-button" class="row50") • Show keyboard diff --git a/web/share/js/kvm/hid.js b/web/share/js/kvm/hid.js index 580a5417..f5b85ac9 100644 --- a/web/share/js/kvm/hid.js +++ b/web/share/js/kvm/hid.js @@ -75,6 +75,7 @@ export function Hid() { window.addEventListener("blur", __releaseAll); tools.setOnClick($("hid-pak-button"), __clickPasteAsKeysButton); + tools.setOnClick($("hid-connect-checkbox"), __clickConnectCheckbox); tools.setOnClick($("hid-reset-button"), __clickResetButton); for (let el_shortcut of $$$("[data-shortcut]")) { @@ -146,11 +147,14 @@ export function Hid() { } tools.featureSetEnabled($("hid-outputs"), has_outputs); 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-mouse-radio", (state && state.online && !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) { __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:
`, http.responseText); + } + } + }); + }; + var __clickResetButton = function() { wm.confirm("Are you sure you want to reset HID (keyboard & mouse)?").then(function(ok) { if (ok) {