nest config gui.buttons....
parent
400762e5fc
commit
4e41fefe2a
|
|
@ -36,6 +36,11 @@ pub struct Device {
|
|||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct GUI {
|
||||
pub buttons: Buttons,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct Buttons {
|
||||
pub up: String,
|
||||
pub down: String,
|
||||
pub left: String,
|
||||
|
|
@ -93,16 +98,18 @@ fn build_config_std() -> Config {
|
|||
name: env::var("INPUT_NAME").unwrap_or(String::from("stdin")),
|
||||
kafka: None,
|
||||
gui: Some(GUI{
|
||||
up: env::var("INPUT_GUI_BUTTON_UP").unwrap_or(String::from("w")),
|
||||
left: env::var("INPUT_GUI_BUTTON_LEFT").unwrap_or(String::from("a")),
|
||||
down: env::var("INPUT_GUI_BUTTON_DOWN").unwrap_or(String::from("s")),
|
||||
right: env::var("INPUT_GUI_BUTTON_RIGHT").unwrap_or(String::from("d")),
|
||||
a: env::var("INPUT_GUI_BUTTON_A").unwrap_or(String::from("1")),
|
||||
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")),
|
||||
l: env::var("INPUT_GUI_BUTTON_L").unwrap_or(String::from("q")),
|
||||
r: env::var("INPUT_GUI_BUTTON_R").unwrap_or(String::from("e")),
|
||||
buttons: Buttons{
|
||||
up: env::var("INPUT_GUI_BUTTON_UP").unwrap_or(String::from("w")),
|
||||
left: env::var("INPUT_GUI_BUTTON_LEFT").unwrap_or(String::from("a")),
|
||||
down: env::var("INPUT_GUI_BUTTON_DOWN").unwrap_or(String::from("s")),
|
||||
right: env::var("INPUT_GUI_BUTTON_RIGHT").unwrap_or(String::from("d")),
|
||||
a: env::var("INPUT_GUI_BUTTON_A").unwrap_or(String::from("1")),
|
||||
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")),
|
||||
l: env::var("INPUT_GUI_BUTTON_L").unwrap_or(String::from("q")),
|
||||
r: env::var("INPUT_GUI_BUTTON_R").unwrap_or(String::from("e")),
|
||||
},
|
||||
}),
|
||||
device: None,
|
||||
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 {
|
||||
fn key_code_to_string(&self, key_code: &iced::keyboard::KeyCode) -> Option<&String> {
|
||||
match key_code {
|
||||
_ if key_code == &self.inputs.stick.up => Some(&self.flags.cfg.up),
|
||||
_ if key_code == &self.inputs.stick.down => Some(&self.flags.cfg.down),
|
||||
_ if key_code == &self.inputs.stick.left => Some(&self.flags.cfg.left),
|
||||
_ if key_code == &self.inputs.stick.right => Some(&self.flags.cfg.right),
|
||||
_ if key_code == &self.inputs.a => Some(&self.flags.cfg.a),
|
||||
_ if key_code == &self.inputs.b => Some(&self.flags.cfg.b),
|
||||
_ if key_code == &self.inputs.x => Some(&self.flags.cfg.x),
|
||||
_ if key_code == &self.inputs.y => Some(&self.flags.cfg.y),
|
||||
_ if key_code == &self.inputs.l => Some(&self.flags.cfg.l),
|
||||
_ if key_code == &self.inputs.r => Some(&self.flags.cfg.r),
|
||||
_ if key_code == &self.inputs.stick.up => Some(&self.flags.cfg.buttons.up),
|
||||
_ if key_code == &self.inputs.stick.down => Some(&self.flags.cfg.buttons.down),
|
||||
_ if key_code == &self.inputs.stick.left => Some(&self.flags.cfg.buttons.left),
|
||||
_ if key_code == &self.inputs.stick.right => Some(&self.flags.cfg.buttons.right),
|
||||
_ if key_code == &self.inputs.a => Some(&self.flags.cfg.buttons.a),
|
||||
_ 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.l => Some(&self.flags.cfg.buttons.l),
|
||||
_ if key_code == &self.inputs.r => Some(&self.flags.cfg.buttons.r),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue