use num::FromPrimitive;
use num::ToPrimitive;
use std::default::Default;
use std::cmp::Ordering;
use Input;
use Button;
bitflags!(
#[allow(missing_docs)]
#[derive(RustcDecodable, RustcEncodable)]
flags ModifierKey: u8 {
const NO_MODIFIER = 0b00000000,
const CTRL = 0b00000001,
const SHIFT = 0b00000010,
const ALT = 0b00000100,
const GUI = 0b00001000,
const CTRL_SHIFT = CTRL.bits
| SHIFT.bits,
const CTRL_ALT = CTRL.bits
| ALT.bits,
const CTRL_GUI = CTRL.bits
| GUI.bits,
const CTRL_SHIFT_ALT = CTRL.bits
| SHIFT.bits
| ALT.bits,
const CTRL_SHIFT_GUI = CTRL.bits
| SHIFT.bits
| GUI.bits,
const CTRL_SHIFT_ALT_GUI = CTRL.bits
| SHIFT.bits
| ALT.bits
| GUI.bits,
const SHIFT_ALT = SHIFT.bits
| ALT.bits,
const SHIFT_GUI = SHIFT.bits
| GUI.bits,
const SHIFT_ALT_GUI = SHIFT.bits
| ALT.bits
| GUI.bits,
const ALT_GUI = ALT.bits
| GUI.bits
}
);
impl ModifierKey {
pub fn handle_input(&mut self, input: &Input) {
match *input {
Input::Press(Button::Keyboard(Key::LCtrl))
| Input::Press(Button::Keyboard(Key::RCtrl)) => self.insert(CTRL),
Input::Release(Button::Keyboard(Key::LCtrl))
| Input::Release(Button::Keyboard(Key::RCtrl)) => self.remove(CTRL),
Input::Press(Button::Keyboard(Key::LShift))
| Input::Press(Button::Keyboard(Key::RShift)) => self.insert(SHIFT),
Input::Release(Button::Keyboard(Key::LShift))
| Input::Release(Button::Keyboard(Key::RShift)) => self.remove(SHIFT),
Input::Press(Button::Keyboard(Key::LAlt))
| Input::Press(Button::Keyboard(Key::RAlt)) => self.insert(ALT),
Input::Release(Button::Keyboard(Key::LAlt))
| Input::Release(Button::Keyboard(Key::RAlt)) => self.remove(ALT),
Input::Press(Button::Keyboard(Key::LGui))
| Input::Press(Button::Keyboard(Key::RGui)) => self.insert(GUI),
Input::Release(Button::Keyboard(Key::LGui))
| Input::Release(Button::Keyboard(Key::RGui)) => self.remove(GUI),
Input::Focus(false) => *self = NO_MODIFIER,
_ => {}
}
}
}
impl Default for ModifierKey {
fn default() -> ModifierKey { NO_MODIFIER }
}
#[allow(missing_docs)]
#[derive(Copy, Clone, RustcDecodable, RustcEncodable, Debug, Hash)]
pub enum Key {
Unknown = 0x00,
Backspace = 0x08,
Tab = 0x09,
Return = 0x0D,
Escape = 0x1B,
Space = 0x20,
Exclaim = 0x21,
Quotedbl = 0x22,
Hash = 0x23,
Dollar = 0x24,
Percent = 0x25,
Ampersand = 0x26,
Quote = 0x27,
LeftParen = 0x28,
RightParen = 0x29,
Asterisk = 0x2A,
Plus = 0x2B,
Comma = 0x2C,
Minus = 0x2D,
Period = 0x2E,
Slash = 0x2F,
D0 = 0x30,
D1 = 0x31,
D2 = 0x32,
D3 = 0x33,
D4 = 0x34,
D5 = 0x35,
D6 = 0x36,
D7 = 0x37,
D8 = 0x38,
D9 = 0x39,
Colon = 0x3A,
Semicolon = 0x3B,
Less = 0x3C,
Equals = 0x3D,
Greater = 0x3E,
Question = 0x3F,
At = 0x40,
LeftBracket = 0x5B,
Backslash = 0x5C,
RightBracket = 0x5D,
Caret = 0x5E,
Underscore = 0x5F,
Backquote = 0x60,
A = 0x61,
B = 0x62,
C = 0x63,
D = 0x64,
E = 0x65,
F = 0x66,
G = 0x67,
H = 0x68,
I = 0x69,
J = 0x6A,
K = 0x6B,
L = 0x6C,
M = 0x6D,
N = 0x6E,
O = 0x6F,
P = 0x70,
Q = 0x71,
R = 0x72,
S = 0x73,
T = 0x74,
U = 0x75,
V = 0x76,
W = 0x77,
X = 0x78,
Y = 0x79,
Z = 0x7A,
Delete = 0x7F,
CapsLock = 0x40000039,
F1 = 0x4000003A,
F2 = 0x4000003B,
F3 = 0x4000003C,
F4 = 0x4000003D,
F5 = 0x4000003E,
F6 = 0x4000003F,
F7 = 0x40000040,
F8 = 0x40000041,
F9 = 0x40000042,
F10 = 0x40000043,
F11 = 0x40000044,
F12 = 0x40000045,
PrintScreen = 0x40000046,
ScrollLock = 0x40000047,
Pause = 0x40000048,
Insert = 0x40000049,
Home = 0x4000004A,
PageUp = 0x4000004B,
End = 0x4000004D,
PageDown = 0x4000004E,
Right = 0x4000004F,
Left = 0x40000050,
Down = 0x40000051,
Up = 0x40000052,
NumLockClear = 0x40000053,
NumPadDivide = 0x40000054,
NumPadMultiply = 0x40000055,
NumPadMinus = 0x40000056,
NumPadPlus = 0x40000057,
NumPadEnter = 0x40000058,
NumPad1 = 0x40000059,
NumPad2 = 0x4000005A,
NumPad3 = 0x4000005B,
NumPad4 = 0x4000005C,
NumPad5 = 0x4000005D,
NumPad6 = 0x4000005E,
NumPad7 = 0x4000005F,
NumPad8 = 0x40000060,
NumPad9 = 0x40000061,
NumPad0 = 0x40000062,
NumPadPeriod = 0x40000063,
Application = 0x40000065,
Power = 0x40000066,
NumPadEquals = 0x40000067,
F13 = 0x40000068,
F14 = 0x40000069,
F15 = 0x4000006A,
F16 = 0x4000006B,
F17 = 0x4000006C,
F18 = 0x4000006D,
F19 = 0x4000006E,
F20 = 0x4000006F,
F21 = 0x40000070,
F22 = 0x40000071,
F23 = 0x40000072,
F24 = 0x40000073,
Execute = 0x40000074,
Help = 0x40000075,
Menu = 0x40000076,
Select = 0x40000077,
Stop = 0x40000078,
Again = 0x40000079,
Undo = 0x4000007A,
Cut = 0x4000007B,
Copy = 0x4000007C,
Paste = 0x4000007D,
Find = 0x4000007E,
Mute = 0x4000007F,
VolumeUp = 0x40000080,
VolumeDown = 0x40000081,
NumPadComma = 0x40000085,
NumPadEqualsAS400 = 0x40000086,
AltErase = 0x40000099,
Sysreq = 0x4000009A,
Cancel = 0x4000009B,
Clear = 0x4000009C,
Prior = 0x4000009D,
Return2 = 0x4000009E,
Separator = 0x4000009F,
Out = 0x400000A0,
Oper = 0x400000A1,
ClearAgain = 0x400000A2,
CrSel = 0x400000A3,
ExSel = 0x400000A4,
NumPad00 = 0x400000B0,
NumPad000 = 0x400000B1,
ThousandsSeparator = 0x400000B2,
DecimalSeparator = 0x400000B3,
CurrencyUnit = 0x400000B4,
CurrencySubUnit = 0x400000B5,
NumPadLeftParen = 0x400000B6,
NumPadRightParen = 0x400000B7,
NumPadLeftBrace = 0x400000B8,
NumPadRightBrace = 0x400000B9,
NumPadTab = 0x400000BA,
NumPadBackspace = 0x400000BB,
NumPadA = 0x400000BC,
NumPadB = 0x400000BD,
NumPadC = 0x400000BE,
NumPadD = 0x400000BF,
NumPadE = 0x400000C0,
NumPadF = 0x400000C1,
NumPadXor = 0x400000C2,
NumPadPower = 0x400000C3,
NumPadPercent = 0x400000C4,
NumPadLess = 0x400000C5,
NumPadGreater = 0x400000C6,
NumPadAmpersand = 0x400000C7,
NumPadDblAmpersand = 0x400000C8,
NumPadVerticalBar = 0x400000C9,
NumPadDblVerticalBar = 0x400000CA,
NumPadColon = 0x400000CB,
NumPadHash = 0x400000CC,
NumPadSpace = 0x400000CD,
NumPadAt = 0x400000CE,
NumPadExclam = 0x400000CF,
NumPadMemStore = 0x400000D0,
NumPadMemRecall = 0x400000D1,
NumPadMemClear = 0x400000D2,
NumPadMemAdd = 0x400000D3,
NumPadMemSubtract = 0x400000D4,
NumPadMemMultiply = 0x400000D5,
NumPadMemDivide = 0x400000D6,
NumPadPlusMinus = 0x400000D7,
NumPadClear = 0x400000D8,
NumPadClearEntry = 0x400000D9,
NumPadBinary = 0x400000DA,
NumPadOctal = 0x400000DB,
NumPadDecimal = 0x400000DC,
NumPadHexadecimal = 0x400000DD,
LCtrl = 0x400000E0,
LShift = 0x400000E1,
LAlt = 0x400000E2,
LGui = 0x400000E3,
RCtrl = 0x400000E4,
RShift = 0x400000E5,
RAlt = 0x400000E6,
RGui = 0x400000E7,
Mode = 0x40000101,
AudioNext = 0x40000102,
AudioPrev = 0x40000103,
AudioStop = 0x40000104,
AudioPlay = 0x40000105,
AudioMute = 0x40000106,
MediaSelect = 0x40000107,
Www = 0x40000108,
Mail = 0x40000109,
Calculator = 0x4000010A,
Computer = 0x4000010B,
AcSearch = 0x4000010C,
AcHome = 0x4000010D,
AcBack = 0x4000010E,
AcForward = 0x4000010F,
AcStop = 0x40000110,
AcRefresh = 0x40000111,
AcBookmarks = 0x40000112,
BrightnessDown = 0x40000113,
BrightnessUp = 0x40000114,
DisplaySwitch = 0x40000115,
KbdIllumToggle = 0x40000116,
KbdIllumDown = 0x40000117,
KbdIllumUp = 0x40000118,
Eject = 0x40000119,
Sleep = 0x4000011A,
}
impl PartialEq for Key {
fn eq(&self, other: &Key) -> bool {
return (*self as i32) == (*other as i32);
}
}
impl Eq for Key {}
impl PartialOrd for Key {
fn partial_cmp(&self, other: &Key) -> Option<Ordering> {
let (s_id, o_id) = (*self as i32, *other as i32);
s_id.partial_cmp(&o_id)
}
}
impl Ord for Key {
fn cmp(&self, other: &Key) -> Ordering {
let (s_id, o_id) = (*self as i32, *other as i32);
s_id.cmp(&o_id)
}
}
impl Key {
#[inline(always)]
pub fn code(&self) -> i32 {
*self as i32
}
}
impl ToPrimitive for Key {
#[inline(always)]
fn to_i64(&self) -> Option<i64> {
Some(self.code() as i64)
}
#[inline(always)]
fn to_u64(&self) -> Option<u64> {
Some(self.code() as u64)
}
#[inline(always)]
fn to_isize(&self) -> Option<isize> {
Some(self.code() as isize)
}
}
impl FromPrimitive for Key {
fn from_u64(n: u64) -> Option<Key> {
match n {
0x00 => Some(Key::Unknown),
0x08 => Some(Key::Backspace),
0x09 => Some(Key::Tab),
0x0D => Some(Key::Return),
0x1B => Some(Key::Escape),
0x20 => Some(Key::Space),
0x21 => Some(Key::Exclaim),
0x22 => Some(Key::Quotedbl),
0x23 => Some(Key::Hash),
0x24 => Some(Key::Dollar),
0x25 => Some(Key::Percent),
0x26 => Some(Key::Ampersand),
0x27 => Some(Key::Quote),
0x28 => Some(Key::LeftParen),
0x29 => Some(Key::RightParen),
0x2A => Some(Key::Asterisk),
0x2B => Some(Key::Plus),
0x2C => Some(Key::Comma),
0x2D => Some(Key::Minus),
0x2E => Some(Key::Period),
0x2F => Some(Key::Slash),
0x30 => Some(Key::D0),
0x31 => Some(Key::D1),
0x32 => Some(Key::D2),
0x33 => Some(Key::D3),
0x34 => Some(Key::D4),
0x35 => Some(Key::D5),
0x36 => Some(Key::D6),
0x37 => Some(Key::D7),
0x38 => Some(Key::D8),
0x39 => Some(Key::D9),
0x3A => Some(Key::Colon),
0x3B => Some(Key::Semicolon),
0x3C => Some(Key::Less),
0x3D => Some(Key::Equals),
0x3E => Some(Key::Greater),
0x3F => Some(Key::Question),
0x40 => Some(Key::At),
0x5B => Some(Key::LeftBracket),
0x5C => Some(Key::Backslash),
0x5D => Some(Key::RightBracket),
0x5E => Some(Key::Caret),
0x5F => Some(Key::Underscore),
0x60 => Some(Key::Backquote),
0x61 => Some(Key::A),
0x62 => Some(Key::B),
0x63 => Some(Key::C),
0x64 => Some(Key::D),
0x65 => Some(Key::E),
0x66 => Some(Key::F),
0x67 => Some(Key::G),
0x68 => Some(Key::H),
0x69 => Some(Key::I),
0x6A => Some(Key::J),
0x6B => Some(Key::K),
0x6C => Some(Key::L),
0x6D => Some(Key::M),
0x6E => Some(Key::N),
0x6F => Some(Key::O),
0x70 => Some(Key::P),
0x71 => Some(Key::Q),
0x72 => Some(Key::R),
0x73 => Some(Key::S),
0x74 => Some(Key::T),
0x75 => Some(Key::U),
0x76 => Some(Key::V),
0x77 => Some(Key::W),
0x78 => Some(Key::X),
0x79 => Some(Key::Y),
0x7A => Some(Key::Z),
0x7F => Some(Key::Delete),
0x40000039 => Some(Key::CapsLock),
0x4000003A => Some(Key::F1),
0x4000003B => Some(Key::F2),
0x4000003C => Some(Key::F3),
0x4000003D => Some(Key::F4),
0x4000003E => Some(Key::F5),
0x4000003F => Some(Key::F6),
0x40000040 => Some(Key::F7),
0x40000041 => Some(Key::F8),
0x40000042 => Some(Key::F9),
0x40000043 => Some(Key::F10),
0x40000044 => Some(Key::F11),
0x40000045 => Some(Key::F12),
0x40000046 => Some(Key::PrintScreen),
0x40000047 => Some(Key::ScrollLock),
0x40000048 => Some(Key::Pause),
0x40000049 => Some(Key::Insert),
0x4000004A => Some(Key::Home),
0x4000004B => Some(Key::PageUp),
0x4000004D => Some(Key::End),
0x4000004E => Some(Key::PageDown),
0x4000004F => Some(Key::Right),
0x40000050 => Some(Key::Left),
0x40000051 => Some(Key::Down),
0x40000052 => Some(Key::Up),
0x40000053 => Some(Key::NumLockClear),
0x40000054 => Some(Key::NumPadDivide),
0x40000055 => Some(Key::NumPadMultiply),
0x40000056 => Some(Key::NumPadMinus),
0x40000057 => Some(Key::NumPadPlus),
0x40000058 => Some(Key::NumPadEnter),
0x40000059 => Some(Key::NumPad1),
0x4000005A => Some(Key::NumPad2),
0x4000005B => Some(Key::NumPad3),
0x4000005C => Some(Key::NumPad4),
0x4000005D => Some(Key::NumPad5),
0x4000005E => Some(Key::NumPad6),
0x4000005F => Some(Key::NumPad7),
0x40000060 => Some(Key::NumPad8),
0x40000061 => Some(Key::NumPad9),
0x40000062 => Some(Key::NumPad0),
0x40000063 => Some(Key::NumPadPeriod),
0x40000065 => Some(Key::Application),
0x40000066 => Some(Key::Power),
0x40000067 => Some(Key::NumPadEquals),
0x40000068 => Some(Key::F13),
0x40000069 => Some(Key::F14),
0x4000006A => Some(Key::F15),
0x4000006B => Some(Key::F16),
0x4000006C => Some(Key::F17),
0x4000006D => Some(Key::F18),
0x4000006E => Some(Key::F19),
0x4000006F => Some(Key::F20),
0x40000070 => Some(Key::F21),
0x40000071 => Some(Key::F22),
0x40000072 => Some(Key::F23),
0x40000073 => Some(Key::F24),
0x40000074 => Some(Key::Execute),
0x40000075 => Some(Key::Help),
0x40000076 => Some(Key::Menu),
0x40000077 => Some(Key::Select),
0x40000078 => Some(Key::Stop),
0x40000079 => Some(Key::Again),
0x4000007A => Some(Key::Undo),
0x4000007B => Some(Key::Cut),
0x4000007C => Some(Key::Copy),
0x4000007D => Some(Key::Paste),
0x4000007E => Some(Key::Find),
0x4000007F => Some(Key::Mute),
0x40000080 => Some(Key::VolumeUp),
0x40000081 => Some(Key::VolumeDown),
0x40000085 => Some(Key::NumPadComma),
0x40000086 => Some(Key::NumPadEqualsAS400),
0x40000099 => Some(Key::AltErase),
0x4000009A => Some(Key::Sysreq),
0x4000009B => Some(Key::Cancel),
0x4000009C => Some(Key::Clear),
0x4000009D => Some(Key::Prior),
0x4000009E => Some(Key::Return2),
0x4000009F => Some(Key::Separator),
0x400000A0 => Some(Key::Out),
0x400000A1 => Some(Key::Oper),
0x400000A2 => Some(Key::ClearAgain),
0x400000A3 => Some(Key::CrSel),
0x400000A4 => Some(Key::ExSel),
0x400000B0 => Some(Key::NumPad00),
0x400000B1 => Some(Key::NumPad000),
0x400000B2 => Some(Key::ThousandsSeparator),
0x400000B3 => Some(Key::DecimalSeparator),
0x400000B4 => Some(Key::CurrencyUnit),
0x400000B5 => Some(Key::CurrencySubUnit),
0x400000B6 => Some(Key::NumPadLeftParen),
0x400000B7 => Some(Key::NumPadRightParen),
0x400000B8 => Some(Key::NumPadLeftBrace),
0x400000B9 => Some(Key::NumPadRightBrace),
0x400000BA => Some(Key::NumPadTab),
0x400000BB => Some(Key::NumPadBackspace),
0x400000BC => Some(Key::NumPadA),
0x400000BD => Some(Key::NumPadB),
0x400000BE => Some(Key::NumPadC),
0x400000BF => Some(Key::NumPadD),
0x400000C0 => Some(Key::NumPadE),
0x400000C1 => Some(Key::NumPadF),
0x400000C2 => Some(Key::NumPadXor),
0x400000C3 => Some(Key::NumPadPower),
0x400000C4 => Some(Key::NumPadPercent),
0x400000C5 => Some(Key::NumPadLess),
0x400000C6 => Some(Key::NumPadGreater),
0x400000C7 => Some(Key::NumPadAmpersand),
0x400000C8 => Some(Key::NumPadDblAmpersand),
0x400000C9 => Some(Key::NumPadVerticalBar),
0x400000CA => Some(Key::NumPadDblVerticalBar),
0x400000CB => Some(Key::NumPadColon),
0x400000CC => Some(Key::NumPadHash),
0x400000CD => Some(Key::NumPadSpace),
0x400000CE => Some(Key::NumPadAt),
0x400000CF => Some(Key::NumPadExclam),
0x400000D0 => Some(Key::NumPadMemStore),
0x400000D1 => Some(Key::NumPadMemRecall),
0x400000D2 => Some(Key::NumPadMemClear),
0x400000D3 => Some(Key::NumPadMemAdd),
0x400000D4 => Some(Key::NumPadMemSubtract),
0x400000D5 => Some(Key::NumPadMemMultiply),
0x400000D6 => Some(Key::NumPadMemDivide),
0x400000D7 => Some(Key::NumPadPlusMinus),
0x400000D8 => Some(Key::NumPadClear),
0x400000D9 => Some(Key::NumPadClearEntry),
0x400000DA => Some(Key::NumPadBinary),
0x400000DB => Some(Key::NumPadOctal),
0x400000DC => Some(Key::NumPadDecimal),
0x400000DD => Some(Key::NumPadHexadecimal),
0x400000E0 => Some(Key::LCtrl),
0x400000E1 => Some(Key::LShift),
0x400000E2 => Some(Key::LAlt),
0x400000E3 => Some(Key::LGui),
0x400000E4 => Some(Key::RCtrl),
0x400000E5 => Some(Key::RShift),
0x400000E6 => Some(Key::RAlt),
0x400000E7 => Some(Key::RGui),
0x40000101 => Some(Key::Mode),
0x40000102 => Some(Key::AudioNext),
0x40000103 => Some(Key::AudioPrev),
0x40000104 => Some(Key::AudioStop),
0x40000105 => Some(Key::AudioPlay),
0x40000106 => Some(Key::AudioMute),
0x40000107 => Some(Key::MediaSelect),
0x40000108 => Some(Key::Www),
0x40000109 => Some(Key::Mail),
0x4000010A => Some(Key::Calculator),
0x4000010B => Some(Key::Computer),
0x4000010C => Some(Key::AcSearch),
0x4000010D => Some(Key::AcHome),
0x4000010E => Some(Key::AcBack),
0x4000010F => Some(Key::AcForward),
0x40000110 => Some(Key::AcStop),
0x40000111 => Some(Key::AcRefresh),
0x40000112 => Some(Key::AcBookmarks),
0x40000113 => Some(Key::BrightnessDown),
0x40000114 => Some(Key::BrightnessUp),
0x40000115 => Some(Key::DisplaySwitch),
0x40000116 => Some(Key::KbdIllumToggle),
0x40000117 => Some(Key::KbdIllumDown),
0x40000118 => Some(Key::KbdIllumUp),
0x40000119 => Some(Key::Eject),
0x4000011A => Some(Key::Sleep),
_ => Some(Key::Unknown)
}
}
#[inline(always)]
fn from_i64(n: i64) -> Option<Key> {
FromPrimitive::from_u64(n as u64)
}
#[inline(always)]
fn from_isize(n: isize) -> Option<Key> {
FromPrimitive::from_u64(n as u64)
}
}
#[cfg(test)]
mod tests {
#[test]
fn keycode() {
use super::Key;
use super::Key::*;
use num::{ FromPrimitive, ToPrimitive };
let keys = vec![
Unknown,
Backspace,
Tab,
Return,
Escape,
Space,
Exclaim,
Quotedbl,
Hash,
Dollar,
Percent,
Ampersand,
Quote,
LeftParen,
RightParen,
Asterisk,
Plus,
Comma,
Minus,
Period,
Slash,
D0,
D1,
D2,
D3,
D4,
D5,
D6,
D7,
D8,
D9,
Colon,
Semicolon,
Less,
Equals,
Greater,
Question,
At,
LeftBracket,
Backslash,
RightBracket,
Caret,
Underscore,
Backquote,
A,
B,
C,
D,
E,
F,
G,
H,
I,
J,
K,
L,
M,
N,
O,
P,
Q,
R,
S,
T,
U,
V,
W,
X,
Y,
Z,
Delete,
CapsLock,
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
PrintScreen,
ScrollLock,
Pause,
Insert,
Home,
PageUp,
End,
PageDown,
Right,
Left,
Down,
Up,
NumLockClear,
NumPadDivide,
NumPadMultiply,
NumPadMinus,
NumPadPlus,
NumPadEnter,
NumPad1,
NumPad2,
NumPad3,
NumPad4,
NumPad5,
NumPad6,
NumPad7,
NumPad8,
NumPad9,
NumPad0,
NumPadPeriod,
Application,
Power,
NumPadEquals,
F13,
F14,
F15,
F16,
F17,
F18,
F19,
F20,
F21,
F22,
F23,
F24,
Execute,
Help,
Menu,
Select,
Stop,
Again,
Undo,
Cut,
Copy,
Paste,
Find,
Mute,
VolumeUp,
VolumeDown,
NumPadComma,
NumPadEqualsAS400,
AltErase,
Sysreq,
Cancel,
Clear,
Prior,
Return2,
Separator,
Out,
Oper,
ClearAgain,
CrSel,
ExSel,
NumPad00,
NumPad000,
ThousandsSeparator,
DecimalSeparator,
CurrencyUnit,
CurrencySubUnit,
NumPadLeftParen,
NumPadRightParen,
NumPadLeftBrace,
NumPadRightBrace,
NumPadTab,
NumPadBackspace,
NumPadA,
NumPadB,
NumPadC,
NumPadD,
NumPadE,
NumPadF,
NumPadXor,
NumPadPower,
NumPadPercent,
NumPadLess,
NumPadGreater,
NumPadAmpersand,
NumPadDblAmpersand,
NumPadVerticalBar,
NumPadDblVerticalBar,
NumPadColon,
NumPadHash,
NumPadSpace,
NumPadAt,
NumPadExclam,
NumPadMemStore,
NumPadMemRecall,
NumPadMemClear,
NumPadMemAdd,
NumPadMemSubtract,
NumPadMemMultiply,
NumPadMemDivide,
NumPadPlusMinus,
NumPadClear,
NumPadClearEntry,
NumPadBinary,
NumPadOctal,
NumPadDecimal,
NumPadHexadecimal,
LCtrl,
LShift,
LAlt,
LGui,
RCtrl,
RShift,
RAlt,
RGui,
Mode,
AudioNext,
AudioPrev,
AudioStop,
AudioPlay,
AudioMute,
MediaSelect,
Www,
Mail,
Calculator,
Computer,
AcSearch,
AcHome,
AcBack,
AcForward,
AcStop,
AcRefresh,
AcBookmarks,
BrightnessDown,
BrightnessUp,
DisplaySwitch,
KbdIllumToggle,
KbdIllumDown,
KbdIllumUp,
Eject,
Sleep,
];
for key in &keys {
let val = key.to_u64().unwrap();
let key2: Key = FromPrimitive::from_u64(val).unwrap();
assert_eq!(*key, key2);
}
}
}