borrow input types from termwiz

This commit is contained in:
Wez Furlong committed 2019-09-15 19:09:08 -07:00
1 parent 7cd92a92c8
commit bed8664617
3 files changed
+138

No files matched your search

+1
View File
@@ -8,6 +8,7 @@ description = "Cross platform window setup and render"
license = "MIT"
[dependencies]
bitflags = "1.0"
failure = "0.1"
failure_derive = "0.1"
lazy_static = "1.3"
+135
View File
@@ -0,0 +1,135 @@
use bitflags::*;
/// Which key is pressed. Not all of these are probable to appear
/// on most systems. A lot of this list is @wez trawling docs and
/// making an entry for things that might be possible in this first pass.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum KeyCode {
/// The decoded unicode character
Char(char),
Hyper,
Super,
Meta,
/// Ctrl-break on windows
Cancel,
Backspace,
Tab,
Clear,
Enter,
Shift,
Escape,
LeftShift,
RightShift,
Control,
LeftControl,
RightControl,
Alt,
LeftAlt,
RightAlt,
Menu,
LeftMenu,
RightMenu,
Pause,
CapsLock,
PageUp,
PageDown,
End,
Home,
LeftArrow,
RightArrow,
UpArrow,
DownArrow,
Select,
Print,
Execute,
PrintScreen,
Insert,
Delete,
Help,
LeftWindows,
RightWindows,
Applications,
Sleep,
Numpad0,
Numpad1,
Numpad2,
Numpad3,
Numpad4,
Numpad5,
Numpad6,
Numpad7,
Numpad8,
Numpad9,
Multiply,
Add,
Separator,
Subtract,
Decimal,
Divide,
/// F1-F24 are possible
Function(u8),
NumLock,
ScrollLock,
BrowserBack,
BrowserForward,
BrowserRefresh,
BrowserStop,
BrowserSearch,
BrowserFavorites,
BrowserHome,
VolumeMute,
VolumeDown,
VolumeUp,
MediaNextTrack,
MediaPrevTrack,
MediaStop,
MediaPlayPause,
ApplicationLeftArrow,
ApplicationRightArrow,
ApplicationUpArrow,
ApplicationDownArrow,
}
bitflags! {
#[derive(Default)]
pub struct Modifiers: u8 {
const NONE = 0;
const SHIFT = 1<<1;
const ALT = 1<<2;
const CTRL = 1<<3;
const SUPER = 1<<4;
}
}
bitflags! {
#[derive(Default)]
pub struct MouseButtons: u8 {
const NONE = 0;
const LEFT = 1<<1;
const RIGHT = 1<<2;
const MIDDLE = 1<<3;
const VERT_WHEEL = 1<<4;
const HORZ_WHEEL = 1<<5;
/// if set then the wheel movement was in the positive
/// direction, else the negative direction
const WHEEL_POSITIVE = 1<<6;
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct MouseEvent {
pub x: u16,
pub y: u16,
pub mouse_buttons: MouseButtons,
pub modifiers: Modifiers,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct KeyEvent {
/// Which key was pressed
pub key: KeyCode,
/// Which modifiers are down
pub modifiers: Modifiers,
}
+2
View File
@@ -1,10 +1,12 @@
pub mod bitmaps;
pub mod color;
pub mod input;
pub mod os;
pub use bitmaps::BitmapImage;
pub use color::Color;
pub use input::*;
pub use os::*;
/// Compositing operator.