Add gamecube adapter support

This commit is contained in:
2026-08-27 14:53:42 +02:00
parent e7e744f15e
commit 00d47e9c9b
14 changed files with 719 additions and 68 deletions
+35
View File
@@ -0,0 +1,35 @@
pub mod bridge;
pub mod poll;
pub use bridge::{GcPort, GcPorts, GC_PORT_COUNT};
pub use poll::{GcAdapterSnapshot, GcPortState};
use bevy::input::gamepad::{gamepad_connection_system, gamepad_event_processing_system};
use bevy::input::InputSystems;
use bevy::prelude::*;
#[derive(Default)]
pub struct GamecubeAdapterPlugin;
impl Plugin for GamecubeAdapterPlugin {
fn build(&self, app: &mut App) {
app.init_resource::<GcPorts>();
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),
);
}
}