mirror of
https://github.com/AkiChase/scrcpy-mask
synced 2024-11-13 04:21:26 +08:00
feat(Device): ctrl+v to past text into device
This commit is contained in:
parent
aa5b435833
commit
a632269ed3
@ -12,6 +12,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tauri-apps/api": ">=2.0.0-beta.8",
|
"@tauri-apps/api": ">=2.0.0-beta.8",
|
||||||
|
"@tauri-apps/plugin-clipboard-manager": "2.1.0-beta.1",
|
||||||
"@tauri-apps/plugin-http": "2.0.0-beta.3",
|
"@tauri-apps/plugin-http": "2.0.0-beta.3",
|
||||||
"@tauri-apps/plugin-process": "2.0.0-beta.2",
|
"@tauri-apps/plugin-process": "2.0.0-beta.2",
|
||||||
"@tauri-apps/plugin-shell": "2.0.0-beta.3",
|
"@tauri-apps/plugin-shell": "2.0.0-beta.3",
|
||||||
|
@ -21,3 +21,4 @@ tokio = { version = "1.36.0", features = ["rt-multi-thread", "net", "macros", "i
|
|||||||
tauri-plugin-process = "2.0.0-beta"
|
tauri-plugin-process = "2.0.0-beta"
|
||||||
tauri-plugin-shell = "2.0.0-beta"
|
tauri-plugin-shell = "2.0.0-beta"
|
||||||
tauri-plugin-http = "2.0.0-beta"
|
tauri-plugin-http = "2.0.0-beta"
|
||||||
|
tauri-plugin-clipboard-manager = "2.1.0-beta.2"
|
||||||
|
@ -34,11 +34,16 @@
|
|||||||
{
|
{
|
||||||
"identifier": "http:default",
|
"identifier": "http:default",
|
||||||
"allow": [
|
"allow": [
|
||||||
{ "url": "https://api.github.com/repos/AkiChase/scrcpy-mask/*" }
|
{
|
||||||
|
"url": "https://api.github.com/repos/AkiChase/scrcpy-mask/*"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"http:allow-fetch",
|
"http:allow-fetch",
|
||||||
"app:default",
|
"app:default",
|
||||||
"app:allow-version"
|
"app:allow-version",
|
||||||
|
"clipboard-manager:default",
|
||||||
|
"clipboard-manager:allow-read-text",
|
||||||
|
"clipboard-manager:allow-write-text"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -4,5 +4,5 @@ pub mod client;
|
|||||||
pub mod control_msg;
|
pub mod control_msg;
|
||||||
pub mod resource;
|
pub mod resource;
|
||||||
pub mod scrcpy_mask_cmd;
|
pub mod scrcpy_mask_cmd;
|
||||||
pub mod socket;
|
|
||||||
pub mod share;
|
pub mod share;
|
||||||
|
pub mod socket;
|
||||||
|
@ -181,6 +181,7 @@ fn set_adb_path(adb_path: String, app: tauri::AppHandle) -> Result<(), String> {
|
|||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
|
.plugin(tauri_plugin_clipboard_manager::init())
|
||||||
.plugin(tauri_plugin_http::init())
|
.plugin(tauri_plugin_http::init())
|
||||||
.plugin(tauri_plugin_shell::init())
|
.plugin(tauri_plugin_shell::init())
|
||||||
.plugin(tauri_plugin_process::init())
|
.plugin(tauri_plugin_process::init())
|
||||||
|
@ -45,6 +45,7 @@ import { useGlobalStore } from "../store/global";
|
|||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { closeExternalControl, connectExternalControl } from "../websocket";
|
import { closeExternalControl, connectExternalControl } from "../websocket";
|
||||||
import { LogicalSize, getCurrent } from "@tauri-apps/api/window";
|
import { LogicalSize, getCurrent } from "@tauri-apps/api/window";
|
||||||
|
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const dialog = useDialog();
|
const dialog = useDialog();
|
||||||
@ -73,15 +74,8 @@ onMounted(async () => {
|
|||||||
case "ClipboardChanged":
|
case "ClipboardChanged":
|
||||||
if (payload.clipboard === lastClipboard) break;
|
if (payload.clipboard === lastClipboard) break;
|
||||||
lastClipboard = payload.clipboard;
|
lastClipboard = payload.clipboard;
|
||||||
navigator.clipboard
|
writeText(payload.clipboard);
|
||||||
.writeText(payload.clipboard)
|
console.log(payload);
|
||||||
.then(() => {
|
|
||||||
message.info(t("pages.Device.clipboard.deviceSync.success"));
|
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
console.error(e);
|
|
||||||
message.error(t("pages.Device.clipboard.deviceSync.failed"));
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
case "ClipboardSetAck":
|
case "ClipboardSetAck":
|
||||||
break;
|
break;
|
||||||
|
@ -19,6 +19,7 @@ import { loadDefaultKeyconfig } from "../../invoke";
|
|||||||
import { KeyMappingConfig } from "../../keyMappingConfig";
|
import { KeyMappingConfig } from "../../keyMappingConfig";
|
||||||
import { useKeyboardStore } from "../../store/keyboard";
|
import { useKeyboardStore } from "../../store/keyboard";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
|
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const store = useGlobalStore();
|
const store = useGlobalStore();
|
||||||
@ -251,8 +252,7 @@ function renameKeyMappingConfig() {
|
|||||||
function exportKeyMappingConfig() {
|
function exportKeyMappingConfig() {
|
||||||
const config = store.keyMappingConfigList[store.curKeyMappingIndex];
|
const config = store.keyMappingConfigList[store.curKeyMappingIndex];
|
||||||
const data = JSON.stringify(config, null, 2);
|
const data = JSON.stringify(config, null, 2);
|
||||||
navigator.clipboard
|
writeText(data)
|
||||||
.writeText(data)
|
|
||||||
.then(() => {
|
.then(() => {
|
||||||
message.success(t("pages.KeyBoard.KeySetting.exportSuccess"));
|
message.success(t("pages.KeyBoard.KeySetting.exportSuccess"));
|
||||||
})
|
})
|
||||||
|
@ -163,13 +163,13 @@ interface InjectKeycode {
|
|||||||
metastate: AndroidMetastate;
|
metastate: AndroidMetastate;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ScCopyKey {
|
export enum ScCopyKey {
|
||||||
SC_COPY_KEY_NONE,
|
SC_COPY_KEY_NONE,
|
||||||
SC_COPY_KEY_COPY,
|
SC_COPY_KEY_COPY,
|
||||||
SC_COPY_KEY_CUT,
|
SC_COPY_KEY_CUT,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ScScreenPowerMode {
|
export enum ScScreenPowerMode {
|
||||||
// see <https://android.googlesource.com/platform/frameworks/base.git/+/pie-release-2/core/java/android/view/SurfaceControl.java#305>
|
// see <https://android.googlesource.com/platform/frameworks/base.git/+/pie-release-2/core/java/android/view/SurfaceControl.java#305>
|
||||||
SC_SCREEN_POWER_MODE_OFF = 0,
|
SC_SCREEN_POWER_MODE_OFF = 0,
|
||||||
SC_SCREEN_POWER_MODE_NORMAL = 2,
|
SC_SCREEN_POWER_MODE_NORMAL = 2,
|
||||||
|
@ -23,6 +23,7 @@ import {
|
|||||||
} from "./keyMappingConfig";
|
} from "./keyMappingConfig";
|
||||||
import { useGlobalStore } from "./store/global";
|
import { useGlobalStore } from "./store/global";
|
||||||
import { LogicalPosition, getCurrent } from "@tauri-apps/api/window";
|
import { LogicalPosition, getCurrent } from "@tauri-apps/api/window";
|
||||||
|
import { readText } from "@tauri-apps/plugin-clipboard-manager";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { KeyToCodeMap } from "./frontcommand/KeyToCodeMap";
|
import { KeyToCodeMap } from "./frontcommand/KeyToCodeMap";
|
||||||
import {
|
import {
|
||||||
@ -30,7 +31,7 @@ import {
|
|||||||
AndroidMetastate,
|
AndroidMetastate,
|
||||||
} from "./frontcommand/android";
|
} from "./frontcommand/android";
|
||||||
import { UIEventsCode } from "./frontcommand/UIEventsCode";
|
import { UIEventsCode } from "./frontcommand/UIEventsCode";
|
||||||
import { sendInjectKeycode } from "./frontcommand/controlMsg";
|
import { sendInjectKeycode, sendSetClipboard } from "./frontcommand/controlMsg";
|
||||||
|
|
||||||
function clientxToPosx(clientx: number) {
|
function clientxToPosx(clientx: number) {
|
||||||
return clientx < 70
|
return clientx < 70
|
||||||
@ -1046,6 +1047,8 @@ export class KeyInputHandler {
|
|||||||
let action: AndroidKeyEventAction;
|
let action: AndroidKeyEventAction;
|
||||||
let repeatCount = 0;
|
let repeatCount = 0;
|
||||||
if (event.type === "keydown") {
|
if (event.type === "keydown") {
|
||||||
|
if (event.getModifierState("Control") && event.code === "KeyV") return;
|
||||||
|
|
||||||
action = AndroidKeyEventAction.AKEY_EVENT_ACTION_DOWN;
|
action = AndroidKeyEventAction.AKEY_EVENT_ACTION_DOWN;
|
||||||
if (event.repeat) {
|
if (event.repeat) {
|
||||||
let count = KeyInputHandler.repeatCounter.get(keycode);
|
let count = KeyInputHandler.repeatCounter.get(keycode);
|
||||||
@ -1058,6 +1061,18 @@ export class KeyInputHandler {
|
|||||||
KeyInputHandler.repeatCounter.set(keycode, count);
|
KeyInputHandler.repeatCounter.set(keycode, count);
|
||||||
}
|
}
|
||||||
} else if (event.type === "keyup") {
|
} else if (event.type === "keyup") {
|
||||||
|
if (event.getModifierState("Control") && event.code === "KeyV") {
|
||||||
|
(async () => {
|
||||||
|
const text = await readText();
|
||||||
|
await sendSetClipboard({
|
||||||
|
sequence: Math.floor(Math.random() * 10000),
|
||||||
|
text,
|
||||||
|
paste: true,
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
action = AndroidKeyEventAction.AKEY_EVENT_ACTION_UP;
|
action = AndroidKeyEventAction.AKEY_EVENT_ACTION_UP;
|
||||||
KeyInputHandler.repeatCounter.delete(keycode);
|
KeyInputHandler.repeatCounter.delete(keycode);
|
||||||
} else {
|
} else {
|
||||||
@ -1078,12 +1093,6 @@ export class KeyInputHandler {
|
|||||||
? AndroidMetastate.AMETA_NUM_LOCK_ON
|
? AndroidMetastate.AMETA_NUM_LOCK_ON
|
||||||
: 0);
|
: 0);
|
||||||
|
|
||||||
// const controlMessage = new KeyCodeControlMessage(
|
|
||||||
// action,
|
|
||||||
// keyCode,
|
|
||||||
// repeatCount,
|
|
||||||
// metaState
|
|
||||||
// );
|
|
||||||
sendInjectKeycode({
|
sendInjectKeycode({
|
||||||
action,
|
action,
|
||||||
keycode,
|
keycode,
|
||||||
|
@ -36,13 +36,7 @@
|
|||||||
"wsConnect": "Control",
|
"wsConnect": "Control",
|
||||||
"adbDeviceError": "Unable to get available devices",
|
"adbDeviceError": "Unable to get available devices",
|
||||||
"adbConnectError": "Wireless connection failed",
|
"adbConnectError": "Wireless connection failed",
|
||||||
"rotation": "Device rotation {0}°",
|
"rotation": "Device rotation {0}°"
|
||||||
"clipboard": {
|
|
||||||
"deviceSync": {
|
|
||||||
"success": "Device clipboard synced",
|
|
||||||
"failed": "Device clipboard sync failed"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"Mask": {
|
"Mask": {
|
||||||
"keyconfigException": "The key mapping config is abnormal, please delete this config",
|
"keyconfigException": "The key mapping config is abnormal, please delete this config",
|
||||||
|
@ -36,13 +36,7 @@
|
|||||||
"wsConnect": "控制",
|
"wsConnect": "控制",
|
||||||
"adbDeviceError": "无法获取可用设备",
|
"adbDeviceError": "无法获取可用设备",
|
||||||
"adbConnectError": "无线连接失败",
|
"adbConnectError": "无线连接失败",
|
||||||
"rotation": "设备旋转 {0}°",
|
"rotation": "设备旋转 {0}°"
|
||||||
"clipboard": {
|
|
||||||
"deviceSync": {
|
|
||||||
"success": "已从设备同步剪切板",
|
|
||||||
"failed": "从设备同步剪切板失败"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"Mask": {
|
"Mask": {
|
||||||
"keyconfigException": "按键方案异常,请删除此方案",
|
"keyconfigException": "按键方案异常,请删除此方案",
|
||||||
|
Loading…
Reference in New Issue
Block a user