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_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:?}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue