diff --git a/CMakeLists.txt b/CMakeLists.txt index f7e9dec9..a8e2b256 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,7 @@ if(WIN32) include_directories(third-party/ViGEmClient/include) set(PLATFORM_TARGET_FILES + sunshine/platform/windows/misc.cpp sunshine/platform/windows/input.cpp sunshine/platform/windows/display.h sunshine/platform/windows/display_base.cpp diff --git a/sunshine/config.cpp b/sunshine/config.cpp index 08a54ee5..d0f5c07c 100644 --- a/sunshine/config.cpp +++ b/sunshine/config.cpp @@ -377,6 +377,14 @@ void path_f(std::unordered_map &vars, const std::strin } } +void path_f(std::unordered_map &vars, const std::string &name, std::string &input) { + fs::path temp = input; + + path_f(vars, name, temp); + + input = temp.string(); +} + void int_f(std::unordered_map &vars, const std::string &name, int &input) { auto it = vars.find(name); diff --git a/sunshine/config.h b/sunshine/config.h index 7f05a16f..a905a0fd 100644 --- a/sunshine/config.h +++ b/sunshine/config.h @@ -3,7 +3,6 @@ #include #include -#include #include #include #include @@ -48,7 +47,7 @@ struct audio_t { struct stream_t { std::chrono::milliseconds ping_timeout; - std::filesystem::path file_apps; + std::string file_apps; int fec_percentage; @@ -61,12 +60,12 @@ struct nvhttp_t { // pc|lan|wan std::string origin_pin_allowed; - std::filesystem::path pkey; // must be 2048 bits - std::filesystem::path cert; // must be signed with a key of 2048 bits + std::string pkey; // must be 2048 bits + std::string cert; // must be signed with a key of 2048 bits std::string sunshine_name; - std::filesystem::path file_state; + std::string file_state; std::string external_ip; std::vector resolutions; @@ -91,13 +90,13 @@ enum flag_e : std::size_t { struct sunshine_t { int min_log_level; std::bitset flags; - std::filesystem::path credentials_file; + std::string credentials_file; std::string username; std::string password; std::string salt; - std::filesystem::path config_file; + std::string config_file; struct cmd_t { std::string name; diff --git a/sunshine/platform/windows/input.cpp b/sunshine/platform/windows/input.cpp index 0d34ad1e..9eb6667b 100755 --- a/sunshine/platform/windows/input.cpp +++ b/sunshine/platform/windows/input.cpp @@ -1,15 +1,6 @@ -#include -#include -#include - -// prevent clang format from "optimizing" the header include order -// clang-format off -#include -#include #include -#include -#include -// clang-format on + +#include #include @@ -19,8 +10,6 @@ namespace platf { using namespace std::literals; -using adapteraddrs_t = util::c_ptr; - volatile HDESK _lastKnownInputDesktop = NULL; constexpr touch_port_t target_touch_port { 0, 0, @@ -98,71 +87,6 @@ public: client_t client; }; -std::string from_sockaddr(const sockaddr *const socket_address) { - char data[INET6_ADDRSTRLEN]; - - auto family = socket_address->sa_family; - if(family == AF_INET6) { - inet_ntop(AF_INET6, &((sockaddr_in6 *)socket_address)->sin6_addr, data, INET6_ADDRSTRLEN); - } - - if(family == AF_INET) { - inet_ntop(AF_INET, &((sockaddr_in *)socket_address)->sin_addr, data, INET_ADDRSTRLEN); - } - - return std::string { data }; -} - -std::pair from_sockaddr_ex(const sockaddr *const ip_addr) { - char data[INET6_ADDRSTRLEN]; - - auto family = ip_addr->sa_family; - std::uint16_t port; - if(family == AF_INET6) { - inet_ntop(AF_INET6, &((sockaddr_in6 *)ip_addr)->sin6_addr, data, INET6_ADDRSTRLEN); - port = ((sockaddr_in6 *)ip_addr)->sin6_port; - } - - if(family == AF_INET) { - inet_ntop(AF_INET, &((sockaddr_in *)ip_addr)->sin_addr, data, INET_ADDRSTRLEN); - port = ((sockaddr_in *)ip_addr)->sin_port; - } - - return { port, std::string { data } }; -} - -adapteraddrs_t get_adapteraddrs() { - adapteraddrs_t info { nullptr }; - ULONG size = 0; - - while(GetAdaptersAddresses(AF_UNSPEC, 0, nullptr, info.get(), &size) == ERROR_BUFFER_OVERFLOW) { - info.reset((PIP_ADAPTER_ADDRESSES)malloc(size)); - } - - return info; -} - -std::string get_mac_address(const std::string_view &address) { - adapteraddrs_t info = get_adapteraddrs(); - for(auto adapter_pos = info.get(); adapter_pos != nullptr; adapter_pos = adapter_pos->Next) { - for(auto addr_pos = adapter_pos->FirstUnicastAddress; addr_pos != nullptr; addr_pos = addr_pos->Next) { - if(adapter_pos->PhysicalAddressLength != 0 && address == from_sockaddr(addr_pos->Address.lpSockaddr)) { - std::stringstream mac_addr; - mac_addr << std::hex; - for(int i = 0; i < adapter_pos->PhysicalAddressLength; i++) { - if(i > 0) { - mac_addr << ':'; - } - mac_addr << std::setw(2) << std::setfill('0') << (int)adapter_pos->PhysicalAddress[i]; - } - return mac_addr.str(); - } - } - } - BOOST_LOG(warning) << "Unable to find MAC address for "sv << address; - return "00:00:00:00:00:00"s; -} - input_t input() { input_t result { new vigem_t {} };