add input handling
This commit is contained in:
parent
b8751a7374
commit
9fb93e5f7d
1 changed files with 8 additions and 2 deletions
10
src/input.rs
10
src/input.rs
|
@ -57,8 +57,8 @@ fn update_input(mut events: EventReader<GamepadEvent>, mut istate: ResMut<InputS
|
|||
button_type, value, ..
|
||||
} = button_event;
|
||||
match button_type {
|
||||
GamepadButtonType::RightTrigger => istate.throttle = *value,
|
||||
GamepadButtonType::LeftTrigger => istate.throttle = -value,
|
||||
GamepadButtonType::RightTrigger2 => istate.throttle = *value,
|
||||
GamepadButtonType::LeftTrigger2 => istate.throttle = -value,
|
||||
GamepadButtonType::East => {
|
||||
if value > &0.5 {
|
||||
istate.brake = true;
|
||||
|
@ -74,6 +74,12 @@ fn update_input(mut events: EventReader<GamepadEvent>, mut istate: ResMut<InputS
|
|||
axis_type, value, ..
|
||||
} = axis_event;
|
||||
match axis_type {
|
||||
GamepadAxisType::LeftStickX => {
|
||||
istate.yaw = *value;
|
||||
}
|
||||
GamepadAxisType::RightStickY => {
|
||||
istate.pitch = *value;
|
||||
}
|
||||
_ => info!("unhandled axis event: {axis_event:?}"),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue