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)
{
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)