mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-27 00:00:07 -06:00
begin work on proper multiplayer UI shito.
for now, determine a global instance ID, and derivate the system MAC from it. remove 'randomize MAC' option.
This commit is contained in:
@ -235,7 +235,7 @@ void SemReset(int num)
|
||||
|
||||
bool Init()
|
||||
{
|
||||
MPQueue = new QSharedMemory("melonNIFI_FIFO");
|
||||
MPQueue = new QSharedMemory("melonNIFI");
|
||||
|
||||
if (!MPQueue->attach())
|
||||
{
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <QSemaphore>
|
||||
#include <QMutex>
|
||||
#include <QOpenGLContext>
|
||||
#include <QSharedMemory>
|
||||
|
||||
#include "Platform.h"
|
||||
#include "Config.h"
|
||||
@ -44,6 +45,55 @@ void emuStop();
|
||||
namespace Platform
|
||||
{
|
||||
|
||||
QSharedMemory* IPCBuffer = nullptr;
|
||||
int IPCInstanceID;
|
||||
|
||||
void IPCInit()
|
||||
{
|
||||
IPCInstanceID = 0;
|
||||
|
||||
IPCBuffer = new QSharedMemory("melonIPC");
|
||||
|
||||
if (!IPCBuffer->attach())
|
||||
{
|
||||
printf("IPC sharedmem doesn't exist. creating\n");
|
||||
if (!IPCBuffer->create(4096))
|
||||
{
|
||||
printf("IPC sharedmem create failed :(\n");
|
||||
delete IPCBuffer;
|
||||
IPCBuffer= nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
IPCBuffer->lock();
|
||||
memset(IPCBuffer->data(), 0, IPCBuffer->size());
|
||||
IPCBuffer->unlock();
|
||||
}
|
||||
|
||||
IPCBuffer->lock();
|
||||
u8* data = (u8*)IPCBuffer->data();
|
||||
u16 mask = *(u16*)&data[0];
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
if (!(mask & (1<<i)))
|
||||
{
|
||||
IPCInstanceID = i;
|
||||
*(u16*)&data[0] |= (1<<i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
IPCBuffer->unlock();
|
||||
|
||||
printf("IPC: instance ID %d\n", IPCInstanceID);
|
||||
}
|
||||
|
||||
void IPCDeInit()
|
||||
{
|
||||
if (IPCBuffer) delete IPCBuffer;
|
||||
IPCBuffer = nullptr;
|
||||
}
|
||||
|
||||
|
||||
void Init(int argc, char** argv)
|
||||
{
|
||||
#if defined(__WIN32__) || defined(PORTABLE)
|
||||
@ -77,10 +127,13 @@ void Init(int argc, char** argv)
|
||||
confdir = config.absolutePath() + "/melonDS/";
|
||||
EmuDirectory = confdir.toStdString();
|
||||
#endif
|
||||
|
||||
IPCInit();
|
||||
}
|
||||
|
||||
void DeInit()
|
||||
{
|
||||
IPCDeInit();
|
||||
}
|
||||
|
||||
|
||||
@ -90,6 +143,12 @@ void StopEmu()
|
||||
}
|
||||
|
||||
|
||||
int InstanceID()
|
||||
{
|
||||
return IPCInstanceID;
|
||||
}
|
||||
|
||||
|
||||
int GetConfigInt(ConfigEntry entry)
|
||||
{
|
||||
const int imgsizes[] = {0, 256, 512, 1024, 2048, 4096};
|
||||
|
@ -647,7 +647,11 @@ void EmuThread::run()
|
||||
if (winUpdateFreq < 1)
|
||||
winUpdateFreq = 1;
|
||||
|
||||
sprintf(melontitle, "[%d/%.0f] melonDS " MELONDS_VERSION, fps, fpstarget);
|
||||
int inst = Platform::InstanceID();
|
||||
if (inst == 0)
|
||||
sprintf(melontitle, "[%d/%.0f] melonDS " MELONDS_VERSION, fps, fpstarget);
|
||||
else
|
||||
sprintf(melontitle, "[%d/%.0f] melonDS (%d)", fps, fpstarget, inst+1);
|
||||
changeWindowTitle(melontitle);
|
||||
}
|
||||
}
|
||||
@ -662,7 +666,11 @@ void EmuThread::run()
|
||||
|
||||
EmuStatus = EmuRunning;
|
||||
|
||||
sprintf(melontitle, "melonDS " MELONDS_VERSION);
|
||||
int inst = Platform::InstanceID();
|
||||
if (inst == 0)
|
||||
sprintf(melontitle, "melonDS " MELONDS_VERSION);
|
||||
else
|
||||
sprintf(melontitle, "melonDS (%d)", inst+1);
|
||||
changeWindowTitle(melontitle);
|
||||
|
||||
SDL_Delay(75);
|
||||
|
Reference in New Issue
Block a user