flutter.rs Session -> ui_session_interface.rs

This commit is contained in:
csf
2022-08-31 22:24:57 +08:00
parent e5c4554221
commit ae265ca836
4 changed files with 213 additions and 758 deletions

View File

@@ -11,6 +11,7 @@ use cpal::{
traits::{DeviceTrait, HostTrait, StreamTrait},
Device, Host, StreamConfig,
};
use enigo::{Enigo, KeyboardControllable};
use magnum_opus::{Channels::*, Decoder as AudioDecoder};
use sha2::{Digest, Sha256};
use uuid::Uuid;
@@ -58,6 +59,18 @@ lazy_static::lazy_static! {
static ref AUDIO_HOST: Host = cpal::default_host();
}
lazy_static::lazy_static! {
static ref ENIGO: Arc<Mutex<Enigo>> = Arc::new(Mutex::new(Enigo::new()));
}
pub fn get_key_state(key: enigo::Key) -> bool {
#[cfg(target_os = "macos")]
if key == enigo::Key::NumLock {
return true;
}
ENIGO.lock().unwrap().get_key_state(key)
}
cfg_if::cfg_if! {
if #[cfg(target_os = "android")] {