mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 00:51:53 +08:00
pikvm/pikvm#1334: Bad link mode for keyboard events
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
@@ -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") {
|
||||
|
||||
@@ -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") {
|
||||
|
||||
Reference in New Issue
Block a user