diff --git a/README-zh.md b/README-zh.md index 9e61d8b..28d4321 100644 --- a/README-zh.md +++ b/README-zh.md @@ -66,9 +66,8 @@ 2. 对于模拟器,不仅不需要投屏,而且模拟器通常默认启用 ADB 有线调试。所以几乎不用操作就能获得最好的体验。 3. 启动软件并导航到设备页面。 1. 在可用的设备中查找你的设备(如果未找到,请自行搜索如何为安装设备启用 ADB 调试)。 - 2. 右击你的设备并选择“获取屏幕大小”。根据获得的屏幕尺寸为参考,正确输入设备的宽度和高度。注意:如果宽度或高度不正确 (例如,在纵向和横向模式下这两个参数是颠倒的),所有触摸操作将被忽略,但是不会有任何错误消息。 - 3. 再次右击设备并选择“控制此设备”。 -4. 导航到设置页面->蒙版设置,将蒙版的宽度和高度设置为设备大小的一定倍数,以确保蒙版大小合适。 + 2. 右击设备并选择“控制此设备”。 +4. 导航到设置页面->蒙版设置,将蒙版的宽度和高度设置为设备屏幕尺寸相同的比例,确保蒙版大小合适。 5. 导航到蒙版页面,你可以在其中看到一个完全透明的蒙版区域。接下来,调整并移动模拟器窗口或投屏窗口,让其内容区域与透明蒙版区域完全对齐。 6. 导航到键映射页面,切换或编辑键映射配置。 7. 返回到蒙版界面,开始使用吧! diff --git a/README.md b/README.md index c08da68..0124208 100644 --- a/README.md +++ b/README.md @@ -68,9 +68,8 @@ Furthermore, to better support interaction between Scrcpy Mask and Android devic 2. For emulator, you don't need screen mirror, and emulator generally default to enabling ADB wired debugging. So this is the best way for game, I think. 3. Launch the software and navigate to the Device page. 1. Find your device among the available devices (if not found, please search for how to enable ADB debugging for your device). - 2. Right-click on your device and choose "Get Screen Size". Use the obtained screen size as a reference and enter the device's width and height correctly. Note: If the width or height is incorrect (for example, they are reversed in portrait and landscape modes), all touch operations will be ignored, but no error message will appear. 3. Right-click on your device again and choose "Control this device". -4. Navigate to the Settings page -> Mask Settings, and set the width and height of the mask to a certain multiple of the device's size to ensure the mask size is appropriate. +4. Navigate to the Settings page -> Mask Settings, set the width and height of the mask to the same ratio of the device screen size and ensure that the mask size is appropriate. 5. Navigate to the Mask page where you can see a transparent mask. Next, adjust and move your emulator window or screen mirroring window to align the displayed content area with the transparent mask area. 6. Navigate to the Key mapping page and switch or edit the key mapping configs. 7. Return to the Mask page and start enjoying. diff --git a/package.json b/package.json index a02ee49..426100e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "scrcpy-mask", "private": true, - "version": "0.4.0", + "version": "0.4.1", "type": "module", "scripts": { "dev": "vite", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 6bcb527..0b19dc5 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "scrcpy-mask" -version = "0.4.0" +version = "0.4.1" description = "A Tauri App" authors = ["AkiChase"] edition = "2021" diff --git a/src-tauri/src/adb.rs b/src-tauri/src/adb.rs index c800913..3c418d4 100644 --- a/src-tauri/src/adb.rs +++ b/src-tauri/src/adb.rs @@ -8,6 +8,8 @@ use std::os::windows::process::CommandExt; use anyhow::{Context, Ok, Result}; +use crate::share; + #[derive(Clone, Debug, serde::Serialize)] pub struct Device { pub id: String, @@ -85,13 +87,14 @@ pub struct Adb; /// But some output of command won't be output, like adb service startup information. impl Adb { pub fn cmd_base() -> Command { + let adb_path = share::ADB_PATH.lock().unwrap().clone(); #[cfg(target_os = "windows")] { - let mut cmd = Command::new("adb"); + let mut cmd = Command::new(adb_path); cmd.creation_flags(0x08000000); // CREATE_NO_WINDOW return cmd; } - Command::new("adb") + Command::new(adb_path) } /// execute "adb devices" and return devices list diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index fe05d0d..01290b6 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -157,6 +157,24 @@ fn check_adb_available() -> Result<(), String> { } } +#[tauri::command] +fn set_adb_path(adb_path: String, app: tauri::AppHandle) -> Result<(), String> { + let app_h = app.app_handle().clone(); + let stores = app_h.state::>(); + let path = std::path::PathBuf::from("store.bin"); + let store_res: Result<(), tauri_plugin_store::Error> = + tauri_plugin_store::with_store(app, stores, path, |store| { + store.insert("adbPath".to_string(), serde_json::json!(adb_path))?; + *share::ADB_PATH.lock().unwrap() = adb_path; + Ok(()) + }); + + match store_res { + Ok(_) => Ok(()), + Err(e) => Err(e.to_string()), + } +} + #[tokio::main] async fn main() { tauri::Builder::default() @@ -168,8 +186,16 @@ async fn main() { let stores = app .app_handle() .state::>(); - let path = std::path::PathBuf::from("store.bin"); + let path: std::path::PathBuf = std::path::PathBuf::from("store.bin"); tauri_plugin_store::with_store(app.app_handle().clone(), stores, path, |store| { + // load adb path + match store.get("adbPath") { + Some(value) => *share::ADB_PATH.lock().unwrap() = value.to_string(), + None => store + .insert("adbPath".to_string(), serde_json::json!("adb")) + .unwrap(), + }; + // restore window position and size match store.get("maskArea") { Some(value) => { @@ -239,7 +265,8 @@ async fn main() { get_device_screen_size, adb_connect, load_default_keyconfig, - check_adb_available + check_adb_available, + set_adb_path ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); diff --git a/src-tauri/src/share.rs b/src-tauri/src/share.rs index 74173fa..3402b9a 100644 --- a/src-tauri/src/share.rs +++ b/src-tauri/src/share.rs @@ -21,3 +21,7 @@ impl ClientInfo { lazy_static! { pub static ref CLIENT_INFO: Mutex> = Mutex::new(None); } + +lazy_static! { + pub static ref ADB_PATH: Mutex = Mutex::new(String::from("adb")); +} diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index dcaf49f..4b5a801 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,6 +1,6 @@ { "productName": "scrcpy-mask", - "version": "0.4.0", + "version": "0.4.1", "identifier": "com.akichase.mask", "build": { "beforeDevCommand": "pnpm dev", diff --git a/src/components/Device.vue b/src/components/Device.vue index fc5915b..617fdec 100644 --- a/src/components/Device.vue +++ b/src/components/Device.vue @@ -320,8 +320,13 @@ async function connectDevice() { } store.showLoading(); - message.info(await adbConnect(wireless_address.value)); - await refreshDevices(); + try { + message.info(await adbConnect(wireless_address.value)); + await refreshDevices(); + } catch (e) { + message.error("t('pages.Device.adbConnectError')"); + console.error(e); + } } function connectWS() { diff --git a/src/components/Mask.vue b/src/components/Mask.vue index ca9be6f..2aaa9c5 100644 --- a/src/components/Mask.vue +++ b/src/components/Mask.vue @@ -1,6 +1,12 @@