static int config_render = 1; /* opengl render */
static int config_skip_intro = 0;
static int config_multisampling = 8;
+static int config_joystick = -1, config_joystick_x = -1, config_joystick_y = -1, config_joystick_fire = -1;
#ifdef HAVE_OVR
static double config_benson_size = 0.7;
static double config_fov = FOV_JOLLY;
static int help_view = 1;
static int help_views = 0;
static int32_t osd_timer = 0, border_timer = 0;
-#ifdef HAVE_OVR
-#define SCREEN_WIDTH 1344
-#define SCREEN_HEIGHT 800
-#else
#define SCREEN_WIDTH (320*3)
#define SCREEN_HEIGHT (200*3)
-#endif
#define IMAGE_WIDTH 320
#define IMAGE_HEIGHT 200
#define BENSON_AT_LINE 136
print_info(" Set field-of-view. Default is %.0f.\n", FOV_NOVAGEN);
print_info(" -i --skip-intro\n");
print_info(" Skip intro sequence approaching to Eris space port.\n");
+ print_info(" -j --joystick <num> | list\n");
+ print_info(" Select given joystick number or show list. (default = 0, if available)\n");
+ print_info(" --joystick-x <axis num>\n");
+ print_info(" --joystick-y <axis num>\n");
+ print_info(" --joystick-fire <button num>\n");
+ print_info(" Specify explicit axis and button of joystick.\n");
print_info("Improvement options:\n");
print_info(" --extend-roads 1 | 0\n");
print_info(" Roads in the distance end in a single point. This was ok for low\n");
if (!strcmp(argv[i], "-i") || !strcmp(argv[i], "--skip-intro")) {
config_skip_intro = 1;
} else
+ if (!strcmp(argv[i], "-j") || !strcmp(argv[i], "--joystick")) {
+ i++;
+ if (argc == i)
+ goto missing_parameter;
+ if (!strcmp(argv[i], "list")) {
+ sdl_list_joysticks();
+ return 1;
+ }
+ config_joystick = atoi(argv[i]);
+ } else
+ if (!strcmp(argv[i], "--joystick-x")) {
+ i++;
+ if (argc == i)
+ goto missing_parameter;
+ config_joystick_x = atoi(argv[i]);
+ } else
+ if (!strcmp(argv[i], "--joystick-y")) {
+ i++;
+ if (argc == i)
+ goto missing_parameter;
+ config_joystick_y = atoi(argv[i]);
+ } else
+ if (!strcmp(argv[i], "--joystick-fire")) {
+ i++;
+ if (argc == i)
+ goto missing_parameter;
+ config_joystick_fire = atoi(argv[i]);
+ } else
if (!strcmp(argv[i], "--extend-roads")) {
i++;
if (argc == i)
static int keyboard_on = 0;
static enum keycode vr_key_pressed = 0, vr_key = 0;
static int we_walk = 0, we_rotate = 0;
+static double degrees45 = 45.0 / 180.0 * M_PI;
static void handle_vr_poses(void)
{
/* handle input */
get_poses_ovr(&button_a, &button_b, &button_x, &button_y, &button_menu, &button_left_trigger, &button_right_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, &head_yaw, &head_pitch, &head_roll);
- if (button_menu && !button_menu_last) {
+ if (button_a && !button_a_last) {
/* menu toggle */
toggle_help();
}
- if (button_right_thumb) {
+ if (button_b && !button_b_last) {
+ /* reset observer */
+ reset_observer_ovr();
+ osd_info("", "reset observer");
+ }
+ if (button_x && !button_x_last) {
+ /* menu toggle */
+ toggle_help();
+ }
+ if (button_y && !button_y_last) {
/* reset observer */
reset_observer_ovr();
osd_info("", "reset observer");
}
if (!help_view) {
- if (button_x && !button_x_last) {
- /* '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_right_trigger && !button_right_trigger_last) {
/* trigger pressed */
if (keyboard_on) {
if (vr_key) {
vr_key_pressed = vr_key;
set_amiga_key(vr_key_pressed, 1);
+ /* reset vr thrust */
+ thrust = 0;
}
} else {
/* fire button */
mercenary_vr_move(1, move_east, move_north, 256, 256);
}
- /* if we rotate */
+ /* snap orientation to steps of 45 degrees */
if (we_rotate == 1) {
- /* change orientation */
mercenary_get_orientation(&roll, &pitch, &yaw);
+ yaw = round(yaw / degrees45) * degrees45;
+ /* if we rotate: change orientation */
if (stick_right_x > 0)
- mercenary_set_orientation(yaw - 45.0 / 180.0 * M_PI);
+ yaw -= degrees45;
else
- mercenary_set_orientation(yaw + 45.0 / 180.0 * M_PI);
- /* rotate only once */
+ yaw += degrees45;
+ /* rotate only once per stick movement */
we_rotate = 2;
+ mercenary_set_orientation(yaw);
}
}
if (joystick_set_x_last && !joystick_set_x)
/* render result on window */
while (!quit) {
#ifdef HAVE_OVR
+ /* quit by OVR server */
+ if (should_quit_ovr())
+ break;
/* get vr poses */
handle_vr_poses();
#endif
set_amiga_key(KEYCODE_HELP, down);
break;
default:
+ /* reset vr thrust */
+#ifdef HAVE_OVR
+ thrust_last = 0;
+#endif
set_amiga_key(keycode, down);
}
}
+static double joystick_last_x = 0, joystick_last_y = 0;
+static int joystick_last_fire = 0;
+
+static void joystick_sdl(double x, double y, int fire)
+{
+ int left = -1, right = -1, up = -1, down = -1;
+
+ if (x <= -0.5 && joystick_last_x > -0.5)
+ left = 1;
+ if (x > -0.5 && joystick_last_x <= -0.5)
+ left = 0;
+ if (x >= 0.5 && joystick_last_x < 0.5)
+ right = 1;
+ if (x < 0.5 && joystick_last_x >= 0.5)
+ right = 0;
+ if (y <= -0.5 && joystick_last_y > -0.5)
+ up = 1;
+ if (y > -0.5 && joystick_last_y <= -0.5)
+ up = 0;
+ if (y >= 0.5 && joystick_last_y < 0.5)
+ down = 1;
+ if (y < 0.5 && joystick_last_y >= 0.5)
+ down = 0;
+ set_joystick(left, right, up, down, fire);
+ joystick_last_x = x;
+ joystick_last_y = y;
+ joystick_last_fire = fire;
+}
+
void audio_sdl(float *data, int length)
{
int fill, s;
window_width = (config_debug_opengl) ? SCREEN_WIDTH / 3 * 2 : SCREEN_WIDTH;
window_height = (config_debug_opengl) ? SCREEN_HEIGHT / 3 * 4 : SCREEN_HEIGHT;
#endif
- rc = init_sdl(argv[0], window_width, window_height, SOUND_SAMPLERATE, sdl_sound_chunk, keyboard_sdl, audio_sdl, resize_window, multisampling, vbl_sync, vr);
+ rc = init_sdl(mercenary_name, window_width, window_height, SOUND_SAMPLERATE, sdl_sound_chunk, keyboard_sdl, config_joystick, config_joystick_x, config_joystick_y, config_joystick_fire, joystick_sdl, audio_sdl, resize_window, multisampling, vbl_sync, vr);
if (rc < 0)
goto done;
#ifdef HAVE_OVR
text_render(help_osd[2], IMAGE_WIDTH * 2, IMAGE_HEIGHT * 2, mercenary_name, HELP_ALPHA, 3, (double)(80 - strlen(mercenary_name)) / 2.0, 1, 1);
text_render(help_osd[2], IMAGE_WIDTH * 2, IMAGE_HEIGHT * 2,
"Emulation using Controller:\n"
- " Press `Enter' button to toggle this help screen on or off.\n"
- " To have a virtual keyboard, point below benson (control pannel).\n"
+ " Press `A' or 'X' button to toggle this help screen on or off.\n"
+ " Press 'B' or 'Y' button to reset observer position. (importaint!)\n"
+ " To have a virtual keyboard, point right hand below control pannel.\n"
" Point to a key on keyboard. The key will highlight.\n"
" Pull `Trigger' on right controller to enter the highlighted key.\n"
- " Press thumb stick on right controller to reset observer position.\n"
"\n"
"Walking / Driving / Flying using Controller:\n"
" Use thumb stick on right controller, to move player / craft.\n"