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

Scan all gamepads for inputs if none is registered #168

Merged
merged 12 commits into from
Jul 12, 2022

Conversation

alice-i-cecile
Copy link
Contributor

Fixes #154. There's some minor breakage in here, as we add Gamepads to our ever-growing collection of InputStream fields.

@alice-i-cecile alice-i-cecile added the usability Reduce user friction label Jul 12, 2022
@alice-i-cecile alice-i-cecile changed the base branch from main to dev July 12, 2022 01:52
@alice-i-cecile alice-i-cecile marked this pull request as draft July 12, 2022 03:18
@alice-i-cecile alice-i-cecile marked this pull request as ready for review July 12, 2022 14:11
@alice-i-cecile alice-i-cecile merged commit e8bd6e0 into dev Jul 12, 2022
@alice-i-cecile alice-i-cecile deleted the default-gamepads branch July 12, 2022 14:37
bors bot pushed a commit to bevyengine/bevy that referenced this pull request Jul 13, 2022
Generally a good idea.

I ran into this because I wanted to store `Gamepads` in a wrapper struct in Leafwing-Studios/leafwing-input-manager#168. 

This PR allows the `Debug` derive used there to continue working. I could workaround this with a custom impl, but a PR upstream seemed like the right fix.
bors bot pushed a commit to bevyengine/bevy that referenced this pull request Jul 13, 2022
Generally a good idea.

I ran into this because I wanted to store `Gamepads` in a wrapper struct in Leafwing-Studios/leafwing-input-manager#168. 

This PR allows the `Debug` derive used there to continue working. I could workaround this with a custom impl, but a PR upstream seemed like the right fix.
alice-i-cecile added a commit that referenced this pull request Aug 2, 2022
* Start 0.3 process

* Swap back to a by-value API

* Primitives for working with Axislike inputs

* Split primitives into a dedicated file

* Improve conversion strategy for primitives

* Direction partitionings

* Algebraic operations for Rotation

* Fixed broken tests

* InputAxis -> AxisPair

* AxisPair::new()

* Swap to usize-based hashing to support value-ful actions

* Noted addition of geometric rotation primitives

* Simplify set_state logic

* Correctly initialize ActionState again

* Fix PartialOrd trait for Timing

* Store and set action values

* Use Vec storage internally

Fixes #69.

* Experimentation with action value API

* Revert "Experimentation with action value API"

This reverts commit 76b9d15.

* Don't store action values

* Run examples in CI

Borrowed from https://github.com/bevyengine/bevy/blob/main/.github/workflows/ci.yml

* Remove bevy-specific logic in examples CI

* Don't try to run examples; way too hard

* Use underscores for crate name

* mdlint rules

* Move geometric primitives into leafwing_2d

* Remove dead code in macro

* Underscores in crate name

* Local development

* Relative path for macros crate

* Fix outdated example

* Fix underscores in crate name

* Polish README

* Fix broken doc links

* Simplify CI: no reason to try to run on all platforms

* Refactor `which_pressed` to return a `Vec<VirtualButtonState>`

This is not only cleaner than returning a `HashSet` of indicies, but also opens up the way to add `UserInput` information

* Update `get_clashes` to use a slice instead of a full `Vec`

Clippy recommended this for _performance purposes_

* Run `cargo fmt`

Oops

* Add API method to return which `UserInput` triggered an action

* Move bevy_ui dependency under a feature

* Vendor leafwing_2d orientation code

Should not block a release

* replace_at and clear_at can be used in a device-agnostic way

* Use usize for container sizes

* Fix missing dependencies

* Remove per_mode_cap

* Simplify InputMap API

* Fix docs formatting

* Remove extra pub specifier

* Remove UserInput::Null

* Remove empty_chords test

Doesn't make sense after `UserInput::Null` removal.

* Update RELEASES.md

* Add missing change to RELEASES.md

* Add methods to conveniently iterate over mappings

* Use type alias

* Add InputMap::remove

* Store ClashStrategy in a resource

* Remove clashing input caching

* Enable default for serde

* Fix formatting

* Changed `ActionState.button_states` inserts into direct assignments

* Added helper function for setting `action` as "held"

* Iterate over actions with mapping by default

In previous PR I added a method to iterate over inputs. But I realized
that such iteration should be with action like in normal map.
So I renamed the submitted `iter()` method into `iter_inputs()` and
added `iter()` that iterates over actions with inputs.
I also have to delete `IntoIter` currently because we can't use opaque
type in traits without nightly compiler.
If you know how to implement it properly - I would appreciate your
advice. But for now I removed it.

* Add binding_menu example

