From 324a7b07b0dfcc1373b28a7f85a5d2ea070caec2 Mon Sep 17 00:00:00 2001 From: bel Date: Sun, 2 Apr 2023 09:45:30 -0600 Subject: [PATCH] add start button --- src/config.rs | 2 ++ src/gui.rs | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/config.rs b/src/config.rs index f7fbd73..01e82fb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -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")), }, diff --git a/src/gui.rs b/src/gui.rs index f867ec8..e9458a5 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -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, @@ -243,6 +246,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 +295,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 }, _ => {}, @@ -377,6 +382,7 @@ impl Application for Main { 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::Start, self.inputs.start), new_cfg_button(Message::L, self.inputs.l), new_cfg_button(Message::R, self.inputs.r), text(String::from("--------------")).size(24),