X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=mercenary-reloaded.git;a=blobdiff_plain;f=src%2Fmercenary%2Fmain.c;h=45d87e4bca4637f5df95041260555dcbe51d4981;hp=d4ac4ee316900799fd2a2610190496d7d8ab4dfd;hb=3c70467233fef462f9bc9a132019800386978cc8;hpb=a5eace5cedc6ac233ceba04f1a6ef69c0544542e diff --git a/src/mercenary/main.c b/src/mercenary/main.c index d4ac4ee..45d87e4 100644 --- a/src/mercenary/main.c +++ b/src/mercenary/main.c @@ -114,13 +114,8 @@ static uint8_t *info_osd = NULL; 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 @@ -422,6 +417,7 @@ static int joystick_set_x_last = 0, joystick_set_y_last = 0; 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) { @@ -583,16 +579,18 @@ static void handle_vr_poses(void) 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) @@ -767,6 +765,9 @@ static void main_loop(void) /* 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 @@ -1496,7 +1497,7 @@ int main(int argc, char *argv[]) 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, config_joystick, config_joystick_x, config_joystick_y, config_joystick_fire, joystick_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