OVR: Make adjustments to the game's input using controllers
authorAndreas Eversberg <jolly@eversberg.eu>
Mon, 30 Apr 2018 08:43:49 +0000 (10:43 +0200)
committerAndreas Eversberg <jolly@eversberg.eu>
Mon, 30 Apr 2018 09:50:07 +0000 (11:50 +0200)
src/mercenary/main.c

index 24ea8a0..d9fb1c7 100644 (file)
@@ -71,10 +71,10 @@ static double config_fov = FOV_JOLLY;
 static double config_benson_size = 1.0;
 static double config_fov = FOV_NOVAGEN;
 #endif
 static double config_benson_size = 1.0;
 static double config_fov = FOV_NOVAGEN;
 #endif
-static double config_monitor_distance = 31.5; /* inch */
+static double config_monitor_distance = 41.5; /* inch */
 #ifdef HAVE_OVR
 #ifdef HAVE_OVR
-static double config_keyboard_distance = 30.5; /* inch */
-static double config_keyboard_height = -22.0; /* inch */
+static double config_keyboard_distance = 40.5; /* inch */
+static double config_keyboard_height = -26.0; /* inch */
 #endif
 static int config_debug_transparent = 0;
 static int config_debug_opengl = 0;
 #endif
 static int config_debug_transparent = 0;
 static int config_debug_opengl = 0;
@@ -380,7 +380,7 @@ static void handle_vr_poses(void)
        double hand_right_yaw = 0.0, hand_right_pitch = 0.0, hand_right_roll = 0.0;
        double head_yaw = 0.0, head_pitch = 0.0, head_roll = 0.0;
        double stick_left_x = 0.0, stick_left_y = 0.0, stick_right_x = 0.0, stick_right_y = 0.0;
        double hand_right_yaw = 0.0, hand_right_pitch = 0.0, hand_right_roll = 0.0;
        double head_yaw = 0.0, head_pitch = 0.0, head_roll = 0.0;
        double stick_left_x = 0.0, stick_left_y = 0.0, stick_right_x = 0.0, stick_right_y = 0.0;
-       int thrust = 0;
+       int thrust = thrust_last;
        int joystick_set_x = 0, joystick_set_y = 0;
        static uint32_t current_time, last_time = 0, diff;
        static double increment, inc_count = 0.0;
        int joystick_set_x = 0, joystick_set_y = 0;
        static uint32_t current_time, last_time = 0, diff;
        static double increment, inc_count = 0.0;
@@ -394,7 +394,7 @@ static void handle_vr_poses(void)
                else
                        help_view++;
        }
                else
                        help_view++;
        }
-       if (button_left_trigger && button_right_trigger) {
+       if (button_left_thumb) {
                /* reset observer */
                reset_observer_ovr();
                osd_info("", "reset observer");
                /* reset observer */
                reset_observer_ovr();
                osd_info("", "reset observer");
@@ -404,25 +404,30 @@ static void handle_vr_poses(void)
                        /* 'board' pressed */
                        set_amiga_key(KEYCODE_b, 1);
                        set_amiga_key(KEYCODE_b, 0);
                        /* 'board' pressed */
                        set_amiga_key(KEYCODE_b, 1);
                        set_amiga_key(KEYCODE_b, 0);
+                       /* important: get rid of old state */
+                       thrust = 0;
                }
                if (button_y && !button_y_last) {
                        /* 'leave' pressed */
                        set_amiga_key(KEYCODE_l, 1);
                        set_amiga_key(KEYCODE_l, 0);
                }
                }
                if (button_y && !button_y_last) {
                        /* 'leave' pressed */
                        set_amiga_key(KEYCODE_l, 1);
                        set_amiga_key(KEYCODE_l, 0);
                }
