macOS: Fix alt and win keycodes (#552)

* macOS: Generate LAlt/RAlt VirtualKeyCode

* macOS: Correct RWin/LWin
This commit is contained in:
Francesca Frangipane 2018-06-06 11:30:26 -04:00 committed by GitHub
parent 19dd961752
commit 79aebf06dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View file

@ -7,6 +7,8 @@
- On X11, the environment variable `WINIT_HIDPI_FACTOR` has been added for overriding DPI factor. - On X11, the environment variable `WINIT_HIDPI_FACTOR` has been added for overriding DPI factor.
- On X11, enabling transparency no longer causes the window contents to flicker when resizing. - On X11, enabling transparency no longer causes the window contents to flicker when resizing.
- On X11, `with_override_redirect` now actually enables override redirect. - On X11, `with_override_redirect` now actually enables override redirect.
- macOS now generates `VirtualKeyCode::LAlt` and `VirtualKeyCode::RAlt` instead of `None` for both.
- On macOS, `VirtualKeyCode::RWin` and `VirtualKeyCode::LWin` are no longer switched.
# Version 0.15.0 (2018-05-22) # Version 0.15.0 (2018-05-22)

View file

@ -598,14 +598,14 @@ pub fn to_virtual_key_code(code: c_ushort) -> Option<events::VirtualKeyCode> {
0x33 => events::VirtualKeyCode::Back, 0x33 => events::VirtualKeyCode::Back,
//0x34 => unkown, //0x34 => unkown,
0x35 => events::VirtualKeyCode::Escape, 0x35 => events::VirtualKeyCode::Escape,
0x36 => events::VirtualKeyCode::RWin, 0x36 => events::VirtualKeyCode::LWin,
0x37 => events::VirtualKeyCode::LWin, 0x37 => events::VirtualKeyCode::RWin,
0x38 => events::VirtualKeyCode::LShift, 0x38 => events::VirtualKeyCode::LShift,
//0x39 => Caps lock, //0x39 => Caps lock,
//0x3a => Left alt, 0x3a => events::VirtualKeyCode::LAlt,
0x3b => events::VirtualKeyCode::LControl, 0x3b => events::VirtualKeyCode::LControl,
0x3c => events::VirtualKeyCode::RShift, 0x3c => events::VirtualKeyCode::RShift,
//0x3d => Right alt, 0x3d => events::VirtualKeyCode::RAlt,
0x3e => events::VirtualKeyCode::RControl, 0x3e => events::VirtualKeyCode::RControl,
//0x3f => Fn key, //0x3f => Fn key,
//0x40 => F17 Key, //0x40 => F17 Key,
@ -695,7 +695,7 @@ unsafe fn modifier_event(
keymask: NSEventModifierFlags, keymask: NSEventModifierFlags,
key_pressed: bool, key_pressed: bool,
) -> Option<WindowEvent> { ) -> Option<WindowEvent> {
if !key_pressed && NSEvent::modifierFlags(ns_event).contains(keymask) if !key_pressed && NSEvent::modifierFlags(ns_event).contains(keymask)
|| key_pressed && !NSEvent::modifierFlags(ns_event).contains(keymask) { || key_pressed && !NSEvent::modifierFlags(ns_event).contains(keymask) {
let state = ElementState::Released; let state = ElementState::Released;
let keycode = NSEvent::keyCode(ns_event); let keycode = NSEvent::keyCode(ns_event);