From a038dc359cc1851ff20dcc098adb29a11375d8ad Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Tue, 1 May 2018 07:11:34 +0200 Subject: [PATCH] OVR: Fixup thrust control --- src/mercenary/main.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/mercenary/main.c b/src/mercenary/main.c index c514326..520dc8f 100644 --- a/src/mercenary/main.c +++ b/src/mercenary/main.c @@ -402,7 +402,7 @@ static void handle_vr_poses(void) /* menu toggle */ toggle_help(); } - if (button_left_thumb) { + if (button_right_thumb) { /* reset observer */ reset_observer_ovr(); osd_info("", "reset observer"); @@ -534,13 +534,18 @@ static void handle_vr_poses(void) set_joystick(-1, -1, 0, 0, -1); /* thrust */ /* button to toggle between stop and escape */ - if (button_left_trigger && !button_left_trigger_last) { + if (button_left_thumb && !button_left_thumb_last) { /* 'escape' pressed */ - if (thrust_last == 0) + if (thrust_last != -99) thrust = -99; else thrust = 0; } + /* button to stop */ + if (button_left_trigger && !button_left_trigger_last) { + /* 'stop' pressed */ + thrust = 0; + } /* get stick to increment or decrement thrust */ if (stick_left_y > STICK_THRUST_THRESHOLD) increment = (stick_left_y - STICK_THRUST_THRESHOLD) / (1.0 - STICK_THRUST_THRESHOLD); @@ -553,6 +558,9 @@ static void handle_vr_poses(void) if (increment) { diff = current_time - last_time; inc_count += increment * diff; + /* if we are in 'escape' mode, we stop thrust first */ + if (thrust == -99) + thrust = 0; if (inc_count > 150.0 && thrust >= -10 && thrust < 10) { thrust++; inc_count = 0.0; @@ -567,6 +575,12 @@ static void handle_vr_poses(void) last_time = current_time; /* send thrust change as keycodes */ if (thrust_last != thrust) { + /* if we were in escape mode, we stop us first and then apply the new code */ + if (thrust_last == -99) { + set_amiga_key(KEYCODE_SPACE, 1); + set_amiga_key(KEYCODE_SPACE, 0); + } + if (thrust >= 10) { set_amiga_key(KEYCODE_0, 1); set_amiga_key(KEYCODE_0, 0); @@ -1402,7 +1416,7 @@ int main(int argc, char *argv[]) " Press `X' button to board, `Y' button to leave.\n" " Move thumb stick on left controller to drive/fly forward or backward.\n" " Pull `Trigger' on left controller stop craft.\n" - " Pull `Trigger' on left controller for escape sequence, after stop.\n" + " Press thumb stick on left controller for escape sequence and stop it.\n" " Pull `Trigger' on right controller to fire.\n" "\n" "For all other game function, use the virtual or real keyboard!\n" -- 2.13.6