Merge pull request #21 from AkiChase/dev

Scrcpy Mask v0.1.10
This commit is contained in:
如初 2024-05-14 10:01:58 +08:00 committed by GitHub
commit 05609843f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 63 additions and 31 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "scrcpy-mask", "name": "scrcpy-mask",
"private": true, "private": true,
"version": "0.1.9", "version": "0.1.10",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "scrcpy-mask" name = "scrcpy-mask"
version = "0.1.9" version = "0.1.10"
description = "A Tauri App" description = "A Tauri App"
authors = ["AkiChase"] authors = ["AkiChase"]
edition = "2021" edition = "2021"

Binary file not shown.

View File

@ -28,9 +28,11 @@ impl ResHelper {
pub fn get_file_path(dir: &PathBuf, file_name: ResourceName) -> PathBuf { pub fn get_file_path(dir: &PathBuf, file_name: ResourceName) -> PathBuf {
match file_name { match file_name {
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
ResourceName::Adb => dir.join("adb.exe"), ResourceName::Adb => dir.join("adb-win.exe"),
#[cfg(not(target_os = "windows"))] #[cfg(target_os = "linux")]
ResourceName::Adb => dir.join("adb"), 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::ScrcpyServer => dir.join("scrcpy-server-v2.4"),
ResourceName::DefaultKeyConfig => dir.join("default-key-config.json"), ResourceName::DefaultKeyConfig => dir.join("default-key-config.json"),

View File

@ -1,6 +1,6 @@
{ {
"productName": "scrcpy-mask", "productName": "scrcpy-mask",
"version": "0.1.9", "version": "0.1.10",
"identifier": "com.akichase.mask", "identifier": "com.akichase.mask",
"build": { "build": {
"beforeDevCommand": "pnpm dev", "beforeDevCommand": "pnpm dev",
@ -30,11 +30,6 @@
"icons/128x128@2x.png", "icons/128x128@2x.png",
"icons/icon.icns", "icons/icon.icns",
"icons/icon.ico" "icons/icon.ico"
],
"resources": [
"resource/default-key-config.json",
"resource/scrcpy-server-v2.4",
"resource/adb"
] ]
} }
} }

View File

@ -0,0 +1,9 @@
{
"bundle": {
"resources": [
"resource/default-key-config.json",
"resource/scrcpy-server-v2.4",
"resource/adb-linux"
]
}
}

View File

@ -0,0 +1,9 @@
{
"bundle": {
"resources": [
"resource/default-key-config.json",
"resource/scrcpy-server-v2.4",
"resource/adb-mac"
]
}
}

View File

@ -3,7 +3,7 @@
"resources": [ "resources": [
"resource/default-key-config.json", "resource/default-key-config.json",
"resource/scrcpy-server-v2.4", "resource/scrcpy-server-v2.4",
"resource/adb.exe", "resource/adb-win.exe",
"resource/AdbWinApi.dll", "resource/AdbWinApi.dll",
"resource/AdbWinUsbApi.dll" "resource/AdbWinUsbApi.dll"
] ]

View File

@ -308,19 +308,15 @@ function addTriggerWhenPressedSkillShortcuts(
rangeOrTime: number, rangeOrTime: number,
pointerId: number pointerId: number
) { ) {
if (directional) {
posX = Math.round((posX / relativeSize.w) * screenSizeW); posX = Math.round((posX / relativeSize.w) * screenSizeW);
posY = Math.round((posY / relativeSize.h) * screenSizeH); posY = Math.round((posY / relativeSize.h) * screenSizeH);
if (directional) {
addShortcut( addShortcut(
key, key,
// down // down
async () => { async () => {
// up doublepress skill // up doublepress skill
for (const [key, val] of doublePressedDownKey) { await upDoublePressedKey();
if (val) {
downKeyCBMap.get(key)?.();
}
}
const skillOffset = clientPosToSkillOffset( const skillOffset = clientPosToSkillOffset(
{ x: mouseX, y: mouseY }, { x: mouseX, y: mouseY },
rangeOrTime rangeOrTime
@ -346,7 +342,27 @@ function addTriggerWhenPressedSkillShortcuts(
undefined undefined
); );
} else { } 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 // down
async () => { async () => {
// up doublepress skill // up doublepress skill
for (const [key, val] of doublePressedDownKey) { await upDoublePressedKey();
if (val) {
downKeyCBMap.get(key)?.();
}
}
await touch({ await touch({
action: TouchAction.Down, action: TouchAction.Down,
pointerId, 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) // add shortcuts for directional skill (cancelable)
function addDirectionalSkillShortcuts( function addDirectionalSkillShortcuts(
key: string, key: string,
@ -512,11 +533,7 @@ function addDirectionalSkillShortcuts(
// down // down
async () => { async () => {
// up doublepress skill // up doublepress skill
for (const [key, val] of doublePressedDownKey) { await upDoublePressedKey();
if (val) {
downKeyCBMap.get(key)?.();
}
}
const skillOffset = clientPosToSkillOffset( const skillOffset = clientPosToSkillOffset(
{ x: mouseX, y: mouseY }, { x: mouseX, y: mouseY },
range range
@ -787,8 +804,8 @@ const upKeyCBMap: Map<string, () => Promise<void>> = new Map();
const cancelAbleKeyList: string[] = []; const cancelAbleKeyList: string[] = [];
function keydownHandler(event: KeyboardEvent) { function keydownHandler(event: KeyboardEvent) {
if (event.repeat) return;
event.preventDefault(); event.preventDefault();
if (event.repeat) return;
if (downKeyMap.has(event.code)) { if (downKeyMap.has(event.code)) {
downKeyMap.set(event.code, true); downKeyMap.set(event.code, true);
// execute the down callback (if there is) asyncily // execute the down callback (if there is) asyncily