mirror of https://github.com/jetkvm/kvm.git
fix: update keysDownState handling
This commit is contained in:
parent
455ab1bf02
commit
ade9a4961a
|
@ -87,7 +87,7 @@ export default function useKeyboard() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// On older backends, we need to set the keysDownState manually since without the hidRpc API, the state doesn't trickle down from the backend
|
// On older backends, we need to set the keysDownState manually since without the hidRpc API, the state doesn't trickle down from the backend
|
||||||
setKeysDownState(MACRO_RESET_KEYBOARD_STATE);
|
setKeysDownState({ modifier, keys });
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[send, setKeysDownState],
|
[send, setKeysDownState],
|
||||||
|
@ -155,7 +155,7 @@ export default function useKeyboard() {
|
||||||
|
|
||||||
const ac = new AbortController();
|
const ac = new AbortController();
|
||||||
setAbortController(ac);
|
setAbortController(ac);
|
||||||
|
|
||||||
for (const [_, step] of steps.entries()) {
|
for (const [_, step] of steps.entries()) {
|
||||||
const keyValues = (step.keys || []).map(key => keys[key]).filter(Boolean);
|
const keyValues = (step.keys || []).map(key => keys[key]).filter(Boolean);
|
||||||
const modifierMask: number = (step.modifiers || [])
|
const modifierMask: number = (step.modifiers || [])
|
||||||
|
@ -167,7 +167,7 @@ export default function useKeyboard() {
|
||||||
promises.push(() => sendKeystrokeLegacy(keyValues, modifierMask, ac));
|
promises.push(() => sendKeystrokeLegacy(keyValues, modifierMask, ac));
|
||||||
promises.push(() => resetKeyboardState());
|
promises.push(() => resetKeyboardState());
|
||||||
promises.push(() => sleep(step.delay || 100));
|
promises.push(() => sleep(step.delay || 100));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const runAll = async () => {
|
const runAll = async () => {
|
||||||
|
@ -185,9 +185,9 @@ export default function useKeyboard() {
|
||||||
const abortListener = () => {
|
const abortListener = () => {
|
||||||
reject(new Error("Macro execution aborted"));
|
reject(new Error("Macro execution aborted"));
|
||||||
};
|
};
|
||||||
|
|
||||||
ac.signal.addEventListener("abort", abortListener);
|
ac.signal.addEventListener("abort", abortListener);
|
||||||
|
|
||||||
runAll()
|
runAll()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
ac.signal.removeEventListener("abort", abortListener);
|
ac.signal.removeEventListener("abort", abortListener);
|
||||||
|
|
Loading…
Reference in New Issue