Files
daveyandCraig 0e3ced6f65 vr: follow the headset through GET_VIDEO_VIEWS_STATUS
A core learns about a headset only from the HMD status bit;
SET_VIDEO_VIEWS returning true means the map was accepted. The scene
walker now enters VR on the first frame with HMD, sends a TRACKED map
at the frontend's recommended eye size and goes flat with an empty map.

A video reinit restarts the headset session, and entering or leaving VR
changes the geometry, which reinits video. A lost headset is waited for
five seconds, repeating the last frame, before the core goes flat.
Input is still polled on those frames.

While VR is tracking, the map is sent every retro_run(), as libretro.h
asks: it covers state loads and run-ahead. The frontend writes the
recommended eye size back on each call, so a new size there is taken as
a resize, and the AV info is sent once for it. A frontend that reports
a headset but refuses the tracked map is not asked again until the
headset drops or the VR option is turned off.

Co-authored-by: Craig <[email protected]>
2026-10-12 05:25:22 -07:00

76 lines
2.2 KiB
C

/*
* Libretro 3DEngine
* Copyright (C) 2013 - Hans-Kristian Arntzen
* Copyright (C) 2013 - Daniel De Matteis
*
* Libretro 3DEngine is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* Libretro 3DEngine is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Libretro 3DEngine.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PROGRAM_H__
#define PROGRAM_H__
#include "gl.hpp"
#include "glm/glm.hpp"
#include "glm/gtc/matrix_transform.hpp"
#include "vr_support.hpp"
extern retro_input_poll_t input_poll_cb;
extern retro_input_state_t input_state_cb;
extern struct retro_hw_render_callback hw_render;
extern retro_video_refresh_t video_cb;
extern retro_environment_t environ_cb;
extern unsigned engine_width;
extern unsigned engine_height;
extern GLuint g_texture_target;
extern GLuint tex;
extern bool location_camera_control_enable;
extern bool sensor_enable;
extern enum retro_hw_context_type active_hw_context;
extern bool renderer_is_vulkan(void);
typedef struct
{
float latitude;
float longitude;
float horizontal_accuracy;
float vertical_accuracy;
} retro_position_t;
extern retro_position_t previous_location;
extern retro_position_t current_location;
typedef struct engine_program
{
void (*load_game)(const struct retro_game_info *info);
void (*run)(void);
void (*context_reset)(void);
void (*update_variables)(retro_environment_t environ_cb);
glm::vec3 (*check_input)(void);
void (*context_destroy)(void); /* optional, may be NULL */
} engine_program_t;
extern const engine_program_t engine_program_instancingviewer;
extern const engine_program_t engine_program_modelviewer;
// VR
extern bool vr_active;
extern unsigned vr_eye_width;
extern unsigned vr_eye_height;
extern bool vr_update(struct retro_vr_frame_state *fs, bool capable, bool *dupe);
#endif