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

Add deserializer function for MouseButton #654

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- `GamepadButton` and `GamepadButtonType` now get values from `Axis<GamepadButton>`
- `VirtualAxis`, `VirtualDPad`, and `VirtualDPad3D` now report axis values based on the values of the constitute buttons
- added `value` field to `ActionDiff::Pressed`
- added missing deserializer function for `MouseButton`

### Usability (0.16.0)

Expand Down
1 change: 1 addition & 0 deletions src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ impl<A: Actionlike + TypePath + bevy::reflect::GetTypeRegistration> Plugin
app.register_type::<AccumulatedMouseMovement>()
.register_type::<AccumulatedMouseScroll>()
.register_buttonlike_input::<MouseMoveDirection>()
.register_buttonlike_input::<MouseButton>()
.register_axislike_input::<MouseMoveAxis>()
.register_dual_axislike_input::<MouseMove>()
.register_buttonlike_input::<MouseScrollDirection>()
Expand Down
25 changes: 25 additions & 0 deletions src/user_input/trait_serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,31 @@ mod tests {
);
}

#[cfg(feature = "mouse")]
#[test]
fn test_mouse_button_serde() {
use bevy::prelude::MouseButton;
use serde_test::{assert_tokens, Token};

use crate::prelude::Buttonlike;

register_input_deserializers();

let boxed_input: Box<dyn Buttonlike> = Box::new(MouseButton::Left);
assert_tokens(
&boxed_input,
&[
Token::Map { len: Some(1) },
Token::BorrowedStr("MouseButton"),
Token::UnitVariant {
name: "MouseButton",
variant: "Left",
},
Token::MapEnd,
],
);
}

#[cfg(feature = "mouse")]
#[test]
fn test_axis_serde() {
Expand Down