summaryrefslogtreecommitdiff
path: root/web/share/js
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2023-10-23 08:10:19 +0300
committerMaxim Devaev <[email protected]>2023-10-23 08:10:19 +0300
commit4038754c375e38d5379a701ea5d65411bfb19034 (patch)
tree16e501286e95aa88228624747bd805c652c97bc8 /web/share/js
parent73f96fa0c7fb9cda167521349c646a7b9a91253b (diff)
pikvm/pikvm#57: Mouse jiggler
Diffstat (limited to 'web/share/js')
-rw-r--r--web/share/js/kvm/hid.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/web/share/js/kvm/hid.js b/web/share/js/kvm/hid.js
index 3f399b67..6d9d8597 100644
--- a/web/share/js/kvm/hid.js
+++ b/web/share/js/kvm/hid.js
@@ -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() {