more on AltGr
This commit is contained in:
parent
b8f7e347c3
commit
dcad90e073
@ -13,7 +13,7 @@ mod eo;
|
|||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
pub fn translate(name: String) -> String {
|
pub fn translate(name: String) -> String {
|
||||||
let locale = sys_locale::get_locale().unwrap_or_default().to_lowercase();
|
let locale = sys_locale::get_locale().unwrap_or_default().to_lowercase();
|
||||||
log::debug!("The current locale is {}", locale);
|
log::trace!("The current locale is {}", locale);
|
||||||
translate_locale(name, &locale)
|
translate_locale(name, &locale)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,6 +198,7 @@ fn modifier_sleep() {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_modifier_state(key: Key, en: &mut Enigo) -> bool {
|
fn get_modifier_state(key: Key, en: &mut Enigo) -> bool {
|
||||||
|
// https://github.com/rustdesk/rustdesk/issues/332
|
||||||
// on Linux, if RightAlt is down, RightAlt status is false, Alt status is true
|
// on Linux, if RightAlt is down, RightAlt status is false, Alt status is true
|
||||||
// but on Windows, both are true
|
// but on Windows, both are true
|
||||||
let x = en.get_key_state(key.clone());
|
let x = en.get_key_state(key.clone());
|
||||||
@ -293,6 +294,11 @@ fn fix_modifier(
|
|||||||
en: &mut Enigo,
|
en: &mut Enigo,
|
||||||
) {
|
) {
|
||||||
if get_modifier_state(key1, en) && !modifiers.contains(&ProtobufEnumOrUnknown::new(key0)) {
|
if get_modifier_state(key1, en) && !modifiers.contains(&ProtobufEnumOrUnknown::new(key0)) {
|
||||||
|
#[cfg(windows)]
|
||||||
|
if key0 == ControlKey::Control && get_modifier_state(Key::Alt, en) {
|
||||||
|
// AltGr case
|
||||||
|
return;
|
||||||
|
}
|
||||||
en.key_up(key1);
|
en.key_up(key1);
|
||||||
log::debug!("Fixed {:?}", key1);
|
log::debug!("Fixed {:?}", key1);
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,8 @@ static mut KEYBOARD_HOOKED: bool = false;
|
|||||||
static mut SERVER_KEYBOARD_ENABLED: bool = true;
|
static mut SERVER_KEYBOARD_ENABLED: bool = true;
|
||||||
static mut SERVER_FILE_TRANSFER_ENABLED: bool = true;
|
static mut SERVER_FILE_TRANSFER_ENABLED: bool = true;
|
||||||
static mut SERVER_CLIPBOARD_ENABLED: bool = true;
|
static mut SERVER_CLIPBOARD_ENABLED: bool = true;
|
||||||
|
#[cfg(windows)]
|
||||||
|
static mut IS_ALT_GR: bool = false;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct HandlerInner {
|
pub struct HandlerInner {
|
||||||
@ -254,6 +256,23 @@ impl Handler {
|
|||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
let alt = get_key_state(enigo::Key::Alt);
|
let alt = get_key_state(enigo::Key::Alt);
|
||||||
|
#[cfg(windows)]
|
||||||
|
let ctrl = {
|
||||||
|
let mut tmp = get_key_state(enigo::Key::Control);
|
||||||
|
unsafe {
|
||||||
|
if IS_ALT_GR {
|
||||||
|
if alt || key == Key::Alt {
|
||||||
|
if tmp {
|
||||||
|
tmp = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
IS_ALT_GR = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tmp
|
||||||
|
};
|
||||||
|
#[cfg(not(windows))]
|
||||||
let ctrl = get_key_state(enigo::Key::Control);
|
let ctrl = get_key_state(enigo::Key::Control);
|
||||||
let shift = get_key_state(enigo::Key::Shift);
|
let shift = get_key_state(enigo::Key::Shift);
|
||||||
let command = get_key_state(enigo::Key::Meta);
|
let command = get_key_state(enigo::Key::Meta);
|
||||||
@ -266,6 +285,9 @@ impl Handler {
|
|||||||
// scancode with bit 9 set is sent, let's ignore this.
|
// scancode with bit 9 set is sent, let's ignore this.
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
if evt.scan_code & 0x200 != 0 {
|
if evt.scan_code & 0x200 != 0 {
|
||||||
|
unsafe {
|
||||||
|
IS_ALT_GR = true;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Some(ControlKey::Control)
|
Some(ControlKey::Control)
|
||||||
@ -1844,7 +1866,8 @@ impl Remote {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Some(misc::Union::option_response(resp)) => {
|
Some(misc::Union::option_response(resp)) => {
|
||||||
self.handler.msgbox("warn", "Option Error", &resp.error);
|
self.handler
|
||||||
|
.msgbox("custom-error", "Option Error", &resp.error);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user