@@ -66,8 +66,8 @@ SIDevices ISIDevice::GetDeviceType() const
int ISIDevice::RunBuffer(u8* buffer, int request_length)
{
#ifdef _DEBUG
DEBUG_LOG(SERIALINTERFACE, "Send Data Device(%i) - Length(%i) ", m_device_number,
request_length);
DEBUG_LOG_FMT(SERIALINTERFACE, "Send Data Device({}) - Length({}) ", m_device_number,
request_length);

std::string temp;
int num = 0;
@@ -79,12 +79,12 @@ int ISIDevice::RunBuffer(u8* buffer, int request_length)

if ((num % 8) == 0)
{
DEBUG_LOG(SERIALINTERFACE, "%s", temp.c_str());
DEBUG_LOG_FMT(SERIALINTERFACE, "{}", temp);
temp.clear();
}
}

DEBUG_LOG(SERIALINTERFACE, "%s", temp.c_str());
DEBUG_LOG_FMT(SERIALINTERFACE, "{}", temp);
#endif
return 0;
}
@@ -300,8 +300,8 @@ int CSIDevice_GBA::RunBuffer(u8* buffer, int request_length)
if (m_sock_server.Connect())
{
#ifdef _DEBUG
NOTICE_LOG(SERIALINTERFACE, "%01d cmd %02x [> %02x%02x%02x%02x]", m_device_number, buffer[0],
buffer[1], buffer[2], buffer[3], buffer[4]);
NOTICE_LOG_FMT(SERIALINTERFACE, "{} cmd {:02x} [> {:02x}{:02x}{:02x}{:02x}]", m_device_number,
buffer[0], buffer[1], buffer[2], buffer[3], buffer[4]);
#endif
m_sock_server.Send(buffer);
}
@@ -341,16 +341,17 @@ int CSIDevice_GBA::RunBuffer(u8* buffer, int request_length)
const Common::Log::LOG_LEVELS log_level =
(m_last_cmd == CMD_STATUS || m_last_cmd == CMD_RESET) ? Common::Log::LERROR :
Common::Log::LWARNING;
GENERIC_LOG(Common::Log::SERIALINTERFACE, log_level,
"%01d [< %02x%02x%02x%02x%02x] (%i)", m_device_number,
buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], num_data_received);
GENERIC_LOG_FMT(Common::Log::SERIALINTERFACE, log_level,
"{} [< {:02x}{:02x}{:02x}{:02x}{:02x}] ({})",
m_device_number, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4],
num_data_received);
#endif
return num_data_received;
}
}

// This should never happen, but appease MSVC which thinks it might.
ERROR_LOG(SERIALINTERFACE, "Unknown state %i\n", static_cast<int>(m_next_action));
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown state {}\n", m_next_action);
return 0;
}

@@ -65,7 +65,7 @@ int CSIDevice_GCController::RunBuffer(u8* buffer, int request_length)

