1 // Copyright 2008 Dolphin Emulator Project 2 // Licensed under GPLv2+ 3 // Refer to the license.txt file included. 4 5 #pragma once 6 7 #include <limits> 8 #include <optional> 9 #include <set> 10 #include <string> 11 #include <utility> 12 #include <vector> 13 14 #include "Common/Common.h" 15 #include "Common/CommonTypes.h" 16 17 class IniFile; 18 19 namespace DiscIO 20 { 21 enum class Language; 22 enum class Platform; 23 enum class Region; 24 struct Partition; 25 class Volume; 26 } // namespace DiscIO 27 28 namespace ExpansionInterface 29 { 30 enum TEXIDevices : int; 31 } // namespace ExpansionInterface 32 33 namespace IOS::ES 34 { 35 class TMDReader; 36 } // namespace IOS::ES 37 38 namespace PowerPC 39 { 40 enum class CPUCore; 41 } // namespace PowerPC 42 43 namespace SerialInterface 44 { 45 enum SIDevices : int; 46 } // namespace SerialInterface 47 48 struct BootParameters; 49 50 // DSP Backend Types 51 #define BACKEND_NULLSOUND _trans("No Audio Output") 52 #define BACKEND_ALSA "ALSA" 53 #define BACKEND_CUBEB "Cubeb" 54 #define BACKEND_OPENAL "OpenAL" 55 #define BACKEND_PULSEAUDIO "Pulse" 56 #define BACKEND_OPENSLES "OpenSLES" 57 #define BACKEND_WASAPI _trans("WASAPI (Exclusive Mode)") 58 59 enum class GPUDeterminismMode 60 { 61 Auto, 62 Disabled, 63 // This is currently the only mode. There will probably be at least 64 // one more at some point. 65 FakeCompletion, 66 }; 67 68 struct SConfig 69 { 70 // Wii Devices 71 bool m_WiiSDCard; 72 bool m_WiiKeyboard; 73 bool m_WiimoteContinuousScanning; 74 bool m_WiimoteEnableSpeaker; 75 bool connect_wiimotes_for_ciface; 76 77 // ISO folder 78 std::vector<std::string> m_ISOFolder; 79 80 // Settings 81 bool bEnableDebugging = false; 82 #ifdef USE_GDBSTUB 83 int iGDBPort; 84 #ifndef _WIN32 85 std::string gdb_socket; 86 #endif 87 #endif 88 bool bAutomaticStart = false; 89 bool bBootToPause = false; 90 91 PowerPC::CPUCore cpu_core; 92 93 bool bJITFollowBranch; 94 bool bJITNoBlockCache = false; 95 bool bJITNoBlockLinking = false; 96 bool bJITOff = false; 97 bool bJITLoadStoreOff = false; 98 bool bJITLoadStorelXzOff = false; 99 bool bJITLoadStorelwzOff = false; 100 bool bJITLoadStorelbzxOff = false; 101 bool bJITLoadStoreFloatingOff = false; 102 bool bJITLoadStorePairedOff = false; 103 bool bJITFloatingPointOff = false; 104 bool bJITIntegerOff = false; 105 bool bJITPairedOff = false; 106 bool bJITSystemRegistersOff = false; 107 bool bJITBranchOff = false; 108 bool bJITRegisterCacheOff = false; 109 110 bool bFastmem; 111 bool bFPRF = false; 112 bool bAccurateNaNs = false; 113 114 int iTimingVariance = 40; // in milli secounds 115 bool bCPUThread = true; 116 bool bDSPThread = false; 117 bool bDSPHLE = true; 118 bool bSyncGPUOnSkipIdleHack = true; 119 bool bHLE_BS2 = true; 120 bool bEnableCheats = false; 121 bool bEnableMemcardSdWriting = true; 122 bool bCopyWiiSaveNetplay = true; 123 124 bool bDPL2Decoder = false; 125 int iLatency = 20; 126 bool m_audio_stretch = false; 127 int m_audio_stretch_max_latency = 80; 128 129 bool bRunCompareServer = false; 130 bool bRunCompareClient = false; 131 132 bool bMMU = false; 133 bool bLowDCBZHack = false; 134 int iBBDumpPort = 0; 135 bool bFastDiscSpeed = false; 136 137 bool bSyncGPU = false; 138 int iSyncGpuMaxDistance; 139 int iSyncGpuMinDistance; 140 float fSyncGpuOverclock; 141 142 int SelectedLanguage = 0; 143 bool bOverrideRegionSettings = false; 144 145 bool bWii = false; 146 bool m_is_mios = false; 147 148 // Interface settings 149 bool bConfirmStop = false; 150 bool bHideCursor = false; 151 std::string theme_name; 152 153 // Bluetooth passthrough mode settings 154 bool m_bt_passthrough_enabled = false; 155 int m_bt_passthrough_pid = -1; 156 int m_bt_passthrough_vid = -1; 157 std::string m_bt_passthrough_link_keys; 158 159 // USB passthrough settings 160 std::set<std::pair<u16, u16>> m_usb_passthrough_devices; 161 bool IsUSBDeviceWhitelisted(std::pair<u16, u16> vid_pid) const; 162 163 // Fifo Player related settings 164 bool bLoopFifoReplay = true; 165 166 // Custom RTC 167 bool bEnableCustomRTC; 168 u32 m_customRTCValue; 169 170 // DPL2 171 bool ShouldUseDPL2Decoder() const; 172 173 DiscIO::Region m_region; 174 175 std::string m_strGPUDeterminismMode; 176 177 // set based on the string version 178 GPUDeterminismMode m_GPUDeterminismMode; 179 180 // files 181 std::string m_strBootROM; 182 std::string m_strSRAM; 183 184 std::string m_perfDir; 185 186 std::string m_debugger_game_id; 187 // TODO: remove this as soon as the ticket view hack in IOS/ES/Views is dropped. 188 bool m_disc_booted_from_game_list = false; 189 GetGameIDSConfig190 const std::string& GetGameID() const { return m_game_id; } GetTitleDescriptionSConfig191 const std::string& GetTitleDescription() const { return m_title_description; } GetTitleIDSConfig192 u64 GetTitleID() const { return m_title_id; } GetRevisionSConfig193 u16 GetRevision() const { return m_revision; } 194 void ResetRunningGameMetadata(); 195 void SetRunningGameMetadata(const DiscIO::Volume& volume, const DiscIO::Partition& partition); 196 void SetRunningGameMetadata(const IOS::ES::TMDReader& tmd, DiscIO::Platform platform); 197 198 void LoadDefaults(); 199 // Replaces NTSC-K with some other region, and doesn't replace non-NTSC-K regions 200 static DiscIO::Region ToGameCubeRegion(DiscIO::Region region); 201 // The region argument must be valid for GameCube (i.e. must not be NTSC-K) 202 static const char* GetDirectoryForRegion(DiscIO::Region region); 203 std::string GetBootROMPath(const std::string& region_directory) const; 204 bool SetPathsAndGameMetadata(const BootParameters& boot); 205 static DiscIO::Region GetFallbackRegion(); 206 DiscIO::Language GetCurrentLanguage(bool wii) const; 207 DiscIO::Language GetLanguageAdjustedForRegion(bool wii, DiscIO::Region region) const; 208 209 IniFile LoadDefaultGameIni() const; 210 IniFile LoadLocalGameIni() const; 211 IniFile LoadGameIni() const; 212 213 static IniFile LoadDefaultGameIni(const std::string& id, std::optional<u16> revision); 214 static IniFile LoadLocalGameIni(const std::string& id, std::optional<u16> revision); 215 static IniFile LoadGameIni(const std::string& id, std::optional<u16> revision); 216 217 std::string m_strGbaCartA; 218 std::string m_strGbaCartB; 219 ExpansionInterface::TEXIDevices m_EXIDevice[3]; 220 SerialInterface::SIDevices m_SIDevice[4]; 221 222 std::string m_bba_mac; 223 std::string m_bba_xlink_ip; 224 bool m_bba_xlink_chat_osd = true; 225 226 // interface language 227 std::string m_InterfaceLanguage; 228 float m_EmulationSpeed; 229 bool m_OCEnable; 230 float m_OCFactor; 231 // other interface settings 232 bool m_InterfaceExtendedFPSInfo; 233 bool m_show_active_title = false; 234 bool m_use_builtin_title_database = true; 235 236 bool m_ListDrives; 237 bool m_ListWad; 238 bool m_ListElfDol; 239 bool m_ListWii; 240 bool m_ListGC; 241 bool m_ListPal; 242 bool m_ListUsa; 243 bool m_ListJap; 244 bool m_ListAustralia; 245 bool m_ListFrance; 246 bool m_ListGermany; 247 bool m_ListItaly; 248 bool m_ListKorea; 249 bool m_ListNetherlands; 250 bool m_ListRussia; 251 bool m_ListSpain; 252 bool m_ListTaiwan; 253 bool m_ListWorld; 254 bool m_ListUnknown; 255 int m_ListSort; 256 int m_ListSort2; 257 258 // Game list column toggles 259 bool m_showSystemColumn; 260 bool m_showBannerColumn; 261 bool m_showDescriptionColumn; 262 bool m_showTitleColumn; 263 bool m_showMakerColumn; 264 bool m_showFileNameColumn; 265 bool m_showFilePathColumn; 266 bool m_showIDColumn; 267 bool m_showRegionColumn; 268 bool m_showSizeColumn; 269 bool m_showFileFormatColumn; 270 bool m_showBlockSizeColumn; 271 bool m_showCompressionColumn; 272 bool m_showTagsColumn; 273 274 std::string m_WirelessMac; 275 bool m_PauseMovie; 276 bool m_ShowLag; 277 bool m_ShowFrameCount; 278 bool m_ShowRTC; 279 std::string m_strMovieAuthor; 280 bool m_DumpFrames; 281 bool m_DumpFramesSilent; 282 bool m_ShowInputDisplay; 283 284 bool m_PauseOnFocusLost; 285 286 // DSP settings 287 bool m_DSPEnableJIT; 288 bool m_DSPCaptureLog; 289 bool m_DumpAudio; 290 bool m_DumpAudioSilent; 291 bool m_IsMuted; 292 bool m_DumpUCode; 293 int m_Volume; 294 std::string sBackend; 295 296 #ifdef _WIN32 297 // WSAPI settings 298 std::string sWASAPIDevice; 299 #endif 300 301 // Input settings 302 bool m_BackgroundInput; 303 bool m_AdapterRumble[4]; 304 bool m_AdapterKonga[4]; 305 306 // Auto-update settings 307 std::string m_auto_update_track; 308 std::string m_auto_update_hash_override; 309 310 SConfig(const SConfig&) = delete; 311 SConfig& operator=(const SConfig&) = delete; 312 SConfig(SConfig&&) = delete; 313 SConfig& operator=(SConfig&&) = delete; 314 315 // Save settings 316 void SaveSettings(); 317 318 // Load settings 319 void LoadSettings(); 320 321 // Return the permanent and somewhat globally used instance of this struct GetInstanceSConfig322 static SConfig& GetInstance() { return (*m_Instance); } 323 static void Init(); 324 static void Shutdown(); 325 326 private: 327 SConfig(); 328 ~SConfig(); 329 330 void SaveGeneralSettings(IniFile& ini); 331 void SaveInterfaceSettings(IniFile& ini); 332 void SaveGameListSettings(IniFile& ini); 333 void SaveCoreSettings(IniFile& ini); 334 void SaveDSPSettings(IniFile& ini); 335 void SaveInputSettings(IniFile& ini); 336 void SaveMovieSettings(IniFile& ini); 337 void SaveFifoPlayerSettings(IniFile& ini); 338 void SaveBluetoothPassthroughSettings(IniFile& ini); 339 void SaveUSBPassthroughSettings(IniFile& ini); 340 void SaveAutoUpdateSettings(IniFile& ini); 341 void SaveJitDebugSettings(IniFile& ini); 342 343 void LoadGeneralSettings(IniFile& ini); 344 void LoadInterfaceSettings(IniFile& ini); 345 void LoadGameListSettings(IniFile& ini); 346 void LoadCoreSettings(IniFile& ini); 347 void LoadDSPSettings(IniFile& ini); 348 void LoadInputSettings(IniFile& ini); 349 void LoadMovieSettings(IniFile& ini); 350 void LoadFifoPlayerSettings(IniFile& ini); 351 void LoadBluetoothPassthroughSettings(IniFile& ini); 352 void LoadUSBPassthroughSettings(IniFile& ini); 353 void LoadAutoUpdateSettings(IniFile& ini); 354 void LoadJitDebugSettings(IniFile& ini); 355 356 void SetRunningGameMetadata(const std::string& game_id, const std::string& gametdb_id, 357 u64 title_id, u16 revision, DiscIO::Region region); 358 359 static SConfig* m_Instance; 360 361 std::string m_game_id; 362 std::string m_gametdb_id; 363 std::string m_title_description; 364 u64 m_title_id; 365 u16 m_revision; 366 }; 367