Disable GameCube adapter on Windows (#80)
CI / build-and-test (push) Successful in 1m24s
CI / production-build (push) Successful in 11m34s

## Summary
- add a feature flag for the GameCube adapter driver
- keep the driver enabled by default on supported platforms
- exclude the adapter dependency and polling systems on Windows

Reviewed-on: #80
Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
This commit was merged in pull request #80.
This commit is contained in:
2026-10-02 11:19:01 +00:00
committed by EIREXE
parent adf83ba03f
commit 47f7ae1e69
3 changed files with 39 additions and 28 deletions
+2 -10
View File
@@ -7,7 +7,8 @@ use bevy::input::gamepad::{
};
use bevy::prelude::*;
use super::poll::{GcAdapterSnapshot, GcPortState};
use super::GcPorts;
use super::poll::GcAdapterSnapshot;
/// GameCube adapters report 4 ports.
pub const GC_PORT_COUNT: usize = 4;
@@ -23,15 +24,6 @@ const GC_ADAPTER_PID: u16 = 0x0337;
#[derive(Component, Debug, Clone, Copy)]
pub struct GcPort(pub u8);
/// Tracks which entity (if any) represents each of the 4 adapter ports,
/// and the last snapshot seen, so both systems below can diff instead of
/// re-deriving state every frame.
#[derive(Resource, Default)]
pub struct GcPorts {
pub entities: [Option<Entity>; GC_PORT_COUNT],
last: [GcPortState; GC_PORT_COUNT],
}
fn passthrough_gamepad_settings() -> GamepadSettings {
let mut settings = GamepadSettings::default();
for axis in GamepadAxis::all() {
+32 -16
View File
@@ -1,10 +1,23 @@
#[cfg(all(feature = "gamecube-adapter", not(target_os = "windows")))]
pub mod bridge;
#[cfg(all(feature = "gamecube-adapter", not(target_os = "windows")))]
pub mod poll;
pub use bridge::{GC_PORT_COUNT, GcPort, GcPorts};
#[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<Entity>; 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::*;
@@ -15,21 +28,24 @@ 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;
};
#[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),
);
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),
);
}
}
}