projects
/
mercenary-reloaded.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
OVR: Show mirror of single eye only
[mercenary-reloaded.git]
/
src
/
mercenary
/
main.c
diff --git
a/src/mercenary/main.c
b/src/mercenary/main.c
index
1ba1f44
..
45d87e4
100644
(file)
--- 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;
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)
#define SCREEN_WIDTH (320*3)
#define SCREEN_HEIGHT (200*3)
-#endif
#define IMAGE_WIDTH 320
#define IMAGE_HEIGHT 200
#define BENSON_AT_LINE 136
#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 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)
{
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);
}
mercenary_vr_move(1, move_east, move_north, 256, 256);
}
- /*
if we rotate
*/
+ /*
snap orientation to steps of 45 degrees
*/
if (we_rotate == 1) {
if (we_rotate == 1) {
- /* change orientation */
mercenary_get_orientation(&roll, &pitch, &yaw);
mercenary_get_orientation(&roll, &pitch, &yaw);
+ yaw = round(yaw / degrees45) * degrees45;
+ /* if we rotate: change orientation */
if (stick_right_x > 0)
if (stick_right_x > 0)
-
mercenary_set_orientation(yaw - 45.0 / 180.0 * M_PI)
;
+
yaw -= degrees45
;
else
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;
we_rotate = 2;
+ mercenary_set_orientation(yaw);
}
}
if (joystick_set_x_last && !joystick_set_x)
}
}
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
/* 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
/* get vr poses */
handle_vr_poses();
#endif