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_type, value, ..
} = button_event; } = button_event;
match button_type { match button_type {
GamepadButtonType::RightTrigger => istate.throttle = *value, GamepadButtonType::RightTrigger2 => istate.throttle = *value,
GamepadButtonType::LeftTrigger => istate.throttle = -value, GamepadButtonType::LeftTrigger2 => istate.throttle = -value,
GamepadButtonType::East => { GamepadButtonType::East => {
if value > &0.5 { if value > &0.5 {
istate.brake = true; istate.brake = true;
@ -74,6 +74,12 @@ fn update_input(mut events: EventReader<GamepadEvent>, mut istate: ResMut<InputS
axis_type, value, .. axis_type, value, ..
} = axis_event; } = axis_event;
match axis_type { match axis_type {
GamepadAxisType::LeftStickX => {
istate.yaw = *value;
}
GamepadAxisType::RightStickY => {
istate.pitch = *value;
}
_ => info!("unhandled axis event: {axis_event:?}"), _ => info!("unhandled axis event: {axis_event:?}"),
} }
} }