Merge remote-tracking branch 'origin/master' into season3

This commit is contained in:
Arisotura
2024-08-10 16:58:48 +02:00
9 changed files with 153 additions and 74 deletions

View File

@ -167,9 +167,6 @@ target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../..")
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../../net")
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../../net/libslirp/src")
get_target_property(SLIRP_BINARY_DIR slirp BINARY_DIR)
target_include_directories(melonDS PUBLIC "${SLIRP_BINARY_DIR}") # for libslirp-version.h
if (USE_QT6)
target_include_directories(melonDS PUBLIC ${Qt6Gui_PRIVATE_INCLUDE_DIRS})
else()
@ -246,6 +243,8 @@ if (UNIX AND NOT APPLE)
INTERPROCEDURAL_OPTIMIZATION OFF
INTERPROCEDURAL_OPTIMIZATION_RELEASE OFF)
endif()
elseif(APPLE)
install(TARGETS melonDS BUNDLE DESTINATION "${CMAKE_INSTALL_PREFIX}/Applications")
endif()
if (ENABLE_OGLRENDERER)

View File

@ -39,6 +39,7 @@
#include <QMimeData>
#include <QVector>
#include <QCommandLineParser>
#include <QDesktopServices>
#ifndef _WIN32
#include <QGuiApplication>
#include <QSocketNotifier>
@ -366,6 +367,12 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
actUndoStateLoad->setShortcut(QKeySequence(Qt::Key_F12));
connect(actUndoStateLoad, &QAction::triggered, this, &MainWindow::onUndoStateLoad);
menu->addSeparator();
actOpenConfig = menu->addAction("Open melonDS directory");
connect(actOpenConfig, &QAction::triggered, this, [&]() {
QDesktopServices::openUrl(QUrl::fromLocalFile(emuDirectory));
});
menu->addSeparator();
actQuit = menu->addAction("Quit");

View File

@ -275,6 +275,7 @@ public:
QAction* actSaveState[9];
QAction* actLoadState[9];
QAction* actUndoStateLoad;
QAction* actOpenConfig;
QAction* actQuit;
QAction* actPause;

View File

@ -1,3 +1,5 @@
include(FixInterfaceIncludes)
add_library(net-utils STATIC
Net.cpp
Net_PCap.cpp
@ -16,11 +18,11 @@ target_include_directories(net-utils PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
option(USE_SYSTEM_LIBSLIRP "Use system libslirp instead of the bundled version" OFF)
if (USE_SYSTEM_LIBSLIRP)
pkg_check_modules(Slirp REQUIRED IMPORTED_TARGET slirp)
target_link_libraries(net-utils PRIVATE PkgConfig::Slirp)
fix_interface_includes(PkgConfig::Slirp)
target_link_libraries(net-utils PUBLIC PkgConfig::Slirp)
else()
add_subdirectory(libslirp EXCLUDE_FROM_ALL)
target_include_directories(net-utils SYSTEM PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/libslirp/glib")
target_link_libraries(net-utils PRIVATE slirp)
target_link_libraries(net-utils PUBLIC slirp)
endif()
find_package(ENet REQUIRED)

View File

@ -25,11 +25,6 @@
#include <libslirp.h>
// "register" is indirectly used by slirp.h but isn't allowed in C++17, this is a workaround
#define register
// Needed for Slirp's definition so we can adjust the opaque pointer in the move constructor
#include <slirp.h>
#ifdef __WIN32__
#include <ws2tcpip.h>
#else
@ -163,63 +158,6 @@ Net_Slirp::Net_Slirp(const Platform::SendPacketCallback& callback) noexcept : Ca
Ctx = slirp_new(&cfg, &cb, this);
}
Net_Slirp::Net_Slirp(Net_Slirp&& other) noexcept
{
RXBuffer = other.RXBuffer;
IPv4ID = other.IPv4ID;
Ctx = other.Ctx;
PollListSize = other.PollListSize;
Callback = std::move(other.Callback);
memcpy(PollList, other.PollList, sizeof(PollList));
other.RXBuffer = {};
other.IPv4ID = 0;
other.Ctx = nullptr;
other.PollListSize = 0;
other.Callback = nullptr;
memset(other.PollList, 0, sizeof(other.PollList));
if (Ctx)
{
Ctx->opaque = this;
// Gotta ensure that the context doesn't try to pass around a dead object
}
}
Net_Slirp& Net_Slirp::operator=(Net_Slirp&& other) noexcept
{
if (this != &other)
{
if (Ctx)
{
slirp_cleanup(Ctx);
}
RXBuffer = other.RXBuffer;
IPv4ID = other.IPv4ID;
Ctx = other.Ctx;
PollListSize = other.PollListSize;
Callback = std::move(other.Callback);
memcpy(PollList, other.PollList, sizeof(PollList));
other.RXBuffer = {};
other.IPv4ID = 0;
other.Ctx = nullptr;
other.PollListSize = 0;
other.Callback = nullptr;
memset(other.PollList, 0, sizeof(other.PollList));
if (Ctx)
{
Ctx->opaque = this;
// Gotta ensure that the context doesn't try to pass around a dead object
}
}
return *this;
}
Net_Slirp::~Net_Slirp() noexcept
{
if (Ctx)
@ -229,7 +167,6 @@ Net_Slirp::~Net_Slirp() noexcept
}
}
void FinishUDPFrame(u8* data, int len)
{
u8* ipheader = &data[0xE];

View File

@ -49,9 +49,9 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/libslirp-version.h.in" "${CMAKE_
add_library(slirp STATIC ${SOURCES})
target_compile_definitions(slirp PUBLIC LIBSLIRP_STATIC_BUILD)
target_include_directories(slirp PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/glib")
target_include_directories(slirp PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src")
target_include_directories(slirp PUBLIC "${CMAKE_CURRENT_BINARY_DIR}")
target_include_directories(slirp SYSTEM PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/glib")
target_include_directories(slirp SYSTEM PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src")
target_include_directories(slirp SYSTEM PUBLIC "${CMAKE_CURRENT_BINARY_DIR}")
target_compile_definitions(slirp PRIVATE BUILDING_LIBSLIRP)
target_compile_definitions(slirp PRIVATE "G_LOG_DOMAIN=\"Slirp\"")

View File

@ -68,10 +68,10 @@
#define GLIB_SIZEOF_VOID_P 8
#ifndef MAX
#define MAX(a, b) (a > b ? a : b)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a, b) (a < b ? a : b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
#ifndef TRUE