add input handling

This commit is contained in:
Joe Ardent 2023-03-21 17:50:51 -07:00
parent b8751a7374
commit 9fb93e5f7d

View file

@ -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:?}"),
}
}