Skip to content

Commit

Permalink
address
Browse files Browse the repository at this point in the history
  • Loading branch information
Shute052 committed Sep 13, 2024
1 parent 6f6b89f commit 88bbaac
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
10 changes: 6 additions & 4 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release Notes

## Version 0.16.0 (Unreleased)

### Usability (0.16.0)

- added `threshold` value for `GamepadControlDirection`, `MouseMoveDirection`, and `MouseScrollDirection` to be considered pressed.

## Version 0.15.1

### Enhancements (0.15.1)
Expand All @@ -25,10 +31,6 @@

- Reflect `Component` and `Resource`, which enables accessing the data in the type registry

#### Inputs

- added `threshold` value for `GamepadControlDirection`, `MouseMoveDirection`, and `MouseScrollDirection` to be considered pressed.

#### ActionDiffEvent

- Implement `MapEntities`, which lets networking crates translate owner entity IDs between ECS worlds
Expand Down
5 changes: 3 additions & 2 deletions src/axislike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ impl AxisDirection {
}

/// Checks if the given `value` represents an active input in this direction,
/// considering the specified `threshold`.
/// considering the specified `threshold` (Must be non-negative).
#[must_use]
#[inline]
pub fn is_active(&self, value: f32, threshold: f32) -> bool {
assert!(threshold >= 0.0);
match self {
Self::Negative => value < -threshold,
Self::Positive => value > threshold,
Expand Down Expand Up @@ -153,7 +154,7 @@ impl DualAxisDirection {
}

/// Checks if the given `value` represents an active input in this direction,
/// considering the specified `threshold`.
/// considering the specified `threshold` (Must be non-negative).
#[must_use]
#[inline]
pub fn is_active(&self, value: Vec2, threshold: f32) -> bool {
Expand Down
4 changes: 3 additions & 1 deletion src/user_input/gamepad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ pub struct GamepadControlDirection {
pub direction: AxisDirection,

/// The threshold value for the direction to be considered pressed.
/// Must be non-negative.
pub threshold: f32,
}

Expand All @@ -106,9 +107,10 @@ impl GamepadControlDirection {
}
}

/// Sets the `threshold` value.
/// Sets the `threshold` value. Must be non-negative.
#[inline]
pub const fn threshold(mut self, threshold: f32) -> Self {
assert!(threshold >= 0.0);
self.threshold = threshold;
self
}
Expand Down
8 changes: 6 additions & 2 deletions src/user_input/mouse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,15 @@ pub struct MouseMoveDirection {
pub direction: DualAxisDirection,

/// The threshold value for the direction to be considered pressed.
/// Must be non-negative.
pub threshold: f32,
}

impl MouseMoveDirection {
/// Sets the `threshold` value.
/// Sets the `threshold` value. Must be non-negative.
#[inline]
pub const fn threshold(mut self, threshold: f32) -> Self {
assert!(threshold >= 0.0);
self.threshold = threshold;
self
}
Expand Down Expand Up @@ -469,13 +471,15 @@ pub struct MouseScrollDirection {
pub direction: DualAxisDirection,

/// The threshold value for the direction to be considered pressed.
/// Must be non-negative.
pub threshold: f32,
}

impl MouseScrollDirection {
/// Sets the `threshold` value.
/// Sets the `threshold` value. Must be non-negative.
#[inline]
pub const fn threshold(mut self, threshold: f32) -> Self {
assert!(threshold >= 0.0);
self.threshold = threshold;
self
}
Expand Down

0 comments on commit 88bbaac

Please sign in to comment.