From c2ba5cf34adb394891d1cc2efc75432a07bc2961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Rom=C3=A1n=20N=C3=BA=C3=B1ez?= Date: Thu, 1 Oct 2026 08:11:25 +0200 Subject: [PATCH 1/2] Disable GameCube adapter on Windows --- Cargo.toml | 7 ++++-- src/input/gamecube/bridge.rs | 12 ++-------- src/input/gamecube/mod.rs | 46 +++++++++++++++++++++++------------- 3 files changed, 37 insertions(+), 28 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 537e519..78e1f28 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,9 +7,10 @@ authors = [""] [workspace] [features] -default = ["development", "debug_features"] +default = ["development", "debug_features", "gamecube-adapter"] development = ["bevy/dynamic_linking", "bevy/file_watcher", "bevy/embedded_watcher"] debug_features = ["bevy/free_camera"] +gamecube-adapter = ["dep:gc-adapter-neo"] [dependencies] bevy = { version = "0.19", features = ["asset_processor", "basis-universal", "compressed_image_saver", "bevy_settings"] } @@ -34,7 +35,6 @@ strum = "0.28.0" strum_macros = "0.28.0" bevy_asset_loader = "0.27.0" ron_asset_manager = "0.9.0" -gc-adapter-neo = { version = "1.1.1", features = ["libusb"] } rhai = "1.26.0" enum_cycling = "0.2.1" enum_cycling_derive = "0.2.1" @@ -49,3 +49,6 @@ inherits = "release" lto = "thin" codegen-units = 1 strip = "symbols" + +[target.'cfg(not(target_os = "windows"))'.dependencies] +gc-adapter-neo = { version = "1.1.1", features = ["libusb"], optional = true } diff --git a/src/input/gamecube/bridge.rs b/src/input/gamecube/bridge.rs index 97e9030..bb8d7a9 100644 --- a/src/input/gamecube/bridge.rs +++ b/src/input/gamecube/bridge.rs @@ -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; GC_PORT_COUNT], - last: [GcPortState; GC_PORT_COUNT], -} - fn passthrough_gamepad_settings() -> GamepadSettings { let mut settings = GamepadSettings::default(); for axis in GamepadAxis::all() { diff --git a/src/input/gamecube/mod.rs b/src/input/gamecube/mod.rs index 35ac83c..86c0c93 100644 --- a/src/input/gamecube/mod.rs +++ b/src/input/gamecube/mod.rs @@ -1,9 +1,20 @@ +#[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; 4], + #[cfg(all(feature = "gamecube-adapter", not(target_os = "windows")))] + pub(super) last: [poll::GcPortState; 4], +} + use bevy::input::InputSystems; use bevy::input::gamepad::{gamepad_connection_system, gamepad_event_processing_system}; use bevy::prelude::*; @@ -15,21 +26,24 @@ impl Plugin for GamecubeAdapterPlugin { fn build(&self, app: &mut App) { app.init_resource::(); - 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), + ); + } } } -- 2.54.0 From cdea632dae87672a883a7c9088ff54b7d09f6709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Rom=C3=A1n=20N=C3=BA=C3=B1ez?= Date: Fri, 2 Oct 2026 11:38:51 +0200 Subject: [PATCH 2/2] Fix build --- src/input/gamecube/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/input/gamecube/mod.rs b/src/input/gamecube/mod.rs index 86c0c93..8eceb87 100644 --- a/src/input/gamecube/mod.rs +++ b/src/input/gamecube/mod.rs @@ -15,7 +15,9 @@ pub struct GcPorts { 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::*; -- 2.54.0