Fix keyboard shortcuts for A/D switches

This commit is contained in:
pjht 2024-01-29 16:06:47 -06:00
parent 91fbc53305
commit 8b0d96533d
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E

View File

@ -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);