From 527ab97a0470605e13f8361ac5bb74fac323056b Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Sat, 25 Sep 2021 01:50:24 -0400 Subject: [PATCH] noop identical keys --- src/keymapper.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/keymapper.rs b/src/keymapper.rs index b599a30..e4f125d 100644 --- a/src/keymapper.rs +++ b/src/keymapper.rs @@ -149,8 +149,14 @@ impl KeyMaps let mut keymap = KeyMap::new(); let mut i: usize = 0; for key_code in v { - // todo: if these are the same, do Noop instead - keymap.map(base_keymap[i], key_code); + // if it's a direct key and it's the same, don't do any mapping + if let Key::Direct(key) = key_code { + if base_keymap[i] != key { + keymap.map(base_keymap[i], key_code); + } + } else { + keymap.map(base_keymap[i], key_code); + } i = i + 1; if i > base_keymap.len() { panic!("all keymaps must be the same length, keymap index 0 length: {}, index {} length: {},", base_keymap.len(), x, i);