win, translate mode, fix dead key
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
4134b77680
commit
1588e44d61
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -4405,7 +4405,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "rdev"
|
name = "rdev"
|
||||||
version = "0.5.0-2"
|
version = "0.5.0-2"
|
||||||
source = "git+https://github.com/fufesou/rdev#4d8231f05e14c5a04cd7d2c1288e87ad52d39e4c"
|
source = "git+https://github.com/fufesou/rdev#cedc4e62744566775026af4b434ef799804c1130"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cocoa",
|
"cocoa",
|
||||||
"core-foundation 0.9.3",
|
"core-foundation 0.9.3",
|
||||||
|
@ -193,8 +193,8 @@ pub mod client {
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
pub fn update_grab_get_key_name() {
|
pub fn update_grab_get_key_name() {
|
||||||
match get_keyboard_mode_enum() {
|
match get_keyboard_mode_enum() {
|
||||||
KeyboardMode::Map => rdev::set_get_key_name(false),
|
KeyboardMode::Map => rdev::set_get_key_unicode(false),
|
||||||
KeyboardMode::Translate => rdev::set_get_key_name(true),
|
KeyboardMode::Translate => rdev::set_get_key_unicode(true),
|
||||||
_ => {}
|
_ => {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -256,6 +256,7 @@ pub fn start_grab_loop() {
|
|||||||
if let Err(error) = rdev::grab(func) {
|
if let Err(error) = rdev::grab(func) {
|
||||||
log::error!("rdev Error: {:?}", error)
|
log::error!("rdev Error: {:?}", error)
|
||||||
}
|
}
|
||||||
|
rdev::set_event_popup(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
@ -757,12 +758,10 @@ pub fn map_keyboard_mode(event: &Event, mut key_event: KeyEvent) -> Option<KeyEv
|
|||||||
fn try_fill_unicode(event: &Event, key_event: &KeyEvent, events: &mut Vec<KeyEvent>) {
|
fn try_fill_unicode(event: &Event, key_event: &KeyEvent, events: &mut Vec<KeyEvent>) {
|
||||||
match &event.unicode {
|
match &event.unicode {
|
||||||
Some(unicode_info) => {
|
Some(unicode_info) => {
|
||||||
if !unicode_info.is_dead {
|
for code in &unicode_info.unicode {
|
||||||
for code in &unicode_info.unicode {
|
let mut evt = key_event.clone();
|
||||||
let mut evt = key_event.clone();
|
evt.set_unicode(*code as _);
|
||||||
evt.set_unicode(*code as _);
|
events.push(evt);
|
||||||
events.push(evt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {}
|
None => {}
|
||||||
@ -816,6 +815,12 @@ pub fn translate_virtual_keycode(event: &Event, mut key_event: KeyEvent) -> Opti
|
|||||||
|
|
||||||
pub fn translate_keyboard_mode(event: &Event, key_event: KeyEvent) -> Vec<KeyEvent> {
|
pub fn translate_keyboard_mode(event: &Event, key_event: KeyEvent) -> Vec<KeyEvent> {
|
||||||
let mut events: Vec<KeyEvent> = Vec::new();
|
let mut events: Vec<KeyEvent> = Vec::new();
|
||||||
|
if let Some(unicode_info) = &event.unicode {
|
||||||
|
if unicode_info.is_dead {
|
||||||
|
return events;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
unsafe {
|
unsafe {
|
||||||
if event.scan_code == 0x021D {
|
if event.scan_code == 0x021D {
|
||||||
|
@ -368,8 +368,8 @@ impl<T: InvokeUiSession> Session<T> {
|
|||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
{
|
{
|
||||||
match &self.lc.read().unwrap().keyboard_mode as _ {
|
match &self.lc.read().unwrap().keyboard_mode as _ {
|
||||||
"legacy" => rdev::set_get_key_name(true),
|
"legacy" => rdev::set_get_key_unicode(true),
|
||||||
"translate" => rdev::set_get_key_name(true),
|
"translate" => rdev::set_get_key_unicode(true),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -381,7 +381,7 @@ impl<T: InvokeUiSession> Session<T> {
|
|||||||
pub fn leave(&self) {
|
pub fn leave(&self) {
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
{
|
{
|
||||||
rdev::set_get_key_name(false);
|
rdev::set_get_key_unicode(false);
|
||||||
}
|
}
|
||||||
IS_IN.store(false, Ordering::SeqCst);
|
IS_IN.store(false, Ordering::SeqCst);
|
||||||
keyboard::client::change_grab_status(GrabState::Wait);
|
keyboard::client::change_grab_status(GrabState::Wait);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user