Skip to content

Commit

Permalink
fix(win-llhook): restore MapVirtualKeyA for default kanata.exe
Browse files Browse the repository at this point in the history
The commit fab0d89 intended to fix the functionality of keypad enter.
It worked for the US layout but broke other OS layouts. It turns out
MapVirtualKeyA **was** needed to translate to the appropriate scancode
output. The fix for keypad enter is done by attempting `osc_to_u16` if
MapVirtualKeyA fails, which it should for a nonexistent VK that kanata
uses for keypad enter.
  • Loading branch information
jtroo committed Nov 23, 2024
1 parent 538cfd9 commit 0b202b5
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/oskbd/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,18 @@ fn send_key_sendinput(code: u16, is_key_up: bool) {

let code_u32 = code as u32;
kb_input.dwFlags |= KEYEVENTF_SCANCODE;
kb_input.wScan =
osc_to_u16(code.into()).unwrap_or_else(|| MapVirtualKeyA(code_u32, 0) as u16);
#[cfg(not(feature = "win_llhook_read_scancodes"))]
{
kb_input.wScan = MapVirtualKeyA(code_u32, 0) as u16;
if kb_input.wScan == 0 {
kb_input.wScan = osc_to_u16(code.into()).unwrap_or(0);
}
}
#[cfg(feature = "win_llhook_read_scancodes")]
{
kb_input.wScan =
osc_to_u16(code.into()).unwrap_or_else(|| MapVirtualKeyA(code_u32, 0) as u16);
}
if kb_input.wScan == 0 {
kb_input.dwFlags &= !KEYEVENTF_SCANCODE;
kb_input.wVk = code;
Expand Down

0 comments on commit 0b202b5

Please sign in to comment.