mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-23 02:16:33 +11:00
Add prefix byte for extended scancodes on Windows (#1679)
This commit is contained in:
parent
7c543a43a9
commit
fbd3918d3a
2 changed files with 18 additions and 13 deletions
|
@ -3,6 +3,7 @@
|
||||||
- On Android, calling `WindowEvent::Focused` now works properly instead of always returning false.
|
- On Android, calling `WindowEvent::Focused` now works properly instead of always returning false.
|
||||||
- On Windows, fix alt-tab behaviour by removing borderless fullscreen "always on top" flag.
|
- On Windows, fix alt-tab behaviour by removing borderless fullscreen "always on top" flag.
|
||||||
- On Windows, fix bug preventing windows with transparency enabled from having fully-opaque regions.
|
- On Windows, fix bug preventing windows with transparency enabled from having fully-opaque regions.
|
||||||
|
- **Breaking:** On Windows, include prefix byte in scancodes.
|
||||||
|
|
||||||
# 0.23.0 (2020-10-02)
|
# 0.23.0 (2020-10-02)
|
||||||
|
|
||||||
|
|
|
@ -343,6 +343,7 @@ pub fn handle_extended_keys(
|
||||||
extended: bool,
|
extended: bool,
|
||||||
) -> Option<(c_int, UINT)> {
|
) -> Option<(c_int, UINT)> {
|
||||||
// Welcome to hell https://blog.molecular-matters.com/2011/09/05/properly-handling-keyboard-input/
|
// Welcome to hell https://blog.molecular-matters.com/2011/09/05/properly-handling-keyboard-input/
|
||||||
|
scancode = if extended { 0xE000 } else { 0x0000 } | scancode;
|
||||||
let vkey = match vkey {
|
let vkey = match vkey {
|
||||||
winuser::VK_SHIFT => unsafe {
|
winuser::VK_SHIFT => unsafe {
|
||||||
winuser::MapVirtualKeyA(scancode, winuser::MAPVK_VSC_TO_VK_EX) as _
|
winuser::MapVirtualKeyA(scancode, winuser::MAPVK_VSC_TO_VK_EX) as _
|
||||||
|
@ -363,20 +364,23 @@ pub fn handle_extended_keys(
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
match scancode {
|
match scancode {
|
||||||
// This is only triggered when using raw input. Without this check, we get two events whenever VK_PAUSE is
|
// When VK_PAUSE is pressed it emits a LeftControl + NumLock scancode event sequence, but reports VK_PAUSE
|
||||||
// pressed, the first one having scancode 0x1D but vkey VK_PAUSE...
|
// as the virtual key on both events, or VK_PAUSE on the first event or 0xFF when using raw input.
|
||||||
0x1D if vkey == winuser::VK_PAUSE => return None,
|
// Don't emit anything for the LeftControl event in the pair...
|
||||||
// ...and the second having scancode 0x45 but an unmatched vkey!
|
0xE01D if vkey == winuser::VK_PAUSE => return None,
|
||||||
0x45 => winuser::VK_PAUSE,
|
// ...and emit the Pause event for the second event in the pair.
|
||||||
// VK_PAUSE and VK_SCROLL have the same scancode when using modifiers, alongside incorrect vkey values.
|
0x45 if vkey == winuser::VK_PAUSE || vkey == 0xFF as _ => {
|
||||||
0x46 => {
|
scancode = 0xE059;
|
||||||
if extended {
|
winuser::VK_PAUSE
|
||||||
scancode = 0x45;
|
|
||||||
winuser::VK_PAUSE
|
|
||||||
} else {
|
|
||||||
winuser::VK_SCROLL
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// VK_PAUSE has an incorrect vkey value when used with modifiers. VK_PAUSE also reports a different
|
||||||
|
// scancode when used with modifiers than when used without
|
||||||
|
0xE046 => {
|
||||||
|
scancode = 0xE059;
|
||||||
|
winuser::VK_PAUSE
|
||||||
|
}
|
||||||
|
// VK_SCROLL has an incorrect vkey value when used with modifiers.
|
||||||
|
0x46 => winuser::VK_SCROLL,
|
||||||
_ => vkey,
|
_ => vkey,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue