master
Bel LaPointe 2023-03-22 18:10:25 -06:00
parent 941220eef8
commit 3ef0a15ce4
1 changed files with 42 additions and 5 deletions

View File

@ -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<Message, char>,
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<Message> {
iced_native::subscription::events().map(Message::EventOccurred)
return subscription::events().map(Message::EventOccurred)
}
fn view(&self) -> Element<Message> {