Update for rustc

This commit is contained in:
Pierre Krieger 2014-11-19 06:09:54 +01:00
parent 4edb3df155
commit ff3a29aaf5
10 changed files with 1325 additions and 1301 deletions

View file

@ -2,8 +2,11 @@ extern crate android_glue;
extern crate native;
use libc;
use {CreationError, OsError, Event, WindowBuilder};
use {Pressed, Released, LeftMouseButton, MouseInput, MouseMoved};
use {CreationError, Event, WindowBuilder};
use CreationError::OsError;
use events::ElementState::{Pressed, Released};
use events::Event::{MouseInput, MouseMoved};
use events::MouseButton::LeftMouseButton;
pub struct Window {
display: ffi::egl::types::EGLDisplay,

View file

@ -79,7 +79,7 @@ pub enum CreationError {
impl std::error::Error for CreationError {
fn description(&self) -> &str {
match self {
&OsError(ref text) => text.as_slice(),
&CreationError::OsError(ref text) => text.as_slice(),
}
}
}

View file

@ -2,133 +2,133 @@ use events;
pub fn vkeycode_to_element(code: u16) -> Option<events::VirtualKeyCode> {
Some(match code {
0x00 => events::A,
0x01 => events::S,
0x02 => events::D,
0x03 => events::F,
0x04 => events::H,
0x05 => events::G,
0x06 => events::Z,
0x07 => events::X,
0x08 => events::C,
0x09 => events::V,
0x00 => events::VirtualKeyCode::A,
0x01 => events::VirtualKeyCode::S,
0x02 => events::VirtualKeyCode::D,
0x03 => events::VirtualKeyCode::F,
0x04 => events::VirtualKeyCode::H,
0x05 => events::VirtualKeyCode::G,
0x06 => events::VirtualKeyCode::Z,
0x07 => events::VirtualKeyCode::X,
0x08 => events::VirtualKeyCode::C,
0x09 => events::VirtualKeyCode::V,
//0x0a => World 1,
0x0b => events::B,
0x0c => events::Q,
0x0d => events::W,
0x0e => events::E,
0x0f => events::R,
0x10 => events::Y,
0x11 => events::T,
0x12 => events::Key1,
0x13 => events::Key2,
0x14 => events::Key3,
0x15 => events::Key4,
0x16 => events::Key6,
0x17 => events::Key5,
0x18 => events::Equals,
0x19 => events::Key9,
0x1a => events::Key7,
0x1b => events::Minus,
0x1c => events::Key8,
0x1d => events::Key0,
0x1e => events::RBracket,
0x1f => events::O,
0x20 => events::U,
0x21 => events::LBracket,
0x22 => events::I,
0x23 => events::P,
0x24 => events::Return,
0x25 => events::L,
0x26 => events::J,
0x27 => events::Apostrophe,
0x28 => events::K,
0x29 => events::Semicolon,
0x2a => events::Backslash,
0x2b => events::Comma,
0x2c => events::Slash,
0x2d => events::N,
0x2e => events::M,
0x2f => events::Period,
0x30 => events::Tab,
0x31 => events::Space,
0x32 => events::Grave,
0x33 => events::Back,
0x0b => events::VirtualKeyCode::B,
0x0c => events::VirtualKeyCode::Q,
0x0d => events::VirtualKeyCode::W,
0x0e => events::VirtualKeyCode::E,
0x0f => events::VirtualKeyCode::R,
0x10 => events::VirtualKeyCode::Y,
0x11 => events::VirtualKeyCode::T,
0x12 => events::VirtualKeyCode::Key1,
0x13 => events::VirtualKeyCode::Key2,
0x14 => events::VirtualKeyCode::Key3,
0x15 => events::VirtualKeyCode::Key4,
0x16 => events::VirtualKeyCode::Key6,
0x17 => events::VirtualKeyCode::Key5,
0x18 => events::VirtualKeyCode::Equals,
0x19 => events::VirtualKeyCode::Key9,
0x1a => events::VirtualKeyCode::Key7,
0x1b => events::VirtualKeyCode::Minus,
0x1c => events::VirtualKeyCode::Key8,
0x1d => events::VirtualKeyCode::Key0,
0x1e => events::VirtualKeyCode::RBracket,
0x1f => events::VirtualKeyCode::O,
0x20 => events::VirtualKeyCode::U,
0x21 => events::VirtualKeyCode::LBracket,
0x22 => events::VirtualKeyCode::I,
0x23 => events::VirtualKeyCode::P,
0x24 => events::VirtualKeyCode::Return,
0x25 => events::VirtualKeyCode::L,
0x26 => events::VirtualKeyCode::J,
0x27 => events::VirtualKeyCode::Apostrophe,
0x28 => events::VirtualKeyCode::K,
0x29 => events::VirtualKeyCode::Semicolon,
0x2a => events::VirtualKeyCode::Backslash,
0x2b => events::VirtualKeyCode::Comma,
0x2c => events::VirtualKeyCode::Slash,
0x2d => events::VirtualKeyCode::N,
0x2e => events::VirtualKeyCode::M,
0x2f => events::VirtualKeyCode::Period,
0x30 => events::VirtualKeyCode::Tab,
0x31 => events::VirtualKeyCode::Space,
0x32 => events::VirtualKeyCode::Grave,
0x33 => events::VirtualKeyCode::Back,
//0x34 => unkown,
0x35 => events::Escape,
0x36 => events::RWin,
0x37 => events::LWin,
0x38 => events::LShift,
0x35 => events::VirtualKeyCode::Escape,
0x36 => events::VirtualKeyCode::RWin,
0x37 => events::VirtualKeyCode::LWin,
0x38 => events::VirtualKeyCode::LShift,
//0x39 => Caps lock,
//0x3a => Left alt,
0x3b => events::LControl,
0x3c => events::RShift,
0x3b => events::VirtualKeyCode::LControl,
0x3c => events::VirtualKeyCode::RShift,
//0x3d => Right alt,
0x3e => events::RControl,
0x3e => events::VirtualKeyCode::RControl,
//0x3f => Fn key,
//0x40 => F17 Key,
0x41 => events::Decimal,
0x41 => events::VirtualKeyCode::Decimal,
//0x42 -> unkown,
0x43 => events::Multiply,
0x43 => events::VirtualKeyCode::Multiply,
//0x44 => unkown,
0x45 => events::Add,
0x45 => events::VirtualKeyCode::Add,
//0x46 => unkown,
0x47 => events::Numlock,
0x47 => events::VirtualKeyCode::Numlock,
//0x48 => KeypadClear,
0x49 => events::VolumeUp,
0x4a => events::VolumeDown,
0x4b => events::Divide,
0x4c => events::NumpadEnter,
0x49 => events::VirtualKeyCode::VolumeUp,
0x4a => events::VirtualKeyCode::VolumeDown,
0x4b => events::VirtualKeyCode::Divide,
0x4c => events::VirtualKeyCode::NumpadEnter,
//0x4d => unkown,
0x4e => events::Subtract,
0x4e => events::VirtualKeyCode::Subtract,
//0x4f => F18 key,
//0x50 => F19 Key,
0x51 => events::NumpadEquals,
0x52 => events::Numpad0,
0x53 => events::Numpad1,
0x54 => events::Numpad2,
0x55 => events::Numpad3,
0x56 => events::Numpad4,
0x57 => events::Numpad5,
0x58 => events::Numpad6,
0x59 => events::Numpad7,
0x51 => events::VirtualKeyCode::NumpadEquals,
0x52 => events::VirtualKeyCode::Numpad0,
0x53 => events::VirtualKeyCode::Numpad1,
0x54 => events::VirtualKeyCode::Numpad2,
0x55 => events::VirtualKeyCode::Numpad3,
0x56 => events::VirtualKeyCode::Numpad4,
0x57 => events::VirtualKeyCode::Numpad5,
0x58 => events::VirtualKeyCode::Numpad6,
0x59 => events::VirtualKeyCode::Numpad7,
//0x5a => F20 Key,
0x5b => events::Numpad8,
0x5c => events::Numpad9,
0x5b => events::VirtualKeyCode::Numpad8,
0x5c => events::VirtualKeyCode::Numpad9,
//0x5d => unkown,
//0x5e => unkown,
//0x5f => unkown,
0x60 => events::F5,
0x61 => events::F6,
0x62 => events::F7,
0x63 => events::F3,
0x64 => events::F8,
0x65 => events::F9,
0x60 => events::VirtualKeyCode::F5,
0x61 => events::VirtualKeyCode::F6,
0x62 => events::VirtualKeyCode::F7,
0x63 => events::VirtualKeyCode::F3,
0x64 => events::VirtualKeyCode::F8,
0x65 => events::VirtualKeyCode::F9,
//0x66 => unkown,
0x67 => events::F11,
0x67 => events::VirtualKeyCode::F11,
//0x68 => unkown,
0x69 => events::F13,
0x69 => events::VirtualKeyCode::F13,
//0x6a => F16 Key,
0x6b => events::F14,
0x6b => events::VirtualKeyCode::F14,
//0x6c => unkown,
0x6d => events::F10,
0x6d => events::VirtualKeyCode::F10,
//0x6e => unkown,
0x6f => events::F12,
0x6f => events::VirtualKeyCode::F12,
//0x70 => unkown,
0x71 => events::F15,
0x72 => events::Insert,
0x73 => events::Home,
0x74 => events::PageUp,
0x75 => events::Delete,
0x76 => events::F4,
0x77 => events::End,
0x78 => events::F2,
0x79 => events::PageDown,
0x7a => events::F1,
0x7b => events::Left,
0x7c => events::Right,
0x7d => events::Down,
0x7e => events::Up,
0x71 => events::VirtualKeyCode::F15,
0x72 => events::VirtualKeyCode::Insert,
0x73 => events::VirtualKeyCode::Home,
0x74 => events::VirtualKeyCode::PageUp,
0x75 => events::VirtualKeyCode::Delete,
0x76 => events::VirtualKeyCode::F4,
0x77 => events::VirtualKeyCode::End,
0x78 => events::VirtualKeyCode::F2,
0x79 => events::VirtualKeyCode::PageDown,
0x7a => events::VirtualKeyCode::F1,
0x7b => events::VirtualKeyCode::Left,
0x7c => events::VirtualKeyCode::Right,
0x7d => events::VirtualKeyCode::Down,
0x7e => events::VirtualKeyCode::Up,
//0x7f => unkown,
_ => return None,

View file

@ -17,9 +17,10 @@ use core_foundation::string::CFString;
use core_foundation::bundle::{CFBundleGetBundleWithIdentifier, CFBundleGetFunctionPointerForName};
use std::c_str::CString;
use {MouseInput, Pressed, Released, LeftMouseButton, RightMouseButton, MouseMoved, ReceivedCharacter,
KeyboardInput};
use events::Event::{MouseInput, Pressed, Released, MouseMoved, ReceivedCharacter, KeyboardInput};
use events::ElementState::{Pressed, Released};
use events::MouseButton::{LeftMouseButton, RightMouseButton};
use events;
pub use self::monitor::{MonitorID, get_available_monitors, get_primary_monitor};

View file

@ -3,179 +3,179 @@ use super::ffi;
pub fn vkeycode_to_element(code: ffi::WPARAM) -> Option<events::VirtualKeyCode> {
Some(match code {
//ffi::VK_LBUTTON => events::Lbutton,
//ffi::VK_RBUTTON => events::Rbutton,
//ffi::VK_CANCEL => events::Cancel,
//ffi::VK_MBUTTON => events::Mbutton,
//ffi::VK_XBUTTON1 => events::Xbutton1,
//ffi::VK_XBUTTON2 => events::Xbutton2,
ffi::VK_BACK => events::Back,
ffi::VK_TAB => events::Tab,
//ffi::VK_CLEAR => events::Clear,
ffi::VK_RETURN => events::Return,
//ffi::VK_SHIFT => events::Shift,
//ffi::VK_CONTROL => events::Control,
//ffi::VK_MENU => events::Menu,
ffi::VK_PAUSE => events::Pause,
ffi::VK_CAPITAL => events::Capital,
ffi::VK_KANA => events::Kana,
//ffi::VK_HANGUEL => events::Hanguel,
//ffi::VK_HANGUL => events::Hangul,
//ffi::VK_JUNJA => events::Junja,
//ffi::VK_FINAL => events::Final,
//ffi::VK_HANJA => events::Hanja,
ffi::VK_KANJI => events::Kanji,
ffi::VK_ESCAPE => events::Escape,
ffi::VK_CONVERT => events::Convert,
//ffi::VK_NONCONVERT => events::Nonconvert,
//ffi::VK_ACCEPT => events::Accept,
//ffi::VK_MODECHANGE => events::Modechange,
ffi::VK_SPACE => events::Space,
ffi::VK_PRIOR => events::PageUp,
ffi::VK_NEXT => events::PageDown,
ffi::VK_END => events::End,
ffi::VK_HOME => events::Home,
ffi::VK_LEFT => events::Left,
ffi::VK_UP => events::Up,
ffi::VK_RIGHT => events::Right,
ffi::VK_DOWN => events::Down,
//ffi::VK_SELECT => events::Select,
//ffi::VK_PRINT => events::Print,
//ffi::VK_EXECUTE => events::Execute,
ffi::VK_SNAPSHOT => events::Snapshot,
ffi::VK_INSERT => events::Insert,
ffi::VK_DELETE => events::Delete,
//ffi::VK_HELP => events::Help,
0x30 => events::Key0,
0x31 => events::Key1,
0x32 => events::Key2,
0x33 => events::Key3,
0x34 => events::Key4,
0x35 => events::Key5,
0x36 => events::Key6,
0x37 => events::Key7,
0x38 => events::Key8,
0x39 => events::Key9,
0x41 => events::A,
0x42 => events::B,
0x43 => events::C,
0x44 => events::D,
0x45 => events::E,
0x46 => events::F,
0x47 => events::G,
0x48 => events::H,
0x49 => events::I,
0x4A => events::J,
0x4B => events::K,
0x4C => events::L,
0x4D => events::M,
0x4E => events::N,
0x4F => events::O,
0x50 => events::P,
0x51 => events::Q,
0x52 => events::R,
0x53 => events::S,
0x54 => events::T,
0x55 => events::U,
0x56 => events::V,
0x57 => events::W,
0x58 => events::X,
0x59 => events::Y,
0x5A => events::Z,
//ffi::VK_LWIN => events::Lwin,
//ffi::VK_RWIN => events::Rwin,
ffi::VK_APPS => events::Apps,
ffi::VK_SLEEP => events::Sleep,
ffi::VK_NUMPAD0 => events::Numpad0,
ffi::VK_NUMPAD1 => events::Numpad1,
ffi::VK_NUMPAD2 => events::Numpad2,
ffi::VK_NUMPAD3 => events::Numpad3,
ffi::VK_NUMPAD4 => events::Numpad4,
ffi::VK_NUMPAD5 => events::Numpad5,
ffi::VK_NUMPAD6 => events::Numpad6,
ffi::VK_NUMPAD7 => events::Numpad7,
ffi::VK_NUMPAD8 => events::Numpad8,
ffi::VK_NUMPAD9 => events::Numpad9,
ffi::VK_MULTIPLY => events::Multiply,
ffi::VK_ADD => events::Add,
//ffi::VK_SEPARATOR => events::Separator,
ffi::VK_SUBTRACT => events::Subtract,
ffi::VK_DECIMAL => events::Decimal,
ffi::VK_DIVIDE => events::Divide,
ffi::VK_F1 => events::F1,
ffi::VK_F2 => events::F2,
ffi::VK_F3 => events::F3,
ffi::VK_F4 => events::F4,
ffi::VK_F5 => events::F5,
ffi::VK_F6 => events::F6,
ffi::VK_F7 => events::F7,
ffi::VK_F8 => events::F8,
ffi::VK_F9 => events::F9,
ffi::VK_F10 => events::F10,
ffi::VK_F11 => events::F11,
ffi::VK_F12 => events::F12,
ffi::VK_F13 => events::F13,
ffi::VK_F14 => events::F14,
ffi::VK_F15 => events::F15,
/*ffi::VK_F16 => events::F16,
ffi::VK_F17 => events::F17,
ffi::VK_F18 => events::F18,
ffi::VK_F19 => events::F19,
ffi::VK_F20 => events::F20,
ffi::VK_F21 => events::F21,
ffi::VK_F22 => events::F22,
ffi::VK_F23 => events::F23,
ffi::VK_F24 => events::F24,*/
ffi::VK_NUMLOCK => events::Numlock,
ffi::VK_SCROLL => events::Scroll,
/*ffi::VK_LSHIFT => events::Lshift,
ffi::VK_RSHIFT => events::Rshift,
ffi::VK_LCONTROL => events::Lcontrol,
ffi::VK_RCONTROL => events::Rcontrol,
ffi::VK_LMENU => events::Lmenu,
ffi::VK_RMENU => events::Rmenu,
ffi::VK_BROWSER_BACK => events::Browser_back,
ffi::VK_BROWSER_FORWARD => events::Browser_forward,
ffi::VK_BROWSER_REFRESH => events::Browser_refresh,
ffi::VK_BROWSER_STOP => events::Browser_stop,
ffi::VK_BROWSER_SEARCH => events::Browser_search,
ffi::VK_BROWSER_FAVORITES => events::Browser_favorites,
ffi::VK_BROWSER_HOME => events::Browser_home,
ffi::VK_VOLUME_MUTE => events::Volume_mute,
ffi::VK_VOLUME_DOWN => events::Volume_down,
ffi::VK_VOLUME_UP => events::Volume_up,
ffi::VK_MEDIA_NEXT_TRACK => events::Media_next_track,
ffi::VK_MEDIA_PREV_TRACK => events::Media_prev_track,
ffi::VK_MEDIA_STOP => events::Media_stop,
ffi::VK_MEDIA_PLAY_PAUSE => events::Media_play_pause,
ffi::VK_LAUNCH_MAIL => events::Launch_mail,
ffi::VK_LAUNCH_MEDIA_SELECT => events::Launch_media_select,
ffi::VK_LAUNCH_APP1 => events::Launch_app1,
ffi::VK_LAUNCH_APP2 => events::Launch_app2,
ffi::VK_OEM_1 => events::Oem_1,
ffi::VK_OEM_PLUS => events::Oem_plus,
ffi::VK_OEM_COMMA => events::Oem_comma,
ffi::VK_OEM_MINUS => events::Oem_minus,
ffi::VK_OEM_PERIOD => events::Oem_period,
ffi::VK_OEM_2 => events::Oem_2,
ffi::VK_OEM_3 => events::Oem_3,
ffi::VK_OEM_4 => events::Oem_4,
ffi::VK_OEM_5 => events::Oem_5,
ffi::VK_OEM_6 => events::Oem_6,
ffi::VK_OEM_7 => events::Oem_7,
ffi::VK_OEM_8 => events::Oem_8,
ffi::VK_OEM_102 => events::Oem_102,
ffi::VK_PROCESSKEY => events::Processkey,
ffi::VK_PACKET => events::Packet,
ffi::VK_ATTN => events::Attn,
ffi::VK_CRSEL => events::Crsel,
ffi::VK_EXSEL => events::Exsel,
ffi::VK_EREOF => events::Ereof,
ffi::VK_PLAY => events::Play,
ffi::VK_ZOOM => events::Zoom,
ffi::VK_NONAME => events::Noname,
ffi::VK_PA1 => events::Pa1,
ffi::VK_OEM_CLEAR => events::Oem_clear,*/
//ffi::VK_LBUTTON => events::VirtualKeyCode::Lbutton,
//ffi::VK_RBUTTON => events::VirtualKeyCode::Rbutton,
//ffi::VK_CANCEL => events::VirtualKeyCode::Cancel,
//ffi::VK_MBUTTON => events::VirtualKeyCode::Mbutton,
//ffi::VK_XBUTTON1 => events::VirtualKeyCode::Xbutton1,
//ffi::VK_XBUTTON2 => events::VirtualKeyCode::Xbutton2,
ffi::VK_BACK => events::VirtualKeyCode::Back,
ffi::VK_TAB => events::VirtualKeyCode::Tab,
//ffi::VK_CLEAR => events::VirtualKeyCode::Clear,
ffi::VK_RETURN => events::VirtualKeyCode::Return,
//ffi::VK_SHIFT => events::VirtualKeyCode::Shift,
//ffi::VK_CONTROL => events::VirtualKeyCode::Control,
//ffi::VK_MENU => events::VirtualKeyCode::Menu,
ffi::VK_PAUSE => events::VirtualKeyCode::Pause,
ffi::VK_CAPITAL => events::VirtualKeyCode::Capital,
ffi::VK_KANA => events::VirtualKeyCode::Kana,
//ffi::VK_HANGUEL => events::VirtualKeyCode::Hanguel,
//ffi::VK_HANGUL => events::VirtualKeyCode::Hangul,
//ffi::VK_JUNJA => events::VirtualKeyCode::Junja,
//ffi::VK_FINAL => events::VirtualKeyCode::Final,
//ffi::VK_HANJA => events::VirtualKeyCode::Hanja,
ffi::VK_KANJI => events::VirtualKeyCode::Kanji,
ffi::VK_ESCAPE => events::VirtualKeyCode::Escape,
ffi::VK_CONVERT => events::VirtualKeyCode::Convert,
//ffi::VK_NONCONVERT => events::VirtualKeyCode::Nonconvert,
//ffi::VK_ACCEPT => events::VirtualKeyCode::Accept,
//ffi::VK_MODECHANGE => events::VirtualKeyCode::Modechange,
ffi::VK_SPACE => events::VirtualKeyCode::Space,
ffi::VK_PRIOR => events::VirtualKeyCode::PageUp,
ffi::VK_NEXT => events::VirtualKeyCode::PageDown,
ffi::VK_END => events::VirtualKeyCode::End,
ffi::VK_HOME => events::VirtualKeyCode::Home,
ffi::VK_LEFT => events::VirtualKeyCode::Left,
ffi::VK_UP => events::VirtualKeyCode::Up,
ffi::VK_RIGHT => events::VirtualKeyCode::Right,
ffi::VK_DOWN => events::VirtualKeyCode::Down,
//ffi::VK_SELECT => events::VirtualKeyCode::Select,
//ffi::VK_PRINT => events::VirtualKeyCode::Print,
//ffi::VK_EXECUTE => events::VirtualKeyCode::Execute,
ffi::VK_SNAPSHOT => events::VirtualKeyCode::Snapshot,
ffi::VK_INSERT => events::VirtualKeyCode::Insert,
ffi::VK_DELETE => events::VirtualKeyCode::Delete,
//ffi::VK_HELP => events::VirtualKeyCode::Help,
0x30 => events::VirtualKeyCode::Key0,
0x31 => events::VirtualKeyCode::Key1,
0x32 => events::VirtualKeyCode::Key2,
0x33 => events::VirtualKeyCode::Key3,
0x34 => events::VirtualKeyCode::Key4,
0x35 => events::VirtualKeyCode::Key5,
0x36 => events::VirtualKeyCode::Key6,
0x37 => events::VirtualKeyCode::Key7,
0x38 => events::VirtualKeyCode::Key8,
0x39 => events::VirtualKeyCode::Key9,
0x41 => events::VirtualKeyCode::A,
0x42 => events::VirtualKeyCode::B,
0x43 => events::VirtualKeyCode::C,
0x44 => events::VirtualKeyCode::D,
0x45 => events::VirtualKeyCode::E,
0x46 => events::VirtualKeyCode::F,
0x47 => events::VirtualKeyCode::G,
0x48 => events::VirtualKeyCode::H,
0x49 => events::VirtualKeyCode::I,
0x4A => events::VirtualKeyCode::J,
0x4B => events::VirtualKeyCode::K,
0x4C => events::VirtualKeyCode::L,
0x4D => events::VirtualKeyCode::M,
0x4E => events::VirtualKeyCode::N,
0x4F => events::VirtualKeyCode::O,
0x50 => events::VirtualKeyCode::P,
0x51 => events::VirtualKeyCode::Q,
0x52 => events::VirtualKeyCode::R,
0x53 => events::VirtualKeyCode::S,
0x54 => events::VirtualKeyCode::T,
0x55 => events::VirtualKeyCode::U,
0x56 => events::VirtualKeyCode::V,
0x57 => events::VirtualKeyCode::W,
0x58 => events::VirtualKeyCode::X,
0x59 => events::VirtualKeyCode::Y,
0x5A => events::VirtualKeyCode::Z,
//ffi::VK_LWIN => events::VirtualKeyCode::Lwin,
//ffi::VK_RWIN => events::VirtualKeyCode::Rwin,
ffi::VK_APPS => events::VirtualKeyCode::Apps,
ffi::VK_SLEEP => events::VirtualKeyCode::Sleep,
ffi::VK_NUMPAD0 => events::VirtualKeyCode::Numpad0,
ffi::VK_NUMPAD1 => events::VirtualKeyCode::Numpad1,
ffi::VK_NUMPAD2 => events::VirtualKeyCode::Numpad2,
ffi::VK_NUMPAD3 => events::VirtualKeyCode::Numpad3,
ffi::VK_NUMPAD4 => events::VirtualKeyCode::Numpad4,
ffi::VK_NUMPAD5 => events::VirtualKeyCode::Numpad5,
ffi::VK_NUMPAD6 => events::VirtualKeyCode::Numpad6,
ffi::VK_NUMPAD7 => events::VirtualKeyCode::Numpad7,
ffi::VK_NUMPAD8 => events::VirtualKeyCode::Numpad8,
ffi::VK_NUMPAD9 => events::VirtualKeyCode::Numpad9,
ffi::VK_MULTIPLY => events::VirtualKeyCode::Multiply,
ffi::VK_ADD => events::VirtualKeyCode::Add,
//ffi::VK_SEPARATOR => events::VirtualKeyCode::Separator,
ffi::VK_SUBTRACT => events::VirtualKeyCode::Subtract,
ffi::VK_DECIMAL => events::VirtualKeyCode::Decimal,
ffi::VK_DIVIDE => events::VirtualKeyCode::Divide,
ffi::VK_F1 => events::VirtualKeyCode::F1,
ffi::VK_F2 => events::VirtualKeyCode::F2,
ffi::VK_F3 => events::VirtualKeyCode::F3,
ffi::VK_F4 => events::VirtualKeyCode::F4,
ffi::VK_F5 => events::VirtualKeyCode::F5,
ffi::VK_F6 => events::VirtualKeyCode::F6,
ffi::VK_F7 => events::VirtualKeyCode::F7,
ffi::VK_F8 => events::VirtualKeyCode::F8,
ffi::VK_F9 => events::VirtualKeyCode::F9,
ffi::VK_F10 => events::VirtualKeyCode::F10,
ffi::VK_F11 => events::VirtualKeyCode::F11,
ffi::VK_F12 => events::VirtualKeyCode::F12,
ffi::VK_F13 => events::VirtualKeyCode::F13,
ffi::VK_F14 => events::VirtualKeyCode::F14,
ffi::VK_F15 => events::VirtualKeyCode::F15,
/*ffi::VK_F16 => events::VirtualKeyCode::F16,
ffi::VK_F17 => events::VirtualKeyCode::F17,
ffi::VK_F18 => events::VirtualKeyCode::F18,
ffi::VK_F19 => events::VirtualKeyCode::F19,
ffi::VK_F20 => events::VirtualKeyCode::F20,
ffi::VK_F21 => events::VirtualKeyCode::F21,
ffi::VK_F22 => events::VirtualKeyCode::F22,
ffi::VK_F23 => events::VirtualKeyCode::F23,
ffi::VK_F24 => events::VirtualKeyCode::F24,*/
ffi::VK_NUMLOCK => events::VirtualKeyCode::Numlock,
ffi::VK_SCROLL => events::VirtualKeyCode::Scroll,
/*ffi::VK_LSHIFT => events::VirtualKeyCode::Lshift,
ffi::VK_RSHIFT => events::VirtualKeyCode::Rshift,
ffi::VK_LCONTROL => events::VirtualKeyCode::Lcontrol,
ffi::VK_RCONTROL => events::VirtualKeyCode::Rcontrol,
ffi::VK_LMENU => events::VirtualKeyCode::Lmenu,
ffi::VK_RMENU => events::VirtualKeyCode::Rmenu,
ffi::VK_BROWSER_BACK => events::VirtualKeyCode::Browser_back,
ffi::VK_BROWSER_FORWARD => events::VirtualKeyCode::Browser_forward,
ffi::VK_BROWSER_REFRESH => events::VirtualKeyCode::Browser_refresh,
ffi::VK_BROWSER_STOP => events::VirtualKeyCode::Browser_stop,
ffi::VK_BROWSER_SEARCH => events::VirtualKeyCode::Browser_search,
ffi::VK_BROWSER_FAVORITES => events::VirtualKeyCode::Browser_favorites,
ffi::VK_BROWSER_HOME => events::VirtualKeyCode::Browser_home,
ffi::VK_VOLUME_MUTE => events::VirtualKeyCode::Volume_mute,
ffi::VK_VOLUME_DOWN => events::VirtualKeyCode::Volume_down,
ffi::VK_VOLUME_UP => events::VirtualKeyCode::Volume_up,
ffi::VK_MEDIA_NEXT_TRACK => events::VirtualKeyCode::Media_next_track,
ffi::VK_MEDIA_PREV_TRACK => events::VirtualKeyCode::Media_prev_track,
ffi::VK_MEDIA_STOP => events::VirtualKeyCode::Media_stop,
ffi::VK_MEDIA_PLAY_PAUSE => events::VirtualKeyCode::Media_play_pause,
ffi::VK_LAUNCH_MAIL => events::VirtualKeyCode::Launch_mail,
ffi::VK_LAUNCH_MEDIA_SELECT => events::VirtualKeyCode::Launch_media_select,
ffi::VK_LAUNCH_APP1 => events::VirtualKeyCode::Launch_app1,
ffi::VK_LAUNCH_APP2 => events::VirtualKeyCode::Launch_app2,
ffi::VK_OEM_1 => events::VirtualKeyCode::Oem_1,
ffi::VK_OEM_PLUS => events::VirtualKeyCode::Oem_plus,
ffi::VK_OEM_COMMA => events::VirtualKeyCode::Oem_comma,
ffi::VK_OEM_MINUS => events::VirtualKeyCode::Oem_minus,
ffi::VK_OEM_PERIOD => events::VirtualKeyCode::Oem_period,
ffi::VK_OEM_2 => events::VirtualKeyCode::Oem_2,
ffi::VK_OEM_3 => events::VirtualKeyCode::Oem_3,
ffi::VK_OEM_4 => events::VirtualKeyCode::Oem_4,
ffi::VK_OEM_5 => events::VirtualKeyCode::Oem_5,
ffi::VK_OEM_6 => events::VirtualKeyCode::Oem_6,
ffi::VK_OEM_7 => events::VirtualKeyCode::Oem_7,
ffi::VK_OEM_8 => events::VirtualKeyCode::Oem_8,
ffi::VK_OEM_102 => events::VirtualKeyCode::Oem_102,
ffi::VK_PROCESSKEY => events::VirtualKeyCode::Processkey,
ffi::VK_PACKET => events::VirtualKeyCode::Packet,
ffi::VK_ATTN => events::VirtualKeyCode::Attn,
ffi::VK_CRSEL => events::VirtualKeyCode::Crsel,
ffi::VK_EXSEL => events::VirtualKeyCode::Exsel,
ffi::VK_EREOF => events::VirtualKeyCode::Ereof,
ffi::VK_PLAY => events::VirtualKeyCode::Play,
ffi::VK_ZOOM => events::VirtualKeyCode::Zoom,
ffi::VK_NONAME => events::VirtualKeyCode::Noname,
ffi::VK_PA1 => events::VirtualKeyCode::Pa1,
ffi::VK_OEM_CLEAR => events::VirtualKeyCode::Oem_clear,*/
_ => return None
})
}

View file

@ -6,7 +6,8 @@ use std::sync::atomic::AtomicBool;
use std::ptr;
use super::{event, ffi};
use super::Window;
use {CreationError, OsError, Event};
use {CreationError, Event};
use CreationError::OsError;
/// Stores the current window and its events dispatcher.
///
@ -422,7 +423,7 @@ extern "stdcall" fn callback(window: ffi::HWND, msg: ffi::UINT,
{
match msg {
ffi::WM_DESTROY => {
use Closed;
use events::Event::Closed;
match WINDOW.get() {
None => (),
@ -444,7 +445,7 @@ extern "stdcall" fn callback(window: ffi::HWND, msg: ffi::UINT,
},
ffi::WM_SIZE => {
use Resized;
use events::Event::Resized;
let w = ffi::LOWORD(lparam as ffi::DWORD) as uint;
let h = ffi::HIWORD(lparam as ffi::DWORD) as uint;
send_event(window, Resized(w, h));
@ -452,7 +453,7 @@ extern "stdcall" fn callback(window: ffi::HWND, msg: ffi::UINT,
},
ffi::WM_MOVE => {
use events::Moved;
use events::Event::Moved;
let x = ffi::LOWORD(lparam as ffi::DWORD) as i16 as int;
let y = ffi::HIWORD(lparam as ffi::DWORD) as i16 as int;
send_event(window, Moved(x, y));
@ -461,14 +462,14 @@ extern "stdcall" fn callback(window: ffi::HWND, msg: ffi::UINT,
ffi::WM_CHAR => {
use std::mem;
use events::ReceivedCharacter;
use events::Event::ReceivedCharacter;
let chr: char = unsafe { mem::transmute(wparam as u32) };
send_event(window, ReceivedCharacter(chr));
0
},
ffi::WM_MOUSEMOVE => {
use MouseMoved;
use events::Event::MouseMoved;
let x = ffi::GET_X_LPARAM(lparam) as int;
let y = ffi::GET_Y_LPARAM(lparam) as int;
@ -479,7 +480,7 @@ extern "stdcall" fn callback(window: ffi::HWND, msg: ffi::UINT,
},
ffi::WM_MOUSEWHEEL => {
use events::MouseWheel;
use events::Event::MouseWheel;
let value = (wparam >> 16) as i16;
let value = value as i32;
@ -490,7 +491,8 @@ extern "stdcall" fn callback(window: ffi::HWND, msg: ffi::UINT,
},
ffi::WM_KEYDOWN => {
use events::{KeyboardInput, Pressed};
use events::Event::KeyboardInput;
use events::ElementState::Pressed;
let scancode = ((lparam >> 16) & 0xff) as u8;
let vkey = event::vkeycode_to_element(wparam);
send_event(window, KeyboardInput(Pressed, scancode, vkey));
@ -498,7 +500,8 @@ extern "stdcall" fn callback(window: ffi::HWND, msg: ffi::UINT,
},
ffi::WM_KEYUP => {
use events::{KeyboardInput, Released};
use events::Event::KeyboardInput;
use events::ElementState::Released;
let scancode = ((lparam >> 16) & 0xff) as u8;
let vkey = event::vkeycode_to_element(wparam);
send_event(window, KeyboardInput(Released, scancode, vkey));
@ -506,49 +509,61 @@ extern "stdcall" fn callback(window: ffi::HWND, msg: ffi::UINT,
},
ffi::WM_LBUTTONDOWN => {
use events::{Pressed, MouseInput, LeftMouseButton};
use events::Event::MouseInput;
use events::MouseButton::LeftMouseButton;
use events::ElementState::Pressed;
send_event(window, MouseInput(Pressed, LeftMouseButton));
0
},
ffi::WM_LBUTTONUP => {
use events::{Released, MouseInput, LeftMouseButton};
use events::Event::MouseInput;
use events::MouseButton::LeftMouseButton;
use events::ElementState::Released;
send_event(window, MouseInput(Released, LeftMouseButton));
0
},
ffi::WM_RBUTTONDOWN => {
use events::{Pressed, MouseInput, RightMouseButton};
use events::Event::MouseInput;
use events::MouseButton::RightMouseButton;
use events::ElementState::Pressed;
send_event(window, MouseInput(Pressed, RightMouseButton));
0
},
ffi::WM_RBUTTONUP => {
use events::{Released, MouseInput, RightMouseButton};
use events::Event::MouseInput;
use events::MouseButton::RightMouseButton;
use events::ElementState::Released;
send_event(window, MouseInput(Released, RightMouseButton));
0
},
ffi::WM_MBUTTONDOWN => {
use events::{Pressed, MouseInput, MiddleMouseButton};
use events::Event::MouseInput;
use events::MouseButton::MiddleMouseButton;
use events::ElementState::Pressed;
send_event(window, MouseInput(Pressed, MiddleMouseButton));
0
},
ffi::WM_MBUTTONUP => {
use events::{Released, MouseInput, MiddleMouseButton};
use events::Event::MouseInput;
use events::MouseButton::MiddleMouseButton;
use events::ElementState::Released;
send_event(window, MouseInput(Released, MiddleMouseButton));
0
},
ffi::WM_SETFOCUS => {
use events::Focused;
use events::Event::Focused;
send_event(window, Focused(true));
0
},
ffi::WM_KILLFOCUS => {
use events::Focused;
use events::Event::Focused;
send_event(window, Focused(false));
0
},

View file

@ -183,7 +183,7 @@ impl Window {
}
// if one of the received events is `Closed`, setting `is_closed` to true
if events.iter().find(|e| match e { &&::Closed => true, _ => false }).is_some() {
if events.iter().any(|e| match e { &::events::Event::Closed => true, _ => false }) {
use std::sync::atomic::Relaxed;
self.is_closed.store(true, Relaxed);
}
@ -198,7 +198,7 @@ impl Window {
Ok(ev) => {
// if the received event is `Closed`, setting `is_closed` to true
match ev {
::Closed => {
::events::Event::Closed => {
use std::sync::atomic::Relaxed;
self.is_closed.store(true, Relaxed);
},

View file

@ -1,5 +1,6 @@
use HeadlessRendererBuilder;
use {CreationError, OsError};
use CreationError;
use CreationError::OsError;
use libc;
use std::{mem, ptr};
use super::ffi;

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,6 @@
use {Event, WindowBuilder};
use {CreationError, OsError};
use CreationError;
use CreationError::OsError;
use libc;
use std::{mem, ptr};
use std::cell::Cell;
@ -375,7 +376,7 @@ impl Window {
},
ffi::ClientMessage => {
use Closed;
use events::Event::Closed;
use std::sync::atomic::Relaxed;
let client_msg: &ffi::XClientMessageEvent = unsafe { mem::transmute(&xev) };
@ -387,7 +388,7 @@ impl Window {
},
ffi::ConfigureNotify => {
use Resized;
use events::Event::Resized;
let cfg_event: &ffi::XConfigureEvent = unsafe { mem::transmute(&xev) };
let (current_width, current_height) = self.current_size.get();
if current_width != cfg_event.width || current_height != cfg_event.height {
@ -397,13 +398,14 @@ impl Window {
},
ffi::MotionNotify => {
use MouseMoved;
use events::Event::MouseMoved;
let event: &ffi::XMotionEvent = unsafe { mem::transmute(&xev) };
events.push(MouseMoved((event.x as int, event.y as int)));
},
ffi::KeyPress | ffi::KeyRelease => {
use {KeyboardInput, Pressed, Released, ReceivedCharacter};
use events::Event::{KeyboardInput, ReceivedCharacter};
use events::ElementState::{Pressed, Released};
let event: &mut ffi::XKeyEvent = unsafe { mem::transmute(&xev) };
if event.type_ == ffi::KeyPress {
@ -440,8 +442,10 @@ impl Window {
},
ffi::ButtonPress | ffi::ButtonRelease => {
use {MouseInput, MouseWheel, Pressed, Released};
use {LeftMouseButton, RightMouseButton, MiddleMouseButton};
use events::Event::{MouseInput, MouseWheel};
use events::ElementState::{Pressed, Released};
use events::MouseButton::{LeftMouseButton, RightMouseButton, MiddleMouseButton};
let event: &ffi::XButtonEvent = unsafe { mem::transmute(&xev) };
let state = if xev.type_ == ffi::ButtonPress { Pressed } else { Released };