Skip to content

bevy_input is now optional, but there's no way to enable it #18397

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

Closed
rparrett opened this issue Mar 18, 2025 · 6 comments · Fixed by #18638
Closed

bevy_input is now optional, but there's no way to enable it #18397

rparrett opened this issue Mar 18, 2025 · 6 comments · Fixed by #18638
Labels
A-Input Player input via keyboard, mouse, gamepad, and more C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Design This issue requires design work to think about how it would best be accomplished

Comments

@rparrett
Copy link
Contributor

rparrett commented Mar 18, 2025

Bevy version

main, since #17955

What you did

Attempted to migrate a crate dealing with input and using default-features = false to Bevy 0.16-dev

What went wrong

error[E0433]: failed to resolve: could not find `input` in `bevy`
  --> src/lib.rs:28:5
   |
28 |     input::keyboard::{Key, KeyboardInput},
   |     ^^^^^ could not find `input` in `bevy`

And there doesn't appear to be any way of rectifying this. It seems that we need a new bevy_input feature, but it's also possible that bevy_input becoming optional was a mistake. I haven't been following the no_std effort closely, so I'm not sure.

A bad workaround is to add the std feature, which includes bevy_input. (This may be a separate bug. Seems like with bevy_input optional, bevy_internal/std should be using bevy_input?/std).

@rparrett rparrett added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Mar 18, 2025
@rparrett rparrett added this to the 0.16 milestone Mar 18, 2025
@alice-i-cecile alice-i-cecile added A-Input Player input via keyboard, mouse, gamepad, and more D-Straightforward Simple bug fixes and API improvements, docs, test and examples and removed S-Needs-Triage This issue needs to be labelled labels Mar 18, 2025
@alice-i-cecile
Copy link
Member

@bushrat011899 may know better, but my instincts say we're just missing a feature flag.

@alice-i-cecile alice-i-cecile added the S-Needs-Design This issue requires design work to think about how it would best be accomplished label Mar 18, 2025
@bushrat011899
Copy link
Contributor

Tl;Dr enable either std or libm and you'll get bevy_input.

The problem is bevy_math, bevy_inout, etc. need a floating point backend, so you must enable either libm or std. To allow no-default-features to still compile, the only option is to make those crates optional.

I'll give this another look though and see if there's a way to make this more intuitive!

@alice-i-cecile alice-i-cecile removed this from the 0.16 milestone Mar 18, 2025
@alice-i-cecile
Copy link
Member

Cutting from the milestone: that's a good enough workaround for me to be comfortable shipping it. Rust please give us enum features 🥺

@rparrett
Copy link
Contributor Author

rparrett commented Mar 18, 2025

Tl;Dr enable either std or libm and you'll get bevy_input.

Gotcha, thanks. So the play for maximum compatibility would be to add a matching std and libm feature to my crate? (and include std in my own default features?)

Side note: we may want to amend https://bevyengine.org/learn/quick-start/plugin-development/#small-crate-size

@bushrat011899
Copy link
Contributor

Yep! In the release notes we'll call out a newly added example in examples/no_std/library (which you should check as well!) which shows how to make a maximally compatible Bevy library, and some suggestions for how to test it for no_std compatibility.

@alice-i-cecile
Copy link
Member

Pre-RFC for a cargo feature in this space: https://internals.rust-lang.org/t/pre-rfc-mutually-excusive-global-features/19618

github-merge-queue bot pushed a commit that referenced this issue Mar 31, 2025
# Objective

- Fixes #18397
- Supersedes #18474
- Simplifies 0.16 migration

## Solution

- Upgrade to Glam 0.29.3, which has backported the `nostd-libm` feature.
- Expose a similar feature in `bevy_math` and enable it in
`bevy_internal`, allowing `bevy_math`, `bevy_input`, and
`bevy_transform` to be unconditional dependencies again.

## Testing

- CI

---

## Notes

- This includes `libm` as a dependency, but this was already the case in
the common scenario where `rand` or many other features were enabled.
Considering `libm` is an official Rust crate, it's a very low-risk
dependency to unconditionally include.
- For users who do not want `libm` included, simply import Bevy's
subcrates directly, since `bevy_math/nostd-libm` will not be enabled.
- I know we are _very_ late in the RC cycle for 0.16, but this has a
substantial impact on the usability of `bevy` that I consider worth
including.
mockersf pushed a commit that referenced this issue Mar 31, 2025
- Fixes #18397
- Supersedes #18474
- Simplifies 0.16 migration

- Upgrade to Glam 0.29.3, which has backported the `nostd-libm` feature.
- Expose a similar feature in `bevy_math` and enable it in
`bevy_internal`, allowing `bevy_math`, `bevy_input`, and
`bevy_transform` to be unconditional dependencies again.

- CI

---

- This includes `libm` as a dependency, but this was already the case in
the common scenario where `rand` or many other features were enabled.
Considering `libm` is an official Rust crate, it's a very low-risk
dependency to unconditionally include.
- For users who do not want `libm` included, simply import Bevy's
subcrates directly, since `bevy_math/nostd-libm` will not be enabled.
- I know we are _very_ late in the RC cycle for 0.16, but this has a
substantial impact on the usability of `bevy` that I consider worth
including.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Input Player input via keyboard, mouse, gamepad, and more C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Design This issue requires design work to think about how it would best be accomplished
Projects
None yet
3 participants