2020-09-18 21:43:47 +00:00
|
|
|
mod converter;
|
|
|
|
mod gilrs_system;
|
|
|
|
|
2021-07-27 20:21:06 +00:00
|
|
|
use bevy_app::{App, CoreStage, Plugin, StartupStage};
|
2020-11-13 01:23:57 +00:00
|
|
|
use bevy_utils::tracing::error;
|
2020-10-21 17:27:00 +00:00
|
|
|
use gilrs::GilrsBuilder;
|
2020-10-29 20:55:35 +00:00
|
|
|
use gilrs_system::{gilrs_event_startup_system, gilrs_event_system};
|
2020-09-18 21:43:47 +00:00
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
pub struct GilrsPlugin;
|
|
|
|
|
|
|
|
impl Plugin for GilrsPlugin {
|
2021-07-27 20:21:06 +00:00
|
|
|
fn build(&self, app: &mut App) {
|
2020-10-21 17:27:00 +00:00
|
|
|
match GilrsBuilder::new()
|
|
|
|
.with_default_filters(false)
|
|
|
|
.set_update_state(false)
|
|
|
|
.build()
|
|
|
|
{
|
2020-09-18 21:43:47 +00:00
|
|
|
Ok(gilrs) => {
|
2021-02-09 20:14:10 +00:00
|
|
|
app.insert_non_send_resource(gilrs)
|
|
|
|
.add_startup_system_to_stage(
|
2021-02-18 21:20:37 +00:00
|
|
|
StartupStage::PreStartup,
|
2021-10-08 00:37:08 +00:00
|
|
|
gilrs_event_startup_system,
|
2021-02-09 20:14:10 +00:00
|
|
|
)
|
2021-10-08 00:37:08 +00:00
|
|
|
.add_system_to_stage(CoreStage::PreUpdate, gilrs_event_system);
|
2020-09-18 21:43:47 +00:00
|
|
|
}
|
2020-11-13 01:23:57 +00:00
|
|
|
Err(err) => error!("Failed to start Gilrs. {}", err),
|
2020-09-18 21:43:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|