Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new fluent builders and iterators for InputMap #513

Merged
merged 4 commits into from
May 3, 2024

Conversation

Shute052
Copy link
Collaborator

@Shute052 Shute052 commented May 1, 2024

  • added new fluent builders for creating a new InputMap<A> with short configurations:
    • fn with(mut self, action: A, input: impl Into<Item = UserInput>).
    • fn with_one_to_many(mut self, action: A, inputs: impl IntoIterator<Item = UserInput>).
    • fn with_multiple(mut self, bindings: impl IntoIterator<Item = (A, UserInput)>) -> Self.
    • fn with_gamepad(mut self, gamepad: Gamepad) -> Self.
  • added new iterators over InputMap<A>:
    • bindings(&self) -> impl Iterator<Item = (&A, &UserInput)> for iterating over all registered action-input bindings.
    • actions(&self) -> impl Iterator<Item = &A> for iterating over all registered actions.
  • removed InputMap::build method in favor of new fluent builder pattern.
  • renamed InputMap::which_pressed method to process_actions to better reflect its current functionality for clarity.

@alice-i-cecile alice-i-cecile added usability Reduce user friction breaking-change A breaking change that requires a new major version labels May 1, 2024
@@ -26,7 +26,7 @@ and a single input can result in multiple actions being triggered, which can be

- Full keyboard, mouse and joystick support for button-like and axis inputs
- Dual axis support for analog inputs from gamepads and joysticks
- Bind arbitrary button inputs into virtual DPads
Copy link
Collaborator Author

@Shute052 Shute052 May 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clippy (1.79.0-nightly (aed2187d5 2024-04-27) reports doc_markdown here

@Shute052 Shute052 marked this pull request as draft May 1, 2024 19:40
@Shute052 Shute052 marked this pull request as ready for review May 1, 2024 19:58
Copy link
Contributor

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with_gamepad feels less clear than set_gamepad: it's not the same style of operation as the other with methods. Revert that and this LGTM :)

@alice-i-cecile alice-i-cecile merged commit bc2375a into Leafwing-Studios:main May 3, 2024
4 checks passed
@Shute052 Shute052 deleted the new-input-map branch May 3, 2024 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change A breaking change that requires a new major version usability Reduce user friction
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants