re-implement J/K/U/L/I/O key bindings for mouseless gaming

This commit is contained in:
yuni 2024-11-18 05:24:41 +01:00
parent 7ec1cc885b
commit 780fa65349
3 changed files with 24 additions and 0 deletions

View file

@ -54,6 +54,7 @@ Press **ESC** to view these any time from the in-game menu.
- **T**: Cruise control
- **R**: Rotate (hold + move mouse)
- **AWSD/Shift/Ctrl**: Move
- **J/K/U/L/I/O**: Rotate
- **F11**: Fullscreen
- **Tab**: Toggle Augmented Reality
- **Left click**: Target objects (in AR only)

View file

@ -444,6 +444,7 @@ fn manage_player_actor(
pub fn apply_input_to_player(
mut commands: Commands,
time: Res<Time>,
settings: Res<var::Settings>,
mut q_player: Query<
(
@ -465,6 +466,7 @@ pub fn apply_input_to_player(
return;
}
let (entity, mut accel, rot_change) = player.unwrap();
let dt = time.delta_seconds();
let (win_res_x, win_res_y): (f32, f32);
if let Ok(window) = &q_windows.get_single() {
@ -478,6 +480,26 @@ pub fn apply_input_to_player(
// Determine rotation delta
let mut pitch_yaw_rot = Vec3::ZERO;
let mut mouse_delta = Vec2::ZERO;
let mouseless_sensitivity = 1.0 * dt;
let mouseless_rotation_sensitivity = 4.0 * dt;
if key_input.pressed(settings.key_mouseup) {
pitch_yaw_rot[0] -= mouseless_sensitivity;
}
if key_input.pressed(settings.key_mousedown) {
pitch_yaw_rot[0] += mouseless_sensitivity;
}
if key_input.pressed(settings.key_mouseleft) {
pitch_yaw_rot[1] += mouseless_sensitivity;
}
if key_input.pressed(settings.key_mouseright) {
pitch_yaw_rot[1] -= mouseless_sensitivity;
}
if key_input.pressed(settings.key_rotateleft) {
pitch_yaw_rot[2] -= mouseless_rotation_sensitivity;
}
if key_input.pressed(settings.key_rotateright) {
pitch_yaw_rot[2] += mouseless_rotation_sensitivity;
}
for mouse_event in mouse_events.read() {
mouse_delta += mouse_event.delta;
}

View file

@ -7,6 +7,7 @@ C: Camera
T: Cruise control
R: Rotate (hold + move mouse)
AWSD/Shift/Ctrl: Move
J/K/U/L/I/O: Rotate
F11: Fullscreen
Tab: Toggle Augmented Reality
Left click: Target objects (in AR only)