added ScrollLock and numeric keypad

This commit is contained in:
Krzysztof Kondrak 2015-12-17 12:27:46 +01:00 committed by Krzysztof Kondrak
parent cacc5b564b
commit 2f91a754d5
2 changed files with 39 additions and 2 deletions

View file

@ -134,13 +134,32 @@ pub enum Key {
Pause, Pause,
Space, Space,
Tab, Tab,
NumLock,
CapsLock, CapsLock,
ScrollLock,
LeftShift, LeftShift,
RightShift, RightShift,
LeftCtrl, LeftCtrl,
RightCtrl, RightCtrl,
Count = 84, NumPad0,
NumPad1,
NumPad2,
NumPad3,
NumPad4,
NumPad5,
NumPad6,
NumPad7,
NumPad8,
NumPad9,
NumPadDot,
NumPadSlash,
NumPadAsterisk,
NumPadMinus,
NumPadPlus,
NumPadEnter,
Count = 102,
} }
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]

View file

@ -105,12 +105,30 @@ fn update_key_state(window: &mut Window, wparam: u32, state: bool) {
0x045 => window.keys[Key::Pause as usize] = state, 0x045 => window.keys[Key::Pause as usize] = state,
0x039 => window.keys[Key::Space as usize] = state, 0x039 => window.keys[Key::Space as usize] = state,
0x00F => window.keys[Key::Tab as usize] = state, 0x00F => window.keys[Key::Tab as usize] = state,
0x145 => window.keys[Key::NumLock as usize] = state,
0x03A => window.keys[Key::CapsLock as usize] = state, 0x03A => window.keys[Key::CapsLock as usize] = state,
0x046 => window.keys[Key::ScrollLock as usize] = state,
0x02A => window.keys[Key::LeftShift as usize] = state, 0x02A => window.keys[Key::LeftShift as usize] = state,
0x036 => window.keys[Key::RightShift as usize] = state, 0x036 => window.keys[Key::RightShift as usize] = state,
0x01D => window.keys[Key::LeftCtrl as usize] = state, 0x01D => window.keys[Key::LeftCtrl as usize] = state,
0x11D => window.keys[Key::RightCtrl as usize] = state, 0x11D => window.keys[Key::RightCtrl as usize] = state,
_ => (), 0x052 => window.keys[Key::NumPad0 as usize] = state,
0x04F => window.keys[Key::NumPad1 as usize] = state,
0x050 => window.keys[Key::NumPad2 as usize] = state,
0x051 => window.keys[Key::NumPad3 as usize] = state,
0x04B => window.keys[Key::NumPad4 as usize] = state,
0x04C => window.keys[Key::NumPad5 as usize] = state,
0x04D => window.keys[Key::NumPad6 as usize] = state,
0x047 => window.keys[Key::NumPad7 as usize] = state,
0x048 => window.keys[Key::NumPad8 as usize] = state,
0x049 => window.keys[Key::NumPad9 as usize] = state,
0x053 => window.keys[Key::NumPadDot as usize] = state,
0x135 => window.keys[Key::NumPadSlash as usize] = state,
0x037 => window.keys[Key::NumPadAsterisk as usize] = state,
0x04A => window.keys[Key::NumPadMinus as usize] = state,
0x04E => window.keys[Key::NumPadPlus as usize] = state,
0x11C => window.keys[Key::NumPadEnter as usize] = state,
_ => {println!("key {:04X}", wparam & 0x1ff)},
} }
} }