mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-27 23:23:14 -04:00
Change ModifiersState to a bitflags struct (#1306)
* Change ModifiersState to a bitflags struct * Make examples work * Add modifier state methods * all things considered, only erroring out in one file throughout all of these changes is kinda impressive * Make expansion plans more clear * Move changelog entry * Try to fix macos build * Revert modifiers println in cursor_grab * Make serde serialization less bug-prone
This commit is contained in:
@@ -17,13 +17,22 @@ fn key_pressed(vkey: c_int) -> bool {
|
||||
}
|
||||
|
||||
pub fn get_key_mods() -> ModifiersState {
|
||||
let mut mods = ModifiersState::default();
|
||||
let filter_out_altgr = layout_uses_altgr() && key_pressed(winuser::VK_RMENU);
|
||||
|
||||
mods.shift = key_pressed(winuser::VK_SHIFT);
|
||||
mods.ctrl = key_pressed(winuser::VK_CONTROL) && !filter_out_altgr;
|
||||
mods.alt = key_pressed(winuser::VK_MENU) && !filter_out_altgr;
|
||||
mods.logo = key_pressed(winuser::VK_LWIN) || key_pressed(winuser::VK_RWIN);
|
||||
let mut mods = ModifiersState::empty();
|
||||
mods.set(ModifiersState::SHIFT, key_pressed(winuser::VK_SHIFT));
|
||||
mods.set(
|
||||
ModifiersState::CTRL,
|
||||
key_pressed(winuser::VK_CONTROL) && !filter_out_altgr,
|
||||
);
|
||||
mods.set(
|
||||
ModifiersState::ALT,
|
||||
key_pressed(winuser::VK_MENU) && !filter_out_altgr,
|
||||
);
|
||||
mods.set(
|
||||
ModifiersState::LOGO,
|
||||
key_pressed(winuser::VK_LWIN) || key_pressed(winuser::VK_RWIN),
|
||||
);
|
||||
mods
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user