-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 getters and setters for InputAxis
and ButtonSettings
#3446
Conversation
Thanks for contributing, and the great questions! I've replied to your questions over in #3446, could you apply them to this PR if you agree with them? :) |
@alice-i-cecile I do agree with them, thanks. I'll make sure to run clippy this time too lol. Not sure why |
positive_high => livezone_upperbound positive_low => deadzone_upperbound negative_low => deadzone_lowerbound negative_high => livezone_lowerbound
Fixed up |
Could you add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, this looks fantastic. What a nice improvement!
InputAxis
InputAxis
and ButtonSettings
1.0 | ||
} else if new_value <= self.negative_high { | ||
-1.0 | ||
/// Creates a new AxisSettings instance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Creates a new AxisSettings instance | |
/// Creates a new [`AxisSettings`] instance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome. Truly an industrial strength API now 😉 The clarity is very much appreciated here.
@@ -2,6 +2,18 @@ use crate::{Axis, Input}; | |||
use bevy_app::{EventReader, EventWriter}; | |||
use bevy_ecs::system::{Res, ResMut}; | |||
use bevy_utils::{tracing::info, HashMap, HashSet}; | |||
use thiserror::Error; | |||
|
|||
/// Errors that occur when setting settings for gamepad input |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe "configuring settings" or "setting up gamepad input". "setting settings" feels weird
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor nits to doc-comments, otherwise this looks really solid :)
@@ -2,6 +2,18 @@ use crate::{Axis, Input}; | |||
use bevy_app::{EventReader, EventWriter}; | |||
use bevy_ecs::system::{Res, ResMut}; | |||
use bevy_utils::{tracing::info, HashMap, HashSet}; | |||
use thiserror::Error; | |||
|
|||
/// Errors that occur when setting settings for gamepad input |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Errors that occur when setting settings for gamepad input | |
/// Errors that occur when attempting to incorrectly configure gamepad input |
@mfdorst do you have time to get back to this? This is almost ready to merge :) |
Closing in favor of the rebased #6050. |
# Objective Fixes #3418 ## Solution Originally a rebase of #3446. Work was originally done by mfdorst, who should receive considerable credit. Then the error types were extensively reworked by targrub. ## Migration Guide `AxisSettings` now has a `new()`, which may return an `AxisSettingsError`. `AxisSettings` fields made private; now must be accessed through getters and setters. There's a dead zone, from `.deadzone_upperbound()` to `.deadzone_lowerbound()`, and a live zone, from `.deadzone_upperbound()` to `.livezone_upperbound()` and from `.deadzone_lowerbound()` to `.livezone_lowerbound()`. `AxisSettings` setters no longer panic. `ButtonSettings` fields made private; now must be accessed through getters and setters. `ButtonSettings` now has a `new()`, which may return a `ButtonSettingsError`. Co-authored-by: targrub <62773321+targrub@users.noreply.github.com>
…ine#6088) # Objective Fixes bevyengine#3418 ## Solution Originally a rebase of bevyengine#3446. Work was originally done by mfdorst, who should receive considerable credit. Then the error types were extensively reworked by targrub. ## Migration Guide `AxisSettings` now has a `new()`, which may return an `AxisSettingsError`. `AxisSettings` fields made private; now must be accessed through getters and setters. There's a dead zone, from `.deadzone_upperbound()` to `.deadzone_lowerbound()`, and a live zone, from `.deadzone_upperbound()` to `.livezone_upperbound()` and from `.deadzone_lowerbound()` to `.livezone_lowerbound()`. `AxisSettings` setters no longer panic. `ButtonSettings` fields made private; now must be accessed through getters and setters. `ButtonSettings` now has a `new()`, which may return a `ButtonSettingsError`. Co-authored-by: targrub <62773321+targrub@users.noreply.github.com>
…ine#6088) # Objective Fixes bevyengine#3418 ## Solution Originally a rebase of bevyengine#3446. Work was originally done by mfdorst, who should receive considerable credit. Then the error types were extensively reworked by targrub. ## Migration Guide `AxisSettings` now has a `new()`, which may return an `AxisSettingsError`. `AxisSettings` fields made private; now must be accessed through getters and setters. There's a dead zone, from `.deadzone_upperbound()` to `.deadzone_lowerbound()`, and a live zone, from `.deadzone_upperbound()` to `.livezone_upperbound()` and from `.deadzone_lowerbound()` to `.livezone_lowerbound()`. `AxisSettings` setters no longer panic. `ButtonSettings` fields made private; now must be accessed through getters and setters. `ButtonSettings` now has a `new()`, which may return a `ButtonSettingsError`. Co-authored-by: targrub <62773321+targrub@users.noreply.github.com>
…ine#6088) # Objective Fixes bevyengine#3418 ## Solution Originally a rebase of bevyengine#3446. Work was originally done by mfdorst, who should receive considerable credit. Then the error types were extensively reworked by targrub. ## Migration Guide `AxisSettings` now has a `new()`, which may return an `AxisSettingsError`. `AxisSettings` fields made private; now must be accessed through getters and setters. There's a dead zone, from `.deadzone_upperbound()` to `.deadzone_lowerbound()`, and a live zone, from `.deadzone_upperbound()` to `.livezone_upperbound()` and from `.deadzone_lowerbound()` to `.livezone_lowerbound()`. `AxisSettings` setters no longer panic. `ButtonSettings` fields made private; now must be accessed through getters and setters. `ButtonSettings` now has a `new()`, which may return a `ButtonSettingsError`. Co-authored-by: targrub <62773321+targrub@users.noreply.github.com>
…ine#6088) # Objective Fixes bevyengine#3418 ## Solution Originally a rebase of bevyengine#3446. Work was originally done by mfdorst, who should receive considerable credit. Then the error types were extensively reworked by targrub. ## Migration Guide `AxisSettings` now has a `new()`, which may return an `AxisSettingsError`. `AxisSettings` fields made private; now must be accessed through getters and setters. There's a dead zone, from `.deadzone_upperbound()` to `.deadzone_lowerbound()`, and a live zone, from `.deadzone_upperbound()` to `.livezone_upperbound()` and from `.deadzone_lowerbound()` to `.livezone_lowerbound()`. `AxisSettings` setters no longer panic. `ButtonSettings` fields made private; now must be accessed through getters and setters. `ButtonSettings` now has a `new()`, which may return a `ButtonSettingsError`. Co-authored-by: targrub <62773321+targrub@users.noreply.github.com>
Fixes #3418