winit-sonoma-fix/src/events.rs

214 lines
3.3 KiB
Rust
Raw Normal View History

2014-07-27 20:59:45 +10:00
#[deriving(Clone,Show)]
pub enum Event {
/// The size of the window has changed.
2014-07-30 21:11:49 +10:00
Resized(uint, uint),
2014-07-27 20:59:45 +10:00
2014-07-28 04:08:31 +10:00
/// The position of the window has changed.
Moved(int, int),
2014-07-28 04:08:31 +10:00
2014-07-27 20:59:45 +10:00
/// The window has been closed.
Closed,
2014-07-28 01:06:03 +10:00
/// The window received a unicode character.
ReceivedCharacter(char),
2014-07-27 20:59:45 +10:00
/// The window gained or lost focus.
2014-10-11 21:04:48 +11:00
///
2014-07-27 20:59:45 +10:00
/// The parameter is true if the window has gained focus, and false if it has lost focus.
Focused(bool),
2014-08-14 01:04:57 +10:00
/// An event from the keyboard has been received.
KeyboardInput(ElementState, ScanCode, Option<VirtualKeyCode>, KeyModifiers),
/// The cursor has moved on the window.
2014-10-11 21:04:48 +11:00
///
2014-08-14 01:04:57 +10:00
/// The parameter are the (x,y) coords in pixels relative to the top-left corner of the window.
MouseMoved((int, int)),
/// A positive value indicates that the wheel was rotated forward, away from the user;
/// a negative value indicates that the wheel was rotated backward, toward the user.
MouseWheel(i32),
/// An event from the mouse has been received.
MouseInput(ElementState, MouseButton),
}
pub type ScanCode = u8;
bitflags!(
#[deriving(Show)]
flags KeyModifiers: u8 {
2014-10-11 21:38:34 +11:00
const LEFT_CONTROL_MODIFIER = 1,
const RIGHT_CONTROL_MODIFIER = 2,
const LEFT_SHIFT_MODIFIER = 4,
const RIGHT_SHIFT_MODIFIER = 8,
const LEFT_ALT_MODIFIER = 16,
const RIGHT_ALT_MODIFIER = 32,
const NUM_LOCK_MODIFIER = 64,
const CAPS_LOCK_MODIFIER = 128
2014-08-14 01:04:57 +10:00
}
)
#[deriving(Show, Hash, PartialEq, Eq, Clone)]
pub enum ElementState {
Pressed,
Released,
}
2014-07-28 01:06:03 +10:00
2014-08-14 01:04:57 +10:00
#[deriving(Show, Hash, PartialEq, Eq, Clone)]
pub enum MouseButton {
LeftMouseButton,
RightMouseButton,
MiddleMouseButton,
OtherMouseButton(u8),
2014-07-28 01:06:03 +10:00
}
2014-08-14 01:04:57 +10:00
#[deriving(Show, Hash, PartialEq, Eq, Clone)]
pub enum VirtualKeyCode {
2014-07-28 01:06:03 +10:00
Key0,
Key1,
Key2,
Key3,
Key4,
Key5,
Key6,
Key7,
Key8,
Key9,
A,
AbntC1,
AbntC2,
Add,
Apostrophe,
Apps,
At,
Ax,
B,
Back,
Backslash,
C,
Calculator,
Capital,
Colon,
Comma,
Convert,
D,
Decimal,
Delete,
Divide,
Down,
E,
End,
Equals,
Escape,
F,
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
F13,
F14,
F15,
G,
Grave,
H,
Home,
I,
Insert,
J,
K,
Kana,
Kanji,
L,
LBracket,
2014-07-28 01:06:03 +10:00
LControl,
Left,
LMenu,
LShift,
LWin,
M,
Mail,
MediaSelect,
MediaStop,
Minus,
Multiply,
Mute,
MyComputer,
N,
NextTrack,
NoConvert,
Numlock,
Numpad0,
Numpad1,
Numpad2,
Numpad3,
Numpad4,
Numpad5,
Numpad6,
Numpad7,
Numpad8,
Numpad9,
NumpadComma,
NumpadEnter,
NumpadEquals,
O,
OEM102,
P,
2014-08-14 01:04:57 +10:00
PageDown,
PageUp,
2014-07-28 01:06:03 +10:00
Pause,
Period,
Playpause,
Power,
Prevtrack,
Q,
R,
RBracket,
RControl,
Return,
Right,
RMenu,
RShift,
RWin,
S,
Scroll,
Semicolon,
Slash,
Sleep,
Snapshot,
Space,
Stop,
Subtract,
Sysrq,
T,
Tab,
U,
Underline,
Unlabeled,
Up,
V,
VolumeDown,
VolumeUp,
W,
Wake,
Webback,
WebFavorites,
WebForward,
WebHome,
WebRefresh,
WebSearch,
WebStop,
X,
Y,
Yen,
Z
2014-07-27 20:59:45 +10:00
}