USB: misc fixes on settings string conversion

This commit is contained in:
Gauvain 'GovanifY' Roussel-Tarbouriech 2020-11-11 19:10:56 +01:00 committed by refractionpcsx2
parent ce658e8a96
commit f3f50a948e
10 changed files with 51 additions and 18 deletions

View File

@ -79,7 +79,8 @@ void PopulateAPIs(HWND hW, int port)
std::string selApi = GetSelectedAPI(std::make_pair(port, devName)); std::string selApi = GetSelectedAPI(std::make_pair(port, devName));
std::string var; std::string var;
if (!LoadSetting(nullptr, port, rd.Name(devtype), N_DEVICE_API, str_to_wstr(var))) std::wstring tmp;
if (!LoadSetting(nullptr, port, rd.Name(devtype), N_DEVICE_API, tmp))
{ {
if (apis.begin() != apis.end()) if (apis.begin() != apis.end())
{ {
@ -88,6 +89,7 @@ void PopulateAPIs(HWND hW, int port)
} }
} }
var = wstr_to_str(tmp);
int i = 0, sel = 0; int i = 0, sel = 0;
for (auto& api : apis) for (auto& api : apis)
{ {

View File

@ -205,7 +205,8 @@ void LoadConfig()
{ {
std::string api; std::string api;
#ifdef _WIN32 #ifdef _WIN32
LoadSetting(nullptr, i, conf.Port[i], N_DEVICE_API, str_to_wstr(api)); LoadSetting(nullptr, i, conf.Port[i], N_DEVICE_API, tmp);
api = wstr_to_str(tmp);
#else #else
LoadSetting(nullptr, i, conf.Port[i], N_DEVICE_API, api); LoadSetting(nullptr, i, conf.Port[i], N_DEVICE_API, api);
#endif #endif

View File

@ -504,7 +504,9 @@ namespace usb_eyetoy
VideoDevice* videodev = nullptr; VideoDevice* videodev = nullptr;
std::string varApi; std::string varApi;
#ifdef _WIN32 #ifdef _WIN32
LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, str_to_wstr(varApi)); std::wstring tmp;
LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, tmp);
varApi = wstr_to_str(tmp);
#else #else
LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, varApi); LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, varApi);
#endif #endif

View File

@ -730,7 +730,9 @@ namespace usb_hid
std::string varApi; std::string varApi;
#ifdef _WIN32 #ifdef _WIN32
LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, str_to_wstr(varApi)); std::wstring tmp;
LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, tmp);
varApi = wstr_to_str(tmp);
#else #else
LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, varApi); LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, varApi);
#endif #endif
@ -825,7 +827,9 @@ namespace usb_hid
std::string varApi; std::string varApi;
#ifdef _WIN32 #ifdef _WIN32
LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, str_to_wstr(varApi)); std::wstring tmp;
LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, tmp);
varApi = wstr_to_str(tmp);
#else #else
LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, varApi); LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, varApi);
#endif #endif
@ -901,7 +905,9 @@ namespace usb_hid
std::string varApi; std::string varApi;
#ifdef _WIN32 #ifdef _WIN32
LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, str_to_wstr(varApi)); std::wstring tmp;
LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, tmp);
varApi = wstr_to_str(tmp);
#else #else
LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, varApi); LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, varApi);
#endif #endif

View File

@ -971,11 +971,14 @@ namespace usb_mic
{ {
std::string api; std::string api;
#ifdef _WIN32 #ifdef _WIN32
if (!LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, str_to_wstr(api))) std::wstring tmp;
if (!LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, tmp))
return nullptr;
api = wstr_to_str(tmp);
#else #else
if (!LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, api)) if (!LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, api))
#endif
return nullptr; return nullptr;
#endif
return HeadsetDevice::CreateDevice(port, api); return HeadsetDevice::CreateDevice(port, api);
} }

View File

