Wait 3s when the session is not running before calling on_unfocused
This commit is contained in:
@@ -1369,7 +1369,7 @@ void application::load_locale()
|
|||||||
std::locale::global(loc);
|
std::locale::global(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<XrAction, XrActionType> application::get_action(const std::string & requested_name)
|
std::pair<XrAction, XrActionType> application::get_action(std::string_view requested_name)
|
||||||
{
|
{
|
||||||
for (const auto & [action, type, name]: instance().actions)
|
for (const auto & [action, type, name]: instance().actions)
|
||||||
{
|
{
|
||||||
@@ -1567,15 +1567,21 @@ void application::loop()
|
|||||||
poll_events();
|
poll_events();
|
||||||
|
|
||||||
auto scene = current_scene();
|
auto scene = current_scene();
|
||||||
if (!is_session_running())
|
if (not is_session_running())
|
||||||
{
|
{
|
||||||
if (scene)
|
if (not timestamp_unsynchronized)
|
||||||
|
timestamp_unsynchronized = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
|
if (scene and std::chrono::steady_clock::now() - *timestamp_unsynchronized > 3s)
|
||||||
scene->set_focused(false);
|
scene->set_focused(false);
|
||||||
|
|
||||||
// Throttle loop since xrWaitFrame won't be called.
|
// Throttle loop since xrWaitFrame won't be called.
|
||||||
std::this_thread::sleep_for(250ms);
|
std::this_thread::sleep_for(250ms);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
timestamp_unsynchronized.reset();
|
||||||
|
|
||||||
if (scene)
|
if (scene)
|
||||||
{
|
{
|
||||||
poll_actions();
|
poll_actions();
|
||||||
|
|||||||
@@ -132,6 +132,8 @@ class application : public singleton<application>
|
|||||||
bool session_running = false;
|
bool session_running = false;
|
||||||
bool session_focused = false;
|
bool session_focused = false;
|
||||||
bool session_visible = false;
|
bool session_visible = false;
|
||||||
|
std::optional<std::chrono::steady_clock::time_point> timestamp_unsynchronized; // Timestamp when session_synchronized becomes false
|
||||||
|
|
||||||
bool debug_extensions_found = false;
|
bool debug_extensions_found = false;
|
||||||
std::vector<const char *> vk_device_extensions;
|
std::vector<const char *> vk_device_extensions;
|
||||||
std::atomic<bool> exit_requested = false;
|
std::atomic<bool> exit_requested = false;
|
||||||
@@ -231,7 +233,7 @@ public:
|
|||||||
{
|
{
|
||||||
return instance().actions;
|
return instance().actions;
|
||||||
}
|
}
|
||||||
static std::pair<XrAction, XrActionType> get_action(const std::string & name);
|
static std::pair<XrAction, XrActionType> get_action(std::string_view name);
|
||||||
|
|
||||||
static std::optional<std::pair<glm::vec3, glm::quat>> locate_controller(XrSpace space, XrSpace reference, XrTime time)
|
static std::optional<std::pair<glm::vec3, glm::quat>> locate_controller(XrSpace space, XrSpace reference, XrTime time)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user