nest config gui.buttons....
parent
400762e5fc
commit
4e41fefe2a
|
|
@ -36,6 +36,11 @@ pub struct Device {
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct GUI {
|
pub struct GUI {
|
||||||
|
pub buttons: Buttons,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct Buttons {
|
||||||
pub up: String,
|
pub up: String,
|
||||||
pub down: String,
|
pub down: String,
|
||||||
pub left: String,
|
pub left: String,
|
||||||
|
|
@ -93,6 +98,7 @@ fn build_config_std() -> Config {
|
||||||
name: env::var("INPUT_NAME").unwrap_or(String::from("stdin")),
|
name: env::var("INPUT_NAME").unwrap_or(String::from("stdin")),
|
||||||
kafka: None,
|
kafka: None,
|
||||||
gui: Some(GUI{
|
gui: Some(GUI{
|
||||||
|
buttons: Buttons{
|
||||||
up: env::var("INPUT_GUI_BUTTON_UP").unwrap_or(String::from("w")),
|
up: env::var("INPUT_GUI_BUTTON_UP").unwrap_or(String::from("w")),
|
||||||
left: env::var("INPUT_GUI_BUTTON_LEFT").unwrap_or(String::from("a")),
|
left: env::var("INPUT_GUI_BUTTON_LEFT").unwrap_or(String::from("a")),
|
||||||
down: env::var("INPUT_GUI_BUTTON_DOWN").unwrap_or(String::from("s")),
|
down: env::var("INPUT_GUI_BUTTON_DOWN").unwrap_or(String::from("s")),
|
||||||
|
|
@ -103,6 +109,7 @@ fn build_config_std() -> Config {
|
||||||
y: env::var("INPUT_GUI_BUTTON_Y").unwrap_or(String::from("4")),
|
y: env::var("INPUT_GUI_BUTTON_Y").unwrap_or(String::from("4")),
|
||||||
l: env::var("INPUT_GUI_BUTTON_L").unwrap_or(String::from("q")),
|
l: env::var("INPUT_GUI_BUTTON_L").unwrap_or(String::from("q")),
|
||||||
r: env::var("INPUT_GUI_BUTTON_R").unwrap_or(String::from("e")),
|
r: env::var("INPUT_GUI_BUTTON_R").unwrap_or(String::from("e")),
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
device: None,
|
device: None,
|
||||||
udp: Some(UDP{
|
udp: Some(UDP{
|
||||||
|
|
|
||||||
20
src/gui.rs
20
src/gui.rs
|
|
@ -82,16 +82,16 @@ fn controller_button_to_string(btn: Message, cur: iced::keyboard::KeyCode) -> St
|
||||||
impl Main {
|
impl Main {
|
||||||
fn key_code_to_string(&self, key_code: &iced::keyboard::KeyCode) -> Option<&String> {
|
fn key_code_to_string(&self, key_code: &iced::keyboard::KeyCode) -> Option<&String> {
|
||||||
match key_code {
|
match key_code {
|
||||||
_ if key_code == &self.inputs.stick.up => Some(&self.flags.cfg.up),
|
_ if key_code == &self.inputs.stick.up => Some(&self.flags.cfg.buttons.up),
|
||||||
_ if key_code == &self.inputs.stick.down => Some(&self.flags.cfg.down),
|
_ if key_code == &self.inputs.stick.down => Some(&self.flags.cfg.buttons.down),
|
||||||
_ if key_code == &self.inputs.stick.left => Some(&self.flags.cfg.left),
|
_ if key_code == &self.inputs.stick.left => Some(&self.flags.cfg.buttons.left),
|
||||||
_ if key_code == &self.inputs.stick.right => Some(&self.flags.cfg.right),
|
_ if key_code == &self.inputs.stick.right => Some(&self.flags.cfg.buttons.right),
|
||||||
_ if key_code == &self.inputs.a => Some(&self.flags.cfg.a),
|
_ if key_code == &self.inputs.a => Some(&self.flags.cfg.buttons.a),
|
||||||
_ if key_code == &self.inputs.b => Some(&self.flags.cfg.b),
|
_ if key_code == &self.inputs.b => Some(&self.flags.cfg.buttons.b),
|
||||||
_ if key_code == &self.inputs.x => Some(&self.flags.cfg.x),
|
_ if key_code == &self.inputs.x => Some(&self.flags.cfg.buttons.x),
|
||||||
_ if key_code == &self.inputs.y => Some(&self.flags.cfg.y),
|
_ if key_code == &self.inputs.y => Some(&self.flags.cfg.buttons.y),
|
||||||
_ if key_code == &self.inputs.l => Some(&self.flags.cfg.l),
|
_ if key_code == &self.inputs.l => Some(&self.flags.cfg.buttons.l),
|
||||||
_ if key_code == &self.inputs.r => Some(&self.flags.cfg.r),
|
_ if key_code == &self.inputs.r => Some(&self.flags.cfg.buttons.r),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue