mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 21:37:42 -07:00
lay base for netplay
This commit is contained in:
parent
e14c06401e
commit
ed32edf683
48
cmake/FindENet.cmake
Normal file
48
cmake/FindENet.cmake
Normal file
@ -0,0 +1,48 @@
|
||||
# - Try to find enet
|
||||
# Once done this will define
|
||||
#
|
||||
# ENET_FOUND - system has enet
|
||||
# ENET_INCLUDE_DIRS - the enet include directory
|
||||
# ENET_LIBRARIES - the libraries needed to use enet
|
||||
#
|
||||
# $ENETDIR is an environment variable used for finding enet.
|
||||
#
|
||||
# Borrowed from The Mana World
|
||||
# http://themanaworld.org/
|
||||
#
|
||||
# Several changes and additions by Fabian 'x3n' Landau
|
||||
# Lots of simplifications by Adrian Friedli
|
||||
# > www.orxonox.net <
|
||||
|
||||
FIND_PATH(ENET_INCLUDE_DIRS enet/enet.h
|
||||
PATHS
|
||||
$ENV{ENETDIR}
|
||||
/usr/local
|
||||
/usr
|
||||
PATH_SUFFIXES include
|
||||
)
|
||||
|
||||
FIND_LIBRARY(ENET_LIBRARY
|
||||
NAMES enet
|
||||
PATHS
|
||||
$ENV{ENETDIR}
|
||||
/usr/local
|
||||
/usr
|
||||
PATH_SUFFIXES lib
|
||||
)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set ENET_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ENet DEFAULT_MSG ENET_LIBRARY ENET_INCLUDE_DIRS)
|
||||
|
||||
IF (ENET_FOUND)
|
||||
IF(WIN32)
|
||||
SET(WINDOWS_ENET_DEPENDENCIES "ws2_32;winmm")
|
||||
SET(ENET_LIBRARIES ${ENET_LIBRARY} ${WINDOWS_ENET_DEPENDENCIES})
|
||||
ELSE(WIN32)
|
||||
SET(ENET_LIBRARIES ${ENET_LIBRARY})
|
||||
ENDIF(WIN32)
|
||||
ENDIF (ENET_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(ENET_LIBRARY ENET_LIBRARIES ENET_INCLUDE_DIRS)
|
@ -28,6 +28,7 @@ set(SOURCES_QT_SDL
|
||||
IPC.cpp
|
||||
LAN_PCap.cpp
|
||||
LAN_Socket.cpp
|
||||
Netplay.cpp
|
||||
OSD.cpp
|
||||
OSD_shaders.h
|
||||
font.h
|
||||
@ -91,6 +92,8 @@ add_compile_definitions(ARCHIVE_SUPPORT_ENABLED)
|
||||
|
||||
add_executable(melonDS ${SOURCES_QT_SDL})
|
||||
|
||||
find_package(ENet REQUIRED)
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(melonDS PUBLIC opengl32)
|
||||
|
||||
@ -158,6 +161,7 @@ endif()
|
||||
target_link_libraries(melonDS PRIVATE core)
|
||||
target_link_libraries(melonDS PRIVATE PkgConfig::SDL2 PkgConfig::Slirp PkgConfig::LibArchive PkgConfig::Zstd)
|
||||
target_link_libraries(melonDS PRIVATE ${QT_LINK_LIBS} ${CMAKE_DL_LIBS})
|
||||
target_link_libraries(melonDS PRIVATE ${ENET_LIBRARIES})
|
||||
|
||||
if (UNIX)
|
||||
option(PORTABLE "Make a portable build that looks for its configuration in the current directory" OFF)
|
||||
|
48
src/frontend/qt_sdl/Netplay.cpp
Normal file
48
src/frontend/qt_sdl/Netplay.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
Copyright 2016-2022 melonDS team
|
||||
|
||||
This file is part of melonDS.
|
||||
|
||||
melonDS is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation, either version 3 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with melonDS. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <enet/enet.h>
|
||||
|
||||
#include "Netplay.h"
|
||||
|
||||
|
||||
namespace Netplay
|
||||
{
|
||||
|
||||
bool Init()
|
||||
{
|
||||
if (enet_initialize() != 0)
|
||||
{
|
||||
printf("enet shat itself :(\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
printf("enet init OK\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeInit()
|
||||
{
|
||||
enet_deinitialize();
|
||||
}
|
||||
|
||||
}
|
32
src/frontend/qt_sdl/Netplay.h
Normal file
32
src/frontend/qt_sdl/Netplay.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
Copyright 2016-2022 melonDS team
|
||||
|
||||
This file is part of melonDS.
|
||||
|
||||
melonDS is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation, either version 3 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with melonDS. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
#ifndef NETPLAY_H
|
||||
#define NETPLAY_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
namespace Netplay
|
||||
{
|
||||
|
||||
bool Init();
|
||||
void DeInit();
|
||||
|
||||
}
|
||||
|
||||
#endif // NETPLAY_H
|
@ -88,6 +88,7 @@
|
||||
#include "Wifi.h"
|
||||
#include "Platform.h"
|
||||
#include "IPC.h"
|
||||
#include "Netplay.h"
|
||||
#include "Config.h"
|
||||
#include "DSi_I2C.h"
|
||||
|
||||
@ -318,6 +319,7 @@ void EmuThread::run()
|
||||
|
||||
IPC::InitSema();
|
||||
IPC::SetMPRecvTimeout(Config::MPRecvTimeout);
|
||||
Netplay::Init();
|
||||
|
||||
NDS::Init();
|
||||
|
||||
@ -658,6 +660,7 @@ void EmuThread::run()
|
||||
|
||||
GPU::DeInitRenderer();
|
||||
NDS::DeInit();
|
||||
Netplay::DeInit();
|
||||
IPC::DeInitSema();
|
||||
//Platform::LAN_DeInit();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user