From 92be17986fe0383096e9d40a0ca65ad7069d81e5 Mon Sep 17 00:00:00 2001 From: GovanifY Date: Wed, 4 Nov 2020 13:43:32 +0100 Subject: [PATCH] USB: introduce back linux support --- pcsx2/USB/configuration.cpp | 18 ++++++++++++++++++ pcsx2/USB/usb-eyetoy/usb-eyetoy-webcam.cpp | 4 ++++ pcsx2/USB/usb-hid/usb-hid.cpp | 12 ++++++++++++ pcsx2/USB/usb-mic/usb-headset.cpp | 4 ++++ pcsx2/USB/usb-mic/usb-mic-logitech.cpp | 4 ++++ pcsx2/USB/usb-mic/usb-mic-singstar.cpp | 4 ++++ pcsx2/USB/usb-pad/dx/dinput-config.cpp | 12 ++++++++++++ pcsx2/USB/usb-pad/usb-pad.cpp | 12 ++++++++++++ pcsx2/USB/usb-pad/usb-seamic.cpp | 14 ++++++++++++-- 9 files changed, 82 insertions(+), 2 deletions(-) diff --git a/pcsx2/USB/configuration.cpp b/pcsx2/USB/configuration.cpp index ad636a4fc8..24200e8d4a 100644 --- a/pcsx2/USB/configuration.cpp +++ b/pcsx2/USB/configuration.cpp @@ -136,15 +136,24 @@ void SaveConfig() SaveSetting("MAIN", "log", conf.Log); #endif +#ifdef _WIN32 SaveSetting(nullptr, 0, N_DEVICE_PORT, N_DEVICE, str_to_wstr(conf.Port[0])); SaveSetting(nullptr, 1, N_DEVICE_PORT, N_DEVICE, str_to_wstr(conf.Port[1])); +#else + SaveSetting(nullptr, 0, N_DEVICE_PORT, N_DEVICE, conf.Port[0]); + SaveSetting(nullptr, 1, N_DEVICE_PORT, N_DEVICE, conf.Port[1]); +#endif SaveSetting(nullptr, 0, N_DEVICE_PORT, N_WHEEL_TYPE, conf.WheelType[0]); SaveSetting(nullptr, 1, N_DEVICE_PORT, N_WHEEL_TYPE, conf.WheelType[1]); for (auto& k : changedAPIs) { +#ifdef _WIN32 SaveSetting(nullptr, k.first.first, k.first.second, N_DEVICE_API, str_to_wstr(k.second)); +#else + SaveSetting(nullptr, k.first.first, k.first.second, N_DEVICE_API, k.second); +#endif } #ifdef _WIN32 @@ -169,8 +178,13 @@ void LoadConfig() LoadSetting("MAIN", "log", conf.Log); #endif +#ifdef _WIN32 LoadSetting(nullptr, 0, N_DEVICE_PORT, N_DEVICE, str_to_wstr(conf.Port[0])); LoadSetting(nullptr, 1, N_DEVICE_PORT, N_DEVICE, str_to_wstr(conf.Port[1])); +#else + LoadSetting(nullptr, 0, N_DEVICE_PORT, N_DEVICE, conf.Port[0]); + LoadSetting(nullptr, 1, N_DEVICE_PORT, N_DEVICE, conf.Port[1]); +#endif LoadSetting(nullptr, 0, N_DEVICE_PORT, N_WHEEL_TYPE, conf.WheelType[0]); LoadSetting(nullptr, 1, N_DEVICE_PORT, N_WHEEL_TYPE, conf.WheelType[1]); @@ -180,7 +194,11 @@ void LoadConfig() for (int i = 0; i < 2; i++) { std::string api; +#ifdef _WIN32 LoadSetting(nullptr, i, conf.Port[i], N_DEVICE_API, str_to_wstr(api)); +#else + LoadSetting(nullptr, i, conf.Port[i], N_DEVICE_API, api); +#endif auto dev = instance.Device(conf.Port[i]); if (dev) diff --git a/pcsx2/USB/usb-eyetoy/usb-eyetoy-webcam.cpp b/pcsx2/USB/usb-eyetoy/usb-eyetoy-webcam.cpp index 7153368da6..355944b309 100644 --- a/pcsx2/USB/usb-eyetoy/usb-eyetoy-webcam.cpp +++ b/pcsx2/USB/usb-eyetoy/usb-eyetoy-webcam.cpp @@ -516,7 +516,11 @@ namespace usb_eyetoy { VideoDevice* videodev = nullptr; std::string varApi; +#ifdef _WIN32 LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, str_to_wstr(varApi)); +#else + LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, varApi); +#endif VideoDeviceProxyBase* proxy = RegisterVideoDevice::instance().Proxy(varApi); if (!proxy) { diff --git a/pcsx2/USB/usb-hid/usb-hid.cpp b/pcsx2/USB/usb-hid/usb-hid.cpp index 18f22f9e68..e65c7501c4 100644 --- a/pcsx2/USB/usb-hid/usb-hid.cpp +++ b/pcsx2/USB/usb-hid/usb-hid.cpp @@ -730,7 +730,11 @@ namespace usb_hid UsbHIDState* s; std::string varApi; +#ifdef _WIN32 LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, str_to_wstr(varApi)); +#else + LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, varApi); +#endif UsbHIDProxyBase* proxy = RegisterUsbHID::instance().Proxy(varApi); if (!proxy) { @@ -821,7 +825,11 @@ namespace usb_hid UsbHIDState* s; std::string varApi; +#ifdef _WIN32 LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, str_to_wstr(varApi)); +#else + LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, varApi); +#endif UsbHIDProxyBase* proxy = RegisterUsbHID::instance().Proxy(varApi); if (!proxy) { @@ -893,7 +901,11 @@ namespace usb_hid UsbHIDState* s; std::string varApi; +#ifdef _WIN32 LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, str_to_wstr(varApi)); +#else + LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, varApi); +#endif UsbHIDProxyBase* proxy = RegisterUsbHID::instance().Proxy(varApi); if (!proxy) { diff --git a/pcsx2/USB/usb-mic/usb-headset.cpp b/pcsx2/USB/usb-mic/usb-headset.cpp index 1c364d46a8..f667840f82 100644 --- a/pcsx2/USB/usb-mic/usb-headset.cpp +++ b/pcsx2/USB/usb-mic/usb-headset.cpp @@ -986,7 +986,11 @@ namespace usb_mic USBDevice* HeadsetDevice::CreateDevice(int port) { std::string api; +#ifdef _WIN32 if (!LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, str_to_wstr(api))) +#else + if (!LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, api)) +#endif return nullptr; return HeadsetDevice::CreateDevice(port, api); } diff --git a/pcsx2/USB/usb-mic/usb-mic-logitech.cpp b/pcsx2/USB/usb-mic/usb-mic-logitech.cpp index 655580354a..1e16a353c0 100644 --- a/pcsx2/USB/usb-mic/usb-mic-logitech.cpp +++ b/pcsx2/USB/usb-mic/usb-mic-logitech.cpp @@ -243,7 +243,11 @@ namespace usb_mic USBDevice* LogitechMicDevice::CreateDevice(int port) { std::string api; +#ifdef _WIN32 if (!LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, str_to_wstr(api))) +#else + if (!LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, api)) +#endif return nullptr; USBDevice* dev = SingstarDevice::CreateDevice(port, api); diff --git a/pcsx2/USB/usb-mic/usb-mic-singstar.cpp b/pcsx2/USB/usb-mic/usb-mic-singstar.cpp index 91b41421ae..29c9bff5cb 100644 --- a/pcsx2/USB/usb-mic/usb-mic-singstar.cpp +++ b/pcsx2/USB/usb-mic/usb-mic-singstar.cpp @@ -778,7 +778,11 @@ namespace usb_mic USBDevice* SingstarDevice::CreateDevice(int port) { std::string api; +#ifdef _WIN32 LoadSetting(nullptr, port, SingstarDevice::TypeName(), N_DEVICE_API, str_to_wstr(api)); +#else + LoadSetting(nullptr, port, SingstarDevice::TypeName(), N_DEVICE_API, api); +#endif return SingstarDevice::CreateDevice(port, api); } USBDevice* SingstarDevice::CreateDevice(int port, const std::string& api) diff --git a/pcsx2/USB/usb-pad/dx/dinput-config.cpp b/pcsx2/USB/usb-pad/dx/dinput-config.cpp index 77d9068dc5..9922d4739f 100644 --- a/pcsx2/USB/usb-pad/dx/dinput-config.cpp +++ b/pcsx2/USB/usb-pad/dx/dinput-config.cpp @@ -1228,7 +1228,11 @@ namespace usb_pad ClearSection(section); SaveSetting(section, _T("INVERTFORCES"), INVERTFORCES[port]); +#ifdef _WIN32 SaveSetting(section, _T("# CONTROL n"), str_to_wstr("GUID,MAPPING TYPE,MAPPED TO,INVERTED,HALF,LINEAR,OFFSET,DEADZONE")); +#else + SaveSetting(section, _T("# CONTROL n"), "GUID,MAPPING TYPE,MAPPED TO,INVERTED,HALF,LINEAR,OFFSET,DEADZONE"); +#endif for (auto& control : g_Controls[port]) { @@ -1250,7 +1254,11 @@ namespace usb_pad } swprintf_s(text, _T("CONTROL %i"), cid); +#ifdef _WIN32 SaveSetting(section, text, str_to_wstr(ss.str())); +#else + SaveSetting(section, text, ss.str()); +#endif } SaveSetting(section, _T("GAINZ"), GAINZ[port][0]); @@ -1285,7 +1293,11 @@ namespace usb_pad std::stringstream ss; swprintf_s(text, _T("CONTROL %i"), cid); +#ifdef _WIN32 if (!LoadSetting(section, text, str_to_wstr(control))) +#else + if (!LoadSetting(section, text, control)) +#endif continue; ss << control; diff --git a/pcsx2/USB/usb-pad/usb-pad.cpp b/pcsx2/USB/usb-pad/usb-pad.cpp index 221bd62481..72e752af24 100644 --- a/pcsx2/USB/usb-pad/usb-pad.cpp +++ b/pcsx2/USB/usb-pad/usb-pad.cpp @@ -539,7 +539,11 @@ namespace usb_pad USBDevice* PadDevice::CreateDevice(int port) { std::string varApi; +#ifdef _WIN32 LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, str_to_wstr(varApi)); +#else + LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, varApi); +#endif PadProxyBase* proxy = RegisterPad::instance().Proxy(varApi); if (!proxy) { @@ -663,7 +667,11 @@ namespace usb_pad USBDevice* RBDrumKitDevice::CreateDevice(int port) { std::string varApi; +#ifdef _WIN32 LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, str_to_wstr(varApi)); +#else + LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, varApi); +#endif PadProxyBase* proxy = RegisterPad::instance().Proxy(varApi); if (!proxy) { @@ -732,7 +740,11 @@ namespace usb_pad USBDevice* BuzzDevice::CreateDevice(int port) { std::string varApi; +#ifdef _WIN32 LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, str_to_wstr(varApi)); +#else + LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, varApi); +#endif PadProxyBase* proxy = RegisterPad::instance().Proxy(varApi); if (!proxy) { diff --git a/pcsx2/USB/usb-pad/usb-seamic.cpp b/pcsx2/USB/usb-pad/usb-seamic.cpp index 1c90854053..8c0ad13601 100644 --- a/pcsx2/USB/usb-pad/usb-seamic.cpp +++ b/pcsx2/USB/usb-pad/usb-seamic.cpp @@ -392,7 +392,11 @@ namespace usb_pad USBDevice* SeamicDevice::CreateDevice(int port) { std::string varApi; +#ifdef _WIN32 LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, str_to_wstr(varApi)); +#else + LoadSetting(nullptr, port, TypeName(), N_DEVICE_API, varApi); +#endif PadProxyBase* proxy = RegisterPad::instance().Proxy(varApi); if (!proxy) { @@ -401,10 +405,16 @@ namespace usb_pad return NULL; } - USB_LOG("usb-pad: creating device '%s' on port %d with %s\n", TypeName(), port, str_to_wstr(varApi)); - std::string api; + + +#ifdef _WIN32 + USB_LOG("usb-pad: creating device '%s' on port %d with %s\n", TypeName(), port, str_to_wstr(varApi)); if (!LoadSetting(nullptr, port, usb_mic::SingstarDevice::TypeName(), N_DEVICE_API, str_to_wstr(api))) +#else + USB_LOG("usb-pad: creating device '%s' on port %d with %s\n", TypeName(), port, varApi.c_str()); + if (!LoadSetting(nullptr, port, usb_mic::SingstarDevice::TypeName(), N_DEVICE_API, api)) +#endif return nullptr; USBDevice* mic = usb_mic::SingstarDevice::CreateDevice(port, api);