fix build windows

This commit is contained in:
loki 2021-06-16 14:34:05 +02:00
parent c21301a423
commit 02360f7aef
4 changed files with 17 additions and 85 deletions

View File

@ -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

View File

@ -377,6 +377,14 @@ void path_f(std::unordered_map<std::string, std::string> &vars, const std::strin
}
}
void path_f(std::unordered_map<std::string, std::string> &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<std::string, std::string> &vars, const std::string &name, int &input) {
auto it = vars.find(name);

View File

@ -3,7 +3,6 @@
#include <bitset>
#include <chrono>
#include <filesystem>
#include <optional>
#include <string>
#include <unordered_map>
@ -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<std::string> resolutions;
@ -91,13 +90,13 @@ enum flag_e : std::size_t {
struct sunshine_t {
int min_log_level;
std::bitset<flag::FLAG_SIZE> 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;

View File

@ -1,15 +1,6 @@
#include <cmath>
#include <iomanip>
#include <sstream>
// prevent clang format from "optimizing" the header include order
// clang-format off
#include <winsock2.h>
#include <iphlpapi.h>
#include <windows.h>
#include <winuser.h>
#include <ws2tcpip.h>
// clang-format on
#include <cmath>
#include <ViGEm/Client.h>
@ -19,8 +10,6 @@
namespace platf {
using namespace std::literals;
using adapteraddrs_t = util::c_ptr<IP_ADAPTER_ADDRESSES>;
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<std::uint16_t, std::string> 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 {} };