mirror of https://github.com/PCSX2/pcsx2.git
USB: fix ini saves
This commit is contained in:
parent
b5dbd794de
commit
47d65c3f89
|
@ -27,6 +27,7 @@
|
||||||
#include "qemu-usb/desc.h"
|
#include "qemu-usb/desc.h"
|
||||||
#include "shared/shared_usb.h"
|
#include "shared/shared_usb.h"
|
||||||
#include "deviceproxy.h"
|
#include "deviceproxy.h"
|
||||||
|
#include "configuration.h"
|
||||||
|
|
||||||
#define PSXCLK 36864000 /* 36.864 Mhz */
|
#define PSXCLK 36864000 /* 36.864 Mhz */
|
||||||
|
|
||||||
|
@ -183,7 +184,7 @@ void CreateDevices()
|
||||||
|
|
||||||
s32 USBinit()
|
s32 USBinit()
|
||||||
{
|
{
|
||||||
OSDebugOut(TEXT("USBinit\n"));
|
USBsetSettingsDir();
|
||||||
|
|
||||||
RegisterDevice::Register();
|
RegisterDevice::Register();
|
||||||
LoadConfig();
|
LoadConfig();
|
||||||
|
@ -196,7 +197,6 @@ s32 USBinit()
|
||||||
usbLog = wfopen(LogDir.c_str(), "wb"); // L"wb,ccs=UNICODE");
|
usbLog = wfopen(LogDir.c_str(), "wb"); // L"wb,ccs=UNICODE");
|
||||||
#endif
|
#endif
|
||||||
//if(usbLog) setvbuf(usbLog, NULL, _IONBF, 0);
|
//if(usbLog) setvbuf(usbLog, NULL, _IONBF, 0);
|
||||||
USB_LOG("USBinit\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qemu_ohci = ohci_create(0x1f801600, 2);
|
qemu_ohci = ohci_create(0x1f801600, 2);
|
||||||
|
@ -238,9 +238,6 @@ s32 USBopen(void* pDsp)
|
||||||
//if(usbLog) setvbuf(usbLog, NULL, _IONBF, 0);
|
//if(usbLog) setvbuf(usbLog, NULL, _IONBF, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
USB_LOG("USBopen\n");
|
|
||||||
OSDebugOut(TEXT("USBopen\n"));
|
|
||||||
|
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
|
|
||||||
HWND hWnd = (HWND)pDsp;
|
HWND hWnd = (HWND)pDsp;
|
||||||
|
|
|
@ -237,10 +237,11 @@ BOOL CALLBACK ConfigureDlgProcUSB(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPar
|
||||||
void USBconfigure()
|
void USBconfigure()
|
||||||
{
|
{
|
||||||
ScopedCoreThreadPause paused_core;
|
ScopedCoreThreadPause paused_core;
|
||||||
|
USBsetSettingsDir();
|
||||||
RegisterDevice::Register();
|
RegisterDevice::Register();
|
||||||
DialogBox(hInstUSB,
|
DialogBox(hInstUSB,
|
||||||
MAKEINTRESOURCE(IDD_CONFIG),
|
MAKEINTRESOURCE(IDD_CONFIG),
|
||||||
GetActiveWindow(),
|
GetActiveWindow(),
|
||||||
(DLGPROC)ConfigureDlgProcUSB);
|
(DLGPROC)ConfigureDlgProcUSB);
|
||||||
paused_core.AllowResume();
|
paused_core.AllowResume();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,24 +19,29 @@
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "shared/inifile_usb.h"
|
#include "shared/inifile_usb.h"
|
||||||
#include "platcompat.h"
|
#include "platcompat.h"
|
||||||
|
#include "AppConfig.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
std::map<std::pair<int, std::string>, std::string> changedAPIs;
|
std::map<std::pair<int, std::string>, std::string> changedAPIs;
|
||||||
const TCHAR* iniFile = TEXT("USBqemu-wheel.ini");
|
wxString iniFile(L"USB.ini");
|
||||||
static TSTDSTRING usb_path;
|
static TSTDSTRING usb_path;
|
||||||
TSTDSTRING IniPath = TSTDSTRING(TEXT("./inis/")) + iniFile; // default path, just in case
|
TSTDSTRING IniPath; // default path, just in case
|
||||||
TSTDSTRING LogDir;
|
TSTDSTRING LogDir;
|
||||||
CIniFile ciniFile;
|
CIniFile ciniFile;
|
||||||
|
bool USBpathSet = false;
|
||||||
|
|
||||||
void USBsetSettingsDir(const char* dir)
|
void USBsetSettingsDir()
|
||||||
{
|
{
|
||||||
|
if(!USBpathSet)
|
||||||
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
IniPath = str_to_wstr(dir);
|
IniPath = GetSettingsFolder().Combine( iniFile ).GetFullPath(); // default path, just in case
|
||||||
#else
|
#else
|
||||||
IniPath = dir;
|
IniPath = std::string(GetSettingsFolder().Combine( iniFile ).GetFullPath()); // default path, just in case
|
||||||
#endif
|
#endif
|
||||||
IniPath.append(iniFile);
|
USBpathSet = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void USBsetLogDir(const char* dir)
|
void USBsetLogDir(const char* dir)
|
||||||
|
@ -50,6 +55,7 @@ void USBsetLogDir(const char* dir)
|
||||||
|
|
||||||
std::string GetSelectedAPI(const std::pair<int, std::string>& pair)
|
std::string GetSelectedAPI(const std::pair<int, std::string>& pair)
|
||||||
{
|
{
|
||||||
|
USBsetSettingsDir();
|
||||||
auto it = changedAPIs.find(pair);
|
auto it = changedAPIs.find(pair);
|
||||||
if (it != changedAPIs.end())
|
if (it != changedAPIs.end())
|
||||||
return it->second;
|
return it->second;
|
||||||
|
@ -58,6 +64,7 @@ std::string GetSelectedAPI(const std::pair<int, std::string>& pair)
|
||||||
|
|
||||||
bool LoadSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, TSTDSTRING& value)
|
bool LoadSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, TSTDSTRING& value)
|
||||||
{
|
{
|
||||||
|
USBsetSettingsDir();
|
||||||
CIniKey* key;
|
CIniKey* key;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
auto sect = ciniFile.GetSection(section);
|
auto sect = ciniFile.GetSection(section);
|
||||||
|
@ -79,6 +86,7 @@ bool LoadSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TC
|
||||||
|
|
||||||
bool LoadSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, int32_t& value)
|
bool LoadSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, int32_t& value)
|
||||||
{
|
{
|
||||||
|
USBsetSettingsDir();
|
||||||
CIniKey* key;
|
CIniKey* key;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
auto sect = ciniFile.GetSection(section);
|
auto sect = ciniFile.GetSection(section);
|
||||||
|
@ -109,6 +117,7 @@ bool LoadSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TC
|
||||||
|
|
||||||
bool SaveSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, const TSTDSTRING& value)
|
bool SaveSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, const TSTDSTRING& value)
|
||||||
{
|
{
|
||||||
|
USBsetSettingsDir();
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
ciniFile.SetKeyValue(section, param, value);
|
ciniFile.SetKeyValue(section, param, value);
|
||||||
#else
|
#else
|
||||||
|
@ -119,6 +128,7 @@ bool SaveSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TC
|
||||||
|
|
||||||
bool SaveSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, int32_t value)
|
bool SaveSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, int32_t value)
|
||||||
{
|
{
|
||||||
|
USBsetSettingsDir();
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
ciniFile.SetKeyValue(section, param, TSTDTOSTRING(value));
|
ciniFile.SetKeyValue(section, param, TSTDTOSTRING(value));
|
||||||
#else
|
#else
|
||||||
|
@ -129,7 +139,7 @@ bool SaveSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TC
|
||||||
|
|
||||||
void SaveConfig()
|
void SaveConfig()
|
||||||
{
|
{
|
||||||
|
USBsetSettingsDir();
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
SaveSetting(L"MAIN", L"log", conf.Log);
|
SaveSetting(L"MAIN", L"log", conf.Log);
|
||||||
#else
|
#else
|
||||||
|
@ -167,8 +177,8 @@ void SaveConfig()
|
||||||
|
|
||||||
void LoadConfig()
|
void LoadConfig()
|
||||||
{
|
{
|
||||||
std::cerr << "USB load config\n"
|
|
||||||
<< std::endl;
|
USBsetSettingsDir();
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
ciniFile.Load(IniPath);
|
ciniFile.Load(IniPath);
|
||||||
|
@ -224,6 +234,7 @@ void LoadConfig()
|
||||||
|
|
||||||
void ClearSection(const TCHAR* section)
|
void ClearSection(const TCHAR* section)
|
||||||
{
|
{
|
||||||
|
USBsetSettingsDir();
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
auto s = ciniFile.GetSection(section);
|
auto s = ciniFile.GetSection(section);
|
||||||
#else
|
#else
|
||||||
|
@ -237,6 +248,7 @@ void ClearSection(const TCHAR* section)
|
||||||
|
|
||||||
void RemoveSection(const char* dev_type, int port, const std::string& key)
|
void RemoveSection(const char* dev_type, int port, const std::string& key)
|
||||||
{
|
{
|
||||||
|
USBsetSettingsDir();
|
||||||
TSTDSTRING tkey;
|
TSTDSTRING tkey;
|
||||||
tkey.assign(key.begin(), key.end());
|
tkey.assign(key.begin(), key.end());
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ void RemoveSection(const char* dev_type, int port, const std::string& key);
|
||||||
|
|
||||||
extern TSTDSTRING IniPath;
|
extern TSTDSTRING IniPath;
|
||||||
extern TSTDSTRING LogDir;
|
extern TSTDSTRING LogDir;
|
||||||
extern const TCHAR* iniFile;
|
extern wxString iniFile;
|
||||||
extern std::map<std::pair<int /*port*/, std::string /*devname*/>, std::string> changedAPIs;
|
extern std::map<std::pair<int /*port*/, std::string /*devname*/>, std::string> changedAPIs;
|
||||||
std::string GetSelectedAPI(const std::pair<int /*port*/, std::string /*devname*/>& pair);
|
std::string GetSelectedAPI(const std::pair<int /*port*/, std::string /*devname*/>& pair);
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ bool LoadSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TC
|
||||||
bool SaveSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, const std::string& value);
|
bool SaveSettingValue(const TSTDSTRING& ini, const TSTDSTRING& section, const TCHAR* param, const std::string& value);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void USBsetSettingsDir(const char* dir);
|
void USBsetSettingsDir();
|
||||||
void USBsetLogDir(const char* dir);
|
void USBsetLogDir(const char* dir);
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
|
|
|
@ -207,6 +207,7 @@ void USBconfigure()
|
||||||
{
|
{
|
||||||
ScopedCoreThreadPause paused_core;
|
ScopedCoreThreadPause paused_core;
|
||||||
|
|
||||||
|
USBsetSettingsDir();
|
||||||
RegisterDevice::Register();
|
RegisterDevice::Register();
|
||||||
LoadConfig();
|
LoadConfig();
|
||||||
void* that = NULL;
|
void* that = NULL;
|
||||||
|
|
Loading…
Reference in New Issue