Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the dependencies to bevy 0.13 and bevy_egui 0.25 #463

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
0a3ffed
Update the dependencies to `bevy` 0.13 and `bevy_egui` 0.25
Shute052 Feb 3, 2024
ac9df18
Remove `ScanCode` and fix linter by refactoring
Shute052 Feb 3, 2024
fe74fe3
fix linter
Shute052 Feb 3, 2024
8caeaf4
Rename
Shute052 Feb 3, 2024
7908944
Bad linter warning
Shute052 Feb 3, 2024
b60f162
Send a placeholder like 'Mocking' as a logical key
Shute052 Feb 3, 2024
582c2aa
Incorrect sign
Shute052 Feb 3, 2024
58a62e0
Fix issues in docs
Shute052 Feb 3, 2024
31db397
Update RELEASES.md
Shute052 Feb 3, 2024
c6f6973
Fix docs
Shute052 Feb 3, 2024
15c5553
Merge branch 'main' into bevy_0.13
Shute052 Feb 3, 2024
4c84908
Update RELEASES.md
Shute052 Feb 3, 2024
c1877ff
Remove `Copy` from `InputKind` and add `InputKind::Keyboard(Key)`
Shute052 Feb 4, 2024
7d15ffd
Fix `input_mocking`
Shute052 Feb 4, 2024
610d2d6
Fix
Shute052 Feb 4, 2024
bc2b168
Add example for logical key bindings
Shute052 Feb 4, 2024
7d40896
fix egui
Shute052 Feb 4, 2024
b1d41b3
Fix linter
Shute052 Feb 4, 2024
1f44181
Replace `Keyboard` and `KeyLocation` in `InputKind` with more straigh…
Shute052 Feb 4, 2024
41b8ef1
Update RELEASES.md
Shute052 Feb 4, 2024
737cb09
Bad fmt
Shute052 Feb 4, 2024
06d14fb
Remove feature flag `logical_key_binding` and make the MSVC linker happy
Shute052 Feb 4, 2024
bf5d02c
Fix the linter report and make them happy
Shute052 Feb 4, 2024
f81e84d
Make the compiler happy
Shute052 Feb 4, 2024
8af1fc6
Make the clippy happy
Shute052 Feb 4, 2024
017e5bf
Fix the unintended `JustReleased` of logical keys
Shute052 Feb 4, 2024
d7b1a3d
Clean up
Shute052 Feb 4, 2024
6cea797
Avoid memory leaking
Shute052 Feb 4, 2024
9404645
Split unrelated changes out of this PR
Shute052 Feb 5, 2024
ed7bb00
Eliminate the logical keybindings system
Shute052 Feb 5, 2024
a0dc3bf
Revert "Split unrelated changes out of this PR"
Shute052 Feb 5, 2024
23fbb31
Fix testing with no-default-features
Shute052 Feb 5, 2024
73b869c
Refactor the logic for simplification and improved performance
Shute052 Feb 5, 2024
4bcc875
Make clippy happy
Shute052 Feb 5, 2024
655a7f6
Use `extract_single_axis_data`
Shute052 Feb 5, 2024
8c28761
Cleanup
Shute052 Feb 5, 2024
b9ccd92
Update to Bevy 0.13 and Egui 0.26.2
Shute052 Feb 18, 2024
898d358
Fix typo
Shute052 Feb 18, 2024
d5f2cb1
Cleanup
Shute052 Feb 18, 2024
fbc1d6c
Improve readability
Shute052 Feb 18, 2024
2b069dd
Extract function
Shute052 Feb 18, 2024
55994cd
Add dependency `bevy/bevy_asset`
Shute052 Feb 18, 2024
a8e0011
Add a feature gate for `bevy/bevy_asset`
Shute052 Feb 18, 2024
467734e
doc
Shute052 Feb 19, 2024
2595c64
Merge branch 'main' into bevy_0.13
Shute052 Feb 19, 2024
917f233
Add supported Bevy versions in README.md
Shute052 Feb 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ opt-level = 3
members = ["./", "tools/ci", "macros"]

[features]
default = ['ui', 'block_ui_interactions']
default = ['asset', 'ui', 'block_ui_interactions']

# Allow you to use the `InputMap` as `bevy::asset::Asset`.
asset = ['bevy/bevy_asset']

# Provide functionality refer to `bevy::ui`:
# - `MockUIInteraction` for `bevy::ui` input mocking.
Expand All @@ -35,11 +38,12 @@ egui = ['dep:bevy_egui']

