Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Support for UWP #85

Closed
wants to merge 11 commits into from
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ endif()
target_link_libraries(moonlight-common-c PRIVATE enet)

if(MSVC)
target_compile_options(moonlight-common-c PRIVATE /W3 /wd4100 /wd4232 /wd5105 /WX)
target_compile_options(moonlight-common-c PRIVATE /W3 /wd4100 /wd4232 /wd5105)
if(NOT TARGET_UWP)
target_compile_options(moonlight-common-c PRIVATE /WX)
TheElixZammuto marked this conversation as resolved.
Show resolved Hide resolved
endif()
target_link_libraries(moonlight-common-c PRIVATE ws2_32.lib winmm.lib)
elseif(MINGW)
target_link_libraries(moonlight-common-c PRIVATE -lws2_32 -lwinmm)
Expand Down
12 changes: 10 additions & 2 deletions src/PlatformSockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,26 @@

#if defined(LC_WINDOWS)

# if defined(WINAPI_FAMILY) && WINAPI_FAMILY==WINAPI_FAMILY_APP
# define LC_UWP
# else
# define LC_WINDOWS_DESKTOP
#endif
TheElixZammuto marked this conversation as resolved.
Show resolved Hide resolved

#ifndef SIO_UDP_CONNRESET
#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR, 12)
#endif

static HMODULE WlanApiLibraryHandle;
static HANDLE WlanHandle;

#if defined(LC_WINDOWS_DESKTOP)
DWORD (WINAPI *pfnWlanOpenHandle)(DWORD dwClientVersion, PVOID pReserved, PDWORD pdwNegotiatedVersion, PHANDLE phClientHandle);
DWORD (WINAPI *pfnWlanCloseHandle)(HANDLE hClientHandle, PVOID pReserved);
DWORD (WINAPI *pfnWlanEnumInterfaces)(HANDLE hClientHandle, PVOID pReserved, PWLAN_INTERFACE_INFO_LIST *ppInterfaceList);
VOID (WINAPI *pfnWlanFreeMemory)(PVOID pMemory);
DWORD (WINAPI *pfnWlanSetInterface)(HANDLE hClientHandle, CONST GUID *pInterfaceGuid, WLAN_INTF_OPCODE OpCode, DWORD dwDataSize, CONST PVOID pData, PVOID pReserved);
#endif

#ifndef WLAN_API_MAKE_VERSION
#define WLAN_API_MAKE_VERSION(_major, _minor) (((DWORD)(_minor)) << 16 | (_major))
Expand Down Expand Up @@ -618,7 +626,7 @@ bool isPrivateNetworkAddress(struct sockaddr_storage* address) {

// Enable platform-specific low latency options (best-effort)
void enterLowLatencyMode(void) {
#if defined(LC_WINDOWS)
#if defined(LC_WINDOWS_DESKTOP)
DWORD negotiatedVersion;
PWLAN_INTERFACE_INFO_LIST wlanInterfaceList;
DWORD i;
Expand Down Expand Up @@ -692,7 +700,7 @@ void enterLowLatencyMode(void) {
}

void exitLowLatencyMode(void) {
#if defined(LC_WINDOWS)
#if defined(LC_WINDOWS_DESKTOP)
// Closing our WLAN client handle will undo our optimizations
if (WlanHandle != NULL) {
pfnWlanCloseHandle(WlanHandle, NULL);
Expand Down