diff --git a/src/gui.rs b/src/gui.rs index 853f3dc..c08320c 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -1,7 +1,9 @@ use iced::widget::{button, column, text}; use iced::executor; +use iced::keyboard; +use iced::event; +use iced::subscription; use iced::{Alignment, Element, Application, Settings, Subscription, Theme, Command}; -use iced_native::Event; pub fn main() -> iced::Result { Main::run(Settings::default()) @@ -10,7 +12,24 @@ pub fn main() -> iced::Result { struct Main { ntfy: String, configuring: bool, - inputs: std::collections::HashMap, + inputs: Inputs, +} + +struct Inputs { + stick: Stick, + a: char, + b: char, + x: char, + y: char, + l: char, + r: char, +} + +struct Stick { + up: char, + down: char, + left: char, + right: char, } #[derive(Debug, Clone)] @@ -42,6 +61,20 @@ impl Application for Main { return (Self { ntfy: String::from(":wave:"), configuring: false, + inputs: Inputs{ + stick: Stick { + up: 'w', + down: 's', + left: 'a', + right: 'd', + }, + a: 'k', + b: 'j', + x: 'i', + y: 'u', + l: 'q', + r: 'e', + }, }, Command::none()) } @@ -53,8 +86,12 @@ impl Application for Main { match msg { Message::EventOccurred(event) if self.configuring => { match event { - iced_native::Event::Keyboard(kb) => { - self.ntfy = format!("would set {:?}", kb); + iced::event::Event::Keyboard(keyboard::Event::KeyPressed{ + key_code, + modifiers, + .. + }) => { + self.ntfy = format!("would set {:?}", key_code); self.configuring = false; }, _ => {}, @@ -70,7 +107,7 @@ impl Application for Main { } fn subscription(&self) -> Subscription { - iced_native::subscription::events().map(Message::EventOccurred) + return subscription::events().map(Message::EventOccurred) } fn view(&self) -> Element {