Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -11,6 +11,10 @@
|
||||
#include <string>
|
||||
|
||||
#include <boost/core/noncopyable.hpp>
|
||||
#ifndef _WIN32
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/process.hpp>
|
||||
#endif
|
||||
|
||||
#include "src/config.h"
|
||||
#include "src/logging.h"
|
||||
@@ -31,6 +35,7 @@ struct AVHWFramesContext;
|
||||
struct AVCodecContext;
|
||||
struct AVDictionary;
|
||||
|
||||
#ifdef _WIN32
|
||||
// Forward declarations of boost classes to avoid having to include boost headers
|
||||
// here, which results in issues with Windows.h and WinSock2.h include order.
|
||||
namespace boost {
|
||||
@@ -50,6 +55,7 @@ namespace boost {
|
||||
typedef basic_environment<char> environment;
|
||||
} // namespace process
|
||||
} // namespace boost
|
||||
#endif
|
||||
namespace video {
|
||||
struct config_t;
|
||||
} // namespace video
|
||||
@@ -612,6 +618,23 @@ namespace platf {
|
||||
void
|
||||
restart();
|
||||
|
||||
/**
|
||||
* @brief Set an environment variable.
|
||||
* @param name The name of the environment variable.
|
||||
* @param value The value to set the environment variable to.
|
||||
* @return 0 on success, non-zero on failure.
|
||||
*/
|
||||
int
|
||||
set_env(const std::string &name, const std::string &value);
|
||||
|
||||
/**
|
||||
* @brief Unset an environment variable.
|
||||
* @param name The name of the environment variable.
|
||||
* @return 0 on success, non-zero on failure.
|
||||
*/
|
||||
int
|
||||
unset_env(const std::string &name);
|
||||
|
||||
struct buffer_descriptor_t {
|
||||
const char *buffer;
|
||||
size_t size;
|
||||
@@ -837,6 +860,8 @@ namespace platf {
|
||||
|
||||
/**
|
||||
* @brief Gets the supported gamepads for this platform backend.
|
||||
* @details This may be called prior to `platf::input()`!
|
||||
* @param input Pointer to the platform's `input_t` or `nullptr`.
|
||||
* @return Vector of gamepad options and status.
|
||||
*/
|
||||
std::vector<supported_gamepad_t> &
|
||||
|
||||
@@ -326,6 +326,16 @@ namespace platf {
|
||||
lifetime::exit_sunshine(0, true);
|
||||
}
|
||||
|
||||
int
|
||||
set_env(const std::string &name, const std::string &value) {
|
||||
return setenv(name.c_str(), value.c_str(), 1);
|
||||
}
|
||||
|
||||
int
|
||||
unset_env(const std::string &name) {
|
||||
return unsetenv(name.c_str());
|
||||
}
|
||||
|
||||
bool
|
||||
request_process_group_exit(std::uintptr_t native_handle) {
|
||||
if (kill(-((pid_t) native_handle), SIGTERM) == 0 || errno == ESRCH) {
|
||||
@@ -913,6 +923,10 @@ namespace platf {
|
||||
|
||||
std::unique_ptr<deinit_t>
|
||||
init() {
|
||||
// enable low latency mode for AMD
|
||||
// https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30039
|
||||
set_env("AMD_DEBUG", "lowlatency");
|
||||
|
||||
// These are allowed to fail.
|
||||
gbm::init();
|
||||
|
||||
|
||||
@@ -426,7 +426,8 @@ namespace platf::publish {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
name.reset(avahi::strdup(SERVICE_NAME));
|
||||
auto instance_name = net::mdns_instance_name(boost::asio::ip::host_name());
|
||||
name.reset(avahi::strdup(instance_name.c_str()));
|
||||
|
||||
client.reset(
|
||||
avahi::client_new(avahi::simple_poll_get(poll.get()), avahi::ClientFlags(0), client_callback, nullptr, &avhi_error));
|
||||
|
||||
@@ -253,6 +253,16 @@ namespace platf {
|
||||
lifetime::exit_sunshine(0, true);
|
||||
}
|
||||
|
||||
int
|
||||
set_env(const std::string &name, const std::string &value) {
|
||||
return setenv(name.c_str(), value.c_str(), 1);
|
||||
}
|
||||
|
||||
int
|
||||
unset_env(const std::string &name) {
|
||||
return unsetenv(name.c_str());
|
||||
}
|
||||
|
||||
bool
|
||||
request_process_group_exit(std::uintptr_t native_handle) {
|
||||
if (killpg((pid_t) native_handle, SIGTERM) == 0 || errno == ESRCH) {
|
||||
|
||||
@@ -105,7 +105,8 @@ namespace platf::publish {
|
||||
&serviceRef,
|
||||
0, // flags
|
||||
0, // interfaceIndex
|
||||
SERVICE_NAME, SERVICE_TYPE,
|
||||
nullptr, // name
|
||||
SERVICE_TYPE,
|
||||
nullptr, // domain
|
||||
nullptr, // host
|
||||
htons(net::map_port(nvhttp::PORT_HTTP)),
|
||||
|
||||
@@ -1728,15 +1728,18 @@ namespace platf {
|
||||
|
||||
std::vector<supported_gamepad_t> &
|
||||
supported_gamepads(input_t *input) {
|
||||
bool enabled;
|
||||
if (input) {
|
||||
auto vigem = ((input_raw_t *) input)->vigem;
|
||||
enabled = vigem != nullptr;
|
||||
}
|
||||
else {
|
||||
enabled = false;
|
||||
if (!input) {
|
||||
static std::vector gps {
|
||||
supported_gamepad_t { "auto", true, "" },
|
||||
supported_gamepad_t { "x360", false, "" },
|
||||
supported_gamepad_t { "ds4", false, "" },
|
||||
};
|
||||
|
||||
return gps;
|
||||
}
|
||||
|
||||
auto vigem = ((input_raw_t *) input)->vigem;
|
||||
auto enabled = vigem != nullptr;
|
||||
auto reason = enabled ? "" : "gamepads.vigem-not-available";
|
||||
|
||||
// ds4 == ps4
|
||||
|
||||
@@ -1313,6 +1313,16 @@ namespace platf {
|
||||
lifetime::exit_sunshine(0, true);
|
||||
}
|
||||
|
||||
int
|
||||
set_env(const std::string &name, const std::string &value) {
|
||||
return _putenv_s(name.c_str(), value.c_str());
|
||||
}
|
||||
|
||||
int
|
||||
unset_env(const std::string &name) {
|
||||
return _putenv_s(name.c_str(), "");
|
||||
}
|
||||
|
||||
struct enum_wnd_context_t {
|
||||
std::set<DWORD> process_ids;
|
||||
bool requested_exit;
|
||||
|
||||
@@ -37,7 +37,6 @@ constexpr auto DNS_QUERY_RESULTS_VERSION1 = 0x1;
|
||||
|
||||
#define SERVICE_DOMAIN "local"
|
||||
|
||||
constexpr auto SERVICE_INSTANCE_NAME = SV(SERVICE_NAME "." SERVICE_TYPE "." SERVICE_DOMAIN);
|
||||
constexpr auto SERVICE_TYPE_DOMAIN = SV(SERVICE_TYPE "." SERVICE_DOMAIN);
|
||||
|
||||
#ifndef __MINGW32__
|
||||
@@ -107,10 +106,11 @@ namespace platf::publish {
|
||||
service(bool enable, PDNS_SERVICE_INSTANCE &existing_instance) {
|
||||
auto alarm = safe::make_alarm<PDNS_SERVICE_INSTANCE>();
|
||||
|
||||
std::wstring name { SERVICE_INSTANCE_NAME.data(), SERVICE_INSTANCE_NAME.size() };
|
||||
std::wstring domain { SERVICE_TYPE_DOMAIN.data(), SERVICE_TYPE_DOMAIN.size() };
|
||||
|
||||
auto host = from_utf8(boost::asio::ip::host_name() + ".local");
|
||||
auto hostname = boost::asio::ip::host_name();
|
||||
auto name = from_utf8(net::mdns_instance_name(hostname) + '.') + domain;
|
||||
auto host = from_utf8(hostname + ".local");
|
||||
|
||||
DNS_SERVICE_INSTANCE instance {};
|
||||
instance.pszInstanceName = name.data();
|
||||
|
||||
Reference in New Issue
Block a user