From 8b0d96533ddc6085427969b18e26c9ca163e584a Mon Sep 17 00:00:00 2001 From: pjht Date: Mon, 29 Jan 2024 16:06:47 -0600 Subject: [PATCH] Fix keyboard shortcuts for A/D switches --- src/frontpanel.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/frontpanel.rs b/src/frontpanel.rs index c230916..670f20e 100644 --- a/src/frontpanel.rs +++ b/src/frontpanel.rs @@ -152,7 +152,7 @@ impl Widget for &mut Frontpanel<'_> { .add(switch::ToggleSwitch::new( &mut power_inv, &sw_textures, - Some(KeyboardShortcut::new(Modifiers::NONE, Key::Q)), + Some(KeyboardShortcut::new(Modifiers::NONE, Key::A)), )) .changed() { @@ -167,9 +167,9 @@ impl Widget for &mut Frontpanel<'_> { let mut sw_state = self.state.ad_sws & bit_mask > 0; ui.allocate_ui_at_rect(Rect::from_center_size(pos, vec2(11.0, 25.0)), |ui| { let key_offset = (i - 1) % 8; - let key = (b'1' + key_offset as u8) as char; - let key = Key::from_name(&key.to_string()).unwrap(); - let mods = if (i - 1) >= 8 { + let key = ["Q", "W", "E", "R", "T", "Y", "U", "I"][key_offset]; + let key = Key::from_name(&key).unwrap(); + let mods = if (i - 1) < 8 { Modifiers::SHIFT } else { Modifiers::NONE @@ -200,8 +200,8 @@ impl Widget for &mut Frontpanel<'_> { }; ui.allocate_ui_at_rect(Rect::from_center_size(pos, vec2(11.0, 25.0)), |ui| { let sw_offset = i - 17; - let up_key = ["W", "E", "R", "T", "Y", "U", "I", "O"][sw_offset]; - let down_key = ["S", "D", "F", "G", "H", "J", "K", "L"][sw_offset]; + let up_key = ["S", "D", "F", "G", "H", "J", "K", "L"][sw_offset]; + let down_key = ["X", "C", "V", "B", "N", "M", ",", "."][sw_offset]; let up_key = Key::from_name(up_key).unwrap(); let down_key = Key::from_name(down_key).unwrap(); let up_shortcut = KeyboardShortcut::new(Modifiers::NONE, up_key);