fix build windows
This commit is contained in:
@@ -43,6 +43,7 @@ if(WIN32)
|
|||||||
include_directories(third-party/ViGEmClient/include)
|
include_directories(third-party/ViGEmClient/include)
|
||||||
|
|
||||||
set(PLATFORM_TARGET_FILES
|
set(PLATFORM_TARGET_FILES
|
||||||
|
sunshine/platform/windows/misc.cpp
|
||||||
sunshine/platform/windows/input.cpp
|
sunshine/platform/windows/input.cpp
|
||||||
sunshine/platform/windows/display.h
|
sunshine/platform/windows/display.h
|
||||||
sunshine/platform/windows/display_base.cpp
|
sunshine/platform/windows/display_base.cpp
|
||||||
|
|||||||
@@ -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) {
|
void int_f(std::unordered_map<std::string, std::string> &vars, const std::string &name, int &input) {
|
||||||
auto it = vars.find(name);
|
auto it = vars.find(name);
|
||||||
|
|
||||||
|
|||||||
+6
-7
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <filesystem>
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
@@ -48,7 +47,7 @@ struct audio_t {
|
|||||||
struct stream_t {
|
struct stream_t {
|
||||||
std::chrono::milliseconds ping_timeout;
|
std::chrono::milliseconds ping_timeout;
|
||||||
|
|
||||||
std::filesystem::path file_apps;
|
std::string file_apps;
|
||||||
|
|
||||||
int fec_percentage;
|
int fec_percentage;
|
||||||
|
|
||||||
@@ -61,12 +60,12 @@ struct nvhttp_t {
|
|||||||
// pc|lan|wan
|
// pc|lan|wan
|
||||||
std::string origin_pin_allowed;
|
std::string origin_pin_allowed;
|
||||||
|
|
||||||
std::filesystem::path pkey; // must be 2048 bits
|
std::string pkey; // must be 2048 bits
|
||||||
std::filesystem::path cert; // must be signed with a key of 2048 bits
|
std::string cert; // must be signed with a key of 2048 bits
|
||||||
|
|
||||||
std::string sunshine_name;
|
std::string sunshine_name;
|
||||||
|
|
||||||
std::filesystem::path file_state;
|
std::string file_state;
|
||||||
|
|
||||||
std::string external_ip;
|
std::string external_ip;
|
||||||
std::vector<std::string> resolutions;
|
std::vector<std::string> resolutions;
|
||||||
@@ -91,13 +90,13 @@ enum flag_e : std::size_t {
|
|||||||
struct sunshine_t {
|
struct sunshine_t {
|
||||||
int min_log_level;
|
int min_log_level;
|
||||||
std::bitset<flag::FLAG_SIZE> flags;
|
std::bitset<flag::FLAG_SIZE> flags;
|
||||||
std::filesystem::path credentials_file;
|
std::string credentials_file;
|
||||||
|
|
||||||
std::string username;
|
std::string username;
|
||||||
std::string password;
|
std::string password;
|
||||||
std::string salt;
|
std::string salt;
|
||||||
|
|
||||||
std::filesystem::path config_file;
|
std::string config_file;
|
||||||
|
|
||||||
struct cmd_t {
|
struct cmd_t {
|
||||||
std::string name;
|
std::string name;
|
||||||
|
|||||||
@@ -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 <windows.h>
|
||||||
#include <winuser.h>
|
|
||||||
#include <ws2tcpip.h>
|
#include <cmath>
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
#include <ViGEm/Client.h>
|
#include <ViGEm/Client.h>
|
||||||
|
|
||||||
@@ -19,8 +10,6 @@
|
|||||||
namespace platf {
|
namespace platf {
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
|
|
||||||
using adapteraddrs_t = util::c_ptr<IP_ADAPTER_ADDRESSES>;
|
|
||||||
|
|
||||||
volatile HDESK _lastKnownInputDesktop = NULL;
|
volatile HDESK _lastKnownInputDesktop = NULL;
|
||||||
constexpr touch_port_t target_touch_port {
|
constexpr touch_port_t target_touch_port {
|
||||||
0, 0,
|
0, 0,
|
||||||
@@ -98,71 +87,6 @@ public:
|
|||||||
client_t client;
|
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 input() {
|
||||||
input_t result { new vigem_t {} };
|
input_t result { new vigem_t {} };
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user