merge doublemelon (#2067)

non-exhaustive (but exhausting) list of changes:

* base laid for multiple window support, but will likely require more work to work correctly
* encapsulation of frontend state for proper multi-instance support
* (JIT still needs a fix for the NDS::Current workaround but we can get there later)
* new, more flexible configuration system
This commit is contained in:
Arisotura
2024-06-15 13:52:47 +02:00
committed by GitHub
parent 8e9b88d01d
commit 25a7b1ca1d
111 changed files with 16802 additions and 5042 deletions

View File

@ -16,208 +16,127 @@
with melonDS. If not, see http://www.gnu.org/licenses/.
*/
#ifndef PLATFORMCONFIG_H
#define PLATFORMCONFIG_H
#ifndef CONFIG_H
#define CONFIG_H
#include <variant>
#include <string>
#include <QString>
#include <unordered_map>
#include <tuple>
enum
#ifndef TOML11_VALUE_HPP
namespace toml
{
HK_Lid = 0,
HK_Mic,
HK_Pause,
HK_Reset,
HK_FastForward,
HK_FastForwardToggle,
HK_FullscreenToggle,
HK_SwapScreens,
HK_SwapScreenEmphasis,
HK_SolarSensorDecrease,
HK_SolarSensorIncrease,
HK_FrameStep,
HK_PowerButton,
HK_VolumeUp,
HK_VolumeDown,
HK_MAX
};
enum
{
micInputType_Silence,
micInputType_External,
micInputType_Noise,
micInputType_Wav,
micInputType_MAX,
};
enum
{
renderer3D_Software = 0,
#ifdef OGLRENDERER_ENABLED
renderer3D_OpenGL,
renderer3D_OpenGLCompute,
class value;
}
#endif
renderer3D_Max,
};
namespace Config
{
struct ConfigEntry
struct LegacyEntry
{
char Name[32];
int Type; // 0=int 1=bool 2=string 3=64bit int
void* Value; // pointer to the value variable
std::variant<int, bool, std::string, int64_t> Default;
char TOMLPath[64];
bool InstanceUnique; // whether the setting can exist individually for each instance in multiplayer
};
struct CameraConfig
template<typename T>
using DefaultList = std::unordered_map<std::string, T>;
using RangeList = std::unordered_map<std::string, std::tuple<int, int>>;
class Table;
class Array
{
int InputType; // 0=blank 1=image 2=camera
std::string ImagePath;
std::string CamDeviceName;
bool XFlip;
public:
Array(toml::value& data);
~Array() {}
size_t Size();
void Clear();
Array GetArray(const int id);
int GetInt(const int id);
int64_t GetInt64(const int id);
bool GetBool(const int id);
std::string GetString(const int id);
void SetInt(const int id, int val);
void SetInt64(const int id, int64_t val);
void SetBool(const int id, bool val);
void SetString(const int id, const std::string& val);
// convenience
QString GetQString(const int id)
{
return QString::fromStdString(GetString(id));
}
void SetQString(const int id, const QString& val)
{
return SetString(id, val.toStdString());
}
private:
toml::value& Data;
};
class Table
{
public:
//Table();
Table(toml::value& data, const std::string& path);
~Table() {}
extern int KeyMapping[12];
extern int JoyMapping[12];
Table& operator=(const Table& b);
extern int HKKeyMapping[HK_MAX];
extern int HKJoyMapping[HK_MAX];
Array GetArray(const std::string& path);
Table GetTable(const std::string& path, const std::string& defpath = "");
extern int JoystickID;
int GetInt(const std::string& path);
int64_t GetInt64(const std::string& path);
bool GetBool(const std::string& path);
std::string GetString(const std::string& path);
extern int WindowWidth;
extern int WindowHeight;
extern bool WindowMaximized;
void SetInt(const std::string& path, int val);
void SetInt64(const std::string& path, int64_t val);
void SetBool(const std::string& path, bool val);
void SetString(const std::string& path, const std::string& val);
extern int ScreenRotation;
extern int ScreenGap;
extern int ScreenLayout;
extern bool ScreenSwap;
extern int ScreenSizing;
extern int ScreenAspectTop;
extern int ScreenAspectBot;
extern bool IntegerScaling;
extern bool ScreenFilter;
// convenience
extern bool ScreenUseGL;
extern bool ScreenVSync;
extern int ScreenVSyncInterval;
QString GetQString(const std::string& path)
{
return QString::fromStdString(GetString(path));
}
extern int _3DRenderer;
extern bool Threaded3D;
void SetQString(const std::string& path, const QString& val)
{
return SetString(path, val.toStdString());
}
extern int GL_ScaleFactor;
extern bool GL_BetterPolygons;
extern bool GL_HiresCoordinates;
private:
toml::value& Data;
std::string PathPrefix;
extern bool LimitFPS;
extern int MaxFPS;
extern bool AudioSync;
extern bool ShowOSD;
extern int ConsoleType;
extern bool DirectBoot;
#ifdef JIT_ENABLED
extern bool JIT_Enable;
extern int JIT_MaxBlockSize;
extern bool JIT_BranchOptimisations;
extern bool JIT_LiteralOptimisations;
extern bool JIT_FastMemory;
#endif
extern bool ExternalBIOSEnable;
extern std::string BIOS9Path;
extern std::string BIOS7Path;
extern std::string FirmwarePath;
extern std::string DSiBIOS9Path;
extern std::string DSiBIOS7Path;
extern std::string DSiFirmwarePath;
extern std::string DSiNANDPath;
extern bool DLDIEnable;
extern std::string DLDISDPath;
extern int DLDISize;
extern bool DLDIReadOnly;
extern bool DLDIFolderSync;
extern std::string DLDIFolderPath;
extern bool DSiSDEnable;
extern std::string DSiSDPath;
extern int DSiSDSize;
extern bool DSiSDReadOnly;
extern bool DSiSDFolderSync;
extern std::string DSiSDFolderPath;
extern bool FirmwareOverrideSettings;
extern std::string FirmwareUsername;
extern int FirmwareLanguage;
extern int FirmwareBirthdayMonth;
extern int FirmwareBirthdayDay;
extern int FirmwareFavouriteColour;
extern std::string FirmwareMessage;
extern std::string FirmwareMAC;
extern std::string WifiSettingsPath;
extern int MPAudioMode;
extern int MPRecvTimeout;
extern std::string LANDevice;
extern bool DirectLAN;
extern bool SavestateRelocSRAM;
extern int AudioInterp;
extern int AudioBitDepth;
extern int AudioVolume;
extern bool DSiVolumeSync;
extern int MicInputType;
extern std::string MicDevice;
extern std::string MicWavPath;
extern std::string LastROMFolder;
extern std::string LastBIOSFolder;
extern std::string RecentROMList[10];
extern std::string SaveFilePath;
extern std::string SavestatePath;
extern std::string CheatFilePath;
extern bool EnableCheats;
extern bool MouseHide;
extern int MouseHideSeconds;
extern bool PauseLostFocus;
extern std::string UITheme;
extern int64_t RTCOffset;
extern bool DSBatteryLevelOkay;
extern int DSiBatteryLevel;
extern bool DSiBatteryCharging;
extern bool DSiFullBIOSBoot;
extern CameraConfig Camera[2];
extern bool GdbEnabled;
extern int GdbPortARM7;
extern int GdbPortARM9;
extern bool GdbARM7BreakOnStartup;
extern bool GdbARM9BreakOnStartup;
toml::value& ResolvePath(const std::string& path);
template<typename T> T FindDefault(const std::string& path, T def, DefaultList<T> list);
};
bool Load();
void Save();
Table GetLocalTable(int instance);
inline Table GetGlobalTable() { return GetLocalTable(-1); }
}
#endif // PLATFORMCONFIG_H
#endif // CONFIG_H