Add VR help screen
authorAndreas Eversberg <jolly@eversberg.eu>
Sun, 22 Apr 2018 14:08:58 +0000 (16:08 +0200)
committerAndreas Eversberg <jolly@eversberg.eu>
Fri, 27 Apr 2018 19:21:15 +0000 (21:21 +0200)
src/mercenary/main.c

index 2c1a526..bd0fca6 100644 (file)
@@ -95,9 +95,10 @@ static int config_improve_smooth_planets = 1;        /* set to 1 to rotate planets smoo
 static uint8_t *memory = NULL;
 static uint8_t *stop_event = NULL;
 static uint8_t *image = NULL;
-static uint8_t *help_osd = NULL;
+static uint8_t *help_osd[2] = { NULL, NULL };
 static uint8_t *info_osd = NULL;
 static int help_view = 1;
+static int help_views = 1;
 static int32_t osd_timer = 0;
 #ifdef HAVE_OVR
 #define SCREEN_WIDTH   1344
@@ -316,7 +317,10 @@ static void handle_vr_poses(void)
        get_poses_ovr(&button_a, &button_b, &button_x, &button_y, &button_menu, &button_trigger, &button_left_thumb, &button_right_thumb, &hand_right_x, &hand_right_y, &hand_right_z, &hand_right_yaw, &hand_right_pitch, &hand_right_roll, &stick_left_x, &stick_left_y, &stick_right_x, &stick_right_y);
        if (button_menu && !button_menu_last) {
                /* menu toggle */
