gui with text
parent
eb6d7d136c
commit
c70d48d630
File diff suppressed because it is too large
Load Diff
|
|
@ -12,3 +12,4 @@ rdkafka = "0.29.0"
|
||||||
rusb = "0.9.1"
|
rusb = "0.9.1"
|
||||||
hidapi = "0.5.0"
|
hidapi = "0.5.0"
|
||||||
gilrs = "0.10.1"
|
gilrs = "0.10.1"
|
||||||
|
iced = "0.8.0"
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ fn build_config_std() -> Config {
|
||||||
streams: Streams{
|
streams: Streams{
|
||||||
input: Stream {
|
input: Stream {
|
||||||
engine: Engine{
|
engine: Engine{
|
||||||
name: String::from("stdin"),
|
name: String::from("gui"),
|
||||||
kafka: None,
|
kafka: None,
|
||||||
device: None,
|
device: None,
|
||||||
udp: None,
|
udp: None,
|
||||||
|
|
@ -76,7 +76,7 @@ fn build_config_std() -> Config {
|
||||||
},
|
},
|
||||||
output: Stream {
|
output: Stream {
|
||||||
engine: Engine{
|
engine: Engine{
|
||||||
name: String::from("stdout"),
|
name: String::from("gui"),
|
||||||
kafka: None,
|
kafka: None,
|
||||||
device: None,
|
device: None,
|
||||||
udp: None,
|
udp: None,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
use iced::widget::{button, column, text};
|
||||||
|
use iced::{Alignment, Element, Sandbox, Settings};
|
||||||
|
|
||||||
|
pub fn main() -> iced::Result {
|
||||||
|
Main::run(Settings::default())
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Main {
|
||||||
|
ntfy: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
enum ControllerButton {
|
||||||
|
Up,
|
||||||
|
Down,
|
||||||
|
Left,
|
||||||
|
Right,
|
||||||
|
A,
|
||||||
|
B,
|
||||||
|
X,
|
||||||
|
Y,
|
||||||
|
L,
|
||||||
|
R,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn controller_button_to_string(btn: ControllerButton) -> String {
|
||||||
|
return format!("{:?}", btn);
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Sandbox for Main {
|
||||||
|
type Message = ControllerButton;
|
||||||
|
|
||||||
|
fn new() -> Self {
|
||||||
|
return Self { ntfy: String::from(":wave:") }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn title(&self) -> String {
|
||||||
|
return String::from("Rusty Pipe")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update(&mut self, controllerButton: ControllerButton) {
|
||||||
|
self.ntfy = format!("push a key to bind to {:?}", controllerButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn view(&self) -> Element<ControllerButton> {
|
||||||
|
return column![
|
||||||
|
button(text(controller_button_to_string(ControllerButton::Up))).on_press(ControllerButton::Up),
|
||||||
|
button(text(controller_button_to_string(ControllerButton::Down))).on_press(ControllerButton::Down),
|
||||||
|
button(text(controller_button_to_string(ControllerButton::Left))).on_press(ControllerButton::Left),
|
||||||
|
button(text(controller_button_to_string(ControllerButton::Right))).on_press(ControllerButton::Right),
|
||||||
|
button(text(controller_button_to_string(ControllerButton::A))).on_press(ControllerButton::A),
|
||||||
|
button(text(controller_button_to_string(ControllerButton::B))).on_press(ControllerButton::B),
|
||||||
|
button(text(controller_button_to_string(ControllerButton::X))).on_press(ControllerButton::X),
|
||||||
|
button(text(controller_button_to_string(ControllerButton::Y))).on_press(ControllerButton::Y),
|
||||||
|
button(text(controller_button_to_string(ControllerButton::L))).on_press(ControllerButton::L),
|
||||||
|
button(text(controller_button_to_string(ControllerButton::R))).on_press(ControllerButton::R),
|
||||||
|
text(self.ntfy.clone()).size(50),
|
||||||
|
]
|
||||||
|
.padding(20)
|
||||||
|
.align_items(Alignment::Center)
|
||||||
|
.into();
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/main.rs
11
src/main.rs
|
|
@ -1,12 +1,17 @@
|
||||||
mod config;
|
mod config;
|
||||||
mod engine;
|
mod engine;
|
||||||
|
mod gui;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
main_cli();
|
let cfg = config::build_config().unwrap();
|
||||||
|
if cfg.streams.input.engine.name == "gui" {
|
||||||
|
gui::main().unwrap();
|
||||||
|
} else {
|
||||||
|
main_cli(cfg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main_cli() {
|
fn main_cli(cfg: config::Config) {
|
||||||
let cfg = config::build_config().unwrap();
|
|
||||||
let input_engine = engine::build_input_engine(&cfg.streams.input.engine);
|
let input_engine = engine::build_input_engine(&cfg.streams.input.engine);
|
||||||
let output_engine = engine::build_output_engine(&cfg.streams.output.engine);
|
let output_engine = engine::build_output_engine(&cfg.streams.output.engine);
|
||||||
println!("{:?} => {}", cfg.streams.input.engine.name, input_engine.is_ok());
|
println!("{:?} => {}", cfg.streams.input.engine.name, input_engine.is_ok());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue