summaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2024-12-30 18:55:59 +0200
committerMaxim Devaev <[email protected]>2024-12-30 18:55:59 +0200
commitfed3bf1efdea7528919eb9f318c5ada2dcf35410 (patch)
treef1bd27d882b85cf845b92b489b1c494c4d1dd715 /web
parentd52bb34bb9f5bc669f6b915ba585461356128e39 (diff)
pikvm/pikvm#1334: Bad link mode for keyboard events
Diffstat (limited to 'web')
-rw-r--r--web/kvm/index.html13
-rw-r--r--web/kvm/navbar-system.pug6
-rw-r--r--web/share/js/kvm/keyboard.js8
-rw-r--r--web/share/js/kvm/recorder.js6
-rw-r--r--web/share/js/kvm/session.js3
5 files changed, 30 insertions, 6 deletions
diff --git a/web/kvm/index.html b/web/kvm/index.html
index 1db915ee..c6d3301d 100644
--- a/web/kvm/index.html
+++ b/web/kvm/index.html
@@ -285,7 +285,7 @@
</tr>
</table>
<details>
- <summary>Keyboard &amp; Mouse (HID) settings</summary>
+ <summary>Keyboard &amp; mouse (HID) settings</summary>
<div class="spoiler">
<table class="kv">
<tr>
@@ -401,6 +401,15 @@
</div>
</details>
<table class="kv">
+ <tr>
+ <td>Bad link mode (release keys immediately):</td>
+ <td align="right">
+ <div class="switch-box">
+ <input type="checkbox" id="hid-keyboard-bad-link-switch">
+ <label for="hid-keyboard-bad-link-switch"><span class="switch-inner"></span><span class="switch"></span></label>
+ </div>
+ </td>
+ </tr>
<tr class="feature-disabled" id="hid-connect">
<td>Connect HID to Server:</td>
<td align="right">
@@ -420,7 +429,7 @@
</td>
</tr>
<tr>
- <td>Mute HID input events:</td>
+ <td>Mute all input HID events:</td>
<td align="right">
<div class="switch-box">
<input type="checkbox" id="hid-mute-switch">
diff --git a/web/kvm/navbar-system.pug b/web/kvm/navbar-system.pug
index a3438486..55d70757 100644
--- a/web/kvm/navbar-system.pug
+++ b/web/kvm/navbar-system.pug
@@ -85,7 +85,7 @@ li(id="system-dropdown" class="right")
td Mouse #[a(target="_blank" href="https://docs.pikvm.org/mouse") mode]:
td #[div(id="hid-outputs-mouse-box" class="radio-box")]
details
- summary Keyboard &amp; Mouse (HID) settings
+ summary Keyboard &amp; mouse (HID) settings
div(class="spoiler")
table(class="kv")
tr
@@ -127,12 +127,14 @@ li(id="system-dropdown" class="right")
tr
+menu_switch_notable("page-full-tab-stream-switch", "Expand for the entire tab by default", true, false)
table(class="kv")
+ tr
+ +menu_switch_notable("hid-keyboard-bad-link-switch", "Bad link mode (release keys immediately)", true, false)
tr(id="hid-connect" class="feature-disabled")
+menu_switch_notable("hid-connect-switch", "Connect HID to Server", true, true)
tr(id="hid-jiggler" class="feature-disabled")
+menu_switch_notable("hid-jiggler-switch", "<a href=\"https://docs.pikvm.org/mouse_jiggler\" target=\"_blank\">Mouse jiggler</a>", false, false)
tr
- +menu_switch_notable("hid-mute-switch", "Mute HID input events", true, false)
+ +menu_switch_notable("hid-mute-switch", "Mute all input HID events", true, false)
tr(id="v3-usb-breaker" class="feature-disabled")
+menu_switch_notable_gpio("__v3_usb_breaker__", "Connect main USB to Server",
"Turning off this switch will disconnect the main USB from the server. Are you sure you want to continue?")
diff --git a/web/share/js/kvm/keyboard.js b/web/share/js/kvm/keyboard.js
index 2377d07a..f30dbfe9 100644
--- a/web/share/js/kvm/keyboard.js
+++ b/web/share/js/kvm/keyboard.js
@@ -52,6 +52,7 @@ export function Keyboard(__recordWsEvent) {
window.addEventListener("focusin", __updateOnlineLeds);
window.addEventListener("focusout", __updateOnlineLeds);
+ tools.storage.bindSimpleSwitch($("hid-keyboard-bad-link-switch"), "hid.keyboard.bad_link", false);
tools.storage.bindSimpleSwitch($("hid-keyboard-swap-cc-switch"), "hid.keyboard.swap_cc", false);
};
@@ -140,11 +141,16 @@ export function Keyboard(__recordWsEvent) {
}
let event = {
"event_type": "key",
- "event": {"key": code, "state": state},
+ "event": {
+ "key": code,
+ "state": state,
+ "finish": $("hid-keyboard-bad-link-switch").checked,
+ },
};
if (__ws && !$("hid-mute-switch").checked) {
__ws.sendHidEvent(event);
}
+ delete event.event.finish;
__recordWsEvent(event);
};
diff --git a/web/share/js/kvm/recorder.js b/web/share/js/kvm/recorder.js
index 5d9d1553..cf792bc2 100644
--- a/web/share/js/kvm/recorder.js
+++ b/web/share/js/kvm/recorder.js
@@ -336,7 +336,11 @@ export function Recorder() {
});
return;
- } else if (["key", "mouse_button", "mouse_move", "mouse_wheel", "mouse_relative"].includes(event.event_type)) {
+ } else if (event.event_type === "key") {
+ event.event.finish = $("hid-keyboard-bad-link-switch").checked;
+ __ws.sendHidEvent(event);
+
+ } else if (["mouse_button", "mouse_move", "mouse_wheel", "mouse_relative"].includes(event.event_type)) {
__ws.sendHidEvent(event);
} else if (event.event_type === "mouse_move_random") {
diff --git a/web/share/js/kvm/session.js b/web/share/js/kvm/session.js
index c9839aca..38508f18 100644
--- a/web/share/js/kvm/session.js
+++ b/web/share/js/kvm/session.js
@@ -316,6 +316,9 @@ export function Session() {
if (event_type == "key") {
let data = __ascii_encoder.encode("\x01\x00" + event.key);
data[1] = (event.state ? 1 : 0);
+ if (event.finish === true) { // Optional
+ data[1] |= 0x02;
+ }
ws.send(data);
} else if (event_type == "mouse_button") {