This commit is contained in:
Maxim Devaev
2023-10-23 08:10:19 +03:00
parent 73f96fa0c7
commit 4038754c37
9 changed files with 156 additions and 9 deletions

View File

@@ -338,6 +338,15 @@
</div>
</td>
</tr>
<tr>
<td>Mouse jiggler:</td>
<td align="right">
<div class="switch-box">
<input disabled type="checkbox" id="hid-jiggler-switch">
<label for="hid-jiggler-switch"><span class="switch-inner"></span><span class="switch"></span></label>
</div>
</td>
</tr>
<tr>
<td>Mute HID input events:</td>
<td align="right">

View File

@@ -99,6 +99,8 @@ li(id="system-dropdown" class="right")
table(class="kv")
tr(id="hid-connect" class="feature-disabled")
+menu_switch_notable("hid-connect-switch", "Connect HID to Server", true, true)
tr
+menu_switch_notable("hid-jiggler-switch", "Mouse jiggler", false, false)
tr
+menu_switch_notable("hid-mute-switch", "Mute HID input events", true, false)
tr(id="v3-usb-breaker" class="feature-disabled")

View File

@@ -111,6 +111,8 @@ export function Hid(__getGeometry, __recorder) {
}
tools.storage.bindSimpleSwitch($("hid-sysrq-ask-switch"), "hid.sysrq.ask", true);
tools.el.setOnClick($("hid-jiggler-switch"), __clickJigglerSwitch);
};
/************************************************************************/
@@ -119,6 +121,7 @@ export function Hid(__getGeometry, __recorder) {
tools.el.setEnabled($("hid-pak-text"), ws);
tools.el.setEnabled($("hid-pak-button"), ws);
tools.el.setEnabled($("hid-reset-button"), ws);
tools.el.setEnabled($("hid-jiggler-switch"), ws);
if (!ws) {
self.setState(null);
}
@@ -129,6 +132,9 @@ export function Hid(__getGeometry, __recorder) {
self.setState = function(state) {
let has_relative_squash = false;
if (state) {
$("hid-jiggler-switch").checked = !!state.jiggler.enabled;
}
if (state && state.online) {
let keyboard_outputs = state.keyboard.outputs.available;
let mouse_outputs = state.mouse.outputs.available;
@@ -290,6 +296,17 @@ export function Hid(__getGeometry, __recorder) {
});
};
var __clickJigglerSwitch = function() {
let enabled = $("hid-jiggler-switch").checked;
let http = tools.makeRequest("POST", `/api/hid/set_params?jiggler=${enabled}`, function() {
if (http.readyState === 4) {
if (http.status !== 200) {
wm.error(`Can't ${enabled ? "enabled" : "disable"} mouse juggler:<br>`, http.responseText);
}
}
});
};
var __clickConnectSwitch = function() {
let connected = $("hid-connect-switch").checked;
let http = tools.makeRequest("POST", `/api/hid/set_connected?connected=${connected}`, function() {