Skip to content
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
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ include = ["/src", "/tests", "/examples", "/LICENSE*"]
bevy_enhanced_input_macros = { path = "macros", version = "0.7.0" }
bevy = { version = "0.15", default-features = false, features = ["serialize"] }
bevy_egui = { version = "0.33", default-features = false, optional = true }
serde = "1.0"
serde = { version = "1.0", default-features = false, features = ["derive"] }
bitflags = { version = "2.6", features = ["serde"] }

[dev-dependencies]
Expand Down Expand Up @@ -48,6 +48,9 @@ required-features = [

[lints.clippy]
type_complexity = "allow"
alloc_instead_of_core = "warn"
std_instead_of_alloc = "warn"
std_instead_of_core = "warn"

[workspace]
members = ["macros"]
2 changes: 1 addition & 1 deletion examples/context_layering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

mod player_box;

use std::f32::consts::FRAC_PI_4;
use core::f32::consts::FRAC_PI_4;

use bevy::{color::palettes::tailwind::INDIGO_600, prelude::*};
use bevy_enhanced_input::prelude::*;
Expand Down
2 changes: 1 addition & 1 deletion examples/context_switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

mod player_box;

use std::f32::consts::FRAC_PI_4;
use core::f32::consts::FRAC_PI_4;

use bevy::{color::palettes::tailwind::FUCHSIA_400, prelude::*};
use bevy_enhanced_input::prelude::*;
Expand Down
3 changes: 2 additions & 1 deletion examples/keybinding_menu.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{error::Error, fmt::Write, fs};
use core::{error::Error, fmt::Write};
use std::fs;

use bevy::{
input::{common_conditions::*, keyboard::KeyboardInput, mouse::MouseButtonInput, ButtonState},
Expand Down
2 changes: 1 addition & 1 deletion examples/local_multiplayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

mod player_box;

use std::f32::consts::FRAC_PI_4;
use core::f32::consts::FRAC_PI_4;

use bevy::{
color::palettes::tailwind::{BLUE_600, RED_600},
Expand Down
2 changes: 1 addition & 1 deletion examples/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

mod player_box;

use std::f32::consts::FRAC_PI_4;
use core::f32::consts::FRAC_PI_4;

use bevy::prelude::*;
use bevy_enhanced_input::prelude::*;
Expand Down
2 changes: 1 addition & 1 deletion src/action_value.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::fmt::Debug;
use core::fmt::Debug;

use bevy::prelude::*;
use serde::{Deserialize, Serialize};
Expand Down
2 changes: 1 addition & 1 deletion src/events.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::fmt::Debug;
use core::fmt::Debug;

use bevy::prelude::*;
use bitflags::bitflags;
Expand Down
4 changes: 3 additions & 1 deletion src/input.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{
use core::{
fmt::{self, Display, Formatter},
hash::Hash,
};
Expand Down Expand Up @@ -265,6 +265,8 @@ impl From<Entity> for GamepadDevice {

#[cfg(test)]
mod tests {
use alloc::string::ToString;

use super::*;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/input_action.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::fmt::Debug;
use core::fmt::Debug;

use bevy::prelude::*;

Expand Down
5 changes: 3 additions & 2 deletions src/input_bind.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::iter;
use alloc::{boxed::Box, vec::Vec};
use core::iter;

use super::{
input_condition::{InputCondition, InputConditionSet},
Expand Down Expand Up @@ -228,7 +229,7 @@ macro_rules! impl_tuple_binds {
#[allow(non_snake_case)]
fn bindings(self) -> impl Iterator<Item = InputBind> {
let ($($name,)+) = self;
std::iter::empty()
core::iter::empty()
$(.chain($name.bindings()))+
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/input_condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ pub mod pulse;
pub mod release;
pub mod tap;

use std::{fmt::Debug, iter};
use alloc::boxed::Box;
use core::{fmt::Debug, iter};

use bevy::prelude::*;

Expand Down Expand Up @@ -97,7 +98,7 @@ macro_rules! impl_tuple_condition {
#[allow(non_snake_case)]
fn conditions(self) -> impl Iterator<Item = Box<dyn InputCondition>> {
let ($($name,)+) = self;
std::iter::empty()
core::iter::empty()
$(.chain(iter::once(Box::new($name) as Box<dyn InputCondition>)))+
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/input_condition/block_by.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{any, marker::PhantomData};
use core::{any, marker::PhantomData};

use bevy::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion src/input_condition/chord.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{any, marker::PhantomData};
use core::{any, marker::PhantomData};

use bevy::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion src/input_condition/condition_timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl ConditionTimer {

#[cfg(test)]
mod tests {
use std::time::Duration;
use core::time::Duration;

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion src/input_condition/hold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl InputCondition for Hold {

#[cfg(test)]
mod tests {
use std::time::Duration;
use core::time::Duration;

use super::*;
use crate::input_context::ActionsData;
Expand Down
2 changes: 1 addition & 1 deletion src/input_condition/hold_and_release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl InputCondition for HoldAndRelease {

#[cfg(test)]
mod tests {
use std::time::Duration;
use core::time::Duration;

use super::*;
use crate::input_context::ActionsData;
Expand Down
2 changes: 1 addition & 1 deletion src/input_condition/pulse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl InputCondition for Pulse {

#[cfg(test)]
mod tests {
use std::time::Duration;
use core::time::Duration;

use super::*;
use crate::input_context::ActionsData;
Expand Down
2 changes: 1 addition & 1 deletion src/input_condition/tap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl InputCondition for Tap {

#[cfg(test)]
mod tests {
use std::time::Duration;
use core::time::Duration;

use super::*;

Expand Down
3 changes: 2 additions & 1 deletion src/input_context.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{
use alloc::{boxed::Box, vec::Vec};
use core::{
any::{self, TypeId},
cmp::Ordering,
fmt::Debug,
Expand Down
5 changes: 3 additions & 2 deletions src/input_modifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ pub mod scale;
pub mod smooth_nudge;
pub mod swizzle_axis;

use std::{fmt::Debug, iter};
use alloc::boxed::Box;
use core::{fmt::Debug, iter};

use bevy::prelude::*;

Expand Down Expand Up @@ -56,7 +57,7 @@ macro_rules! impl_tuple_modifiers {
#[allow(non_snake_case)]
fn modifiers(self) -> impl Iterator<Item = Box<dyn InputModifier>> {
let ($($name,)+) = self;
std::iter::empty()
core::iter::empty()
$(.chain(iter::once(Box::new($name) as Box<dyn InputModifier>)))+
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/input_modifier/accumulate_by.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{any, marker::PhantomData};
use core::{any, marker::PhantomData};

use bevy::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion src/input_modifier/delta_scale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl InputModifier for DeltaScale {

#[cfg(test)]
mod tests {
use std::time::Duration;
use core::time::Duration;

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion src/input_modifier/smooth_nudge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl InputModifier for SmoothNudge {

#[cfg(test)]
mod tests {
use std::time::Duration;
use core::time::Duration;

use super::*;

Expand Down
5 changes: 3 additions & 2 deletions src/input_reader.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::hash::Hash;
use alloc::vec::Vec;
use core::hash::Hash;

use bevy::{
ecs::system::SystemParam,
Expand Down Expand Up @@ -41,7 +42,7 @@ impl InputReader<'_, '_> {
self.consumed.reset();

// Temporary take the original value to avoid issues with the borrow checker.
let mut reset_input = std::mem::take(&mut *self.reset_input);
let mut reset_input = core::mem::take(&mut *self.reset_input);
reset_input.retain(|&input| {
if self.value(input).as_bool() {
self.consume(input);
Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ The exact method depends on the OS shell.
Alternatively you can configure [`LogPlugin`](bevy::log::LogPlugin) to make it permanent.
*/

#![no_std]

extern crate std;

extern crate alloc;

// Required for the derive macro to work within the crate.
extern crate self as bevy_enhanced_input;

Expand Down
3 changes: 2 additions & 1 deletion src/registry.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{
use alloc::vec::Vec;
use core::{
any::{self, TypeId},
cmp::Reverse,
marker::PhantomData,
Expand Down
2 changes: 2 additions & 0 deletions src/trigger_tracker.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use alloc::boxed::Box;

use bevy::prelude::*;

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion tests/condition_kind.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::any;
use core::any;

use bevy::{input::InputPlugin, prelude::*};
use bevy_enhanced_input::prelude::*;
Expand Down
2 changes: 1 addition & 1 deletion tests/state_and_value_merge.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::any;
use core::any;

use bevy::{input::InputPlugin, prelude::*};
use bevy_enhanced_input::prelude::*;
Expand Down