
# Objective - Fix adding `#![allow(clippy::type_complexity)]` everywhere. like #9796 ## Solution - Use the new [lints] table that will land in 1.74 (https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#lints) - inherit lint to the workspace, crates and examples. ``` [lints] workspace = true ``` ## Changelog - Bump rust version to 1.74 - Enable lints table for the workspace ```toml [workspace.lints.clippy] type_complexity = "allow" ``` - Allow type complexity for all crates and examples ```toml [lints] workspace = true ``` --------- Co-authored-by: Martín Maita <47983254+mnmaita@users.noreply.github.com>
46 lines
1.5 KiB
Rust
46 lines
1.5 KiB
Rust
//! Systems and type definitions for gamepad handling in Bevy.
|
|
//!
|
|
//! This crate is built on top of [GilRs](gilrs), a library
|
|
//! that handles abstracting over platform-specific gamepad APIs.
|
|
|
|
#![warn(missing_docs)]
|
|
|
|
mod converter;
|
|
mod gilrs_system;
|
|
mod rumble;
|
|
|
|
use bevy_app::{App, Plugin, PostUpdate, PreStartup, PreUpdate};
|
|
use bevy_ecs::prelude::*;
|
|
use bevy_input::InputSystem;
|
|
use bevy_utils::tracing::error;
|
|
use gilrs::GilrsBuilder;
|
|
use gilrs_system::{gilrs_event_startup_system, gilrs_event_system};
|
|
use rumble::{play_gilrs_rumble, RunningRumbleEffects};
|
|
|
|
/// Plugin that provides gamepad handling to an [`App`].
|
|
#[derive(Default)]
|
|
pub struct GilrsPlugin;
|
|
|
|
/// Updates the running gamepad rumble effects.
|
|
#[derive(Debug, PartialEq, Eq, Clone, Hash, SystemSet)]
|
|
pub struct RumbleSystem;
|
|
|
|
impl Plugin for GilrsPlugin {
|
|
fn build(&self, app: &mut App) {
|
|
match GilrsBuilder::new()
|
|
.with_default_filters(false)
|
|
.set_update_state(false)
|
|
.build()
|
|
{
|
|
Ok(gilrs) => {
|
|
app.insert_non_send_resource(gilrs)
|
|
.init_non_send_resource::<RunningRumbleEffects>()
|
|
.add_systems(PreStartup, gilrs_event_startup_system)
|
|
.add_systems(PreUpdate, gilrs_event_system.before(InputSystem))
|
|
.add_systems(PostUpdate, play_gilrs_rumble.in_set(RumbleSystem));
|
|
}
|
|
Err(err) => error!("Failed to start Gilrs. {}", err),
|
|
}
|
|
}
|
|
}
|