Add packet to start an application
This commit is contained in:
@@ -450,6 +450,11 @@ struct get_application_list
|
|||||||
std::string variant;
|
std::string variant;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct start_app
|
||||||
|
{
|
||||||
|
std::string app_id;
|
||||||
|
};
|
||||||
|
|
||||||
using packets = std::variant<
|
using packets = std::variant<
|
||||||
crypto_handshake,
|
crypto_handshake,
|
||||||
pin_check_1,
|
pin_check_1,
|
||||||
@@ -471,7 +476,8 @@ using packets = std::variant<
|
|||||||
session_state_changed,
|
session_state_changed,
|
||||||
user_presence_changed,
|
user_presence_changed,
|
||||||
override_foveation_center,
|
override_foveation_center,
|
||||||
get_application_list>;
|
get_application_list,
|
||||||
|
start_app>;
|
||||||
} // namespace from_headset
|
} // namespace from_headset
|
||||||
|
|
||||||
namespace to_headset
|
namespace to_headset
|
||||||
|
|||||||
@@ -742,6 +742,11 @@ void wivrn_session::operator()(from_headset::get_application_list && request)
|
|||||||
send_control(std::move(response));
|
send_control(std::move(response));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wivrn_session::operator()(const from_headset::start_app & request)
|
||||||
|
{
|
||||||
|
send_to_main(request);
|
||||||
|
}
|
||||||
|
|
||||||
void wivrn_session::operator()(audio_data && data)
|
void wivrn_session::operator()(audio_data && data)
|
||||||
{
|
{
|
||||||
if (audio_handle)
|
if (audio_handle)
|
||||||
|
|||||||
@@ -191,6 +191,7 @@ public:
|
|||||||
void operator()(from_headset::refresh_rate_changed &&);
|
void operator()(from_headset::refresh_rate_changed &&);
|
||||||
void operator()(from_headset::override_foveation_center &&);
|
void operator()(from_headset::override_foveation_center &&);
|
||||||
void operator()(from_headset::get_application_list &&);
|
void operator()(from_headset::get_application_list &&);
|
||||||
|
void operator()(const from_headset::start_app &);
|
||||||
void operator()(audio_data &&);
|
void operator()(audio_data &&);
|
||||||
|
|
||||||
void operator()(to_monado::disconnect &&);
|
void operator()(to_monado::disconnect &&);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
* @brief Main file for WiVRn Monado service.
|
* @brief Main file for WiVRn Monado service.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "application.h"
|
||||||
#include "openxr/openxr.h"
|
#include "openxr/openxr.h"
|
||||||
#include "sleep_inhibitor.h"
|
#include "sleep_inhibitor.h"
|
||||||
#include "util/u_trace_marker.h"
|
#include "util/u_trace_marker.h"
|
||||||
@@ -510,6 +511,11 @@ gboolean control_received(gint fd, GIOCondition condition, gpointer user_data)
|
|||||||
inhibitor.emplace();
|
inhibitor.emplace();
|
||||||
wivrn_server_set_headset_connected(dbus_server, true);
|
wivrn_server_set_headset_connected(dbus_server, true);
|
||||||
},
|
},
|
||||||
|
[&](const wivrn::from_headset::start_app & request) {
|
||||||
|
const auto & apps = list_applications();
|
||||||
|
if (auto it = apps.find(request.app_id); it != apps.end())
|
||||||
|
children->start_application(it->second.exec);
|
||||||
|
},
|
||||||
[&](const from_monado::headset_connected &) {
|
[&](const from_monado::headset_connected &) {
|
||||||
stop_publishing();
|
stop_publishing();
|
||||||
inhibitor.emplace();
|
inhibitor.emplace();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* WiVRn VR streaming
|
* WiVRn VR streaming
|
||||||
|
* Copyright (C) 2024 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||||
* Copyright (C) 2025 Patrick Nicolas <patricknicolas@laposte.net>
|
* Copyright (C) 2025 Patrick Nicolas <patricknicolas@laposte.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
@@ -32,6 +33,73 @@ namespace wivrn
|
|||||||
|
|
||||||
children_manager::~children_manager() {}
|
children_manager::~children_manager() {}
|
||||||
|
|
||||||
|
static std::vector<std::string> unescape_string(const std::string & app_string)
|
||||||
|
{
|
||||||
|
std::vector<std::string> app;
|
||||||
|
app.emplace_back();
|
||||||
|
|
||||||
|
bool seen_backslash = false;
|
||||||
|
bool seen_single_quote = false;
|
||||||
|
bool seen_double_quote = false;
|
||||||
|
for (auto c: app_string)
|
||||||
|
{
|
||||||
|
if (seen_backslash)
|
||||||
|
{
|
||||||
|
app.back() += c;
|
||||||
|
seen_backslash = false;
|
||||||
|
}
|
||||||
|
else if (seen_single_quote)
|
||||||
|
{
|
||||||
|
if (c == '\'')
|
||||||
|
seen_single_quote = false;
|
||||||
|
else if (c == '\\')
|
||||||
|
seen_backslash = true;
|
||||||
|
else
|
||||||
|
app.back() += c;
|
||||||
|
}
|
||||||
|
else if (seen_double_quote)
|
||||||
|
{
|
||||||
|
if (c == '"')
|
||||||
|
seen_double_quote = false;
|
||||||
|
else if (c == '\\')
|
||||||
|
seen_backslash = true;
|
||||||
|
else
|
||||||
|
app.back() += c;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case '\\':
|
||||||
|
seen_backslash = true;
|
||||||
|
break;
|
||||||
|
case '\'':
|
||||||
|
seen_single_quote = true;
|
||||||
|
break;
|
||||||
|
case '"':
|
||||||
|
seen_double_quote = true;
|
||||||
|
break;
|
||||||
|
case ' ':
|
||||||
|
if (app.back() != "")
|
||||||
|
app.emplace_back();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
app.back() += c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (app.back() == "")
|
||||||
|
app.pop_back();
|
||||||
|
|
||||||
|
return app;
|
||||||
|
}
|
||||||
|
|
||||||
|
void children_manager::start_application(const std::string & exec)
|
||||||
|
{
|
||||||
|
start_application(unescape_string(exec));
|
||||||
|
}
|
||||||
|
|
||||||
forked_children::forked_children(std::function<void()> state_changed_cb) :
|
forked_children::forked_children(std::function<void()> state_changed_cb) :
|
||||||
state_changed_cb(state_changed_cb) {}
|
state_changed_cb(state_changed_cb) {}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ public:
|
|||||||
virtual ~children_manager();
|
virtual ~children_manager();
|
||||||
|
|
||||||
virtual void start_application(const std::vector<std::string> &) = 0;
|
virtual void start_application(const std::vector<std::string> &) = 0;
|
||||||
|
void start_application(const std::string &);
|
||||||
|
|
||||||
virtual bool running() const = 0;
|
virtual bool running() const = 0;
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -47,7 +47,12 @@ struct bitrate_changed
|
|||||||
uint32_t bitrate_bps;
|
uint32_t bitrate_bps;
|
||||||
};
|
};
|
||||||
|
|
||||||
using packets = std::variant<wivrn::from_headset::headset_info_packet, headset_connected, headset_disconnected, bitrate_changed>;
|
using packets = std::variant<
|
||||||
|
wivrn::from_headset::headset_info_packet,
|
||||||
|
wivrn::from_headset::start_app,
|
||||||
|
headset_connected,
|
||||||
|
headset_disconnected,
|
||||||
|
bitrate_changed>;
|
||||||
} // namespace from_monado
|
} // namespace from_monado
|
||||||
|
|
||||||
namespace to_monado
|
namespace to_monado
|
||||||
|
|||||||
Reference in New Issue
Block a user