projects
/
mercenary-reloaded.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
OVR: Exit on request from OVR server
[mercenary-reloaded.git]
/
src
/
mercenary
/
main.c
diff --git
a/src/mercenary/main.c
b/src/mercenary/main.c
index
1ba1f44
..
8b66015
100644
(file)
--- a/
src/mercenary/main.c
+++ b/
src/mercenary/main.c
@@
-422,6
+422,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
+584,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
+770,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