mirror of https://github.com/jetkvm/kvm.git
Compare commits
2 Commits
93dbd280fb
...
eb22ff2ab9
| Author | SHA1 | Date |
|---|---|---|
|
|
eb22ff2ab9 | |
|
|
703625d59a |
|
|
@ -1136,9 +1136,7 @@ func rpcDoExecuteKeyboardMacro(ctx context.Context, macro []hidrpc.KeyboardMacro
|
||||||
|
|
||||||
// don't report keyboard state changes while executing the macro
|
// don't report keyboard state changes while executing the macro
|
||||||
gadget.SuspendKeyDownMessages()
|
gadget.SuspendKeyDownMessages()
|
||||||
defer func() {
|
defer gadget.ResumeSuspendKeyDownMessages()
|
||||||
gadget.ResumeSuspendKeyDownMessages()
|
|
||||||
}()
|
|
||||||
|
|
||||||
for i, step := range macro {
|
for i, step := range macro {
|
||||||
delay := time.Duration(step.Delay) * time.Millisecond
|
delay := time.Duration(step.Delay) * time.Millisecond
|
||||||
|
|
@ -1159,7 +1157,8 @@ func rpcDoExecuteKeyboardMacro(ctx context.Context, macro []hidrpc.KeyboardMacro
|
||||||
case <-time.After(delay):
|
case <-time.After(delay):
|
||||||
// Sleep completed normally
|
// Sleep completed normally
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
// make sure keyboard state is reset
|
// make sure keyboard state is reset and the client gets notified
|
||||||
|
gadget.ResumeSuspendKeyDownMessages()
|
||||||
err := rpcKeyboardReport(0, keyboardClearStateKeys)
|
err := rpcKeyboardReport(0, keyboardClearStateKeys)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warn().Err(err).Msg("failed to reset keyboard state")
|
logger.Warn().Err(err).Msg("failed to reset keyboard state")
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import { TextAreaWithLabel } from "@components/TextArea";
|
||||||
|
|
||||||
// uint32 max value / 4
|
// uint32 max value / 4
|
||||||
const pasteMaxLength = 1073741824;
|
const pasteMaxLength = 1073741824;
|
||||||
|
const defaultDelay = 20;
|
||||||
|
|
||||||
export default function PasteModal() {
|
export default function PasteModal() {
|
||||||
const TextAreaRef = useRef<HTMLTextAreaElement>(null);
|
const TextAreaRef = useRef<HTMLTextAreaElement>(null);
|
||||||
|
|
@ -27,10 +28,10 @@ export default function PasteModal() {
|
||||||
const { executeMacro, cancelExecuteMacro } = useKeyboard();
|
const { executeMacro, cancelExecuteMacro } = useKeyboard();
|
||||||
|
|
||||||
const [invalidChars, setInvalidChars] = useState<string[]>([]);
|
const [invalidChars, setInvalidChars] = useState<string[]>([]);
|
||||||
const [delayValue, setDelayValue] = useState(20);
|
const [delayValue, setDelayValue] = useState(defaultDelay);
|
||||||
const delay = useMemo(() => {
|
const delay = useMemo(() => {
|
||||||
if (delayValue < 0 || delayValue > 65534) {
|
if (delayValue < 0 || delayValue > 65534) {
|
||||||
return 20;
|
return defaultDelay;
|
||||||
}
|
}
|
||||||
return delayValue;
|
return delayValue;
|
||||||
}, [delayValue]);
|
}, [delayValue]);
|
||||||
|
|
@ -40,7 +41,7 @@ export default function PasteModal() {
|
||||||
const delayClassName = useMemo(() => debugMode ? "" : "hidden", [debugMode]);
|
const delayClassName = useMemo(() => debugMode ? "" : "hidden", [debugMode]);
|
||||||
|
|
||||||
const { setKeyboardLayout } = useSettingsStore();
|
const { setKeyboardLayout } = useSettingsStore();
|
||||||
const { selectedKeyboard } = useKeyboardLayout();
|
const { selectedKeyboard } = useKeyboardLayout();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
send("getKeyboardLayout", {}, (resp: JsonRpcResponse) => {
|
send("getKeyboardLayout", {}, (resp: JsonRpcResponse) => {
|
||||||
|
|
@ -194,11 +195,11 @@ export default function PasteModal() {
|
||||||
setDelayValue(parseInt(e.target.value, 10));
|
setDelayValue(parseInt(e.target.value, 10));
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{delayValue < 0 || delayValue > 65534 && (
|
{delayValue < defaultDelay || delayValue > 65534 && (
|
||||||
<div className="mt-2 flex items-center gap-x-2">
|
<div className="mt-2 flex items-center gap-x-2">
|
||||||
<ExclamationCircleIcon className="h-4 w-4 text-red-500 dark:text-red-400" />
|
<ExclamationCircleIcon className="h-4 w-4 text-red-500 dark:text-red-400" />
|
||||||
<span className="text-xs text-red-500 dark:text-red-400">
|
<span className="text-xs text-red-500 dark:text-red-400">
|
||||||
Delay must be between 0 and 65534
|
Delay should be between 20 and 65534
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue