mirror of
https://github.com/italicsjenga/rust_minifb.git
synced 2024-12-23 19:31:30 +11:00
Added get_keys() function
This commit is contained in:
parent
03e8075157
commit
0c2e4cee7c
|
@ -297,6 +297,23 @@ impl Window {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_keys(&self) -> Option<Vec<Key>> {
|
||||
let mut index: u16 = 0;
|
||||
let mut keys: Vec<Key> = Vec::new();
|
||||
|
||||
for i in self.keys.iter() {
|
||||
if *i {
|
||||
unsafe {
|
||||
keys.push(mem::transmute(index as u8));
|
||||
}
|
||||
}
|
||||
|
||||
index += 1;
|
||||
}
|
||||
|
||||
Some(keys)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_key_down(&self, key: Key) -> bool {
|
||||
return self.keys[key as usize];
|
||||
|
|
Loading…
Reference in a new issue