mirror of
https://codeberg.org/PLG-Development/PLG-MuDiCS
synced 2026-07-06 08:57:09 +00:00
chore(control): Keyboard queue (#31)
Co-authored-by: 2mal3 <56305732+2mal3@users.noreply.github.com>
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
import { ArrowDownToLine, ArrowUpFromLine, Grid2x2, Grid2X2, Option } from 'lucide-svelte';
|
||||
import Button from '$lib/components/Button.svelte';
|
||||
import { onDestroy } from 'svelte';
|
||||
import { add_to_keyboard_queue } from '$lib/ts/utils';
|
||||
|
||||
let {
|
||||
popup_close_function
|
||||
@@ -58,17 +59,21 @@
|
||||
const action: 'press' | 'release' = key_down ? 'press' : 'release';
|
||||
|
||||
add_to_last_keys(action.toUpperCase() + ' ' + key);
|
||||
await run_on_all_selected_displays((d) => send_keyboard_input(d.ip, [{ key, action }]), true);
|
||||
add_to_keyboard_queue(async () => {
|
||||
await run_on_all_selected_displays((d) => send_keyboard_input(d.ip, [{ key, action }]), true);
|
||||
});
|
||||
}
|
||||
|
||||
async function release_all_pressed_keys() {
|
||||
function release_all_pressed_keys() {
|
||||
const inputs: { key: string; action: 'press' | 'release' }[] = [];
|
||||
for (let i = current_keys.length - 1; i >= 0; i--) {
|
||||
inputs.push({ key: current_keys[i], action: 'release' });
|
||||
current_keys.splice(i, 1);
|
||||
}
|
||||
|
||||
await run_on_all_selected_displays((d) => send_keyboard_input(d.ip, inputs), true);
|
||||
add_to_keyboard_queue(async () => {
|
||||
await run_on_all_selected_displays((d) => send_keyboard_input(d.ip, inputs), true);
|
||||
});
|
||||
}
|
||||
|
||||
onDestroy(() => {
|
||||
@@ -91,7 +96,7 @@
|
||||
}}
|
||||
onblur={async () => {
|
||||
active = false;
|
||||
await release_all_pressed_keys();
|
||||
release_all_pressed_keys();
|
||||
}}
|
||||
onkeydown={(e) => on_keyboard_input(e, true)}
|
||||
onkeyup={(e) => on_keyboard_input(e, false)}
|
||||
|
||||
Reference in New Issue
Block a user