#[cfg(all(feature = "gamecube-adapter", not(target_os = "windows")))] pub mod bridge; #[cfg(all(feature = "gamecube-adapter", not(target_os = "windows")))] pub mod poll; #[cfg(all(feature = "gamecube-adapter", not(target_os = "windows")))] pub use bridge::{GC_PORT_COUNT, GcPort}; #[cfg(all(feature = "gamecube-adapter", not(target_os = "windows")))] pub use poll::{GcAdapterSnapshot, GcPortState}; #[derive(Resource, Default)] pub struct GcPorts { pub entities: [Option; 4], #[cfg(all(feature = "gamecube-adapter", not(target_os = "windows")))] pub(super) last: [poll::GcPortState; 4], } #[cfg(all(feature = "gamecube-adapter", not(target_os = "windows")))] use bevy::input::InputSystems; #[cfg(all(feature = "gamecube-adapter", not(target_os = "windows")))] use bevy::input::gamepad::{gamepad_connection_system, gamepad_event_processing_system}; use bevy::prelude::*; #[derive(Default)] pub struct GamecubeAdapterPlugin; impl Plugin for GamecubeAdapterPlugin { fn build(&self, app: &mut App) { app.init_resource::(); #[cfg(all(feature = "gamecube-adapter", not(target_os = "windows")))] { let Ok(snapshot) = poll::spawn_poll_thread() else { // No adapter connected; leave GcPorts empty and skip wiring the // polling systems. return; }; app.insert_resource(snapshot).add_systems( PreUpdate, ( bridge::gc_connection_system.before(gamepad_connection_system), bridge::gc_event_system .after(gamepad_connection_system) .before(gamepad_event_processing_system), ) .in_set(InputSystems), ); } } }