2022-05-12 17:35:25 +08:00
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
pub use linux::*;
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
pub use macos::*;
|
|
|
|
#[cfg(windows)]
|
|
|
|
pub use windows::*;
|
|
|
|
|
|
|
|
#[cfg(windows)]
|
|
|
|
pub mod windows;
|
|
|
|
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
pub mod macos;
|
|
|
|
|
2023-03-02 13:32:21 +08:00
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
pub mod delegate;
|
|
|
|
|
2022-05-12 17:35:25 +08:00
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
pub mod linux;
|
|
|
|
|
2023-04-01 00:28:56 +08:00
|
|
|
#[cfg(all(target_os = "linux", feature = "linux_headless"))]
|
2023-04-09 11:35:14 +08:00
|
|
|
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
|
2023-03-28 22:20:15 +08:00
|
|
|
pub mod linux_desktop_manager;
|
2023-03-22 17:01:11 +08:00
|
|
|
|
2022-11-13 18:11:13 +08:00
|
|
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
2022-05-12 17:35:25 +08:00
|
|
|
use hbb_common::{message_proto::CursorData, ResultType};
|
2023-03-27 19:13:29 +08:00
|
|
|
#[cfg(not(any(target_os = "macos", target_os = "android", target_os = "ios")))]
|
2022-05-12 17:35:25 +08:00
|
|
|
const SERVICE_INTERVAL: u64 = 300;
|
|
|
|
|
|
|
|
pub fn is_xfce() -> bool {
|
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
{
|
|
|
|
return std::env::var_os("XDG_CURRENT_DESKTOP") == Some(std::ffi::OsString::from("XFCE"));
|
|
|
|
}
|
|
|
|
#[cfg(not(target_os = "linux"))]
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-19 19:02:59 -07:00
|
|
|
pub fn breakdown_callback() {
|
|
|
|
#[cfg(target_os = "linux")]
|
2023-03-28 21:49:22 -07:00
|
|
|
crate::input_service::clear_remapped_keycode();
|
2023-03-29 00:41:27 -07:00
|
|
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
2023-03-29 00:40:05 -07:00
|
|
|
crate::input_service::release_device_modifiers();
|
2023-03-19 19:02:59 -07:00
|
|
|
}
|
|
|
|
|
2022-05-12 17:35:25 +08:00
|
|
|
// Android
|
|
|
|
#[cfg(target_os = "android")]
|
|
|
|
pub fn get_active_username() -> String {
|
|
|
|
// TODO
|
|
|
|
"android".into()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(target_os = "android")]
|
|
|
|
pub const PA_SAMPLE_RATE: u32 = 48000;
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
#[test]
|
|
|
|
fn test_cursor_data() {
|
|
|
|
for _ in 0..30 {
|
|
|
|
if let Some(hc) = get_cursor().unwrap() {
|
|
|
|
let cd = get_cursor_data(hc).unwrap();
|
|
|
|
repng::encode(
|
|
|
|
std::fs::File::create("cursor.png").unwrap(),
|
|
|
|
cd.width as _,
|
|
|
|
cd.height as _,
|
|
|
|
&cd.colors[..],
|
|
|
|
)
|
|
|
|
.unwrap();
|
|
|
|
}
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
macos::is_process_trusted(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#[test]
|
|
|
|
fn test_get_cursor_pos() {
|
|
|
|
for _ in 0..30 {
|
|
|
|
assert!(!get_cursor_pos().is_none());
|
|
|
|
}
|
|
|
|
}
|
2022-11-15 23:09:29 -08:00
|
|
|
|
2023-02-09 15:53:51 +08:00
|
|
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
|
|
|
#[test]
|
|
|
|
fn test_resolution() {
|
|
|
|
let name = r"\\.\DISPLAY1";
|
|
|
|
println!("current:{:?}", current_resolution(name));
|
|
|
|
println!("change:{:?}", change_resolution(name, 2880, 1800));
|
|
|
|
println!("resolutions:{:?}", resolutions(name));
|
|
|
|
}
|
|
|
|
}
|