Skip to content

Commit

Permalink
Reflect derived traits on all components and resources: bevy_input (#…
Browse files Browse the repository at this point in the history
…15220)

Solves #15187 for bevy_input
  • Loading branch information
blazepaws authored Sep 15, 2024
1 parent 569f68f commit e718bbd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion crates/bevy_input/src/button_input.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! The generic input type.

#[cfg(feature = "bevy_reflect")]
use bevy_ecs::reflect::ReflectResource;
use bevy_ecs::system::Resource;
#[cfg(feature = "bevy_reflect")]
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
Expand Down Expand Up @@ -154,7 +156,7 @@ use std::hash::Hash;
///[`ResMut`]: bevy_ecs::system::ResMut
///[`DetectChangesMut::bypass_change_detection`]: bevy_ecs::change_detection::DetectChangesMut::bypass_change_detection
#[derive(Debug, Clone, Resource)]
#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Default))]
#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Default, Resource))]
pub struct ButtonInput<T: Copy + Eq + Hash + Send + Sync + 'static> {
/// A collection of every button that is currently being pressed.
pressed: HashSet<T>,
Expand Down
8 changes: 7 additions & 1 deletion crates/bevy_input/src/gamepad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

use crate::{Axis, ButtonInput, ButtonState};
use bevy_ecs::event::{Event, EventReader, EventWriter};
#[cfg(feature = "bevy_reflect")]
use bevy_ecs::reflect::ReflectResource;
use bevy_ecs::{
change_detection::DetectChangesMut,
system::{Res, ResMut, Resource},
Expand Down Expand Up @@ -384,7 +386,11 @@ impl GamepadAxis {
/// should register as a [`GamepadEvent`]. Events that don't meet the change thresholds defined in [`GamepadSettings`]
/// will not register. To modify these settings, mutate the corresponding resource.
#[derive(Resource, Default, Debug)]
#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Debug, Default))]
#[cfg_attr(
feature = "bevy_reflect",
derive(Reflect),
reflect(Debug, Default, Resource)
)]

pub struct GamepadSettings {
/// The default button settings.
Expand Down

0 comments on commit e718bbd

Please sign in to comment.