case CMD_DIRECT:
{
INFO_LOG(SERIALINTERFACE, "PAD - Direct (Request length: %d)", request_length);
INFO_LOG_FMT(SERIALINTERFACE, "PAD - Direct (Request length: {})", request_length);
u32 high, low;
GetData(high, low);
for (int i = 0; i < 4; i++)
@@ -78,7 +78,7 @@ int CSIDevice_GCController::RunBuffer(u8* buffer, int request_length)

case CMD_ORIGIN:
{
INFO_LOG(SERIALINTERFACE, "PAD - Get Origin");
INFO_LOG_FMT(SERIALINTERFACE, "PAD - Get Origin");

u8* calibration = reinterpret_cast<u8*>(&m_origin);
for (int i = 0; i < (int)sizeof(SOrigin); i++)
@@ -91,7 +91,7 @@ int CSIDevice_GCController::RunBuffer(u8* buffer, int request_length)
// Recalibrate (FiRES: i am not 100 percent sure about this)
case CMD_RECALIBRATE:
{
INFO_LOG(SERIALINTERFACE, "PAD - Recalibrate");
INFO_LOG_FMT(SERIALINTERFACE, "PAD - Recalibrate");

u8* calibration = reinterpret_cast<u8*>(&m_origin);
for (int i = 0; i < (int)sizeof(SOrigin); i++)
@@ -104,8 +104,8 @@ int CSIDevice_GCController::RunBuffer(u8* buffer, int request_length)
// DEFAULT
default:
{
ERROR_LOG(SERIALINTERFACE, "Unknown SI command (0x%x)", command);
PanicAlert("SI: Unknown command (0x%x)", command);
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown SI command ({:#x})", command);
PanicAlertFmt("SI: Unknown command ({:#x})", command);
}
break;
}
@@ -263,12 +263,12 @@ CSIDevice_GCController::HandleButtonCombos(const GCPadStatus& pad_status)
{
if (m_last_button_combo == COMBO_RESET)
{
INFO_LOG(SERIALINTERFACE, "PAD - COMBO_RESET");
INFO_LOG_FMT(SERIALINTERFACE, "PAD - COMBO_RESET");
ProcessorInterface::ResetButton_Tap();
}
else if (m_last_button_combo == COMBO_ORIGIN)
{
INFO_LOG(SERIALINTERFACE, "PAD - COMBO_ORIGIN");
INFO_LOG_FMT(SERIALINTERFACE, "PAD - COMBO_ORIGIN");
SetOrigin(pad_status);
}

@@ -303,7 +303,7 @@ void CSIDevice_GCController::SendCommand(u32 command, u8 poll)

case CMD_WRITE:
{
unsigned int type = controller_command.parameter1; // 0 = stop, 1 = rumble, 2 = stop hard
const u32 type = controller_command.parameter1; // 0 = stop, 1 = rumble, 2 = stop hard

// get the correct pad number that should rumble locally when using netplay
const int pad_num = NetPlay_InGamePadToLocalPad(m_device_number);
@@ -316,18 +316,18 @@ void CSIDevice_GCController::SendCommand(u32 command, u8 poll)
CSIDevice_GCController::Rumble(pad_num, 0.0);
}

if (!poll)
if (poll == 0)
{
m_mode = controller_command.parameter2;
INFO_LOG(SERIALINTERFACE, "PAD %i set to mode %i", m_device_number, m_mode);
INFO_LOG_FMT(SERIALINTERFACE, "PAD {} set to mode {}", m_device_number, m_mode);
}
}
break;

default:
{
ERROR_LOG(SERIALINTERFACE, "Unknown direct command (0x%x)", command);
PanicAlert("SI: Unknown direct command");
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown direct command ({:#x})", command);
PanicAlertFmt("SI: Unknown direct command");
}
break;
}
@@ -129,15 +129,15 @@ void CSIDevice_GCSteeringWheel::SendCommand(u32 command, u8 poll)
Pad::Rumble(pad_num, 0);
break;
default:
WARN_LOG(SERIALINTERFACE, "Unknown CMD_FORCE type %i", int(type));
WARN_LOG_FMT(SERIALINTERFACE, "Unknown CMD_FORCE type {}", int(type));
break;
}
}

if (!poll)
if (poll == 0)
{
m_mode = wheel_command.parameter2;
INFO_LOG(SERIALINTERFACE, "PAD %i set to mode %i", m_device_number, m_mode);
INFO_LOG_FMT(SERIALINTERFACE, "PAD {} set to mode {}", m_device_number, m_mode);
}
}
else
@@ -27,7 +27,7 @@ int CSIDevice_Keyboard::RunBuffer(u8* buffer, int request_length)
ISIDevice::RunBuffer(buffer, request_length);

// Read the command
EBufferCommands command = static_cast<EBufferCommands>(buffer[0]);
const auto command = static_cast<EBufferCommands>(buffer[0]);

// Handle it
switch (command)
@@ -42,7 +42,7 @@ int CSIDevice_Keyboard::RunBuffer(u8* buffer, int request_length)

case CMD_DIRECT:
{
INFO_LOG(SERIALINTERFACE, "Keyboard - Direct (Request Length: %d)", request_length);
INFO_LOG_FMT(SERIALINTERFACE, "Keyboard - Direct (Request Length: {})", request_length);
u32 high, low;
GetData(high, low);
for (int i = 0; i < 4; i++)
@@ -55,7 +55,7 @@ int CSIDevice_Keyboard::RunBuffer(u8* buffer, int request_length)

default:
{
ERROR_LOG(SERIALINTERFACE, "Unknown SI command (0x%x)", command);
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown SI command ({:#x})", command);
}
break;
}
@@ -98,7 +98,7 @@ void CSIDevice_Keyboard::SendCommand(u32 command, u8 poll)
break;
default:
{
ERROR_LOG(SERIALINTERFACE, "Unknown direct command (0x%x)", command);
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown direct command ({:#x})", command);
}
break;
}
@@ -30,7 +30,7 @@ void Wiimote::HandleReportMode(const OutputReportMode& dr)
if (!DataReportBuilder::IsValidMode(dr.mode))
{
// A real wiimote ignores the entire message if the mode is invalid.
WARN_LOG(WIIMOTE, "Game requested invalid report mode: 0x%02x", int(dr.mode));
WARN_LOG_FMT(WIIMOTE, "Game requested invalid report mode: {:#04x}", dr.mode);
return;
}

@@ -56,7 +56,7 @@ void Wiimote::InvokeHandler(H&& handler, const WiimoteCommon::OutputReportGeneri
{
if (size < sizeof(T))
{
ERROR_LOG(WIIMOTE, "InvokeHandler: report: 0x%02x invalid size: %d", int(rpt.rpt_id), size);
ERROR_LOG_FMT(WIIMOTE, "InvokeHandler: report: {:#04x} invalid size: {}", rpt.rpt_id, size);
return;
}

@@ -75,18 +75,18 @@ void Wiimote::EventUnlinked()

void Wiimote::InterruptDataOutput(const u8* data, u32 size)
{
if (!size)
if (size == 0)
{
ERROR_LOG(WIIMOTE, "OutputData: zero sized data");
ERROR_LOG_FMT(WIIMOTE, "OutputData: zero sized data");
return;
}

auto& rpt = *reinterpret_cast<const OutputReportGeneric*>(data);
const auto& rpt = *reinterpret_cast<const OutputReportGeneric*>(data);
const int rpt_size = size - OutputReportGeneric::HEADER_SIZE;

if (!rpt_size)
if (rpt_size == 0)
{
ERROR_LOG(WIIMOTE, "OutputData: zero sized report");
ERROR_LOG_FMT(WIIMOTE, "OutputData: zero sized report");
return;
}

@@ -130,7 +130,7 @@ void Wiimote::InterruptDataOutput(const u8* data, u32 size)
InvokeHandler<OutputReportEnableFeature>(&Wiimote::HandleIRLogicEnable2, rpt, rpt_size);
break;
default:
PanicAlert("HidOutputReport: Unknown report ID 0x%02x", int(rpt.rpt_id));
PanicAlertFmt("HidOutputReport: Unknown report ID {:#04x}", rpt.rpt_id);
break;
}
}
@@ -255,17 +255,17 @@ void Wiimote::HandleWriteData(const OutputReportWriteData& wd)
{
// FYI: Writes during an active read will occasionally produce a "busy" (0x4) ack.
// We won't simulate that as it often does work. Poorly programmed games may rely on it.
WARN_LOG(WIIMOTE, "WriteData: write during active read request.");
WARN_LOG_FMT(WIIMOTE, "WriteData: write during active read request.");
}

u16 address = Common::swap16(wd.address);
const u16 address = Common::swap16(wd.address);

DEBUG_LOG(WIIMOTE, "Wiimote::WriteData: 0x%02x @ 0x%02x @ 0x%02x (%d)", wd.space,
wd.slave_address, address, wd.size);
DEBUG_LOG_FMT(WIIMOTE, "Wiimote::WriteData: {:#04x} @ {:#04x} @ {:#04x} ({})", wd.space,
wd.slave_address, address, wd.size);

if (0 == wd.size || wd.size > 16)
{
WARN_LOG(WIIMOTE, "WriteData: invalid size: %d", wd.size);
WARN_LOG_FMT(WIIMOTE, "WriteData: invalid size: {}", wd.size);
// A real wiimote silently ignores such a request:
return;
}
@@ -278,7 +278,7 @@ void Wiimote::HandleWriteData(const OutputReportWriteData& wd)
{
if (address + wd.size > EEPROM_FREE_SIZE)
{
WARN_LOG(WIIMOTE, "WriteData: address + size out of bounds!");
WARN_LOG_FMT(WIIMOTE, "WriteData: address + size out of bounds!");
error_code = ErrorCode::InvalidAddress;
}
else
@@ -295,7 +295,7 @@ void Wiimote::HandleWriteData(const OutputReportWriteData& wd)
// Attempting to access the EEPROM directly over i2c results in error 8.
if (EEPROM_I2C_ADDR == m_read_request.slave_address)
{
WARN_LOG(WIIMOTE, "Attempt to write EEPROM directly.");
WARN_LOG_FMT(WIIMOTE, "Attempt to write EEPROM directly.");
error_code = ErrorCode::InvalidAddress;
break;
}
@@ -311,7 +311,7 @@ void Wiimote::HandleWriteData(const OutputReportWriteData& wd)
break;

default:
WARN_LOG(WIIMOTE, "WriteData: invalid address space: 0x%x", wd.space);
WARN_LOG_FMT(WIIMOTE, "WriteData: invalid address space: {:#x}", wd.space);
// A real wiimote gives error 6:
error_code = ErrorCode::InvalidSpace;
break;
@@ -383,7 +383,7 @@ void Wiimote::HandleSpeakerData(const WiimoteCommon::OutputReportSpeakerData& rp
{
if (rpt.length > std::size(rpt.data))
{
ERROR_LOG(WIIMOTE, "Bad speaker data length: %d", rpt.length);
ERROR_LOG_FMT(WIIMOTE, "Bad speaker data length: {}", rpt.length);
}
else
{
@@ -403,7 +403,7 @@ void Wiimote::HandleReadData(const OutputReportReadData& rd)
if (m_read_request.size)
{
// There is already an active read being processed.
WARN_LOG(WIIMOTE, "ReadData: attempting read during active request.");
WARN_LOG_FMT(WIIMOTE, "ReadData: attempting read during active request.");

// A real wm+ sends a busy ack in this situation.
SendAck(OutputReportID::ReadData, ErrorCode::Busy);
@@ -417,8 +417,8 @@ void Wiimote::HandleReadData(const OutputReportReadData& rd)
// A zero size request is just ignored, like on the real wiimote.
m_read_request.size = Common::swap16(rd.size);

DEBUG_LOG(WIIMOTE, "Wiimote::ReadData: %d @ 0x%02x @ 0x%02x (%d)", int(m_read_request.space),
m_read_request.slave_address, m_read_request.address, m_read_request.size);
DEBUG_LOG_FMT(WIIMOTE, "Wiimote::ReadData: {} @ {:#04x} @ {:#04x} ({})", m_read_request.space,
m_read_request.slave_address, m_read_request.address, m_read_request.size);

// Send up to one read-data-reply.
// If more data needs to be sent it will happen on the next "Update()"
@@ -480,7 +480,7 @@ bool Wiimote::ProcessReadDataRequest()
// Attempting to access the EEPROM directly over i2c results in error 8.
if (EEPROM_I2C_ADDR == m_read_request.slave_address)
{
WARN_LOG(WIIMOTE, "Attempt to read EEPROM directly.");
WARN_LOG_FMT(WIIMOTE, "Attempt to read EEPROM directly.");
error_code = ErrorCode::InvalidAddress;
break;
}
@@ -504,8 +504,8 @@ bool Wiimote::ProcessReadDataRequest()

if (bytes_read != bytes_to_read)
{
DEBUG_LOG(WIIMOTE, "Responding with read error 7 @ 0x%x @ 0x%x (%d)",
m_read_request.slave_address, m_read_request.address, m_read_request.size);
DEBUG_LOG_FMT(WIIMOTE, "Responding with read error 7 @ {:#x} @ {:#x} ({})",
m_read_request.slave_address, m_read_request.address, m_read_request.size);
error_code = ErrorCode::Nack;
break;
}
@@ -515,7 +515,7 @@ bool Wiimote::ProcessReadDataRequest()
break;

default:
WARN_LOG(WIIMOTE, "ReadData: invalid address space: 0x%x", int(m_read_request.space));
WARN_LOG_FMT(WIIMOTE, "ReadData: invalid address space: {:#x}", int(m_read_request.space));
// A real wiimote gives error 6:
error_code = ErrorCode::InvalidSpace;
break;
@@ -501,7 +501,7 @@ EncryptionKey KeyGen::GenerateFromExtensionKeyData(const ExtKeyData& ext_key) co

// Retail games never hit this path but some homebrew fills encryption key with 0x00.
// Real extensions seem to then use entirely differnet "sboxes" for table generation.
WARN_LOG(WIIMOTE, "Extension key gen did not match any idx. Generating fallback tables.");
WARN_LOG_FMT(WIIMOTE, "Extension key gen did not match any idx. Generating fallback tables.");
return GenerateFallbackTables(rand, key);
}

@@ -234,7 +234,7 @@ int MotionPlus::BusWrite(u8 slave_addr, u8 addr, int count, const u8* data_in)
return m_i2c_bus.BusWrite(slave_addr, addr, count, data_in);
}

DEBUG_LOG(WIIMOTE, "Inactive M+ write 0x%x : %s", addr, ArrayToString(data_in, count).c_str());
DEBUG_LOG_FMT(WIIMOTE, "Inactive M+ write {:#x} : {}", addr, ArrayToString(data_in, count));

auto const result = RawWrite(&m_reg_data, addr, count, data_in);

@@ -255,7 +255,7 @@ int MotionPlus::BusWrite(u8 slave_addr, u8 addr, int count, const u8* data_in)
return 0;
}

DEBUG_LOG(WIIMOTE, "Active M+ write 0x%x : %s", addr, ArrayToString(data_in, count).c_str());
DEBUG_LOG_FMT(WIIMOTE, "Active M+ write {:#x} : {}", addr, ArrayToString(data_in, count));

auto const result = RawWrite(&m_reg_data, addr, count, data_in);

@@ -273,7 +273,7 @@ int MotionPlus::BusWrite(u8 slave_addr, u8 addr, int count, const u8* data_in)
case offsetof(Register, challenge_type):
if (ChallengeState::ParameterXReady == m_reg_data.challenge_state)
{
DEBUG_LOG(WIIMOTE, "M+ challenge: 0x%x", m_reg_data.challenge_type);
DEBUG_LOG_FMT(WIIMOTE, "M+ challenge: {:#x}", m_reg_data.challenge_type);

// After games read parameter x they write here to request y0 or y1.
if (0 == m_reg_data.challenge_type)
@@ -301,7 +301,7 @@ int MotionPlus::BusWrite(u8 slave_addr, u8 addr, int count, const u8* data_in)

case offsetof(Register, calibration_trigger):
// Games seem to invoke this to start and stop calibration. Exact consequences unknown.
DEBUG_LOG(WIIMOTE, "M+ calibration trigger: 0x%x", m_reg_data.calibration_trigger);
DEBUG_LOG_FMT(WIIMOTE, "M+ calibration trigger: {:#x}", m_reg_data.calibration_trigger);
break;

case PASSTHROUGH_MODE_OFFSET:
@@ -343,7 +343,7 @@ void MotionPlus::OnPassthroughModeWrite()

void MotionPlus::Activate()
{
DEBUG_LOG(WIIMOTE, "M+ has been activated.");
DEBUG_LOG_FMT(WIIMOTE, "M+ has been activated.");

m_reg_data.ext_identifier[2] = ACTIVE_DEVICE_ADDR << 1;

@@ -360,7 +360,7 @@ void MotionPlus::Activate()

void MotionPlus::Deactivate()
{
DEBUG_LOG(WIIMOTE, "M+ has been deactivated.");
DEBUG_LOG_FMT(WIIMOTE, "M+ has been deactivated.");

m_reg_data.ext_identifier[2] = INACTIVE_DEVICE_ADDR << 1;

@@ -421,7 +421,7 @@ void MotionPlus::Update()
{
if (is_ext_connected)
{
DEBUG_LOG(WIIMOTE, "M+ initializing new extension.");
DEBUG_LOG_FMT(WIIMOTE, "M+ initializing new extension.");

// The M+ automatically initializes an extension when attached.

@@ -488,7 +488,7 @@ void MotionPlus::Update()
// Big-int little endian parameter x.
param_x.WriteLittleEndianBinary(&m_reg_data.challenge_data);

DEBUG_LOG(WIIMOTE, "M+ parameter x ready.");
DEBUG_LOG_FMT(WIIMOTE, "M+ parameter x ready.");
m_reg_data.challenge_state = ChallengeState::ParameterXReady;
break;
}
@@ -514,7 +514,7 @@ void MotionPlus::Update()
param_y1.WriteLittleEndianBinary(&m_reg_data.challenge_data);
}

DEBUG_LOG(WIIMOTE, "M+ parameter y ready.");
DEBUG_LOG_FMT(WIIMOTE, "M+ parameter y ready.");
m_reg_data.challenge_state = ChallengeState::ParameterYReady;
break;

@@ -583,7 +583,7 @@ void MotionPlus::PrepareInput(const Common::Vec3& angular_velocity)
break;
default:
// This really shouldn't happen as the M+ deactivates on an invalid mode write.
ERROR_LOG(WIIMOTE, "M+ unknown passthrough-mode %d", int(GetPassthroughMode()));
ERROR_LOG_FMT(WIIMOTE, "M+ unknown passthrough-mode {}", GetPassthroughMode());
mplus_data.is_mp_data = true;
break;
}
@@ -117,13 +117,13 @@ void SpeakerLogic::SpeakerData(const u8* data, int length, float speaker_pan)
}
else
{
ERROR_LOG(IOS_WIIMOTE, "Unknown speaker format %x", reg_data.format);
ERROR_LOG_FMT(IOS_WIIMOTE, "Unknown speaker format {:x}", reg_data.format);
return;
}

if (reg_data.volume > volume_divisor)
{
DEBUG_LOG(IOS_WIIMOTE, "Wiimote volume is higher than suspected maximum!");
DEBUG_LOG_FMT(IOS_WIIMOTE, "Wiimote volume is higher than suspected maximum!");
volume_divisor = reg_data.volume;
}

@@ -82,7 +82,7 @@ void Wiimote::Reset()
if (m_eeprom_dirty)
{
// Write out existing EEPROM
INFO_LOG(WIIMOTE, "Wrote EEPROM for %s", GetName().c_str());
INFO_LOG_FMT(WIIMOTE, "Wrote EEPROM for {}", GetName());
std::ofstream file;
File::OpenFStream(file, eeprom_file, std::ios::binary | std::ios::out);
file.write(reinterpret_cast<char*>(m_eeprom.data.data()), EEPROM_FREE_SIZE);
@@ -405,7 +405,7 @@ bool Wiimote::ProcessExtensionPortEvent()
// FYI: This happens even during a read request which continues after the status report is sent.
m_reporting_mode = InputReportID::ReportDisabled;

DEBUG_LOG(WIIMOTE, "Sending status report due to extension status change.");
DEBUG_LOG_FMT(WIIMOTE, "Sending status report due to extension status change.");

HandleRequestStatus(OutputReportRequestStatus{});

@@ -27,7 +27,7 @@ void WiimoteScannerAndroid::FindWiimotes(std::vector<Wiimote*>& found_wiimotes,
found_wiimotes.clear();
found_board = nullptr;

NOTICE_LOG(WIIMOTE, "Finding Wiimotes");
NOTICE_LOG_FMT(WIIMOTE, "Finding Wiimotes");

JNIEnv* env = IDCache::GetEnvForThread();

@@ -24,15 +24,15 @@ WiimoteScannerLinux::WiimoteScannerLinux() : m_device_id(-1), m_device_sock(-1)
m_device_id = hci_get_route(nullptr);
if (m_device_id < 0)
{
NOTICE_LOG(WIIMOTE, "Bluetooth not found.");
NOTICE_LOG_FMT(WIIMOTE, "Bluetooth not found.");
return;
}

// Create a socket to the device
m_device_sock = hci_open_dev(m_device_id);
if (m_device_sock < 0)
{
ERROR_LOG(WIIMOTE, "Unable to open Bluetooth.");
ERROR_LOG_FMT(WIIMOTE, "Unable to open Bluetooth.");
return;
}
}
@@ -66,26 +66,26 @@ void WiimoteScannerLinux::FindWiimotes(std::vector<Wiimote*>& found_wiimotes, Wi
hci_inquiry(m_device_id, wait_len, max_infos, lap, &scan_infos_ptr, IREQ_CACHE_FLUSH);
if (found_devices < 0)
{
ERROR_LOG(WIIMOTE, "Error searching for Bluetooth devices.");
ERROR_LOG_FMT(WIIMOTE, "Error searching for Bluetooth devices.");
return;
}

DEBUG_LOG(WIIMOTE, "Found %i Bluetooth device(s).", found_devices);
DEBUG_LOG_FMT(WIIMOTE, "Found {} Bluetooth device(s).", found_devices);

// Display discovered devices
for (int i = 0; i < found_devices; ++i)
{
NOTICE_LOG(WIIMOTE, "found a device...");
NOTICE_LOG_FMT(WIIMOTE, "found a device...");

// BT names are a maximum of 248 bytes apparently
char name[255] = {};
if (hci_read_remote_name(m_device_sock, &scan_infos[i].bdaddr, sizeof(name), name, 1000) < 0)
{
ERROR_LOG(WIIMOTE, "name request failed");
ERROR_LOG_FMT(WIIMOTE, "name request failed");
continue;
}

NOTICE_LOG(WIIMOTE, "device name %s", name);
NOTICE_LOG_FMT(WIIMOTE, "device name {}", name);
if (!IsValidDeviceName(name))
continue;

@@ -100,12 +100,12 @@ void WiimoteScannerLinux::FindWiimotes(std::vector<Wiimote*>& found_wiimotes, Wi
if (IsBalanceBoardName(name))
{
found_board = wm;
NOTICE_LOG(WIIMOTE, "Found balance board (%s).", bdaddr_str);
NOTICE_LOG_FMT(WIIMOTE, "Found balance board ({}).", bdaddr_str);
}
else
{
found_wiimotes.push_back(wm);
NOTICE_LOG(WIIMOTE, "Found Wiimote (%s).", bdaddr_str);
NOTICE_LOG_FMT(WIIMOTE, "Found Wiimote ({}).", bdaddr_str);
}
}
}
@@ -120,7 +120,7 @@ WiimoteLinux::WiimoteLinux(bdaddr_t bdaddr) : m_bdaddr(bdaddr)
int fds[2];
if (pipe(fds))
{
ERROR_LOG(WIIMOTE, "pipe failed");
ERROR_LOG_FMT(WIIMOTE, "pipe failed");
abort();
}
m_wakeup_pipe_w = fds[1];
@@ -152,7 +152,7 @@ bool WiimoteLinux::ConnectInternal()
// If opening channel fails sleep and try again
if (retry == 3)
{
WARN_LOG(WIIMOTE, "Unable to connect control channel of Wiimote: %s", strerror(errno));
WARN_LOG_FMT(WIIMOTE, "Unable to connect control channel of Wiimote: {}", strerror(errno));
close(m_cmd_sock);
m_cmd_sock = -1;
return false;
@@ -163,7 +163,7 @@ bool WiimoteLinux::ConnectInternal()
}
else
{
WARN_LOG(WIIMOTE, "Unable to open control socket to Wiimote: %s", strerror(errno));
WARN_LOG_FMT(WIIMOTE, "Unable to open control socket to Wiimote: {}", strerror(errno));
return false;
}

@@ -177,7 +177,8 @@ bool WiimoteLinux::ConnectInternal()
// If opening channel fails sleep and try again
if (retry == 3)
{
WARN_LOG(WIIMOTE, "Unable to connect interrupt channel of Wiimote: %s", strerror(errno));
WARN_LOG_FMT(WIIMOTE, "Unable to connect interrupt channel of Wiimote: {}",
strerror(errno));
close(m_int_sock);
close(m_cmd_sock);
m_int_sock = m_cmd_sock = -1;
@@ -189,7 +190,7 @@ bool WiimoteLinux::ConnectInternal()
}
else
{
WARN_LOG(WIIMOTE, "Unable to open interrupt socket to Wiimote: %s", strerror(errno));
WARN_LOG_FMT(WIIMOTE, "Unable to open interrupt socket to Wiimote: {}", strerror(errno));
close(m_cmd_sock);
m_int_sock = m_cmd_sock = -1;
return false;
@@ -217,7 +218,7 @@ void WiimoteLinux::IOWakeup()
char c = 0;
if (write(m_wakeup_pipe_w, &c, 1) != 1)
{
ERROR_LOG(WIIMOTE, "Unable to write to wakeup pipe.");
ERROR_LOG_FMT(WIIMOTE, "Unable to write to wakeup pipe.");
}
}

@@ -238,7 +239,7 @@ int WiimoteLinux::IORead(u8* buf)

if (poll(pollfds.data(), pollfds.size(), -1) == -1)
{
ERROR_LOG(WIIMOTE, "Unable to poll Wiimote %i input socket.", m_index + 1);
ERROR_LOG_FMT(WIIMOTE, "Unable to poll Wiimote {} input socket.", m_index + 1);
return -1;
}

@@ -247,7 +248,7 @@ int WiimoteLinux::IORead(u8* buf)
char c;
if (read(m_wakeup_pipe_r, &c, 1) != 1)
{
ERROR_LOG(WIIMOTE, "Unable to read from wakeup pipe.");
ERROR_LOG_FMT(WIIMOTE, "Unable to read from wakeup pipe.");
}
return -1;
}
@@ -260,15 +261,15 @@ int WiimoteLinux::IORead(u8* buf)
if (r == -1)
{
// Error reading data
ERROR_LOG(WIIMOTE, "Receiving data from Wiimote %i.", m_index + 1);
ERROR_LOG_FMT(WIIMOTE, "Receiving data from Wiimote {}.", m_index + 1);

if (errno == ENOTCONN)
{
// This can happen if the Bluetooth dongle is disconnected
ERROR_LOG(WIIMOTE,
"Bluetooth appears to be disconnected. "
"Wiimote %i will be disconnected.",
m_index + 1);
ERROR_LOG_FMT(WIIMOTE,
"Bluetooth appears to be disconnected. "
"Wiimote {} will be disconnected.",
m_index + 1);
}

r = 0;
@@ -180,7 +180,8 @@ void init_lib()
// all nullptr.
if (!load_hid() || !load_bthprops())
{
NOTICE_LOG(WIIMOTE, "Failed to load Bluetooth support libraries, Wiimotes will not function");
NOTICE_LOG_FMT(WIIMOTE,
"Failed to load Bluetooth support libraries, Wiimotes will not function");
return;
}

@@ -232,20 +233,21 @@ std::wstring GetDeviceProperty(const HDEVINFO& device_info, const PSP_DEVINFO_DA

int IOWritePerSetOutputReport(HANDLE& dev_handle, const u8* buf, size_t len, DWORD* written)
{
BOOLEAN result = pHidD_SetOutputReport(dev_handle, const_cast<u8*>(buf) + 1, (ULONG)(len - 1));
const BOOLEAN result =
pHidD_SetOutputReport(dev_handle, const_cast<u8*>(buf) + 1, (ULONG)(len - 1));
if (!result)
{
DWORD err = GetLastError();
const DWORD err = GetLastError();
if (err == ERROR_SEM_TIMEOUT)
{
NOTICE_LOG(WIIMOTE, "IOWrite[WWM_SET_OUTPUT_REPORT]: Unable to send data to the Wiimote");
NOTICE_LOG_FMT(WIIMOTE, "IOWrite[WWM_SET_OUTPUT_REPORT]: Unable to send data to the Wiimote");
}
else if (err != ERROR_GEN_FAILURE)
{
// Some third-party adapters (DolphinBar) use this
// error code to signal the absence of a Wiimote
// linked to the HID device.
WARN_LOG(WIIMOTE, "IOWrite[WWM_SET_OUTPUT_REPORT]: Error: %08x", err);
WARN_LOG_FMT(WIIMOTE, "IOWrite[WWM_SET_OUTPUT_REPORT]: Error: {:08x}", err);
}
}

@@ -288,14 +290,14 @@ int IOWritePerWriteFile(HANDLE& dev_handle, OVERLAPPED& hid_overlap_write,
switch (error)
{
case ERROR_INVALID_USER_BUFFER:
INFO_LOG(WIIMOTE, "IOWrite[WWM_WRITE_FILE]: Falling back to SetOutputReport");
INFO_LOG_FMT(WIIMOTE, "IOWrite[WWM_WRITE_FILE]: Falling back to SetOutputReport");
write_method = WWM_SET_OUTPUT_REPORT;
return IOWritePerSetOutputReport(dev_handle, buf, len, written);
case ERROR_IO_PENDING:
// Pending is no error!
break;
default:
WARN_LOG(WIIMOTE, "IOWrite[WWM_WRITE_FILE]: Error on WriteFile: %08x", error);
WARN_LOG_FMT(WIIMOTE, "IOWrite[WWM_WRITE_FILE]: Error on WriteFile: {:08x}", error);
CancelIo(dev_handle);
return 0;
}
@@ -311,13 +313,13 @@ int IOWritePerWriteFile(HANDLE& dev_handle, OVERLAPPED& hid_overlap_write,

if (WAIT_TIMEOUT == wait_result)
{
WARN_LOG(WIIMOTE, "IOWrite[WWM_WRITE_FILE]: A timeout occurred on writing to Wiimote.");
WARN_LOG_FMT(WIIMOTE, "IOWrite[WWM_WRITE_FILE]: A timeout occurred on writing to Wiimote.");
CancelIo(dev_handle);
return 1;
}
else if (WAIT_FAILED == wait_result)
{
WARN_LOG(WIIMOTE, "IOWrite[WWM_WRITE_FILE]: A wait error occurred on writing to Wiimote.");
WARN_LOG_FMT(WIIMOTE, "IOWrite[WWM_WRITE_FILE]: A wait error occurred on writing to Wiimote.");
CancelIo(dev_handle);
return 1;
}
@@ -407,7 +409,7 @@ bool CheckForToshibaStack(const DEVINST& hid_interface_device_instance)
return (class_driver_provider == L"TOSHIBA");
}

DEBUG_LOG(WIIMOTE, "Unable to detect class driver provider!");
DEBUG_LOG_FMT(WIIMOTE, "Unable to detect class driver provider!");

return false;
}
@@ -477,7 +479,7 @@ bool IsWiimote(const std::basic_string<TCHAR>& device_path, WinWriteMethod& meth
case InputReportID::Status:
return true;
default:
WARN_LOG(WIIMOTE, "IsWiimote(): Received unexpected report %02x", buf[1]);
WARN_LOG_FMT(WIIMOTE, "IsWiimote(): Received unexpected report {:02x}", buf[1]);
invalid_report_count++;
// If we receive over 15 invalid reports, then this is probably not a Wiimote.
if (invalid_report_count > 15)
@@ -637,8 +639,6 @@ bool WiimoteWindows::ConnectInternal()
TCHAR name[128] = {};
pHidD_GetProductString(dev_handle, name, 128);

//ERROR_LOG(WIIMOTE, "Product string: %s", TStrToUTF8(name).c_str());

if (!IsValidBluetoothName(TStrToUTF8(name)))
{
CloseHandle(dev_handle);
@@ -664,7 +664,7 @@ bool WiimoteWindows::ConnectInternal()
/*
if (!SetThreadPriority(m_wiimote_thread.native_handle(), THREAD_PRIORITY_TIME_CRITICAL))
{
ERROR_LOG(WIIMOTE, "Failed to set Wiimote thread priority");
ERROR_LOG_FMT(WIIMOTE, "Failed to set Wiimote thread priority");
}
*/

@@ -756,7 +756,8 @@ int IORead(HANDLE& dev_handle, OVERLAPPED& hid_overlap_read, u8* buf, int index)
return -1;
}

WARN_LOG(WIIMOTE, "GetOverlappedResult error %d on Wiimote %i.", overlapped_err, index + 1);
WARN_LOG_FMT(WIIMOTE, "GetOverlappedResult error {} on Wiimote {}.", overlapped_err,
index + 1);
return 0;
}
// If IOWakeup sets the event so GetOverlappedResult returns prematurely, but the request is
@@ -770,17 +771,17 @@ int IORead(HANDLE& dev_handle, OVERLAPPED& hid_overlap_read, u8* buf, int index)
}
else
{
WARN_LOG(WIIMOTE, "ReadFile error %d on Wiimote %i.", read_err, index + 1);
WARN_LOG_FMT(WIIMOTE, "ReadFile error {} on Wiimote {}.", read_err, index + 1);
return 0;
}
}

// ReadFile will always return 22 bytes read.
// So we need to calculate the actual report size by its report ID
DWORD report_size = static_cast<DWORD>(GetReportSize(buf[1]));
const auto report_size = static_cast<DWORD>(GetReportSize(buf[1]));
if (report_size == 0)
{
WARN_LOG(WIIMOTE, "Received unsupported report %d in Wii Remote %i", buf[1], index + 1);
WARN_LOG_FMT(WIIMOTE, "Received unsupported report {} in Wii Remote {}", buf[1], index + 1);
return -1;
}

@@ -894,8 +895,8 @@ void ProcessWiimotes(bool new_scan, const T& callback)
while (hFindDevice)
{
// btdi.szName is sometimes missing it's content - it's a bt feature..
DEBUG_LOG(WIIMOTE, "Authenticated %i connected %i remembered %i ", btdi.fAuthenticated,
btdi.fConnected, btdi.fRemembered);
DEBUG_LOG_FMT(WIIMOTE, "Authenticated {} connected {} remembered {} ", btdi.fAuthenticated,
btdi.fConnected, btdi.fRemembered);

if (IsValidDeviceName(WStringToUTF8(btdi.szName)))
{
@@ -925,7 +926,7 @@ void RemoveWiimote(BLUETOOTH_DEVICE_INFO_STRUCT& btdi)
{
if (SUCCEEDED(pBluetoothRemoveDevice(&btdi.Address)))
{
NOTICE_LOG(WIIMOTE, "Removed BT Device", GetLastError());
NOTICE_LOG_FMT(WIIMOTE, "Removed BT Device {}", GetLastError());
}
}
}
@@ -939,8 +940,9 @@ bool AttachWiimote(HANDLE hRadio, const BLUETOOTH_RADIO_INFO& radio_info,
{
auto const& wm_addr = btdi.Address.rgBytes;

NOTICE_LOG(WIIMOTE, "Found Wiimote (%02x:%02x:%02x:%02x:%02x:%02x). Enabling HID service.",
wm_addr[0], wm_addr[1], wm_addr[2], wm_addr[3], wm_addr[4], wm_addr[5]);
NOTICE_LOG_FMT(
WIIMOTE, "Found Wiimote ({:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}). Enabling HID service.",
wm_addr[0], wm_addr[1], wm_addr[2], wm_addr[3], wm_addr[4], wm_addr[5]);

#if defined(AUTHENTICATE_WIIMOTES)
// Authenticate
@@ -953,7 +955,8 @@ bool AttachWiimote(HANDLE hRadio, const BLUETOOTH_RADIO_INFO& radio_info,

if (ERROR_SUCCESS != auth_result)
{
ERROR_LOG(WIIMOTE, "AttachWiimote: BluetoothAuthenticateDeviceEx returned %08x", auth_result);
ERROR_LOG_FMT(WIIMOTE, "AttachWiimote: BluetoothAuthenticateDeviceEx returned {:08x}",
auth_result);
}

DWORD pcServices = 16;
@@ -964,8 +967,8 @@ bool AttachWiimote(HANDLE hRadio, const BLUETOOTH_RADIO_INFO& radio_info,

if (ERROR_SUCCESS != srv_result)
{
ERROR_LOG(WIIMOTE, "AttachWiimote: BluetoothEnumerateInstalledServices returned %08x",
srv_result);
ERROR_LOG_FMT(WIIMOTE, "AttachWiimote: BluetoothEnumerateInstalledServices returned {:08x}",
srv_result);
}
#endif
// Activate service
@@ -976,7 +979,7 @@ bool AttachWiimote(HANDLE hRadio, const BLUETOOTH_RADIO_INFO& radio_info,

if (FAILED(hr))
{
ERROR_LOG(WIIMOTE, "AttachWiimote: BluetoothSetServiceState returned %08x", hr);
ERROR_LOG_FMT(WIIMOTE, "AttachWiimote: BluetoothSetServiceState returned {:08x}", hr);
}
else
{
@@ -996,13 +999,13 @@ bool ForgetWiimote(BLUETOOTH_DEVICE_INFO_STRUCT& btdi)
// Sometimes SetServiceState takes a while..
auto const avoid_forget_seconds = 5.0;

auto pair_time = s_connect_times.find(btdi.Address.ullLong);
const auto pair_time = s_connect_times.find(btdi.Address.ullLong);
if (pair_time == s_connect_times.end() ||
std::difftime(time(nullptr), pair_time->second) >= avoid_forget_seconds)
{
// Make Windows forget about device so it will re-find it if visible.
// This is also required to detect a disconnect for some reason..
NOTICE_LOG(WIIMOTE, "Removing remembered Wiimote.");
NOTICE_LOG_FMT(WIIMOTE, "Removing remembered Wiimote.");
pBluetoothRemoveDevice(&btdi.Address);
return true;
}
@@ -38,7 +38,7 @@ @interface ConnectBT : NSObject
bool btFailed = [bth addressAsString] == nil;
if (btFailed)
{
WARN_LOG(WIIMOTE, "No Bluetooth host controller");
WARN_LOG_FMT(WIIMOTE, "No Bluetooth host controller");
[bth release];
return;
}
@@ -51,7 +51,7 @@ @interface ConnectBT : NSObject

if ([bti start] != kIOReturnSuccess)
{
ERROR_LOG(WIIMOTE, "Unable to do Bluetooth discovery");
ERROR_LOG_FMT(WIIMOTE, "Unable to do Bluetooth discovery");
[bth release];
[sbt release];
btFailed = true;
@@ -65,7 +65,7 @@ @interface ConnectBT : NSObject
int found_devices = [[bti foundDevices] count];

if (found_devices)
NOTICE_LOG(WIIMOTE, "Found %i Bluetooth devices", found_devices);
NOTICE_LOG_FMT(WIIMOTE, "Found {} Bluetooth devices", found_devices);

NSEnumerator* en = [[bti foundDevices] objectEnumerator];
for (int i = 0; i < found_devices; i++)
@@ -131,15 +131,16 @@ @interface ConnectBT : NSObject
IOReturn ret = [m_btd openConnection];
if (ret)
{
ERROR_LOG(WIIMOTE, "Unable to open Bluetooth connection to Wiimote %i: %x", m_index + 1, ret);
ERROR_LOG_FMT(WIIMOTE, "Unable to open Bluetooth connection to Wiimote {}: {:x}", m_index + 1,
ret);
[cbt release];
return false;
}

ret = [m_btd openL2CAPChannelSync:&m_cchan withPSM:kBluetoothL2CAPPSMHIDControl delegate:cbt];
if (ret)
{
ERROR_LOG(WIIMOTE, "Unable to open control channel for Wiimote %i: %x", m_index + 1, ret);
ERROR_LOG_FMT(WIIMOTE, "Unable to open control channel for Wiimote {}: {:x}", m_index + 1, ret);
goto bad;
}
// Apple docs claim:
@@ -152,13 +153,14 @@ @interface ConnectBT : NSObject
ret = [m_btd openL2CAPChannelSync:&m_ichan withPSM:kBluetoothL2CAPPSMHIDInterrupt delegate:cbt];
if (ret)
{
WARN_LOG(WIIMOTE, "Unable to open interrupt channel for Wiimote %i: %x", m_index + 1, ret);
WARN_LOG_FMT(WIIMOTE, "Unable to open interrupt channel for Wiimote {}: {:x}", m_index + 1,
ret);
goto bad;
}
[m_ichan retain];

NOTICE_LOG(WIIMOTE, "Connected to Wiimote %i at %s", m_index + 1,
[[m_btd addressString] UTF8String]);
NOTICE_LOG_FMT(WIIMOTE, "Connected to Wiimote {} at {}", m_index + 1,
[[m_btd addressString] UTF8String]);

m_connected = true;

@@ -190,7 +192,7 @@ @interface ConnectBT : NSObject
if (!IsConnected())
return;

NOTICE_LOG(WIIMOTE, "Disconnecting Wiimote %i", m_index + 1);
NOTICE_LOG_FMT(WIIMOTE, "Disconnecting Wiimote {}", m_index + 1);

m_connected = false;
}
@@ -240,7 +242,9 @@ @interface ConnectBT : NSObject
if (IOReturn ret = IOPMAssertionCreateWithName(
kIOPMAssertPreventUserIdleDisplaySleep, kIOPMAssertionLevelOn,
CFSTR("Dolphin Wiimote activity"), &m_pm_assertion))
ERROR_LOG(WIIMOTE, "Could not create power management assertion: %08x", ret);
{
ERROR_LOG_FMT(WIIMOTE, "Could not create power management assertion: {:08x}", ret);
}
}
}

@@ -249,7 +253,7 @@ @interface ConnectBT : NSObject
if (m_pm_assertion != kIOPMNullAssertionID)
{
if (IOReturn ret = IOPMAssertionRelease(m_pm_assertion))
ERROR_LOG(WIIMOTE, "Could not release power management assertion: %08x", ret);
ERROR_LOG_FMT(WIIMOTE, "Could not release power management assertion: {:08x}", ret);
}
}
} // namespace
@@ -264,8 +268,8 @@ - (void)deviceInquiryComplete:(IOBluetoothDeviceInquiry*)sender

- (void)deviceInquiryDeviceFound:(IOBluetoothDeviceInquiry*)sender device:(IOBluetoothDevice*)device
{
NOTICE_LOG(WIIMOTE, "Discovered Bluetooth device at %s: %s", [[device addressString] UTF8String],
[[device name] UTF8String]);
NOTICE_LOG_FMT(WIIMOTE, "Discovered Bluetooth device at {}: {}",
[[device addressString] UTF8String], [[device name] UTF8String]);

if ([[sender foundDevices] count] == maxDevices)
[sender stop];
@@ -294,19 +298,19 @@ - (void)l2capChannelData:(IOBluetoothL2CAPChannel*)l2capChannel

if (wm == nullptr)
{
ERROR_LOG(WIIMOTE, "Received packet for unknown Wiimote");
ERROR_LOG_FMT(WIIMOTE, "Received packet for unknown Wiimote");
return;
}

if (length > WiimoteCommon::MAX_PAYLOAD)
{
WARN_LOG(WIIMOTE, "Dropping packet for Wiimote %i, too large", wm->GetIndex() + 1);
WARN_LOG_FMT(WIIMOTE, "Dropping packet for Wiimote {}, too large", wm->GetIndex() + 1);
return;
}

if (wm->m_inputlen != -1)
{
WARN_LOG(WIIMOTE, "Dropping packet for Wiimote %i, queue full", wm->GetIndex() + 1);
WARN_LOG_FMT(WIIMOTE, "Dropping packet for Wiimote {}, queue full", wm->GetIndex() + 1);
return;
}

@@ -335,11 +339,11 @@ - (void)l2capChannelClosed:(IOBluetoothL2CAPChannel*)l2capChannel

if (wm == nullptr)
{
ERROR_LOG(WIIMOTE, "Channel for unknown Wiimote was closed");
ERROR_LOG_FMT(WIIMOTE, "Channel for unknown Wiimote was closed");
return;
}

WARN_LOG(WIIMOTE, "Lost channel to Wiimote %i", wm->GetIndex() + 1);
WARN_LOG_FMT(WIIMOTE, "Lost channel to Wiimote {}", wm->GetIndex() + 1);

wm->DisconnectInternal();
}
@@ -18,10 +18,10 @@ static bool IsDeviceUsable(const std::string& device_path)
hid_device* handle = hid_open_path(device_path.c_str());
if (handle == nullptr)
{
ERROR_LOG(WIIMOTE,
"Could not connect to Wii Remote at \"%s\". "
"Do you have permission to access the device?",
device_path.c_str());
ERROR_LOG_FMT(WIIMOTE,
"Could not connect to Wii Remote at \"{}\". "
"Do you have permission to access the device?",
device_path);
return false;
}
// Some third-party adapters (DolphinBar) always expose all four Wii Remotes as HIDs
@@ -31,7 +31,7 @@ static bool IsDeviceUsable(const std::string& device_path)
const int result = hid_write(handle, report, sizeof(report));
// The DolphinBar uses EPIPE to signal the absence of a Wii Remote connected to this HID.
if (result == -1 && errno != EPIPE)
ERROR_LOG(WIIMOTE, "Couldn't write to Wii Remote at \"%s\".", device_path.c_str());
ERROR_LOG_FMT(WIIMOTE, "Couldn't write to Wii Remote at \"{}\".", device_path);

hid_close(handle);
return result != -1;
@@ -48,7 +48,7 @@ WiimoteScannerHidapi::WiimoteScannerHidapi()
WiimoteScannerHidapi::~WiimoteScannerHidapi()
{
if (hid_exit() == -1)
ERROR_LOG(WIIMOTE, "Failed to clean up hidapi.");
ERROR_LOG_FMT(WIIMOTE, "Failed to clean up hidapi.");
}

bool WiimoteScannerHidapi::IsReady() const
@@ -75,10 +75,10 @@ void WiimoteScannerHidapi::FindWiimotes(std::vector<Wiimote*>& wiimotes, Wiimote
else
wiimotes.push_back(wiimote);

NOTICE_LOG(WIIMOTE, "Found %s at %s: %ls %ls (%04hx:%04hx)",
is_balance_board ? "balance board" : "Wiimote", device->path,
device->manufacturer_string, device->product_string, device->vendor_id,
device->product_id);
NOTICE_LOG_FMT(WIIMOTE, "Found {} at {}: {} {} ({:04x}:{:04x})",
is_balance_board ? "balance board" : "Wiimote", device->path,
WStringToUTF8(device->manufacturer_string),
WStringToUTF8(device->product_string), device->vendor_id, device->product_id);
}
hid_free_enumeration(list);
}
@@ -100,10 +100,10 @@ bool WiimoteHidapi::ConnectInternal()
m_handle = hid_open_path(m_device_path.c_str());
if (m_handle == nullptr)
{
ERROR_LOG(WIIMOTE,
"Could not connect to Wii Remote at \"%s\". "
"Do you have permission to access the device?",
m_device_path.c_str());
ERROR_LOG_FMT(WIIMOTE,
"Could not connect to Wii Remote at \"{}\". "
"Do you have permission to access the device?",
m_device_path);
}
return m_handle != nullptr;
}
@@ -126,7 +126,7 @@ int WiimoteHidapi::IORead(u8* buf)
// TODO: If and once we use hidapi across plaforms, change our internal API to clean up this mess.
if (result == -1)
{
ERROR_LOG(WIIMOTE, "Failed to read from %s.", m_device_path.c_str());
ERROR_LOG_FMT(WIIMOTE, "Failed to read from {}.", m_device_path);
return 0; // error
}
if (result == 0)
@@ -143,7 +143,7 @@ int WiimoteHidapi::IOWrite(const u8* buf, size_t len)
int result = hid_write(m_handle, buf + 1, len - 1);
if (result == -1)
{
ERROR_LOG(WIIMOTE, "Failed to write to %s.", m_device_path.c_str());
ERROR_LOG_FMT(WIIMOTE, "Failed to write to {}.", m_device_path);
return 0;
}
return (result == 0) ? 1 : result;
@@ -126,7 +126,7 @@ void AddWiimoteToPool(std::unique_ptr<Wiimote> wiimote)

if (!wiimote->Connect(POOL_WIIMOTE_INDEX))
{
ERROR_LOG(WIIMOTE, "Failed to connect real wiimote.");
ERROR_LOG_FMT(WIIMOTE, "Failed to connect real wiimote.");
return;
}

@@ -147,7 +147,7 @@ void Wiimote::Shutdown()
ClearReadQueue();
m_write_reports.Clear();

NOTICE_LOG(WIIMOTE, "Disconnected real wiimote.");
NOTICE_LOG_FMT(WIIMOTE, "Disconnected real wiimote.");
}

// to be called from CPU thread
@@ -293,7 +293,7 @@ void Wiimote::Read()
}
else if (0 == result)
{
ERROR_LOG(WIIMOTE, "Wiimote::IORead failed. Disconnecting Wii Remote %d.", m_index + 1);
ERROR_LOG_FMT(WIIMOTE, "Wiimote::IORead failed. Disconnecting Wii Remote {}.", m_index + 1);
DisconnectInternal();
}
}
@@ -337,7 +337,7 @@ bool Wiimote::IsBalanceBoard()
if (!IOWrite(init_extension_rpt1, sizeof(init_extension_rpt1)) ||
!IOWrite(init_extension_rpt2, sizeof(init_extension_rpt2)))
{
ERROR_LOG(WIIMOTE, "IsBalanceBoard(): Failed to initialise extension.");
ERROR_LOG_FMT(WIIMOTE, "IsBalanceBoard(): Failed to initialise extension.");
return false;
}

@@ -374,8 +374,8 @@ bool Wiimote::IsBalanceBoard()
const auto* reply = reinterpret_cast<InputReportReadDataReply*>(&buf[2]);
if (Common::swap16(reply->address) != 0x00fe)
{
ERROR_LOG(WIIMOTE, "IsBalanceBoard(): Received unexpected data reply for address %X",
Common::swap16(reply->address));
ERROR_LOG_FMT(WIIMOTE, "IsBalanceBoard(): Received unexpected data reply for address {:X}",
Common::swap16(reply->address));
return false;
}
// A Balance Board ext can be identified by checking for 0x0402.
@@ -386,7 +386,8 @@ bool Wiimote::IsBalanceBoard()
const auto* ack = reinterpret_cast<InputReportAck*>(&buf[2]);
if (ack->rpt_id == OutputReportID::ReadData && ack->error_code != ErrorCode::Success)
{
WARN_LOG(WIIMOTE, "Failed to read from 0xa400fe, assuming Wiimote is not a Balance Board.");
WARN_LOG_FMT(WIIMOTE,
"Failed to read from 0xa400fe, assuming Wiimote is not a Balance Board.");
return false;
}
}
@@ -578,12 +579,12 @@ void WiimoteScanner::PoolThreadFunc()
{
if (!it->wiimote->IsConnected())
{
INFO_LOG(WIIMOTE, "Removing disconnected wiimote pool entry.");
INFO_LOG_FMT(WIIMOTE, "Removing disconnected wiimote pool entry.");
it = s_wiimote_pool.erase(it);
}
else if (it->IsExpired())
{
INFO_LOG(WIIMOTE, "Removing expired wiimote pool entry.");
INFO_LOG_FMT(WIIMOTE, "Removing expired wiimote pool entry.");
it = s_wiimote_pool.erase(it);
}
else
@@ -610,7 +611,7 @@ void WiimoteScanner::ThreadFunc()

Common::SetCurrentThreadName("Wiimote Scanning Thread");

NOTICE_LOG(WIIMOTE, "Wiimote scanning thread has started.");
NOTICE_LOG_FMT(WIIMOTE, "Wiimote scanning thread has started.");

// Create and destroy scanner backends here to ensure all operations stay on the same thread. The
// HIDAPI backend on macOS has an error condition when IOHIDManagerCreate and IOHIDManagerClose
@@ -696,7 +697,7 @@ void WiimoteScanner::ThreadFunc()

pool_thread.join();

NOTICE_LOG(WIIMOTE, "Wiimote scanning thread has stopped.");
NOTICE_LOG_FMT(WIIMOTE, "Wiimote scanning thread has stopped.");
}

bool Wiimote::Connect(int index)
@@ -752,13 +753,13 @@ void Wiimote::ThreadFunc()
{
if (m_need_prepare.TestAndClear() && !PrepareOnThread())
{
ERROR_LOG(WIIMOTE, "Wiimote::PrepareOnThread failed. Disconnecting Wiimote %d.",
m_index + 1);
ERROR_LOG_FMT(WIIMOTE, "Wiimote::PrepareOnThread failed. Disconnecting Wiimote {}.",
m_index + 1);
break;
}
if (!Write())
{
ERROR_LOG(WIIMOTE, "Wiimote::Write failed. Disconnecting Wiimote %d.", m_index + 1);
ERROR_LOG_FMT(WIIMOTE, "Wiimote::Write failed. Disconnecting Wiimote {}.", m_index + 1);
break;
}
Read();
@@ -826,7 +827,7 @@ void Initialize(::Wiimote::InitializeMode init_mode)
if (g_real_wiimotes_initialized)
return;

NOTICE_LOG(WIIMOTE, "WiimoteReal::Initialize");
NOTICE_LOG_FMT(WIIMOTE, "WiimoteReal::Initialize");

g_real_wiimotes_initialized = true;
}
@@ -845,7 +846,7 @@ void Shutdown()
g_real_wiimotes_initialized = false;
s_wiimote_scanner.StopThread();

NOTICE_LOG(WIIMOTE, "WiimoteReal::Shutdown");
NOTICE_LOG_FMT(WIIMOTE, "WiimoteReal::Shutdown");

std::lock_guard lk(g_wiimotes_mutex);
for (unsigned int i = 0; i < MAX_BBMOTES; ++i)
@@ -878,7 +879,7 @@ static bool TryToConnectWiimoteToSlot(std::unique_ptr<Wiimote>& wm, unsigned int

if (!wm->Connect(i))
{
ERROR_LOG(WIIMOTE, "Failed to connect real wiimote.");
ERROR_LOG_FMT(WIIMOTE, "Failed to connect real wiimote.");
return false;
}

@@ -894,7 +895,7 @@ static bool TryToConnectWiimoteToSlot(std::unique_ptr<Wiimote>& wm, unsigned int
WiimoteCommon::UpdateSource(i);
});

NOTICE_LOG(WIIMOTE, "Connected real wiimote to slot %i.", i + 1);
NOTICE_LOG_FMT(WIIMOTE, "Connected real wiimote to slot {}.", i + 1);

return true;
}
@@ -904,7 +905,7 @@ static void TryToConnectBalanceBoard(std::unique_ptr<Wiimote> wm)
if (TryToConnectWiimoteToSlot(wm, WIIMOTE_BALANCE_BOARD))
return;

NOTICE_LOG(WIIMOTE, "No open slot for real balance board.");
NOTICE_LOG_FMT(WIIMOTE, "No open slot for real balance board.");
}

static void HandleWiimoteDisconnect(int index)

Large diffs are not rendered by default.

@@ -94,21 +94,21 @@ bool IOCtlVRequest::HasNumberOfValidVectors(const size_t in_count, const size_t
std::all_of(io_vectors.begin(), io_vectors.end(), IsValidVector);
}

void IOCtlRequest::Log(const std::string& device_name, Common::Log::LOG_TYPE type,
void IOCtlRequest::Log(std::string_view device_name, Common::Log::LOG_TYPE type,
Common::Log::LOG_LEVELS verbosity) const
{
GENERIC_LOG(type, verbosity, "%s (fd %u) - IOCtl 0x%x (in_size=0x%x, out_size=0x%x)",
device_name.c_str(), fd, request, buffer_in_size, buffer_out_size);
GENERIC_LOG_FMT(type, verbosity, "{} (fd {}) - IOCtl {:#x} (in_size={:#x}, out_size={:#x})",
device_name, fd, request, buffer_in_size, buffer_out_size);
}

void IOCtlRequest::Dump(const std::string& description, Common::Log::LOG_TYPE type,
Common::Log::LOG_LEVELS level) const
{
Log("===== " + description, type, level);
GENERIC_LOG(type, level, "In buffer\n%s",
HexDump(Memory::GetPointer(buffer_in), buffer_in_size).c_str());
GENERIC_LOG(type, level, "Out buffer\n%s",
HexDump(Memory::GetPointer(buffer_out), buffer_out_size).c_str());
GENERIC_LOG_FMT(type, level, "In buffer\n{}",
HexDump(Memory::GetPointer(buffer_in), buffer_in_size));
GENERIC_LOG_FMT(type, level, "Out buffer\n{}",
HexDump(Memory::GetPointer(buffer_out), buffer_out_size));
}

void IOCtlRequest::DumpUnknown(const std::string& description, Common::Log::LOG_TYPE type,
@@ -117,20 +117,22 @@ void IOCtlRequest::DumpUnknown(const std::string& description, Common::Log::LOG_
Dump("Unknown IOCtl - " + description, type, level);
}

void IOCtlVRequest::Dump(const std::string& description, Common::Log::LOG_TYPE type,
void IOCtlVRequest::Dump(std::string_view description, Common::Log::LOG_TYPE type,
Common::Log::LOG_LEVELS level) const
{
GENERIC_LOG(type, level, "===== %s (fd %u) - IOCtlV 0x%x (%zu in, %zu io)", description.c_str(),
fd, request, in_vectors.size(), io_vectors.size());
GENERIC_LOG_FMT(type, level, "===== {} (fd {}) - IOCtlV {:#x} ({} in, {} io)", description, fd,
request, in_vectors.size(), io_vectors.size());

size_t i = 0;
for (const auto& vector : in_vectors)
GENERIC_LOG(type, level, "in[%zu] (size=0x%x):\n%s", i++, vector.size,
HexDump(Memory::GetPointer(vector.address), vector.size).c_str());
{
GENERIC_LOG_FMT(type, level, "in[{}] (size={:#x}):\n{}", i++, vector.size,
HexDump(Memory::GetPointer(vector.address), vector.size));
}

i = 0;
for (const auto& vector : io_vectors)
GENERIC_LOG(type, level, "io[%zu] (size=0x%x)", i++, vector.size);
GENERIC_LOG_FMT(type, level, "io[{}] (size={:#x})", i++, vector.size);
}

void IOCtlVRequest::DumpUnknown(const std::string& description, Common::Log::LOG_TYPE type,
@@ -173,12 +175,15 @@ IPCCommandResult Device::Close(u32 fd)

IPCCommandResult Device::Unsupported(const Request& request)
{
static std::map<IPCCommandType, std::string> names = {{{IPC_CMD_READ, "Read"},
{IPC_CMD_WRITE, "Write"},
{IPC_CMD_SEEK, "Seek"},
{IPC_CMD_IOCTL, "IOCtl"},
{IPC_CMD_IOCTLV, "IOCtlV"}}};
WARN_LOG(IOS, "%s does not support %s()", m_name.c_str(), names[request.command].c_str());
static const std::map<IPCCommandType, std::string_view> names{{
{IPC_CMD_READ, "Read"},
{IPC_CMD_WRITE, "Write"},
{IPC_CMD_SEEK, "Seek"},
{IPC_CMD_IOCTL, "IOCtl"},
{IPC_CMD_IOCTLV, "IOCtlV"},
}};

WARN_LOG_FMT(IOS, "{} does not support {}()", m_name, names.at(request.command));
return GetDefaultReply(IPC_EINVAL);
}

@@ -130,7 +130,7 @@ struct IOCtlRequest final : Request
u32 buffer_out = 0;
u32 buffer_out_size = 0;
explicit IOCtlRequest(u32 address);
void Log(const std::string& description, Common::Log::LOG_TYPE type = Common::Log::IOS,
void Log(std::string_view description, Common::Log::LOG_TYPE type = Common::Log::IOS,
Common::Log::LOG_LEVELS level = Common::Log::LINFO) const;
void Dump(const std::string& description, Common::Log::LOG_TYPE type = Common::Log::IOS,
Common::Log::LOG_LEVELS level = Common::Log::LINFO) const;
@@ -157,7 +157,7 @@ struct IOCtlVRequest final : Request
const IOVector* GetVector(size_t index) const;
explicit IOCtlVRequest(u32 address);
bool HasNumberOfValidVectors(size_t in_count, size_t io_count) const;
void Dump(const std::string& description, Common::Log::LOG_TYPE type = Common::Log::IOS,
void Dump(std::string_view description, Common::Log::LOG_TYPE type = Common::Log::IOS,
Common::Log::LOG_LEVELS level = Common::Log::LINFO) const;
void DumpUnknown(const std::string& description, Common::Log::LOG_TYPE type = Common::Log::IOS,
Common::Log::LOG_LEVELS level = Common::Log::LERROR) const;
@@ -10,20 +10,20 @@ namespace IOS::HLE::Device
{
IPCCommandResult Stub::Open(const OpenRequest& request)
{
WARN_LOG(IOS, "%s faking Open()", m_name.c_str());
WARN_LOG_FMT(IOS, "{} faking Open()", m_name);
m_is_active = true;
return GetDefaultReply(IPC_SUCCESS);
}

IPCCommandResult Stub::IOCtl(const IOCtlRequest& request)
{
WARN_LOG(IOS, "%s faking IOCtl()", m_name.c_str());
WARN_LOG_FMT(IOS, "{} faking IOCtl()", m_name);
return GetDefaultReply(IPC_SUCCESS);
}

IPCCommandResult Stub::IOCtlV(const IOCtlVRequest& request)
{
WARN_LOG(IOS, "%s faking IOCtlV()", m_name.c_str());
WARN_LOG_FMT(IOS, "{} faking IOCtlV()", m_name);
return GetDefaultReply(IPC_SUCCESS);
}
} // namespace IOS::HLE::Device
@@ -5,7 +5,6 @@
#include "Core/IOS/ES/ES.h"

#include <algorithm>
#include <cinttypes>
#include <cstdio>
#include <memory>
#include <utility>
@@ -63,7 +62,10 @@ ES::ES(Kernel& ios, const std::string& device_name) : Device(ios, device_name)
const auto result = m_ios.GetFS()->CreateDirectory(PID_KERNEL, PID_KERNEL, directory.path,
directory.attribute, directory.modes);
if (result != FS::ResultCode::Success && result != FS::ResultCode::AlreadyExists)
ERROR_LOG(IOS_ES, "Failed to create %s: error %d", directory.path, FS::ConvertResult(result));
{
ERROR_LOG_FMT(IOS_ES, "Failed to create {}: error {}", directory.path,
FS::ConvertResult(result));
}

// Now update the UID/GID and other attributes.
m_ios.GetFS()->SetMetadata(0, directory.path, directory.uid, directory.gid, directory.attribute,
@@ -74,7 +76,7 @@ ES::ES(Kernel& ios, const std::string& device_name) : Device(ios, device_name)

if (s_title_to_launch != 0)
{
NOTICE_LOG(IOS, "Re-launching title after IOS reload.");
NOTICE_LOG_FMT(IOS, "Re-launching title after IOS reload.");
LaunchTitle(s_title_to_launch, true);
s_title_to_launch = 0;
}
@@ -99,7 +101,7 @@ void TitleContext::Update(const IOS::ES::TMDReader& tmd_, const IOS::ES::TicketR
{
if (!tmd_.IsValid() || !ticket_.IsValid())
{
ERROR_LOG(IOS_ES, "TMD or ticket is not valid -- refusing to update title context");
ERROR_LOG_FMT(IOS_ES, "TMD or ticket is not valid -- refusing to update title context");
return;
}

@@ -120,12 +122,13 @@ IPCCommandResult ES::GetTitleDirectory(const IOCtlVRequest& request)
if (!request.HasNumberOfValidVectors(1, 1))
return GetDefaultReply(ES_EINVAL);

u64 TitleID = Memory::Read_U64(request.in_vectors[0].address);
const u64 title_id = Memory::Read_U64(request.in_vectors[0].address);

char* Path = (char*)Memory::GetPointer(request.io_vectors[0].address);
sprintf(Path, "/title/%08x/%08x/data", (u32)(TitleID >> 32), (u32)TitleID);
char* path = reinterpret_cast<char*>(Memory::GetPointer(request.io_vectors[0].address));
sprintf(path, "/title/%08x/%08x/data", static_cast<u32>(title_id >> 32),
static_cast<u32>(title_id));

INFO_LOG(IOS_ES, "IOCTL_ES_GETTITLEDIR: %s", Path);
INFO_LOG_FMT(IOS_ES, "IOCTL_ES_GETTITLEDIR: {}", path);
return GetDefaultReply(IPC_SUCCESS);
}

@@ -148,8 +151,8 @@ IPCCommandResult ES::GetTitleId(const IOCtlVRequest& request)
return GetDefaultReply(ret);

Memory::Write_U64(title_id, request.io_vectors[0].address);
INFO_LOG(IOS_ES, "IOCTL_ES_GETTITLEID: %08x/%08x", static_cast<u32>(title_id >> 32),
static_cast<u32>(title_id));
INFO_LOG_FMT(IOS_ES, "IOCTL_ES_GETTITLEID: {:08x}/{:08x}", static_cast<u32>(title_id >> 32),
static_cast<u32>(title_id));
return GetDefaultReply(IPC_SUCCESS);
}

@@ -158,9 +161,9 @@ static bool UpdateUIDAndGID(Kernel& kernel, const IOS::ES::TMDReader& tmd)
IOS::ES::UIDSys uid_sys{kernel.GetFS()};
const u64 title_id = tmd.GetTitleId();
const u32 uid = uid_sys.GetOrInsertUIDForTitle(title_id);
if (!uid)
if (uid == 0)
{
ERROR_LOG(IOS_ES, "Failed to get UID for title %016" PRIx64, title_id);
ERROR_LOG_FMT(IOS_ES, "Failed to get UID for title {:016x}", title_id);
return false;
}
kernel.SetUidForPPC(uid);
@@ -200,7 +203,7 @@ IPCCommandResult ES::SetUID(u32 uid, const IOCtlVRequest& request)
const s32 ret = CheckIsAllowedToSetUID(m_ios, uid, m_title_context.tmd);
if (ret < 0)
{
ERROR_LOG(IOS_ES, "SetUID: Permission check failed with error %d", ret);
ERROR_LOG_FMT(IOS_ES, "SetUID: Permission check failed with error {}", ret);
return GetDefaultReply(ret);
}

@@ -210,7 +213,7 @@ IPCCommandResult ES::SetUID(u32 uid, const IOCtlVRequest& request)

if (!UpdateUIDAndGID(m_ios, tmd))
{
ERROR_LOG(IOS_ES, "SetUID: Failed to get UID for title %016" PRIx64, title_id);
ERROR_LOG_FMT(IOS_ES, "SetUID: Failed to get UID for title {:016x}", title_id);
return GetDefaultReply(ES_SHORT_READ);
}

@@ -220,17 +223,18 @@ IPCCommandResult ES::SetUID(u32 uid, const IOCtlVRequest& request)
bool ES::LaunchTitle(u64 title_id, bool skip_reload)
{
m_title_context.Clear();
INFO_LOG(IOS_ES, "ES_Launch: Title context changed: (none)");
INFO_LOG_FMT(IOS_ES, "ES_Launch: Title context changed: (none)");

NOTICE_LOG(IOS_ES, "Launching title %016" PRIx64 "...", title_id);
NOTICE_LOG_FMT(IOS_ES, "Launching title {:016x}...", title_id);

if ((title_id == Titles::SHOP || title_id == Titles::KOREAN_SHOP) &&
m_ios.GetIOSC().IsUsingDefaultId())
{
ERROR_LOG(IOS_ES, "Refusing to launch the shop channel with default device credentials");
CriticalAlertT("You cannot use the Wii Shop Channel without using your own device credentials."
"\nPlease refer to the NAND usage guide for setup instructions: "
"https://dolphin-emu.org/docs/guides/nand-usage-guide/");
ERROR_LOG_FMT(IOS_ES, "Refusing to launch the shop channel with default device credentials");
CriticalAlertFmtT(
"You cannot use the Wii Shop Channel without using your own device credentials."
"\nPlease refer to the NAND usage guide for setup instructions: "
"https://dolphin-emu.org/docs/guides/nand-usage-guide/");

// Send the user back to the system menu instead of returning an error, which would
// likely make the system menu crash. Doing this is okay as anyone who has the shop
@@ -256,7 +260,7 @@ bool ES::LaunchIOS(u64 ios_title_id)
// (indirectly via boot2), we can just launch MIOS when BC is launched.
if (ios_title_id == Titles::BC)
{
NOTICE_LOG(IOS, "BC: Launching MIOS...");
NOTICE_LOG_FMT(IOS, "BC: Launching MIOS...");
return LaunchIOS(Titles::MIOS);
}

@@ -271,9 +275,9 @@ bool ES::LaunchIOS(u64 ios_title_id)
if (!tmd.IsValid() || !ticket.IsValid() || !tmd.GetContent(tmd.GetBootIndex(), &content) ||
!m_ios.BootIOS(ios_title_id, GetContentPath(ios_title_id, content)))
{
PanicAlertT("Could not launch IOS %016" PRIx64 " because it is missing from the NAND.\n"
"The emulated software will likely hang now.",
ios_title_id);
PanicAlertFmtT("Could not launch IOS {0:016x} because it is missing from the NAND.\n"
"The emulated software will likely hang now.",
ios_title_id);
return false;
}
return true;
@@ -291,14 +295,14 @@ bool ES::LaunchPPCTitle(u64 title_id, bool skip_reload)
{
if (title_id == Titles::SYSTEM_MENU)
{
PanicAlertT("Could not launch the Wii Menu because it is missing from the NAND.\n"
"The emulated software will likely hang now.");
PanicAlertFmtT("Could not launch the Wii Menu because it is missing from the NAND.\n"
"The emulated software will likely hang now.");
}
else
{
PanicAlertT("Could not launch title %016" PRIx64 " because it is missing from the NAND.\n"
"The emulated software will likely hang now.",
title_id);
PanicAlertFmtT("Could not launch title {0:016x} because it is missing from the NAND.\n"
"The emulated software will likely hang now.",
title_id);
}
return false;
}
@@ -314,14 +318,14 @@ bool ES::LaunchPPCTitle(u64 title_id, bool skip_reload)
}

m_title_context.Update(tmd, ticket, DiscIO::Platform::WiiWAD);
INFO_LOG(IOS_ES, "LaunchPPCTitle: Title context changed: %016" PRIx64, tmd.GetTitleId());
INFO_LOG_FMT(IOS_ES, "LaunchPPCTitle: Title context changed: {:016x}", tmd.GetTitleId());

// Note: the UID/GID is also updated for IOS titles, but since we have no guarantee IOS titles
// are installed, we can only do this for PPC titles.
if (!UpdateUIDAndGID(m_ios, m_title_context.tmd))
{
m_title_context.Clear();
INFO_LOG(IOS_ES, "LaunchPPCTitle: Title context changed: (none)");
INFO_LOG_FMT(IOS_ES, "LaunchPPCTitle: Title context changed: (none)");
return false;
}

@@ -395,14 +399,14 @@ IPCCommandResult ES::Close(u32 fd)
context->active = false;
context->ipc_fd = -1;

INFO_LOG(IOS_ES, "ES: Close");
INFO_LOG_FMT(IOS_ES, "ES: Close");
m_is_active = false;
return GetDefaultReply(IPC_SUCCESS);
}

IPCCommandResult ES::IOCtlV(const IOCtlVRequest& request)
{
DEBUG_LOG(IOS_ES, "%s (0x%x)", GetDeviceName().c_str(), request.request);
DEBUG_LOG_FMT(IOS_ES, "{} ({:#x})", GetDeviceName(), request.request);
auto context = FindActiveContext(request.fd);
if (context == m_contexts.end())
return GetDefaultReply(ES_EINVAL);
@@ -552,8 +556,8 @@ IPCCommandResult ES::IOCtlV(const IOCtlVRequest& request)

case IOCTL_ES_UNKNOWN_41:
case IOCTL_ES_UNKNOWN_42:
PanicAlert("IOS-ES: Unimplemented ioctlv 0x%x (%zu in vectors, %zu io vectors)",
request.request, request.in_vectors.size(), request.io_vectors.size());
PanicAlertFmt("IOS-ES: Unimplemented ioctlv {:#x} ({} in vectors, {} io vectors)",
request.request, request.in_vectors.size(), request.io_vectors.size());
request.DumpUnknown(GetDeviceName(), Common::Log::IOS_ES, Common::Log::LERROR);
return GetDefaultReply(IPC_EINVAL);

@@ -570,7 +574,7 @@ IPCCommandResult ES::GetConsumption(const IOCtlVRequest& request)

// This is at least what crediar's ES module does
Memory::Write_U32(0, request.io_vectors[1].address);
INFO_LOG(IOS_ES, "IOCTL_ES_GETCONSUMPTION");
INFO_LOG_FMT(IOS_ES, "IOCTL_ES_GETCONSUMPTION");
return GetDefaultReply(IPC_SUCCESS);
}

@@ -579,23 +583,23 @@ IPCCommandResult ES::Launch(const IOCtlVRequest& request)
if (!request.HasNumberOfValidVectors(2, 0))
return GetDefaultReply(ES_EINVAL);

u64 TitleID = Memory::Read_U64(request.in_vectors[0].address);
u32 view = Memory::Read_U32(request.in_vectors[1].address);
u64 ticketid = Memory::Read_U64(request.in_vectors[1].address + 4);
u32 devicetype = Memory::Read_U32(request.in_vectors[1].address + 12);
u64 titleid = Memory::Read_U64(request.in_vectors[1].address + 16);
u16 access = Memory::Read_U16(request.in_vectors[1].address + 24);
const u64 title_id = Memory::Read_U64(request.in_vectors[0].address);
const u32 view = Memory::Read_U32(request.in_vectors[1].address);
const u64 ticketid = Memory::Read_U64(request.in_vectors[1].address + 4);
const u32 devicetype = Memory::Read_U32(request.in_vectors[1].address + 12);
const u64 titleid = Memory::Read_U64(request.in_vectors[1].address + 16);
const u16 access = Memory::Read_U16(request.in_vectors[1].address + 24);

INFO_LOG(IOS_ES, "IOCTL_ES_LAUNCH %016" PRIx64 " %08x %016" PRIx64 " %08x %016" PRIx64 " %04x",
TitleID, view, ticketid, devicetype, titleid, access);
INFO_LOG_FMT(IOS_ES, "IOCTL_ES_LAUNCH {:016x} {:08x} {:016x} {:08x} {:016x} {:04x}", title_id,
view, ticketid, devicetype, titleid, access);

// Prevent loading installed IOSes that are not emulated.
if (!IOS::HLE::IsEmulated(TitleID))
if (!IOS::HLE::IsEmulated(title_id))
return GetDefaultReply(FS_ENOENT);

// IOS replies to the request through the mailbox on failure, and acks if the launch succeeds.
// Note: Launch will potentially reset the whole IOS state -- including this ES instance.
if (!LaunchTitle(TitleID))
if (!LaunchTitle(title_id))
return GetDefaultReply(FS_ENOENT);

// ES_LAUNCH involves restarting IOS, which results in two acknowledgements in a row
@@ -655,7 +659,7 @@ static ReturnCode WriteTmdForDiVerify(FS::FileSystem* fs, const IOS::ES::TMDRead
ReturnCode ES::DIVerify(const IOS::ES::TMDReader& tmd, const IOS::ES::TicketReader& ticket)
{
m_title_context.Clear();
INFO_LOG(IOS_ES, "ES_DIVerify: Title context changed: (none)");
INFO_LOG_FMT(IOS_ES, "ES_DIVerify: Title context changed: (none)");

if (!tmd.IsValid() || !ticket.IsValid())
return ES_EINVAL;
@@ -664,7 +668,7 @@ ReturnCode ES::DIVerify(const IOS::ES::TMDReader& tmd, const IOS::ES::TicketRead
return ES_EINVAL;

m_title_context.Update(tmd, ticket, DiscIO::Platform::WiiDisc);
INFO_LOG(IOS_ES, "ES_DIVerify: Title context changed: %016" PRIx64, tmd.GetTitleId());
INFO_LOG_FMT(IOS_ES, "ES_DIVerify: Title context changed: {:016x}", tmd.GetTitleId());

// XXX: We are supposed to verify the TMD and ticket here, but cannot because
// this may cause issues with custom/patched games.
@@ -674,7 +678,7 @@ ReturnCode ES::DIVerify(const IOS::ES::TMDReader& tmd, const IOS::ES::TicketRead
{
if (const ReturnCode ret = WriteTmdForDiVerify(fs.get(), tmd))
{
ERROR_LOG(IOS_ES, "DiVerify failed to write disc TMD to NAND.");
ERROR_LOG_FMT(IOS_ES, "DiVerify failed to write disc TMD to NAND.");
return ret;
}
}
@@ -932,7 +936,7 @@ ReturnCode ES::VerifyContainer(VerifyContainerType type, VerifyMode mode,
ret = iosc.ImportCertificate(ca_cert, IOSC::HANDLE_ROOT_KEY, handle, PID_ES);
if (ret != IPC_SUCCESS)
{
ERROR_LOG(IOS_ES, "VerifyContainer: IOSC_ImportCertificate(ca) failed with error %d", ret);
ERROR_LOG_FMT(IOS_ES, "VerifyContainer: IOSC_ImportCertificate(ca) failed with error {}", ret);
return ret;
}

@@ -946,7 +950,8 @@ ReturnCode ES::VerifyContainer(VerifyContainerType type, VerifyMode mode,
ret = iosc.ImportCertificate(issuer_cert, handle, issuer_handle, PID_ES);
if (ret != IPC_SUCCESS)
{
ERROR_LOG(IOS_ES, "VerifyContainer: IOSC_ImportCertificate(issuer) failed with error %d", ret);
ERROR_LOG_FMT(IOS_ES, "VerifyContainer: IOSC_ImportCertificate(issuer) failed with error {}",
ret);
return ret;
}

@@ -955,19 +960,22 @@ ReturnCode ES::VerifyContainer(VerifyContainerType type, VerifyMode mode,
ret = iosc.VerifyPublicKeySign(signed_blob.GetSha1(), issuer_handle, signature, PID_ES);
if (ret != IPC_SUCCESS)
{
ERROR_LOG(IOS_ES, "VerifyContainer: IOSC_VerifyPublicKeySign failed with error %d", ret);
ERROR_LOG_FMT(IOS_ES, "VerifyContainer: IOSC_VerifyPublicKeySign failed with error {}", ret);
return ret;
}

if (mode == VerifyMode::UpdateCertStore)
{
ret = WriteNewCertToStore(issuer_cert);
if (ret != IPC_SUCCESS)
ERROR_LOG(IOS_ES, "VerifyContainer: Writing the issuer cert failed with return code %d", ret);
{
ERROR_LOG_FMT(IOS_ES, "VerifyContainer: Writing the issuer cert failed with return code {}",
ret);
}

ret = WriteNewCertToStore(ca_cert);
if (ret != IPC_SUCCESS)
ERROR_LOG(IOS_ES, "VerifyContainer: Writing the CA cert failed with return code %d", ret);
ERROR_LOG_FMT(IOS_ES, "VerifyContainer: Writing the CA cert failed with return code {}", ret);
}

if (ret == IPC_SUCCESS && issuer_handle_out)
@@ -6,7 +6,6 @@

#include <algorithm>
#include <array>
#include <cinttypes>
#include <cstddef>
#include <cstring>
#include <map>
@@ -430,8 +429,8 @@ std::array<u8, 16> TicketReader::GetTitleKey(const HLE::IOSC& iosc) const
u8 index = m_bytes.at(offsetof(Ticket, common_key_index));
if (index >= HLE::IOSC::COMMON_KEY_HANDLES.size())
{
PanicAlert("Bad common key index for title %016" PRIx64 ": %u -- using common key 0",
GetTitleId(), index);
PanicAlertFmt("Bad common key index for title {:016x}: {} -- using common key 0", GetTitleId(),
index);
index = 0;
}
auto common_key_handle = HLE::IOSC::COMMON_KEY_HANDLES[index];
@@ -654,7 +653,7 @@ u32 UIDSys::GetOrInsertUIDForTitle(const u64 title_id)
const u32 current_uid = GetUIDFromTitle(title_id);
if (current_uid)
{
INFO_LOG(IOS_ES, "Title %016" PRIx64 " already exists in uid.sys", title_id);
INFO_LOG_FMT(IOS_ES, "Title {:016x} already exists in uid.sys", title_id);
return current_uid;
}

@@ -671,7 +670,7 @@ u32 UIDSys::GetOrInsertUIDForTitle(const u64 title_id)
if (!file || !file->Seek(0, HLE::FS::SeekMode::End) || !file->Write(&swapped_title_id, 1) ||
!file->Write(&swapped_uid, 1))
{
ERROR_LOG(IOS_ES, "Failed to write to /sys/uid.sys");
ERROR_LOG_FMT(IOS_ES, "Failed to write to /sys/uid.sys");
return 0;
}

@@ -23,7 +23,7 @@ namespace IOS::HLE::Device
ReturnCode ES::GetDeviceId(u32* device_id) const
{
*device_id = m_ios.GetIOSC().GetDeviceId();
INFO_LOG(IOS_ES, "GetDeviceId: %08X", *device_id);
INFO_LOG_FMT(IOS_ES, "GetDeviceId: {:08X}", *device_id);
return IPC_SUCCESS;
}

@@ -83,7 +83,7 @@ IPCCommandResult ES::CheckKoreaRegion(const IOCtlVRequest& request)
// IOS70 has this to let system menu 4.2 check if the console is region changed. it returns
// -1017
// if the IOS didn't find the Korean keys and 0 if it does. 0 leads to a error 003
INFO_LOG(IOS_ES, "IOCTL_ES_CHECKKOREAREGION: Title checked for Korean keys.");
INFO_LOG_FMT(IOS_ES, "IOCTL_ES_CHECKKOREAREGION: Title checked for Korean keys.");
return GetDefaultReply(ES_EINVAL);
}

@@ -92,7 +92,7 @@ IPCCommandResult ES::GetDeviceCertificate(const IOCtlVRequest& request)
if (!request.HasNumberOfValidVectors(0, 1) || request.io_vectors[0].size != 0x180)
return GetDefaultReply(ES_EINVAL);

INFO_LOG(IOS_ES, "IOCTL_ES_GETDEVICECERT");
INFO_LOG_FMT(IOS_ES, "IOCTL_ES_GETDEVICECERT");

const IOS::CertECC cert = m_ios.GetIOSC().GetDeviceCertificate();
Memory::CopyToEmu(request.io_vectors[0].address, &cert, sizeof(cert));
@@ -104,7 +104,7 @@ IPCCommandResult ES::Sign(const IOCtlVRequest& request)
if (!request.HasNumberOfValidVectors(1, 2))
return GetDefaultReply(ES_EINVAL);

INFO_LOG(IOS_ES, "IOCTL_ES_SIGN");
INFO_LOG_FMT(IOS_ES, "IOCTL_ES_SIGN");
u8* ap_cert_out = Memory::GetPointer(request.io_vectors[1].address);
u8* data = Memory::GetPointer(request.in_vectors[0].address);
u32 data_size = request.in_vectors[0].size;
@@ -148,14 +148,14 @@ ReturnCode ES::VerifySign(const std::vector<u8>& hash, const std::vector<u8>& ec
certs_bytes, ng_cert);
if (ret != IPC_SUCCESS)
{
ERROR_LOG(IOS_ES, "VerifySign: VerifyContainer(ng) failed with error %d", ret);
ERROR_LOG_FMT(IOS_ES, "VerifySign: VerifyContainer(ng) failed with error {}", ret);
return ret;
}

ret = iosc.VerifyPublicKeySign(ap.GetSha1(), ng_cert, ap.GetSignatureData(), PID_ES);
if (ret != IPC_SUCCESS)
{
ERROR_LOG(IOS_ES, "VerifySign: IOSC_VerifyPublicKeySign(ap) failed with error %d", ret);
ERROR_LOG_FMT(IOS_ES, "VerifySign: IOSC_VerifyPublicKeySign(ap) failed with error {}", ret);
return ret;
}

@@ -168,7 +168,7 @@ ReturnCode ES::VerifySign(const std::vector<u8>& hash, const std::vector<u8>& ec
ret = iosc.ImportPublicKey(ap_cert, ap.GetPublicKey().data(), nullptr, PID_ES);
if (ret != IPC_SUCCESS)
{
ERROR_LOG(IOS_ES, "VerifySign: IOSC_ImportPublicKey(ap) failed with error %d", ret);
ERROR_LOG_FMT(IOS_ES, "VerifySign: IOSC_ImportPublicKey(ap) failed with error {}", ret);
return ret;
}

@@ -177,7 +177,7 @@ ReturnCode ES::VerifySign(const std::vector<u8>& hash, const std::vector<u8>& ec
ret = iosc.VerifyPublicKeySign(sha1, ap_cert, ecc_signature, PID_ES);
if (ret != IPC_SUCCESS)
{
ERROR_LOG(IOS_ES, "VerifySign: IOSC_VerifyPublicKeySign(data) failed with error %d", ret);
ERROR_LOG_FMT(IOS_ES, "VerifySign: IOSC_VerifyPublicKeySign(data) failed with error {}", ret);
return ret;
}

@@ -5,7 +5,6 @@
#include <algorithm>
#include <array>
#include <cctype>
#include <cinttypes>
#include <functional>
#include <iterator>
#include <string>
@@ -75,7 +74,7 @@ static std::vector<u64> GetTitlesInTitleOrImport(FS::FileSystem* fs, const std::
const auto entries = fs->ReadDirectory(PID_KERNEL, PID_KERNEL, titles_dir);
if (!entries)
{
ERROR_LOG(IOS_ES, "%s is not a directory", titles_dir.c_str());
ERROR_LOG_FMT(IOS_ES, "{} is not a directory", titles_dir);
return {};
}

@@ -128,7 +127,7 @@ std::vector<u64> ES::GetTitlesWithTickets() const
const auto entries = fs->ReadDirectory(PID_KERNEL, PID_KERNEL, "/ticket");
if (!entries)
{
ERROR_LOG(IOS_ES, "/ticket is not a directory");
ERROR_LOG_FMT(IOS_ES, "/ticket is not a directory");
return {};
}

@@ -232,7 +231,7 @@ bool ES::CreateTitleDirectories(u64 title_id, u16 group_id) const
fs->SetMetadata(PID_KERNEL, content_dir, PID_KERNEL, PID_KERNEL, 0, content_dir_modes);
if (result1 != FS::ResultCode::Success || result2 != FS::ResultCode::Success)
{
ERROR_LOG(IOS_ES, "Failed to create or set metadata on content dir for %016" PRIx64, title_id);
ERROR_LOG_FMT(IOS_ES, "Failed to create or set metadata on content dir for {:016x}", title_id);
return false;
}

@@ -242,15 +241,15 @@ bool ES::CreateTitleDirectories(u64 title_id, u16 group_id) const
fs->CreateDirectory(PID_KERNEL, PID_KERNEL, data_dir, 0,
data_dir_modes) != FS::ResultCode::Success))
{
ERROR_LOG(IOS_ES, "Failed to create data dir for %016" PRIx64, title_id);
ERROR_LOG_FMT(IOS_ES, "Failed to create data dir for {:016x}", title_id);
return false;
}

IOS::ES::UIDSys uid_sys{fs};
const u32 uid = uid_sys.GetOrInsertUIDForTitle(title_id);
if (fs->SetMetadata(0, data_dir, uid, group_id, 0, data_dir_modes) != FS::ResultCode::Success)
{
ERROR_LOG(IOS_ES, "Failed to set metadata on data dir for %016" PRIx64, title_id);
ERROR_LOG_FMT(IOS_ES, "Failed to set metadata on data dir for {:016x}", title_id);
return false;
}

@@ -268,7 +267,7 @@ bool ES::InitImport(const IOS::ES::TMDReader& tmd)
fs->CreateFullPath(PID_KERNEL, PID_KERNEL, import_content_dir + '/', 0, content_dir_modes);
if (result != FS::ResultCode::Success)
{
ERROR_LOG(IOS_ES, "InitImport: Failed to create content dir for %016" PRIx64, tmd.GetTitleId());
ERROR_LOG_FMT(IOS_ES, "InitImport: Failed to create content dir for {:016x}", tmd.GetTitleId());
return false;
}

@@ -282,7 +281,7 @@ bool ES::InitImport(const IOS::ES::TMDReader& tmd)
const auto rename_result = fs->Rename(PID_KERNEL, PID_KERNEL, content_dir, import_content_dir);
if (rename_result != FS::ResultCode::Success)
{
ERROR_LOG(IOS_ES, "InitImport: Failed to move content dir for %016" PRIx64, tmd.GetTitleId());
ERROR_LOG_FMT(IOS_ES, "InitImport: Failed to move content dir for {:016x}", tmd.GetTitleId());
return false;
}
DeleteDirectoriesIfEmpty(m_ios.GetFS().get(), import_content_dir);
@@ -316,7 +315,7 @@ bool ES::FinishImport(const IOS::ES::TMDReader& tmd)
if (fs->Rename(PID_KERNEL, PID_KERNEL, import_content_dir, content_dir) !=
FS::ResultCode::Success)
{
ERROR_LOG(IOS_ES, "FinishImport: Failed to rename import directory to %s", content_dir.c_str());
ERROR_LOG_FMT(IOS_ES, "FinishImport: Failed to rename import directory to {}", content_dir);
return false;
}
return true;
@@ -4,7 +4,6 @@

#include "Core/IOS/ES/ES.h"

#include <cinttypes>
#include <utility>
#include <vector>

@@ -40,7 +39,7 @@ s32 ES::OpenContent(const IOS::ES::TMDReader& tmd, u16 content_index, u32 uid)
entry.m_content = content;
entry.m_title_id = title_id;
entry.m_uid = uid;
INFO_LOG(IOS_ES, "OpenContent: title ID %016" PRIx64 ", UID 0x%x, CFD %zu", title_id, uid, i);
INFO_LOG_FMT(IOS_ES, "OpenContent: title ID {:016x}, UID {:#x}, CFD {}", title_id, uid, i);
return static_cast<s32>(i);
}

@@ -125,7 +124,7 @@ ReturnCode ES::CloseContent(u32 cfd, u32 uid)

m_ios.GetFS()->Close(entry.m_fd);
entry = {};
INFO_LOG(IOS_ES, "CloseContent: CFD %u", cfd);
INFO_LOG_FMT(IOS_ES, "CloseContent: CFD {}", cfd);
return IPC_SUCCESS;
}

@@ -4,7 +4,6 @@

#include "Core/IOS/ES/ES.h"

#include <cinttypes>
#include <cstdio>
#include <string>
#include <vector>
@@ -26,8 +25,8 @@ IPCCommandResult ES::GetStoredContentsCount(const IOS::ES::TMDReader& tmd,
const u16 num_contents = static_cast<u16>(GetStoredContentsFromTMD(tmd).size());
Memory::Write_U32(num_contents, request.io_vectors[0].address);

INFO_LOG(IOS_ES, "GetStoredContentsCount (0x%x): %u content(s) for %016" PRIx64, request.request,
num_contents, tmd.GetTitleId());
INFO_LOG_FMT(IOS_ES, "GetStoredContentsCount ({:#x}): {} content(s) for {:016x}",
request.request, num_contents, tmd.GetTitleId());
return GetDefaultReply(IPC_SUCCESS);
}

@@ -129,15 +128,15 @@ IPCCommandResult ES::GetTitles(const std::vector<u64>& titles, const IOCtlVReque
for (size_t i = 0; i < std::min(max_count, titles.size()); i++)
{
Memory::Write_U64(titles[i], request.io_vectors[0].address + static_cast<u32>(i) * sizeof(u64));
INFO_LOG(IOS_ES, " title %016" PRIx64, titles[i]);
INFO_LOG_FMT(IOS_ES, " title {:016x}", titles[i]);
}
return GetDefaultReply(IPC_SUCCESS);
}

IPCCommandResult ES::GetTitleCount(const IOCtlVRequest& request)
{
const std::vector<u64> titles = GetInstalledTitles();
INFO_LOG(IOS_ES, "GetTitleCount: %zu titles", titles.size());
INFO_LOG_FMT(IOS_ES, "GetTitleCount: {} titles", titles.size());
return GetTitleCount(titles, request);
}

@@ -159,7 +158,7 @@ IPCCommandResult ES::GetStoredTMDSize(const IOCtlVRequest& request)
const u32 tmd_size = static_cast<u32>(tmd.GetBytes().size());
Memory::Write_U32(tmd_size, request.io_vectors[0].address);

INFO_LOG(IOS_ES, "GetStoredTMDSize: %u bytes for %016" PRIx64, tmd_size, title_id);
INFO_LOG_FMT(IOS_ES, "GetStoredTMDSize: {} bytes for {:016x}", tmd_size, title_id);

return GetDefaultReply(IPC_SUCCESS);
}
@@ -183,14 +182,14 @@ IPCCommandResult ES::GetStoredTMD(const IOCtlVRequest& request)

Memory::CopyToEmu(request.io_vectors[0].address, raw_tmd.data(), raw_tmd.size());

INFO_LOG(IOS_ES, "GetStoredTMD: title %016" PRIx64 " (buffer size: %u)", title_id, MaxCount);
INFO_LOG_FMT(IOS_ES, "GetStoredTMD: title {:016x} (buffer size: {})", title_id, MaxCount);
return GetDefaultReply(IPC_SUCCESS);
}

IPCCommandResult ES::GetOwnedTitleCount(const IOCtlVRequest& request)
{
const std::vector<u64> titles = GetTitlesWithTickets();
INFO_LOG(IOS_ES, "GetOwnedTitleCount: %zu titles", titles.size());
INFO_LOG_FMT(IOS_ES, "GetOwnedTitleCount: {} titles", titles.size());
return GetTitleCount(titles, request);
}

@@ -204,7 +203,7 @@ IPCCommandResult ES::GetBoot2Version(const IOCtlVRequest& request)
if (!request.HasNumberOfValidVectors(0, 1))
return GetDefaultReply(ES_EINVAL);

INFO_LOG(IOS_ES, "IOCTL_ES_GETBOOT2VERSION");
INFO_LOG_FMT(IOS_ES, "IOCTL_ES_GETBOOT2VERSION");

// as of 26/02/2012, this was latest bootmii version
Memory::Write_U32(4, request.io_vectors[0].address);
@@ -219,7 +218,7 @@ IPCCommandResult ES::GetSharedContentsCount(const IOCtlVRequest& request) const
const u32 count = GetSharedContentsCount();
Memory::Write_U32(count, request.io_vectors[0].address);

INFO_LOG(IOS_ES, "GetSharedContentsCount: %u contents", count);
INFO_LOG_FMT(IOS_ES, "GetSharedContentsCount: {} contents", count);
return GetDefaultReply(IPC_SUCCESS);
}

@@ -236,7 +235,7 @@ IPCCommandResult ES::GetSharedContents(const IOCtlVRequest& request) const
const u32 count = std::min(static_cast<u32>(hashes.size()), max_count);
Memory::CopyToEmu(request.io_vectors[0].address, hashes.data(), 20 * count);

INFO_LOG(IOS_ES, "GetSharedContents: %u contents (%u requested)", count, max_count);
INFO_LOG_FMT(IOS_ES, "GetSharedContents: {} contents ({} requested)", count, max_count);
return GetDefaultReply(IPC_SUCCESS);
}
} // namespace IOS::HLE::Device
@@ -63,14 +63,15 @@ ReturnCode ES::ImportTicket(const std::vector<u8>& ticket_bytes, const std::vect
{
if (device_id != ticket_device_id)
{
WARN_LOG(IOS_ES, "Device ID mismatch: ticket %08x, device %08x", ticket_device_id, device_id);
WARN_LOG_FMT(IOS_ES, "Device ID mismatch: ticket {:08x}, device {:08x}", ticket_device_id,
device_id);
return ES_DEVICE_ID_MISMATCH;
}
const ReturnCode ret = ticket.Unpersonalise(m_ios.GetIOSC());
if (ret < 0)
{
ERROR_LOG(IOS_ES, "ImportTicket: Failed to unpersonalise ticket for %016" PRIx64 " (%d)",
ticket.GetTitleId(), ret);
ERROR_LOG_FMT(IOS_ES, "ImportTicket: Failed to unpersonalise ticket for {:016x} ({})",
ticket.GetTitleId(), ret);
return ret;
}
}
@@ -87,7 +88,7 @@ ReturnCode ES::ImportTicket(const std::vector<u8>& ticket_bytes, const std::vect
if (write_ret != IPC_SUCCESS)
return write_ret;

INFO_LOG(IOS_ES, "ImportTicket: Imported ticket for title %016" PRIx64, ticket.GetTitleId());
INFO_LOG_FMT(IOS_ES, "ImportTicket: Imported ticket for title {:016x}", ticket.GetTitleId());
return IPC_SUCCESS;
}

@@ -137,7 +138,7 @@ static void ResetTitleImportContext(ES::Context* context, IOSC& iosc)

ReturnCode ES::ImportTmd(Context& context, const std::vector<u8>& tmd_bytes)
{
INFO_LOG(IOS_ES, "ImportTmd");
INFO_LOG_FMT(IOS_ES, "ImportTmd");

// Ioctlv 0x2b writes the TMD to /tmp/title.tmd (for imports) and doesn't seem to write it
// to either /import or /title. So here we simply have to set the import TMD.
@@ -155,25 +156,25 @@ ReturnCode ES::ImportTmd(Context& context, const std::vector<u8>& tmd_bytes)
context.title_import_export.tmd, cert_store);
if (ret != IPC_SUCCESS)
{
ERROR_LOG(IOS_ES, "ImportTmd: VerifyContainer failed with error %d", ret);
ERROR_LOG_FMT(IOS_ES, "ImportTmd: VerifyContainer failed with error {}", ret);
return ret;
}

if (!InitImport(context.title_import_export.tmd))
{
ERROR_LOG(IOS_ES, "ImportTmd: Failed to initialise title import");
ERROR_LOG_FMT(IOS_ES, "ImportTmd: Failed to initialise title import");
return ES_EIO;
}

ret =
InitBackupKey(m_title_context.tmd, m_ios.GetIOSC(), &context.title_import_export.key_handle);
if (ret != IPC_SUCCESS)
{
ERROR_LOG(IOS_ES, "ImportTmd: InitBackupKey failed with error %d", ret);
ERROR_LOG_FMT(IOS_ES, "ImportTmd: InitBackupKey failed with error {}", ret);
return ret;
}

INFO_LOG(IOS_ES, "ImportTmd: All checks passed, marking context as valid");
INFO_LOG_FMT(IOS_ES, "ImportTmd: All checks passed, marking context as valid");
context.title_import_export.valid = true;
return IPC_SUCCESS;
}
@@ -211,12 +212,12 @@ static ReturnCode InitTitleImportKey(const std::vector<u8>& ticket_bytes, IOSC&
ReturnCode ES::ImportTitleInit(Context& context, const std::vector<u8>& tmd_bytes,
const std::vector<u8>& cert_chain, VerifySignature verify_signature)
{
INFO_LOG(IOS_ES, "ImportTitleInit");
INFO_LOG_FMT(IOS_ES, "ImportTitleInit");
ResetTitleImportContext(&context, m_ios.GetIOSC());
context.title_import_export.tmd.SetBytes(tmd_bytes);
if (!context.title_import_export.tmd.IsValid())
{
ERROR_LOG(IOS_ES, "Invalid TMD while adding title (size = %zd)", tmd_bytes.size());
ERROR_LOG_FMT(IOS_ES, "Invalid TMD while adding title (size = {})", tmd_bytes.size());
return ES_EINVAL;
}

@@ -281,25 +282,23 @@ ReturnCode ES::ImportContentBegin(Context& context, u64 title_id, u32 content_id
{
if (context.title_import_export.content.valid)
{
ERROR_LOG(IOS_ES, "Trying to add content when we haven't finished adding "
"another content. Unsupported.");
ERROR_LOG_FMT(IOS_ES, "Trying to add content when we haven't finished adding "
"another content. Unsupported.");
return ES_EINVAL;
}
context.title_import_export.content = {};
context.title_import_export.content.id = content_id;

INFO_LOG(IOS_ES, "ImportContentBegin: title %016" PRIx64 ", content ID %08x", title_id,
context.title_import_export.content.id);
INFO_LOG_FMT(IOS_ES, "ImportContentBegin: title {:016x}, content ID {:08x}", title_id,
context.title_import_export.content.id);

if (!context.title_import_export.valid)
return ES_EINVAL;

if (title_id != context.title_import_export.tmd.GetTitleId())
{
ERROR_LOG(IOS_ES,
"ImportContentBegin: title id %016" PRIx64 " != "
"TMD title id %016" PRIx64 ", ignoring",
title_id, context.title_import_export.tmd.GetTitleId());
ERROR_LOG_FMT(IOS_ES, "ImportContentBegin: title id {:016x} != TMD title id {:016x}, ignoring",
title_id, context.title_import_export.tmd.GetTitleId());
return ES_EINVAL;
}

@@ -334,7 +333,7 @@ IPCCommandResult ES::ImportContentBegin(Context& context, const IOCtlVRequest& r

ReturnCode ES::ImportContentData(Context& context, u32 content_fd, const u8* data, u32 data_size)
{
INFO_LOG(IOS_ES, "ImportContentData: content fd %08x, size %d", content_fd, data_size);
INFO_LOG_FMT(IOS_ES, "ImportContentData: content fd {:08x}, size {}", content_fd, data_size);
context.title_import_export.content.buffer.insert(
context.title_import_export.content.buffer.end(), data, data + data_size);
return IPC_SUCCESS;
@@ -365,7 +364,7 @@ static std::string GetImportContentPath(u64 title_id, u32 content_id)

ReturnCode ES::ImportContentEnd(Context& context, u32 content_fd)
{
INFO_LOG(IOS_ES, "ImportContentEnd: content fd %08x", content_fd);
INFO_LOG_FMT(IOS_ES, "ImportContentEnd: content fd {:08x}", content_fd);

if (!context.title_import_export.valid || !context.title_import_export.content.valid)
return ES_EINVAL;
@@ -383,7 +382,8 @@ ReturnCode ES::ImportContentEnd(Context& context, u32 content_fd)
&content_info);
if (!CheckIfContentHashMatches(decrypted_data, content_info))
{
ERROR_LOG(IOS_ES, "ImportContentEnd: Hash for content %08x doesn't match", content_info.id);
ERROR_LOG_FMT(IOS_ES, "ImportContentEnd: Hash for content {:08x} doesn't match",
content_info.id);
return ES_HASH_MISMATCH;
}

@@ -408,7 +408,7 @@ ReturnCode ES::ImportContentEnd(Context& context, u32 content_fd)
const auto file = fs->CreateAndOpenFile(PID_KERNEL, PID_KERNEL, temp_path, content_modes);
if (!file || !file->Write(decrypted_data.data(), content_info.size))
{
ERROR_LOG(IOS_ES, "ImportContentEnd: Failed to write to %s", temp_path.c_str());
ERROR_LOG_FMT(IOS_ES, "ImportContentEnd: Failed to write to {}", temp_path);
return ES_EIO;
}
}
@@ -417,7 +417,7 @@ ReturnCode ES::ImportContentEnd(Context& context, u32 content_fd)
if (rename_result != FS::ResultCode::Success)
{
fs->Delete(PID_KERNEL, PID_KERNEL, temp_path);
ERROR_LOG(IOS_ES, "ImportContentEnd: Failed to move content to %s", content_path.c_str());
ERROR_LOG_FMT(IOS_ES, "ImportContentEnd: Failed to move content to {}", content_path);
return FS::ConvertResult(rename_result);
}

@@ -457,7 +457,8 @@ ReturnCode ES::ImportTitleDone(Context& context)
{
if (!context.title_import_export.valid || context.title_import_export.content.valid)
{
ERROR_LOG(IOS_ES, "ImportTitleDone: No title import, or a content import is still in progress");
ERROR_LOG_FMT(IOS_ES,
"ImportTitleDone: No title import, or a content import is still in progress");
return ES_EINVAL;
}

@@ -466,23 +467,23 @@ ReturnCode ES::ImportTitleDone(Context& context)
if (title_id - 0x100000001LL <= 0x100 &&
!HasAllRequiredContents(m_ios, context.title_import_export.tmd))
{
ERROR_LOG(IOS_ES, "ImportTitleDone: Some required contents are missing");
ERROR_LOG_FMT(IOS_ES, "ImportTitleDone: Some required contents are missing");
return ES_EINVAL;
}

if (!WriteImportTMD(context.title_import_export.tmd))
{
ERROR_LOG(IOS_ES, "ImportTitleDone: Failed to write import TMD");
ERROR_LOG_FMT(IOS_ES, "ImportTitleDone: Failed to write import TMD");
return ES_EIO;
}

if (!FinishImport(context.title_import_export.tmd))
{
ERROR_LOG(IOS_ES, "ImportTitleDone: Failed to finalise title import");
ERROR_LOG_FMT(IOS_ES, "ImportTitleDone: Failed to finalise title import");
return ES_EIO;
}

INFO_LOG(IOS_ES, "ImportTitleDone: title %016" PRIx64, title_id);
INFO_LOG_FMT(IOS_ES, "ImportTitleDone: title {:016x}", title_id);
ResetTitleImportContext(&context, m_ios.GetIOSC());
return IPC_SUCCESS;
}
@@ -506,7 +507,7 @@ ReturnCode ES::ImportTitleCancel(Context& context)
{
const u64 title_id = context.title_import_export.tmd.GetTitleId();
FinishStaleImport(title_id);
INFO_LOG(IOS_ES, "ImportTitleCancel: title %016" PRIx64, title_id);
INFO_LOG_FMT(IOS_ES, "ImportTitleCancel: title {:016x}", title_id);
}

ResetTitleImportContext(&context, m_ios.GetIOSC());
@@ -696,7 +697,7 @@ ReturnCode ES::ExportContentBegin(Context& context, u64 title_id, u32 content_id
if (!context.title_import_export.valid ||
context.title_import_export.tmd.GetTitleId() != title_id)
{
ERROR_LOG(IOS_ES, "Tried to use ExportContentBegin with an invalid title export context.");
ERROR_LOG_FMT(IOS_ES, "Tried to use ExportContentBegin with an invalid title export context.");
return ES_EINVAL;
}

@@ -5,7 +5,6 @@
#include "Core/IOS/ES/ES.h"

#include <algorithm>
#include <cinttypes>
#include <cstddef>
#include <cstdio>
#include <vector>
@@ -43,24 +42,24 @@ IPCCommandResult ES::GetTicketViewCount(const IOCtlVRequest& request)
if (!request.HasNumberOfValidVectors(1, 1))
return GetDefaultReply(ES_EINVAL);

u64 TitleID = Memory::Read_U64(request.in_vectors[0].address);
const u64 TitleID = Memory::Read_U64(request.in_vectors[0].address);

const IOS::ES::TicketReader ticket = FindSignedTicket(TitleID);
u32 view_count = ticket.IsValid() ? static_cast<u32>(ticket.GetNumberOfTickets()) : 0;

if (!IOS::HLE::IsEmulated(TitleID))
{
view_count = 0;
ERROR_LOG(IOS_ES, "GetViewCount: Dolphin doesn't emulate IOS title %016" PRIx64, TitleID);
ERROR_LOG_FMT(IOS_ES, "GetViewCount: Dolphin doesn't emulate IOS title {:016x}", TitleID);
}
else if (ShouldReturnFakeViewsForIOSes(TitleID, m_title_context))
{
view_count = 1;
WARN_LOG(IOS_ES, "GetViewCount: Faking IOS title %016" PRIx64 " being present", TitleID);
WARN_LOG_FMT(IOS_ES, "GetViewCount: Faking IOS title {:016x} being present", TitleID);
}

INFO_LOG(IOS_ES, "IOCTL_ES_GETVIEWCNT for titleID: %016" PRIx64 " (View Count = %u)", TitleID,
view_count);
INFO_LOG_FMT(IOS_ES, "IOCTL_ES_GETVIEWCNT for titleID: {:016x} (View Count = {})", TitleID,
view_count);

Memory::Write_U32(view_count, request.io_vectors[0].address);
return GetDefaultReply(IPC_SUCCESS);
@@ -71,14 +70,14 @@ IPCCommandResult ES::GetTicketViews(const IOCtlVRequest& request)
if (!request.HasNumberOfValidVectors(2, 1))
return GetDefaultReply(ES_EINVAL);

u64 TitleID = Memory::Read_U64(request.in_vectors[0].address);
u32 maxViews = Memory::Read_U32(request.in_vectors[1].address);
const u64 TitleID = Memory::Read_U64(request.in_vectors[0].address);
const u32 maxViews = Memory::Read_U32(request.in_vectors[1].address);

const IOS::ES::TicketReader ticket = FindSignedTicket(TitleID);

if (!IOS::HLE::IsEmulated(TitleID))
{
ERROR_LOG(IOS_ES, "GetViews: Dolphin doesn't emulate IOS title %016" PRIx64, TitleID);
ERROR_LOG_FMT(IOS_ES, "GetViews: Dolphin doesn't emulate IOS title {:016x}", TitleID);
}
else if (ticket.IsValid())
{
@@ -93,11 +92,10 @@ IPCCommandResult ES::GetTicketViews(const IOCtlVRequest& request)
else if (ShouldReturnFakeViewsForIOSes(TitleID, m_title_context))
{
Memory::Memset(request.io_vectors[0].address, 0, sizeof(IOS::ES::TicketView));
WARN_LOG(IOS_ES, "GetViews: Faking IOS title %016" PRIx64 " being present", TitleID);
WARN_LOG_FMT(IOS_ES, "GetViews: Faking IOS title {:016x} being present", TitleID);
}

INFO_LOG(IOS_ES, "IOCTL_ES_GETVIEWS for titleID: %016" PRIx64 " (MaxViews = %i)", TitleID,
maxViews);
INFO_LOG_FMT(IOS_ES, "IOCTL_ES_GETVIEWS for titleID: {:016x} (MaxViews = {})", TitleID, maxViews);

return GetDefaultReply(IPC_SUCCESS);
}
@@ -147,7 +145,7 @@ ReturnCode ES::GetTicketFromView(const u8* ticket_view, u8* ticket, u32* ticket_
// Currently, we have no support for v1 tickets at all (unlike IOS), so we fake it
// and return that there is no ticket.
// TODO: implement GetV1TicketFromView when we gain v1 ticket support.
ERROR_LOG(IOS_ES, "GetV1TicketFromView: Unimplemented -- returning -1028");
ERROR_LOG_FMT(IOS_ES, "GetV1TicketFromView: Unimplemented -- returning -1028");
return ES_NO_TICKET;
}
if (ticket != nullptr)
@@ -210,8 +208,7 @@ IPCCommandResult ES::GetTMDViewSize(const IOCtlVRequest& request)
if (!request.HasNumberOfValidVectors(1, 1))
return GetDefaultReply(ES_EINVAL);

u64 TitleID = Memory::Read_U64(request.in_vectors[0].address);

const u64 TitleID = Memory::Read_U64(request.in_vectors[0].address);
const IOS::ES::TMDReader tmd = FindInstalledTMD(TitleID);

if (!tmd.IsValid())
@@ -220,7 +217,7 @@ IPCCommandResult ES::GetTMDViewSize(const IOCtlVRequest& request)
const u32 view_size = static_cast<u32>(tmd.GetRawView().size());
Memory::Write_U32(view_size, request.io_vectors[0].address);

INFO_LOG(IOS_ES, "GetTMDViewSize: %u bytes for title %016" PRIx64, view_size, TitleID);
INFO_LOG_FMT(IOS_ES, "GetTMDViewSize: {} bytes for title {:016x}", view_size, TitleID);
return GetDefaultReply(IPC_SUCCESS);
}

@@ -246,7 +243,7 @@ IPCCommandResult ES::GetTMDViews(const IOCtlVRequest& request)

Memory::CopyToEmu(request.io_vectors[0].address, raw_view.data(), raw_view.size());

INFO_LOG(IOS_ES, "GetTMDView: %zu bytes for title %016" PRIx64, raw_view.size(), title_id);
INFO_LOG_FMT(IOS_ES, "GetTMDView: {} bytes for title {:016x}", raw_view.size(), title_id);
return GetDefaultReply(IPC_SUCCESS);
}

@@ -105,7 +105,7 @@ static bool SetupMemory(u64 ios_title_id, MemorySetupType setup_type)

if (target_imv == GetMemoryValues().end())
{
ERROR_LOG(IOS, "Unknown IOS version: %016" PRIx64, ios_title_id);
ERROR_LOG_FMT(IOS, "Unknown IOS version: {:016x}", ios_title_id);
return false;
}

@@ -249,10 +249,10 @@ Kernel::Kernel(u64 title_id) : m_title_id(title_id)

EmulationKernel::EmulationKernel(u64 title_id) : Kernel(title_id)
{
INFO_LOG(IOS, "Starting IOS %016" PRIx64, title_id);
INFO_LOG_FMT(IOS, "Starting IOS {:016x}", title_id);

if (!SetupMemory(title_id, MemorySetupType::IOSReload))
WARN_LOG(IOS, "No information about this IOS -- cannot set up memory values");
WARN_LOG_FMT(IOS, "No information about this IOS -- cannot set up memory values");

if (title_id == Titles::MIOS)
{
@@ -521,10 +521,10 @@ std::shared_ptr<Device::Device> EmulationKernel::GetDeviceByName(const std::stri
IPCCommandResult Kernel::OpenDevice(OpenRequest& request)
{
const s32 new_fd = GetFreeDeviceID();
INFO_LOG(IOS, "Opening %s (mode %d, fd %d)", request.path.c_str(), request.flags, new_fd);
INFO_LOG_FMT(IOS, "Opening {} (mode {}, fd {})", request.path, request.flags, new_fd);
if (new_fd < 0 || new_fd >= IPC_MAX_FDS)
{
ERROR_LOG(IOS, "Couldn't get a free fd, too many open files");
ERROR_LOG_FMT(IOS, "Couldn't get a free fd, too many open files");
return IPCCommandResult{IPC_EMAX, true, 5000 * SystemTimers::TIMER_RATIO};
}
request.fd = new_fd;
@@ -546,7 +546,7 @@ IPCCommandResult Kernel::OpenDevice(OpenRequest& request)

if (!device)
{
ERROR_LOG(IOS, "Unknown device: %s", request.path.c_str());
ERROR_LOG_FMT(IOS, "Unknown device: {}", request.path);
return {IPC_ENOENT, true, 3700 * SystemTimers::TIMER_RATIO};
}

@@ -575,7 +575,7 @@ IPCCommandResult Kernel::HandleIPCCommand(const Request& request)
return IPCCommandResult{IPC_EINVAL, true, 550 * SystemTimers::TIMER_RATIO};

IPCCommandResult ret;
u64 wall_time_before = Common::Timer::GetTimeUs();
const u64 wall_time_before = Common::Timer::GetTimeUs();

switch (request.command)
{
@@ -604,12 +604,12 @@ IPCCommandResult Kernel::HandleIPCCommand(const Request& request)
break;
}

u64 wall_time_after = Common::Timer::GetTimeUs();
const u64 wall_time_after = Common::Timer::GetTimeUs();
constexpr u64 BLOCKING_IPC_COMMAND_THRESHOLD_US = 2000;
if (wall_time_after - wall_time_before > BLOCKING_IPC_COMMAND_THRESHOLD_US)
{
WARN_LOG(IOS, "Previous request to device %s blocked emulation for %" PRIu64 " microseconds.",
device->GetDeviceName().c_str(), wall_time_after - wall_time_before);
WARN_LOG_FMT(IOS, "Previous request to device {} blocked emulation for {} microseconds.",
device->GetDeviceName(), wall_time_after - wall_time_before);
}

return ret;
@@ -690,15 +690,15 @@ void Kernel::UpdateIPC()
if (!m_reply_queue.empty())
{
GenerateReply(m_reply_queue.front());
DEBUG_LOG(IOS, "<<-- Reply to IPC Request @ 0x%08x", m_reply_queue.front());
DEBUG_LOG_FMT(IOS, "<<-- Reply to IPC Request @ {:#010x}", m_reply_queue.front());
m_reply_queue.pop_front();
return;
}

if (!m_ack_queue.empty())
{
GenerateAck(m_ack_queue.front());
WARN_LOG(IOS, "<<-- Double-ack to IPC Request @ 0x%08x", m_ack_queue.front());
WARN_LOG_FMT(IOS, "<<-- Double-ack to IPC Request @ {:#010x}", m_ack_queue.front());
m_ack_queue.pop_front();
return;
}