From 2be71306ec40cd8cc660bbd4160103aa485b2999 Mon Sep 17 00:00:00 2001 From: Tomaka17 Date: Thu, 30 Oct 2014 14:01:52 +0100 Subject: Remove key modifiers in KeyboardInput --- src/osx/event.rs | 18 ------------------ src/osx/mod.rs | 12 +++++------- 2 files changed, 5 insertions(+), 25 deletions(-) (limited to 'src/osx') diff --git a/src/osx/event.rs b/src/osx/event.rs index a4128a4..b5853bc 100644 --- a/src/osx/event.rs +++ b/src/osx/event.rs @@ -1,25 +1,7 @@ use events; -use events::KeyModifiers; use cocoa::base::NSUInteger; use cocoa::appkit; -pub fn modifierflag_to_element(flag: NSUInteger) -> KeyModifiers { - let mut modifiers = KeyModifiers::empty(); - if flag & appkit::NSShiftKeyMask as u64 == appkit::NSShiftKeyMask as u64 { - modifiers = modifiers | events::LEFT_SHIFT_MODIFIER; - } - if flag & appkit::NSControlKeyMask as u64 == appkit::NSControlKeyMask as u64 { - modifiers = modifiers | events::LEFT_CONTROL_MODIFIER; - } - if flag & appkit::NSAlternateKeyMask as u64 == appkit::NSAlternateKeyMask as u64 { - modifiers = modifiers | events::LEFT_ALT_MODIFIER; - } - if flag & appkit::NSNumericPadKeyMask as u64 == appkit::NSNumericPadKeyMask as u64 { - modifiers = modifiers | events::NUM_LOCK_MODIFIER; - } - modifiers -} - pub fn vkeycode_to_element(code: u16) -> Option { Some(match code { 0x00 => events::A, diff --git a/src/osx/mod.rs b/src/osx/mod.rs index de7e902..ea79f04 100644 --- a/src/osx/mod.rs +++ b/src/osx/mod.rs @@ -18,7 +18,7 @@ use core_foundation::bundle::{CFBundleGetBundleWithIdentifier, CFBundleGetFuncti use std::c_str::CString; use {MouseInput, Pressed, Released, LeftMouseButton, RightMouseButton, MouseMoved, ReceivedCharacter, - KeyboardInput, KeyModifiers}; + KeyboardInput}; use events; @@ -252,13 +252,11 @@ impl Window { } let vkey = event::vkeycode_to_element(event.keycode()); - let modifiers = event::modifierflag_to_element(event.modifierFlags()); - events.push(KeyboardInput(Pressed, event.keycode() as u8, vkey, modifiers)); + events.push(KeyboardInput(Pressed, event.keycode() as u8, vkey)); }, NSKeyUp => { let vkey = event::vkeycode_to_element(event.keycode()); - let modifiers = event::modifierflag_to_element(event.modifierFlags()); - events.push(KeyboardInput(Released, event.keycode() as u8, vkey, modifiers)); + events.push(KeyboardInput(Released, event.keycode() as u8, vkey)); }, NSFlagsChanged => { let shift_modifier = Window::modifier_event(event, appkit::NSShiftKeyMask as u64, events::LShift, shift_pressed); @@ -295,10 +293,10 @@ impl Window { unsafe fn modifier_event(event: id, keymask: u64, key: events::VirtualKeyCode, key_pressed: bool) -> Option { if !key_pressed && Window::modifier_key_pressed(event, keymask) { - return Some(KeyboardInput(Pressed, event.keycode() as u8, Some(key), KeyModifiers::empty())); + return Some(KeyboardInput(Pressed, event.keycode() as u8, Some(key))); } else if key_pressed && !Window::modifier_key_pressed(event, keymask) { - return Some(KeyboardInput(Released, event.keycode() as u8, Some(key), KeyModifiers::empty())); + return Some(KeyboardInput(Released, event.keycode() as u8, Some(key))); } return None; -- cgit v1.2.3