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",
"private": true,
"version": "0.1.9",
"version": "0.1.10",
"type": "module",
"scripts": {
"dev": "vite",

View File

@ -1,6 +1,6 @@
[package]
name = "scrcpy-mask"
version = "0.1.9"
version = "0.1.10"
description = "A Tauri App"
authors = ["AkiChase"]
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 {
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"),

View File

@ -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"
]
}
}

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": [
"resource/default-key-config.json",
"resource/scrcpy-server-v2.4",
"resource/adb.exe",
"resource/adb-win.exe",
"resource/AdbWinApi.dll",
"resource/AdbWinUsbApi.dll"
]

View File

@ -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<string, () => Promise<void>> = 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