* Fix tests (#99)

* Fix which_pressed test

* Remove references to leafwing_2d

* Fix failing doc tests

* Depend on bevy subcrates (#100)

* Fix doc strings

* Use bevy subcrates for faster compiles and easier feature creation

* Replace run_in_state with DisableInput resource (#106)

* Replace run_in_state with DisableInput resource

* Update release notes

* Fix formatting

* Improve system label description

* Apply suggestions

* Systems refactor (#107)

* Refactor plugin systems logic

Insert systems right away instead of putting them into
input_manager_systems system set.

* Rename `InputManagerSystem::Reset` into `InputManagerSystem::Tick`

* Chain add_system_to_stage calls

* Allow use of InputMap and ActionState as resources

* Adding InputResource and supporting system modifications

* Second Attempt

* Cleaning up formatting.

* Adding RELEASES.md notice.

* Update RELEASES.md

New working as provided by alice-i-cecile

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* Addressing Shatur's naming Concerns.

* Adding lint exception

* adding clippy:: to too_many_arguments

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* Naming nits for systems (#111)

* Tests and refactoring for reasons pressed (#110)

* Move VirtualButtonState and Timing into a more appropriate location

* Use named fields in VirtualButtonState

* Removed poorly motivated ButtonThresholds struct

* reasons_pressed methods

* press and release methods on VirtualButtonState

* VirtualButtonState::tick

* Doc tests for reasons_pressed

* Shorten module names

* Refactor UserInput into its own file

* Fix timing test

* Fix broken doc tests

* ActionState::reset API (#112)

* ActionState::make_held -> ActionState::reset

* Fix rename in doc test

* Fixed misleading merge conflict in RELEASES

* Clean up release notes

* Fix import in doc tests

* More release note polish...

* Fix doc test

* Added example demonstrating how to use reset in system

* Refactor VirtualButtonState (#113)

* Rename VirtualButtonState to ButtonState

* Radically simplify ButtonState

* Re-add reasons_pressed functionality

* Fetch ActionData, not ButtonState

* Re-add Timing functionality

* Consolidate tests

* Updated release notes

* Assorted cleanup

* Fix tests

* Provide functionality to release inputs during mocking (#114)

* Note that mocked inputs will not be automatically released

* Add input releasing to input mocking tools

* Add UserInput::raw_inputs

* Add ActionState::freeze (#115)

* ActionState::freeze and ActionState::unfreeze

* Yeet DisableInput resource

* Fix stray doc test (#116)

* Replace freeze API with improved DisableInput resource (#117)

* Replace freeze API with DisableInput improved resource

ActionState::freeze was introduced to consume actions. But it turns
out not very ergonomic. Also freeze require to spawn an entity or
init the resource should which is not always the case.
In this iteration I used run criteria to make the code nicer.
Also I extended disable_input test to check if global and entity input
is released on disable.

* Use field to control if actions are enabled

* Update RELEASES.md

* Add ActionState::consume (#118)

* Update to Bevy 0.7 (#119)

* Bump dependencies

* New ergonomics!

* Fix typo

* Bump bevy_egui dev-dependency

* Finalize release notes (#120)

* Reduce Bevy dependencies (#126)

* Properly document ToggleActions (#134)

* Fix dead links to ToggleActions

* Add plugin-level documentation to describe how to pause and resume

* Improve plugin-level docs (#137)

* Document the need to specify system ordering

* Document the use of multiple actionlike enums

* Expanded ActionStateDriver docs (#138)

* Don't run CI twice for repo-owned branches (#140)

* Bump LWIM dependency

* Add code snippet to README (#139)

* Remove missed boilerplate from README (#142)

* Update crate name in README (#143)

* Add Bevy Gilrs to Dev Dependency Features (#150)

This way you can run the examples with gamepad support.

* Fix broken duration pressed functionality (#129)

* Improve press_duration example description

* Added integration test for durations

* Test cleanup

* Create seemingly useless test

* Isolate source of problems

* Don't flip the timing unless a state change occurs

* Add bug fix to release notes

* Made duration integration test stricter

* Handle time not having a last update gracefully (#146)

* Identify source(s) of problems

* Improve tricky duration pressed integration test

* Do not advance timing info for consumed actions

* Remove reset_inputs from tests

* Move trivial do_nothing test to top of integration test file

* Remove double updates from duration test

* Improve strategy for computing elapsed time

* Don't sleep in unit tests

* Simplify duration tests

* Start timer at the correct time

* Current duration should be measured from the last frame

* Add missing release note

* Fix CI

* Bump to 0.4 because breaking change needed

Co-authored-by: Aceeri <conmcclusk@gmail.com>

* Reverse order of `InputMap` from `(action, input)` to `(input, action)` (#152)

* Swap order of InputMap methods from (Action, Input) to (Input, Action)

* Update release notes

* Don't duplicate CI checks for Leafwing-Studios PRs (#153)

* Add Support For Gamepad Axes (#151)

* Add Support For Gamepad Axes

* Update Doc Comment

Co-authored-by: Nathan Stocks <cleancut@github.com>

* Demonstrate Button Value in the Analog Stick Demo

* Add Helper Method ActionState::get_value()

* Add Dual Axis Support

* Implement Virtual DPad

* Implement Values and Axis Pairs for Chords

* Address Code Review

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* Update README.md and RELEASES.md

* Cargo Format

* Non-Inclusive Comparisons For positive_low/high

* Split Dual Axis Deadzone Into Component Parts

* Apply Updates Suggested in Review

* Apply More Suggestions

* Move VirtualDPad To Its Own Struct

* Apply Updates From Code Review

Co-authored-by: Nathan Stocks <cleancut@github.com>

* Fix Compile Errors

* Fix DPad Clash Detection

* Cargo Format

Co-authored-by: Nathan Stocks <cleancut@github.com>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* Merge changes from main into dev branch (#163)

* Release 0.4 (#141)

* Start 0.3 process

* Swap back to a by-value API

* Primitives for working with Axislike inputs

* Split primitives into a dedicated file

* Improve conversion strategy for primitives

* Direction partitionings

* Algebraic operations for Rotation

* Fixed broken tests

* InputAxis -> AxisPair

* AxisPair::new()

* Swap to usize-based hashing to support value-ful actions

* Noted addition of geometric rotation primitives

* Simplify set_state logic

* Correctly initialize ActionState again

* Fix PartialOrd trait for Timing

* Store and set action values

* Use Vec storage internally

Fixes #69.

* Experimentation with action value API

* Revert "Experimentation with action value API"

This reverts commit 76b9d15.

* Don't store action values

* Run examples in CI

Borrowed from https://github.com/bevyengine/bevy/blob/main/.github/workflows/ci.yml

* Remove bevy-specific logic in examples CI

* Don't try to run examples; way too hard

* Use underscores for crate name

* mdlint rules

* Move geometric primitives into leafwing_2d

* Remove dead code in macro

* Underscores in crate name

* Local development

* Relative path for macros crate

* Fix outdated example

* Fix underscores in crate name

* Polish README

* Fix broken doc links

* Simplify CI: no reason to try to run on all platforms

* Refactor `which_pressed` to return a `Vec<VirtualButtonState>`

This is not only cleaner than returning a `HashSet` of indicies, but also opens up the way to add `UserInput` information

* Update `get_clashes` to use a slice instead of a full `Vec`

Clippy recommended this for _performance purposes_

* Run `cargo fmt`

Oops

* Add API method to return which `UserInput` triggered an action

* Move bevy_ui dependency under a feature

* Vendor leafwing_2d orientation code

Should not block a release

* replace_at and clear_at can be used in a device-agnostic way

* Use usize for container sizes

* Fix missing dependencies

* Remove per_mode_cap

* Simplify InputMap API

* Fix docs formatting

* Remove extra pub specifier

* Remove UserInput::Null

* Remove empty_chords test

Doesn't make sense after `UserInput::Null` removal.

* Update RELEASES.md

* Add missing change to RELEASES.md

* Add methods to conveniently iterate over mappings

* Use type alias

* Add InputMap::remove

* Store ClashStrategy in a resource

* Remove clashing input caching

* Enable default for serde

* Fix formatting

* Changed `ActionState.button_states` inserts into direct assignments

* Added helper function for setting `action` as "held"

* Iterate over actions with mapping by default

In previous PR I added a method to iterate over inputs. But I realized
that such iteration should be with action like in normal map.
So I renamed the submitted `iter()` method into `iter_inputs()` and
added `iter()` that iterates over actions with inputs.
I also have to delete `IntoIter` currently because we can't use opaque
type in traits without nightly compiler.
If you know how to implement it properly - I would appreciate your
advice. But for now I removed it.

* Add binding_menu example

* Fix tests (#99)

* Fix which_pressed test

* Remove references to leafwing_2d

* Fix failing doc tests

* Depend on bevy subcrates (#100)

* Fix doc strings

* Use bevy subcrates for faster compiles and easier feature creation

* Replace run_in_state with DisableInput resource (#106)

* Replace run_in_state with DisableInput resource

* Update release notes

* Fix formatting

* Improve system label description

* Apply suggestions

* Systems refactor (#107)

* Refactor plugin systems logic

Insert systems right away instead of putting them into
input_manager_systems system set.

* Rename `InputManagerSystem::Reset` into `InputManagerSystem::Tick`

* Chain add_system_to_stage calls

* Allow use of InputMap and ActionState as resources

* Adding InputResource and supporting system modifications

* Second Attempt

* Cleaning up formatting.

* Adding RELEASES.md notice.

* Update RELEASES.md

New working as provided by alice-i-cecile

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* Addressing Shatur's naming Concerns.

* Adding lint exception

* adding clippy:: to too_many_arguments

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* Naming nits for systems (#111)

* Tests and refactoring for reasons pressed (#110)

* Move VirtualButtonState and Timing into a more appropriate location

* Use named fields in VirtualButtonState

* Removed poorly motivated ButtonThresholds struct

* reasons_pressed methods

* press and release methods on VirtualButtonState

* VirtualButtonState::tick

* Doc tests for reasons_pressed

* Shorten module names

* Refactor UserInput into its own file

* Fix timing test

* Fix broken doc tests

* ActionState::reset API (#112)

* ActionState::make_held -> ActionState::reset

* Fix rename in doc test

* Fixed misleading merge conflict in RELEASES

* Clean up release notes

* Fix import in doc tests

* More release note polish...

* Fix doc test

* Added example demonstrating how to use reset in system

* Refactor VirtualButtonState (#113)

* Rename VirtualButtonState to ButtonState

* Radically simplify ButtonState

* Re-add reasons_pressed functionality

* Fetch ActionData, not ButtonState

* Re-add Timing functionality

* Consolidate tests

* Updated release notes

* Assorted cleanup

* Fix tests

* Provide functionality to release inputs during mocking (#114)

* Note that mocked inputs will not be automatically released

* Add input releasing to input mocking tools

* Add UserInput::raw_inputs

* Add ActionState::freeze (#115)

* ActionState::freeze and ActionState::unfreeze

* Yeet DisableInput resource

* Fix stray doc test (#116)

* Replace freeze API with improved DisableInput resource (#117)

* Replace freeze API with DisableInput improved resource

ActionState::freeze was introduced to consume actions. But it turns
out not very ergonomic. Also freeze require to spawn an entity or
init the resource should which is not always the case.
In this iteration I used run criteria to make the code nicer.
Also I extended disable_input test to check if global and entity input
is released on disable.

* Use field to control if actions are enabled

* Update RELEASES.md

* Add ActionState::consume (#118)

* Update to Bevy 0.7 (#119)

* Bump dependencies

* New ergonomics!

* Fix typo

* Bump bevy_egui dev-dependency

* Finalize release notes (#120)

* Reduce Bevy dependencies (#126)

* Properly document ToggleActions (#134)

* Fix dead links to ToggleActions

* Add plugin-level documentation to describe how to pause and resume

* Improve plugin-level docs (#137)

* Document the need to specify system ordering

* Document the use of multiple actionlike enums

* Expanded ActionStateDriver docs (#138)

* Don't run CI twice for repo-owned branches (#140)

* Bump LWIM dependency

* Add code snippet to README (#139)

* Remove missed boilerplate from README (#142)

* Update crate name in README (#143)

* Add Bevy Gilrs to Dev Dependency Features (#150)

This way you can run the examples with gamepad support.

* Fix broken duration pressed functionality (#129)

* Improve press_duration example description

* Added integration test for durations

* Test cleanup

* Create seemingly useless test

* Isolate source of problems

* Don't flip the timing unless a state change occurs

* Add bug fix to release notes

* Made duration integration test stricter

* Handle time not having a last update gracefully (#146)

* Identify source(s) of problems

* Improve tricky duration pressed integration test

* Do not advance timing info for consumed actions

* Remove reset_inputs from tests

* Move trivial do_nothing test to top of integration test file

* Remove double updates from duration test

* Improve strategy for computing elapsed time

* Don't sleep in unit tests

* Simplify duration tests

* Start timer at the correct time

* Current duration should be measured from the last frame

* Add missing release note

* Fix CI

* Bump to 0.4 because breaking change needed

Co-authored-by: Aceeri <conmcclusk@gmail.com>

* Reverse order of `InputMap` from `(action, input)` to `(input, action)` (#152)

* Swap order of InputMap methods from (Action, Input) to (Input, Action)

* Update release notes

Co-authored-by: Rose Peck <olaf223224@gmail.com>
Co-authored-by: Hennadii Chernyshchyk <genaloner@gmail.com>
Co-authored-by: Elfein Landers <patlymlatun@mgail.com>
Co-authored-by: Hans W. Uhlig <huhlig@gmail.com>
Co-authored-by: Christopher Biscardi <chris@christopherbiscardi.com>
Co-authored-by: Zicklag <zicklag@katharostech.com>
Co-authored-by: Aceeri <conmcclusk@gmail.com>

* Hyphens in crate name

* sync up macros dependency with macros crate name (#161)

* sync up macros dependency with macros crate name

* version bump and release notes for 0.4.1

* Update hyphenation of parent crate in docs

* Fix conflict between macro crate name and version (#162)

* Revert "sync up macros dependency with macros crate name (#161)"

This reverts commit ba4e704.

* Swap to underscores in macro crate name only

This matches the published crate name.

* Add release notes

* Bump version of macros crate

* Bump version of main crate

Co-authored-by: Shea Newton <shnewto@gmail.com>

* Bump version numbers

* Fixed release notes

* Specify minor versions

Co-authored-by: Rose Peck <olaf223224@gmail.com>
Co-authored-by: Hennadii Chernyshchyk <genaloner@gmail.com>
Co-authored-by: Elfein Landers <patlymlatun@mgail.com>
Co-authored-by: Hans W. Uhlig <huhlig@gmail.com>
Co-authored-by: Christopher Biscardi <chris@christopherbiscardi.com>
Co-authored-by: Zicklag <zicklag@katharostech.com>
Co-authored-by: Aceeri <conmcclusk@gmail.com>
Co-authored-by: Shea Newton <shnewto@gmail.com>

* Add builder methods for new axislike input types (#165)

* Move VirtualDpad to axislike.rs file

* Work around RA macro import resolution issue

* Add simple builder methods for VirtualDPads

* Move SingleGamepadAxis and DualGamepadAxis to axislike.rs

* Simple builder methods for Single and DualGamepadAxis

* Add builder methods for gamepad analogue sticks

* Update example to use new builders

* Don't store DualGamepadAxis in VirtualDPad

* Silence spurious clippy warning

* Remove reasons_pressed API. (#167)

* Scan all gamepads for inputs if none is registered (#168)

* Remove reasons_pressed API.

* Scan the list of all gamepads if no particular gamepad is registered

* Update examples

* Use same strategies for InputMocking::pressed

* Record FIXME notes

* Search all gamepads if no gamepad is registered

* Remove incorrect Chord logic for axis_pair and input_value

* Use button value in get_input_value as a fallback, rather than 0.0

* Explain weird design choice

* Update docs

* Clippy

* Update to Bevy 0.8-dev (#170)

* Update dependencies to 0.8-dev branch of Bevy

* Fix compile errors

* Use new const Vec2 methods

* Make egui example pass CI

* Align variable naming with bevy_input conventions

* Set axis values when mocking user input (#171)

* Remove resolved FIXME comments

* Allow users to send analog input values

* Clarity rename

* Update doc string to reflect current design

* Fix broken imports (#172)

Thanks merge conflicts :(

* Cleanup old TODO and FIXME comments (#176)

* Remove completed TODO / FIXME comments

* Add Direction::try_new

* Measure rotation counterclockwise from x (#177)

* switch from 'clockwise from midnight' to 'counterclockwise from the positive x axis' for Rotation and Direction

* fix usage

* stop using .normalize(), which can panic

* simplify logic

* remove unused import

* Doc nit

* re-enable all assertions

* add release notes

* clarify why we changed rotation direction

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* use Result consistently

* Tweak release notes

* Remove Direction::try_new

Co-authored-by: Nathan Stocks <cleancut@github.com>

* Support mouse wheel inputs (#173)

* Rename SingleGamepadAxis to SingleAxis

* Do not clamp lengths of axis pairs

* Move InputStreams into a dedicated file

UserInput was getting excessively long and InputStreams code is well isolated.

* Add helper methods to construct InputStream types from the World

* Add mouse wheel events to InputStreams

* Generalize GamepadAxisType to AxisType

* Update release notes

* Rename for generality

* Rename AxisPair to DualAxisData

* Store two SingleAxis inside of DualAxis

* Use more descriptive variable names in user_input.rs

* Account for mouse wheel inputs in InputMode conversion

* Yeet InputMode enum

* Variable renaming for generality

* Mock mouse wheel inputs

* Refactor input_value methods on InputStreams

* Take a pair of floats in DualAxisData::new

* Sum mouse wheel events to get input_value

* Add buttonlike MouseWheelDirection InputKind

* Rederive Debug

Fixes #175.

* clippy

* Builder methods for working with mouse wheel inputs

* Add new types to prelude

* Add missing From impls

* Add mouse_wheel example

* Make mouse wheel direction summing less clever

* Actually add code for panning right to example

* Add note about dumb Bevy bug

* Scale 2D cameras correctly :upside_down:

* Fix stated ordering in InputMap docs

* Add tests for working with mouse wheel inputs

* Add DualAxis::from_value helpers

* Add test for raw events

* get_input_value -> input_value

* Add clamped helper methods

* Shorten axis_pair and value method names

* Make CI pass

* Support Single Axis Inputs in Virtual DPads (#180)

* Temporarily Comment Out Bevy Egui

* Make Axis Input Example Slightly More Readable

* Fix Bug in Symmetric Axis Constructor

Axis would always trigger because negative_low was positive.

* Return Axis Pair Results When Action Isn't Pressed

This makes sure that axis_pair() returns `Some` even if the value is
zero because the axis isn't moved.

* Set Dual Axis Value Zero if Not in Trigger Range

* Make Single-Axis Inputs Work in Virtual DPad

This makes sure that SingleAxis inputs will report a value of 0.0 if the
axis value is not withing the triggering zone. This makes it possible to
create a virtual gamepad made up of multiple single-axis inputs on the
same stick.

* Cargo Format

* Add mouse motion support (#186)

* Add MouseMotion events to input streams

* Add discretized MouseMotionDirection buttonlike input support

* Continuous-valued mouse motion inputs

* Doc fixes for AxisData

* Builder methods for Axis types

* Add simple mouse_motion example

* Depend on bevy directly (#187)

This is a) much cleaner and easier to maintain b) makes it easier for others to patch this crate to a specific version and c) slightly more robust to bevy shuffling code around

* Add bevy_asset as a feature for the examples (#190)

* Bump to Bevy 0.8 (#192)

* Bump dependencies

* Re-enable binding_menu example

* Make input stream fields non-optional (#193)

* Add better module-level docs

* Make input streams non-optional

* InputStreams::from_world does not need &mut World

* Satisfy borrow checker in tests

* Fix lifetime of MutableInputStreams -> InputStreams method

* Fix integration test

* Update release notes

* Add mockable_world builder function

* Clean up input mocking code (#194)

* Documentation improvements to input mocking

* (Mostly) implement InputMocking trait for MutableInputStreams

* Use InputStreams::guess_gamepad internally

* Allows conversion by reference from MutableInputStreams

* Add tests for decomposing `UserInput` into raw inputs (#197)

* Documentation improvements to input mocking

* (Mostly) implement InputMocking trait for MutableInputStreams

* Use InputStreams::guess_gamepad internally

* Allows conversion by reference from MutableInputStreams

* Correctly release input

* Swap to a RawInputs struct

* Update docs for UserInput::chord

* Add tests for RawInputs

* Fix Compile Without UI Feature (#198)

* Fix axislike input mocking (kind of) (#200)

* Re-enable tests

* Actually add axislike inputmanagerplugin XD

* Move actionstate init to test setup

* Improve axis-like input mocking tests

* Reorganize MutableInputStreams::send_input

* Actually send discrete mouse motion events

* Add more tests for axislike inputs

* Improve gamepad status handling for axislike gamepad inputs

* Ignore failing tests

* Actually register a gamepad for tests

* Disable tests that are still failing

* Mocking inputs should send raw events (#207)

* Add more fields to mutable input streams

* Rename InputStreams fields for clarity

* Send raw events when doing input mocking

* Don't guess gamepad in send_input_to_gamepad; handled upstream

* Enable fixed gamepad mocking tests

* Always enable bevy_gilrs

* Fix failing tests

* Fix failing gamepad axis tests

* Minor documentation fix, s/pressed/released/ (#206)

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

Co-authored-by: Rose Peck <olaf223224@gmail.com>
Co-authored-by: Hennadii Chernyshchyk <genaloner@gmail.com>
Co-authored-by: Elfein Landers <patlymlatun@mgail.com>
Co-authored-by: Hans W. Uhlig <huhlig@gmail.com>
Co-authored-by: Christopher Biscardi <chris@christopherbiscardi.com>
Co-authored-by: Zicklag <zicklag@katharostech.com>
Co-authored-by: Aceeri <conmcclusk@gmail.com>
Co-authored-by: Nathan Stocks <cleancut@github.com>
Co-authored-by: Shea Newton <shnewto@gmail.com>
Co-authored-by: Nolan Darilek <nolan@thewordnerd.info>
inodentry pushed a commit to IyesGames/bevy that referenced this pull request Aug 8, 2022
Generally a good idea.

I ran into this because I wanted to store `Gamepads` in a wrapper struct in Leafwing-Studios/leafwing-input-manager#168. 

This PR allows the `Debug` derive used there to continue working. I could workaround this with a custom impl, but a PR upstream seemed like the right fix.
alice-i-cecile added a commit that referenced this pull request Oct 14, 2022
* Start 0.3 process

* Swap back to a by-value API

* Primitives for working with Axislike inputs

* Split primitives into a dedicated file

* Improve conversion strategy for primitives

* Direction partitionings

* Algebraic operations for Rotation

* Fixed broken tests

* InputAxis -> AxisPair

* AxisPair::new()

* Swap to usize-based hashing to support value-ful actions

* Noted addition of geometric rotation primitives

* Simplify set_state logic

* Correctly initialize ActionState again

* Fix PartialOrd trait for Timing

* Store and set action values

* Use Vec storage internally

Fixes #69.

* Experimentation with action value API

* Revert "Experimentation with action value API"

This reverts commit 76b9d15.

* Don't store action values

* Run examples in CI

Borrowed from https://github.com/bevyengine/bevy/blob/main/.github/workflows/ci.yml

* Remove bevy-specific logic in examples CI

* Don't try to run examples; way too hard

* Use underscores for crate name

* mdlint rules

* Move geometric primitives into leafwing_2d

* Remove dead code in macro

* Underscores in crate name

* Local development

* Relative path for macros crate

* Fix outdated example

* Fix underscores in crate name

* Polish README

* Fix broken doc links

* Simplify CI: no reason to try to run on all platforms

* Refactor `which_pressed` to return a `Vec<VirtualButtonState>`

This is not only cleaner than returning a `HashSet` of indicies, but also opens up the way to add `UserInput` information

* Update `get_clashes` to use a slice instead of a full `Vec`

Clippy recommended this for _performance purposes_

* Run `cargo fmt`

Oops

* Add API method to return which `UserInput` triggered an action

* Move bevy_ui dependency under a feature

* Vendor leafwing_2d orientation code

Should not block a release

* replace_at and clear_at can be used in a device-agnostic way

* Use usize for container sizes

* Fix missing dependencies

* Remove per_mode_cap

* Simplify InputMap API

* Fix docs formatting

* Remove extra pub specifier

* Remove UserInput::Null

* Remove empty_chords test

Doesn't make sense after `UserInput::Null` removal.

* Update RELEASES.md

* Add missing change to RELEASES.md

* Add methods to conveniently iterate over mappings

* Use type alias

* Add InputMap::remove

* Store ClashStrategy in a resource

* Remove clashing input caching

* Enable default for serde

* Fix formatting

* Changed `ActionState.button_states` inserts into direct assignments

* Added helper function for setting `action` as "held"

* Iterate over actions with mapping by default

In previous PR I added a method to iterate over inputs. But I realized
that such iteration should be with action like in normal map.
So I renamed the submitted `iter()` method into `iter_inputs()` and
added `iter()` that iterates over actions with inputs.
I also have to delete `IntoIter` currently because we can't use opaque
type in traits without nightly compiler.
If you know how to implement it properly - I would appreciate your
advice. But for now I removed it.

* Add binding_menu example

* Fix tests (#99)

* Fix which_pressed test

* Remove references to leafwing_2d

* Fix failing doc tests

* Depend on bevy subcrates (#100)

* Fix doc strings

* Use bevy subcrates for faster compiles and easier feature creation

* Replace run_in_state with DisableInput resource (#106)

* Replace run_in_state with DisableInput resource

* Update release notes

* Fix formatting

* Improve system label description

* Apply suggestions

* Systems refactor (#107)

* Refactor plugin systems logic

Insert systems right away instead of putting them into
input_manager_systems system set.

* Rename `InputManagerSystem::Reset` into `InputManagerSystem::Tick`

* Chain add_system_to_stage calls

* Allow use of InputMap and ActionState as resources

* Adding InputResource and supporting system modifications

* Second Attempt

* Cleaning up formatting.

* Adding RELEASES.md notice.

* Update RELEASES.md

New working as provided by alice-i-cecile

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* Addressing Shatur's naming Concerns.

* Adding lint exception

* adding clippy:: to too_many_arguments

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* Naming nits for systems (#111)

* Tests and refactoring for reasons pressed (#110)

* Move VirtualButtonState and Timing into a more appropriate location

* Use named fields in VirtualButtonState

* Removed poorly motivated ButtonThresholds struct

* reasons_pressed methods

* press and release methods on VirtualButtonState

* VirtualButtonState::tick

* Doc tests for reasons_pressed

* Shorten module names

* Refactor UserInput into its own file

* Fix timing test

* Fix broken doc tests

* ActionState::reset API (#112)

* ActionState::make_held -> ActionState::reset

* Fix rename in doc test

* Fixed misleading merge conflict in RELEASES

* Clean up release notes

* Fix import in doc tests

* More release note polish...

* Fix doc test

* Added example demonstrating how to use reset in system

* Refactor VirtualButtonState (#113)

* Rename VirtualButtonState to ButtonState

* Radically simplify ButtonState

* Re-add reasons_pressed functionality

* Fetch ActionData, not ButtonState

* Re-add Timing functionality

* Consolidate tests

* Updated release notes

* Assorted cleanup

* Fix tests

* Provide functionality to release inputs during mocking (#114)

* Note that mocked inputs will not be automatically released

* Add input releasing to input mocking tools

* Add UserInput::raw_inputs

* Add ActionState::freeze (#115)

* ActionState::freeze and ActionState::unfreeze

* Yeet DisableInput resource

* Fix stray doc test (#116)

* Replace freeze API with improved DisableInput resource (#117)

* Replace freeze API with DisableInput improved resource

ActionState::freeze was introduced to consume actions. But it turns
out not very ergonomic. Also freeze require to spawn an entity or
init the resource should which is not always the case.
In this iteration I used run criteria to make the code nicer.
Also I extended disable_input test to check if global and entity input
is released on disable.

* Use field to control if actions are enabled

* Update RELEASES.md

* Add ActionState::consume (#118)

* Update to Bevy 0.7 (#119)

* Bump dependencies

* New ergonomics!

* Fix typo

* Bump bevy_egui dev-dependency

* Finalize release notes (#120)

* Reduce Bevy dependencies (#126)

* Properly document ToggleActions (#134)

* Fix dead links to ToggleActions

* Add plugin-level documentation to describe how to pause and resume

* Improve plugin-level docs (#137)

* Document the need to specify system ordering

* Document the use of multiple actionlike enums

* Expanded ActionStateDriver docs (#138)

* Don't run CI twice for repo-owned branches (#140)

* Bump LWIM dependency

* Add code snippet to README (#139)

* Remove missed boilerplate from README (#142)

* Update crate name in README (#143)

* Add Bevy Gilrs to Dev Dependency Features (#150)

This way you can run the examples with gamepad support.

* Fix broken duration pressed functionality (#129)

* Improve press_duration example description

* Added integration test for durations

* Test cleanup

* Create seemingly useless test

* Isolate source of problems

* Don't flip the timing unless a state change occurs

* Add bug fix to release notes

* Made duration integration test stricter

* Handle time not having a last update gracefully (#146)

* Identify source(s) of problems

* Improve tricky duration pressed integration test

* Do not advance timing info for consumed actions

* Remove reset_inputs from tests

* Move trivial do_nothing test to top of integration test file

* Remove double updates from duration test

* Improve strategy for computing elapsed time

* Don't sleep in unit tests

* Simplify duration tests

* Start timer at the correct time

* Current duration should be measured from the last frame

* Add missing release note

* Fix CI

* Bump to 0.4 because breaking change needed

Co-authored-by: Aceeri <conmcclusk@gmail.com>

* Reverse order of `InputMap` from `(action, input)` to `(input, action)` (#152)

* Swap order of InputMap methods from (Action, Input) to (Input, Action)

* Update release notes

* Don't duplicate CI checks for Leafwing-Studios PRs (#153)

* Add Support For Gamepad Axes (#151)

* Add Support For Gamepad Axes

* Update Doc Comment

Co-authored-by: Nathan Stocks <cleancut@github.com>

* Demonstrate Button Value in the Analog Stick Demo

* Add Helper Method ActionState::get_value()

* Add Dual Axis Support

* Implement Virtual DPad

* Implement Values and Axis Pairs for Chords

* Address Code Review

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* Update README.md and RELEASES.md

* Cargo Format

* Non-Inclusive Comparisons For positive_low/high

* Split Dual Axis Deadzone Into Component Parts

* Apply Updates Suggested in Review

* Apply More Suggestions

* Move VirtualDPad To Its Own Struct

* Apply Updates From Code Review

Co-authored-by: Nathan Stocks <cleancut@github.com>

* Fix Compile Errors

* Fix DPad Clash Detection

* Cargo Format

Co-authored-by: Nathan Stocks <cleancut@github.com>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* Merge changes from main into dev branch (#163)

* Release 0.4 (#141)

* Start 0.3 process

* Swap back to a by-value API

* Primitives for working with Axislike inputs

* Split primitives into a dedicated file

* Improve conversion strategy for primitives

* Direction partitionings

* Algebraic operations for Rotation

* Fixed broken tests

* InputAxis -> AxisPair

* AxisPair::new()

* Swap to usize-based hashing to support value-ful actions

* Noted addition of geometric rotation primitives

* Simplify set_state logic

* Correctly initialize ActionState again

* Fix PartialOrd trait for Timing

* Store and set action values

* Use Vec storage internally

Fixes #69.

* Experimentation with action value API

* Revert "Experimentation with action value API"

This reverts commit 76b9d15.

* Don't store action values

* Run examples in CI

Borrowed from https://github.com/bevyengine/bevy/blob/main/.github/workflows/ci.yml

* Remove bevy-specific logic in examples CI

* Don't try to run examples; way too hard

* Use underscores for crate name

* mdlint rules

* Move geometric primitives into leafwing_2d

* Remove dead code in macro

* Underscores in crate name

* Local development

* Relative path for macros crate

* Fix outdated example

* Fix underscores in crate name

* Polish README

* Fix broken doc links

* Simplify CI: no reason to try to run on all platforms

* Refactor `which_pressed` to return a `Vec<VirtualButtonState>`

This is not only cleaner than returning a `HashSet` of indicies, but also opens up the way to add `UserInput` information

* Update `get_clashes` to use a slice instead of a full `Vec`

Clippy recommended this for _performance purposes_

* Run `cargo fmt`

Oops

* Add API method to return which `UserInput` triggered an action

* Move bevy_ui dependency under a feature

* Vendor leafwing_2d orientation code

Should not block a release

* replace_at and clear_at can be used in a device-agnostic way

* Use usize for container sizes

* Fix missing dependencies

* Remove per_mode_cap

* Simplify InputMap API

* Fix docs formatting

* Remove extra pub specifier

* Remove UserInput::Null

* Remove empty_chords test

Doesn't make sense after `UserInput::Null` removal.

* Update RELEASES.md

* Add missing change to RELEASES.md

* Add methods to conveniently iterate over mappings

* Use type alias

* Add InputMap::remove

* Store ClashStrategy in a resource

* Remove clashing input caching

* Enable default for serde

* Fix formatting

* Changed `ActionState.button_states` inserts into direct assignments

* Added helper function for setting `action` as "held"

* Iterate over actions with mapping by default

In previous PR I added a method to iterate over inputs. But I realized
that such iteration should be with action like in normal map.
So I renamed the submitted `iter()` method into `iter_inputs()` and
added `iter()` that iterates over actions with inputs.
I also have to delete `IntoIter` currently because we can't use opaque
type in traits without nightly compiler.
If you know how to implement it properly - I would appreciate your
advice. But for now I removed it.

* Add binding_menu example

* Fix tests (#99)

* Fix which_pressed test

* Remove references to leafwing_2d

* Fix failing doc tests

* Depend on bevy subcrates (#100)

* Fix doc strings

* Use bevy subcrates for faster compiles and easier feature creation

* Replace run_in_state with DisableInput resource (#106)

* Replace run_in_state with DisableInput resource

* Update release notes

* Fix formatting

* Improve system label description

* Apply suggestions

* Systems refactor (#107)

* Refactor plugin systems logic

Insert systems right away instead of putting them into
input_manager_systems system set.

* Rename `InputManagerSystem::Reset` into `InputManagerSystem::Tick`

* Chain add_system_to_stage calls

* Allow use of InputMap and ActionState as resources

* Adding InputResource and supporting system modifications

* Second Attempt

* Cleaning up formatting.

* Adding RELEASES.md notice.

* Update RELEASES.md

New working as provided by alice-i-cecile

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* Addressing Shatur's naming Concerns.

* Adding lint exception

* adding clippy:: to too_many_arguments

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* Naming nits for systems (#111)

* Tests and refactoring for reasons pressed (#110)

* Move VirtualButtonState and Timing into a more appropriate location

* Use named fields in VirtualButtonState

* Removed poorly motivated ButtonThresholds struct

* reasons_pressed methods

* press and release methods on VirtualButtonState

* VirtualButtonState::tick

* Doc tests for reasons_pressed

* Shorten module names

* Refactor UserInput into its own file

* Fix timing test

* Fix broken doc tests

* ActionState::reset API (#112)

* ActionState::make_held -> ActionState::reset

* Fix rename in doc test

* Fixed misleading merge conflict in RELEASES

* Clean up release notes

* Fix import in doc tests

* More release note polish...

* Fix doc test

* Added example demonstrating how to use reset in system

* Refactor VirtualButtonState (#113)

* Rename VirtualButtonState to ButtonState

* Radically simplify ButtonState

* Re-add reasons_pressed functionality

* Fetch ActionData, not ButtonState

* Re-add Timing functionality

* Consolidate tests

* Updated release notes

* Assorted cleanup

* Fix tests

* Provide functionality to release inputs during mocking (#114)

* Note that mocked inputs will not be automatically released

* Add input releasing to input mocking tools

* Add UserInput::raw_inputs

* Add ActionState::freeze (#115)

* ActionState::freeze and ActionState::unfreeze

* Yeet DisableInput resource

* Fix stray doc test (#116)

* Replace freeze API with improved DisableInput resource (#117)

* Replace freeze API with DisableInput improved resource

ActionState::freeze was introduced to consume actions. But it turns
out not very ergonomic. Also freeze require to spawn an entity or
init the resource should which is not always the case.
In this iteration I used run criteria to make the code nicer.
Also I extended disable_input test to check if global and entity input
is released on disable.

* Use field to control if actions are enabled

* Update RELEASES.md

* Add ActionState::consume (#118)

* Update to Bevy 0.7 (#119)

* Bump dependencies

* New ergonomics!

* Fix typo

* Bump bevy_egui dev-dependency

* Finalize release notes (#120)

* Reduce Bevy dependencies (#126)

* Properly document ToggleActions (#134)

* Fix dead links to ToggleActions

* Add plugin-level documentation to describe how to pause and resume

* Improve plugin-level docs (#137)

* Document the need to specify system ordering

* Document the use of multiple actionlike enums

* Expanded ActionStateDriver docs (#138)

* Don't run CI twice for repo-owned branches (#140)

* Bump LWIM dependency

* Add code snippet to README (#139)

* Remove missed boilerplate from README (#142)

* Update crate name in README (#143)

* Add Bevy Gilrs to Dev Dependency Features (#150)

This way you can run the examples with gamepad support.

* Fix broken duration pressed functionality (#129)

* Improve press_duration example description

* Added integration test for durations

* Test cleanup

* Create seemingly useless test

* Isolate source of problems

* Don't flip the timing unless a state change occurs

* Add bug fix to release notes

* Made duration integration test stricter

* Handle time not having a last update gracefully (#146)

* Identify source(s) of problems

* Improve tricky duration pressed integration test

* Do not advance timing info for consumed actions

* Remove reset_inputs from tests

* Move trivial do_nothing test to top of integration test file

* Remove double updates from duration test

* Improve strategy for computing elapsed time

* Don't sleep in unit tests

* Simplify duration tests

* Start timer at the correct time

* Current duration should be measured from the last frame

* Add missing release note

* Fix CI

* Bump to 0.4 because breaking change needed

Co-authored-by: Aceeri <conmcclusk@gmail.com>

* Reverse order of `InputMap` from `(action, input)` to `(input, action)` (#152)

* Swap order of InputMap methods from (Action, Input) to (Input, Action)

* Update release notes

Co-authored-by: Rose Peck <olaf223224@gmail.com>
Co-authored-by: Hennadii Chernyshchyk <genaloner@gmail.com>
Co-authored-by: Elfein Landers <patlymlatun@mgail.com>
Co-authored-by: Hans W. Uhlig <huhlig@gmail.com>
Co-authored-by: Christopher Biscardi <chris@christopherbiscardi.com>
Co-authored-by: Zicklag <zicklag@katharostech.com>
Co-authored-by: Aceeri <conmcclusk@gmail.com>

* Hyphens in crate name

* sync up macros dependency with macros crate name (#161)

* sync up macros dependency with macros crate name

* version bump and release notes for 0.4.1

* Update hyphenation of parent crate in docs

* Fix conflict between macro crate name and version (#162)

* Revert "sync up macros dependency with macros crate name (#161)"

This reverts commit ba4e704.

* Swap to underscores in macro crate name only

This matches the published crate name.

* Add release notes

* Bump version of macros crate

* Bump version of main crate

Co-authored-by: Shea Newton <shnewto@gmail.com>

* Bump version numbers

* Fixed release notes

* Specify minor versions

Co-authored-by: Rose Peck <olaf223224@gmail.com>
Co-authored-by: Hennadii Chernyshchyk <genaloner@gmail.com>
Co-authored-by: Elfein Landers <patlymlatun@mgail.com>
Co-authored-by: Hans W. Uhlig <huhlig@gmail.com>
Co-authored-by: Christopher Biscardi <chris@christopherbiscardi.com>
Co-authored-by: Zicklag <zicklag@katharostech.com>
Co-authored-by: Aceeri <conmcclusk@gmail.com>
Co-authored-by: Shea Newton <shnewto@gmail.com>

* Add builder methods for new axislike input types (#165)

* Move VirtualDpad to axislike.rs file

* Work around RA macro import resolution issue

* Add simple builder methods for VirtualDPads

* Move SingleGamepadAxis and DualGamepadAxis to axislike.rs

* Simple builder methods for Single and DualGamepadAxis

* Add builder methods for gamepad analogue sticks

* Update example to use new builders

* Don't store DualGamepadAxis in VirtualDPad

* Silence spurious clippy warning

* Remove reasons_pressed API. (#167)

* Scan all gamepads for inputs if none is registered (#168)

* Remove reasons_pressed API.

* Scan the list of all gamepads if no particular gamepad is registered

* Update examples

* Use same strategies for InputMocking::pressed

* Record FIXME notes

* Search all gamepads if no gamepad is registered

* Remove incorrect Chord logic for axis_pair and input_value

* Use button value in get_input_value as a fallback, rather than 0.0

* Explain weird design choice

* Update docs

* Clippy

* Update to Bevy 0.8-dev (#170)

* Update dependencies to 0.8-dev branch of Bevy

* Fix compile errors

* Use new const Vec2 methods

* Make egui example pass CI

* Align variable naming with bevy_input conventions

* Set axis values when mocking user input (#171)

* Remove resolved FIXME comments

* Allow users to send analog input values

* Clarity rename

* Update doc string to reflect current design

* Fix broken imports (#172)

Thanks merge conflicts :(

* Cleanup old TODO and FIXME comments (#176)

* Remove completed TODO / FIXME comments

* Add Direction::try_new

* Measure rotation counterclockwise from x (#177)

* switch from 'clockwise from midnight' to 'counterclockwise from the positive x axis' for Rotation and Direction

* fix usage

* stop using .normalize(), which can panic

* simplify logic

* remove unused import

* Doc nit

* re-enable all assertions

* add release notes

* clarify why we changed rotation direction

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* use Result consistently

* Tweak release notes

* Remove Direction::try_new

Co-authored-by: Nathan Stocks <cleancut@github.com>

* Support mouse wheel inputs (#173)

* Rename SingleGamepadAxis to SingleAxis

* Do not clamp lengths of axis pairs

* Move InputStreams into a dedicated file

UserInput was getting excessively long and InputStreams code is well isolated.

* Add helper methods to construct InputStream types from the World

* Add mouse wheel events to InputStreams

* Generalize GamepadAxisType to AxisType

* Update release notes

* Rename for generality

* Rename AxisPair to DualAxisData

* Store two SingleAxis inside of DualAxis

* Use more descriptive variable names in user_input.rs

* Account for mouse wheel inputs in InputMode conversion

* Yeet InputMode enum

* Variable renaming for generality

* Mock mouse wheel inputs

* Refactor input_value methods on InputStreams

* Take a pair of floats in DualAxisData::new

* Sum mouse wheel events to get input_value

* Add buttonlike MouseWheelDirection InputKind

* Rederive Debug

Fixes #175.

* clippy

* Builder methods for working with mouse wheel inputs

* Add new types to prelude

* Add missing From impls

* Add mouse_wheel example

* Make mouse wheel direction summing less clever

* Actually add code for panning right to example

* Add note about dumb Bevy bug

* Scale 2D cameras correctly :upside_down:

* Fix stated ordering in InputMap docs

* Add tests for working with mouse wheel inputs

* Add DualAxis::from_value helpers

* Add test for raw events

* get_input_value -> input_value

* Add clamped helper methods

* Shorten axis_pair and value method names

* Make CI pass

* Support Single Axis Inputs in Virtual DPads (#180)

* Temporarily Comment Out Bevy Egui

* Make Axis Input Example Slightly More Readable

* Fix Bug in Symmetric Axis Constructor

Axis would always trigger because negative_low was positive.

* Return Axis Pair Results When Action Isn't Pressed

This makes sure that axis_pair() returns `Some` even if the value is
zero because the axis isn't moved.

* Set Dual Axis Value Zero if Not in Trigger Range

* Make Single-Axis Inputs Work in Virtual DPad

This makes sure that SingleAxis inputs will report a value of 0.0 if the
axis value is not withing the triggering zone. This makes it possible to
create a virtual gamepad made up of multiple single-axis inputs on the
same stick.

* Cargo Format

* Add mouse motion support (#186)

* Add MouseMotion events to input streams

* Add discretized MouseMotionDirection buttonlike input support

* Continuous-valued mouse motion inputs

* Doc fixes for AxisData

* Builder methods for Axis types

* Add simple mouse_motion example

* Depend on bevy directly (#187)

This is a) much cleaner and easier to maintain b) makes it easier for others to patch this crate to a specific version and c) slightly more robust to bevy shuffling code around

* Add bevy_asset as a feature for the examples (#190)

* Bump to Bevy 0.8 (#192)

* Bump dependencies

* Re-enable binding_menu example

* Make input stream fields non-optional (#193)

* Add better module-level docs

* Make input streams non-optional

* InputStreams::from_world does not need &mut World

* Satisfy borrow checker in tests

* Fix lifetime of MutableInputStreams -> InputStreams method

* Fix integration test

* Update release notes

* Add mockable_world builder function

* Clean up input mocking code (#194)

* Documentation improvements to input mocking

* (Mostly) implement InputMocking trait for MutableInputStreams

* Use InputStreams::guess_gamepad internally

* Allows conversion by reference from MutableInputStreams

* Add tests for decomposing `UserInput` into raw inputs (#197)

* Documentation improvements to input mocking

* (Mostly) implement InputMocking trait for MutableInputStreams

* Use InputStreams::guess_gamepad internally

* Allows conversion by reference from MutableInputStreams

* Correctly release input

* Swap to a RawInputs struct

* Update docs for UserInput::chord

* Add tests for RawInputs

* Fix Compile Without UI Feature (#198)

* Fix axislike input mocking (kind of) (#200)

* Re-enable tests

* Actually add axislike inputmanagerplugin XD

* Move actionstate init to test setup

* Improve axis-like input mocking tests

* Reorganize MutableInputStreams::send_input

* Actually send discrete mouse motion events

* Add more tests for axislike inputs

* Improve gamepad status handling for axislike gamepad inputs

* Ignore failing tests

* Actually register a gamepad for tests

* Disable tests that are still failing

* Mocking inputs should send raw events (#207)

* Add more fields to mutable input streams

* Rename InputStreams fields for clarity

* Send raw events when doing input mocking

* Don't guess gamepad in send_input_to_gamepad; handled upstream

* Enable fixed gamepad mocking tests

* Always enable bevy_gilrs

* Fix failing tests

* Fix failing gamepad axis tests

* Minor documentation fix, s/pressed/released/ (#206)

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* Improve ToggleActions (#228)

* Improve ToggleActions, closes #227

- Make `_phantom` field public and rename into `phantom`.
- Add `ToggleActions::new`.
- Add `ToggleActions::ENABLED` and `ToggleActions::DISABLED`.

* Remove ToggleActions::new

* Add `ActionState::action_data_mut` for retrieving mutable state for an action. (#214)

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* Fix clippy warnings to also derive `Eq` (#236)

* Fix clippy warnings to also derive Eq

* Add implementation of Eq for Timing and InputMap to changelog

* Move derive Eq changelog to Usability section

* Run 'cargo check' with no features and default features in CI (#235)

* Run clippy on examples in CI (#234)

* Run clippy on examples in CI

* Fix example lint command

* Change CI workflow to run on ubuntu-latest (#233)

* Change CI workflow to run on ubuntu-latest

* Install required libraries on Linux for CI workflow

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* Release inputs when InputMap is removed (#245)

Fixes #244

* Add negative_only and positive_only constructors to SingleAxis (#246)

* Add negative_only and positive_only constructors to SingleAxis

* Update changelog

* Store per-action cooldowns (#253)

* Add very simple cooldowns

* Add cooldowns to ActionState and ActionData

* Add trigger and can_trigger methods to `ActionState`

* Clean up and demo API for ActionState cooldowns

* Update release notes

* Store Cooldowns in a component (#261)

* Store Cooldowns as a component

* Revise RELEASES

* Add simple integration tests

* Actually tick the cooldowns

* Fix tests

* Add cooldown ticking system to plugin

* Fix merge

* Add with_deadzone method (#264)

Authored by @Pulau-Komodo; this is just a rebase

* Add global cooldowns (#262)

* Docs clarity

* Add global cooldowns

* Add tests for GCDs

* More tests

* Fix tests

* Track number of cooldown charges (#265)

* Add cooldown charges

* Remove zero duration cooldown from tests

* Fix bugs

* Fix broken test

* Avoid overflows

* Add direct support for modifier keys (#267)

* Add Modifier type and InputKind variant

* Add convenience method to create modifier + button inputs

* Add InputMap::insert_modified

* Update release notes

* Compile errors

* Add unit tests

* Fix broken doc links

* Fix unit test

Co-authored-by: Rose Peck <olaf223224@gmail.com>
Co-authored-by: Hennadii Chernyshchyk <genaloner@gmail.com>
Co-authored-by: Elfein Landers <patlymlatun@mgail.com>
Co-authored-by: Hans W. Uhlig <huhlig@gmail.com>
Co-authored-by: Christopher Biscardi <chris@christopherbiscardi.com>
Co-authored-by: Zicklag <zicklag@katharostech.com>
Co-authored-by: Aceeri <conmcclusk@gmail.com>
Co-authored-by: Nathan Stocks <cleancut@github.com>
Co-authored-by: Shea Newton <shnewto@gmail.com>
Co-authored-by: Nolan Darilek <nolan@thewordnerd.info>
Co-authored-by: TimJentzsch <tim-jentzsch@gmx.de>
Co-authored-by: Paul Hansen <mail@paul.rs>
Co-authored-by: Rob Parrett <robparrett@gmail.com>
alice-i-cecile added a commit that referenced this pull request Oct 14, 2022
* Start 0.3 process

* Swap back to a by-value API

* Primitives for working with Axislike inputs

* Split primitives into a dedicated file

* Improve conversion strategy for primitives

* Direction partitionings

* Algebraic operations for Rotation

* Fixed broken tests

* InputAxis -> AxisPair

* AxisPair::new()

* Swap to usize-based hashing to support value-ful actions

* Noted addition of geometric rotation primitives

* Simplify set_state logic

* Correctly initialize ActionState again

* Fix PartialOrd trait for Timing

* Store and set action values

* Use Vec storage internally

Fixes #69.

* Experimentation with action value API

* Revert "Experimentation with action value API"

This reverts commit 76b9d15.

* Don't store action values

* Run examples in CI

Borrowed from https://github.com/bevyengine/bevy/blob/main/.github/workflows/ci.yml

* Remove bevy-specific logic in examples CI

* Don't try to run examples; way too hard

* Use underscores for crate name

* mdlint rules

* Move geometric primitives into leafwing_2d

* Remove dead code in macro

* Underscores in crate name

* Local development

* Relative path for macros crate

* Fix outdated example

* Fix underscores in crate name

* Polish README

* Fix broken doc links

* Simplify CI: no reason to try to run on all platforms

* Refactor `which_pressed` to return a `Vec<VirtualButtonState>`

This is not only cleaner than returning a `HashSet` of indicies, but also opens up the way to add `UserInput` information

* Update `get_clashes` to use a slice instead of a full `Vec`

Clippy recommended this for _performance purposes_

* Run `cargo fmt`

Oops

* Add API method to return which `UserInput` triggered an action

* Move bevy_ui dependency under a feature

* Vendor leafwing_2d orientation code

Should not block a release

* replace_at and clear_at can be used in a device-agnostic way

* Use usize for container sizes

* Fix missing dependencies

* Remove per_mode_cap

* Simplify InputMap API

* Fix docs formatting

* Remove extra pub specifier

* Remove UserInput::Null

* Remove empty_chords test

Doesn't make sense after `UserInput::Null` removal.

* Update RELEASES.md

* Add missing change to RELEASES.md

* Add methods to conveniently iterate over mappings

* Use type alias

* Add InputMap::remove

* Store ClashStrategy in a resource

* Remove clashing input caching

* Enable default for serde

* Fix formatting

* Changed `ActionState.button_states` inserts into direct assignments

* Added helper function for setting `action` as "held"

* Iterate over actions with mapping by default

In previous PR I added a method to iterate over inputs. But I realized
that such iteration should be with action like in normal map.
So I renamed the submitted `iter()` method into `iter_inputs()` and
added `iter()` that iterates over actions with inputs.
I also have to delete `IntoIter` currently because we can't use opaque
type in traits without nightly compiler.
If you know how to implement it properly - I would appreciate your
advice. But for now I removed it.

* Add binding_menu example

* Fix tests (#99)

* Fix which_pressed test

* Remove references to leafwing_2d

* Fix failing doc tests

* Depend on bevy subcrates (#100)

* Fix doc strings

* Use bevy subcrates for faster compiles and easier feature creation

* Replace run_in_state with DisableInput resource (#106)

* Replace run_in_state with DisableInput resource

* Update release notes

* Fix formatting

* Improve system label description

* Apply suggestions

* Systems refactor (#107)

* Refactor plugin systems logic

Insert systems right away instead of putting them into
input_manager_systems system set.

* Rename `InputManagerSystem::Reset` into `InputManagerSystem::Tick`

* Chain add_system_to_stage calls

* Allow use of InputMap and ActionState as resources

* Adding InputResource and supporting system modifications

* Second Attempt

* Cleaning up formatting.

* Adding RELEASES.md notice.

* Update RELEASES.md

New working as provided by alice-i-cecile

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* Addressing Shatur's naming Concerns.

* Adding lint exception

* adding clippy:: to too_many_arguments

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* Naming nits for systems (#111)

* Tests and refactoring for reasons pressed (#110)

* Move VirtualButtonState and Timing into a more appropriate location

* Use named fields in VirtualButtonState

* Removed poorly motivated ButtonThresholds struct

* reasons_pressed methods

* press and release methods on VirtualButtonState

* VirtualButtonState::tick

* Doc tests for reasons_pressed

* Shorten module names

* Refactor UserInput into its own file

* Fix timing test

* Fix broken doc tests

* ActionState::reset API (#112)

* ActionState::make_held -> ActionState::reset

* Fix rename in doc test

* Fixed misleading merge conflict in RELEASES

* Clean up release notes

* Fix import in doc tests

* More release note polish...

* Fix doc test

* Added example demonstrating how to use reset in system

* Refactor VirtualButtonState (#113)

* Rename VirtualButtonState to ButtonState

* Radically simplify ButtonState

* Re-add reasons_pressed functionality

* Fetch ActionData, not ButtonState

* Re-add Timing functionality

* Consolidate tests

* Updated release notes

* Assorted cleanup

* Fix tests

* Provide functionality to release inputs during mocking (#114)

* Note that mocked inputs will not be automatically released

* Add input releasing to input mocking tools

* Add UserInput::raw_inputs

* Add ActionState::freeze (#115)

* ActionState::freeze and ActionState::unfreeze

* Yeet DisableInput resource

* Fix stray doc test (#116)

* Replace freeze API with improved DisableInput resource (#117)

* Replace freeze API with DisableInput improved resource

ActionState::freeze was introduced to consume actions. But it turns
out not very ergonomic. Also freeze require to spawn an entity or
init the resource should which is not always the case.
In this iteration I used run criteria to make the code nicer.
Also I extended disable_input test to check if global and entity input
is released on disable.

* Use field to control if actions are enabled

* Update RELEASES.md

* Add ActionState::consume (#118)

* Update to Bevy 0.7 (#119)

* Bump dependencies

* New ergonomics!

* Fix typo

* Bump bevy_egui dev-dependency

* Finalize release notes (#120)

* Reduce Bevy dependencies (#126)

* Properly document ToggleActions (#134)

* Fix dead links to ToggleActions

* Add plugin-level documentation to describe how to pause and resume

* Improve plugin-level docs (#137)

* Document the need to specify system ordering

* Document the use of multiple actionlike enums

* Expanded ActionStateDriver docs (#138)

* Don't run CI twice for repo-owned branches (#140)

* Bump LWIM dependency

* Add code snippet to README (#139)

* Remove missed boilerplate from README (#142)

* Update crate name in README (#143)

* Add Bevy Gilrs to Dev Dependency Features (#150)

This way you can run the examples with gamepad support.

* Fix broken duration pressed functionality (#129)

* Improve press_duration example description

* Added integration test for durations

* Test cleanup

* Create seemingly useless test

* Isolate source of problems

* Don't flip the timing unless a state change occurs

* Add bug fix to release notes

* Made duration integration test stricter

* Handle time not having a last update gracefully (#146)

* Identify source(s) of problems

* Improve tricky duration pressed integration test

* Do not advance timing info for consumed actions

* Remove reset_inputs from tests

* Move trivial do_nothing test to top of integration test file

* Remove double updates from duration test

* Improve strategy for computing elapsed time

* Don't sleep in unit tests

* Simplify duration tests

* Start timer at the correct time

* Current duration should be measured from the last frame

* Add missing release note

* Fix CI

* Bump to 0.4 because breaking change needed

Co-authored-by: Aceeri <conmcclusk@gmail.com>

* Reverse order of `InputMap` from `(action, input)` to `(input, action)` (#152)

* Swap order of InputMap methods from (Action, Input) to (Input, Action)

* Update release notes

* Don't duplicate CI checks for Leafwing-Studios PRs (#153)

* Add Support For Gamepad Axes (#151)

* Add Support For Gamepad Axes

* Update Doc Comment

Co-authored-by: Nathan Stocks <cleancut@github.com>

* Demonstrate Button Value in the Analog Stick Demo

* Add Helper Method ActionState::get_value()

* Add Dual Axis Support

* Implement Virtual DPad

* Implement Values and Axis Pairs for Chords

* Address Code Review

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* Update README.md and RELEASES.md

* Cargo Format

* Non-Inclusive Comparisons For positive_low/high

* Split Dual Axis Deadzone Into Component Parts

* Apply Updates Suggested in Review

* Apply More Suggestions

* Move VirtualDPad To Its Own Struct

* Apply Updates From Code Review

Co-authored-by: Nathan Stocks <cleancut@github.com>

* Fix Compile Errors

* Fix DPad Clash Detection

* Cargo Format

Co-authored-by: Nathan Stocks <cleancut@github.com>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* Merge changes from main into dev branch (#163)

* Release 0.4 (#141)

* Start 0.3 process

* Swap back to a by-value API

* Primitives for working with Axislike inputs

* Split primitives into a dedicated file

* Improve conversion strategy for primitives

* Direction partitionings

* Algebraic operations for Rotation

* Fixed broken tests

* InputAxis -> AxisPair

* AxisPair::new()

* Swap to usize-based hashing to support value-ful actions

* Noted addition of geometric rotation primitives

* Simplify set_state logic

* Correctly initialize ActionState again

* Fix PartialOrd trait for Timing

* Store and set action values

* Use Vec storage internally

Fixes #69.

* Experimentation with action value API

* Revert "Experimentation with action value API"

This reverts commit 76b9d15.

* Don't store action values

* Run examples in CI

Borrowed from https://github.com/bevyengine/bevy/blob/main/.github/workflows/ci.yml

* Remove bevy-specific logic in examples CI

* Don't try to run examples; way too hard

* Use underscores for crate name

* mdlint rules

* Move geometric primitives into leafwing_2d

* Remove dead code in macro

* Underscores in crate name

* Local development

* Relative path for macros crate

* Fix outdated example

* Fix underscores in crate name

* Polish README

* Fix broken doc links

* Simplify CI: no reason to try to run on all platforms

* Refactor `which_pressed` to return a `Vec<VirtualButtonState>`

This is not only cleaner than returning a `HashSet` of indicies, but also opens up the way to add `UserInput` information

* Update `get_clashes` to use a slice instead of a full `Vec`

Clippy recommended this for _performance purposes_

* Run `cargo fmt`

Oops

* Add API method to return which `UserInput` triggered an action

* Move bevy_ui dependency under a feature

* Vendor leafwing_2d orientation code

Should not block a release

* replace_at and clear_at can be used in a device-agnostic way

* Use usize for container sizes

* Fix missing dependencies

* Remove per_mode_cap

* Simplify InputMap API

* Fix docs formatting

* Remove extra pub specifier

* Remove UserInput::Null

* Remove empty_chords test

Doesn't make sense after `UserInput::Null` removal.

* Update RELEASES.md

* Add missing change to RELEASES.md

* Add methods to conveniently iterate over mappings

* Use type alias

* Add InputMap::remove

* Store ClashStrategy in a resource

* Remove clashing input caching

* Enable default for serde

* Fix formatting

* Changed `ActionState.button_states` inserts into direct assignments

* Added helper function for setting `action` as "held"

* Iterate over actions with mapping by default

In previous PR I added a method to iterate over inputs. But I realized
that such iteration should be with action like in normal map.
So I renamed the submitted `iter()` method into `iter_inputs()` and
added `iter()` that iterates over actions with inputs.
I also have to delete `IntoIter` currently because we can't use opaque
type in traits without nightly compiler.
If you know how to implement it properly - I would appreciate your
advice. But for now I removed it.

* Add binding_menu example

* Fix tests (#99)

* Fix which_pressed test

* Remove references to leafwing_2d

* Fix failing doc tests

* Depend on bevy subcrates (#100)

* Fix doc strings

* Use bevy subcrates for faster compiles and easier feature creation

* Replace run_in_state with DisableInput resource (#106)

* Replace run_in_state with DisableInput resource

* Update release notes

* Fix formatting

* Improve system label description

* Apply suggestions

* Systems refactor (#107)

* Refactor plugin systems logic

Insert systems right away instead of putting them into
input_manager_systems system set.

* Rename `InputManagerSystem::Reset` into `InputManagerSystem::Tick`

* Chain add_system_to_stage calls

* Allow use of InputMap and ActionState as resources

* Adding InputResource and supporting system modifications

* Second Attempt

* Cleaning up formatting.

* Adding RELEASES.md notice.

* Update RELEASES.md

New working as provided by alice-i-cecile

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* Addressing Shatur's naming Concerns.

* Adding lint exception

* adding clippy:: to too_many_arguments

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* Naming nits for systems (#111)

* Tests and refactoring for reasons pressed (#110)

* Move VirtualButtonState and Timing into a more appropriate location

* Use named fields in VirtualButtonState

* Removed poorly motivated ButtonThresholds struct

* reasons_pressed methods

* press and release methods on VirtualButtonState

* VirtualButtonState::tick

* Doc tests for reasons_pressed

* Shorten module names

* Refactor UserInput into its own file

* Fix timing test

* Fix broken doc tests

* ActionState::reset API (#112)

* ActionState::make_held -> ActionState::reset

* Fix rename in doc test

* Fixed misleading merge conflict in RELEASES

* Clean up release notes

* Fix import in doc tests

* More release note polish...

* Fix doc test

* Added example demonstrating how to use reset in system

* Refactor VirtualButtonState (#113)

* Rename VirtualButtonState to ButtonState

* Radically simplify ButtonState

* Re-add reasons_pressed functionality

* Fetch ActionData, not ButtonState

* Re-add Timing functionality

* Consolidate tests

* Updated release notes

* Assorted cleanup

* Fix tests

* Provide functionality to release inputs during mocking (#114)

* Note that mocked inputs will not be automatically released

* Add input releasing to input mocking tools

* Add UserInput::raw_inputs

* Add ActionState::freeze (#115)

* ActionState::freeze and ActionState::unfreeze

* Yeet DisableInput resource

* Fix stray doc test (#116)

* Replace freeze API with improved DisableInput resource (#117)

* Replace freeze API with DisableInput improved resource

ActionState::freeze was introduced to consume actions. But it turns
out not very ergonomic. Also freeze require to spawn an entity or
init the resource should which is not always the case.
In this iteration I used run criteria to make the code nicer.
Also I extended disable_input test to check if global and entity input
is released on disable.

* Use field to control if actions are enabled

* Update RELEASES.md

* Add ActionState::consume (#118)

* Update to Bevy 0.7 (#119)

* Bump dependencies

* New ergonomics!

* Fix typo

* Bump bevy_egui dev-dependency

* Finalize release notes (#120)

* Reduce Bevy dependencies (#126)

* Properly document ToggleActions (#134)

* Fix dead links to ToggleActions

* Add plugin-level documentation to describe how to pause and resume

* Improve plugin-level docs (#137)

* Document the need to specify system ordering

* Document the use of multiple actionlike enums

* Expanded ActionStateDriver docs (#138)

* Don't run CI twice for repo-owned branches (#140)

* Bump LWIM dependency

* Add code snippet to README (#139)

* Remove missed boilerplate from README (#142)

* Update crate name in README (#143)

* Add Bevy Gilrs to Dev Dependency Features (#150)

This way you can run the examples with gamepad support.

* Fix broken duration pressed functionality (#129)

* Improve press_duration example description

* Added integration test for durations

* Test cleanup

* Create seemingly useless test

* Isolate source of problems

* Don't flip the timing unless a state change occurs

* Add bug fix to release notes

* Made duration integration test stricter

* Handle time not having a last update gracefully (#146)

* Identify source(s) of problems

* Improve tricky duration pressed integration test

* Do not advance timing info for consumed actions

* Remove reset_inputs from tests

* Move trivial do_nothing test to top of integration test file

* Remove double updates from duration test

* Improve strategy for computing elapsed time

* Don't sleep in unit tests

* Simplify duration tests

* Start timer at the correct time

* Current duration should be measured from the last frame

* Add missing release note

* Fix CI

* Bump to 0.4 because breaking change needed

Co-authored-by: Aceeri <conmcclusk@gmail.com>

* Reverse order of `InputMap` from `(action, input)` to `(input, action)` (#152)

* Swap order of InputMap methods from (Action, Input) to (Input, Action)

* Update release notes

Co-authored-by: Rose Peck <olaf223224@gmail.com>
Co-authored-by: Hennadii Chernyshchyk <genaloner@gmail.com>
Co-authored-by: Elfein Landers <patlymlatun@mgail.com>
Co-authored-by: Hans W. Uhlig <huhlig@gmail.com>
Co-authored-by: Christopher Biscardi <chris@christopherbiscardi.com>
Co-authored-by: Zicklag <zicklag@katharostech.com>
Co-authored-by: Aceeri <conmcclusk@gmail.com>

* Hyphens in crate name

* sync up macros dependency with macros crate name (#161)

* sync up macros dependency with macros crate name

* version bump and release notes for 0.4.1

* Update hyphenation of parent crate in docs

* Fix conflict between macro crate name and version (#162)

* Revert "sync up macros dependency with macros crate name (#161)"

This reverts commit ba4e704.

* Swap to underscores in macro crate name only

This matches the published crate name.

* Add release notes

* Bump version of macros crate

* Bump version of main crate

Co-authored-by: Shea Newton <shnewto@gmail.com>

* Bump version numbers

* Fixed release notes

* Specify minor versions

Co-authored-by: Rose Peck <olaf223224@gmail.com>
Co-authored-by: Hennadii Chernyshchyk <genaloner@gmail.com>
Co-authored-by: Elfein Landers <patlymlatun@mgail.com>
Co-authored-by: Hans W. Uhlig <huhlig@gmail.com>
Co-authored-by: Christopher Biscardi <chris@christopherbiscardi.com>
Co-authored-by: Zicklag <zicklag@katharostech.com>
Co-authored-by: Aceeri <conmcclusk@gmail.com>
Co-authored-by: Shea Newton <shnewto@gmail.com>

* Add builder methods for new axislike input types (#165)

* Move VirtualDpad to axislike.rs file

* Work around RA macro import resolution issue

* Add simple builder methods for VirtualDPads

* Move SingleGamepadAxis and DualGamepadAxis to axislike.rs

* Simple builder methods for Single and DualGamepadAxis

* Add builder methods for gamepad analogue sticks

* Update example to use new builders

* Don't store DualGamepadAxis in VirtualDPad

* Silence spurious clippy warning

* Remove reasons_pressed API. (#167)

* Scan all gamepads for inputs if none is registered (#168)

* Remove reasons_pressed API.

* Scan the list of all gamepads if no particular gamepad is registered

* Update examples

* Use same strategies for InputMocking::pressed

* Record FIXME notes

* Search all gamepads if no gamepad is registered

* Remove incorrect Chord logic for axis_pair and input_value

* Use button value in get_input_value as a fallback, rather than 0.0

* Explain weird design choice

* Update docs

* Clippy

* Update to Bevy 0.8-dev (#170)

* Update dependencies to 0.8-dev branch of Bevy

* Fix compile errors

* Use new const Vec2 methods

* Make egui example pass CI

* Align variable naming with bevy_input conventions

* Set axis values when mocking user input (#171)

* Remove resolved FIXME comments

* Allow users to send analog input values

* Clarity rename

* Update doc string to reflect current design

* Fix broken imports (#172)

Thanks merge conflicts :(

* Cleanup old TODO and FIXME comments (#176)

* Remove completed TODO / FIXME comments

* Add Direction::try_new

* Measure rotation counterclockwise from x (#177)

* switch from 'clockwise from midnight' to 'counterclockwise from the positive x axis' for Rotation and Direction

* fix usage

* stop using .normalize(), which can panic

* simplify logic

* remove unused import

* Doc nit

* re-enable all assertions

* add release notes

* clarify why we changed rotation direction

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* use Result consistently

* Tweak release notes

* Remove Direction::try_new

Co-authored-by: Nathan Stocks <cleancut@github.com>

* Support mouse wheel inputs (#173)

* Rename SingleGamepadAxis to SingleAxis

* Do not clamp lengths of axis pairs

* Move InputStreams into a dedicated file

UserInput was getting excessively long and InputStreams code is well isolated.

* Add helper methods to construct InputStream types from the World

* Add mouse wheel events to InputStreams

* Generalize GamepadAxisType to AxisType

* Update release notes

* Rename for generality

* Rename AxisPair to DualAxisData

* Store two SingleAxis inside of DualAxis

* Use more descriptive variable names in user_input.rs

* Account for mouse wheel inputs in InputMode conversion

* Yeet InputMode enum

* Variable renaming for generality

* Mock mouse wheel inputs

* Refactor input_value methods on InputStreams

* Take a pair of floats in DualAxisData::new

* Sum mouse wheel events to get input_value

* Add buttonlike MouseWheelDirection InputKind

* Rederive Debug

Fixes #175.

* clippy

* Builder methods for working with mouse wheel inputs

* Add new types to prelude

* Add missing From impls

* Add mouse_wheel example

* Make mouse wheel direction summing less clever

* Actually add code for panning right to example

* Add note about dumb Bevy bug

* Scale 2D cameras correctly :upside_down:

* Fix stated ordering in InputMap docs

* Add tests for working with mouse wheel inputs

* Add DualAxis::from_value helpers

* Add test for raw events

* get_input_value -> input_value

* Add clamped helper methods

* Shorten axis_pair and value method names

* Make CI pass

* Support Single Axis Inputs in Virtual DPads (#180)

* Temporarily Comment Out Bevy Egui

* Make Axis Input Example Slightly More Readable

* Fix Bug in Symmetric Axis Constructor

Axis would always trigger because negative_low was positive.

* Return Axis Pair Results When Action Isn't Pressed

This makes sure that axis_pair() returns `Some` even if the value is
zero because the axis isn't moved.

* Set Dual Axis Value Zero if Not in Trigger Range

* Make Single-Axis Inputs Work in Virtual DPad

This makes sure that SingleAxis inputs will report a value of 0.0 if the
axis value is not withing the triggering zone. This makes it possible to
create a virtual gamepad made up of multiple single-axis inputs on the
same stick.

* Cargo Format

* Add mouse motion support (#186)

* Add MouseMotion events to input streams

* Add discretized MouseMotionDirection buttonlike input support

* Continuous-valued mouse motion inputs

* Doc fixes for AxisData

* Builder methods for Axis types

* Add simple mouse_motion example

* Depend on bevy directly (#187)

This is a) much cleaner and easier to maintain b) makes it easier for others to patch this crate to a specific version and c) slightly more robust to bevy shuffling code around

* Add bevy_asset as a feature for the examples (#190)

* Bump to Bevy 0.8 (#192)

* Bump dependencies

* Re-enable binding_menu example

* Make input stream fields non-optional (#193)

* Add better module-level docs

* Make input streams non-optional

* InputStreams::from_world does not need &mut World

* Satisfy borrow checker in tests

* Fix lifetime of MutableInputStreams -> InputStreams method

* Fix integration test

* Update release notes

* Add mockable_world builder function

* Clean up input mocking code (#194)

* Documentation improvements to input mocking

* (Mostly) implement InputMocking trait for MutableInputStreams

* Use InputStreams::guess_gamepad internally

* Allows conversion by reference from MutableInputStreams

* Add tests for decomposing `UserInput` into raw inputs (#197)

* Documentation improvements to input mocking

* (Mostly) implement InputMocking trait for MutableInputStreams

* Use InputStreams::guess_gamepad internally

* Allows conversion by reference from MutableInputStreams

* Correctly release input

* Swap to a RawInputs struct

* Update docs for UserInput::chord

* Add tests for RawInputs

* Fix Compile Without UI Feature (#198)

* Fix axislike input mocking (kind of) (#200)

* Re-enable tests

* Actually add axislike inputmanagerplugin XD

* Move actionstate init to test setup

* Improve axis-like input mocking tests

* Reorganize MutableInputStreams::send_input

* Actually send discrete mouse motion events

* Add more tests for axislike inputs

* Improve gamepad status handling for axislike gamepad inputs

* Ignore failing tests

* Actually register a gamepad for tests

* Disable tests that are still failing

* Mocking inputs should send raw events (#207)

* Add more fields to mutable input streams

* Rename InputStreams fields for clarity

* Send raw events when doing input mocking

* Don't guess gamepad in send_input_to_gamepad; handled upstream

* Enable fixed gamepad mocking tests

* Always enable bevy_gilrs

* Fix failing tests

* Fix failing gamepad axis tests

* Minor documentation fix, s/pressed/released/ (#206)

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* Improve ToggleActions (#228)

* Improve ToggleActions, closes #227

- Make `_phantom` field public and rename into `phantom`.
- Add `ToggleActions::new`.
- Add `ToggleActions::ENABLED` and `ToggleActions::DISABLED`.

* Remove ToggleActions::new

* Add `ActionState::action_data_mut` for retrieving mutable state for an action. (#214)

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* Fix clippy warnings to also derive `Eq` (#236)

* Fix clippy warnings to also derive Eq

* Add implementation of Eq for Timing and InputMap to changelog

* Move derive Eq changelog to Usability section

* Run 'cargo check' with no features and default features in CI (#235)

* Run clippy on examples in CI (#234)

* Run clippy on examples in CI

* Fix example lint command

* Change CI workflow to run on ubuntu-latest (#233)

* Change CI workflow to run on ubuntu-latest

* Install required libraries on Linux for CI workflow

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>

* Release inputs when InputMap is removed (#245)

Fixes #244

* Add negative_only and positive_only constructors to SingleAxis (#246)

* Add negative_only and positive_only constructors to SingleAxis

* Update changelog

* Store per-action cooldowns (#253)

* Add very simple cooldowns

* Add cooldowns to ActionState and ActionData

* Add trigger and can_trigger methods to `ActionState`

* Clean up and demo API for ActionState cooldowns

* Update release notes

* Store Cooldowns in a component (#261)

* Store Cooldowns as a component

* Revise RELEASES

* Add simple integration tests

* Actually tick the cooldowns

* Fix tests

* Add cooldown ticking system to plugin

* Fix merge

* Add with_deadzone method (#264)

Authored by @Pulau-Komodo; this is just a rebase

* Add global cooldowns (#262)

* Docs clarity

* Add global cooldowns

* Add tests for GCDs

* More tests

* Fix tests

* Track number of cooldown charges (#265)

* Add cooldown charges

* Remove zero duration cooldown from tests

* Fix bugs

* Fix broken test

* Avoid overflows

* Add direct support for modifier keys (#267)

* Add Modifier type and InputKind variant

* Add convenience method to create modifier + button inputs

* Add InputMap::insert_modified

* Update release notes

* Compile errors

* Add unit tests

* Fix broken doc links

* Fix unit test

* Bump macro crate version to match

* Update README

Co-authored-by: Rose Peck <olaf223224@gmail.com>
Co-authored-by: Hennadii Chernyshchyk <genaloner@gmail.com>
Co-authored-by: Elfein Landers <patlymlatun@mgail.com>
Co-authored-by: Hans W. Uhlig <huhlig@gmail.com>
Co-authored-by: Christopher Biscardi <chris@christopherbiscardi.com>
Co-authored-by: Zicklag <zicklag@katharostech.com>
Co-authored-by: Aceeri <conmcclusk@gmail.com>
Co-authored-by: Nathan Stocks <cleancut@github.com>
Co-authored-by: Shea Newton <shnewto@gmail.com>
Co-authored-by: Nolan Darilek <nolan@thewordnerd.info>
Co-authored-by: TimJentzsch <tim-jentzsch@gmx.de>
Co-authored-by: Paul Hansen <mail@paul.rs>
Co-authored-by: Rob Parrett <robparrett@gmail.com>
james7132 pushed a commit to james7132/bevy that referenced this pull request Oct 28, 2022
Generally a good idea.

I ran into this because I wanted to store `Gamepads` in a wrapper struct in Leafwing-Studios/leafwing-input-manager#168. 

This PR allows the `Debug` derive used there to continue working. I could workaround this with a custom impl, but a PR upstream seemed like the right fix.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
Generally a good idea.

I ran into this because I wanted to store `Gamepads` in a wrapper struct in Leafwing-Studios/leafwing-input-manager#168. 

This PR allows the `Debug` derive used there to continue working. I could workaround this with a custom impl, but a PR upstream seemed like the right fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
usability Reduce user friction
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple Gamepads Bound to One InputMap
1 participant