diff --git a/package.json b/package.json index b7ea005..9bba9fa 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "scrcpy-mask", "private": true, - "version": "0.1.9", + "version": "0.1.10", "type": "module", "scripts": { "dev": "vite", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 61ac541..4b63133 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "scrcpy-mask" -version = "0.1.9" +version = "0.1.10" description = "A Tauri App" authors = ["AkiChase"] edition = "2021" diff --git a/src-tauri/resource/adb-linux b/src-tauri/resource/adb-linux new file mode 100644 index 0000000..48a0d4a Binary files /dev/null and b/src-tauri/resource/adb-linux differ diff --git a/src-tauri/resource/adb b/src-tauri/resource/adb-mac similarity index 100% rename from src-tauri/resource/adb rename to src-tauri/resource/adb-mac diff --git a/src-tauri/resource/adb.exe b/src-tauri/resource/adb-win.exe similarity index 100% rename from src-tauri/resource/adb.exe rename to src-tauri/resource/adb-win.exe diff --git a/src-tauri/src/resource.rs b/src-tauri/src/resource.rs index 41b7900..9efdf26 100644 --- a/src-tauri/src/resource.rs +++ b/src-tauri/src/resource.rs @@ -28,9 +28,11 @@ impl ResHelper { pub fn get_file_path(dir: &PathBuf, file_name: ResourceName) -> PathBuf { match file_name { #[cfg(target_os = "windows")] - ResourceName::Adb => dir.join("adb.exe"), - #[cfg(not(target_os = "windows"))] - ResourceName::Adb => dir.join("adb"), + ResourceName::Adb => dir.join("adb-win.exe"), + #[cfg(target_os = "linux")] + ResourceName::Adb => dir.join("adb-linux"), + #[cfg(target_os = "macos")] + ResourceName::Adb => dir.join("adb-mac"), ResourceName::ScrcpyServer => dir.join("scrcpy-server-v2.4"), ResourceName::DefaultKeyConfig => dir.join("default-key-config.json"), diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 1fd0562..1961dd0 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,6 +1,6 @@ { "productName": "scrcpy-mask", - "version": "0.1.9", + "version": "0.1.10", "identifier": "com.akichase.mask", "build": { "beforeDevCommand": "pnpm dev", @@ -30,11 +30,6 @@ "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico" - ], - "resources": [ - "resource/default-key-config.json", - "resource/scrcpy-server-v2.4", - "resource/adb" ] } } diff --git a/src-tauri/tauri.linux.conf.json.json b/src-tauri/tauri.linux.conf.json.json new file mode 100644 index 0000000..36ee96e --- /dev/null +++ b/src-tauri/tauri.linux.conf.json.json @@ -0,0 +1,9 @@ +{ + "bundle": { + "resources": [ + "resource/default-key-config.json", + "resource/scrcpy-server-v2.4", + "resource/adb-linux" + ] + } +} diff --git a/src-tauri/tauri.macos.conf.json b/src-tauri/tauri.macos.conf.json new file mode 100644 index 0000000..113f2d0 --- /dev/null +++ b/src-tauri/tauri.macos.conf.json @@ -0,0 +1,9 @@ +{ + "bundle": { + "resources": [ + "resource/default-key-config.json", + "resource/scrcpy-server-v2.4", + "resource/adb-mac" + ] + } +} diff --git a/src-tauri/tauri.windows.conf.json b/src-tauri/tauri.windows.conf.json index 7b18573..7222ecb 100644 --- a/src-tauri/tauri.windows.conf.json +++ b/src-tauri/tauri.windows.conf.json @@ -3,7 +3,7 @@ "resources": [ "resource/default-key-config.json", "resource/scrcpy-server-v2.4", - "resource/adb.exe", + "resource/adb-win.exe", "resource/AdbWinApi.dll", "resource/AdbWinUsbApi.dll" ] diff --git a/src/hotkey.ts b/src/hotkey.ts index d6189e9..135074a 100644 --- a/src/hotkey.ts +++ b/src/hotkey.ts @@ -308,19 +308,15 @@ function addTriggerWhenPressedSkillShortcuts( rangeOrTime: number, pointerId: number ) { + posX = Math.round((posX / relativeSize.w) * screenSizeW); + posY = Math.round((posY / relativeSize.h) * screenSizeH); if (directional) { - posX = Math.round((posX / relativeSize.w) * screenSizeW); - posY = Math.round((posY / relativeSize.h) * screenSizeH); addShortcut( key, // down async () => { // up doublepress skill - for (const [key, val] of doublePressedDownKey) { - if (val) { - downKeyCBMap.get(key)?.(); - } - } + await upDoublePressedKey(); const skillOffset = clientPosToSkillOffset( { x: mouseX, y: mouseY }, rangeOrTime @@ -346,7 +342,27 @@ function addTriggerWhenPressedSkillShortcuts( undefined ); } else { - addTapShortcuts(key, relativeSize, rangeOrTime, posX, posY, pointerId); + addShortcut( + key, + async () => { + await upDoublePressedKey(); + await touch({ + action: TouchAction.Default, + pointerId, + screen: { + w: screenSizeW, + h: screenSizeH, + }, + pos: { + x: posX, + y: posY, + }, + time: rangeOrTime, + }); + }, + undefined, + undefined + ); } } @@ -456,11 +472,7 @@ function addDirectionlessSkillShortcuts( // down async () => { // up doublepress skill - for (const [key, val] of doublePressedDownKey) { - if (val) { - downKeyCBMap.get(key)?.(); - } - } + await upDoublePressedKey(); await touch({ action: TouchAction.Down, pointerId, @@ -495,6 +507,15 @@ function addDirectionlessSkillShortcuts( ); } +// up all double pressed key +async function upDoublePressedKey() { + for (const [key, val] of doublePressedDownKey) { + if (val) { + await downKeyCBMap.get(key)?.(); + } + } +} + // add shortcuts for directional skill (cancelable) function addDirectionalSkillShortcuts( key: string, @@ -512,11 +533,7 @@ function addDirectionalSkillShortcuts( // down async () => { // up doublepress skill - for (const [key, val] of doublePressedDownKey) { - if (val) { - downKeyCBMap.get(key)?.(); - } - } + await upDoublePressedKey(); const skillOffset = clientPosToSkillOffset( { x: mouseX, y: mouseY }, range @@ -787,8 +804,8 @@ const upKeyCBMap: Map Promise> = new Map(); const cancelAbleKeyList: string[] = []; function keydownHandler(event: KeyboardEvent) { - if (event.repeat) return; event.preventDefault(); + if (event.repeat) return; if (downKeyMap.has(event.code)) { downKeyMap.set(event.code, true); // execute the down callback (if there is) asyncily