Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(windows): use osc_to_u16 even without read scancode #1321

Merged
merged 1 commit into from
Nov 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions src/oskbd/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,8 @@ fn send_key_sendinput(code: u16, is_key_up: bool) {

let code_u32 = code as u32;
kb_input.dwFlags |= KEYEVENTF_SCANCODE;
#[cfg(not(feature = "win_llhook_read_scancodes"))]
{
kb_input.wScan = MapVirtualKeyA(code_u32, 0) as u16;
}
#[cfg(feature = "win_llhook_read_scancodes")]
{
kb_input.wScan =
osc_to_u16(code.into()).unwrap_or_else(|| MapVirtualKeyA(code_u32, 0) as u16);
}
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 All @@ -150,7 +143,11 @@ fn send_key_sendinput(code: u16, is_key_up: bool) {
}
#[cfg(not(feature = "win_sendinput_send_scancodes"))]
{
kb_input.wVk = code;
use kanata_parser::keys::*;
kb_input.wVk = match code {
VK_KPENTER_FAKE => VK_RETURN as u16,
_ => code,
};
}

let mut inputs: [INPUT; 1] = mem::zeroed();
Expand Down
Loading