mirror of
https://github.com/AkiChase/scrcpy-mask
synced 2025-05-13 03:08:03 +08:00
feat(scrcpy-mask-server): use custom scrcpy-server
This commit is contained in:
parent
a55db6acf8
commit
afa2ef9d45
BIN
src-tauri/resource/scrcpy-mask-server-v2.4
Executable file
BIN
src-tauri/resource/scrcpy-mask-server-v2.4
Executable file
Binary file not shown.
Binary file not shown.
@ -28,7 +28,7 @@ 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 {
|
||||||
ResourceName::ScrcpyServer => dir.join("scrcpy-server-v2.4"),
|
ResourceName::ScrcpyServer => dir.join("scrcpy-mask-server-v2.4"),
|
||||||
ResourceName::DefaultKeyConfig => dir.join("default-key-config.json"),
|
ResourceName::DefaultKeyConfig => dir.join("default-key-config.json"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,12 @@ async fn read_socket(
|
|||||||
}
|
}
|
||||||
let device_name = std::str::from_utf8(&buf[..end]).unwrap();
|
let device_name = std::str::from_utf8(&buf[..end]).unwrap();
|
||||||
// update device name for share
|
// update device name for share
|
||||||
share::CLIENT_INFO.lock().unwrap().as_mut().unwrap().device_name = device_name.to_string();
|
share::CLIENT_INFO
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.device_name = device_name.to_string();
|
||||||
|
|
||||||
let msg = json!({
|
let msg = json!({
|
||||||
"type": "MetaData",
|
"type": "MetaData",
|
||||||
@ -149,6 +154,20 @@ async fn handle_device_message(
|
|||||||
let mut buf: Vec<u8> = vec![0; size as usize];
|
let mut buf: Vec<u8> = vec![0; size as usize];
|
||||||
reader.read_exact(&mut buf).await?;
|
reader.read_exact(&mut buf).await?;
|
||||||
}
|
}
|
||||||
|
// 设备旋转
|
||||||
|
DeviceMsgType::DeviceMsgTypeRotation => {
|
||||||
|
let rotation = reader.read_u16().await?;
|
||||||
|
let width = reader.read_i32().await?;
|
||||||
|
let height = reader.read_i32().await?;
|
||||||
|
let msg = json!({
|
||||||
|
"type": "DeviceRotation",
|
||||||
|
"rotation": rotation,
|
||||||
|
"width": width,
|
||||||
|
"height": height
|
||||||
|
})
|
||||||
|
.to_string();
|
||||||
|
device_reply_sender.send(msg).await?;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
anyhow::Ok(())
|
anyhow::Ok(())
|
||||||
}
|
}
|
||||||
@ -181,6 +200,8 @@ async fn recv_front_msg(
|
|||||||
// 处理Scrcpy Mask命令
|
// 处理Scrcpy Mask命令
|
||||||
if let Some(cmd_type) = ScrcpyMaskCmdType::from_i64(front_msg_type) {
|
if let Some(cmd_type) = ScrcpyMaskCmdType::from_i64(front_msg_type) {
|
||||||
if let ScrcpyMaskCmdType::Shutdown = cmd_type {
|
if let ScrcpyMaskCmdType::Shutdown = cmd_type {
|
||||||
|
*share::CLIENT_INFO.lock().unwrap() = None;
|
||||||
|
|
||||||
drop(write_half);
|
drop(write_half);
|
||||||
println!("Drop TcpStream writer");
|
println!("Drop TcpStream writer");
|
||||||
app.unlisten(listen_handler);
|
app.unlisten(listen_handler);
|
||||||
@ -197,7 +218,7 @@ async fn recv_front_msg(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
eprintln!("fc-command非法");
|
eprintln!("fc-command invalid!");
|
||||||
eprintln!("{:?}", payload);
|
eprintln!("{:?}", payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -212,6 +233,7 @@ enum DeviceMsgType {
|
|||||||
DeviceMsgTypeClipboard,
|
DeviceMsgTypeClipboard,
|
||||||
DeviceMsgTypeAckClipboard,
|
DeviceMsgTypeAckClipboard,
|
||||||
DeviceMsgTypeUhidOutput,
|
DeviceMsgTypeUhidOutput,
|
||||||
|
DeviceMsgTypeRotation,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DeviceMsgType {
|
impl DeviceMsgType {
|
||||||
@ -220,6 +242,7 @@ impl DeviceMsgType {
|
|||||||
0 => Some(Self::DeviceMsgTypeClipboard),
|
0 => Some(Self::DeviceMsgTypeClipboard),
|
||||||
1 => Some(Self::DeviceMsgTypeAckClipboard),
|
1 => Some(Self::DeviceMsgTypeAckClipboard),
|
||||||
2 => Some(Self::DeviceMsgTypeUhidOutput),
|
2 => Some(Self::DeviceMsgTypeUhidOutput),
|
||||||
|
3 => Some(Self::DeviceMsgTypeRotation),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
],
|
],
|
||||||
"resources": [
|
"resources": [
|
||||||
"resource/default-key-config.json",
|
"resource/default-key-config.json",
|
||||||
"resource/scrcpy-server-v2.4"
|
"resource/scrcpy-mask-server-v2.4"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user