Compare commits

...

4 Commits

Author SHA1 Message Date
Bel LaPointe 31bdb6d92e status every 2s 2023-04-02 11:34:25 -06:00
Bel LaPointe 83f4ee0e51 trim for multiline text i guess 2023-04-02 11:30:22 -06:00
Bel LaPointe ed1d2b5835 condense configs 2023-04-02 11:03:24 -06:00
bel 324a7b07b0 add start button 2023-04-02 09:45:30 -06:00
2 changed files with 30 additions and 14 deletions

View File

@ -60,6 +60,7 @@ pub struct Buttons {
pub b: String,
pub x: String,
pub y: String,
pub start: String,
pub l: String,
pub r: String,
}
@ -120,6 +121,7 @@ fn build_config_std() -> Config {
b: env::var("INPUT_GUI_BUTTON_B").unwrap_or(String::from("2")),
x: env::var("INPUT_GUI_BUTTON_X").unwrap_or(String::from("3")),
y: env::var("INPUT_GUI_BUTTON_Y").unwrap_or(String::from("4")),
start: env::var("INPUT_GUI_BUTTON_START").unwrap_or(String::from("5")),
l: env::var("INPUT_GUI_BUTTON_L").unwrap_or(String::from("q")),
r: env::var("INPUT_GUI_BUTTON_R").unwrap_or(String::from("e")),
},

View File

@ -29,7 +29,7 @@ pub fn main(cfg: GUI, output_stream: Box<dyn OutputStream>) -> iced::Result {
text_multithreading: def.text_multithreading,
try_opengles_first: def.try_opengles_first,
window: iced::window::Settings{
size: (300, 720),
size: (300, 900),
position: iced::window::Position::Specific(0, 0),
..iced::window::Settings::default()
},
@ -63,6 +63,7 @@ struct Inputs {
b: iced::keyboard::KeyCode,
x: iced::keyboard::KeyCode,
y: iced::keyboard::KeyCode,
start: iced::keyboard::KeyCode,
l: iced::keyboard::KeyCode,
r: iced::keyboard::KeyCode,
}
@ -89,6 +90,7 @@ enum Message {
B,
X,
Y,
Start,
L,
R,
}
@ -115,6 +117,7 @@ impl Main {
_ if key_code == &self.inputs.b => Some(&self.flags.cfg.buttons.b),
_ if key_code == &self.inputs.x => Some(&self.flags.cfg.buttons.x),
_ if key_code == &self.inputs.y => Some(&self.flags.cfg.buttons.y),
_ if key_code == &self.inputs.start => Some(&self.flags.cfg.buttons.start),
_ if key_code == &self.inputs.l => Some(&self.flags.cfg.buttons.l),
_ if key_code == &self.inputs.r => Some(&self.flags.cfg.buttons.r),
_ => None,
@ -142,7 +145,9 @@ impl Main {
match self.feedback_recv_c.try_recv() {
Ok(msg) => {
match msg {
Feedback::Heard(msg) => self.ntfy_from_server = msg,
Feedback::Heard(msg) => {
self.ntfy_from_server = msg;
},
_ => break,
};
},
@ -243,6 +248,7 @@ impl Application for Main {
b: iced::keyboard::KeyCode::Key2,
x: iced::keyboard::KeyCode::Key3,
y: iced::keyboard::KeyCode::Key4,
start: iced::keyboard::KeyCode::Key5,
l: iced::keyboard::KeyCode::Q,
r: iced::keyboard::KeyCode::E,
},
@ -291,6 +297,7 @@ impl Application for Main {
Message::B => { self.inputs.b = key_code },
Message::X => { self.inputs.x = key_code },
Message::Y => { self.inputs.y = key_code },
Message::Start => { self.inputs.start = key_code },
Message::L => { self.inputs.l = key_code },
Message::R => { self.inputs.r = key_code },
_ => {},
@ -357,7 +364,7 @@ impl Application for Main {
},
_ => None,
}),
every(std::time::Duration::from_millis(5000)).map(|_| Message::Tick),
every(std::time::Duration::from_millis(2000)).map(|_| Message::Tick),
]);
}
@ -369,16 +376,23 @@ impl Application for Main {
column![
text(String::from("Button Mapping")).size(24),
text(String::from("--------------")).size(24),
new_cfg_button(Message::Up, self.inputs.stick.up),
new_cfg_button(Message::Down, self.inputs.stick.down),
new_cfg_button(Message::Left, self.inputs.stick.left),
new_cfg_button(Message::Right, self.inputs.stick.right),
new_cfg_button(Message::A, self.inputs.a),
new_cfg_button(Message::B, self.inputs.b),
new_cfg_button(Message::X, self.inputs.x),
new_cfg_button(Message::Y, self.inputs.y),
new_cfg_button(Message::L, self.inputs.l),
new_cfg_button(Message::R, self.inputs.r),
row![
column![
new_cfg_button(Message::Up, self.inputs.stick.up),
new_cfg_button(Message::Down, self.inputs.stick.down),
new_cfg_button(Message::Left, self.inputs.stick.left),
new_cfg_button(Message::Right, self.inputs.stick.right),
new_cfg_button(Message::Start, self.inputs.start),
].padding(5).align_items(Alignment::Center),
column![
new_cfg_button(Message::A, self.inputs.a),
new_cfg_button(Message::B, self.inputs.b),
new_cfg_button(Message::X, self.inputs.x),
new_cfg_button(Message::Y, self.inputs.y),
new_cfg_button(Message::L, self.inputs.l),
new_cfg_button(Message::R, self.inputs.r),
].padding(5).align_items(Alignment::Center),
].padding(5).align_items(Alignment::Center),
text(String::from("--------------")).size(24),
text(self.ntfy_from_client.clone()).size(18),
].padding(20).align_items(Alignment::Center),
@ -392,7 +406,7 @@ impl Application for Main {
button(text("Say")).on_press(Message::InputTextEntrySubmitSay).padding(20),
button(text("Send")).on_press(Message::InputTextEntrySubmitSend).padding(20),
].padding(20).align_items(Alignment::Center),
text(self.ntfy_from_server.clone()).size(18),
text(self.ntfy_from_server.clone().trim()).size(18),
].padding(20).align_items(Alignment::Center),
].padding(0).align_items(Alignment::Center),
].padding(0).align_items(Alignment::Center).into();