Switch from Vec<Key> to [Key]

This commit is contained in:
Travis Burtrum 2017-09-23 00:47:20 -04:00
parent ef4ee29518
commit 80d2d09ae2
1 changed files with 7 additions and 2 deletions

View File

@ -196,8 +196,8 @@ impl KeyMaps {
const KEY_MAX: usize = 249; const KEY_MAX: usize = 249;
struct KeyMap { struct KeyMap {
keymap: Vec<Key>, //keymap: Vec<Key>,
//[Box<KeyMapper>; KEY_MAX], keymap: [Key; KEY_MAX],
} }
impl KeyMap { impl KeyMap {
@ -205,11 +205,14 @@ impl KeyMap {
//let mut keymap = [0u16; KEY_MAX]; //let mut keymap = [0u16; KEY_MAX];
//let mut keymap : [Box<KeyMapper>; KEY_MAX] = [Box::new(NOOP); KEY_MAX]; //let mut keymap : [Box<KeyMapper>; KEY_MAX] = [Box::new(NOOP); KEY_MAX];
//let mut keymap : [Box<KeyMapper>; KEY_MAX] = [Box::new(0u16); KEY_MAX]; //let mut keymap : [Box<KeyMapper>; KEY_MAX] = [Box::new(0u16); KEY_MAX];
let keymap : [Key; KEY_MAX] = [Key::Noop; KEY_MAX];
/*
let mut keymap: Vec<Key> = Vec::with_capacity(KEY_MAX); let mut keymap: Vec<Key> = Vec::with_capacity(KEY_MAX);
#[allow(unused_variables)] #[allow(unused_variables)]
for x in 0..KEY_MAX { for x in 0..KEY_MAX {
keymap.push(Key::Noop); keymap.push(Key::Noop);
} }
*/
// which is rustier // which is rustier
/* /*
for x in 0..KEY_MAX { for x in 0..KEY_MAX {
@ -251,6 +254,7 @@ impl KeyMapper for u16 {
} }
// todo:capslock_nomodify is like a whole-key thing, not a half-key thing, split code/invert_shift to own struct, send into send_key from *InvertedKey, maybe anyway, consider it, maybe 1 char for whole key and another for half? // todo:capslock_nomodify is like a whole-key thing, not a half-key thing, split code/invert_shift to own struct, send into send_key from *InvertedKey, maybe anyway, consider it, maybe 1 char for whole key and another for half?
#[derive(Clone, Copy)]
struct HalfInvertedKey { struct HalfInvertedKey {
code: u16, code: u16,
// code this is describing // code this is describing
@ -321,6 +325,7 @@ impl KeyMapper for HalfInvertedKey {
} }
} }
#[derive(Clone, Copy)]
enum Key { enum Key {
Noop, Noop,
Direct(u16), Direct(u16),