Skip to content

Commit

Permalink
Add deserializer function for MouseButton (#654)
Browse files Browse the repository at this point in the history
  • Loading branch information
alradish authored Nov 7, 2024
1 parent a829b41 commit f04b5da
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
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

0 comments on commit f04b5da

Please sign in to comment.