Skip to content

Commit

Permalink
Remove petitset dependency (#400)
Browse files Browse the repository at this point in the history
* Fix typo

* Update release notes

* Straightforward migration

* Remove useless test for from impl

* Just use a Vec for chords :(

* Clone because our API is jank

* Hash all the types

* Repair tests after swapping to a Vec

* Simple fixes for binding_map

* Remove binding_menu egui example due to maintenance burden

* Clippy

* Fix idempotency of insertion

* Remove brittle serde test

* Simple doc test fixes

* Remove outdated references to 16 max input maps

* Implement Reflect for InputMap

Closes #386.

* Reflect UserInput

Closes #331

* Simple fix for doc test

* Fix mismatched HashMap types in doc test

* Remove example using removed API

* Switch `A::variants()` to `self.iter()` (#411)

* Update for Bevy 0.12 (#408)

* Update to git

* forgot a configure_set

* Update examples

* Update Bevy to 0.12 release

* Bump versions

* Disable failing test

* Remove bevy_egui so we can ship

* Update release notes

---------

Co-authored-by: Tomato <[email protected]>
Co-authored-by: Alice Cecile <[email protected]>

* Add back `bevy_egui` to LWIM 0.11 (#409)

* Update to `bevy_egui` 0.23 for Bevy 0.12

* Bump to 0.11.1

* Update RELEASES.md

* Switch `A::variants()` to `self.iter()`

---------

Co-authored-by: Alice Cecile <[email protected]>
Co-authored-by: Alice Cecile <[email protected]>

---------

Co-authored-by: Tomato <[email protected]>
Co-authored-by: Alice Cecile <[email protected]>
  • Loading branch information
3 people authored Nov 11, 2023
1 parent 42b0b21 commit 6d98b8e
Show file tree
Hide file tree
Showing 23 changed files with 188 additions and 431 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ bevy = { version = "0.12", default-features = false, features = [
] }
bevy_egui = { version = "0.23", optional = true }

petitset = { version = "0.2.1", features = ["serde_compat"] }
derive_more = { version = "0.99", default-features = false, features = [
"display",
"error",
Expand All @@ -41,6 +40,7 @@ itertools = "0.11"
serde = { version = "1.0", features = ["derive"] }
fixedbitset = "0.4.2"
once_cell = "1.17.1"
multimap = "0.9.0"

[dev-dependencies]
bevy = { version = "0.12", default-features = false, features = [
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn main() {
}
// This is the list of "things in the game I want to be able to do based on input"
#[derive(Actionlike, PartialEq, Eq, Clone, Copy, Hash, Debug, Reflect)]
#[derive(Actionlike, PartialEq, Eq, Hash, Clone, Copy, Debug, Reflect)]
enum Action {
Run,
Jump,
Expand Down
41 changes: 33 additions & 8 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Release Notes

## Unreleased
## Version 0.11.1
- `bevy_egui` integration and the `egui` feature flag have been added back with the release of `bevy_egui` 0.23.

### Bugs
- A disabled `ToggleActions` of one `Action` now does not release other `Action`'s inputs.
Expand All @@ -18,15 +19,19 @@

### Bugs

- Fixed system order ambiguity between bevy_ui and update_action_state systems
- The input values of axis inputs in a `Chord` are now prioritized over buttons
- Fixed unassigned `InputMaps`s not receiving input from all connected gamepads
### Known issues

### Docs
- `bevy_egui` integration and the `egui` feature flag have been temporarily removed to ensure a timely release
- gamepad input mocking is not completely functional due to upstream changes: see [#407](https://github.com/Leafwing-Studios/leafwing-input-manager/issues/407)
- additional experiments and information would be helpful!

- Fixed invalid example code in README
- Added example for setting default controls
- Added example for registering gamepads in a local multiplayer fashion
### Breaking Changes

- The `UserInput::insert_at` method has been removed: build this abstraction into your input binding menus if desired.
- `InputMap::iter()` now returns a simple iterator of (action, input) pairs
- As a result, the `InputMap::iter_inputs` method has been removed.
- The `InputMap::remove_at` API now returns `Some(removed_input)`, rather than just a `bool`.
- The serialization format for `InputMap` has changed. You will need to re-generate your input maps if you were storing these persistently.

### Enhancements

Expand All @@ -37,6 +42,26 @@
### Usability

- Added `block_ui_interactions` feature flag; when on, mouse input won't be read if any `bevy_ui` element has an active `Interaction`.
- Chords no longer have a max length.
- `InputMap`, `UserInput` and all of the contained types now implement `Reflect`. As a result, the trait bound on `Actionlike` has been changed from `TypePath` to `Reflect`.

### Bugs

- Fixed system order ambiguity between bevy_ui and update_action_state systems
- The input values of axis inputs in a `Chord` are now prioritized over buttons
- Fixed unassigned `InputMaps`s not receiving input from all connected gamepads

### Performance

- Removed the `petitset` dependency in favor of a `MultiMap` to reduce stack size of input types.
- As a result, the `Actionlike` trait now has the additional `Hash` and `Eq` trait bounds
- `UserInput::Chord` now stores a simple `Vec` of `InputKind`s

### Docs

- Fixed invalid example code in README
- Added example for setting default controls
- Added example for registering gamepads in a local multiplayer fashion

## Version 0.10

Expand Down
2 changes: 1 addition & 1 deletion examples/arpg_indirection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ enum Slot {
}

// The list of possible abilities is typically longer than the list of slots
#[derive(Actionlike, PartialEq, Eq, Clone, Debug, Copy, Reflect)]
#[derive(Actionlike, PartialEq, Eq, Hash, Clone, Debug, Copy, Reflect)]
enum Ability {
Slash,
Shoot,
Expand Down
2 changes: 1 addition & 1 deletion examples/consuming_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn main() {
.run()
}

#[derive(Actionlike, Debug, Clone, Reflect)]
#[derive(Actionlike, Debug, Clone, Reflect, PartialEq, Eq, Hash)]
enum MenuAction {
CloseWindow,
OpenMainMenu,
Expand Down
2 changes: 1 addition & 1 deletion examples/mouse_motion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn main() {
.run()
}

#[derive(Actionlike, Clone, Debug, Copy, PartialEq, Eq, Reflect)]
#[derive(Actionlike, Clone, Debug, Copy, PartialEq, Eq, Hash, Reflect)]
enum CameraMovement {
Pan,
}
Expand Down
2 changes: 1 addition & 1 deletion examples/mouse_position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn main() {
.run();
}

#[derive(Actionlike, Clone, Debug, Copy, PartialEq, Eq, Reflect)]
#[derive(Actionlike, Clone, Debug, Copy, PartialEq, Eq, Hash, Reflect)]
enum BoxMovement {
MousePosition,
}
Expand Down
2 changes: 1 addition & 1 deletion examples/mouse_wheel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn main() {
.run()
}

#[derive(Actionlike, Clone, Debug, Copy, PartialEq, Eq, Reflect)]
#[derive(Actionlike, Clone, Debug, Copy, PartialEq, Eq, Hash, Reflect)]
enum CameraMovement {
Zoom,
PanLeft,
Expand Down
22 changes: 11 additions & 11 deletions src/action_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub struct ActionData {
/// use leafwing_input_manager::prelude::*;
/// use bevy::utils::Instant;
///
/// #[derive(Actionlike, PartialEq, Eq, Clone, Copy, Debug, Reflect)]
/// #[derive(Actionlike, PartialEq, Eq, Hash, Clone, Copy, Debug, Reflect)]
/// enum Action {
/// Left,
/// Right,
Expand Down Expand Up @@ -127,7 +127,7 @@ impl<A: Actionlike> ActionState<A> {
/// use leafwing_input_manager::buttonlike::ButtonState;
/// use bevy::utils::Instant;
///
/// #[derive(Actionlike, Clone, Copy, PartialEq, Eq, Debug, Reflect)]
/// #[derive(Actionlike, Clone, Copy, PartialEq, Eq, Hash, Debug, Reflect)]
/// enum Action {
/// Run,
/// Jump,
Expand Down Expand Up @@ -180,7 +180,7 @@ impl<A: Actionlike> ActionState<A> {
/// use bevy::prelude::Reflect;
/// use leafwing_input_manager::prelude::*;
///
/// #[derive(Actionlike, Clone, Copy, PartialEq, Eq, Debug, Reflect)]
/// #[derive(Actionlike, Clone, Copy, PartialEq, Eq, Hash, Debug, Reflect)]
/// enum Action {
/// Run,
/// Jump,
Expand All @@ -206,7 +206,7 @@ impl<A: Actionlike> ActionState<A> {
/// use bevy::prelude::Reflect;
/// use leafwing_input_manager::prelude::*;
///
/// #[derive(Actionlike, Clone, Copy, PartialEq, Eq, Debug, Reflect)]
/// #[derive(Actionlike, Clone, Copy, PartialEq, Eq, Hash, Debug, Reflect)]
/// enum Action {
/// Run,
/// Jump,
Expand Down Expand Up @@ -294,13 +294,13 @@ impl<A: Actionlike> ActionState<A> {
/// use bevy::prelude::Reflect;
/// use leafwing_input_manager::prelude::*;
///
/// #[derive(Actionlike, Clone, Copy, PartialEq, Eq, Debug, Reflect)]
/// #[derive(Actionlike, Clone, Copy, PartialEq, Eq, Hash, Debug, Reflect)]
/// enum AbilitySlot {
/// Slot1,
/// Slot2,
/// }
///
/// #[derive(Actionlike, Clone, Copy, PartialEq, Eq, Debug, Reflect)]
/// #[derive(Actionlike, Clone, Copy, PartialEq, Eq, Hash, Debug, Reflect)]
/// enum Action {
/// Run,
/// Jump,
Expand Down Expand Up @@ -372,7 +372,7 @@ impl<A: Actionlike> ActionState<A> {
/// use bevy::prelude::Reflect;
/// use leafwing_input_manager::prelude::*;
///
/// #[derive(Actionlike, Clone, Copy, PartialEq, Eq, Debug, Reflect)]
/// #[derive(Actionlike, Clone, Copy, PartialEq, Eq, Hash, Debug, Reflect)]
/// enum Action {
/// Eat,
/// Sleep,
Expand Down Expand Up @@ -522,7 +522,7 @@ impl<A: Actionlike> Default for ActionState<A> {
/// use bevy::prelude::*;
/// use leafwing_input_manager::prelude::*;
///
/// #[derive(Actionlike, Clone, Copy, Reflect)]
/// #[derive(Actionlike, PartialEq, Eq, Hash, Clone, Copy, Reflect)]
/// enum DanceDance {
/// Left,
/// Right,
Expand Down Expand Up @@ -551,7 +551,7 @@ impl<A: Actionlike> Default for ActionState<A> {
/// although this should be reserved for cases where the entity whose value you want to check
/// is distinct from the entity whose [`ActionState`] you want to set.
/// Check the source code of [`update_action_state_from_interaction`](crate::systems::update_action_state_from_interaction) for an example of how this is done.
#[derive(Component, Clone, PartialEq, Eq)]
#[derive(Debug, Component, Clone, PartialEq, Eq)]
pub struct ActionStateDriver<A: Actionlike> {
/// The action triggered by this entity
pub action: A,
Expand All @@ -560,7 +560,7 @@ pub struct ActionStateDriver<A: Actionlike> {
}

/// Represents the entities that an ``ActionStateDriver`` targets.
#[derive(Component, Clone, PartialEq, Eq)]
#[derive(Debug, Component, Clone, PartialEq, Eq)]
pub enum ActionStateDriverTarget {
/// No targets
None,
Expand Down Expand Up @@ -785,7 +785,7 @@ mod tests {

use super::ActionStateDriverTarget;

#[derive(Actionlike, Clone, Copy, PartialEq, Eq, Debug, Reflect)]
#[derive(Actionlike, Clone, Copy, PartialEq, Eq, Hash, Debug, Reflect)]
enum Action {
Run,
Jump,
Expand Down
16 changes: 8 additions & 8 deletions src/axislike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use serde::{Deserialize, Serialize};
/// # Warning
///
/// `positive_low` must be greater than or equal to `negative_low` for this type to be validly constructed.
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize, Reflect)]
pub struct SingleAxis {
/// The axis that is being checked.
pub axis_type: AxisType,
Expand Down Expand Up @@ -203,7 +203,7 @@ impl std::hash::Hash for SingleAxis {
/// # Warning
///
/// `positive_low` must be greater than or equal to `negative_low` for both `x` and `y` for this type to be validly constructed.
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash, Reflect)]
pub struct DualAxis {
/// The axis representing horizontal movement.
pub x: SingleAxis,
Expand Down Expand Up @@ -342,7 +342,7 @@ impl DualAxis {
/// even though it can be stored as an [`InputKind`].
///
/// Instead, use it directly as [`InputKind::DualAxis`]!
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Reflect)]
pub struct VirtualDPad {
/// The input that represents the up direction in this virtual DPad
pub up: InputKind,
Expand Down Expand Up @@ -449,7 +449,7 @@ impl VirtualDPad {
/// even though it can be stored as an [`InputKind`].
///
/// Instead, use it directly as [`InputKind::SingleAxis`]!
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Reflect)]
pub struct VirtualAxis {
/// The input that represents the negative direction of this virtual axis
pub negative: InputKind,
Expand Down Expand Up @@ -516,7 +516,7 @@ impl VirtualAxis {
/// The type of axis used by a [`UserInput`](crate::user_input::UserInput).
///
/// This is stored in either a [`SingleAxis`] or [`DualAxis`].
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Reflect)]
pub enum AxisType {
/// Input associated with a gamepad, such as the triggers or one axis of an analog stick.
Gamepad(GamepadAxisType),
Expand All @@ -529,7 +529,7 @@ pub enum AxisType {
/// The direction of motion of the mouse wheel.
///
/// Stored in the [`AxisType`] enum.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Reflect)]
pub enum MouseWheelAxisType {
/// Horizontal movement.
///
Expand All @@ -544,7 +544,7 @@ pub enum MouseWheelAxisType {
/// The direction of motion of the mouse.
///
/// Stored in the [`AxisType`] enum.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Reflect)]
pub enum MouseMotionAxisType {
/// Horizontal movement.
X,
Expand Down Expand Up @@ -736,7 +736,7 @@ impl From<DualAxisData> for Vec2 {
/// If a volume of a shape is 0, then all input values are read.
///
/// Deadzone values should be in the range `0.0..=1.0`.
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Reflect)]
pub enum DeadZoneShape {
/// Deadzone with the shape of a cross.
///
Expand Down
4 changes: 2 additions & 2 deletions src/buttonlike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl ButtonState {
/// A buttonlike-input triggered by [`MouseWheel`](bevy::input::mouse::MouseWheel) events
///
/// These will be considered pressed if non-zero net movement in the correct direction is detected.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Reflect)]
pub enum MouseWheelDirection {
/// Corresponds to `+y`
Up,
Expand All @@ -102,7 +102,7 @@ pub enum MouseWheelDirection {
/// A buttonlike-input triggered by [`MouseMotion`](bevy::input::mouse::MouseMotion) events
///
/// These will be considered pressed if non-zero net movement in the correct direction is detected.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Reflect)]
pub enum MouseMotionDirection {
/// Corresponds to `+y`
Up,
Expand Down
Loading

0 comments on commit 6d98b8e

Please sign in to comment.