@ -244,11 +244,14 @@ namespace usb_mic
{ {
std::string api; std::string api;
#ifdef _WIN32 #ifdef _WIN32
if (!LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, str_to_wstr(api))) std::wstring tmp;
if (!LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, tmp))
return nullptr;
api = wstr_to_str(tmp);
#else #else
if (!LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, api)) if (!LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, api))
#endif
return nullptr; return nullptr;
#endif
USBDevice* dev = SingstarDevice::CreateDevice(port, api); USBDevice* dev = SingstarDevice::CreateDevice(port, api);
if (!dev) if (!dev)

View File

@ -765,7 +765,9 @@ namespace usb_mic
{ {
std::string api; std::string api;
#ifdef _WIN32 #ifdef _WIN32
LoadSetting(nullptr, port, SingstarDevice::TypeName(), N_DEVICE_API, str_to_wstr(api)); std::wstring tmp;
LoadSetting(nullptr, port, SingstarDevice::TypeName(), N_DEVICE_API, tmp);
api = wstr_to_str(tmp);
#else #else
LoadSetting(nullptr, port, SingstarDevice::TypeName(), N_DEVICE_API, api); LoadSetting(nullptr, port, SingstarDevice::TypeName(), N_DEVICE_API, api);
#endif #endif

View File

@ -1282,11 +1282,15 @@ namespace usb_pad
swprintf_s(text, TEXT("CONTROL %i"), cid); swprintf_s(text, TEXT("CONTROL %i"), cid);
#ifdef _WIN32 #ifdef _WIN32
if (!LoadSetting(section, text, str_to_wstr(control))) std::wstring tmp;
bool res_control = LoadSetting(section, text, tmp);
control = wstr_to_str(tmp);
if (!res_control)
continue;
#else #else
if (!LoadSetting(section, text, control)) if (!LoadSetting(section, text, control))
#endif
continue; continue;
#endif
ss << control; ss << control;
std::getline(ss, guid, ','); std::getline(ss, guid, ',');

View File

@ -533,7 +533,9 @@ namespace usb_pad
{ {
std::string varApi; std::string varApi;
#ifdef _WIN32 #ifdef _WIN32
LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, str_to_wstr(varApi)); std::wstring tmp;
LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, tmp);
varApi = wstr_to_str(tmp);
#else #else
LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, varApi); LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, varApi);
#endif #endif
@ -659,7 +661,9 @@ namespace usb_pad
{ {
std::string varApi; std::string varApi;
#ifdef _WIN32 #ifdef _WIN32
LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, str_to_wstr(varApi)); std::wstring tmp;
LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, tmp);
varApi = wstr_to_str(tmp);
#else #else
LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, varApi); LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, varApi);
#endif #endif
@ -730,7 +734,9 @@ namespace usb_pad
{ {
std::string varApi; std::string varApi;
#ifdef _WIN32 #ifdef _WIN32
LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, str_to_wstr(varApi)); std::wstring tmp;
LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, tmp);
varApi = wstr_to_str(tmp);
#else #else
LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, varApi); LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, varApi);
#endif #endif

View File

@ -389,7 +389,9 @@ namespace usb_pad
{ {
std::string varApi; std::string varApi;
#ifdef _WIN32 #ifdef _WIN32
LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, str_to_wstr(varApi)); std::wstring tmp;
LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, tmp);
varApi = wstr_to_str(tmp);
#else #else
LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, varApi); LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, varApi);
#endif #endif
@ -404,7 +406,9 @@ namespace usb_pad
#ifdef _WIN32 #ifdef _WIN32
if (!LoadSetting(nullptr, port, usb_mic::SingstarDevice::TypeName(), N_DEVICE_API, str_to_wstr(api))) if (!LoadSetting(nullptr, port, usb_mic::SingstarDevice::TypeName(), N_DEVICE_API, tmp))
return nullptr;
api = wstr_to_str(tmp);
#else #else
if (!LoadSetting(nullptr, port, usb_mic::SingstarDevice::TypeName(), N_DEVICE_API, api)) if (!LoadSetting(nullptr, port, usb_mic::SingstarDevice::TypeName(), N_DEVICE_API, api))
#endif #endif