[dependencies]
leafwing_input_manager_macros = { path = "macros", version = "0.12" }
bevy = { version = "0.12", default-features = false, features = [
bevy = { version = "0.13", default-features = false, features = [
"serialize",
"bevy_gilrs",
] }
bevy_egui = { version = "0.24", optional = true }
# TODO(clean): Existing PR repo for update `bevy_egui` to bevy 0.13
bevy_egui = { git = "https://github.com/Shute052/bevy_egui.git", branch = "Bevy-0.13-and-Egui-0.26", optional = true }

derive_more = { version = "0.99", default-features = false, features = [
"display",
Expand All @@ -51,7 +55,7 @@ fixedbitset = "0.4.2"
once_cell = "1.17.1"

[dev-dependencies]
bevy = { version = "0.12", default-features = false, features = [
bevy = { version = "0.13", default-features = false, features = [
"bevy_asset",
"bevy_sprite",
"bevy_text",
Expand All @@ -60,7 +64,8 @@ bevy = { version = "0.12", default-features = false, features = [
"bevy_core_pipeline",
"x11",
] }
bevy_egui = { version = "0.24" }
# TODO(clean): Existing PR repo for update `bevy_egui` to bevy 0.13
bevy_egui = { git = "https://github.com/Shute052/bevy_egui.git", branch = "Bevy-0.13-and-Egui-0.26" }
serde_test = "1.0"
criterion = "0.5"

Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ The mapping between inputs and actions is many-to-many, and easily configured an
A single action can be triggered by multiple inputs (or set directly by UI elements or gameplay logic),
and a single input can result in multiple actions being triggered, which can be handled contextually.

## Supported Bevy Versions

| Bevy | leafwing-input-manager |
|------|------------------------|
| 0.13 | 0.13 |
| 0.12 | 0.11..0.12 |
| 0.11 | 0.10 |
| 0.10 | 0.9 |
| 0.9 | 0.7..0.8 |

## Features

- Full keyboard, mouse and joystick support for button-like and axis inputs
Expand All @@ -25,13 +35,13 @@ and a single input can result in multiple actions being triggered, which can be
- Ergonomic insertion API that seamlessly blends multiple input types for you
- Can't decide between `input_map.insert(Action::Jump, KeyCode::Space)` and `input_map.insert(Action::Jump, GamepadButtonType::South)`? Have both!
- Full support for arbitrary button combinations: chord your heart out.
- `input_map.insert_chord(Action::Console, [KeyCode::ControlLeft, KeyCode::Shift, KeyCode::C])`
- `input_map.insert_chord(Action::Console, [KeyCode::ControlLeft, KeyCode::Shift, KeyCode::KeyC])`
- Sophisticated input disambiguation with the `ClashStrategy` enum: stop triggering individual buttons when you meant to press a chord!
- Create an arbitrary number of strongly typed disjoint action sets by adding multiple copies of this plugin: decouple your camera and player state
- Local multiplayer support: freely bind keys to distinct entities, rather than worrying about singular global state
- Networked multiplayer support: serializable structs, and a space-conscious `ActionDiff` representation to send on the wire
- Powerful and easy-to-use input mocking API for integration testing your Bevy applications
- `app.send_input(KeyCode::B)` or `world.send_input(UserInput::chord([KeyCode::B, KeyCode::E, KeyCode::V, KeyCode::Y])`
- `app.send_input(KeyCode::KeyB)` or `world.send_input(UserInput::chord([KeyCode::KeyB, KeyCode::KeyE, KeyCode::KeyV, KeyCode::KeyY])`
- Control which state this plugin is active in: stop wandering around while in a menu!
- Leafwing Studio's trademark `#![forbid(missing_docs)]`

Expand Down Expand Up @@ -100,5 +110,5 @@ This snippet is the `minimal.rs` example from the [`examples`](./examples) folde

## Crate Feature Flags

This crate has three feature flags: `ui`, `block_ui_interactions`, and `egui`.
This crate has four feature flags: `asset`, `ui`, `block_ui_interactions`, and `egui`.
Please refer to the `[features]` section in the [`Cargo.toml`](./Cargo.toml) for detailed information about their configurations.
18 changes: 18 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Release Notes

## Unreleased

### Breaking Changes

- both `KeyCode`-based logical keybindings and `ScanCode`-based physical keybindings are no longer supported;
- please migrate to:
- `KeyCode` is now representing physical keybindings.
- `InputKind::KeyLocation` have been removed; please use `InputKind::PhysicalKey` instead.
- `ScanCode` and `QwertyScanCode` have been removed; please use `KeyCode` instead:
- all letter keys now follow the format `KeyCode::Key<Letter>`, e.g., `ScanCode::K` is now `KeyCode::KeyK`.
- all number keys over letters now follow the format `KeyCode::Digit<Number>`, e.g., `ScanCode::Key1` is now `KeyCode::Digit1`.
- all arrow keys now follow the format `KeyCode::Arrow<Direction>`, e.g., `ScanCode::Up` is now `KeyCode::ArrowUp`.

### Usability

- `bevy` dependency has been bumped from 0.12 to 0.13.
- `bevy_egui` dependency has been bumped from 0.24 to 0.25.

## Version 0.12

### Enhancements
Expand Down
44 changes: 22 additions & 22 deletions benches/input_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,32 @@ enum TestAction {

fn construct_input_map_from_iter() -> InputMap<TestAction> {
black_box(InputMap::new([
(TestAction::A, KeyCode::A),
(TestAction::B, KeyCode::B),
(TestAction::C, KeyCode::C),
(TestAction::D, KeyCode::D),
(TestAction::E, KeyCode::E),
(TestAction::F, KeyCode::F),
(TestAction::G, KeyCode::G),
(TestAction::H, KeyCode::H),
(TestAction::I, KeyCode::I),
(TestAction::J, KeyCode::J),
(TestAction::A, KeyCode::KeyA),
(TestAction::B, KeyCode::KeyB),
(TestAction::C, KeyCode::KeyC),
(TestAction::D, KeyCode::KeyD),
(TestAction::E, KeyCode::KeyE),
(TestAction::F, KeyCode::KeyF),
(TestAction::G, KeyCode::KeyG),
(TestAction::H, KeyCode::KeyH),
(TestAction::I, KeyCode::KeyI),
(TestAction::J, KeyCode::KeyJ),
]))
}

fn construct_input_map_from_chained_calls() -> InputMap<TestAction> {
black_box(
InputMap::default()
.insert(TestAction::A, KeyCode::A)
.insert(TestAction::B, KeyCode::B)
.insert(TestAction::C, KeyCode::C)
.insert(TestAction::D, KeyCode::D)
.insert(TestAction::E, KeyCode::E)
.insert(TestAction::F, KeyCode::F)
.insert(TestAction::G, KeyCode::G)
.insert(TestAction::H, KeyCode::H)
.insert(TestAction::I, KeyCode::I)
.insert(TestAction::J, KeyCode::J)
.insert(TestAction::A, KeyCode::KeyA)
.insert(TestAction::B, KeyCode::KeyB)
.insert(TestAction::C, KeyCode::KeyC)
.insert(TestAction::D, KeyCode::KeyD)
.insert(TestAction::E, KeyCode::KeyE)
.insert(TestAction::F, KeyCode::KeyF)
.insert(TestAction::G, KeyCode::KeyG)
.insert(TestAction::H, KeyCode::KeyH)
.insert(TestAction::I, KeyCode::KeyI)
.insert(TestAction::J, KeyCode::KeyJ)
.build(),
)
}
Expand All @@ -78,8 +78,8 @@ pub fn criterion_benchmark(c: &mut Criterion) {
// Constructing our test app / input stream outside of the timed benchmark
let mut app = App::new();
app.add_plugins(InputPlugin);
app.send_input(KeyCode::A);
app.send_input(KeyCode::B);
app.send_input(KeyCode::KeyA);
app.send_input(KeyCode::KeyB);
app.update();

let input_streams = InputStreams::from_world(&app.world, None);
Expand Down
2 changes: 1 addition & 1 deletion examples/action_state_resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl PlayerAction {
fn mkb_input_map() -> InputMap<PlayerAction> {
use KeyCode::*;
InputMap::new([
(Self::Jump, UserInput::Single(InputKind::Keyboard(Space))),
(Self::Jump, UserInput::Single(InputKind::PhysicalKey(Space))),
(Self::Move, UserInput::VirtualDPad(VirtualDPad::wasd())),
])
}
Expand Down
8 changes: 4 additions & 4 deletions examples/arpg_indirection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ fn spawn_player(mut commands: Commands) {
commands.spawn(PlayerBundle {
player: Player,
slot_input_map: InputMap::new([
(Slot::Ability1, Q),
(Slot::Ability2, W),
(Slot::Ability3, E),
(Slot::Ability4, R),
(Slot::Ability1, KeyQ),
(Slot::Ability2, KeyW),
(Slot::Ability3, KeyE),
(Slot::Ability4, KeyR),
])
.insert(Slot::Primary, MouseButton::Left)
.insert(Slot::Secondary, MouseButton::Right)
Expand Down
10 changes: 5 additions & 5 deletions examples/clash_handling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ fn spawn_input_map(mut commands: Commands) {
let mut input_map = InputMap::default();

// Setting up input mappings in the obvious way
input_map.insert_multiple([(One, Key1), (Two, Key2), (Three, Key3)]);
input_map.insert_multiple([(One, Digit1), (Two, Digit2), (Three, Digit3)]);

input_map.insert_chord(OneAndTwo, [Key1, Key2]);
input_map.insert_chord(OneAndThree, [Key1, Key3]);
input_map.insert_chord(TwoAndThree, [Key2, Key3]);
input_map.insert_chord(OneAndTwo, [Digit1, Digit2]);
input_map.insert_chord(OneAndThree, [Digit1, Digit3]);
input_map.insert_chord(TwoAndThree, [Digit2, Digit3]);

input_map.insert_chord(OneAndTwoAndThree, [Key1, Key2, Key3]);
input_map.insert_chord(OneAndTwoAndThree, [Digit1, Digit2, Digit3]);

commands.spawn(InputManagerBundle {
input_map,
Expand Down
4 changes: 2 additions & 2 deletions examples/consuming_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ fn main() {
.init_resource::<ActionState<MenuAction>>()
.insert_resource(InputMap::<MenuAction>::new([
(MenuAction::CloseWindow, KeyCode::Escape),
(MenuAction::OpenMainMenu, KeyCode::M),
(MenuAction::OpenSubMenu, KeyCode::S),
(MenuAction::OpenMainMenu, KeyCode::KeyM),
(MenuAction::OpenSubMenu, KeyCode::KeyS),
]))
.init_resource::<MainMenu>()
.init_resource::<SubMenu>()
Expand Down
2 changes: 1 addition & 1 deletion examples/default_controls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl PlayerAction {
// Match against the provided action to get the correct default keyboard-mouse input
match self {
Self::Run => UserInput::VirtualDPad(VirtualDPad::wasd()),
Self::Jump => UserInput::Single(InputKind::Keyboard(KeyCode::Space)),
Self::Jump => UserInput::Single(InputKind::PhysicalKey(KeyCode::Space)),
Self::UseItem => UserInput::Single(InputKind::Mouse(MouseButton::Left)),
}
}
Expand Down
12 changes: 6 additions & 6 deletions examples/multiplayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ impl PlayerBundle {
fn input_map(player: Player) -> InputMap<Action> {
let mut input_map = match player {
Player::One => InputMap::new([
(Action::Left, KeyCode::A),
(Action::Right, KeyCode::D),
(Action::Jump, KeyCode::W),
(Action::Left, KeyCode::KeyA),
(Action::Right, KeyCode::KeyD),
(Action::Jump, KeyCode::KeyW),
])
// This is a quick and hacky solution:
// you should coordinate with the `Gamepads` resource to determine the correct gamepad for each player
Expand All @@ -44,9 +44,9 @@ impl PlayerBundle {
.set_gamepad(Gamepad { id: 0 })
.build(),
Player::Two => InputMap::new([
(Action::Left, KeyCode::Left),
(Action::Right, KeyCode::Right),
(Action::Jump, KeyCode::Up),
(Action::Left, KeyCode::ArrowLeft),
(Action::Right, KeyCode::ArrowRight),
(Action::Jump, KeyCode::ArrowUp),
])
.set_gamepad(Gamepad { id: 1 })
.build(),
Expand Down
73 changes: 0 additions & 73 deletions examples/physical_key_bindings.rs

This file was deleted.

8 changes: 4 additions & 4 deletions examples/press_duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ impl PlayerBundle {
use Action::*;

InputMap::new([
(Left, KeyCode::A),
(Left, KeyCode::Left),
(Right, KeyCode::D),
(Right, KeyCode::Right),
(Left, KeyCode::KeyA),
(Left, KeyCode::ArrowLeft),
(Right, KeyCode::KeyD),
(Right, KeyCode::ArrowRight),
])
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/register_gamepads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn join(
mut commands: Commands,
mut joined_players: ResMut<JoinedPlayers>,
gamepads: Res<Gamepads>,
button_inputs: Res<Input<GamepadButton>>,
button_inputs: Res<ButtonInput<GamepadButton>>,
) {
for gamepad in gamepads.iter() {
// Join the game when both bumpers (L+R) on the controller are pressed
Expand Down
2 changes: 1 addition & 1 deletion examples/send_actions_over_network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ fn spawn_player(mut commands: Commands) {

commands
.spawn(InputManagerBundle {
input_map: InputMap::new([(MoveLeft, W), (MoveRight, D), (Jump, Space)])
input_map: InputMap::new([(MoveLeft, KeyW), (MoveRight, KeyD), (Jump, Space)])
.insert(Shoot, MouseButton::Left)
.build(),
..default()
Expand Down
Loading
Loading