From 49b9c723e23d89140fcc45662b6b0079eed33010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Wed, 18 Jan 2017 20:27:51 +0100 Subject: [PATCH] Put IOS devices in a namespace and drop WII_IPC_HLE prefix --- Source/Core/Core/HW/DVDInterface.cpp | 4 +- Source/Core/Core/HW/ProcessorInterface.cpp | 10 +- Source/Core/Core/HW/SystemTimers.cpp | 4 +- Source/Core/Core/IOS/DI/DI.cpp | 26 ++- Source/Core/Core/IOS/DI/DI.h | 9 +- Source/Core/Core/IOS/Device.cpp | 20 +- Source/Core/Core/IOS/Device.h | 13 +- Source/Core/Core/IOS/DeviceStub.cpp | 14 +- Source/Core/Core/IOS/DeviceStub.h | 7 +- Source/Core/Core/IOS/ES/ES.cpp | 39 ++-- Source/Core/Core/IOS/ES/ES.h | 7 +- Source/Core/Core/IOS/FS/FS.cpp | 22 +- Source/Core/Core/IOS/FS/FS.h | 7 +- Source/Core/Core/IOS/FS/FileIO.cpp | 28 +-- Source/Core/Core/IOS/FS/FileIO.h | 7 +- Source/Core/Core/IOS/IPC.cpp | 91 +++++---- Source/Core/Core/IOS/IPC.h | 10 +- Source/Core/Core/IOS/Network/Net.cpp | 54 ++--- Source/Core/Core/IOS/Network/Net.h | 114 +++++------ Source/Core/Core/IOS/Network/SSL.cpp | 17 +- Source/Core/Core/IOS/Network/SSL.h | 12 +- Source/Core/Core/IOS/Network/Socket.cpp | 6 +- Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp | 27 ++- Source/Core/Core/IOS/SDIO/SDIOSlot0.h | 7 +- Source/Core/Core/IOS/STM/STM.cpp | 20 +- Source/Core/Core/IOS/STM/STM.h | 19 +- Source/Core/Core/IOS/USB/Bluetooth/BTBase.cpp | 12 +- Source/Core/Core/IOS/USB/Bluetooth/BTBase.h | 11 +- Source/Core/Core/IOS/USB/Bluetooth/BTEmu.cpp | 188 +++++++++--------- Source/Core/Core/IOS/USB/Bluetooth/BTEmu.h | 20 +- Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp | 61 +++--- Source/Core/Core/IOS/USB/Bluetooth/BTReal.h | 15 +- Source/Core/Core/IOS/USB/Bluetooth/BTStub.cpp | 7 +- Source/Core/Core/IOS/USB/Bluetooth/BTStub.h | 10 +- .../Core/IOS/USB/Bluetooth/WiimoteDevice.cpp | 67 +++---- .../Core/IOS/USB/Bluetooth/WiimoteDevice.h | 17 +- Source/Core/Core/IOS/USB/USB_HIDv4.cpp | 43 ++-- Source/Core/Core/IOS/USB/USB_HIDv4.h | 11 +- Source/Core/Core/IOS/USB/USB_KBD.cpp | 27 +-- Source/Core/Core/IOS/USB/USB_KBD.h | 7 +- Source/Core/Core/IOS/USB/USB_VEN.cpp | 11 +- Source/Core/Core/IOS/USB/USB_VEN.h | 7 +- Source/Core/Core/IOS/WFS/WFSI.cpp | 8 +- Source/Core/Core/IOS/WFS/WFSI.h | 7 +- Source/Core/Core/IOS/WFS/WFSSRV.cpp | 18 +- Source/Core/Core/IOS/WFS/WFSSRV.h | 7 +- Source/Core/Core/Movie.cpp | 2 +- .../Core/DolphinWX/ControllerConfigDiag.cpp | 5 +- Source/Core/DolphinWX/Frame.cpp | 4 +- Source/Core/DolphinWX/FrameTools.cpp | 6 +- Source/Core/DolphinWX/MainNoGUI.cpp | 3 +- 51 files changed, 598 insertions(+), 570 deletions(-) diff --git a/Source/Core/Core/HW/DVDInterface.cpp b/Source/Core/Core/HW/DVDInterface.cpp index 355f04ab27..c8fb97d8e1 100644 --- a/Source/Core/Core/HW/DVDInterface.cpp +++ b/Source/Core/Core/HW/DVDInterface.cpp @@ -1155,9 +1155,9 @@ void FinishExecutingCommand(ReplyType reply_type, DIInterruptType interrupt_type case ReplyType::IOS_HLE: { - std::shared_ptr di = IOS::HLE::GetDeviceByName("/dev/di"); + auto di = IOS::HLE::GetDeviceByName("/dev/di"); if (di) - std::static_pointer_cast(di)->FinishIOCtl(interrupt_type); + std::static_pointer_cast(di)->FinishIOCtl(interrupt_type); break; } diff --git a/Source/Core/Core/HW/ProcessorInterface.cpp b/Source/Core/Core/HW/ProcessorInterface.cpp index f7925d30e3..47535938fc 100644 --- a/Source/Core/Core/HW/ProcessorInterface.cpp +++ b/Source/Core/Core/HW/ProcessorInterface.cpp @@ -212,10 +212,9 @@ static void IOSNotifyResetButtonCallback(u64 userdata, s64 cyclesLate) { if (SConfig::GetInstance().bWii) { - std::shared_ptr stm = - IOS::HLE::GetDeviceByName("/dev/stm/eventhook"); + auto stm = IOS::HLE::GetDeviceByName("/dev/stm/eventhook"); if (stm) - std::static_pointer_cast(stm)->ResetButton(); + std::static_pointer_cast(stm)->ResetButton(); } } @@ -223,10 +222,9 @@ static void IOSNotifyPowerButtonCallback(u64 userdata, s64 cyclesLate) { if (SConfig::GetInstance().bWii) { - std::shared_ptr stm = - IOS::HLE::GetDeviceByName("/dev/stm/eventhook"); + auto stm = IOS::HLE::GetDeviceByName("/dev/stm/eventhook"); if (stm) - std::static_pointer_cast(stm)->PowerButton(); + std::static_pointer_cast(stm)->PowerButton(); } } diff --git a/Source/Core/Core/HW/SystemTimers.cpp b/Source/Core/Core/HW/SystemTimers.cpp index 45e5f010d0..fcd269e199 100644 --- a/Source/Core/Core/HW/SystemTimers.cpp +++ b/Source/Core/Core/HW/SystemTimers.cpp @@ -34,13 +34,13 @@ IPC_HLE_PERIOD: For the Wii Remote this is the call schedule: // If the AclFrameQue is empty this will call Wiimote_Update() and make it send the current input status to the game. I'm not sure if this occurs approximately once every frame or if the frequency is not exactly tied to rendered frames - CWII_IPC_HLE_Device_usb_oh1_57e_305::Update() + IOS::HLE::Device::BluetoothEmu::Update() PluginWiimote::Wiimote_Update() // This is also a device updated by IOS::HLE::Update() but it doesn't seem to ultimately call PluginWiimote::Wiimote_Update(). However it can be called by the /dev/usb/oh1 device if the AclFrameQue is empty. - CWII_IPC_HLE_WiiMote::Update() + IOS::HLE::WiimoteDevice::Update() */ #include "Core/HW/SystemTimers.h" diff --git a/Source/Core/Core/IOS/DI/DI.cpp b/Source/Core/Core/IOS/DI/DI.cpp index 5706661bfd..a13c7a6dea 100644 --- a/Source/Core/Core/IOS/DI/DI.cpp +++ b/Source/Core/Core/IOS/DI/DI.cpp @@ -21,22 +21,19 @@ namespace IOS { namespace HLE { -CWII_IPC_HLE_Device_di::CWII_IPC_HLE_Device_di(u32 _DeviceID, const std::string& _rDeviceName) - : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) +namespace Device +{ +DI::DI(u32 device_id, const std::string& device_name) : Device(device_id, device_name) { } -CWII_IPC_HLE_Device_di::~CWII_IPC_HLE_Device_di() -{ -} - -void CWII_IPC_HLE_Device_di::DoState(PointerWrap& p) +void DI::DoState(PointerWrap& p) { DoStateShared(p); p.Do(m_commands_to_execute); } -IPCCommandResult CWII_IPC_HLE_Device_di::IOCtl(const IOSIOCtlRequest& request) +IPCCommandResult DI::IOCtl(const IOSIOCtlRequest& request) { // DI IOCtls are handled in a special way by Dolphin // compared to other WII_IPC_HLE functions. @@ -50,12 +47,12 @@ IPCCommandResult CWII_IPC_HLE_Device_di::IOCtl(const IOSIOCtlRequest& request) if (ready_to_execute) StartIOCtl(request); - // DVDInterface handles the timing and we handle the reply, - // so WII_IPC_HLE shouldn't handle anything. + // DVDInterface handles the timing and will call FinishIOCtl after the command + // has been executed to reply to the request, so we shouldn't reply here. return GetNoReply(); } -void CWII_IPC_HLE_Device_di::StartIOCtl(const IOSIOCtlRequest& request) +void DI::StartIOCtl(const IOSIOCtlRequest& request) { const u32 command_0 = Memory::Read_U32(request.buffer_in); const u32 command_1 = Memory::Read_U32(request.buffer_in + 4); @@ -67,11 +64,11 @@ void CWII_IPC_HLE_Device_di::StartIOCtl(const IOSIOCtlRequest& request) request.buffer_out_size, true); } -void CWII_IPC_HLE_Device_di::FinishIOCtl(DVDInterface::DIInterruptType interrupt_type) +void DI::FinishIOCtl(DVDInterface::DIInterruptType interrupt_type) { if (m_commands_to_execute.empty()) { - PanicAlert("WII_IPC_HLE_Device_DI: There is no command to execute!"); + PanicAlert("IOS::HLE::Device::DI: There is no command to execute!"); return; } @@ -89,7 +86,7 @@ void CWII_IPC_HLE_Device_di::FinishIOCtl(DVDInterface::DIInterruptType interrupt } } -IPCCommandResult CWII_IPC_HLE_Device_di::IOCtlV(const IOSIOCtlVRequest& request) +IPCCommandResult DI::IOCtlV(const IOSIOCtlVRequest& request) { for (const auto& vector : request.io_vectors) Memory::Memset(vector.address, 0, vector.size); @@ -121,5 +118,6 @@ IPCCommandResult CWII_IPC_HLE_Device_di::IOCtlV(const IOSIOCtlVRequest& request) } return GetDefaultReply(return_value); } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/DI/DI.h b/Source/Core/Core/IOS/DI/DI.h index fa56c9fb2e..489ebfcbee 100644 --- a/Source/Core/Core/IOS/DI/DI.h +++ b/Source/Core/Core/IOS/DI/DI.h @@ -22,12 +22,12 @@ namespace IOS { namespace HLE { -class CWII_IPC_HLE_Device_di : public IWII_IPC_HLE_Device +namespace Device +{ +class DI : public Device { public: - CWII_IPC_HLE_Device_di(u32 _DeviceID, const std::string& _rDeviceName); - - virtual ~CWII_IPC_HLE_Device_di(); + DI(u32 device_id, const std::string& device_name); void DoState(PointerWrap& p) override; @@ -41,5 +41,6 @@ private: std::deque m_commands_to_execute; }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/Device.cpp b/Source/Core/Core/IOS/Device.cpp index cdaf14f20a..f8b87ef7fd 100644 --- a/Source/Core/Core/IOS/Device.cpp +++ b/Source/Core/Core/IOS/Device.cpp @@ -121,19 +121,20 @@ void IOSIOCtlVRequest::DumpUnknown(const std::string& description, LogTypes::LOG Dump("Unknown IOCtlV - " + description, type, level); } -IWII_IPC_HLE_Device::IWII_IPC_HLE_Device(const u32 device_id, const std::string& device_name, - const DeviceType type) +namespace Device +{ +Device::Device(const u32 device_id, const std::string& device_name, const DeviceType type) : m_name(device_name), m_device_id(device_id), m_device_type(type) { } -void IWII_IPC_HLE_Device::DoState(PointerWrap& p) +void Device::DoState(PointerWrap& p) { DoStateShared(p); p.Do(m_is_active); } -void IWII_IPC_HLE_Device::DoStateShared(PointerWrap& p) +void Device::DoStateShared(PointerWrap& p) { p.Do(m_name); p.Do(m_device_id); @@ -141,18 +142,18 @@ void IWII_IPC_HLE_Device::DoStateShared(PointerWrap& p) p.Do(m_is_active); } -IOSReturnCode IWII_IPC_HLE_Device::Open(const IOSOpenRequest& request) +IOSReturnCode Device::Open(const IOSOpenRequest& request) { m_is_active = true; return IPC_SUCCESS; } -void IWII_IPC_HLE_Device::Close() +void Device::Close() { m_is_active = false; } -IPCCommandResult IWII_IPC_HLE_Device::Unsupported(const IOSRequest& request) +IPCCommandResult Device::Unsupported(const IOSRequest& request) { static std::map names = {{{IPC_CMD_READ, "Read"}, {IPC_CMD_WRITE, "Write"}, @@ -164,16 +165,17 @@ IPCCommandResult IWII_IPC_HLE_Device::Unsupported(const IOSRequest& request) } // Returns an IPCCommandResult for a reply that takes 250 us (arbitrarily chosen value) -IPCCommandResult IWII_IPC_HLE_Device::GetDefaultReply(const s32 return_value) +IPCCommandResult Device::GetDefaultReply(const s32 return_value) { return {return_value, true, SystemTimers::GetTicksPerSecond() / 4000}; } // Returns an IPCCommandResult with no reply. Useful for async commands that will generate a reply // later. This takes no return value because it won't be used. -IPCCommandResult IWII_IPC_HLE_Device::GetNoReply() +IPCCommandResult Device::GetNoReply() { return {IPC_SUCCESS, false, 0}; } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/Device.h b/Source/Core/Core/IOS/Device.h index 441f9081cb..7765da1a7e 100644 --- a/Source/Core/Core/IOS/Device.h +++ b/Source/Core/Core/IOS/Device.h @@ -128,7 +128,9 @@ struct IOSIOCtlVRequest final : IOSRequest LogTypes::LOG_LEVELS level = LogTypes::LERROR) const; }; -class IWII_IPC_HLE_Device +namespace Device +{ +class Device { public: enum class DeviceType : u32 @@ -137,10 +139,9 @@ public: FileIO, // FileIO devices which are created dynamically. }; - IWII_IPC_HLE_Device(u32 device_id, const std::string& device_name, - DeviceType type = DeviceType::Static); + Device(u32 device_id, const std::string& device_name, DeviceType type = DeviceType::Static); - virtual ~IWII_IPC_HLE_Device() = default; + virtual ~Device() = default; // Release any resources which might interfere with savestating. virtual void PrepareForState(PointerWrap::Mode mode) {} virtual void DoState(PointerWrap& p); @@ -148,7 +149,8 @@ public: const std::string& GetDeviceName() const { return m_name; } u32 GetDeviceID() const { return m_device_id; } - // Replies to Open and Close requests are sent by WII_IPC_HLE, not by the devices themselves. + // Replies to Open and Close requests are sent by the IPC request handler (HandleCommand), + // not by the devices themselves. virtual IOSReturnCode Open(const IOSOpenRequest& request); virtual void Close(); virtual IPCCommandResult Seek(const IOSSeekRequest& seek) { return Unsupported(seek); } @@ -172,5 +174,6 @@ protected: private: IPCCommandResult Unsupported(const IOSRequest& request); }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/DeviceStub.cpp b/Source/Core/Core/IOS/DeviceStub.cpp index 7136c5683d..5fb763553d 100644 --- a/Source/Core/Core/IOS/DeviceStub.cpp +++ b/Source/Core/Core/IOS/DeviceStub.cpp @@ -9,34 +9,36 @@ namespace IOS { namespace HLE { -CWII_IPC_HLE_Device_stub::CWII_IPC_HLE_Device_stub(u32 device_id, const std::string& device_name) - : IWII_IPC_HLE_Device(device_id, device_name) +namespace Device +{ +Stub::Stub(u32 device_id, const std::string& device_name) : Device(device_id, device_name) { } -IOSReturnCode CWII_IPC_HLE_Device_stub::Open(const IOSOpenRequest& request) +IOSReturnCode Stub::Open(const IOSOpenRequest& request) { WARN_LOG(WII_IPC_HLE, "%s faking Open()", m_name.c_str()); m_is_active = true; return IPC_SUCCESS; } -void CWII_IPC_HLE_Device_stub::Close() +void Stub::Close() { WARN_LOG(WII_IPC_HLE, "%s faking Close()", m_name.c_str()); m_is_active = false; } -IPCCommandResult CWII_IPC_HLE_Device_stub::IOCtl(const IOSIOCtlRequest& request) +IPCCommandResult Stub::IOCtl(const IOSIOCtlRequest& request) { WARN_LOG(WII_IPC_HLE, "%s faking IOCtl()", m_name.c_str()); return GetDefaultReply(IPC_SUCCESS); } -IPCCommandResult CWII_IPC_HLE_Device_stub::IOCtlV(const IOSIOCtlVRequest& request) +IPCCommandResult Stub::IOCtlV(const IOSIOCtlVRequest& request) { WARN_LOG(WII_IPC_HLE, "%s faking IOCtlV()", m_name.c_str()); return GetDefaultReply(IPC_SUCCESS); } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/DeviceStub.h b/Source/Core/Core/IOS/DeviceStub.h index 15cacc8cdb..672432c43c 100644 --- a/Source/Core/Core/IOS/DeviceStub.h +++ b/Source/Core/Core/IOS/DeviceStub.h @@ -14,15 +14,18 @@ namespace IOS { namespace HLE { -class CWII_IPC_HLE_Device_stub : public IWII_IPC_HLE_Device +namespace Device +{ +class Stub final : public Device { public: - CWII_IPC_HLE_Device_stub(u32 device_id, const std::string& device_name); + Stub(u32 device_id, const std::string& device_name); IOSReturnCode Open(const IOSOpenRequest& request) override; void Close() override; IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override; IPCCommandResult IOCtlV(const IOSIOCtlVRequest& request) override; }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/ES/ES.cpp b/Source/Core/Core/IOS/ES/ES.cpp index a8dc23fd52..4c6db1f154 100644 --- a/Source/Core/Core/IOS/ES/ES.cpp +++ b/Source/Core/Core/IOS/ES/ES.cpp @@ -71,10 +71,11 @@ namespace IOS { namespace HLE { -std::string CWII_IPC_HLE_Device_es::m_ContentFile; +namespace Device +{ +std::string ES::m_ContentFile; -CWII_IPC_HLE_Device_es::CWII_IPC_HLE_Device_es(u32 device_id, const std::string& device_name) - : IWII_IPC_HLE_Device(device_id, device_name) +ES::ES(u32 device_id, const std::string& device_name) : Device(device_id, device_name) { } @@ -87,7 +88,7 @@ static u8 key_empty[0x10] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // default key table -u8* CWII_IPC_HLE_Device_es::keyTable[11] = { +u8* ES::keyTable[11] = { key_ecc, // ECC Private Key key_empty, // Console ID key_empty, // NAND AES Key @@ -101,13 +102,12 @@ u8* CWII_IPC_HLE_Device_es::keyTable[11] = { key_empty, // Unknown }; -void CWII_IPC_HLE_Device_es::LoadWAD(const std::string& _rContentFile) +void ES::LoadWAD(const std::string& _rContentFile) { m_ContentFile = _rContentFile; } -void CWII_IPC_HLE_Device_es::DecryptContent(u32 key_index, u8* iv, u8* input, u32 size, u8* new_iv, - u8* output) +void ES::DecryptContent(u32 key_index, u8* iv, u8* input, u32 size, u8* new_iv, u8* output) { mbedtls_aes_context AES_ctx; mbedtls_aes_setkey_dec(&AES_ctx, keyTable[key_index], 128); @@ -115,7 +115,7 @@ void CWII_IPC_HLE_Device_es::DecryptContent(u32 key_index, u8* iv, u8* input, u3 mbedtls_aes_crypt_cbc(&AES_ctx, MBEDTLS_AES_DECRYPT, size, new_iv, input, output); } -void CWII_IPC_HLE_Device_es::OpenInternal() +void ES::OpenInternal() { auto& contentLoader = DiscIO::CNANDContentManager::Access().GetNANDLoader(m_ContentFile); @@ -144,9 +144,9 @@ void CWII_IPC_HLE_Device_es::OpenInternal() INFO_LOG(WII_IPC_ES, "Set default title to %08x/%08x", (u32)(m_TitleID >> 32), (u32)m_TitleID); } -void CWII_IPC_HLE_Device_es::DoState(PointerWrap& p) +void ES::DoState(PointerWrap& p) { - IWII_IPC_HLE_Device::DoState(p); + Device::DoState(p); p.Do(m_ContentFile); OpenInternal(); p.Do(m_AccessIdentID); @@ -195,16 +195,16 @@ void CWII_IPC_HLE_Device_es::DoState(PointerWrap& p) } } -IOSReturnCode CWII_IPC_HLE_Device_es::Open(const IOSOpenRequest& request) +IOSReturnCode ES::Open(const IOSOpenRequest& request) { OpenInternal(); if (m_is_active) INFO_LOG(WII_IPC_ES, "Device was re-opened."); - return IWII_IPC_HLE_Device::Open(request); + return Device::Open(request); } -void CWII_IPC_HLE_Device_es::Close() +void ES::Close() { m_ContentAccessMap.clear(); m_TitleIDs.clear(); @@ -217,7 +217,7 @@ void CWII_IPC_HLE_Device_es::Close() DiscIO::CNANDContentManager::Access().ClearCache(); } -u32 CWII_IPC_HLE_Device_es::OpenTitleContent(u32 CFD, u64 TitleID, u16 Index) +u32 ES::OpenTitleContent(u32 CFD, u64 TitleID, u16 Index) { const DiscIO::CNANDContentLoader& Loader = AccessContentDevice(TitleID); @@ -246,7 +246,7 @@ u32 CWII_IPC_HLE_Device_es::OpenTitleContent(u32 CFD, u64 TitleID, u16 Index) return CFD; } -IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) +IPCCommandResult ES::IOCtlV(const IOSIOCtlVRequest& request) { DEBUG_LOG(WII_IPC_ES, "%s (0x%x)", GetDeviceName().c_str(), request.request); // Clear the IO buffers. Note that this is unsafe for other ioctlvs. @@ -1113,7 +1113,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) bool* wiiMoteConnected = new bool[MAX_BBMOTES]; if (!SConfig::GetInstance().m_bt_passthrough_enabled) { - CWII_IPC_HLE_Device_usb_oh1_57e_305_emu* s_Usb = GetUsbPointer(); + BluetoothEmu* s_Usb = GetUsbPointer(); for (unsigned int i = 0; i < MAX_BBMOTES; i++) wiiMoteConnected[i] = s_Usb->m_WiiMotes[i].IsConnected(); } @@ -1123,7 +1123,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) if (!SConfig::GetInstance().m_bt_passthrough_enabled) { - CWII_IPC_HLE_Device_usb_oh1_57e_305_emu* s_Usb = GetUsbPointer(); + BluetoothEmu* s_Usb = GetUsbPointer(); for (unsigned int i = 0; i < MAX_BBMOTES; i++) { if (wiiMoteConnected[i]) @@ -1237,7 +1237,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) return GetDefaultReply(IPC_SUCCESS); } -const DiscIO::CNANDContentLoader& CWII_IPC_HLE_Device_es::AccessContentDevice(u64 title_id) +const DiscIO::CNANDContentLoader& ES::AccessContentDevice(u64 title_id) { // for WADs, the passed title id and the stored title id match; along with m_ContentFile being set // to the @@ -1251,7 +1251,7 @@ const DiscIO::CNANDContentLoader& CWII_IPC_HLE_Device_es::AccessContentDevice(u6 return DiscIO::CNANDContentManager::Access().GetNANDLoader(title_id, Common::FROM_SESSION_ROOT); } -u32 CWII_IPC_HLE_Device_es::ES_DIVerify(const std::vector& tmd) +u32 ES::ES_DIVerify(const std::vector& tmd) { u64 title_id = 0xDEADBEEFDEADBEEFull; u64 tmd_title_id = Common::swap64(&tmd[0x18C]); @@ -1323,5 +1323,6 @@ u32 CWII_IPC_HLE_Device_es::ES_DIVerify(const std::vector& tmd) DiscIO::CNANDContentManager::Access().ClearCache(); return 0; } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/ES/ES.h b/Source/Core/Core/IOS/ES/ES.h index df9cb41e48..1f2ccfe111 100644 --- a/Source/Core/Core/IOS/ES/ES.h +++ b/Source/Core/Core/IOS/ES/ES.h @@ -26,10 +26,12 @@ namespace IOS { namespace HLE { -class CWII_IPC_HLE_Device_es : public IWII_IPC_HLE_Device +namespace Device +{ +class ES : public Device { public: - CWII_IPC_HLE_Device_es(u32 _DeviceID, const std::string& _rDeviceName); + ES(u32 device_id, const std::string& device_name); void LoadWAD(const std::string& _rContentFile); @@ -166,5 +168,6 @@ private: u8 padding[0x3c]; }; }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/FS/FS.cpp b/Source/Core/Core/IOS/FS/FS.cpp index f2d862017b..4027e7a005 100644 --- a/Source/Core/Core/IOS/FS/FS.cpp +++ b/Source/Core/Core/IOS/FS/FS.cpp @@ -31,19 +31,20 @@ static bool IsValidWiiPath(const std::string& path) return path.compare(0, 1, "/") == 0; } -CWII_IPC_HLE_Device_fs::CWII_IPC_HLE_Device_fs(u32 _DeviceID, const std::string& _rDeviceName) - : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) +namespace Device +{ +FS::FS(u32 device_id, const std::string& device_name) : Device(device_id, device_name) { } // ~1/1000th of a second is too short and causes hangs in Wii Party // Play it safe at 1/500th -IPCCommandResult CWII_IPC_HLE_Device_fs::GetFSReply(const s32 return_value) const +IPCCommandResult FS::GetFSReply(const s32 return_value) const { return {return_value, true, SystemTimers::GetTicksPerSecond() / 500}; } -IOSReturnCode CWII_IPC_HLE_Device_fs::Open(const IOSOpenRequest& request) +IOSReturnCode FS::Open(const IOSOpenRequest& request) { // clear tmp folder { @@ -71,7 +72,7 @@ static u64 ComputeTotalFileSize(const File::FSTEntry& parentEntry) return sizeOfFiles; } -IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtlV(const IOSIOCtlVRequest& request) +IPCCommandResult FS::IOCtlV(const IOSIOCtlVRequest& request) { s32 return_value = IPC_SUCCESS; switch (request.request) @@ -231,14 +232,14 @@ IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtlV(const IOSIOCtlVRequest& request) return GetFSReply(return_value); } -IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtl(const IOSIOCtlRequest& request) +IPCCommandResult FS::IOCtl(const IOSIOCtlRequest& request) { Memory::Memset(request.buffer_out, 0, request.buffer_out_size); const s32 return_value = ExecuteCommand(request); return GetFSReply(return_value); } -s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(const IOSIOCtlRequest& request) +s32 FS::ExecuteCommand(const IOSIOCtlRequest& request) { switch (request.request) { @@ -522,8 +523,8 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(const IOSIOCtlRequest& request) bool Result = File::CreateEmptyFile(Filename); if (!Result) { - ERROR_LOG(WII_IPC_FILEIO, "CWII_IPC_HLE_Device_fs: couldn't create new file"); - PanicAlert("CWII_IPC_HLE_Device_fs: couldn't create new file"); + ERROR_LOG(WII_IPC_FILEIO, "FS: couldn't create new file"); + PanicAlert("FS: couldn't create new file"); return FS_EINVAL; } @@ -544,7 +545,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(const IOSIOCtlRequest& request) return FS_EINVAL; } -void CWII_IPC_HLE_Device_fs::DoState(PointerWrap& p) +void FS::DoState(PointerWrap& p) { DoStateShared(p); @@ -638,5 +639,6 @@ void CWII_IPC_HLE_Device_fs::DoState(PointerWrap& p) p.Do(type); } } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/FS/FS.h b/Source/Core/Core/IOS/FS/FS.h index ee2784b549..fb7bd8f0be 100644 --- a/Source/Core/Core/IOS/FS/FS.h +++ b/Source/Core/Core/IOS/FS/FS.h @@ -27,10 +27,12 @@ struct NANDStat u32 Used_Inodes; }; -class CWII_IPC_HLE_Device_fs : public IWII_IPC_HLE_Device +namespace Device +{ +class FS : public Device { public: - CWII_IPC_HLE_Device_fs(u32 _DeviceID, const std::string& _rDeviceName); + FS(u32 device_id, const std::string& device_name); void DoState(PointerWrap& p) override; @@ -56,5 +58,6 @@ private: IPCCommandResult GetFSReply(s32 return_value) const; s32 ExecuteCommand(const IOSIOCtlRequest& request); }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/FS/FileIO.cpp b/Source/Core/Core/IOS/FS/FileIO.cpp index 3a16fc1ce7..6956c1a3e7 100644 --- a/Source/Core/Core/IOS/FS/FileIO.cpp +++ b/Source/Core/Core/IOS/FS/FileIO.cpp @@ -69,13 +69,14 @@ void HLE_IPC_CreateVirtualFATFilesystem() } } -CWII_IPC_HLE_Device_FileIO::CWII_IPC_HLE_Device_FileIO(u32 device_id, - const std::string& device_name) - : IWII_IPC_HLE_Device(device_id, device_name, DeviceType::FileIO) +namespace Device +{ +FileIO::FileIO(u32 device_id, const std::string& device_name) + : Device(device_id, device_name, DeviceType::FileIO) { } -void CWII_IPC_HLE_Device_FileIO::Close() +void FileIO::Close() { INFO_LOG(WII_IPC_FILEIO, "FileIO: Close %s (DeviceID=%08x)", m_name.c_str(), m_device_id); m_Mode = 0; @@ -87,7 +88,7 @@ void CWII_IPC_HLE_Device_FileIO::Close() m_is_active = false; } -IOSReturnCode CWII_IPC_HLE_Device_FileIO::Open(const IOSOpenRequest& request) +IOSReturnCode FileIO::Open(const IOSOpenRequest& request) { m_Mode = request.flags; @@ -112,7 +113,7 @@ IOSReturnCode CWII_IPC_HLE_Device_FileIO::Open(const IOSOpenRequest& request) } // This isn't theadsafe, but it's only called from the CPU thread. -void CWII_IPC_HLE_Device_FileIO::OpenFile() +void FileIO::OpenFile() { // On the wii, all file operations are strongly ordered. // If a game opens the same file twice (or 8 times, looking at you PokePark Wii) @@ -155,7 +156,7 @@ void CWII_IPC_HLE_Device_FileIO::OpenFile() } } -IPCCommandResult CWII_IPC_HLE_Device_FileIO::Seek(const IOSSeekRequest& request) +IPCCommandResult FileIO::Seek(const IOSSeekRequest& request) { u32 return_value = FS_EINVAL; @@ -201,7 +202,7 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::Seek(const IOSSeekRequest& request) default: { - PanicAlert("CWII_IPC_HLE_Device_FileIO Unsupported seek mode %i", request.mode); + PanicAlert("FileIO Unsupported seek mode %i", request.mode); return_value = FS_EINVAL; break; } @@ -214,7 +215,7 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::Seek(const IOSSeekRequest& request) return GetDefaultReply(return_value); } -IPCCommandResult CWII_IPC_HLE_Device_FileIO::Read(const IOSReadWriteRequest& request) +IPCCommandResult FileIO::Read(const IOSReadWriteRequest& request) { s32 return_value = FS_EACCESS; if (m_file->IsOpen()) @@ -253,7 +254,7 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::Read(const IOSReadWriteRequest& req return GetDefaultReply(return_value); } -IPCCommandResult CWII_IPC_HLE_Device_FileIO::Write(const IOSReadWriteRequest& request) +IPCCommandResult FileIO::Write(const IOSReadWriteRequest& request) { s32 return_value = FS_EACCESS; if (m_file->IsOpen()) @@ -288,7 +289,7 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::Write(const IOSReadWriteRequest& re return GetDefaultReply(return_value); } -IPCCommandResult CWII_IPC_HLE_Device_FileIO::IOCtl(const IOSIOCtlRequest& request) +IPCCommandResult FileIO::IOCtl(const IOSIOCtlRequest& request) { DEBUG_LOG(WII_IPC_FILEIO, "FileIO: IOCtl (Device=%s)", m_name.c_str()); s32 return_value = IPC_SUCCESS; @@ -318,14 +319,14 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::IOCtl(const IOSIOCtlRequest& reques return GetDefaultReply(return_value); } -void CWII_IPC_HLE_Device_FileIO::PrepareForState(PointerWrap::Mode mode) +void FileIO::PrepareForState(PointerWrap::Mode mode) { // Temporally close the file, to prevent any issues with the savestating of /tmp // it can be opened again with another call to OpenFile() m_file.reset(); } -void CWII_IPC_HLE_Device_FileIO::DoState(PointerWrap& p) +void FileIO::DoState(PointerWrap& p) { DoStateShared(p); @@ -338,5 +339,6 @@ void CWII_IPC_HLE_Device_FileIO::DoState(PointerWrap& p) // Open it again OpenFile(); } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/FS/FileIO.h b/Source/Core/Core/IOS/FS/FileIO.h index 8f2751e97c..f0bb1927b3 100644 --- a/Source/Core/Core/IOS/FS/FileIO.h +++ b/Source/Core/Core/IOS/FS/FileIO.h @@ -25,10 +25,12 @@ namespace HLE std::string HLE_IPC_BuildFilename(const std::string& wii_path); void HLE_IPC_CreateVirtualFATFilesystem(); -class CWII_IPC_HLE_Device_FileIO : public IWII_IPC_HLE_Device +namespace Device +{ +class FileIO : public Device { public: - CWII_IPC_HLE_Device_FileIO(u32 _DeviceID, const std::string& _rDeviceName); + FileIO(u32 device_id, const std::string& device_name); void Close() override; IOSReturnCode Open(const IOSOpenRequest& request) override; @@ -74,5 +76,6 @@ private: std::string m_filepath; std::shared_ptr m_file; }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/IPC.cpp b/Source/Core/Core/IOS/IPC.cpp index 17c4ea9101..3396d5f094 100644 --- a/Source/Core/Core/IOS/IPC.cpp +++ b/Source/Core/Core/IOS/IPC.cpp @@ -64,14 +64,14 @@ namespace IOS { namespace HLE { -static std::map> s_device_map; +static std::map> s_device_map; static std::mutex s_device_map_mutex; // STATE_TO_SAVE constexpr u8 IPC_MAX_FDS = 0x18; constexpr u8 ES_MAX_COUNT = 3; -static std::shared_ptr s_fdmap[IPC_MAX_FDS]; -static std::shared_ptr s_es_handles[ES_MAX_COUNT]; +static std::shared_ptr s_fdmap[IPC_MAX_FDS]; +static std::shared_ptr s_es_handles[ES_MAX_COUNT]; using IPCMsgQueue = std::deque; static IPCMsgQueue s_request_queue; // ppc -> arm @@ -104,8 +104,7 @@ static void EnqueueEvent(u64 userdata, s64 cycles_late = 0) static void SDIO_EventNotify_CPUThread(u64 userdata, s64 cycles_late) { - auto device = - static_cast(GetDeviceByName("/dev/sdio/slot0").get()); + auto device = static_cast(GetDeviceByName("/dev/sdio/slot0").get()); if (device) device->EventNotify(); } @@ -116,7 +115,7 @@ template std::shared_ptr AddDevice(const char* device_name) { auto device = std::make_shared(num_devices, device_name); - _assert_(device->GetDeviceType() == IWII_IPC_HLE_Device::DeviceType::Static); + _assert_(device->GetDeviceType() == Device::Device::DeviceType::Static); s_device_map[num_devices] = device; num_devices++; return device; @@ -126,43 +125,43 @@ void Reinit() { std::lock_guard lock(s_device_map_mutex); _assert_msg_(WII_IPC_HLE, s_device_map.empty(), "Reinit called while already initialized"); - CWII_IPC_HLE_Device_es::m_ContentFile = ""; + Device::ES::m_ContentFile = ""; num_devices = 0; // Build hardware devices if (!SConfig::GetInstance().m_bt_passthrough_enabled) - AddDevice("/dev/usb/oh1/57e/305"); + AddDevice("/dev/usb/oh1/57e/305"); else - AddDevice("/dev/usb/oh1/57e/305"); + AddDevice("/dev/usb/oh1/57e/305"); - AddDevice("/dev/stm/immediate"); - AddDevice("/dev/stm/eventhook"); - AddDevice("/dev/fs"); + AddDevice("/dev/stm/immediate"); + AddDevice("/dev/stm/eventhook"); + AddDevice("/dev/fs"); // IOS allows two ES devices at a time for (auto& es_device : s_es_handles) - es_device = AddDevice("/dev/es"); + es_device = AddDevice("/dev/es"); - AddDevice("/dev/di"); - AddDevice("/dev/net/kd/request"); - AddDevice("/dev/net/kd/time"); - AddDevice("/dev/net/ncd/manage"); - AddDevice("/dev/net/wd/command"); - AddDevice("/dev/net/ip/top"); - AddDevice("/dev/net/ssl"); - AddDevice("/dev/usb/kbd"); - AddDevice("/dev/usb/ven"); - AddDevice("/dev/sdio/slot0"); - AddDevice("/dev/sdio/slot1"); + AddDevice("/dev/di"); + AddDevice("/dev/net/kd/request"); + AddDevice("/dev/net/kd/time"); + AddDevice("/dev/net/ncd/manage"); + AddDevice("/dev/net/wd/command"); + AddDevice("/dev/net/ip/top"); + AddDevice("/dev/net/ssl"); + AddDevice("/dev/usb/kbd"); + AddDevice("/dev/usb/ven"); + AddDevice("/dev/sdio/slot0"); + AddDevice("/dev/sdio/slot1"); #if defined(__LIBUSB__) - AddDevice("/dev/usb/hid"); + AddDevice("/dev/usb/hid"); #else - AddDevice("/dev/usb/hid"); + AddDevice("/dev/usb/hid"); #endif - AddDevice("/dev/usb/oh1"); - AddDevice("/dev/usb/wfssrv"); - AddDevice("/dev/wfsi"); + AddDevice("/dev/usb/oh1"); + AddDevice("/dev/usb/wfssrv"); + AddDevice("/dev/wfsi"); } void Init() @@ -212,7 +211,7 @@ void SetDefaultContentFile(const std::string& file_name) void ES_DIVerify(const std::vector& tmd) { - CWII_IPC_HLE_Device_es::ES_DIVerify(tmd); + Device::ES::ES_DIVerify(tmd); } void SDIO_EventNotify() @@ -236,7 +235,7 @@ static int GetFreeDeviceID() return -1; } -std::shared_ptr GetDeviceByName(const std::string& device_name) +std::shared_ptr GetDeviceByName(const std::string& device_name) { std::lock_guard lock(s_device_map_mutex); for (const auto& entry : s_device_map) @@ -250,7 +249,7 @@ std::shared_ptr GetDeviceByName(const std::string& device_n return nullptr; } -std::shared_ptr AccessDeviceByID(u32 id) +std::shared_ptr AccessDeviceByID(u32 id) { std::lock_guard lock(s_device_map_mutex); if (s_device_map.find(id) != s_device_map.end()) @@ -267,7 +266,7 @@ void DoState(PointerWrap& p) p.Do(s_reply_queue); p.Do(s_last_reply_time); - // We need to make sure all file handles are closed so WII_IPC_Devices_fs::DoState can + // We need to make sure all file handles are closed so IOS::HLE::Device::FS::DoState can // successfully save or re-create /tmp for (auto& descriptor : s_fdmap) { @@ -286,19 +285,19 @@ void DoState(PointerWrap& p) p.Do(exists); if (exists) { - auto device_type = IWII_IPC_HLE_Device::DeviceType::Static; + auto device_type = Device::Device::DeviceType::Static; p.Do(device_type); switch (device_type) { - case IWII_IPC_HLE_Device::DeviceType::Static: + case Device::Device::DeviceType::Static: { u32 device_id = 0; p.Do(device_id); s_fdmap[i] = AccessDeviceByID(device_id); break; } - case IWII_IPC_HLE_Device::DeviceType::FileIO: - s_fdmap[i] = std::make_shared(i, ""); + case Device::Device::DeviceType::FileIO: + s_fdmap[i] = std::make_shared(i, ""); s_fdmap[i]->DoState(p); break; } @@ -309,7 +308,7 @@ void DoState(PointerWrap& p) { const u32 handle_id = es_device->GetDeviceID(); p.Do(handle_id); - es_device = std::static_pointer_cast(AccessDeviceByID(handle_id)); + es_device = std::static_pointer_cast(AccessDeviceByID(handle_id)); } } else @@ -322,7 +321,7 @@ void DoState(PointerWrap& p) { auto device_type = descriptor->GetDeviceType(); p.Do(device_type); - if (device_type == IWII_IPC_HLE_Device::DeviceType::Static) + if (device_type == Device::Device::DeviceType::Static) { u32 hwId = descriptor->GetDeviceID(); p.Do(hwId); @@ -342,7 +341,7 @@ void DoState(PointerWrap& p) } } -static std::shared_ptr GetUnusedESDevice() +static std::shared_ptr GetUnusedESDevice() { const auto iterator = std::find_if(std::begin(s_es_handles), std::end(s_es_handles), [](const auto& es_device) { return !es_device->IsOpened(); }); @@ -360,7 +359,7 @@ static s32 OpenDevice(const IOSOpenRequest& request) return FS_EFDEXHAUSTED; } - std::shared_ptr device; + std::shared_ptr device; if (request.path == "/dev/es") { device = GetUnusedESDevice(); @@ -373,7 +372,7 @@ static s32 OpenDevice(const IOSOpenRequest& request) } else if (request.path.find('/') == 0) { - device = std::make_shared(new_fd, request.path); + device = std::make_shared(new_fd, request.path); } if (!device) @@ -395,19 +394,19 @@ static IPCCommandResult HandleCommand(const IOSRequest& request) { IOSOpenRequest open_request{request.address}; const s32 new_fd = OpenDevice(open_request); - return IWII_IPC_HLE_Device::GetDefaultReply(new_fd); + return Device::Device::GetDefaultReply(new_fd); } const auto device = (request.fd < IPC_MAX_FDS) ? s_fdmap[request.fd] : nullptr; if (!device) - return IWII_IPC_HLE_Device::GetDefaultReply(IPC_EINVAL); + return Device::Device::GetDefaultReply(IPC_EINVAL); switch (request.command) { case IPC_CMD_CLOSE: s_fdmap[request.fd].reset(); device->Close(); - return IWII_IPC_HLE_Device::GetDefaultReply(IPC_SUCCESS); + return Device::Device::GetDefaultReply(IPC_SUCCESS); case IPC_CMD_READ: return device->Read(IOSReadWriteRequest{request.address}); case IPC_CMD_WRITE: @@ -420,7 +419,7 @@ static IPCCommandResult HandleCommand(const IOSRequest& request) return device->IOCtlV(IOSIOCtlVRequest{request.address}); default: _assert_msg_(WII_IPC_HLE, false, "Unexpected command: %x", request.command); - return IWII_IPC_HLE_Device::GetDefaultReply(IPC_EINVAL); + return Device::Device::GetDefaultReply(IPC_EINVAL); } } diff --git a/Source/Core/Core/IOS/IPC.h b/Source/Core/Core/IOS/IPC.h index c18ab49189..366feda655 100644 --- a/Source/Core/Core/IOS/IPC.h +++ b/Source/Core/Core/IOS/IPC.h @@ -18,7 +18,11 @@ namespace IOS { namespace HLE { -class IWII_IPC_HLE_Device; +namespace Device +{ +class Device; +} + struct IOSRequest; struct IPCCommandResult @@ -62,8 +66,8 @@ void ES_DIVerify(const std::vector& tmd); void SDIO_EventNotify(); -std::shared_ptr GetDeviceByName(const std::string& device_name); -std::shared_ptr AccessDeviceByID(u32 id); +std::shared_ptr GetDeviceByName(const std::string& device_name); +std::shared_ptr AccessDeviceByID(u32 id); // Update void Update(); diff --git a/Source/Core/Core/IOS/Network/Net.cpp b/Source/Core/Core/IOS/Network/Net.cpp index d581374fb0..8eff10edee 100644 --- a/Source/Core/Core/IOS/Network/Net.cpp +++ b/Source/Core/Core/IOS/Network/Net.cpp @@ -63,20 +63,21 @@ namespace IOS { namespace HLE { +namespace Device +{ // ********************************************************************************** // Handle /dev/net/kd/request requests -CWII_IPC_HLE_Device_net_kd_request::CWII_IPC_HLE_Device_net_kd_request( - u32 _DeviceID, const std::string& _rDeviceName) - : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) +NetKDRequest::NetKDRequest(u32 device_id, const std::string& device_name) + : Device(device_id, device_name) { } -CWII_IPC_HLE_Device_net_kd_request::~CWII_IPC_HLE_Device_net_kd_request() +NetKDRequest::~NetKDRequest() { WiiSockMan::GetInstance().Clean(); } -IPCCommandResult CWII_IPC_HLE_Device_net_kd_request::IOCtl(const IOSIOCtlRequest& request) +IPCCommandResult NetKDRequest::IOCtl(const IOSIOCtlRequest& request) { s32 return_value = 0; switch (request.request) @@ -197,7 +198,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_kd_request::IOCtl(const IOSIOCtlRequest return GetDefaultReply(return_value); } -u8 CWII_IPC_HLE_Device_net_kd_request::GetAreaCode(const std::string& area) const +u8 NetKDRequest::GetAreaCode(const std::string& area) const { static std::map regions = { {"JPN", 0}, {"USA", 1}, {"EUR", 2}, {"AUS", 2}, {"BRA", 1}, {"TWN", 3}, {"ROC", 3}, @@ -211,7 +212,7 @@ u8 CWII_IPC_HLE_Device_net_kd_request::GetAreaCode(const std::string& area) cons return 7; // Unknown } -u8 CWII_IPC_HLE_Device_net_kd_request::GetHardwareModel(const std::string& model) const +u8 NetKDRequest::GetHardwareModel(const std::string& model) const { static std::map models = { {"RVL", MODEL_RVL}, {"RVT", MODEL_RVT}, {"RVV", MODEL_RVV}, {"RVD", MODEL_RVD}, @@ -236,8 +237,8 @@ static inline u64 u64_insert_byte(u64 value, u8 shift, u8 byte) return (value & ~mask) | inst; } -s32 CWII_IPC_HLE_Device_net_kd_request::NWC24MakeUserID(u64* nwc24_id, u32 hollywood_id, u16 id_ctr, - u8 hardware_model, u8 area_code) +s32 NetKDRequest::NWC24MakeUserID(u64* nwc24_id, u32 hollywood_id, u16 id_ctr, u8 hardware_model, + u8 area_code) { const u8 table2[8] = {0x1, 0x5, 0x0, 0x4, 0x2, 0x3, 0x6, 0x7}; const u8 table1[16] = {0x4, 0xB, 0x7, 0x9, 0xF, 0x1, 0xD, 0x3, @@ -320,17 +321,12 @@ static void GetMacAddress(u8* mac) // ********************************************************************************** // Handle /dev/net/ncd/manage requests -CWII_IPC_HLE_Device_net_ncd_manage::CWII_IPC_HLE_Device_net_ncd_manage( - u32 _DeviceID, const std::string& _rDeviceName) - : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) +NetNCDManage::NetNCDManage(u32 device_id, const std::string& device_name) + : Device(device_id, device_name) { } -CWII_IPC_HLE_Device_net_ncd_manage::~CWII_IPC_HLE_Device_net_ncd_manage() -{ -} - -IPCCommandResult CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(const IOSIOCtlVRequest& request) +IPCCommandResult NetNCDManage::IOCtlV(const IOSIOCtlVRequest& request) { s32 return_value = IPC_SUCCESS; u32 common_result = 0; @@ -398,20 +394,15 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(const IOSIOCtlVReque // ********************************************************************************** // Handle /dev/net/wd/command requests -CWII_IPC_HLE_Device_net_wd_command::CWII_IPC_HLE_Device_net_wd_command( - u32 DeviceID, const std::string& DeviceName) - : IWII_IPC_HLE_Device(DeviceID, DeviceName) -{ -} - -CWII_IPC_HLE_Device_net_wd_command::~CWII_IPC_HLE_Device_net_wd_command() +NetWDCommand::NetWDCommand(u32 device_id, const std::string& device_name) + : Device(device_id, device_name) { } // This is just for debugging / playing around. // There really is no reason to implement wd unless we can bend it such that // we can talk to the DS. -IPCCommandResult CWII_IPC_HLE_Device_net_wd_command::IOCtlV(const IOSIOCtlVRequest& request) +IPCCommandResult NetWDCommand::IOCtlV(const IOSIOCtlVRequest& request) { s32 return_value = IPC_SUCCESS; @@ -483,9 +474,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_wd_command::IOCtlV(const IOSIOCtlVReque // ********************************************************************************** // Handle /dev/net/ip/top requests -CWII_IPC_HLE_Device_net_ip_top::CWII_IPC_HLE_Device_net_ip_top(u32 _DeviceID, - const std::string& _rDeviceName) - : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) +NetIPTop::NetIPTop(u32 device_id, const std::string& device_name) : Device(device_id, device_name) { #ifdef _WIN32 int ret = WSAStartup(MAKEWORD(2, 2), &InitData); @@ -493,7 +482,7 @@ CWII_IPC_HLE_Device_net_ip_top::CWII_IPC_HLE_Device_net_ip_top(u32 _DeviceID, #endif } -CWII_IPC_HLE_Device_net_ip_top::~CWII_IPC_HLE_Device_net_ip_top() +NetIPTop::~NetIPTop() { #ifdef _WIN32 WSACleanup(); @@ -550,7 +539,7 @@ static unsigned int opt_level_mapping[][2] = {{SOL_SOCKET, 0xFFFF}}; static unsigned int opt_name_mapping[][2] = { {SO_REUSEADDR, 0x4}, {SO_SNDBUF, 0x1001}, {SO_RCVBUF, 0x1002}, {SO_ERROR, 0x1009}}; -IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& request) +IPCCommandResult NetIPTop::IOCtl(const IOSIOCtlRequest& request) { if (Core::g_want_determinism) { @@ -1063,7 +1052,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re return GetDefaultReply(return_value); } -IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtlV(const IOSIOCtlVRequest& request) +IPCCommandResult NetIPTop::IOCtlV(const IOSIOCtlVRequest& request) { s32 return_value = 0; @@ -1373,9 +1362,10 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtlV(const IOSIOCtlVRequest& return GetDefaultReply(return_value); } -void CWII_IPC_HLE_Device_net_ip_top::Update() +void NetIPTop::Update() { WiiSockMan::GetInstance().Update(); } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/Network/Net.h b/Source/Core/Core/IOS/Network/Net.h index e750eea0dc..22fccd91ae 100644 --- a/Source/Core/Core/IOS/Network/Net.h +++ b/Source/Core/Core/IOS/Network/Net.h @@ -23,16 +23,58 @@ namespace IOS { namespace HLE { +enum NET_IOCTL +{ + IOCTL_SO_ACCEPT = 1, + IOCTL_SO_BIND, + IOCTL_SO_CLOSE, + IOCTL_SO_CONNECT, + IOCTL_SO_FCNTL, + IOCTL_SO_GETPEERNAME, + IOCTL_SO_GETSOCKNAME, + IOCTL_SO_GETSOCKOPT, + IOCTL_SO_SETSOCKOPT, + IOCTL_SO_LISTEN, + IOCTL_SO_POLL, + IOCTLV_SO_RECVFROM, + IOCTLV_SO_SENDTO, + IOCTL_SO_SHUTDOWN, + IOCTL_SO_SOCKET, + IOCTL_SO_GETHOSTID, + IOCTL_SO_GETHOSTBYNAME, + IOCTL_SO_GETHOSTBYADDR, + IOCTLV_SO_GETNAMEINFO, + IOCTL_SO_UNK14, + IOCTL_SO_INETATON, + IOCTL_SO_INETPTON, + IOCTL_SO_INETNTOP, + IOCTLV_SO_GETADDRINFO, + IOCTL_SO_SOCKATMARK, + IOCTLV_SO_UNK1A, + IOCTLV_SO_UNK1B, + IOCTLV_SO_GETINTERFACEOPT, + IOCTLV_SO_SETINTERFACEOPT, + IOCTL_SO_SETINTERFACE, + IOCTL_SO_STARTUP, + IOCTL_SO_ICMPSOCKET = 0x30, + IOCTLV_SO_ICMPPING, + IOCTL_SO_ICMPCANCEL, + IOCTL_SO_ICMPCLOSE +}; + +// TODO: split this up. +namespace Device +{ ////////////////////////////////////////////////////////////////////////// // KD is the IOS module responsible for implementing WiiConnect24 functionality. // It can perform HTTPS downloads, send and receive mail via SMTP, and execute a // JavaScript-like language while the Wii is in standby mode. -class CWII_IPC_HLE_Device_net_kd_request : public IWII_IPC_HLE_Device +class NetKDRequest : public Device { public: - CWII_IPC_HLE_Device_net_kd_request(u32 _DeviceID, const std::string& _rDeviceName); + NetKDRequest(u32 device_id, const std::string& device_name); - virtual ~CWII_IPC_HLE_Device_net_kd_request(); + virtual ~NetKDRequest(); IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override; @@ -81,15 +123,15 @@ private: }; ////////////////////////////////////////////////////////////////////////// -class CWII_IPC_HLE_Device_net_kd_time : public IWII_IPC_HLE_Device +class NetKDTime : public Device { public: - CWII_IPC_HLE_Device_net_kd_time(u32 _DeviceID, const std::string& _rDeviceName) - : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName), rtc(), utcdiff() + NetKDTime(u32 device_id, const std::string& device_name) + : Device(device_id, device_name), rtc(), utcdiff() { } - virtual ~CWII_IPC_HLE_Device_net_kd_time() {} + virtual ~NetKDTime() {} IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override { s32 result = 0; @@ -159,52 +201,13 @@ private: } }; -enum NET_IOCTL -{ - IOCTL_SO_ACCEPT = 1, - IOCTL_SO_BIND, - IOCTL_SO_CLOSE, - IOCTL_SO_CONNECT, - IOCTL_SO_FCNTL, - IOCTL_SO_GETPEERNAME, - IOCTL_SO_GETSOCKNAME, - IOCTL_SO_GETSOCKOPT, - IOCTL_SO_SETSOCKOPT, - IOCTL_SO_LISTEN, - IOCTL_SO_POLL, - IOCTLV_SO_RECVFROM, - IOCTLV_SO_SENDTO, - IOCTL_SO_SHUTDOWN, - IOCTL_SO_SOCKET, - IOCTL_SO_GETHOSTID, - IOCTL_SO_GETHOSTBYNAME, - IOCTL_SO_GETHOSTBYADDR, - IOCTLV_SO_GETNAMEINFO, - IOCTL_SO_UNK14, - IOCTL_SO_INETATON, - IOCTL_SO_INETPTON, - IOCTL_SO_INETNTOP, - IOCTLV_SO_GETADDRINFO, - IOCTL_SO_SOCKATMARK, - IOCTLV_SO_UNK1A, - IOCTLV_SO_UNK1B, - IOCTLV_SO_GETINTERFACEOPT, - IOCTLV_SO_SETINTERFACEOPT, - IOCTL_SO_SETINTERFACE, - IOCTL_SO_STARTUP, - IOCTL_SO_ICMPSOCKET = 0x30, - IOCTLV_SO_ICMPPING, - IOCTL_SO_ICMPCANCEL, - IOCTL_SO_ICMPCLOSE -}; - ////////////////////////////////////////////////////////////////////////// -class CWII_IPC_HLE_Device_net_ip_top : public IWII_IPC_HLE_Device +class NetIPTop : public Device { public: - CWII_IPC_HLE_Device_net_ip_top(u32 _DeviceID, const std::string& _rDeviceName); + NetIPTop(u32 device_id, const std::string& device_name); - virtual ~CWII_IPC_HLE_Device_net_ip_top(); + virtual ~NetIPTop(); IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override; IPCCommandResult IOCtlV(const IOSIOCtlVRequest& request) override; @@ -219,12 +222,10 @@ private: // ********************************************************************************** // Interface for reading and changing network configuration (probably some other stuff as well) -class CWII_IPC_HLE_Device_net_ncd_manage : public IWII_IPC_HLE_Device +class NetNCDManage : public Device { public: - CWII_IPC_HLE_Device_net_ncd_manage(u32 _DeviceID, const std::string& _rDeviceName); - - virtual ~CWII_IPC_HLE_Device_net_ncd_manage(); + NetNCDManage(u32 device_id, const std::string& device_name); IPCCommandResult IOCtlV(const IOSIOCtlVRequest& request) override; @@ -245,12 +246,10 @@ private: }; ////////////////////////////////////////////////////////////////////////// -class CWII_IPC_HLE_Device_net_wd_command : public IWII_IPC_HLE_Device +class NetWDCommand : public Device { public: - CWII_IPC_HLE_Device_net_wd_command(u32 DeviceID, const std::string& DeviceName); - - virtual ~CWII_IPC_HLE_Device_net_wd_command(); + NetWDCommand(u32 device_id, const std::string& device_name); IPCCommandResult IOCtlV(const IOSIOCtlVRequest& request) override; @@ -335,5 +334,6 @@ private: }; #pragma pack(pop) }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/Network/SSL.cpp b/Source/Core/Core/IOS/Network/SSL.cpp index 51ff2aa5e6..3eb7d4501e 100644 --- a/Source/Core/Core/IOS/Network/SSL.cpp +++ b/Source/Core/Core/IOS/Network/SSL.cpp @@ -20,7 +20,9 @@ namespace IOS { namespace HLE { -WII_SSL CWII_IPC_HLE_Device_net_ssl::_SSL[NET_SSL_MAXINSTANCES]; +namespace Device +{ +WII_SSL NetSSL::_SSL[NET_SSL_MAXINSTANCES]; static constexpr mbedtls_x509_crt_profile mbedtls_x509_crt_profile_wii = { /* Hashes from SHA-1 and above */ @@ -32,9 +34,7 @@ static constexpr mbedtls_x509_crt_profile mbedtls_x509_crt_profile_wii = { 0, /* No RSA min key size */ }; -CWII_IPC_HLE_Device_net_ssl::CWII_IPC_HLE_Device_net_ssl(u32 _DeviceID, - const std::string& _rDeviceName) - : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) +NetSSL::NetSSL(u32 device_id, const std::string& device_name) : Device(device_id, device_name) { for (WII_SSL& ssl : _SSL) { @@ -42,7 +42,7 @@ CWII_IPC_HLE_Device_net_ssl::CWII_IPC_HLE_Device_net_ssl(u32 _DeviceID, } } -CWII_IPC_HLE_Device_net_ssl::~CWII_IPC_HLE_Device_net_ssl() +NetSSL::~NetSSL() { // Cleanup sessions for (WII_SSL& ssl : _SSL) @@ -67,7 +67,7 @@ CWII_IPC_HLE_Device_net_ssl::~CWII_IPC_HLE_Device_net_ssl() } } -int CWII_IPC_HLE_Device_net_ssl::GetSSLFreeID() const +int NetSSL::GetSSLFreeID() const { for (int i = 0; i < NET_SSL_MAXINSTANCES; i++) { @@ -79,13 +79,13 @@ int CWII_IPC_HLE_Device_net_ssl::GetSSLFreeID() const return 0; } -IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtl(const IOSIOCtlRequest& request) +IPCCommandResult NetSSL::IOCtl(const IOSIOCtlRequest& request) { request.Log(GetDeviceName(), LogTypes::WII_IPC_SSL, LogTypes::LINFO); return GetDefaultReply(IPC_SUCCESS); } -IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(const IOSIOCtlVRequest& request) +IPCCommandResult NetSSL::IOCtlV(const IOSIOCtlVRequest& request) { u32 BufferIn = 0, BufferIn2 = 0, BufferIn3 = 0; u32 BufferInSize = 0, BufferInSize2 = 0, BufferInSize3 = 0; @@ -498,5 +498,6 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(const IOSIOCtlVRequest& req // SSL return codes are written to BufferIn return GetDefaultReply(IPC_SUCCESS); } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/Network/SSL.h b/Source/Core/Core/IOS/Network/SSL.h index bd003b6d77..1114f65f6f 100644 --- a/Source/Core/Core/IOS/Network/SSL.h +++ b/Source/Core/Core/IOS/Network/SSL.h @@ -28,8 +28,9 @@ namespace HLE { #define NET_SSL_MAXINSTANCES 4 +// TODO: remove this macro. #define SSLID_VALID(x) \ - (x >= 0 && x < NET_SSL_MAXINSTANCES && CWII_IPC_HLE_Device_net_ssl::_SSL[x].active) + (x >= 0 && x < NET_SSL_MAXINSTANCES && ::IOS::HLE::Device::NetSSL::_SSL[x].active) enum ssl_err_t { @@ -84,12 +85,14 @@ struct WII_SSL bool active; }; -class CWII_IPC_HLE_Device_net_ssl : public IWII_IPC_HLE_Device +namespace Device +{ +class NetSSL : public Device { public: - CWII_IPC_HLE_Device_net_ssl(u32 _DeviceID, const std::string& _rDeviceName); + NetSSL(u32 device_id, const std::string& device_name); - virtual ~CWII_IPC_HLE_Device_net_ssl(); + virtual ~NetSSL(); IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override; IPCCommandResult IOCtlV(const IOSIOCtlVRequest& request) override; @@ -98,5 +101,6 @@ public: static WII_SSL _SSL[NET_SSL_MAXINSTANCES]; }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/Network/Socket.cpp b/Source/Core/Core/IOS/Network/Socket.cpp index 0a3ded07a4..4b3404d90b 100644 --- a/Source/Core/Core/IOS/Network/Socket.cpp +++ b/Source/Core/Core/IOS/Network/Socket.cpp @@ -309,7 +309,7 @@ void WiiSocket::Update(bool read, bool write, bool except) { case IOCTLV_NET_SSL_DOHANDSHAKE: { - mbedtls_ssl_context* ctx = &CWII_IPC_HLE_Device_net_ssl::_SSL[sslID].ctx; + mbedtls_ssl_context* ctx = &Device::NetSSL::_SSL[sslID].ctx; int ret = mbedtls_ssl_handshake(ctx); if (ret) { @@ -384,7 +384,7 @@ void WiiSocket::Update(bool read, bool write, bool except) } case IOCTLV_NET_SSL_WRITE: { - int ret = mbedtls_ssl_write(&CWII_IPC_HLE_Device_net_ssl::_SSL[sslID].ctx, + int ret = mbedtls_ssl_write(&Device::NetSSL::_SSL[sslID].ctx, Memory::GetPointer(BufferOut2), BufferOutSize2); if (SConfig::GetInstance().m_SSLDumpWrite && ret > 0) @@ -422,7 +422,7 @@ void WiiSocket::Update(bool read, bool write, bool except) } case IOCTLV_NET_SSL_READ: { - int ret = mbedtls_ssl_read(&CWII_IPC_HLE_Device_net_ssl::_SSL[sslID].ctx, + int ret = mbedtls_ssl_read(&Device::NetSSL::_SSL[sslID].ctx, Memory::GetPointer(BufferIn2), BufferInSize2); if (SConfig::GetInstance().m_SSLDumpRead && ret > 0) diff --git a/Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp b/Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp index 7cb2bbeca1..90ed9d632a 100644 --- a/Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp +++ b/Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp @@ -21,13 +21,13 @@ namespace IOS { namespace HLE { -CWII_IPC_HLE_Device_sdio_slot0::CWII_IPC_HLE_Device_sdio_slot0(const u32 device_id, - const std::string& device_name) - : IWII_IPC_HLE_Device(device_id, device_name) +namespace Device +{ +SDIOSlot0::SDIOSlot0(u32 device_id, const std::string& device_name) : Device(device_id, device_name) { } -void CWII_IPC_HLE_Device_sdio_slot0::DoState(PointerWrap& p) +void SDIOSlot0::DoState(PointerWrap& p) { DoStateShared(p); if (p.GetMode() == PointerWrap::MODE_READ) @@ -40,7 +40,7 @@ void CWII_IPC_HLE_Device_sdio_slot0::DoState(PointerWrap& p) p.Do(m_registers); } -void CWII_IPC_HLE_Device_sdio_slot0::EventNotify() +void SDIOSlot0::EventNotify() { if (!m_event) return; @@ -54,7 +54,7 @@ void CWII_IPC_HLE_Device_sdio_slot0::EventNotify() } } -void CWII_IPC_HLE_Device_sdio_slot0::OpenInternal() +void SDIOSlot0::OpenInternal() { const std::string filename = File::GetUserPath(F_WIISDCARD_IDX); m_Card.Open(filename, "r+b"); @@ -74,7 +74,7 @@ void CWII_IPC_HLE_Device_sdio_slot0::OpenInternal() } } -IOSReturnCode CWII_IPC_HLE_Device_sdio_slot0::Open(const IOSOpenRequest& request) +IOSReturnCode SDIOSlot0::Open(const IOSOpenRequest& request) { OpenInternal(); m_registers.fill(0); @@ -83,7 +83,7 @@ IOSReturnCode CWII_IPC_HLE_Device_sdio_slot0::Open(const IOSOpenRequest& request return IPC_SUCCESS; } -void CWII_IPC_HLE_Device_sdio_slot0::Close() +void SDIOSlot0::Close() { m_Card.Close(); m_BlockLength = 0; @@ -93,7 +93,7 @@ void CWII_IPC_HLE_Device_sdio_slot0::Close() } // The front SD slot -IPCCommandResult CWII_IPC_HLE_Device_sdio_slot0::IOCtl(const IOSIOCtlRequest& request) +IPCCommandResult SDIOSlot0::IOCtl(const IOSIOCtlRequest& request) { Memory::Memset(request.buffer_out, 0, request.buffer_out_size); s32 return_value = IPC_SUCCESS; @@ -204,7 +204,7 @@ IPCCommandResult CWII_IPC_HLE_Device_sdio_slot0::IOCtl(const IOSIOCtlRequest& re return GetDefaultReply(return_value); } -IPCCommandResult CWII_IPC_HLE_Device_sdio_slot0::IOCtlV(const IOSIOCtlVRequest& request) +IPCCommandResult SDIOSlot0::IOCtlV(const IOSIOCtlVRequest& request) { s32 return_value = IPC_SUCCESS; switch (request.request) @@ -225,10 +225,8 @@ IPCCommandResult CWII_IPC_HLE_Device_sdio_slot0::IOCtlV(const IOSIOCtlVRequest& return GetDefaultReply(return_value); } -u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(const IOSRequest& request, u32 _BufferIn, - u32 _BufferInSize, u32 _rwBuffer, - u32 _rwBufferSize, u32 _BufferOut, - u32 _BufferOutSize) +u32 SDIOSlot0::ExecuteCommand(const IOSRequest& request, u32 _BufferIn, u32 _BufferInSize, + u32 _rwBuffer, u32 _rwBufferSize, u32 _BufferOut, u32 _BufferOutSize) { // The game will send us a SendCMD with this information. To be able to read and write // to a file we need to prepare a 0x10 byte output buffer as response. @@ -407,5 +405,6 @@ u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(const IOSRequest& request, u3 return ret; } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/SDIO/SDIOSlot0.h b/Source/Core/Core/IOS/SDIO/SDIOSlot0.h index f227d7d114..69106da61a 100644 --- a/Source/Core/Core/IOS/SDIO/SDIOSlot0.h +++ b/Source/Core/Core/IOS/SDIO/SDIOSlot0.h @@ -20,10 +20,12 @@ namespace IOS { namespace HLE { -class CWII_IPC_HLE_Device_sdio_slot0 : public IWII_IPC_HLE_Device +namespace Device +{ +class SDIOSlot0 : public Device { public: - CWII_IPC_HLE_Device_sdio_slot0(u32 device_id, const std::string& device_name); + SDIOSlot0(u32 device_id, const std::string& device_name); void DoState(PointerWrap& p) override; @@ -129,5 +131,6 @@ private: u32 BufferInSize2, u32 _BufferOut, u32 BufferOutSize); void OpenInternal(); }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/STM/STM.cpp b/Source/Core/Core/IOS/STM/STM.cpp index f79ceda8cd..a74c0b9c57 100644 --- a/Source/Core/Core/IOS/STM/STM.cpp +++ b/Source/Core/Core/IOS/STM/STM.cpp @@ -21,9 +21,11 @@ namespace IOS { namespace HLE { +namespace Device +{ static std::unique_ptr s_event_hook_request; -IPCCommandResult CWII_IPC_HLE_Device_stm_immediate::IOCtl(const IOSIOCtlRequest& request) +IPCCommandResult STMImmediate::IOCtl(const IOSIOCtlRequest& request) { s32 return_value = IPC_SUCCESS; switch (request.request) @@ -69,19 +71,16 @@ IPCCommandResult CWII_IPC_HLE_Device_stm_immediate::IOCtl(const IOSIOCtlRequest& return GetDefaultReply(return_value); } -void CWII_IPC_HLE_Device_stm_eventhook::Close() +void STMEventHook::Close() { s_event_hook_request.reset(); m_is_active = false; } -IPCCommandResult CWII_IPC_HLE_Device_stm_eventhook::IOCtl(const IOSIOCtlRequest& request) +IPCCommandResult STMEventHook::IOCtl(const IOSIOCtlRequest& request) { if (request.request != IOCTL_STM_EVENTHOOK) - { - ERROR_LOG(WII_IPC_STM, "Bad IOCtl in CWII_IPC_HLE_Device_stm_eventhook"); return GetDefaultReply(IPC_EINVAL); - } if (s_event_hook_request) return GetDefaultReply(IPC_EEXIST); @@ -91,12 +90,12 @@ IPCCommandResult CWII_IPC_HLE_Device_stm_eventhook::IOCtl(const IOSIOCtlRequest& return GetNoReply(); } -bool CWII_IPC_HLE_Device_stm_eventhook::HasHookInstalled() const +bool STMEventHook::HasHookInstalled() const { return s_event_hook_request != nullptr; } -void CWII_IPC_HLE_Device_stm_eventhook::TriggerEvent(const u32 event) const +void STMEventHook::TriggerEvent(const u32 event) const { // If the device isn't open, ignore the button press. if (!m_is_active || !s_event_hook_request) @@ -107,15 +106,16 @@ void CWII_IPC_HLE_Device_stm_eventhook::TriggerEvent(const u32 event) const s_event_hook_request.reset(); } -void CWII_IPC_HLE_Device_stm_eventhook::ResetButton() const +void STMEventHook::ResetButton() const { // The reset button triggers STM_EVENT_RESET. TriggerEvent(STM_EVENT_RESET); } -void CWII_IPC_HLE_Device_stm_eventhook::PowerButton() const +void STMEventHook::PowerButton() const { TriggerEvent(STM_EVENT_POWER); } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/STM/STM.h b/Source/Core/Core/IOS/STM/STM.h index 7f332cf003..40c804ce02 100644 --- a/Source/Core/Core/IOS/STM/STM.h +++ b/Source/Core/Core/IOS/STM/STM.h @@ -38,27 +38,21 @@ enum STM_EVENT_POWER = 0x00000800 }; +namespace Device +{ // The /dev/stm/immediate -class CWII_IPC_HLE_Device_stm_immediate final : public IWII_IPC_HLE_Device +class STMImmediate final : public Device { public: - CWII_IPC_HLE_Device_stm_immediate(u32 device_id, const std::string& device_name) - : IWII_IPC_HLE_Device(device_id, device_name) - { - } - + STMImmediate(u32 device_id, const std::string& device_name) : Device(device_id, device_name) {} IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override; }; // The /dev/stm/eventhook -class CWII_IPC_HLE_Device_stm_eventhook final : public IWII_IPC_HLE_Device +class STMEventHook final : public Device { public: - CWII_IPC_HLE_Device_stm_eventhook(u32 device_id, const std::string& device_name) - : IWII_IPC_HLE_Device(device_id, device_name) - { - } - + STMEventHook(u32 device_id, const std::string& device_name) : Device(device_id, device_name) {} void Close() override; IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override; @@ -69,5 +63,6 @@ public: private: void TriggerEvent(u32 event) const; }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/USB/Bluetooth/BTBase.cpp b/Source/Core/Core/IOS/USB/Bluetooth/BTBase.cpp index 7e0e664661..fb7d7566d1 100644 --- a/Source/Core/Core/IOS/USB/Bluetooth/BTBase.cpp +++ b/Source/Core/Core/IOS/USB/Bluetooth/BTBase.cpp @@ -54,8 +54,9 @@ void RestoreBTInfoSection(SysConf* sysconf) File::Delete(filename); } -CWII_IPC_HLE_Device_usb_oh1_57e_305_base::CtrlMessage::CtrlMessage(const IOSIOCtlVRequest& ioctlv) - : ios_request(ioctlv) +namespace Device +{ +BluetoothBase::CtrlMessage::CtrlMessage(const IOSIOCtlVRequest& ioctlv) : ios_request(ioctlv) { request_type = Memory::Read_U8(ioctlv.in_vectors[0].address); request = Memory::Read_U8(ioctlv.in_vectors[1].address); @@ -65,20 +66,19 @@ CWII_IPC_HLE_Device_usb_oh1_57e_305_base::CtrlMessage::CtrlMessage(const IOSIOCt payload_addr = ioctlv.io_vectors[0].address; } -CWII_IPC_HLE_Device_usb_oh1_57e_305_base::CtrlBuffer::CtrlBuffer(const IOSIOCtlVRequest& ioctlv) - : ios_request(ioctlv) +BluetoothBase::CtrlBuffer::CtrlBuffer(const IOSIOCtlVRequest& ioctlv) : ios_request(ioctlv) { m_endpoint = Memory::Read_U8(ioctlv.in_vectors[0].address); m_length = Memory::Read_U16(ioctlv.in_vectors[1].address); m_payload_addr = ioctlv.io_vectors[0].address; } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_base::CtrlBuffer::FillBuffer(const u8* src, - const size_t size) const +void BluetoothBase::CtrlBuffer::FillBuffer(const u8* src, const size_t size) const { _assert_msg_(WII_IPC_WIIMOTE, size <= m_length, "FillBuffer: size %li > payload length %i", size, m_length); Memory::CopyToEmu(m_payload_addr, src, size); } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/USB/Bluetooth/BTBase.h b/Source/Core/Core/IOS/USB/Bluetooth/BTBase.h index c03d041455..2677ff45a8 100644 --- a/Source/Core/Core/IOS/USB/Bluetooth/BTBase.h +++ b/Source/Core/Core/IOS/USB/Bluetooth/BTBase.h @@ -21,14 +21,12 @@ namespace HLE void BackUpBTInfoSection(SysConf* sysconf); void RestoreBTInfoSection(SysConf* sysconf); -class CWII_IPC_HLE_Device_usb_oh1_57e_305_base : public IWII_IPC_HLE_Device +namespace Device +{ +class BluetoothBase : public Device { public: - CWII_IPC_HLE_Device_usb_oh1_57e_305_base(u32 device_id, const std::string& device_name) - : IWII_IPC_HLE_Device(device_id, device_name) - { - } - + BluetoothBase(u32 device_id, const std::string& device_name) : Device(device_id, device_name) {} virtual void UpdateSyncButtonState(bool is_held) {} virtual void TriggerSyncButtonPressedEvent() {} virtual void TriggerSyncButtonHeldEvent() {} @@ -75,5 +73,6 @@ protected: u32 m_payload_addr = 0; }; }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/USB/Bluetooth/BTEmu.cpp b/Source/Core/Core/IOS/USB/Bluetooth/BTEmu.cpp index 5365f899ad..5e6b7a845d 100644 --- a/Source/Core/Core/IOS/USB/Bluetooth/BTEmu.cpp +++ b/Source/Core/Core/IOS/USB/Bluetooth/BTEmu.cpp @@ -37,10 +37,10 @@ SQueuedEvent::SQueuedEvent(u32 size, u16 handle) : m_size(size), m_connectionHan PanicAlert("SQueuedEvent: The size is too large."); } -// The device class -CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CWII_IPC_HLE_Device_usb_oh1_57e_305_emu( - u32 _DeviceID, const std::string& _rDeviceName) - : CWII_IPC_HLE_Device_usb_oh1_57e_305_base(_DeviceID, _rDeviceName) +namespace Device +{ +BluetoothEmu::BluetoothEmu(u32 device_id, const std::string& device_name) + : BluetoothBase(device_id, device_name) { SysConf sysconf{Core::g_want_determinism ? Common::FromWhichRoot::FROM_SESSION_ROOT : Common::FromWhichRoot::FROM_CONFIGURED_ROOT}; @@ -79,7 +79,7 @@ CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CWII_IPC_HLE_Device_usb_oh1_57e_305_emu DEBUG_LOG(WII_IPC_WIIMOTE, "Wii Remote %d BT ID %x,%x,%x,%x,%x,%x", i, tmpBD.b[0], tmpBD.b[1], tmpBD.b[2], tmpBD.b[3], tmpBD.b[4], tmpBD.b[5]); - m_WiiMotes.push_back(CWII_IPC_HLE_WiiMote(this, i, tmpBD, false)); + m_WiiMotes.emplace_back(this, i, tmpBD, false); i++; } @@ -101,7 +101,7 @@ CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CWII_IPC_HLE_Device_usb_oh1_57e_305_emu Host_SetWiiMoteConnectionState(0); } -CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::~CWII_IPC_HLE_Device_usb_oh1_57e_305_emu() +BluetoothEmu::~BluetoothEmu() { m_WiiMotes.clear(); SetUsbPointer(nullptr); @@ -119,7 +119,7 @@ static void DoStateForMessage(PointerWrap& p, std::unique_ptr& message) } } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::DoState(PointerWrap& p) +void BluetoothEmu::DoState(PointerWrap& p) { bool passthrough_bluetooth = false; p.Do(passthrough_bluetooth); @@ -145,12 +145,12 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::DoState(PointerWrap& p) m_WiiMotes[i].DoState(p); } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::RemoteDisconnect(u16 _connectionHandle) +bool BluetoothEmu::RemoteDisconnect(u16 _connectionHandle) { return SendEventDisconnect(_connectionHandle, 0x13); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::Close() +void BluetoothEmu::Close() { // Clean up state m_ScanEnable = 0; @@ -162,7 +162,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::Close() m_is_active = false; } -IPCCommandResult CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::IOCtlV(const IOSIOCtlVRequest& request) +IPCCommandResult BluetoothEmu::IOCtlV(const IOSIOCtlVRequest& request) { bool send_reply = true; switch (request.request) @@ -233,10 +233,9 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::IOCtlV(const IOSIOCtlV } // Here we handle the USBV0_IOCTL_BLKMSG Ioctlv -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendToDevice(u16 _ConnectionHandle, u8* _pData, - u32 _Size) +void BluetoothEmu::SendToDevice(u16 _ConnectionHandle, u8* _pData, u32 _Size) { - CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_ConnectionHandle); + WiimoteDevice* pWiiMote = AccessWiiMote(_ConnectionHandle); if (pWiiMote == nullptr) return; @@ -245,15 +244,14 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendToDevice(u16 _ConnectionHandle pWiiMote->ExecuteL2capCmd(_pData, _Size); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::IncDataPacket(u16 _ConnectionHandle) +void BluetoothEmu::IncDataPacket(u16 _ConnectionHandle) { m_PacketCount[_ConnectionHandle & 0xff]++; } // Here we send ACL packets to CPU. They will consist of header + data. // The header is for example 07 00 41 00 which means size 0x0007 and channel 0x0041. -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendACLPacket(u16 connection_handle, const u8* data, - u32 size) +void BluetoothEmu::SendACLPacket(u16 connection_handle, const u8* data, u32 size) { DEBUG_LOG(WII_IPC_WIIMOTE, "ACL packet from %x ready to send to stack...", connection_handle); @@ -285,7 +283,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendACLPacket(u16 connection_handl // // Our WII_IPC_HLE is so efficient that we could fill the buffer immediately // rather than enqueue it to some other memory and this will do good for StateSave -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::AddEventToQueue(const SQueuedEvent& _event) +void BluetoothEmu::AddEventToQueue(const SQueuedEvent& _event) { DEBUG_LOG(WII_IPC_WIIMOTE, "HCI event %x completed...", ((hci_event_hdr_t*)_event.m_buffer)->event); @@ -328,7 +326,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::AddEventToQueue(const SQueuedEvent } } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::Update() +void BluetoothEmu::Update() { // check HCI queue if (!m_EventQueue.empty() && m_HCIEndpoint) @@ -396,8 +394,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::Update() SendEventNumberOfCompletedPackets(); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::ACLPool::Store(const u8* data, const u16 size, - const u16 conn_handle) +void BluetoothEmu::ACLPool::Store(const u8* data, const u16 size, const u16 conn_handle) { if (m_queue.size() >= 100) { @@ -416,7 +413,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::ACLPool::Store(const u8* data, con packet.conn_handle = conn_handle; } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::ACLPool::WriteToEndpoint(CtrlBuffer& endpoint) +void BluetoothEmu::ACLPool::WriteToEndpoint(CtrlBuffer& endpoint) { auto& packet = m_queue.front(); @@ -440,7 +437,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::ACLPool::WriteToEndpoint(CtrlBuffe EnqueueReply(endpoint.ios_request, sizeof(hci_acldata_hdr_t) + size); } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventInquiryComplete() +bool BluetoothEmu::SendEventInquiryComplete() { SQueuedEvent Event(sizeof(SHCIEventInquiryComplete), 0); @@ -456,7 +453,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventInquiryComplete() return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventInquiryResponse() +bool BluetoothEmu::SendEventInquiryResponse() { if (m_WiiMotes.empty()) return false; @@ -506,9 +503,9 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventInquiryResponse() return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventConnectionComplete(const bdaddr_t& _bd) +bool BluetoothEmu::SendEventConnectionComplete(const bdaddr_t& _bd) { - CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_bd); + WiimoteDevice* pWiiMote = AccessWiiMote(_bd); if (pWiiMote == nullptr) return false; @@ -526,7 +523,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventConnectionComplete(const AddEventToQueue(Event); - CWII_IPC_HLE_WiiMote* pWiimote = AccessWiiMote(pConnectionComplete->Connection_Handle); + WiimoteDevice* pWiimote = AccessWiiMote(pConnectionComplete->Connection_Handle); if (pWiimote) pWiimote->EventConnectionAccepted(); @@ -549,8 +546,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventConnectionComplete(const } // This is called from Update() after ScanEnable has been enabled. -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventRequestConnection( - CWII_IPC_HLE_WiiMote& _rWiiMote) +bool BluetoothEmu::SendEventRequestConnection(WiimoteDevice& _rWiiMote) { SQueuedEvent Event(sizeof(SHCIEventRequestConnection), 0); @@ -585,9 +581,9 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventRequestConnection( return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventDisconnect(u16 _connectionHandle, u8 _Reason) +bool BluetoothEmu::SendEventDisconnect(u16 _connectionHandle, u8 _Reason) { - CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_connectionHandle); + WiimoteDevice* pWiiMote = AccessWiiMote(_connectionHandle); if (pWiiMote == nullptr) return false; @@ -609,10 +605,9 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventDisconnect(u16 _connectio return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventAuthenticationCompleted( - u16 _connectionHandle) +bool BluetoothEmu::SendEventAuthenticationCompleted(u16 _connectionHandle) { - CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_connectionHandle); + WiimoteDevice* pWiiMote = AccessWiiMote(_connectionHandle); if (pWiiMote == nullptr) return false; @@ -634,9 +629,9 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventAuthenticationCompleted( return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventRemoteNameReq(const bdaddr_t& _bd) +bool BluetoothEmu::SendEventRemoteNameReq(const bdaddr_t& _bd) { - CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_bd); + WiimoteDevice* pWiiMote = AccessWiiMote(_bd); if (pWiiMote == nullptr) return false; @@ -661,9 +656,9 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventRemoteNameReq(const bdadd return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventReadRemoteFeatures(u16 _connectionHandle) +bool BluetoothEmu::SendEventReadRemoteFeatures(u16 _connectionHandle) { - CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_connectionHandle); + WiimoteDevice* pWiiMote = AccessWiiMote(_connectionHandle); if (pWiiMote == nullptr) return false; @@ -697,9 +692,9 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventReadRemoteFeatures(u16 _c return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventReadRemoteVerInfo(u16 _connectionHandle) +bool BluetoothEmu::SendEventReadRemoteVerInfo(u16 _connectionHandle) { - CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_connectionHandle); + WiimoteDevice* pWiiMote = AccessWiiMote(_connectionHandle); if (pWiiMote == nullptr) return false; @@ -725,8 +720,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventReadRemoteVerInfo(u16 _co return true; } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventCommandComplete(u16 opcode, const void* data, - u32 data_size) +void BluetoothEmu::SendEventCommandComplete(u16 opcode, const void* data, u32 data_size) { _dbg_assert_(WII_IPC_WIIMOTE, (sizeof(SHCIEventCommand) - 2 + data_size) < 256); @@ -750,7 +744,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventCommandComplete(u16 opcod AddEventToQueue(event); } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventCommandStatus(u16 _Opcode) +bool BluetoothEmu::SendEventCommandStatus(u16 _Opcode) { SQueuedEvent Event(sizeof(SHCIEventStatus), 0); @@ -768,9 +762,9 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventCommandStatus(u16 _Opcode return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventRoleChange(bdaddr_t _bd, bool _master) +bool BluetoothEmu::SendEventRoleChange(bdaddr_t _bd, bool _master) { - CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_bd); + WiimoteDevice* pWiiMote = AccessWiiMote(_bd); if (pWiiMote == nullptr) return false; @@ -795,7 +789,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventRoleChange(bdaddr_t _bd, return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventNumberOfCompletedPackets() +bool BluetoothEmu::SendEventNumberOfCompletedPackets() { SQueuedEvent Event((u32)(sizeof(hci_event_hdr_t) + sizeof(hci_num_compl_pkts_ep) + (sizeof(hci_num_compl_pkts_info) * m_WiiMotes.size())), @@ -841,10 +835,9 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventNumberOfCompletedPackets( return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventModeChange(u16 _connectionHandle, u8 _mode, - u16 _value) +bool BluetoothEmu::SendEventModeChange(u16 _connectionHandle, u8 _mode, u16 _value) { - CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_connectionHandle); + WiimoteDevice* pWiiMote = AccessWiiMote(_connectionHandle); if (pWiiMote == nullptr) return false; @@ -867,7 +860,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventModeChange(u16 _connectio return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventLinkKeyNotification(const u8 num_to_send) +bool BluetoothEmu::SendEventLinkKeyNotification(const u8 num_to_send) { u8 payload_length = sizeof(hci_return_link_keys_ep) + sizeof(hci_link_key_rep_cp) * num_to_send; SQueuedEvent Event(2 + payload_length, 0); @@ -900,7 +893,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventLinkKeyNotification(const return true; }; -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventRequestLinkKey(const bdaddr_t& _bd) +bool BluetoothEmu::SendEventRequestLinkKey(const bdaddr_t& _bd) { SQueuedEvent Event(sizeof(SHCIEventRequestLinkKey), 0); @@ -921,10 +914,9 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventRequestLinkKey(const bdad return true; }; -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventReadClockOffsetComplete( - u16 _connectionHandle) +bool BluetoothEmu::SendEventReadClockOffsetComplete(u16 _connectionHandle) { - CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_connectionHandle); + WiimoteDevice* pWiiMote = AccessWiiMote(_connectionHandle); if (pWiiMote == nullptr) return false; @@ -948,10 +940,9 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventReadClockOffsetComplete( return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventConPacketTypeChange(u16 _connectionHandle, - u16 _packetType) +bool BluetoothEmu::SendEventConPacketTypeChange(u16 _connectionHandle, u16 _packetType) { - CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_connectionHandle); + WiimoteDevice* pWiiMote = AccessWiiMote(_connectionHandle); if (pWiiMote == nullptr) return false; @@ -976,8 +967,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventConPacketTypeChange(u16 _ // Command dispatcher // This is called from the USBV0_IOCTL_CTRLMSG Ioctlv -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::ExecuteHCICommandMessage( - const CtrlMessage& ctrl_message) +void BluetoothEmu::ExecuteHCICommandMessage(const CtrlMessage& ctrl_message) { u8* pInput = Memory::GetPointer(ctrl_message.payload_addr + 3); SCommandMessage* pMsg = (SCommandMessage*)Memory::GetPointer(ctrl_message.payload_addr); @@ -1165,7 +1155,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::ExecuteHCICommandMessage( // --- command helper // // -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandInquiry(const u8* input) +void BluetoothEmu::CommandInquiry(const u8* input) { // Inquiry should not be called normally const hci_inquiry_cp* inquiry = reinterpret_cast(input); @@ -1183,7 +1173,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandInquiry(const u8* input) SendEventInquiryComplete(); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandInquiryCancel(const u8* input) +void BluetoothEmu::CommandInquiryCancel(const u8* input) { hci_inquiry_cancel_rp reply; reply.status = 0x00; @@ -1193,7 +1183,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandInquiryCancel(const u8* inp SendEventCommandComplete(HCI_CMD_INQUIRY_CANCEL, &reply, sizeof(hci_inquiry_cancel_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandCreateCon(const u8* input) +void BluetoothEmu::CommandCreateCon(const u8* input) { const hci_create_con_cp* create_connection = reinterpret_cast(input); @@ -1214,7 +1204,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandCreateCon(const u8* input) SendEventConnectionComplete(create_connection->bdaddr); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandDisconnect(const u8* input) +void BluetoothEmu::CommandDisconnect(const u8* input) { const hci_discon_cp* disconnect = reinterpret_cast(input); @@ -1228,12 +1218,12 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandDisconnect(const u8* input) SendEventCommandStatus(HCI_CMD_DISCONNECT); SendEventDisconnect(disconnect->con_handle, disconnect->reason); - CWII_IPC_HLE_WiiMote* wiimote = AccessWiiMote(disconnect->con_handle); + WiimoteDevice* wiimote = AccessWiiMote(disconnect->con_handle); if (wiimote) wiimote->EventDisconnect(); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandAcceptCon(const u8* input) +void BluetoothEmu::CommandAcceptCon(const u8* input) { const hci_accept_con_cp* accept_connection = reinterpret_cast(input); @@ -1259,7 +1249,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandAcceptCon(const u8* input) SendEventConnectionComplete(accept_connection->bdaddr); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandLinkKeyRep(const u8* input) +void BluetoothEmu::CommandLinkKeyRep(const u8* input) { const hci_link_key_rep_cp* key_rep = reinterpret_cast(input); @@ -1275,7 +1265,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandLinkKeyRep(const u8* input) SendEventCommandComplete(HCI_CMD_LINK_KEY_REP, &reply, sizeof(hci_link_key_rep_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandLinkKeyNegRep(const u8* input) +void BluetoothEmu::CommandLinkKeyNegRep(const u8* input) { const hci_link_key_neg_rep_cp* key_neg = reinterpret_cast(input); @@ -1291,7 +1281,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandLinkKeyNegRep(const u8* inp SendEventCommandComplete(HCI_CMD_LINK_KEY_NEG_REP, &reply, sizeof(hci_link_key_neg_rep_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandChangeConPacketType(const u8* input) +void BluetoothEmu::CommandChangeConPacketType(const u8* input) { const hci_change_con_pkt_type_cp* change_packet_type = reinterpret_cast(input); @@ -1307,7 +1297,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandChangeConPacketType(const u SendEventConPacketTypeChange(change_packet_type->con_handle, change_packet_type->pkt_type); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandAuthenticationRequested(const u8* input) +void BluetoothEmu::CommandAuthenticationRequested(const u8* input) { const hci_auth_req_cp* auth_req = reinterpret_cast(input); @@ -1318,7 +1308,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandAuthenticationRequested(con SendEventAuthenticationCompleted(auth_req->con_handle); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandRemoteNameReq(const u8* input) +void BluetoothEmu::CommandRemoteNameReq(const u8* input) { const hci_remote_name_req_cp* remote_name_req = reinterpret_cast(input); @@ -1336,7 +1326,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandRemoteNameReq(const u8* inp SendEventRemoteNameReq(remote_name_req->bdaddr); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadRemoteFeatures(const u8* input) +void BluetoothEmu::CommandReadRemoteFeatures(const u8* input) { const hci_read_remote_features_cp* read_remote_features = reinterpret_cast(input); @@ -1348,7 +1338,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadRemoteFeatures(const u8 SendEventReadRemoteFeatures(read_remote_features->con_handle); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadRemoteVerInfo(const u8* input) +void BluetoothEmu::CommandReadRemoteVerInfo(const u8* input) { const hci_read_remote_ver_info_cp* read_remote_ver_info = reinterpret_cast(input); @@ -1360,7 +1350,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadRemoteVerInfo(const u8* SendEventReadRemoteVerInfo(read_remote_ver_info->con_handle); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadClockOffset(const u8* input) +void BluetoothEmu::CommandReadClockOffset(const u8* input) { const hci_read_clock_offset_cp* read_clock_offset = reinterpret_cast(input); @@ -1372,7 +1362,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadClockOffset(const u8* i SendEventReadClockOffsetComplete(read_clock_offset->con_handle); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandSniffMode(const u8* input) +void BluetoothEmu::CommandSniffMode(const u8* input) { const hci_sniff_mode_cp* sniff_mode = reinterpret_cast(input); @@ -1387,7 +1377,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandSniffMode(const u8* input) SendEventModeChange(sniff_mode->con_handle, 0x02, sniff_mode->max_interval); // 0x02 - sniff mode } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteLinkPolicy(const u8* input) +void BluetoothEmu::CommandWriteLinkPolicy(const u8* input) { const hci_write_link_policy_settings_cp* link_policy = reinterpret_cast(input); @@ -1399,7 +1389,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteLinkPolicy(const u8* i SendEventCommandStatus(HCI_CMD_WRITE_LINK_POLICY_SETTINGS); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReset(const u8* input) +void BluetoothEmu::CommandReset(const u8* input) { hci_status_rp reply; reply.status = 0x00; @@ -1409,7 +1399,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReset(const u8* input) SendEventCommandComplete(HCI_CMD_RESET, &reply, sizeof(hci_status_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandSetEventFilter(const u8* input) +void BluetoothEmu::CommandSetEventFilter(const u8* input) { const hci_set_event_filter_cp* set_event_filter = reinterpret_cast(input); @@ -1425,7 +1415,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandSetEventFilter(const u8* in SendEventCommandComplete(HCI_CMD_SET_EVENT_FILTER, &reply, sizeof(hci_set_event_filter_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWritePinType(const u8* input) +void BluetoothEmu::CommandWritePinType(const u8* input) { const hci_write_pin_type_cp* write_pin_type = reinterpret_cast(input); @@ -1439,7 +1429,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWritePinType(const u8* inpu SendEventCommandComplete(HCI_CMD_WRITE_PIN_TYPE, &reply, sizeof(hci_write_pin_type_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadStoredLinkKey(const u8* input) +void BluetoothEmu::CommandReadStoredLinkKey(const u8* input) { const hci_read_stored_link_key_cp* read_stored_link_key = reinterpret_cast(input); @@ -1474,7 +1464,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadStoredLinkKey(const u8* sizeof(hci_read_stored_link_key_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandDeleteStoredLinkKey(const u8* input) +void BluetoothEmu::CommandDeleteStoredLinkKey(const u8* input) { const hci_delete_stored_link_key_cp* delete_stored_link_key = reinterpret_cast(input); @@ -1486,7 +1476,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandDeleteStoredLinkKey(const u delete_stored_link_key->bdaddr.b[4], delete_stored_link_key->bdaddr.b[5]); DEBUG_LOG(WII_IPC_WIIMOTE, " delete_all: 0x%01x", delete_stored_link_key->delete_all); - CWII_IPC_HLE_WiiMote* wiiMote = AccessWiiMote(delete_stored_link_key->bdaddr); + WiimoteDevice* wiiMote = AccessWiiMote(delete_stored_link_key->bdaddr); if (wiiMote == nullptr) return; @@ -1501,7 +1491,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandDeleteStoredLinkKey(const u "has failed. Could be a problem with loading the SCONF"); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteLocalName(const u8* input) +void BluetoothEmu::CommandWriteLocalName(const u8* input) { const hci_write_local_name_cp* write_local_name = reinterpret_cast(input); @@ -1517,7 +1507,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteLocalName(const u8* in // Here we normally receive the timeout interval. // But not from homebrew games that use lwbt. Why not? -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWritePageTimeOut(const u8* input) +void BluetoothEmu::CommandWritePageTimeOut(const u8* input) { const hci_write_page_timeout_cp* write_page_timeout = reinterpret_cast(input); @@ -1532,7 +1522,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWritePageTimeOut(const u8* } /* This will enable ScanEnable so that Update() can start the Wii Remote. */ -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteScanEnable(const u8* input) +void BluetoothEmu::CommandWriteScanEnable(const u8* input) { const hci_write_scan_enable_cp* write_scan_enable = reinterpret_cast(input); @@ -1555,7 +1545,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteScanEnable(const u8* i SendEventCommandComplete(HCI_CMD_WRITE_SCAN_ENABLE, &reply, sizeof(hci_write_scan_enable_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteUnitClass(const u8* input) +void BluetoothEmu::CommandWriteUnitClass(const u8* input) { const hci_write_unit_class_cp* write_unit_class = reinterpret_cast(input); @@ -1571,7 +1561,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteUnitClass(const u8* in SendEventCommandComplete(HCI_CMD_WRITE_UNIT_CLASS, &reply, sizeof(hci_write_unit_class_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandHostBufferSize(const u8* input) +void BluetoothEmu::CommandHostBufferSize(const u8* input) { const hci_host_buffer_size_cp* host_buffer_size = reinterpret_cast(input); @@ -1588,7 +1578,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandHostBufferSize(const u8* in SendEventCommandComplete(HCI_CMD_HOST_BUFFER_SIZE, &reply, sizeof(hci_host_buffer_size_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteLinkSupervisionTimeout(const u8* input) +void BluetoothEmu::CommandWriteLinkSupervisionTimeout(const u8* input) { const hci_write_link_supervision_timeout_cp* supervision = reinterpret_cast(input); @@ -1606,7 +1596,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteLinkSupervisionTimeout sizeof(hci_write_link_supervision_timeout_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteInquiryScanType(const u8* input) +void BluetoothEmu::CommandWriteInquiryScanType(const u8* input) { const hci_write_inquiry_scan_type_cp* set_event_filter = reinterpret_cast(input); @@ -1621,7 +1611,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteInquiryScanType(const sizeof(hci_write_inquiry_scan_type_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteInquiryMode(const u8* input) +void BluetoothEmu::CommandWriteInquiryMode(const u8* input) { const hci_write_inquiry_mode_cp* inquiry_mode = reinterpret_cast(input); @@ -1639,7 +1629,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteInquiryMode(const u8* SendEventCommandComplete(HCI_CMD_WRITE_INQUIRY_MODE, &reply, sizeof(hci_write_inquiry_mode_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWritePageScanType(const u8* input) +void BluetoothEmu::CommandWritePageScanType(const u8* input) { const hci_write_page_scan_type_cp* write_page_scan_type = reinterpret_cast(input); @@ -1657,7 +1647,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWritePageScanType(const u8* sizeof(hci_write_page_scan_type_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadLocalVer(const u8* input) +void BluetoothEmu::CommandReadLocalVer(const u8* input) { hci_read_local_ver_rp reply; reply.status = 0x00; @@ -1678,7 +1668,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadLocalVer(const u8* inpu SendEventCommandComplete(HCI_CMD_READ_LOCAL_VER, &reply, sizeof(hci_read_local_ver_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadLocalFeatures(const u8* input) +void BluetoothEmu::CommandReadLocalFeatures(const u8* input) { hci_read_local_features_rp reply; reply.status = 0x00; @@ -1700,7 +1690,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadLocalFeatures(const u8* SendEventCommandComplete(HCI_CMD_READ_LOCAL_FEATURES, &reply, sizeof(hci_read_local_features_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadBufferSize(const u8* input) +void BluetoothEmu::CommandReadBufferSize(const u8* input) { hci_read_buffer_size_rp reply; reply.status = 0x00; @@ -1722,7 +1712,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadBufferSize(const u8* in SendEventCommandComplete(HCI_CMD_READ_BUFFER_SIZE, &reply, sizeof(hci_read_buffer_size_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadBDAdrr(const u8* input) +void BluetoothEmu::CommandReadBDAdrr(const u8* input) { hci_read_bdaddr_rp reply; reply.status = 0x00; @@ -1737,7 +1727,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadBDAdrr(const u8* input) SendEventCommandComplete(HCI_CMD_READ_BDADDR, &reply, sizeof(hci_read_bdaddr_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandVendorSpecific_FC4F(const u8* input, u32 size) +void BluetoothEmu::CommandVendorSpecific_FC4F(const u8* input, u32 size) { // callstack... // BTM_VendorSpecificCommad() @@ -1757,7 +1747,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandVendorSpecific_FC4F(const u SendEventCommandComplete(0xFC4F, &reply, sizeof(hci_status_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandVendorSpecific_FC4C(const u8* input, u32 size) +void BluetoothEmu::CommandVendorSpecific_FC4C(const u8* input, u32 size) { hci_status_rp reply; reply.status = 0x00; @@ -1774,7 +1764,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandVendorSpecific_FC4C(const u // --- helper // // -CWII_IPC_HLE_WiiMote* CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::AccessWiiMote(const bdaddr_t& _rAddr) +WiimoteDevice* BluetoothEmu::AccessWiiMote(const bdaddr_t& _rAddr) { for (auto& wiimote : m_WiiMotes) { @@ -1789,7 +1779,7 @@ CWII_IPC_HLE_WiiMote* CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::AccessWiiMote(con return nullptr; } -CWII_IPC_HLE_WiiMote* CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::AccessWiiMote(u16 _ConnectionHandle) +WiimoteDevice* BluetoothEmu::AccessWiiMote(u16 _ConnectionHandle) { for (auto& wiimote : m_WiiMotes) { @@ -1802,8 +1792,7 @@ CWII_IPC_HLE_WiiMote* CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::AccessWiiMote(u16 return nullptr; } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::DisplayDisconnectMessage(const int wiimoteNumber, - const int reason) +void BluetoothEmu::DisplayDisconnectMessage(const int wiimoteNumber, const int reason) { // TODO: If someone wants to be fancy we could also figure out what the values for pDiscon->reason // mean @@ -1811,5 +1800,6 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::DisplayDisconnectMessage(const int Core::DisplayMessage( StringFromFormat("Wii Remote %i disconnected by emulated software", wiimoteNumber), 3000); } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/USB/Bluetooth/BTEmu.h b/Source/Core/Core/IOS/USB/Bluetooth/BTEmu.h index 66146d3e6c..960dac4d49 100644 --- a/Source/Core/Core/IOS/USB/Bluetooth/BTEmu.h +++ b/Source/Core/Core/IOS/USB/Bluetooth/BTEmu.h @@ -25,8 +25,6 @@ namespace IOS { namespace HLE { -class CWII_IPC_HLE_WiiMote; - struct SQueuedEvent { u8 m_buffer[1024] = {0}; @@ -37,17 +35,18 @@ struct SQueuedEvent SQueuedEvent() = default; }; +namespace Device +{ // Important to remember that this class is for /dev/usb/oh1/57e/305 ONLY // /dev/usb/oh1 -> internal usb bus // 57e/305 -> VendorID/ProductID of device on usb bus // This device is ONLY the internal Bluetooth module (based on BCM2045 chip) -class CWII_IPC_HLE_Device_usb_oh1_57e_305_emu final - : public CWII_IPC_HLE_Device_usb_oh1_57e_305_base +class BluetoothEmu final : public BluetoothBase { public: - CWII_IPC_HLE_Device_usb_oh1_57e_305_emu(u32 _DeviceID, const std::string& _rDeviceName); + BluetoothEmu(u32 device_id, const std::string& device_name); - virtual ~CWII_IPC_HLE_Device_usb_oh1_57e_305_emu(); + virtual ~BluetoothEmu(); void Close() override; IPCCommandResult IOCtlV(const IOSIOCtlVRequest& request) override; @@ -59,9 +58,9 @@ public: bool RemoteDisconnect(u16 _connectionHandle); - std::vector m_WiiMotes; - CWII_IPC_HLE_WiiMote* AccessWiiMote(const bdaddr_t& _rAddr); - CWII_IPC_HLE_WiiMote* AccessWiiMote(u16 _ConnectionHandle); + std::vector m_WiiMotes; + WiimoteDevice* AccessWiiMote(const bdaddr_t& _rAddr); + WiimoteDevice* AccessWiiMote(u16 _ConnectionHandle); void DoState(PointerWrap& p) override; @@ -112,7 +111,7 @@ private: bool SendEventInquiryResponse(); bool SendEventInquiryComplete(); bool SendEventRemoteNameReq(const bdaddr_t& _bd); - bool SendEventRequestConnection(CWII_IPC_HLE_WiiMote& _rWiiMote); + bool SendEventRequestConnection(WiimoteDevice& _rWiiMote); bool SendEventConnectionComplete(const bdaddr_t& _bd); bool SendEventReadClockOffsetComplete(u16 _connectionHandle); bool SendEventConPacketTypeChange(u16 _connectionHandle, u16 _packetType); @@ -194,5 +193,6 @@ private: }; #pragma pack(pop) }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp b/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp index bb550c4000..06c28eaaa0 100644 --- a/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp +++ b/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp @@ -66,9 +66,10 @@ static bool IsBluetoothDevice(const libusb_interface_descriptor& descriptor) descriptor.bInterfaceProtocol == PROTOCOL_BLUETOOTH; } -CWII_IPC_HLE_Device_usb_oh1_57e_305_real::CWII_IPC_HLE_Device_usb_oh1_57e_305_real( - u32 device_id, const std::string& device_name) - : CWII_IPC_HLE_Device_usb_oh1_57e_305_base(device_id, device_name) +namespace Device +{ +BluetoothReal::BluetoothReal(u32 device_id, const std::string& device_name) + : BluetoothBase(device_id, device_name) { const int ret = libusb_init(&m_libusb_context); _assert_msg_(WII_IPC_WIIMOTE, ret == 0, "Failed to init libusb."); @@ -76,7 +77,7 @@ CWII_IPC_HLE_Device_usb_oh1_57e_305_real::CWII_IPC_HLE_Device_usb_oh1_57e_305_re LoadLinkKeys(); } -CWII_IPC_HLE_Device_usb_oh1_57e_305_real::~CWII_IPC_HLE_Device_usb_oh1_57e_305_real() +BluetoothReal::~BluetoothReal() { if (m_handle != nullptr) { @@ -94,7 +95,7 @@ CWII_IPC_HLE_Device_usb_oh1_57e_305_real::~CWII_IPC_HLE_Device_usb_oh1_57e_305_r SaveLinkKeys(); } -IOSReturnCode CWII_IPC_HLE_Device_usb_oh1_57e_305_real::Open(const IOSOpenRequest& request) +IOSReturnCode BluetoothReal::Open(const IOSOpenRequest& request) { libusb_device** list; const ssize_t cnt = libusb_get_device_list(m_libusb_context, &list); @@ -150,7 +151,7 @@ IOSReturnCode CWII_IPC_HLE_Device_usb_oh1_57e_305_real::Open(const IOSOpenReques return IPC_SUCCESS; } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::Close() +void BluetoothReal::Close() { if (m_handle) { @@ -163,7 +164,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::Close() m_is_active = false; } -IPCCommandResult CWII_IPC_HLE_Device_usb_oh1_57e_305_real::IOCtlV(const IOSIOCtlVRequest& request) +IPCCommandResult BluetoothReal::IOCtlV(const IOSIOCtlVRequest& request) { if (!m_is_wii_bt_module && s_need_reset_keys.TestAndClear()) { @@ -266,7 +267,7 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_oh1_57e_305_real::IOCtlV(const IOSIOCtl return GetNoReply(); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::DoState(PointerWrap& p) +void BluetoothReal::DoState(PointerWrap& p) { bool passthrough_bluetooth = true; p.Do(passthrough_bluetooth); @@ -280,7 +281,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::DoState(PointerWrap& p) } } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::UpdateSyncButtonState(const bool is_held) +void BluetoothReal::UpdateSyncButtonState(const bool is_held) { if (m_sync_button_state == SyncButtonState::Unpressed && is_held) { @@ -298,17 +299,17 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::UpdateSyncButtonState(const bool m_sync_button_state = SyncButtonState::Unpressed; } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::TriggerSyncButtonPressedEvent() +void BluetoothReal::TriggerSyncButtonPressedEvent() { m_sync_button_state = SyncButtonState::Pressed; } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::TriggerSyncButtonHeldEvent() +void BluetoothReal::TriggerSyncButtonHeldEvent() { m_sync_button_state = SyncButtonState::LongPressed; } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::WaitForHCICommandComplete(const u16 opcode) +void BluetoothReal::WaitForHCICommandComplete(const u16 opcode) { int actual_length; std::vector buffer(1024); @@ -323,7 +324,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::WaitForHCICommandComplete(const u } } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::SendHCIResetCommand() +void BluetoothReal::SendHCIResetCommand() { const u8 type = LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE; u8 packet[3] = {}; @@ -333,7 +334,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::SendHCIResetCommand() INFO_LOG(WII_IPC_WIIMOTE, "Sent a reset command to adapter"); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::SendHCIDeleteLinkKeyCommand() +void BluetoothReal::SendHCIDeleteLinkKeyCommand() { const u8 type = LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE; std::vector packet(sizeof(hci_cmd_hdr_t) + sizeof(hci_delete_stored_link_key_cp)); @@ -350,7 +351,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::SendHCIDeleteLinkKeyCommand() TIMEOUT); } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_real::SendHCIStoreLinkKeyCommand() +bool BluetoothReal::SendHCIStoreLinkKeyCommand() { if (s_link_keys.empty()) return false; @@ -389,7 +390,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_real::SendHCIStoreLinkKeyCommand() return true; } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::FakeVendorCommandReply(CtrlBuffer& ctrl) +void BluetoothReal::FakeVendorCommandReply(CtrlBuffer& ctrl) { u8* packet = Memory::GetPointer(ctrl.m_payload_addr); auto* hci_event = reinterpret_cast(packet); @@ -406,7 +407,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::FakeVendorCommandReply(CtrlBuffer // - it will cause a u8 underflow and royally screw things up. // Therefore, the reply to this command has to be faked to avoid random, weird issues // (including Wiimote disconnects and "event mismatch" warning messages). -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::FakeReadBufferSizeReply(CtrlBuffer& ctrl) +void BluetoothReal::FakeReadBufferSizeReply(CtrlBuffer& ctrl) { u8* packet = Memory::GetPointer(ctrl.m_payload_addr); auto* hci_event = reinterpret_cast(packet); @@ -427,8 +428,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::FakeReadBufferSizeReply(CtrlBuffe static_cast(sizeof(SHCIEventCommand) + sizeof(hci_read_buffer_size_rp))); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::FakeSyncButtonEvent(CtrlBuffer& ctrl, - const u8* payload, const u8 size) +void BluetoothReal::FakeSyncButtonEvent(CtrlBuffer& ctrl, const u8* payload, const u8 size) { u8* packet = Memory::GetPointer(ctrl.m_payload_addr); auto* hci_event = reinterpret_cast(packet); @@ -442,7 +442,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::FakeSyncButtonEvent(CtrlBuffer& c // > HCI Event: Vendor (0xff) plen 1 // 08 // This causes the emulated software to perform a BT inquiry and connect to found Wiimotes. -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::FakeSyncButtonPressedEvent(CtrlBuffer& ctrl) +void BluetoothReal::FakeSyncButtonPressedEvent(CtrlBuffer& ctrl) { NOTICE_LOG(WII_IPC_WIIMOTE, "Faking 'sync button pressed' (0x08) event packet"); const u8 payload[1] = {0x08}; @@ -451,7 +451,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::FakeSyncButtonPressedEvent(CtrlBu } // When the red sync button is held for 10 seconds, a HCI event with payload 09 is sent. -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::FakeSyncButtonHeldEvent(CtrlBuffer& ctrl) +void BluetoothReal::FakeSyncButtonHeldEvent(CtrlBuffer& ctrl) { NOTICE_LOG(WII_IPC_WIIMOTE, "Faking 'sync button held' (0x09) event packet"); const u8 payload[1] = {0x09}; @@ -459,7 +459,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::FakeSyncButtonHeldEvent(CtrlBuffe m_sync_button_state = SyncButtonState::Ignored; } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::LoadLinkKeys() +void BluetoothReal::LoadLinkKeys() { const std::string& entries = SConfig::GetInstance().m_bt_passthrough_link_keys; if (entries.empty()) @@ -490,7 +490,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::LoadLinkKeys() } } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::SaveLinkKeys() +void BluetoothReal::SaveLinkKeys() { std::ostringstream oss; for (const auto& entry : s_link_keys) @@ -511,7 +511,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::SaveLinkKeys() SConfig::GetInstance().m_bt_passthrough_link_keys = config_string; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_real::OpenDevice(libusb_device* device) +bool BluetoothReal::OpenDevice(libusb_device* device) { m_device = libusb_ref_device(device); const int ret = libusb_open(m_device, &m_handle); @@ -536,15 +536,15 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_real::OpenDevice(libusb_device* device) return true; } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::StartTransferThread() +void BluetoothReal::StartTransferThread() { if (m_thread_running.IsSet()) return; m_thread_running.Set(); - m_thread = std::thread(&CWII_IPC_HLE_Device_usb_oh1_57e_305_real::TransferThread, this); + m_thread = std::thread(&BluetoothReal::TransferThread, this); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::StopTransferThread() +void BluetoothReal::StopTransferThread() { if (m_thread_running.TestAndClear()) { @@ -553,7 +553,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::StopTransferThread() } } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::TransferThread() +void BluetoothReal::TransferThread() { Common::SetCurrentThreadName("BT USB Thread"); while (m_thread_running.IsSet()) @@ -563,7 +563,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::TransferThread() } // The callbacks are called from libusb code on a separate thread. -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::CommandCallback(libusb_transfer* tr) +void BluetoothReal::CommandCallback(libusb_transfer* tr) { const std::unique_ptr cmd(static_cast(tr->user_data)); if (tr->status != LIBUSB_TRANSFER_COMPLETED && tr->status != LIBUSB_TRANSFER_NO_DEVICE) @@ -584,7 +584,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::CommandCallback(libusb_transfer* EnqueueReply(cmd->ios_request, tr->actual_length, 0, CoreTiming::FromThread::NON_CPU); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::TransferCallback(libusb_transfer* tr) +void BluetoothReal::TransferCallback(libusb_transfer* tr) { const std::unique_ptr ctrl(static_cast(tr->user_data)); if (tr->status != LIBUSB_TRANSFER_COMPLETED && tr->status != LIBUSB_TRANSFER_TIMED_OUT && @@ -627,5 +627,6 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::TransferCallback(libusb_transfer* EnqueueReply(ctrl->ios_request, tr->actual_length, 0, CoreTiming::FromThread::NON_CPU); } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/USB/Bluetooth/BTReal.h b/Source/Core/Core/IOS/USB/Bluetooth/BTReal.h index 316ad3cef9..692e3fb3b8 100644 --- a/Source/Core/Core/IOS/USB/Bluetooth/BTReal.h +++ b/Source/Core/Core/IOS/USB/Bluetooth/BTReal.h @@ -39,12 +39,13 @@ enum class SyncButtonState using btaddr_t = std::array; using linkkey_t = std::array; -class CWII_IPC_HLE_Device_usb_oh1_57e_305_real final - : public CWII_IPC_HLE_Device_usb_oh1_57e_305_base +namespace Device +{ +class BluetoothReal final : public BluetoothBase { public: - CWII_IPC_HLE_Device_usb_oh1_57e_305_real(u32 device_id, const std::string& device_name); - ~CWII_IPC_HLE_Device_usb_oh1_57e_305_real() override; + BluetoothReal(u32 device_id, const std::string& device_name); + ~BluetoothReal() override; IOSReturnCode Open(const IOSOpenRequest& request) override; void Close() override; @@ -100,6 +101,7 @@ private: static void CommandCallback(libusb_transfer* transfer); static void TransferCallback(libusb_transfer* transfer); }; +} // namespace Device } // namespace HLE } // namespace IOS @@ -110,7 +112,10 @@ namespace IOS { namespace HLE { -using CWII_IPC_HLE_Device_usb_oh1_57e_305_real = CWII_IPC_HLE_Device_usb_oh1_57e_305_stub; +namespace Device +{ +using BluetoothReal = BluetoothStub; +} // namespace Device } // namespace HLE } // namespace IOS #endif diff --git a/Source/Core/Core/IOS/USB/Bluetooth/BTStub.cpp b/Source/Core/Core/IOS/USB/Bluetooth/BTStub.cpp index 1c9b20222f..1a76484427 100644 --- a/Source/Core/Core/IOS/USB/Bluetooth/BTStub.cpp +++ b/Source/Core/Core/IOS/USB/Bluetooth/BTStub.cpp @@ -16,17 +16,20 @@ namespace IOS { namespace HLE { -IOSReturnCode CWII_IPC_HLE_Device_usb_oh1_57e_305_stub::Open(const IOSOpenRequest& request) +namespace Device +{ +IOSReturnCode BluetoothStub::Open(const IOSOpenRequest& request) { PanicAlertT("Bluetooth passthrough mode is enabled, but Dolphin was built without libusb." " Passthrough mode cannot be used."); return IPC_ENOENT; } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_stub::DoState(PointerWrap& p) +void BluetoothStub::DoState(PointerWrap& p) { Core::DisplayMessage("The current IPC_HLE_Device_usb is a stub. Aborting load.", 4000); p.SetMode(PointerWrap::MODE_VERIFY); } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/USB/Bluetooth/BTStub.h b/Source/Core/Core/IOS/USB/Bluetooth/BTStub.h index 875d888f0d..0d78d991d0 100644 --- a/Source/Core/Core/IOS/USB/Bluetooth/BTStub.h +++ b/Source/Core/Core/IOS/USB/Bluetooth/BTStub.h @@ -16,16 +16,18 @@ namespace IOS { namespace HLE { -class CWII_IPC_HLE_Device_usb_oh1_57e_305_stub final - : public CWII_IPC_HLE_Device_usb_oh1_57e_305_base +namespace Device +{ +class BluetoothStub final : public BluetoothBase { public: - CWII_IPC_HLE_Device_usb_oh1_57e_305_stub(const u32 device_id, const std::string& device_name) - : CWII_IPC_HLE_Device_usb_oh1_57e_305_base(device_id, device_name) + BluetoothStub(const u32 device_id, const std::string& device_name) + : BluetoothBase(device_id, device_name) { } IOSReturnCode Open(const IOSOpenRequest& request) override; void DoState(PointerWrap& p) override; }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/USB/Bluetooth/WiimoteDevice.cpp b/Source/Core/Core/IOS/USB/Bluetooth/WiimoteDevice.cpp index 0735a41034..57caa8743a 100644 --- a/Source/Core/Core/IOS/USB/Bluetooth/WiimoteDevice.cpp +++ b/Source/Core/Core/IOS/USB/Bluetooth/WiimoteDevice.cpp @@ -25,20 +25,19 @@ namespace IOS { namespace HLE { -static CWII_IPC_HLE_Device_usb_oh1_57e_305_emu* s_Usb = nullptr; +static Device::BluetoothEmu* s_Usb = nullptr; -CWII_IPC_HLE_Device_usb_oh1_57e_305_emu* GetUsbPointer() +Device::BluetoothEmu* GetUsbPointer() { return s_Usb; } -void SetUsbPointer(CWII_IPC_HLE_Device_usb_oh1_57e_305_emu* ptr) +void SetUsbPointer(Device::BluetoothEmu* ptr) { s_Usb = ptr; } -CWII_IPC_HLE_WiiMote::CWII_IPC_HLE_WiiMote(CWII_IPC_HLE_Device_usb_oh1_57e_305_emu* host, - int number, bdaddr_t bd, bool ready) +WiimoteDevice::WiimoteDevice(Device::BluetoothEmu* host, int number, bdaddr_t bd, bool ready) : m_BD(bd), m_Name(number == WIIMOTE_BALANCE_BOARD ? "Nintendo RVL-WBC-01" : "Nintendo RVL-CNT-01"), m_pHost(host) @@ -76,7 +75,7 @@ CWII_IPC_HLE_WiiMote::CWII_IPC_HLE_WiiMote(CWII_IPC_HLE_Device_usb_oh1_57e_305_e lmp_subversion = 0x229; } -void CWII_IPC_HLE_WiiMote::DoState(PointerWrap& p) +void WiimoteDevice::DoState(PointerWrap& p) { bool passthrough_bluetooth = false; p.Do(passthrough_bluetooth); @@ -88,7 +87,7 @@ void CWII_IPC_HLE_WiiMote::DoState(PointerWrap& p) return; } - // this function is usually not called... see CWII_IPC_HLE_Device_usb_oh1_57e_305::DoState + // this function is usually not called... see Device::BluetoothEmu::DoState p.Do(m_ConnectionState); @@ -124,7 +123,7 @@ void CWII_IPC_HLE_WiiMote::DoState(PointerWrap& p) // // -bool CWII_IPC_HLE_WiiMote::LinkChannel() +bool WiimoteDevice::LinkChannel() { if (m_ConnectionState != CONN_LINKING) return false; @@ -189,7 +188,7 @@ bool CWII_IPC_HLE_WiiMote::LinkChannel() // // // -void CWII_IPC_HLE_WiiMote::Activate(bool ready) +void WiimoteDevice::Activate(bool ready) { if (ready && (m_ConnectionState == CONN_INACTIVE)) { @@ -202,13 +201,13 @@ void CWII_IPC_HLE_WiiMote::Activate(bool ready) } } -void CWII_IPC_HLE_WiiMote::EventConnectionAccepted() +void WiimoteDevice::EventConnectionAccepted() { DEBUG_LOG(WII_IPC_WIIMOTE, "ConnectionState %x -> CONN_LINKING", m_ConnectionState); m_ConnectionState = CONN_LINKING; } -void CWII_IPC_HLE_WiiMote::EventDisconnect() +void WiimoteDevice::EventDisconnect() { // Send disconnect message to plugin Wiimote::ControlChannel(m_ConnectionHandle & 0xFF, 99, nullptr, 0); @@ -218,7 +217,7 @@ void CWII_IPC_HLE_WiiMote::EventDisconnect() ResetChannels(); } -bool CWII_IPC_HLE_WiiMote::EventPagingChanged(u8 _pageMode) +bool WiimoteDevice::EventPagingChanged(u8 _pageMode) { if ((m_ConnectionState == CONN_READY) && (_pageMode & HCI_PAGE_SCAN_ENABLE)) return true; @@ -226,7 +225,7 @@ bool CWII_IPC_HLE_WiiMote::EventPagingChanged(u8 _pageMode) return false; } -void CWII_IPC_HLE_WiiMote::ResetChannels() +void WiimoteDevice::ResetChannels() { // reset connection process m_HIDControlChannel_Connected = false; @@ -251,7 +250,7 @@ void CWII_IPC_HLE_WiiMote::ResetChannels() // // This function receives L2CAP commands from the CPU -void CWII_IPC_HLE_WiiMote::ExecuteL2capCmd(u8* _pData, u32 _Size) +void WiimoteDevice::ExecuteL2capCmd(u8* _pData, u32 _Size) { // parse the command l2cap_hdr_t* pHeader = (l2cap_hdr_t*)_pData; @@ -319,7 +318,7 @@ void CWII_IPC_HLE_WiiMote::ExecuteL2capCmd(u8* _pData, u32 _Size) } } -void CWII_IPC_HLE_WiiMote::SignalChannel(u8* _pData, u32 _Size) +void WiimoteDevice::SignalChannel(u8* _pData, u32 _Size) { while (_Size >= sizeof(l2cap_cmd_hdr_t)) { @@ -374,7 +373,7 @@ void CWII_IPC_HLE_WiiMote::SignalChannel(u8* _pData, u32 _Size) // // -void CWII_IPC_HLE_WiiMote::ReceiveConnectionReq(u8 _Ident, u8* _pData, u32 _Size) +void WiimoteDevice::ReceiveConnectionReq(u8 _Ident, u8* _pData, u32 _Size) { l2cap_con_req_cp* pCommandConnectionReq = (l2cap_con_req_cp*)_pData; @@ -409,7 +408,7 @@ void CWII_IPC_HLE_WiiMote::ReceiveConnectionReq(u8 _Ident, u8* _pData, u32 _Size */ } -void CWII_IPC_HLE_WiiMote::ReceiveConnectionResponse(u8 _Ident, u8* _pData, u32 _Size) +void WiimoteDevice::ReceiveConnectionResponse(u8 _Ident, u8* _pData, u32 _Size) { l2cap_con_rsp_cp* rsp = (l2cap_con_rsp_cp*)_pData; @@ -435,7 +434,7 @@ void CWII_IPC_HLE_WiiMote::ReceiveConnectionResponse(u8 _Ident, u8* _pData, u32 m_HIDInterruptChannel_Connected = true; } -void CWII_IPC_HLE_WiiMote::ReceiveConfigurationReq(u8 _Ident, u8* _pData, u32 _Size) +void WiimoteDevice::ReceiveConfigurationReq(u8 _Ident, u8* _pData, u32 _Size) { u32 Offset = 0; l2cap_cfg_req_cp* pCommandConfigReq = (l2cap_cfg_req_cp*)_pData; @@ -511,7 +510,7 @@ void CWII_IPC_HLE_WiiMote::ReceiveConfigurationReq(u8 _Ident, u8* _pData, u32 _S m_HIDInterruptChannel_Connected = true; } -void CWII_IPC_HLE_WiiMote::ReceiveConfigurationResponse(u8 _Ident, u8* _pData, u32 _Size) +void WiimoteDevice::ReceiveConfigurationResponse(u8 _Ident, u8* _pData, u32 _Size) { l2cap_cfg_rsp_cp* rsp = (l2cap_cfg_rsp_cp*)_pData; @@ -531,7 +530,7 @@ void CWII_IPC_HLE_WiiMote::ReceiveConfigurationResponse(u8 _Ident, u8* _pData, u m_HIDInterruptChannel_Config = true; } -void CWII_IPC_HLE_WiiMote::ReceiveDisconnectionReq(u8 _Ident, u8* _pData, u32 _Size) +void WiimoteDevice::ReceiveDisconnectionReq(u8 _Ident, u8* _pData, u32 _Size) { l2cap_discon_req_cp* pCommandDisconnectionReq = (l2cap_discon_req_cp*)_pData; @@ -561,7 +560,7 @@ void CWII_IPC_HLE_WiiMote::ReceiveDisconnectionReq(u8 _Ident, u8* _pData, u32 _S // // We assume Wiimote is always connected -void CWII_IPC_HLE_WiiMote::SendConnectionRequest(u16 scid, u16 psm) +void WiimoteDevice::SendConnectionRequest(u16 scid, u16 psm) { // create the channel SChannel& rChannel = m_Channel[scid]; @@ -580,7 +579,7 @@ void CWII_IPC_HLE_WiiMote::SendConnectionRequest(u16 scid, u16 psm) } // We don't initially disconnect Wiimote though ... -void CWII_IPC_HLE_WiiMote::SendDisconnectRequest(u16 scid) +void WiimoteDevice::SendDisconnectRequest(u16 scid) { // create the channel SChannel& rChannel = m_Channel[scid]; @@ -597,7 +596,7 @@ void CWII_IPC_HLE_WiiMote::SendDisconnectRequest(u16 scid) (u8*)&cr); } -void CWII_IPC_HLE_WiiMote::SendConfigurationRequest(u16 scid, u16 MTU, u16 FlushTimeOut) +void WiimoteDevice::SendConfigurationRequest(u16 scid, u16 MTU, u16 FlushTimeOut) { _dbg_assert_(WII_IPC_WIIMOTE, DoesChannelExist(scid)); SChannel& rChannel = m_Channel[scid]; @@ -666,9 +665,9 @@ void CWII_IPC_HLE_WiiMote::SendConfigurationRequest(u16 scid, u16 MTU, u16 Flush #define SDP_SEQ8 0x35 #define SDP_SEQ16 0x36 -void CWII_IPC_HLE_WiiMote::SDPSendServiceSearchResponse(u16 cid, u16 TransactionID, - u8* pServiceSearchPattern, - u16 MaximumServiceRecordCount) +void WiimoteDevice::SDPSendServiceSearchResponse(u16 cid, u16 TransactionID, + u8* pServiceSearchPattern, + u16 MaximumServiceRecordCount) { // verify block... we handle search pattern for HID service only { @@ -765,11 +764,10 @@ static int ParseAttribList(u8* pAttribIDList, u16& _startID, u16& _endID) return attribOffset; } -void CWII_IPC_HLE_WiiMote::SDPSendServiceAttributeResponse(u16 cid, u16 TransactionID, - u32 ServiceHandle, u16 startAttrID, - u16 endAttrID, - u16 MaximumAttributeByteCount, - u8* pContinuationState) +void WiimoteDevice::SDPSendServiceAttributeResponse(u16 cid, u16 TransactionID, u32 ServiceHandle, + u16 startAttrID, u16 endAttrID, + u16 MaximumAttributeByteCount, + u8* pContinuationState) { if (ServiceHandle != 0x10000) { @@ -808,7 +806,7 @@ void CWII_IPC_HLE_WiiMote::SDPSendServiceAttributeResponse(u16 cid, u16 Transact // "test response: "); } -void CWII_IPC_HLE_WiiMote::HandleSDP(u16 cid, u8* _pData, u32 _Size) +void WiimoteDevice::HandleSDP(u16 cid, u8* _pData, u32 _Size) { // Debugger::PrintDataBuffer(LogTypes::WIIMOTE, _pData, _Size, "HandleSDP: "); @@ -874,8 +872,7 @@ void CWII_IPC_HLE_WiiMote::HandleSDP(u16 cid, u8* _pData, u32 _Size) // // -void CWII_IPC_HLE_WiiMote::SendCommandToACL(u8 _Ident, u8 _Code, u8 _CommandLength, - u8* _pCommandData) +void WiimoteDevice::SendCommandToACL(u8 _Ident, u8 _Code, u8 _CommandLength, u8* _pCommandData) { u8 DataFrame[1024]; u32 Offset = 0; @@ -904,7 +901,7 @@ void CWII_IPC_HLE_WiiMote::SendCommandToACL(u8 _Ident, u8 _Code, u8 _CommandLeng // "m_pHost->SendACLPacket: "); } -void CWII_IPC_HLE_WiiMote::ReceiveL2capData(u16 scid, const void* _pData, u32 _Size) +void WiimoteDevice::ReceiveL2capData(u16 scid, const void* _pData, u32 _Size) { // Allocate DataFrame u8 DataFrame[1024]; diff --git a/Source/Core/Core/IOS/USB/Bluetooth/WiimoteDevice.h b/Source/Core/Core/IOS/USB/Bluetooth/WiimoteDevice.h index ac7a1abd4c..c7e1066d5f 100644 --- a/Source/Core/Core/IOS/USB/Bluetooth/WiimoteDevice.h +++ b/Source/Core/Core/IOS/USB/Bluetooth/WiimoteDevice.h @@ -18,10 +18,13 @@ namespace IOS { namespace HLE { -class CWII_IPC_HLE_Device_usb_oh1_57e_305_emu; +namespace Device +{ +class BluetoothEmu; +} -CWII_IPC_HLE_Device_usb_oh1_57e_305_emu* GetUsbPointer(); -void SetUsbPointer(CWII_IPC_HLE_Device_usb_oh1_57e_305_emu* ptr); +Device::BluetoothEmu* GetUsbPointer(); +void SetUsbPointer(Device::BluetoothEmu* ptr); class CBigEndianBuffer { @@ -38,13 +41,11 @@ private: u8* m_pBuffer; }; -class CWII_IPC_HLE_WiiMote +class WiimoteDevice { public: - CWII_IPC_HLE_WiiMote(CWII_IPC_HLE_Device_usb_oh1_57e_305_emu* _pHost, int _Number, bdaddr_t _BD, - bool ready = false); + WiimoteDevice(Device::BluetoothEmu* _pHost, int _Number, bdaddr_t _BD, bool ready = false); - virtual ~CWII_IPC_HLE_WiiMote() {} void DoState(PointerWrap& p); // ugly Host handling.... @@ -99,7 +100,7 @@ private: u16 lmp_subversion; u8 m_LinkKey[HCI_KEY_SIZE]; std::string m_Name; - CWII_IPC_HLE_Device_usb_oh1_57e_305_emu* m_pHost; + Device::BluetoothEmu* m_pHost; struct SChannel { diff --git a/Source/Core/Core/IOS/USB/USB_HIDv4.cpp b/Source/Core/Core/IOS/USB/USB_HIDv4.cpp index 11469d6eda..07c4cba414 100644 --- a/Source/Core/Core/IOS/USB/USB_HIDv4.cpp +++ b/Source/Core/Core/IOS/USB/USB_HIDv4.cpp @@ -24,11 +24,13 @@ namespace IOS { namespace HLE { -#define MAX_DEVICE_DEVNUM 256 +namespace Device +{ +constexpr int MAX_DEVICE_DEVNUM = 256; static u64 hidDeviceAliases[MAX_DEVICE_DEVNUM]; // Regular thread -void CWII_IPC_HLE_Device_hid::checkUsbUpdates(CWII_IPC_HLE_Device_hid* hid) +void USB_HIDv4::checkUsbUpdates(USB_HIDv4* hid) { timeval tv; tv.tv_sec = 0; @@ -54,7 +56,7 @@ void CWII_IPC_HLE_Device_hid::checkUsbUpdates(CWII_IPC_HLE_Device_hid* hid) return; } -void CWII_IPC_HLE_Device_hid::handleUsbUpdates(struct libusb_transfer* transfer) +void USB_HIDv4::handleUsbUpdates(struct libusb_transfer* transfer) { s32 ret = IPC_EINVAL; u32 replyAddress = (u32)(size_t)transfer->user_data; @@ -67,8 +69,7 @@ void CWII_IPC_HLE_Device_hid::handleUsbUpdates(struct libusb_transfer* transfer) EnqueueReply(request, ret, 0, CoreTiming::FromThread::NON_CPU); } -CWII_IPC_HLE_Device_hid::CWII_IPC_HLE_Device_hid(u32 _DeviceID, const std::string& _rDeviceName) - : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) +USB_HIDv4::USB_HIDv4(u32 device_id, const std::string& device_name) : Device(device_id, device_name) { deviceCommandAddress = 0; memset(hidDeviceAliases, 0, sizeof(hidDeviceAliases)); @@ -84,7 +85,7 @@ CWII_IPC_HLE_Device_hid::CWII_IPC_HLE_Device_hid(u32 _DeviceID, const std::strin } } -CWII_IPC_HLE_Device_hid::~CWII_IPC_HLE_Device_hid() +USB_HIDv4::~USB_HIDv4() { bool deinit_libusb = false; if (usb_thread_running) @@ -104,7 +105,7 @@ CWII_IPC_HLE_Device_hid::~CWII_IPC_HLE_Device_hid() libusb_exit(nullptr); } -IPCCommandResult CWII_IPC_HLE_Device_hid::IOCtl(const IOSIOCtlRequest& request) +IPCCommandResult USB_HIDv4::IOCtl(const IOSIOCtlRequest& request) { if (Core::g_want_determinism) { @@ -229,7 +230,7 @@ IPCCommandResult CWII_IPC_HLE_Device_hid::IOCtl(const IOSIOCtlRequest& request) return GetDefaultReply(return_value); } -bool CWII_IPC_HLE_Device_hid::ClaimDevice(libusb_device_handle* dev) +bool USB_HIDv4::ClaimDevice(libusb_device_handle* dev) { int ret = 0; if ((ret = libusb_kernel_driver_active(dev, 0)) == 1) @@ -255,15 +256,15 @@ bool CWII_IPC_HLE_Device_hid::ClaimDevice(libusb_device_handle* dev) return true; } -IPCCommandResult CWII_IPC_HLE_Device_hid::IOCtlV(const IOSIOCtlVRequest& request) +IPCCommandResult USB_HIDv4::IOCtlV(const IOSIOCtlVRequest& request) { Dolphin_Debugger::PrintCallstack(LogTypes::WII_IPC_HID, LogTypes::LWARNING); request.DumpUnknown(GetDeviceName(), LogTypes::WII_IPC_HID); return GetDefaultReply(IPC_SUCCESS); } -void CWII_IPC_HLE_Device_hid::ConvertDeviceToWii(WiiHIDDeviceDescriptor* dest, - const struct libusb_device_descriptor* src) +void USB_HIDv4::ConvertDeviceToWii(WiiHIDDeviceDescriptor* dest, + const struct libusb_device_descriptor* src) { dest->bLength = src->bLength; dest->bDescriptorType = src->bDescriptorType; @@ -281,27 +282,27 @@ void CWII_IPC_HLE_Device_hid::ConvertDeviceToWii(WiiHIDDeviceDescriptor* dest, dest->bNumConfigurations = src->bNumConfigurations; } -void CWII_IPC_HLE_Device_hid::ConvertConfigToWii(WiiHIDConfigDescriptor* dest, - const struct libusb_config_descriptor* src) +void USB_HIDv4::ConvertConfigToWii(WiiHIDConfigDescriptor* dest, + const struct libusb_config_descriptor* src) { memcpy(dest, src, sizeof(WiiHIDConfigDescriptor)); dest->wTotalLength = Common::swap16(dest->wTotalLength); } -void CWII_IPC_HLE_Device_hid::ConvertInterfaceToWii(WiiHIDInterfaceDescriptor* dest, - const struct libusb_interface_descriptor* src) +void USB_HIDv4::ConvertInterfaceToWii(WiiHIDInterfaceDescriptor* dest, + const struct libusb_interface_descriptor* src) { memcpy(dest, src, sizeof(WiiHIDInterfaceDescriptor)); } -void CWII_IPC_HLE_Device_hid::ConvertEndpointToWii(WiiHIDEndpointDescriptor* dest, - const struct libusb_endpoint_descriptor* src) +void USB_HIDv4::ConvertEndpointToWii(WiiHIDEndpointDescriptor* dest, + const struct libusb_endpoint_descriptor* src) { memcpy(dest, src, sizeof(WiiHIDEndpointDescriptor)); dest->wMaxPacketSize = Common::swap16(dest->wMaxPacketSize); } -void CWII_IPC_HLE_Device_hid::FillOutDevices(const IOSIOCtlRequest& request) +void USB_HIDv4::FillOutDevices(const IOSIOCtlRequest& request) { static u16 check = 1; int OffsetBuffer = request.buffer_out; @@ -441,7 +442,7 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(const IOSIOCtlRequest& request) Memory::Write_U32(0xFFFFFFFF, OffsetBuffer); // no more devices } -libusb_device_handle* CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum) +libusb_device_handle* USB_HIDv4::GetDeviceByDevNum(u32 devNum) { libusb_device** list; libusb_device_handle* handle = nullptr; @@ -545,8 +546,7 @@ libusb_device_handle* CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum) return handle; } -int CWII_IPC_HLE_Device_hid::GetAvailableDevNum(u16 idVendor, u16 idProduct, u8 bus, u8 port, - u16 check) +int USB_HIDv4::GetAvailableDevNum(u16 idVendor, u16 idProduct, u8 bus, u8 port, u16 check) { int pos = -1; u64 unique_id = ((u64)idVendor << 32) | ((u64)idProduct << 16) | ((u64)bus << 8) | (u64)port; @@ -573,5 +573,6 @@ int CWII_IPC_HLE_Device_hid::GetAvailableDevNum(u16 idVendor, u16 idProduct, u8 return -1; } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/USB/USB_HIDv4.h b/Source/Core/Core/IOS/USB/USB_HIDv4.h index 651773189d..588fa7987a 100644 --- a/Source/Core/Core/IOS/USB/USB_HIDv4.h +++ b/Source/Core/Core/IOS/USB/USB_HIDv4.h @@ -35,12 +35,14 @@ namespace HLE #define HID_ID_MASK 0x0000FFFFFFFFFFFF #define MAX_HID_INTERFACES 1 -class CWII_IPC_HLE_Device_hid : public IWII_IPC_HLE_Device +namespace Device +{ +class USB_HIDv4 : public Device { public: - CWII_IPC_HLE_Device_hid(u32 _DeviceID, const std::string& _rDeviceName); + USB_HIDv4(u32 _DeviceID, const std::string& _rDeviceName); - virtual ~CWII_IPC_HLE_Device_hid(); + virtual ~USB_HIDv4(); IPCCommandResult IOCtlV(const IOSIOCtlVRequest& request) override; IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override; @@ -129,7 +131,7 @@ private: const libusb_interface_descriptor* src); void ConvertEndpointToWii(WiiHIDEndpointDescriptor* dest, const libusb_endpoint_descriptor* src); - static void checkUsbUpdates(CWII_IPC_HLE_Device_hid* hid); + static void checkUsbUpdates(USB_HIDv4* hid); static void LIBUSB_CALL handleUsbUpdates(libusb_transfer* transfer); libusb_device_handle* GetDeviceByDevNum(u32 devNum); @@ -140,5 +142,6 @@ private: std::thread usb_thread; bool usb_thread_running; }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/USB/USB_KBD.cpp b/Source/Core/Core/IOS/USB/USB_KBD.cpp index b45c84953b..0ac68a238f 100644 --- a/Source/Core/Core/IOS/USB/USB_KBD.cpp +++ b/Source/Core/Core/IOS/USB/USB_KBD.cpp @@ -21,7 +21,9 @@ namespace IOS { namespace HLE { -CWII_IPC_HLE_Device_usb_kbd::SMessageData::SMessageData(u32 type, u8 modifiers, u8* pressed_keys) +namespace Device +{ +USB_KBD::SMessageData::SMessageData(u32 type, u8 modifiers, u8* pressed_keys) { MsgType = Common::swap32(type); Unk1 = 0; // swapped @@ -36,15 +38,13 @@ CWII_IPC_HLE_Device_usb_kbd::SMessageData::SMessageData(u32 type, u8 modifiers, // TODO: support in netplay/movies. -CWII_IPC_HLE_Device_usb_kbd::CWII_IPC_HLE_Device_usb_kbd(u32 _DeviceID, - const std::string& _rDeviceName) - : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) +USB_KBD::USB_KBD(u32 device_id, const std::string& device_name) : Device(device_id, device_name) { } -IOSReturnCode CWII_IPC_HLE_Device_usb_kbd::Open(const IOSOpenRequest& request) +IOSReturnCode USB_KBD::Open(const IOSOpenRequest& request) { - INFO_LOG(WII_IPC_HLE, "CWII_IPC_HLE_Device_usb_kbd: Open"); + INFO_LOG(WII_IPC_HLE, "USB_KBD: Open"); IniFile ini; ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)); ini.GetOrCreateSection("USB Keyboard")->Get("Layout", &m_KeyboardLayout, KBD_LAYOUT_QWERTY); @@ -62,7 +62,7 @@ IOSReturnCode CWII_IPC_HLE_Device_usb_kbd::Open(const IOSOpenRequest& request) return IPC_SUCCESS; } -IPCCommandResult CWII_IPC_HLE_Device_usb_kbd::IOCtl(const IOSIOCtlRequest& request) +IPCCommandResult USB_KBD::IOCtl(const IOSIOCtlRequest& request) { if (SConfig::GetInstance().m_WiiKeyboard && !Core::g_want_determinism && !m_MessageQueue.empty()) { @@ -72,7 +72,7 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_kbd::IOCtl(const IOSIOCtlRequest& reque return GetDefaultReply(IPC_SUCCESS); } -bool CWII_IPC_HLE_Device_usb_kbd::IsKeyPressed(int _Key) +bool USB_KBD::IsKeyPressed(int _Key) { #ifdef _WIN32 if (GetAsyncKeyState(_Key) & 0x8000) @@ -85,7 +85,7 @@ bool CWII_IPC_HLE_Device_usb_kbd::IsKeyPressed(int _Key) #endif } -void CWII_IPC_HLE_Device_usb_kbd::Update() +void USB_KBD::Update() { if (!SConfig::GetInstance().m_WiiKeyboard || Core::g_want_determinism || !m_is_active) return; @@ -165,7 +165,7 @@ void CWII_IPC_HLE_Device_usb_kbd::Update() // Crazy ugly #ifdef _WIN32 -u8 CWII_IPC_HLE_Device_usb_kbd::m_KeyCodesQWERTY[256] = { +u8 USB_KBD::m_KeyCodesQWERTY[256] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2A, // Backspace @@ -239,7 +239,7 @@ u8 CWII_IPC_HLE_Device_usb_kbd::m_KeyCodesQWERTY[256] = { }; -u8 CWII_IPC_HLE_Device_usb_kbd::m_KeyCodesAZERTY[256] = { +u8 USB_KBD::m_KeyCodesAZERTY[256] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2A, // Backspace @@ -313,9 +313,10 @@ u8 CWII_IPC_HLE_Device_usb_kbd::m_KeyCodesAZERTY[256] = { }; #else -u8 CWII_IPC_HLE_Device_usb_kbd::m_KeyCodesQWERTY[256] = {0}; +u8 USB_KBD::m_KeyCodesQWERTY[256] = {0}; -u8 CWII_IPC_HLE_Device_usb_kbd::m_KeyCodesAZERTY[256] = {0}; +u8 USB_KBD::m_KeyCodesAZERTY[256] = {0}; #endif +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/USB/USB_KBD.h b/Source/Core/Core/IOS/USB/USB_KBD.h index 7a54a1e0e0..eb4849446d 100644 --- a/Source/Core/Core/IOS/USB/USB_KBD.h +++ b/Source/Core/Core/IOS/USB/USB_KBD.h @@ -15,10 +15,12 @@ namespace IOS { namespace HLE { -class CWII_IPC_HLE_Device_usb_kbd : public IWII_IPC_HLE_Device +namespace Device +{ +class USB_KBD : public Device { public: - CWII_IPC_HLE_Device_usb_kbd(u32 _DeviceID, const std::string& _rDeviceName); + USB_KBD(u32 device_id, const std::string& device_name); IOSReturnCode Open(const IOSOpenRequest& request) override; IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override; @@ -61,5 +63,6 @@ private: static u8 m_KeyCodesQWERTY[256]; static u8 m_KeyCodesAZERTY[256]; }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/USB/USB_VEN.cpp b/Source/Core/Core/IOS/USB/USB_VEN.cpp index f4b59f9df7..61eb50ed71 100644 --- a/Source/Core/Core/IOS/USB/USB_VEN.cpp +++ b/Source/Core/Core/IOS/USB/USB_VEN.cpp @@ -10,19 +10,19 @@ namespace IOS { namespace HLE { -CWII_IPC_HLE_Device_usb_ven::CWII_IPC_HLE_Device_usb_ven(const u32 device_id, - const std::string& device_name) - : IWII_IPC_HLE_Device(device_id, device_name) +namespace Device +{ +USB_VEN::USB_VEN(u32 device_id, const std::string& device_name) : Device(device_id, device_name) { } -IPCCommandResult CWII_IPC_HLE_Device_usb_ven::IOCtlV(const IOSIOCtlVRequest& request) +IPCCommandResult USB_VEN::IOCtlV(const IOSIOCtlVRequest& request) { request.Dump(GetDeviceName()); return GetNoReply(); } -IPCCommandResult CWII_IPC_HLE_Device_usb_ven::IOCtl(const IOSIOCtlRequest& request) +IPCCommandResult USB_VEN::IOCtl(const IOSIOCtlRequest& request) { request.Log(GetDeviceName(), LogTypes::OSHLE); @@ -78,5 +78,6 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_ven::IOCtl(const IOSIOCtlRequest& reque } return reply; } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/USB/USB_VEN.h b/Source/Core/Core/IOS/USB/USB_VEN.h index 3c67a4be37..6e3e7019df 100644 --- a/Source/Core/Core/IOS/USB/USB_VEN.h +++ b/Source/Core/Core/IOS/USB/USB_VEN.h @@ -14,10 +14,12 @@ namespace IOS { namespace HLE { -class CWII_IPC_HLE_Device_usb_ven final : public IWII_IPC_HLE_Device +namespace Device +{ +class USB_VEN final : public Device { public: - CWII_IPC_HLE_Device_usb_ven(u32 device_id, const std::string& device_name); + USB_VEN(u32 device_id, const std::string& device_name); IPCCommandResult IOCtlV(const IOSIOCtlVRequest& request) override; IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override; @@ -39,5 +41,6 @@ private: USBV5_IOCTL_BULKMSG = 21 }; }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/WFS/WFSI.cpp b/Source/Core/Core/IOS/WFS/WFSI.cpp index 26ac69cb57..e50bd0db11 100644 --- a/Source/Core/Core/IOS/WFS/WFSI.cpp +++ b/Source/Core/Core/IOS/WFS/WFSI.cpp @@ -78,12 +78,13 @@ void ARCUnpacker::Extract(const WriteCallback& callback) } } -CWII_IPC_HLE_Device_wfsi::CWII_IPC_HLE_Device_wfsi(u32 device_id, const std::string& device_name) - : IWII_IPC_HLE_Device(device_id, device_name) +namespace Device +{ +WFSI::WFSI(u32 device_id, const std::string& device_name) : Device(device_id, device_name) { } -IPCCommandResult CWII_IPC_HLE_Device_wfsi::IOCtl(const IOSIOCtlRequest& request) +IPCCommandResult WFSI::IOCtl(const IOSIOCtlRequest& request) { u32 return_error_code = IPC_SUCCESS; @@ -244,5 +245,6 @@ IPCCommandResult CWII_IPC_HLE_Device_wfsi::IOCtl(const IOSIOCtlRequest& request) return GetDefaultReply(return_error_code); } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/WFS/WFSI.h b/Source/Core/Core/IOS/WFS/WFSI.h index 11f0190bd0..f7ddccd587 100644 --- a/Source/Core/Core/IOS/WFS/WFSI.h +++ b/Source/Core/Core/IOS/WFS/WFSI.h @@ -33,10 +33,12 @@ private: std::vector m_whole_file; }; -class CWII_IPC_HLE_Device_wfsi : public IWII_IPC_HLE_Device +namespace Device +{ +class WFSI : public Device { public: - CWII_IPC_HLE_Device_wfsi(u32 device_id, const std::string& device_name); + WFSI(u32 device_id, const std::string& device_name); IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override; @@ -73,5 +75,6 @@ private: IOCTL_WFSI_APPLY_TITLE_PROFILE = 0x89, }; }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/WFS/WFSSRV.cpp b/Source/Core/Core/IOS/WFS/WFSSRV.cpp index 1e8dd64b52..0f863d0f04 100644 --- a/Source/Core/Core/IOS/WFS/WFSSRV.cpp +++ b/Source/Core/Core/IOS/WFS/WFSSRV.cpp @@ -26,14 +26,14 @@ std::string NativePath(const std::string& wfs_path) } } // namespace WFS -CWII_IPC_HLE_Device_usb_wfssrv::CWII_IPC_HLE_Device_usb_wfssrv(u32 device_id, - const std::string& device_name) - : IWII_IPC_HLE_Device(device_id, device_name) +namespace Device +{ +WFSSRV::WFSSRV(u32 device_id, const std::string& device_name) : Device(device_id, device_name) { m_device_name = "msc01"; } -IPCCommandResult CWII_IPC_HLE_Device_usb_wfssrv::IOCtl(const IOSIOCtlRequest& request) +IPCCommandResult WFSSRV::IOCtl(const IOSIOCtlRequest& request) { int return_error_code = IPC_SUCCESS; @@ -164,8 +164,7 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_wfssrv::IOCtl(const IOSIOCtlRequest& re return GetDefaultReply(return_error_code); } -CWII_IPC_HLE_Device_usb_wfssrv::FileDescriptor* -CWII_IPC_HLE_Device_usb_wfssrv::FindFileDescriptor(u16 fd) +WFSSRV::FileDescriptor* WFSSRV::FindFileDescriptor(u16 fd) { if (fd >= m_fds.size() || !m_fds[fd].in_use) { @@ -174,7 +173,7 @@ CWII_IPC_HLE_Device_usb_wfssrv::FindFileDescriptor(u16 fd) return &m_fds[fd]; } -u16 CWII_IPC_HLE_Device_usb_wfssrv::GetNewFileDescriptor() +u16 WFSSRV::GetNewFileDescriptor() { for (u32 i = 0; i < m_fds.size(); ++i) { @@ -187,7 +186,7 @@ u16 CWII_IPC_HLE_Device_usb_wfssrv::GetNewFileDescriptor() return static_cast(m_fds.size() - 1); } -void CWII_IPC_HLE_Device_usb_wfssrv::ReleaseFileDescriptor(u16 fd) +void WFSSRV::ReleaseFileDescriptor(u16 fd) { FileDescriptor* fd_obj = FindFileDescriptor(fd); if (!fd_obj) @@ -203,7 +202,7 @@ void CWII_IPC_HLE_Device_usb_wfssrv::ReleaseFileDescriptor(u16 fd) } } -bool CWII_IPC_HLE_Device_usb_wfssrv::FileDescriptor::Open() +bool WFSSRV::FileDescriptor::Open() { const char* mode_string; @@ -227,5 +226,6 @@ bool CWII_IPC_HLE_Device_usb_wfssrv::FileDescriptor::Open() return file.Open(WFS::NativePath(path), mode_string); } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IOS/WFS/WFSSRV.h b/Source/Core/Core/IOS/WFS/WFSSRV.h index a6096f969d..f0f6084972 100644 --- a/Source/Core/Core/IOS/WFS/WFSSRV.h +++ b/Source/Core/Core/IOS/WFS/WFSSRV.h @@ -22,10 +22,12 @@ namespace WFS std::string NativePath(const std::string& wfs_path); } -class CWII_IPC_HLE_Device_usb_wfssrv : public IWII_IPC_HLE_Device +namespace Device +{ +class WFSSRV : public Device { public: - CWII_IPC_HLE_Device_usb_wfssrv(u32 device_id, const std::string& device_name); + WFSSRV(u32 device_id, const std::string& device_name); IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override; @@ -77,5 +79,6 @@ private: u16 GetNewFileDescriptor(); void ReleaseFileDescriptor(u16 fd); }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/Movie.cpp b/Source/Core/Core/Movie.cpp index da3da6dcd0..13882da1df 100644 --- a/Source/Core/Core/Movie.cpp +++ b/Source/Core/Core/Movie.cpp @@ -580,7 +580,7 @@ bool BeginRecordingInput(int controllers) s_bRecordingFromSaveState = true; // This is only done here if starting from save state because otherwise we won't have the - // titleid. Otherwise it's set in WII_IPC_HLE_Device_es.cpp. + // titleid. Otherwise it's set in IOS::HLE::Device::ES. // TODO: find a way to GetTitleDataPath() from Movie::Init() if (SConfig::GetInstance().bWii) { diff --git a/Source/Core/DolphinWX/ControllerConfigDiag.cpp b/Source/Core/DolphinWX/ControllerConfigDiag.cpp index 366e12cad4..a63a9cdff7 100644 --- a/Source/Core/DolphinWX/ControllerConfigDiag.cpp +++ b/Source/Core/DolphinWX/ControllerConfigDiag.cpp @@ -529,7 +529,7 @@ void ControllerConfigDiag::OnPassthroughScanButton(wxCommandEvent& event) } auto device = IOS::HLE::GetDeviceByName("/dev/usb/oh1/57e/305"); if (device != nullptr) - std::static_pointer_cast(device) + std::static_pointer_cast(device) ->TriggerSyncButtonPressedEvent(); } @@ -543,8 +543,7 @@ void ControllerConfigDiag::OnPassthroughResetButton(wxCommandEvent& event) } auto device = IOS::HLE::GetDeviceByName("/dev/usb/oh1/57e/305"); if (device != nullptr) - std::static_pointer_cast(device) - ->TriggerSyncButtonHeldEvent(); + std::static_pointer_cast(device)->TriggerSyncButtonHeldEvent(); } void ControllerConfigDiag::OnBalanceBoardChanged(wxCommandEvent& event) diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 4ea3c3901d..9bb98c5f62 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -1279,8 +1279,8 @@ void CFrame::ParseHotkeys() { auto device = IOS::HLE::GetDeviceByName("/dev/usb/oh1/57e/305"); if (device != nullptr) - std::static_pointer_cast(device) - ->UpdateSyncButtonState(IsHotkey(HK_TRIGGER_SYNC_BUTTON, true)); + std::static_pointer_cast(device)->UpdateSyncButtonState( + IsHotkey(HK_TRIGGER_SYNC_BUTTON, true)); } if (UseDebugger) diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index 7c57776b74..50dec10be5 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -861,12 +861,8 @@ void CFrame::DoStop() bool CFrame::TriggerSTMPowerEvent() { const auto stm = IOS::HLE::GetDeviceByName("/dev/stm/eventhook"); - if (!stm || - !std::static_pointer_cast(stm) - ->HasHookInstalled()) - { + if (!stm || !std::static_pointer_cast(stm)->HasHookInstalled()) return false; - } Core::DisplayMessage("Shutting down", 30000); // Unpause because gracefully shutting down needs the game to actually request a shutdown diff --git a/Source/Core/DolphinWX/MainNoGUI.cpp b/Source/Core/DolphinWX/MainNoGUI.cpp index eb957997a5..f4e64f120e 100644 --- a/Source/Core/DolphinWX/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/MainNoGUI.cpp @@ -239,8 +239,7 @@ class PlatformX11 : public Platform { const auto stm = IOS::HLE::GetDeviceByName("/dev/stm/eventhook"); if (!s_tried_graceful_shutdown.IsSet() && stm && - std::static_pointer_cast(stm) - ->HasHookInstalled()) + std::static_pointer_cast(stm)->HasHookInstalled()) { ProcessorInterface::PowerButton_Tap(); s_tried_graceful_shutdown.Set();