mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
Merge branch 'rustdesk:master' into master
This commit is contained in:
@@ -40,7 +40,7 @@ struct Input {
|
||||
time: i64,
|
||||
}
|
||||
|
||||
const KEY_CHAR_START: i32 = 9999;
|
||||
const KEY_CHAR_START: u64 = 9999;
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
pub struct MouseCursorSub {
|
||||
@@ -163,7 +163,7 @@ fn run_cursor(sp: MouseCursorService, state: &mut StateCursor) -> ResultType<()>
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref ENIGO: Arc<Mutex<Enigo>> = Arc::new(Mutex::new(Enigo::new()));
|
||||
static ref KEYS_DOWN: Arc<Mutex<HashMap<i32, Instant>>> = Default::default();
|
||||
static ref KEYS_DOWN: Arc<Mutex<HashMap<u64, Instant>>> = Default::default();
|
||||
static ref LATEST_INPUT: Arc<Mutex<Input>> = Default::default();
|
||||
}
|
||||
static EXITING: AtomicBool = AtomicBool::new(false);
|
||||
@@ -246,6 +246,11 @@ pub fn fix_key_down_timeout_at_exit() {
|
||||
log::info!("fix_key_down_timeout_at_exit");
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn get_layout(key: u32) -> Key {
|
||||
Key::Layout(std::char::from_u32(key).unwrap_or('\0'))
|
||||
}
|
||||
|
||||
fn fix_key_down_timeout(force: bool) {
|
||||
if KEYS_DOWN.lock().unwrap().is_empty() {
|
||||
return;
|
||||
@@ -256,13 +261,13 @@ fn fix_key_down_timeout(force: bool) {
|
||||
if force || value.elapsed().as_millis() >= 3_000 {
|
||||
KEYS_DOWN.lock().unwrap().remove(&key);
|
||||
let key = if key < KEY_CHAR_START {
|
||||
if let Some(key) = KEY_MAP.get(&key) {
|
||||
if let Some(key) = KEY_MAP.get(&(key as _)) {
|
||||
Some(*key)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
Some(Key::Layout(((key - KEY_CHAR_START) as u8) as _))
|
||||
Some(get_layout((key - KEY_CHAR_START) as _))
|
||||
};
|
||||
if let Some(key) = key {
|
||||
let func = move || {
|
||||
@@ -352,7 +357,7 @@ fn handle_mouse_(evt: &MouseEvent, conn: i32) {
|
||||
modifier_sleep();
|
||||
to_release.push(key);
|
||||
} else {
|
||||
KEYS_DOWN.lock().unwrap().insert(ck.value(), Instant::now());
|
||||
KEYS_DOWN.lock().unwrap().insert(ck.value() as _, Instant::now());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -572,7 +577,7 @@ fn handle_key_(evt: &KeyEvent) {
|
||||
modifier_sleep();
|
||||
to_release.push(key);
|
||||
} else {
|
||||
KEYS_DOWN.lock().unwrap().insert(ck.value(), Instant::now());
|
||||
KEYS_DOWN.lock().unwrap().insert(ck.value() as _, Instant::now());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -604,10 +609,13 @@ fn handle_key_(evt: &KeyEvent) {
|
||||
}
|
||||
if evt.down {
|
||||
allow_err!(en.key_down(key.clone()));
|
||||
KEYS_DOWN.lock().unwrap().insert(ck.value(), Instant::now());
|
||||
KEYS_DOWN
|
||||
.lock()
|
||||
.unwrap()
|
||||
.insert(ck.value() as _, Instant::now());
|
||||
} else {
|
||||
en.key_up(key.clone());
|
||||
KEYS_DOWN.lock().unwrap().remove(&ck.value());
|
||||
KEYS_DOWN.lock().unwrap().remove(&(ck.value() as _));
|
||||
}
|
||||
} else if ck.value() == ControlKey::CtrlAltDel.value() {
|
||||
// have to spawn new thread because send_sas is tokio_main, the caller can not be tokio_main.
|
||||
@@ -621,17 +629,17 @@ fn handle_key_(evt: &KeyEvent) {
|
||||
}
|
||||
Some(key_event::Union::chr(chr)) => {
|
||||
if evt.down {
|
||||
allow_err!(en.key_down(Key::Layout(chr as u8 as _)));
|
||||
allow_err!(en.key_down(get_layout(chr)));
|
||||
KEYS_DOWN
|
||||
.lock()
|
||||
.unwrap()
|
||||
.insert(chr as i32 + KEY_CHAR_START, Instant::now());
|
||||
.insert(chr as u64 + KEY_CHAR_START, Instant::now());
|
||||
} else {
|
||||
en.key_up(Key::Layout(chr as u8 as _));
|
||||
en.key_up(get_layout(chr));
|
||||
KEYS_DOWN
|
||||
.lock()
|
||||
.unwrap()
|
||||
.remove(&(chr as i32 + KEY_CHAR_START));
|
||||
.remove(&(chr as u64 + KEY_CHAR_START));
|
||||
}
|
||||
}
|
||||
Some(key_event::Union::unicode(chr)) => {
|
||||
|
||||
@@ -328,7 +328,7 @@ fn handle_one_frame(
|
||||
sp: &GenericService,
|
||||
frame: &[u8],
|
||||
ms: i64,
|
||||
crc: &mut (u32, u32),
|
||||
_crc: &mut (u32, u32),
|
||||
vpx: &mut Encoder,
|
||||
) -> ResultType<HashSet<i32>> {
|
||||
sp.snapshot(|sps| {
|
||||
@@ -338,6 +338,12 @@ fn handle_one_frame(
|
||||
}
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
/*
|
||||
// crc runs faster on my i7-4790, around 0.5ms for 720p picture,
|
||||
// but it is super slow on my Linux (in virtualbox) on the same machine, 720ms consumed.
|
||||
// crc do save band width for static scenario (especially for gdi),
|
||||
// Disable it since its uncertainty, who know what will happen on the other machines.
|
||||
let mut hasher = crc32fast::Hasher::new();
|
||||
hasher.update(frame);
|
||||
let checksum = hasher.finalize();
|
||||
@@ -347,9 +353,12 @@ fn handle_one_frame(
|
||||
} else {
|
||||
crc.1 += 1;
|
||||
}
|
||||
let encode = crc.1 <= 180 && crc.1 % 5 == 0;
|
||||
*/
|
||||
let encode = true;
|
||||
|
||||
let mut send_conn_ids: HashSet<i32> = Default::default();
|
||||
if crc.1 <= 180 && crc.1 % 5 == 0 {
|
||||
if encode {
|
||||
let mut frames = Vec::new();
|
||||
for ref frame in vpx
|
||||
.encode(ms, frame, STRIDE_ALIGN)
|
||||
|
||||
Reference in New Issue
Block a user