keypressed stashed

master
Bel LaPointe 2023-03-23 17:28:11 -06:00
parent ca192aa4ac
commit 68a496e920
1 changed files with 29 additions and 19 deletions

View File

@ -31,7 +31,7 @@ struct Main {
ntfy: String, ntfy: String,
configuring: Option<Message>, configuring: Option<Message>,
inputs: Inputs, inputs: Inputs,
// TODO keys down keys_down: Vec<iced::keyboard::KeyCode>,
flags: Flags, flags: Flags,
} }
@ -101,6 +101,7 @@ impl Application for Main {
r: iced::keyboard::KeyCode::E, r: iced::keyboard::KeyCode::E,
}, },
flags: flags, flags: flags,
keys_down: vec![],
}, Command::none()) }, Command::none())
} }
@ -144,23 +145,8 @@ impl Application for Main {
modifiers: _, modifiers: _,
.. ..
}) => { }) => {
let nope = String::from(""); self.keys_down.push(key_code);
let s = match key_code { self.keys_down.dedup();
_ if key_code == self.inputs.stick.up => &self.flags.cfg.up,
_ if key_code == self.inputs.stick.down => &self.flags.cfg.down,
_ if key_code == self.inputs.stick.left => &self.flags.cfg.left,
_ if key_code == self.inputs.stick.right => &self.flags.cfg.right,
_ if key_code == self.inputs.a => &self.flags.cfg.a,
_ if key_code == self.inputs.b => &self.flags.cfg.b,
_ if key_code == self.inputs.x => &self.flags.cfg.x,
_ if key_code == self.inputs.y => &self.flags.cfg.y,
_ if key_code == self.inputs.l => &self.flags.cfg.l,
_ if key_code == self.inputs.r => &self.flags.cfg.r,
_ => &nope,
};
if s.len() > 0 {
self.flags.output_stream.put(s.chars().collect());
}
}, },
_ => {}, _ => {},
} }
@ -170,7 +156,31 @@ impl Application for Main {
self.ntfy = format!("push a key to bind to {:?}", msg.clone()); self.ntfy = format!("push a key to bind to {:?}", msg.clone());
}, },
} }
// TODO self.flags.output_stream.put(s.chars().collect()); for all keys down let mut s = vec![];
for key_code in self.keys_down.iter() {
let nope = String::from("");
let s2 = match key_code {
_ if key_code == &self.inputs.stick.up => &self.flags.cfg.up,
_ if key_code == &self.inputs.stick.down => &self.flags.cfg.down,
_ if key_code == &self.inputs.stick.left => &self.flags.cfg.left,
_ if key_code == &self.inputs.stick.right => &self.flags.cfg.right,
_ if key_code == &self.inputs.a => &self.flags.cfg.a,
_ if key_code == &self.inputs.b => &self.flags.cfg.b,
_ if key_code == &self.inputs.x => &self.flags.cfg.x,
_ if key_code == &self.inputs.y => &self.flags.cfg.y,
_ if key_code == &self.inputs.l => &self.flags.cfg.l,
_ if key_code == &self.inputs.r => &self.flags.cfg.r,
_ => &nope,
};
if s2.len() > 0 {
for c in s2.chars() {
s.push(c);
}
}
}
if s.len() > 0 {
self.flags.output_stream.put(s);
}
return Command::none(); return Command::none();
} }