You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Read the value from both the button and the custom axislike, while printing out all of the GamepadEvents that are received
let throttle = action_state.button_value(&PlayerAction::Throttle);
if throttle != 0.0 {println!("Throttle {:?}", throttle);}
let custom_throttle = action_state.value(&PlayerAction::CustomThrottle);
if custom_throttle != 0.0 {println!("CustomThrottle {:?}", custom_throttle);}
The custom Axislike reads from the CentralInputStore.
#[serde_typetag]
impl Axislike for GamepadButtonAxes {
fn value(&self, input_store: &updating::CentralInputStore, gamepad: Gamepad) -> f32 {
let up_value = match self.positive {
Some(button) => input_store.button_value(&GamepadButton::new(gamepad, button)),
None => 0.0
};
let down_value = match self.negative {
Some(button) => input_store.button_value(&GamepadButton::new(gamepad, button)),
None => 0.0
};
return up_value - down_value;
}
}
What you expected to happen
The throttle value to change over the entire range from 0.0 to 1.0 as the analog stick was depressed
What actually happened
Although GamepadEvents are emitted smoothly over depressing the analog stick, reading the value from the button only ever returns 1.0 (or 0.0) and reading the value from the CentralInputStore only returns high values over about 0.75 (or 0.0).
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.050980393
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.0627451
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.07450981
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.08627451
...
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.3647059
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.38039216
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.4
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.42352942
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.44313726
...
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.7019608
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.7254902
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.74509805
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.7607843
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.78431374
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.79607844
Throttle 1.0
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.80784315
CustomThrottle 0.827451
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.827451
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.8392157
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.8509804
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.8666667
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.8784314
Throttle 1.0
CustomThrottle 0.9019608
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.8901961
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.9019608
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.9137255
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.93333334
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 0.9490196
Throttle 1.0
CustomThrottle 0.9490196
Button RightTrigger2 on gamepad Gamepad { id: 0 } is now at 1.0
Throttle 1.0
CustomThrottle 1.0
Throttle 1.0
CustomThrottle 1.0
...
Additional information
The UpdatableInput implementation for GamepadButton only records the axis values for buttons that are either pressed or just_released
I don't know why ActionState<>::button_value and ActionState<>::clamped_button_value only return 1.0 or 0.0 even though they are documented as returning analog values in examples/axis_input.rs:
Version
54a361b
Operating system & version
Debian 12
What you did
Added a throttle button using the right analog trigger on a gamepad, and with a custom
Axislike
that reads the same thing from theCentralInputStore
.Into an input map for this
Actionlike
Read the value from both the button and the custom axislike, while printing out all of the
GamepadEvent
s that are receivedThe custom
Axislike
reads from theCentralInputStore
.What you expected to happen
The throttle value to change over the entire range from
0.0
to1.0
as the analog stick was depressedWhat actually happened
Although
GamepadEvent
s are emitted smoothly over depressing the analog stick, reading the value from the button only ever returns1.0
(or0.0
) and reading the value from theCentralInputStore
only returns high values over about0.75
(or0.0
).Additional information
The
UpdatableInput
implementation forGamepadButton
only records the axis values for buttons that are eitherpressed
orjust_released
leafwing-input-manager/src/user_input/gamepad.rs
Lines 570 to 587 in 54a361b
I don't know why
ActionState<>::button_value
andActionState<>::clamped_button_value
only return1.0
or0.0
even though they are documented as returning analog values inexamples/axis_input.rs
:leafwing-input-manager/examples/axis_inputs.rs
Lines 63 to 65 in 54a361b
The text was updated successfully, but these errors were encountered: