debug: add evdev event logging + non-grabbed backspace fix
This commit is contained in:
parent
6d9e8ba4f9
commit
350d76e8a2
1 changed files with 45 additions and 1 deletions
|
|
@ -1360,6 +1360,7 @@ fn run_with_evdev(
|
||||||
);
|
);
|
||||||
let _ = devices[primary_idx].0.ungrab();
|
let _ = devices[primary_idx].0.ungrab();
|
||||||
grabbed = false;
|
grabbed = false;
|
||||||
|
log_info("[vietc] Non-grabbed mode: polling all evdev devices for keystrokes");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1398,6 +1399,13 @@ fn run_with_evdev(
|
||||||
}
|
}
|
||||||
idle_polls = 0;
|
idle_polls = 0;
|
||||||
|
|
||||||
|
if !grabbed {
|
||||||
|
log_info(&format!(
|
||||||
|
"[vietc] evdev: {} device(s) have events after ungrab",
|
||||||
|
pfds.iter().filter(|p| (p.revents & libc::POLLIN) != 0).count()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
// Check for status changes instantly
|
// Check for status changes instantly
|
||||||
if status_changed.load(Ordering::SeqCst) {
|
if status_changed.load(Ordering::SeqCst) {
|
||||||
daemon.sync_status_file();
|
daemon.sync_status_file();
|
||||||
|
|
@ -1435,8 +1443,10 @@ fn run_with_evdev(
|
||||||
};
|
};
|
||||||
last_event_time = std::time::Instant::now();
|
last_event_time = std::time::Instant::now();
|
||||||
|
|
||||||
|
let mut non_key_logged = 0u32;
|
||||||
for event in events {
|
for event in events {
|
||||||
if let evdev::InputEventKind::Key(key) = event.kind() {
|
match event.kind() {
|
||||||
|
evdev::InputEventKind::Key(key) => {
|
||||||
let value = event.value();
|
let value = event.value();
|
||||||
let keycode = key.0;
|
let keycode = key.0;
|
||||||
|
|
||||||
|
|
@ -1512,6 +1522,28 @@ fn run_with_evdev(
|
||||||
commands.push(OutputCommand::Type(buf_after));
|
commands.push(OutputCommand::Type(buf_after));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Non-grabbed fix: the VNI/Telex control key character reached
|
||||||
|
// the app directly. Add 1 extra backspace to remove it.
|
||||||
|
if !commands.is_empty()
|
||||||
|
&& is_vn_control_key(daemon.app_state.effective_method(), ch)
|
||||||
|
{
|
||||||
|
for cmd in &mut commands {
|
||||||
|
if let OutputCommand::Backspace(ref mut n) = cmd {
|
||||||
|
*n += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log_info(&format!(
|
||||||
|
"[vietc] non-grabbed: ch='{}' adjusted backspace+1",
|
||||||
|
ch.escape_default()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if !commands.is_empty() {
|
||||||
|
log_info(&format!(
|
||||||
|
"[vietc] non-grabbed inject: ch='{}' cmds={:?}",
|
||||||
|
ch.escape_default(),
|
||||||
|
commands
|
||||||
|
));
|
||||||
|
}
|
||||||
execute_commands(&*injector, &commands, false);
|
execute_commands(&*injector, &commands, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1664,6 +1696,18 @@ fn run_with_evdev(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_ => {
|
||||||
|
if non_key_logged < 5 {
|
||||||
|
log_info(&format!(
|
||||||
|
"[vietc] evdev: non-key event type={:?} code={} value={}",
|
||||||
|
event.event_type(),
|
||||||
|
event.code(),
|
||||||
|
event.value()
|
||||||
|
));
|
||||||
|
non_key_logged += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save updated key state back
|
// Save updated key state back
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue