Large diffs are not rendered by default.

@@ -33,18 +33,16 @@ 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 BluetoothEmu final : public BluetoothBase
class BluetoothEmuDevice final : public BluetoothBaseDevice
{
public:
BluetoothEmu(Kernel& ios, const std::string& device_name);
BluetoothEmuDevice(Kernel& ios, const std::string& device_name);

virtual ~BluetoothEmu();
virtual ~BluetoothEmuDevice();

IPCCommandResult Close(u32 fd) override;
IPCCommandResult IOCtlV(const IOCtlVRequest& request) override;
@@ -199,5 +197,4 @@ class BluetoothEmu final : public BluetoothBase
};
#pragma pack(pop)
};
} // namespace Device
} // namespace IOS::HLE
@@ -31,7 +31,7 @@
#include "Core/IOS/Device.h"
#include "VideoCommon/OnScreenDisplay.h"

namespace IOS::HLE::Device
namespace IOS::HLE
{
constexpr u8 REQUEST_TYPE = static_cast<u8>(LIBUSB_ENDPOINT_OUT) |
static_cast<u8>(LIBUSB_REQUEST_TYPE_CLASS) |
@@ -58,13 +58,13 @@ static bool IsBluetoothDevice(const libusb_interface_descriptor& descriptor)
descriptor.bInterfaceProtocol == PROTOCOL_BLUETOOTH;
}

BluetoothReal::BluetoothReal(Kernel& ios, const std::string& device_name)
: BluetoothBase(ios, device_name)
BluetoothRealDevice::BluetoothRealDevice(Kernel& ios, const std::string& device_name)
: BluetoothBaseDevice(ios, device_name)
{
LoadLinkKeys();
}

BluetoothReal::~BluetoothReal()
BluetoothRealDevice::~BluetoothRealDevice()
{
if (m_handle != nullptr)
{
@@ -77,7 +77,7 @@ BluetoothReal::~BluetoothReal()
SaveLinkKeys();
}

IPCCommandResult BluetoothReal::Open(const OpenRequest& request)
IPCCommandResult BluetoothRealDevice::Open(const OpenRequest& request)
{
if (!m_context.IsValid())
return GetDefaultReply(IPC_EACCES);
@@ -138,7 +138,7 @@ IPCCommandResult BluetoothReal::Open(const OpenRequest& request)
return Device::Open(request);
}

IPCCommandResult BluetoothReal::Close(u32 fd)
IPCCommandResult BluetoothRealDevice::Close(u32 fd)
{
if (m_handle)
{
@@ -151,7 +151,7 @@ IPCCommandResult BluetoothReal::Close(u32 fd)
return Device::Close(fd);
}

IPCCommandResult BluetoothReal::IOCtlV(const IOCtlVRequest& request)
IPCCommandResult BluetoothRealDevice::IOCtlV(const IOCtlVRequest& request)
{
if (!m_is_wii_bt_module && m_need_reset_keys.TestAndClear())
{
@@ -199,7 +199,7 @@ IPCCommandResult BluetoothReal::IOCtlV(const IOCtlVRequest& request)
transfer->flags |= LIBUSB_TRANSFER_FREE_TRANSFER;
libusb_fill_control_transfer(transfer, m_handle, buffer.get(), nullptr, this, 0);
transfer->callback = [](libusb_transfer* tr) {
static_cast<BluetoothReal*>(tr->user_data)->HandleCtrlTransfer(tr);
static_cast<BluetoothRealDevice*>(tr->user_data)->HandleCtrlTransfer(tr);
};
PendingTransfer pending_transfer{std::move(cmd), std::move(buffer)};
m_current_transfers.emplace(transfer, std::move(pending_transfer));
@@ -241,7 +241,7 @@ IPCCommandResult BluetoothReal::IOCtlV(const IOCtlVRequest& request)
libusb_transfer* transfer = libusb_alloc_transfer(0);
transfer->buffer = buffer.get();
transfer->callback = [](libusb_transfer* tr) {
static_cast<BluetoothReal*>(tr->user_data)->HandleBulkOrIntrTransfer(tr);
static_cast<BluetoothRealDevice*>(tr->user_data)->HandleBulkOrIntrTransfer(tr);
};
transfer->dev_handle = m_handle;
transfer->endpoint = cmd->endpoint;
@@ -262,7 +262,7 @@ IPCCommandResult BluetoothReal::IOCtlV(const IOCtlVRequest& request)
}

static bool s_has_shown_savestate_warning = false;
void BluetoothReal::DoState(PointerWrap& p)
void BluetoothRealDevice::DoState(PointerWrap& p)
{
bool passthrough_bluetooth = true;
p.Do(passthrough_bluetooth);
@@ -317,7 +317,7 @@ void BluetoothReal::DoState(PointerWrap& p)
m_transfers_mutex.unlock();
}

void BluetoothReal::UpdateSyncButtonState(const bool is_held)
void BluetoothRealDevice::UpdateSyncButtonState(const bool is_held)
{
if (m_sync_button_state == SyncButtonState::Unpressed && is_held)
{
@@ -335,17 +335,17 @@ void BluetoothReal::UpdateSyncButtonState(const bool is_held)
m_sync_button_state = SyncButtonState::Unpressed;
}

void BluetoothReal::TriggerSyncButtonPressedEvent()
void BluetoothRealDevice::TriggerSyncButtonPressedEvent()
{
m_sync_button_state = SyncButtonState::Pressed;
}

void BluetoothReal::TriggerSyncButtonHeldEvent()
void BluetoothRealDevice::TriggerSyncButtonHeldEvent()
{
m_sync_button_state = SyncButtonState::LongPressed;
}

void BluetoothReal::WaitForHCICommandComplete(const u16 opcode)
void BluetoothRealDevice::WaitForHCICommandComplete(const u16 opcode)
{
int actual_length;
SHCIEventCommand packet;
@@ -363,7 +363,7 @@ void BluetoothReal::WaitForHCICommandComplete(const u16 opcode)
}
}

void BluetoothReal::SendHCIResetCommand()
void BluetoothRealDevice::SendHCIResetCommand()
{
u8 packet[3] = {};
const u16 payload[] = {HCI_CMD_RESET};
@@ -372,7 +372,7 @@ void BluetoothReal::SendHCIResetCommand()
INFO_LOG_FMT(IOS_WIIMOTE, "Sent a reset command to adapter");
}

void BluetoothReal::SendHCIDeleteLinkKeyCommand()
void BluetoothRealDevice::SendHCIDeleteLinkKeyCommand()
{
struct Payload
{
@@ -389,7 +389,7 @@ void BluetoothReal::SendHCIDeleteLinkKeyCommand()
static_cast<u16>(sizeof(payload)), TIMEOUT);
}

bool BluetoothReal::SendHCIStoreLinkKeyCommand()
bool BluetoothRealDevice::SendHCIStoreLinkKeyCommand()
{
if (m_link_keys.empty())
return false;
@@ -428,7 +428,7 @@ bool BluetoothReal::SendHCIStoreLinkKeyCommand()
return true;
}

void BluetoothReal::FakeVendorCommandReply(USB::V0IntrMessage& ctrl)
void BluetoothRealDevice::FakeVendorCommandReply(USB::V0IntrMessage& ctrl)
{
SHCIEventCommand hci_event;
Memory::CopyFromEmu(&hci_event, ctrl.data_address, sizeof(hci_event));
@@ -445,7 +445,7 @@ void BluetoothReal::FakeVendorCommandReply(USB::V0IntrMessage& ctrl)
// - 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 BluetoothReal::FakeReadBufferSizeReply(USB::V0IntrMessage& ctrl)
void BluetoothRealDevice::FakeReadBufferSizeReply(USB::V0IntrMessage& ctrl)
{
SHCIEventCommand hci_event;
Memory::CopyFromEmu(&hci_event, ctrl.data_address, sizeof(hci_event));
@@ -465,7 +465,8 @@ void BluetoothReal::FakeReadBufferSizeReply(USB::V0IntrMessage& ctrl)
m_ios.EnqueueIPCReply(ctrl.ios_request, static_cast<s32>(sizeof(hci_event) + sizeof(reply)));
}

void BluetoothReal::FakeSyncButtonEvent(USB::V0IntrMessage& ctrl, const u8* payload, const u8 size)
void BluetoothRealDevice::FakeSyncButtonEvent(USB::V0IntrMessage& ctrl, const u8* payload,
const u8 size)
{
hci_event_hdr_t hci_event;
Memory::CopyFromEmu(&hci_event, ctrl.data_address, sizeof(hci_event));
@@ -480,7 +481,7 @@ void BluetoothReal::FakeSyncButtonEvent(USB::V0IntrMessage& ctrl, const u8* payl
// > HCI Event: Vendor (0xff) plen 1
// 08
// This causes the emulated software to perform a BT inquiry and connect to found Wiimotes.
void BluetoothReal::FakeSyncButtonPressedEvent(USB::V0IntrMessage& ctrl)
void BluetoothRealDevice::FakeSyncButtonPressedEvent(USB::V0IntrMessage& ctrl)
{
NOTICE_LOG_FMT(IOS_WIIMOTE, "Faking 'sync button pressed' (0x08) event packet");
constexpr u8 payload[1] = {0x08};
@@ -489,15 +490,15 @@ void BluetoothReal::FakeSyncButtonPressedEvent(USB::V0IntrMessage& ctrl)
}

// When the red sync button is held for 10 seconds, a HCI event with payload 09 is sent.
void BluetoothReal::FakeSyncButtonHeldEvent(USB::V0IntrMessage& ctrl)
void BluetoothRealDevice::FakeSyncButtonHeldEvent(USB::V0IntrMessage& ctrl)
{
NOTICE_LOG_FMT(IOS_WIIMOTE, "Faking 'sync button held' (0x09) event packet");
constexpr u8 payload[1] = {0x09};
FakeSyncButtonEvent(ctrl, payload, sizeof(payload));
m_sync_button_state = SyncButtonState::Ignored;
}

void BluetoothReal::LoadLinkKeys()
void BluetoothRealDevice::LoadLinkKeys()
{
const std::string& entries = SConfig::GetInstance().m_bt_passthrough_link_keys;
if (entries.empty())
@@ -535,7 +536,7 @@ void BluetoothReal::LoadLinkKeys()
}
}

void BluetoothReal::SaveLinkKeys()
void BluetoothRealDevice::SaveLinkKeys()
{
std::ostringstream oss;
for (const auto& entry : m_link_keys)
@@ -556,7 +557,7 @@ void BluetoothReal::SaveLinkKeys()
SConfig::GetInstance().m_bt_passthrough_link_keys = config_string;
}

bool BluetoothReal::OpenDevice(libusb_device* device)
bool BluetoothRealDevice::OpenDevice(libusb_device* device)
{
m_device = libusb_ref_device(device);
const int ret = libusb_open(m_device, &m_handle);
@@ -592,7 +593,7 @@ bool BluetoothReal::OpenDevice(libusb_device* device)
}

// The callbacks are called from libusb code on a separate thread.
void BluetoothReal::HandleCtrlTransfer(libusb_transfer* tr)
void BluetoothRealDevice::HandleCtrlTransfer(libusb_transfer* tr)
{
std::lock_guard lk(m_transfers_mutex);
if (!m_current_transfers.count(tr))
@@ -618,7 +619,7 @@ void BluetoothReal::HandleCtrlTransfer(libusb_transfer* tr)
m_current_transfers.erase(tr);
}

void BluetoothReal::HandleBulkOrIntrTransfer(libusb_transfer* tr)
void BluetoothRealDevice::HandleBulkOrIntrTransfer(libusb_transfer* tr)
{
std::lock_guard lk(m_transfers_mutex);
if (!m_current_transfers.count(tr))
@@ -665,4 +666,4 @@ void BluetoothReal::HandleBulkOrIntrTransfer(libusb_transfer* tr)
m_ios.EnqueueIPCReply(command->ios_request, tr->actual_length, 0, CoreTiming::FromThread::ANY);
m_current_transfers.erase(tr);
}
} // namespace IOS::HLE::Device
} // namespace IOS::HLE
@@ -40,13 +40,11 @@ enum class SyncButtonState

using linkkey_t = std::array<u8, 16>;

namespace Device
{
class BluetoothReal final : public BluetoothBase
class BluetoothRealDevice final : public BluetoothBaseDevice
{
public:
BluetoothReal(Kernel& ios, const std::string& device_name);
~BluetoothReal() override;
BluetoothRealDevice(Kernel& ios, const std::string& device_name);
~BluetoothRealDevice() override;

IPCCommandResult Open(const OpenRequest& request) override;
IPCCommandResult Close(u32 fd) override;
@@ -121,14 +119,13 @@ class BluetoothReal final : public BluetoothBase

bool OpenDevice(libusb_device* device);
};
} // namespace Device
} // namespace IOS::HLE

#else
#include "Core/IOS/USB/Bluetooth/BTStub.h"

namespace IOS::HLE::Device
namespace IOS::HLE
{
using BluetoothReal = BluetoothStub;
} // namespace IOS::HLE::Device
using BluetoothRealDevice = BluetoothStubDevice;
} // namespace IOS::HLE
#endif
@@ -8,18 +8,18 @@
#include "Common/MsgHandler.h"
#include "Core/Core.h"

namespace IOS::HLE::Device
namespace IOS::HLE
{
IPCCommandResult BluetoothStub::Open(const OpenRequest& request)
IPCCommandResult BluetoothStubDevice::Open(const OpenRequest& request)
{
PanicAlertFmtT("Bluetooth passthrough mode is enabled, but Dolphin was built without libusb."
" Passthrough mode cannot be used.");
return GetDefaultReply(IPC_ENOENT);
}

void BluetoothStub::DoState(PointerWrap& p)
void BluetoothStubDevice::DoState(PointerWrap& p)
{
Core::DisplayMessage("The current IPC_HLE_Device_usb is a stub. Aborting load.", 4000);
p.SetMode(PointerWrap::MODE_VERIFY);
}
} // namespace IOS::HLE::Device
} // namespace IOS::HLE
@@ -12,13 +12,13 @@

class PointerWrap;

namespace IOS::HLE::Device
namespace IOS::HLE
{
class BluetoothStub final : public BluetoothBase
class BluetoothStubDevice final : public BluetoothBaseDevice
{
public:
using BluetoothBase::BluetoothBase;
using BluetoothBaseDevice::BluetoothBaseDevice;
IPCCommandResult Open(const OpenRequest& request) override;
void DoState(PointerWrap& p) override;
};
} // namespace IOS::HLE::Device
} // namespace IOS::HLE
@@ -55,7 +55,7 @@ class CBigEndianBuffer

constexpr int CONNECTION_MESSAGE_TIME = 3000;

WiimoteDevice::WiimoteDevice(Device::BluetoothEmu* host, int number, bdaddr_t bd)
WiimoteDevice::WiimoteDevice(BluetoothEmuDevice* host, int number, bdaddr_t bd)
: m_host(host), m_bd(bd),
m_name(number == WIIMOTE_BALANCE_BOARD ? "Nintendo RVL-WBC-01" : "Nintendo RVL-CNT-01")

@@ -16,10 +16,7 @@ class PointerWrap;

namespace IOS::HLE
{
namespace Device
{
class BluetoothEmu;
}
class BluetoothEmuDevice;

class WiimoteDevice
{
@@ -28,7 +25,7 @@ class WiimoteDevice
using FeaturesType = std::array<u8, HCI_FEATURES_SIZE>;
using LinkKeyType = std::array<u8, HCI_KEY_SIZE>;

WiimoteDevice(Device::BluetoothEmu* host, int number, bdaddr_t bd);
WiimoteDevice(BluetoothEmuDevice* host, int number, bdaddr_t bd);
~WiimoteDevice();

WiimoteDevice(const WiimoteDevice&) = delete;
@@ -116,7 +113,7 @@ class WiimoteDevice

using ChannelMap = std::map<u16, SChannel>;

Device::BluetoothEmu* m_host;
BluetoothEmuDevice* m_host;
WiimoteCommon::HIDWiimote* m_hid_source = nullptr;

// State to save:
@@ -25,7 +25,7 @@
#include "Core/IOS/USB/Common.h"
#include "Core/IOS/USB/LibusbDevice.h"

namespace IOS::HLE::Device
namespace IOS::HLE
{
USBHost::USBHost(Kernel& ios, const std::string& device_name) : Device(ios, device_name)
{
@@ -227,4 +227,4 @@ IPCCommandResult USBHost::HandleTransfer(std::shared_ptr<USB::Device> device, u3
device->GetVid(), device->GetPid(), request, device->GetErrorName(ret));
return GetDefaultReply(ret <= 0 ? ret : IPC_EINVAL);
}
} // namespace IOS::HLE::Device
} // namespace IOS::HLE
@@ -24,7 +24,7 @@

class PointerWrap;

namespace IOS::HLE::Device
namespace IOS::HLE
{
// Common base class for USB host devices (such as /dev/usb/oh0 and /dev/usb/ven).
class USBHost : public Device
@@ -85,4 +85,4 @@ class USBHost : public Device
bool m_has_initialised = false;
LibusbUtils::Context m_context;
};
} // namespace IOS::HLE::Device
} // namespace IOS::HLE
@@ -20,7 +20,7 @@
#include "Core/IOS/USB/USBV0.h"
#include "Core/IOS/VersionInfo.h"

namespace IOS::HLE::Device
namespace IOS::HLE
{
OH0::OH0(Kernel& ios, const std::string& device_name) : USBHost(ios, device_name)
{
@@ -348,4 +348,4 @@ s32 OH0::SubmitTransfer(USB::Device& device, const IOCtlVRequest& ioctlv)
return IPC_EINVAL;
}
}
} // namespace IOS::HLE::Device
} // namespace IOS::HLE
@@ -30,8 +30,6 @@ struct DeviceInfo
};
} // namespace USB

namespace Device
{
// /dev/usb/oh0
class OH0 final : public USBHost
{
@@ -85,5 +83,4 @@ class OH0 final : public USBHost

ScanThread m_scan_thread{this};
};
} // namespace Device
} // namespace IOS::HLE
@@ -14,7 +14,7 @@
#include "Core/IOS/IOS.h"
#include "Core/IOS/USB/OH0/OH0.h"

namespace IOS::HLE::Device
namespace IOS::HLE
{
static void GetVidPidFromDevicePath(const std::string& device_path, u16& vid, u16& pid)
{
@@ -78,4 +78,4 @@ IPCCommandResult OH0Device::IOCtlV(const IOCtlVRequest& request)
{
return m_oh0->DeviceIOCtlV(m_device_id, request);
}
} // namespace IOS::HLE::Device
} // namespace IOS::HLE
@@ -12,7 +12,7 @@

class PointerWrap;

namespace IOS::HLE::Device
namespace IOS::HLE
{
class OH0;
class OH0Device final : public Device
@@ -32,4 +32,4 @@ class OH0Device final : public Device
u16 m_pid = 0;
u64 m_device_id = 0;
};
} // namespace IOS::HLE::Device
} // namespace IOS::HLE
@@ -62,8 +62,6 @@ V5IsoMessage::V5IsoMessage(Kernel& ios, const IOCtlVRequest& ioctlv)
}
} // namespace USB

namespace Device
{
namespace
{
#pragma pack(push, 1)
@@ -274,5 +272,4 @@ void USBV5ResourceManager::TriggerDeviceChangeReply()
m_devicechange_hook_request.reset();
INFO_LOG_FMT(IOS_USB, "{} USBv5 device(s), including interfaces", num_devices);
}
} // namespace Device
} // namespace IOS::HLE
@@ -63,8 +63,6 @@ struct V5IsoMessage final : IsoMessage
};
} // namespace USB

namespace Device
{
class USBV5ResourceManager : public USBHost
{
public:
@@ -109,5 +107,4 @@ class USBV5ResourceManager : public USBHost
mutable std::mutex m_usbv5_devices_mutex;
u16 m_current_device_number = 0x21;
};
} // namespace Device
} // namespace IOS::HLE
@@ -20,7 +20,7 @@
#include "Core/IOS/USB/Common.h"
#include "Core/IOS/USB/USBV4.h"

namespace IOS::HLE::Device
namespace IOS::HLE
{
USB_HIDv4::USB_HIDv4(Kernel& ios, const std::string& device_name) : USBHost(ios, device_name)
{
@@ -258,4 +258,4 @@ std::vector<u8> USB_HIDv4::GetDeviceEntry(const USB::Device& device) const

return entry;
}
} // namespace IOS::HLE::Device
} // namespace IOS::HLE
@@ -16,7 +16,7 @@

class PointerWrap;

namespace IOS::HLE::Device
namespace IOS::HLE
{
class USB_HIDv4 final : public USBHost
{
@@ -56,4 +56,4 @@ class USB_HIDv4 final : public USBHost

ScanThread m_scan_thread{this};
};
} // namespace IOS::HLE::Device
} // namespace IOS::HLE
@@ -14,7 +14,7 @@
#include "Core/HW/Memmap.h"
#include "Core/IOS/USB/Common.h"

namespace IOS::HLE::Device
namespace IOS::HLE
{
constexpr u32 USBV5_VERSION = 0x50001;

@@ -196,4 +196,4 @@ bool USB_HIDv5::ShouldAddDevice(const USB::Device& device) const
constexpr u8 HID_CLASS = 0x03;
return device.HasClass(HID_CLASS);
}
} // namespace IOS::HLE::Device
} // namespace IOS::HLE
@@ -9,7 +9,7 @@
#include "Core/IOS/USB/Host.h"
#include "Core/IOS/USB/USBV5.h"

namespace IOS::HLE::Device
namespace IOS::HLE
{
class USB_HIDv5 final : public USBV5ResourceManager
{
@@ -39,4 +39,4 @@ class USB_HIDv5 final : public USBV5ResourceManager

ScanThread m_scan_thread{this};
};
} // namespace IOS::HLE::Device
} // namespace IOS::HLE
@@ -20,7 +20,7 @@
#include <windows.h>
#endif

namespace IOS::HLE::Device
namespace IOS::HLE
{
namespace
{
@@ -307,4 +307,4 @@ void USB_KBD::Update()
if (got_event)
m_message_queue.emplace(MessageType::Event, modifiers, pressed_keys);
}
} // namespace IOS::HLE::Device
} // namespace IOS::HLE
@@ -13,7 +13,7 @@
#include "Core/IOS/Device.h"
#include "Core/IOS/IOS.h"

namespace IOS::HLE::Device
namespace IOS::HLE
{
class USB_KBD : public Device
{
@@ -64,4 +64,4 @@ class USB_KBD : public Device
};
int m_keyboard_layout = KBD_LAYOUT_QWERTY;
};
} // namespace IOS::HLE::Device
} // namespace IOS::HLE
@@ -14,7 +14,7 @@
#include "Core/HW/Memmap.h"
#include "Core/IOS/USB/Common.h"

namespace IOS::HLE::Device
namespace IOS::HLE
{
constexpr u32 USBV5_VERSION = 0x50001;

@@ -159,4 +159,4 @@ IPCCommandResult USB_VEN::GetDeviceInfo(USBV5Device& device, const IOCtlRequest&

return GetDefaultReply(IPC_SUCCESS);
}
} // namespace IOS::HLE::Device
} // namespace IOS::HLE
@@ -9,7 +9,7 @@
#include "Core/IOS/USB/Host.h"
#include "Core/IOS/USB/USBV5.h"

namespace IOS::HLE::Device
namespace IOS::HLE
{
class USB_VEN final : public USBV5ResourceManager
{
@@ -31,4 +31,4 @@ class USB_VEN final : public USBV5ResourceManager

ScanThread m_scan_thread{this};
};
} // namespace IOS::HLE::Device
} // namespace IOS::HLE
@@ -94,13 +94,11 @@ void ARCUnpacker::Extract(const WriteCallback& callback)
}
}

namespace Device
{
WFSI::WFSI(Kernel& ios, const std::string& device_name) : Device(ios, device_name)
WFSIDevice::WFSIDevice(Kernel& ios, const std::string& device_name) : Device(ios, device_name)
{
}

void WFSI::SetCurrentTitleIdAndGroupId(u64 tid, u16 gid)
void WFSIDevice::SetCurrentTitleIdAndGroupId(u64 tid, u16 gid)
{
m_current_title_id = tid;
m_current_group_id = gid;
@@ -109,7 +107,7 @@ void WFSI::SetCurrentTitleIdAndGroupId(u64 tid, u16 gid)
m_current_group_id_str = GroupIdStr(gid);
}

void WFSI::SetImportTitleIdAndGroupId(u64 tid, u16 gid)
void WFSIDevice::SetImportTitleIdAndGroupId(u64 tid, u16 gid)
{
m_import_title_id = tid;
m_import_group_id = gid;
@@ -118,15 +116,15 @@ void WFSI::SetImportTitleIdAndGroupId(u64 tid, u16 gid)
m_import_group_id_str = GroupIdStr(gid);
}

void WFSI::FinalizePatchInstall()
void WFSIDevice::FinalizePatchInstall()
{
const std::string current_title_dir = fmt::format("/vol/{}/title/{}/{}", m_device_name,
m_current_group_id_str, m_current_title_id_str);
const std::string patch_dir = current_title_dir + "/_patch";
File::CopyDir(WFS::NativePath(patch_dir), WFS::NativePath(current_title_dir), true);
}

IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
IPCCommandResult WFSIDevice::IOCtl(const IOCtlRequest& request)
{
s32 return_error_code = IPC_SUCCESS;

@@ -354,7 +352,7 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
auto device = IOS::HLE::GetIOS()->GetDeviceByName("/dev/usb/wfssrv");
if (!device)
break;
std::static_pointer_cast<IOS::HLE::Device::WFSSRV>(device)->SetHomeDir(homedir_path);
std::static_pointer_cast<IOS::HLE::WFSSRVDevice>(device)->SetHomeDir(homedir_path);
return_error_code = IPC_SUCCESS;
break;
}
@@ -551,7 +549,7 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
return GetDefaultReply(return_error_code);
}

u32 WFSI::GetTmd(u16 group_id, u32 title_id, u64 subtitle_id, u32 address, u32* size) const
u32 WFSIDevice::GetTmd(u16 group_id, u32 title_id, u64 subtitle_id, u32 address, u32* size) const
{
const std::string path = fmt::format("/vol/{}/title/{}/{}/meta/{:016x}.tmd", m_device_name,
GroupIdStr(group_id), TitleIdStr(title_id), subtitle_id);
@@ -576,7 +574,7 @@ static s32 DeleteTemporaryFiles(const std::string& device_name, u64 title_id)
return IPC_SUCCESS;
}

s32 WFSI::CancelTitleImport(bool continue_install)
s32 WFSIDevice::CancelTitleImport(bool continue_install)
{
m_arc_unpacker.Reset();

@@ -590,7 +588,7 @@ s32 WFSI::CancelTitleImport(bool continue_install)
return IPC_SUCCESS;
}

s32 WFSI::CancelPatchImport(bool continue_install)
s32 WFSIDevice::CancelPatchImport(bool continue_install)
{
m_arc_unpacker.Reset();

@@ -614,5 +612,4 @@ s32 WFSI::CancelPatchImport(bool continue_install)

return IPC_SUCCESS;
}
} // namespace Device
} // namespace IOS::HLE
@@ -32,12 +32,10 @@ class ARCUnpacker
std::vector<u8> m_whole_file;
};

namespace Device
{
class WFSI : public Device
class WFSIDevice : public Device
{
public:
WFSI(Kernel& ios, const std::string& device_name);
WFSIDevice(Kernel& ios, const std::string& device_name);

IPCCommandResult IOCtl(const IOCtlRequest& request) override;

@@ -125,5 +123,4 @@ class WFSI : public Device
IOCTL_WFSI_CHECK_HAS_SPACE = 0x95,
};
};
} // namespace Device
} // namespace IOS::HLE
@@ -26,14 +26,12 @@ std::string NativePath(const std::string& wfs_path)
}
} // namespace WFS

namespace Device
{
WFSSRV::WFSSRV(Kernel& ios, const std::string& device_name) : Device(ios, device_name)
WFSSRVDevice::WFSSRVDevice(Kernel& ios, const std::string& device_name) : Device(ios, device_name)
{
m_device_name = "msc01";
}

IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
IPCCommandResult WFSSRVDevice::IOCtl(const IOCtlRequest& request)
{
int return_error_code = IPC_SUCCESS;

@@ -364,7 +362,7 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
return GetDefaultReply(return_error_code);
}

s32 WFSSRV::Rename(std::string source, std::string dest) const
s32 WFSSRVDevice::Rename(std::string source, std::string dest) const
{
source = NormalizePath(source);
dest = NormalizePath(dest);
@@ -384,12 +382,12 @@ s32 WFSSRV::Rename(std::string source, std::string dest) const
return IPC_SUCCESS;
}

void WFSSRV::SetHomeDir(const std::string& home_directory)
void WFSSRVDevice::SetHomeDir(const std::string& home_directory)
{
m_home_directory = home_directory;
}

std::string WFSSRV::NormalizePath(const std::string& path) const
std::string WFSSRVDevice::NormalizePath(const std::string& path) const
{
std::string expanded;
if (!path.empty() && path[0] == '~')
@@ -425,7 +423,7 @@ std::string WFSSRV::NormalizePath(const std::string& path) const
return "/" + JoinStrings(normalized_components, "/");
}

WFSSRV::FileDescriptor* WFSSRV::FindFileDescriptor(u16 fd)
WFSSRVDevice::FileDescriptor* WFSSRVDevice::FindFileDescriptor(u16 fd)
{
if (fd >= m_fds.size() || !m_fds[fd].in_use)
{
@@ -434,7 +432,7 @@ WFSSRV::FileDescriptor* WFSSRV::FindFileDescriptor(u16 fd)
return &m_fds[fd];
}

u16 WFSSRV::GetNewFileDescriptor()
u16 WFSSRVDevice::GetNewFileDescriptor()
{
for (u32 i = 0; i < m_fds.size(); ++i)
{
@@ -447,7 +445,7 @@ u16 WFSSRV::GetNewFileDescriptor()
return static_cast<u16>(m_fds.size() - 1);
}

void WFSSRV::ReleaseFileDescriptor(u16 fd)
void WFSSRVDevice::ReleaseFileDescriptor(u16 fd)
{
FileDescriptor* fd_obj = FindFileDescriptor(fd);
if (!fd_obj)
@@ -463,7 +461,7 @@ void WFSSRV::ReleaseFileDescriptor(u16 fd)
}
}

bool WFSSRV::FileDescriptor::Open()
bool WFSSRVDevice::FileDescriptor::Open()
{
const char* mode_string;

@@ -487,5 +485,4 @@ bool WFSSRV::FileDescriptor::Open()

return file.Open(WFS::NativePath(path), mode_string);
}
} // namespace Device
} // namespace IOS::HLE
@@ -29,12 +29,10 @@ enum
WFS_FILE_IS_OPENED = -10032, // Cannot perform operation on an opened file.
};

namespace Device
{
class WFSSRV : public Device
class WFSSRVDevice : public Device
{
public:
WFSSRV(Kernel& ios, const std::string& device_name);
WFSSRVDevice(Kernel& ios, const std::string& device_name);

IPCCommandResult IOCtl(const IOCtlRequest& request) override;

@@ -105,5 +103,4 @@ class WFSSRV : public Device
// shutdown time.
std::vector<u32> m_hanging;
};
} // namespace Device
} // namespace IOS::HLE
@@ -470,7 +470,7 @@ void ChangeWiiPads(bool instantly)
return;

const auto ios = IOS::HLE::GetIOS();
const auto bt = ios ? std::static_pointer_cast<IOS::HLE::Device::BluetoothEmu>(
const auto bt = ios ? std::static_pointer_cast<IOS::HLE::BluetoothEmuDevice>(
ios->GetDeviceByName("/dev/usb/oh1/57e/305")) :
nullptr;
for (int i = 0; i < MAX_WIIMOTES; ++i)
@@ -48,7 +48,7 @@
namespace WiiUtils
{
static bool ImportWAD(IOS::HLE::Kernel& ios, const DiscIO::VolumeWAD& wad,
IOS::HLE::Device::ES::VerifySignature verify_signature)
IOS::HLE::ESDevice::VerifySignature verify_signature)
{
if (!wad.GetTicket().IsValid() || !wad.GetTMD().IsValid())
{
@@ -60,14 +60,14 @@ static bool ImportWAD(IOS::HLE::Kernel& ios, const DiscIO::VolumeWAD& wad,
const auto es = ios.GetES();
const auto fs = ios.GetFS();

IOS::HLE::Device::ES::Context context;
IOS::HLE::ESDevice::Context context;
IOS::HLE::ReturnCode ret;

// Ensure the common key index is correct, as it's checked by IOS.
IOS::ES::TicketReader ticket = wad.GetTicketWithFixedCommonKey();

while ((ret = es->ImportTicket(ticket.GetBytes(), wad.GetCertificateChain(),
IOS::HLE::Device::ES::TicketImportType::Unpersonalised,
IOS::HLE::ESDevice::TicketImportType::Unpersonalised,
verify_signature)) < 0 ||
(ret = es->ImportTitleInit(context, tmd.GetBytes(), wad.GetCertificateChain(),
verify_signature)) < 0)
@@ -151,7 +151,7 @@ bool InstallWAD(IOS::HLE::Kernel& ios, const DiscIO::VolumeWAD& wad, InstallType

// Skip the install if the WAD is already installed.
const auto installed_contents = ios.GetES()->GetStoredContentsFromTMD(
wad.GetTMD(), IOS::HLE::Device::ES::CheckContentHashes::Yes);
wad.GetTMD(), IOS::HLE::ESDevice::CheckContentHashes::Yes);
if (wad.GetTMD().GetContents() == installed_contents)
{
// Clear the "temporary title ID" flag in case the user tries to permanently install a title
@@ -180,7 +180,7 @@ bool InstallWAD(IOS::HLE::Kernel& ios, const DiscIO::VolumeWAD& wad, InstallType
ios.GetES()->DeleteTitleContent(previous_temporary_title_id);

// A lot of people use fakesigned WADs, so disable signature checking when installing a WAD.
if (!ImportWAD(ios, wad, IOS::HLE::Device::ES::VerifySignature::No))
if (!ImportWAD(ios, wad, IOS::HLE::ESDevice::VerifySignature::No))
return false;

// Keep track of the title ID so this title can be removed to make room for any future install.
@@ -265,7 +265,7 @@ IOS::ES::TMDReader FindBackupTMD(IOS::HLE::FS::FileSystem& fs, u64 title_id)
}
}

bool EnsureTMDIsImported(IOS::HLE::FS::FileSystem& fs, IOS::HLE::Device::ES& es, u64 title_id)
bool EnsureTMDIsImported(IOS::HLE::FS::FileSystem& fs, IOS::HLE::ESDevice& es, u64 title_id)
{
if (IsTMDImported(fs, title_id))
return true;
@@ -274,7 +274,7 @@ bool EnsureTMDIsImported(IOS::HLE::FS::FileSystem& fs, IOS::HLE::Device::ES& es,
if (!tmd.IsValid())
return false;

IOS::HLE::Device::ES::Context context;
IOS::HLE::ESDevice::Context context;
context.uid = IOS::SYSMENU_UID;
context.gid = IOS::SYSMENU_GID;
const auto import_result =
@@ -563,7 +563,7 @@ UpdateResult OnlineSystemUpdater::InstallTitleFromNUS(const std::string& prefix_
}

// Initialise the title import.
IOS::HLE::Device::ES::Context context;
IOS::HLE::ESDevice::Context context;
if ((ret = es->ImportTitleInit(context, tmd.first.GetBytes(), tmd.second)) < 0)
{
ERROR_LOG_FMT(CORE, "Failed to initialise title import: error {}", ret);
@@ -832,7 +832,7 @@ UpdateResult DiscSystemUpdater::ProcessEntry(u32 type, std::bitset<32> attrs,
return UpdateResult::DiscReadFailed;
}
const DiscIO::VolumeWAD wad{std::move(blob)};
const bool success = ImportWAD(m_ios, wad, IOS::HLE::Device::ES::VerifySignature::Yes);
const bool success = ImportWAD(m_ios, wad, IOS::HLE::ESDevice::VerifySignature::Yes);
return success ? UpdateResult::Succeeded : UpdateResult::ImportFailed;
}

@@ -22,19 +22,15 @@ class VolumeWAD;

namespace IOS::HLE
{
class ESDevice;
class Kernel;
}
} // namespace IOS::HLE

namespace IOS::HLE::FS
{
class FileSystem;
}

namespace IOS::HLE::Device
{
class ES;
}

namespace WiiUtils
{
enum class InstallType
@@ -62,7 +58,7 @@ IOS::ES::TMDReader FindBackupTMD(IOS::HLE::FS::FileSystem& fs, u64 title_id);
// Checks if there's a title.tmd imported for the given title ID. If there is not, we attempt to
// re-import it from the TMDs stored in /title/00000001/00000002/data/tmds.sys.
// Returns true if, after this function call, we have an imported title.tmd, or false if not.
bool EnsureTMDIsImported(IOS::HLE::FS::FileSystem& fs, IOS::HLE::Device::ES& es, u64 title_id);
bool EnsureTMDIsImported(IOS::HLE::FS::FileSystem& fs, IOS::HLE::ESDevice& es, u64 title_id);

enum class UpdateResult
{
@@ -568,12 +568,12 @@ bool VolumeVerifier::CheckPartition(const Partition& partition)
const std::vector<u8>& cert_chain = m_volume.GetCertificateChain(partition);

if (IOS::HLE::IPC_SUCCESS !=
es->VerifyContainer(IOS::HLE::Device::ES::VerifyContainerType::Ticket,
IOS::HLE::Device::ES::VerifyMode::DoNotUpdateCertStore,
es->VerifyContainer(IOS::HLE::ESDevice::VerifyContainerType::Ticket,
IOS::HLE::ESDevice::VerifyMode::DoNotUpdateCertStore,
m_volume.GetTicket(partition), cert_chain) ||
IOS::HLE::IPC_SUCCESS !=
es->VerifyContainer(IOS::HLE::Device::ES::VerifyContainerType::TMD,
IOS::HLE::Device::ES::VerifyMode::DoNotUpdateCertStore,
es->VerifyContainer(IOS::HLE::ESDevice::VerifyContainerType::TMD,
IOS::HLE::ESDevice::VerifyMode::DoNotUpdateCertStore,
m_volume.GetTMD(partition), cert_chain))
{
AddProblem(Severity::Low,
@@ -1010,18 +1010,17 @@ void VolumeVerifier::CheckMisc()
const std::vector<u8>& cert_chain = m_volume.GetCertificateChain(PARTITION_NONE);

if (IOS::HLE::IPC_SUCCESS !=
es->VerifyContainer(IOS::HLE::Device::ES::VerifyContainerType::Ticket,
IOS::HLE::Device::ES::VerifyMode::DoNotUpdateCertStore, m_ticket,
es->VerifyContainer(IOS::HLE::ESDevice::VerifyContainerType::Ticket,
IOS::HLE::ESDevice::VerifyMode::DoNotUpdateCertStore, m_ticket,
cert_chain))
{
// i18n: "Ticket" here is a kind of digital authorization to use a certain title (e.g. a game)
AddProblem(Severity::Low, Common::GetStringT("The ticket is not correctly signed."));
}

if (IOS::HLE::IPC_SUCCESS !=
es->VerifyContainer(IOS::HLE::Device::ES::VerifyContainerType::TMD,
IOS::HLE::Device::ES::VerifyMode::DoNotUpdateCertStore, tmd,
cert_chain))
es->VerifyContainer(IOS::HLE::ESDevice::VerifyContainerType::TMD,
IOS::HLE::ESDevice::VerifyMode::DoNotUpdateCertStore, tmd, cert_chain))
{
AddProblem(Severity::Low, Common::GetStringT("The TMD is not correctly signed."));
}
@@ -30,7 +30,7 @@ void Platform::UpdateRunningFlag()
const auto ios = IOS::HLE::GetIOS();
const auto stm = ios ? ios->GetDeviceByName("/dev/stm/eventhook") : nullptr;
if (!m_tried_graceful_shutdown.IsSet() && stm &&
std::static_pointer_cast<IOS::HLE::Device::STMEventHook>(stm)->HasHookInstalled())
std::static_pointer_cast<IOS::HLE::STMEventHookDevice>(stm)->HasHookInstalled())
{
ProcessorInterface::PowerButton_Tap();
m_tried_graceful_shutdown.Set();
@@ -245,7 +245,7 @@ void WiimoteControllersWidget::OnBluetoothPassthroughResetPressed()
auto device = ios->GetDeviceByName("/dev/usb/oh1/57e/305");
if (device != nullptr)
{
std::static_pointer_cast<IOS::HLE::Device::BluetoothBase>(device)->TriggerSyncButtonHeldEvent();
std::static_pointer_cast<IOS::HLE::BluetoothBaseDevice>(device)->TriggerSyncButtonHeldEvent();
}
}

@@ -264,7 +264,7 @@ void WiimoteControllersWidget::OnBluetoothPassthroughSyncPressed()

if (device != nullptr)
{
std::static_pointer_cast<IOS::HLE::Device::BluetoothBase>(device)
std::static_pointer_cast<IOS::HLE::BluetoothBaseDevice>(device)
->TriggerSyncButtonPressedEvent();
}
}
@@ -241,9 +241,9 @@ void NetworkWidget::Update()
{
m_ssl_table->insertRow(ssl_id);
s32 host_fd = -1;
if (IOS::HLE::Device::IsSSLIDValid(ssl_id))
if (IOS::HLE::IsSSLIDValid(ssl_id))
{
host_fd = IOS::HLE::Device::NetSSL::_SSL[ssl_id].hostfd;
host_fd = IOS::HLE::NetSSLDevice::_SSL[ssl_id].hostfd;
}
m_ssl_table->setItem(ssl_id, 0, new QTableWidgetItem(QString::number(ssl_id)));
m_ssl_table->setItem(ssl_id, 1, GetSocketDomain(host_fd));
@@ -233,7 +233,7 @@ void HotkeyScheduler::Run()
auto device = ios ? ios->GetDeviceByName("/dev/usb/oh1/57e/305") : nullptr;

if (device != nullptr)
std::static_pointer_cast<IOS::HLE::Device::BluetoothBase>(device)->UpdateSyncButtonState(
std::static_pointer_cast<IOS::HLE::BluetoothBaseDevice>(device)->UpdateSyncButtonState(
IsHotkey(HK_TRIGGER_SYNC_BUTTON, true));
}

@@ -1732,7 +1732,7 @@ void MainWindow::OnConnectWiiRemote(int id)
if (!ios || SConfig::GetInstance().m_bt_passthrough_enabled)
return;
Core::RunAsCPUThread([&] {
if (const auto bt = std::static_pointer_cast<IOS::HLE::Device::BluetoothEmu>(
if (const auto bt = std::static_pointer_cast<IOS::HLE::BluetoothEmuDevice>(
ios->GetDeviceByName("/dev/usb/oh1/57e/305")))
{
const auto wm = bt->AccessWiimoteByIndex(id);
@@ -1022,7 +1022,7 @@ void MenuBar::UpdateToolsMenu(bool emulation_started)
}

const auto ios = IOS::HLE::GetIOS();
const auto bt = ios ? std::static_pointer_cast<IOS::HLE::Device::BluetoothEmu>(
const auto bt = ios ? std::static_pointer_cast<IOS::HLE::BluetoothEmuDevice>(
ios->GetDeviceByName("/dev/usb/oh1/57e/305")) :
nullptr;
const bool enable_wiimotes =
@@ -385,7 +385,7 @@ bool TriggerSTMPowerEvent()
return false;

const auto stm = ios->GetDeviceByName("/dev/stm/eventhook");
if (!stm || !std::static_pointer_cast<IOS::HLE::Device::STMEventHook>(stm)->HasHookInstalled())
if (!stm || !std::static_pointer_cast<IOS::HLE::STMEventHookDevice>(stm)->HasHookInstalled())
return false;

Core::DisplayMessage("Shutting down", 30000);