dolphin/Source/Core/Core/ConfigManager.h

381 lines
10 KiB
C
Raw Normal View History

// Copyright 2008 Dolphin Emulator Project
2015-05-18 01:08:10 +02:00
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
2016-08-14 19:54:01 +00:00
#include <limits>
#include <optional>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "Common/IniFile.h"
#include "Core/HW/EXI/EXI_Device.h"
#include "Core/HW/SI/SI_Device.h"
#include "Core/TitleDatabase.h"
namespace DiscIO
{
enum class Language;
enum class Region;
struct Partition;
class Volume;
}
namespace IOS
{
namespace ES
{
class TMDReader;
}
}
2013-01-16 20:16:56 -05:00
// DSP Backend Types
2017-05-11 15:59:31 -07:00
#define BACKEND_NULLSOUND _trans("No Audio Output")
#define BACKEND_ALSA "ALSA"
2017-03-22 16:09:59 -07:00
#define BACKEND_CUBEB "Cubeb"
#define BACKEND_OPENAL "OpenAL"
#define BACKEND_PULSEAUDIO "Pulse"
#define BACKEND_XAUDIO2 "XAudio2"
#define BACKEND_OPENSLES "OpenSLES"
enum GPUDeterminismMode
{
GPU_DETERMINISM_AUTO,
GPU_DETERMINISM_NONE,
// This is currently the only mode. There will probably be at least
// one more at some point.
GPU_DETERMINISM_FAKE_COMPLETION,
};
Boot: Clean up the boot code * Move out boot parameters to a separate struct, which is not part of SConfig/ConfigManager because there is no reason for it to be there. * Move out file name parsing and constructing the appropriate params from paths to a separate function that does that, and only that. * For every different boot type we support, add a proper struct with only the required parameters, with descriptive names and use std::variant to only store what we need. * Clean up the bHLE_BS2 stuff which made no sense sometimes. Now instead of using bHLE_BS2 for two different things, both for storing the user config setting and as a runtime boot parameter, we simply replace the Disc boot params with BootParameters::IPL. * Const correctness so it's clear what can or cannot update the config. * Drop unused parameters and unneeded checks. * Make a few checks a lot more concise. (Looking at you, extension checks for disc images.) * Remove a mildly terrible workaround where we needed to pass an empty string in order to boot the GC IPL without any game inserted. (Not required anymore thanks to std::variant and std::optional.) The motivation for this are multiple: cleaning up and being able to add support for booting an installed NAND title. Without this change, it'd be pretty much impossible to implement that. Also, using std::visit with std::variant makes the compiler do additional type checks: now we're guaranteed that the boot code will handle all boot types and no invalid boot type will be possible.
2017-05-27 15:43:40 +02:00
struct BootParameters;
Remove NonCopyable The class NonCopyable is, like the name says, supposed to disallow copying. But should it allow moving? For a long time, NonCopyable used to not allow moving. (It declared a deleted copy constructor and assigment operator without declaring a move constructor and assignment operator, making the compiler implicitly delete the move constructor and assignment operator.) That's fine if the classes that inherit from NonCopyable don't need to be movable or if writing the move constructor and assignment operator by hand is fine, but that's not the case for all classes, as I discovered when I was working on the DirectoryBlob PR. Because of that, I decided to make NonCopyable movable in c7602cc, allowing me to use NonCopyable in DirectoryBlob.h. That was however an unfortunate decision, because some of the classes that inherit from NonCopyable have incorrect behavior when moved by default- generated move constructors and assignment operators, and do not explicitly delete the move constructors and assignment operators, relying on NonCopyable being non-movable. So what can we do about this? There are four solutions that I can think of: 1. Make NonCopyable non-movable and tell DirectoryBlob to suck it. 2. Keep allowing moving NonCopyable, and expect that classes that don't support moving will delete the move constructor and assignment operator manually. Not only is this inconsistent (having classes disallow copying one way and disallow moving another way), but deleting the move constructor and assignment operator manually is too easy to forget compared to how tricky the resulting problems are. 3. Have one "MovableNonCopyable" and one "NonMovableNonCopyable". It works, but it feels rather silly... 4. Don't have a NonCopyable class at all. Considering that deleting the copy constructor and assignment operator only takes two lines of code, I don't see much of a reason to keep NonCopyable. I suppose that there was more of a point in having NonCopyable back in the pre-C++11 days, when it wasn't possible to use "= delete". I decided to go with the fourth one (like the commit title says). The implementation of the commit is fairly straight-forward, though I would like to point out that I skipped adding "= delete" lines for classes whose only reason for being uncopyable is that they contain uncopyable classes like File::IOFile and std::unique_ptr, because the compiler makes such classes uncopyable automatically.
2017-08-04 23:57:12 +02:00
struct SConfig
{
// Wii Devices
bool m_WiiSDCard;
bool m_WiiKeyboard;
bool m_WiimoteContinuousScanning;
bool m_WiimoteEnableSpeaker;
// ISO folder
std::vector<std::string> m_ISOFolder;
bool m_RecursiveISOFolder;
// Settings
bool bEnableDebugging = false;
#ifdef USE_GDBSTUB
int iGDBPort;
#ifndef _WIN32
std::string gdb_socket;
#endif
#endif
bool bAutomaticStart = false;
bool bBootToPause = false;
2017-05-19 16:57:31 +02:00
int iCPUCore; // Uses the values of PowerPC::CPUCore
bool bJITNoBlockCache = false;
bool bJITNoBlockLinking = false;
bool bJITOff = false;
bool bJITLoadStoreOff = false;
bool bJITLoadStorelXzOff = false;
bool bJITLoadStorelwzOff = false;
bool bJITLoadStorelbzxOff = false;
bool bJITLoadStoreFloatingOff = false;
bool bJITLoadStorePairedOff = false;
bool bJITFloatingPointOff = false;
bool bJITIntegerOff = false;
bool bJITPairedOff = false;
bool bJITSystemRegistersOff = false;
bool bJITBranchOff = false;
bool bFastmem;
bool bFPRF = false;
bool bAccurateNaNs = false;
int iTimingVariance = 40; // in milli secounds
bool bCPUThread = true;
bool bDSPThread = false;
bool bDSPHLE = true;
bool bSyncGPUOnSkipIdleHack = true;
bool bHLE_BS2 = true;
bool bEnableCheats = false;
bool bEnableMemcardSdWriting = true;
bool bCopyWiiSaveNetplay = true;
bool bDPL2Decoder = false;
int iLatency = 20;
bool m_audio_stretch = false;
int m_audio_stretch_max_latency = 80;
bool bRunCompareServer = false;
bool bRunCompareClient = false;
bool bMMU = false;
bool bDCBZOFF = false;
bool bLowDCBZHack = false;
int iBBDumpPort = 0;
bool bFastDiscSpeed = false;
bool bSyncGPU = false;
int iSyncGpuMaxDistance;
int iSyncGpuMinDistance;
float fSyncGpuOverclock;
int SelectedLanguage = 0;
bool bOverrideGCLanguage = false;
bool bWii = false;
bool m_is_mios = false;
// Interface settings
bool bConfirmStop = false;
bool bHideCursor = false;
bool bUsePanicHandlers = true;
bool bOnScreenDisplayMessages = true;
std::string theme_name;
// Display settings
std::string strFullscreenResolution;
2016-08-14 19:54:01 +00:00
int iRenderWindowXPos = std::numeric_limits<int>::min();
int iRenderWindowYPos = std::numeric_limits<int>::min();
int iRenderWindowWidth = -1;
int iRenderWindowHeight = -1;
bool bRenderWindowAutoSize = false, bKeepWindowOnTop = false;
bool bFullscreen = false, bRenderToMain = false;
bool bDisableScreenSaver = false;
int iPosX, iPosY, iWidth, iHeight;
// Analytics settings.
std::string m_analytics_id;
bool m_analytics_enabled = false;
bool m_analytics_permission_asked = false;
// Bluetooth passthrough mode settings
bool m_bt_passthrough_enabled = false;
int m_bt_passthrough_pid = -1;
int m_bt_passthrough_vid = -1;
std::string m_bt_passthrough_link_keys;
// USB passthrough settings
std::set<std::pair<u16, u16>> m_usb_passthrough_devices;
bool IsUSBDeviceWhitelisted(std::pair<u16, u16> vid_pid) const;
bool m_enable_signature_checks = true;
// Fifo Player related settings
bool bLoopFifoReplay = true;
2016-07-13 16:46:14 -04:00
// Custom RTC
bool bEnableCustomRTC;
u32 m_customRTCValue;
DiscIO::Region m_region;
std::string m_strVideoBackend;
std::string m_strGPUDeterminismMode;
// set based on the string version
GPUDeterminismMode m_GPUDeterminismMode;
// files
std::string m_strBootROM;
std::string m_strSRAM;
std::string m_strDefaultISO;
std::string m_strWiiSDCardPath;
std::string m_perfDir;
2017-06-05 13:55:54 +02:00
std::string m_debugger_game_id;
Boot: Clean up the boot code * Move out boot parameters to a separate struct, which is not part of SConfig/ConfigManager because there is no reason for it to be there. * Move out file name parsing and constructing the appropriate params from paths to a separate function that does that, and only that. * For every different boot type we support, add a proper struct with only the required parameters, with descriptive names and use std::variant to only store what we need. * Clean up the bHLE_BS2 stuff which made no sense sometimes. Now instead of using bHLE_BS2 for two different things, both for storing the user config setting and as a runtime boot parameter, we simply replace the Disc boot params with BootParameters::IPL. * Const correctness so it's clear what can or cannot update the config. * Drop unused parameters and unneeded checks. * Make a few checks a lot more concise. (Looking at you, extension checks for disc images.) * Remove a mildly terrible workaround where we needed to pass an empty string in order to boot the GC IPL without any game inserted. (Not required anymore thanks to std::variant and std::optional.) The motivation for this are multiple: cleaning up and being able to add support for booting an installed NAND title. Without this change, it'd be pretty much impossible to implement that. Also, using std::visit with std::variant makes the compiler do additional type checks: now we're guaranteed that the boot code will handle all boot types and no invalid boot type will be possible.
2017-05-27 15:43:40 +02:00
// TODO: remove this as soon as the ticket view hack in IOS/ES/Views is dropped.
bool m_disc_booted_from_game_list = false;
const std::string& GetGameID() const { return m_game_id; }
const std::string& GetTitleDescription() const { return m_title_description; }
u64 GetTitleID() const { return m_title_id; }
u16 GetRevision() const { return m_revision; }
void ResetRunningGameMetadata();
void SetRunningGameMetadata(const DiscIO::Volume& volume, const DiscIO::Partition& partition);
void SetRunningGameMetadata(const IOS::ES::TMDReader& tmd);
void LoadDefaults();
// Replaces NTSC-K with some other region, and doesn't replace non-NTSC-K regions
static DiscIO::Region ToGameCubeRegion(DiscIO::Region region);
// The region argument must be valid for GameCube (i.e. must not be NTSC-K)
static const char* GetDirectoryForRegion(DiscIO::Region region);
2017-05-21 22:21:34 +01:00
std::string GetBootROMPath(const std::string& region_directory) const;
Boot: Clean up the boot code * Move out boot parameters to a separate struct, which is not part of SConfig/ConfigManager because there is no reason for it to be there. * Move out file name parsing and constructing the appropriate params from paths to a separate function that does that, and only that. * For every different boot type we support, add a proper struct with only the required parameters, with descriptive names and use std::variant to only store what we need. * Clean up the bHLE_BS2 stuff which made no sense sometimes. Now instead of using bHLE_BS2 for two different things, both for storing the user config setting and as a runtime boot parameter, we simply replace the Disc boot params with BootParameters::IPL. * Const correctness so it's clear what can or cannot update the config. * Drop unused parameters and unneeded checks. * Make a few checks a lot more concise. (Looking at you, extension checks for disc images.) * Remove a mildly terrible workaround where we needed to pass an empty string in order to boot the GC IPL without any game inserted. (Not required anymore thanks to std::variant and std::optional.) The motivation for this are multiple: cleaning up and being able to add support for booting an installed NAND title. Without this change, it'd be pretty much impossible to implement that. Also, using std::visit with std::variant makes the compiler do additional type checks: now we're guaranteed that the boot code will handle all boot types and no invalid boot type will be possible.
2017-05-27 15:43:40 +02:00
bool SetPathsAndGameMetadata(const BootParameters& boot);
void CheckMemcardPath(std::string& memcardPath, const std::string& gameRegion, bool isSlotA);
DiscIO::Language GetCurrentLanguage(bool wii) const;
IniFile LoadDefaultGameIni() const;
IniFile LoadLocalGameIni() const;
IniFile LoadGameIni() const;
static IniFile LoadDefaultGameIni(const std::string& id, std::optional<u16> revision);
static IniFile LoadLocalGameIni(const std::string& id, std::optional<u16> revision);
static IniFile LoadGameIni(const std::string& id, std::optional<u16> revision);
std::string m_NANDPath;
2016-06-25 11:24:43 -04:00
std::string m_DumpPath;
std::string m_strMemoryCardA;
std::string m_strMemoryCardB;
std::string m_strGbaCartA;
std::string m_strGbaCartB;
2017-03-18 17:46:05 -04:00
ExpansionInterface::TEXIDevices m_EXIDevice[3];
SerialInterface::SIDevices m_SIDevice[4];
std::string m_bba_mac;
// interface language
std::string m_InterfaceLanguage;
float m_EmulationSpeed;
bool m_OCEnable;
float m_OCFactor;
// other interface settings
bool m_InterfaceToolbar;
bool m_InterfaceStatusbar;
bool m_InterfaceLogWindow;
bool m_InterfaceLogConfigWindow;
bool m_InterfaceExtendedFPSInfo;
bool m_show_active_title = false;
bool m_use_builtin_title_database = true;
bool m_ListDrives;
bool m_ListWad;
bool m_ListElfDol;
bool m_ListWii;
bool m_ListGC;
bool m_ListPal;
bool m_ListUsa;
bool m_ListJap;
bool m_ListAustralia;
bool m_ListFrance;
bool m_ListGermany;
bool m_ListItaly;
bool m_ListKorea;
bool m_ListNetherlands;
bool m_ListRussia;
bool m_ListSpain;
bool m_ListTaiwan;
bool m_ListWorld;
bool m_ListUnknown;
int m_ListSort;
int m_ListSort2;
// Game list column toggles
bool m_showSystemColumn;
bool m_showBannerColumn;
2017-05-08 19:03:59 +02:00
bool m_showDescriptionColumn;
bool m_showTitleColumn;
bool m_showMakerColumn;
bool m_showFileNameColumn;
bool m_showIDColumn;
bool m_showRegionColumn;
bool m_showSizeColumn;
std::string m_WirelessMac;
bool m_PauseMovie;
bool m_ShowLag;
bool m_ShowFrameCount;
2016-07-19 20:23:25 -04:00
bool m_ShowRTC;
std::string m_strMovieAuthor;
unsigned int m_FrameSkip;
bool m_DumpFrames;
bool m_DumpFramesSilent;
bool m_ShowInputDisplay;
bool m_PauseOnFocusLost;
bool m_DisableTooltips;
// DSP settings
bool m_DSPEnableJIT;
bool m_DSPCaptureLog;
bool m_DumpAudio;
2017-01-08 13:51:00 -05:00
bool m_DumpAudioSilent;
bool m_IsMuted;
bool m_DumpUCode;
int m_Volume;
std::string sBackend;
// Input settings
bool m_BackgroundInput;
bool m_AdapterRumble[4];
bool m_AdapterKonga[4];
2015-06-16 21:48:09 +02:00
// Network settings
bool m_SSLDumpRead;
bool m_SSLDumpWrite;
2015-06-09 20:23:56 +02:00
bool m_SSLVerifyCert;
bool m_SSLDumpRootCA;
bool m_SSLDumpPeerCert;
2015-06-16 21:48:09 +02:00
// Auto-update settings
std::string m_auto_update_track;
std::string m_auto_update_hash_override;
Remove NonCopyable The class NonCopyable is, like the name says, supposed to disallow copying. But should it allow moving? For a long time, NonCopyable used to not allow moving. (It declared a deleted copy constructor and assigment operator without declaring a move constructor and assignment operator, making the compiler implicitly delete the move constructor and assignment operator.) That's fine if the classes that inherit from NonCopyable don't need to be movable or if writing the move constructor and assignment operator by hand is fine, but that's not the case for all classes, as I discovered when I was working on the DirectoryBlob PR. Because of that, I decided to make NonCopyable movable in c7602cc, allowing me to use NonCopyable in DirectoryBlob.h. That was however an unfortunate decision, because some of the classes that inherit from NonCopyable have incorrect behavior when moved by default- generated move constructors and assignment operators, and do not explicitly delete the move constructors and assignment operators, relying on NonCopyable being non-movable. So what can we do about this? There are four solutions that I can think of: 1. Make NonCopyable non-movable and tell DirectoryBlob to suck it. 2. Keep allowing moving NonCopyable, and expect that classes that don't support moving will delete the move constructor and assignment operator manually. Not only is this inconsistent (having classes disallow copying one way and disallow moving another way), but deleting the move constructor and assignment operator manually is too easy to forget compared to how tricky the resulting problems are. 3. Have one "MovableNonCopyable" and one "NonMovableNonCopyable". It works, but it feels rather silly... 4. Don't have a NonCopyable class at all. Considering that deleting the copy constructor and assignment operator only takes two lines of code, I don't see much of a reason to keep NonCopyable. I suppose that there was more of a point in having NonCopyable back in the pre-C++11 days, when it wasn't possible to use "= delete". I decided to go with the fourth one (like the commit title says). The implementation of the commit is fairly straight-forward, though I would like to point out that I skipped adding "= delete" lines for classes whose only reason for being uncopyable is that they contain uncopyable classes like File::IOFile and std::unique_ptr, because the compiler makes such classes uncopyable automatically.
2017-08-04 23:57:12 +02:00
SConfig(const SConfig&) = delete;
SConfig& operator=(const SConfig&) = delete;
SConfig(SConfig&&) = delete;
SConfig& operator=(SConfig&&) = delete;
// Save settings
void SaveSettings();
// Load settings
void LoadSettings();
// Return the permanent and somewhat globally used instance of this struct
static SConfig& GetInstance() { return (*m_Instance); }
static void Init();
static void Shutdown();
private:
SConfig();
~SConfig();
void SaveGeneralSettings(IniFile& ini);
void SaveInterfaceSettings(IniFile& ini);
void SaveDisplaySettings(IniFile& ini);
void SaveGameListSettings(IniFile& ini);
void SaveCoreSettings(IniFile& ini);
void SaveDSPSettings(IniFile& ini);
void SaveInputSettings(IniFile& ini);
void SaveMovieSettings(IniFile& ini);
void SaveFifoPlayerSettings(IniFile& ini);
2015-06-16 21:48:09 +02:00
void SaveNetworkSettings(IniFile& ini);
void SaveAnalyticsSettings(IniFile& ini);
void SaveBluetoothPassthroughSettings(IniFile& ini);
void SaveUSBPassthroughSettings(IniFile& ini);
void SaveAutoUpdateSettings(IniFile& ini);
void LoadGeneralSettings(IniFile& ini);
void LoadInterfaceSettings(IniFile& ini);
void LoadDisplaySettings(IniFile& ini);
void LoadGameListSettings(IniFile& ini);
void LoadCoreSettings(IniFile& ini);
void LoadDSPSettings(IniFile& ini);
void LoadInputSettings(IniFile& ini);
void LoadMovieSettings(IniFile& ini);
void LoadFifoPlayerSettings(IniFile& ini);
2015-06-16 21:48:09 +02:00
void LoadNetworkSettings(IniFile& ini);
void LoadAnalyticsSettings(IniFile& ini);
void LoadBluetoothPassthroughSettings(IniFile& ini);
void LoadUSBPassthroughSettings(IniFile& ini);
void LoadAutoUpdateSettings(IniFile& ini);
void SetRunningGameMetadata(const std::string& game_id, u64 title_id, u16 revision,
Core::TitleDatabase::TitleType type);
static SConfig* m_Instance;
std::string m_game_id;
std::string m_title_description;
u64 m_title_id;
u16 m_revision;
};