mirror of
https://github.com/AkiChase/scrcpy-mask
synced 2024-11-12 20:11:21 +08:00
style(sendKey): simplify the code
This commit is contained in:
parent
83f097fbf0
commit
a55c28ffc8
@ -14,18 +14,12 @@ import { KeyMappingConfig, KeySteeringWheel } from "../keyMappingConfig";
|
||||
import { getVersion } from "@tauri-apps/api/app";
|
||||
import { fetch } from "@tauri-apps/plugin-http";
|
||||
import { open } from "@tauri-apps/plugin-shell";
|
||||
import {
|
||||
sendInjectKeycode,
|
||||
sendSetClipboard,
|
||||
} from "../frontcommand/controlMsg";
|
||||
import { sendSetClipboard } from "../frontcommand/controlMsg";
|
||||
import { getCurrent, PhysicalSize } from "@tauri-apps/api/window";
|
||||
import {
|
||||
AndroidKeyEventAction,
|
||||
AndroidKeycode,
|
||||
AndroidMetastate,
|
||||
} from "../frontcommand/android";
|
||||
import { AndroidKeycode } from "../frontcommand/android";
|
||||
import { Store } from "@tauri-apps/plugin-store";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { SendKeyAction, sendKey } from "../frontcommand/scrcpyMaskCmd";
|
||||
|
||||
const { t } = useI18n();
|
||||
const store = useGlobalStore();
|
||||
@ -203,18 +197,9 @@ async function pasteText() {
|
||||
});
|
||||
await sleep(300);
|
||||
// send enter
|
||||
await sendInjectKeycode({
|
||||
action: AndroidKeyEventAction.AKEY_EVENT_ACTION_DOWN,
|
||||
await sendKey({
|
||||
action: SendKeyAction.Default,
|
||||
keycode: AndroidKeycode.AKEYCODE_ENTER,
|
||||
repeat: 0,
|
||||
metastate: AndroidMetastate.AMETA_NONE,
|
||||
});
|
||||
await sleep(50);
|
||||
await sendInjectKeycode({
|
||||
action: AndroidKeyEventAction.AKEY_EVENT_ACTION_UP,
|
||||
keycode: AndroidKeycode.AKEYCODE_ENTER,
|
||||
repeat: 0,
|
||||
metastate: AndroidMetastate.AMETA_NONE,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -15,17 +15,11 @@ import {
|
||||
import { Keyboard24Regular } from "@vicons/fluent";
|
||||
import { NIcon, useMessage } from "naive-ui";
|
||||
import { useGlobalStore } from "../store/global";
|
||||
import {
|
||||
sendInjectKeycode,
|
||||
sendSetScreenPowerMode,
|
||||
} from "../frontcommand/controlMsg";
|
||||
import {
|
||||
AndroidKeyEventAction,
|
||||
AndroidKeycode,
|
||||
AndroidMetastate,
|
||||
} from "../frontcommand/android";
|
||||
import { sendSetScreenPowerMode } from "../frontcommand/controlMsg";
|
||||
import { AndroidKeycode } from "../frontcommand/android";
|
||||
import { ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { SendKeyAction, sendKey } from "../frontcommand/scrcpyMaskCmd";
|
||||
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
@ -39,28 +33,11 @@ function nav(name: string) {
|
||||
router.replace({ name });
|
||||
}
|
||||
|
||||
function sleep(time: number) {
|
||||
return new Promise<void>((resolve) => {
|
||||
setTimeout(() => {
|
||||
resolve();
|
||||
}, time);
|
||||
});
|
||||
}
|
||||
|
||||
async function sendKeyCodeToDevice(code: AndroidKeycode) {
|
||||
if (store.controledDevice) {
|
||||
await sendInjectKeycode({
|
||||
action: AndroidKeyEventAction.AKEY_EVENT_ACTION_DOWN,
|
||||
await sendKey({
|
||||
action: SendKeyAction.Default,
|
||||
keycode: code,
|
||||
repeat: 0,
|
||||
metastate: AndroidMetastate.AMETA_NONE,
|
||||
});
|
||||
await sleep(50);
|
||||
await sendInjectKeycode({
|
||||
action: AndroidKeyEventAction.AKEY_EVENT_ACTION_UP,
|
||||
keycode: code,
|
||||
repeat: 0,
|
||||
metastate: AndroidMetastate.AMETA_NONE,
|
||||
});
|
||||
} else {
|
||||
message.error(t("sidebar.noControledDevice"));
|
||||
|
@ -35,7 +35,7 @@ export enum ScrcpyMaskCmdType {
|
||||
|
||||
type ScrcpyMaskCmdData = CmdDataSendKey | CmdDataTouch | CmdDataSwipe | String;
|
||||
|
||||
enum SendKeyAction {
|
||||
export enum SendKeyAction {
|
||||
Default = 0,
|
||||
Down = 1,
|
||||
Up = 2,
|
||||
|
Loading…
Reference in New Issue
Block a user