-               if (button_right_thumb && !button_right_thumb_last) {
-                       /* 'change orientation' pressed */
-                       double roll, pitch, yaw;
-                       mercenary_get_orientation(&roll, &pitch, &yaw);
-                       mercenary_set_orientation(yaw + hand_right_yaw);
-               }
                if (button_right_trigger && !button_right_trigger_last) {
                        /* trigger pressed */
                if (button_right_trigger && !button_right_trigger_last) {
                        /* trigger pressed */
-                       if (!keyboard_on) {
+                       if (keyboard_on) {
+                               if (vr_key) {
+                                       vr_key_pressed = vr_key;
+                                       set_amiga_key(vr_key_pressed, 1);
+                               }
+                       } else
+                       if (mercenary_get_info_walking()) {
+                               /* change orientation */
+                               double roll, pitch, yaw;
+                               mercenary_get_orientation(&roll, &pitch, &yaw);
+                               mercenary_set_orientation(yaw + hand_right_yaw);
+                       } else {
+                               /* fire button */
                                set_joystick(-1, -1, -1, -1, 1);
                                set_joystick(-1, -1, -1, -1, 1);
-                       } else if (vr_key) {
-                               vr_key_pressed = vr_key;
-                               set_amiga_key(vr_key_pressed, 1);
                        }
                }
                if (!button_right_trigger && button_right_trigger_last) {
                        }
                }
                if (!button_right_trigger && button_right_trigger_last) {
@@ -520,9 +525,8 @@ static void handle_vr_poses(void)
                if (joystick_set_y_last && !joystick_set_y)
                        set_joystick(-1, -1, 0, 0, -1);
                /* thrust */
                if (joystick_set_y_last && !joystick_set_y)
                        set_joystick(-1, -1, 0, 0, -1);
                /* thrust */
-               thrust = thrust_last;
                /* button to toggle between stop and escape */
                /* button to toggle between stop and escape */
-               if (button_left_thumb && !button_left_thumb_last) {
+               if (button_left_trigger && !button_left_trigger_last) {
                        /* 'escape' pressed */
                        if (thrust_last == 0)
                                thrust = -99;
                        /* 'escape' pressed */
                        if (thrust_last == 0)
                                thrust = -99;
@@ -1371,20 +1375,20 @@ int main(int argc, char *argv[])
                "        Press `Enter' button to toggle this help screen on or off.\n"
                "        To have a virtual keyboard, point below benson (control pannel).\n"
                "        Point to a key on keyboard. The key will highlight.\n"
                "        Press `Enter' button to toggle this help screen on or off.\n"
                "        To have a virtual keyboard, point below benson (control pannel).\n"
                "        Point to a key on keyboard. The key will highlight.\n"
-               "        Pull `Trigger' on right controller enter the highlighted key.\n"
-               "        Pull `Trigger' on both controllers to reset observer position.\n"
+               "        Pull `Trigger' on right controller to enter the highlighted key.\n"
+               "        Press thumb stick on left controller to reset observer position.\n"
                "\n"
                "Walking / Driving / Flying using Controller:\n"
                "        Use thumb stick on right controller, to move player / craft.\n"
                "        Point right controller towards the direction to walk to.\n"
                "\n"
                "Walking / Driving / Flying using Controller:\n"
                "        Use thumb stick on right controller, to move player / craft.\n"
                "        Point right controller towards the direction to walk to.\n"
-               "        Press thumb stick to change orientation to that direction.\n"
+               "        Pull `Trigger' on right controller to change orientation.\n"
                "        Press `X' button to board, `Y' button to leave.\n"
                "        Move thumb stick on left controller to drive/fly forward or backward.\n"
                "        Press `X' button to board, `Y' button to leave.\n"
                "        Move thumb stick on left controller to drive/fly forward or backward.\n"
-               "        Press thumb stick on left controller stop craft.\n"
-               "        Press thumb stick on left controller for escape sequence, after stop.\n"
+               "        Pull `Trigger' on left controller stop craft.\n"
+               "        Pull `Trigger' on left controller for escape sequence, after stop.\n"
                "        Pull `Trigger' on right controller to fire.\n"
                "\n"
                "        Pull `Trigger' on right controller to fire.\n"
                "\n"
-               "For all other game function, use the emulated keyboards!\n"
+               "For all other game function, use the virtual or real keyboard!\n"
                ,HELP_ALPHA, 1, 2, 5, 0);
        help_views = 2;
 #endif
                ,HELP_ALPHA, 1, 2, 5, 0);
        help_views = 2;
 #endif