Disable GameCube adapter on Windows (#80)
## 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:
+5
-2
@@ -7,9 +7,10 @@ authors = [""]
|
|||||||
[workspace]
|
[workspace]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["development", "debug_features"]
|
default = ["development", "debug_features", "gamecube-adapter"]
|
||||||
development = ["bevy/dynamic_linking", "bevy/file_watcher", "bevy/embedded_watcher"]
|
development = ["bevy/dynamic_linking", "bevy/file_watcher", "bevy/embedded_watcher"]
|
||||||
debug_features = ["bevy/free_camera"]
|
debug_features = ["bevy/free_camera"]
|
||||||
|
gamecube-adapter = ["dep:gc-adapter-neo"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = { version = "0.19", features = ["asset_processor", "basis-universal", "compressed_image_saver", "bevy_settings"] }
|
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"
|
strum_macros = "0.28.0"
|
||||||
bevy_asset_loader = "0.27.0"
|
bevy_asset_loader = "0.27.0"
|
||||||
ron_asset_manager = "0.9.0"
|
ron_asset_manager = "0.9.0"
|
||||||
gc-adapter-neo = { version = "1.1.1", features = ["libusb"] }
|
|
||||||
rhai = "1.26.0"
|
rhai = "1.26.0"
|
||||||
enum_cycling = "0.2.1"
|
enum_cycling = "0.2.1"
|
||||||
enum_cycling_derive = "0.2.1"
|
enum_cycling_derive = "0.2.1"
|
||||||
@@ -49,3 +49,6 @@ inherits = "release"
|
|||||||
lto = "thin"
|
lto = "thin"
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
strip = "symbols"
|
strip = "symbols"
|
||||||
|
|
||||||
|
[target.'cfg(not(target_os = "windows"))'.dependencies]
|
||||||
|
gc-adapter-neo = { version = "1.1.1", features = ["libusb"], optional = true }
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ use bevy::input::gamepad::{
|
|||||||
};
|
};
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
use super::poll::{GcAdapterSnapshot, GcPortState};
|
use super::GcPorts;
|
||||||
|
use super::poll::GcAdapterSnapshot;
|
||||||
|
|
||||||
/// GameCube adapters report 4 ports.
|
/// GameCube adapters report 4 ports.
|
||||||
pub const GC_PORT_COUNT: usize = 4;
|
pub const GC_PORT_COUNT: usize = 4;
|
||||||
@@ -23,15 +24,6 @@ const GC_ADAPTER_PID: u16 = 0x0337;
|
|||||||
#[derive(Component, Debug, Clone, Copy)]
|
#[derive(Component, Debug, Clone, Copy)]
|
||||||
pub struct GcPort(pub u8);
|
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 {
|
fn passthrough_gamepad_settings() -> GamepadSettings {
|
||||||
let mut settings = GamepadSettings::default();
|
let mut settings = GamepadSettings::default();
|
||||||
for axis in GamepadAxis::all() {
|
for axis in GamepadAxis::all() {
|
||||||
|
|||||||
+32
-16
@@ -1,10 +1,23 @@
|
|||||||
|
#[cfg(all(feature = "gamecube-adapter", not(target_os = "windows")))]
|
||||||
pub mod bridge;
|
pub mod bridge;
|
||||||
|
#[cfg(all(feature = "gamecube-adapter", not(target_os = "windows")))]
|
||||||
pub mod poll;
|
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};
|
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;
|
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::input::gamepad::{gamepad_connection_system, gamepad_event_processing_system};
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
@@ -15,21 +28,24 @@ impl Plugin for GamecubeAdapterPlugin {
|
|||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.init_resource::<GcPorts>();
|
app.init_resource::<GcPorts>();
|
||||||
|
|
||||||
let Ok(snapshot) = poll::spawn_poll_thread() else {
|
#[cfg(all(feature = "gamecube-adapter", not(target_os = "windows")))]
|
||||||
// No adapter connected; leave GcPorts empty and skip wiring the
|
{
|
||||||
// polling systems.
|
let Ok(snapshot) = poll::spawn_poll_thread() else {
|
||||||
return;
|
// No adapter connected; leave GcPorts empty and skip wiring the
|
||||||
};
|
// polling systems.
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
app.insert_resource(snapshot).add_systems(
|
app.insert_resource(snapshot).add_systems(
|
||||||
PreUpdate,
|
PreUpdate,
|
||||||
(
|
(
|
||||||
bridge::gc_connection_system.before(gamepad_connection_system),
|
bridge::gc_connection_system.before(gamepad_connection_system),
|
||||||
bridge::gc_event_system
|
bridge::gc_event_system
|
||||||
.after(gamepad_connection_system)
|
.after(gamepad_connection_system)
|
||||||
.before(gamepad_event_processing_system),
|
.before(gamepad_event_processing_system),
|
||||||
)
|
)
|
||||||
.in_set(InputSystems),
|
.in_set(InputSystems),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user