-               help_view ^= 1;
+               if (help_view == help_views)
+                       help_view = 0;
+               else
+                       help_view++;
        }
        if (help_view) {
                if (button_trigger && !button_trigger_last) {
@@ -606,7 +610,7 @@ static void main_loop(void)
                                opengl_blit_image(image, config_video_filter, (double_pixel_size) ? BENSON_AT_LINE * 2 : BENSON_AT_LINE, 1, config_fov, config_monitor_distance, benson_size, 0);
 #endif
                                if (help_view)
-                                       opengl_blit_osd(0, help_osd, config_video_filter, (double_pixel_size) ? BENSON_AT_LINE * 2 : BENSON_AT_LINE, config_fov, config_monitor_distance, benson_size, 1.0, 1.0, 0.0, 0.0);
+                                       opengl_blit_osd(0, help_osd[help_view - 1], config_video_filter, (double_pixel_size) ? BENSON_AT_LINE * 2 : BENSON_AT_LINE, config_fov, config_monitor_distance, benson_size, 1.0, 1.0, 0.0, 0.0);
                                if (osd_timer) {
                                        opengl_blit_osd(1, info_osd, config_video_filter, (double_pixel_size) ? BENSON_AT_LINE * 2 : BENSON_AT_LINE, config_fov, config_monitor_distance, benson_size, 0.5, 0.04, 0.5, -0.95);
                                        if (osd_timer - (int32_t)ticks_sdl() < 0)
@@ -628,7 +632,7 @@ static void main_loop(void)
 #endif
                                opengl_blit_image(image, config_video_filter, (double_pixel_size) ? BENSON_AT_LINE * 2 : BENSON_AT_LINE, 0, config_fov, config_monitor_distance, 1.0, 0);
                                if (help_view)
-                                       opengl_blit_osd(0, help_osd, config_video_filter, (double_pixel_size) ? BENSON_AT_LINE * 2 : BENSON_AT_LINE, config_fov, config_monitor_distance, 1.0, 1.0, 1.0, 0.0, 0.0);
+                                       opengl_blit_osd(0, help_osd[help_view - 1], config_video_filter, (double_pixel_size) ? BENSON_AT_LINE * 2 : BENSON_AT_LINE, config_fov, config_monitor_distance, 1.0, 1.0, 1.0, 0.0, 0.0);
                                if (osd_timer) {
                                        opengl_blit_osd(1, info_osd, config_video_filter, (double_pixel_size) ? BENSON_AT_LINE * 2 : BENSON_AT_LINE, config_fov, config_monitor_distance, 1.0, 0.5, 0.04, 0.5, -0.95);
                                        if (osd_timer - (int32_t)ticks_sdl() < 0)
@@ -860,7 +864,10 @@ static void keyboard_sdl(int down, enum keycode keycode)
        if (ctrl && down) {
                switch (keycode) {
                case KEYCODE_h:
-                       help_view ^= 1;
+                       if (help_view == help_views)
+                               help_view = 0;
+                       else
+                               help_view++;
                        break;
                case KEYCODE_v:
                        config_video_filter ^= 1;
@@ -902,7 +909,7 @@ static void keyboard_sdl(int down, enum keycode keycode)
                        if (config_ctrl_c)
                                quit = 1;
                        break;
-               case KEYCODE_n:
+               case KEYCODE_o:
 #ifdef HAVE_OVR
                        normalize_observer_ovr();
                        osd_info("", "change height");
@@ -930,8 +937,12 @@ static void keyboard_sdl(int down, enum keycode keycode)
                return;
        }
 
-       if (keycode == KEYCODE_PAUSE && down)
-               help_view ^= 1;
+       if (keycode == KEYCODE_PAUSE && down) {
+               if (help_view == help_views)
+                       help_view = 0;
+               else
+                       help_view++;
+       }
 
        /* in help view we must not forward keypresses */
        if (help_view)
@@ -1134,11 +1145,11 @@ int main(int argc, char *argv[])
        rc = init_opengl_osd(1, OSD_WIDTH, OSD_HEIGHT);
        if (rc < 0)
                goto done;
-       help_osd = text_alloc(IMAGE_WIDTH * 2, IMAGE_HEIGHT * 2, HELP_ALPHA);
-       if (!help_osd)
+       help_osd[0] = text_alloc(IMAGE_WIDTH * 2, IMAGE_HEIGHT * 2, HELP_ALPHA);
+       if (!help_osd[0])
                goto done;
-       text_render(help_osd, IMAGE_WIDTH * 2, IMAGE_HEIGHT * 2, mercenary_name, HELP_ALPHA, 3, (double)(80 - strlen(mercenary_name)) / 2.0, 1, 1);
-       text_render(help_osd, IMAGE_WIDTH * 2, IMAGE_HEIGHT * 2,
+       text_render(help_osd[0], IMAGE_WIDTH * 2, IMAGE_HEIGHT * 2, mercenary_name, HELP_ALPHA, 3, (double)(80 - strlen(mercenary_name)) / 2.0, 1, 1);
+       text_render(help_osd[0], IMAGE_WIDTH * 2, IMAGE_HEIGHT * 2,
                "Emulation:\n"
                "        Press `PAUSE' to toggle this help screen on or off.\n"
                "        Press `CTRL' + `F' to toggle between full screen / window mode.\n"
@@ -1150,7 +1161,7 @@ int main(int argc, char *argv[])
                "        Press `CTRL' + `+' or `-' to change field-of-view (OpenGL).\n"
                "        Press `CTRL' + `I' to skip intro (approaching to Eris).\n"
 #ifdef HAVE_OVR
-               "        Press `CTRL' + `N' to normalize player position.\n"
+               "        Press `CTRL' + `O' (or right trigger) to reset observer position.\n"
 #endif
                "\n"
                "Answer to a Question:\n"
@@ -1183,6 +1194,33 @@ int main(int argc, char *argv[])
                "        Press `INSERT' to loading and saving options.\n"
                "        Press `ENTER' to pause game, other key to continue.\n"
                ,HELP_ALPHA, 1, 2, 5, 0);
+#ifdef HAVE_OVR
+       help_osd[1] = text_alloc(IMAGE_WIDTH * 2, IMAGE_HEIGHT * 2, HELP_ALPHA);
+       if (!help_osd[1])
+               goto done;
+       text_render(help_osd[1], IMAGE_WIDTH * 2, IMAGE_HEIGHT * 2, mercenary_name, HELP_ALPHA, 3, (double)(80 - strlen(mercenary_name)) / 2.0, 1, 1);
+       text_render(help_osd[1], IMAGE_WIDTH * 2, IMAGE_HEIGHT * 2,
+               "Emulation using Controller:\n"
+               "        Press `Enter' button to toggle this help screen on or off.\n"
+               "        Press `A' button to emulate keyboard to control game.\n"
+               "        Press `B' button to emulate keyboard to enter alphanumeric keys.\n"
+               "        Press `A' or `B' button again to dismiss keyboard.\n"
+               "        Point right controller to a key on keyboard. The key will highlight.\n"
+               "        Press `Trigger' on right controller enter the highlighted key.\n"
+               "\n"
+               "Walking / Driving / Flying using Controller:\n"
+               "        Use thumb stick on right controller, to move player / craft.\n"
+               "        Press thumb stick on tright controller to toggle running/walking speed.\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 and hold thumb stick on left controller for escape sequence.\n"
+               "        Release thumb stick on left controller stop craft.\n"
+               "        Press `Trigger' on right controller to fire.\n"
+               "\n"
+               "For all other game function, use the emulated keyboards!\n"
+               ,HELP_ALPHA, 1, 2, 5, 0);
+       help_views = 2;
+#endif
        info_osd = text_alloc(OSD_WIDTH, OSD_HEIGHT, 0x00);
        if (!info_osd)
                goto done;
@@ -1216,8 +1254,10 @@ done:
                free(sound_buffer);
        if (image)
                free(image);
-       if (help_osd)
-               free(help_osd);
+       if (help_osd[0])
+               free(help_osd[0]);
+       if (help_osd[1])
+               free(help_osd[1]);
        if (info_osd)
                free(info_osd);