Skip to content

Commit

Permalink
fix(wintercept): send Esc for unmapped oscode (#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtroo authored Nov 22, 2023
1 parent 1f7af8f commit 7f984db
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/oskbd/windows/interception.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use std::io;

use kanata_interception::{Interception, KeyState, MouseFlags, MouseState, Stroke};
use kanata_interception::{Interception, KeyState, MouseFlags, MouseState, ScanCode, Stroke};

use super::OsCodeWrapper;
use crate::kanata::CalculatedMouseMove;
Expand All @@ -16,8 +16,14 @@ pub struct InputEvent(pub Stroke);

impl InputEvent {
fn from_oscode(code: OsCode, val: KeyValue) -> Self {
let mut stroke =
Stroke::try_from(OsCodeWrapper(code)).expect("kanata only sends mapped `OsCode`s");
let mut stroke = Stroke::try_from(OsCodeWrapper(code)).unwrap_or_else(|_| {
log::error!("Trying to send unmapped oscode '{code:?}', sending esc instead");
Stroke::Keyboard {
code: ScanCode::Esc,
state: KeyState::empty(),
information: 0,
}
});
match &mut stroke {
Stroke::Keyboard { state, .. } => {
state.set(
Expand Down

0 comments on commit 7f984db

Please sign in to comment.